From: support Date: Mon, 20 Jun 2022 13:51:57 +0000 (+0000) Subject: Built motion from commit ff88c200.|2.6.11 X-Git-Url: http://repos.xcallymotion.com/base/%22https:/wiki.xcallymotion.com/display/XMV//%22?a=commitdiff_plain;h=ea1a8a7e360f7ed674f4718593fa8137833126cc;p=motion2.git Built motion from commit ff88c200.|2.6.11 --- diff --git a/apidoc/api_project.js b/apidoc/api_project.js index d6272ea..4e6d995 100644 --- a/apidoc/api_project.js +++ b/apidoc/api_project.js @@ -17,7 +17,7 @@ define({ "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2022-06-20T13:13:00.453Z", + "time": "2022-06-20T13:43:47.197Z", "url": "http://apidocjs.com", "version": "0.24.0" } diff --git a/apidoc/api_project.json b/apidoc/api_project.json index db30eb2..8d13af2 100644 --- a/apidoc/api_project.json +++ b/apidoc/api_project.json @@ -17,7 +17,7 @@ "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2022-06-20T13:13:00.453Z", + "time": "2022-06-20T13:43:47.197Z", "url": "http://apidocjs.com", "version": "0.24.0" } diff --git a/server/api/action/action.attributes.js b/server/api/action/action.attributes.js new file mode 100644 index 0000000..23677a6 --- /dev/null +++ b/server/api/action/action.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x383c=['Allowed\x20values:\x20contactManager,\x20integration,\x20motionbar,\x20jscripty,\x20urlForward,\x20browser,\x20bot,\x20script','contactManager[autoCreate(0=No,1=Yes)],\x20urlForward[URL],\x20script[type],\x20integration[AccountId],\x20motionbar[TemplateId,URL,WinAppPath],\x20browser[TemplateId,URL]','browser[location(0=NewTab,1=NewWindow,2=MotionTab)],\x20contactManager[autoCreateField]','urlForward[timeout],\x20browser[windowWidth],\x20contactManager[ignoreDialerContactId]','TEXT','urlForward[body]','VIRTUAL','getDataValue','STRING','contactManager','motionbar','urlForward','bot','script'];(function(_0x5dc919,_0x16326b){var _0x2447d7=function(_0x2181c8){while(--_0x2181c8){_0x5dc919['push'](_0x5dc919['shift']());}};_0x2447d7(++_0x16326b);}(_0x383c,0x164));var _0xc383=function(_0x29d915,_0x54a040){_0x29d915=_0x29d915-0x0;var _0x160f86=_0x383c[_0x29d915];return _0x160f86;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0xc383('0x0')],'get':function(_0x588d90){return this[_0xc383('0x1')]('action');}},'action':{'type':Sequelize[_0xc383('0x2')],'allowNull':![],'validate':{'isIn':{'args':[[_0xc383('0x3'),'integration',_0xc383('0x4'),'jscripty',_0xc383('0x5'),'browser',_0xc383('0x6'),_0xc383('0x7')]],'msg':'Allowed\x20values:\x20contactManager,\x20integration,\x20motionbar,\x20jscripty,\x20urlForward,\x20browser,\x20bot,\x20script'}},'comment':_0xc383('0x8')},'data1':{'type':Sequelize[_0xc383('0x2')](0x1000),'comment':'jscripty[ProjectId],\x20browser[type(0=Popup,1=CTI\x20URL)],\x20contactManager[ListId],\x20urlForward[type(GET,POST,PUT,DELETE)],\x20script[info],\x20integration[intName(desk,dynamics365,freshdesk,freshsales,salesforce,sugarcrm,vtiger,zendesk,zoho)],\x20motionbar[type(0=Popup,1=CTI\x20URL,2=WinApp)]'},'data2':{'type':Sequelize[_0xc383('0x2')](0x1000),'comment':_0xc383('0x9')},'data3':{'type':Sequelize[_0xc383('0x2')](0x1000),'comment':'contactManager[searchFields],\x20script[script],\x20integration[ConfigurationId],\x20motionbar[NULL,eventVariables(0=No,1=Yes),WinAppArguments],\x20browser[NULL,eventVariables(0=No,1=Yes)]'},'data4':{'type':Sequelize[_0xc383('0x2')](0x1000),'comments':_0xc383('0xa')},'data5':{'type':Sequelize[_0xc383('0x2')](0x1000),'comments':_0xc383('0xb')},'data6':{'type':Sequelize[_0xc383('0x2')],'comments':'urlForward[headers],\x20browser[wsindowHeight]'},'data7':{'type':Sequelize[_0xc383('0xc')],'comments':_0xc383('0xd')}}; \ No newline at end of file diff --git a/server/api/action/action.controller.js b/server/api/action/action.controller.js new file mode 100644 index 0000000..f7e122a --- /dev/null +++ b/server/api/action/action.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x25e6=['desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','save','update','destroy','error','stack','name','send','body','Action','params','then','catch','find','rimraf','zip-dir','moment','bluebird','mustache','sox','ejs','fs-extra','lodash','squel','jsforce'];(function(_0x19a87b,_0x26c651){var _0x4e41e6=function(_0x235345){while(--_0x235345){_0x19a87b['push'](_0x19a87b['shift']());}};_0x4e41e6(++_0x26c651);}(_0x25e6,0xdb));var _0x625e=function(_0x5581a3,_0x2fabd8){_0x5581a3=_0x5581a3-0x0;var _0x3c277b=_0x25e6[_0x5581a3];return _0x3c277b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x625e('0x0'));var zipdir=require(_0x625e('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x625e('0x2'));var BPromise=require(_0x625e('0x3'));var Mustache=require(_0x625e('0x4'));var util=require('util');var path=require('path');var sox=require(_0x625e('0x5'));var csv=require('to-csv');var ejs=require(_0x625e('0x6'));var fs=require('fs');var fs_extra=require(_0x625e('0x7'));var _=require(_0x625e('0x8'));var squel=require(_0x625e('0x9'));var crypto=require('crypto');var jsforce=require(_0x625e('0xa'));var deskjs=require(_0x625e('0xb'));var toCsv=require('to-csv');var querystring=require(_0x625e('0xc'));var Papa=require(_0x625e('0xd'));var Redis=require(_0x625e('0xe'));var authService=require(_0x625e('0xf'));var qs=require(_0x625e('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x625e('0x11'));var logger=require('../../config/logger')(_0x625e('0x12'));var utils=require(_0x625e('0x13'));var config=require(_0x625e('0x14'));var licenseUtil=require(_0x625e('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x49f895,_0x17bc27){_0x17bc27=_0x17bc27||0xcc;return function(_0x1fe4a6){if(_0x1fe4a6){return _0x49f895[_0x625e('0x16')](_0x17bc27);}return _0x49f895[_0x625e('0x17')](_0x17bc27)[_0x625e('0x18')]();};}function respondWithResult(_0x1e0410,_0xbabaf){_0xbabaf=_0xbabaf||0xc8;return function(_0x2c169a){if(_0x2c169a){return _0x1e0410[_0x625e('0x17')](_0xbabaf)[_0x625e('0x19')](_0x2c169a);}};}function respondWithFilteredResult(_0x4beb13,_0x2b6b13){return function(_0x3e8813){if(_0x3e8813){var _0x65b2a4=typeof _0x2b6b13['offset']==='undefined'&&typeof _0x2b6b13[_0x625e('0x1a')]===_0x625e('0x1b');var _0x41dc53=_0x3e8813[_0x625e('0x1c')];var _0x47260c=_0x65b2a4?0x0:_0x2b6b13[_0x625e('0x1d')];var _0x4b4bca=_0x65b2a4?_0x3e8813[_0x625e('0x1c')]:_0x2b6b13[_0x625e('0x1d')]+_0x2b6b13[_0x625e('0x1a')];var _0x5e1d7a;if(_0x4b4bca>=_0x41dc53){_0x4b4bca=_0x41dc53;_0x5e1d7a=0xc8;}else{_0x5e1d7a=0xce;}_0x4beb13['status'](_0x5e1d7a);return _0x4beb13[_0x625e('0x1e')](_0x625e('0x1f'),_0x47260c+'-'+_0x4b4bca+'/'+_0x41dc53)['json'](_0x3e8813);}return null;};}function patchUpdates(_0x3efd2c){return function(_0x2842c4){try{jsonpatch[_0x625e('0x20')](_0x2842c4,_0x3efd2c,!![]);}catch(_0x30e548){return BPromise['reject'](_0x30e548);}return _0x2842c4[_0x625e('0x21')]();};}function saveUpdates(_0x1e7d4d,_0x5043f9){return function(_0x55693a){if(_0x55693a){return _0x55693a[_0x625e('0x22')](_0x1e7d4d)['then'](function(_0x3d3ff0){return _0x3d3ff0;});}return null;};}function removeEntity(_0x2e4b51,_0x2d0e81){return function(_0x2fb4f2){if(_0x2fb4f2){return _0x2fb4f2[_0x625e('0x23')]()['then'](function(){_0x2e4b51[_0x625e('0x17')](0xcc)[_0x625e('0x18')]();});}};}function handleEntityNotFound(_0x491a03,_0x2dc1c1){return function(_0x138505){if(!_0x138505){_0x491a03[_0x625e('0x16')](0x194);}return _0x138505;};}function handleError(_0x4e22b6,_0x45a451){_0x45a451=_0x45a451||0x1f4;return function(_0x531246){logger[_0x625e('0x24')](_0x531246[_0x625e('0x25')]);if(_0x531246['name']){delete _0x531246[_0x625e('0x26')];}_0x4e22b6[_0x625e('0x17')](_0x45a451)[_0x625e('0x27')](_0x531246);};}exports['update']=function(_0x5a94b2,_0x3bdb2d){if(_0x5a94b2['body']['id']){delete _0x5a94b2[_0x625e('0x28')]['id'];}return db[_0x625e('0x29')]['find']({'where':{'id':_0x5a94b2[_0x625e('0x2a')]['id']}})[_0x625e('0x2b')](handleEntityNotFound(_0x3bdb2d,null))[_0x625e('0x2b')](saveUpdates(_0x5a94b2['body'],null))[_0x625e('0x2b')](respondWithResult(_0x3bdb2d,null))[_0x625e('0x2c')](handleError(_0x3bdb2d,null));};exports['destroy']=function(_0x38a391,_0x5d86c3){return db['Action'][_0x625e('0x2d')]({'where':{'id':_0x38a391[_0x625e('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5d86c3,null))['then'](removeEntity(_0x5d86c3,null))[_0x625e('0x2c')](handleError(_0x5d86c3,null));}; \ No newline at end of file diff --git a/server/api/action/action.model.js b/server/api/action/action.model.js new file mode 100644 index 0000000..ed47394 --- /dev/null +++ b/server/api/action/action.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7bad=['api','bluebird','request-promise','rimraf','./action.attributes','define','Action','lodash','util','../../config/logger'];(function(_0x378720,_0xa711f1){var _0x47920a=function(_0xc5056){while(--_0xc5056){_0x378720['push'](_0x378720['shift']());}};_0x47920a(++_0xa711f1);}(_0x7bad,0xb1));var _0xd7ba=function(_0x5b142f,_0x10815a){_0x5b142f=_0x5b142f-0x0;var _0x327bbd=_0x7bad[_0x5b142f];return _0x327bbd;};'use strict';var _=require(_0xd7ba('0x0'));var util=require(_0xd7ba('0x1'));var logger=require(_0xd7ba('0x2'))(_0xd7ba('0x3'));var moment=require('moment');var BPromise=require(_0xd7ba('0x4'));var rp=require(_0xd7ba('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xd7ba('0x6'));var config=require('../../config/environment');var attributes=require(_0xd7ba('0x7'));module['exports']=function(_0xacb246,_0x1d8288){return _0xacb246[_0xd7ba('0x8')](_0xd7ba('0x9'),attributes,{'tableName':'tools_actions','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/action/action.rpc.js b/server/api/action/action.rpc.js new file mode 100644 index 0000000..58ad728 --- /dev/null +++ b/server/api/action/action.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5fab=['../../config/environment','jayson/promise','client','request','then','request\x20sent','debug','Action,\x20%s,\x20%s,\x20%s','stringify','error','code','message','Action,\x20%s,\x20%s','result','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x52cde3,_0x28d007){var _0x106ff1=function(_0x54613e){while(--_0x54613e){_0x52cde3['push'](_0x52cde3['shift']());}};_0x106ff1(++_0x28d007);}(_0x5fab,0x177));var _0xb5fa=function(_0xf0f7ba,_0x48be70){_0xf0f7ba=_0xf0f7ba-0x0;var _0x44382c=_0x5fab[_0xf0f7ba];return _0x44382c;};'use strict';var _=require(_0xb5fa('0x0'));var util=require(_0xb5fa('0x1'));var moment=require('moment');var BPromise=require(_0xb5fa('0x2'));var rs=require(_0xb5fa('0x3'));var fs=require('fs');var Redis=require(_0xb5fa('0x4'));var db=require(_0xb5fa('0x5'))['db'];var utils=require(_0xb5fa('0x6'));var logger=require(_0xb5fa('0x7'))(_0xb5fa('0x8'));var config=require(_0xb5fa('0x9'));var jayson=require(_0xb5fa('0xa'));var client=jayson[_0xb5fa('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5d70f6,_0x2e3804,_0x1aec3e){return new BPromise(function(_0x9c7bce,_0x56d018){return client[_0xb5fa('0xc')](_0x5d70f6,_0x1aec3e)[_0xb5fa('0xd')](function(_0x2cf4a5){logger['info']('Action,\x20%s,\x20%s',_0x2e3804,_0xb5fa('0xe'));logger[_0xb5fa('0xf')](_0xb5fa('0x10'),_0x2e3804,_0xb5fa('0xe'),JSON[_0xb5fa('0x11')](_0x2cf4a5));if(_0x2cf4a5[_0xb5fa('0x12')]){if(_0x2cf4a5[_0xb5fa('0x12')][_0xb5fa('0x13')]===0x1f4){logger[_0xb5fa('0x12')]('Action,\x20%s,\x20%s',_0x2e3804,_0x2cf4a5[_0xb5fa('0x12')][_0xb5fa('0x14')]);return _0x56d018(_0x2cf4a5['error'][_0xb5fa('0x14')]);}logger['error'](_0xb5fa('0x15'),_0x2e3804,_0x2cf4a5[_0xb5fa('0x12')][_0xb5fa('0x14')]);return _0x9c7bce(_0x2cf4a5[_0xb5fa('0x12')][_0xb5fa('0x14')]);}else{logger['info']('Action,\x20%s,\x20%s',_0x2e3804,_0xb5fa('0xe'));_0x9c7bce(_0x2cf4a5[_0xb5fa('0x16')][_0xb5fa('0x14')]);}})[_0xb5fa('0x17')](function(_0x56fe10){logger['error'](_0xb5fa('0x15'),_0x2e3804,_0x56fe10);_0x56d018(_0x56fe10);});});} \ No newline at end of file diff --git a/server/api/action/index.js b/server/api/action/index.js new file mode 100644 index 0000000..e73def9 --- /dev/null +++ b/server/api/action/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf464=['update','delete','destroy','exports','util','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','put','/:id','isAuthenticated'];(function(_0x1d1a0e,_0x38aa63){var _0x42ad05=function(_0x5a506d){while(--_0x5a506d){_0x1d1a0e['push'](_0x1d1a0e['shift']());}};_0x42ad05(++_0x38aa63);}(_0xf464,0x146));var _0x4f46=function(_0x2eb5b4,_0x452438){_0x2eb5b4=_0x2eb5b4-0x0;var _0xcd022e=_0xf464[_0x2eb5b4];return _0xcd022e;};'use strict';var multer=require('multer');var util=require(_0x4f46('0x0'));var path=require('path');var timeout=require('connect-timeout');var express=require(_0x4f46('0x1'));var router=express[_0x4f46('0x2')]();var fs_extra=require(_0x4f46('0x3'));var auth=require(_0x4f46('0x4'));var interaction=require(_0x4f46('0x5'));var config=require(_0x4f46('0x6'));var controller=require('./action.controller');router[_0x4f46('0x7')](_0x4f46('0x8'),auth[_0x4f46('0x9')](),controller[_0x4f46('0xa')]);router[_0x4f46('0xb')](_0x4f46('0x8'),auth[_0x4f46('0x9')](),controller[_0x4f46('0xc')]);module[_0x4f46('0xd')]=router; \ No newline at end of file diff --git a/server/api/analyticCustomReport/analyticCustomReport.attributes.js b/server/api/analyticCustomReport/analyticCustomReport.attributes.js new file mode 100644 index 0000000..73d3693 --- /dev/null +++ b/server/api/analyticCustomReport/analyticCustomReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5fab=['exports','STRING','TEXT','sequelize'];(function(_0x6c0123,_0x4c8d3b){var _0x5a87d2=function(_0x1ff614){while(--_0x1ff614){_0x6c0123['push'](_0x6c0123['shift']());}};_0x5a87d2(++_0x4c8d3b);}(_0x5fab,0x177));var _0xb5fa=function(_0x493030,_0x29ec7e){_0x493030=_0x493030-0x0;var _0x56f5e4=_0x5fab[_0x493030];return _0x56f5e4;};'use strict';var Sequelize=require(_0xb5fa('0x0'));module[_0xb5fa('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![]},'description':{'type':Sequelize[_0xb5fa('0x2')]},'parent':{'type':Sequelize[_0xb5fa('0x2')]},'table':{'type':Sequelize[_0xb5fa('0x2')]},'conditions':{'type':Sequelize[_0xb5fa('0x3')]},'joins':{'type':Sequelize[_0xb5fa('0x3')]}}; \ No newline at end of file diff --git a/server/api/analyticCustomReport/analyticCustomReport.controller.js b/server/api/analyticCustomReport/analyticCustomReport.controller.js new file mode 100644 index 0000000..88a54b3 --- /dev/null +++ b/server/api/analyticCustomReport/analyticCustomReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x053c=['Reports','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','join','right_join','cross_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','DATE(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','findAll','keyBy','select','table','MetricId','metric','function','replace','format','groupBy','orderBy','alias','joins','parse','foreignTable','%s.%s\x20=\x20%s.%s','parentKey','conditions','clone','debug','Limited\x20Query:','toString','sequelize','SELECT','left_join','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','value','getFields','from','DESC','foreignKey','output','web','%s-%s.%s','generate','csv','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','.createdAt\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','info','child_process','../../components/export/','savename','countTable','COUNT(*)','QueryTypes','runReport','HOUR(%s)','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','to-csv','fs-extra','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','end','json','undefined','offset','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','CustomReports','UserProfileResource','stack','name','index','AnalyticCustomReport','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL','options','includeAll','include','rows','catch','show','params','find','create','get','role','user'];(function(_0x8012b2,_0x370e3b){var _0x99bfa9=function(_0x4d1e29){while(--_0x4d1e29){_0x8012b2['push'](_0x8012b2['shift']());}};_0x99bfa9(++_0x370e3b);}(_0x053c,0xfc));var _0xc053=function(_0x502c7d,_0x2f1285){_0x502c7d=_0x502c7d-0x0;var _0x30b7ed=_0x053c[_0x502c7d];return _0x30b7ed;};'use strict';var emlformat=require(_0xc053('0x0'));var rimraf=require(_0xc053('0x1'));var zipdir=require(_0xc053('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xc053('0x3'));var BPromise=require(_0xc053('0x4'));var Mustache=require(_0xc053('0x5'));var util=require(_0xc053('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0xc053('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xc053('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xc053('0x9'));var jsforce=require(_0xc053('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xc053('0x7'));var querystring=require('querystring');var Papa=require(_0xc053('0xb'));var Redis=require(_0xc053('0xc'));var authService=require('../../components/auth/service');var qs=require(_0xc053('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc053('0xe'));var logger=require(_0xc053('0xf'))(_0xc053('0x10'));var utils=require(_0xc053('0x11'));var config=require(_0xc053('0x12'));var licenseUtil=require(_0xc053('0x13'));var db=require(_0xc053('0x14'))['db'];var dbH=require(_0xc053('0x14'))[_0xc053('0x15')];function respondWithStatusCode(_0x57f00e,_0x1a5749){_0x1a5749=_0x1a5749||0xcc;return function(_0x32032e){if(_0x32032e){return _0x57f00e[_0xc053('0x16')](_0x1a5749);}return _0x57f00e[_0xc053('0x17')](_0x1a5749)[_0xc053('0x18')]();};}function respondWithResult(_0x7ea9f3,_0x22d111){_0x22d111=_0x22d111||0xc8;return function(_0x2b1854){if(_0x2b1854){return _0x7ea9f3['status'](_0x22d111)[_0xc053('0x19')](_0x2b1854);}};}function respondWithFilteredResult(_0x264c0e,_0x8a4b1b){return function(_0xb50f73){if(_0xb50f73){var _0x116d00=typeof _0x8a4b1b['offset']===_0xc053('0x1a')&&typeof _0x8a4b1b['limit']===_0xc053('0x1a');var _0x4f8ce9=_0xb50f73['count'];var _0x55a034=_0x116d00?0x0:_0x8a4b1b[_0xc053('0x1b')];var _0x521734=_0x116d00?_0xb50f73[_0xc053('0x1c')]:_0x8a4b1b[_0xc053('0x1b')]+_0x8a4b1b[_0xc053('0x1d')];var _0x23287e;if(_0x521734>=_0x4f8ce9){_0x521734=_0x4f8ce9;_0x23287e=0xc8;}else{_0x23287e=0xce;}_0x264c0e[_0xc053('0x17')](_0x23287e);return _0x264c0e[_0xc053('0x1e')](_0xc053('0x1f'),_0x55a034+'-'+_0x521734+'/'+_0x4f8ce9)[_0xc053('0x19')](_0xb50f73);}return null;};}function patchUpdates(_0x4af9dd){return function(_0x5ee846){try{jsonpatch[_0xc053('0x20')](_0x5ee846,_0x4af9dd,!![]);}catch(_0x4d9a88){return BPromise[_0xc053('0x21')](_0x4d9a88);}return _0x5ee846[_0xc053('0x22')]();};}function saveUpdates(_0x2d58f2,_0x9a6f91){return function(_0x48459d){if(_0x48459d){return _0x48459d[_0xc053('0x23')](_0x2d58f2)[_0xc053('0x24')](function(_0x27e75d){return _0x27e75d;});}return null;};}function removeEntity(_0x4918e2,_0x46bf14){return function(_0x2e93d7){if(_0x2e93d7){return _0x2e93d7[_0xc053('0x25')]()['then'](function(){var _0x29d74b=_0x2e93d7['get']({'plain':!![]});var _0x31c535=_0xc053('0x26');return db[_0xc053('0x27')][_0xc053('0x25')]({'where':{'type':_0x31c535,'resourceId':_0x29d74b['id']}})[_0xc053('0x24')](function(){return _0x2e93d7;});})['then'](function(){_0x4918e2[_0xc053('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x211fc7,_0x5a56d2){return function(_0x55b3e6){if(!_0x55b3e6){_0x211fc7[_0xc053('0x16')](0x194);}return _0x55b3e6;};}function handleError(_0x4b6b47,_0x1f4020){_0x1f4020=_0x1f4020||0x1f4;return function(_0x259092){logger['error'](_0x259092[_0xc053('0x28')]);if(_0x259092[_0xc053('0x29')]){delete _0x259092[_0xc053('0x29')];}_0x4b6b47['status'](_0x1f4020)['send'](_0x259092);};}exports[_0xc053('0x2a')]=function(_0x5e4f7e,_0x51cdb3){var _0x11d526={},_0x7c7a9b={},_0x1a761f={'count':0x0,'rows':[]};var _0xf4e60=_['map'](db[_0xc053('0x2b')][_0xc053('0x2c')],function(_0x46414a){return{'name':_0x46414a[_0xc053('0x2d')],'type':_0x46414a[_0xc053('0x2e')][_0xc053('0x2f')]};});_0x7c7a9b['model']=_['map'](_0xf4e60,_0xc053('0x29'));_0x7c7a9b['query']=_[_0xc053('0x30')](_0x5e4f7e[_0xc053('0x31')]);_0x7c7a9b[_0xc053('0x32')]=_[_0xc053('0x33')](_0x7c7a9b[_0xc053('0x34')],_0x7c7a9b[_0xc053('0x31')]);_0x11d526[_0xc053('0x35')]=_[_0xc053('0x33')](_0x7c7a9b[_0xc053('0x34')],qs[_0xc053('0x36')](_0x5e4f7e[_0xc053('0x31')]['fields']));_0x11d526[_0xc053('0x35')]=_0x11d526[_0xc053('0x35')][_0xc053('0x37')]?_0x11d526[_0xc053('0x35')]:_0x7c7a9b[_0xc053('0x34')];if(!_0x5e4f7e['query'][_0xc053('0x38')](_0xc053('0x39'))){_0x11d526[_0xc053('0x1d')]=qs[_0xc053('0x1d')](_0x5e4f7e[_0xc053('0x31')][_0xc053('0x1d')]);_0x11d526[_0xc053('0x1b')]=qs[_0xc053('0x1b')](_0x5e4f7e['query']['offset']);}_0x11d526[_0xc053('0x3a')]=qs[_0xc053('0x3b')](_0x5e4f7e[_0xc053('0x31')][_0xc053('0x3b')]);_0x11d526[_0xc053('0x3c')]=qs[_0xc053('0x32')](_[_0xc053('0x3d')](_0x5e4f7e[_0xc053('0x31')],_0x7c7a9b[_0xc053('0x32')]),_0xf4e60);if(_0x5e4f7e[_0xc053('0x31')][_0xc053('0x3e')]){_0x11d526['where']=_[_0xc053('0x3f')](_0x11d526[_0xc053('0x3c')],{'$or':_[_0xc053('0x40')](_0xf4e60,function(_0x1fa566){if(_0x1fa566[_0xc053('0x2e')]!==_0xc053('0x41')){var _0x2660df={};_0x2660df[_0x1fa566['name']]={'$like':'%'+_0x5e4f7e[_0xc053('0x31')][_0xc053('0x3e')]+'%'};return _0x2660df;}})});}_0x11d526=_[_0xc053('0x3f')]({},_0x11d526,_0x5e4f7e[_0xc053('0x42')]);var _0x565058={'where':_0x11d526['where']};return db[_0xc053('0x2b')][_0xc053('0x1c')](_0x565058)[_0xc053('0x24')](function(_0x39638f){_0x1a761f[_0xc053('0x1c')]=_0x39638f;if(_0x5e4f7e[_0xc053('0x31')][_0xc053('0x43')]){_0x11d526[_0xc053('0x44')]=[{'all':!![]}];}return db[_0xc053('0x2b')]['findAll'](_0x11d526);})[_0xc053('0x24')](function(_0x24a9e7){_0x1a761f[_0xc053('0x45')]=_0x24a9e7;return _0x1a761f;})[_0xc053('0x24')](respondWithFilteredResult(_0x51cdb3,_0x11d526))[_0xc053('0x46')](handleError(_0x51cdb3,null));};exports[_0xc053('0x47')]=function(_0x14436d,_0x2c86c5){var _0x311ff8={'raw':![],'where':{'id':_0x14436d[_0xc053('0x48')]['id']}},_0x5a3d4c={};_0x5a3d4c[_0xc053('0x34')]=_['keys'](db['AnalyticCustomReport'][_0xc053('0x2c')]);_0x5a3d4c[_0xc053('0x31')]=_[_0xc053('0x30')](_0x14436d['query']);_0x5a3d4c['filters']=_['intersection'](_0x5a3d4c[_0xc053('0x34')],_0x5a3d4c[_0xc053('0x31')]);_0x311ff8[_0xc053('0x35')]=_[_0xc053('0x33')](_0x5a3d4c[_0xc053('0x34')],qs[_0xc053('0x36')](_0x14436d[_0xc053('0x31')][_0xc053('0x36')]));_0x311ff8['attributes']=_0x311ff8['attributes'][_0xc053('0x37')]?_0x311ff8[_0xc053('0x35')]:_0x5a3d4c['model'];if(_0x14436d[_0xc053('0x31')][_0xc053('0x43')]){_0x311ff8[_0xc053('0x44')]=[{'all':!![]}];}_0x311ff8=_['merge']({},_0x311ff8,_0x14436d[_0xc053('0x42')]);return db[_0xc053('0x2b')][_0xc053('0x49')](_0x311ff8)['then'](handleEntityNotFound(_0x2c86c5,null))['then'](respondWithResult(_0x2c86c5,null))['catch'](handleError(_0x2c86c5,null));};exports[_0xc053('0x4a')]=function(_0x445dbe,_0x428bf2){return db[_0xc053('0x2b')][_0xc053('0x4a')](_0x445dbe['body'],{})['then'](function(_0x2eab3e){var _0x24dd02=_0x445dbe['user'][_0xc053('0x4b')]({'plain':!![]});if(!_0x24dd02)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x24dd02[_0xc053('0x4c')]===_0xc053('0x4d')){var _0x487722=_0x2eab3e[_0xc053('0x4b')]({'plain':!![]});var _0x190a0d=_0xc053('0x4e');return db[_0xc053('0x4f')][_0xc053('0x49')]({'where':{'name':_0x190a0d,'userProfileId':_0x24dd02['userProfileId']},'raw':!![]})['then'](function(_0x38d3bc){if(_0x38d3bc&&_0x38d3bc[_0xc053('0x50')]===0x0){return db['UserProfileResource'][_0xc053('0x4a')]({'name':_0x487722[_0xc053('0x29')],'resourceId':_0x487722['id'],'type':_0xc053('0x26'),'sectionId':_0x38d3bc['id']},{})[_0xc053('0x24')](function(){return _0x2eab3e;});}else{return _0x2eab3e;}})['catch'](function(_0x2e95a8){logger[_0xc053('0x51')](_0xc053('0x52'),_0x2e95a8);throw _0x2e95a8;});}return _0x2eab3e;})[_0xc053('0x24')](respondWithResult(_0x428bf2,0xc9))[_0xc053('0x46')](handleError(_0x428bf2,null));};exports[_0xc053('0x23')]=function(_0x44dda1,_0x1f8f3e){if(_0x44dda1[_0xc053('0x53')]['id']){delete _0x44dda1['body']['id'];}return db[_0xc053('0x2b')][_0xc053('0x49')]({'where':{'id':_0x44dda1[_0xc053('0x48')]['id']}})[_0xc053('0x24')](handleEntityNotFound(_0x1f8f3e,null))[_0xc053('0x24')](saveUpdates(_0x44dda1[_0xc053('0x53')],null))[_0xc053('0x24')](respondWithResult(_0x1f8f3e,null))['catch'](handleError(_0x1f8f3e,null));};exports[_0xc053('0x25')]=function(_0x360454,_0x2e0388){return db[_0xc053('0x2b')][_0xc053('0x49')]({'where':{'id':_0x360454[_0xc053('0x48')]['id']}})['then'](handleEntityNotFound(_0x2e0388,null))[_0xc053('0x24')](removeEntity(_0x2e0388,null))['catch'](handleError(_0x2e0388,null));};exports[_0xc053('0x54')]=function(_0x1f1ebe,_0x1dba92){var _0x2e7ff0=0xa;var _0xf15d13=[_0xc053('0x55'),'left_join',_0xc053('0x56'),_0xc053('0x57')];var _0x6d7b78={'SUM':_0xc053('0x58'),'COUNT':_0xc053('0x59'),'COUNT DISTINCT':_0xc053('0x5a'),'MAX':_0xc053('0x5b'),'MIN':_0xc053('0x5c'),'AVG':_0xc053('0x5d'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xc053('0x5e'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x47c883={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xc053('0x5f'),'HOUR':'HOUR(%s)','ROUND':_0xc053('0x60'),'UNIX_TIMESTAMP':_0xc053('0x61')};var _0x40510e=function(_0x591150){return!_[_0xc053('0x62')]([_0xc053('0x63'),_0xc053('0x64'),_0xc053('0x65'),_0xc053('0x66')],_0x591150);};var _0xf079c7=function(_0x382414){if(!_0x382414||!_0x382414[_0xc053('0x67')][_0xc053('0x37')]){return'';}for(var _0x5c54e2='(',_0x158b40=0x0;_0x158b40<_0x382414[_0xc053('0x67')][_0xc053('0x37')];_0x158b40+=0x1){_0x158b40>0x0&&(_0x5c54e2+='\x20'+_0x382414[_0xc053('0x68')]+'\x20');_0x5c54e2+=_0x382414[_0xc053('0x67')][_0x158b40][_0xc053('0x69')]?_0xf079c7(_0x382414[_0xc053('0x67')][_0x158b40][_0xc053('0x69')]):_0x382414[_0xc053('0x67')][_0x158b40][_0xc053('0x6a')]+'\x20'+_0x382414[_0xc053('0x67')][_0x158b40][_0xc053('0x6b')]+(_0x40510e(_0x382414[_0xc053('0x67')][_0x158b40][_0xc053('0x6b')])?'\x20'+_0x382414[_0xc053('0x67')][_0x158b40]['value']:'');}return _0x5c54e2+')';};var _0x1b2bda={'where':{'id':_0x1f1ebe[_0xc053('0x48')]['id']}},_0x336e0f,_0x3e95fa,_0x5cf202,_0x348347,_0x3e7c75;_0x1b2bda=_[_0xc053('0x3f')]({},_0x1b2bda,_0x1f1ebe[_0xc053('0x42')]);return db[_0xc053('0x2b')][_0xc053('0x49')](_0x1b2bda)[_0xc053('0x24')](function(_0x3395c5){if(_0x3395c5){_0x336e0f=_0x3395c5;return _0x3395c5['getFields']();}return null;})['then'](function(_0x2439ed){if(_0x2439ed){if(!_0x2439ed[_0xc053('0x37')]){throw new db[(_0xc053('0x6c'))][(_0xc053('0x6d'))](_0xc053('0x6e'),0x193);}_0x3e95fa=_0x2439ed;return db[_0xc053('0x6f')][_0xc053('0x70')]({'raw':!![]});}return null;})[_0xc053('0x24')](function(_0x14733f){if(_0x14733f){_0x5cf202=_[_0xc053('0x71')](_0x14733f,'id');var _0x59e7ab;var _0x39ad2c=squel[_0xc053('0x72')]();_0x39ad2c['from'](_0x336e0f[_0xc053('0x73')]);for(var _0x359938=0x0;_0x359938<_0x3e95fa['length'];_0x359938+=0x1){_0x59e7ab=_0x3e95fa[_0x359938][_0xc053('0x74')]?_0x5cf202[_0x3e95fa[_0x359938]['MetricId']][_0xc053('0x75')]:_0x3e95fa[_0x359938]['field'];_0x59e7ab=_0x3e95fa[_0x359938][_0xc053('0x76')]?_[_0xc053('0x77')](_0x6d7b78[_0x3e95fa[_0x359938]['function']],'%s',_0x59e7ab):_0x59e7ab;_0x59e7ab=_0x3e95fa[_0x359938]['format']?_[_0xc053('0x77')](_0x47c883[_0x3e95fa[_0x359938][_0xc053('0x78')]],'%s',_0x59e7ab):_0x59e7ab;if(_0x3e95fa[_0x359938][_0xc053('0x79')]){_0x39ad2c[_0xc053('0x69')](_0x59e7ab);}_0x3e95fa[_0x359938][_0xc053('0x7a')]&&_0x39ad2c['order'](_0x59e7ab,_0x3e95fa[_0x359938]['orderBy']==='DESC'?![]:!![]);_0x39ad2c['field'](_0x59e7ab,_0x3e95fa[_0x359938][_0xc053('0x7b')]||_0x59e7ab);}if(_0x336e0f[_0xc053('0x7c')]){_0x336e0f[_0xc053('0x7c')]=JSON[_0xc053('0x7d')](_0x336e0f[_0xc053('0x7c')]);for(var _0x2cd9ad=0x0;_0x2cd9ad<_0x336e0f['joins']['length'];_0x2cd9ad+=0x1){if(_0x336e0f['joins'][_0x2cd9ad]['type']&&_[_0xc053('0x62')](_0xf15d13,_0x336e0f[_0xc053('0x7c')][_0x2cd9ad][_0xc053('0x2e')])&&_0x336e0f['joins'][_0x2cd9ad]['parentKey']&&_0x336e0f[_0xc053('0x7c')][_0x2cd9ad][_0xc053('0x7e')]&&_0x336e0f[_0xc053('0x7c')][_0x2cd9ad]['foreignKey']){_0x39ad2c[_0x336e0f[_0xc053('0x7c')][_0x2cd9ad]['type']](_0x336e0f['joins'][_0x2cd9ad][_0xc053('0x7e')],null,util[_0xc053('0x78')](_0xc053('0x7f'),_0x336e0f[_0xc053('0x73')],_0x336e0f[_0xc053('0x7c')][_0x2cd9ad][_0xc053('0x80')],_0x336e0f[_0xc053('0x7c')][_0x2cd9ad][_0xc053('0x7e')],_0x336e0f[_0xc053('0x7c')][_0x2cd9ad]['foreignKey']));}}}if(_0x336e0f[_0xc053('0x81')]){_0x336e0f['conditions']=JSON['parse'](_0x336e0f[_0xc053('0x81')]);_0x39ad2c[_0xc053('0x3c')](_0xf079c7(_0x336e0f[_0xc053('0x81')][_0xc053('0x69')]));}_0x3e7c75=_0x39ad2c[_0xc053('0x82')]();_0x39ad2c[_0xc053('0x1d')](_0x2e7ff0);_0x39ad2c[_0xc053('0x1b')](0x0);logger[_0xc053('0x83')](_0xc053('0x84'),_0x39ad2c[_0xc053('0x85')]());return dbH[_0xc053('0x86')][_0xc053('0x31')](_0x39ad2c['toString'](),{'type':dbH[_0xc053('0x86')]['QueryTypes'][_0xc053('0x87')]});}})[_0xc053('0x24')](respondWithResult(_0x1dba92,null))['catch'](handleError(_0x1dba92,null));};function runReport(_0x4b0e4b,_0x3c8ef2,_0x2ce017){var _0xb3e19=_0x3c8ef2['name'];var _0x44bea2=0xa;var _0x41db2a=['join',_0xc053('0x88'),_0xc053('0x56'),_0xc053('0x57')];var _0xff585a={'SUM':_0xc053('0x58'),'COUNT':_0xc053('0x59'),'COUNT DISTINCT':_0xc053('0x5a'),'MAX':'MAX(%s)','MIN':_0xc053('0x5c'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xc053('0x89'),'GROUP_CONCAT ASC':_0xc053('0x5e'),'GROUP_CONCAT DESC':_0xc053('0x8a')};var _0x455624={'SEC_TO_TIME':_0xc053('0x8b'),'DATE':_0xc053('0x5f'),'HOUR':'HOUR(%s)','ROUND':_0xc053('0x60'),'UNIX_TIMESTAMP':_0xc053('0x61')};var _0x175b2d=function(_0x582b58){return!_[_0xc053('0x62')]([_0xc053('0x63'),'IS\x20NOT\x20NULL',_0xc053('0x65'),'IS\x20NOT\x20EMPTY'],_0x582b58);};var _0x1d58e7=function(_0x912610){if(!_0x912610||!_0x912610[_0xc053('0x67')][_0xc053('0x37')]){return'';}for(var _0xc4b5c2='(',_0x498fbd=0x0;_0x498fbd<_0x912610[_0xc053('0x67')][_0xc053('0x37')];_0x498fbd+=0x1){_0x498fbd>0x0&&(_0xc4b5c2+='\x20'+_0x912610[_0xc053('0x68')]+'\x20');_0xc4b5c2+=_0x912610[_0xc053('0x67')][_0x498fbd][_0xc053('0x69')]?_0x1d58e7(_0x912610['rules'][_0x498fbd][_0xc053('0x69')]):_0x912610['rules'][_0x498fbd][_0xc053('0x6a')]+'\x20'+_0x912610[_0xc053('0x67')][_0x498fbd][_0xc053('0x6b')]+(_0x175b2d(_0x912610[_0xc053('0x67')][_0x498fbd]['condition'])?'\x20'+_0x912610['rules'][_0x498fbd][_0xc053('0x8c')]:'');}return _0xc4b5c2+')';};var _0x48e883={'where':{'id':_0x4b0e4b['id']}},_0x554167,_0x3541ae,_0x4ffa82,_0x23b526,_0x532d2d;_0x48e883=_[_0xc053('0x3f')]({},_0x48e883,_0x2ce017);return db[_0xc053('0x2b')]['find'](_0x48e883)['then'](function(_0x5f3457){if(_0x5f3457){_0x554167=_0x5f3457;return _0x5f3457[_0xc053('0x8d')]();}return null;})[_0xc053('0x24')](function(_0x382c5f){if(_0x382c5f){if(!_0x382c5f[_0xc053('0x37')]){throw new db[(_0xc053('0x6c'))][(_0xc053('0x6d'))](_0xc053('0x6e'),0x193);}_0x3541ae=_0x382c5f;return db['AnalyticMetric'][_0xc053('0x70')]({'raw':!![]});}return null;})[_0xc053('0x24')](function(_0x18779d){if(_0x18779d){_0x4ffa82=_['keyBy'](_0x18779d,'id');var _0x422598;var _0x35c486=squel['select']();_0x35c486[_0xc053('0x8e')](_0x554167[_0xc053('0x73')]);for(var _0x18a9f8=0x0;_0x18a9f8<_0x3541ae[_0xc053('0x37')];_0x18a9f8+=0x1){_0x422598=_0x3541ae[_0x18a9f8]['MetricId']?_0x4ffa82[_0x3541ae[_0x18a9f8][_0xc053('0x74')]][_0xc053('0x75')]:_0x3541ae[_0x18a9f8][_0xc053('0x6a')];_0x422598=_0x3541ae[_0x18a9f8][_0xc053('0x76')]?_[_0xc053('0x77')](_0xff585a[_0x3541ae[_0x18a9f8][_0xc053('0x76')]],'%s',_0x422598):_0x422598;_0x422598=_0x3541ae[_0x18a9f8][_0xc053('0x78')]?_[_0xc053('0x77')](_0x455624[_0x3541ae[_0x18a9f8][_0xc053('0x78')]],'%s',_0x422598):_0x422598;if(_0x3541ae[_0x18a9f8][_0xc053('0x79')]){_0x35c486[_0xc053('0x69')](_0x422598);}_0x3541ae[_0x18a9f8][_0xc053('0x7a')]&&_0x35c486[_0xc053('0x3a')](_0x422598,_0x3541ae[_0x18a9f8][_0xc053('0x7a')]===_0xc053('0x8f')?![]:!![]);_0x35c486['field'](_0x422598,_0x3541ae[_0x18a9f8][_0xc053('0x7b')]||_0x422598);}if(_0x554167[_0xc053('0x7c')]){_0x554167[_0xc053('0x7c')]=JSON[_0xc053('0x7d')](_0x554167[_0xc053('0x7c')]);for(var _0x24efb6=0x0;_0x24efb6<_0x554167[_0xc053('0x7c')]['length'];_0x24efb6+=0x1){if(_0x554167[_0xc053('0x7c')][_0x24efb6][_0xc053('0x2e')]&&_[_0xc053('0x62')](_0x41db2a,_0x554167[_0xc053('0x7c')][_0x24efb6][_0xc053('0x2e')])&&_0x554167['joins'][_0x24efb6][_0xc053('0x80')]&&_0x554167[_0xc053('0x7c')][_0x24efb6][_0xc053('0x7e')]&&_0x554167['joins'][_0x24efb6][_0xc053('0x90')]){_0x35c486[_0x554167['joins'][_0x24efb6][_0xc053('0x2e')]](_0x554167['joins'][_0x24efb6][_0xc053('0x7e')],null,util[_0xc053('0x78')]('%s.%s\x20=\x20%s.%s',_0x554167['table'],_0x554167[_0xc053('0x7c')][_0x24efb6][_0xc053('0x80')],_0x554167['joins'][_0x24efb6][_0xc053('0x7e')],_0x554167[_0xc053('0x7c')][_0x24efb6][_0xc053('0x90')]));}}}if(_0x554167['conditions']){_0x554167[_0xc053('0x81')]=JSON[_0xc053('0x7d')](_0x554167[_0xc053('0x81')]);_0x35c486['where'](_0x1d58e7(_0x554167[_0xc053('0x81')]['group']));}_0x532d2d=_0x35c486[_0xc053('0x82')]();_0x35c486['limit'](_0x44bea2);_0x35c486[_0xc053('0x1b')](0x0);return;}})[_0xc053('0x24')](function(){if(_0x3c8ef2[_0xc053('0x91')]===_0xc053('0x92')){return null;}var _0x462082=_[_0xc053('0x3f')](_0x3c8ef2,{'name':_0x3c8ef2['fullPath']||_0x3c8ef2[_0xc053('0x29')]||_0x554167[_0xc053('0x29')],'basename':_0xb3e19,'savename':util[_0xc053('0x78')](_0xc053('0x93'),_0x3c8ef2[_0xc053('0x29')]||_0x554167[_0xc053('0x29')],require('randomstring')[_0xc053('0x94')](0x4),_0x3c8ef2[_0xc053('0x91')]||_0xc053('0x95')),'reportId':_0x554167['id'],'reportType':'custom'});return db[_0xc053('0x96')]['create'](_0x462082,{'raw':!![]});})[_0xc053('0x24')](function(_0x43a803){if(_0x554167[_0xc053('0x73')]===_0xc053('0x97')){_0x532d2d[_0xc053('0x3c')](_0x554167['table']+_0xc053('0x98'),_0x3c8ef2['startDate'],_0x3c8ef2['endDate']);}else{_0x532d2d[_0xc053('0x3c')](_0x554167[_0xc053('0x73')]+_0xc053('0x99'),_0x3c8ef2[_0xc053('0x9a')],_0x3c8ef2[_0xc053('0x9b')]);}if(_0x43a803){logger[_0xc053('0x9c')]('Run\x20Query:',_0x532d2d[_0xc053('0x85')]());require(_0xc053('0x9d'))['fork'](path[_0xc053('0x55')](__dirname,_0xc053('0x9e'),_0x43a803[_0xc053('0x91')]),[_0x43a803['id'],_0x532d2d['toString'](),path['join'](__dirname,'../../files/reports',_0x43a803[_0xc053('0x9f')]),_0xb3e19]);return _0x43a803;}else{var _0x2a35f7=squel[_0xc053('0x72')]();_0x2a35f7['from']('('+_0x532d2d[_0xc053('0x85')]()+')',_0xc053('0xa0'));_0x2a35f7[_0xc053('0x6a')](_0xc053('0xa1'),_0xc053('0x1c'));_0x532d2d[_0xc053('0x1d')](_0x3c8ef2[_0xc053('0x1d')]||_0x44bea2);_0x532d2d[_0xc053('0x1b')](_0x3c8ef2[_0xc053('0x1b')]||0x0);return dbH[_0xc053('0x86')][_0xc053('0x31')](_0x2a35f7['toString'](),{'type':dbH[_0xc053('0x86')][_0xc053('0xa2')]['SELECT']})['then'](function(_0x4ce280){if(!_0x4ce280[_0xc053('0x37')]){_0x23b526=0x0;}else{_0x23b526=_0x4ce280[0x0][_0xc053('0x1c')]||0x0;}return dbH['sequelize'][_0xc053('0x31')](_0x532d2d[_0xc053('0x85')](),{'type':dbH[_0xc053('0x86')][_0xc053('0xa2')][_0xc053('0x87')]});})[_0xc053('0x24')](function(_0xfa9717){return{'rows':_0xfa9717||[],'count':_0x23b526};});}});}exports['run']=function(_0x541b23,_0x5cbe53){return runReport(_0x541b23[_0xc053('0x48')],_0x541b23[_0xc053('0x31')],_0x541b23[_0xc053('0x42')])[_0xc053('0x24')](respondWithResult(_0x5cbe53,null))[_0xc053('0x46')](handleError(_0x5cbe53,null));};exports[_0xc053('0xa3')]=runReport;exports[_0xc053('0x31')]=function(_0x4c338f,_0x1c5125){var _0x5d1dc1=0xa;var _0x307832=[_0xc053('0x55'),_0xc053('0x88'),_0xc053('0x56'),_0xc053('0x57')];var _0x294585={'SUM':_0xc053('0x58'),'COUNT':_0xc053('0x59'),'COUNT DISTINCT':_0xc053('0x5a'),'MAX':_0xc053('0x5b'),'MIN':_0xc053('0x5c'),'AVG':_0xc053('0x5d'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xc053('0x5e'),'GROUP_CONCAT DESC':_0xc053('0x8a')};var _0x5c93fe={'SEC_TO_TIME':_0xc053('0x8b'),'DATE':_0xc053('0x5f'),'HOUR':_0xc053('0xa4'),'ROUND':_0xc053('0x60'),'UNIX_TIMESTAMP':_0xc053('0x61')};var _0x5b7718=function(_0x213616){return!_[_0xc053('0x62')](['IS\x20NULL',_0xc053('0x64'),_0xc053('0x65'),_0xc053('0x66')],_0x213616);};var _0x49be74=function(_0x41fd14){if(!_0x41fd14||!_0x41fd14[_0xc053('0x67')]['length']){return'';}for(var _0x478c6e='(',_0x5535ea=0x0;_0x5535ea<_0x41fd14[_0xc053('0x67')][_0xc053('0x37')];_0x5535ea+=0x1){_0x5535ea>0x0&&(_0x478c6e+='\x20'+_0x41fd14[_0xc053('0x68')]+'\x20');_0x478c6e+=_0x41fd14[_0xc053('0x67')][_0x5535ea][_0xc053('0x69')]?_0x49be74(_0x41fd14[_0xc053('0x67')][_0x5535ea][_0xc053('0x69')]):_0x41fd14[_0xc053('0x67')][_0x5535ea][_0xc053('0x6a')]+'\x20'+_0x41fd14[_0xc053('0x67')][_0x5535ea][_0xc053('0x6b')]+(_0x5b7718(_0x41fd14[_0xc053('0x67')][_0x5535ea][_0xc053('0x6b')])?'\x20'+_0x41fd14[_0xc053('0x67')][_0x5535ea]['value']:'');}return _0x478c6e+')';};var _0x4440db={'where':{'id':_0x4c338f['params']['id']}},_0x4c25ff,_0x22d7d5,_0x31d8a4,_0x2dab0d,_0x122ba0;_0x4440db=_['merge']({},_0x4440db,_0x4c338f['options']);return db[_0xc053('0x2b')]['find'](_0x4440db)[_0xc053('0x24')](function(_0x4dc941){if(_0x4dc941){_0x4c25ff=_0x4dc941;return _0x4dc941['getFields']();}return null;})[_0xc053('0x24')](function(_0x9ac83f){if(_0x9ac83f){if(!_0x9ac83f[_0xc053('0x37')]){throw new db['Sequelize']['ValidationErrorItem']('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x22d7d5=_0x9ac83f;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xc053('0x24')](function(_0x8b0205){if(_0x8b0205){_0x31d8a4=_[_0xc053('0x71')](_0x8b0205,'id');var _0x371aa2;var _0x21fbe1=squel['select']();_0x21fbe1['from'](_0x4c25ff[_0xc053('0x73')]);for(var _0x384a77=0x0;_0x384a77<_0x22d7d5[_0xc053('0x37')];_0x384a77+=0x1){_0x371aa2=_0x22d7d5[_0x384a77][_0xc053('0x74')]?_0x31d8a4[_0x22d7d5[_0x384a77][_0xc053('0x74')]][_0xc053('0x75')]:_0x22d7d5[_0x384a77][_0xc053('0x6a')];_0x371aa2=_0x22d7d5[_0x384a77][_0xc053('0x76')]?_[_0xc053('0x77')](_0x294585[_0x22d7d5[_0x384a77][_0xc053('0x76')]],'%s',_0x371aa2):_0x371aa2;_0x371aa2=_0x22d7d5[_0x384a77][_0xc053('0x78')]?_[_0xc053('0x77')](_0x5c93fe[_0x22d7d5[_0x384a77][_0xc053('0x78')]],'%s',_0x371aa2):_0x371aa2;if(_0x22d7d5[_0x384a77][_0xc053('0x79')]){_0x21fbe1[_0xc053('0x69')](_0x371aa2);}_0x22d7d5[_0x384a77][_0xc053('0x7a')]&&_0x21fbe1[_0xc053('0x3a')](_0x371aa2,_0x22d7d5[_0x384a77]['orderBy']===_0xc053('0x8f')?![]:!![]);_0x21fbe1[_0xc053('0x6a')](_0x371aa2,_0x22d7d5[_0x384a77][_0xc053('0x7b')]||_0x371aa2);}if(_0x4c25ff[_0xc053('0x7c')]){_0x4c25ff[_0xc053('0x7c')]=JSON[_0xc053('0x7d')](_0x4c25ff[_0xc053('0x7c')]);for(var _0x490dd7=0x0;_0x490dd7<_0x4c25ff[_0xc053('0x7c')]['length'];_0x490dd7+=0x1){if(_0x4c25ff['joins'][_0x490dd7][_0xc053('0x2e')]&&_[_0xc053('0x62')](_0x307832,_0x4c25ff[_0xc053('0x7c')][_0x490dd7][_0xc053('0x2e')])&&_0x4c25ff[_0xc053('0x7c')][_0x490dd7][_0xc053('0x80')]&&_0x4c25ff[_0xc053('0x7c')][_0x490dd7]['foreignTable']&&_0x4c25ff[_0xc053('0x7c')][_0x490dd7]['foreignKey']){_0x21fbe1[_0x4c25ff[_0xc053('0x7c')][_0x490dd7][_0xc053('0x2e')]](_0x4c25ff[_0xc053('0x7c')][_0x490dd7][_0xc053('0x7e')],null,util[_0xc053('0x78')](_0xc053('0x7f'),_0x4c25ff[_0xc053('0x73')],_0x4c25ff[_0xc053('0x7c')][_0x490dd7][_0xc053('0x80')],_0x4c25ff['joins'][_0x490dd7]['foreignTable'],_0x4c25ff['joins'][_0x490dd7][_0xc053('0x90')]));}}}if(_0x4c25ff[_0xc053('0x81')]){_0x4c25ff[_0xc053('0x81')]=JSON[_0xc053('0x7d')](_0x4c25ff[_0xc053('0x81')]);_0x21fbe1[_0xc053('0x3c')](_0x49be74(_0x4c25ff[_0xc053('0x81')][_0xc053('0x69')]));}_0x122ba0=_0x21fbe1[_0xc053('0x82')]();_0x21fbe1[_0xc053('0x1d')](_0x5d1dc1);_0x21fbe1[_0xc053('0x1b')](0x0);logger['debug'](_0xc053('0x84'),_0x21fbe1[_0xc053('0x85')]());return dbH[_0xc053('0x86')]['query'](_0x21fbe1[_0xc053('0x85')](),{'type':dbH[_0xc053('0x86')][_0xc053('0xa2')][_0xc053('0x87')]});}})[_0xc053('0x24')](function(){return{'sql':_0x122ba0[_0xc053('0x85')]()};})[_0xc053('0x24')](respondWithResult(_0x1c5125,null))[_0xc053('0x46')](handleError(_0x1c5125,null));}; \ No newline at end of file diff --git a/server/api/analyticCustomReport/analyticCustomReport.model.js b/server/api/analyticCustomReport/analyticCustomReport.model.js new file mode 100644 index 0000000..69b69cb --- /dev/null +++ b/server/api/analyticCustomReport/analyticCustomReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa66e=['moment','bluebird','request-promise','path','../../config/environment','./analyticCustomReport.attributes','exports','define','lodash','../../config/logger'];(function(_0x2f57b2,_0xa8e91a){var _0x5ace77=function(_0x59c00a){while(--_0x59c00a){_0x2f57b2['push'](_0x2f57b2['shift']());}};_0x5ace77(++_0xa8e91a);}(_0xa66e,0x1f2));var _0xea66=function(_0x4e5dcf,_0x32ef3e){_0x4e5dcf=_0x4e5dcf-0x0;var _0xff7a0f=_0xa66e[_0x4e5dcf];return _0xff7a0f;};'use strict';var _=require(_0xea66('0x0'));var util=require('util');var logger=require(_0xea66('0x1'))('api');var moment=require(_0xea66('0x2'));var BPromise=require(_0xea66('0x3'));var rp=require(_0xea66('0x4'));var fs=require('fs');var path=require(_0xea66('0x5'));var rimraf=require('rimraf');var config=require(_0xea66('0x6'));var attributes=require(_0xea66('0x7'));module[_0xea66('0x8')]=function(_0x499344,_0x5b60c6){return _0x499344[_0xea66('0x9')]('AnalyticCustomReport',attributes,{'tableName':'analytics_custom_reports','paranoid':!![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticCustomReport/analyticCustomReport.rpc.js b/server/api/analyticCustomReport/analyticCustomReport.rpc.js new file mode 100644 index 0000000..e7ce7b9 --- /dev/null +++ b/server/api/analyticCustomReport/analyticCustomReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x69ee=['AnalyticCustomReport,\x20%s,\x20%s','request\x20sent','debug','AnalyticCustomReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info'];(function(_0x4fe370,_0x3e5324){var _0x4c191e=function(_0x4c0517){while(--_0x4c0517){_0x4fe370['push'](_0x4fe370['shift']());}};_0x4c191e(++_0x3e5324);}(_0x69ee,0x133));var _0xe69e=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x69ee[_0x397e5f];return _0x5302b8;};'use strict';var _=require(_0xe69e('0x0'));var util=require(_0xe69e('0x1'));var moment=require(_0xe69e('0x2'));var BPromise=require(_0xe69e('0x3'));var rs=require(_0xe69e('0x4'));var fs=require('fs');var Redis=require(_0xe69e('0x5'));var db=require(_0xe69e('0x6'))['db'];var utils=require(_0xe69e('0x7'));var logger=require(_0xe69e('0x8'))(_0xe69e('0x9'));var config=require(_0xe69e('0xa'));var jayson=require(_0xe69e('0xb'));var client=jayson[_0xe69e('0xc')][_0xe69e('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x53e87d,_0x3f169a,_0x24af57){return new BPromise(function(_0x3b482c,_0x338e6f){return client[_0xe69e('0xe')](_0x53e87d,_0x24af57)[_0xe69e('0xf')](function(_0x4661ad){logger[_0xe69e('0x10')](_0xe69e('0x11'),_0x3f169a,_0xe69e('0x12'));logger[_0xe69e('0x13')](_0xe69e('0x14'),_0x3f169a,'request\x20sent',JSON[_0xe69e('0x15')](_0x4661ad));if(_0x4661ad[_0xe69e('0x16')]){if(_0x4661ad['error'][_0xe69e('0x17')]===0x1f4){logger[_0xe69e('0x16')](_0xe69e('0x11'),_0x3f169a,_0x4661ad[_0xe69e('0x16')][_0xe69e('0x18')]);return _0x338e6f(_0x4661ad[_0xe69e('0x16')][_0xe69e('0x18')]);}logger['error'](_0xe69e('0x11'),_0x3f169a,_0x4661ad[_0xe69e('0x16')][_0xe69e('0x18')]);return _0x3b482c(_0x4661ad[_0xe69e('0x16')]['message']);}else{logger['info'](_0xe69e('0x11'),_0x3f169a,_0xe69e('0x12'));_0x3b482c(_0x4661ad[_0xe69e('0x19')][_0xe69e('0x18')]);}})[_0xe69e('0x1a')](function(_0x345d55){logger[_0xe69e('0x16')](_0xe69e('0x11'),_0x3f169a,_0x345d55);_0x338e6f(_0x345d55);});});} \ No newline at end of file diff --git a/server/api/analyticCustomReport/index.js b/server/api/analyticCustomReport/index.js new file mode 100644 index 0000000..48f21d9 --- /dev/null +++ b/server/api/analyticCustomReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x43af=['isAuthenticated','/:id','show','/:id/preview','run','post','put','update','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','get'];(function(_0x549feb,_0x544a55){var _0x30b9b6=function(_0x12b583){while(--_0x12b583){_0x549feb['push'](_0x549feb['shift']());}};_0x30b9b6(++_0x544a55);}(_0x43af,0x100));var _0xf43a=function(_0x5267b3,_0x556b53){_0x5267b3=_0x5267b3-0x0;var _0x77157=_0x43af[_0x5267b3];return _0x77157;};'use strict';var multer=require(_0xf43a('0x0'));var util=require(_0xf43a('0x1'));var path=require(_0xf43a('0x2'));var timeout=require(_0xf43a('0x3'));var express=require(_0xf43a('0x4'));var router=express[_0xf43a('0x5')]();var fs_extra=require(_0xf43a('0x6'));var auth=require(_0xf43a('0x7'));var interaction=require(_0xf43a('0x8'));var config=require('../../config/environment');var controller=require('./analyticCustomReport.controller');router[_0xf43a('0x9')]('/',auth[_0xf43a('0xa')](),controller['index']);router['get'](_0xf43a('0xb'),auth[_0xf43a('0xa')](),controller[_0xf43a('0xc')]);router[_0xf43a('0x9')](_0xf43a('0xd'),auth['isAuthenticated'](),controller['preview']);router[_0xf43a('0x9')]('/:id/run',auth['isAuthenticated'](),controller[_0xf43a('0xe')]);router[_0xf43a('0x9')]('/:id/query',auth[_0xf43a('0xa')](),controller['query']);router[_0xf43a('0xf')]('/',auth['isAuthenticated'](),controller['create']);router[_0xf43a('0x10')](_0xf43a('0xb'),auth[_0xf43a('0xa')](),controller[_0xf43a('0x11')]);router['delete']('/:id',auth[_0xf43a('0xa')](),controller['destroy']);module[_0xf43a('0x12')]=router; \ No newline at end of file diff --git a/server/api/analyticDefaultReport/analyticDefaultReport.attributes.js b/server/api/analyticDefaultReport/analyticDefaultReport.attributes.js new file mode 100644 index 0000000..6ed90f5 --- /dev/null +++ b/server/api/analyticDefaultReport/analyticDefaultReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5d17=['sequelize','exports','STRING','TEXT'];(function(_0x51b6ac,_0xa7a756){var _0x52e611=function(_0x3beb01){while(--_0x3beb01){_0x51b6ac['push'](_0x51b6ac['shift']());}};_0x52e611(++_0xa7a756);}(_0x5d17,0x114));var _0x75d1=function(_0x32e2eb,_0x3347b7){_0x32e2eb=_0x32e2eb-0x0;var _0x2418ce=_0x5d17[_0x32e2eb];return _0x2418ce;};'use strict';var Sequelize=require(_0x75d1('0x0'));module[_0x75d1('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![]},'description':{'type':Sequelize['STRING']},'parent':{'type':Sequelize[_0x75d1('0x2')]},'table':{'type':Sequelize[_0x75d1('0x2')]},'conditions':{'type':Sequelize[_0x75d1('0x3')]},'joins':{'type':Sequelize['TEXT']}}; \ No newline at end of file diff --git a/server/api/analyticDefaultReport/analyticDefaultReport.controller.js b/server/api/analyticDefaultReport/analyticDefaultReport.controller.js new file mode 100644 index 0000000..81b164f --- /dev/null +++ b/server/api/analyticDefaultReport/analyticDefaultReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2ef3=['Sequelize','from','foreignKey','output','web','fullPath','generate','csv','cdr','startDate','endDate','info','child_process','fork','../../components/export/','savename','countTable','COUNT(*)','runReport','IS\x20NULL','IS\x20NOT\x20EMPTY','metric','Limited\x20Query:','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','offset','undefined','count','limit','set','Content-Range','apply','save','then','destroy','get','DefaultReports','UserProfileResource','end','error','stack','name','send','index','map','rawAttributes','type','key','model','query','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','AnalyticDefaultReport','includeAll','include','findAll','rows','catch','show','params','keys','fields','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','autoAssociation','update','preview','left_join','right_join','cross_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','includes','IS\x20EMPTY','operator','rules','group','condition','value','getFields','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','MetricId','field','function','replace','format','groupBy','orderBy','DESC','alias','joins','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','table','conditions','parse','clone','debug','toString','sequelize','QueryTypes','SELECT','join','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','UNIX_TIMESTAMP(%s)','IS\x20NOT\x20NULL'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x2ef3,0xba));var _0x32ef=function(_0x2e32e2,_0x5506ab){_0x2e32e2=_0x2e32e2-0x0;var _0x40d019=_0x2ef3[_0x2e32e2];return _0x40d019;};'use strict';var emlformat=require(_0x32ef('0x0'));var rimraf=require(_0x32ef('0x1'));var zipdir=require(_0x32ef('0x2'));var jsonpatch=require(_0x32ef('0x3'));var rp=require(_0x32ef('0x4'));var moment=require(_0x32ef('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x32ef('0x6'));var util=require(_0x32ef('0x7'));var path=require('path');var sox=require(_0x32ef('0x8'));var csv=require(_0x32ef('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x32ef('0xa'));var squel=require(_0x32ef('0xb'));var crypto=require(_0x32ef('0xc'));var jsforce=require(_0x32ef('0xd'));var deskjs=require(_0x32ef('0xe'));var toCsv=require(_0x32ef('0x9'));var querystring=require(_0x32ef('0xf'));var Papa=require(_0x32ef('0x10'));var Redis=require(_0x32ef('0x11'));var authService=require(_0x32ef('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x32ef('0x13'));var logger=require(_0x32ef('0x14'))(_0x32ef('0x15'));var utils=require(_0x32ef('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x32ef('0x17'));var db=require('../../mysqldb')['db'];var dbH=require(_0x32ef('0x18'))['dbH'];function respondWithStatusCode(_0x3e98df,_0x1ef1ae){_0x1ef1ae=_0x1ef1ae||0xcc;return function(_0x5c3eb9){if(_0x5c3eb9){return _0x3e98df['sendStatus'](_0x1ef1ae);}return _0x3e98df[_0x32ef('0x19')](_0x1ef1ae)['end']();};}function respondWithResult(_0x326fce,_0x40a6e6){_0x40a6e6=_0x40a6e6||0xc8;return function(_0x93d492){if(_0x93d492){return _0x326fce[_0x32ef('0x19')](_0x40a6e6)['json'](_0x93d492);}};}function respondWithFilteredResult(_0x55bf0b,_0x531e30){return function(_0x13db1a){if(_0x13db1a){var _0x3950e6=typeof _0x531e30[_0x32ef('0x1a')]==='undefined'&&typeof _0x531e30['limit']===_0x32ef('0x1b');var _0x1a9476=_0x13db1a[_0x32ef('0x1c')];var _0x57863c=_0x3950e6?0x0:_0x531e30[_0x32ef('0x1a')];var _0x33e230=_0x3950e6?_0x13db1a['count']:_0x531e30[_0x32ef('0x1a')]+_0x531e30[_0x32ef('0x1d')];var _0x26aff3;if(_0x33e230>=_0x1a9476){_0x33e230=_0x1a9476;_0x26aff3=0xc8;}else{_0x26aff3=0xce;}_0x55bf0b[_0x32ef('0x19')](_0x26aff3);return _0x55bf0b[_0x32ef('0x1e')](_0x32ef('0x1f'),_0x57863c+'-'+_0x33e230+'/'+_0x1a9476)['json'](_0x13db1a);}return null;};}function patchUpdates(_0x3c5b78){return function(_0x5cc3ef){try{jsonpatch[_0x32ef('0x20')](_0x5cc3ef,_0x3c5b78,!![]);}catch(_0x3a20ca){return BPromise['reject'](_0x3a20ca);}return _0x5cc3ef[_0x32ef('0x21')]();};}function saveUpdates(_0x97780,_0x5e8898){return function(_0x55f7f2){if(_0x55f7f2){return _0x55f7f2['update'](_0x97780)[_0x32ef('0x22')](function(_0xb30fab){return _0xb30fab;});}return null;};}function removeEntity(_0x225feb,_0x478bef){return function(_0x59585f){if(_0x59585f){return _0x59585f[_0x32ef('0x23')]()['then'](function(){var _0x51a412=_0x59585f[_0x32ef('0x24')]({'plain':!![]});var _0x14d4b3=_0x32ef('0x25');return db[_0x32ef('0x26')][_0x32ef('0x23')]({'where':{'type':_0x14d4b3,'resourceId':_0x51a412['id']}})[_0x32ef('0x22')](function(){return _0x59585f;});})[_0x32ef('0x22')](function(){_0x225feb[_0x32ef('0x19')](0xcc)[_0x32ef('0x27')]();});}};}function handleEntityNotFound(_0x2f52d7,_0x1335e2){return function(_0xba4b3f){if(!_0xba4b3f){_0x2f52d7['sendStatus'](0x194);}return _0xba4b3f;};}function handleError(_0xd65fde,_0x2f5d06){_0x2f5d06=_0x2f5d06||0x1f4;return function(_0x5a04cd){logger[_0x32ef('0x28')](_0x5a04cd[_0x32ef('0x29')]);if(_0x5a04cd[_0x32ef('0x2a')]){delete _0x5a04cd[_0x32ef('0x2a')];}_0xd65fde['status'](_0x2f5d06)[_0x32ef('0x2b')](_0x5a04cd);};}exports[_0x32ef('0x2c')]=function(_0x31dbc3,_0x2ac686){var _0x1b668a={},_0x1a6ed2={},_0x1a122d={'count':0x0,'rows':[]};var _0x575f3e=_[_0x32ef('0x2d')](db['AnalyticDefaultReport'][_0x32ef('0x2e')],function(_0x2b6c6a){return{'name':_0x2b6c6a['fieldName'],'type':_0x2b6c6a[_0x32ef('0x2f')][_0x32ef('0x30')]};});_0x1a6ed2[_0x32ef('0x31')]=_[_0x32ef('0x2d')](_0x575f3e,_0x32ef('0x2a'));_0x1a6ed2['query']=_['keys'](_0x31dbc3[_0x32ef('0x32')]);_0x1a6ed2['filters']=_[_0x32ef('0x33')](_0x1a6ed2[_0x32ef('0x31')],_0x1a6ed2[_0x32ef('0x32')]);_0x1b668a[_0x32ef('0x34')]=_[_0x32ef('0x33')](_0x1a6ed2[_0x32ef('0x31')],qs['fields'](_0x31dbc3['query']['fields']));_0x1b668a[_0x32ef('0x34')]=_0x1b668a[_0x32ef('0x34')][_0x32ef('0x35')]?_0x1b668a['attributes']:_0x1a6ed2['model'];if(!_0x31dbc3[_0x32ef('0x32')][_0x32ef('0x36')](_0x32ef('0x37'))){_0x1b668a['limit']=qs['limit'](_0x31dbc3[_0x32ef('0x32')][_0x32ef('0x1d')]);_0x1b668a[_0x32ef('0x1a')]=qs[_0x32ef('0x1a')](_0x31dbc3[_0x32ef('0x32')][_0x32ef('0x1a')]);}_0x1b668a[_0x32ef('0x38')]=qs[_0x32ef('0x39')](_0x31dbc3[_0x32ef('0x32')]['sort']);_0x1b668a[_0x32ef('0x3a')]=qs[_0x32ef('0x3b')](_[_0x32ef('0x3c')](_0x31dbc3['query'],_0x1a6ed2[_0x32ef('0x3b')]),_0x575f3e);if(_0x31dbc3[_0x32ef('0x32')][_0x32ef('0x3d')]){_0x1b668a[_0x32ef('0x3a')]=_[_0x32ef('0x3e')](_0x1b668a[_0x32ef('0x3a')],{'$or':_[_0x32ef('0x2d')](_0x575f3e,function(_0x1cebed){if(_0x1cebed[_0x32ef('0x2f')]!==_0x32ef('0x3f')){var _0xb4db74={};_0xb4db74[_0x1cebed[_0x32ef('0x2a')]]={'$like':'%'+_0x31dbc3['query'][_0x32ef('0x3d')]+'%'};return _0xb4db74;}})});}_0x1b668a=_[_0x32ef('0x3e')]({},_0x1b668a,_0x31dbc3[_0x32ef('0x40')]);var _0x1733e3={'where':_0x1b668a[_0x32ef('0x3a')]};return db[_0x32ef('0x41')][_0x32ef('0x1c')](_0x1733e3)['then'](function(_0x538758){_0x1a122d[_0x32ef('0x1c')]=_0x538758;if(_0x31dbc3[_0x32ef('0x32')][_0x32ef('0x42')]){_0x1b668a[_0x32ef('0x43')]=[{'all':!![]}];}return db['AnalyticDefaultReport'][_0x32ef('0x44')](_0x1b668a);})[_0x32ef('0x22')](function(_0x5d2f06){_0x1a122d[_0x32ef('0x45')]=_0x5d2f06;return _0x1a122d;})['then'](respondWithFilteredResult(_0x2ac686,_0x1b668a))[_0x32ef('0x46')](handleError(_0x2ac686,null));};exports[_0x32ef('0x47')]=function(_0x37a497,_0x3be46d){var _0x2c2b62={'raw':!![],'where':{'id':_0x37a497[_0x32ef('0x48')]['id']}},_0x2310ae={};_0x2310ae[_0x32ef('0x31')]=_[_0x32ef('0x49')](db[_0x32ef('0x41')]['rawAttributes']);_0x2310ae[_0x32ef('0x32')]=_['keys'](_0x37a497[_0x32ef('0x32')]);_0x2310ae[_0x32ef('0x3b')]=_[_0x32ef('0x33')](_0x2310ae['model'],_0x2310ae[_0x32ef('0x32')]);_0x2c2b62[_0x32ef('0x34')]=_[_0x32ef('0x33')](_0x2310ae[_0x32ef('0x31')],qs[_0x32ef('0x4a')](_0x37a497[_0x32ef('0x32')][_0x32ef('0x4a')]));_0x2c2b62['attributes']=_0x2c2b62['attributes'][_0x32ef('0x35')]?_0x2c2b62[_0x32ef('0x34')]:_0x2310ae[_0x32ef('0x31')];if(_0x37a497[_0x32ef('0x32')][_0x32ef('0x42')]){_0x2c2b62[_0x32ef('0x43')]=[{'all':!![]}];}_0x2c2b62=_[_0x32ef('0x3e')]({},_0x2c2b62,_0x37a497[_0x32ef('0x40')]);return db[_0x32ef('0x41')][_0x32ef('0x4b')](_0x2c2b62)[_0x32ef('0x22')](handleEntityNotFound(_0x3be46d,null))[_0x32ef('0x22')](respondWithResult(_0x3be46d,null))[_0x32ef('0x46')](handleError(_0x3be46d,null));};exports['create']=function(_0x420f00,_0x12fbd7){return db[_0x32ef('0x41')][_0x32ef('0x4c')](_0x420f00[_0x32ef('0x4d')],{})[_0x32ef('0x22')](function(_0x278696){var _0x1acded=_0x420f00[_0x32ef('0x4e')][_0x32ef('0x24')]({'plain':!![]});if(!_0x1acded)throw new Error(_0x32ef('0x4f'));if(_0x1acded[_0x32ef('0x50')]===_0x32ef('0x4e')){var _0x326445=_0x278696[_0x32ef('0x24')]({'plain':!![]});var _0x3fb4d8=_0x32ef('0x51');return db[_0x32ef('0x52')]['find']({'where':{'name':_0x3fb4d8,'userProfileId':_0x1acded['userProfileId']},'raw':!![]})[_0x32ef('0x22')](function(_0x259c32){if(_0x259c32&&_0x259c32[_0x32ef('0x53')]===0x0){return db[_0x32ef('0x26')][_0x32ef('0x4c')]({'name':_0x326445[_0x32ef('0x2a')],'resourceId':_0x326445['id'],'type':_0x32ef('0x25'),'sectionId':_0x259c32['id']},{})[_0x32ef('0x22')](function(){return _0x278696;});}else{return _0x278696;}})[_0x32ef('0x46')](function(_0x368bf1){logger[_0x32ef('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x368bf1);throw _0x368bf1;});}return _0x278696;})[_0x32ef('0x22')](respondWithResult(_0x12fbd7,0xc9))[_0x32ef('0x46')](handleError(_0x12fbd7,null));};exports[_0x32ef('0x54')]=function(_0x3fe01f,_0x38314a){if(_0x3fe01f[_0x32ef('0x4d')]['id']){delete _0x3fe01f['body']['id'];}return db[_0x32ef('0x41')][_0x32ef('0x4b')]({'where':{'id':_0x3fe01f[_0x32ef('0x48')]['id']}})['then'](handleEntityNotFound(_0x38314a,null))[_0x32ef('0x22')](saveUpdates(_0x3fe01f['body'],null))[_0x32ef('0x22')](respondWithResult(_0x38314a,null))[_0x32ef('0x46')](handleError(_0x38314a,null));};exports['destroy']=function(_0x206ad5,_0x59e5f9){return db[_0x32ef('0x41')][_0x32ef('0x4b')]({'where':{'id':_0x206ad5[_0x32ef('0x48')]['id']}})[_0x32ef('0x22')](handleEntityNotFound(_0x59e5f9,null))[_0x32ef('0x22')](removeEntity(_0x59e5f9,null))[_0x32ef('0x46')](handleError(_0x59e5f9,null));};exports[_0x32ef('0x55')]=function(_0x56260f,_0x56cc75){var _0xdfa103=0xa;var _0x52232a=['join',_0x32ef('0x56'),_0x32ef('0x57'),_0x32ef('0x58')];var _0x6aae59={'SUM':_0x32ef('0x59'),'COUNT':_0x32ef('0x5a'),'COUNT DISTINCT':_0x32ef('0x5b'),'MAX':_0x32ef('0x5c'),'MIN':_0x32ef('0x5d'),'AVG':_0x32ef('0x5e'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x32ef('0x5f')};var _0xbd059e={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x32ef('0x60'),'HOUR':_0x32ef('0x61'),'ROUND':_0x32ef('0x62'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x2ac877=function(_0x3c31d0){return!_[_0x32ef('0x63')](['IS\x20NULL','IS\x20NOT\x20NULL',_0x32ef('0x64'),'IS\x20NOT\x20EMPTY'],_0x3c31d0);};var _0x17f447=function(_0x5bb114){if(!_0x5bb114||!_0x5bb114['rules'][_0x32ef('0x35')]){return'';}for(var _0x208989='(',_0x10cb37=0x0;_0x10cb37<_0x5bb114['rules'][_0x32ef('0x35')];_0x10cb37+=0x1){_0x10cb37>0x0&&(_0x208989+='\x20'+_0x5bb114[_0x32ef('0x65')]+'\x20');_0x208989+=_0x5bb114[_0x32ef('0x66')][_0x10cb37]['group']?_0x17f447(_0x5bb114[_0x32ef('0x66')][_0x10cb37][_0x32ef('0x67')]):_0x5bb114['rules'][_0x10cb37]['field']+'\x20'+_0x5bb114[_0x32ef('0x66')][_0x10cb37][_0x32ef('0x68')]+(_0x2ac877(_0x5bb114[_0x32ef('0x66')][_0x10cb37][_0x32ef('0x68')])?'\x20'+_0x5bb114[_0x32ef('0x66')][_0x10cb37][_0x32ef('0x69')]:'');}return _0x208989+')';};var _0x4c89e8={'where':{'id':_0x56260f[_0x32ef('0x48')]['id']}},_0x285330,_0x63b65,_0x25b6d6,_0x36ed97,_0x21e930;_0x4c89e8=_[_0x32ef('0x3e')]({},_0x4c89e8,_0x56260f[_0x32ef('0x40')]);return db[_0x32ef('0x41')]['find'](_0x4c89e8)[_0x32ef('0x22')](function(_0x29ff58){if(_0x29ff58){_0x285330=_0x29ff58;return _0x29ff58[_0x32ef('0x6a')]();}return null;})[_0x32ef('0x22')](function(_0x79ae28){if(_0x79ae28){if(!_0x79ae28['length']){throw new db['Sequelize'][(_0x32ef('0x6b'))](_0x32ef('0x6c'),0x193);}_0x63b65=_0x79ae28;return db[_0x32ef('0x6d')][_0x32ef('0x44')]({'raw':!![]});}return null;})[_0x32ef('0x22')](function(_0x526fb1){if(_0x526fb1){_0x25b6d6=_[_0x32ef('0x6e')](_0x526fb1,'id');var _0x544045;var _0x216e2f=squel[_0x32ef('0x6f')]();_0x216e2f['from'](_0x285330['table']);for(var _0x2c9f7a=0x0;_0x2c9f7a<_0x63b65[_0x32ef('0x35')];_0x2c9f7a+=0x1){_0x544045=_0x63b65[_0x2c9f7a][_0x32ef('0x70')]?_0x25b6d6[_0x63b65[_0x2c9f7a]['MetricId']]['metric']:_0x63b65[_0x2c9f7a][_0x32ef('0x71')];_0x544045=_0x63b65[_0x2c9f7a][_0x32ef('0x72')]?_[_0x32ef('0x73')](_0x6aae59[_0x63b65[_0x2c9f7a][_0x32ef('0x72')]],'%s',_0x544045):_0x544045;_0x544045=_0x63b65[_0x2c9f7a]['format']?_[_0x32ef('0x73')](_0xbd059e[_0x63b65[_0x2c9f7a][_0x32ef('0x74')]],'%s',_0x544045):_0x544045;if(_0x63b65[_0x2c9f7a][_0x32ef('0x75')]){_0x216e2f[_0x32ef('0x67')](_0x544045);}_0x63b65[_0x2c9f7a][_0x32ef('0x76')]&&_0x216e2f[_0x32ef('0x38')](_0x544045,_0x63b65[_0x2c9f7a][_0x32ef('0x76')]===_0x32ef('0x77')?![]:!![]);_0x216e2f[_0x32ef('0x71')](_0x544045,_0x63b65[_0x2c9f7a][_0x32ef('0x78')]||_0x544045);}if(_0x285330[_0x32ef('0x79')]){_0x285330[_0x32ef('0x79')]=JSON['parse'](_0x285330['joins']);for(var _0x3a9c97=0x0;_0x3a9c97<_0x285330[_0x32ef('0x79')]['length'];_0x3a9c97+=0x1){if(_0x285330[_0x32ef('0x79')][_0x3a9c97]['type']&&_[_0x32ef('0x63')](_0x52232a,_0x285330[_0x32ef('0x79')][_0x3a9c97][_0x32ef('0x2f')])&&_0x285330['joins'][_0x3a9c97][_0x32ef('0x7a')]&&_0x285330['joins'][_0x3a9c97][_0x32ef('0x7b')]&&_0x285330[_0x32ef('0x79')][_0x3a9c97]['foreignKey']){_0x216e2f[_0x285330['joins'][_0x3a9c97][_0x32ef('0x2f')]](_0x285330['joins'][_0x3a9c97][_0x32ef('0x7b')],null,util['format'](_0x32ef('0x7c'),_0x285330[_0x32ef('0x7d')],_0x285330[_0x32ef('0x79')][_0x3a9c97]['parentKey'],_0x285330['joins'][_0x3a9c97]['foreignTable'],_0x285330[_0x32ef('0x79')][_0x3a9c97]['foreignKey']));}}}if(_0x285330[_0x32ef('0x7e')]){_0x285330[_0x32ef('0x7e')]=JSON[_0x32ef('0x7f')](_0x285330[_0x32ef('0x7e')]);_0x216e2f[_0x32ef('0x3a')](_0x17f447(_0x285330[_0x32ef('0x7e')]['group']));}_0x21e930=_0x216e2f[_0x32ef('0x80')]();_0x216e2f['limit'](_0xdfa103);_0x216e2f['offset'](0x0);logger[_0x32ef('0x81')]('Limited\x20Query:',_0x216e2f[_0x32ef('0x82')]());return dbH[_0x32ef('0x83')]['query'](_0x216e2f[_0x32ef('0x82')](),{'type':dbH[_0x32ef('0x83')][_0x32ef('0x84')][_0x32ef('0x85')]});}})[_0x32ef('0x22')](respondWithResult(_0x56cc75,null))[_0x32ef('0x46')](handleError(_0x56cc75,null));};function runReport(_0x4b5506,_0x51736f,_0x35b10d){var _0x5e0b55=_0x51736f[_0x32ef('0x2a')];var _0x266688=0xa;var _0x114d8e=[_0x32ef('0x86'),_0x32ef('0x56'),_0x32ef('0x57'),'cross_join'];var _0x3232ca={'SUM':_0x32ef('0x59'),'COUNT':_0x32ef('0x5a'),'COUNT DISTINCT':_0x32ef('0x5b'),'MAX':_0x32ef('0x5c'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0x32ef('0x87'),'GROUP_CONCAT ASC':_0x32ef('0x88'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x211fb1={'SEC_TO_TIME':_0x32ef('0x89'),'DATE':_0x32ef('0x60'),'HOUR':_0x32ef('0x61'),'ROUND':_0x32ef('0x62'),'UNIX_TIMESTAMP':_0x32ef('0x8a')};var _0xfb4845=function(_0x21067e){return!_[_0x32ef('0x63')](['IS\x20NULL',_0x32ef('0x8b'),_0x32ef('0x64'),'IS\x20NOT\x20EMPTY'],_0x21067e);};var _0x35653b=function(_0x5ea727){if(!_0x5ea727||!_0x5ea727[_0x32ef('0x66')]['length']){return'';}for(var _0x43f36e='(',_0x39300f=0x0;_0x39300f<_0x5ea727[_0x32ef('0x66')][_0x32ef('0x35')];_0x39300f+=0x1){_0x39300f>0x0&&(_0x43f36e+='\x20'+_0x5ea727['operator']+'\x20');_0x43f36e+=_0x5ea727[_0x32ef('0x66')][_0x39300f][_0x32ef('0x67')]?_0x35653b(_0x5ea727[_0x32ef('0x66')][_0x39300f]['group']):_0x5ea727['rules'][_0x39300f]['field']+'\x20'+_0x5ea727[_0x32ef('0x66')][_0x39300f][_0x32ef('0x68')]+(_0xfb4845(_0x5ea727[_0x32ef('0x66')][_0x39300f][_0x32ef('0x68')])?'\x20'+_0x5ea727[_0x32ef('0x66')][_0x39300f]['value']:'');}return _0x43f36e+')';};var _0x2678e3={'where':{'id':_0x4b5506['id']}},_0x5b3deb,_0x471de6,_0x7b0ea5,_0xc43e1,_0x4baa7a;_0x2678e3=_[_0x32ef('0x3e')]({},_0x2678e3,_0x35b10d);return db[_0x32ef('0x41')][_0x32ef('0x4b')](_0x2678e3)[_0x32ef('0x22')](function(_0x28bebb){if(_0x28bebb){_0x5b3deb=_0x28bebb;return _0x28bebb['getFields']();}return null;})[_0x32ef('0x22')](function(_0x484df0){if(_0x484df0){if(!_0x484df0[_0x32ef('0x35')]){throw new db[(_0x32ef('0x8c'))]['ValidationErrorItem']('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x471de6=_0x484df0;return db[_0x32ef('0x6d')][_0x32ef('0x44')]({'raw':!![]});}return null;})[_0x32ef('0x22')](function(_0x3b9896){if(_0x3b9896){_0x7b0ea5=_['keyBy'](_0x3b9896,'id');var _0x356fd4;var _0x51ca6e=squel['select']();_0x51ca6e[_0x32ef('0x8d')](_0x5b3deb['table']);for(var _0x2237cf=0x0;_0x2237cf<_0x471de6[_0x32ef('0x35')];_0x2237cf+=0x1){_0x356fd4=_0x471de6[_0x2237cf][_0x32ef('0x70')]?_0x7b0ea5[_0x471de6[_0x2237cf]['MetricId']]['metric']:_0x471de6[_0x2237cf][_0x32ef('0x71')];_0x356fd4=_0x471de6[_0x2237cf][_0x32ef('0x72')]?_[_0x32ef('0x73')](_0x3232ca[_0x471de6[_0x2237cf][_0x32ef('0x72')]],'%s',_0x356fd4):_0x356fd4;_0x356fd4=_0x471de6[_0x2237cf][_0x32ef('0x74')]?_[_0x32ef('0x73')](_0x211fb1[_0x471de6[_0x2237cf][_0x32ef('0x74')]],'%s',_0x356fd4):_0x356fd4;if(_0x471de6[_0x2237cf]['groupBy']){_0x51ca6e[_0x32ef('0x67')](_0x356fd4);}_0x471de6[_0x2237cf][_0x32ef('0x76')]&&_0x51ca6e[_0x32ef('0x38')](_0x356fd4,_0x471de6[_0x2237cf][_0x32ef('0x76')]==='DESC'?![]:!![]);_0x51ca6e['field'](_0x356fd4,_0x471de6[_0x2237cf][_0x32ef('0x78')]||_0x356fd4);}if(_0x5b3deb['joins']){_0x5b3deb[_0x32ef('0x79')]=JSON[_0x32ef('0x7f')](_0x5b3deb['joins']);for(var _0x5c7594=0x0;_0x5c7594<_0x5b3deb['joins'][_0x32ef('0x35')];_0x5c7594+=0x1){if(_0x5b3deb[_0x32ef('0x79')][_0x5c7594][_0x32ef('0x2f')]&&_[_0x32ef('0x63')](_0x114d8e,_0x5b3deb['joins'][_0x5c7594][_0x32ef('0x2f')])&&_0x5b3deb[_0x32ef('0x79')][_0x5c7594][_0x32ef('0x7a')]&&_0x5b3deb['joins'][_0x5c7594][_0x32ef('0x7b')]&&_0x5b3deb['joins'][_0x5c7594][_0x32ef('0x8e')]){_0x51ca6e[_0x5b3deb[_0x32ef('0x79')][_0x5c7594]['type']](_0x5b3deb['joins'][_0x5c7594][_0x32ef('0x7b')],null,util[_0x32ef('0x74')](_0x32ef('0x7c'),_0x5b3deb[_0x32ef('0x7d')],_0x5b3deb[_0x32ef('0x79')][_0x5c7594][_0x32ef('0x7a')],_0x5b3deb[_0x32ef('0x79')][_0x5c7594][_0x32ef('0x7b')],_0x5b3deb[_0x32ef('0x79')][_0x5c7594]['foreignKey']));}}}if(_0x5b3deb[_0x32ef('0x7e')]){_0x5b3deb['conditions']=JSON[_0x32ef('0x7f')](_0x5b3deb[_0x32ef('0x7e')]);_0x51ca6e[_0x32ef('0x3a')](_0x35653b(_0x5b3deb[_0x32ef('0x7e')][_0x32ef('0x67')]));}_0x4baa7a=_0x51ca6e['clone']();_0x51ca6e[_0x32ef('0x1d')](_0x266688);_0x51ca6e[_0x32ef('0x1a')](0x0);return;}})[_0x32ef('0x22')](function(){if(_0x51736f[_0x32ef('0x8f')]===_0x32ef('0x90')){return null;}var _0x1cfdd8=_[_0x32ef('0x3e')](_0x51736f,{'name':_0x51736f[_0x32ef('0x91')]||_0x51736f[_0x32ef('0x2a')]||_0x5b3deb['name'],'basename':_0x5e0b55,'savename':util['format']('%s-%s.%s',_0x51736f[_0x32ef('0x2a')]||_0x5b3deb[_0x32ef('0x2a')],require('randomstring')[_0x32ef('0x92')](0x4),_0x51736f['output']||_0x32ef('0x93')),'reportId':_0x5b3deb['id'],'reportType':'default'});return db['AnalyticExtractedReport'][_0x32ef('0x4c')](_0x1cfdd8,{'raw':!![]});})[_0x32ef('0x22')](function(_0x118d2e){if(_0x5b3deb[_0x32ef('0x7d')]===_0x32ef('0x94')){_0x4baa7a['where'](_0x5b3deb[_0x32ef('0x7d')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x51736f[_0x32ef('0x95')],_0x51736f['endDate']);}else{_0x4baa7a['where'](_0x5b3deb['table']+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x51736f['startDate'],_0x51736f[_0x32ef('0x96')]);}if(_0x118d2e){logger[_0x32ef('0x97')]('Run\x20Query:',_0x4baa7a[_0x32ef('0x82')]());require(_0x32ef('0x98'))[_0x32ef('0x99')](path[_0x32ef('0x86')](__dirname,_0x32ef('0x9a'),_0x118d2e[_0x32ef('0x8f')]),[_0x118d2e['id'],_0x4baa7a['toString'](),path[_0x32ef('0x86')](__dirname,'../../files/reports',_0x118d2e[_0x32ef('0x9b')]),_0x5e0b55]);return _0x118d2e;}else{var _0x1be713=squel['select']();_0x1be713[_0x32ef('0x8d')]('('+_0x4baa7a['toString']()+')',_0x32ef('0x9c'));_0x1be713[_0x32ef('0x71')](_0x32ef('0x9d'),_0x32ef('0x1c'));_0x4baa7a['limit'](_0x51736f[_0x32ef('0x1d')]||_0x266688);_0x4baa7a[_0x32ef('0x1a')](_0x51736f[_0x32ef('0x1a')]||0x0);return dbH[_0x32ef('0x83')]['query'](_0x1be713[_0x32ef('0x82')](),{'type':dbH['sequelize'][_0x32ef('0x84')][_0x32ef('0x85')]})[_0x32ef('0x22')](function(_0x28ef17){if(!_0x28ef17[_0x32ef('0x35')]){_0xc43e1=0x0;}else{_0xc43e1=_0x28ef17[0x0][_0x32ef('0x1c')]||0x0;}return dbH['sequelize'][_0x32ef('0x32')](_0x4baa7a['toString'](),{'type':dbH['sequelize'][_0x32ef('0x84')][_0x32ef('0x85')]});})[_0x32ef('0x22')](function(_0x3956e7){return{'rows':_0x3956e7||[],'count':_0xc43e1};});}});}exports['run']=function(_0x8d3b24,_0x642716){return runReport(_0x8d3b24[_0x32ef('0x48')],_0x8d3b24[_0x32ef('0x32')],_0x8d3b24['options'])['then'](respondWithResult(_0x642716,null))['catch'](handleError(_0x642716,null));};exports[_0x32ef('0x9e')]=runReport;exports[_0x32ef('0x32')]=function(_0x4454f3,_0xc92dcc){var _0x3d18b9=0xa;var _0x9233cb=[_0x32ef('0x86'),_0x32ef('0x56'),_0x32ef('0x57'),_0x32ef('0x58')];var _0xa76912={'SUM':'SUM(%s)','COUNT':_0x32ef('0x5a'),'COUNT DISTINCT':_0x32ef('0x5b'),'MAX':_0x32ef('0x5c'),'MIN':_0x32ef('0x5d'),'AVG':_0x32ef('0x5e'),'GROUP_CONCAT':_0x32ef('0x87'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x32ef('0x5f')};var _0x1526a1={'SEC_TO_TIME':_0x32ef('0x89'),'DATE':_0x32ef('0x60'),'HOUR':_0x32ef('0x61'),'ROUND':_0x32ef('0x62'),'UNIX_TIMESTAMP':_0x32ef('0x8a')};var _0x2d4d2f=function(_0x292488){return!_[_0x32ef('0x63')]([_0x32ef('0x9f'),_0x32ef('0x8b'),_0x32ef('0x64'),_0x32ef('0xa0')],_0x292488);};var _0x50b674=function(_0x379d40){if(!_0x379d40||!_0x379d40[_0x32ef('0x66')][_0x32ef('0x35')]){return'';}for(var _0x4b7a4d='(',_0x16525b=0x0;_0x16525b<_0x379d40['rules'][_0x32ef('0x35')];_0x16525b+=0x1){_0x16525b>0x0&&(_0x4b7a4d+='\x20'+_0x379d40[_0x32ef('0x65')]+'\x20');_0x4b7a4d+=_0x379d40[_0x32ef('0x66')][_0x16525b]['group']?_0x50b674(_0x379d40[_0x32ef('0x66')][_0x16525b]['group']):_0x379d40[_0x32ef('0x66')][_0x16525b][_0x32ef('0x71')]+'\x20'+_0x379d40['rules'][_0x16525b][_0x32ef('0x68')]+(_0x2d4d2f(_0x379d40[_0x32ef('0x66')][_0x16525b][_0x32ef('0x68')])?'\x20'+_0x379d40[_0x32ef('0x66')][_0x16525b][_0x32ef('0x69')]:'');}return _0x4b7a4d+')';};var _0x264075={'where':{'id':_0x4454f3[_0x32ef('0x48')]['id']}},_0x3798d1,_0x4befa9,_0x493ae9,_0x143d39,_0x497948;_0x264075=_[_0x32ef('0x3e')]({},_0x264075,_0x4454f3['options']);return db[_0x32ef('0x41')][_0x32ef('0x4b')](_0x264075)['then'](function(_0x1200c9){if(_0x1200c9){_0x3798d1=_0x1200c9;return _0x1200c9[_0x32ef('0x6a')]();}return null;})[_0x32ef('0x22')](function(_0xa5f787){if(_0xa5f787){if(!_0xa5f787[_0x32ef('0x35')]){throw new db['Sequelize'][(_0x32ef('0x6b'))](_0x32ef('0x6c'),0x193);}_0x4befa9=_0xa5f787;return db['AnalyticMetric'][_0x32ef('0x44')]({'raw':!![]});}return null;})[_0x32ef('0x22')](function(_0x55ad11){if(_0x55ad11){_0x493ae9=_[_0x32ef('0x6e')](_0x55ad11,'id');var _0x2971a8;var _0x522c22=squel[_0x32ef('0x6f')]();_0x522c22[_0x32ef('0x8d')](_0x3798d1['table']);for(var _0xb41a01=0x0;_0xb41a01<_0x4befa9[_0x32ef('0x35')];_0xb41a01+=0x1){_0x2971a8=_0x4befa9[_0xb41a01][_0x32ef('0x70')]?_0x493ae9[_0x4befa9[_0xb41a01][_0x32ef('0x70')]][_0x32ef('0xa1')]:_0x4befa9[_0xb41a01][_0x32ef('0x71')];_0x2971a8=_0x4befa9[_0xb41a01][_0x32ef('0x72')]?_['replace'](_0xa76912[_0x4befa9[_0xb41a01]['function']],'%s',_0x2971a8):_0x2971a8;_0x2971a8=_0x4befa9[_0xb41a01][_0x32ef('0x74')]?_[_0x32ef('0x73')](_0x1526a1[_0x4befa9[_0xb41a01][_0x32ef('0x74')]],'%s',_0x2971a8):_0x2971a8;if(_0x4befa9[_0xb41a01]['groupBy']){_0x522c22[_0x32ef('0x67')](_0x2971a8);}_0x4befa9[_0xb41a01][_0x32ef('0x76')]&&_0x522c22['order'](_0x2971a8,_0x4befa9[_0xb41a01][_0x32ef('0x76')]===_0x32ef('0x77')?![]:!![]);_0x522c22['field'](_0x2971a8,_0x4befa9[_0xb41a01]['alias']||_0x2971a8);}if(_0x3798d1[_0x32ef('0x79')]){_0x3798d1[_0x32ef('0x79')]=JSON[_0x32ef('0x7f')](_0x3798d1['joins']);for(var _0x5f4eab=0x0;_0x5f4eab<_0x3798d1['joins'][_0x32ef('0x35')];_0x5f4eab+=0x1){if(_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x2f')]&&_['includes'](_0x9233cb,_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x2f')])&&_0x3798d1[_0x32ef('0x79')][_0x5f4eab]['parentKey']&&_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x7b')]&&_0x3798d1['joins'][_0x5f4eab]['foreignKey']){_0x522c22[_0x3798d1[_0x32ef('0x79')][_0x5f4eab]['type']](_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x7b')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x3798d1[_0x32ef('0x7d')],_0x3798d1['joins'][_0x5f4eab][_0x32ef('0x7a')],_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x7b')],_0x3798d1[_0x32ef('0x79')][_0x5f4eab][_0x32ef('0x8e')]));}}}if(_0x3798d1[_0x32ef('0x7e')]){_0x3798d1[_0x32ef('0x7e')]=JSON[_0x32ef('0x7f')](_0x3798d1[_0x32ef('0x7e')]);_0x522c22[_0x32ef('0x3a')](_0x50b674(_0x3798d1['conditions']['group']));}_0x497948=_0x522c22[_0x32ef('0x80')]();_0x522c22[_0x32ef('0x1d')](_0x3d18b9);_0x522c22[_0x32ef('0x1a')](0x0);logger[_0x32ef('0x81')](_0x32ef('0xa2'),_0x522c22[_0x32ef('0x82')]());return dbH[_0x32ef('0x83')][_0x32ef('0x32')](_0x522c22[_0x32ef('0x82')](),{'type':dbH[_0x32ef('0x83')]['QueryTypes'][_0x32ef('0x85')]});}})[_0x32ef('0x22')](function(){return{'sql':_0x497948[_0x32ef('0x82')]()};})[_0x32ef('0x22')](respondWithResult(_0xc92dcc,null))[_0x32ef('0x46')](handleError(_0xc92dcc,null));}; \ No newline at end of file diff --git a/server/api/analyticDefaultReport/analyticDefaultReport.model.js b/server/api/analyticDefaultReport/analyticDefaultReport.model.js new file mode 100644 index 0000000..083f60e --- /dev/null +++ b/server/api/analyticDefaultReport/analyticDefaultReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x483d=['rimraf','../../config/environment','./analyticDefaultReport.attributes','define','AnalyticDefaultReport','analytics_default_reports','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path'];(function(_0x5e92a5,_0x450ab4){var _0x48918a=function(_0x1a553f){while(--_0x1a553f){_0x5e92a5['push'](_0x5e92a5['shift']());}};_0x48918a(++_0x450ab4);}(_0x483d,0x1c6));var _0xd483=function(_0x1372fd,_0x24da45){_0x1372fd=_0x1372fd-0x0;var _0x57d743=_0x483d[_0x1372fd];return _0x57d743;};'use strict';var _=require(_0xd483('0x0'));var util=require(_0xd483('0x1'));var logger=require(_0xd483('0x2'))(_0xd483('0x3'));var moment=require(_0xd483('0x4'));var BPromise=require(_0xd483('0x5'));var rp=require(_0xd483('0x6'));var fs=require('fs');var path=require(_0xd483('0x7'));var rimraf=require(_0xd483('0x8'));var config=require(_0xd483('0x9'));var attributes=require(_0xd483('0xa'));module['exports']=function(_0x1198cd,_0x2d6535){return _0x1198cd[_0xd483('0xb')](_0xd483('0xc'),attributes,{'tableName':_0xd483('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticDefaultReport/analyticDefaultReport.rpc.js b/server/api/analyticDefaultReport/analyticDefaultReport.rpc.js new file mode 100644 index 0000000..495a15c --- /dev/null +++ b/server/api/analyticDefaultReport/analyticDefaultReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc424=['stringify','error','message','result','catch','lodash','moment','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','AnalyticDefaultReport,\x20%s,\x20%s','request\x20sent','debug','AnalyticDefaultReport,\x20%s,\x20%s,\x20%s'];(function(_0x166445,_0xed011){var _0x590e17=function(_0x4d053b){while(--_0x4d053b){_0x166445['push'](_0x166445['shift']());}};_0x590e17(++_0xed011);}(_0xc424,0x6e));var _0x4c42=function(_0x3fef06,_0x8c9962){_0x3fef06=_0x3fef06-0x0;var _0x5d3b49=_0xc424[_0x3fef06];return _0x5d3b49;};'use strict';var _=require(_0x4c42('0x0'));var util=require('util');var moment=require(_0x4c42('0x1'));var BPromise=require('bluebird');var rs=require(_0x4c42('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4c42('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x4c42('0x4'))('rpc');var config=require(_0x4c42('0x5'));var jayson=require(_0x4c42('0x6'));var client=jayson[_0x4c42('0x7')][_0x4c42('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1203bf,_0x48435f,_0x518199){return new BPromise(function(_0x156044,_0x3eaec4){return client[_0x4c42('0x9')](_0x1203bf,_0x518199)[_0x4c42('0xa')](function(_0x35fbe2){logger[_0x4c42('0xb')](_0x4c42('0xc'),_0x48435f,_0x4c42('0xd'));logger[_0x4c42('0xe')](_0x4c42('0xf'),_0x48435f,_0x4c42('0xd'),JSON[_0x4c42('0x10')](_0x35fbe2));if(_0x35fbe2[_0x4c42('0x11')]){if(_0x35fbe2[_0x4c42('0x11')]['code']===0x1f4){logger['error'](_0x4c42('0xc'),_0x48435f,_0x35fbe2[_0x4c42('0x11')][_0x4c42('0x12')]);return _0x3eaec4(_0x35fbe2[_0x4c42('0x11')][_0x4c42('0x12')]);}logger[_0x4c42('0x11')](_0x4c42('0xc'),_0x48435f,_0x35fbe2['error'][_0x4c42('0x12')]);return _0x156044(_0x35fbe2[_0x4c42('0x11')][_0x4c42('0x12')]);}else{logger['info'](_0x4c42('0xc'),_0x48435f,'request\x20sent');_0x156044(_0x35fbe2[_0x4c42('0x13')][_0x4c42('0x12')]);}})[_0x4c42('0x14')](function(_0x13fe7c){logger[_0x4c42('0x11')]('AnalyticDefaultReport,\x20%s,\x20%s',_0x48435f,_0x13fe7c);_0x3eaec4(_0x13fe7c);});});} \ No newline at end of file diff --git a/server/api/analyticDefaultReport/index.js b/server/api/analyticDefaultReport/index.js new file mode 100644 index 0000000..9a05819 --- /dev/null +++ b/server/api/analyticDefaultReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5173=['preview','/:id/run','run','query','post','create','put','update','exports','multer','util','path','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./analyticDefaultReport.controller','get','isAuthenticated','/:id','show'];(function(_0x254723,_0x101579){var _0x2104b8=function(_0x12314a){while(--_0x12314a){_0x254723['push'](_0x254723['shift']());}};_0x2104b8(++_0x101579);}(_0x5173,0xd8));var _0x3517=function(_0x157255,_0x38090f){_0x157255=_0x157255-0x0;var _0xb59ae6=_0x5173[_0x157255];return _0xb59ae6;};'use strict';var multer=require(_0x3517('0x0'));var util=require(_0x3517('0x1'));var path=require(_0x3517('0x2'));var timeout=require(_0x3517('0x3'));var express=require(_0x3517('0x4'));var router=express['Router']();var fs_extra=require(_0x3517('0x5'));var auth=require(_0x3517('0x6'));var interaction=require(_0x3517('0x7'));var config=require(_0x3517('0x8'));var controller=require(_0x3517('0x9'));router[_0x3517('0xa')]('/',auth[_0x3517('0xb')](),controller['index']);router[_0x3517('0xa')](_0x3517('0xc'),auth['isAuthenticated'](),controller[_0x3517('0xd')]);router[_0x3517('0xa')]('/:id/preview',auth['isAuthenticated'](),controller[_0x3517('0xe')]);router['get'](_0x3517('0xf'),auth[_0x3517('0xb')](),controller[_0x3517('0x10')]);router[_0x3517('0xa')]('/:id/query',auth['isAuthenticated'](),controller[_0x3517('0x11')]);router[_0x3517('0x12')]('/',auth[_0x3517('0xb')](),controller[_0x3517('0x13')]);router[_0x3517('0x14')](_0x3517('0xc'),auth['isAuthenticated'](),controller[_0x3517('0x15')]);router['delete']('/:id',auth[_0x3517('0xb')](),controller['destroy']);module[_0x3517('0x16')]=router; \ No newline at end of file diff --git a/server/api/analyticExtractedReport/analyticExtractedReport.attributes.js b/server/api/analyticExtractedReport/analyticExtractedReport.attributes.js new file mode 100644 index 0000000..082435c --- /dev/null +++ b/server/api/analyticExtractedReport/analyticExtractedReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c28=['STRING','csv','xlsx','DATE','ENUM','UNSIGNED','sequelize','moment'];(function(_0x35ccab,_0x170c29){var _0x42a2c=function(_0x3ffd2d){while(--_0x3ffd2d){_0x35ccab['push'](_0x35ccab['shift']());}};_0x42a2c(++_0x170c29);}(_0x9c28,0xb6));var _0x89c2=function(_0x19020c,_0x1c1d9c){_0x19020c=_0x19020c-0x0;var _0x15d6ea=_0x9c28[_0x19020c];return _0x15d6ea;};'use strict';var Sequelize=require(_0x89c2('0x0'));var moment=require(_0x89c2('0x1'));module['exports']={'name':{'type':Sequelize[_0x89c2('0x2')],'allowNull':![]},'basename':{'type':Sequelize[_0x89c2('0x2')],'allowNull':![]},'output':{'type':Sequelize['ENUM'](_0x89c2('0x3'),'pdf',_0x89c2('0x4')),'allowNull':![],'defaultValue':_0x89c2('0x3')},'savename':{'type':Sequelize[_0x89c2('0x2')],'allowNull':![]},'startDate':{'type':Sequelize[_0x89c2('0x5')]},'endDate':{'type':Sequelize['DATE']},'status':{'type':Sequelize['STRING'],'defaultValue':'Loading'},'type':{'type':Sequelize[_0x89c2('0x6')]('manual','scheduled'),'allowNull':![],'defaultValue':'manual'},'reportId':{'type':Sequelize['INTEGER'](0xb)[_0x89c2('0x7')]},'reportType':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/analyticExtractedReport/analyticExtractedReport.controller.js b/server/api/analyticExtractedReport/analyticExtractedReport.controller.js new file mode 100644 index 0000000..1f9d6f8 --- /dev/null +++ b/server/api/analyticExtractedReport/analyticExtractedReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x24d2=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','update','then','get','ExtractedReports','UserProfileResource','destroy','error','stack','name','send','map','AnalyticExtractedReport','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','download','basename','savename','output','existsSync','join','server/files/reports','ValidationError','exists','format','%s.%s','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','querystring','papaparse'];(function(_0x4521cc,_0xd02d95){var _0x4c3bfd=function(_0x400860){while(--_0x400860){_0x4521cc['push'](_0x4521cc['shift']());}};_0x4c3bfd(++_0xd02d95);}(_0x24d2,0xaf));var _0x224d=function(_0x5d0fb2,_0x43e289){_0x5d0fb2=_0x5d0fb2-0x0;var _0x3d909a=_0x24d2[_0x5d0fb2];return _0x3d909a;};'use strict';var emlformat=require(_0x224d('0x0'));var rimraf=require(_0x224d('0x1'));var zipdir=require(_0x224d('0x2'));var jsonpatch=require(_0x224d('0x3'));var rp=require('request-promise');var moment=require(_0x224d('0x4'));var BPromise=require(_0x224d('0x5'));var Mustache=require('mustache');var util=require(_0x224d('0x6'));var path=require(_0x224d('0x7'));var sox=require(_0x224d('0x8'));var csv=require(_0x224d('0x9'));var ejs=require(_0x224d('0xa'));var fs=require('fs');var fs_extra=require(_0x224d('0xb'));var _=require('lodash');var squel=require(_0x224d('0xc'));var crypto=require(_0x224d('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x224d('0xe'));var toCsv=require('to-csv');var querystring=require(_0x224d('0xf'));var Papa=require(_0x224d('0x10'));var Redis=require(_0x224d('0x11'));var authService=require(_0x224d('0x12'));var qs=require(_0x224d('0x13'));var as=require(_0x224d('0x14'));var hardwareService=require(_0x224d('0x15'));var logger=require(_0x224d('0x16'))('api');var utils=require(_0x224d('0x17'));var config=require(_0x224d('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x224d('0x19'))['db'];function respondWithStatusCode(_0x2e6295,_0x28a2da){_0x28a2da=_0x28a2da||0xcc;return function(_0x46fbc1){if(_0x46fbc1){return _0x2e6295[_0x224d('0x1a')](_0x28a2da);}return _0x2e6295[_0x224d('0x1b')](_0x28a2da)[_0x224d('0x1c')]();};}function respondWithResult(_0x49c64a,_0xb480ee){_0xb480ee=_0xb480ee||0xc8;return function(_0x7b2bb9){if(_0x7b2bb9){return _0x49c64a[_0x224d('0x1b')](_0xb480ee)[_0x224d('0x1d')](_0x7b2bb9);}};}function respondWithFilteredResult(_0x42e2e7,_0x271634){return function(_0x128024){if(_0x128024){var _0x192108=typeof _0x271634['offset']===_0x224d('0x1e')&&typeof _0x271634[_0x224d('0x1f')]===_0x224d('0x1e');var _0x1092d3=_0x128024[_0x224d('0x20')];var _0xc1f59d=_0x192108?0x0:_0x271634['offset'];var _0x32ef78=_0x192108?_0x128024[_0x224d('0x20')]:_0x271634[_0x224d('0x21')]+_0x271634['limit'];var _0xe38320;if(_0x32ef78>=_0x1092d3){_0x32ef78=_0x1092d3;_0xe38320=0xc8;}else{_0xe38320=0xce;}_0x42e2e7['status'](_0xe38320);return _0x42e2e7[_0x224d('0x22')](_0x224d('0x23'),_0xc1f59d+'-'+_0x32ef78+'/'+_0x1092d3)['json'](_0x128024);}return null;};}function patchUpdates(_0x57978a){return function(_0x48e4ba){try{jsonpatch[_0x224d('0x24')](_0x48e4ba,_0x57978a,!![]);}catch(_0x1b5530){return BPromise[_0x224d('0x25')](_0x1b5530);}return _0x48e4ba['save']();};}function saveUpdates(_0x5bf783,_0x34e268){return function(_0x4d61a8){if(_0x4d61a8){return _0x4d61a8[_0x224d('0x26')](_0x5bf783)[_0x224d('0x27')](function(_0xd8597d){return _0xd8597d;});}return null;};}function removeEntity(_0x11aa60,_0x440c26){return function(_0x28853b){if(_0x28853b){return _0x28853b['destroy']()['then'](function(){var _0x2743cd=_0x28853b[_0x224d('0x28')]({'plain':!![]});var _0x4434d0=_0x224d('0x29');return db[_0x224d('0x2a')][_0x224d('0x2b')]({'where':{'type':_0x4434d0,'resourceId':_0x2743cd['id']}})[_0x224d('0x27')](function(){return _0x28853b;});})[_0x224d('0x27')](function(){_0x11aa60[_0x224d('0x1b')](0xcc)[_0x224d('0x1c')]();});}};}function handleEntityNotFound(_0x5d8db1,_0x53e62d){return function(_0x3f13ef){if(!_0x3f13ef){_0x5d8db1[_0x224d('0x1a')](0x194);}return _0x3f13ef;};}function handleError(_0x454e56,_0x1f209e){_0x1f209e=_0x1f209e||0x1f4;return function(_0x1925e3){logger[_0x224d('0x2c')](_0x1925e3[_0x224d('0x2d')]);if(_0x1925e3[_0x224d('0x2e')]){delete _0x1925e3[_0x224d('0x2e')];}_0x454e56[_0x224d('0x1b')](_0x1f209e)[_0x224d('0x2f')](_0x1925e3);};}exports['index']=function(_0x4c7e41,_0x25bd1c){var _0x1e9f6c={},_0x4c5900={},_0x40cb06={'count':0x0,'rows':[]};var _0x1e022a=_[_0x224d('0x30')](db[_0x224d('0x31')][_0x224d('0x32')],function(_0x14efeb){return{'name':_0x14efeb[_0x224d('0x33')],'type':_0x14efeb['type'][_0x224d('0x34')]};});_0x4c5900[_0x224d('0x35')]=_[_0x224d('0x30')](_0x1e022a,_0x224d('0x2e'));_0x4c5900[_0x224d('0x36')]=_[_0x224d('0x37')](_0x4c7e41[_0x224d('0x36')]);_0x4c5900[_0x224d('0x38')]=_[_0x224d('0x39')](_0x4c5900['model'],_0x4c5900[_0x224d('0x36')]);_0x1e9f6c[_0x224d('0x3a')]=_['intersection'](_0x4c5900[_0x224d('0x35')],qs[_0x224d('0x3b')](_0x4c7e41[_0x224d('0x36')][_0x224d('0x3b')]));_0x1e9f6c[_0x224d('0x3a')]=_0x1e9f6c['attributes'][_0x224d('0x3c')]?_0x1e9f6c[_0x224d('0x3a')]:_0x4c5900[_0x224d('0x35')];if(!_0x4c7e41[_0x224d('0x36')][_0x224d('0x3d')](_0x224d('0x3e'))){_0x1e9f6c[_0x224d('0x1f')]=qs[_0x224d('0x1f')](_0x4c7e41['query'][_0x224d('0x1f')]);_0x1e9f6c[_0x224d('0x21')]=qs['offset'](_0x4c7e41[_0x224d('0x36')][_0x224d('0x21')]);}_0x1e9f6c[_0x224d('0x3f')]=qs[_0x224d('0x40')](_0x4c7e41[_0x224d('0x36')][_0x224d('0x40')]);_0x1e9f6c['where']=qs[_0x224d('0x38')](_[_0x224d('0x41')](_0x4c7e41[_0x224d('0x36')],_0x4c5900[_0x224d('0x38')]),_0x1e022a);if(_0x4c7e41[_0x224d('0x36')][_0x224d('0x42')]){_0x1e9f6c[_0x224d('0x43')]=_[_0x224d('0x44')](_0x1e9f6c['where'],{'$or':_[_0x224d('0x30')](_0x1e022a,function(_0x214445){if(_0x214445['type']!==_0x224d('0x45')){var _0x51334f={};_0x51334f[_0x214445['name']]={'$like':'%'+_0x4c7e41[_0x224d('0x36')][_0x224d('0x42')]+'%'};return _0x51334f;}})});}_0x1e9f6c=_['merge']({},_0x1e9f6c,_0x4c7e41[_0x224d('0x46')]);var _0x11fede={'where':_0x1e9f6c['where']};return db[_0x224d('0x31')][_0x224d('0x20')](_0x11fede)[_0x224d('0x27')](function(_0x42ab56){_0x40cb06[_0x224d('0x20')]=_0x42ab56;if(_0x4c7e41[_0x224d('0x36')][_0x224d('0x47')]){_0x1e9f6c[_0x224d('0x48')]=[{'all':!![]}];}return db[_0x224d('0x31')][_0x224d('0x49')](_0x1e9f6c);})[_0x224d('0x27')](function(_0x193c2c){_0x40cb06[_0x224d('0x4a')]=_0x193c2c;return _0x40cb06;})['then'](respondWithFilteredResult(_0x25bd1c,_0x1e9f6c))['catch'](handleError(_0x25bd1c,null));};exports[_0x224d('0x4b')]=function(_0x48b40a,_0x4953ac){var _0x4150ca={'raw':!![],'where':{'id':_0x48b40a[_0x224d('0x4c')]['id']}},_0x32f330={};_0x32f330[_0x224d('0x35')]=_[_0x224d('0x37')](db[_0x224d('0x31')][_0x224d('0x32')]);_0x32f330[_0x224d('0x36')]=_[_0x224d('0x37')](_0x48b40a[_0x224d('0x36')]);_0x32f330['filters']=_[_0x224d('0x39')](_0x32f330[_0x224d('0x35')],_0x32f330[_0x224d('0x36')]);_0x4150ca[_0x224d('0x3a')]=_[_0x224d('0x39')](_0x32f330[_0x224d('0x35')],qs[_0x224d('0x3b')](_0x48b40a[_0x224d('0x36')]['fields']));_0x4150ca['attributes']=_0x4150ca[_0x224d('0x3a')][_0x224d('0x3c')]?_0x4150ca['attributes']:_0x32f330[_0x224d('0x35')];if(_0x48b40a[_0x224d('0x36')][_0x224d('0x47')]){_0x4150ca['include']=[{'all':!![]}];}_0x4150ca=_[_0x224d('0x44')]({},_0x4150ca,_0x48b40a['options']);return db[_0x224d('0x31')][_0x224d('0x4d')](_0x4150ca)[_0x224d('0x27')](handleEntityNotFound(_0x4953ac,null))[_0x224d('0x27')](respondWithResult(_0x4953ac,null))[_0x224d('0x4e')](handleError(_0x4953ac,null));};exports[_0x224d('0x4f')]=function(_0x1e834c,_0x4bdbc4){return db[_0x224d('0x31')]['create'](_0x1e834c[_0x224d('0x50')],{})[_0x224d('0x27')](function(_0x353171){var _0x56db02=_0x1e834c[_0x224d('0x51')][_0x224d('0x28')]({'plain':!![]});if(!_0x56db02)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x56db02['role']===_0x224d('0x51')){var _0x2c0cf9=_0x353171[_0x224d('0x28')]({'plain':!![]});var _0x26cb60=_0x224d('0x29');return db['UserProfileSection'][_0x224d('0x4d')]({'where':{'name':_0x26cb60,'userProfileId':_0x56db02[_0x224d('0x52')]},'raw':!![]})[_0x224d('0x27')](function(_0xc7acfc){if(_0xc7acfc&&_0xc7acfc[_0x224d('0x53')]===0x0){return db[_0x224d('0x2a')][_0x224d('0x4f')]({'name':_0x2c0cf9[_0x224d('0x2e')],'resourceId':_0x2c0cf9['id'],'type':_0xc7acfc[_0x224d('0x2e')],'sectionId':_0xc7acfc['id']},{})[_0x224d('0x27')](function(){return _0x353171;});}else{return _0x353171;}})[_0x224d('0x4e')](function(_0x47086e){logger[_0x224d('0x2c')](_0x224d('0x54'),_0x47086e);throw _0x47086e;});}return _0x353171;})['then'](respondWithResult(_0x4bdbc4,0xc9))[_0x224d('0x4e')](handleError(_0x4bdbc4,null));};exports[_0x224d('0x26')]=function(_0x2b09fc,_0x2b7047){if(_0x2b09fc[_0x224d('0x50')]['id']){delete _0x2b09fc[_0x224d('0x50')]['id'];}return db['AnalyticExtractedReport'][_0x224d('0x4d')]({'where':{'id':_0x2b09fc[_0x224d('0x4c')]['id']}})[_0x224d('0x27')](handleEntityNotFound(_0x2b7047,null))[_0x224d('0x27')](saveUpdates(_0x2b09fc[_0x224d('0x50')],null))[_0x224d('0x27')](respondWithResult(_0x2b7047,null))[_0x224d('0x4e')](handleError(_0x2b7047,null));};exports['destroy']=function(_0x400027,_0xe1db5f){return db[_0x224d('0x31')][_0x224d('0x4d')]({'where':{'id':_0x400027[_0x224d('0x4c')]['id']}})[_0x224d('0x27')](handleEntityNotFound(_0xe1db5f,null))[_0x224d('0x27')](removeEntity(_0xe1db5f,null))[_0x224d('0x4e')](handleError(_0xe1db5f,null));};exports[_0x224d('0x55')]=function(_0x5834a2,_0x19d75f,_0x36ce9b){return db[_0x224d('0x31')][_0x224d('0x4d')]({'where':{'id':_0x5834a2[_0x224d('0x4c')]['id']},'attributes':[_0x224d('0x2e'),_0x224d('0x56'),_0x224d('0x57'),_0x224d('0x58')],'raw':!![]})[_0x224d('0x27')](handleEntityNotFound(_0x19d75f,null))['then'](function(_0x10f5fb){if(_0x10f5fb){if(!fs[_0x224d('0x59')](path[_0x224d('0x5a')](config['root'],_0x224d('0x5b'),_0x10f5fb['savename']))){throw new db['Sequelize'][(_0x224d('0x5c'))]('Report\x20not\x20found\x20or\x20empty');}if(_0x5834a2[_0x224d('0x36')][_0x224d('0x5d')]){return _0x19d75f[_0x224d('0x1a')](0xc8);}return _0x19d75f['download'](path[_0x224d('0x5a')](config['root'],_0x224d('0x5b'),_0x10f5fb[_0x224d('0x57')]),util[_0x224d('0x5e')](_0x224d('0x5f'),_0x10f5fb[_0x224d('0x56')]||_0x10f5fb['name'],_0x10f5fb[_0x224d('0x58')]['toLowerCase']()));}})[_0x224d('0x4e')](handleError(_0x19d75f,null));}; \ No newline at end of file diff --git a/server/api/analyticExtractedReport/analyticExtractedReport.model.js b/server/api/analyticExtractedReport/analyticExtractedReport.model.js new file mode 100644 index 0000000..f3d535c --- /dev/null +++ b/server/api/analyticExtractedReport/analyticExtractedReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x85e1=['../../config/logger','api','request-promise','path','rimraf','../../config/environment','./analyticExtractedReport.attributes','exports','define','AnalyticExtractedReport','analytics_extracted_reports','util'];(function(_0x2077c2,_0x275ab5){var _0x312f9f=function(_0x331435){while(--_0x331435){_0x2077c2['push'](_0x2077c2['shift']());}};_0x312f9f(++_0x275ab5);}(_0x85e1,0x11f));var _0x185e=function(_0x2ebc18,_0x239f20){_0x2ebc18=_0x2ebc18-0x0;var _0x4113b4=_0x85e1[_0x2ebc18];return _0x4113b4;};'use strict';var _=require('lodash');var util=require(_0x185e('0x0'));var logger=require(_0x185e('0x1'))(_0x185e('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x185e('0x3'));var fs=require('fs');var path=require(_0x185e('0x4'));var rimraf=require(_0x185e('0x5'));var config=require(_0x185e('0x6'));var attributes=require(_0x185e('0x7'));module[_0x185e('0x8')]=function(_0x2dbe50,_0x314626){return _0x2dbe50[_0x185e('0x9')](_0x185e('0xa'),attributes,{'tableName':_0x185e('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticExtractedReport/analyticExtractedReport.rpc.js b/server/api/analyticExtractedReport/analyticExtractedReport.rpc.js new file mode 100644 index 0000000..c7253d6 --- /dev/null +++ b/server/api/analyticExtractedReport/analyticExtractedReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x73ab=['debug','stringify','error','code','message','result','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','jayson/promise','client','info','AnalyticExtractedReport,\x20%s,\x20%s','request\x20sent'];(function(_0x51ef40,_0x48a870){var _0x3ff060=function(_0x25e0a2){while(--_0x25e0a2){_0x51ef40['push'](_0x51ef40['shift']());}};_0x3ff060(++_0x48a870);}(_0x73ab,0x182));var _0xb73a=function(_0x22f85a,_0x195ed5){_0x22f85a=_0x22f85a-0x0;var _0xaa717=_0x73ab[_0x22f85a];return _0xaa717;};'use strict';var _=require(_0xb73a('0x0'));var util=require(_0xb73a('0x1'));var moment=require(_0xb73a('0x2'));var BPromise=require(_0xb73a('0x3'));var rs=require(_0xb73a('0x4'));var fs=require('fs');var Redis=require(_0xb73a('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xb73a('0x6'))(_0xb73a('0x7'));var config=require('../../config/environment');var jayson=require(_0xb73a('0x8'));var client=jayson[_0xb73a('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x309c91,_0x5b056d,_0x13e533){return new BPromise(function(_0x21a5b6,_0x1f5c91){return client['request'](_0x309c91,_0x13e533)['then'](function(_0x2b1934){logger[_0xb73a('0xa')](_0xb73a('0xb'),_0x5b056d,_0xb73a('0xc'));logger[_0xb73a('0xd')]('AnalyticExtractedReport,\x20%s,\x20%s,\x20%s',_0x5b056d,_0xb73a('0xc'),JSON[_0xb73a('0xe')](_0x2b1934));if(_0x2b1934[_0xb73a('0xf')]){if(_0x2b1934[_0xb73a('0xf')][_0xb73a('0x10')]===0x1f4){logger[_0xb73a('0xf')](_0xb73a('0xb'),_0x5b056d,_0x2b1934[_0xb73a('0xf')][_0xb73a('0x11')]);return _0x1f5c91(_0x2b1934[_0xb73a('0xf')][_0xb73a('0x11')]);}logger[_0xb73a('0xf')](_0xb73a('0xb'),_0x5b056d,_0x2b1934[_0xb73a('0xf')][_0xb73a('0x11')]);return _0x21a5b6(_0x2b1934[_0xb73a('0xf')][_0xb73a('0x11')]);}else{logger[_0xb73a('0xa')]('AnalyticExtractedReport,\x20%s,\x20%s',_0x5b056d,_0xb73a('0xc'));_0x21a5b6(_0x2b1934[_0xb73a('0x12')][_0xb73a('0x11')]);}})['catch'](function(_0x1197e6){logger[_0xb73a('0xf')](_0xb73a('0xb'),_0x5b056d,_0x1197e6);_0x1f5c91(_0x1197e6);});});} \ No newline at end of file diff --git a/server/api/analyticExtractedReport/index.js b/server/api/analyticExtractedReport/index.js new file mode 100644 index 0000000..6b7c8f2 --- /dev/null +++ b/server/api/analyticExtractedReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e8a=['post','create','put','update','delete','destroy','exports','multer','util','path','express','fs-extra','../../components/auth/service','../../config/environment','./analyticExtractedReport.controller','isAuthenticated','index','get','/:id','show','download'];(function(_0x1adb5f,_0x4a633e){var _0x536d8a=function(_0x2bb2ac){while(--_0x2bb2ac){_0x1adb5f['push'](_0x1adb5f['shift']());}};_0x536d8a(++_0x4a633e);}(_0x3e8a,0x9a));var _0xa3e8=function(_0x5440d3,_0x68412d){_0x5440d3=_0x5440d3-0x0;var _0x49b20a=_0x3e8a[_0x5440d3];return _0x49b20a;};'use strict';var multer=require(_0xa3e8('0x0'));var util=require(_0xa3e8('0x1'));var path=require(_0xa3e8('0x2'));var timeout=require('connect-timeout');var express=require(_0xa3e8('0x3'));var router=express['Router']();var fs_extra=require(_0xa3e8('0x4'));var auth=require(_0xa3e8('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0xa3e8('0x6'));var controller=require(_0xa3e8('0x7'));router['get']('/',auth[_0xa3e8('0x8')](),controller[_0xa3e8('0x9')]);router[_0xa3e8('0xa')](_0xa3e8('0xb'),auth[_0xa3e8('0x8')](),controller[_0xa3e8('0xc')]);router['get']('/:id/download',auth['isAuthenticated'](),controller[_0xa3e8('0xd')]);router[_0xa3e8('0xe')]('/',auth[_0xa3e8('0x8')](),controller[_0xa3e8('0xf')]);router[_0xa3e8('0x10')](_0xa3e8('0xb'),auth[_0xa3e8('0x8')](),controller[_0xa3e8('0x11')]);router[_0xa3e8('0x12')]('/:id',auth['isAuthenticated'](),controller[_0xa3e8('0x13')]);module[_0xa3e8('0x14')]=router; \ No newline at end of file diff --git a/server/api/analyticFieldReport/analyticFieldReport.attributes.js b/server/api/analyticFieldReport/analyticFieldReport.attributes.js new file mode 100644 index 0000000..c40dd9f --- /dev/null +++ b/server/api/analyticFieldReport/analyticFieldReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x53c0=['sequelize','exports','TEXT','STRING','BOOLEAN'];(function(_0x439150,_0x4a87ab){var _0x51ec95=function(_0x543fdd){while(--_0x543fdd){_0x439150['push'](_0x439150['shift']());}};_0x51ec95(++_0x4a87ab);}(_0x53c0,0xd2));var _0x053c=function(_0x59f0dc,_0x1e2497){_0x59f0dc=_0x59f0dc-0x0;var _0x5b5445=_0x53c0[_0x59f0dc];return _0x5b5445;};'use strict';var Sequelize=require(_0x053c('0x0'));module[_0x053c('0x1')]={'field':{'type':Sequelize[_0x053c('0x2')]},'alias':{'type':Sequelize['STRING']},'function':{'type':Sequelize['STRING']},'format':{'type':Sequelize[_0x053c('0x3')]},'groupBy':{'type':Sequelize[_0x053c('0x4')],'defaultValue':![]},'orderBy':{'type':Sequelize[_0x053c('0x3')]},'custom':{'type':Sequelize[_0x053c('0x4')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/analyticFieldReport/analyticFieldReport.controller.js b/server/api/analyticFieldReport/analyticFieldReport.controller.js new file mode 100644 index 0000000..2935e87 --- /dev/null +++ b/server/api/analyticFieldReport/analyticFieldReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e2d=['sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','name','send','map','AnalyticFieldReport','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','include','findAll','catch','show','keys','includeAll','options','find','create','bulkCreate','body','params','addFields','AnalyticCustomReport','findOne','sequelize','CustomReportId','eml-format','rimraf','request-promise','moment','mustache','path','sox','to-csv','fs-extra','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util'];(function(_0x3536e9,_0x78bee3){var _0x1958af=function(_0x51db3d){while(--_0x51db3d){_0x3536e9['push'](_0x3536e9['shift']());}};_0x1958af(++_0x78bee3);}(_0x4e2d,0x11c));var _0xd4e2=function(_0x5206a8,_0x140f28){_0x5206a8=_0x5206a8-0x0;var _0x19a917=_0x4e2d[_0x5206a8];return _0x19a917;};'use strict';var emlformat=require(_0xd4e2('0x0'));var rimraf=require(_0xd4e2('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xd4e2('0x2'));var moment=require(_0xd4e2('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xd4e2('0x4'));var util=require('util');var path=require(_0xd4e2('0x5'));var sox=require(_0xd4e2('0x6'));var csv=require(_0xd4e2('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xd4e2('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xd4e2('0x9'));var jsforce=require(_0xd4e2('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xd4e2('0x7'));var querystring=require(_0xd4e2('0xb'));var Papa=require(_0xd4e2('0xc'));var Redis=require(_0xd4e2('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xd4e2('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xd4e2('0xf'))(_0xd4e2('0x10'));var utils=require(_0xd4e2('0x11'));var config=require(_0xd4e2('0x12'));var licenseUtil=require(_0xd4e2('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x400c23,_0x421090){_0x421090=_0x421090||0xcc;return function(_0x1f4989){if(_0x1f4989){return _0x400c23[_0xd4e2('0x14')](_0x421090);}return _0x400c23[_0xd4e2('0x15')](_0x421090)[_0xd4e2('0x16')]();};}function respondWithResult(_0x2d60e7,_0x2effbc){_0x2effbc=_0x2effbc||0xc8;return function(_0x2d2704){if(_0x2d2704){return _0x2d60e7[_0xd4e2('0x15')](_0x2effbc)[_0xd4e2('0x17')](_0x2d2704);}};}function respondWithFilteredResult(_0x144994,_0x3a1fbf){return function(_0xcb3c94){if(_0xcb3c94){var _0x265b01=typeof _0x3a1fbf[_0xd4e2('0x18')]===_0xd4e2('0x19')&&typeof _0x3a1fbf[_0xd4e2('0x1a')]==='undefined';var _0x3acf9e=_0xcb3c94[_0xd4e2('0x1b')];var _0x5c0415=_0x265b01?0x0:_0x3a1fbf[_0xd4e2('0x18')];var _0x484f5f=_0x265b01?_0xcb3c94[_0xd4e2('0x1b')]:_0x3a1fbf[_0xd4e2('0x18')]+_0x3a1fbf['limit'];var _0x3cc689;if(_0x484f5f>=_0x3acf9e){_0x484f5f=_0x3acf9e;_0x3cc689=0xc8;}else{_0x3cc689=0xce;}_0x144994[_0xd4e2('0x15')](_0x3cc689);return _0x144994[_0xd4e2('0x1c')](_0xd4e2('0x1d'),_0x5c0415+'-'+_0x484f5f+'/'+_0x3acf9e)[_0xd4e2('0x17')](_0xcb3c94);}return null;};}function patchUpdates(_0xc7eb39){return function(_0x30d725){try{jsonpatch[_0xd4e2('0x1e')](_0x30d725,_0xc7eb39,!![]);}catch(_0x75d9ee){return BPromise[_0xd4e2('0x1f')](_0x75d9ee);}return _0x30d725[_0xd4e2('0x20')]();};}function saveUpdates(_0x26eae4,_0x4cbbf9){return function(_0x286e81){if(_0x286e81){return _0x286e81[_0xd4e2('0x21')](_0x26eae4)[_0xd4e2('0x22')](function(_0x5164b4){return _0x5164b4;});}return null;};}function removeEntity(_0x66d5b6,_0x34a40b){return function(_0x1521ba){if(_0x1521ba){return _0x1521ba[_0xd4e2('0x23')]()[_0xd4e2('0x22')](function(){_0x66d5b6[_0xd4e2('0x15')](0xcc)[_0xd4e2('0x16')]();});}};}function handleEntityNotFound(_0x34cda0,_0x527561){return function(_0x457cb0){if(!_0x457cb0){_0x34cda0[_0xd4e2('0x14')](0x194);}return _0x457cb0;};}function handleError(_0x22cf9b,_0x26a1e3){_0x26a1e3=_0x26a1e3||0x1f4;return function(_0x2fa2e9){logger['error'](_0x2fa2e9['stack']);if(_0x2fa2e9[_0xd4e2('0x24')]){delete _0x2fa2e9[_0xd4e2('0x24')];}_0x22cf9b[_0xd4e2('0x15')](_0x26a1e3)[_0xd4e2('0x25')](_0x2fa2e9);};}exports['index']=function(_0x105ac5,_0x45242b){var _0x55026c={},_0x3270a5={},_0xdfaad0={'count':0x0,'rows':[]};var _0x19a36c=_[_0xd4e2('0x26')](db[_0xd4e2('0x27')][_0xd4e2('0x28')],function(_0x3d80b2){return{'name':_0x3d80b2[_0xd4e2('0x29')],'type':_0x3d80b2[_0xd4e2('0x2a')][_0xd4e2('0x2b')]};});_0x3270a5[_0xd4e2('0x2c')]=_[_0xd4e2('0x26')](_0x19a36c,_0xd4e2('0x24'));_0x3270a5[_0xd4e2('0x2d')]=_['keys'](_0x105ac5[_0xd4e2('0x2d')]);_0x3270a5[_0xd4e2('0x2e')]=_[_0xd4e2('0x2f')](_0x3270a5[_0xd4e2('0x2c')],_0x3270a5[_0xd4e2('0x2d')]);_0x55026c[_0xd4e2('0x30')]=_[_0xd4e2('0x2f')](_0x3270a5[_0xd4e2('0x2c')],qs[_0xd4e2('0x31')](_0x105ac5[_0xd4e2('0x2d')][_0xd4e2('0x31')]));_0x55026c[_0xd4e2('0x30')]=_0x55026c[_0xd4e2('0x30')][_0xd4e2('0x32')]?_0x55026c['attributes']:_0x3270a5[_0xd4e2('0x2c')];if(!_0x105ac5[_0xd4e2('0x2d')][_0xd4e2('0x33')](_0xd4e2('0x34'))){_0x55026c[_0xd4e2('0x1a')]=qs[_0xd4e2('0x1a')](_0x105ac5[_0xd4e2('0x2d')]['limit']);_0x55026c['offset']=qs[_0xd4e2('0x18')](_0x105ac5[_0xd4e2('0x2d')][_0xd4e2('0x18')]);}_0x55026c[_0xd4e2('0x35')]=qs[_0xd4e2('0x36')](_0x105ac5[_0xd4e2('0x2d')][_0xd4e2('0x36')]);_0x55026c['where']=qs[_0xd4e2('0x2e')](_[_0xd4e2('0x37')](_0x105ac5[_0xd4e2('0x2d')],_0x3270a5[_0xd4e2('0x2e')]),_0x19a36c);if(_0x105ac5[_0xd4e2('0x2d')][_0xd4e2('0x38')]){_0x55026c[_0xd4e2('0x39')]=_[_0xd4e2('0x3a')](_0x55026c[_0xd4e2('0x39')],{'$or':_['map'](_0x19a36c,function(_0x81492e){if(_0x81492e[_0xd4e2('0x2a')]!=='VIRTUAL'){var _0xee02d6={};_0xee02d6[_0x81492e[_0xd4e2('0x24')]]={'$like':'%'+_0x105ac5[_0xd4e2('0x2d')]['filter']+'%'};return _0xee02d6;}})});}_0x55026c=_[_0xd4e2('0x3a')]({},_0x55026c,_0x105ac5['options']);var _0x28b502={'where':_0x55026c[_0xd4e2('0x39')]};return db[_0xd4e2('0x27')]['count'](_0x28b502)['then'](function(_0x310b9d){_0xdfaad0[_0xd4e2('0x1b')]=_0x310b9d;if(_0x105ac5[_0xd4e2('0x2d')]['includeAll']){_0x55026c[_0xd4e2('0x3b')]=[{'all':!![]}];}return db[_0xd4e2('0x27')][_0xd4e2('0x3c')](_0x55026c);})[_0xd4e2('0x22')](function(_0x29a92a){_0xdfaad0['rows']=_0x29a92a;return _0xdfaad0;})[_0xd4e2('0x22')](respondWithFilteredResult(_0x45242b,_0x55026c))[_0xd4e2('0x3d')](handleError(_0x45242b,null));};exports[_0xd4e2('0x3e')]=function(_0x3be9fa,_0xb21a87){var _0x355763={'raw':![],'where':{'id':_0x3be9fa['params']['id']}},_0x4748ff={};_0x4748ff['model']=_['keys'](db[_0xd4e2('0x27')]['rawAttributes']);_0x4748ff[_0xd4e2('0x2d')]=_[_0xd4e2('0x3f')](_0x3be9fa[_0xd4e2('0x2d')]);_0x4748ff[_0xd4e2('0x2e')]=_[_0xd4e2('0x2f')](_0x4748ff[_0xd4e2('0x2c')],_0x4748ff['query']);_0x355763[_0xd4e2('0x30')]=_[_0xd4e2('0x2f')](_0x4748ff['model'],qs[_0xd4e2('0x31')](_0x3be9fa[_0xd4e2('0x2d')]['fields']));_0x355763[_0xd4e2('0x30')]=_0x355763['attributes'][_0xd4e2('0x32')]?_0x355763[_0xd4e2('0x30')]:_0x4748ff[_0xd4e2('0x2c')];if(_0x3be9fa[_0xd4e2('0x2d')][_0xd4e2('0x40')]){_0x355763[_0xd4e2('0x3b')]=[{'all':!![]}];}_0x355763=_[_0xd4e2('0x3a')]({},_0x355763,_0x3be9fa[_0xd4e2('0x41')]);return db[_0xd4e2('0x27')][_0xd4e2('0x42')](_0x355763)['then'](handleEntityNotFound(_0xb21a87,null))[_0xd4e2('0x22')](respondWithResult(_0xb21a87,null))[_0xd4e2('0x3d')](handleError(_0xb21a87,null));};exports[_0xd4e2('0x43')]=function(_0x404fb8,_0xeb83d3){return db[_0xd4e2('0x27')][_0xd4e2('0x43')](_0x404fb8['body'],{})['then'](respondWithResult(_0xeb83d3,0xc9))['catch'](handleError(_0xeb83d3,null));};exports['bulkCreate']=function(_0xdb4141,_0x470547){return db[_0xd4e2('0x27')][_0xd4e2('0x44')](_0xdb4141['body'],{'raw':![],'individualHooks':!![]})[_0xd4e2('0x22')](respondWithResult(_0x470547,0xc9))[_0xd4e2('0x3d')](handleError(_0x470547,null));};exports[_0xd4e2('0x21')]=function(_0x3bac07,_0x407ccc){if(_0x3bac07['body']['id']){delete _0x3bac07[_0xd4e2('0x45')]['id'];}return db[_0xd4e2('0x27')][_0xd4e2('0x42')]({'where':{'id':_0x3bac07[_0xd4e2('0x46')]['id']}})[_0xd4e2('0x22')](handleEntityNotFound(_0x407ccc,null))[_0xd4e2('0x22')](saveUpdates(_0x3bac07[_0xd4e2('0x45')],null))['then'](respondWithResult(_0x407ccc,null))[_0xd4e2('0x3d')](handleError(_0x407ccc,null));};exports[_0xd4e2('0x23')]=function(_0x5eab33,_0x3a925f){return db[_0xd4e2('0x27')][_0xd4e2('0x42')]({'where':{'id':_0x5eab33['params']['id']}})['then'](handleEntityNotFound(_0x3a925f,null))['then'](removeEntity(_0x3a925f,null))[_0xd4e2('0x3d')](handleError(_0x3a925f,null));};exports['bulkDestroy']=function(_0x61b1df,_0x33de1c){return db[_0xd4e2('0x27')]['destroy']({'where':{'id':_0x61b1df['query']['ids']||[]},'raw':![],'individualHooks':!![]})['then'](respondWithResult(_0x33de1c,0xcc))[_0xd4e2('0x3d')](handleError(_0x33de1c,null));};exports[_0xd4e2('0x47')]=function(_0x57f68b,_0x1428b2,_0x5670cb){return db[_0xd4e2('0x48')][_0xd4e2('0x49')]({'where':{'id':_0x57f68b['params']['id']}})['then'](handleEntityNotFound(_0x1428b2,null))['then'](function(_0x3c973c){if(_0x3c973c){return db[_0xd4e2('0x4a')]['transaction'](function(_0x370f8a){return db['AnalyticFieldReport'][_0xd4e2('0x23')]({'where':{'CustomReportId':_0x57f68b[_0xd4e2('0x46')]['id']},'transaction':_0x370f8a})[_0xd4e2('0x22')](function(_0x30595a){var _0x20a526=_[_0xd4e2('0x26')](_0x57f68b[_0xd4e2('0x45')],function(_0x59b6e0){delete _0x59b6e0['id'];_0x59b6e0[_0xd4e2('0x4b')]=_0x57f68b[_0xd4e2('0x46')]['id'];return _0x59b6e0;});return db[_0xd4e2('0x27')][_0xd4e2('0x44')](_0x20a526,{'transaction':_0x370f8a});});})[_0xd4e2('0x22')](function(){return db[_0xd4e2('0x27')][_0xd4e2('0x3c')]({'where':{'CustomReportId':_0x57f68b[_0xd4e2('0x46')]['id']}});});}})[_0xd4e2('0x22')](respondWithResult(_0x1428b2,null))['catch'](handleError(_0x1428b2,null));}; \ No newline at end of file diff --git a/server/api/analyticFieldReport/analyticFieldReport.model.js b/server/api/analyticFieldReport/analyticFieldReport.model.js new file mode 100644 index 0000000..b24730a --- /dev/null +++ b/server/api/analyticFieldReport/analyticFieldReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xca26=['./analyticFieldReport.attributes','exports','define','AnalyticFieldReport','analytics_report_fields','lodash','util','api','moment','bluebird','request-promise','../../config/environment'];(function(_0x173441,_0x26b0d9){var _0x2423a8=function(_0x4d96c2){while(--_0x4d96c2){_0x173441['push'](_0x173441['shift']());}};_0x2423a8(++_0x26b0d9);}(_0xca26,0x65));var _0x6ca2=function(_0x2a75e3,_0x339c92){_0x2a75e3=_0x2a75e3-0x0;var _0xd396de=_0xca26[_0x2a75e3];return _0xd396de;};'use strict';var _=require(_0x6ca2('0x0'));var util=require(_0x6ca2('0x1'));var logger=require('../../config/logger')(_0x6ca2('0x2'));var moment=require(_0x6ca2('0x3'));var BPromise=require(_0x6ca2('0x4'));var rp=require(_0x6ca2('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x6ca2('0x6'));var attributes=require(_0x6ca2('0x7'));module[_0x6ca2('0x8')]=function(_0x2c6831,_0x37a935){return _0x2c6831[_0x6ca2('0x9')](_0x6ca2('0xa'),attributes,{'tableName':_0x6ca2('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticFieldReport/analyticFieldReport.rpc.js b/server/api/analyticFieldReport/analyticFieldReport.rpc.js new file mode 100644 index 0000000..57d9ce9 --- /dev/null +++ b/server/api/analyticFieldReport/analyticFieldReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcaab=['message','result','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','info','AnalyticFieldReport,\x20%s,\x20%s','request\x20sent','debug','AnalyticFieldReport,\x20%s,\x20%s,\x20%s','error','code'];(function(_0x3e4c0c,_0x33c473){var _0x4e9b0d=function(_0x4dc6b2){while(--_0x4dc6b2){_0x3e4c0c['push'](_0x3e4c0c['shift']());}};_0x4e9b0d(++_0x33c473);}(_0xcaab,0x1a7));var _0xbcaa=function(_0x30a4d1,_0x31a1f2){_0x30a4d1=_0x30a4d1-0x0;var _0x4cbf87=_0xcaab[_0x30a4d1];return _0x4cbf87;};'use strict';var _=require(_0xbcaa('0x0'));var util=require(_0xbcaa('0x1'));var moment=require(_0xbcaa('0x2'));var BPromise=require(_0xbcaa('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbcaa('0x4'))['db'];var utils=require(_0xbcaa('0x5'));var logger=require(_0xbcaa('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0xbcaa('0x7'));var client=jayson[_0xbcaa('0x8')][_0xbcaa('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x539ae9,_0x2815c4,_0x256ecc){return new BPromise(function(_0x31c167,_0x40511c){return client['request'](_0x539ae9,_0x256ecc)['then'](function(_0x2d7c03){logger[_0xbcaa('0xa')](_0xbcaa('0xb'),_0x2815c4,_0xbcaa('0xc'));logger[_0xbcaa('0xd')](_0xbcaa('0xe'),_0x2815c4,'request\x20sent',JSON['stringify'](_0x2d7c03));if(_0x2d7c03[_0xbcaa('0xf')]){if(_0x2d7c03[_0xbcaa('0xf')][_0xbcaa('0x10')]===0x1f4){logger[_0xbcaa('0xf')]('AnalyticFieldReport,\x20%s,\x20%s',_0x2815c4,_0x2d7c03[_0xbcaa('0xf')][_0xbcaa('0x11')]);return _0x40511c(_0x2d7c03[_0xbcaa('0xf')]['message']);}logger[_0xbcaa('0xf')](_0xbcaa('0xb'),_0x2815c4,_0x2d7c03[_0xbcaa('0xf')][_0xbcaa('0x11')]);return _0x31c167(_0x2d7c03[_0xbcaa('0xf')][_0xbcaa('0x11')]);}else{logger[_0xbcaa('0xa')](_0xbcaa('0xb'),_0x2815c4,'request\x20sent');_0x31c167(_0x2d7c03[_0xbcaa('0x12')]['message']);}})[_0xbcaa('0x13')](function(_0x2d60e4){logger['error'](_0xbcaa('0xb'),_0x2815c4,_0x2d60e4);_0x40511c(_0x2d60e4);});});} \ No newline at end of file diff --git a/server/api/analyticFieldReport/index.js b/server/api/analyticFieldReport/index.js new file mode 100644 index 0000000..66a7bf6 --- /dev/null +++ b/server/api/analyticFieldReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['delete','/destroy_many','bulkDestroy','destroy','exports','multer','util','path','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./analyticFieldReport.controller','get','index','/:id','post','/create_many','isAuthenticated','bulkCreate','/:id/create_many','update'];(function(_0x5a2613,_0x10617a){var _0x4cde56=function(_0x168f11){while(--_0x168f11){_0x5a2613['push'](_0x5a2613['shift']());}};_0x4cde56(++_0x10617a);}(_0xa9e0,0x123));var _0x0a9e=function(_0x433a86,_0x175b5c){_0x433a86=_0x433a86-0x0;var _0x23000c=_0xa9e0[_0x433a86];return _0x23000c;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['show']);router[_0x0a9e('0xb')]('/',auth['isAuthenticated'](),controller['create']);router[_0x0a9e('0xb')](_0x0a9e('0xc'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0xb')](_0x0a9e('0xf'),auth['isAuthenticated'](),controller['addFields']);router['put']('/:id',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x10')]);router[_0x0a9e('0x11')](_0x0a9e('0x12'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x13')]);router['delete'](_0x0a9e('0xa'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x14')]);module[_0x0a9e('0x15')]=router; \ No newline at end of file diff --git a/server/api/analyticMetric/analyticMetric.attributes.js b/server/api/analyticMetric/analyticMetric.attributes.js new file mode 100644 index 0000000..044939c --- /dev/null +++ b/server/api/analyticMetric/analyticMetric.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb63f=['TEXT','STRING','name'];(function(_0x35e54a,_0x46953a){var _0x35c2b0=function(_0x3c0ab9){while(--_0x3c0ab9){_0x35e54a['push'](_0x35e54a['shift']());}};_0x35c2b0(++_0x46953a);}(_0xb63f,0xa3));var _0xfb63=function(_0x5f309e,_0x66e31){_0x5f309e=_0x5f309e-0x0;var _0x487b5e=_0xb63f[_0x5f309e];return _0x487b5e;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0xfb63('0x0')],'allowNull':![],'unique':_0xfb63('0x1')},'table':{'type':Sequelize[_0xfb63('0x0')]},'metric':{'type':Sequelize[_0xfb63('0x2')]},'description':{'type':Sequelize[_0xfb63('0x0')]}}; \ No newline at end of file diff --git a/server/api/analyticMetric/analyticMetric.controller.js b/server/api/analyticMetric/analyticMetric.controller.js new file mode 100644 index 0000000..56eff14 --- /dev/null +++ b/server/api/analyticMetric/analyticMetric.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e74=['status','set','Content-Range','apply','save','update','then','destroy','get','Metrics','sendStatus','stack','name','send','index','map','AnalyticMetric','fieldName','type','key','model','query','keys','attributes','intersection','fields','hasOwnProperty','sort','where','filters','pick','merge','VIRTUAL','filter','include','findAll','rows','catch','params','rawAttributes','length','includeAll','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','eml-format','zip-dir','fast-json-patch','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','end','json','undefined','limit','offset','count'];(function(_0x75a9f6,_0x1f27e0){var _0x227845=function(_0x165ca3){while(--_0x165ca3){_0x75a9f6['push'](_0x75a9f6['shift']());}};_0x227845(++_0x1f27e0);}(_0x3e74,0x175));var _0x43e7=function(_0x200a9d,_0x5a86ae){_0x200a9d=_0x200a9d-0x0;var _0x5ecdd9=_0x3e74[_0x200a9d];return _0x5ecdd9;};'use strict';var emlformat=require(_0x43e7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x43e7('0x1'));var jsonpatch=require(_0x43e7('0x2'));var rp=require(_0x43e7('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x43e7('0x4'));var util=require('util');var path=require(_0x43e7('0x5'));var sox=require(_0x43e7('0x6'));var csv=require(_0x43e7('0x7'));var ejs=require(_0x43e7('0x8'));var fs=require('fs');var fs_extra=require(_0x43e7('0x9'));var _=require('lodash');var squel=require(_0x43e7('0xa'));var crypto=require(_0x43e7('0xb'));var jsforce=require(_0x43e7('0xc'));var deskjs=require(_0x43e7('0xd'));var toCsv=require(_0x43e7('0x7'));var querystring=require('querystring');var Papa=require(_0x43e7('0xe'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x43e7('0xf'));var as=require(_0x43e7('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x43e7('0x11'))('api');var utils=require(_0x43e7('0x12'));var config=require(_0x43e7('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x43e7('0x14'))['db'];function respondWithStatusCode(_0xc960ea,_0x2718d3){_0x2718d3=_0x2718d3||0xcc;return function(_0x3bb83f){if(_0x3bb83f){return _0xc960ea['sendStatus'](_0x2718d3);}return _0xc960ea['status'](_0x2718d3)[_0x43e7('0x15')]();};}function respondWithResult(_0x21fdd3,_0x44b0bd){_0x44b0bd=_0x44b0bd||0xc8;return function(_0x51b974){if(_0x51b974){return _0x21fdd3['status'](_0x44b0bd)[_0x43e7('0x16')](_0x51b974);}};}function respondWithFilteredResult(_0x14c146,_0x203378){return function(_0x328445){if(_0x328445){var _0x4de324=typeof _0x203378['offset']===_0x43e7('0x17')&&typeof _0x203378[_0x43e7('0x18')]===_0x43e7('0x17');var _0x5d346f=_0x328445['count'];var _0x446986=_0x4de324?0x0:_0x203378[_0x43e7('0x19')];var _0x9037d3=_0x4de324?_0x328445[_0x43e7('0x1a')]:_0x203378[_0x43e7('0x19')]+_0x203378[_0x43e7('0x18')];var _0x619236;if(_0x9037d3>=_0x5d346f){_0x9037d3=_0x5d346f;_0x619236=0xc8;}else{_0x619236=0xce;}_0x14c146[_0x43e7('0x1b')](_0x619236);return _0x14c146[_0x43e7('0x1c')](_0x43e7('0x1d'),_0x446986+'-'+_0x9037d3+'/'+_0x5d346f)[_0x43e7('0x16')](_0x328445);}return null;};}function patchUpdates(_0x177ee1){return function(_0x4b5d64){try{jsonpatch[_0x43e7('0x1e')](_0x4b5d64,_0x177ee1,!![]);}catch(_0x3c6625){return BPromise['reject'](_0x3c6625);}return _0x4b5d64[_0x43e7('0x1f')]();};}function saveUpdates(_0x3e281e,_0x3945bb){return function(_0x28aacc){if(_0x28aacc){return _0x28aacc[_0x43e7('0x20')](_0x3e281e)[_0x43e7('0x21')](function(_0x54a9e7){return _0x54a9e7;});}return null;};}function removeEntity(_0x454359,_0x4eea52){return function(_0x4c9df3){if(_0x4c9df3){return _0x4c9df3[_0x43e7('0x22')]()[_0x43e7('0x21')](function(){var _0x4b2b9f=_0x4c9df3[_0x43e7('0x23')]({'plain':!![]});var _0x4ca5cf=_0x43e7('0x24');return db['UserProfileResource'][_0x43e7('0x22')]({'where':{'type':_0x4ca5cf,'resourceId':_0x4b2b9f['id']}})[_0x43e7('0x21')](function(){return _0x4c9df3;});})[_0x43e7('0x21')](function(){_0x454359[_0x43e7('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x52b7b3,_0x805b54){return function(_0x501551){if(!_0x501551){_0x52b7b3[_0x43e7('0x25')](0x194);}return _0x501551;};}function handleError(_0x40dc8f,_0x3565cf){_0x3565cf=_0x3565cf||0x1f4;return function(_0xb1fc63){logger['error'](_0xb1fc63[_0x43e7('0x26')]);if(_0xb1fc63[_0x43e7('0x27')]){delete _0xb1fc63[_0x43e7('0x27')];}_0x40dc8f[_0x43e7('0x1b')](_0x3565cf)[_0x43e7('0x28')](_0xb1fc63);};}exports[_0x43e7('0x29')]=function(_0x2b85a5,_0x31b2a6){var _0x3bf475={},_0x35dbcd={},_0x17df44={'count':0x0,'rows':[]};var _0x19725a=_[_0x43e7('0x2a')](db[_0x43e7('0x2b')]['rawAttributes'],function(_0x238321){return{'name':_0x238321[_0x43e7('0x2c')],'type':_0x238321[_0x43e7('0x2d')][_0x43e7('0x2e')]};});_0x35dbcd[_0x43e7('0x2f')]=_['map'](_0x19725a,_0x43e7('0x27'));_0x35dbcd[_0x43e7('0x30')]=_[_0x43e7('0x31')](_0x2b85a5[_0x43e7('0x30')]);_0x35dbcd['filters']=_['intersection'](_0x35dbcd['model'],_0x35dbcd[_0x43e7('0x30')]);_0x3bf475[_0x43e7('0x32')]=_[_0x43e7('0x33')](_0x35dbcd[_0x43e7('0x2f')],qs[_0x43e7('0x34')](_0x2b85a5[_0x43e7('0x30')]['fields']));_0x3bf475['attributes']=_0x3bf475['attributes']['length']?_0x3bf475['attributes']:_0x35dbcd['model'];if(!_0x2b85a5['query'][_0x43e7('0x35')]('nolimit')){_0x3bf475[_0x43e7('0x18')]=qs[_0x43e7('0x18')](_0x2b85a5[_0x43e7('0x30')][_0x43e7('0x18')]);_0x3bf475[_0x43e7('0x19')]=qs[_0x43e7('0x19')](_0x2b85a5[_0x43e7('0x30')]['offset']);}_0x3bf475['order']=qs['sort'](_0x2b85a5[_0x43e7('0x30')][_0x43e7('0x36')]);_0x3bf475[_0x43e7('0x37')]=qs[_0x43e7('0x38')](_[_0x43e7('0x39')](_0x2b85a5[_0x43e7('0x30')],_0x35dbcd[_0x43e7('0x38')]),_0x19725a);if(_0x2b85a5[_0x43e7('0x30')]['filter']){_0x3bf475[_0x43e7('0x37')]=_[_0x43e7('0x3a')](_0x3bf475['where'],{'$or':_[_0x43e7('0x2a')](_0x19725a,function(_0x4c0c7a){if(_0x4c0c7a[_0x43e7('0x2d')]!==_0x43e7('0x3b')){var _0x1c6f45={};_0x1c6f45[_0x4c0c7a[_0x43e7('0x27')]]={'$like':'%'+_0x2b85a5[_0x43e7('0x30')][_0x43e7('0x3c')]+'%'};return _0x1c6f45;}})});}_0x3bf475=_['merge']({},_0x3bf475,_0x2b85a5['options']);var _0x30dfa9={'where':_0x3bf475[_0x43e7('0x37')]};return db[_0x43e7('0x2b')][_0x43e7('0x1a')](_0x30dfa9)[_0x43e7('0x21')](function(_0x4a4a85){_0x17df44[_0x43e7('0x1a')]=_0x4a4a85;if(_0x2b85a5[_0x43e7('0x30')]['includeAll']){_0x3bf475[_0x43e7('0x3d')]=[{'all':!![]}];}return db['AnalyticMetric'][_0x43e7('0x3e')](_0x3bf475);})['then'](function(_0x3d81ae){_0x17df44[_0x43e7('0x3f')]=_0x3d81ae;return _0x17df44;})[_0x43e7('0x21')](respondWithFilteredResult(_0x31b2a6,_0x3bf475))[_0x43e7('0x40')](handleError(_0x31b2a6,null));};exports['show']=function(_0x47d6a1,_0x103393){var _0x40c509={'raw':!![],'where':{'id':_0x47d6a1[_0x43e7('0x41')]['id']}},_0xe979b5={};_0xe979b5['model']=_['keys'](db['AnalyticMetric'][_0x43e7('0x42')]);_0xe979b5['query']=_[_0x43e7('0x31')](_0x47d6a1['query']);_0xe979b5['filters']=_[_0x43e7('0x33')](_0xe979b5['model'],_0xe979b5[_0x43e7('0x30')]);_0x40c509[_0x43e7('0x32')]=_[_0x43e7('0x33')](_0xe979b5[_0x43e7('0x2f')],qs['fields'](_0x47d6a1[_0x43e7('0x30')][_0x43e7('0x34')]));_0x40c509[_0x43e7('0x32')]=_0x40c509[_0x43e7('0x32')][_0x43e7('0x43')]?_0x40c509[_0x43e7('0x32')]:_0xe979b5['model'];if(_0x47d6a1['query'][_0x43e7('0x44')]){_0x40c509[_0x43e7('0x3d')]=[{'all':!![]}];}_0x40c509=_[_0x43e7('0x3a')]({},_0x40c509,_0x47d6a1['options']);return db['AnalyticMetric']['find'](_0x40c509)[_0x43e7('0x21')](handleEntityNotFound(_0x103393,null))[_0x43e7('0x21')](respondWithResult(_0x103393,null))['catch'](handleError(_0x103393,null));};exports[_0x43e7('0x45')]=function(_0x47686e,_0x3c96fe){return db['AnalyticMetric']['create'](_0x47686e['body'],{})['then'](function(_0x214e7e){var _0xe955fc=_0x47686e['user'][_0x43e7('0x23')]({'plain':!![]});if(!_0xe955fc)throw new Error(_0x43e7('0x46'));if(_0xe955fc[_0x43e7('0x47')]===_0x43e7('0x48')){var _0x4a0ce5=_0x214e7e[_0x43e7('0x23')]({'plain':!![]});var _0x483f20='Metrics';return db[_0x43e7('0x49')][_0x43e7('0x4a')]({'where':{'name':_0x483f20,'userProfileId':_0xe955fc[_0x43e7('0x4b')]},'raw':!![]})[_0x43e7('0x21')](function(_0x13503c){if(_0x13503c&&_0x13503c[_0x43e7('0x4c')]===0x0){return db[_0x43e7('0x4d')][_0x43e7('0x45')]({'name':_0x4a0ce5[_0x43e7('0x27')],'resourceId':_0x4a0ce5['id'],'type':_0x13503c[_0x43e7('0x27')],'sectionId':_0x13503c['id']},{})['then'](function(){return _0x214e7e;});}else{return _0x214e7e;}})[_0x43e7('0x40')](function(_0x46c910){logger['error'](_0x43e7('0x4e'),_0x46c910);throw _0x46c910;});}return _0x214e7e;})['then'](respondWithResult(_0x3c96fe,0xc9))[_0x43e7('0x40')](handleError(_0x3c96fe,null));};exports[_0x43e7('0x20')]=function(_0x34e2ec,_0x1f561f){if(_0x34e2ec[_0x43e7('0x4f')]['id']){delete _0x34e2ec['body']['id'];}return db['AnalyticMetric'][_0x43e7('0x4a')]({'where':{'id':_0x34e2ec[_0x43e7('0x41')]['id']}})[_0x43e7('0x21')](handleEntityNotFound(_0x1f561f,null))[_0x43e7('0x21')](saveUpdates(_0x34e2ec[_0x43e7('0x4f')],null))[_0x43e7('0x21')](respondWithResult(_0x1f561f,null))[_0x43e7('0x40')](handleError(_0x1f561f,null));};exports[_0x43e7('0x22')]=function(_0x26d86c,_0x24e758){return db[_0x43e7('0x2b')]['find']({'where':{'id':_0x26d86c[_0x43e7('0x41')]['id']}})[_0x43e7('0x21')](handleEntityNotFound(_0x24e758,null))['then'](removeEntity(_0x24e758,null))[_0x43e7('0x40')](handleError(_0x24e758,null));}; \ No newline at end of file diff --git a/server/api/analyticMetric/analyticMetric.model.js b/server/api/analyticMetric/analyticMetric.model.js new file mode 100644 index 0000000..fc16128 --- /dev/null +++ b/server/api/analyticMetric/analyticMetric.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0f89=['moment','bluebird','request-promise','path','../../config/environment','./analyticMetric.attributes','define','AnalyticMetric','analytics_metrics','lodash','util','../../config/logger'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x0f89,0x111));var _0x90f8=function(_0x2e56bc,_0x1a7e2c){_0x2e56bc=_0x2e56bc-0x0;var _0x1e34b7=_0x0f89[_0x2e56bc];return _0x1e34b7;};'use strict';var _=require(_0x90f8('0x0'));var util=require(_0x90f8('0x1'));var logger=require(_0x90f8('0x2'))('api');var moment=require(_0x90f8('0x3'));var BPromise=require(_0x90f8('0x4'));var rp=require(_0x90f8('0x5'));var fs=require('fs');var path=require(_0x90f8('0x6'));var rimraf=require('rimraf');var config=require(_0x90f8('0x7'));var attributes=require(_0x90f8('0x8'));module['exports']=function(_0x7b8d25,_0x4439a9){return _0x7b8d25[_0x90f8('0x9')](_0x90f8('0xa'),attributes,{'tableName':_0x90f8('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticMetric/analyticMetric.rpc.js b/server/api/analyticMetric/analyticMetric.rpc.js new file mode 100644 index 0000000..4ccdb24 --- /dev/null +++ b/server/api/analyticMetric/analyticMetric.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaccb=['then','info','AnalyticMetric,\x20%s,\x20%s','request\x20sent','debug','AnalyticMetric,\x20%s,\x20%s,\x20%s','error','message','result','catch','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x40fb42,_0x3b15e4){var _0x1901d6=function(_0x5f067a){while(--_0x5f067a){_0x40fb42['push'](_0x40fb42['shift']());}};_0x1901d6(++_0x3b15e4);}(_0xaccb,0xb5));var _0xbacc=function(_0x3bd282,_0x31a0ce){_0x3bd282=_0x3bd282-0x0;var _0x36e2ac=_0xaccb[_0x3bd282];return _0x36e2ac;};'use strict';var _=require('lodash');var util=require(_0xbacc('0x0'));var moment=require(_0xbacc('0x1'));var BPromise=require(_0xbacc('0x2'));var rs=require(_0xbacc('0x3'));var fs=require('fs');var Redis=require(_0xbacc('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xbacc('0x5'));var logger=require(_0xbacc('0x6'))(_0xbacc('0x7'));var config=require(_0xbacc('0x8'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1af07e,_0x29819a,_0x2fe890){return new BPromise(function(_0x50379a,_0x27aa0a){return client['request'](_0x1af07e,_0x2fe890)[_0xbacc('0x9')](function(_0x4deab4){logger[_0xbacc('0xa')](_0xbacc('0xb'),_0x29819a,_0xbacc('0xc'));logger[_0xbacc('0xd')](_0xbacc('0xe'),_0x29819a,_0xbacc('0xc'),JSON['stringify'](_0x4deab4));if(_0x4deab4[_0xbacc('0xf')]){if(_0x4deab4[_0xbacc('0xf')]['code']===0x1f4){logger[_0xbacc('0xf')](_0xbacc('0xb'),_0x29819a,_0x4deab4[_0xbacc('0xf')][_0xbacc('0x10')]);return _0x27aa0a(_0x4deab4[_0xbacc('0xf')][_0xbacc('0x10')]);}logger['error'](_0xbacc('0xb'),_0x29819a,_0x4deab4[_0xbacc('0xf')]['message']);return _0x50379a(_0x4deab4[_0xbacc('0xf')][_0xbacc('0x10')]);}else{logger[_0xbacc('0xa')](_0xbacc('0xb'),_0x29819a,_0xbacc('0xc'));_0x50379a(_0x4deab4[_0xbacc('0x11')][_0xbacc('0x10')]);}})[_0xbacc('0x12')](function(_0x29000d){logger[_0xbacc('0xf')](_0xbacc('0xb'),_0x29819a,_0x29000d);_0x27aa0a(_0x29000d);});});} \ No newline at end of file diff --git a/server/api/analyticMetric/index.js b/server/api/analyticMetric/index.js new file mode 100644 index 0000000..b9d316f --- /dev/null +++ b/server/api/analyticMetric/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e9d=['put','update','delete','destroy','exports','multer','util','connect-timeout','express','Router','fs-extra','../../config/environment','./analyticMetric.controller','get','isAuthenticated','/:id','show','post','create'];(function(_0x3c4f1f,_0x20d3ec){var _0x19cb69=function(_0x2e04bc){while(--_0x2e04bc){_0x3c4f1f['push'](_0x3c4f1f['shift']());}};_0x19cb69(++_0x20d3ec);}(_0x3e9d,0x1ba));var _0xd3e9=function(_0x2fa465,_0x188c11){_0x2fa465=_0x2fa465-0x0;var _0x4fc9f9=_0x3e9d[_0x2fa465];return _0x4fc9f9;};'use strict';var multer=require(_0xd3e9('0x0'));var util=require(_0xd3e9('0x1'));var path=require('path');var timeout=require(_0xd3e9('0x2'));var express=require(_0xd3e9('0x3'));var router=express[_0xd3e9('0x4')]();var fs_extra=require(_0xd3e9('0x5'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require(_0xd3e9('0x6'));var controller=require(_0xd3e9('0x7'));router[_0xd3e9('0x8')]('/',auth[_0xd3e9('0x9')](),controller['index']);router['get'](_0xd3e9('0xa'),auth[_0xd3e9('0x9')](),controller[_0xd3e9('0xb')]);router[_0xd3e9('0xc')]('/',auth[_0xd3e9('0x9')](),controller[_0xd3e9('0xd')]);router[_0xd3e9('0xe')]('/:id',auth[_0xd3e9('0x9')](),controller[_0xd3e9('0xf')]);router[_0xd3e9('0x10')](_0xd3e9('0xa'),auth[_0xd3e9('0x9')](),controller[_0xd3e9('0x11')]);module[_0xd3e9('0x12')]=router; \ No newline at end of file diff --git a/server/api/analyticTreeReport/analyticTreeReport.attributes.js b/server/api/analyticTreeReport/analyticTreeReport.attributes.js new file mode 100644 index 0000000..2dc3b35 --- /dev/null +++ b/server/api/analyticTreeReport/analyticTreeReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf69c=['TEXT','exports'];(function(_0x13ee16,_0x9b0374){var _0x48a844=function(_0x10bc0e){while(--_0x10bc0e){_0x13ee16['push'](_0x13ee16['shift']());}};_0x48a844(++_0x9b0374);}(_0xf69c,0xaf));var _0xcf69=function(_0x5b13c3,_0x378e0a){_0x5b13c3=_0x5b13c3-0x0;var _0x3d6780=_0xf69c[_0x5b13c3];return _0x3d6780;};'use strict';var Sequelize=require('sequelize');module[_0xcf69('0x0')]={'tree':{'type':Sequelize[_0xcf69('0x1')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/analyticTreeReport/analyticTreeReport.controller.js b/server/api/analyticTreeReport/analyticTreeReport.controller.js new file mode 100644 index 0000000..eb9ea27 --- /dev/null +++ b/server/api/analyticTreeReport/analyticTreeReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcb5f=['apply','reject','save','update','then','destroy','error','stack','name','send','index','map','AnalyticTreeReport','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','order','where','pick','filter','merge','includeAll','include','findAll','rows','catch','show','params','length','options','find','create','body','eml-format','rimraf','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','limit','undefined','count','offset','set','Content-Range','json'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xcb5f,0x110));var _0xfcb5=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xcb5f[_0x321bb2];return _0x9c12ed;};'use strict';var emlformat=require(_0xfcb5('0x0'));var rimraf=require(_0xfcb5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xfcb5('0x2'));var moment=require(_0xfcb5('0x3'));var BPromise=require(_0xfcb5('0x4'));var Mustache=require('mustache');var util=require(_0xfcb5('0x5'));var path=require(_0xfcb5('0x6'));var sox=require(_0xfcb5('0x7'));var csv=require(_0xfcb5('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xfcb5('0x9'));var _=require(_0xfcb5('0xa'));var squel=require(_0xfcb5('0xb'));var crypto=require(_0xfcb5('0xc'));var jsforce=require(_0xfcb5('0xd'));var deskjs=require(_0xfcb5('0xe'));var toCsv=require(_0xfcb5('0x8'));var querystring=require(_0xfcb5('0xf'));var Papa=require(_0xfcb5('0x10'));var Redis=require(_0xfcb5('0x11'));var authService=require(_0xfcb5('0x12'));var qs=require(_0xfcb5('0x13'));var as=require(_0xfcb5('0x14'));var hardwareService=require(_0xfcb5('0x15'));var logger=require('../../config/logger')('api');var utils=require(_0xfcb5('0x16'));var config=require(_0xfcb5('0x17'));var licenseUtil=require(_0xfcb5('0x18'));var db=require(_0xfcb5('0x19'))['db'];function respondWithStatusCode(_0x12bfaa,_0x14fcef){_0x14fcef=_0x14fcef||0xcc;return function(_0x56512c){if(_0x56512c){return _0x12bfaa[_0xfcb5('0x1a')](_0x14fcef);}return _0x12bfaa[_0xfcb5('0x1b')](_0x14fcef)[_0xfcb5('0x1c')]();};}function respondWithResult(_0x3bb582,_0x4eb92f){_0x4eb92f=_0x4eb92f||0xc8;return function(_0x19eafd){if(_0x19eafd){return _0x3bb582[_0xfcb5('0x1b')](_0x4eb92f)['json'](_0x19eafd);}};}function respondWithFilteredResult(_0x321853,_0x5cf6d5){return function(_0x4facf2){if(_0x4facf2){var _0x4030f9=typeof _0x5cf6d5['offset']==='undefined'&&typeof _0x5cf6d5[_0xfcb5('0x1d')]===_0xfcb5('0x1e');var _0x104f6b=_0x4facf2[_0xfcb5('0x1f')];var _0x2780f7=_0x4030f9?0x0:_0x5cf6d5['offset'];var _0x3fef68=_0x4030f9?_0x4facf2[_0xfcb5('0x1f')]:_0x5cf6d5[_0xfcb5('0x20')]+_0x5cf6d5['limit'];var _0x34a56a;if(_0x3fef68>=_0x104f6b){_0x3fef68=_0x104f6b;_0x34a56a=0xc8;}else{_0x34a56a=0xce;}_0x321853[_0xfcb5('0x1b')](_0x34a56a);return _0x321853[_0xfcb5('0x21')](_0xfcb5('0x22'),_0x2780f7+'-'+_0x3fef68+'/'+_0x104f6b)[_0xfcb5('0x23')](_0x4facf2);}return null;};}function patchUpdates(_0xadb24b){return function(_0x933ab7){try{jsonpatch[_0xfcb5('0x24')](_0x933ab7,_0xadb24b,!![]);}catch(_0x3176ba){return BPromise[_0xfcb5('0x25')](_0x3176ba);}return _0x933ab7[_0xfcb5('0x26')]();};}function saveUpdates(_0x2fcbb5,_0x438aaf){return function(_0x216795){if(_0x216795){return _0x216795[_0xfcb5('0x27')](_0x2fcbb5)[_0xfcb5('0x28')](function(_0x221045){return _0x221045;});}return null;};}function removeEntity(_0x302dce,_0x5349ca){return function(_0x3cde3f){if(_0x3cde3f){return _0x3cde3f[_0xfcb5('0x29')]()['then'](function(){_0x302dce['status'](0xcc)[_0xfcb5('0x1c')]();});}};}function handleEntityNotFound(_0x36f1d3,_0x2cc2e6){return function(_0x5a2a64){if(!_0x5a2a64){_0x36f1d3[_0xfcb5('0x1a')](0x194);}return _0x5a2a64;};}function handleError(_0x512b6e,_0x17968f){_0x17968f=_0x17968f||0x1f4;return function(_0x3bc7b9){logger[_0xfcb5('0x2a')](_0x3bc7b9[_0xfcb5('0x2b')]);if(_0x3bc7b9['name']){delete _0x3bc7b9[_0xfcb5('0x2c')];}_0x512b6e[_0xfcb5('0x1b')](_0x17968f)[_0xfcb5('0x2d')](_0x3bc7b9);};}exports[_0xfcb5('0x2e')]=function(_0x4f5762,_0x23b949){var _0x55040b={},_0x410d24={},_0xb971e6={'count':0x0,'rows':[]};var _0x1eff0b=_[_0xfcb5('0x2f')](db[_0xfcb5('0x30')][_0xfcb5('0x31')],function(_0x52200a){return{'name':_0x52200a[_0xfcb5('0x32')],'type':_0x52200a[_0xfcb5('0x33')][_0xfcb5('0x34')]};});_0x410d24[_0xfcb5('0x35')]=_['map'](_0x1eff0b,_0xfcb5('0x2c'));_0x410d24[_0xfcb5('0x36')]=_[_0xfcb5('0x37')](_0x4f5762[_0xfcb5('0x36')]);_0x410d24[_0xfcb5('0x38')]=_[_0xfcb5('0x39')](_0x410d24[_0xfcb5('0x35')],_0x410d24[_0xfcb5('0x36')]);_0x55040b[_0xfcb5('0x3a')]=_[_0xfcb5('0x39')](_0x410d24[_0xfcb5('0x35')],qs[_0xfcb5('0x3b')](_0x4f5762[_0xfcb5('0x36')][_0xfcb5('0x3b')]));_0x55040b[_0xfcb5('0x3a')]=_0x55040b[_0xfcb5('0x3a')]['length']?_0x55040b['attributes']:_0x410d24[_0xfcb5('0x35')];if(!_0x4f5762['query']['hasOwnProperty']('nolimit')){_0x55040b['limit']=qs[_0xfcb5('0x1d')](_0x4f5762[_0xfcb5('0x36')][_0xfcb5('0x1d')]);_0x55040b[_0xfcb5('0x20')]=qs[_0xfcb5('0x20')](_0x4f5762[_0xfcb5('0x36')][_0xfcb5('0x20')]);}_0x55040b[_0xfcb5('0x3c')]=qs['sort'](_0x4f5762[_0xfcb5('0x36')]['sort']);_0x55040b[_0xfcb5('0x3d')]=qs['filters'](_[_0xfcb5('0x3e')](_0x4f5762[_0xfcb5('0x36')],_0x410d24[_0xfcb5('0x38')]),_0x1eff0b);if(_0x4f5762[_0xfcb5('0x36')][_0xfcb5('0x3f')]){_0x55040b[_0xfcb5('0x3d')]=_[_0xfcb5('0x40')](_0x55040b[_0xfcb5('0x3d')],{'$or':_[_0xfcb5('0x2f')](_0x1eff0b,function(_0x18c266){if(_0x18c266[_0xfcb5('0x33')]!=='VIRTUAL'){var _0x462b45={};_0x462b45[_0x18c266[_0xfcb5('0x2c')]]={'$like':'%'+_0x4f5762[_0xfcb5('0x36')][_0xfcb5('0x3f')]+'%'};return _0x462b45;}})});}_0x55040b=_[_0xfcb5('0x40')]({},_0x55040b,_0x4f5762['options']);var _0x20c260={'where':_0x55040b[_0xfcb5('0x3d')]};return db[_0xfcb5('0x30')][_0xfcb5('0x1f')](_0x20c260)['then'](function(_0x525c73){_0xb971e6[_0xfcb5('0x1f')]=_0x525c73;if(_0x4f5762['query'][_0xfcb5('0x41')]){_0x55040b[_0xfcb5('0x42')]=[{'all':!![]}];}return db[_0xfcb5('0x30')][_0xfcb5('0x43')](_0x55040b);})[_0xfcb5('0x28')](function(_0x39094c){_0xb971e6[_0xfcb5('0x44')]=_0x39094c;return _0xb971e6;})[_0xfcb5('0x28')](respondWithFilteredResult(_0x23b949,_0x55040b))[_0xfcb5('0x45')](handleError(_0x23b949,null));};exports[_0xfcb5('0x46')]=function(_0x1e0113,_0x5c2fc4){var _0x1bc309={'raw':!![],'where':{'id':_0x1e0113[_0xfcb5('0x47')]['id']}},_0x3e747e={};_0x3e747e['model']=_[_0xfcb5('0x37')](db['AnalyticTreeReport']['rawAttributes']);_0x3e747e[_0xfcb5('0x36')]=_[_0xfcb5('0x37')](_0x1e0113[_0xfcb5('0x36')]);_0x3e747e['filters']=_[_0xfcb5('0x39')](_0x3e747e[_0xfcb5('0x35')],_0x3e747e['query']);_0x1bc309[_0xfcb5('0x3a')]=_['intersection'](_0x3e747e['model'],qs[_0xfcb5('0x3b')](_0x1e0113['query']['fields']));_0x1bc309[_0xfcb5('0x3a')]=_0x1bc309[_0xfcb5('0x3a')][_0xfcb5('0x48')]?_0x1bc309['attributes']:_0x3e747e[_0xfcb5('0x35')];if(_0x1e0113[_0xfcb5('0x36')]['includeAll']){_0x1bc309[_0xfcb5('0x42')]=[{'all':!![]}];}_0x1bc309=_['merge']({},_0x1bc309,_0x1e0113[_0xfcb5('0x49')]);return db['AnalyticTreeReport'][_0xfcb5('0x4a')](_0x1bc309)['then'](handleEntityNotFound(_0x5c2fc4,null))[_0xfcb5('0x28')](respondWithResult(_0x5c2fc4,null))['catch'](handleError(_0x5c2fc4,null));};exports['create']=function(_0x1f1e23,_0x57ca6a){return db[_0xfcb5('0x30')][_0xfcb5('0x4b')](_0x1f1e23['body'],{})['then'](respondWithResult(_0x57ca6a,0xc9))['catch'](handleError(_0x57ca6a,null));};exports[_0xfcb5('0x27')]=function(_0x239d60,_0x4d7eae){if(_0x239d60[_0xfcb5('0x4c')]['id']){delete _0x239d60[_0xfcb5('0x4c')]['id'];}return db['AnalyticTreeReport'][_0xfcb5('0x4a')]({'where':{'id':_0x239d60[_0xfcb5('0x47')]['id']}})[_0xfcb5('0x28')](handleEntityNotFound(_0x4d7eae,null))['then'](saveUpdates(_0x239d60[_0xfcb5('0x4c')],null))[_0xfcb5('0x28')](respondWithResult(_0x4d7eae,null))['catch'](handleError(_0x4d7eae,null));};exports[_0xfcb5('0x29')]=function(_0x137e59,_0x559caf){return db['AnalyticTreeReport'][_0xfcb5('0x4a')]({'where':{'id':_0x137e59['params']['id']}})[_0xfcb5('0x28')](handleEntityNotFound(_0x559caf,null))[_0xfcb5('0x28')](removeEntity(_0x559caf,null))[_0xfcb5('0x45')](handleError(_0x559caf,null));}; \ No newline at end of file diff --git a/server/api/analyticTreeReport/analyticTreeReport.model.js b/server/api/analyticTreeReport/analyticTreeReport.model.js new file mode 100644 index 0000000..b9fa528 --- /dev/null +++ b/server/api/analyticTreeReport/analyticTreeReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7188=['util','../../config/logger','moment','request-promise','path','rimraf','../../config/environment','./analyticTreeReport.attributes','exports','define','AnalyticTreeReport','lodash'];(function(_0x3edc8b,_0x1996cb){var _0xbf74e5=function(_0x2fcc27){while(--_0x2fcc27){_0x3edc8b['push'](_0x3edc8b['shift']());}};_0xbf74e5(++_0x1996cb);}(_0x7188,0xef));var _0x8718=function(_0x2cce70,_0x417165){_0x2cce70=_0x2cce70-0x0;var _0x798d77=_0x7188[_0x2cce70];return _0x798d77;};'use strict';var _=require(_0x8718('0x0'));var util=require(_0x8718('0x1'));var logger=require(_0x8718('0x2'))('api');var moment=require(_0x8718('0x3'));var BPromise=require('bluebird');var rp=require(_0x8718('0x4'));var fs=require('fs');var path=require(_0x8718('0x5'));var rimraf=require(_0x8718('0x6'));var config=require(_0x8718('0x7'));var attributes=require(_0x8718('0x8'));module[_0x8718('0x9')]=function(_0x12233b,_0x4b9a91){return _0x12233b[_0x8718('0xa')](_0x8718('0xb'),attributes,{'tableName':'analytics_report_trees','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/analyticTreeReport/analyticTreeReport.rpc.js b/server/api/analyticTreeReport/analyticTreeReport.rpc.js new file mode 100644 index 0000000..721b99e --- /dev/null +++ b/server/api/analyticTreeReport/analyticTreeReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadb5=['error','code','message','result','catch','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','AnalyticTreeReport,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x59881a,_0x5ef668){var _0x33a221=function(_0x396188){while(--_0x396188){_0x59881a['push'](_0x59881a['shift']());}};_0x33a221(++_0x5ef668);}(_0xadb5,0xad));var _0x5adb=function(_0x2ab64b,_0x4ae122){_0x2ab64b=_0x2ab64b-0x0;var _0x1765fd=_0xadb5[_0x2ab64b];return _0x1765fd;};'use strict';var _=require('lodash');var util=require(_0x5adb('0x0'));var moment=require('moment');var BPromise=require(_0x5adb('0x1'));var rs=require(_0x5adb('0x2'));var fs=require('fs');var Redis=require(_0x5adb('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x5adb('0x4'));var logger=require(_0x5adb('0x5'))(_0x5adb('0x6'));var config=require('../../config/environment');var jayson=require(_0x5adb('0x7'));var client=jayson[_0x5adb('0x8')][_0x5adb('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3213e8,_0xdf3776,_0x353885){return new BPromise(function(_0x47228a,_0x6d1b45){return client[_0x5adb('0xa')](_0x3213e8,_0x353885)[_0x5adb('0xb')](function(_0x34f59d){logger[_0x5adb('0xc')](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));logger['debug']('AnalyticTreeReport,\x20%s,\x20%s,\x20%s',_0xdf3776,_0x5adb('0xe'),JSON[_0x5adb('0xf')](_0x34f59d));if(_0x34f59d[_0x5adb('0x10')]){if(_0x34f59d['error'][_0x5adb('0x11')]===0x1f4){logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d['error'][_0x5adb('0x12')]);return _0x6d1b45(_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);}logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);return _0x47228a(_0x34f59d['error'][_0x5adb('0x12')]);}else{logger['info'](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));_0x47228a(_0x34f59d[_0x5adb('0x13')][_0x5adb('0x12')]);}})[_0x5adb('0x14')](function(_0x39d24d){logger[_0x5adb('0x10')](_0x5adb('0xd'),_0xdf3776,_0x39d24d);_0x6d1b45(_0x39d24d);});});} \ No newline at end of file diff --git a/server/api/analyticTreeReport/index.js b/server/api/analyticTreeReport/index.js new file mode 100644 index 0000000..49fa467 --- /dev/null +++ b/server/api/analyticTreeReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9888=['index','/:id','show','post','create','put','delete','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment','./analyticTreeReport.controller','get','isAuthenticated'];(function(_0x75f869,_0x3690d6){var _0x10af8b=function(_0x22d3ff){while(--_0x22d3ff){_0x75f869['push'](_0x75f869['shift']());}};_0x10af8b(++_0x3690d6);}(_0x9888,0x1bd));var _0x8988=function(_0xfe01b3,_0x1bbed1){_0xfe01b3=_0xfe01b3-0x0;var _0x4b95d4=_0x9888[_0xfe01b3];return _0x4b95d4;};'use strict';var multer=require(_0x8988('0x0'));var util=require(_0x8988('0x1'));var path=require(_0x8988('0x2'));var timeout=require(_0x8988('0x3'));var express=require('express');var router=express[_0x8988('0x4')]();var fs_extra=require(_0x8988('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x8988('0x6'));var config=require(_0x8988('0x7'));var controller=require(_0x8988('0x8'));router[_0x8988('0x9')]('/',auth[_0x8988('0xa')](),controller[_0x8988('0xb')]);router[_0x8988('0x9')](_0x8988('0xc'),auth[_0x8988('0xa')](),controller[_0x8988('0xd')]);router[_0x8988('0xe')]('/',auth[_0x8988('0xa')](),controller[_0x8988('0xf')]);router[_0x8988('0x10')](_0x8988('0xc'),auth[_0x8988('0xa')](),controller['update']);router[_0x8988('0x11')](_0x8988('0xc'),auth[_0x8988('0xa')](),controller['destroy']);module[_0x8988('0x12')]=router; \ No newline at end of file diff --git a/server/api/attachment/attachment.attributes.js b/server/api/attachment/attachment.attributes.js new file mode 100644 index 0000000..761fdc9 --- /dev/null +++ b/server/api/attachment/attachment.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe64a=['sequelize','exports','STRING'];(function(_0x1d4081,_0x2e0fa1){var _0x2eb5ea=function(_0x551e7a){while(--_0x551e7a){_0x1d4081['push'](_0x1d4081['shift']());}};_0x2eb5ea(++_0x2e0fa1);}(_0xe64a,0x1e0));var _0xae64=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xe64a[_0x122ef9];return _0x42fba0;};'use strict';var Sequelize=require(_0xae64('0x0'));module[_0xae64('0x1')]={'name':{'type':Sequelize[_0xae64('0x2')]},'basename':{'type':Sequelize[_0xae64('0x2')]},'type':{'type':Sequelize[_0xae64('0x2')]}}; \ No newline at end of file diff --git a/server/api/attachment/attachment.controller.js b/server/api/attachment/attachment.controller.js new file mode 100644 index 0000000..3d4abbf --- /dev/null +++ b/server/api/attachment/attachment.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9512=['crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','update','then','destroy','error','stack','name','send','map','Attachment','rawAttributes','fieldName','key','model','keys','intersection','query','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','type','VIRTUAL','merge','options','includeAll','findAll','catch','params','fields','include','find','get','body','createdAt','updatedAt','create','file','originalname','filename','download','findOne','ChatOfflineMessageId','root','join','basename','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','sox','ejs','fs-extra','lodash','squel'];(function(_0x473c48,_0x3c3ce7){var _0x3a45b6=function(_0x537c35){while(--_0x537c35){_0x473c48['push'](_0x473c48['shift']());}};_0x3a45b6(++_0x3c3ce7);}(_0x9512,0xf6));var _0x2951=function(_0x471448,_0x1c0e9e){_0x471448=_0x471448-0x0;var _0x38190b=_0x9512[_0x471448];return _0x38190b;};'use strict';var emlformat=require(_0x2951('0x0'));var rimraf=require(_0x2951('0x1'));var zipdir=require(_0x2951('0x2'));var jsonpatch=require(_0x2951('0x3'));var rp=require('request-promise');var moment=require(_0x2951('0x4'));var BPromise=require(_0x2951('0x5'));var Mustache=require(_0x2951('0x6'));var util=require('util');var path=require('path');var sox=require(_0x2951('0x7'));var csv=require('to-csv');var ejs=require(_0x2951('0x8'));var fs=require('fs');var fs_extra=require(_0x2951('0x9'));var _=require(_0x2951('0xa'));var squel=require(_0x2951('0xb'));var crypto=require(_0x2951('0xc'));var jsforce=require(_0x2951('0xd'));var deskjs=require(_0x2951('0xe'));var toCsv=require('to-csv');var querystring=require(_0x2951('0xf'));var Papa=require(_0x2951('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x2951('0x11'));var as=require(_0x2951('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x2951('0x13'))(_0x2951('0x14'));var utils=require(_0x2951('0x15'));var config=require(_0x2951('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x2951('0x17'))['db'];function respondWithStatusCode(_0x16a209,_0x1a4c74){_0x1a4c74=_0x1a4c74||0xcc;return function(_0x6a7c07){if(_0x6a7c07){return _0x16a209[_0x2951('0x18')](_0x1a4c74);}return _0x16a209[_0x2951('0x19')](_0x1a4c74)[_0x2951('0x1a')]();};}function respondWithResult(_0x37eaf4,_0x4152b4){_0x4152b4=_0x4152b4||0xc8;return function(_0x633847){if(_0x633847){return _0x37eaf4[_0x2951('0x19')](_0x4152b4)[_0x2951('0x1b')](_0x633847);}};}function respondWithFilteredResult(_0x5b46ee,_0x520d0b){return function(_0x4c2110){if(_0x4c2110){var _0x959597=typeof _0x520d0b[_0x2951('0x1c')]===_0x2951('0x1d')&&typeof _0x520d0b[_0x2951('0x1e')]==='undefined';var _0x1d4236=_0x4c2110[_0x2951('0x1f')];var _0x53d385=_0x959597?0x0:_0x520d0b[_0x2951('0x1c')];var _0x131028=_0x959597?_0x4c2110['count']:_0x520d0b[_0x2951('0x1c')]+_0x520d0b[_0x2951('0x1e')];var _0x1fe121;if(_0x131028>=_0x1d4236){_0x131028=_0x1d4236;_0x1fe121=0xc8;}else{_0x1fe121=0xce;}_0x5b46ee[_0x2951('0x19')](_0x1fe121);return _0x5b46ee['set'](_0x2951('0x20'),_0x53d385+'-'+_0x131028+'/'+_0x1d4236)[_0x2951('0x1b')](_0x4c2110);}return null;};}function patchUpdates(_0xa7a101){return function(_0x2cbf1d){try{jsonpatch[_0x2951('0x21')](_0x2cbf1d,_0xa7a101,!![]);}catch(_0x3608a0){return BPromise[_0x2951('0x22')](_0x3608a0);}return _0x2cbf1d['save']();};}function saveUpdates(_0x17806b,_0x27185a){return function(_0x48ae8a){if(_0x48ae8a){return _0x48ae8a[_0x2951('0x23')](_0x17806b)[_0x2951('0x24')](function(_0x1d99cb){return _0x1d99cb;});}return null;};}function removeEntity(_0x22277a,_0x5e15c3){return function(_0x134e46){if(_0x134e46){return _0x134e46[_0x2951('0x25')]()[_0x2951('0x24')](function(){_0x22277a[_0x2951('0x19')](0xcc)[_0x2951('0x1a')]();});}};}function handleEntityNotFound(_0x1af13f,_0x4897fc){return function(_0x5f0ab2){if(!_0x5f0ab2){_0x1af13f[_0x2951('0x18')](0x194);}return _0x5f0ab2;};}function handleError(_0x40d6aa,_0x55d4ae){_0x55d4ae=_0x55d4ae||0x1f4;return function(_0x5e119e){logger[_0x2951('0x26')](_0x5e119e[_0x2951('0x27')]);if(_0x5e119e[_0x2951('0x28')]){delete _0x5e119e[_0x2951('0x28')];}_0x40d6aa[_0x2951('0x19')](_0x55d4ae)[_0x2951('0x29')](_0x5e119e);};}exports['index']=function(_0x2dc713,_0x40d82e){var _0x138ae3={},_0x3e9dd4={},_0x34b35e={'count':0x0,'rows':[]};var _0x2bd35c=_[_0x2951('0x2a')](db[_0x2951('0x2b')][_0x2951('0x2c')],function(_0x3b8ae1){return{'name':_0x3b8ae1[_0x2951('0x2d')],'type':_0x3b8ae1['type'][_0x2951('0x2e')]};});_0x3e9dd4[_0x2951('0x2f')]=_[_0x2951('0x2a')](_0x2bd35c,'name');_0x3e9dd4['query']=_[_0x2951('0x30')](_0x2dc713['query']);_0x3e9dd4['filters']=_[_0x2951('0x31')](_0x3e9dd4[_0x2951('0x2f')],_0x3e9dd4[_0x2951('0x32')]);_0x138ae3[_0x2951('0x33')]=_['intersection'](_0x3e9dd4['model'],qs['fields'](_0x2dc713[_0x2951('0x32')]['fields']));_0x138ae3[_0x2951('0x33')]=_0x138ae3[_0x2951('0x33')][_0x2951('0x34')]?_0x138ae3[_0x2951('0x33')]:_0x3e9dd4[_0x2951('0x2f')];if(!_0x2dc713['query'][_0x2951('0x35')](_0x2951('0x36'))){_0x138ae3['limit']=qs['limit'](_0x2dc713[_0x2951('0x32')][_0x2951('0x1e')]);_0x138ae3[_0x2951('0x1c')]=qs[_0x2951('0x1c')](_0x2dc713[_0x2951('0x32')][_0x2951('0x1c')]);}_0x138ae3[_0x2951('0x37')]=qs[_0x2951('0x38')](_0x2dc713['query'][_0x2951('0x38')]);_0x138ae3[_0x2951('0x39')]=qs[_0x2951('0x3a')](_[_0x2951('0x3b')](_0x2dc713[_0x2951('0x32')],_0x3e9dd4[_0x2951('0x3a')]),_0x2bd35c);if(_0x2dc713[_0x2951('0x32')][_0x2951('0x3c')]){_0x138ae3['where']=_['merge'](_0x138ae3[_0x2951('0x39')],{'$or':_[_0x2951('0x2a')](_0x2bd35c,function(_0x20dfbd){if(_0x20dfbd[_0x2951('0x3d')]!==_0x2951('0x3e')){var _0x5e136e={};_0x5e136e[_0x20dfbd[_0x2951('0x28')]]={'$like':'%'+_0x2dc713[_0x2951('0x32')][_0x2951('0x3c')]+'%'};return _0x5e136e;}})});}_0x138ae3=_[_0x2951('0x3f')]({},_0x138ae3,_0x2dc713[_0x2951('0x40')]);var _0x31d92b={'where':_0x138ae3[_0x2951('0x39')]};return db[_0x2951('0x2b')][_0x2951('0x1f')](_0x31d92b)[_0x2951('0x24')](function(_0x4b5f99){_0x34b35e[_0x2951('0x1f')]=_0x4b5f99;if(_0x2dc713[_0x2951('0x32')][_0x2951('0x41')]){_0x138ae3['include']=[{'all':!![]}];}return db[_0x2951('0x2b')][_0x2951('0x42')](_0x138ae3);})[_0x2951('0x24')](function(_0x3f8e4c){_0x34b35e['rows']=_0x3f8e4c;return _0x34b35e;})['then'](respondWithFilteredResult(_0x40d82e,_0x138ae3))[_0x2951('0x43')](handleError(_0x40d82e,null));};exports['show']=function(_0x2db622,_0xef8ca9){var _0x155e3b={'raw':!![],'where':{'id':_0x2db622[_0x2951('0x44')]['id']}},_0x30f86a={};_0x30f86a['model']=_[_0x2951('0x30')](db[_0x2951('0x2b')]['rawAttributes']);_0x30f86a[_0x2951('0x32')]=_[_0x2951('0x30')](_0x2db622['query']);_0x30f86a['filters']=_[_0x2951('0x31')](_0x30f86a['model'],_0x30f86a[_0x2951('0x32')]);_0x155e3b[_0x2951('0x33')]=_[_0x2951('0x31')](_0x30f86a[_0x2951('0x2f')],qs[_0x2951('0x45')](_0x2db622[_0x2951('0x32')][_0x2951('0x45')]));_0x155e3b[_0x2951('0x33')]=_0x155e3b[_0x2951('0x33')][_0x2951('0x34')]?_0x155e3b[_0x2951('0x33')]:_0x30f86a[_0x2951('0x2f')];if(_0x2db622[_0x2951('0x32')]['includeAll']){_0x155e3b[_0x2951('0x46')]=[{'all':!![]}];}_0x155e3b=_[_0x2951('0x3f')]({},_0x155e3b,_0x2db622[_0x2951('0x40')]);return db[_0x2951('0x2b')][_0x2951('0x47')](_0x155e3b)[_0x2951('0x24')](handleEntityNotFound(_0xef8ca9,null))[_0x2951('0x24')](respondWithResult(_0xef8ca9,null))[_0x2951('0x43')](handleError(_0xef8ca9,null));};exports['clone']=function(_0x56728a,_0x1c4e6e){var _0x475f0a={'where':{'id':_0x56728a[_0x2951('0x44')]['id']}},_0xb8b92c={};_0xb8b92c[_0x2951('0x2f')]=_[_0x2951('0x30')](db['Attachment'][_0x2951('0x2c')]);_0x475f0a[_0x2951('0x33')]=_[_0x2951('0x31')](_0xb8b92c['model'],qs[_0x2951('0x45')](_0x56728a[_0x2951('0x32')][_0x2951('0x45')]));_0x475f0a['attributes']=_0x475f0a['attributes'][_0x2951('0x34')]?_0x475f0a[_0x2951('0x33')]:_0xb8b92c[_0x2951('0x2f')];if(_0x56728a[_0x2951('0x32')]['includeAll']){_0x475f0a['include']=[{'all':!![]}];}_0x475f0a=_[_0x2951('0x3f')]({},_0x475f0a,_0x56728a[_0x2951('0x40')]);return db['Attachment']['find'](_0x475f0a)[_0x2951('0x24')](handleEntityNotFound(_0x1c4e6e,null))[_0x2951('0x24')](function(_0x3505d3){if(_0x3505d3){var _0x164a9e=_0x3505d3[_0x2951('0x48')]({'plain':!![]});_0x164a9e=qs['omit'](_0x164a9e,['id','createdAt','updatedAt']);_0x56728a[_0x2951('0x49')]=_['omit'](_0x56728a['body'],['id',_0x2951('0x4a'),_0x2951('0x4b')]);return db[_0x2951('0x2b')]['create'](_[_0x2951('0x3f')](_0x164a9e,_0x56728a[_0x2951('0x49')]),{'include':_0x56728a[_0x2951('0x32')]['includeAll']?[{'all':!![]}]:undefined});}})[_0x2951('0x24')](respondWithResult(_0x1c4e6e,0xc9))[_0x2951('0x43')](handleError(_0x1c4e6e,null));};exports['update']=function(_0x53f367,_0x2707fd){if(_0x53f367[_0x2951('0x49')]['id']){delete _0x53f367['body']['id'];}return db[_0x2951('0x2b')][_0x2951('0x47')]({'where':{'id':_0x53f367[_0x2951('0x44')]['id']}})[_0x2951('0x24')](handleEntityNotFound(_0x2707fd,null))[_0x2951('0x24')](saveUpdates(_0x53f367['body'],null))[_0x2951('0x24')](respondWithResult(_0x2707fd,null))[_0x2951('0x43')](handleError(_0x2707fd,null));};exports[_0x2951('0x25')]=function(_0x557dc9,_0x12db91){return db['Attachment']['find']({'where':{'id':_0x557dc9[_0x2951('0x44')]['id']}})[_0x2951('0x24')](handleEntityNotFound(_0x12db91,null))[_0x2951('0x24')](removeEntity(_0x12db91,null))[_0x2951('0x43')](handleError(_0x12db91,null));};exports[_0x2951('0x4c')]=function(_0x4f98ff,_0x3b4231,_0x41daef){_0x4f98ff[_0x2951('0x49')][_0x2951('0x28')]=_0x4f98ff[_0x2951('0x4d')][_0x2951('0x4e')];_0x4f98ff['body']['basename']=_0x4f98ff[_0x2951('0x4d')][_0x2951('0x4f')];_0x4f98ff[_0x2951('0x49')]['type']=_0x4f98ff[_0x2951('0x4d')]['mimetype'];return db['Attachment'][_0x2951('0x4c')](_0x4f98ff[_0x2951('0x49')])['then'](respondWithResult(_0x3b4231,0xc9))[_0x2951('0x43')](handleError(_0x3b4231,null));};exports[_0x2951('0x50')]=function(_0x52e7ed,_0x5a8cb9,_0x2cebaf){return db['Attachment'][_0x2951('0x51')]({'where':{'id':_0x52e7ed['params']['id']},'raw':!![]})[_0x2951('0x24')](handleEntityNotFound(_0x5a8cb9,null))[_0x2951('0x24')](function(_0x5dcd3a){if(_0x5dcd3a){var _0x10d99d=_0x5dcd3a[_0x2951('0x52')]!==null;var _0x2243a1=path['join'](config[_0x2951('0x53')],'server/files/attachments/');if(_0x10d99d){_0x2243a1=path[_0x2951('0x54')](_0x2243a1,'offline-chat/');}var _0x50062d=path[_0x2951('0x54')](_0x2243a1,_0x5dcd3a[_0x2951('0x55')]);return _0x5a8cb9[_0x2951('0x50')](_0x50062d);}})[_0x2951('0x43')](handleError(_0x5a8cb9,null));}; \ No newline at end of file diff --git a/server/api/attachment/attachment.model.js b/server/api/attachment/attachment.model.js new file mode 100644 index 0000000..4a494fb --- /dev/null +++ b/server/api/attachment/attachment.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x140d=['util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./attachment.attributes','exports','define','Attachment','attachments','lodash'];(function(_0x304f57,_0x1d51db){var _0x4bd430=function(_0x4f1b54){while(--_0x4f1b54){_0x304f57['push'](_0x304f57['shift']());}};_0x4bd430(++_0x1d51db);}(_0x140d,0x14f));var _0xd140=function(_0x9a2980,_0x27c0b8){_0x9a2980=_0x9a2980-0x0;var _0x88b506=_0x140d[_0x9a2980];return _0x88b506;};'use strict';var _=require(_0xd140('0x0'));var util=require(_0xd140('0x1'));var logger=require('../../config/logger')(_0xd140('0x2'));var moment=require(_0xd140('0x3'));var BPromise=require(_0xd140('0x4'));var rp=require(_0xd140('0x5'));var fs=require('fs');var path=require(_0xd140('0x6'));var rimraf=require(_0xd140('0x7'));var config=require(_0xd140('0x8'));var attributes=require(_0xd140('0x9'));module[_0xd140('0xa')]=function(_0x4d51d9,_0x4a30e5){return _0x4d51d9[_0xd140('0xb')](_0xd140('0xc'),attributes,{'tableName':_0xd140('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/attachment/attachment.rpc.js b/server/api/attachment/attachment.rpc.js new file mode 100644 index 0000000..2ecb570 --- /dev/null +++ b/server/api/attachment/attachment.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf53f=['create','options','raw','then','debug','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','info','result','CreateAttachment'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf53f,0x8d));var _0xff53=function(_0x44a297,_0x34d9d8){_0x44a297=_0x44a297-0x0;var _0x4b25de=_0xf53f[_0x44a297];return _0x4b25de;};'use strict';var _=require(_0xff53('0x0'));var util=require(_0xff53('0x1'));var moment=require(_0xff53('0x2'));var BPromise=require(_0xff53('0x3'));var rs=require(_0xff53('0x4'));var fs=require('fs');var Redis=require(_0xff53('0x5'));var db=require(_0xff53('0x6'))['db'];var utils=require(_0xff53('0x7'));var logger=require(_0xff53('0x8'))(_0xff53('0x9'));var config=require(_0xff53('0xa'));var jayson=require(_0xff53('0xb'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x27b397,_0x5751e7,_0x1c27bb){return new BPromise(function(_0x122746,_0x1bc4b3){return client['request'](_0x27b397,_0x1c27bb)['then'](function(_0x3c001d){logger['info'](_0xff53('0xc'),_0x5751e7,_0xff53('0xd'));logger['debug'](_0xff53('0xe'),_0x5751e7,_0xff53('0xd'),JSON['stringify'](_0x3c001d));if(_0x3c001d[_0xff53('0xf')]){if(_0x3c001d[_0xff53('0xf')][_0xff53('0x10')]===0x1f4){logger['error'](_0xff53('0xc'),_0x5751e7,_0x3c001d[_0xff53('0xf')][_0xff53('0x11')]);return _0x1bc4b3(_0x3c001d['error'][_0xff53('0x11')]);}logger[_0xff53('0xf')]('Attachment,\x20%s,\x20%s',_0x5751e7,_0x3c001d['error']['message']);return _0x122746(_0x3c001d['error'][_0xff53('0x11')]);}else{logger[_0xff53('0x12')](_0xff53('0xc'),_0x5751e7,'request\x20sent');_0x122746(_0x3c001d[_0xff53('0x13')]['message']);}})['catch'](function(_0x12e90b){logger[_0xff53('0xf')](_0xff53('0xc'),_0x5751e7,_0x12e90b);_0x1bc4b3(_0x12e90b);});});}exports[_0xff53('0x14')]=function(_0x38883f){var _0x319ce5=this;return new Promise(function(_0x14b502,_0x5e9ba6){return db['Attachment'][_0xff53('0x15')](_0x38883f['body'],{'raw':_0x38883f[_0xff53('0x16')]?_0x38883f[_0xff53('0x16')][_0xff53('0x17')]===undefined?!![]:![]:!![]})[_0xff53('0x18')](function(_0x39b3d1){logger[_0xff53('0x12')](_0xff53('0x14'),_0x38883f);logger[_0xff53('0x19')](_0xff53('0x14'),_0x38883f,JSON['stringify'](_0x39b3d1));_0x14b502(_0x39b3d1);})[_0xff53('0x1a')](function(_0x5cd878){logger['error']('CreateAttachment',_0x5cd878['message'],_0x38883f);_0x5e9ba6(_0x319ce5[_0xff53('0xf')](0x1f4,_0x5cd878[_0xff53('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/attachment/index.js b/server/api/attachment/index.js new file mode 100644 index 0000000..6472294 --- /dev/null +++ b/server/api/attachment/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2032=['./attachment.controller','get','isAuthenticated','index','/:id','show','download','/:id/clone','clone','root','server/files/attachments/','now','post','single','file','create','put','update','delete','destroy','exports','util','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment'];(function(_0x7f8a44,_0x13830e){var _0x93f2de=function(_0x1134c0){while(--_0x1134c0){_0x7f8a44['push'](_0x7f8a44['shift']());}};_0x93f2de(++_0x13830e);}(_0x2032,0xd9));var _0x2203=function(_0x3d8706,_0x382abc){_0x3d8706=_0x3d8706-0x0;var _0x46cd13=_0x2032[_0x3d8706];return _0x46cd13;};'use strict';var multer=require('multer');var util=require(_0x2203('0x0'));var path=require(_0x2203('0x1'));var timeout=require(_0x2203('0x2'));var express=require('express');var router=express[_0x2203('0x3')]();var fs_extra=require(_0x2203('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x2203('0x5'));var config=require(_0x2203('0x6'));var controller=require(_0x2203('0x7'));router[_0x2203('0x8')]('/',auth[_0x2203('0x9')](),controller[_0x2203('0xa')]);router[_0x2203('0x8')](_0x2203('0xb'),auth[_0x2203('0x9')](),controller[_0x2203('0xc')]);router[_0x2203('0x8')]('/:id/download',auth['isAuthenticated'](),controller[_0x2203('0xd')]);router['post'](_0x2203('0xe'),auth[_0x2203('0x9')](),controller[_0x2203('0xf')]);var upload=multer({'storage':multer['diskStorage']({'destination':function(_0x849049,_0x4a6832,_0x3f690a){_0x3f690a(null,path['join'](config[_0x2203('0x10')],_0x2203('0x11')));},'filename':function(_0x4b9376,_0x583bc7,_0x585c76){_0x585c76(null,util['format']('%s-%s',Date[_0x2203('0x12')](),_0x583bc7['originalname']['replace'](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-')));}})});router[_0x2203('0x13')]('/',upload[_0x2203('0x14')](_0x2203('0x15')),controller[_0x2203('0x16')]);router[_0x2203('0x17')](_0x2203('0xb'),auth[_0x2203('0x9')](),controller[_0x2203('0x18')]);router[_0x2203('0x19')](_0x2203('0xb'),auth['isAuthenticated'](),controller[_0x2203('0x1a')]);module[_0x2203('0x1b')]=router; \ No newline at end of file diff --git a/server/api/authActiveDirectory/authActiveDirectory.controller.js b/server/api/authActiveDirectory/authActiveDirectory.controller.js new file mode 100644 index 0000000..d8a62c8 --- /dev/null +++ b/server/api/authActiveDirectory/authActiveDirectory.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb0af=['message','login','authenticate','ad-login','Something\x20went\x20wrong,\x20please\x20try\x20again.','json','User','passport-local','moment','activedirectory2','bluebird','../../mysqldb','../../components/auth/service','../../config/utils','../../config/logger','activedirectory','undefined','baseDN','url','error','Error\x20authenticate\x20%s:\x20%s','inspect','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','Error\x20authenticate\x20%s:\x20Wrong\x20credentials','findOne','adSsoEnabled','then','Error\x20authenticate\x20%s:\x20Active\x20Directory\x20not\x20enabled','name','password','salt','role','disabled','blocked','online','admin','user','agent','domain','blockedAt','add','blockDuration','clearBlockUser','getLicense','catch','status'];(function(_0x325552,_0x2244c4){var _0x40b052=function(_0x268961){while(--_0x268961){_0x325552['push'](_0x325552['shift']());}};_0x40b052(++_0x2244c4);}(_0xb0af,0xed));var _0xfb0a=function(_0x309817,_0x44d860){_0x309817=_0x309817-0x0;var _0x1c6922=_0xb0af[_0x309817];return _0x1c6922;};'use strict';var passport=require('passport');var LocalStrategy=require(_0xfb0a('0x0'))['Strategy'];var moment=require(_0xfb0a('0x1'));var ActiveDirectory=require(_0xfb0a('0x2'));var BPromise=require(_0xfb0a('0x3'));var util=require('util');var db=require(_0xfb0a('0x4'))['db'];var authService=require(_0xfb0a('0x5'));var utils=require(_0xfb0a('0x6'));var config=require('../../config/environment');var logger=require(_0xfb0a('0x7'))('api');function isActiveDirectoryConfigured(_0x220005){var _0x3ff04c=![];if(typeof _0x220005[_0xfb0a('0x8')]!==_0xfb0a('0x9')){_0x3ff04c=_0x220005[_0xfb0a('0x8')][_0xfb0a('0xa')]&&_0x220005[_0xfb0a('0x8')][_0xfb0a('0xb')]&&_0x220005[_0xfb0a('0x8')]['domain'];}return _0x3ff04c;}function adAuthenticate(_0x57c2b8,_0x1307d4,_0x1ce68d){return new BPromise(function(_0x4f7a04,_0x5abad9){try{var _0x482f3e=new ActiveDirectory(_0x57c2b8);_0x482f3e['authenticate'](_0x1307d4,_0x1ce68d,function(_0x49e3dd,_0x29605e){if(_0x49e3dd){logger[_0xfb0a('0xc')](_0xfb0a('0xd'),_0x1307d4,util[_0xfb0a('0xe')](_0x49e3dd,{'showHidden':![],'depth':null}));_0x5abad9(_0xfb0a('0xf'));}else if(!_0x29605e){logger[_0xfb0a('0xc')](_0xfb0a('0x10'),_0x1307d4);_0x5abad9(_0xfb0a('0xf'));}else{_0x4f7a04(_0x29605e);}});}catch(_0x3e8f78){_0x5abad9(_0x3e8f78);}});}function ActiveDirectoryAuthenticate(_0x4a72cd,_0x5d14b9,_0x316127,_0x41642c){var _0x4e331a,_0x1a3407;if(!isActiveDirectoryConfigured(config)){logger[_0xfb0a('0xc')]('Error\x20authenticate\x20%s:\x20Active\x20Directory\x20not\x20configured',_0x5d14b9);return _0x41642c(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}return db['Setting'][_0xfb0a('0x11')]({'where':{'id':0x1},'attributes':[_0xfb0a('0x12'),'blockDuration'],'raw':!![]})[_0xfb0a('0x13')](function(_0x4e72ba){_0x4e331a=_0x4e72ba;if(!_0x4e331a[_0xfb0a('0x12')]){logger[_0xfb0a('0xc')](_0xfb0a('0x14'),_0x5d14b9);throw new Error(_0xfb0a('0xf'));}return _0x4a72cd['findOne']({'attributes':['id',_0xfb0a('0x15'),_0xfb0a('0x16'),_0xfb0a('0x17'),_0xfb0a('0x18'),_0xfb0a('0x19'),_0xfb0a('0x1a'),'blockedAt',_0xfb0a('0x1b')],'where':{'name':_0x5d14b9,'role':{'$or':[_0xfb0a('0x1c'),_0xfb0a('0x1d'),_0xfb0a('0x1e')]},'adSsoEnabled':!![]}});})[_0xfb0a('0x13')](function(_0x1328cb){if(!_0x1328cb||_0x1328cb&&_0x1328cb['name']!==_0x5d14b9){throw new Error(_0xfb0a('0xf'));}_0x1a3407=_0x1328cb;var _0x1c051e=_0x1a3407['name']+'@'+config['activedirectory'][_0xfb0a('0x1f')];return adAuthenticate(config[_0xfb0a('0x8')],_0x1c051e,_0x316127);})['then'](function(_0x51d5f0){if(_0x1a3407['disabled']){throw new Error(_0xfb0a('0xf'));}if(_0x4e331a['blockDuration']>0x0){if(_0x1a3407[_0xfb0a('0x1a')]){if(moment(_0x1a3407[_0xfb0a('0x20')])[_0xfb0a('0x21')](_0x4e331a[_0xfb0a('0x22')],'minutes')>moment()){throw new Error(_0xfb0a('0xf'));}return utils[_0xfb0a('0x23')](_0x1a3407,0x0,![],null)[_0xfb0a('0x13')](function(){return utils[_0xfb0a('0x24')](_0x1a3407);})[_0xfb0a('0x13')](function(){return _0x41642c(null,_0x1a3407);});}else{return utils[_0xfb0a('0x24')](_0x1a3407)[_0xfb0a('0x13')](function(){return _0x41642c(null,_0x1a3407);});}}else{return utils[_0xfb0a('0x24')](_0x1a3407)[_0xfb0a('0x13')](function(){return _0x41642c(null,_0x1a3407);});}})[_0xfb0a('0x25')](function(_0x54ef1a){return _0x41642c(null,![],_0x54ef1a);});}function handleError(_0x21c3ee,_0x229fce,_0x47b783){return _0x21c3ee[_0xfb0a('0x26')](_0x229fce||0x1f4)['send']({'message':_0x47b783?_0x47b783[_0xfb0a('0x27')]||_0x47b783:''});}exports[_0xfb0a('0x28')]=function(_0x3186e2,_0x1abd37,_0x49b3ee){passport[_0xfb0a('0x29')](_0xfb0a('0x2a'),function(_0x2482f1,_0x59a701,_0x1cd61b){var _0x107e7f=_0x2482f1||_0x1cd61b;if(_0x107e7f){return handleError(_0x1abd37,0x191,_0x107e7f);}if(!_0x59a701){return handleError(_0x1abd37,0x194,{'message':_0xfb0a('0x2b')});}else{var _0x48be35={'payload':{'id':_0x59a701['id'],'role':_0x59a701[_0xfb0a('0x18')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x48be35)[_0xfb0a('0x13')](function(_0x1e7f04){_0x1abd37[_0xfb0a('0x2c')]({'id':_0x59a701['id'],'token':_0x1e7f04,'statusCall':'','isAlreadyLogged':_0x59a701[_0xfb0a('0x1b')]});});}})(_0x3186e2,_0x1abd37,_0x49b3ee);};passport['use']('ad-login',new LocalStrategy({'usernameField':'name','passwordField':_0xfb0a('0x16')},function(_0x50470d,_0x4b907c,_0x52c86f){return ActiveDirectoryAuthenticate(db[_0xfb0a('0x2d')],_0x50470d,_0x4b907c,_0x52c86f);})); \ No newline at end of file diff --git a/server/api/authActiveDirectory/index.js b/server/api/authActiveDirectory/index.js new file mode 100644 index 0000000..73910dc --- /dev/null +++ b/server/api/authActiveDirectory/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2361=['Router','./authActiveDirectory.controller','post','exports'];(function(_0x42bdad,_0x12836c){var _0x122626=function(_0x2eb29c){while(--_0x2eb29c){_0x42bdad['push'](_0x42bdad['shift']());}};_0x122626(++_0x12836c);}(_0x2361,0x150));var _0x1236=function(_0x19b941,_0x61476f){_0x19b941=_0x19b941-0x0;var _0x222d17=_0x2361[_0x19b941];return _0x222d17;};'use strict';var express=require('express');var router=express[_0x1236('0x0')]();var controller=require(_0x1236('0x1'));router[_0x1236('0x2')]('/',controller['login']);module[_0x1236('0x3')]=router; \ No newline at end of file diff --git a/server/api/authGoogle/authGoogle.controller.js b/server/api/authGoogle/authGoogle.controller.js new file mode 100644 index 0000000..d80f377 --- /dev/null +++ b/server/api/authGoogle/authGoogle.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9957=['../../config/environment','../../config/utils','login','google','/login','profile','email','callback','authenticate','use','clientID','clientSecret','secret','callbackURL','Setting','findOne','allowedLoginAttempts','User','find','map','emails','value','admin','user','then','disabled','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','blockDuration','blocked','blockedAt','add','getLicense','catch','lodash','passport','passport-google-oauth20','Strategy','../../mysqldb'];(function(_0x4c60cc,_0x42acaf){var _0x26c875=function(_0x52e0de){while(--_0x52e0de){_0x4c60cc['push'](_0x4c60cc['shift']());}};_0x26c875(++_0x42acaf);}(_0x9957,0x93));var _0x7995=function(_0x6131cd,_0x4c26a1){_0x6131cd=_0x6131cd-0x0;var _0x47e916=_0x9957[_0x6131cd];return _0x47e916;};'use strict';var _=require(_0x7995('0x0'));var passport=require(_0x7995('0x1'));var GoogleStrategy=require(_0x7995('0x2'))[_0x7995('0x3')];var moment=require('moment');var db=require(_0x7995('0x4'))['db'];var config=require(_0x7995('0x5'));var utils=require(_0x7995('0x6'));exports[_0x7995('0x7')]=passport['authenticate'](_0x7995('0x8'),{'failureRedirect':_0x7995('0x9'),'scope':[_0x7995('0xa'),_0x7995('0xb')],'session':![]});exports[_0x7995('0xc')]=passport[_0x7995('0xd')]('google',{'failureRedirect':_0x7995('0x9'),'session':![]});passport[_0x7995('0xe')](new GoogleStrategy({'clientID':config['google']?config[_0x7995('0x8')][_0x7995('0xf')]:'id','clientSecret':config[_0x7995('0x8')]?config[_0x7995('0x8')][_0x7995('0x10')]:_0x7995('0x11'),'callbackURL':config[_0x7995('0x8')]?config['google'][_0x7995('0x12')]:''},function(_0x41c652,_0x581f22,_0xb0c872,_0x2cb37a){var _0x19a27e,_0x385f00;return db[_0x7995('0x13')][_0x7995('0x14')]({'where':{'id':0x1},'attributes':[_0x7995('0x15'),'blockDuration'],'raw':!![]})['then'](function(_0x2b4e94){_0x19a27e=_0x2b4e94;return db[_0x7995('0x16')][_0x7995('0x17')]({'where':{'email':_[_0x7995('0x18')](_0xb0c872[_0x7995('0x19')],_0x7995('0x1a')),'role':{'$or':[_0x7995('0x1b'),_0x7995('0x1c'),'agent']}}});})[_0x7995('0x1d')](function(_0x565d97){_0x385f00=_0x565d97;if(_0x385f00){if(_0x385f00[_0x7995('0x1e')]){return _0x2cb37a(_0x7995('0x1f'));}else if(_0x19a27e[_0x7995('0x20')]>0x0){if(_0x385f00[_0x7995('0x21')]){if(moment(_0x385f00[_0x7995('0x22')])[_0x7995('0x23')](_0x19a27e['blockDuration'],'minutes')>moment()){return _0x2cb37a(_0x7995('0x1f'));}else{return utils['clearBlockUser'](_0x385f00,0x0,![],null)['then'](function(){return utils[_0x7995('0x24')](_0x385f00);})[_0x7995('0x1d')](function(){return _0x2cb37a(null,_0x385f00);});}}else{return utils['getLicense'](_0x385f00)[_0x7995('0x1d')](function(){return _0x2cb37a(null,_0x385f00);});}}else{return utils['getLicense'](_0x385f00)['then'](function(){return _0x2cb37a(null,_0x385f00);});}}return _0x2cb37a(_0x7995('0x1f'));})[_0x7995('0x25')](function(_0x350fd9){_0x2cb37a(_0x350fd9);});})); \ No newline at end of file diff --git a/server/api/authGoogle/index.js b/server/api/authGoogle/index.js new file mode 100644 index 0000000..bc527c3 --- /dev/null +++ b/server/api/authGoogle/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa807=['./authGoogle.controller','get','login','/callback','setTokenCookie','exports','express','passport','Router'];(function(_0x55e907,_0x317402){var _0x20ac83=function(_0x10a88c){while(--_0x10a88c){_0x55e907['push'](_0x55e907['shift']());}};_0x20ac83(++_0x317402);}(_0xa807,0x1e3));var _0x7a80=function(_0x5c9630,_0x2ac5a0){_0x5c9630=_0x5c9630-0x0;var _0x1a724=_0xa807[_0x5c9630];return _0x1a724;};'use strict';var express=require(_0x7a80('0x0'));var passport=require(_0x7a80('0x1'));var router=express[_0x7a80('0x2')]();var controller=require(_0x7a80('0x3'));var userController=require('../user/user.controller.js');var authService=require('../../components/auth/service');router[_0x7a80('0x4')]('/',controller[_0x7a80('0x5')]);router[_0x7a80('0x4')](_0x7a80('0x6'),controller['callback'],authService['isMiddleware'],userController[_0x7a80('0x5')],authService[_0x7a80('0x7')]);module[_0x7a80('0x8')]=router; \ No newline at end of file diff --git a/server/api/authLocal/authLocal.controller.js b/server/api/authLocal/authLocal.controller.js new file mode 100644 index 0000000..1455a12 --- /dev/null +++ b/server/api/authLocal/authLocal.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbe72=['online','forgot','body','email','Email\x20parameter\x20is\x20missing','generate','trim','toLowerCase','User','This\x20email\x20is\x20not\x20registered.','resetPasswordExpires','now','save','xCally\x20Motion\x20Password\x20Reset','https://','/reset/','If\x20you\x20did\x20not\x20request\x20this,\x20please\x20ignore\x20this\x20email\x20and\x20your\x20password\x20will\x20remain\x20unchanged.\x0a','Reset\x20Email\x20sent!','reset','params','token','securePassword','passwordHistoryLimit','validatePasswordPattern','enforcePasswordHistory','validatePasswordHistory','resetPasswordToken','Password\x20reset!','use','util','passport-local','Strategy','jayson/promise','lodash','randomstring','moment','../../components/auth/service','../../config/utils','client','Setting','findOne','allowedLoginAttempts','blockDuration','then','name','password','salt','role','disabled','blocked','loginAttempts','agent','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','blockedAt','add','minutes','clearBlockUser','getLicense','catch','MailAccount','find','MailServerOut','Smtp','CloudProvider','Unable\x20to\x20find\x20a\x20configured\x20SMTP\x20service!','getSmtpOptions','merge','format','\x22%s\x22\x20<%s>','user','request','error','SendMail\x20error:\x20%s.\x20Please\x20contact\x20your\x20Administrator!','message','stringify','status','send','login','local-login','json'];(function(_0x3712c6,_0x178102){var _0x15ab9b=function(_0x324474){while(--_0x324474){_0x3712c6['push'](_0x3712c6['shift']());}};_0x15ab9b(++_0x178102);}(_0xbe72,0x6d));var _0x2be7=function(_0x311c35,_0x534915){_0x311c35=_0x311c35-0x0;var _0x5cc50c=_0xbe72[_0x311c35];return _0x5cc50c;};'use strict';var util=require(_0x2be7('0x0'));var passport=require('passport');var LocalStrategy=require(_0x2be7('0x1'))[_0x2be7('0x2')];var jayson=require(_0x2be7('0x3'));var _=require(_0x2be7('0x4'));var rs=require(_0x2be7('0x5'));var moment=require(_0x2be7('0x6'));var db=require('../../mysqldb')['db'];var authService=require(_0x2be7('0x7'));var utils=require(_0x2be7('0x8'));var client=jayson[_0x2be7('0x9')]['http']({'port':0x232b});function localAuthenticate(_0x47418d,_0x28a202,_0x49be6b,_0x3b07bc){var _0x26cb7a,_0x355b00;return db[_0x2be7('0xa')][_0x2be7('0xb')]({'where':{'id':0x1},'attributes':[_0x2be7('0xc'),_0x2be7('0xd')],'raw':!![]})[_0x2be7('0xe')](function(_0x492aff){_0x26cb7a=_0x492aff;return _0x47418d[_0x2be7('0xb')]({'attributes':['id',_0x2be7('0xf'),_0x2be7('0x10'),_0x2be7('0x11'),_0x2be7('0x12'),_0x2be7('0x13'),_0x2be7('0x14'),'blockedAt',_0x2be7('0x15')],'where':{'name':_0x28a202,'role':{'$or':['admin','user',_0x2be7('0x16')]}}});})[_0x2be7('0xe')](function(_0x4498d4){if(!_0x4498d4||_0x4498d4&&_0x4498d4[_0x2be7('0xf')]!==_0x28a202){throw new Error(_0x2be7('0x17'));}else{_0x355b00=_0x4498d4;return _0x355b00;}})[_0x2be7('0xe')](function(){_0x355b00['authenticate'](_0x49be6b,function(_0x5dc5f4,_0x1dfc3e){var _0x3d7939=_0x355b00[_0x2be7('0x15')]+0x1;if(_0x5dc5f4){return _0x3b07bc(_0x5dc5f4);}else if(!_0x1dfc3e){if(_0x355b00[_0x2be7('0x13')]){return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}else if(_0x26cb7a['allowedLoginAttempts']>0x0){if(_0x355b00[_0x2be7('0x14')]){if(_0x26cb7a['blockDuration']>0x0){if(moment(_0x355b00[_0x2be7('0x18')])[_0x2be7('0x19')](_0x26cb7a['blockDuration'],_0x2be7('0x1a'))>moment()){return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}else{return utils['clearBlockUser'](_0x355b00,_0x3d7939,![],null)[_0x2be7('0xe')](function(){return _0x3b07bc(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}else{return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}}else{if(_0x3d7939>=_0x26cb7a[_0x2be7('0xc')]){return utils[_0x2be7('0x1b')](_0x355b00,0x0,!![],moment())[_0x2be7('0xe')](function(){return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});});}else{return utils['clearBlockUser'](_0x355b00,_0x3d7939,![],null)[_0x2be7('0xe')](function(){return _0x3b07bc(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});});}}}else{return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}}else{if(_0x355b00[_0x2be7('0x13')]){return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}else if(_0x26cb7a[_0x2be7('0xc')]>0x0){if(_0x355b00[_0x2be7('0x14')]){if(_0x26cb7a[_0x2be7('0xd')]>0x0){if(moment(_0x355b00['blockedAt'])[_0x2be7('0x19')](_0x26cb7a['blockDuration'],'minutes')>moment()){return _0x3b07bc(null,![],{'message':'Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'});}else{return utils['clearBlockUser'](_0x355b00,0x0,![],null)[_0x2be7('0xe')](function(){return utils[_0x2be7('0x1c')](_0x355b00);})[_0x2be7('0xe')](function(){return _0x3b07bc(null,_0x355b00);});}}else{return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}}else{return utils[_0x2be7('0x1b')](_0x355b00,0x0,![],null)[_0x2be7('0xe')](function(){return utils['getLicense'](_0x355b00);})[_0x2be7('0xe')](function(){return _0x3b07bc(null,_0x355b00);})['catch'](function(_0x2f309d){return _0x3b07bc(null,![],_0x2f309d);});}}else{if(_0x355b00[_0x2be7('0x14')]){return _0x3b07bc(null,![],{'message':_0x2be7('0x17')});}else{return utils[_0x2be7('0x1c')](_0x355b00)[_0x2be7('0xe')](function(){return _0x3b07bc(null,_0x355b00);});}}}});})[_0x2be7('0x1d')](function(_0x179180){return _0x3b07bc(null,![],_0x179180);});}function sendServiceMail(_0xc6949c){return db[_0x2be7('0x1e')][_0x2be7('0x1f')]({'where':{'service':!![]},'attributes':['id',_0x2be7('0xf'),'email'],'include':[{'model':db[_0x2be7('0x20')],'as':_0x2be7('0x21'),'include':[{'model':db[_0x2be7('0x22')],'as':_0x2be7('0x22')}]}]})[_0x2be7('0xe')](function(_0x4fa96e){if(!_0x4fa96e){throw new Error(_0x2be7('0x23'));}var _0xcaa196=_0x4fa96e[_0x2be7('0x24')]();var _0x297839={'account':_0xcaa196,'message':_[_0x2be7('0x25')]({'from':util[_0x2be7('0x26')](_0x2be7('0x27'),_0x4fa96e[_0x2be7('0xf')],_0x4fa96e['email']||_0x4fa96e[_0x2be7('0x21')][_0x2be7('0x28')])},_0xc6949c)};return client[_0x2be7('0x29')]('SendMail',_0x297839);})[_0x2be7('0xe')](function(_0x3e18fe){if(_0x3e18fe[_0x2be7('0x2a')]){throw new Error(util[_0x2be7('0x26')](_0x2be7('0x2b'),_0x3e18fe[_0x2be7('0x2a')][_0x2be7('0x2c')]||JSON[_0x2be7('0x2d')](_0x3e18fe[_0x2be7('0x2a')])));}return!![];});}function handleError(_0x41e7d3,_0x11cea2,_0x1f721c){return _0x41e7d3[_0x2be7('0x2e')](_0x11cea2||0x1f4)[_0x2be7('0x2f')]({'message':_0x1f721c?_0x1f721c[_0x2be7('0x2c')]||_0x1f721c:''});}exports[_0x2be7('0x30')]=function(_0x3614ca,_0x27d3be,_0x159818){passport['authenticate'](_0x2be7('0x31'),function(_0x61a87f,_0x53da36,_0x3f96e1){var _0x13e459=_0x61a87f||_0x3f96e1;if(_0x13e459){return handleError(_0x27d3be,0x191,_0x13e459);}if(!_0x53da36){return handleError(_0x27d3be,0x194,{'message':'Something\x20went\x20wrong,\x20please\x20try\x20again.'});}else{var _0x596d0f={'payload':{'id':_0x53da36['id'],'role':_0x53da36[_0x2be7('0x12')]},'options':{'expiresIn':0x15180}};return authService['signToken'](_0x596d0f)[_0x2be7('0xe')](function(_0x761f94){_0x27d3be[_0x2be7('0x32')]({'id':_0x53da36['id'],'token':_0x761f94,'statusCall':'','isAlreadyLogged':_0x53da36[_0x2be7('0x33')]});});}})(_0x3614ca,_0x27d3be,_0x159818);};exports[_0x2be7('0x34')]=function(_0xdb7266,_0x2e572e){if(!_0xdb7266[_0x2be7('0x35')][_0x2be7('0x36')]){return handleError(_0x2e572e,0x1f4,{'message':_0x2be7('0x37')});}var _0x2897bc=rs[_0x2be7('0x38')]();_0xdb7266[_0x2be7('0x35')][_0x2be7('0x36')]=_0xdb7266['body']['email'][_0x2be7('0x39')]()[_0x2be7('0x3a')]();var _0x2ced07;return db[_0x2be7('0xa')][_0x2be7('0xb')]({'where':{'id':0x1},'attributes':[_0x2be7('0xc'),'blockDuration'],'raw':!![]})['then'](function(_0x572595){_0x2ced07=_0x572595;return db[_0x2be7('0x3b')][_0x2be7('0x1f')]({'where':{'email':_0xdb7266[_0x2be7('0x35')][_0x2be7('0x36')]}});})[_0x2be7('0xe')](function(_0x4d3901){if(!_0x4d3901){throw new Error(_0x2be7('0x3c'));}if(_0x4d3901[_0x2be7('0x13')]){throw new Error('The\x20user\x20is\x20disabled.\x20Please\x20contact\x20the\x20administrator.');}if(_0x4d3901[_0x2be7('0x14')]){if(moment(_0x4d3901[_0x2be7('0x18')])[_0x2be7('0x19')](_0x2ced07[_0x2be7('0xd')],_0x2be7('0x1a'))>moment()){throw new Error('The\x20user\x20is\x20blocked.\x20Please\x20contact\x20the\x20administrator.');}else{_0x4d3901['blocked']=![];_0x4d3901[_0x2be7('0x18')]=null;}}_0x4d3901['resetPasswordToken']=_0x2897bc;_0x4d3901[_0x2be7('0x3d')]=Date[_0x2be7('0x3e')]()+0x36ee80;return _0x4d3901[_0x2be7('0x3f')]();})[_0x2be7('0xe')](function(){return sendServiceMail({'to':_0xdb7266[_0x2be7('0x35')]['email'],'subject':_0x2be7('0x40'),'text':'You\x20are\x20receiving\x20this\x20because\x20you\x20(or\x20someone\x20else)\x20have\x20requested\x20the\x20reset\x20of\x20the\x20password\x20for\x20your\x20account.\x0a\x0a'+'Please\x20click\x20on\x20the\x20following\x20link,\x20or\x20paste\x20this\x20into\x20your\x20browser\x20to\x20complete\x20the\x20process:\x0a\x0a'+_0x2be7('0x41')+_0xdb7266['headers']['host']+_0x2be7('0x42')+_0x2897bc+'\x0a\x0a'+_0x2be7('0x43')});})[_0x2be7('0xe')](function(){_0x2e572e[_0x2be7('0x2e')](0xc8)[_0x2be7('0x2f')]({'message':_0x2be7('0x44')});})['catch'](function(_0x3825a1){return handleError(_0x2e572e,0x1f4,_0x3825a1);});};exports[_0x2be7('0x45')]=function(_0x5a7a2b,_0x4fe1a2){return db[_0x2be7('0x3b')]['find']({'where':{'resetPasswordToken':_0x5a7a2b[_0x2be7('0x46')][_0x2be7('0x47')],'resetPasswordExpires':{'$gt':Date[_0x2be7('0x3e')]()}}})[_0x2be7('0xe')](function(_0x3498a3){if(!_0x3498a3){throw new Error('Password\x20reset\x20token\x20is\x20invalid\x20or\x20has\x20expired.');}return db[_0x2be7('0xa')]['findOne']({'attributes':['id',_0x2be7('0x48'),'enforcePasswordHistory',_0x2be7('0x49')]})[_0x2be7('0xe')](function(_0x768d9d){if(_0x768d9d[_0x2be7('0x48')])authService[_0x2be7('0x4a')](_0x5a7a2b[_0x2be7('0x35')][_0x2be7('0x10')]);if(!_0x768d9d[_0x2be7('0x4b')]||!_0x3498a3['previousPasswords'])return _0x3498a3;authService[_0x2be7('0x4c')](_0x5a7a2b['body'][_0x2be7('0x10')],_0x3498a3['previousPasswords'],_0x768d9d['passwordHistoryLimit']);return _0x3498a3;})[_0x2be7('0xe')](function(){_0x3498a3[_0x2be7('0x10')]=_0x5a7a2b[_0x2be7('0x35')][_0x2be7('0x10')];_0x3498a3[_0x2be7('0x4d')]=null;_0x3498a3['resetPasswordExpires']=null;return _0x3498a3[_0x2be7('0x3f')]();});})[_0x2be7('0xe')](function(){_0x4fe1a2['status'](0xc8)['send']({'message':_0x2be7('0x4e')});})[_0x2be7('0x1d')](function(_0x289584){return handleError(_0x4fe1a2,0x1f4,_0x289584);});};passport[_0x2be7('0x4f')](_0x2be7('0x31'),new LocalStrategy({'usernameField':_0x2be7('0xf'),'passwordField':_0x2be7('0x10')},function(_0x3390cb,_0x16df06,_0x58cebb){return localAuthenticate(db[_0x2be7('0x3b')],_0x3390cb,_0x16df06,_0x58cebb);})); \ No newline at end of file diff --git a/server/api/authLocal/index.js b/server/api/authLocal/index.js new file mode 100644 index 0000000..5381d83 --- /dev/null +++ b/server/api/authLocal/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x93d1=['forgot','/reset/:token','reset','Router','post','login'];(function(_0x2555d0,_0x4150a6){var _0x3bb486=function(_0x1eb89f){while(--_0x1eb89f){_0x2555d0['push'](_0x2555d0['shift']());}};_0x3bb486(++_0x4150a6);}(_0x93d1,0xab));var _0x193d=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x93d1[_0x3dd15e];return _0x231fd0;};'use strict';var express=require('express');var router=express[_0x193d('0x0')]();var controller=require('./authLocal.controller');router[_0x193d('0x1')]('/',controller[_0x193d('0x2')]);router['post']('/forgot',controller[_0x193d('0x3')]);router[_0x193d('0x1')](_0x193d('0x4'),controller[_0x193d('0x5')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/automation/automation.attributes.js b/server/api/automation/automation.attributes.js new file mode 100644 index 0000000..48d4756 --- /dev/null +++ b/server/api/automation/automation.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xad1f=['STRING','INTEGER','sequelize','exports'];(function(_0x112b01,_0x7fbb25){var _0x2af193=function(_0x43198c){while(--_0x43198c){_0x112b01['push'](_0x112b01['shift']());}};_0x2af193(++_0x7fbb25);}(_0xad1f,0x13e));var _0xfad1=function(_0xc83e25,_0x5b5aaa){_0xc83e25=_0xc83e25-0x0;var _0x3a8424=_0xad1f[_0xc83e25];return _0x3a8424;};'use strict';var Sequelize=require(_0xfad1('0x0'));module[_0xfad1('0x1')]={'name':{'type':Sequelize[_0xfad1('0x2')],'allowNull':![]},'channel':{'type':Sequelize['STRING']},'description':{'type':Sequelize[_0xfad1('0x2')]},'status':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'timeout':{'type':Sequelize[_0xfad1('0x3')],'defaultValue':0xa}}; \ No newline at end of file diff --git a/server/api/automation/automation.controller.js b/server/api/automation/automation.controller.js new file mode 100644 index 0000000..b0d06c8 --- /dev/null +++ b/server/api/automation/automation.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa180=['show','params','keys','rawAttributes','filters','fields','length','options','create','body','update','find','addConditions','Condition','ids','omit','findOne','getConditions','addActions','Action','getActions','eml-format','rimraf','zip-dir','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','count','set','Content-Range','reject','save','then','destroy','end','name','send','index','map','Automation','fieldName','type','key','model','query','attributes','intersection','hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','merge','VIRTUAL','includeAll','findAll','rows','catch'];(function(_0x5e9920,_0x3dbf38){var _0x1adeba=function(_0x3f9c1d){while(--_0x3f9c1d){_0x5e9920['push'](_0x5e9920['shift']());}};_0x1adeba(++_0x3dbf38);}(_0xa180,0x1b9));var _0x0a18=function(_0x1d272c,_0x337619){_0x1d272c=_0x1d272c-0x0;var _0x30423e=_0xa180[_0x1d272c];return _0x30423e;};'use strict';var emlformat=require(_0x0a18('0x0'));var rimraf=require(_0x0a18('0x1'));var zipdir=require(_0x0a18('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0a18('0x3'));var BPromise=require(_0x0a18('0x4'));var Mustache=require(_0x0a18('0x5'));var util=require('util');var path=require(_0x0a18('0x6'));var sox=require(_0x0a18('0x7'));var csv=require(_0x0a18('0x8'));var ejs=require(_0x0a18('0x9'));var fs=require('fs');var fs_extra=require(_0x0a18('0xa'));var _=require('lodash');var squel=require(_0x0a18('0xb'));var crypto=require(_0x0a18('0xc'));var jsforce=require(_0x0a18('0xd'));var deskjs=require(_0x0a18('0xe'));var toCsv=require(_0x0a18('0x8'));var querystring=require(_0x0a18('0xf'));var Papa=require('papaparse');var Redis=require(_0x0a18('0x10'));var authService=require(_0x0a18('0x11'));var qs=require(_0x0a18('0x12'));var as=require(_0x0a18('0x13'));var hardwareService=require(_0x0a18('0x14'));var logger=require('../../config/logger')(_0x0a18('0x15'));var utils=require('../../config/utils');var config=require(_0x0a18('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x0a18('0x17'))['db'];function respondWithStatusCode(_0x2ec77c,_0x560348){_0x560348=_0x560348||0xcc;return function(_0x1ec720){if(_0x1ec720){return _0x2ec77c[_0x0a18('0x18')](_0x560348);}return _0x2ec77c['status'](_0x560348)['end']();};}function respondWithResult(_0x281000,_0x52a0ff){_0x52a0ff=_0x52a0ff||0xc8;return function(_0x2a0cee){if(_0x2a0cee){return _0x281000[_0x0a18('0x19')](_0x52a0ff)[_0x0a18('0x1a')](_0x2a0cee);}};}function respondWithFilteredResult(_0x35573b,_0x1eb825){return function(_0x582a3f){if(_0x582a3f){var _0x2d1c0c=typeof _0x1eb825[_0x0a18('0x1b')]===_0x0a18('0x1c')&&typeof _0x1eb825['limit']==='undefined';var _0x35d370=_0x582a3f['count'];var _0x10b3af=_0x2d1c0c?0x0:_0x1eb825[_0x0a18('0x1b')];var _0x52cc51=_0x2d1c0c?_0x582a3f[_0x0a18('0x1d')]:_0x1eb825[_0x0a18('0x1b')]+_0x1eb825['limit'];var _0x48bccd;if(_0x52cc51>=_0x35d370){_0x52cc51=_0x35d370;_0x48bccd=0xc8;}else{_0x48bccd=0xce;}_0x35573b[_0x0a18('0x19')](_0x48bccd);return _0x35573b[_0x0a18('0x1e')](_0x0a18('0x1f'),_0x10b3af+'-'+_0x52cc51+'/'+_0x35d370)[_0x0a18('0x1a')](_0x582a3f);}return null;};}function patchUpdates(_0x319dc1){return function(_0x2c135d){try{jsonpatch['apply'](_0x2c135d,_0x319dc1,!![]);}catch(_0x45280e){return BPromise[_0x0a18('0x20')](_0x45280e);}return _0x2c135d[_0x0a18('0x21')]();};}function saveUpdates(_0x2a6c40,_0x27b4ca){return function(_0x19d8ed){if(_0x19d8ed){return _0x19d8ed['update'](_0x2a6c40)[_0x0a18('0x22')](function(_0x2f03cd){return _0x2f03cd;});}return null;};}function removeEntity(_0x2f387b,_0xe8c24c){return function(_0x2871ef){if(_0x2871ef){return _0x2871ef[_0x0a18('0x23')]()[_0x0a18('0x22')](function(){_0x2f387b[_0x0a18('0x19')](0xcc)[_0x0a18('0x24')]();});}};}function handleEntityNotFound(_0x28ebe3,_0x1f0aff){return function(_0x3d462a){if(!_0x3d462a){_0x28ebe3[_0x0a18('0x18')](0x194);}return _0x3d462a;};}function handleError(_0x1a4945,_0x512f93){_0x512f93=_0x512f93||0x1f4;return function(_0xa2dc5){logger['error'](_0xa2dc5['stack']);if(_0xa2dc5[_0x0a18('0x25')]){delete _0xa2dc5['name'];}_0x1a4945[_0x0a18('0x19')](_0x512f93)[_0x0a18('0x26')](_0xa2dc5);};}exports[_0x0a18('0x27')]=function(_0x424f6d,_0x22d579){var _0xd92825={},_0x2013b0={},_0x40e007={'count':0x0,'rows':[]};var _0x5a95ab=_[_0x0a18('0x28')](db[_0x0a18('0x29')]['rawAttributes'],function(_0x26ae95){return{'name':_0x26ae95[_0x0a18('0x2a')],'type':_0x26ae95[_0x0a18('0x2b')][_0x0a18('0x2c')]};});_0x2013b0[_0x0a18('0x2d')]=_[_0x0a18('0x28')](_0x5a95ab,'name');_0x2013b0[_0x0a18('0x2e')]=_['keys'](_0x424f6d[_0x0a18('0x2e')]);_0x2013b0['filters']=_['intersection'](_0x2013b0[_0x0a18('0x2d')],_0x2013b0[_0x0a18('0x2e')]);_0xd92825[_0x0a18('0x2f')]=_[_0x0a18('0x30')](_0x2013b0[_0x0a18('0x2d')],qs['fields'](_0x424f6d[_0x0a18('0x2e')]['fields']));_0xd92825[_0x0a18('0x2f')]=_0xd92825[_0x0a18('0x2f')]['length']?_0xd92825[_0x0a18('0x2f')]:_0x2013b0[_0x0a18('0x2d')];if(!_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x31')](_0x0a18('0x32'))){_0xd92825['limit']=qs[_0x0a18('0x33')](_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x33')]);_0xd92825[_0x0a18('0x1b')]=qs[_0x0a18('0x1b')](_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x1b')]);}_0xd92825[_0x0a18('0x34')]=qs[_0x0a18('0x35')](_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x35')]);_0xd92825['where']=qs['filters'](_[_0x0a18('0x36')](_0x424f6d[_0x0a18('0x2e')],_0x2013b0['filters']),_0x5a95ab);if(_0x424f6d['query'][_0x0a18('0x37')]){_0xd92825[_0x0a18('0x38')]=_[_0x0a18('0x39')](_0xd92825[_0x0a18('0x38')],{'$or':_['map'](_0x5a95ab,function(_0x55abf5){if(_0x55abf5[_0x0a18('0x2b')]!==_0x0a18('0x3a')){var _0x31e099={};_0x31e099[_0x55abf5['name']]={'$like':'%'+_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x37')]+'%'};return _0x31e099;}})});}_0xd92825=_[_0x0a18('0x39')]({},_0xd92825,_0x424f6d['options']);var _0x555b2f={'where':_0xd92825[_0x0a18('0x38')]};return db[_0x0a18('0x29')]['count'](_0x555b2f)[_0x0a18('0x22')](function(_0x53733b){_0x40e007[_0x0a18('0x1d')]=_0x53733b;if(_0x424f6d[_0x0a18('0x2e')][_0x0a18('0x3b')]){_0xd92825['include']=[{'all':!![]}];}return db[_0x0a18('0x29')][_0x0a18('0x3c')](_0xd92825);})[_0x0a18('0x22')](function(_0x36d4e7){_0x40e007[_0x0a18('0x3d')]=_0x36d4e7;return _0x40e007;})[_0x0a18('0x22')](respondWithFilteredResult(_0x22d579,_0xd92825))[_0x0a18('0x3e')](handleError(_0x22d579,null));};exports[_0x0a18('0x3f')]=function(_0x37e4bf,_0x2394b2){var _0x98a1cf={'raw':![],'where':{'id':_0x37e4bf[_0x0a18('0x40')]['id']}},_0x128271={};_0x128271[_0x0a18('0x2d')]=_[_0x0a18('0x41')](db[_0x0a18('0x29')][_0x0a18('0x42')]);_0x128271['query']=_[_0x0a18('0x41')](_0x37e4bf['query']);_0x128271[_0x0a18('0x43')]=_[_0x0a18('0x30')](_0x128271[_0x0a18('0x2d')],_0x128271[_0x0a18('0x2e')]);_0x98a1cf[_0x0a18('0x2f')]=_['intersection'](_0x128271[_0x0a18('0x2d')],qs[_0x0a18('0x44')](_0x37e4bf['query'][_0x0a18('0x44')]));_0x98a1cf[_0x0a18('0x2f')]=_0x98a1cf['attributes'][_0x0a18('0x45')]?_0x98a1cf[_0x0a18('0x2f')]:_0x128271[_0x0a18('0x2d')];if(_0x37e4bf[_0x0a18('0x2e')][_0x0a18('0x3b')]){_0x98a1cf['include']=[{'all':!![]}];}_0x98a1cf=_[_0x0a18('0x39')]({},_0x98a1cf,_0x37e4bf[_0x0a18('0x46')]);return db['Automation']['find'](_0x98a1cf)[_0x0a18('0x22')](handleEntityNotFound(_0x2394b2,null))[_0x0a18('0x22')](respondWithResult(_0x2394b2,null))[_0x0a18('0x3e')](handleError(_0x2394b2,null));};exports[_0x0a18('0x47')]=function(_0x48b137,_0x2d3120){return db[_0x0a18('0x29')][_0x0a18('0x47')](_0x48b137[_0x0a18('0x48')],{})[_0x0a18('0x22')](respondWithResult(_0x2d3120,0xc9))[_0x0a18('0x3e')](handleError(_0x2d3120,null));};exports[_0x0a18('0x49')]=function(_0x44a83d,_0x28e13f){if(_0x44a83d[_0x0a18('0x48')]['id']){delete _0x44a83d[_0x0a18('0x48')]['id'];}return db[_0x0a18('0x29')][_0x0a18('0x4a')]({'where':{'id':_0x44a83d['params']['id']}})[_0x0a18('0x22')](handleEntityNotFound(_0x28e13f,null))[_0x0a18('0x22')](saveUpdates(_0x44a83d['body'],null))[_0x0a18('0x22')](respondWithResult(_0x28e13f,null))[_0x0a18('0x3e')](handleError(_0x28e13f,null));};exports['destroy']=function(_0x267117,_0x205d4a){return db['Automation'][_0x0a18('0x4a')]({'where':{'id':_0x267117[_0x0a18('0x40')]['id']}})['then'](handleEntityNotFound(_0x205d4a,null))[_0x0a18('0x22')](removeEntity(_0x205d4a,null))[_0x0a18('0x3e')](handleError(_0x205d4a,null));};exports[_0x0a18('0x4b')]=function(_0x12e869,_0x3af4c9,_0x1dd96a){return db[_0x0a18('0x4c')][_0x0a18('0x4a')]({'where':{'id':_0x12e869[_0x0a18('0x40')]['id']}})[_0x0a18('0x22')](handleEntityNotFound(_0x3af4c9,null))[_0x0a18('0x22')](function(_0x214fb3){if(_0x214fb3){return _0x214fb3[_0x0a18('0x4b')](_0x12e869[_0x0a18('0x48')][_0x0a18('0x4d')],_[_0x0a18('0x4e')](_0x12e869[_0x0a18('0x48')],[_0x0a18('0x4d'),'id'])||{});}})[_0x0a18('0x22')](respondWithResult(_0x3af4c9,null))[_0x0a18('0x3e')](handleError(_0x3af4c9,null));};exports['getConditions']=function(_0x503d37,_0x4fd4ca,_0x307d9d){var _0xadce1b={};var _0x56a3ec={};var _0x4aca19;var _0x19bbc6;return db[_0x0a18('0x29')][_0x0a18('0x4f')]({'where':{'id':_0x503d37['params']['id']}})[_0x0a18('0x22')](handleEntityNotFound(_0x4fd4ca,null))[_0x0a18('0x22')](function(_0x1477e6){if(_0x1477e6){_0x4aca19=_0x1477e6;_0x56a3ec[_0x0a18('0x2d')]=_[_0x0a18('0x41')](db[_0x0a18('0x4c')]['rawAttributes']);_0x56a3ec[_0x0a18('0x2e')]=_[_0x0a18('0x41')](_0x503d37[_0x0a18('0x2e')]);_0x56a3ec[_0x0a18('0x43')]=_['intersection'](_0x56a3ec['model'],_0x56a3ec[_0x0a18('0x2e')]);_0xadce1b[_0x0a18('0x2f')]=_['intersection'](_0x56a3ec[_0x0a18('0x2d')],qs[_0x0a18('0x44')](_0x503d37[_0x0a18('0x2e')][_0x0a18('0x44')]));_0xadce1b[_0x0a18('0x2f')]=_0xadce1b[_0x0a18('0x2f')][_0x0a18('0x45')]?_0xadce1b[_0x0a18('0x2f')]:_0x56a3ec[_0x0a18('0x2d')];_0xadce1b[_0x0a18('0x34')]=qs[_0x0a18('0x35')](_0x503d37['query'][_0x0a18('0x35')]);_0xadce1b['where']=qs[_0x0a18('0x43')](_['pick'](_0x503d37[_0x0a18('0x2e')],_0x56a3ec['filters']));if(_0x503d37[_0x0a18('0x2e')][_0x0a18('0x37')]){_0xadce1b['where']=_[_0x0a18('0x39')](_0xadce1b[_0x0a18('0x38')],{'$or':_[_0x0a18('0x28')](_0xadce1b['attributes'],function(_0x373f46){var _0x5b1890={};_0x5b1890[_0x373f46]={'$like':'%'+_0x503d37[_0x0a18('0x2e')][_0x0a18('0x37')]+'%'};return _0x5b1890;})});}_0xadce1b=_[_0x0a18('0x39')]({},_0xadce1b,_0x503d37[_0x0a18('0x46')]);return _0x4aca19[_0x0a18('0x50')](_0xadce1b);}})[_0x0a18('0x22')](function(_0x387bf9){if(_0x387bf9){_0x19bbc6=_0x387bf9[_0x0a18('0x45')];if(!_0x503d37[_0x0a18('0x2e')][_0x0a18('0x31')](_0x0a18('0x32'))){_0xadce1b[_0x0a18('0x33')]=qs[_0x0a18('0x33')](_0x503d37['query'][_0x0a18('0x33')]);_0xadce1b[_0x0a18('0x1b')]=qs[_0x0a18('0x1b')](_0x503d37[_0x0a18('0x2e')][_0x0a18('0x1b')]);}return _0x4aca19['getConditions'](_0xadce1b);}})[_0x0a18('0x22')](function(_0x1fda0b){if(_0x1fda0b){return _0x1fda0b?{'count':_0x19bbc6,'rows':_0x1fda0b}:null;}})[_0x0a18('0x22')](respondWithResult(_0x4fd4ca,null))['catch'](handleError(_0x4fd4ca,null));};exports[_0x0a18('0x51')]=function(_0x27e0a1,_0x203c2a,_0x15fd9a){return db[_0x0a18('0x52')]['find']({'where':{'id':_0x27e0a1[_0x0a18('0x40')]['id']}})['then'](handleEntityNotFound(_0x203c2a,null))[_0x0a18('0x22')](function(_0x37009f){if(_0x37009f){return _0x37009f[_0x0a18('0x51')](_0x27e0a1[_0x0a18('0x48')][_0x0a18('0x4d')],_['omit'](_0x27e0a1[_0x0a18('0x48')],[_0x0a18('0x4d'),'id'])||{});}})[_0x0a18('0x22')](respondWithResult(_0x203c2a,null))[_0x0a18('0x3e')](handleError(_0x203c2a,null));};exports[_0x0a18('0x53')]=function(_0x4f8a92,_0x46dcc5,_0x20a59a){var _0x4cd50a={};var _0x580cf8={};var _0x34eb9d;var _0x35acbc;return db['Automation'][_0x0a18('0x4f')]({'where':{'id':_0x4f8a92[_0x0a18('0x40')]['id']}})[_0x0a18('0x22')](handleEntityNotFound(_0x46dcc5,null))[_0x0a18('0x22')](function(_0x1f3ed1){if(_0x1f3ed1){_0x34eb9d=_0x1f3ed1;_0x580cf8[_0x0a18('0x2d')]=_[_0x0a18('0x41')](db['Action'][_0x0a18('0x42')]);_0x580cf8[_0x0a18('0x2e')]=_['keys'](_0x4f8a92[_0x0a18('0x2e')]);_0x580cf8[_0x0a18('0x43')]=_[_0x0a18('0x30')](_0x580cf8[_0x0a18('0x2d')],_0x580cf8[_0x0a18('0x2e')]);_0x4cd50a['attributes']=_['intersection'](_0x580cf8[_0x0a18('0x2d')],qs[_0x0a18('0x44')](_0x4f8a92[_0x0a18('0x2e')]['fields']));_0x4cd50a[_0x0a18('0x2f')]=_0x4cd50a[_0x0a18('0x2f')][_0x0a18('0x45')]?_0x4cd50a[_0x0a18('0x2f')]:_0x580cf8[_0x0a18('0x2d')];_0x4cd50a[_0x0a18('0x34')]=qs[_0x0a18('0x35')](_0x4f8a92[_0x0a18('0x2e')]['sort']);_0x4cd50a[_0x0a18('0x38')]=qs[_0x0a18('0x43')](_[_0x0a18('0x36')](_0x4f8a92['query'],_0x580cf8[_0x0a18('0x43')]));if(_0x4f8a92[_0x0a18('0x2e')][_0x0a18('0x37')]){_0x4cd50a['where']=_[_0x0a18('0x39')](_0x4cd50a[_0x0a18('0x38')],{'$or':_['map'](_0x4cd50a[_0x0a18('0x2f')],function(_0x519359){var _0x5c28d8={};_0x5c28d8[_0x519359]={'$like':'%'+_0x4f8a92[_0x0a18('0x2e')][_0x0a18('0x37')]+'%'};return _0x5c28d8;})});}_0x4cd50a=_[_0x0a18('0x39')]({},_0x4cd50a,_0x4f8a92['options']);return _0x34eb9d[_0x0a18('0x53')](_0x4cd50a);}})[_0x0a18('0x22')](function(_0x28c460){if(_0x28c460){_0x35acbc=_0x28c460[_0x0a18('0x45')];if(!_0x4f8a92[_0x0a18('0x2e')][_0x0a18('0x31')](_0x0a18('0x32'))){_0x4cd50a[_0x0a18('0x33')]=qs['limit'](_0x4f8a92['query'][_0x0a18('0x33')]);_0x4cd50a[_0x0a18('0x1b')]=qs[_0x0a18('0x1b')](_0x4f8a92[_0x0a18('0x2e')][_0x0a18('0x1b')]);}return _0x34eb9d['getActions'](_0x4cd50a);}})['then'](function(_0xc9a07f){if(_0xc9a07f){return _0xc9a07f?{'count':_0x35acbc,'rows':_0xc9a07f}:null;}})[_0x0a18('0x22')](respondWithResult(_0x46dcc5,null))[_0x0a18('0x3e')](handleError(_0x46dcc5,null));}; \ No newline at end of file diff --git a/server/api/automation/automation.model.js b/server/api/automation/automation.model.js new file mode 100644 index 0000000..9834720 --- /dev/null +++ b/server/api/automation/automation.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8709=['../../config/environment','exports','define','Automation','tools_automations','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x8709,0x109));var _0x9870=function(_0x324f7d,_0x3a0184){_0x324f7d=_0x324f7d-0x0;var _0x158d1e=_0x8709[_0x324f7d];return _0x158d1e;};'use strict';var _=require('lodash');var util=require(_0x9870('0x0'));var logger=require(_0x9870('0x1'))(_0x9870('0x2'));var moment=require(_0x9870('0x3'));var BPromise=require(_0x9870('0x4'));var rp=require(_0x9870('0x5'));var fs=require('fs');var path=require(_0x9870('0x6'));var rimraf=require(_0x9870('0x7'));var config=require(_0x9870('0x8'));var attributes=require('./automation.attributes');module[_0x9870('0x9')]=function(_0x35292a,_0x2a14d8){return _0x35292a[_0x9870('0xa')](_0x9870('0xb'),attributes,{'tableName':_0x9870('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/automation/automation.rpc.js b/server/api/automation/automation.rpc.js new file mode 100644 index 0000000..5e85bc6 --- /dev/null +++ b/server/api/automation/automation.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x39d0=['rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','Automation,\x20%s,\x20%s,\x20%s','error','code','Automation,\x20%s,\x20%s','message','result','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x45783c,_0x49c56d){var _0x1161da=function(_0x3c5d41){while(--_0x3c5d41){_0x45783c['push'](_0x45783c['shift']());}};_0x1161da(++_0x49c56d);}(_0x39d0,0x144));var _0x039d=function(_0x22ebfb,_0x936122){_0x22ebfb=_0x22ebfb-0x0;var _0x1eaee0=_0x39d0[_0x22ebfb];return _0x1eaee0;};'use strict';var _=require(_0x039d('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x039d('0x1'));var rs=require(_0x039d('0x2'));var fs=require('fs');var Redis=require(_0x039d('0x3'));var db=require(_0x039d('0x4'))['db'];var utils=require(_0x039d('0x5'));var logger=require('../../config/logger')(_0x039d('0x6'));var config=require(_0x039d('0x7'));var jayson=require(_0x039d('0x8'));var client=jayson[_0x039d('0x9')][_0x039d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x7dcc60,_0x2f8c4b,_0x4705e8){return new BPromise(function(_0x425f6e,_0x210090){return client[_0x039d('0xb')](_0x7dcc60,_0x4705e8)['then'](function(_0x591f97){logger[_0x039d('0xc')]('Automation,\x20%s,\x20%s',_0x2f8c4b,_0x039d('0xd'));logger[_0x039d('0xe')](_0x039d('0xf'),_0x2f8c4b,_0x039d('0xd'),JSON['stringify'](_0x591f97));if(_0x591f97[_0x039d('0x10')]){if(_0x591f97[_0x039d('0x10')][_0x039d('0x11')]===0x1f4){logger['error'](_0x039d('0x12'),_0x2f8c4b,_0x591f97[_0x039d('0x10')][_0x039d('0x13')]);return _0x210090(_0x591f97[_0x039d('0x10')][_0x039d('0x13')]);}logger[_0x039d('0x10')](_0x039d('0x12'),_0x2f8c4b,_0x591f97['error']['message']);return _0x425f6e(_0x591f97[_0x039d('0x10')][_0x039d('0x13')]);}else{logger[_0x039d('0xc')](_0x039d('0x12'),_0x2f8c4b,_0x039d('0xd'));_0x425f6e(_0x591f97[_0x039d('0x14')]['message']);}})[_0x039d('0x15')](function(_0x226853){logger[_0x039d('0x10')]('Automation,\x20%s,\x20%s',_0x2f8c4b,_0x226853);_0x210090(_0x226853);});});} \ No newline at end of file diff --git a/server/api/automation/index.js b/server/api/automation/index.js new file mode 100644 index 0000000..22e71dd --- /dev/null +++ b/server/api/automation/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x56ff=['get','index','isAuthenticated','/:id/conditions','getConditions','getActions','post','create','addConditions','/:id/actions','addActions','put','update','delete','/:id','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./automation.controller'];(function(_0x2ac856,_0x5b3cf3){var _0x522d28=function(_0xe7b035){while(--_0xe7b035){_0x2ac856['push'](_0x2ac856['shift']());}};_0x522d28(++_0x5b3cf3);}(_0x56ff,0xb9));var _0xf56f=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x56ff[_0x321bb2];return _0x9c12ed;};'use strict';var multer=require(_0xf56f('0x0'));var util=require(_0xf56f('0x1'));var path=require(_0xf56f('0x2'));var timeout=require(_0xf56f('0x3'));var express=require(_0xf56f('0x4'));var router=express[_0xf56f('0x5')]();var fs_extra=require(_0xf56f('0x6'));var auth=require(_0xf56f('0x7'));var interaction=require(_0xf56f('0x8'));var config=require(_0xf56f('0x9'));var controller=require(_0xf56f('0xa'));router[_0xf56f('0xb')]('/',auth['isAuthenticated'](),controller[_0xf56f('0xc')]);router[_0xf56f('0xb')]('/:id',auth[_0xf56f('0xd')](),controller['show']);router[_0xf56f('0xb')](_0xf56f('0xe'),auth[_0xf56f('0xd')](),controller[_0xf56f('0xf')]);router['get']('/:id/actions',auth['isAuthenticated'](),controller[_0xf56f('0x10')]);router[_0xf56f('0x11')]('/',auth[_0xf56f('0xd')](),controller[_0xf56f('0x12')]);router['post']('/:id/conditions',auth['isAuthenticated'](),controller[_0xf56f('0x13')]);router[_0xf56f('0x11')](_0xf56f('0x14'),auth[_0xf56f('0xd')](),controller[_0xf56f('0x15')]);router[_0xf56f('0x16')]('/:id',auth['isAuthenticated'](),controller[_0xf56f('0x17')]);router[_0xf56f('0x18')](_0xf56f('0x19'),auth[_0xf56f('0xd')](),controller[_0xf56f('0x1a')]);module[_0xf56f('0x1b')]=router; \ No newline at end of file diff --git a/server/api/campaign/campaign.attributes.js b/server/api/campaign/campaign.attributes.js new file mode 100644 index 0000000..bd8a04e --- /dev/null +++ b/server/api/campaign/campaign.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c33=['UNSIGNED','Max\x20200\x20calls.','Originate\x20Timeout\x20Seconds\x20(min:1,\x20max:999)','Congestion\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#NoAnswer\x20Retry\x20(min:1,\x20max:999)','NoAnswer\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#Global\x20Max\x20Retry\x20(min:1,\x20max:999)','07:00-22:00,*,*,*','always','onlyIfOpen','Active/Disactive\x20AMD','#AMD\x20Greeting','#AMD\x20After\x20Greeting\x20Silence','#AMD\x20Total\x20Analysis\x20Time','#AMD\x20Between\x20Words\x20Silence','#AMD\x20Maximum\x20Number\x20Of\x20Words','DESC','ASC','Cut\x20Digit\x20(min:1,\x20max:15)','#NoSuchNumber\x20Retry\x20(min:1,\x20max:999)','NoSuchNumber\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','Drop\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#Abandoned\x20Retry\x20(min:1,\x20max:999)','#Machine\x20Retry\x20(min:1,\x20max:999)','#AgentReject\x20Retry\x20(min:1,\x20max:999)','AgentReject\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','exports','STRING','name','ENUM','ivr','BOOLEAN','INTEGER'];(function(_0x6116ee,_0x316cb9){var _0x58320a=function(_0x2b6fdd){while(--_0x2b6fdd){_0x6116ee['push'](_0x6116ee['shift']());}};_0x58320a(++_0x316cb9);}(_0x9c33,0xe0));var _0x39c3=function(_0xe73080,_0x24c56d){_0xe73080=_0xe73080-0x0;var _0x12cbc4=_0x9c33[_0xe73080];return _0x12cbc4;};'use strict';var Sequelize=require('sequelize');module[_0x39c3('0x0')]={'name':{'type':Sequelize[_0x39c3('0x1')],'unique':_0x39c3('0x2'),'allowNull':![],'validate':{'is':/[A-Za-z0-9._\\+*!-]+/,'notEmpty':!![]}},'type':{'type':Sequelize[_0x39c3('0x3')](_0x39c3('0x4')),'allowNull':![],'defaultValue':_0x39c3('0x4')},'description':{'type':Sequelize[_0x39c3('0x1')]},'active':{'type':Sequelize[_0x39c3('0x5')],'defaultValue':0x0,'comment':'Active/Disactive\x20Campaign'},'limitCalls':{'type':Sequelize[_0x39c3('0x6')](0x4)[_0x39c3('0x7')],'defaultValue':0x1e,'validate':{'min':0x1,'max':0xc8},'comment':_0x39c3('0x8')},'dialOriginateCallerIdName':{'type':Sequelize[_0x39c3('0x1')]},'dialOriginateCallerIdNumber':{'type':Sequelize[_0x39c3('0x1')]},'dialOriginateTimeout':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x1e,'validate':{'min':0x1,'max':0x3e7},'comment':_0x39c3('0x9')},'dialCongestionMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':'#Congestion\x20Retry\x20(min:1,\x20max:999)'},'dialCongestionRetryFrequency':{'type':Sequelize[_0x39c3('0x6')](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0x39c3('0xa')},'dialBusyMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':'#Busy\x20Retry\x20(min:1,\x20max:999)'},'dialBusyRetryFrequency':{'type':Sequelize[_0x39c3('0x6')](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':'Busy\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)'},'dialNoAnswerMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'comment':_0x39c3('0xb')},'dialNoAnswerRetryFrequency':{'type':Sequelize['INTEGER'](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0x39c3('0xc')},'dialGlobalMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)['UNSIGNED'],'validate':{'min':0x1,'max':0x3e7},'defaultValue':0x4,'comment':_0x39c3('0xd')},'dialTimezone':{'type':Sequelize[_0x39c3('0x1')],'defaultValue':null},'dialGlobalInterval':{'type':Sequelize[_0x39c3('0x1')],'defaultValue':_0x39c3('0xe')},'dialCheckDuplicateType':{'type':Sequelize[_0x39c3('0x3')](_0x39c3('0xf'),'never',_0x39c3('0x10')),'defaultValue':_0x39c3('0xf')},'dialAMDActive':{'type':Sequelize[_0x39c3('0x5')],'defaultValue':0x0,'comment':_0x39c3('0x11')},'dialAMDInitialSilence':{'type':Sequelize[_0x39c3('0x6')](0x9)['UNSIGNED'],'defaultValue':0x9c4,'validate':{'min':0x0},'comment':'#AMD\x20Initial\x20Silence'},'dialAMDGreeting':{'type':Sequelize[_0x39c3('0x6')](0x9)[_0x39c3('0x7')],'defaultValue':0x5dc,'validate':{'min':0x0},'comment':_0x39c3('0x12')},'dialAMDAfterGreetingSilence':{'type':Sequelize[_0x39c3('0x6')](0x9)[_0x39c3('0x7')],'defaultValue':0x320,'validate':{'min':0x0},'comment':_0x39c3('0x13')},'dialAMDTotalAnalysisTime':{'type':Sequelize[_0x39c3('0x6')](0x9)['UNSIGNED'],'defaultValue':0x1388,'validate':{'min':0x0},'comment':_0x39c3('0x14')},'dialAMDMinWordLength':{'type':Sequelize['INTEGER'](0x9)[_0x39c3('0x7')],'defaultValue':0x64,'validate':{'min':0x0},'comment':'#AMD\x20Min\x20Word\x20Length'},'dialAMDBetweenWordsSilence':{'type':Sequelize[_0x39c3('0x6')](0x9)[_0x39c3('0x7')],'defaultValue':0x32,'validate':{'min':0x0},'comment':_0x39c3('0x15')},'dialAMDMaximumNumberOfWords':{'type':Sequelize[_0x39c3('0x6')](0x9)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x0},'comment':_0x39c3('0x16')},'dialAMDSilenceThreshold':{'type':Sequelize[_0x39c3('0x6')](0x5)[_0x39c3('0x7')],'validate':{'min':0x0,'max':0x7fff},'defaultValue':0x100,'comment':'#AMD\x20Silence\x20Threshold\x20(min:0,\x20max:32767)'},'dialAMDMaximumWordLength':{'type':Sequelize[_0x39c3('0x6')](0x9)[_0x39c3('0x7')],'defaultValue':0x1388,'validate':{'min':0x0},'comment':'#AMD\x20Maximum\x20Word\x20Length'},'dialOrderByScheduledAt':{'type':Sequelize[_0x39c3('0x3')](_0x39c3('0x17'),_0x39c3('0x18')),'defaultValue':_0x39c3('0x17')},'dialPrefix':{'type':Sequelize[_0x39c3('0x1')],'defaultValue':null},'dialRandomLastDigitCallerIdNumber':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'validate':{'min':0x0,'max':0xf},'defaultValue':0x0,'comment':'Random\x20Last\x20Digit\x20(min:1,\x20max:15)'},'dialCutDigit':{'type':Sequelize[_0x39c3('0x6')](0x3)['UNSIGNED'],'validate':{'min':0x0,'max':0xf},'defaultValue':0x0,'comment':_0x39c3('0x19')},'dialNoSuchNumberMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0x39c3('0x1a')},'dialNoSuchNumberRetryFrequency':{'type':Sequelize['INTEGER'](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0x39c3('0x1b')},'dialDropMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)['UNSIGNED'],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':'#Drop\x20Retry\x20(min:1,\x20max:999)'},'dialDropRetryFrequency':{'type':Sequelize[_0x39c3('0x6')](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0x39c3('0x1c')},'dialAbandonedMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0x39c3('0x1d')},'dialAbandonedRetryFrequency':{'type':Sequelize[_0x39c3('0x6')](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':'Abandoned\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)'},'dialMachineMaxRetry':{'type':Sequelize['INTEGER'](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0x39c3('0x1e')},'dialMachineRetryFrequency':{'type':Sequelize[_0x39c3('0x6')](0x5)['UNSIGNED'],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':'Machine\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)'},'dialAgentRejectMaxRetry':{'type':Sequelize[_0x39c3('0x6')](0x3)[_0x39c3('0x7')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0x39c3('0x1f')},'dialAgentRejectRetryFrequency':{'type':Sequelize['INTEGER'](0x5)[_0x39c3('0x7')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0x39c3('0x20')}}; \ No newline at end of file diff --git a/server/api/campaign/campaign.controller.js b/server/api/campaign/campaign.controller.js new file mode 100644 index 0000000..aa08646 --- /dev/null +++ b/server/api/campaign/campaign.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeb43=['fromQuery','scheduledAt','ContactId','select','phone','field','CmListId','toString','ListId','from','cm_contacts','deletedAt\x20IS\x20NULL','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','CampaignId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','onlyIfOpen','insert','NOW()','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','cmHopperId','OrderBy','h.id','ci.item','cm_contact_has_items','join','h.ListId\x20=\x20?','h.CampaignId=?','push','sequelize','all','removeLists','CmList','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','eml-format','rimraf','zip-dir','request-promise','mustache','util','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','status','set','Content-Range','apply','reject','save','update','destroy','get','IvrCampaigns','UserProfileResource','then','stack','name','index','map','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','Campaign','includeAll','include','findAll','rows','show','params','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','catch','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','omit','createdAt','updatedAt','userProfileId','autoAssociation','findOne','CmHopper','length','pick','CmHopperHistory','CampaignId','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','format','YYYY-MM-DD\x20HH:mm:ss','addLists','ids','spread','dialCheckDuplicateType','always','into','cm_hopper'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xeb43,0x149));var _0x3eb4=function(_0x1fd5eb,_0x235203){_0x1fd5eb=_0x1fd5eb-0x0;var _0x102365=_0xeb43[_0x1fd5eb];return _0x102365;};'use strict';var emlformat=require(_0x3eb4('0x0'));var rimraf=require(_0x3eb4('0x1'));var zipdir=require(_0x3eb4('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x3eb4('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x3eb4('0x4'));var util=require(_0x3eb4('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0x3eb4('0x6'));var ejs=require(_0x3eb4('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3eb4('0x8'));var squel=require('squel');var crypto=require(_0x3eb4('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x3eb4('0xa'));var toCsv=require(_0x3eb4('0x6'));var querystring=require(_0x3eb4('0xb'));var Papa=require(_0x3eb4('0xc'));var Redis=require(_0x3eb4('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x3eb4('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3eb4('0xf'));var logger=require(_0x3eb4('0x10'))(_0x3eb4('0x11'));var utils=require(_0x3eb4('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x3eb4('0x13'));var db=require(_0x3eb4('0x14'))['db'];function respondWithStatusCode(_0x282ffa,_0x10e49e){_0x10e49e=_0x10e49e||0xcc;return function(_0x1e738e){if(_0x1e738e){return _0x282ffa[_0x3eb4('0x15')](_0x10e49e);}return _0x282ffa['status'](_0x10e49e)[_0x3eb4('0x16')]();};}function respondWithResult(_0x4caa07,_0x5549e5){_0x5549e5=_0x5549e5||0xc8;return function(_0x45342a){if(_0x45342a){return _0x4caa07['status'](_0x5549e5)[_0x3eb4('0x17')](_0x45342a);}};}function respondWithFilteredResult(_0x7d975e,_0x450a5e){return function(_0x123861){if(_0x123861){var _0xc5b9c2=typeof _0x450a5e[_0x3eb4('0x18')]===_0x3eb4('0x19')&&typeof _0x450a5e[_0x3eb4('0x1a')]===_0x3eb4('0x19');var _0x1af3ed=_0x123861['count'];var _0x3fb1c0=_0xc5b9c2?0x0:_0x450a5e[_0x3eb4('0x18')];var _0x1fcc85=_0xc5b9c2?_0x123861[_0x3eb4('0x1b')]:_0x450a5e[_0x3eb4('0x18')]+_0x450a5e[_0x3eb4('0x1a')];var _0x175d3c;if(_0x1fcc85>=_0x1af3ed){_0x1fcc85=_0x1af3ed;_0x175d3c=0xc8;}else{_0x175d3c=0xce;}_0x7d975e[_0x3eb4('0x1c')](_0x175d3c);return _0x7d975e[_0x3eb4('0x1d')](_0x3eb4('0x1e'),_0x3fb1c0+'-'+_0x1fcc85+'/'+_0x1af3ed)['json'](_0x123861);}return null;};}function patchUpdates(_0x55fe47){return function(_0x276934){try{jsonpatch[_0x3eb4('0x1f')](_0x276934,_0x55fe47,!![]);}catch(_0x25ee8d){return BPromise[_0x3eb4('0x20')](_0x25ee8d);}return _0x276934[_0x3eb4('0x21')]();};}function saveUpdates(_0x47b4bd,_0x35c4ec){return function(_0x5eb01d){if(_0x5eb01d){return _0x5eb01d[_0x3eb4('0x22')](_0x47b4bd)['then'](function(_0x2edf82){return _0x2edf82;});}return null;};}function removeEntity(_0x425457,_0x1e87a6){return function(_0x1c2f04){if(_0x1c2f04){return _0x1c2f04[_0x3eb4('0x23')]()['then'](function(){var _0x1b4c97=_0x1c2f04[_0x3eb4('0x24')]({'plain':!![]});var _0x5b8149=_0x3eb4('0x25');return db[_0x3eb4('0x26')][_0x3eb4('0x23')]({'where':{'type':_0x5b8149,'resourceId':_0x1b4c97['id']}})[_0x3eb4('0x27')](function(){return _0x1c2f04;});})['then'](function(){_0x425457[_0x3eb4('0x1c')](0xcc)[_0x3eb4('0x16')]();});}};}function handleEntityNotFound(_0x96d1e,_0x5303f2){return function(_0x50684f){if(!_0x50684f){_0x96d1e[_0x3eb4('0x15')](0x194);}return _0x50684f;};}function handleError(_0x281a5a,_0x3fd1a7){_0x3fd1a7=_0x3fd1a7||0x1f4;return function(_0x51ef72){logger['error'](_0x51ef72[_0x3eb4('0x28')]);if(_0x51ef72['name']){delete _0x51ef72[_0x3eb4('0x29')];}_0x281a5a['status'](_0x3fd1a7)['send'](_0x51ef72);};}exports[_0x3eb4('0x2a')]=function(_0x5975e4,_0x3d9af8){var _0x2ba4fe={},_0xc8bb50={},_0xb55d7e={'count':0x0,'rows':[]};var _0x43e992=_[_0x3eb4('0x2b')](db['Campaign']['rawAttributes'],function(_0x248e37){return{'name':_0x248e37[_0x3eb4('0x2c')],'type':_0x248e37[_0x3eb4('0x2d')][_0x3eb4('0x2e')]};});_0xc8bb50[_0x3eb4('0x2f')]=_['map'](_0x43e992,_0x3eb4('0x29'));_0xc8bb50[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x5975e4[_0x3eb4('0x30')]);_0xc8bb50[_0x3eb4('0x32')]=_['intersection'](_0xc8bb50['model'],_0xc8bb50[_0x3eb4('0x30')]);_0x2ba4fe[_0x3eb4('0x33')]=_[_0x3eb4('0x34')](_0xc8bb50[_0x3eb4('0x2f')],qs[_0x3eb4('0x35')](_0x5975e4[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x2ba4fe['attributes']=_0x2ba4fe[_0x3eb4('0x33')]['length']?_0x2ba4fe[_0x3eb4('0x33')]:_0xc8bb50['model'];if(!_0x5975e4[_0x3eb4('0x30')][_0x3eb4('0x36')](_0x3eb4('0x37'))){_0x2ba4fe['limit']=qs['limit'](_0x5975e4[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x2ba4fe[_0x3eb4('0x18')]=qs[_0x3eb4('0x18')](_0x5975e4[_0x3eb4('0x30')]['offset']);}_0x2ba4fe[_0x3eb4('0x38')]=qs[_0x3eb4('0x39')](_0x5975e4['query'][_0x3eb4('0x39')]);_0x2ba4fe[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_['pick'](_0x5975e4['query'],_0xc8bb50[_0x3eb4('0x32')]),_0x43e992);if(_0x5975e4['query'][_0x3eb4('0x3b')]){_0x2ba4fe[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x2ba4fe[_0x3eb4('0x3a')],{'$or':_['map'](_0x43e992,function(_0x2e62e1){if(_0x2e62e1[_0x3eb4('0x2d')]!==_0x3eb4('0x3d')){var _0x4ede9a={};_0x4ede9a[_0x2e62e1[_0x3eb4('0x29')]]={'$like':'%'+_0x5975e4[_0x3eb4('0x30')][_0x3eb4('0x3b')]+'%'};return _0x4ede9a;}})});}_0x2ba4fe=_[_0x3eb4('0x3c')]({},_0x2ba4fe,_0x5975e4[_0x3eb4('0x3e')]);var _0x8b69b2={'where':_0x2ba4fe[_0x3eb4('0x3a')]};return db[_0x3eb4('0x3f')][_0x3eb4('0x1b')](_0x8b69b2)[_0x3eb4('0x27')](function(_0x1f1376){_0xb55d7e['count']=_0x1f1376;if(_0x5975e4['query'][_0x3eb4('0x40')]){_0x2ba4fe[_0x3eb4('0x41')]=[{'all':!![]}];}return db[_0x3eb4('0x3f')][_0x3eb4('0x42')](_0x2ba4fe);})[_0x3eb4('0x27')](function(_0x14d5be){_0xb55d7e[_0x3eb4('0x43')]=_0x14d5be;return _0xb55d7e;})[_0x3eb4('0x27')](respondWithFilteredResult(_0x3d9af8,_0x2ba4fe))['catch'](handleError(_0x3d9af8,null));};exports[_0x3eb4('0x44')]=function(_0x5be81b,_0x2c958){var _0x140343={'raw':![],'where':{'id':_0x5be81b[_0x3eb4('0x45')]['id']}},_0x34da0d={};_0x34da0d[_0x3eb4('0x2f')]=_[_0x3eb4('0x31')](db[_0x3eb4('0x3f')][_0x3eb4('0x46')]);_0x34da0d[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x5be81b['query']);_0x34da0d[_0x3eb4('0x32')]=_[_0x3eb4('0x34')](_0x34da0d[_0x3eb4('0x2f')],_0x34da0d['query']);_0x140343[_0x3eb4('0x33')]=_['intersection'](_0x34da0d[_0x3eb4('0x2f')],qs['fields'](_0x5be81b[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x140343[_0x3eb4('0x33')]=_0x140343[_0x3eb4('0x33')]['length']?_0x140343['attributes']:_0x34da0d[_0x3eb4('0x2f')];if(_0x5be81b[_0x3eb4('0x30')][_0x3eb4('0x40')]){_0x140343[_0x3eb4('0x41')]=[{'all':!![]}];}_0x140343=_[_0x3eb4('0x3c')]({},_0x140343,_0x5be81b[_0x3eb4('0x3e')]);return db[_0x3eb4('0x3f')][_0x3eb4('0x47')](_0x140343)[_0x3eb4('0x27')](handleEntityNotFound(_0x2c958,null))[_0x3eb4('0x27')](respondWithResult(_0x2c958,null))['catch'](handleError(_0x2c958,null));};exports[_0x3eb4('0x48')]=function(_0x7cb397,_0x11362b){return db['Campaign']['create'](_0x7cb397[_0x3eb4('0x49')],{})['then'](function(_0x3da2e6){var _0x453ba4=_0x7cb397[_0x3eb4('0x4a')][_0x3eb4('0x24')]({'plain':!![]});if(!_0x453ba4)throw new Error(_0x3eb4('0x4b'));if(_0x453ba4[_0x3eb4('0x4c')]===_0x3eb4('0x4a')){var _0x1ff839=_0x3da2e6[_0x3eb4('0x24')]({'plain':!![]});var _0x20221d=_0x3eb4('0x25');return db[_0x3eb4('0x4d')][_0x3eb4('0x47')]({'where':{'name':_0x20221d,'userProfileId':_0x453ba4['userProfileId']},'raw':!![]})[_0x3eb4('0x27')](function(_0x85da6f){if(_0x85da6f&&_0x85da6f['autoAssociation']===0x0){return db[_0x3eb4('0x26')]['create']({'name':_0x1ff839[_0x3eb4('0x29')],'resourceId':_0x1ff839['id'],'type':_0x85da6f[_0x3eb4('0x29')],'sectionId':_0x85da6f['id']},{})[_0x3eb4('0x27')](function(){return _0x3da2e6;});}else{return _0x3da2e6;}})[_0x3eb4('0x4e')](function(_0x134d2e){logger[_0x3eb4('0x4f')](_0x3eb4('0x50'),_0x134d2e);throw _0x134d2e;});}return _0x3da2e6;})[_0x3eb4('0x27')](respondWithResult(_0x11362b,0xc9))['catch'](handleError(_0x11362b,null));};exports['clone']=function(_0x34b431,_0x1eab5a){var _0x5a9eec={'where':{'id':_0x34b431[_0x3eb4('0x45')]['id']}},_0x1c8f40={};_0x1c8f40['model']=_[_0x3eb4('0x31')](db['Campaign'][_0x3eb4('0x46')]);_0x5a9eec[_0x3eb4('0x33')]=_['intersection'](_0x1c8f40[_0x3eb4('0x2f')],qs['fields'](_0x34b431[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x5a9eec[_0x3eb4('0x33')]=_0x5a9eec[_0x3eb4('0x33')]['length']?_0x5a9eec['attributes']:_0x1c8f40[_0x3eb4('0x2f')];if(_0x34b431[_0x3eb4('0x30')]['includeAll']){_0x5a9eec[_0x3eb4('0x41')]=[{'all':!![]}];}_0x5a9eec=_[_0x3eb4('0x3c')]({},_0x5a9eec,_0x34b431[_0x3eb4('0x3e')]);return db[_0x3eb4('0x3f')][_0x3eb4('0x47')](_0x5a9eec)[_0x3eb4('0x27')](handleEntityNotFound(_0x1eab5a,null))['then'](function(_0x4c1315){if(_0x4c1315){var _0x16e131=_0x4c1315[_0x3eb4('0x24')]({'plain':!![]});_0x16e131=qs[_0x3eb4('0x51')](_0x16e131,['id',_0x3eb4('0x52'),_0x3eb4('0x53')]);_0x34b431[_0x3eb4('0x49')]=_[_0x3eb4('0x51')](_0x34b431['body'],['id',_0x3eb4('0x52'),'updatedAt']);return db[_0x3eb4('0x3f')][_0x3eb4('0x48')](_[_0x3eb4('0x3c')](_0x16e131,_0x34b431[_0x3eb4('0x49')]),{'include':_0x34b431[_0x3eb4('0x30')][_0x3eb4('0x40')]?[{'all':!![]}]:undefined})[_0x3eb4('0x27')](function(_0x5b22fa){var _0x565e18=_0x34b431[_0x3eb4('0x4a')][_0x3eb4('0x24')]({'plain':!![]});if(!_0x565e18)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x565e18[_0x3eb4('0x4c')]===_0x3eb4('0x4a')){var _0x1ca2a2=_0x5b22fa[_0x3eb4('0x24')]({'plain':!![]});var _0x156304=_0x3eb4('0x25');return db[_0x3eb4('0x4d')][_0x3eb4('0x47')]({'where':{'name':_0x156304,'userProfileId':_0x565e18[_0x3eb4('0x54')]},'raw':!![]})['then'](function(_0x43d75f){if(_0x43d75f&&_0x43d75f[_0x3eb4('0x55')]===0x0){return db[_0x3eb4('0x26')]['create']({'name':_0x1ca2a2[_0x3eb4('0x29')],'resourceId':_0x1ca2a2['id'],'type':_0x43d75f[_0x3eb4('0x29')],'sectionId':_0x43d75f['id']},{})['then'](function(){return _0x5b22fa;});}else{return _0x5b22fa;}})[_0x3eb4('0x4e')](function(_0x4d3bd2){logger[_0x3eb4('0x4f')](_0x3eb4('0x50'),_0x4d3bd2);throw _0x4d3bd2;});}return _0x5b22fa;});}})['then'](respondWithResult(_0x1eab5a,0xc9))[_0x3eb4('0x4e')](handleError(_0x1eab5a,null));};exports['update']=function(_0x1f8584,_0x58a2b8){if(_0x1f8584['body']['id']){delete _0x1f8584[_0x3eb4('0x49')]['id'];}return db[_0x3eb4('0x3f')][_0x3eb4('0x47')]({'where':{'id':_0x1f8584[_0x3eb4('0x45')]['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x58a2b8,null))[_0x3eb4('0x27')](saveUpdates(_0x1f8584[_0x3eb4('0x49')],null))[_0x3eb4('0x27')](respondWithResult(_0x58a2b8,null))[_0x3eb4('0x4e')](handleError(_0x58a2b8,null));};exports[_0x3eb4('0x23')]=function(_0x1a0215,_0x23455f){return db[_0x3eb4('0x3f')]['find']({'where':{'id':_0x1a0215['params']['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x23455f,null))[_0x3eb4('0x27')](removeEntity(_0x23455f,null))[_0x3eb4('0x4e')](handleError(_0x23455f,null));};exports['getHoppers']=function(_0x2dc9d9,_0x229261,_0xe77724){var _0x32b1b8={'raw':!![],'where':{}};var _0x2fcfc2={};var _0x4b12d3={'count':0x0,'rows':[]};return db[_0x3eb4('0x3f')][_0x3eb4('0x56')]({'where':{'id':_0x2dc9d9[_0x3eb4('0x45')]['id']}})['then'](handleEntityNotFound(_0x229261,null))[_0x3eb4('0x27')](function(_0x140a4a){if(_0x140a4a){_0x2fcfc2[_0x3eb4('0x2f')]=_[_0x3eb4('0x31')](db[_0x3eb4('0x57')][_0x3eb4('0x46')]);_0x2fcfc2[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x2dc9d9['query']);_0x2fcfc2['filters']=_['intersection'](_0x2fcfc2[_0x3eb4('0x2f')],_0x2fcfc2['query']);_0x32b1b8[_0x3eb4('0x33')]=_[_0x3eb4('0x34')](_0x2fcfc2[_0x3eb4('0x2f')],qs[_0x3eb4('0x35')](_0x2dc9d9['query']['fields']));_0x32b1b8['attributes']=_0x32b1b8['attributes'][_0x3eb4('0x58')]?_0x32b1b8[_0x3eb4('0x33')]:_0x2fcfc2[_0x3eb4('0x2f')];if(!_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x36')]('nolimit')){_0x32b1b8[_0x3eb4('0x1a')]=qs['limit'](_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x32b1b8[_0x3eb4('0x18')]=qs[_0x3eb4('0x18')](_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x18')]);}_0x32b1b8[_0x3eb4('0x38')]=qs[_0x3eb4('0x39')](_0x2dc9d9['query'][_0x3eb4('0x39')]);_0x32b1b8[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_[_0x3eb4('0x59')](_0x2dc9d9[_0x3eb4('0x30')],_0x2fcfc2['filters']));_0x32b1b8[_0x3eb4('0x3a')]['CampaignId']=_0x140a4a['id'];if(_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x3b')]){_0x32b1b8[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x32b1b8[_0x3eb4('0x3a')],{'$or':_[_0x3eb4('0x2b')](_0x32b1b8[_0x3eb4('0x33')],function(_0xa5a9d0){var _0x514f99={};_0x514f99[_0xa5a9d0]={'$like':'%'+_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x3b')]+'%'};return _0x514f99;})});}_0x32b1b8=_[_0x3eb4('0x3c')]({},_0x32b1b8,_0x2dc9d9[_0x3eb4('0x3e')]);return db['CmHopper'][_0x3eb4('0x1b')]({'where':_0x32b1b8['where']})[_0x3eb4('0x27')](function(_0x160bda){_0x4b12d3['count']=_0x160bda;if(_0x2dc9d9[_0x3eb4('0x30')][_0x3eb4('0x40')]){_0x32b1b8[_0x3eb4('0x41')]=[{'all':!![]}];}return db[_0x3eb4('0x57')][_0x3eb4('0x42')](_0x32b1b8);})[_0x3eb4('0x27')](function(_0x27818a){_0x4b12d3[_0x3eb4('0x43')]=_0x27818a;return _0x4b12d3;});}})[_0x3eb4('0x27')](respondWithFilteredResult(_0x229261,_0x32b1b8))[_0x3eb4('0x4e')](handleError(_0x229261,null));};exports['getHopperHistories']=function(_0x337595,_0x513146,_0x1453b8){var _0x750267={'raw':!![],'where':{}};var _0x4286f3={};var _0x4e9984={'count':0x0,'rows':[]};return db[_0x3eb4('0x3f')][_0x3eb4('0x56')]({'where':{'id':_0x337595['params']['id']}})['then'](handleEntityNotFound(_0x513146,null))[_0x3eb4('0x27')](function(_0x80000f){if(_0x80000f){_0x4286f3['model']=_[_0x3eb4('0x31')](db[_0x3eb4('0x5a')][_0x3eb4('0x46')]);_0x4286f3[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x337595[_0x3eb4('0x30')]);_0x4286f3[_0x3eb4('0x32')]=_[_0x3eb4('0x34')](_0x4286f3['model'],_0x4286f3[_0x3eb4('0x30')]);_0x750267['attributes']=_['intersection'](_0x4286f3['model'],qs[_0x3eb4('0x35')](_0x337595[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x750267[_0x3eb4('0x33')]=_0x750267[_0x3eb4('0x33')][_0x3eb4('0x58')]?_0x750267[_0x3eb4('0x33')]:_0x4286f3[_0x3eb4('0x2f')];if(!_0x337595[_0x3eb4('0x30')][_0x3eb4('0x36')](_0x3eb4('0x37'))){_0x750267[_0x3eb4('0x1a')]=qs[_0x3eb4('0x1a')](_0x337595[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x750267['offset']=qs[_0x3eb4('0x18')](_0x337595[_0x3eb4('0x30')][_0x3eb4('0x18')]);}_0x750267[_0x3eb4('0x38')]=qs[_0x3eb4('0x39')](_0x337595[_0x3eb4('0x30')][_0x3eb4('0x39')]);_0x750267[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_[_0x3eb4('0x59')](_0x337595[_0x3eb4('0x30')],_0x4286f3['filters']));_0x750267[_0x3eb4('0x3a')][_0x3eb4('0x5b')]=_0x80000f['id'];if(_0x337595[_0x3eb4('0x30')][_0x3eb4('0x3b')]){_0x750267[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x750267[_0x3eb4('0x3a')],{'$or':_[_0x3eb4('0x2b')](_0x750267['attributes'],function(_0xf4928d){var _0x1fa262={};_0x1fa262[_0xf4928d]={'$like':'%'+_0x337595[_0x3eb4('0x30')]['filter']+'%'};return _0x1fa262;})});}_0x750267=_[_0x3eb4('0x3c')]({},_0x750267,_0x337595[_0x3eb4('0x3e')]);return db[_0x3eb4('0x5a')][_0x3eb4('0x1b')]({'where':_0x750267[_0x3eb4('0x3a')]})[_0x3eb4('0x27')](function(_0x7a85e4){_0x4e9984[_0x3eb4('0x1b')]=_0x7a85e4;if(_0x337595[_0x3eb4('0x30')][_0x3eb4('0x40')]){_0x750267[_0x3eb4('0x41')]=[{'all':!![]}];}return db[_0x3eb4('0x5a')]['findAll'](_0x750267);})['then'](function(_0x983a61){_0x4e9984[_0x3eb4('0x43')]=_0x983a61;return _0x4e9984;});}})[_0x3eb4('0x27')](respondWithFilteredResult(_0x513146,_0x750267))['catch'](handleError(_0x513146,null));};exports[_0x3eb4('0x5c')]=function(_0x38e7dc,_0x322108,_0x1dfc71){var _0x27538e={'raw':!![],'where':{}};var _0x3806d2={};var _0x485a76={'count':0x0,'rows':[]};return db[_0x3eb4('0x3f')]['findOne']({'where':{'id':_0x38e7dc[_0x3eb4('0x45')]['id']}})['then'](handleEntityNotFound(_0x322108,null))[_0x3eb4('0x27')](function(_0x382cfe){if(_0x382cfe){_0x3806d2['model']=_[_0x3eb4('0x31')](db[_0x3eb4('0x5d')]['rawAttributes']);_0x3806d2[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x38e7dc[_0x3eb4('0x30')]);_0x3806d2[_0x3eb4('0x32')]=_[_0x3eb4('0x34')](_0x3806d2[_0x3eb4('0x2f')],_0x3806d2['query']);_0x27538e[_0x3eb4('0x33')]=_[_0x3eb4('0x34')](_0x3806d2[_0x3eb4('0x2f')],qs[_0x3eb4('0x35')](_0x38e7dc[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x27538e[_0x3eb4('0x33')]=_0x27538e[_0x3eb4('0x33')]['length']?_0x27538e[_0x3eb4('0x33')]:_0x3806d2['model'];if(!_0x38e7dc['query'][_0x3eb4('0x36')]('nolimit')){_0x27538e[_0x3eb4('0x1a')]=qs['limit'](_0x38e7dc[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x27538e[_0x3eb4('0x18')]=qs[_0x3eb4('0x18')](_0x38e7dc['query'][_0x3eb4('0x18')]);}_0x27538e[_0x3eb4('0x38')]=qs['sort'](_0x38e7dc[_0x3eb4('0x30')][_0x3eb4('0x39')]);_0x27538e[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_[_0x3eb4('0x59')](_0x38e7dc[_0x3eb4('0x30')],_0x3806d2[_0x3eb4('0x32')]));_0x27538e['where'][_0x3eb4('0x5b')]=_0x382cfe['id'];if(_0x38e7dc[_0x3eb4('0x30')][_0x3eb4('0x3b')]){_0x27538e[_0x3eb4('0x3a')]=_['merge'](_0x27538e[_0x3eb4('0x3a')],{'$or':_[_0x3eb4('0x2b')](_0x27538e[_0x3eb4('0x33')],function(_0x230958){var _0x171885={};_0x171885[_0x230958]={'$like':'%'+_0x38e7dc[_0x3eb4('0x30')]['filter']+'%'};return _0x171885;})});}_0x27538e=_[_0x3eb4('0x3c')]({},_0x27538e,_0x38e7dc[_0x3eb4('0x3e')]);return db['CmHopperFinal'][_0x3eb4('0x1b')]({'where':_0x27538e['where']})[_0x3eb4('0x27')](function(_0x513ab6){_0x485a76[_0x3eb4('0x1b')]=_0x513ab6;if(_0x38e7dc[_0x3eb4('0x30')][_0x3eb4('0x40')]){_0x27538e[_0x3eb4('0x41')]=[{'all':!![]}];}return db[_0x3eb4('0x5d')][_0x3eb4('0x42')](_0x27538e);})[_0x3eb4('0x27')](function(_0x15ae28){_0x485a76[_0x3eb4('0x43')]=_0x15ae28;return _0x485a76;});}})[_0x3eb4('0x27')](respondWithFilteredResult(_0x322108,_0x27538e))[_0x3eb4('0x4e')](handleError(_0x322108,null));};exports[_0x3eb4('0x5e')]=function(_0x4756fd,_0x364a96,_0x5cd0d7){var _0x280d04={'raw':!![],'where':{}};var _0x31ebe4={};var _0x36d096={'count':0x0,'rows':[]};return db['Campaign'][_0x3eb4('0x56')]({'where':{'id':_0x4756fd[_0x3eb4('0x45')]['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x364a96,null))[_0x3eb4('0x27')](function(_0x339dc7){if(_0x339dc7){_0x31ebe4[_0x3eb4('0x2f')]=_[_0x3eb4('0x31')](db[_0x3eb4('0x5f')][_0x3eb4('0x46')]);_0x31ebe4['query']=_[_0x3eb4('0x31')](_0x4756fd[_0x3eb4('0x30')]);_0x31ebe4[_0x3eb4('0x32')]=_[_0x3eb4('0x34')](_0x31ebe4[_0x3eb4('0x2f')],_0x31ebe4[_0x3eb4('0x30')]);_0x280d04[_0x3eb4('0x33')]=_['intersection'](_0x31ebe4[_0x3eb4('0x2f')],qs[_0x3eb4('0x35')](_0x4756fd['query'][_0x3eb4('0x35')]));_0x280d04[_0x3eb4('0x33')]=_0x280d04['attributes'][_0x3eb4('0x58')]?_0x280d04[_0x3eb4('0x33')]:_0x31ebe4[_0x3eb4('0x2f')];if(!_0x4756fd['query'][_0x3eb4('0x36')](_0x3eb4('0x37'))){_0x280d04[_0x3eb4('0x1a')]=qs[_0x3eb4('0x1a')](_0x4756fd[_0x3eb4('0x30')]['limit']);_0x280d04[_0x3eb4('0x18')]=qs['offset'](_0x4756fd['query'][_0x3eb4('0x18')]);}_0x280d04[_0x3eb4('0x38')]=qs['sort'](_0x4756fd[_0x3eb4('0x30')]['sort']);_0x280d04[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_[_0x3eb4('0x59')](_0x4756fd['query'],_0x31ebe4[_0x3eb4('0x32')]));_0x280d04['where'][_0x3eb4('0x5b')]=_0x339dc7['id'];if(_0x4756fd[_0x3eb4('0x30')][_0x3eb4('0x3b')]){_0x280d04[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x280d04[_0x3eb4('0x3a')],{'$or':_[_0x3eb4('0x2b')](_0x280d04[_0x3eb4('0x33')],function(_0x3476b9){var _0x9a89cd={};_0x9a89cd[_0x3476b9]={'$like':'%'+_0x4756fd[_0x3eb4('0x30')][_0x3eb4('0x3b')]+'%'};return _0x9a89cd;})});}_0x280d04=_[_0x3eb4('0x3c')]({},_0x280d04,_0x4756fd[_0x3eb4('0x3e')]);return db[_0x3eb4('0x5f')]['count']({'where':_0x280d04['where']})['then'](function(_0x38171e){_0x36d096[_0x3eb4('0x1b')]=_0x38171e;if(_0x4756fd['query'][_0x3eb4('0x40')]){_0x280d04[_0x3eb4('0x41')]=[{'all':!![]}];}return db['CmHopperBlack'][_0x3eb4('0x42')](_0x280d04);})[_0x3eb4('0x27')](function(_0x3fcff8){_0x36d096[_0x3eb4('0x43')]=_0x3fcff8;return _0x36d096;});}})[_0x3eb4('0x27')](respondWithFilteredResult(_0x364a96,_0x280d04))[_0x3eb4('0x4e')](handleError(_0x364a96,null));};exports[_0x3eb4('0x60')]=function(_0x47f1a9,_0x36b46a,_0x55b83a){var _0x1f527f={};var _0x269043={};var _0x2d845d;var _0x3697e8;return db['Campaign'][_0x3eb4('0x56')]({'where':{'id':_0x47f1a9['params']['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x36b46a,null))[_0x3eb4('0x27')](function(_0x1b05eb){if(_0x1b05eb){_0x2d845d=_0x1b05eb;_0x269043[_0x3eb4('0x2f')]=_['keys'](db['CmList'][_0x3eb4('0x46')]);_0x269043[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0x47f1a9[_0x3eb4('0x30')]);_0x269043['filters']=_['intersection'](_0x269043[_0x3eb4('0x2f')],_0x269043[_0x3eb4('0x30')]);_0x1f527f[_0x3eb4('0x33')]=_[_0x3eb4('0x34')](_0x269043[_0x3eb4('0x2f')],qs[_0x3eb4('0x35')](_0x47f1a9[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x1f527f[_0x3eb4('0x33')]=_0x1f527f['attributes'][_0x3eb4('0x58')]?_0x1f527f[_0x3eb4('0x33')]:_0x269043['model'];_0x1f527f[_0x3eb4('0x38')]=qs[_0x3eb4('0x39')](_0x47f1a9[_0x3eb4('0x30')][_0x3eb4('0x39')]);_0x1f527f[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_['pick'](_0x47f1a9[_0x3eb4('0x30')],_0x269043[_0x3eb4('0x32')]));if(_0x47f1a9['query']['filter']){_0x1f527f[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x1f527f[_0x3eb4('0x3a')],{'$or':_['map'](_0x1f527f[_0x3eb4('0x33')],function(_0xabc43b){var _0x68e89f={};_0x68e89f[_0xabc43b]={'$like':'%'+_0x47f1a9[_0x3eb4('0x30')][_0x3eb4('0x3b')]+'%'};return _0x68e89f;})});}_0x1f527f=_[_0x3eb4('0x3c')]({},_0x1f527f,_0x47f1a9[_0x3eb4('0x3e')]);return _0x2d845d['getLists'](_0x1f527f);}})[_0x3eb4('0x27')](function(_0x36cb11){if(_0x36cb11){_0x3697e8=_0x36cb11['length'];if(!_0x47f1a9[_0x3eb4('0x30')][_0x3eb4('0x36')](_0x3eb4('0x37'))){_0x1f527f[_0x3eb4('0x1a')]=qs[_0x3eb4('0x1a')](_0x47f1a9[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x1f527f[_0x3eb4('0x18')]=qs[_0x3eb4('0x18')](_0x47f1a9[_0x3eb4('0x30')]['offset']);}return _0x2d845d[_0x3eb4('0x60')](_0x1f527f);}})[_0x3eb4('0x27')](function(_0x1b84f7){if(_0x1b84f7){return _0x1b84f7?{'count':_0x3697e8,'rows':_0x1b84f7}:null;}})[_0x3eb4('0x27')](respondWithResult(_0x36b46a,null))['catch'](handleError(_0x36b46a,null));};exports['addLists']=function(_0x3b5844,_0x35d863,_0x2a8795){var _0x2e90dd,_0x1de48d;var _0x5c45b7=[];var _0xb2f96c=moment()[_0x3eb4('0x61')](_0x3eb4('0x62'));return db['Campaign'][_0x3eb4('0x47')]({'where':{'id':_0x3b5844[_0x3eb4('0x45')]['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x35d863,null))[_0x3eb4('0x27')](function(_0x262b1d){if(_0x262b1d){_0x1de48d=_0x262b1d;return _0x262b1d[_0x3eb4('0x63')](_0x3b5844[_0x3eb4('0x49')][_0x3eb4('0x64')],_['omit'](_0x3b5844[_0x3eb4('0x49')],['ids','id'])||{});}return null;})[_0x3eb4('0x65')](function(_0x231eb5){var _0x57e7f1;var _0x42366d;_0x2e90dd=_0x231eb5||[];var _0x59297c=[];if(_0x231eb5){for(var _0x3c90f6=0x0;_0x3c90f6<_0x231eb5[_0x3eb4('0x58')];_0x3c90f6+=0x1){var _0x2dca0f=_0x231eb5[_0x3c90f6][_0x3eb4('0x24')]({'plain':!![]});_0x1de48d[_0x3eb4('0x66')]=_0x3b5844[_0x3eb4('0x49')]['dialCheckDuplicateType']?_0x3b5844[_0x3eb4('0x49')][_0x3eb4('0x66')]:_0x1de48d[_0x3eb4('0x66')];switch(_0x1de48d[_0x3eb4('0x66')]){case _0x3eb4('0x67'):_0x57e7f1=squel['insert']()[_0x3eb4('0x68')](_0x3eb4('0x69'))[_0x3eb4('0x6a')](['phone',_0x3eb4('0x6b'),_0x3eb4('0x6c'),'ListId',_0x3eb4('0x5b'),_0x3eb4('0x52'),_0x3eb4('0x53')],squel[_0x3eb4('0x6d')]()['field'](_0x3eb4('0x6e'),'phone')[_0x3eb4('0x6f')]('NOW()',_0x3eb4('0x6b'))[_0x3eb4('0x6f')]('id',_0x3eb4('0x6c'))['field'](_0x2dca0f[_0x3eb4('0x70')][_0x3eb4('0x71')](),_0x3eb4('0x72'))['field'](_0x3b5844['params']['id'][_0x3eb4('0x71')](),_0x3eb4('0x5b'))[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x52'))[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x53'))[_0x3eb4('0x73')](_0x3eb4('0x74'))[_0x3eb4('0x3a')](_0x3eb4('0x75'))[_0x3eb4('0x3a')]('ListId\x20=\x20?',_0x2dca0f[_0x3eb4('0x70')][_0x3eb4('0x71')]())[_0x3eb4('0x3a')]('phone\x20IS\x20NOT\x20NULL')[_0x3eb4('0x3a')]('phone\x20NOT\x20IN\x20(?)',squel['select']()['field'](_0x3eb4('0x76'))[_0x3eb4('0x73')](_0x3eb4('0x77'))['where'](_0x3eb4('0x78'),_0x3b5844[_0x3eb4('0x45')]['id'][_0x3eb4('0x71')]()))['where'](_0x3eb4('0x79'),squel[_0x3eb4('0x6d')]()['field'](_0x3eb4('0x7a'))[_0x3eb4('0x73')]('cm_hopper')['where'](_0x3eb4('0x78'),_0x3b5844['params']['id']['toString']())))[_0x3eb4('0x71')]();break;case _0x3eb4('0x7b'):_0x57e7f1=squel[_0x3eb4('0x7c')]()['into'](_0x3eb4('0x69'))['fromQuery']([_0x3eb4('0x6e'),_0x3eb4('0x6b'),_0x3eb4('0x6c'),_0x3eb4('0x72'),_0x3eb4('0x5b'),_0x3eb4('0x52'),'updatedAt'],squel[_0x3eb4('0x6d')]()['field'](_0x3eb4('0x6e'),_0x3eb4('0x6e'))[_0x3eb4('0x6f')](_0x3eb4('0x7d'),'scheduledAt')[_0x3eb4('0x6f')]('id',_0x3eb4('0x6c'))['field'](_0x2dca0f['CmListId'][_0x3eb4('0x71')](),'ListId')[_0x3eb4('0x6f')](_0x3b5844['params']['id']['toString'](),_0x3eb4('0x5b'))[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x52'))['field']('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x53'))[_0x3eb4('0x73')](_0x3eb4('0x74'))[_0x3eb4('0x3a')]('deletedAt\x20IS\x20NULL')[_0x3eb4('0x3a')](_0x3eb4('0x7e'),_0x2dca0f[_0x3eb4('0x70')][_0x3eb4('0x71')]())[_0x3eb4('0x3a')](_0x3eb4('0x7f'))[_0x3eb4('0x3a')](_0x3eb4('0x79'),squel['select']()['field']('COALESCE(phone,\x27\x27)')[_0x3eb4('0x73')](_0x3eb4('0x69'))[_0x3eb4('0x3a')]('CampaignId\x20=\x20?',_0x3b5844[_0x3eb4('0x45')]['id'][_0x3eb4('0x71')]())))[_0x3eb4('0x71')]();break;default:_0x57e7f1=squel[_0x3eb4('0x7c')]()[_0x3eb4('0x68')]('cm_hopper')['fromQuery'](['phone',_0x3eb4('0x6b'),_0x3eb4('0x6c'),_0x3eb4('0x72'),_0x3eb4('0x5b'),_0x3eb4('0x52'),_0x3eb4('0x53')],squel[_0x3eb4('0x6d')]()[_0x3eb4('0x6f')](_0x3eb4('0x6e'),_0x3eb4('0x6e'))[_0x3eb4('0x6f')](_0x3eb4('0x7d'),'scheduledAt')['field']('id',_0x3eb4('0x6c'))['field'](_0x2dca0f[_0x3eb4('0x70')][_0x3eb4('0x71')](),'ListId')[_0x3eb4('0x6f')](_0x3b5844[_0x3eb4('0x45')]['id'][_0x3eb4('0x71')](),'CampaignId')[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x52'))[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x53'))['from'](_0x3eb4('0x74'))['where'](_0x3eb4('0x75'))[_0x3eb4('0x3a')](_0x3eb4('0x7e'),_0x2dca0f['CmListId'][_0x3eb4('0x71')]())[_0x3eb4('0x3a')](_0x3eb4('0x7f')))[_0x3eb4('0x71')]();}_0x42366d=squel[_0x3eb4('0x7c')]()[_0x3eb4('0x68')]('cm_hopper_additional_phones')[_0x3eb4('0x6a')]([_0x3eb4('0x80'),_0x3eb4('0x6b'),_0x3eb4('0x6e'),_0x3eb4('0x81'),_0x3eb4('0x52'),_0x3eb4('0x53')],squel['select']()[_0x3eb4('0x6f')](_0x3eb4('0x82'),'id')[_0x3eb4('0x6f')](_0x3eb4('0x7d'),_0x3eb4('0x6b'))['field'](_0x3eb4('0x83'),_0x3eb4('0x6e'))[_0x3eb4('0x6f')]('ci.OrderBY',_0x3eb4('0x81'))[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27','createdAt')[_0x3eb4('0x6f')]('\x27'+_0xb2f96c+'\x27',_0x3eb4('0x53'))[_0x3eb4('0x73')](_0x3eb4('0x84'),'ci')[_0x3eb4('0x85')]('cm_hopper','h','h.ContactId\x20=\x20ci.CmContactId')[_0x3eb4('0x3a')](_0x3eb4('0x86'),_0x2dca0f[_0x3eb4('0x70')][_0x3eb4('0x71')]())[_0x3eb4('0x3a')](_0x3eb4('0x87'),_0x3b5844[_0x3eb4('0x45')]['id'][_0x3eb4('0x71')]())[_0x3eb4('0x3a')]('h.createdAt\x20=\x20?',_0xb2f96c))[_0x3eb4('0x71')]();_0x59297c[_0x3eb4('0x88')](db['sequelize'][_0x3eb4('0x30')](_0x57e7f1));_0x5c45b7['push'](db[_0x3eb4('0x89')][_0x3eb4('0x30')](_0x42366d));}return BPromise['all'](_0x59297c);}})['then'](function(){return BPromise[_0x3eb4('0x8a')](_0x5c45b7);})[_0x3eb4('0x27')](function(){return _0x2e90dd;})[_0x3eb4('0x27')](respondWithResult(_0x35d863,null))['catch'](handleError(_0x35d863,null));};exports[_0x3eb4('0x8b')]=function(_0x385f87,_0x5d6613,_0x1d24cc){return db[_0x3eb4('0x3f')][_0x3eb4('0x47')]({'where':{'id':_0x385f87['params']['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x5d6613,null))[_0x3eb4('0x27')](function(_0x18018c){if(_0x18018c){return _0x18018c[_0x3eb4('0x8b')](_0x385f87['query'][_0x3eb4('0x64')]);}})[_0x3eb4('0x27')](function(_0x14dbb6){if(_0x14dbb6){return db['CmHopper']['destroy']({'where':{'ListId':_0x385f87[_0x3eb4('0x30')][_0x3eb4('0x64')],'CampaignId':_0x385f87['params']['id']}})[_0x3eb4('0x27')](function(){return _0x14dbb6;});}})[_0x3eb4('0x27')](respondWithStatusCode(_0x5d6613,null))[_0x3eb4('0x4e')](handleError(_0x5d6613,null));};exports['getBlackLists']=function(_0xbad989,_0x517544,_0x13f2e8){var _0x1fafc2={};var _0x45d8b4={};var _0x324cd3;var _0x23db46;return db[_0x3eb4('0x3f')][_0x3eb4('0x56')]({'where':{'id':_0xbad989[_0x3eb4('0x45')]['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x517544,null))[_0x3eb4('0x27')](function(_0x148a33){if(_0x148a33){_0x324cd3=_0x148a33;_0x45d8b4['model']=_['keys'](db[_0x3eb4('0x8c')][_0x3eb4('0x46')]);_0x45d8b4[_0x3eb4('0x30')]=_[_0x3eb4('0x31')](_0xbad989[_0x3eb4('0x30')]);_0x45d8b4[_0x3eb4('0x32')]=_[_0x3eb4('0x34')](_0x45d8b4['model'],_0x45d8b4['query']);_0x1fafc2[_0x3eb4('0x33')]=_[_0x3eb4('0x34')](_0x45d8b4[_0x3eb4('0x2f')],qs['fields'](_0xbad989[_0x3eb4('0x30')][_0x3eb4('0x35')]));_0x1fafc2['attributes']=_0x1fafc2[_0x3eb4('0x33')][_0x3eb4('0x58')]?_0x1fafc2['attributes']:_0x45d8b4[_0x3eb4('0x2f')];_0x1fafc2[_0x3eb4('0x38')]=qs[_0x3eb4('0x39')](_0xbad989[_0x3eb4('0x30')][_0x3eb4('0x39')]);_0x1fafc2[_0x3eb4('0x3a')]=qs[_0x3eb4('0x32')](_[_0x3eb4('0x59')](_0xbad989['query'],_0x45d8b4['filters']));if(_0xbad989['query']['filter']){_0x1fafc2[_0x3eb4('0x3a')]=_[_0x3eb4('0x3c')](_0x1fafc2['where'],{'$or':_['map'](_0x1fafc2[_0x3eb4('0x33')],function(_0x4b129f){var _0x62454={};_0x62454[_0x4b129f]={'$like':'%'+_0xbad989[_0x3eb4('0x30')][_0x3eb4('0x3b')]+'%'};return _0x62454;})});}_0x1fafc2=_['merge']({},_0x1fafc2,_0xbad989['options']);return _0x324cd3['getBlackLists'](_0x1fafc2);}})['then'](function(_0x4eadf6){if(_0x4eadf6){_0x23db46=_0x4eadf6[_0x3eb4('0x58')];if(!_0xbad989[_0x3eb4('0x30')]['hasOwnProperty'](_0x3eb4('0x37'))){_0x1fafc2[_0x3eb4('0x1a')]=qs[_0x3eb4('0x1a')](_0xbad989[_0x3eb4('0x30')][_0x3eb4('0x1a')]);_0x1fafc2[_0x3eb4('0x18')]=qs[_0x3eb4('0x18')](_0xbad989[_0x3eb4('0x30')][_0x3eb4('0x18')]);}return _0x324cd3[_0x3eb4('0x8d')](_0x1fafc2);}})[_0x3eb4('0x27')](function(_0x3dde3f){if(_0x3dde3f){return _0x3dde3f?{'count':_0x23db46,'rows':_0x3dde3f}:null;}})[_0x3eb4('0x27')](respondWithResult(_0x517544,null))[_0x3eb4('0x4e')](handleError(_0x517544,null));};exports[_0x3eb4('0x8e')]=function(_0x28af87,_0x34b434,_0x51f5f7){var _0x2e00d6,_0x56bdc1;var _0x3a6066=[];var _0x4da1d6=moment()[_0x3eb4('0x61')](_0x3eb4('0x62'));return db[_0x3eb4('0x3f')][_0x3eb4('0x47')]({'where':{'id':_0x28af87[_0x3eb4('0x45')]['id']}})[_0x3eb4('0x27')](handleEntityNotFound(_0x34b434,null))[_0x3eb4('0x27')](function(_0x565b9b){if(_0x565b9b){_0x56bdc1=_0x565b9b;return _0x565b9b[_0x3eb4('0x8e')](_0x28af87['body'][_0x3eb4('0x64')],_[_0x3eb4('0x51')](_0x28af87['body'],['ids','id'])||{});}return null;})[_0x3eb4('0x65')](function(_0x527cac){var _0xf6ac3c;var _0x222ae2;_0x2e00d6=_0x527cac||[];var _0x50134d=[];if(_0x527cac){for(var _0x91faa=0x0;_0x91faa<_0x527cac['length'];_0x91faa+=0x1){var _0x40bdc7=_0x527cac[_0x91faa][_0x3eb4('0x24')]({'plain':!![]});_0xf6ac3c=squel[_0x3eb4('0x7c')]()[_0x3eb4('0x68')](_0x3eb4('0x8f'))[_0x3eb4('0x6a')]([_0x3eb4('0x6e'),'ContactId',_0x3eb4('0x72'),_0x3eb4('0x5b'),_0x3eb4('0x52'),_0x3eb4('0x53')],squel[_0x3eb4('0x6d')]()[_0x3eb4('0x6f')](_0x3eb4('0x6e'),_0x3eb4('0x6e'))[_0x3eb4('0x6f')]('id',_0x3eb4('0x6c'))[_0x3eb4('0x6f')](_0x40bdc7[_0x3eb4('0x70')][_0x3eb4('0x71')](),_0x3eb4('0x72'))[_0x3eb4('0x6f')](_0x28af87[_0x3eb4('0x45')]['id'][_0x3eb4('0x71')](),_0x3eb4('0x5b'))[_0x3eb4('0x6f')](_0x3eb4('0x7d'),_0x3eb4('0x52'))[_0x3eb4('0x6f')](_0x3eb4('0x7d'),'updatedAt')[_0x3eb4('0x73')](_0x3eb4('0x74'))[_0x3eb4('0x3a')]('deletedAt\x20IS\x20NULL')[_0x3eb4('0x3a')](_0x3eb4('0x7e'),_0x40bdc7['CmListId']['toString']())['where']('phone\x20IS\x20NOT\x20NULL'))['toString']();_0x50134d[_0x3eb4('0x88')](db['sequelize']['query'](_0xf6ac3c));}return BPromise[_0x3eb4('0x8a')](_0x50134d);}})[_0x3eb4('0x27')](function(){return _0x2e00d6;})['then'](respondWithResult(_0x34b434,null))[_0x3eb4('0x4e')](handleError(_0x34b434,null));};exports[_0x3eb4('0x90')]=function(_0x286db0,_0x51808b,_0x453924){return db[_0x3eb4('0x3f')]['find']({'where':{'id':_0x286db0[_0x3eb4('0x45')]['id']}})['then'](handleEntityNotFound(_0x51808b,null))[_0x3eb4('0x27')](function(_0x512db9){if(_0x512db9){return _0x512db9[_0x3eb4('0x90')](_0x286db0['query'][_0x3eb4('0x64')]);}})[_0x3eb4('0x27')](function(_0xb7b30e){if(_0xb7b30e){return db[_0x3eb4('0x5f')][_0x3eb4('0x23')]({'where':{'ListId':_0x286db0['query']['ids'],'CampaignId':_0x286db0['params']['id']}})['then'](function(){return _0xb7b30e;});}})[_0x3eb4('0x27')](respondWithStatusCode(_0x51808b,null))[_0x3eb4('0x4e')](handleError(_0x51808b,null));}; \ No newline at end of file diff --git a/server/api/campaign/campaign.model.js b/server/api/campaign/campaign.model.js new file mode 100644 index 0000000..3481f7c --- /dev/null +++ b/server/api/campaign/campaign.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['../../config/logger','moment','bluebird','path','rimraf','../../config/environment','./campaign.attributes','exports','Campaign','campaigns','lodash','util'];(function(_0x16ebbf,_0x429317){var _0x48d0d3=function(_0xa281a5){while(--_0xa281a5){_0x16ebbf['push'](_0x16ebbf['shift']());}};_0x48d0d3(++_0x429317);}(_0x7a54,0x106));var _0x47a5=function(_0x664b93,_0x2438cc){_0x664b93=_0x664b93-0x0;var _0x47a06a=_0x7a54[_0x664b93];return _0x47a06a;};'use strict';var _=require(_0x47a5('0x0'));var util=require(_0x47a5('0x1'));var logger=require(_0x47a5('0x2'))('api');var moment=require(_0x47a5('0x3'));var BPromise=require(_0x47a5('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x47a5('0x5'));var rimraf=require(_0x47a5('0x6'));var config=require(_0x47a5('0x7'));var attributes=require(_0x47a5('0x8'));module[_0x47a5('0x9')]=function(_0x545a97,_0x3d5629){return _0x545a97['define'](_0x47a5('0xa'),attributes,{'tableName':_0x47a5('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/campaign/campaign.rpc.js b/server/api/campaign/campaign.rpc.js new file mode 100644 index 0000000..cdcb6d5 --- /dev/null +++ b/server/api/campaign/campaign.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x62da=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','Campaign,\x20%s,\x20%s','request\x20sent','debug','Campaign,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','Campaign','options','raw','attributes','limit','map','include','model','stringify','GetCampaign','lodash','moment','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x1147ab,_0x10e72b){var _0x55cb5a=function(_0x364bd6){while(--_0x364bd6){_0x1147ab['push'](_0x1147ab['shift']());}};_0x55cb5a(++_0x10e72b);}(_0x62da,0xc0));var _0xa62d=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x62da[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0xa62d('0x0'));var util=require('util');var moment=require(_0xa62d('0x1'));var BPromise=require(_0xa62d('0x2'));var rs=require(_0xa62d('0x3'));var fs=require('fs');var Redis=require(_0xa62d('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xa62d('0x5'));var logger=require(_0xa62d('0x6'))(_0xa62d('0x7'));var config=require(_0xa62d('0x8'));var jayson=require(_0xa62d('0x9'));var client=jayson[_0xa62d('0xa')][_0xa62d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3ceb21,_0x149386,_0x2f6c03){return new BPromise(function(_0x2e8e25,_0x2d6e41){return client['request'](_0x3ceb21,_0x2f6c03)[_0xa62d('0xc')](function(_0x1208d0){logger['info'](_0xa62d('0xd'),_0x149386,_0xa62d('0xe'));logger[_0xa62d('0xf')](_0xa62d('0x10'),_0x149386,_0xa62d('0xe'),JSON['stringify'](_0x1208d0));if(_0x1208d0[_0xa62d('0x11')]){if(_0x1208d0[_0xa62d('0x11')][_0xa62d('0x12')]===0x1f4){logger[_0xa62d('0x11')](_0xa62d('0xd'),_0x149386,_0x1208d0[_0xa62d('0x11')][_0xa62d('0x13')]);return _0x2d6e41(_0x1208d0[_0xa62d('0x11')][_0xa62d('0x13')]);}logger['error'](_0xa62d('0xd'),_0x149386,_0x1208d0[_0xa62d('0x11')][_0xa62d('0x13')]);return _0x2e8e25(_0x1208d0['error'][_0xa62d('0x13')]);}else{logger[_0xa62d('0x14')](_0xa62d('0xd'),_0x149386,_0xa62d('0xe'));_0x2e8e25(_0x1208d0[_0xa62d('0x15')]['message']);}})[_0xa62d('0x16')](function(_0x51226a){logger[_0xa62d('0x11')]('Campaign,\x20%s,\x20%s',_0x149386,_0x51226a);_0x2d6e41(_0x51226a);});});}exports['GetCampaign']=function(_0x192e4e){var _0xa04d7b=this;return new Promise(function(_0x8394e6,_0x30801f){return db[_0xa62d('0x17')]['findAll']({'raw':_0x192e4e['options']?_0x192e4e[_0xa62d('0x18')][_0xa62d('0x19')]===undefined?!![]:![]:!![],'where':_0x192e4e['options']?_0x192e4e[_0xa62d('0x18')]['where']||null:null,'attributes':_0x192e4e[_0xa62d('0x18')]?_0x192e4e['options'][_0xa62d('0x1a')]||null:null,'limit':_0x192e4e['options']?_0x192e4e[_0xa62d('0x18')][_0xa62d('0x1b')]||null:null,'include':_0x192e4e[_0xa62d('0x18')]?_0x192e4e['options']['include']?_[_0xa62d('0x1c')](_0x192e4e[_0xa62d('0x18')][_0xa62d('0x1d')],function(_0x40e577){return{'model':db[_0x40e577[_0xa62d('0x1e')]],'as':_0x40e577['as'],'attributes':_0x40e577['attributes'],'include':_0x40e577['include']?_[_0xa62d('0x1c')](_0x40e577['include'],function(_0x36cfff){return{'model':db[_0x36cfff[_0xa62d('0x1e')]],'as':_0x36cfff['as'],'attributes':_0x36cfff['attributes'],'include':_0x36cfff['include']?_[_0xa62d('0x1c')](_0x36cfff['include'],function(_0x191dd6){return{'model':db[_0x191dd6['model']],'as':_0x191dd6['as'],'attributes':_0x191dd6[_0xa62d('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x104aae){logger[_0xa62d('0x14')]('GetCampaign',_0x192e4e);logger[_0xa62d('0xf')]('GetCampaign',_0x192e4e,JSON[_0xa62d('0x1f')](_0x104aae));_0x8394e6(_0x104aae);})[_0xa62d('0x16')](function(_0xfab048){logger[_0xa62d('0x11')](_0xa62d('0x20'),_0xfab048[_0xa62d('0x13')],_0x192e4e);_0x30801f(_0xa04d7b[_0xa62d('0x11')](0x1f4,_0xfab048[_0xa62d('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/campaign/index.js b/server/api/campaign/index.js new file mode 100644 index 0000000..5651fc4 --- /dev/null +++ b/server/api/campaign/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x043d=['post','create','/:id/clone','clone','addBlackLists','update','delete','destroy','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./campaign.controller','get','isAuthenticated','index','/:id','getHoppers','getHopperHistories','/:id/hopper_finals','getHopperFinals','/:id/lists','getLists','/:id/blacklists','getBlackLists'];(function(_0x31d637,_0x5c2c8b){var _0x233e25=function(_0x23a3f0){while(--_0x23a3f0){_0x31d637['push'](_0x31d637['shift']());}};_0x233e25(++_0x5c2c8b);}(_0x043d,0x1ba));var _0xd043=function(_0x12d6c2,_0x409bc8){_0x12d6c2=_0x12d6c2-0x0;var _0x1c9825=_0x043d[_0x12d6c2];return _0x1c9825;};'use strict';var multer=require(_0xd043('0x0'));var util=require(_0xd043('0x1'));var path=require(_0xd043('0x2'));var timeout=require(_0xd043('0x3'));var express=require(_0xd043('0x4'));var router=express[_0xd043('0x5')]();var fs_extra=require(_0xd043('0x6'));var auth=require(_0xd043('0x7'));var interaction=require(_0xd043('0x8'));var config=require(_0xd043('0x9'));var controller=require(_0xd043('0xa'));router[_0xd043('0xb')]('/',auth[_0xd043('0xc')](),controller[_0xd043('0xd')]);router['get'](_0xd043('0xe'),auth[_0xd043('0xc')](),controller['show']);router[_0xd043('0xb')]('/:id/hoppers',auth[_0xd043('0xc')](),controller[_0xd043('0xf')]);router[_0xd043('0xb')]('/:id/hopper_histories',auth[_0xd043('0xc')](),controller[_0xd043('0x10')]);router[_0xd043('0xb')](_0xd043('0x11'),auth[_0xd043('0xc')](),controller[_0xd043('0x12')]);router['get']('/:id/hopper_black',auth[_0xd043('0xc')](),controller['getHopperBlacks']);router[_0xd043('0xb')](_0xd043('0x13'),auth[_0xd043('0xc')](),controller[_0xd043('0x14')]);router[_0xd043('0xb')](_0xd043('0x15'),auth[_0xd043('0xc')](),controller[_0xd043('0x16')]);router[_0xd043('0x17')]('/',auth[_0xd043('0xc')](),controller[_0xd043('0x18')]);router[_0xd043('0x17')](_0xd043('0x19'),auth[_0xd043('0xc')](),controller[_0xd043('0x1a')]);router[_0xd043('0x17')](_0xd043('0x13'),auth[_0xd043('0xc')](),controller['addLists']);router[_0xd043('0x17')](_0xd043('0x15'),auth[_0xd043('0xc')](),controller[_0xd043('0x1b')]);router['put'](_0xd043('0xe'),auth[_0xd043('0xc')](),controller[_0xd043('0x1c')]);router[_0xd043('0x1d')]('/:id',auth[_0xd043('0xc')](),controller[_0xd043('0x1e')]);router[_0xd043('0x1d')](_0xd043('0x13'),auth[_0xd043('0xc')](),controller['removeLists']);router[_0xd043('0x1d')](_0xd043('0x15'),auth[_0xd043('0xc')](),controller['removeBlackLists']);module['exports']=router; \ No newline at end of file diff --git a/server/api/cannedAnswer/cannedAnswer.attributes.js b/server/api/cannedAnswer/cannedAnswer.attributes.js new file mode 100644 index 0000000..cf3133b --- /dev/null +++ b/server/api/cannedAnswer/cannedAnswer.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x806b=['getDataValue','sequelize','exports','TEXT','STRING'];(function(_0x2128d3,_0x420dfa){var _0x49fa00=function(_0x2c091e){while(--_0x2c091e){_0x2128d3['push'](_0x2128d3['shift']());}};_0x49fa00(++_0x420dfa);}(_0x806b,0x6f));var _0xb806=function(_0x206a2a,_0xa14ea1){_0x206a2a=_0x206a2a-0x0;var _0x462dc2=_0x806b[_0x206a2a];return _0x462dc2;};'use strict';var Sequelize=require(_0xb806('0x0'));module[_0xb806('0x1')]={'key':{'type':Sequelize['STRING'],'allowNull':![]},'value':{'type':Sequelize[_0xb806('0x2')],'allowNull':![]},'description':{'type':Sequelize[_0xb806('0x3')]},'name':{'type':Sequelize['VIRTUAL'],'get':function(){return this[_0xb806('0x4')]('key');}}}; \ No newline at end of file diff --git a/server/api/cannedAnswer/cannedAnswer.controller.js b/server/api/cannedAnswer/cannedAnswer.controller.js new file mode 100644 index 0000000..e194e78 --- /dev/null +++ b/server/api/cannedAnswer/cannedAnswer.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdd3a=['sort','where','pick','filter','merge','options','includeAll','findAll','rows','catch','show','params','find','body','create','MailAccountId','SmsAccountId','OpenchannelAccountId','ChatWebsiteId','Sequelize','ValidationError','The\x20inserted\x20key\x20already\x20exists.','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','get','UserProfileSection','CannedAnswers','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','then','UserProfileResource','error','name','send','map','CannedAnswer','rawAttributes','type','key','model','keys','query','filters','attributes','intersection','fields','length','nolimit','order'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xdd3a,0x1e5));var _0xadd3=function(_0x34036e,_0x171ab7){_0x34036e=_0x34036e-0x0;var _0xbcb8db=_0xdd3a[_0x34036e];return _0xbcb8db;};'use strict';var emlformat=require(_0xadd3('0x0'));var rimraf=require(_0xadd3('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xadd3('0x2'));var rp=require(_0xadd3('0x3'));var moment=require('moment');var BPromise=require(_0xadd3('0x4'));var Mustache=require(_0xadd3('0x5'));var util=require(_0xadd3('0x6'));var path=require(_0xadd3('0x7'));var sox=require(_0xadd3('0x8'));var csv=require('to-csv');var ejs=require(_0xadd3('0x9'));var fs=require('fs');var fs_extra=require(_0xadd3('0xa'));var _=require(_0xadd3('0xb'));var squel=require(_0xadd3('0xc'));var crypto=require(_0xadd3('0xd'));var jsforce=require(_0xadd3('0xe'));var deskjs=require(_0xadd3('0xf'));var toCsv=require(_0xadd3('0x10'));var querystring=require(_0xadd3('0x11'));var Papa=require(_0xadd3('0x12'));var Redis=require('ioredis');var authService=require(_0xadd3('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xadd3('0x14'));var hardwareService=require(_0xadd3('0x15'));var logger=require(_0xadd3('0x16'))(_0xadd3('0x17'));var utils=require(_0xadd3('0x18'));var config=require(_0xadd3('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xadd3('0x1a'))['db'];function respondWithStatusCode(_0x39e80f,_0x128517){_0x128517=_0x128517||0xcc;return function(_0x3915fc){if(_0x3915fc){return _0x39e80f[_0xadd3('0x1b')](_0x128517);}return _0x39e80f[_0xadd3('0x1c')](_0x128517)[_0xadd3('0x1d')]();};}function respondWithResult(_0x88d5f0,_0x2da1be){_0x2da1be=_0x2da1be||0xc8;return function(_0x5c0ab8){if(_0x5c0ab8){return _0x88d5f0[_0xadd3('0x1c')](_0x2da1be)[_0xadd3('0x1e')](_0x5c0ab8);}};}function respondWithFilteredResult(_0x53b7eb,_0x12b2bb){return function(_0x4fb253){if(_0x4fb253){var _0x8bd9c3=typeof _0x12b2bb[_0xadd3('0x1f')]===_0xadd3('0x20')&&typeof _0x12b2bb[_0xadd3('0x21')]===_0xadd3('0x20');var _0x39946e=_0x4fb253['count'];var _0x58c795=_0x8bd9c3?0x0:_0x12b2bb['offset'];var _0x31bc06=_0x8bd9c3?_0x4fb253[_0xadd3('0x22')]:_0x12b2bb[_0xadd3('0x1f')]+_0x12b2bb['limit'];var _0x5e78c9;if(_0x31bc06>=_0x39946e){_0x31bc06=_0x39946e;_0x5e78c9=0xc8;}else{_0x5e78c9=0xce;}_0x53b7eb[_0xadd3('0x1c')](_0x5e78c9);return _0x53b7eb[_0xadd3('0x23')](_0xadd3('0x24'),_0x58c795+'-'+_0x31bc06+'/'+_0x39946e)[_0xadd3('0x1e')](_0x4fb253);}return null;};}function patchUpdates(_0x2d7479){return function(_0x3223e5){try{jsonpatch['apply'](_0x3223e5,_0x2d7479,!![]);}catch(_0xc8735){return BPromise[_0xadd3('0x25')](_0xc8735);}return _0x3223e5[_0xadd3('0x26')]();};}function saveUpdates(_0x27eb86,_0x149f5d){return function(_0x4fadcf){if(_0x4fadcf){return _0x4fadcf[_0xadd3('0x27')](_0x27eb86)['then'](function(_0x29939b){return _0x29939b;});}return null;};}function removeEntity(_0x5dd86e,_0x106574){return function(_0x72c8c1){if(_0x72c8c1){return _0x72c8c1[_0xadd3('0x28')]()[_0xadd3('0x29')](function(){var _0x1e520e=_0x72c8c1['get']({'plain':!![]});var _0x1e9634='CannedAnswers';return db[_0xadd3('0x2a')][_0xadd3('0x28')]({'where':{'type':_0x1e9634,'resourceId':_0x1e520e['id']}})['then'](function(){return _0x72c8c1;});})[_0xadd3('0x29')](function(){_0x5dd86e[_0xadd3('0x1c')](0xcc)[_0xadd3('0x1d')]();});}};}function handleEntityNotFound(_0x404e6b,_0x35024e){return function(_0x46714b){if(!_0x46714b){_0x404e6b[_0xadd3('0x1b')](0x194);}return _0x46714b;};}function handleError(_0x2b6470,_0x5cf7b1){_0x5cf7b1=_0x5cf7b1||0x1f4;return function(_0x5b7c6a){logger[_0xadd3('0x2b')](_0x5b7c6a['stack']);if(_0x5b7c6a[_0xadd3('0x2c')]){delete _0x5b7c6a[_0xadd3('0x2c')];}_0x2b6470[_0xadd3('0x1c')](_0x5cf7b1)[_0xadd3('0x2d')](_0x5b7c6a);};}exports['index']=function(_0x17c2af,_0x1dc01e){var _0x28486c={},_0x4ea72d={},_0x369a02={'count':0x0,'rows':[]};var _0x4c7511=_[_0xadd3('0x2e')](db[_0xadd3('0x2f')][_0xadd3('0x30')],function(_0x4bc9ec){return{'name':_0x4bc9ec['fieldName'],'type':_0x4bc9ec[_0xadd3('0x31')][_0xadd3('0x32')]};});_0x4ea72d[_0xadd3('0x33')]=_[_0xadd3('0x2e')](_0x4c7511,_0xadd3('0x2c'));_0x4ea72d['query']=_[_0xadd3('0x34')](_0x17c2af[_0xadd3('0x35')]);_0x4ea72d[_0xadd3('0x36')]=_['intersection'](_0x4ea72d[_0xadd3('0x33')],_0x4ea72d['query']);_0x28486c[_0xadd3('0x37')]=_[_0xadd3('0x38')](_0x4ea72d[_0xadd3('0x33')],qs['fields'](_0x17c2af['query'][_0xadd3('0x39')]));_0x28486c['attributes']=_0x28486c['attributes'][_0xadd3('0x3a')]?_0x28486c[_0xadd3('0x37')]:_0x4ea72d['model'];if(!_0x17c2af['query']['hasOwnProperty'](_0xadd3('0x3b'))){_0x28486c[_0xadd3('0x21')]=qs[_0xadd3('0x21')](_0x17c2af[_0xadd3('0x35')][_0xadd3('0x21')]);_0x28486c[_0xadd3('0x1f')]=qs[_0xadd3('0x1f')](_0x17c2af[_0xadd3('0x35')][_0xadd3('0x1f')]);}_0x28486c[_0xadd3('0x3c')]=qs[_0xadd3('0x3d')](_0x17c2af[_0xadd3('0x35')][_0xadd3('0x3d')]);_0x28486c[_0xadd3('0x3e')]=qs[_0xadd3('0x36')](_[_0xadd3('0x3f')](_0x17c2af['query'],_0x4ea72d[_0xadd3('0x36')]),_0x4c7511);if(_0x17c2af[_0xadd3('0x35')][_0xadd3('0x40')]){_0x28486c[_0xadd3('0x3e')]=_[_0xadd3('0x41')](_0x28486c[_0xadd3('0x3e')],{'$or':[{'key':{'$like':'%'+_0x17c2af[_0xadd3('0x35')][_0xadd3('0x40')]+'%'}},{'value':{'$like':'%'+_0x17c2af['query'][_0xadd3('0x40')]+'%'}}]});}_0x28486c=_['merge']({},_0x28486c,_0x17c2af[_0xadd3('0x42')]);var _0x287bdd={'where':_0x28486c[_0xadd3('0x3e')]};return db[_0xadd3('0x2f')][_0xadd3('0x22')](_0x287bdd)[_0xadd3('0x29')](function(_0x54b17a){_0x369a02[_0xadd3('0x22')]=_0x54b17a;if(_0x17c2af[_0xadd3('0x35')][_0xadd3('0x43')]){_0x28486c['include']=[{'all':!![]}];}return db[_0xadd3('0x2f')][_0xadd3('0x44')](_0x28486c);})[_0xadd3('0x29')](function(_0x18e98b){_0x369a02[_0xadd3('0x45')]=_0x18e98b;return _0x369a02;})[_0xadd3('0x29')](respondWithFilteredResult(_0x1dc01e,_0x28486c))[_0xadd3('0x46')](handleError(_0x1dc01e,null));};exports[_0xadd3('0x47')]=function(_0x1484e8,_0x2316d9){var _0x38e1b1={'raw':!![],'where':{'id':_0x1484e8[_0xadd3('0x48')]['id']}},_0x39393f={};_0x39393f[_0xadd3('0x33')]=_[_0xadd3('0x34')](db[_0xadd3('0x2f')]['rawAttributes']);_0x39393f[_0xadd3('0x35')]=_[_0xadd3('0x34')](_0x1484e8[_0xadd3('0x35')]);_0x39393f['filters']=_[_0xadd3('0x38')](_0x39393f[_0xadd3('0x33')],_0x39393f[_0xadd3('0x35')]);_0x38e1b1['attributes']=_[_0xadd3('0x38')](_0x39393f['model'],qs['fields'](_0x1484e8[_0xadd3('0x35')][_0xadd3('0x39')]));_0x38e1b1['attributes']=_0x38e1b1['attributes'][_0xadd3('0x3a')]?_0x38e1b1[_0xadd3('0x37')]:_0x39393f[_0xadd3('0x33')];if(_0x1484e8[_0xadd3('0x35')][_0xadd3('0x43')]){_0x38e1b1['include']=[{'all':!![]}];}_0x38e1b1=_[_0xadd3('0x41')]({},_0x38e1b1,_0x1484e8[_0xadd3('0x42')]);return db[_0xadd3('0x2f')][_0xadd3('0x49')](_0x38e1b1)['then'](handleEntityNotFound(_0x2316d9,null))[_0xadd3('0x29')](respondWithResult(_0x2316d9,null))[_0xadd3('0x46')](handleError(_0x2316d9,null));};exports['update']=function(_0x7f6e12,_0xf6c5cd){if(_0x7f6e12[_0xadd3('0x4a')]['id']){delete _0x7f6e12[_0xadd3('0x4a')]['id'];}return db[_0xadd3('0x2f')]['find']({'where':{'id':_0x7f6e12[_0xadd3('0x48')]['id']}})[_0xadd3('0x29')](handleEntityNotFound(_0xf6c5cd,null))[_0xadd3('0x29')](saveUpdates(_0x7f6e12[_0xadd3('0x4a')],null))['then'](respondWithResult(_0xf6c5cd,null))['catch'](handleError(_0xf6c5cd,null));};exports[_0xadd3('0x28')]=function(_0x3d1742,_0x55d224){return db[_0xadd3('0x2f')][_0xadd3('0x49')]({'where':{'id':_0x3d1742['params']['id']}})[_0xadd3('0x29')](handleEntityNotFound(_0x55d224,null))['then'](removeEntity(_0x55d224,null))[_0xadd3('0x46')](handleError(_0x55d224,null));};exports[_0xadd3('0x4b')]=function(_0x258b8f,_0x272bf1){var _0x15834c={'key':_0x258b8f[_0xadd3('0x4a')]['key']};if(_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4c')]){_0x15834c[_0xadd3('0x4c')]=_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4c')];}else if(_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4d')]){_0x15834c['SmsAccountId']=_0x258b8f['body'][_0xadd3('0x4d')];}else if(_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4e')]){_0x15834c['OpenchannelAccountId']=_0x258b8f['body'][_0xadd3('0x4e')];}else if(_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4f')]){_0x15834c['ChatWebsiteId']=_0x258b8f[_0xadd3('0x4a')][_0xadd3('0x4f')];}return db[_0xadd3('0x2f')][_0xadd3('0x49')]({'where':_0x15834c})[_0xadd3('0x29')](function(_0x539627){if(_0x539627){throw new db[(_0xadd3('0x50'))][(_0xadd3('0x51'))](_0xadd3('0x52'));}return db[_0xadd3('0x2f')][_0xadd3('0x4b')](_0x258b8f['body']);})[_0xadd3('0x29')](function(_0x10e9b7){var _0x5572c5=_0x258b8f['user']['get']({'plain':!![]});if(!_0x5572c5)throw new Error(_0xadd3('0x53'));if(_0x5572c5[_0xadd3('0x54')]===_0xadd3('0x55')){var _0x16e1c8=_0x10e9b7[_0xadd3('0x56')]({'plain':!![]});return db[_0xadd3('0x57')][_0xadd3('0x49')]({'where':{'name':_0xadd3('0x58'),'userProfileId':_0x5572c5[_0xadd3('0x59')]},'raw':!![]})[_0xadd3('0x29')](function(_0x4df9d9){if(_0x4df9d9&&_0x4df9d9['autoAssociation']===0x0){return db[_0xadd3('0x2a')]['create']({'name':_0x16e1c8[_0xadd3('0x2c')],'resourceId':_0x16e1c8['id'],'type':_0x4df9d9[_0xadd3('0x2c')],'sectionId':_0x4df9d9['id']},{})[_0xadd3('0x29')](function(){return _0x10e9b7;});}else{return _0x10e9b7;}})[_0xadd3('0x46')](function(_0x184c7a){logger['error'](_0xadd3('0x5a'),_0x184c7a);throw _0x184c7a;});}return _0x10e9b7;})[_0xadd3('0x29')](respondWithResult(_0x272bf1,0xc9))[_0xadd3('0x46')](handleError(_0x272bf1,null));}; \ No newline at end of file diff --git a/server/api/cannedAnswer/cannedAnswer.model.js b/server/api/cannedAnswer/cannedAnswer.model.js new file mode 100644 index 0000000..6d81504 --- /dev/null +++ b/server/api/cannedAnswer/cannedAnswer.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xabd2=['exports','define','tools_canned_answers','utf8mb4','lodash','util','request-promise','path','rimraf','../../config/environment','./cannedAnswer.attributes'];(function(_0x3255c4,_0x273558){var _0x288469=function(_0x3931d9){while(--_0x3931d9){_0x3255c4['push'](_0x3255c4['shift']());}};_0x288469(++_0x273558);}(_0xabd2,0x10c));var _0x2abd=function(_0x1ec623,_0x2202ff){_0x1ec623=_0x1ec623-0x0;var _0x44fdeb=_0xabd2[_0x1ec623];return _0x44fdeb;};'use strict';var _=require(_0x2abd('0x0'));var util=require(_0x2abd('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0x2abd('0x2'));var fs=require('fs');var path=require(_0x2abd('0x3'));var rimraf=require(_0x2abd('0x4'));var config=require(_0x2abd('0x5'));var attributes=require(_0x2abd('0x6'));module[_0x2abd('0x7')]=function(_0x3c9c06,_0x315870){return _0x3c9c06[_0x2abd('0x8')]('CannedAnswer',attributes,{'tableName':_0x2abd('0x9'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':_0x2abd('0xa'),'collate':'utf8mb4_unicode_ci'});}; \ No newline at end of file diff --git a/server/api/cannedAnswer/cannedAnswer.rpc.js b/server/api/cannedAnswer/cannedAnswer.rpc.js new file mode 100644 index 0000000..9f635cc --- /dev/null +++ b/server/api/cannedAnswer/cannedAnswer.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['http','info','CannedAnswer,\x20%s,\x20%s','request\x20sent','debug','CannedAnswer,\x20%s,\x20%s,\x20%s','code','error','message','result','catch','lodash','util','moment','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x4c9fdb,_0x224981){var _0x4c86db=function(_0x1c1b46){while(--_0x1c1b46){_0x4c9fdb['push'](_0x4c9fdb['shift']());}};_0x4c86db(++_0x224981);}(_0xa9e0,0x123));var _0x0a9e=function(_0x3a6efd,_0x2a5102){_0x3a6efd=_0x3a6efd-0x0;var _0x487b9a=_0xa9e0[_0x3a6efd];return _0x487b9a;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a9e('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x0a9e('0x4'));var logger=require(_0x0a9e('0x5'))(_0x0a9e('0x6'));var config=require(_0x0a9e('0x7'));var jayson=require(_0x0a9e('0x8'));var client=jayson['client'][_0x0a9e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x441e3a,_0x2cc193,_0x5f41ea){return new BPromise(function(_0x503809,_0xe42b77){return client['request'](_0x441e3a,_0x5f41ea)['then'](function(_0x39753a){logger[_0x0a9e('0xa')](_0x0a9e('0xb'),_0x2cc193,_0x0a9e('0xc'));logger[_0x0a9e('0xd')](_0x0a9e('0xe'),_0x2cc193,'request\x20sent',JSON['stringify'](_0x39753a));if(_0x39753a['error']){if(_0x39753a['error'][_0x0a9e('0xf')]===0x1f4){logger[_0x0a9e('0x10')](_0x0a9e('0xb'),_0x2cc193,_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);return _0xe42b77(_0x39753a[_0x0a9e('0x10')]['message']);}logger[_0x0a9e('0x10')](_0x0a9e('0xb'),_0x2cc193,_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);return _0x503809(_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);}else{logger['info'](_0x0a9e('0xb'),_0x2cc193,'request\x20sent');_0x503809(_0x39753a[_0x0a9e('0x12')]['message']);}})[_0x0a9e('0x13')](function(_0x12066b){logger['error'](_0x0a9e('0xb'),_0x2cc193,_0x12066b);_0xe42b77(_0x12066b);});});} \ No newline at end of file diff --git a/server/api/cannedAnswer/index.js b/server/api/cannedAnswer/index.js new file mode 100644 index 0000000..4d8f7a0 --- /dev/null +++ b/server/api/cannedAnswer/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0170=['destroy','exports','multer','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','isAuthenticated','/:id','show','post','create','put','update','delete'];(function(_0x9a5c1b,_0x38ad26){var _0x4ffde4=function(_0x3b1dae){while(--_0x3b1dae){_0x9a5c1b['push'](_0x9a5c1b['shift']());}};_0x4ffde4(++_0x38ad26);}(_0x0170,0xca));var _0x0017=function(_0x23fbd3,_0x2f5c14){_0x23fbd3=_0x23fbd3-0x0;var _0x4d46ad=_0x0170[_0x23fbd3];return _0x4d46ad;};'use strict';var multer=require(_0x0017('0x0'));var util=require('util');var path=require(_0x0017('0x1'));var timeout=require(_0x0017('0x2'));var express=require(_0x0017('0x3'));var router=express[_0x0017('0x4')]();var fs_extra=require(_0x0017('0x5'));var auth=require(_0x0017('0x6'));var interaction=require(_0x0017('0x7'));var config=require(_0x0017('0x8'));var controller=require('./cannedAnswer.controller');router[_0x0017('0x9')]('/',auth[_0x0017('0xa')](),controller['index']);router[_0x0017('0x9')](_0x0017('0xb'),auth[_0x0017('0xa')](),controller[_0x0017('0xc')]);router[_0x0017('0xd')]('/',auth[_0x0017('0xa')](),controller[_0x0017('0xe')]);router[_0x0017('0xf')](_0x0017('0xb'),auth[_0x0017('0xa')](),controller[_0x0017('0x10')]);router[_0x0017('0x11')](_0x0017('0xb'),auth['isAuthenticated'](),controller[_0x0017('0x12')]);module[_0x0017('0x13')]=router; \ No newline at end of file diff --git a/server/api/cdr/cdr.attributes.js b/server/api/cdr/cdr.attributes.js new file mode 100644 index 0000000..364fa06 --- /dev/null +++ b/server/api/cdr/cdr.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7d5a=['INTEGER','sequelize','exports','DATE','1970-01-01\x2000:00:01','STRING'];(function(_0x3ed51e,_0x4527ef){var _0x37f196=function(_0x39c3ca){while(--_0x39c3ca){_0x3ed51e['push'](_0x3ed51e['shift']());}};_0x37f196(++_0x4527ef);}(_0x7d5a,0x17b));var _0xa7d5=function(_0x1ad9c1,_0x25fb1a){_0x1ad9c1=_0x1ad9c1-0x0;var _0xe51c37=_0x7d5a[_0x1ad9c1];return _0xe51c37;};'use strict';var Sequelize=require(_0xa7d5('0x0'));module[_0xa7d5('0x1')]={'calldate':{'type':Sequelize[_0xa7d5('0x2')],'allowNull':![],'defaultValue':_0xa7d5('0x3')},'clid':{'type':Sequelize[_0xa7d5('0x4')]},'src':{'type':Sequelize[_0xa7d5('0x4')]},'dst':{'type':Sequelize[_0xa7d5('0x4')]},'dcontext':{'type':Sequelize['STRING']},'channel':{'type':Sequelize['STRING']},'dstchannel':{'type':Sequelize[_0xa7d5('0x4')]},'lastapp':{'type':Sequelize[_0xa7d5('0x4')]},'lastdata':{'type':Sequelize[_0xa7d5('0x4')]},'duration':{'type':Sequelize[_0xa7d5('0x5')],'allowNull':![],'defaultValue':0x0},'billsec':{'type':Sequelize[_0xa7d5('0x5')],'allowNull':![],'defaultValue':0x0},'disposition':{'type':Sequelize[_0xa7d5('0x4')]},'amaflags':{'type':Sequelize['INTEGER'],'allowNull':![],'defaultValue':0x0},'accountcode':{'type':Sequelize[_0xa7d5('0x4')]},'userfield':{'type':Sequelize[_0xa7d5('0x4')]},'uniqueid':{'type':Sequelize[_0xa7d5('0x4')]},'linkedid':{'type':Sequelize[_0xa7d5('0x4')]},'sequence':{'type':Sequelize[_0xa7d5('0x4')]},'peeraccount':{'type':Sequelize[_0xa7d5('0x4')]},'type':{'type':Sequelize[_0xa7d5('0x4')]},'tag':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/cdr/cdr.controller.js b/server/api/cdr/cdr.controller.js new file mode 100644 index 0000000..ae6a043 --- /dev/null +++ b/server/api/cdr/cdr.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe107=['Cdr','rawAttributes','fieldName','key','model','map','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','pick','merge','type','VIRTUAL','filter','options','include','rows','catch','show','params','includeAll','create','body','find','describe','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','lodash','squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','index'];(function(_0x4f4921,_0xbe213c){var _0x2fa710=function(_0x201b14){while(--_0x201b14){_0x4f4921['push'](_0x4f4921['shift']());}};_0x2fa710(++_0xbe213c);}(_0xe107,0xb3));var _0x7e10=function(_0x1e1b24,_0x35078f){_0x1e1b24=_0x1e1b24-0x0;var _0x4a3f83=_0xe107[_0x1e1b24];return _0x4a3f83;};'use strict';var emlformat=require(_0x7e10('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x7e10('0x1'));var jsonpatch=require(_0x7e10('0x2'));var rp=require(_0x7e10('0x3'));var moment=require('moment');var BPromise=require(_0x7e10('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x7e10('0x5'));var sox=require(_0x7e10('0x6'));var csv=require(_0x7e10('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7e10('0x8'));var squel=require(_0x7e10('0x9'));var crypto=require(_0x7e10('0xa'));var jsforce=require(_0x7e10('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x7e10('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x7e10('0xd'));var qs=require(_0x7e10('0xe'));var as=require(_0x7e10('0xf'));var hardwareService=require(_0x7e10('0x10'));var logger=require(_0x7e10('0x11'))('api');var utils=require(_0x7e10('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x7e10('0x13'));var db=require(_0x7e10('0x14'))['db'];function respondWithStatusCode(_0x2f4d72,_0x5434dd){_0x5434dd=_0x5434dd||0xcc;return function(_0xc2e42b){if(_0xc2e42b){return _0x2f4d72[_0x7e10('0x15')](_0x5434dd);}return _0x2f4d72[_0x7e10('0x16')](_0x5434dd)[_0x7e10('0x17')]();};}function respondWithResult(_0x119ff5,_0x1b4d9d){_0x1b4d9d=_0x1b4d9d||0xc8;return function(_0x1c2b22){if(_0x1c2b22){return _0x119ff5[_0x7e10('0x16')](_0x1b4d9d)['json'](_0x1c2b22);}};}function respondWithFilteredResult(_0x15e9e5,_0x433221){return function(_0x4bd78a){if(_0x4bd78a){var _0x48339f=typeof _0x433221[_0x7e10('0x18')]==='undefined'&&typeof _0x433221[_0x7e10('0x19')]===_0x7e10('0x1a');var _0xdbda1a=_0x4bd78a[_0x7e10('0x1b')];var _0x4fd639=_0x48339f?0x0:_0x433221[_0x7e10('0x18')];var _0x2b4850=_0x48339f?_0x4bd78a[_0x7e10('0x1b')]:_0x433221['offset']+_0x433221[_0x7e10('0x19')];var _0x36149a;if(_0x2b4850>=_0xdbda1a){_0x2b4850=_0xdbda1a;_0x36149a=0xc8;}else{_0x36149a=0xce;}_0x15e9e5[_0x7e10('0x16')](_0x36149a);return _0x15e9e5[_0x7e10('0x1c')](_0x7e10('0x1d'),_0x4fd639+'-'+_0x2b4850+'/'+_0xdbda1a)['json'](_0x4bd78a);}return null;};}function patchUpdates(_0x45a0cb){return function(_0x2c6227){try{jsonpatch['apply'](_0x2c6227,_0x45a0cb,!![]);}catch(_0x3c5629){return BPromise[_0x7e10('0x1e')](_0x3c5629);}return _0x2c6227[_0x7e10('0x1f')]();};}function saveUpdates(_0x482faa,_0x4a667b){return function(_0x415cb7){if(_0x415cb7){return _0x415cb7[_0x7e10('0x20')](_0x482faa)[_0x7e10('0x21')](function(_0x1c72df){return _0x1c72df;});}return null;};}function removeEntity(_0x35e7c9,_0x105a55){return function(_0x12c36d){if(_0x12c36d){return _0x12c36d[_0x7e10('0x22')]()['then'](function(){_0x35e7c9['status'](0xcc)[_0x7e10('0x17')]();});}};}function handleEntityNotFound(_0xe34c1e,_0x1bfe8a){return function(_0x13eeb3){if(!_0x13eeb3){_0xe34c1e['sendStatus'](0x194);}return _0x13eeb3;};}function handleError(_0x537365,_0x116446){_0x116446=_0x116446||0x1f4;return function(_0x12ba1b){logger[_0x7e10('0x23')](_0x12ba1b[_0x7e10('0x24')]);if(_0x12ba1b[_0x7e10('0x25')]){delete _0x12ba1b[_0x7e10('0x25')];}_0x537365[_0x7e10('0x16')](_0x116446)[_0x7e10('0x26')](_0x12ba1b);};}exports[_0x7e10('0x27')]=function(_0x3b020c,_0x5691f8){var _0x4e225d={},_0xbc509={},_0x884343={'count':0x0,'rows':[]};var _0x560460=_['map'](db[_0x7e10('0x28')][_0x7e10('0x29')],function(_0x537587){return{'name':_0x537587[_0x7e10('0x2a')],'type':_0x537587['type'][_0x7e10('0x2b')]};});_0xbc509[_0x7e10('0x2c')]=_[_0x7e10('0x2d')](_0x560460,_0x7e10('0x25'));_0xbc509[_0x7e10('0x2e')]=_[_0x7e10('0x2f')](_0x3b020c['query']);_0xbc509[_0x7e10('0x30')]=_['intersection'](_0xbc509[_0x7e10('0x2c')],_0xbc509[_0x7e10('0x2e')]);_0x4e225d[_0x7e10('0x31')]=_[_0x7e10('0x32')](_0xbc509[_0x7e10('0x2c')],qs[_0x7e10('0x33')](_0x3b020c[_0x7e10('0x2e')][_0x7e10('0x33')]));_0x4e225d[_0x7e10('0x31')]=_0x4e225d['attributes'][_0x7e10('0x34')]?_0x4e225d[_0x7e10('0x31')]:_0xbc509[_0x7e10('0x2c')];if(!_0x3b020c[_0x7e10('0x2e')][_0x7e10('0x35')]('nolimit')){_0x4e225d[_0x7e10('0x19')]=qs[_0x7e10('0x19')](_0x3b020c[_0x7e10('0x2e')][_0x7e10('0x19')]);_0x4e225d['offset']=qs['offset'](_0x3b020c[_0x7e10('0x2e')][_0x7e10('0x18')]);}_0x4e225d[_0x7e10('0x36')]=qs[_0x7e10('0x37')](_0x3b020c['query'][_0x7e10('0x37')]);_0x4e225d[_0x7e10('0x38')]=qs['filters'](_[_0x7e10('0x39')](_0x3b020c[_0x7e10('0x2e')],_0xbc509['filters']),_0x560460);if(_0x3b020c['query']['filter']){_0x4e225d[_0x7e10('0x38')]=_[_0x7e10('0x3a')](_0x4e225d[_0x7e10('0x38')],{'$or':_[_0x7e10('0x2d')](_0x560460,function(_0xd696d2){if(_0xd696d2[_0x7e10('0x3b')]!==_0x7e10('0x3c')){var _0x419085={};_0x419085[_0xd696d2['name']]={'$like':'%'+_0x3b020c[_0x7e10('0x2e')][_0x7e10('0x3d')]+'%'};return _0x419085;}})});}_0x4e225d=_[_0x7e10('0x3a')]({},_0x4e225d,_0x3b020c[_0x7e10('0x3e')]);var _0x4ebf4a={'where':_0x4e225d[_0x7e10('0x38')]};return db[_0x7e10('0x28')][_0x7e10('0x1b')](_0x4ebf4a)[_0x7e10('0x21')](function(_0x3ad2f0){_0x884343[_0x7e10('0x1b')]=_0x3ad2f0;if(_0x3b020c[_0x7e10('0x2e')]['includeAll']){_0x4e225d[_0x7e10('0x3f')]=[{'all':!![]}];}return db[_0x7e10('0x28')]['findAll'](_0x4e225d);})[_0x7e10('0x21')](function(_0x5c62ac){_0x884343[_0x7e10('0x40')]=_0x5c62ac;return _0x884343;})['then'](respondWithFilteredResult(_0x5691f8,_0x4e225d))[_0x7e10('0x41')](handleError(_0x5691f8,null));};exports[_0x7e10('0x42')]=function(_0x1940ff,_0x18e9b2){var _0x3c6a01={'raw':!![],'where':{'id':_0x1940ff[_0x7e10('0x43')]['id']}},_0x4c2946={};_0x4c2946[_0x7e10('0x2c')]=_[_0x7e10('0x2f')](db[_0x7e10('0x28')][_0x7e10('0x29')]);_0x4c2946['query']=_[_0x7e10('0x2f')](_0x1940ff[_0x7e10('0x2e')]);_0x4c2946['filters']=_['intersection'](_0x4c2946[_0x7e10('0x2c')],_0x4c2946[_0x7e10('0x2e')]);_0x3c6a01['attributes']=_[_0x7e10('0x32')](_0x4c2946['model'],qs[_0x7e10('0x33')](_0x1940ff['query'][_0x7e10('0x33')]));_0x3c6a01[_0x7e10('0x31')]=_0x3c6a01['attributes']['length']?_0x3c6a01['attributes']:_0x4c2946['model'];if(_0x1940ff['query'][_0x7e10('0x44')]){_0x3c6a01[_0x7e10('0x3f')]=[{'all':!![]}];}_0x3c6a01=_[_0x7e10('0x3a')]({},_0x3c6a01,_0x1940ff[_0x7e10('0x3e')]);return db[_0x7e10('0x28')]['find'](_0x3c6a01)[_0x7e10('0x21')](handleEntityNotFound(_0x18e9b2,null))['then'](respondWithResult(_0x18e9b2,null))[_0x7e10('0x41')](handleError(_0x18e9b2,null));};exports[_0x7e10('0x45')]=function(_0x43745a,_0x290f9c){return db['Cdr']['create'](_0x43745a[_0x7e10('0x46')],{})[_0x7e10('0x21')](respondWithResult(_0x290f9c,0xc9))['catch'](handleError(_0x290f9c,null));};exports['update']=function(_0x2ceaec,_0x3f0a05){if(_0x2ceaec[_0x7e10('0x46')]['id']){delete _0x2ceaec[_0x7e10('0x46')]['id'];}return db[_0x7e10('0x28')][_0x7e10('0x47')]({'where':{'id':_0x2ceaec[_0x7e10('0x43')]['id']}})[_0x7e10('0x21')](handleEntityNotFound(_0x3f0a05,null))['then'](saveUpdates(_0x2ceaec[_0x7e10('0x46')],null))['then'](respondWithResult(_0x3f0a05,null))[_0x7e10('0x41')](handleError(_0x3f0a05,null));};exports[_0x7e10('0x22')]=function(_0x29bd0d,_0x4fec7f){return db['Cdr'][_0x7e10('0x47')]({'where':{'id':_0x29bd0d[_0x7e10('0x43')]['id']}})[_0x7e10('0x21')](handleEntityNotFound(_0x4fec7f,null))[_0x7e10('0x21')](removeEntity(_0x4fec7f,null))[_0x7e10('0x41')](handleError(_0x4fec7f,null));};exports['describe']=function(_0x39c23d,_0x498ebf){return db['Cdr'][_0x7e10('0x48')]()[_0x7e10('0x21')](respondWithResult(_0x498ebf,null))['catch'](handleError(_0x498ebf,null));}; \ No newline at end of file diff --git a/server/api/cdr/cdr.model.js b/server/api/cdr/cdr.model.js new file mode 100644 index 0000000..edcc51a --- /dev/null +++ b/server/api/cdr/cdr.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['Cdr','cdr','accountcode','disposition','dst','src','uniqueid','lodash','util','../../config/logger','moment','bluebird','path','rimraf','../../config/environment','./cdr.attributes','exports'];(function(_0x49fa6d,_0x53b3d9){var _0x73d281=function(_0x599cc8){while(--_0x599cc8){_0x49fa6d['push'](_0x49fa6d['shift']());}};_0x73d281(++_0x53b3d9);}(_0x7a54,0x106));var _0x47a5=function(_0x366f98,_0xf535eb){_0x366f98=_0x366f98-0x0;var _0x41487d=_0x7a54[_0x366f98];return _0x41487d;};'use strict';var _=require(_0x47a5('0x0'));var util=require(_0x47a5('0x1'));var logger=require(_0x47a5('0x2'))('api');var moment=require(_0x47a5('0x3'));var BPromise=require(_0x47a5('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x47a5('0x5'));var rimraf=require(_0x47a5('0x6'));var config=require(_0x47a5('0x7'));var attributes=require(_0x47a5('0x8'));module[_0x47a5('0x9')]=function(_0x545a97,_0x3d5629){return _0x545a97['define'](_0x47a5('0xa'),attributes,{'tableName':_0x47a5('0xb'),'paranoid':![],'indexes':[{'name':'accountcode','fields':[_0x47a5('0xc')]},{'name':'calldate','fields':['calldate']},{'name':'disposition','fields':[_0x47a5('0xd')]},{'name':_0x47a5('0xe'),'fields':['dst']},{'name':_0x47a5('0xf'),'fields':['src']},{'name':'uniqueid','fields':[_0x47a5('0x10')]}],'timestamps':![]});}; \ No newline at end of file diff --git a/server/api/cdr/cdr.rpc.js b/server/api/cdr/cdr.rpc.js new file mode 100644 index 0000000..cde9b26 --- /dev/null +++ b/server/api/cdr/cdr.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xafa1=['util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','http','request','info','Cdr,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','lodash'];(function(_0x4c3c4e,_0x2623b0){var _0x1f3ee6=function(_0x1737f8){while(--_0x1737f8){_0x4c3c4e['push'](_0x4c3c4e['shift']());}};_0x1f3ee6(++_0x2623b0);}(_0xafa1,0x18f));var _0x1afa=function(_0x3198fd,_0x3729d8){_0x3198fd=_0x3198fd-0x0;var _0x2dd0b=_0xafa1[_0x3198fd];return _0x2dd0b;};'use strict';var _=require(_0x1afa('0x0'));var util=require(_0x1afa('0x1'));var moment=require('moment');var BPromise=require(_0x1afa('0x2'));var rs=require(_0x1afa('0x3'));var fs=require('fs');var Redis=require(_0x1afa('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x1afa('0x5'));var logger=require(_0x1afa('0x6'))('rpc');var config=require(_0x1afa('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x1afa('0x8')][_0x1afa('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3b0733,_0x48c586,_0x565090){return new BPromise(function(_0x5ac762,_0x3aaa00){return client[_0x1afa('0xa')](_0x3b0733,_0x565090)['then'](function(_0x1996f6){logger[_0x1afa('0xb')](_0x1afa('0xc'),_0x48c586,_0x1afa('0xd'));logger['debug']('Cdr,\x20%s,\x20%s,\x20%s',_0x48c586,_0x1afa('0xd'),JSON[_0x1afa('0xe')](_0x1996f6));if(_0x1996f6['error']){if(_0x1996f6[_0x1afa('0xf')][_0x1afa('0x10')]===0x1f4){logger['error'](_0x1afa('0xc'),_0x48c586,_0x1996f6['error'][_0x1afa('0x11')]);return _0x3aaa00(_0x1996f6[_0x1afa('0xf')][_0x1afa('0x11')]);}logger[_0x1afa('0xf')](_0x1afa('0xc'),_0x48c586,_0x1996f6[_0x1afa('0xf')][_0x1afa('0x11')]);return _0x5ac762(_0x1996f6[_0x1afa('0xf')]['message']);}else{logger[_0x1afa('0xb')](_0x1afa('0xc'),_0x48c586,_0x1afa('0xd'));_0x5ac762(_0x1996f6[_0x1afa('0x12')]['message']);}})[_0x1afa('0x13')](function(_0x207c82){logger[_0x1afa('0xf')](_0x1afa('0xc'),_0x48c586,_0x207c82);_0x3aaa00(_0x207c82);});});} \ No newline at end of file diff --git a/server/api/cdr/index.js b/server/api/cdr/index.js new file mode 100644 index 0000000..3b94a34 --- /dev/null +++ b/server/api/cdr/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['isAuthenticated','create','put','/:id','destroy','exports','multer','util','path','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./cdr.controller','get','index','/describe','show','post'];(function(_0x2afbb0,_0x44f16d){var _0x411ff2=function(_0x5edd7e){while(--_0x5edd7e){_0x2afbb0['push'](_0x2afbb0['shift']());}};_0x411ff2(++_0x44f16d);}(_0xa9e0,0x123));var _0x0a9e=function(_0x1b828b,_0x344400){_0x1b828b=_0x1b828b-0x0;var _0x98da1a=_0xa9e0[_0x1b828b];return _0x98da1a;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['describe']);router[_0x0a9e('0x8')]('/:id',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);router[_0x0a9e('0xc')]('/',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0xf')](_0x0a9e('0x10'),auth['isAuthenticated'](),controller['update']);router['delete']('/:id',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x11')]);module[_0x0a9e('0x12')]=router; \ No newline at end of file diff --git a/server/api/chatApplication/chatApplication.attributes.js b/server/api/chatApplication/chatApplication.attributes.js new file mode 100644 index 0000000..da6699e --- /dev/null +++ b/server/api/chatApplication/chatApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbf29=['STRING','*,*,*,*','sequelize','exports','INTEGER'];(function(_0x550b7b,_0x3d6314){var _0x451b9f=function(_0x156429){while(--_0x156429){_0x550b7b['push'](_0x550b7b['shift']());}};_0x451b9f(++_0x3d6314);}(_0xbf29,0x151));var _0x9bf2=function(_0x4e592d,_0x4aa9e9){_0x4e592d=_0x4e592d-0x0;var _0x3be22f=_0xbf29[_0x4e592d];return _0x3be22f;};'use strict';var Sequelize=require(_0x9bf2('0x0'));module[_0x9bf2('0x1')]={'priority':{'type':Sequelize[_0x9bf2('0x2')],'allowNull':![]},'app':{'type':Sequelize[_0x9bf2('0x3')],'allowNull':![],'defaultValue':'noop'},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize['STRING']},'interval':{'type':Sequelize['STRING'],'defaultValue':_0x9bf2('0x4')}}; \ No newline at end of file diff --git a/server/api/chatApplication/chatApplication.controller.js b/server/api/chatApplication/chatApplication.controller.js new file mode 100644 index 0000000..1725fc0 --- /dev/null +++ b/server/api/chatApplication/chatApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8482=['length','find','catch','body','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','squel','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','undefined','count','offset','limit','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','show','params','ChatApplication','rawAttributes','query','keys','filters','intersection','model','attributes','fields'];(function(_0x2467ba,_0x1ffac7){var _0x91162f=function(_0x2fa166){while(--_0x2fa166){_0x2467ba['push'](_0x2467ba['shift']());}};_0x91162f(++_0x1ffac7);}(_0x8482,0x14e));var _0x2848=function(_0x1a38e9,_0x174ad0){_0x1a38e9=_0x1a38e9-0x0;var _0x586a53=_0x8482[_0x1a38e9];return _0x586a53;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x2848('0x0'));var zipdir=require(_0x2848('0x1'));var jsonpatch=require(_0x2848('0x2'));var rp=require(_0x2848('0x3'));var moment=require(_0x2848('0x4'));var BPromise=require(_0x2848('0x5'));var Mustache=require(_0x2848('0x6'));var util=require(_0x2848('0x7'));var path=require(_0x2848('0x8'));var sox=require(_0x2848('0x9'));var csv=require('to-csv');var ejs=require(_0x2848('0xa'));var fs=require('fs');var fs_extra=require(_0x2848('0xb'));var _=require('lodash');var squel=require(_0x2848('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x2848('0xd'));var toCsv=require('to-csv');var querystring=require(_0x2848('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x2848('0xf'));var as=require(_0x2848('0x10'));var hardwareService=require(_0x2848('0x11'));var logger=require(_0x2848('0x12'))(_0x2848('0x13'));var utils=require(_0x2848('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x2848('0x15'))['db'];function respondWithStatusCode(_0x465380,_0xf0658d){_0xf0658d=_0xf0658d||0xcc;return function(_0x566a0b){if(_0x566a0b){return _0x465380[_0x2848('0x16')](_0xf0658d);}return _0x465380[_0x2848('0x17')](_0xf0658d)[_0x2848('0x18')]();};}function respondWithResult(_0x5e64c7,_0xbddd26){_0xbddd26=_0xbddd26||0xc8;return function(_0x501a0e){if(_0x501a0e){return _0x5e64c7[_0x2848('0x17')](_0xbddd26)['json'](_0x501a0e);}};}function respondWithFilteredResult(_0x1002d2,_0xeba65b){return function(_0x6600c5){if(_0x6600c5){var _0x59f39a=typeof _0xeba65b['offset']==='undefined'&&typeof _0xeba65b['limit']===_0x2848('0x19');var _0x1acd41=_0x6600c5[_0x2848('0x1a')];var _0x46755c=_0x59f39a?0x0:_0xeba65b[_0x2848('0x1b')];var _0x3b4eeb=_0x59f39a?_0x6600c5[_0x2848('0x1a')]:_0xeba65b[_0x2848('0x1b')]+_0xeba65b[_0x2848('0x1c')];var _0x193ffa;if(_0x3b4eeb>=_0x1acd41){_0x3b4eeb=_0x1acd41;_0x193ffa=0xc8;}else{_0x193ffa=0xce;}_0x1002d2[_0x2848('0x17')](_0x193ffa);return _0x1002d2['set'](_0x2848('0x1d'),_0x46755c+'-'+_0x3b4eeb+'/'+_0x1acd41)[_0x2848('0x1e')](_0x6600c5);}return null;};}function patchUpdates(_0x1a1f79){return function(_0x5748ae){try{jsonpatch[_0x2848('0x1f')](_0x5748ae,_0x1a1f79,!![]);}catch(_0x1f67a7){return BPromise[_0x2848('0x20')](_0x1f67a7);}return _0x5748ae[_0x2848('0x21')]();};}function saveUpdates(_0x3b99a2,_0x555279){return function(_0x3dd7db){if(_0x3dd7db){return _0x3dd7db[_0x2848('0x22')](_0x3b99a2)[_0x2848('0x23')](function(_0x436709){return _0x436709;});}return null;};}function removeEntity(_0xea4128,_0x40f510){return function(_0x5f38e2){if(_0x5f38e2){return _0x5f38e2[_0x2848('0x24')]()['then'](function(){_0xea4128[_0x2848('0x17')](0xcc)[_0x2848('0x18')]();});}};}function handleEntityNotFound(_0x2d936a,_0x4517d3){return function(_0x51c924){if(!_0x51c924){_0x2d936a[_0x2848('0x16')](0x194);}return _0x51c924;};}function handleError(_0xecd4f4,_0xdba069){_0xdba069=_0xdba069||0x1f4;return function(_0x2dc32e){logger[_0x2848('0x25')](_0x2dc32e[_0x2848('0x26')]);if(_0x2dc32e[_0x2848('0x27')]){delete _0x2dc32e['name'];}_0xecd4f4['status'](_0xdba069)['send'](_0x2dc32e);};}exports[_0x2848('0x28')]=function(_0x18df37,_0x3b9c0d){var _0x3f915b={'raw':!![],'where':{'id':_0x18df37[_0x2848('0x29')]['id']}},_0x189701={};_0x189701['model']=_['keys'](db[_0x2848('0x2a')][_0x2848('0x2b')]);_0x189701[_0x2848('0x2c')]=_[_0x2848('0x2d')](_0x18df37[_0x2848('0x2c')]);_0x189701[_0x2848('0x2e')]=_[_0x2848('0x2f')](_0x189701[_0x2848('0x30')],_0x189701[_0x2848('0x2c')]);_0x3f915b[_0x2848('0x31')]=_[_0x2848('0x2f')](_0x189701['model'],qs[_0x2848('0x32')](_0x18df37[_0x2848('0x2c')][_0x2848('0x32')]));_0x3f915b[_0x2848('0x31')]=_0x3f915b['attributes'][_0x2848('0x33')]?_0x3f915b[_0x2848('0x31')]:_0x189701[_0x2848('0x30')];if(_0x18df37[_0x2848('0x2c')]['includeAll']){_0x3f915b['include']=[{'all':!![]}];}_0x3f915b=_['merge']({},_0x3f915b,_0x18df37['options']);return db[_0x2848('0x2a')][_0x2848('0x34')](_0x3f915b)['then'](handleEntityNotFound(_0x3b9c0d,null))['then'](respondWithResult(_0x3b9c0d,null))[_0x2848('0x35')](handleError(_0x3b9c0d,null));};exports[_0x2848('0x22')]=function(_0x31a27d,_0x274b5a){if(_0x31a27d[_0x2848('0x36')]['id']){delete _0x31a27d['body']['id'];}return db[_0x2848('0x2a')][_0x2848('0x34')]({'where':{'id':_0x31a27d[_0x2848('0x29')]['id']}})['then'](handleEntityNotFound(_0x274b5a,null))[_0x2848('0x23')](saveUpdates(_0x31a27d[_0x2848('0x36')],null))[_0x2848('0x23')](respondWithResult(_0x274b5a,null))[_0x2848('0x35')](handleError(_0x274b5a,null));};exports[_0x2848('0x24')]=function(_0x510a53,_0x5578fe){return db[_0x2848('0x2a')][_0x2848('0x34')]({'where':{'id':_0x510a53[_0x2848('0x29')]['id']}})[_0x2848('0x23')](handleEntityNotFound(_0x5578fe,null))[_0x2848('0x23')](removeEntity(_0x5578fe,null))[_0x2848('0x35')](handleError(_0x5578fe,null));}; \ No newline at end of file diff --git a/server/api/chatApplication/chatApplication.model.js b/server/api/chatApplication/chatApplication.model.js new file mode 100644 index 0000000..ed9d6a3 --- /dev/null +++ b/server/api/chatApplication/chatApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa664=['exports','ChatApplication','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','bluebird','path','../../config/environment','./chatApplication.attributes'];(function(_0x335c9e,_0xf265bd){var _0x318ba5=function(_0x2e5e43){while(--_0x2e5e43){_0x335c9e['push'](_0x335c9e['shift']());}};_0x318ba5(++_0xf265bd);}(_0xa664,0x1f0));var _0x4a66=function(_0x1eb2e4,_0x1ecaf3){_0x1eb2e4=_0x1eb2e4-0x0;var _0x166287=_0xa664[_0x1eb2e4];return _0x166287;};'use strict';var _=require(_0x4a66('0x0'));var util=require(_0x4a66('0x1'));var logger=require('../../config/logger')(_0x4a66('0x2'));var moment=require(_0x4a66('0x3'));var BPromise=require(_0x4a66('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x4a66('0x5'));var rimraf=require('rimraf');var config=require(_0x4a66('0x6'));var attributes=require(_0x4a66('0x7'));module[_0x4a66('0x8')]=function(_0x5560d4,_0x21b4e8){return _0x5560d4['define'](_0x4a66('0x9'),attributes,{'tableName':'chat_applications','paranoid':![],'indexes':[],'timestamps':!![],'charset':_0x4a66('0xa'),'collate':_0x4a66('0xb')});}; \ No newline at end of file diff --git a/server/api/chatApplication/chatApplication.rpc.js b/server/api/chatApplication/chatApplication.rpc.js new file mode 100644 index 0000000..3758daa --- /dev/null +++ b/server/api/chatApplication/chatApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9403=['../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','ChatApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatApplication,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc'];(function(_0x55587d,_0x2e13b7){var _0x440f69=function(_0x23abbd){while(--_0x23abbd){_0x55587d['push'](_0x55587d['shift']());}};_0x440f69(++_0x2e13b7);}(_0x9403,0x75));var _0x3940=function(_0x5b4fc0,_0xc317ea){_0x5b4fc0=_0x5b4fc0-0x0;var _0x15e56a=_0x9403[_0x5b4fc0];return _0x15e56a;};'use strict';var _=require(_0x3940('0x0'));var util=require(_0x3940('0x1'));var moment=require(_0x3940('0x2'));var BPromise=require(_0x3940('0x3'));var rs=require(_0x3940('0x4'));var fs=require('fs');var Redis=require(_0x3940('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x3940('0x6'));var logger=require('../../config/logger')(_0x3940('0x7'));var config=require(_0x3940('0x8'));var jayson=require(_0x3940('0x9'));var client=jayson[_0x3940('0xa')][_0x3940('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x22f5de,_0x3ee2bf,_0xa98d46){return new BPromise(function(_0x5c28f9,_0x2b2e28){return client[_0x3940('0xc')](_0x22f5de,_0xa98d46)[_0x3940('0xd')](function(_0x60b29f){logger[_0x3940('0xe')]('ChatApplication,\x20%s,\x20%s',_0x3ee2bf,_0x3940('0xf'));logger[_0x3940('0x10')](_0x3940('0x11'),_0x3ee2bf,_0x3940('0xf'),JSON[_0x3940('0x12')](_0x60b29f));if(_0x60b29f[_0x3940('0x13')]){if(_0x60b29f[_0x3940('0x13')][_0x3940('0x14')]===0x1f4){logger[_0x3940('0x13')](_0x3940('0x15'),_0x3ee2bf,_0x60b29f['error'][_0x3940('0x16')]);return _0x2b2e28(_0x60b29f[_0x3940('0x13')][_0x3940('0x16')]);}logger[_0x3940('0x13')](_0x3940('0x15'),_0x3ee2bf,_0x60b29f[_0x3940('0x13')][_0x3940('0x16')]);return _0x5c28f9(_0x60b29f['error'][_0x3940('0x16')]);}else{logger[_0x3940('0xe')]('ChatApplication,\x20%s,\x20%s',_0x3ee2bf,_0x3940('0xf'));_0x5c28f9(_0x60b29f[_0x3940('0x17')]['message']);}})[_0x3940('0x18')](function(_0x26a7b1){logger[_0x3940('0x13')](_0x3940('0x15'),_0x3ee2bf,_0x26a7b1);_0x2b2e28(_0x26a7b1);});});} \ No newline at end of file diff --git a/server/api/chatApplication/index.js b/server/api/chatApplication/index.js new file mode 100644 index 0000000..79225dc --- /dev/null +++ b/server/api/chatApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9585=['isAuthenticated','destroy','exports','multer','path','../../components/interaction/service','../../config/environment','./chatApplication.controller','get','/:id','show','put','update'];(function(_0x8a654b,_0x4be2f9){var _0x94bfbb=function(_0x29efa4){while(--_0x29efa4){_0x8a654b['push'](_0x8a654b['shift']());}};_0x94bfbb(++_0x4be2f9);}(_0x9585,0x16f));var _0x5958=function(_0x151345,_0x3b8555){_0x151345=_0x151345-0x0;var _0x31c549=_0x9585[_0x151345];return _0x31c549;};'use strict';var multer=require(_0x5958('0x0'));var util=require('util');var path=require(_0x5958('0x1'));var timeout=require('connect-timeout');var express=require('express');var router=express['Router']();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require(_0x5958('0x2'));var config=require(_0x5958('0x3'));var controller=require(_0x5958('0x4'));router[_0x5958('0x5')](_0x5958('0x6'),auth['isAuthenticated'](),controller[_0x5958('0x7')]);router[_0x5958('0x8')](_0x5958('0x6'),auth['isAuthenticated'](),controller[_0x5958('0x9')]);router['delete']('/:id',auth[_0x5958('0xa')](),controller[_0x5958('0xb')]);module[_0x5958('0xc')]=router; \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.attributes.js b/server/api/chatGroup/chatGroup.attributes.js new file mode 100644 index 0000000..48fb9f9 --- /dev/null +++ b/server/api/chatGroup/chatGroup.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x605b=['STRING','sequelize','exports'];(function(_0x49392e,_0x441b28){var _0xe978bb=function(_0x4404d1){while(--_0x4404d1){_0x49392e['push'](_0x49392e['shift']());}};_0xe978bb(++_0x441b28);}(_0x605b,0xf4));var _0xb605=function(_0x38f3da,_0x43d895){_0x38f3da=_0x38f3da-0x0;var _0x18a10e=_0x605b[_0x38f3da];return _0x18a10e;};'use strict';var Sequelize=require(_0xb605('0x0'));module[_0xb605('0x1')]={'name':{'type':Sequelize[_0xb605('0x2')],'allowNull':![]},'description':{'type':Sequelize[_0xb605('0x2')]},'write':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]}}; \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.controller.js b/server/api/chatGroup/chatGroup.controller.js new file mode 100644 index 0000000..7690bd2 --- /dev/null +++ b/server/api/chatGroup/chatGroup.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xab0e=['rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','merge','VIRTUAL','filter','options','include','findAll','rows','catch','show','params','keys','includeAll','find','create','body','describe','ChatInternalMessage','count','user','addMembers','findOne','User','getMembers','hasOwnProperty','removeMembers','ids','addMessage','ChatGroupId','getMessages','pick','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','undefined','limit','offset','set','Content-Range','json','apply','save','update','then','destroy','stack','name','send','index','map','ChatGroup'];(function(_0x3d6785,_0x492ea3){var _0x39a624=function(_0x27d7db){while(--_0x27d7db){_0x3d6785['push'](_0x3d6785['shift']());}};_0x39a624(++_0x492ea3);}(_0xab0e,0x93));var _0xeab0=function(_0xa148b7,_0x2f3eb2){_0xa148b7=_0xa148b7-0x0;var _0x51efd3=_0xab0e[_0xa148b7];return _0x51efd3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xeab0('0x0'));var zipdir=require(_0xeab0('0x1'));var jsonpatch=require(_0xeab0('0x2'));var rp=require(_0xeab0('0x3'));var moment=require(_0xeab0('0x4'));var BPromise=require(_0xeab0('0x5'));var Mustache=require(_0xeab0('0x6'));var util=require(_0xeab0('0x7'));var path=require(_0xeab0('0x8'));var sox=require(_0xeab0('0x9'));var csv=require(_0xeab0('0xa'));var ejs=require(_0xeab0('0xb'));var fs=require('fs');var fs_extra=require(_0xeab0('0xc'));var _=require(_0xeab0('0xd'));var squel=require(_0xeab0('0xe'));var crypto=require(_0xeab0('0xf'));var jsforce=require(_0xeab0('0x10'));var deskjs=require(_0xeab0('0x11'));var toCsv=require('to-csv');var querystring=require(_0xeab0('0x12'));var Papa=require(_0xeab0('0x13'));var Redis=require('ioredis');var authService=require(_0xeab0('0x14'));var qs=require(_0xeab0('0x15'));var as=require(_0xeab0('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xeab0('0x17'))('api');var utils=require(_0xeab0('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xeab0('0x19'))['db'];config['redis']=_[_0xeab0('0x1a')](config[_0xeab0('0x1b')],{'host':_0xeab0('0x1c'),'port':0x18eb});var socket=require(_0xeab0('0x1d'))(new Redis(config['redis']));require('./chatGroup.socket')[_0xeab0('0x1e')](socket);function respondWithStatusCode(_0x4922a4,_0x22d16f){_0x22d16f=_0x22d16f||0xcc;return function(_0x174b00){if(_0x174b00){return _0x4922a4[_0xeab0('0x1f')](_0x22d16f);}return _0x4922a4[_0xeab0('0x20')](_0x22d16f)[_0xeab0('0x21')]();};}function respondWithResult(_0x2597b4,_0x4b94dd){_0x4b94dd=_0x4b94dd||0xc8;return function(_0x3f605e){if(_0x3f605e){return _0x2597b4[_0xeab0('0x20')](_0x4b94dd)['json'](_0x3f605e);}};}function respondWithFilteredResult(_0x617c3e,_0x5cbe81){return function(_0x593514){if(_0x593514){var _0x324fb3=typeof _0x5cbe81['offset']===_0xeab0('0x22')&&typeof _0x5cbe81[_0xeab0('0x23')]===_0xeab0('0x22');var _0x46f1fb=_0x593514['count'];var _0xcb19ea=_0x324fb3?0x0:_0x5cbe81[_0xeab0('0x24')];var _0xc79951=_0x324fb3?_0x593514['count']:_0x5cbe81['offset']+_0x5cbe81['limit'];var _0x33e17c;if(_0xc79951>=_0x46f1fb){_0xc79951=_0x46f1fb;_0x33e17c=0xc8;}else{_0x33e17c=0xce;}_0x617c3e['status'](_0x33e17c);return _0x617c3e[_0xeab0('0x25')](_0xeab0('0x26'),_0xcb19ea+'-'+_0xc79951+'/'+_0x46f1fb)[_0xeab0('0x27')](_0x593514);}return null;};}function patchUpdates(_0x80b8a0){return function(_0x324e29){try{jsonpatch[_0xeab0('0x28')](_0x324e29,_0x80b8a0,!![]);}catch(_0x393f3d){return BPromise['reject'](_0x393f3d);}return _0x324e29[_0xeab0('0x29')]();};}function saveUpdates(_0x5d6a7c,_0x32f385){return function(_0x3a198a){if(_0x3a198a){return _0x3a198a[_0xeab0('0x2a')](_0x5d6a7c)[_0xeab0('0x2b')](function(_0x311d4a){return _0x311d4a;});}return null;};}function removeEntity(_0x1d1f50,_0x4f173e){return function(_0x8ef84a){if(_0x8ef84a){return _0x8ef84a[_0xeab0('0x2c')]()[_0xeab0('0x2b')](function(){_0x1d1f50['status'](0xcc)[_0xeab0('0x21')]();});}};}function handleEntityNotFound(_0x1b5822,_0x355dfe){return function(_0xb7a7c4){if(!_0xb7a7c4){_0x1b5822[_0xeab0('0x1f')](0x194);}return _0xb7a7c4;};}function handleError(_0x4b3e82,_0x2627e7){_0x2627e7=_0x2627e7||0x1f4;return function(_0x276651){logger['error'](_0x276651[_0xeab0('0x2d')]);if(_0x276651[_0xeab0('0x2e')]){delete _0x276651[_0xeab0('0x2e')];}_0x4b3e82[_0xeab0('0x20')](_0x2627e7)[_0xeab0('0x2f')](_0x276651);};}exports[_0xeab0('0x30')]=function(_0x433932,_0x2f07ac){var _0x25b1ae={},_0x30e6b5={},_0x1295ae={'count':0x0,'rows':[]};var _0x284c1b=_[_0xeab0('0x31')](db[_0xeab0('0x32')][_0xeab0('0x33')],function(_0x1bedfa){return{'name':_0x1bedfa[_0xeab0('0x34')],'type':_0x1bedfa[_0xeab0('0x35')]['key']};});_0x30e6b5[_0xeab0('0x36')]=_[_0xeab0('0x31')](_0x284c1b,_0xeab0('0x2e'));_0x30e6b5['query']=_['keys'](_0x433932[_0xeab0('0x37')]);_0x30e6b5[_0xeab0('0x38')]=_[_0xeab0('0x39')](_0x30e6b5[_0xeab0('0x36')],_0x30e6b5[_0xeab0('0x37')]);_0x25b1ae[_0xeab0('0x3a')]=_['intersection'](_0x30e6b5[_0xeab0('0x36')],qs[_0xeab0('0x3b')](_0x433932[_0xeab0('0x37')][_0xeab0('0x3b')]));_0x25b1ae[_0xeab0('0x3a')]=_0x25b1ae[_0xeab0('0x3a')][_0xeab0('0x3c')]?_0x25b1ae['attributes']:_0x30e6b5[_0xeab0('0x36')];if(!_0x433932[_0xeab0('0x37')]['hasOwnProperty'](_0xeab0('0x3d'))){_0x25b1ae['limit']=qs[_0xeab0('0x23')](_0x433932[_0xeab0('0x37')][_0xeab0('0x23')]);_0x25b1ae[_0xeab0('0x24')]=qs[_0xeab0('0x24')](_0x433932[_0xeab0('0x37')]['offset']);}_0x25b1ae[_0xeab0('0x3e')]=qs[_0xeab0('0x3f')](_0x433932[_0xeab0('0x37')][_0xeab0('0x3f')]);_0x25b1ae['where']=qs[_0xeab0('0x38')](_['pick'](_0x433932[_0xeab0('0x37')],_0x30e6b5[_0xeab0('0x38')]),_0x284c1b);if(_0x433932[_0xeab0('0x37')]['filter']){_0x25b1ae[_0xeab0('0x40')]=_[_0xeab0('0x41')](_0x25b1ae[_0xeab0('0x40')],{'$or':_[_0xeab0('0x31')](_0x284c1b,function(_0x2c5f73){if(_0x2c5f73[_0xeab0('0x35')]!==_0xeab0('0x42')){var _0x58b4e2={};_0x58b4e2[_0x2c5f73[_0xeab0('0x2e')]]={'$like':'%'+_0x433932[_0xeab0('0x37')][_0xeab0('0x43')]+'%'};return _0x58b4e2;}})});}_0x25b1ae=_[_0xeab0('0x41')]({},_0x25b1ae,_0x433932[_0xeab0('0x44')]);var _0x13a7b7={'where':_0x25b1ae[_0xeab0('0x40')]};return db[_0xeab0('0x32')]['count'](_0x13a7b7)[_0xeab0('0x2b')](function(_0x416057){_0x1295ae['count']=_0x416057;if(_0x433932[_0xeab0('0x37')]['includeAll']){_0x25b1ae[_0xeab0('0x45')]=[{'all':!![]}];}return db[_0xeab0('0x32')][_0xeab0('0x46')](_0x25b1ae);})[_0xeab0('0x2b')](function(_0x4e162f){_0x1295ae[_0xeab0('0x47')]=_0x4e162f;return _0x1295ae;})[_0xeab0('0x2b')](respondWithFilteredResult(_0x2f07ac,_0x25b1ae))[_0xeab0('0x48')](handleError(_0x2f07ac,null));};exports[_0xeab0('0x49')]=function(_0x2d27ed,_0x3faa6f){var _0x57862e={'raw':!![],'where':{'id':_0x2d27ed[_0xeab0('0x4a')]['id']}},_0x211c0e={};_0x211c0e['model']=_[_0xeab0('0x4b')](db['ChatGroup'][_0xeab0('0x33')]);_0x211c0e[_0xeab0('0x37')]=_[_0xeab0('0x4b')](_0x2d27ed[_0xeab0('0x37')]);_0x211c0e['filters']=_[_0xeab0('0x39')](_0x211c0e[_0xeab0('0x36')],_0x211c0e['query']);_0x57862e[_0xeab0('0x3a')]=_[_0xeab0('0x39')](_0x211c0e[_0xeab0('0x36')],qs[_0xeab0('0x3b')](_0x2d27ed['query'][_0xeab0('0x3b')]));_0x57862e[_0xeab0('0x3a')]=_0x57862e[_0xeab0('0x3a')][_0xeab0('0x3c')]?_0x57862e[_0xeab0('0x3a')]:_0x211c0e[_0xeab0('0x36')];if(_0x2d27ed[_0xeab0('0x37')][_0xeab0('0x4c')]){_0x57862e[_0xeab0('0x45')]=[{'all':!![]}];}_0x57862e=_[_0xeab0('0x41')]({},_0x57862e,_0x2d27ed[_0xeab0('0x44')]);return db[_0xeab0('0x32')][_0xeab0('0x4d')](_0x57862e)['then'](handleEntityNotFound(_0x3faa6f,null))[_0xeab0('0x2b')](respondWithResult(_0x3faa6f,null))['catch'](handleError(_0x3faa6f,null));};exports[_0xeab0('0x4e')]=function(_0x199e3e,_0x1d57d7){return db[_0xeab0('0x32')][_0xeab0('0x4e')](_0x199e3e[_0xeab0('0x4f')],{})[_0xeab0('0x2b')](respondWithResult(_0x1d57d7,0xc9))[_0xeab0('0x48')](handleError(_0x1d57d7,null));};exports['update']=function(_0x4a6998,_0x585ab7){if(_0x4a6998['body']['id']){delete _0x4a6998[_0xeab0('0x4f')]['id'];}return db[_0xeab0('0x32')][_0xeab0('0x4d')]({'where':{'id':_0x4a6998[_0xeab0('0x4a')]['id']}})['then'](handleEntityNotFound(_0x585ab7,null))[_0xeab0('0x2b')](saveUpdates(_0x4a6998[_0xeab0('0x4f')],null))['then'](respondWithResult(_0x585ab7,null))[_0xeab0('0x48')](handleError(_0x585ab7,null));};exports[_0xeab0('0x2c')]=function(_0x4e5402,_0x5675c8){return db[_0xeab0('0x32')][_0xeab0('0x4d')]({'where':{'id':_0x4e5402['params']['id']}})[_0xeab0('0x2b')](handleEntityNotFound(_0x5675c8,null))[_0xeab0('0x2b')](removeEntity(_0x5675c8,null))['catch'](handleError(_0x5675c8,null));};exports[_0xeab0('0x50')]=function(_0x1f4fc7,_0x51958a){return db[_0xeab0('0x32')][_0xeab0('0x50')]()[_0xeab0('0x2b')](respondWithResult(_0x51958a,null))[_0xeab0('0x48')](handleError(_0x51958a,null));};exports['getUnread']=function(_0x2cb0a9,_0x54b4ab,_0x3b0b77){return db[_0xeab0('0x51')][_0xeab0('0x52')]({'where':{'ChatGroupId':_0x2cb0a9[_0xeab0('0x4a')]['id'],'ToId':_0x2cb0a9[_0xeab0('0x53')]['id'],'read':![]}})[_0xeab0('0x2b')](function(_0x24c910){return{'id':_['toInteger'](_0x2cb0a9['params']['id']),'count':_0x24c910};})[_0xeab0('0x2b')](respondWithResult(_0x54b4ab,null))['catch'](handleError(_0x54b4ab,null));};exports['addMembers']=function(_0x1b8b81,_0xe5a684,_0x5c95dc){return db['ChatGroup']['find']({'where':{'id':_0x1b8b81[_0xeab0('0x4a')]['id']}})['then'](handleEntityNotFound(_0xe5a684,null))[_0xeab0('0x2b')](function(_0x305220){if(_0x305220){return _0x305220[_0xeab0('0x54')](_0x1b8b81[_0xeab0('0x4f')]['ids'],_['omit'](_0x1b8b81[_0xeab0('0x4f')],['ids','id'])||{});}})[_0xeab0('0x2b')](respondWithResult(_0xe5a684,null))['catch'](handleError(_0xe5a684,null));};exports['getMembers']=function(_0x27a0b4,_0x46ddf0,_0x51c4fa){var _0x2e030e={};var _0x482704={};var _0x3ff6b8;var _0xccfadd;return db[_0xeab0('0x32')][_0xeab0('0x55')]({'where':{'id':_0x27a0b4['params']['id']}})[_0xeab0('0x2b')](handleEntityNotFound(_0x46ddf0,null))[_0xeab0('0x2b')](function(_0x2b3698){if(_0x2b3698){_0x3ff6b8=_0x2b3698;_0x482704[_0xeab0('0x36')]=_[_0xeab0('0x4b')](db[_0xeab0('0x56')][_0xeab0('0x33')]);_0x482704[_0xeab0('0x37')]=_[_0xeab0('0x4b')](_0x27a0b4[_0xeab0('0x37')]);_0x482704[_0xeab0('0x38')]=_[_0xeab0('0x39')](_0x482704[_0xeab0('0x36')],_0x482704['query']);_0x2e030e['attributes']=_[_0xeab0('0x39')](_0x482704['model'],qs[_0xeab0('0x3b')](_0x27a0b4[_0xeab0('0x37')]['fields']));_0x2e030e[_0xeab0('0x3a')]=_0x2e030e[_0xeab0('0x3a')][_0xeab0('0x3c')]?_0x2e030e[_0xeab0('0x3a')]:_0x482704[_0xeab0('0x36')];_0x2e030e[_0xeab0('0x3e')]=qs[_0xeab0('0x3f')](_0x27a0b4[_0xeab0('0x37')][_0xeab0('0x3f')]);_0x2e030e[_0xeab0('0x40')]=qs[_0xeab0('0x38')](_['pick'](_0x27a0b4[_0xeab0('0x37')],_0x482704[_0xeab0('0x38')]));if(_0x27a0b4['query'][_0xeab0('0x43')]){_0x2e030e[_0xeab0('0x40')]=_[_0xeab0('0x41')](_0x2e030e['where'],{'$or':_[_0xeab0('0x31')](_0x2e030e[_0xeab0('0x3a')],function(_0x2d23a8){var _0x25d9b5={};_0x25d9b5[_0x2d23a8]={'$like':'%'+_0x27a0b4[_0xeab0('0x37')]['filter']+'%'};return _0x25d9b5;})});}_0x2e030e=_[_0xeab0('0x41')]({},_0x2e030e,_0x27a0b4['options']);return _0x3ff6b8[_0xeab0('0x57')](_0x2e030e);}})[_0xeab0('0x2b')](function(_0x2e244b){if(_0x2e244b){_0xccfadd=_0x2e244b['length'];if(!_0x27a0b4[_0xeab0('0x37')][_0xeab0('0x58')](_0xeab0('0x3d'))){_0x2e030e[_0xeab0('0x23')]=qs[_0xeab0('0x23')](_0x27a0b4[_0xeab0('0x37')][_0xeab0('0x23')]);_0x2e030e[_0xeab0('0x24')]=qs[_0xeab0('0x24')](_0x27a0b4['query'][_0xeab0('0x24')]);}return _0x3ff6b8[_0xeab0('0x57')](_0x2e030e);}})[_0xeab0('0x2b')](function(_0x40de8f){if(_0x40de8f){return _0x40de8f?{'count':_0xccfadd,'rows':_0x40de8f}:null;}})['then'](respondWithResult(_0x46ddf0,null))[_0xeab0('0x48')](handleError(_0x46ddf0,null));};exports[_0xeab0('0x59')]=function(_0x3f14ca,_0x401be,_0x24c176){return db[_0xeab0('0x32')][_0xeab0('0x4d')]({'where':{'id':_0x3f14ca[_0xeab0('0x4a')]['id']}})[_0xeab0('0x2b')](handleEntityNotFound(_0x401be,null))[_0xeab0('0x2b')](function(_0x445cff){if(_0x445cff){return _0x445cff[_0xeab0('0x59')](_0x3f14ca[_0xeab0('0x37')][_0xeab0('0x5a')]);}})[_0xeab0('0x2b')](respondWithStatusCode(_0x401be,null))[_0xeab0('0x48')](handleError(_0x401be,null));};exports[_0xeab0('0x5b')]=function(_0x4d3ebb,_0x5eda8b,_0x4d2afb){if(_0x4d3ebb[_0xeab0('0x4f')]['id']){delete _0x4d3ebb[_0xeab0('0x4f')]['id'];}return db[_0xeab0('0x32')][_0xeab0('0x4d')]({'where':{'id':_0x4d3ebb[_0xeab0('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5eda8b,null))[_0xeab0('0x2b')](function(_0xd11aec){if(_0xd11aec){_0x4d3ebb[_0xeab0('0x4f')][_0xeab0('0x5c')]=_0xd11aec['id'];return db[_0xeab0('0x51')][_0xeab0('0x4e')](_0x4d3ebb[_0xeab0('0x4f')]);}})[_0xeab0('0x2b')](respondWithResult(_0x5eda8b,null))[_0xeab0('0x48')](handleError(_0x5eda8b,null));};exports[_0xeab0('0x5d')]=function(_0x337495,_0x6fad92,_0x70cb85){var _0x3c5852={};var _0x343902={};var _0xf9e855;var _0x3a652a;return db[_0xeab0('0x32')][_0xeab0('0x55')]({'where':{'id':_0x337495[_0xeab0('0x4a')]['id']}})['then'](handleEntityNotFound(_0x6fad92,null))['then'](function(_0x3e73fc){if(_0x3e73fc){_0xf9e855=_0x3e73fc;_0x343902[_0xeab0('0x36')]=_[_0xeab0('0x4b')](db[_0xeab0('0x51')]['rawAttributes']);_0x343902['query']=_[_0xeab0('0x4b')](_0x337495['query']);_0x343902[_0xeab0('0x38')]=_[_0xeab0('0x39')](_0x343902[_0xeab0('0x36')],_0x343902['query']);_0x3c5852['attributes']=_[_0xeab0('0x39')](_0x343902[_0xeab0('0x36')],qs['fields'](_0x337495['query'][_0xeab0('0x3b')]));_0x3c5852[_0xeab0('0x3a')]=_0x3c5852[_0xeab0('0x3a')][_0xeab0('0x3c')]?_0x3c5852[_0xeab0('0x3a')]:_0x343902[_0xeab0('0x36')];_0x3c5852[_0xeab0('0x3e')]=qs['sort'](_0x337495[_0xeab0('0x37')][_0xeab0('0x3f')]);_0x3c5852[_0xeab0('0x40')]=qs[_0xeab0('0x38')](_[_0xeab0('0x5e')](_0x337495[_0xeab0('0x37')],_0x343902[_0xeab0('0x38')]));if(_0x337495[_0xeab0('0x37')][_0xeab0('0x43')]){_0x3c5852[_0xeab0('0x40')]=_[_0xeab0('0x41')](_0x3c5852[_0xeab0('0x40')],{'$or':_[_0xeab0('0x31')](_0x3c5852['attributes'],function(_0x495cc9){var _0x2609a1={};_0x2609a1[_0x495cc9]={'$like':'%'+_0x337495[_0xeab0('0x37')][_0xeab0('0x43')]+'%'};return _0x2609a1;})});}if(_0x337495[_0xeab0('0x37')][_0xeab0('0x5f')]){var _0x124506=_0x337495['query'][_0xeab0('0x5f')][_0xeab0('0x60')](',');var _0x17d3b2={};_0x17d3b2[_0x124506[0x0]]={'$gte':moment(_0x124506[0x1])[_0xeab0('0x61')](_0xeab0('0x62'))};_0x3c5852[_0xeab0('0x40')]=_[_0xeab0('0x41')](_0x3c5852[_0xeab0('0x40')],_0x17d3b2);}_0x3c5852=_[_0xeab0('0x41')]({},_0x3c5852,_0x337495[_0xeab0('0x44')]);return _0xf9e855[_0xeab0('0x5d')](_0x3c5852);}})[_0xeab0('0x2b')](function(_0x448a66){if(_0x448a66){_0x3a652a=_0x448a66[_0xeab0('0x3c')];if(!_0x337495[_0xeab0('0x37')][_0xeab0('0x58')](_0xeab0('0x3d'))){_0x3c5852[_0xeab0('0x23')]=qs[_0xeab0('0x23')](_0x337495[_0xeab0('0x37')][_0xeab0('0x23')]);_0x3c5852[_0xeab0('0x24')]=qs['offset'](_0x337495[_0xeab0('0x37')][_0xeab0('0x24')]);}return _0xf9e855[_0xeab0('0x5d')](_0x3c5852);}})['then'](function(_0x3ae9b6){if(_0x3ae9b6){return _0x3ae9b6?{'count':_0x3a652a,'rows':_0x3ae9b6}:null;}})[_0xeab0('0x2b')](respondWithResult(_0x6fad92,null))[_0xeab0('0x48')](handleError(_0x6fad92,null));}; \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.events.js b/server/api/chatGroup/chatGroup.events.js new file mode 100644 index 0000000..a5581c0 --- /dev/null +++ b/server/api/chatGroup/chatGroup.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4689=['update','emit','hasOwnProperty','exports','../../mysqldb','ChatGroup','setMaxListeners'];(function(_0x1e1b18,_0x5d471b){var _0x3da8f2=function(_0x51fe71){while(--_0x51fe71){_0x1e1b18['push'](_0x1e1b18['shift']());}};_0x3da8f2(++_0x5d471b);}(_0x4689,0xf2));var _0x9468=function(_0x48e33b,_0x136b29){_0x48e33b=_0x48e33b-0x0;var _0x3a83aa=_0x4689[_0x48e33b];return _0x3a83aa;};'use strict';var EventEmitter=require('events');var ChatGroup=require(_0x9468('0x0'))['db'][_0x9468('0x1')];var ChatGroupEvents=new EventEmitter();ChatGroupEvents[_0x9468('0x2')](0x0);var events={'afterCreate':'save','afterUpdate':_0x9468('0x3'),'afterDestroy':'remove'};function emitEvent(_0x5ec58d){return function(_0xae5f0b,_0x5dea11,_0x54de70){ChatGroupEvents[_0x9468('0x4')](_0x5ec58d+':'+_0xae5f0b['id'],_0xae5f0b);ChatGroupEvents[_0x9468('0x4')](_0x5ec58d,_0xae5f0b);_0x54de70(null);};}for(var e in events){if(events[_0x9468('0x5')](e)){var event=events[e];ChatGroup['hook'](e,emitEvent(event));}}module[_0x9468('0x6')]=ChatGroupEvents; \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.model.js b/server/api/chatGroup/chatGroup.model.js new file mode 100644 index 0000000..bd5160a --- /dev/null +++ b/server/api/chatGroup/chatGroup.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x19e5=['./chatGroup.attributes','define','ChatGroup','chat_groups','lodash','util','moment','bluebird','path','../../config/environment'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0x19e5,0xae));var _0x519e=function(_0x1f544e,_0x1edbbd){_0x1f544e=_0x1f544e-0x0;var _0x394caa=_0x19e5[_0x1f544e];return _0x394caa;};'use strict';var _=require(_0x519e('0x0'));var util=require(_0x519e('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0x519e('0x2'));var BPromise=require(_0x519e('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x519e('0x4'));var rimraf=require('rimraf');var config=require(_0x519e('0x5'));var attributes=require(_0x519e('0x6'));module['exports']=function(_0x1f6949,_0x21c74d){return _0x1f6949[_0x519e('0x7')](_0x519e('0x8'),attributes,{'tableName':_0x519e('0x9'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.rpc.js b/server/api/chatGroup/chatGroup.rpc.js new file mode 100644 index 0000000..6f064e5 --- /dev/null +++ b/server/api/chatGroup/chatGroup.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3a32=['error','code','message','info','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','register','request','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','stringify'];(function(_0xe13780,_0x5526f8){var _0x33b690=function(_0x25fb63){while(--_0x25fb63){_0xe13780['push'](_0xe13780['shift']());}};_0x33b690(++_0x5526f8);}(_0x3a32,0x9b));var _0x23a3=function(_0xd09668,_0x1435b2){_0xd09668=_0xd09668-0x0;var _0x68726=_0x3a32[_0xd09668];return _0x68726;};'use strict';var _=require(_0x23a3('0x0'));var util=require(_0x23a3('0x1'));var moment=require(_0x23a3('0x2'));var BPromise=require(_0x23a3('0x3'));var rs=require(_0x23a3('0x4'));var fs=require('fs');var Redis=require(_0x23a3('0x5'));var db=require(_0x23a3('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x23a3('0x7'));var config=require(_0x23a3('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x23a3('0x9')]['http']({'port':0x232a});config[_0x23a3('0xa')]=_[_0x23a3('0xb')](config[_0x23a3('0xa')],{'host':_0x23a3('0xc'),'port':0x18eb});var socket=require(_0x23a3('0xd'))(new Redis(config[_0x23a3('0xa')]));require('./chatGroup.socket')[_0x23a3('0xe')](socket);function respondWithRpcPromise(_0x238fbe,_0x5bdf73,_0x5f4b21){return new BPromise(function(_0x93e9d,_0xf9b603){return client[_0x23a3('0xf')](_0x238fbe,_0x5f4b21)['then'](function(_0x2137e4){logger['info'](_0x23a3('0x10'),_0x5bdf73,_0x23a3('0x11'));logger[_0x23a3('0x12')]('ChatGroup,\x20%s,\x20%s,\x20%s',_0x5bdf73,_0x23a3('0x11'),JSON[_0x23a3('0x13')](_0x2137e4));if(_0x2137e4[_0x23a3('0x14')]){if(_0x2137e4[_0x23a3('0x14')][_0x23a3('0x15')]===0x1f4){logger['error'](_0x23a3('0x10'),_0x5bdf73,_0x2137e4[_0x23a3('0x14')]['message']);return _0xf9b603(_0x2137e4[_0x23a3('0x14')][_0x23a3('0x16')]);}logger['error'](_0x23a3('0x10'),_0x5bdf73,_0x2137e4[_0x23a3('0x14')][_0x23a3('0x16')]);return _0x93e9d(_0x2137e4[_0x23a3('0x14')][_0x23a3('0x16')]);}else{logger[_0x23a3('0x17')](_0x23a3('0x10'),_0x5bdf73,_0x23a3('0x11'));_0x93e9d(_0x2137e4['result'][_0x23a3('0x16')]);}})[_0x23a3('0x18')](function(_0x5ed775){logger['error'](_0x23a3('0x10'),_0x5bdf73,_0x5ed775);_0xf9b603(_0x5ed775);});});} \ No newline at end of file diff --git a/server/api/chatGroup/chatGroup.socket.js b/server/api/chatGroup/chatGroup.socket.js new file mode 100644 index 0000000..ff71da0 --- /dev/null +++ b/server/api/chatGroup/chatGroup.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7cba=['emit','length','./chatGroup.events','save'];(function(_0xfdb2df,_0x5517ff){var _0x42dc28=function(_0x3b547e){while(--_0x3b547e){_0xfdb2df['push'](_0xfdb2df['shift']());}};_0x42dc28(++_0x5517ff);}(_0x7cba,0x1ca));var _0xa7cb=function(_0x3c5832,_0x1d3f0e){_0x3c5832=_0x3c5832-0x0;var _0xfae7fc=_0x7cba[_0x3c5832];return _0xfae7fc;};'use strict';var ChatGroupEvents=require(_0xa7cb('0x0'));var events=[_0xa7cb('0x1'),'remove','update'];function createListener(_0x5a441d,_0x125ad8){return function(_0x5d239f){_0x125ad8[_0xa7cb('0x2')](_0x5a441d,_0x5d239f);};}function removeListener(_0x4bd8fd,_0x4d7313){return function(){ChatGroupEvents['removeListener'](_0x4bd8fd,_0x4d7313);};}exports['register']=function(_0x30437c){for(var _0x36ce42=0x0,_0x5cad2=events[_0xa7cb('0x3')];_0x36ce42<_0x5cad2;_0x36ce42++){var _0x563ff3=events[_0x36ce42];var _0x43870e=createListener('chatGroup:'+_0x563ff3,_0x30437c);ChatGroupEvents['on'](_0x563ff3,_0x43870e);}}; \ No newline at end of file diff --git a/server/api/chatGroup/index.js b/server/api/chatGroup/index.js new file mode 100644 index 0000000..31fbc56 --- /dev/null +++ b/server/api/chatGroup/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3374=['get','isAuthenticated','index','/describe','describe','/:id','show','/:id/unread','getUnread','/:id/messages','getMessages','post','create','addMembers','addMessage','update','destroy','delete','removeMembers','exports','util','connect-timeout','express','Router','fs-extra','./chatGroup.controller'];(function(_0x20ef64,_0x4a8fe9){var _0x3707d8=function(_0x5b9a88){while(--_0x5b9a88){_0x20ef64['push'](_0x20ef64['shift']());}};_0x3707d8(++_0x4a8fe9);}(_0x3374,0x166));var _0x4337=function(_0x47d364,_0x506c2f){_0x47d364=_0x47d364-0x0;var _0x4b8e5b=_0x3374[_0x47d364];return _0x4b8e5b;};'use strict';var multer=require('multer');var util=require(_0x4337('0x0'));var path=require('path');var timeout=require(_0x4337('0x1'));var express=require(_0x4337('0x2'));var router=express[_0x4337('0x3')]();var fs_extra=require(_0x4337('0x4'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x4337('0x5'));router[_0x4337('0x6')]('/',auth[_0x4337('0x7')](),controller[_0x4337('0x8')]);router[_0x4337('0x6')](_0x4337('0x9'),auth['isAuthenticated'](),controller[_0x4337('0xa')]);router['get'](_0x4337('0xb'),auth[_0x4337('0x7')](),controller[_0x4337('0xc')]);router[_0x4337('0x6')](_0x4337('0xd'),auth[_0x4337('0x7')](),controller[_0x4337('0xe')]);router[_0x4337('0x6')]('/:id/members',auth[_0x4337('0x7')](),controller['getMembers']);router[_0x4337('0x6')](_0x4337('0xf'),auth[_0x4337('0x7')](),controller[_0x4337('0x10')]);router[_0x4337('0x11')]('/',auth[_0x4337('0x7')](),controller[_0x4337('0x12')]);router[_0x4337('0x11')]('/:id/members',auth[_0x4337('0x7')](),controller[_0x4337('0x13')]);router[_0x4337('0x11')](_0x4337('0xf'),auth[_0x4337('0x7')](),controller[_0x4337('0x14')]);router['put'](_0x4337('0xb'),auth['isAuthenticated'](),controller[_0x4337('0x15')]);router['delete'](_0x4337('0xb'),auth[_0x4337('0x7')](),controller[_0x4337('0x16')]);router[_0x4337('0x17')]('/:id/members',auth['isAuthenticated'](),controller[_0x4337('0x18')]);module[_0x4337('0x19')]=router; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.attributes.js b/server/api/chatInteraction/chatInteraction.attributes.js new file mode 100644 index 0000000..3f6518f --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3266=['BOOLEAN','INTEGER','ENUM','star','thumb','TEXT','STRING','long','DATE','out','sequelize','exports'];(function(_0x4b6f5c,_0x56f7ce){var _0x55548b=function(_0x125619){while(--_0x125619){_0x4b6f5c['push'](_0x4b6f5c['shift']());}};_0x55548b(++_0x56f7ce);}(_0x3266,0x6a));var _0x6326=function(_0x9c2427,_0x17c865){_0x9c2427=_0x9c2427-0x0;var _0x51984f=_0x3266[_0x9c2427];return _0x51984f;};'use strict';var Sequelize=require(_0x6326('0x0'));module[_0x6326('0x1')]={'closed':{'type':Sequelize[_0x6326('0x2')],'defaultValue':![]},'ratingValue':{'type':Sequelize[_0x6326('0x3')]},'ratingType':{'type':Sequelize[_0x6326('0x4')](_0x6326('0x5'),_0x6326('0x6')),'defaultValue':_0x6326('0x5')},'ratingMessage':{'type':Sequelize[_0x6326('0x7')]},'pathTranscript':{'type':Sequelize['TEXT']},'mailTranscript':{'type':Sequelize[_0x6326('0x8')],'validate':{'isEmail':!![]}},'closedAt':{'type':Sequelize['DATE']},'disposition':{'type':Sequelize[_0x6326('0x8')]},'secondDisposition':{'type':Sequelize[_0x6326('0x8')]},'thirdDisposition':{'type':Sequelize[_0x6326('0x8')]},'note':{'type':Sequelize['STRING']},'browserName':{'type':Sequelize[_0x6326('0x8')]},'browserVersion':{'type':Sequelize['STRING']},'osName':{'type':Sequelize[_0x6326('0x8')]},'osVersion':{'type':Sequelize[_0x6326('0x8')]},'deviceModel':{'type':Sequelize[_0x6326('0x8')]},'deviceVendor':{'type':Sequelize[_0x6326('0x8')]},'deviceType':{'type':Sequelize[_0x6326('0x8')]},'referer':{'type':Sequelize['TEXT']},'customerIp':{'type':Sequelize[_0x6326('0x8')]},'formData':{'type':Sequelize[_0x6326('0x7')](_0x6326('0x9'))},'read1stAt':{'type':Sequelize[_0x6326('0xa')]},'lastMsgAt':{'type':Sequelize[_0x6326('0xa')]},'lastMsgDirection':{'type':Sequelize[_0x6326('0x4')]('in',_0x6326('0xb')),'defaultValue':'in','allowNull':![]},'closeReason':{'type':Sequelize[_0x6326('0x8')]},'customerPort':{'type':Sequelize[_0x6326('0x8')]},'vidaooSessionId':{'type':Sequelize[_0x6326('0x7')]},'autoreplyExecuted':{'type':Sequelize['BOOLEAN'],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.controller.js b/server/api/chatInteraction/chatInteraction.controller.js new file mode 100644 index 0000000..703bde6 --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1867=['jayson/promise','client','http','request','info','ChatInteraction,\x20%s,\x20%s','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','sendStatus','offset','undefined','limit','status','set','Content-Range','json','update','then','destroy','end','stack','name','send','render','merge','body','contact','agent','account','index','map','ChatInteraction','fieldName','getOptions','chat','query','user','catch','show','params','model','keys','rawAttributes','filters','intersection','fields','attributes','length','includeAll','include','options','create','find','describe','createVidaooSession','findOne','ChatWebsite','ChatWebsiteId','vidaooApiKey','vidaooEscalation','vidaooTopic','vidaooNote','vidaooMetadata','fullname','email','POST','https://api-vidaoo.xcally.com/api/v1/meetings','isNull','parse','ValidationError','Error\x20in\x20conversion\x20vidaooMetadata','Error\x20in\x20Vidaoo\x20configuration','ChatMessage','Unable\x20to\x20create\x20Vidaoo\x20session','updateAttributes','customUpdate','CmContact','Contact','abandon','abandonInteraction,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','UserId','Sequelize','Interaction\x20already\x20assigned','closed','disposition','AbandonInteraction','attachmentUpload','file','originalname','basename','filename','mimetype','Attachment','attachId','root','server/files/attachments/','offline-chat/','join','mailTranscript','format','transcript-%s.txt','now','pathTranscript','User','ContactId','Messages','%s%d','agentAlias','customer','Visitor','website_alias','System','agent_alias','alias','agent_fullname','createdAt','MM/DD/YYYY\x20HH:mm:ss','secret','appendFileSync','MailAccount','MailServerOut','Smtp','CloudProvider','getSmtpOptions','SendMail','sendMail','Mail\x20Transcript','Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a','addMessage','ids','omit','getMessages','hasOwnProperty','nolimit','order','sort','where','pick','ChatInteractionId','filter','$gte','split','YYYY-MM-DD\x20HH:mm:ss','count','findAll','rows','includeAgent','push','setTags','Tag','color','chatInteractionTags:save','removeTags','download','unix','toString','server','files','attachments','firstName','lastName','direction','Account','get','mkdirSync','Chat','Owner','N.A.','closedAt','browserName','referer','customerIp','customerPort','existsSync','createReadStream','pipe','createWriteStream','out','value','views','downloadInteraction.ejs','.pdf','err','unlinkSync','rimraf','zip-dir','request-promise','moment','bluebird','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','../../config/environment','redis','localhost','socket.io-emitter','./chatInteraction.socket','register'];(function(_0x1e936d,_0x47c8c3){var _0x1992f6=function(_0x1fdab2){while(--_0x1fdab2){_0x1e936d['push'](_0x1e936d['shift']());}};_0x1992f6(++_0x47c8c3);}(_0x1867,0xbf));var _0x7186=function(_0x59a3fb,_0x8e90f5){_0x59a3fb=_0x59a3fb-0x0;var _0x1ab2e7=_0x1867[_0x59a3fb];return _0x1ab2e7;};'use strict';var rimraf=require(_0x7186('0x0'));var zipdir=require(_0x7186('0x1'));var rp=require(_0x7186('0x2'));var moment=require(_0x7186('0x3'));var BPromise=require(_0x7186('0x4'));var Mustache=require('mustache');var util=require('util');var path=require('path');var ejs=require('ejs');var fs=require('fs');var _=require(_0x7186('0x5'));var Redis=require(_0x7186('0x6'));var interaction=require(_0x7186('0x7'));var qs=require(_0x7186('0x8'));var pdf=require('../../components/export/pdf');var logger=require(_0x7186('0x9'))('api');var config=require(_0x7186('0xa'));var db=require('../../mysqldb')['db'];config[_0x7186('0xb')]=_['defaults'](config[_0x7186('0xb')],{'host':_0x7186('0xc'),'port':0x18eb});var socket=require(_0x7186('0xd'))(new Redis(config[_0x7186('0xb')]));require(_0x7186('0xe'))[_0x7186('0xf')](socket);var jayson=require(_0x7186('0x10'));var client=jayson[_0x7186('0x11')][_0x7186('0x12')]({'port':0x232b});var client9004=jayson[_0x7186('0x11')]['http']({'port':0x232c});function respondWithRpcPromise(_0x1d679d,_0x5efbed,_0x1a0804,_0x33320c){return new BPromise(function(_0x15e7b0,_0x586ca3){var _0x1d6407=_0x33320c||client;return _0x1d6407[_0x7186('0x13')](_0x1d679d,_0x1a0804)['then'](function(_0x7beaf3){logger[_0x7186('0x14')](_0x7186('0x15'),_0x5efbed,'request\x20sent');logger[_0x7186('0x16')](_0x7186('0x17'),_0x5efbed,_0x7186('0x18'),JSON[_0x7186('0x19')](_0x7beaf3));if(_0x7beaf3['error']){if(_0x7beaf3[_0x7186('0x1a')][_0x7186('0x1b')]===0x1f4){logger['error']('ChatInteraction,\x20%s,\x20%s',_0x5efbed,_0x7beaf3[_0x7186('0x1a')][_0x7186('0x1c')]);return _0x586ca3(_0x7beaf3[_0x7186('0x1a')][_0x7186('0x1c')]);}logger[_0x7186('0x1a')](_0x7186('0x15'),_0x5efbed,_0x7beaf3[_0x7186('0x1a')][_0x7186('0x1c')]);return _0x15e7b0(_0x7beaf3[_0x7186('0x1a')]['message']);}else{logger[_0x7186('0x14')](_0x7186('0x15'),_0x5efbed,'request\x20sent');_0x15e7b0(_0x7beaf3[_0x7186('0x1d')][_0x7186('0x1c')]);}})['catch'](function(_0x4b347d){logger['error'](_0x7186('0x15'),_0x5efbed,_0x4b347d);_0x586ca3(_0x4b347d);});});}function respondWithStatusCode(_0x2eec8b,_0x5cf4ef){_0x5cf4ef=_0x5cf4ef||0xcc;return function(_0x300f09){if(_0x300f09){return _0x2eec8b[_0x7186('0x1e')](_0x5cf4ef);}return _0x2eec8b['status'](_0x5cf4ef)['end']();};}function respondWithResult(_0x2781c1,_0x54da0b){_0x54da0b=_0x54da0b||0xc8;return function(_0x455226){if(_0x455226){return _0x2781c1['status'](_0x54da0b)['json'](_0x455226);}};}function respondWithFilteredResult(_0x260617,_0x5044ef){return function(_0x4b1ade){if(_0x4b1ade){var _0x546af9=typeof _0x5044ef[_0x7186('0x1f')]===_0x7186('0x20')&&typeof _0x5044ef[_0x7186('0x21')]==='undefined';var _0x4d709e=_0x4b1ade['count'];var _0x49379b=_0x546af9?0x0:_0x5044ef[_0x7186('0x1f')];var _0x28f219=_0x546af9?_0x4b1ade['count']:_0x5044ef[_0x7186('0x1f')]+_0x5044ef[_0x7186('0x21')];var _0x3990e2;if(_0x28f219>=_0x4d709e){_0x28f219=_0x4d709e;_0x3990e2=0xc8;}else{_0x3990e2=0xce;}_0x260617[_0x7186('0x22')](_0x3990e2);return _0x260617[_0x7186('0x23')](_0x7186('0x24'),_0x49379b+'-'+_0x28f219+'/'+_0x4d709e)[_0x7186('0x25')](_0x4b1ade);}return null;};}function saveUpdates(_0x168277){return function(_0x532754){if(_0x532754){return _0x532754[_0x7186('0x26')](_0x168277)[_0x7186('0x27')](function(_0x14b4fe){return _0x14b4fe;});}return null;};}function removeEntity(_0x439b38){return function(_0x1bcca2){if(_0x1bcca2){return _0x1bcca2[_0x7186('0x28')]()['then'](function(){_0x439b38[_0x7186('0x22')](0xcc)[_0x7186('0x29')]();});}};}function handleEntityNotFound(_0x12c082){return function(_0x2617a5){if(!_0x2617a5){_0x12c082[_0x7186('0x1e')](0x194);}return _0x2617a5;};}function handleError(_0x4f5163,_0x1f6570){_0x1f6570=_0x1f6570||0x1f4;return function(_0x1d9369){logger[_0x7186('0x1a')](_0x1d9369[_0x7186('0x2a')]);if(_0x1d9369[_0x7186('0x2b')]){delete _0x1d9369[_0x7186('0x2b')];}_0x4f5163[_0x7186('0x22')](_0x1f6570)[_0x7186('0x2c')](_0x1d9369);};}function getMustacheRender(_0x1e6b1c,_0x791667){return Mustache[_0x7186('0x2d')](_0x1e6b1c,_[_0x7186('0x2e')](_0x791667[_0x7186('0x2f')],{'contact':_0x791667[_0x7186('0x30')],'message':_0x791667['message'],'agent':_0x791667[_0x7186('0x31')],'interaction':_0x791667['interaction'],'account':_0x791667[_0x7186('0x32')]}))||'';}exports[_0x7186('0x33')]=function(_0x43eea3,_0x5db5bd){var _0x3a6a38={};var _0x5f0ee1=_[_0x7186('0x34')](db[_0x7186('0x35')]['rawAttributes'],function(_0x3f1f29){return{'name':_0x3f1f29[_0x7186('0x36')],'type':_0x3f1f29['type']['key']};});_0x3a6a38=qs[_0x7186('0x37')](_0x5f0ee1,_0x43eea3);return interaction['findAll'](_0x7186('0x38'),_0x43eea3[_0x7186('0x39')],_0x43eea3[_0x7186('0x3a')],_0x3a6a38,_0x5f0ee1)[_0x7186('0x27')](respondWithFilteredResult(_0x5db5bd,_0x3a6a38))[_0x7186('0x3b')](handleError(_0x5db5bd,null));};exports[_0x7186('0x3c')]=function(_0x3f51cd,_0xa38d6c){var _0x3ddb2c={'raw':![],'where':{'id':_0x3f51cd[_0x7186('0x3d')]['id']}},_0x532a8b={};_0x532a8b[_0x7186('0x3e')]=_[_0x7186('0x3f')](db[_0x7186('0x35')][_0x7186('0x40')]);_0x532a8b[_0x7186('0x39')]=_['keys'](_0x3f51cd[_0x7186('0x39')]);_0x532a8b[_0x7186('0x41')]=_[_0x7186('0x42')](_0x532a8b[_0x7186('0x3e')],_0x532a8b[_0x7186('0x39')]);_0x3ddb2c['attributes']=_['intersection'](_0x532a8b[_0x7186('0x3e')],qs[_0x7186('0x43')](_0x3f51cd['query'][_0x7186('0x43')]));_0x3ddb2c['attributes']=_0x3ddb2c[_0x7186('0x44')][_0x7186('0x45')]?_0x3ddb2c['attributes']:_0x532a8b[_0x7186('0x3e')];if(_0x3f51cd[_0x7186('0x39')][_0x7186('0x46')]){_0x3ddb2c[_0x7186('0x47')]=[{'all':!![]}];}_0x3ddb2c=_['merge']({},_0x3ddb2c,_0x3f51cd[_0x7186('0x48')]);return db['ChatInteraction']['find'](_0x3ddb2c)[_0x7186('0x27')](handleEntityNotFound(_0xa38d6c,null))['then'](respondWithResult(_0xa38d6c,null))[_0x7186('0x3b')](handleError(_0xa38d6c,null));};exports[_0x7186('0x49')]=function(_0x2d8e73,_0x22275e){return db['ChatInteraction'][_0x7186('0x49')](_0x2d8e73[_0x7186('0x2f')],{})['then'](respondWithResult(_0x22275e,0xc9))[_0x7186('0x3b')](handleError(_0x22275e,null));};exports[_0x7186('0x26')]=function(_0x2554b8,_0xb6bad4){if(_0x2554b8['body']['id']){delete _0x2554b8[_0x7186('0x2f')]['id'];}return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x2554b8[_0x7186('0x3d')]['id']}})['then'](handleEntityNotFound(_0xb6bad4,null))[_0x7186('0x27')](saveUpdates(_0x2554b8[_0x7186('0x2f')],null))['then'](respondWithResult(_0xb6bad4,null))['catch'](handleError(_0xb6bad4,null));};exports[_0x7186('0x28')]=function(_0x5c0bf8,_0x36a662){return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x5c0bf8[_0x7186('0x3d')]['id']}})[_0x7186('0x27')](handleEntityNotFound(_0x36a662,null))['then'](removeEntity(_0x36a662,null))[_0x7186('0x3b')](handleError(_0x36a662,null));};exports[_0x7186('0x4b')]=function(_0x330243,_0xac7c2e){return db['ChatInteraction']['describe']()[_0x7186('0x27')](respondWithResult(_0xac7c2e,null))[_0x7186('0x3b')](handleError(_0xac7c2e,null));};exports[_0x7186('0x4c')]=function(_0x241d52,_0x567d88){var _0x5ee135=_0x241d52[_0x7186('0x3d')]['id'];var _0x475395;var _0x2e224e;var _0x4185f5;return db[_0x7186('0x35')][_0x7186('0x4d')]({'where':{'id':_0x5ee135}})[_0x7186('0x27')](function(_0x54813d){_0x475395=_0x54813d;return db[_0x7186('0x4e')][_0x7186('0x4d')]({'where':{'id':_0x54813d[_0x7186('0x4f')]},'attributes':['id',_0x7186('0x50'),_0x7186('0x51'),_0x7186('0x52'),_0x7186('0x53'),_0x7186('0x54')],'raw':!![]});})[_0x7186('0x27')](function(_0x57d638){if(_0x57d638&&_0x57d638[_0x7186('0x50')]&&_0x57d638['vidaooEscalation']){_0x2e224e=_0x57d638;var _0xac5239={'interaction':{'id':_0x5ee135},'agent':{'id':_0x241d52[_0x7186('0x3a')]['id'],'name':_0x241d52[_0x7186('0x3a')][_0x7186('0x2b')],'fullname':_0x241d52[_0x7186('0x3a')][_0x7186('0x55')],'email':_0x241d52[_0x7186('0x3a')][_0x7186('0x56')]},'contact':_0x241d52['body'][_0x7186('0x30')],'account':_0x241d52[_0x7186('0x2f')]['account']};var _0x7fc537={'rejectUnauthorized':![],'method':_0x7186('0x57'),'url':_0x7186('0x58'),'headers':{'X-APIKEY':_0x57d638[_0x7186('0x50')]},'body':{'duration':null,'scheduledAt':null,'participants':[_0x241d52[_0x7186('0x3a')][_0x7186('0x56')]],'buttons':null,'topic':_0x2e224e[_0x7186('0x52')],'note':_[_0x7186('0x59')](_0x2e224e[_0x7186('0x53')])?null:getMustacheRender(_0x2e224e[_0x7186('0x53')],_0xac5239),'metadata':null},'redirect':'follow','json':!![]};try{if(!_[_0x7186('0x59')](_0x2e224e['vidaooMetadata'])){var _0x33bee7=getMustacheRender(_0x2e224e[_0x7186('0x54')],_0xac5239);var _0x1d796b=JSON[_0x7186('0x5a')](_0x33bee7);_0x7fc537[_0x7186('0x2f')]['metadata']=_0x1d796b;}}catch(_0x419b8e){throw new db['Sequelize'][(_0x7186('0x5b'))](_0x7186('0x5c'));}return rp(_0x7fc537);}else{throw new db['Sequelize'][(_0x7186('0x5b'))](_0x7186('0x5d'));}})[_0x7186('0x27')](function(_0x458e09){_0x4185f5=_0x458e09;if(_0x4185f5['id']){var _0x2c9c29={'body':_0x4185f5['join_url'],'ChatWebsiteId':_0x2e224e['id'],'ChatInteractionId':_0x475395['id'],'direction':'out','UserId':_0x241d52['user']['id']};return db[_0x7186('0x5e')][_0x7186('0x49')](_0x2c9c29,{});}else{throw new db['Sequelize']['ValidationError'](_0x7186('0x5f'));}})[_0x7186('0x27')](function(){return _0x475395[_0x7186('0x60')]({'vidaooSessionId':_0x4185f5['id']});})[_0x7186('0x27')](respondWithResult(_0x567d88,null))[_0x7186('0x3b')](handleError(_0x567d88,null));};exports[_0x7186('0x61')]=function(_0x10d5ae,_0x3bccd5){if(_0x10d5ae['body']['id']){delete _0x10d5ae[_0x7186('0x2f')]['id'];}return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x10d5ae['params']['id']},'include':[{'model':db[_0x7186('0x62')],'as':_0x7186('0x63')}]})['then'](handleEntityNotFound(_0x3bccd5,null))['then'](saveUpdates(_0x10d5ae['body'],null))['then'](respondWithResult(_0x3bccd5,null))[_0x7186('0x3b')](handleError(_0x3bccd5,null));};exports[_0x7186('0x64')]=function(_0x25c54a,_0x1dcda8){if(_0x25c54a[_0x7186('0x2f')]['id']){delete _0x25c54a['body']['id'];}return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x25c54a[_0x7186('0x3d')]['id']}})[_0x7186('0x27')](function(_0x279672){if(!_0x279672){logger[_0x7186('0x1a')](_0x7186('0x65'),'abandon',0x194,_0x7186('0x66'));_0x1dcda8['sendStatus'](0x194);}else{if(_0x279672[_0x7186('0x67')]){throw new db[(_0x7186('0x68'))][(_0x7186('0x5b'))](_0x7186('0x69'));}}return _0x279672;})[_0x7186('0x27')](function(_0x11810d){if(_0x11810d){return _0x11810d[_0x7186('0x26')]({'closed':_0x25c54a[_0x7186('0x2f')][_0x7186('0x6a')],'disposition':_0x25c54a['body'][_0x7186('0x6b')]})['then'](function(_0x2577f5){return _0x2577f5;});}})['then'](function(){return respondWithRpcPromise(_0x7186('0x6c'),'abandon',_0x25c54a[_0x7186('0x2f')],client9004);})['then'](respondWithResult(_0x1dcda8,null))[_0x7186('0x3b')](handleError(_0x1dcda8,null));};exports[_0x7186('0x6d')]=function(_0x2aee69,_0x13f127){_0x2aee69[_0x7186('0x2f')][_0x7186('0x2b')]=_0x2aee69[_0x7186('0x6e')][_0x7186('0x6f')];_0x2aee69[_0x7186('0x2f')][_0x7186('0x70')]=_0x2aee69[_0x7186('0x6e')][_0x7186('0x71')];_0x2aee69[_0x7186('0x2f')]['type']=_0x2aee69[_0x7186('0x6e')][_0x7186('0x72')];return db[_0x7186('0x73')][_0x7186('0x49')](_0x2aee69[_0x7186('0x2f')])['then'](respondWithResult(_0x13f127,0xc9))['catch'](handleError(_0x13f127,null));};exports['attachmentDownload']=function(_0x7cb2a3,_0x276980){return db[_0x7186('0x35')]['findOne']({'where':{'id':_0x7cb2a3[_0x7186('0x3d')]['id']},'raw':!![]})[_0x7186('0x27')](handleEntityNotFound(_0x276980,null))['then'](function(_0x31abe8){if(_0x31abe8){if(_0x31abe8['closed']){return _0x276980[_0x7186('0x22')](0x193)[_0x7186('0x25')]({'status':0x193,'message':'Unauthorized'});}return db[_0x7186('0x73')]['findOne']({'where':{'id':_0x7cb2a3[_0x7186('0x39')][_0x7186('0x74')]},'raw':!![]})[_0x7186('0x27')](handleEntityNotFound(_0x276980,null));}})[_0x7186('0x27')](function(_0xb22a5){if(_0xb22a5){var _0x37c7d7=_0xb22a5['ChatOfflineMessageId']!==null;var _0xc58069=path['join'](config[_0x7186('0x75')],_0x7186('0x76'));if(_0x37c7d7){_0xc58069=path['join'](_0xc58069,_0x7186('0x77'));}var _0x3a0e1f=path[_0x7186('0x78')](_0xc58069,_0xb22a5[_0x7186('0x70')]);return _0x276980['download'](_0x3a0e1f);}})[_0x7186('0x3b')](handleError(_0x276980,null));};exports['close']=function(_0x3f460a,_0x3f0bf9){var _0x5e1fc6=null;var _0x5f1a27=null;var _0x3a0336=null;if(_0x3f460a[_0x7186('0x2f')]['id']){delete _0x3f460a['body']['id'];}if(_0x3f460a[_0x7186('0x2f')][_0x7186('0x79')]){_0x3a0336=path[_0x7186('0x78')](config['root'],'server/files/chat/upload/',util[_0x7186('0x7a')](_0x7186('0x7b'),Date[_0x7186('0x7c')]()));_0x3f460a['body'][_0x7186('0x7d')]=_0x3a0336;}return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x3f460a[_0x7186('0x3d')]['id']},'include':[{'model':db['ChatMessage'],'as':'Messages','include':[{'model':db['User'],'as':_0x7186('0x7e')}]}]})[_0x7186('0x27')](handleEntityNotFound(_0x3f0bf9,null))['then'](saveUpdates(_0x3f460a[_0x7186('0x2f')],null))[_0x7186('0x27')](function(_0x5513a5){if(_0x5513a5){_0x5e1fc6=_0x5513a5;return db[_0x7186('0x4e')][_0x7186('0x4a')]({'where':{'id':_0x5e1fc6[_0x7186('0x4f')]}});}})['then'](function(_0x1b95a9){if(_0x1b95a9){_0x5f1a27=_0x1b95a9;return db['CmContact'][_0x7186('0x4a')]({'where':{'id':_0x5e1fc6[_0x7186('0x7f')]}});}})['then'](function(_0x29892c){if(_0x29892c){if(_0x3a0336){var _0x2dc7bb=null;for(var _0x2b7aad=0x1;_0x2b7aad<_0x5e1fc6['Messages'][_0x7186('0x45')];++_0x2b7aad){_0x2dc7bb=_0x5e1fc6[_0x7186('0x80')][_0x2b7aad];var _0x16ea46=_0x2dc7bb[_0x7186('0x67')]?util[_0x7186('0x7a')](_0x7186('0x81'),_0x5f1a27[_0x7186('0x82')],_0x2dc7bb['UserId']):'System';var _0x5f1b93=_0x3f460a[_0x7186('0x2f')][_0x7186('0x83')]||util[_0x7186('0x7a')](_0x7186('0x81'),_0x7186('0x84'),_0x2dc7bb[_0x7186('0x7f')]);switch(_0x5f1a27['agentIdentifier']){case _0x7186('0x85'):_0x16ea46=_0x2dc7bb[_0x7186('0x67')]?util[_0x7186('0x7a')](_0x7186('0x81'),_0x5f1a27[_0x7186('0x82')],_0x2dc7bb['UserId']):_0x7186('0x86');break;case _0x7186('0x87'):_0x16ea46=_0x2dc7bb[_0x7186('0x67')]?_0x2dc7bb[_0x7186('0x7e')][_0x7186('0x88')]||_0x2dc7bb[_0x7186('0x7e')]['fullname']:_0x7186('0x86');break;case _0x7186('0x89'):_0x16ea46=_0x2dc7bb[_0x7186('0x67')]?_0x2dc7bb[_0x7186('0x7e')][_0x7186('0x55')]:_0x7186('0x86');break;default:_0x16ea46=_0x2dc7bb['UserId']?util[_0x7186('0x7a')](_0x7186('0x81'),_0x5f1a27[_0x7186('0x82')],_0x2dc7bb[_0x7186('0x67')]):_0x7186('0x86');}var _0x49c915=util[_0x7186('0x7a')]('[%s]\x20%s:\x20%s\x0a',moment(_0x2dc7bb[_0x7186('0x8a')])[_0x7186('0x7a')](_0x7186('0x8b')),_0x2dc7bb['direction']==='in'?_0x5f1b93:_0x16ea46,_0x2dc7bb['body']);if(!_0x2dc7bb[_0x7186('0x8c')]){fs[_0x7186('0x8d')](_0x3a0336,_0x49c915);}}return db[_0x7186('0x8e')][_0x7186('0x4d')]({'where':{'service':!![]},'include':[{'model':db[_0x7186('0x8f')],'as':_0x7186('0x90'),'raw':!![],'include':[{'model':db[_0x7186('0x91')],'as':_0x7186('0x91'),'raw':!![]}]}]});}}})[_0x7186('0x27')](function(_0x5572b4){if(!_0x5572b4||!_0x5572b4[_0x7186('0x90')]||!_0x3f460a[_0x7186('0x2f')])return _0x5e1fc6;var _0x403f0e=_0x5572b4[_0x7186('0x92')]();return respondWithRpcPromise(_0x7186('0x93'),_0x7186('0x94'),{'account':_0x403f0e,'message':{'from':util[_0x7186('0x7a')]('\x22%s\x22\x20<%s>',_0x5572b4[_0x7186('0x2b')],_0x5572b4['email']||_0x5572b4[_0x7186('0x90')][_0x7186('0x3a')]),'to':_0x3f460a[_0x7186('0x2f')]['mailTranscript'],'subject':_0x7186('0x95'),'text':util[_0x7186('0x7a')](_0x7186('0x96'),_0x3f460a['body']['mailTranscript']),'attachments':[{'path':_0x3a0336}]}})['then'](function(){return _0x5e1fc6;})['catch'](function(_0x593c05){logger['error'](_0x593c05);});})['then'](respondWithStatusCode(_0x3f0bf9,0xc8))[_0x7186('0x3b')](handleError(_0x3f0bf9,null));};exports['addMessage']=function(_0x14df9b,_0x46f006){return db[_0x7186('0x5e')][_0x7186('0x4a')]({'where':{'id':_0x14df9b['params']['id']}})['then'](handleEntityNotFound(_0x46f006,null))[_0x7186('0x27')](function(_0x18134e){if(_0x18134e){return _0x18134e[_0x7186('0x97')](_0x14df9b[_0x7186('0x2f')][_0x7186('0x98')],_[_0x7186('0x99')](_0x14df9b[_0x7186('0x2f')],[_0x7186('0x98'),'id'])||{});}})[_0x7186('0x27')](respondWithResult(_0x46f006,null))[_0x7186('0x3b')](handleError(_0x46f006,null));};exports[_0x7186('0x9a')]=function(_0x5453d7,_0x1620a1){var _0x518f64={'raw':![],'where':{}};var _0x4aa775={};var _0x4bdaee={'count':0x0,'rows':[]};return db[_0x7186('0x35')][_0x7186('0x4d')]({'where':{'id':_0x5453d7[_0x7186('0x3d')]['id']}})[_0x7186('0x27')](handleEntityNotFound(_0x1620a1,null))[_0x7186('0x27')](function(_0x11675a){if(_0x11675a){_0x4aa775['model']=_[_0x7186('0x3f')](db[_0x7186('0x5e')][_0x7186('0x40')]);_0x4aa775['query']=_[_0x7186('0x3f')](_0x5453d7[_0x7186('0x39')]);_0x4aa775[_0x7186('0x41')]=_[_0x7186('0x42')](_0x4aa775[_0x7186('0x3e')],_0x4aa775[_0x7186('0x39')]);_0x518f64['attributes']=_[_0x7186('0x42')](_0x4aa775['model'],qs[_0x7186('0x43')](_0x5453d7[_0x7186('0x39')][_0x7186('0x43')]));_0x518f64[_0x7186('0x44')]=_0x518f64[_0x7186('0x44')][_0x7186('0x45')]?_0x518f64[_0x7186('0x44')]:_0x4aa775[_0x7186('0x3e')];if(!_0x5453d7[_0x7186('0x39')][_0x7186('0x9b')](_0x7186('0x9c'))){_0x518f64[_0x7186('0x21')]=qs[_0x7186('0x21')](_0x5453d7[_0x7186('0x39')][_0x7186('0x21')]);_0x518f64['offset']=qs[_0x7186('0x1f')](_0x5453d7[_0x7186('0x39')][_0x7186('0x1f')]);}_0x518f64[_0x7186('0x9d')]=qs[_0x7186('0x9e')](_0x5453d7[_0x7186('0x39')]['sort']);_0x518f64[_0x7186('0x9f')]=qs['filters'](_[_0x7186('0xa0')](_0x5453d7[_0x7186('0x39')],_0x4aa775['filters']));_0x518f64[_0x7186('0x9f')][_0x7186('0xa1')]=_0x11675a['id'];if(_0x5453d7['query'][_0x7186('0xa2')]){_0x518f64['where']=_[_0x7186('0x2e')](_0x518f64['where'],{'$or':_[_0x7186('0x34')](_0x518f64[_0x7186('0x44')],function(_0x2e0d51){var _0x87fb21={};_0x87fb21[_0x2e0d51]={'$like':'%'+_0x5453d7['query'][_0x7186('0xa2')]+'%'};return _0x87fb21;})});}if(_0x5453d7[_0x7186('0x39')][_0x7186('0xa3')]){var _0xe0fdb9=_0x5453d7[_0x7186('0x39')][_0x7186('0xa3')][_0x7186('0xa4')](',');var _0x349b53={};_0x349b53[_0xe0fdb9[0x0]]={'$gte':moment(_0xe0fdb9[0x1])[_0x7186('0x7a')](_0x7186('0xa5'))};_0x518f64['where']=_[_0x7186('0x2e')](_0x518f64[_0x7186('0x9f')],_0x349b53);}_0x518f64=_[_0x7186('0x2e')]({},_0x518f64,_0x5453d7[_0x7186('0x48')]);return db[_0x7186('0x5e')]['count']({'where':_0x518f64['where']})[_0x7186('0x27')](function(_0x4a07e9){_0x4bdaee[_0x7186('0xa6')]=_0x4a07e9;if(_0x5453d7[_0x7186('0x39')]['includeAll']){_0x518f64['include']=[{'all':!![]}];}return db[_0x7186('0x5e')][_0x7186('0xa7')](_0x518f64);})[_0x7186('0x27')](function(_0x1478ff){_0x4bdaee[_0x7186('0xa8')]=_0x1478ff;return _0x4bdaee;});}})[_0x7186('0x27')](respondWithFilteredResult(_0x1620a1,_0x518f64))[_0x7186('0x3b')](handleError(_0x1620a1,null));};exports['getMyMessages']=function(_0x2fd194,_0x339f0c){var _0x4c7426={'where':{}},_0x238d27={},_0x147732={'count':0x0,'rows':[]};return db[_0x7186('0x35')][_0x7186('0x4d')]({'where':{'id':_0x2fd194[_0x7186('0x3d')]['id']}})[_0x7186('0x27')](handleEntityNotFound(_0x339f0c,null))[_0x7186('0x27')](function(_0x178b6d){if(_0x178b6d){_0x238d27['model']=_[_0x7186('0x3f')](db[_0x7186('0x5e')][_0x7186('0x40')]);_0x238d27[_0x7186('0x39')]=_[_0x7186('0x3f')](_0x2fd194[_0x7186('0x39')]);_0x238d27[_0x7186('0x41')]=_[_0x7186('0x42')](_0x238d27[_0x7186('0x3e')],_0x238d27[_0x7186('0x39')]);_0x4c7426[_0x7186('0x44')]=_[_0x7186('0x42')](_0x238d27[_0x7186('0x3e')],qs['fields'](_0x2fd194[_0x7186('0x39')]['fields']));_0x4c7426[_0x7186('0x44')]=_0x4c7426[_0x7186('0x44')][_0x7186('0x45')]?_0x4c7426['attributes']:_0x238d27['model'];if(!_0x2fd194[_0x7186('0x39')][_0x7186('0x9b')]('nolimit')){_0x4c7426[_0x7186('0x21')]=qs['limit'](_0x2fd194[_0x7186('0x39')][_0x7186('0x21')]);_0x4c7426[_0x7186('0x1f')]=qs['offset'](_0x2fd194[_0x7186('0x39')][_0x7186('0x1f')]);}_0x4c7426[_0x7186('0x9d')]=qs[_0x7186('0x9e')](_0x2fd194[_0x7186('0x39')]['sort']);_0x4c7426['where']=qs[_0x7186('0x41')](_[_0x7186('0xa0')](_0x2fd194[_0x7186('0x39')],_0x238d27[_0x7186('0x41')]));_0x4c7426['where'][_0x7186('0xa1')]=_0x178b6d['id'];if(_0x2fd194[_0x7186('0x39')][_0x7186('0xa2')]){_0x4c7426['where']=_[_0x7186('0x2e')](_0x4c7426[_0x7186('0x9f')],{'$or':_[_0x7186('0x34')](_0x4c7426[_0x7186('0x44')],function(_0x62e58d){var _0x27102c={};_0x27102c[_0x62e58d]={'$like':'%'+_0x2fd194[_0x7186('0x39')][_0x7186('0xa2')]+'%'};return _0x27102c;})});}_0x4c7426[_0x7186('0x9f')][_0x7186('0x8c')]=![];if(_0x2fd194['query']['id']){_0x4c7426[_0x7186('0x9f')]['id']={'$gt':_0x2fd194[_0x7186('0x39')]['id']};}_0x4c7426=_[_0x7186('0x2e')]({},_0x4c7426,_0x2fd194[_0x7186('0x48')]);return db[_0x7186('0x5e')][_0x7186('0xa6')]({'where':_0x4c7426[_0x7186('0x9f')]})[_0x7186('0x27')](function(_0x1be191){_0x147732[_0x7186('0xa6')]=_0x1be191;_0x4c7426[_0x7186('0x47')]=[];if(_0x2fd194['query'][_0x7186('0xa9')]){_0x4c7426[_0x7186('0x47')][_0x7186('0xaa')]({'model':db[_0x7186('0x7e')],'as':'User','attributes':['id',_0x7186('0x55'),'alias']});}if(_0x2fd194[_0x7186('0x39')][_0x7186('0x46')]){_0x4c7426[_0x7186('0x47')]=[{'all':!![]}];}return db['ChatMessage'][_0x7186('0xa7')](_0x4c7426);})[_0x7186('0x27')](function(_0x31dfb0){_0x147732[_0x7186('0xa8')]=_0x31dfb0;return _0x147732;});}})[_0x7186('0x27')](respondWithFilteredResult(_0x339f0c,_0x4c7426))[_0x7186('0x3b')](handleError(_0x339f0c,null));};exports['addTags']=function(_0x5012b5,_0x56a2c8){return db['ChatInteraction'][_0x7186('0x4a')]({'where':{'id':_0x5012b5[_0x7186('0x3d')]['id']}})['then'](handleEntityNotFound(_0x56a2c8,null))[_0x7186('0x27')](function(_0xad6c07){if(_0xad6c07){return _0xad6c07[_0x7186('0xab')](_0x5012b5[_0x7186('0x2f')]['ids'],_[_0x7186('0x99')](_0x5012b5['body'],[_0x7186('0x98'),'id'])||{})['spread'](function(){return db[_0x7186('0xac')]['findAll']({'attributes':['id',_0x7186('0x2b'),_0x7186('0xad')],'where':{'id':_0x5012b5[_0x7186('0x2f')][_0x7186('0x98')]}});})['then'](function(_0x40a096){socket['emit'](_0x7186('0xae'),{'id':Number(_0x5012b5[_0x7186('0x3d')]['id']),'tags':_0x40a096||[]});return{'id':Number(_0x5012b5[_0x7186('0x3d')]['id']),'tags':_0x40a096||[]};});}})[_0x7186('0x27')](respondWithResult(_0x56a2c8,null))['catch'](handleError(_0x56a2c8,null));};exports[_0x7186('0xaf')]=function(_0xcd4007,_0x3b99a2){return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0xcd4007[_0x7186('0x3d')]['id']}})[_0x7186('0x27')](handleEntityNotFound(_0x3b99a2,null))[_0x7186('0x27')](function(_0xc91831){if(_0xc91831){return _0xc91831['removeTags'](_0xcd4007['query'][_0x7186('0x98')]);}})[_0x7186('0x27')](respondWithStatusCode(_0x3b99a2,null))[_0x7186('0x3b')](handleError(_0x3b99a2,null));};exports[_0x7186('0xb0')]=function(_0x19721c,_0x3cd502){var _0x25d63e=moment()[_0x7186('0xb1')]()[_0x7186('0xb2')]();var _0x242414=path['join'](config['root'],_0x7186('0xb3'),'files','tmp');var _0x296330=path[_0x7186('0x78')](config[_0x7186('0x75')],_0x7186('0xb3'),_0x7186('0xb4'),_0x7186('0xb5'));var _0x179c47=path['join'](_0x242414,_0x25d63e);var _0x4e06a1=util[_0x7186('0x7a')]('transcript-%d-%s.zip',_0x19721c[_0x7186('0x3d')]['id'],_0x25d63e);var _0x5b68f0=path[_0x7186('0x78')](_0x242414,_0x4e06a1);var _0x4cdd8e=[];_0x4cdd8e[_0x7186('0xaa')]({'model':db[_0x7186('0x7e')],'as':_0x7186('0x7e'),'attributes':['id',_0x7186('0x55')],'raw':!![]});_0x4cdd8e[_0x7186('0xaa')]({'model':db[_0x7186('0x62')],'as':'Contact','attributes':['id',_0x7186('0xb6'),_0x7186('0xb7')],'raw':!![]});if(_0x19721c[_0x7186('0x39')][_0x7186('0xb5')]){_0x4cdd8e[_0x7186('0xaa')]({'model':db[_0x7186('0x73')],'as':_0x7186('0x73'),'raw':!![]});}var _0x1e340f=[{'model':db[_0x7186('0x5e')],'as':_0x7186('0x80'),'attributes':['id',_0x7186('0x2f'),_0x7186('0x8a'),_0x7186('0xb8'),_0x7186('0x8c'),'read'],'include':_0x4cdd8e}];_0x1e340f[_0x7186('0xaa')]({'model':db[_0x7186('0x4e')],'as':_0x7186('0xb9'),'attributes':['id',_0x7186('0x2b')]});_0x1e340f[_0x7186('0xaa')]({'model':db[_0x7186('0x7e')],'as':'Owner','attributes':['id',_0x7186('0x55')]});return db[_0x7186('0x35')][_0x7186('0x4a')]({'where':{'id':_0x19721c[_0x7186('0x3d')]['id']},'include':_0x1e340f})[_0x7186('0x27')](handleEntityNotFound(_0x3cd502,null))[_0x7186('0x27')](function(_0x2a263f){if(_0x2a263f){var _0x3eb6ac=_0x2a263f[_0x7186('0xba')]({'plain':!![]});fs[_0x7186('0xbb')](_0x179c47);var _0x3944b4={'channel':_0x7186('0xbc'),'account':_0x3eb6ac[_0x7186('0xb9')][_0x7186('0x2b')],'agent':_0x3eb6ac[_0x7186('0xbd')]?_0x3eb6ac[_0x7186('0xbd')][_0x7186('0x55')]:_0x7186('0xbe'),'createdAt':moment(_0x3eb6ac[_0x7186('0x8a')])[_0x7186('0x7a')](_0x7186('0xa5'))[_0x7186('0xb2')](),'closedAt':_0x3eb6ac[_0x7186('0x6a')]?moment(_0x3eb6ac[_0x7186('0xbf')])[_0x7186('0x7a')]('YYYY-MM-DD\x20HH:mm:ss')['toString']():'','disposition':_0x3eb6ac[_0x7186('0x6b')],'chatInfo':{'browser':_0x3eb6ac[_0x7186('0xc0')],'os':_0x3eb6ac['osName'],'referer':_0x3eb6ac[_0x7186('0xc1')],'customerIp':_0x3eb6ac[_0x7186('0xc2')],'customerPort':_0x3eb6ac[_0x7186('0xc3')]?_0x3eb6ac[_0x7186('0xc3')]:_0x7186('0xbe')},'messages':_(_0x3eb6ac[_0x7186('0x80')])['tail']()[_0x7186('0xa2')]({'secret':![]})[_0x7186('0x34')](function(_0xbee7e8){if(_0xbee7e8[_0x7186('0x73')]){var _0x1beccf=path[_0x7186('0x78')](_0x296330,_0xbee7e8[_0x7186('0x73')][_0x7186('0x70')]);if(fs[_0x7186('0xc4')](_0x1beccf)){fs[_0x7186('0xc5')](_0x1beccf)[_0x7186('0xc6')](fs[_0x7186('0xc7')](path['join'](_0x179c47,_0xbee7e8[_0x7186('0x73')][_0x7186('0x70')])));}}return{'date':moment(_0xbee7e8[_0x7186('0x8a')])[_0x7186('0x7a')](_0x7186('0xa5'))['toString'](),'sender':_0xbee7e8['direction']===_0x7186('0xc8')?_0xbee7e8['User']?_0xbee7e8['User']['fullname']:_0x7186('0x86'):_0xbee7e8['Contact']['firstName']+(_0xbee7e8[_0x7186('0x63')]['lastName']?'\x20'+_0xbee7e8['Contact']['lastName']:''),'body':_0xbee7e8['Attachment']?_0xbee7e8['Attachment'][_0x7186('0x70')]:_0xbee7e8[_0x7186('0x2f')],'direction':_0xbee7e8[_0x7186('0xb8')]==='out'?'A':'C','secret':_0xbee7e8[_0x7186('0x8c')],'read':_0xbee7e8['read'],'attachment':_0xbee7e8['Attachment']};})[_0x7186('0xc9')]()};return ejs['renderFile'](path[_0x7186('0x78')](config[_0x7186('0x75')],_0x7186('0xb3'),_0x7186('0xca'),_0x7186('0xcb')),{'interaction':_0x3944b4})[_0x7186('0x27')](function(_0xde5c7e){var _0x9b2cfb=path['join'](_0x179c47,'transcript-'+_0x3eb6ac['id']+'-'+_0x25d63e+_0x7186('0xcc'));var _0x5a6c66={'path':_0x9b2cfb,'channel':_0x7186('0xbc'),'interactionId':_0x3eb6ac['id']};return pdf['createPdfFromHTML'](_0xde5c7e,_0x5a6c66);})[_0x7186('0x27')](function(){return new Promise(function(_0x5eaabb,_0x2c5f78){zipdir(_0x179c47,{'saveTo':_0x5b68f0},function(_0x19094a,_0x423978){if(_0x19094a)return _0x2c5f78(_0x19094a);return _0x5eaabb(_0x423978);});})['then'](function(){return new BPromise(function(_0x43bc28,_0x5dc2f8){rimraf(_0x179c47,function(_0x164e81){if(_0x164e81)_0x5dc2f8(_0x164e81);return _0x43bc28();});});})[_0x7186('0x27')](function(){return _0x3cd502[_0x7186('0xb0')](_0x5b68f0,_0x4e06a1,function(_0x351925){if(_0x351925){logger[_0x7186('0x1a')](_0x7186('0xcd'),_0x351925);}else{fs[_0x7186('0xce')](_0x5b68f0);}});});});}else{return _0x3cd502[_0x7186('0x1e')](0xc8);}})[_0x7186('0x3b')](handleError(_0x3cd502,null));}; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.events.js b/server/api/chatInteraction/chatInteraction.events.js new file mode 100644 index 0000000..f5a2005 --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7508=['emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','ChatInteraction','ChatMessage','setMaxListeners','save','remove','getUsers','then','setDataValue','Users'];(function(_0x7d9c0d,_0x165295){var _0x26a3c7=function(_0x493af9){while(--_0x493af9){_0x7d9c0d['push'](_0x7d9c0d['shift']());}};_0x26a3c7(++_0x165295);}(_0x7508,0x1e5));var _0x8750=function(_0x15d685,_0x2c9b5b){_0x15d685=_0x15d685-0x0;var _0xc75766=_0x7508[_0x15d685];return _0xc75766;};'use strict';var EventEmitter=require(_0x8750('0x0'));var ChatInteraction=require(_0x8750('0x1'))['db'][_0x8750('0x2')];var ChatMessage=require(_0x8750('0x1'))['db'][_0x8750('0x3')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents[_0x8750('0x4')](0x0);var events={'afterCreate':_0x8750('0x5'),'afterUpdate':'update','afterDestroy':_0x8750('0x6')};function emitEvent(_0x3a9854){return function(_0x2d0299,_0x1ff80c,_0x2c23d8){_0x2d0299[_0x8750('0x7')]({'attributes':['id'],'raw':!![]})[_0x8750('0x8')](function(_0x181f0f){_0x2d0299[_0x8750('0x9')](_0x8750('0xa'),_0x181f0f['map'](function(_0x3e29d3){return{'id':_0x3e29d3['id']};}));return ChatMessage['findAll']({'where':{'ChatInteractionId':_0x2d0299['id'],'direction':'in','read':![]},'raw':!![]});})[_0x8750('0x8')](function(_0x19d1bc){_0x2d0299[_0x8750('0x9')]('unreadMessages',_0x19d1bc['length']);ChatInteractionEvents[_0x8750('0xb')](_0x3a9854+':'+_0x2d0299['id'],_0x2d0299);ChatInteractionEvents[_0x8750('0xb')](_0x3a9854,_0x2d0299);_0x2c23d8(null);})[_0x8750('0xc')](_0x2c23d8(null));};}for(var e in events){if(events[_0x8750('0xd')](e)){var event=events[e];ChatInteraction[_0x8750('0xe')](e,emitEvent(event));}}module[_0x8750('0xf')]=ChatInteractionEvents; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.model.js b/server/api/chatInteraction/chatInteraction.model.js new file mode 100644 index 0000000..a176e82 --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2ac8=['closedAt','YYYY-MM-DD\x20HH:mm:ss','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./chatInteraction.attributes','exports','define','ChatInteraction','chat_interactions','changed','closed'];(function(_0x1b95df,_0x135ab4){var _0x5e530a=function(_0x4917cb){while(--_0x4917cb){_0x1b95df['push'](_0x1b95df['shift']());}};_0x5e530a(++_0x135ab4);}(_0x2ac8,0x1cb));var _0x82ac=function(_0x203eb4,_0x235cb8){_0x203eb4=_0x203eb4-0x0;var _0x5b061c=_0x2ac8[_0x203eb4];return _0x5b061c;};'use strict';var _=require(_0x82ac('0x0'));var util=require(_0x82ac('0x1'));var logger=require(_0x82ac('0x2'))(_0x82ac('0x3'));var moment=require(_0x82ac('0x4'));var BPromise=require(_0x82ac('0x5'));var rp=require(_0x82ac('0x6'));var fs=require('fs');var path=require('path');var rimraf=require(_0x82ac('0x7'));var config=require(_0x82ac('0x8'));var attributes=require(_0x82ac('0x9'));module[_0x82ac('0xa')]=function(_0x510cb4,_0x5ec377){return _0x510cb4[_0x82ac('0xb')](_0x82ac('0xc'),attributes,{'tableName':_0x82ac('0xd'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x3a3aeb,_0x1fc54f,_0x5bd21b){if(_0x3a3aeb[_0x82ac('0xe')](_0x82ac('0xf'))){_0x3a3aeb[_0x82ac('0x10')]=moment()['format'](_0x82ac('0x11'));}_0x5bd21b(null,_0x3a3aeb);}},'charset':'utf8mb4','collate':_0x82ac('0x12')});}; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.rpc.js b/server/api/chatInteraction/chatInteraction.rpc.js new file mode 100644 index 0000000..2a26cf2 --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9979=['request','then','info','ChatInteraction,\x20%s,\x20%s','ChatInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','ChatInteraction','update','body','options','raw','where','attributes','limit','UpdateChatInteraction','debug','stringify','catch','AddTagsToChatInteraction','find','addTags','ids','omit','AddTags','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','redis','./chatInteraction.socket','register'];(function(_0x26d6a2,_0x35dd17){var _0x3771e4=function(_0x385a1c){while(--_0x385a1c){_0x26d6a2['push'](_0x26d6a2['shift']());}};_0x3771e4(++_0x35dd17);}(_0x9979,0x1d4));var _0x9997=function(_0x1ee8cb,_0x4d1c68){_0x1ee8cb=_0x1ee8cb-0x0;var _0x21f29b=_0x9979[_0x1ee8cb];return _0x21f29b;};'use strict';var _=require(_0x9997('0x0'));var util=require('util');var moment=require(_0x9997('0x1'));var BPromise=require('bluebird');var rs=require(_0x9997('0x2'));var fs=require('fs');var Redis=require(_0x9997('0x3'));var db=require(_0x9997('0x4'))['db'];var utils=require(_0x9997('0x5'));var logger=require('../../config/logger')(_0x9997('0x6'));var config=require(_0x9997('0x7'));var jayson=require(_0x9997('0x8'));var client=jayson[_0x9997('0x9')][_0x9997('0xa')]({'port':0x232a});config['redis']=_[_0x9997('0xb')](config['redis'],{'host':_0x9997('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9997('0xd')]));require(_0x9997('0xe'))[_0x9997('0xf')](socket);function respondWithRpcPromise(_0xd47c7e,_0x1f606a,_0x165ea4){return new BPromise(function(_0x5e6ca6,_0x26b8eb){return client[_0x9997('0x10')](_0xd47c7e,_0x165ea4)[_0x9997('0x11')](function(_0x24cc97){logger[_0x9997('0x12')](_0x9997('0x13'),_0x1f606a,'request\x20sent');logger['debug'](_0x9997('0x14'),_0x1f606a,_0x9997('0x15'),JSON['stringify'](_0x24cc97));if(_0x24cc97['error']){if(_0x24cc97[_0x9997('0x16')][_0x9997('0x17')]===0x1f4){logger[_0x9997('0x16')](_0x9997('0x13'),_0x1f606a,_0x24cc97[_0x9997('0x16')][_0x9997('0x18')]);return _0x26b8eb(_0x24cc97['error'][_0x9997('0x18')]);}logger[_0x9997('0x16')](_0x9997('0x13'),_0x1f606a,_0x24cc97[_0x9997('0x16')][_0x9997('0x18')]);return _0x5e6ca6(_0x24cc97['error']['message']);}else{logger[_0x9997('0x12')]('ChatInteraction,\x20%s,\x20%s',_0x1f606a,_0x9997('0x15'));_0x5e6ca6(_0x24cc97[_0x9997('0x19')][_0x9997('0x18')]);}})['catch'](function(_0x3f2720){logger[_0x9997('0x16')]('ChatInteraction,\x20%s,\x20%s',_0x1f606a,_0x3f2720);_0x26b8eb(_0x3f2720);});});}exports['UpdateChatInteraction']=function(_0x44debd){var _0x3f9601=this;return new Promise(function(_0x4e3ae2,_0x311240){return db[_0x9997('0x1a')][_0x9997('0x1b')](_0x44debd[_0x9997('0x1c')],{'raw':_0x44debd[_0x9997('0x1d')]?_0x44debd[_0x9997('0x1d')][_0x9997('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x44debd['options']?_0x44debd[_0x9997('0x1d')][_0x9997('0x1f')]||null:null,'attributes':_0x44debd[_0x9997('0x1d')]?_0x44debd[_0x9997('0x1d')][_0x9997('0x20')]||null:null,'limit':_0x44debd['options']?_0x44debd[_0x9997('0x1d')][_0x9997('0x21')]||null:null})['then'](function(_0x30226d){logger[_0x9997('0x12')](_0x9997('0x22'),_0x44debd);logger[_0x9997('0x23')]('UpdateChatInteraction',_0x44debd,JSON[_0x9997('0x24')](_0x30226d));_0x4e3ae2(_0x30226d);})[_0x9997('0x25')](function(_0xc3a6a6){logger[_0x9997('0x16')](_0x9997('0x22'),_0xc3a6a6[_0x9997('0x18')],_0x44debd);_0x311240(_0x3f9601['error'](0x1f4,_0xc3a6a6[_0x9997('0x18')]));});});};exports[_0x9997('0x26')]=function(_0x4af455){return new Promise(function(_0x4922f6,_0x4b1fba){return db[_0x9997('0x1a')][_0x9997('0x27')]({'where':_0x4af455[_0x9997('0x1d')]?_0x4af455[_0x9997('0x1d')][_0x9997('0x1f')]||null:null})['then'](function(_0x2f102f){if(_0x2f102f){return _0x2f102f[_0x9997('0x28')](_0x4af455[_0x9997('0x1c')][_0x9997('0x29')],_[_0x9997('0x2a')](_0x4af455['body'],[_0x9997('0x29'),'id'])||{});}})['spread'](function(_0x2f6534){logger['info'](_0x9997('0x2b'),_0x4af455);logger[_0x9997('0x23')](_0x9997('0x2b'),_0x4af455,JSON[_0x9997('0x24')](_0x2f6534));_0x4922f6(_0x2f6534);})[_0x9997('0x25')](function(_0x2cb677){logger[_0x9997('0x16')](_0x9997('0x2b'),_0x2cb677[_0x9997('0x18')],_0x4af455);_0x4b1fba(_this[_0x9997('0x16')](0x1f4,_0x2cb677[_0x9997('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/chatInteraction/chatInteraction.socket.js b/server/api/chatInteraction/chatInteraction.socket.js new file mode 100644 index 0000000..3f86a10 --- /dev/null +++ b/server/api/chatInteraction/chatInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9348=['chatInteraction:','./chatInteraction.events','save','remove','update','emit','removeListener','register','length'];(function(_0x2e8ce7,_0x40ef19){var _0x563d95=function(_0x118ec0){while(--_0x118ec0){_0x2e8ce7['push'](_0x2e8ce7['shift']());}};_0x563d95(++_0x40ef19);}(_0x9348,0x160));var _0x8934=function(_0x43058d,_0x567311){_0x43058d=_0x43058d-0x0;var _0x2793d3=_0x9348[_0x43058d];return _0x2793d3;};'use strict';var ChatInteractionEvents=require(_0x8934('0x0'));var events=[_0x8934('0x1'),_0x8934('0x2'),_0x8934('0x3')];function createListener(_0xc7aa75,_0x48c51d){return function(_0x39979e){_0x48c51d[_0x8934('0x4')](_0xc7aa75,_0x39979e);};}function removeListener(_0x386b51,_0xed8e23){return function(){ChatInteractionEvents[_0x8934('0x5')](_0x386b51,_0xed8e23);};}exports[_0x8934('0x6')]=function(_0x3bb404){for(var _0x5ae829=0x0,_0x4420a7=events[_0x8934('0x7')];_0x5ae829<_0x4420a7;_0x5ae829++){var _0x3fc698=events[_0x5ae829];var _0x533196=createListener(_0x8934('0x8')+_0x3fc698,_0x3bb404);ChatInteractionEvents['on'](_0x3fc698,_0x533196);}}; \ No newline at end of file diff --git a/server/api/chatInteraction/index.js b/server/api/chatInteraction/index.js new file mode 100644 index 0000000..d6dec71 --- /dev/null +++ b/server/api/chatInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c91=['now','originalname','replace','single','file','/:id/messages','addMessage','/:id/tags','tracked','chat','addTags','put','chatinteraction:update','update','/:id/custom_update','customUpdate','/:id/abandon','abandon','/:id/close','close','delete','chatinteraction:destroy','destroy','removeTags','exports','multer','express','Router','./chatInteraction.controller','get','isAuthenticated','index','/describe','describe','/:id','/:id/attachment_download','getMessages','isChatInteractionAuthorized','getMyMessages','/:id/download','download','post','/:id/vidaoo','createVidaooSession','diskStorage','root','server/files/attachments/'];(function(_0x13f4a3,_0x5139b2){var _0x51b1d9=function(_0x4291e3){while(--_0x4291e3){_0x13f4a3['push'](_0x13f4a3['shift']());}};_0x51b1d9(++_0x5139b2);}(_0x4c91,0x191));var _0x14c9=function(_0x5ab5e0,_0x36bdf5){_0x5ab5e0=_0x5ab5e0-0x0;var _0x16ecd4=_0x4c91[_0x5ab5e0];return _0x16ecd4;};'use strict';var multer=require(_0x14c9('0x0'));var util=require('util');var path=require('path');var timeout=require('connect-timeout');var express=require(_0x14c9('0x1'));var router=express[_0x14c9('0x2')]();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x14c9('0x3'));router[_0x14c9('0x4')]('/',auth[_0x14c9('0x5')](),controller[_0x14c9('0x6')]);router['get'](_0x14c9('0x7'),auth[_0x14c9('0x5')](),controller[_0x14c9('0x8')]);router['get'](_0x14c9('0x9'),auth['isChatInteractionAuthorized'](),controller['show']);router[_0x14c9('0x4')](_0x14c9('0xa'),auth['isChatInteractionAuthorized'](),controller['attachmentDownload']);router[_0x14c9('0x4')]('/:id/messages',auth[_0x14c9('0x5')](),controller[_0x14c9('0xb')]);router['get']('/:id/my_messages',auth[_0x14c9('0xc')](),controller[_0x14c9('0xd')]);router['get'](_0x14c9('0xe'),auth[_0x14c9('0x5')](),controller[_0x14c9('0xf')]);router['post']('/',auth[_0x14c9('0x5')](),controller['create']);router[_0x14c9('0x10')](_0x14c9('0x11'),auth[_0x14c9('0x5')](),controller[_0x14c9('0x12')]);var upload=multer({'storage':multer[_0x14c9('0x13')]({'destination':function(_0x1815eb,_0x2ad90e,_0x5d6af0){_0x5d6af0(null,path['join'](config[_0x14c9('0x14')],_0x14c9('0x15')));},'filename':function(_0x27f86d,_0x1d1cc8,_0xf5c322){_0xf5c322(null,util['format']('%s-%s',Date[_0x14c9('0x16')](),_0x1d1cc8[_0x14c9('0x17')][_0x14c9('0x18')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-')));}})});router[_0x14c9('0x10')]('/:id/attachment_upload',upload[_0x14c9('0x19')](_0x14c9('0x1a')),controller['attachmentUpload']);router[_0x14c9('0x10')](_0x14c9('0x1b'),auth[_0x14c9('0xc')](),controller[_0x14c9('0x1c')]);router[_0x14c9('0x10')](_0x14c9('0x1d'),auth['isAuthenticated'](),interaction[_0x14c9('0x1e')](_0x14c9('0x1f'),'chatinteraction:addtags'),controller[_0x14c9('0x20')]);router[_0x14c9('0x21')](_0x14c9('0x9'),auth['isAuthenticated'](),interaction[_0x14c9('0x1e')]('chat',_0x14c9('0x22')),controller[_0x14c9('0x23')]);router[_0x14c9('0x21')](_0x14c9('0x24'),controller[_0x14c9('0x25')]);router['put'](_0x14c9('0x26'),auth[_0x14c9('0xc')](),controller[_0x14c9('0x27')]);router[_0x14c9('0x21')](_0x14c9('0x28'),controller[_0x14c9('0x29')]);router[_0x14c9('0x2a')]('/:id',auth[_0x14c9('0x5')](),interaction[_0x14c9('0x1e')](_0x14c9('0x1f'),_0x14c9('0x2b')),controller[_0x14c9('0x2c')]);router['delete']('/:id/tags',auth[_0x14c9('0x5')](),controller[_0x14c9('0x2d')]);module[_0x14c9('0x2e')]=router; \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.attributes.js b/server/api/chatInternalMessage/chatInternalMessage.attributes.js new file mode 100644 index 0000000..8290766 --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb689=['exports','TEXT','medium','BOOLEAN','sequelize'];(function(_0xa00a06,_0x163e41){var _0x45d3e5=function(_0x2885f8){while(--_0x2885f8){_0xa00a06['push'](_0xa00a06['shift']());}};_0x45d3e5(++_0x163e41);}(_0xb689,0x95));var _0x9b68=function(_0x1da709,_0x1eddb9){_0x1da709=_0x1da709-0x0;var _0x17e59c=_0xb689[_0x1da709];return _0x17e59c;};'use strict';var Sequelize=require(_0x9b68('0x0'));module[_0x9b68('0x1')]={'body':{'type':Sequelize[_0x9b68('0x2')](_0x9b68('0x3')),'allowNull':![]},'read':{'type':Sequelize[_0x9b68('0x4')],'defaultValue':![]},'ChatInternalMessageId':{'type':Sequelize['INTEGER']}}; \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.controller.js b/server/api/chatInternalMessage/chatInternalMessage.controller.js new file mode 100644 index 0000000..a7b225c --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc8d5=['options','find','create','body','describe','get','lastMessageAt','format','YYYY-MM-DD\x20HH:mm:ss','lastMessage','getUsers','User','agent','role','userpic','internal','online','allowmessenger','showWebBar','-online','VoiceQueue','user','UserProfileSection','Agents','userProfileId','autoAssociation','resourceId','push','createdAt','ToId','read','eml-format','zip-dir','request-promise','moment','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','socket.io-emitter','./chatInternalMessage.socket','status','end','json','limit','undefined','count','offset','set','apply','reject','save','update','then','destroy','error','stack','name','map','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','type','filter','ChatInternalMessage','includeAll','include','findAll','rows','catch','params','rawAttributes','keys'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0xc8d5,0x1b7));var _0x5c8d=function(_0x166eda,_0x5f0071){_0x166eda=_0x166eda-0x0;var _0x1661c7=_0xc8d5[_0x166eda];return _0x1661c7;};'use strict';var emlformat=require(_0x5c8d('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5c8d('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5c8d('0x2'));var moment=require(_0x5c8d('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x5c8d('0x4'));var path=require(_0x5c8d('0x5'));var sox=require(_0x5c8d('0x6'));var csv=require(_0x5c8d('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5c8d('0x8'));var _=require(_0x5c8d('0x9'));var squel=require(_0x5c8d('0xa'));var crypto=require(_0x5c8d('0xb'));var jsforce=require(_0x5c8d('0xc'));var deskjs=require(_0x5c8d('0xd'));var toCsv=require(_0x5c8d('0x7'));var querystring=require(_0x5c8d('0xe'));var Papa=require(_0x5c8d('0xf'));var Redis=require(_0x5c8d('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x5c8d('0x11'));var hardwareService=require(_0x5c8d('0x12'));var logger=require(_0x5c8d('0x13'))(_0x5c8d('0x14'));var utils=require(_0x5c8d('0x15'));var config=require(_0x5c8d('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x5c8d('0x17')]=_[_0x5c8d('0x18')](config[_0x5c8d('0x17')],{'host':_0x5c8d('0x19'),'port':0x18eb});var socket=require(_0x5c8d('0x1a'))(new Redis(config[_0x5c8d('0x17')]));require(_0x5c8d('0x1b'))['register'](socket);function respondWithStatusCode(_0x2c3d07,_0x4f70e8){_0x4f70e8=_0x4f70e8||0xcc;return function(_0x5aa99a){if(_0x5aa99a){return _0x2c3d07['sendStatus'](_0x4f70e8);}return _0x2c3d07[_0x5c8d('0x1c')](_0x4f70e8)[_0x5c8d('0x1d')]();};}function respondWithResult(_0x2f6da2,_0x4102b6){_0x4102b6=_0x4102b6||0xc8;return function(_0x89181f){if(_0x89181f){return _0x2f6da2[_0x5c8d('0x1c')](_0x4102b6)[_0x5c8d('0x1e')](_0x89181f);}};}function respondWithFilteredResult(_0x52e9aa,_0x4c7c1f){return function(_0x36b00f){if(_0x36b00f){var _0xc99a5b=typeof _0x4c7c1f['offset']==='undefined'&&typeof _0x4c7c1f[_0x5c8d('0x1f')]===_0x5c8d('0x20');var _0x4168c4=_0x36b00f[_0x5c8d('0x21')];var _0x5bd34b=_0xc99a5b?0x0:_0x4c7c1f[_0x5c8d('0x22')];var _0x3e9010=_0xc99a5b?_0x36b00f[_0x5c8d('0x21')]:_0x4c7c1f['offset']+_0x4c7c1f['limit'];var _0x47a83f;if(_0x3e9010>=_0x4168c4){_0x3e9010=_0x4168c4;_0x47a83f=0xc8;}else{_0x47a83f=0xce;}_0x52e9aa[_0x5c8d('0x1c')](_0x47a83f);return _0x52e9aa[_0x5c8d('0x23')]('Content-Range',_0x5bd34b+'-'+_0x3e9010+'/'+_0x4168c4)['json'](_0x36b00f);}return null;};}function patchUpdates(_0x44d9e5){return function(_0x5ed207){try{jsonpatch[_0x5c8d('0x24')](_0x5ed207,_0x44d9e5,!![]);}catch(_0x5a58ad){return BPromise[_0x5c8d('0x25')](_0x5a58ad);}return _0x5ed207[_0x5c8d('0x26')]();};}function saveUpdates(_0x4339e4,_0x3e4031){return function(_0x5eade5){if(_0x5eade5){return _0x5eade5[_0x5c8d('0x27')](_0x4339e4)[_0x5c8d('0x28')](function(_0x3fe870){return _0x3fe870;});}return null;};}function removeEntity(_0x3f1958,_0x3f68ba){return function(_0x2741d4){if(_0x2741d4){return _0x2741d4[_0x5c8d('0x29')]()['then'](function(){_0x3f1958[_0x5c8d('0x1c')](0xcc)[_0x5c8d('0x1d')]();});}};}function handleEntityNotFound(_0x5ae294,_0x2a66b4){return function(_0x22a1a1){if(!_0x22a1a1){_0x5ae294['sendStatus'](0x194);}return _0x22a1a1;};}function handleError(_0x5dd572,_0x30992e){_0x30992e=_0x30992e||0x1f4;return function(_0x850cae){logger[_0x5c8d('0x2a')](_0x850cae[_0x5c8d('0x2b')]);if(_0x850cae[_0x5c8d('0x2c')]){delete _0x850cae[_0x5c8d('0x2c')];}_0x5dd572['status'](_0x30992e)['send'](_0x850cae);};}exports['index']=function(_0xc86011,_0x1168cd){var _0x222bae={},_0x33dee2={},_0x41147d={'count':0x0,'rows':[]};var _0x130d93=_[_0x5c8d('0x2d')](db['ChatInternalMessage']['rawAttributes'],function(_0x2397b1){return{'name':_0x2397b1['fieldName'],'type':_0x2397b1['type'][_0x5c8d('0x2e')]};});_0x33dee2[_0x5c8d('0x2f')]=_[_0x5c8d('0x2d')](_0x130d93,_0x5c8d('0x2c'));_0x33dee2[_0x5c8d('0x30')]=_['keys'](_0xc86011[_0x5c8d('0x30')]);_0x33dee2[_0x5c8d('0x31')]=_[_0x5c8d('0x32')](_0x33dee2['model'],_0x33dee2['query']);_0x222bae[_0x5c8d('0x33')]=_[_0x5c8d('0x32')](_0x33dee2[_0x5c8d('0x2f')],qs[_0x5c8d('0x34')](_0xc86011['query'][_0x5c8d('0x34')]));_0x222bae[_0x5c8d('0x33')]=_0x222bae[_0x5c8d('0x33')][_0x5c8d('0x35')]?_0x222bae[_0x5c8d('0x33')]:_0x33dee2['model'];if(!_0xc86011[_0x5c8d('0x30')][_0x5c8d('0x36')](_0x5c8d('0x37'))){_0x222bae[_0x5c8d('0x1f')]=qs[_0x5c8d('0x1f')](_0xc86011[_0x5c8d('0x30')][_0x5c8d('0x1f')]);_0x222bae['offset']=qs[_0x5c8d('0x22')](_0xc86011['query'][_0x5c8d('0x22')]);}_0x222bae['order']=qs[_0x5c8d('0x38')](_0xc86011['query'][_0x5c8d('0x38')]);_0x222bae[_0x5c8d('0x39')]=qs[_0x5c8d('0x31')](_[_0x5c8d('0x3a')](_0xc86011['query'],_0x33dee2[_0x5c8d('0x31')]),_0x130d93);if(_0xc86011[_0x5c8d('0x30')]['filter']){_0x222bae[_0x5c8d('0x39')]=_[_0x5c8d('0x3b')](_0x222bae['where'],{'$or':_[_0x5c8d('0x2d')](_0x130d93,function(_0x3e71be){if(_0x3e71be[_0x5c8d('0x3c')]!=='VIRTUAL'){var _0xbb1c6c={};_0xbb1c6c[_0x3e71be[_0x5c8d('0x2c')]]={'$like':'%'+_0xc86011[_0x5c8d('0x30')][_0x5c8d('0x3d')]+'%'};return _0xbb1c6c;}})});}_0x222bae=_[_0x5c8d('0x3b')]({},_0x222bae,_0xc86011['options']);var _0x1389a0={'where':_0x222bae[_0x5c8d('0x39')]};return db[_0x5c8d('0x3e')][_0x5c8d('0x21')](_0x1389a0)['then'](function(_0x1b33c8){_0x41147d[_0x5c8d('0x21')]=_0x1b33c8;if(_0xc86011[_0x5c8d('0x30')][_0x5c8d('0x3f')]){_0x222bae[_0x5c8d('0x40')]=[{'all':!![]}];}return db[_0x5c8d('0x3e')][_0x5c8d('0x41')](_0x222bae);})['then'](function(_0x2af939){_0x41147d[_0x5c8d('0x42')]=_0x2af939;return _0x41147d;})[_0x5c8d('0x28')](respondWithFilteredResult(_0x1168cd,_0x222bae))[_0x5c8d('0x43')](handleError(_0x1168cd,null));};exports['show']=function(_0xb0dbce,_0x367bce){var _0x17c593={'raw':!![],'where':{'id':_0xb0dbce[_0x5c8d('0x44')]['id']}},_0x4dc025={};_0x4dc025[_0x5c8d('0x2f')]=_['keys'](db[_0x5c8d('0x3e')][_0x5c8d('0x45')]);_0x4dc025[_0x5c8d('0x30')]=_[_0x5c8d('0x46')](_0xb0dbce[_0x5c8d('0x30')]);_0x4dc025['filters']=_[_0x5c8d('0x32')](_0x4dc025[_0x5c8d('0x2f')],_0x4dc025[_0x5c8d('0x30')]);_0x17c593[_0x5c8d('0x33')]=_[_0x5c8d('0x32')](_0x4dc025[_0x5c8d('0x2f')],qs[_0x5c8d('0x34')](_0xb0dbce[_0x5c8d('0x30')][_0x5c8d('0x34')]));_0x17c593['attributes']=_0x17c593['attributes'][_0x5c8d('0x35')]?_0x17c593['attributes']:_0x4dc025[_0x5c8d('0x2f')];if(_0xb0dbce[_0x5c8d('0x30')][_0x5c8d('0x3f')]){_0x17c593['include']=[{'all':!![]}];}_0x17c593=_['merge']({},_0x17c593,_0xb0dbce[_0x5c8d('0x47')]);return db[_0x5c8d('0x3e')][_0x5c8d('0x48')](_0x17c593)[_0x5c8d('0x28')](handleEntityNotFound(_0x367bce,null))[_0x5c8d('0x28')](respondWithResult(_0x367bce,null))[_0x5c8d('0x43')](handleError(_0x367bce,null));};exports[_0x5c8d('0x49')]=function(_0x327a8d,_0x17da63){return db['ChatInternalMessage'][_0x5c8d('0x49')](_0x327a8d[_0x5c8d('0x4a')],{})['then'](respondWithResult(_0x17da63,0xc9))[_0x5c8d('0x43')](handleError(_0x17da63,null));};exports[_0x5c8d('0x27')]=function(_0x419d31,_0x177273){if(_0x419d31[_0x5c8d('0x4a')]['id']){delete _0x419d31[_0x5c8d('0x4a')]['id'];}return db[_0x5c8d('0x3e')]['find']({'where':{'id':_0x419d31[_0x5c8d('0x44')]['id']}})['then'](handleEntityNotFound(_0x177273,null))[_0x5c8d('0x28')](saveUpdates(_0x419d31[_0x5c8d('0x4a')],null))[_0x5c8d('0x28')](respondWithResult(_0x177273,null))[_0x5c8d('0x43')](handleError(_0x177273,null));};exports[_0x5c8d('0x29')]=function(_0x21c84f,_0x2630ad){return db[_0x5c8d('0x3e')][_0x5c8d('0x48')]({'where':{'id':_0x21c84f[_0x5c8d('0x44')]['id']}})['then'](handleEntityNotFound(_0x2630ad,null))[_0x5c8d('0x28')](removeEntity(_0x2630ad,null))['catch'](handleError(_0x2630ad,null));};exports[_0x5c8d('0x4b')]=function(_0x52c977,_0xea48ba){return db[_0x5c8d('0x3e')][_0x5c8d('0x4b')]()[_0x5c8d('0x28')](respondWithResult(_0xea48ba,null))[_0x5c8d('0x43')](handleError(_0xea48ba,null));};function wrapUser(_0x2dbc34){return function(_0xf602cf){var _0x17bddd=_0x2dbc34[_0x5c8d('0x4c')]({'plain':!![]});_0x17bddd['messages']=[];if(_0xf602cf){_0x17bddd[_0x5c8d('0x4d')]=_0xf602cf['createdAt'];_0x17bddd['lastMessage']=_0xf602cf;}else{_0x17bddd[_0x5c8d('0x4d')]=moment(0x0)[_0x5c8d('0x4e')](_0x5c8d('0x4f'));_0x17bddd[_0x5c8d('0x50')]={};}return _0x17bddd;};}exports[_0x5c8d('0x51')]=function(_0x59100a,_0x3f28e6,_0x4580fc){var _0x3ce5f0=[];return db[_0x5c8d('0x52')][_0x5c8d('0x41')]({'where':{'role':[_0x5c8d('0x53'),'admin','user']},'attributes':['id','fullname',_0x5c8d('0x2c'),_0x5c8d('0x54'),_0x5c8d('0x55'),_0x5c8d('0x56'),_0x5c8d('0x57'),'lastLoginAt',_0x5c8d('0x58'),_0x5c8d('0x59')],'order':qs[_0x5c8d('0x38')](_0x5c8d('0x5a')),'include':[{'model':db[_0x5c8d('0x5b')],'as':'VoiceQueues','attributes':['id','name','type'],'through':{'attributes':[]}}]})['then'](function(_0x4c01e9){if(_0x4c01e9){var _0x3728d1=_0x59100a[_0x5c8d('0x5c')][_0x5c8d('0x4c')]({'plain':!![]});if(!_0x3728d1)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3728d1[_0x5c8d('0x54')]===_0x5c8d('0x5c')){return db[_0x5c8d('0x5d')][_0x5c8d('0x48')]({'where':{'name':_0x5c8d('0x5e'),'userProfileId':_0x3728d1[_0x5c8d('0x5f')]},'raw':!![]})[_0x5c8d('0x28')](function(_0x206605){if(_0x206605){if(_0x206605[_0x5c8d('0x60')]===0x0){return db['UserProfileResource'][_0x5c8d('0x41')]({'where':{'sectionId':_0x206605['id']},'raw':!![]})[_0x5c8d('0x28')](function(_0x4c591e){var _0xca5c8d=[];if(_['isEmpty'](_0x4c591e)){_0xca5c8d=_[_0x5c8d('0x3d')](_0x4c01e9,function(_0x122f43){if(_0x122f43[_0x5c8d('0x54')]!==_0x5c8d('0x53')){return _0x122f43;}});return _0xca5c8d;}else{for(var _0x2f4443=0x0;_0x2f4443<_0x4c01e9[_0x5c8d('0x35')];_0x2f4443++){var _0x5f16ec=_0x4c01e9[_0x2f4443];if(_0x5f16ec[_0x5c8d('0x54')]===_0x5c8d('0x53')){var _0xd7ae7c=_[_0x5c8d('0x48')](_0x4c591e,function(_0x417197){return _0x417197[_0x5c8d('0x61')]===_0x5f16ec['id'];});if(_0xd7ae7c)_0xca5c8d['push'](_0x5f16ec);}else{_0xca5c8d[_0x5c8d('0x62')](_0x5f16ec);}}return _0xca5c8d;}});}else{return _0x4c01e9;}}else{var _0x53f4e9=_[_0x5c8d('0x3d')](_0x4c01e9,function(_0x3830fa){if(_0x3830fa[_0x5c8d('0x54')]!==_0x5c8d('0x53')){return _0x3830fa;}});return _0x53f4e9;}});}else{return _0x4c01e9;}}})[_0x5c8d('0x28')](function(_0x4d65b9){var _0x3c30ce=[];if(_0x4d65b9){_0x3ce5f0=_0x4d65b9;for(var _0x169a12=0x0;_0x169a12<_0x4d65b9[_0x5c8d('0x35')];_0x169a12+=0x1){_0x3ce5f0[_0x169a12]['messages']=[];_0x3c30ce[_0x5c8d('0x62')](db[_0x5c8d('0x3e')][_0x5c8d('0x48')]({'where':{'FromId':[_0x59100a[_0x5c8d('0x5c')]['id'],_0x4d65b9[_0x169a12]['id']],'ToId':[_0x59100a[_0x5c8d('0x5c')]['id'],_0x4d65b9[_0x169a12]['id']],'ChatGroupId':null},'attributes':['id',_0x5c8d('0x63'),'FromId',_0x5c8d('0x64'),_0x5c8d('0x65'),_0x5c8d('0x4a')],'order':qs[_0x5c8d('0x38')]('-createdAt'),'limit':0x1,'offset':0x0,'raw':!![]})[_0x5c8d('0x28')](wrapUser(_0x4d65b9[_0x169a12])));}return BPromise['all'](_0x3c30ce);}return[];})['then'](function(_0xefbe00){return{'rows':_0xefbe00,'count':_0xefbe00['length']};})[_0x5c8d('0x28')](respondWithResult(_0x3f28e6,null))[_0x5c8d('0x43')](handleError(_0x3f28e6,null));}; \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.events.js b/server/api/chatInternalMessage/chatInternalMessage.events.js new file mode 100644 index 0000000..7d40d2a --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdf97=['hasOwnProperty','hook','exports','../../mysqldb','ChatInternalMessage','setMaxListeners','update','remove','emit'];(function(_0x2df3e3,_0x4358f0){var _0x513853=function(_0x15db16){while(--_0x15db16){_0x2df3e3['push'](_0x2df3e3['shift']());}};_0x513853(++_0x4358f0);}(_0xdf97,0x1ce));var _0x7df9=function(_0x182c6e,_0x31831a){_0x182c6e=_0x182c6e-0x0;var _0xfc0e5c=_0xdf97[_0x182c6e];return _0xfc0e5c;};'use strict';var EventEmitter=require('events');var ChatInternalMessage=require(_0x7df9('0x0'))['db'][_0x7df9('0x1')];var ChatInternalMessageEvents=new EventEmitter();ChatInternalMessageEvents[_0x7df9('0x2')](0x0);var events={'afterCreate':'save','afterUpdate':_0x7df9('0x3'),'afterDestroy':_0x7df9('0x4')};function emitEvent(_0x3908f8){return function(_0x5a5440,_0x236379,_0x494fb6){ChatInternalMessageEvents[_0x7df9('0x5')](_0x3908f8+':'+_0x5a5440['id'],_0x5a5440);ChatInternalMessageEvents['emit'](_0x3908f8,_0x5a5440);_0x494fb6(null);};}for(var e in events){if(events[_0x7df9('0x6')](e)){var event=events[e];ChatInternalMessage[_0x7df9('0x7')](e,emitEvent(event));}}module[_0x7df9('0x8')]=ChatInternalMessageEvents; \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.model.js b/server/api/chatInternalMessage/chatInternalMessage.model.js new file mode 100644 index 0000000..fbfe065 --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x92bd=['api','bluebird','request-promise','path','../../config/environment','./chatInternalMessage.attributes','exports','define','ChatInternalMessage','chat_internal_messages','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger'];(function(_0x3bf83f,_0x181cac){var _0x22c4a9=function(_0xb3ff0d){while(--_0xb3ff0d){_0x3bf83f['push'](_0x3bf83f['shift']());}};_0x22c4a9(++_0x181cac);}(_0x92bd,0x11a));var _0xd92b=function(_0x525a60,_0x4c2846){_0x525a60=_0x525a60-0x0;var _0x398893=_0x92bd[_0x525a60];return _0x398893;};'use strict';var _=require(_0xd92b('0x0'));var util=require(_0xd92b('0x1'));var logger=require(_0xd92b('0x2'))(_0xd92b('0x3'));var moment=require('moment');var BPromise=require(_0xd92b('0x4'));var rp=require(_0xd92b('0x5'));var fs=require('fs');var path=require(_0xd92b('0x6'));var rimraf=require('rimraf');var config=require(_0xd92b('0x7'));var attributes=require(_0xd92b('0x8'));module[_0xd92b('0x9')]=function(_0x1a0db3,_0x4f9995){return _0x1a0db3[_0xd92b('0xa')](_0xd92b('0xb'),attributes,{'tableName':_0xd92b('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':_0xd92b('0xd'),'collate':_0xd92b('0xe')});}; \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.rpc.js b/server/api/chatInternalMessage/chatInternalMessage.rpc.js new file mode 100644 index 0000000..824f41e --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7857=['socket.io-emitter','register','request','then','info','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatInternalMessage,\x20%s,\x20%s','message','request\x20sent','result','catch','util','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults'];(function(_0x4e90e3,_0x570a1d){var _0x295e5b=function(_0x754043){while(--_0x754043){_0x4e90e3['push'](_0x4e90e3['shift']());}};_0x295e5b(++_0x570a1d);}(_0x7857,0x1af));var _0x7785=function(_0x1e2de9,_0x1f488b){_0x1e2de9=_0x1e2de9-0x0;var _0x500905=_0x7857[_0x1e2de9];return _0x500905;};'use strict';var _=require('lodash');var util=require(_0x7785('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x7785('0x1'));var fs=require('fs');var Redis=require(_0x7785('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x7785('0x3'))(_0x7785('0x4'));var config=require(_0x7785('0x5'));var jayson=require(_0x7785('0x6'));var client=jayson[_0x7785('0x7')][_0x7785('0x8')]({'port':0x232a});config[_0x7785('0x9')]=_[_0x7785('0xa')](config[_0x7785('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x7785('0xb'))(new Redis(config[_0x7785('0x9')]));require('./chatInternalMessage.socket')[_0x7785('0xc')](socket);function respondWithRpcPromise(_0xd65aa8,_0x297d3b,_0x24fc56){return new BPromise(function(_0x5552da,_0x3b79e9){return client[_0x7785('0xd')](_0xd65aa8,_0x24fc56)[_0x7785('0xe')](function(_0x320c33){logger[_0x7785('0xf')]('ChatInternalMessage,\x20%s,\x20%s',_0x297d3b,'request\x20sent');logger[_0x7785('0x10')](_0x7785('0x11'),_0x297d3b,'request\x20sent',JSON[_0x7785('0x12')](_0x320c33));if(_0x320c33['error']){if(_0x320c33[_0x7785('0x13')][_0x7785('0x14')]===0x1f4){logger[_0x7785('0x13')](_0x7785('0x15'),_0x297d3b,_0x320c33[_0x7785('0x13')]['message']);return _0x3b79e9(_0x320c33[_0x7785('0x13')][_0x7785('0x16')]);}logger[_0x7785('0x13')](_0x7785('0x15'),_0x297d3b,_0x320c33[_0x7785('0x13')][_0x7785('0x16')]);return _0x5552da(_0x320c33[_0x7785('0x13')][_0x7785('0x16')]);}else{logger[_0x7785('0xf')](_0x7785('0x15'),_0x297d3b,_0x7785('0x17'));_0x5552da(_0x320c33[_0x7785('0x18')][_0x7785('0x16')]);}})[_0x7785('0x19')](function(_0x269947){logger['error']('ChatInternalMessage,\x20%s,\x20%s',_0x297d3b,_0x269947);_0x3b79e9(_0x269947);});});} \ No newline at end of file diff --git a/server/api/chatInternalMessage/chatInternalMessage.socket.js b/server/api/chatInternalMessage/chatInternalMessage.socket.js new file mode 100644 index 0000000..cf1424c --- /dev/null +++ b/server/api/chatInternalMessage/chatInternalMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2b04=['remove','update','emit','register','length','chatInternalMessage:','save'];(function(_0x5805dc,_0x243355){var _0x531bc9=function(_0x3bf09b){while(--_0x3bf09b){_0x5805dc['push'](_0x5805dc['shift']());}};_0x531bc9(++_0x243355);}(_0x2b04,0x1cd));var _0x42b0=function(_0x5d1a0a,_0x3df1b4){_0x5d1a0a=_0x5d1a0a-0x0;var _0x165ee2=_0x2b04[_0x5d1a0a];return _0x165ee2;};'use strict';var ChatInternalMessageEvents=require('./chatInternalMessage.events');var events=[_0x42b0('0x0'),_0x42b0('0x1'),_0x42b0('0x2')];function createListener(_0x2a3927,_0x466b93){return function(_0x1a63aa){_0x466b93[_0x42b0('0x3')](_0x2a3927,_0x1a63aa);};}function removeListener(_0x540487,_0x556ca4){return function(){ChatInternalMessageEvents['removeListener'](_0x540487,_0x556ca4);};}exports[_0x42b0('0x4')]=function(_0x33b678){for(var _0x5c9858=0x0,_0x5daa2d=events[_0x42b0('0x5')];_0x5c9858<_0x5daa2d;_0x5c9858++){var _0x15cb14=events[_0x5c9858];var _0x5474b6=createListener(_0x42b0('0x6')+_0x15cb14,_0x33b678);ChatInternalMessageEvents['on'](_0x15cb14,_0x5474b6);}}; \ No newline at end of file diff --git a/server/api/chatInternalMessage/index.js b/server/api/chatInternalMessage/index.js new file mode 100644 index 0000000..d7cd44c --- /dev/null +++ b/server/api/chatInternalMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbf60=['/:id','show','post','create','put','update','exports','multer','util','Router','../../components/auth/service','../../components/interaction/service','index','isAuthenticated','describe','get','/users','getUsers'];(function(_0x37e3d3,_0x98b6){var _0x23d36a=function(_0x19b6c7){while(--_0x19b6c7){_0x37e3d3['push'](_0x37e3d3['shift']());}};_0x23d36a(++_0x98b6);}(_0xbf60,0x127));var _0x0bf6=function(_0xcda377,_0x1e2678){_0xcda377=_0xcda377-0x0;var _0x1c024f=_0xbf60[_0xcda377];return _0x1c024f;};'use strict';var multer=require(_0x0bf6('0x0'));var util=require(_0x0bf6('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0bf6('0x2')]();var fs_extra=require('fs-extra');var auth=require(_0x0bf6('0x3'));var interaction=require(_0x0bf6('0x4'));var config=require('../../config/environment');var controller=require('./chatInternalMessage.controller');router['get']('/',auth['isAuthenticated'](),controller[_0x0bf6('0x5')]);router['get']('/describe',auth[_0x0bf6('0x6')](),controller[_0x0bf6('0x7')]);router[_0x0bf6('0x8')](_0x0bf6('0x9'),auth['isAuthenticated'](),controller[_0x0bf6('0xa')]);router[_0x0bf6('0x8')](_0x0bf6('0xb'),auth[_0x0bf6('0x6')](),controller[_0x0bf6('0xc')]);router[_0x0bf6('0xd')]('/',auth[_0x0bf6('0x6')](),controller[_0x0bf6('0xe')]);router[_0x0bf6('0xf')]('/:id',controller[_0x0bf6('0x10')]);router['delete'](_0x0bf6('0xb'),auth[_0x0bf6('0x6')](),controller['destroy']);module[_0x0bf6('0x11')]=router; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.attributes.js b/server/api/chatMessage/chatMessage.attributes.js new file mode 100644 index 0000000..b22d15c --- /dev/null +++ b/server/api/chatMessage/chatMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1131=['BOOLEAN','ENUM','out','DATE','STRING','exports'];(function(_0x152136,_0x4f14f1){var _0x20df44=function(_0x362877){while(--_0x362877){_0x152136['push'](_0x152136['shift']());}};_0x20df44(++_0x4f14f1);}(_0x1131,0x71));var _0x1113=function(_0x2b58fb,_0x353e04){_0x2b58fb=_0x2b58fb-0x0;var _0xd865fa=_0x1131[_0x2b58fb];return _0xd865fa;};'use strict';var Sequelize=require('sequelize');module[_0x1113('0x0')]={'body':{'type':Sequelize['TEXT']('medium'),'allowNull':![]},'read':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'secret':{'type':Sequelize[_0x1113('0x1')],'defaultValue':![]},'direction':{'type':Sequelize[_0x1113('0x2')]('in',_0x1113('0x3')),'defaultValue':_0x1113('0x3'),'allowNull':![]},'readAt':{'type':Sequelize[_0x1113('0x4')]},'providerName':{'type':Sequelize[_0x1113('0x5')]},'providerResponse':{'type':Sequelize['TEXT']}}; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.controller.js b/server/api/chatMessage/chatMessage.controller.js new file mode 100644 index 0000000..300deb1 --- /dev/null +++ b/server/api/chatMessage/chatMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3124=['stack','name','index','map','ChatMessage','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','includeAll','include','findAll','rows','show','rawAttributes','length','options','find','create','body','params','describe','chat-interactions','accept','chat','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','interaction','info','[CHATMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','AcceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','QueryTypes','SELECT','contact','fullname','email','internal','interface','SIP/%s','channel','EventManager','acceptmessage','formData','ChatInteraction','ChatInteractionId','[CHATMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','rejectMessage','Sequelize','User','event','parse','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./chatMessage.socket','client','http','request','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','offset','undefined','limit','count','set','json','reject','update','then','destroy','end'];(function(_0x45d510,_0x513557){var _0x20d720=function(_0x43e5de){while(--_0x43e5de){_0x45d510['push'](_0x45d510['shift']());}};_0x20d720(++_0x513557);}(_0x3124,0x149));var _0x4312=function(_0x36e807,_0x3f3e2d){_0x36e807=_0x36e807-0x0;var _0x6b408d=_0x3124[_0x36e807];return _0x6b408d;};'use strict';var emlformat=require(_0x4312('0x0'));var rimraf=require(_0x4312('0x1'));var zipdir=require(_0x4312('0x2'));var jsonpatch=require(_0x4312('0x3'));var rp=require('request-promise');var moment=require(_0x4312('0x4'));var BPromise=require(_0x4312('0x5'));var Mustache=require('mustache');var util=require(_0x4312('0x6'));var path=require(_0x4312('0x7'));var sox=require('sox');var csv=require(_0x4312('0x8'));var ejs=require(_0x4312('0x9'));var fs=require('fs');var fs_extra=require(_0x4312('0xa'));var _=require(_0x4312('0xb'));var squel=require(_0x4312('0xc'));var crypto=require(_0x4312('0xd'));var jsforce=require(_0x4312('0xe'));var deskjs=require(_0x4312('0xf'));var toCsv=require(_0x4312('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x4312('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x4312('0x11'));var as=require(_0x4312('0x12'));var hardwareService=require(_0x4312('0x13'));var logger=require(_0x4312('0x14'))(_0x4312('0x15'));var utils=require(_0x4312('0x16'));var config=require(_0x4312('0x17'));var licenseUtil=require(_0x4312('0x18'));var db=require(_0x4312('0x19'))['db'];config[_0x4312('0x1a')]=_[_0x4312('0x1b')](config[_0x4312('0x1a')],{'host':_0x4312('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4312('0x1a')]));require(_0x4312('0x1d'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x4312('0x1e')][_0x4312('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x4312('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x4d5608,_0x40d7ff,_0xf1dd9c,_0x4acaae){return new BPromise(function(_0x216a7c,_0x3da494){var _0x367d94=_0x4acaae||client;return _0x367d94[_0x4312('0x20')](_0x4d5608,_0xf1dd9c)['then'](function(_0xd6e6c3){logger['info'](_0x4312('0x21'),_0x40d7ff,_0x4312('0x22'));logger[_0x4312('0x23')](_0x4312('0x24'),_0x40d7ff,_0x4312('0x22'),JSON[_0x4312('0x25')](_0xd6e6c3));if(_0xd6e6c3[_0x4312('0x26')]){if(_0xd6e6c3[_0x4312('0x26')][_0x4312('0x27')]===0x1f4){logger[_0x4312('0x26')](_0x4312('0x21'),_0x40d7ff,_0xd6e6c3[_0x4312('0x26')]['message']);return _0x3da494(_0xd6e6c3[_0x4312('0x26')][_0x4312('0x28')]);}logger[_0x4312('0x26')](_0x4312('0x21'),_0x40d7ff,_0xd6e6c3[_0x4312('0x26')][_0x4312('0x28')]);return _0x216a7c(_0xd6e6c3['error'][_0x4312('0x28')]);}else{logger['info']('ChatMessage,\x20%s,\x20%s',_0x40d7ff,_0x4312('0x22'));_0x216a7c(_0xd6e6c3['result']['message']);}})[_0x4312('0x29')](function(_0x1095e1){logger[_0x4312('0x26')](_0x4312('0x21'),_0x40d7ff,_0x1095e1);_0x3da494(_0x1095e1);});});}function respondWithStatusCode(_0x5ce5cc,_0x2f37c6){_0x2f37c6=_0x2f37c6||0xcc;return function(_0x4dbef7){if(_0x4dbef7){return _0x5ce5cc[_0x4312('0x2a')](_0x2f37c6);}return _0x5ce5cc[_0x4312('0x2b')](_0x2f37c6)['end']();};}function respondWithResult(_0xcf95e6,_0x13dbd5){_0x13dbd5=_0x13dbd5||0xc8;return function(_0x457970){if(_0x457970){return _0xcf95e6[_0x4312('0x2b')](_0x13dbd5)['json'](_0x457970);}};}function respondWithFilteredResult(_0x4e9908,_0x6905e6){return function(_0x507b4c){if(_0x507b4c){var _0x145942=typeof _0x6905e6[_0x4312('0x2c')]===_0x4312('0x2d')&&typeof _0x6905e6[_0x4312('0x2e')]===_0x4312('0x2d');var _0x49306a=_0x507b4c[_0x4312('0x2f')];var _0x5200c8=_0x145942?0x0:_0x6905e6[_0x4312('0x2c')];var _0x40b99f=_0x145942?_0x507b4c[_0x4312('0x2f')]:_0x6905e6[_0x4312('0x2c')]+_0x6905e6[_0x4312('0x2e')];var _0x3d684e;if(_0x40b99f>=_0x49306a){_0x40b99f=_0x49306a;_0x3d684e=0xc8;}else{_0x3d684e=0xce;}_0x4e9908['status'](_0x3d684e);return _0x4e9908[_0x4312('0x30')]('Content-Range',_0x5200c8+'-'+_0x40b99f+'/'+_0x49306a)[_0x4312('0x31')](_0x507b4c);}return null;};}function patchUpdates(_0x346a8f){return function(_0x5f0217){try{jsonpatch['apply'](_0x5f0217,_0x346a8f,!![]);}catch(_0x1fcee5){return BPromise[_0x4312('0x32')](_0x1fcee5);}return _0x5f0217['save']();};}function saveUpdates(_0x292b9d,_0x236496){return function(_0x517dd3){if(_0x517dd3){return _0x517dd3[_0x4312('0x33')](_0x292b9d)[_0x4312('0x34')](function(_0xc1ccb0){return _0xc1ccb0;});}return null;};}function removeEntity(_0x2d31bc,_0x5e8560){return function(_0x565e49){if(_0x565e49){return _0x565e49[_0x4312('0x35')]()[_0x4312('0x34')](function(){_0x2d31bc['status'](0xcc)[_0x4312('0x36')]();});}};}function handleEntityNotFound(_0xa8d776,_0x1e9f0d){return function(_0x275131){if(!_0x275131){_0xa8d776[_0x4312('0x2a')](0x194);}return _0x275131;};}function handleError(_0xde109e,_0x54f536){_0x54f536=_0x54f536||0x1f4;return function(_0x3593c5){logger[_0x4312('0x26')](_0x3593c5[_0x4312('0x37')]);if(_0x3593c5[_0x4312('0x38')]){delete _0x3593c5['name'];}_0xde109e['status'](_0x54f536)['send'](_0x3593c5);};}exports[_0x4312('0x39')]=function(_0x176e00,_0x385aa8){var _0x4bcbd9={},_0x486f95={},_0x334d93={'count':0x0,'rows':[]};var _0x38f650=_[_0x4312('0x3a')](db[_0x4312('0x3b')]['rawAttributes'],function(_0x552e9b){return{'name':_0x552e9b['fieldName'],'type':_0x552e9b['type'][_0x4312('0x3c')]};});_0x486f95[_0x4312('0x3d')]=_['map'](_0x38f650,_0x4312('0x38'));_0x486f95[_0x4312('0x3e')]=_[_0x4312('0x3f')](_0x176e00[_0x4312('0x3e')]);_0x486f95['filters']=_[_0x4312('0x40')](_0x486f95[_0x4312('0x3d')],_0x486f95[_0x4312('0x3e')]);_0x4bcbd9[_0x4312('0x41')]=_[_0x4312('0x40')](_0x486f95[_0x4312('0x3d')],qs[_0x4312('0x42')](_0x176e00['query'][_0x4312('0x42')]));_0x4bcbd9['attributes']=_0x4bcbd9[_0x4312('0x41')]['length']?_0x4bcbd9[_0x4312('0x41')]:_0x486f95[_0x4312('0x3d')];if(!_0x176e00['query'][_0x4312('0x43')]('nolimit')){_0x4bcbd9[_0x4312('0x2e')]=qs['limit'](_0x176e00[_0x4312('0x3e')][_0x4312('0x2e')]);_0x4bcbd9[_0x4312('0x2c')]=qs[_0x4312('0x2c')](_0x176e00[_0x4312('0x3e')][_0x4312('0x2c')]);}_0x4bcbd9[_0x4312('0x44')]=qs[_0x4312('0x45')](_0x176e00[_0x4312('0x3e')]['sort']);_0x4bcbd9[_0x4312('0x46')]=qs[_0x4312('0x47')](_[_0x4312('0x48')](_0x176e00[_0x4312('0x3e')],_0x486f95['filters']),_0x38f650);if(_0x176e00[_0x4312('0x3e')][_0x4312('0x49')]){_0x4bcbd9[_0x4312('0x46')]=_[_0x4312('0x4a')](_0x4bcbd9[_0x4312('0x46')],{'$or':_[_0x4312('0x3a')](_0x38f650,function(_0x586ba1){if(_0x586ba1[_0x4312('0x4b')]!==_0x4312('0x4c')){var _0x280846={};_0x280846[_0x586ba1[_0x4312('0x38')]]={'$like':'%'+_0x176e00[_0x4312('0x3e')][_0x4312('0x49')]+'%'};return _0x280846;}})});}_0x4bcbd9=_['merge']({},_0x4bcbd9,_0x176e00['options']);var _0x4c4e79={'where':_0x4bcbd9[_0x4312('0x46')]};return db[_0x4312('0x3b')][_0x4312('0x2f')](_0x4c4e79)['then'](function(_0xd4927e){_0x334d93[_0x4312('0x2f')]=_0xd4927e;if(_0x176e00[_0x4312('0x3e')][_0x4312('0x4d')]){_0x4bcbd9[_0x4312('0x4e')]=[{'all':!![]}];}return db[_0x4312('0x3b')][_0x4312('0x4f')](_0x4bcbd9);})[_0x4312('0x34')](function(_0x587fa2){_0x334d93[_0x4312('0x50')]=_0x587fa2;return _0x334d93;})[_0x4312('0x34')](respondWithFilteredResult(_0x385aa8,_0x4bcbd9))['catch'](handleError(_0x385aa8,null));};exports[_0x4312('0x51')]=function(_0x471ceb,_0x110f4d){var _0x4f7793={'raw':!![],'where':{'id':_0x471ceb['params']['id']}},_0x35052a={};_0x35052a[_0x4312('0x3d')]=_[_0x4312('0x3f')](db['ChatMessage'][_0x4312('0x52')]);_0x35052a['query']=_[_0x4312('0x3f')](_0x471ceb[_0x4312('0x3e')]);_0x35052a[_0x4312('0x47')]=_[_0x4312('0x40')](_0x35052a['model'],_0x35052a[_0x4312('0x3e')]);_0x4f7793[_0x4312('0x41')]=_['intersection'](_0x35052a['model'],qs['fields'](_0x471ceb['query'][_0x4312('0x42')]));_0x4f7793[_0x4312('0x41')]=_0x4f7793[_0x4312('0x41')][_0x4312('0x53')]?_0x4f7793[_0x4312('0x41')]:_0x35052a[_0x4312('0x3d')];if(_0x471ceb[_0x4312('0x3e')][_0x4312('0x4d')]){_0x4f7793['include']=[{'all':!![]}];}_0x4f7793=_[_0x4312('0x4a')]({},_0x4f7793,_0x471ceb[_0x4312('0x54')]);return db[_0x4312('0x3b')][_0x4312('0x55')](_0x4f7793)[_0x4312('0x34')](handleEntityNotFound(_0x110f4d,null))['then'](respondWithResult(_0x110f4d,null))[_0x4312('0x29')](handleError(_0x110f4d,null));};exports[_0x4312('0x56')]=function(_0x18621a,_0x4ba0f2){return db['ChatMessage'][_0x4312('0x56')](_0x18621a[_0x4312('0x57')],{})[_0x4312('0x34')](respondWithResult(_0x4ba0f2,0xc9))[_0x4312('0x29')](handleError(_0x4ba0f2,null));};exports['update']=function(_0x4b0c84,_0x31a6d6){if(_0x4b0c84[_0x4312('0x57')]['id']){delete _0x4b0c84[_0x4312('0x57')]['id'];}return db[_0x4312('0x3b')][_0x4312('0x55')]({'where':{'id':_0x4b0c84[_0x4312('0x58')]['id']}})['then'](handleEntityNotFound(_0x31a6d6,null))[_0x4312('0x34')](saveUpdates(_0x4b0c84[_0x4312('0x57')],null))[_0x4312('0x34')](respondWithResult(_0x31a6d6,null))[_0x4312('0x29')](handleError(_0x31a6d6,null));};exports[_0x4312('0x35')]=function(_0x299169,_0x5abafe){return db[_0x4312('0x3b')][_0x4312('0x55')]({'where':{'id':_0x299169[_0x4312('0x58')]['id']}})[_0x4312('0x34')](handleEntityNotFound(_0x5abafe,null))[_0x4312('0x34')](removeEntity(_0x5abafe,null))[_0x4312('0x29')](handleError(_0x5abafe,null));};exports[_0x4312('0x59')]=function(_0x5bcb0f,_0x1e9306){return db[_0x4312('0x3b')][_0x4312('0x59')]()[_0x4312('0x34')](respondWithResult(_0x1e9306,null))[_0x4312('0x29')](handleError(_0x1e9306,null));};var interaction_log=require(_0x4312('0x14'))(_0x4312('0x5a'));exports[_0x4312('0x5b')]=function(_0x70ea4c,_0xd6e83a,_0x5d407b){var _0x24217d={'agent':{},'channel':_0x4312('0x5c')};if(_0x70ea4c['body']['id']){delete _0x70ea4c[_0x4312('0x57')]['id'];}_0x70ea4c['body']['read']=!![];_0x70ea4c[_0x4312('0x57')]['readAt']=moment()[_0x4312('0x5d')](_0x4312('0x5e'));_0x70ea4c[_0x4312('0x57')]['UserId']=_0x70ea4c[_0x4312('0x57')][_0x4312('0x5f')]||_0x70ea4c[_0x4312('0x60')]['id'];_0x24217d[_0x4312('0x61')]['id']=_0x70ea4c['body']['UserId'];return db['ChatMessage'][_0x4312('0x55')]({'where':{'id':_0x70ea4c[_0x4312('0x58')]['id'],'UserId':null}})[_0x4312('0x34')](handleEntityNotFound(_0xd6e83a,null))['then'](saveUpdates(_0x70ea4c[_0x4312('0x57')],null))[_0x4312('0x34')](function(_0x1c3799){if(_0x1c3799){_0x24217d['message']=_0x1c3799[_0x4312('0x62')]({'plain':!![]});return db['ChatInteraction'][_0x4312('0x55')]({'where':{'id':_0x1c3799['ChatInteractionId']}});}return null;})[_0x4312('0x34')](handleEntityNotFound(_0xd6e83a,null))['then'](function(_0x494aae){if(_0x494aae){return _0x494aae[_0x4312('0x33')]({'UserId':_0x70ea4c[_0x4312('0x57')][_0x4312('0x5f')],'read1stAt':_['isNil'](_0x494aae['read1stAt'])?moment()['format'](_0x4312('0x5e')):undefined});}return null;})[_0x4312('0x34')](function(_0x18e724){if(_0x18e724){_0x24217d[_0x4312('0x63')]=_0x18e724[_0x4312('0x62')]({'plain':!![]});interaction_log[_0x4312('0x64')](_0x4312('0x65'),_0x70ea4c[_0x4312('0x60')]['id'],_0x70ea4c[_0x4312('0x60')]['name'],_0x70ea4c[_0x4312('0x60')]['role'],_0x24217d[_0x4312('0x63')]['id'],_0x70ea4c[_0x4312('0x57')]?JSON[_0x4312('0x25')](_0x70ea4c['body']):_0x4312('0x66'));return respondWithRpcPromise(_0x4312('0x67'),'acceptMessage',_0x24217d);}return null;})[_0x4312('0x34')](function(_0x372d8){var _0x3db72e=_0x4312('0x68')+_0x372d8['message'][_0x4312('0x69')];return db[_0x4312('0x6a')][_0x4312('0x3e')](_0x3db72e,{'type':db['Sequelize'][_0x4312('0x6b')][_0x4312('0x6c')],'raw':!![]})[_0x4312('0x34')](function(_0x3929a5){return _0x3929a5;});})[_0x4312('0x34')](function(_0x5b7a79){if(_0x5b7a79){_0x24217d['message'][_0x4312('0x6d')]=_0x5b7a79[0x0];if(!_0x70ea4c[_0x4312('0x57')][_0x4312('0x5f')])return;return db['User'][_0x4312('0x55')]({'where':{'id':_0x70ea4c[_0x4312('0x57')]['UserId'],'role':'agent'},'attributes':['id',_0x4312('0x38'),_0x4312('0x6e'),_0x4312('0x6f'),_0x4312('0x70')],'raw':!![]});}return null;})['then'](function(_0x9f77a3){if(!_0x9f77a3)return null;_0x24217d[_0x4312('0x28')]['agent']=_0x9f77a3;return _0x24217d;})['then'](function(_0x1037ef){if(_0x1037ef){if(_0x70ea4c[_0x4312('0x57')]['manual']){_0x24217d[_0x4312('0x28')][_0x4312('0x71')]=util[_0x4312('0x5d')](_0x4312('0x72'),_0x70ea4c[_0x4312('0x60')]['name']);_0x24217d[_0x4312('0x28')]['channel']=_0x24217d[_0x4312('0x73')];_0x24217d['message']['motionChannel']=_0x24217d[_0x4312('0x73')];_0x24217d['message']['event']='accept';return respondWithRpcPromise('EventManager',_0x4312('0x74'),{'event':_0x4312('0x75'),'message':_['merge'](_0x24217d[_0x4312('0x28')],JSON['parse'](_0x24217d['interaction'][_0x4312('0x76')]))},client9002)[_0x4312('0x34')](function(){return _0x24217d;});}return _0x24217d;}return null;})['then'](respondWithResult(_0xd6e83a,null))['catch'](handleError(_0xd6e83a,null));};var interaction_log=require(_0x4312('0x14'))(_0x4312('0x5a'));exports['reject']=function(_0x56560b,_0x1631bd,_0x46762b){var _0x31e4de={'agent':{},'channel':_0x4312('0x5c')};if(_0x56560b[_0x4312('0x57')]['id']){delete _0x56560b[_0x4312('0x57')]['id'];}_0x56560b['body'][_0x4312('0x5f')]=_0x56560b[_0x4312('0x57')][_0x4312('0x5f')]||_0x56560b[_0x4312('0x60')]['id'];_0x31e4de[_0x4312('0x61')]['id']=_0x56560b['body'][_0x4312('0x5f')];return db[_0x4312('0x3b')][_0x4312('0x55')]({'where':{'id':_0x56560b['params']['id'],'UserId':null}})[_0x4312('0x34')](handleEntityNotFound(_0x1631bd,null))['then'](function(_0x433270){if(_0x433270){_0x31e4de[_0x4312('0x28')]=_0x433270['get']({'plain':!![]});return db[_0x4312('0x77')][_0x4312('0x55')]({'where':{'id':_0x433270[_0x4312('0x78')]}});}return null;})[_0x4312('0x34')](handleEntityNotFound(_0x1631bd,null))[_0x4312('0x34')](function(_0x41ee6f){if(_0x41ee6f){_0x31e4de['interaction']=_0x41ee6f[_0x4312('0x62')]({'plain':!![]});interaction_log['info'](_0x4312('0x79'),_0x56560b[_0x4312('0x60')]['id'],_0x56560b[_0x4312('0x60')][_0x4312('0x38')],_0x56560b[_0x4312('0x60')][_0x4312('0x7a')],_0x31e4de['interaction']['id'],_0x56560b['body']?JSON[_0x4312('0x25')](_0x56560b['body']):_0x4312('0x66'));return respondWithRpcPromise('RejectMessage',_0x4312('0x7b'),_0x31e4de);}return null;})[_0x4312('0x34')](function(_0x166c20){var _0x268fae=_0x4312('0x68')+_0x166c20[_0x4312('0x28')][_0x4312('0x69')];return db[_0x4312('0x6a')][_0x4312('0x3e')](_0x268fae,{'type':db[_0x4312('0x7c')][_0x4312('0x6b')][_0x4312('0x6c')],'raw':!![]})[_0x4312('0x34')](function(_0x566695){return _0x566695;});})['then'](function(_0x4d3128){if(_0x4d3128){_0x31e4de['message'][_0x4312('0x6d')]=_0x4d3128[0x0];if(!_0x56560b[_0x4312('0x57')][_0x4312('0x5f')])return;return db[_0x4312('0x7d')][_0x4312('0x55')]({'where':{'id':_0x56560b['body'][_0x4312('0x5f')],'role':_0x4312('0x61')},'attributes':['id',_0x4312('0x38'),_0x4312('0x6e'),_0x4312('0x6f'),_0x4312('0x70')],'raw':!![]});}return null;})['then'](function(_0x37f603){if(!_0x37f603)return null;_0x31e4de['message']['agent']=_0x37f603;return _0x31e4de;})[_0x4312('0x34')](function(_0x2375ec){if(_0x2375ec){_0x2375ec['message']['interface']=util[_0x4312('0x5d')](_0x4312('0x72'),_0x56560b[_0x4312('0x60')]['name']);_0x2375ec[_0x4312('0x28')][_0x4312('0x73')]=_0x31e4de[_0x4312('0x73')];_0x2375ec[_0x4312('0x28')]['motionChannel']=_0x31e4de['channel'];_0x2375ec[_0x4312('0x28')][_0x4312('0x7e')]='reject';respondWithRpcPromise(_0x4312('0x74'),'EventManager',{'event':'rejectmessage','message':_[_0x4312('0x4a')](_0x31e4de[_0x4312('0x28')],JSON[_0x4312('0x7f')](_0x31e4de[_0x4312('0x63')]['formData']))},client9002);return _0x31e4de;}return null;})['then'](respondWithResult(_0x1631bd,null))[_0x4312('0x29')](handleError(_0x1631bd,null));}; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.events.js b/server/api/chatMessage/chatMessage.events.js new file mode 100644 index 0000000..47e6103 --- /dev/null +++ b/server/api/chatMessage/chatMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x692e=['setMaxListeners','save','update','remove','emit','hasOwnProperty','hook','exports','../../mysqldb','ChatMessage'];(function(_0x4049a7,_0x883b1a){var _0x42702a=function(_0x44252f){while(--_0x44252f){_0x4049a7['push'](_0x4049a7['shift']());}};_0x42702a(++_0x883b1a);}(_0x692e,0x134));var _0xe692=function(_0x443c2d,_0x23570a){_0x443c2d=_0x443c2d-0x0;var _0x2a7eae=_0x692e[_0x443c2d];return _0x2a7eae;};'use strict';var EventEmitter=require('events');var ChatMessage=require(_0xe692('0x0'))['db'][_0xe692('0x1')];var ChatMessageEvents=new EventEmitter();ChatMessageEvents[_0xe692('0x2')](0x0);var events={'afterCreate':_0xe692('0x3'),'afterUpdate':_0xe692('0x4'),'afterDestroy':_0xe692('0x5')};function emitEvent(_0x4d1797){return function(_0x324432,_0x45472b,_0x27e802){ChatMessageEvents[_0xe692('0x6')](_0x4d1797+':'+_0x324432['id'],_0x324432);ChatMessageEvents[_0xe692('0x6')](_0x4d1797,_0x324432);_0x27e802(null);};}for(var e in events){if(events[_0xe692('0x7')](e)){var event=events[e];ChatMessage[_0xe692('0x8')](e,emitEvent(event));}}module[_0xe692('0x9')]=ChatMessageEvents; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.model.js b/server/api/chatMessage/chatMessage.model.js new file mode 100644 index 0000000..4e4049b --- /dev/null +++ b/server/api/chatMessage/chatMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9f1a=['FULLTEXT','models','get','direction','toLowerCase','out','isNil','UserId','ChatInteraction','ChatInteractionId','then','error','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','./chatMessage.attributes','exports','chat_messages','fti_chat_messages','body'];(function(_0x5678b5,_0x1c4aa8){var _0x4c09a5=function(_0x2aa89a){while(--_0x2aa89a){_0x5678b5['push'](_0x5678b5['shift']());}};_0x4c09a5(++_0x1c4aa8);}(_0x9f1a,0x12a));var _0xa9f1=function(_0x4b2c2f,_0x37f8e6){_0x4b2c2f=_0x4b2c2f-0x0;var _0x57d518=_0x9f1a[_0x4b2c2f];return _0x57d518;};'use strict';var _=require(_0xa9f1('0x0'));var util=require(_0xa9f1('0x1'));var logger=require(_0xa9f1('0x2'))(_0xa9f1('0x3'));var moment=require(_0xa9f1('0x4'));var BPromise=require(_0xa9f1('0x5'));var rp=require(_0xa9f1('0x6'));var fs=require('fs');var path=require(_0xa9f1('0x7'));var rimraf=require(_0xa9f1('0x8'));var config=require('../../config/environment');var attributes=require(_0xa9f1('0x9'));module[_0xa9f1('0xa')]=function(_0x2159d0,_0x2084b9){return _0x2159d0['define']('ChatMessage',attributes,{'tableName':_0xa9f1('0xb'),'paranoid':![],'indexes':[{'name':_0xa9f1('0xc'),'fields':[_0xa9f1('0xd')],'type':_0xa9f1('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5b5637,_0x5b0e72,_0x11efb5){var _0x5491fa=_0x2159d0[_0xa9f1('0xf')];var _0x57727a=_0x5b5637[_0xa9f1('0x10')]({'plain':!![]});if(_0x57727a['direction']['toLowerCase']()==='in'||_0x57727a[_0xa9f1('0x11')][_0xa9f1('0x12')]()===_0xa9f1('0x13')&&!_0x57727a['secret']&&!_[_0xa9f1('0x14')](_0x57727a[_0xa9f1('0x15')])){_0x5491fa[_0xa9f1('0x16')]['findOne']({'where':{'id':_0x57727a[_0xa9f1('0x17')]}})[_0xa9f1('0x18')](function(_0x4d4fc4){if(_0x4d4fc4){_0x4d4fc4['update']({'lastMsgAt':_0x57727a['createdAt'],'lastMsgDirection':_0x57727a[_0xa9f1('0x11')]['toLowerCase']()});}})['catch'](function(_0x3753c6){console[_0xa9f1('0x19')](_0x3753c6);});}_0x11efb5();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});}; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.rpc.js b/server/api/chatMessage/chatMessage.rpc.js new file mode 100644 index 0000000..cab0e26 --- /dev/null +++ b/server/api/chatMessage/chatMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x39ed=['code','message','request\x20sent','result','ChatMessage','create','body','raw','then','CreateChatMessage','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','http','redis','defaults','localhost','socket.io-emitter','register','request','info','ChatMessage,\x20%s,\x20%s','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x4ae6ef,_0xc2af80){var _0x3cbb4e=function(_0x569ad5){while(--_0x569ad5){_0x4ae6ef['push'](_0x4ae6ef['shift']());}};_0x3cbb4e(++_0xc2af80);}(_0x39ed,0x155));var _0xd39e=function(_0x512ff7,_0x1725b7){_0x512ff7=_0x512ff7-0x0;var _0xd96f77=_0x39ed[_0x512ff7];return _0xd96f77;};'use strict';var _=require(_0xd39e('0x0'));var util=require(_0xd39e('0x1'));var moment=require(_0xd39e('0x2'));var BPromise=require(_0xd39e('0x3'));var rs=require(_0xd39e('0x4'));var fs=require('fs');var Redis=require(_0xd39e('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xd39e('0x6'))(_0xd39e('0x7'));var config=require(_0xd39e('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0xd39e('0x9')]({'port':0x232a});config[_0xd39e('0xa')]=_[_0xd39e('0xb')](config[_0xd39e('0xa')],{'host':_0xd39e('0xc'),'port':0x18eb});var socket=require(_0xd39e('0xd'))(new Redis(config[_0xd39e('0xa')]));require('./chatMessage.socket')[_0xd39e('0xe')](socket);function respondWithRpcPromise(_0x596d5d,_0x56b0c5,_0x290f3a){return new BPromise(function(_0x57de18,_0x19f6ce){return client[_0xd39e('0xf')](_0x596d5d,_0x290f3a)['then'](function(_0x2aaf02){logger[_0xd39e('0x10')](_0xd39e('0x11'),_0x56b0c5,'request\x20sent');logger[_0xd39e('0x12')](_0xd39e('0x13'),_0x56b0c5,'request\x20sent',JSON[_0xd39e('0x14')](_0x2aaf02));if(_0x2aaf02[_0xd39e('0x15')]){if(_0x2aaf02['error'][_0xd39e('0x16')]===0x1f4){logger['error'](_0xd39e('0x11'),_0x56b0c5,_0x2aaf02[_0xd39e('0x15')][_0xd39e('0x17')]);return _0x19f6ce(_0x2aaf02[_0xd39e('0x15')][_0xd39e('0x17')]);}logger[_0xd39e('0x15')]('ChatMessage,\x20%s,\x20%s',_0x56b0c5,_0x2aaf02[_0xd39e('0x15')][_0xd39e('0x17')]);return _0x57de18(_0x2aaf02['error']['message']);}else{logger['info']('ChatMessage,\x20%s,\x20%s',_0x56b0c5,_0xd39e('0x18'));_0x57de18(_0x2aaf02[_0xd39e('0x19')]['message']);}})['catch'](function(_0x492dc2){logger[_0xd39e('0x15')]('ChatMessage,\x20%s,\x20%s',_0x56b0c5,_0x492dc2);_0x19f6ce(_0x492dc2);});});}exports['CreateChatMessage']=function(_0x1f0a1c){var _0x9427d9=this;return new Promise(function(_0x2c31ee,_0x48ac29){return db[_0xd39e('0x1a')][_0xd39e('0x1b')](_0x1f0a1c[_0xd39e('0x1c')],{'raw':_0x1f0a1c['options']?_0x1f0a1c['options'][_0xd39e('0x1d')]===undefined?!![]:![]:!![]})[_0xd39e('0x1e')](function(_0x47607a){logger['info']('CreateChatMessage',_0x1f0a1c);logger[_0xd39e('0x12')](_0xd39e('0x1f'),_0x1f0a1c,JSON[_0xd39e('0x14')](_0x47607a));_0x2c31ee(_0x47607a);})[_0xd39e('0x20')](function(_0x29c7c5){logger[_0xd39e('0x15')](_0xd39e('0x1f'),_0x29c7c5[_0xd39e('0x17')],_0x1f0a1c);_0x48ac29(_0x9427d9['error'](0x1f4,_0x29c7c5[_0xd39e('0x17')]));});});}; \ No newline at end of file diff --git a/server/api/chatMessage/chatMessage.socket.js b/server/api/chatMessage/chatMessage.socket.js new file mode 100644 index 0000000..b8c1b7a --- /dev/null +++ b/server/api/chatMessage/chatMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf725=['./chatMessage.events','save','remove','update','emit','register','length'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf725,0x7e));var _0x5f72=function(_0xee020d,_0x50c05c){_0xee020d=_0xee020d-0x0;var _0x4d236f=_0xf725[_0xee020d];return _0x4d236f;};'use strict';var ChatMessageEvents=require(_0x5f72('0x0'));var events=[_0x5f72('0x1'),_0x5f72('0x2'),_0x5f72('0x3')];function createListener(_0x1ab380,_0x2fb465){return function(_0x3f7b69){_0x2fb465[_0x5f72('0x4')](_0x1ab380,_0x3f7b69);};}function removeListener(_0x4200ff,_0x17a5bc){return function(){ChatMessageEvents['removeListener'](_0x4200ff,_0x17a5bc);};}exports[_0x5f72('0x5')]=function(_0x14a92d){for(var _0x3f2ca7=0x0,_0x193393=events[_0x5f72('0x6')];_0x3f2ca7<_0x193393;_0x3f2ca7++){var _0x4961d1=events[_0x3f2ca7];var _0x158aa3=createListener('chatMessage:'+_0x4961d1,_0x14a92d);ChatMessageEvents['on'](_0x4961d1,_0x158aa3);}}; \ No newline at end of file diff --git a/server/api/chatMessage/index.js b/server/api/chatMessage/index.js new file mode 100644 index 0000000..980d782 --- /dev/null +++ b/server/api/chatMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x35b6=['put','/:id/accept','accept','reject','destroy','exports','multer','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment','./chatMessage.controller','get','isAuthenticated','index','/describe','describe','/:id','show','post','chat','chatmessage:create'];(function(_0x31bf4a,_0x51eb5f){var _0x2265ec=function(_0x482a5a){while(--_0x482a5a){_0x31bf4a['push'](_0x31bf4a['shift']());}};_0x2265ec(++_0x51eb5f);}(_0x35b6,0xae));var _0x635b=function(_0x52076e,_0x53d6dd){_0x52076e=_0x52076e-0x0;var _0xc00533=_0x35b6[_0x52076e];return _0xc00533;};'use strict';var multer=require(_0x635b('0x0'));var util=require('util');var path=require(_0x635b('0x1'));var timeout=require(_0x635b('0x2'));var express=require('express');var router=express[_0x635b('0x3')]();var fs_extra=require(_0x635b('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x635b('0x5'));var config=require(_0x635b('0x6'));var controller=require(_0x635b('0x7'));router[_0x635b('0x8')]('/',auth[_0x635b('0x9')](),controller[_0x635b('0xa')]);router[_0x635b('0x8')](_0x635b('0xb'),auth[_0x635b('0x9')](),controller[_0x635b('0xc')]);router['get'](_0x635b('0xd'),auth['isAuthenticated'](),controller[_0x635b('0xe')]);router[_0x635b('0xf')]('/',auth[_0x635b('0x9')](),interaction['tracked'](_0x635b('0x10'),_0x635b('0x11')),controller['create']);router[_0x635b('0x12')](_0x635b('0xd'),controller['update']);router[_0x635b('0x12')](_0x635b('0x13'),auth['isAuthenticated'](),controller[_0x635b('0x14')]);router[_0x635b('0x12')]('/:id/reject',auth[_0x635b('0x9')](),controller[_0x635b('0x15')]);router['delete'](_0x635b('0xd'),auth[_0x635b('0x9')](),controller[_0x635b('0x16')]);module[_0x635b('0x17')]=router; \ No newline at end of file diff --git a/server/api/chatOfflineMessage/chatOfflineMessage.attributes.js b/server/api/chatOfflineMessage/chatOfflineMessage.attributes.js new file mode 100644 index 0000000..367beb9 --- /dev/null +++ b/server/api/chatOfflineMessage/chatOfflineMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdb28=['TEXT','medium','sequelize','exports'];(function(_0x1622f9,_0x506fcc){var _0x37087f=function(_0x2cc418){while(--_0x2cc418){_0x1622f9['push'](_0x1622f9['shift']());}};_0x37087f(++_0x506fcc);}(_0xdb28,0x106));var _0x8db2=function(_0x850c46,_0x1bdbf1){_0x850c46=_0x850c46-0x0;var _0x225ac6=_0xdb28[_0x850c46];return _0x225ac6;};'use strict';var Sequelize=require(_0x8db2('0x0'));module[_0x8db2('0x1')]={'body':{'type':Sequelize[_0x8db2('0x2')](_0x8db2('0x3')),'allowNull':![]},'plainBody':{'type':Sequelize['TEXT'](_0x8db2('0x3')),'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/chatOfflineMessage/chatOfflineMessage.controller.js b/server/api/chatOfflineMessage/chatOfflineMessage.controller.js new file mode 100644 index 0000000..c0130c6 --- /dev/null +++ b/server/api/chatOfflineMessage/chatOfflineMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['filter','VIRTUAL','includeAll','include','findAll','rows','show','params','length','merge','options','find','catch','body','Attachment','join','server','attachments','offline-chat','basename','remove','describe','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','index','ChatOfflineMessage','fieldName','type','model','map','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick'];(function(_0x1b828b,_0x344400){var _0x98da1a=function(_0x1a0f5b){while(--_0x1a0f5b){_0x1b828b['push'](_0x1b828b['shift']());}};_0x98da1a(++_0x344400);}(_0x7a54,0x106));var _0x47a5=function(_0x90e71b,_0x3ef8e2){_0x90e71b=_0x90e71b-0x0;var _0xb8a76a=_0x7a54[_0x90e71b];return _0xb8a76a;};'use strict';var emlformat=require(_0x47a5('0x0'));var rimraf=require(_0x47a5('0x1'));var zipdir=require(_0x47a5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x47a5('0x3'));var moment=require(_0x47a5('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x47a5('0x5'));var util=require(_0x47a5('0x6'));var path=require(_0x47a5('0x7'));var sox=require(_0x47a5('0x8'));var csv=require(_0x47a5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x47a5('0xa'));var _=require('lodash');var squel=require(_0x47a5('0xb'));var crypto=require(_0x47a5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x47a5('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x47a5('0xe'));var authService=require(_0x47a5('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x47a5('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x47a5('0x11'));var utils=require(_0x47a5('0x12'));var config=require(_0x47a5('0x13'));var licenseUtil=require(_0x47a5('0x14'));var db=require(_0x47a5('0x15'))['db'];function respondWithStatusCode(_0xd308b8,_0x1eae59){_0x1eae59=_0x1eae59||0xcc;return function(_0x5beb89){if(_0x5beb89){return _0xd308b8[_0x47a5('0x16')](_0x1eae59);}return _0xd308b8[_0x47a5('0x17')](_0x1eae59)[_0x47a5('0x18')]();};}function respondWithResult(_0x711793,_0x139f25){_0x139f25=_0x139f25||0xc8;return function(_0x620ee9){if(_0x620ee9){return _0x711793[_0x47a5('0x17')](_0x139f25)[_0x47a5('0x19')](_0x620ee9);}};}function respondWithFilteredResult(_0x4e99a8,_0x362359){return function(_0x11faf5){if(_0x11faf5){var _0x3b001e=typeof _0x362359[_0x47a5('0x1a')]===_0x47a5('0x1b')&&typeof _0x362359['limit']==='undefined';var _0x138bc0=_0x11faf5['count'];var _0x5247fd=_0x3b001e?0x0:_0x362359[_0x47a5('0x1a')];var _0xaf70a6=_0x3b001e?_0x11faf5[_0x47a5('0x1c')]:_0x362359[_0x47a5('0x1a')]+_0x362359[_0x47a5('0x1d')];var _0x12b98e;if(_0xaf70a6>=_0x138bc0){_0xaf70a6=_0x138bc0;_0x12b98e=0xc8;}else{_0x12b98e=0xce;}_0x4e99a8[_0x47a5('0x17')](_0x12b98e);return _0x4e99a8[_0x47a5('0x1e')](_0x47a5('0x1f'),_0x5247fd+'-'+_0xaf70a6+'/'+_0x138bc0)['json'](_0x11faf5);}return null;};}function patchUpdates(_0x1570bc){return function(_0xf160ba){try{jsonpatch['apply'](_0xf160ba,_0x1570bc,!![]);}catch(_0x2b0360){return BPromise[_0x47a5('0x20')](_0x2b0360);}return _0xf160ba[_0x47a5('0x21')]();};}function saveUpdates(_0x4c5910,_0xb8ae6c){return function(_0x2f142b){if(_0x2f142b){return _0x2f142b[_0x47a5('0x22')](_0x4c5910)[_0x47a5('0x23')](function(_0x5ef1b1){return _0x5ef1b1;});}return null;};}function removeEntity(_0xe2dea9,_0x385687){return function(_0x513981){if(_0x513981){return _0x513981[_0x47a5('0x24')]()[_0x47a5('0x23')](function(){_0xe2dea9[_0x47a5('0x17')](0xcc)[_0x47a5('0x18')]();});}};}function handleEntityNotFound(_0x3abd6a,_0x50bf17){return function(_0x53078a){if(!_0x53078a){_0x3abd6a[_0x47a5('0x16')](0x194);}return _0x53078a;};}function handleError(_0x5686db,_0x1ea9c8){_0x1ea9c8=_0x1ea9c8||0x1f4;return function(_0x5b6c4e){logger[_0x47a5('0x25')](_0x5b6c4e[_0x47a5('0x26')]);if(_0x5b6c4e[_0x47a5('0x27')]){delete _0x5b6c4e[_0x47a5('0x27')];}_0x5686db[_0x47a5('0x17')](_0x1ea9c8)[_0x47a5('0x28')](_0x5b6c4e);};}exports[_0x47a5('0x29')]=function(_0x136b14,_0x16631f){var _0x361bfa={},_0x1127f8={},_0x11a4fa={'count':0x0,'rows':[]};var _0x3ad507=_['map'](db[_0x47a5('0x2a')]['rawAttributes'],function(_0x2ef875){return{'name':_0x2ef875[_0x47a5('0x2b')],'type':_0x2ef875[_0x47a5('0x2c')]['key']};});_0x1127f8[_0x47a5('0x2d')]=_[_0x47a5('0x2e')](_0x3ad507,_0x47a5('0x27'));_0x1127f8[_0x47a5('0x2f')]=_['keys'](_0x136b14['query']);_0x1127f8[_0x47a5('0x30')]=_[_0x47a5('0x31')](_0x1127f8['model'],_0x1127f8['query']);_0x361bfa[_0x47a5('0x32')]=_[_0x47a5('0x31')](_0x1127f8['model'],qs[_0x47a5('0x33')](_0x136b14['query'][_0x47a5('0x33')]));_0x361bfa[_0x47a5('0x32')]=_0x361bfa['attributes']['length']?_0x361bfa[_0x47a5('0x32')]:_0x1127f8['model'];if(!_0x136b14[_0x47a5('0x2f')][_0x47a5('0x34')](_0x47a5('0x35'))){_0x361bfa['limit']=qs[_0x47a5('0x1d')](_0x136b14['query']['limit']);_0x361bfa[_0x47a5('0x1a')]=qs['offset'](_0x136b14[_0x47a5('0x2f')]['offset']);}_0x361bfa[_0x47a5('0x36')]=qs[_0x47a5('0x37')](_0x136b14[_0x47a5('0x2f')][_0x47a5('0x37')]);_0x361bfa[_0x47a5('0x38')]=qs[_0x47a5('0x30')](_[_0x47a5('0x39')](_0x136b14[_0x47a5('0x2f')],_0x1127f8[_0x47a5('0x30')]),_0x3ad507);if(_0x136b14['query'][_0x47a5('0x3a')]){_0x361bfa[_0x47a5('0x38')]=_['merge'](_0x361bfa[_0x47a5('0x38')],{'$or':_[_0x47a5('0x2e')](_0x3ad507,function(_0x1d4348){if(_0x1d4348['type']!==_0x47a5('0x3b')){var _0x10f660={};_0x10f660[_0x1d4348['name']]={'$like':'%'+_0x136b14[_0x47a5('0x2f')][_0x47a5('0x3a')]+'%'};return _0x10f660;}})});}_0x361bfa=_['merge']({},_0x361bfa,_0x136b14['options']);var _0x5ebd8c={'where':_0x361bfa[_0x47a5('0x38')]};return db['ChatOfflineMessage'][_0x47a5('0x1c')](_0x5ebd8c)[_0x47a5('0x23')](function(_0x301a85){_0x11a4fa[_0x47a5('0x1c')]=_0x301a85;if(_0x136b14[_0x47a5('0x2f')][_0x47a5('0x3c')]){_0x361bfa[_0x47a5('0x3d')]=[{'all':!![]}];}return db[_0x47a5('0x2a')][_0x47a5('0x3e')](_0x361bfa);})[_0x47a5('0x23')](function(_0x280500){_0x11a4fa[_0x47a5('0x3f')]=_0x280500;return _0x11a4fa;})[_0x47a5('0x23')](respondWithFilteredResult(_0x16631f,_0x361bfa))['catch'](handleError(_0x16631f,null));};exports[_0x47a5('0x40')]=function(_0x1c36fa,_0x331474){var _0x23bd8d={'raw':!![],'where':{'id':_0x1c36fa[_0x47a5('0x41')]['id']}},_0x586f4f={};_0x586f4f['model']=_['keys'](db['ChatOfflineMessage']['rawAttributes']);_0x586f4f[_0x47a5('0x2f')]=_['keys'](_0x1c36fa[_0x47a5('0x2f')]);_0x586f4f[_0x47a5('0x30')]=_[_0x47a5('0x31')](_0x586f4f['model'],_0x586f4f[_0x47a5('0x2f')]);_0x23bd8d[_0x47a5('0x32')]=_['intersection'](_0x586f4f['model'],qs[_0x47a5('0x33')](_0x1c36fa['query'][_0x47a5('0x33')]));_0x23bd8d[_0x47a5('0x32')]=_0x23bd8d[_0x47a5('0x32')][_0x47a5('0x42')]?_0x23bd8d[_0x47a5('0x32')]:_0x586f4f[_0x47a5('0x2d')];if(_0x1c36fa[_0x47a5('0x2f')][_0x47a5('0x3c')]){_0x23bd8d[_0x47a5('0x3d')]=[{'all':!![]}];}_0x23bd8d=_[_0x47a5('0x43')]({},_0x23bd8d,_0x1c36fa[_0x47a5('0x44')]);return db[_0x47a5('0x2a')][_0x47a5('0x45')](_0x23bd8d)[_0x47a5('0x23')](handleEntityNotFound(_0x331474,null))[_0x47a5('0x23')](respondWithResult(_0x331474,null))[_0x47a5('0x46')](handleError(_0x331474,null));};exports['create']=function(_0x2d38de,_0x23bb04){return db['ChatOfflineMessage']['create'](_0x2d38de[_0x47a5('0x47')],{})['then'](respondWithResult(_0x23bb04,0xc9))[_0x47a5('0x46')](handleError(_0x23bb04,null));};exports[_0x47a5('0x22')]=function(_0x54c35f,_0x4f62d3){if(_0x54c35f[_0x47a5('0x47')]['id']){delete _0x54c35f['body']['id'];}return db[_0x47a5('0x2a')][_0x47a5('0x45')]({'where':{'id':_0x54c35f[_0x47a5('0x41')]['id']}})[_0x47a5('0x23')](handleEntityNotFound(_0x4f62d3,null))[_0x47a5('0x23')](saveUpdates(_0x54c35f[_0x47a5('0x47')],null))[_0x47a5('0x23')](respondWithResult(_0x4f62d3,null))['catch'](handleError(_0x4f62d3,null));};exports['destroy']=function(_0x2dd1db,_0x411230){return db[_0x47a5('0x48')][_0x47a5('0x3e')]({'where':{'ChatOfflineMessageId':_0x2dd1db[_0x47a5('0x41')]['id']},'raw':!![]})[_0x47a5('0x23')](function(_0x249de5){_0x249de5['forEach'](function(_0x45cca5){var _0x1c9a62=path[_0x47a5('0x49')](config['root'],_0x47a5('0x4a'),'files',_0x47a5('0x4b'),_0x47a5('0x4c'),_0x45cca5[_0x47a5('0x4d')]);var _0xf03bd5=fs['existsSync'](_0x1c9a62);if(_0xf03bd5)fs_extra[_0x47a5('0x4e')](_0x1c9a62);});})[_0x47a5('0x23')](function(){return db[_0x47a5('0x2a')][_0x47a5('0x45')]({'where':{'id':_0x2dd1db[_0x47a5('0x41')]['id']},'individualHooks':!![]});})[_0x47a5('0x23')](handleEntityNotFound(_0x411230,null))[_0x47a5('0x23')](removeEntity(_0x411230,null))['catch'](handleError(_0x411230,null));};exports[_0x47a5('0x4f')]=function(_0x43721b,_0x187d7e){return db[_0x47a5('0x2a')][_0x47a5('0x4f')]()[_0x47a5('0x23')](respondWithResult(_0x187d7e,null))['catch'](handleError(_0x187d7e,null));}; \ No newline at end of file diff --git a/server/api/chatOfflineMessage/chatOfflineMessage.events.js b/server/api/chatOfflineMessage/chatOfflineMessage.events.js new file mode 100644 index 0000000..6e5823d --- /dev/null +++ b/server/api/chatOfflineMessage/chatOfflineMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcc21=['../../mysqldb','setMaxListeners','save','update','remove','emit','exports','events'];(function(_0x4c9447,_0xc9ab4b){var _0x5b586e=function(_0x435f7c){while(--_0x435f7c){_0x4c9447['push'](_0x4c9447['shift']());}};_0x5b586e(++_0xc9ab4b);}(_0xcc21,0xc7));var _0x1cc2=function(_0x18c3ca,_0x3c800f){_0x18c3ca=_0x18c3ca-0x0;var _0xa9521a=_0xcc21[_0x18c3ca];return _0xa9521a;};'use strict';var EventEmitter=require(_0x1cc2('0x0'));var ChatOfflineMessage=require(_0x1cc2('0x1'))['db']['ChatOfflineMessage'];var ChatOfflineMessageEvents=new EventEmitter();ChatOfflineMessageEvents[_0x1cc2('0x2')](0x0);var events={'afterCreate':_0x1cc2('0x3'),'afterUpdate':_0x1cc2('0x4'),'afterDestroy':_0x1cc2('0x5')};function emitEvent(_0x46a5a0){return function(_0x538ce5,_0x3e22b1,_0x9ef70f){ChatOfflineMessageEvents[_0x1cc2('0x6')](_0x46a5a0+':'+_0x538ce5['id'],_0x538ce5);ChatOfflineMessageEvents[_0x1cc2('0x6')](_0x46a5a0,_0x538ce5);_0x9ef70f(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];ChatOfflineMessage['hook'](e,emitEvent(event));}}module[_0x1cc2('0x7')]=ChatOfflineMessageEvents; \ No newline at end of file diff --git a/server/api/chatOfflineMessage/chatOfflineMessage.model.js b/server/api/chatOfflineMessage/chatOfflineMessage.model.js new file mode 100644 index 0000000..d18a650 --- /dev/null +++ b/server/api/chatOfflineMessage/chatOfflineMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadac=['./chatOfflineMessage.attributes','exports','define','ChatOfflineMessage','chat_offline_messages','utf8mb4','utf8mb4_unicode_ci'];(function(_0x2521c0,_0x481dbf){var _0x1f22b4=function(_0x1e88d9){while(--_0x1e88d9){_0x2521c0['push'](_0x2521c0['shift']());}};_0x1f22b4(++_0x481dbf);}(_0xadac,0x93));var _0xcada=function(_0x4257b6,_0x2348c7){_0x4257b6=_0x4257b6-0x0;var _0x4ad68c=_0xadac[_0x4257b6];return _0x4ad68c;};'use strict';var attributes=require(_0xcada('0x0'));module[_0xcada('0x1')]=function(_0x4a7e83){return _0x4a7e83[_0xcada('0x2')](_0xcada('0x3'),attributes,{'tableName':_0xcada('0x4'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':_0xcada('0x5'),'collate':_0xcada('0x6')});}; \ No newline at end of file diff --git a/server/api/chatOfflineMessage/chatOfflineMessage.rpc.js b/server/api/chatOfflineMessage/chatOfflineMessage.rpc.js new file mode 100644 index 0000000..4dfb84c --- /dev/null +++ b/server/api/chatOfflineMessage/chatOfflineMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4933=['info','request\x20sent','debug','ChatOfflineMessage,\x20%s,\x20%s,\x20%s','code','error','ChatOfflineMessage,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','then'];(function(_0x7b7606,_0x559570){var _0x1a5edd=function(_0x5cd0df){while(--_0x5cd0df){_0x7b7606['push'](_0x7b7606['shift']());}};_0x1a5edd(++_0x559570);}(_0x4933,0xc2));var _0x3493=function(_0x258919,_0x1754e6){_0x258919=_0x258919-0x0;var _0xfbd68b=_0x4933[_0x258919];return _0xfbd68b;};'use strict';var _=require(_0x3493('0x0'));var util=require(_0x3493('0x1'));var moment=require(_0x3493('0x2'));var BPromise=require(_0x3493('0x3'));var rs=require(_0x3493('0x4'));var fs=require('fs');var Redis=require(_0x3493('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x3493('0x6'));var logger=require(_0x3493('0x7'))('rpc');var config=require(_0x3493('0x8'));var jayson=require(_0x3493('0x9'));var client=jayson['client'][_0x3493('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x47f342,_0x433fa4,_0x37b013){return new BPromise(function(_0xd5082,_0x2979db){return client[_0x3493('0xb')](_0x47f342,_0x37b013)[_0x3493('0xc')](function(_0x5934e4){logger[_0x3493('0xd')]('ChatOfflineMessage,\x20%s,\x20%s',_0x433fa4,_0x3493('0xe'));logger[_0x3493('0xf')](_0x3493('0x10'),_0x433fa4,_0x3493('0xe'),JSON['stringify'](_0x5934e4));if(_0x5934e4['error']){if(_0x5934e4['error'][_0x3493('0x11')]===0x1f4){logger[_0x3493('0x12')](_0x3493('0x13'),_0x433fa4,_0x5934e4[_0x3493('0x12')][_0x3493('0x14')]);return _0x2979db(_0x5934e4[_0x3493('0x12')][_0x3493('0x14')]);}logger[_0x3493('0x12')]('ChatOfflineMessage,\x20%s,\x20%s',_0x433fa4,_0x5934e4[_0x3493('0x12')][_0x3493('0x14')]);return _0xd5082(_0x5934e4[_0x3493('0x12')][_0x3493('0x14')]);}else{logger[_0x3493('0xd')](_0x3493('0x13'),_0x433fa4,'request\x20sent');_0xd5082(_0x5934e4[_0x3493('0x15')][_0x3493('0x14')]);}})[_0x3493('0x16')](function(_0x1c941e){logger[_0x3493('0x12')](_0x3493('0x13'),_0x433fa4,_0x1c941e);_0x2979db(_0x1c941e);});});} \ No newline at end of file diff --git a/server/api/chatOfflineMessage/index.js b/server/api/chatOfflineMessage/index.js new file mode 100644 index 0000000..d022918 --- /dev/null +++ b/server/api/chatOfflineMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcfbd=['get','describe','/:id','show','post','create','put','update','delete','exports','multer','path','connect-timeout','express','fs-extra','../../components/interaction/service','../../config/environment','./chatOfflineMessage.controller','isAuthenticated','index'];(function(_0x3c7081,_0x2082c2){var _0x31ce9c=function(_0x44c936){while(--_0x44c936){_0x3c7081['push'](_0x3c7081['shift']());}};_0x31ce9c(++_0x2082c2);}(_0xcfbd,0x1d6));var _0xdcfb=function(_0x247452,_0x20594f){_0x247452=_0x247452-0x0;var _0x26469f=_0xcfbd[_0x247452];return _0x26469f;};'use strict';var multer=require(_0xdcfb('0x0'));var util=require('util');var path=require(_0xdcfb('0x1'));var timeout=require(_0xdcfb('0x2'));var express=require(_0xdcfb('0x3'));var router=express['Router']();var fs_extra=require(_0xdcfb('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0xdcfb('0x5'));var config=require(_0xdcfb('0x6'));var controller=require(_0xdcfb('0x7'));router['get']('/',auth[_0xdcfb('0x8')](),controller[_0xdcfb('0x9')]);router[_0xdcfb('0xa')]('/describe',auth[_0xdcfb('0x8')](),controller[_0xdcfb('0xb')]);router[_0xdcfb('0xa')](_0xdcfb('0xc'),auth[_0xdcfb('0x8')](),controller[_0xdcfb('0xd')]);router[_0xdcfb('0xe')]('/',auth[_0xdcfb('0x8')](),controller[_0xdcfb('0xf')]);router[_0xdcfb('0x10')]('/:id',auth[_0xdcfb('0x8')](),controller[_0xdcfb('0x11')]);router[_0xdcfb('0x12')]('/:id',auth['isAuthenticated'](),controller['destroy']);module[_0xdcfb('0x13')]=router; \ No newline at end of file diff --git a/server/api/chatProactiveAction/chatProactiveAction.attributes.js b/server/api/chatProactiveAction/chatProactiveAction.attributes.js new file mode 100644 index 0000000..0a3129d --- /dev/null +++ b/server/api/chatProactiveAction/chatProactiveAction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1d33=['exports','STRING','mouseOver','timeout','INTEGER','sequelize'];(function(_0x44b827,_0x1bb1aa){var _0x527342=function(_0x481338){while(--_0x481338){_0x44b827['push'](_0x44b827['shift']());}};_0x527342(++_0x1bb1aa);}(_0x1d33,0x167));var _0x31d3=function(_0x3d7d92,_0x1c27f0){_0x3d7d92=_0x3d7d92-0x0;var _0x3c2300=_0x1d33[_0x3d7d92];return _0x3c2300;};'use strict';var Sequelize=require(_0x31d3('0x0'));module[_0x31d3('0x1')]={'name':{'type':Sequelize[_0x31d3('0x2')],'allowNull':![]},'type':{'type':Sequelize['ENUM'](_0x31d3('0x3'),_0x31d3('0x4')),'defaultValue':_0x31d3('0x3')},'selector':{'type':Sequelize[_0x31d3('0x2')]},'timeout':{'type':Sequelize[_0x31d3('0x5')]}}; \ No newline at end of file diff --git a/server/api/chatProactiveAction/chatProactiveAction.controller.js b/server/api/chatProactiveAction/chatProactiveAction.controller.js new file mode 100644 index 0000000..4bbc081 --- /dev/null +++ b/server/api/chatProactiveAction/chatProactiveAction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa4dc=['bluebird','mustache','util','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','set','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','show','model','keys','rawAttributes','query','intersection','attributes','fields','length','includeAll','include','merge','ChatProactiveAction','find','catch','create','body','params','eml-format','rimraf','request-promise','moment'];(function(_0x32f5d9,_0x4fd417){var _0x22ef8d=function(_0x5c35b3){while(--_0x5c35b3){_0x32f5d9['push'](_0x32f5d9['shift']());}};_0x22ef8d(++_0x4fd417);}(_0xa4dc,0x16a));var _0xca4d=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0xa4dc[_0x19950b];return _0x3c6b41;};'use strict';var emlformat=require(_0xca4d('0x0'));var rimraf=require(_0xca4d('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xca4d('0x2'));var moment=require(_0xca4d('0x3'));var BPromise=require(_0xca4d('0x4'));var Mustache=require(_0xca4d('0x5'));var util=require(_0xca4d('0x6'));var path=require('path');var sox=require(_0xca4d('0x7'));var csv=require(_0xca4d('0x8'));var ejs=require(_0xca4d('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xca4d('0xa'));var squel=require('squel');var crypto=require(_0xca4d('0xb'));var jsforce=require(_0xca4d('0xc'));var deskjs=require(_0xca4d('0xd'));var toCsv=require(_0xca4d('0x8'));var querystring=require('querystring');var Papa=require(_0xca4d('0xe'));var Redis=require(_0xca4d('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xca4d('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xca4d('0x11'));var logger=require(_0xca4d('0x12'))(_0xca4d('0x13'));var utils=require(_0xca4d('0x14'));var config=require(_0xca4d('0x15'));var licenseUtil=require(_0xca4d('0x16'));var db=require(_0xca4d('0x17'))['db'];function respondWithStatusCode(_0x2009d4,_0x5e5163){_0x5e5163=_0x5e5163||0xcc;return function(_0x3fc3ab){if(_0x3fc3ab){return _0x2009d4['sendStatus'](_0x5e5163);}return _0x2009d4[_0xca4d('0x18')](_0x5e5163)[_0xca4d('0x19')]();};}function respondWithResult(_0x2e86ae,_0x4ab15d){_0x4ab15d=_0x4ab15d||0xc8;return function(_0x47285f){if(_0x47285f){return _0x2e86ae['status'](_0x4ab15d)[_0xca4d('0x1a')](_0x47285f);}};}function respondWithFilteredResult(_0x3dddc8,_0x33a7d6){return function(_0x334ab4){if(_0x334ab4){var _0x40e945=typeof _0x33a7d6[_0xca4d('0x1b')]===_0xca4d('0x1c')&&typeof _0x33a7d6['limit']===_0xca4d('0x1c');var _0x20ed84=_0x334ab4[_0xca4d('0x1d')];var _0x388ff7=_0x40e945?0x0:_0x33a7d6[_0xca4d('0x1b')];var _0x395319=_0x40e945?_0x334ab4[_0xca4d('0x1d')]:_0x33a7d6[_0xca4d('0x1b')]+_0x33a7d6[_0xca4d('0x1e')];var _0x5738b6;if(_0x395319>=_0x20ed84){_0x395319=_0x20ed84;_0x5738b6=0xc8;}else{_0x5738b6=0xce;}_0x3dddc8['status'](_0x5738b6);return _0x3dddc8[_0xca4d('0x1f')]('Content-Range',_0x388ff7+'-'+_0x395319+'/'+_0x20ed84)[_0xca4d('0x1a')](_0x334ab4);}return null;};}function patchUpdates(_0x555f0e){return function(_0x375efa){try{jsonpatch[_0xca4d('0x20')](_0x375efa,_0x555f0e,!![]);}catch(_0x35295c){return BPromise[_0xca4d('0x21')](_0x35295c);}return _0x375efa[_0xca4d('0x22')]();};}function saveUpdates(_0x4f692b,_0x58e346){return function(_0xe29bfc){if(_0xe29bfc){return _0xe29bfc[_0xca4d('0x23')](_0x4f692b)[_0xca4d('0x24')](function(_0x390634){return _0x390634;});}return null;};}function removeEntity(_0x5ef722,_0x2515fc){return function(_0x4d7f1a){if(_0x4d7f1a){return _0x4d7f1a[_0xca4d('0x25')]()['then'](function(){_0x5ef722[_0xca4d('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1763f3,_0x3ffe67){return function(_0x3e0210){if(!_0x3e0210){_0x1763f3[_0xca4d('0x26')](0x194);}return _0x3e0210;};}function handleError(_0x57a079,_0x327006){_0x327006=_0x327006||0x1f4;return function(_0xfea1c5){logger[_0xca4d('0x27')](_0xfea1c5[_0xca4d('0x28')]);if(_0xfea1c5[_0xca4d('0x29')]){delete _0xfea1c5[_0xca4d('0x29')];}_0x57a079[_0xca4d('0x18')](_0x327006)[_0xca4d('0x2a')](_0xfea1c5);};}exports[_0xca4d('0x2b')]=function(_0x37d563,_0xfacacb){var _0x319dea={'raw':!![],'where':{'id':_0x37d563['params']['id']}},_0x522be8={};_0x522be8[_0xca4d('0x2c')]=_[_0xca4d('0x2d')](db['ChatProactiveAction'][_0xca4d('0x2e')]);_0x522be8['query']=_[_0xca4d('0x2d')](_0x37d563[_0xca4d('0x2f')]);_0x522be8['filters']=_[_0xca4d('0x30')](_0x522be8[_0xca4d('0x2c')],_0x522be8[_0xca4d('0x2f')]);_0x319dea[_0xca4d('0x31')]=_['intersection'](_0x522be8[_0xca4d('0x2c')],qs[_0xca4d('0x32')](_0x37d563[_0xca4d('0x2f')][_0xca4d('0x32')]));_0x319dea['attributes']=_0x319dea[_0xca4d('0x31')][_0xca4d('0x33')]?_0x319dea[_0xca4d('0x31')]:_0x522be8[_0xca4d('0x2c')];if(_0x37d563['query'][_0xca4d('0x34')]){_0x319dea[_0xca4d('0x35')]=[{'all':!![]}];}_0x319dea=_[_0xca4d('0x36')]({},_0x319dea,_0x37d563['options']);return db[_0xca4d('0x37')][_0xca4d('0x38')](_0x319dea)[_0xca4d('0x24')](handleEntityNotFound(_0xfacacb,null))[_0xca4d('0x24')](respondWithResult(_0xfacacb,null))[_0xca4d('0x39')](handleError(_0xfacacb,null));};exports['create']=function(_0x1659c0,_0x3f673c){return db[_0xca4d('0x37')][_0xca4d('0x3a')](_0x1659c0[_0xca4d('0x3b')],{})['then'](respondWithResult(_0x3f673c,0xc9))[_0xca4d('0x39')](handleError(_0x3f673c,null));};exports[_0xca4d('0x23')]=function(_0x1710c5,_0x3afb53){if(_0x1710c5['body']['id']){delete _0x1710c5['body']['id'];}return db[_0xca4d('0x37')][_0xca4d('0x38')]({'where':{'id':_0x1710c5['params']['id']}})[_0xca4d('0x24')](handleEntityNotFound(_0x3afb53,null))['then'](saveUpdates(_0x1710c5[_0xca4d('0x3b')],null))['then'](respondWithResult(_0x3afb53,null))[_0xca4d('0x39')](handleError(_0x3afb53,null));};exports['destroy']=function(_0x173f09,_0x2e7dd7){return db[_0xca4d('0x37')][_0xca4d('0x38')]({'where':{'id':_0x173f09[_0xca4d('0x3c')]['id']}})['then'](handleEntityNotFound(_0x2e7dd7,null))[_0xca4d('0x24')](removeEntity(_0x2e7dd7,null))[_0xca4d('0x39')](handleError(_0x2e7dd7,null));}; \ No newline at end of file diff --git a/server/api/chatProactiveAction/chatProactiveAction.model.js b/server/api/chatProactiveAction/chatProactiveAction.model.js new file mode 100644 index 0000000..7e6c7eb --- /dev/null +++ b/server/api/chatProactiveAction/chatProactiveAction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcc9e=['request-promise','path','../../config/environment','./chatProactiveAction.attributes','exports','define','ChatProactiveAction','chat_proactive_actions','util','../../config/logger','api','moment','bluebird'];(function(_0x2a306f,_0x3e416f){var _0x319373=function(_0x520f2b){while(--_0x520f2b){_0x2a306f['push'](_0x2a306f['shift']());}};_0x319373(++_0x3e416f);}(_0xcc9e,0x119));var _0xecc9=function(_0xe608b8,_0x35ee07){_0xe608b8=_0xe608b8-0x0;var _0x217aa1=_0xcc9e[_0xe608b8];return _0x217aa1;};'use strict';var _=require('lodash');var util=require(_0xecc9('0x0'));var logger=require(_0xecc9('0x1'))(_0xecc9('0x2'));var moment=require(_0xecc9('0x3'));var BPromise=require(_0xecc9('0x4'));var rp=require(_0xecc9('0x5'));var fs=require('fs');var path=require(_0xecc9('0x6'));var rimraf=require('rimraf');var config=require(_0xecc9('0x7'));var attributes=require(_0xecc9('0x8'));module[_0xecc9('0x9')]=function(_0x2f122a,_0x4303f6){return _0x2f122a[_0xecc9('0xa')](_0xecc9('0xb'),attributes,{'tableName':_0xecc9('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatProactiveAction/chatProactiveAction.rpc.js b/server/api/chatProactiveAction/chatProactiveAction.rpc.js new file mode 100644 index 0000000..50372e5 --- /dev/null +++ b/server/api/chatProactiveAction/chatProactiveAction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd909=['info','ChatProactiveAction,\x20%s,\x20%s','request\x20sent','ChatProactiveAction,\x20%s,\x20%s,\x20%s','error','message','result','catch','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then'];(function(_0x36befb,_0x4ed2f5){var _0x2b0373=function(_0x20a4ce){while(--_0x20a4ce){_0x36befb['push'](_0x36befb['shift']());}};_0x2b0373(++_0x4ed2f5);}(_0xd909,0x1c1));var _0x9d90=function(_0x226175,_0x1b78a0){_0x226175=_0x226175-0x0;var _0x21d7e2=_0xd909[_0x226175];return _0x21d7e2;};'use strict';var _=require('lodash');var util=require(_0x9d90('0x0'));var moment=require(_0x9d90('0x1'));var BPromise=require(_0x9d90('0x2'));var rs=require(_0x9d90('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9d90('0x4'))['db'];var utils=require(_0x9d90('0x5'));var logger=require(_0x9d90('0x6'))(_0x9d90('0x7'));var config=require(_0x9d90('0x8'));var jayson=require(_0x9d90('0x9'));var client=jayson[_0x9d90('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x10930a,_0x1036d5,_0x36ff88){return new BPromise(function(_0x19d78a,_0x3a815b){return client[_0x9d90('0xb')](_0x10930a,_0x36ff88)[_0x9d90('0xc')](function(_0x115e66){logger[_0x9d90('0xd')](_0x9d90('0xe'),_0x1036d5,_0x9d90('0xf'));logger['debug'](_0x9d90('0x10'),_0x1036d5,_0x9d90('0xf'),JSON['stringify'](_0x115e66));if(_0x115e66[_0x9d90('0x11')]){if(_0x115e66['error']['code']===0x1f4){logger[_0x9d90('0x11')](_0x9d90('0xe'),_0x1036d5,_0x115e66[_0x9d90('0x11')][_0x9d90('0x12')]);return _0x3a815b(_0x115e66[_0x9d90('0x11')]['message']);}logger['error'](_0x9d90('0xe'),_0x1036d5,_0x115e66[_0x9d90('0x11')][_0x9d90('0x12')]);return _0x19d78a(_0x115e66[_0x9d90('0x11')][_0x9d90('0x12')]);}else{logger['info'](_0x9d90('0xe'),_0x1036d5,_0x9d90('0xf'));_0x19d78a(_0x115e66[_0x9d90('0x13')][_0x9d90('0x12')]);}})[_0x9d90('0x14')](function(_0x4007d0){logger[_0x9d90('0x11')](_0x9d90('0xe'),_0x1036d5,_0x4007d0);_0x3a815b(_0x4007d0);});});} \ No newline at end of file diff --git a/server/api/chatProactiveAction/index.js b/server/api/chatProactiveAction/index.js new file mode 100644 index 0000000..2e8b7e7 --- /dev/null +++ b/server/api/chatProactiveAction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2d17=['connect-timeout','express','fs-extra','../../components/auth/service','../../config/environment','get','isAuthenticated','show','create','put','update','delete','destroy','exports','multer','util'];(function(_0x31bd20,_0x11de2f){var _0x5f2017=function(_0x3f65a4){while(--_0x3f65a4){_0x31bd20['push'](_0x31bd20['shift']());}};_0x5f2017(++_0x11de2f);}(_0x2d17,0x17e));var _0x72d1=function(_0xe361cf,_0x11db2f){_0xe361cf=_0xe361cf-0x0;var _0x2648b9=_0x2d17[_0xe361cf];return _0x2648b9;};'use strict';var multer=require(_0x72d1('0x0'));var util=require(_0x72d1('0x1'));var path=require('path');var timeout=require(_0x72d1('0x2'));var express=require(_0x72d1('0x3'));var router=express['Router']();var fs_extra=require(_0x72d1('0x4'));var auth=require(_0x72d1('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0x72d1('0x6'));var controller=require('./chatProactiveAction.controller');router[_0x72d1('0x7')]('/:id',auth[_0x72d1('0x8')](),controller[_0x72d1('0x9')]);router['post']('/',auth[_0x72d1('0x8')](),controller[_0x72d1('0xa')]);router[_0x72d1('0xb')]('/:id',auth[_0x72d1('0x8')](),controller[_0x72d1('0xc')]);router[_0x72d1('0xd')]('/:id',auth[_0x72d1('0x8')](),controller[_0x72d1('0xe')]);module[_0x72d1('0xf')]=router; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.attributes.js b/server/api/chatQueue/chatQueue.attributes.js new file mode 100644 index 0000000..ae1aa96 --- /dev/null +++ b/server/api/chatQueue/chatQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf80a=['ENUM','rrmemory','beepall','sequelize','exports','STRING','name'];(function(_0x10c95c,_0x912d30){var _0x598320=function(_0x2fd065){while(--_0x2fd065){_0x10c95c['push'](_0x10c95c['shift']());}};_0x598320(++_0x912d30);}(_0xf80a,0x6c));var _0xaf80=function(_0x29ff42,_0xa8257e){_0x29ff42=_0x29ff42-0x0;var _0x4ff720=_0xf80a[_0x29ff42];return _0x4ff720;};'use strict';var Sequelize=require(_0xaf80('0x0'));module[_0xaf80('0x1')]={'name':{'type':Sequelize[_0xaf80('0x2')],'unique':_0xaf80('0x3'),'allowNull':![],'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'description':{'type':Sequelize[_0xaf80('0x2')]},'timeout':{'type':Sequelize['INTEGER'],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize[_0xaf80('0x4')](_0xaf80('0x5'),_0xaf80('0x6'),'roundrobin')}}; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.controller.js b/server/api/chatQueue/chatQueue.controller.js new file mode 100644 index 0000000..8a061a1 --- /dev/null +++ b/server/api/chatQueue/chatQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc0a7=['./chatQueue.socket','register','jayson/promise','client','http','request','then','info','ChatQueue,\x20%s,\x20%s','debug','ChatQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','get','ChatQueues','UserProfileResource','stack','name','send','map','ChatQueue','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','show','params','length','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','findOne','UserChatQueue','User','findAndCountAll','agent','chatPause','createdAt','rows','format','%s/%s','SIP','updatedAt','getTeams','hasOwnProperty','addTeams','ids','Team','Agents','online','voicePause','interface','flatMap','each','findOrCreate','forEach','emit','userChatQueue:save','select','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','sequelize','toString','QueryTypes','every','includes','union','compact','removeTeams','isEmpty','removeAgents','userChatQueue:remove','addAgents','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0xc0a7,0x1ba));var _0x7c0a=function(_0x1d378a,_0x1a7269){_0x1d378a=_0x1d378a-0x0;var _0x472f87=_0xc0a7[_0x1d378a];return _0x472f87;};'use strict';var emlformat=require(_0x7c0a('0x0'));var rimraf=require(_0x7c0a('0x1'));var zipdir=require(_0x7c0a('0x2'));var jsonpatch=require(_0x7c0a('0x3'));var rp=require(_0x7c0a('0x4'));var moment=require(_0x7c0a('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x7c0a('0x6'));var util=require(_0x7c0a('0x7'));var path=require(_0x7c0a('0x8'));var sox=require(_0x7c0a('0x9'));var csv=require(_0x7c0a('0xa'));var ejs=require(_0x7c0a('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7c0a('0xc'));var squel=require(_0x7c0a('0xd'));var crypto=require(_0x7c0a('0xe'));var jsforce=require(_0x7c0a('0xf'));var deskjs=require(_0x7c0a('0x10'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x7c0a('0x11'));var Redis=require(_0x7c0a('0x12'));var authService=require(_0x7c0a('0x13'));var qs=require(_0x7c0a('0x14'));var as=require(_0x7c0a('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7c0a('0x16'))(_0x7c0a('0x17'));var utils=require(_0x7c0a('0x18'));var config=require(_0x7c0a('0x19'));var licenseUtil=require(_0x7c0a('0x1a'));var db=require(_0x7c0a('0x1b'))['db'];config['redis']=_[_0x7c0a('0x1c')](config[_0x7c0a('0x1d')],{'host':_0x7c0a('0x1e'),'port':0x18eb});var socket=require(_0x7c0a('0x1f'))(new Redis(config[_0x7c0a('0x1d')]));require(_0x7c0a('0x20'))[_0x7c0a('0x21')](socket);var jayson=require(_0x7c0a('0x22'));var client=jayson[_0x7c0a('0x23')][_0x7c0a('0x24')]({'port':0x232a});function respondWithRpcPromise(_0x88933f,_0x5899e6,_0x16a217,_0x48b0f0){return new BPromise(function(_0x56d9db,_0x3a4eb7){var _0x430684=_0x48b0f0||client;return _0x430684[_0x7c0a('0x25')](_0x88933f,_0x16a217)[_0x7c0a('0x26')](function(_0x17310c){logger[_0x7c0a('0x27')](_0x7c0a('0x28'),_0x5899e6,'request\x20sent');logger[_0x7c0a('0x29')](_0x7c0a('0x2a'),_0x5899e6,_0x7c0a('0x2b'),JSON['stringify'](_0x17310c));if(_0x17310c[_0x7c0a('0x2c')]){if(_0x17310c[_0x7c0a('0x2c')][_0x7c0a('0x2d')]===0x1f4){logger['error'](_0x7c0a('0x28'),_0x5899e6,_0x17310c[_0x7c0a('0x2c')][_0x7c0a('0x2e')]);return _0x3a4eb7(_0x17310c['error'][_0x7c0a('0x2e')]);}logger[_0x7c0a('0x2c')](_0x7c0a('0x28'),_0x5899e6,_0x17310c[_0x7c0a('0x2c')][_0x7c0a('0x2e')]);return _0x56d9db(_0x17310c[_0x7c0a('0x2c')][_0x7c0a('0x2e')]);}else{logger[_0x7c0a('0x27')](_0x7c0a('0x28'),_0x5899e6,_0x7c0a('0x2b'));_0x56d9db(_0x17310c[_0x7c0a('0x2f')][_0x7c0a('0x2e')]);}})[_0x7c0a('0x30')](function(_0x9f2614){logger[_0x7c0a('0x2c')]('ChatQueue,\x20%s,\x20%s',_0x5899e6,_0x9f2614);_0x3a4eb7(_0x9f2614);});});}function respondWithStatusCode(_0x4eb733,_0x5bb549){_0x5bb549=_0x5bb549||0xcc;return function(_0x129d13){if(_0x129d13){return _0x4eb733[_0x7c0a('0x31')](_0x5bb549);}return _0x4eb733[_0x7c0a('0x32')](_0x5bb549)[_0x7c0a('0x33')]();};}function respondWithResult(_0x2df6f5,_0x55b4e3){_0x55b4e3=_0x55b4e3||0xc8;return function(_0x5bcee7){if(_0x5bcee7){return _0x2df6f5[_0x7c0a('0x32')](_0x55b4e3)[_0x7c0a('0x34')](_0x5bcee7);}};}function respondWithFilteredResult(_0x4cf449,_0x445bdd){return function(_0x5399fd){if(_0x5399fd){var _0x1640ca=typeof _0x445bdd[_0x7c0a('0x35')]===_0x7c0a('0x36')&&typeof _0x445bdd[_0x7c0a('0x37')]===_0x7c0a('0x36');var _0x2e1cb5=_0x5399fd[_0x7c0a('0x38')];var _0x43190c=_0x1640ca?0x0:_0x445bdd[_0x7c0a('0x35')];var _0x2ead92=_0x1640ca?_0x5399fd[_0x7c0a('0x38')]:_0x445bdd[_0x7c0a('0x35')]+_0x445bdd[_0x7c0a('0x37')];var _0x28c25c;if(_0x2ead92>=_0x2e1cb5){_0x2ead92=_0x2e1cb5;_0x28c25c=0xc8;}else{_0x28c25c=0xce;}_0x4cf449['status'](_0x28c25c);return _0x4cf449[_0x7c0a('0x39')](_0x7c0a('0x3a'),_0x43190c+'-'+_0x2ead92+'/'+_0x2e1cb5)['json'](_0x5399fd);}return null;};}function patchUpdates(_0x1d5223){return function(_0x346d46){try{jsonpatch[_0x7c0a('0x3b')](_0x346d46,_0x1d5223,!![]);}catch(_0x211f4d){return BPromise[_0x7c0a('0x3c')](_0x211f4d);}return _0x346d46[_0x7c0a('0x3d')]();};}function saveUpdates(_0x313a36,_0x32da89){return function(_0x2ef130){if(_0x2ef130){return _0x2ef130[_0x7c0a('0x3e')](_0x313a36)[_0x7c0a('0x26')](function(_0x5a4fc6){return _0x5a4fc6;});}return null;};}function removeEntity(_0x118faa,_0x38a919){return function(_0x14113a){if(_0x14113a){return _0x14113a[_0x7c0a('0x3f')]()[_0x7c0a('0x26')](function(){var _0xb6d835=_0x14113a[_0x7c0a('0x40')]({'plain':!![]});var _0x2a3e6d=_0x7c0a('0x41');return db[_0x7c0a('0x42')][_0x7c0a('0x3f')]({'where':{'type':_0x2a3e6d,'resourceId':_0xb6d835['id']}})[_0x7c0a('0x26')](function(){return _0x14113a;});})[_0x7c0a('0x26')](function(){_0x118faa['status'](0xcc)[_0x7c0a('0x33')]();});}};}function handleEntityNotFound(_0x288525,_0x385a79){return function(_0x38a09f){if(!_0x38a09f){_0x288525['sendStatus'](0x194);}return _0x38a09f;};}function handleError(_0x518412,_0x1d2323){_0x1d2323=_0x1d2323||0x1f4;return function(_0x385952){logger[_0x7c0a('0x2c')](_0x385952[_0x7c0a('0x43')]);if(_0x385952[_0x7c0a('0x44')]){delete _0x385952[_0x7c0a('0x44')];}_0x518412[_0x7c0a('0x32')](_0x1d2323)[_0x7c0a('0x45')](_0x385952);};}exports['index']=function(_0x2cbb45,_0x35392d){var _0x11d22c={},_0x2fcbfb={},_0x1cf8ba={'count':0x0,'rows':[]};var _0x113b35=_[_0x7c0a('0x46')](db[_0x7c0a('0x47')][_0x7c0a('0x48')],function(_0x1464c2){return{'name':_0x1464c2[_0x7c0a('0x49')],'type':_0x1464c2[_0x7c0a('0x4a')][_0x7c0a('0x4b')]};});_0x2fcbfb['model']=_['map'](_0x113b35,_0x7c0a('0x44'));_0x2fcbfb[_0x7c0a('0x4c')]=_[_0x7c0a('0x4d')](_0x2cbb45[_0x7c0a('0x4c')]);_0x2fcbfb[_0x7c0a('0x4e')]=_[_0x7c0a('0x4f')](_0x2fcbfb['model'],_0x2fcbfb['query']);_0x11d22c['attributes']=_['intersection'](_0x2fcbfb[_0x7c0a('0x50')],qs[_0x7c0a('0x51')](_0x2cbb45[_0x7c0a('0x4c')][_0x7c0a('0x51')]));_0x11d22c[_0x7c0a('0x52')]=_0x11d22c[_0x7c0a('0x52')]['length']?_0x11d22c[_0x7c0a('0x52')]:_0x2fcbfb[_0x7c0a('0x50')];if(!_0x2cbb45[_0x7c0a('0x4c')]['hasOwnProperty'](_0x7c0a('0x53'))){_0x11d22c['limit']=qs[_0x7c0a('0x37')](_0x2cbb45[_0x7c0a('0x4c')][_0x7c0a('0x37')]);_0x11d22c[_0x7c0a('0x35')]=qs[_0x7c0a('0x35')](_0x2cbb45[_0x7c0a('0x4c')][_0x7c0a('0x35')]);}_0x11d22c[_0x7c0a('0x54')]=qs[_0x7c0a('0x55')](_0x2cbb45[_0x7c0a('0x4c')][_0x7c0a('0x55')]);_0x11d22c[_0x7c0a('0x56')]=qs[_0x7c0a('0x4e')](_[_0x7c0a('0x57')](_0x2cbb45[_0x7c0a('0x4c')],_0x2fcbfb[_0x7c0a('0x4e')]),_0x113b35);if(_0x2cbb45[_0x7c0a('0x4c')][_0x7c0a('0x58')]){_0x11d22c[_0x7c0a('0x56')]=_[_0x7c0a('0x59')](_0x11d22c[_0x7c0a('0x56')],{'$or':_[_0x7c0a('0x46')](_0x113b35,function(_0x101ae1){if(_0x101ae1[_0x7c0a('0x4a')]!==_0x7c0a('0x5a')){var _0x27d473={};_0x27d473[_0x101ae1[_0x7c0a('0x44')]]={'$like':'%'+_0x2cbb45[_0x7c0a('0x4c')]['filter']+'%'};return _0x27d473;}})});}_0x11d22c=_[_0x7c0a('0x59')]({},_0x11d22c,_0x2cbb45[_0x7c0a('0x5b')]);var _0x1975c1={'where':_0x11d22c[_0x7c0a('0x56')]};return db['ChatQueue']['count'](_0x1975c1)['then'](function(_0x52b7cd){_0x1cf8ba[_0x7c0a('0x38')]=_0x52b7cd;if(_0x2cbb45[_0x7c0a('0x4c')]['includeAll']){_0x11d22c[_0x7c0a('0x5c')]=[{'all':!![]}];}return db[_0x7c0a('0x47')][_0x7c0a('0x5d')](_0x11d22c);})[_0x7c0a('0x26')](function(_0x46a221){_0x1cf8ba['rows']=_0x46a221;return _0x1cf8ba;})[_0x7c0a('0x26')](respondWithFilteredResult(_0x35392d,_0x11d22c))['catch'](handleError(_0x35392d,null));};exports[_0x7c0a('0x5e')]=function(_0x455457,_0x4cc93d){var _0x4f9fae={'raw':!![],'where':{'id':_0x455457[_0x7c0a('0x5f')]['id']}},_0x5f0a16={};_0x5f0a16[_0x7c0a('0x50')]=_[_0x7c0a('0x4d')](db[_0x7c0a('0x47')][_0x7c0a('0x48')]);_0x5f0a16[_0x7c0a('0x4c')]=_[_0x7c0a('0x4d')](_0x455457[_0x7c0a('0x4c')]);_0x5f0a16[_0x7c0a('0x4e')]=_[_0x7c0a('0x4f')](_0x5f0a16[_0x7c0a('0x50')],_0x5f0a16[_0x7c0a('0x4c')]);_0x4f9fae[_0x7c0a('0x52')]=_[_0x7c0a('0x4f')](_0x5f0a16[_0x7c0a('0x50')],qs[_0x7c0a('0x51')](_0x455457[_0x7c0a('0x4c')][_0x7c0a('0x51')]));_0x4f9fae[_0x7c0a('0x52')]=_0x4f9fae['attributes'][_0x7c0a('0x60')]?_0x4f9fae[_0x7c0a('0x52')]:_0x5f0a16[_0x7c0a('0x50')];if(_0x455457[_0x7c0a('0x4c')][_0x7c0a('0x61')]){_0x4f9fae['include']=[{'all':!![]}];}_0x4f9fae=_['merge']({},_0x4f9fae,_0x455457['options']);return db[_0x7c0a('0x47')][_0x7c0a('0x62')](_0x4f9fae)[_0x7c0a('0x26')](handleEntityNotFound(_0x4cc93d,null))[_0x7c0a('0x26')](respondWithResult(_0x4cc93d,null))[_0x7c0a('0x30')](handleError(_0x4cc93d,null));};exports[_0x7c0a('0x63')]=function(_0x450691,_0x17dcd5){return db['ChatQueue'][_0x7c0a('0x63')](_0x450691['body'],{})[_0x7c0a('0x26')](function(_0x5c9860){var _0x15d290=_0x450691[_0x7c0a('0x64')][_0x7c0a('0x40')]({'plain':!![]});if(!_0x15d290)throw new Error(_0x7c0a('0x65'));if(_0x15d290['role']===_0x7c0a('0x64')){var _0x2666ac=_0x5c9860[_0x7c0a('0x40')]({'plain':!![]});var _0x4f6a6c=_0x7c0a('0x41');return db[_0x7c0a('0x66')]['find']({'where':{'name':_0x4f6a6c,'userProfileId':_0x15d290[_0x7c0a('0x67')]},'raw':!![]})['then'](function(_0x23ba90){if(_0x23ba90&&_0x23ba90[_0x7c0a('0x68')]===0x0){return db[_0x7c0a('0x42')]['create']({'name':_0x2666ac[_0x7c0a('0x44')],'resourceId':_0x2666ac['id'],'type':_0x23ba90[_0x7c0a('0x44')],'sectionId':_0x23ba90['id']},{})['then'](function(){return _0x5c9860;});}else{return _0x5c9860;}})[_0x7c0a('0x30')](function(_0x2e0ff8){logger[_0x7c0a('0x2c')](_0x7c0a('0x69'),_0x2e0ff8);throw _0x2e0ff8;});}return _0x5c9860;})[_0x7c0a('0x26')](respondWithResult(_0x17dcd5,0xc9))[_0x7c0a('0x30')](handleError(_0x17dcd5,null));};exports[_0x7c0a('0x3e')]=function(_0xf09dac,_0x26a833){if(_0xf09dac[_0x7c0a('0x6a')]['id']){delete _0xf09dac['body']['id'];}return db[_0x7c0a('0x47')][_0x7c0a('0x62')]({'where':{'id':_0xf09dac[_0x7c0a('0x5f')]['id']}})[_0x7c0a('0x26')](handleEntityNotFound(_0x26a833,null))[_0x7c0a('0x26')](saveUpdates(_0xf09dac['body'],null))[_0x7c0a('0x26')](respondWithResult(_0x26a833,null))[_0x7c0a('0x30')](handleError(_0x26a833,null));};exports[_0x7c0a('0x3f')]=function(_0x1f01d2,_0x1663f6){return db[_0x7c0a('0x47')][_0x7c0a('0x62')]({'where':{'id':_0x1f01d2[_0x7c0a('0x5f')]['id']}})['then'](handleEntityNotFound(_0x1663f6,null))[_0x7c0a('0x26')](removeEntity(_0x1663f6,null))[_0x7c0a('0x30')](handleError(_0x1663f6,null));};exports[_0x7c0a('0x6b')]=function(_0x6fbbaa,_0xd11216){return db[_0x7c0a('0x47')]['describe']()[_0x7c0a('0x26')](respondWithResult(_0xd11216,null))[_0x7c0a('0x30')](handleError(_0xd11216,null));};exports['getMembers']=function(_0x2c15f4,_0x26bd3a,_0x43ba11){var _0x2342ed={'raw':!![],'where':{}},_0x118ae0={},_0x4e9379;return db[_0x7c0a('0x47')][_0x7c0a('0x6c')]({'where':{'id':_0x2c15f4[_0x7c0a('0x5f')]['id']}})['then'](handleEntityNotFound(_0x26bd3a,null))['then'](function(_0x2f300d){if(_0x2f300d){_0x4e9379=_0x2f300d[_0x7c0a('0x40')]({'plain':!![]});_0x118ae0[_0x7c0a('0x50')]=_[_0x7c0a('0x4d')](db[_0x7c0a('0x6d')][_0x7c0a('0x48')]);_0x118ae0[_0x7c0a('0x4c')]=_[_0x7c0a('0x4d')](_0x2c15f4['query']);_0x118ae0['filters']=_[_0x7c0a('0x4f')](_0x118ae0[_0x7c0a('0x50')],_0x118ae0['query']);_0x2342ed[_0x7c0a('0x52')]=_[_0x7c0a('0x4f')](_0x118ae0[_0x7c0a('0x50')],qs[_0x7c0a('0x51')](_0x2c15f4['query'][_0x7c0a('0x51')]));_0x2342ed[_0x7c0a('0x52')]=_0x2342ed[_0x7c0a('0x52')]['length']?_0x2342ed['attributes']:_0x118ae0['model'];if(!_0x2c15f4[_0x7c0a('0x4c')]['hasOwnProperty'](_0x7c0a('0x53'))){_0x2342ed[_0x7c0a('0x37')]=qs[_0x7c0a('0x37')](_0x2c15f4[_0x7c0a('0x4c')][_0x7c0a('0x37')]);_0x2342ed['offset']=qs[_0x7c0a('0x35')](_0x2c15f4['query'][_0x7c0a('0x35')]);}_0x2342ed[_0x7c0a('0x54')]=qs['sort'](_0x2c15f4['query']['sort']);_0x2342ed[_0x7c0a('0x56')]=qs[_0x7c0a('0x4e')](_[_0x7c0a('0x57')](_0x2c15f4[_0x7c0a('0x4c')],_0x118ae0[_0x7c0a('0x4e')]));_0x2342ed['where']['ChatQueueId']=_0x2f300d['id'];if(_0x2c15f4['query'][_0x7c0a('0x58')]){_0x2342ed[_0x7c0a('0x56')]=_[_0x7c0a('0x59')](_0x2342ed[_0x7c0a('0x56')],{'$or':_['map'](_0x2342ed[_0x7c0a('0x52')],function(_0x4ef8c4){var _0x3b5c17={};_0x3b5c17[_0x4ef8c4]={'$like':'%'+_0x2c15f4['query'][_0x7c0a('0x58')]+'%'};return _0x3b5c17;})});}_0x2342ed=_[_0x7c0a('0x59')]({},_0x2342ed,_0x2c15f4['options']);return db[_0x7c0a('0x6d')][_0x7c0a('0x5d')](_0x2342ed);}})[_0x7c0a('0x26')](function(_0x4e1630){if(_0x4e1630){return db[_0x7c0a('0x6e')][_0x7c0a('0x6f')]({'where':{'id':_[_0x7c0a('0x46')](_0x4e1630,'UserId'),'role':_0x7c0a('0x70')},'attributes':['id',_0x7c0a('0x44'),_0x7c0a('0x71'),'updatedAt',_0x7c0a('0x72')]});}})[_0x7c0a('0x26')](function(_0x37dd01){if(_0x37dd01){return{'count':_0x37dd01['count'],'rows':_[_0x7c0a('0x46')](_0x37dd01[_0x7c0a('0x73')],function(_0x3bc6f3){return{'membername':_0x3bc6f3[_0x7c0a('0x44')],'UserId':_0x3bc6f3['id'],'queue_name':_0x4e9379[_0x7c0a('0x44')],'ChatQueueId':_0x4e9379['id'],'interface':util[_0x7c0a('0x74')](_0x7c0a('0x75'),_0x7c0a('0x76'),_0x3bc6f3[_0x7c0a('0x44')]),'penalty':0x0,'paused':_0x3bc6f3[_0x7c0a('0x71')],'createdAt':_0x3bc6f3[_0x7c0a('0x72')],'updatedAt':_0x3bc6f3[_0x7c0a('0x77')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x7c0a('0x26')](respondWithFilteredResult(_0x26bd3a,_0x2342ed))[_0x7c0a('0x30')](handleError(_0x26bd3a,null));};exports[_0x7c0a('0x78')]=function(_0x1f1988,_0x216641,_0x38ec7f){var _0x2cfb77={};var _0x31f030={};var _0x3cb93c;var _0x447f02;return db[_0x7c0a('0x47')][_0x7c0a('0x6c')]({'where':{'id':_0x1f1988[_0x7c0a('0x5f')]['id']}})[_0x7c0a('0x26')](handleEntityNotFound(_0x216641,null))[_0x7c0a('0x26')](function(_0x34247e){if(_0x34247e){_0x3cb93c=_0x34247e;_0x31f030['model']=_[_0x7c0a('0x4d')](db['Team'][_0x7c0a('0x48')]);_0x31f030[_0x7c0a('0x4c')]=_[_0x7c0a('0x4d')](_0x1f1988[_0x7c0a('0x4c')]);_0x31f030[_0x7c0a('0x4e')]=_[_0x7c0a('0x4f')](_0x31f030[_0x7c0a('0x50')],_0x31f030[_0x7c0a('0x4c')]);_0x2cfb77[_0x7c0a('0x52')]=_[_0x7c0a('0x4f')](_0x31f030[_0x7c0a('0x50')],qs[_0x7c0a('0x51')](_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x51')]));_0x2cfb77[_0x7c0a('0x52')]=_0x2cfb77['attributes'][_0x7c0a('0x60')]?_0x2cfb77[_0x7c0a('0x52')]:_0x31f030['model'];_0x2cfb77[_0x7c0a('0x54')]=qs[_0x7c0a('0x55')](_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x55')]);_0x2cfb77[_0x7c0a('0x56')]=qs[_0x7c0a('0x4e')](_[_0x7c0a('0x57')](_0x1f1988[_0x7c0a('0x4c')],_0x31f030[_0x7c0a('0x4e')]));if(_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x58')]){_0x2cfb77['where']=_[_0x7c0a('0x59')](_0x2cfb77['where'],{'$or':_[_0x7c0a('0x46')](_0x2cfb77['attributes'],function(_0x555ec4){var _0x1dc01a={};_0x1dc01a[_0x555ec4]={'$like':'%'+_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x58')]+'%'};return _0x1dc01a;})});}_0x2cfb77=_[_0x7c0a('0x59')]({},_0x2cfb77,_0x1f1988['options']);return _0x3cb93c[_0x7c0a('0x78')](_0x2cfb77);}})['then'](function(_0xb18065){if(_0xb18065){_0x447f02=_0xb18065[_0x7c0a('0x60')];if(!_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x79')](_0x7c0a('0x53'))){_0x2cfb77[_0x7c0a('0x37')]=qs[_0x7c0a('0x37')](_0x1f1988[_0x7c0a('0x4c')]['limit']);_0x2cfb77[_0x7c0a('0x35')]=qs[_0x7c0a('0x35')](_0x1f1988[_0x7c0a('0x4c')][_0x7c0a('0x35')]);}return _0x3cb93c['getTeams'](_0x2cfb77);}})[_0x7c0a('0x26')](function(_0x4340c3){if(_0x4340c3){return _0x4340c3?{'count':_0x447f02,'rows':_0x4340c3}:null;}})['then'](respondWithResult(_0x216641,null))[_0x7c0a('0x30')](handleError(_0x216641,null));};exports[_0x7c0a('0x7a')]=function(_0x3c0058,_0x3b2701,_0x4978da){var _0x7658a8=_0x3c0058[_0x7c0a('0x6a')][_0x7c0a('0x7b')];return db[_0x7c0a('0x7c')][_0x7c0a('0x5d')]({'where':{'id':_0x7658a8},'attributes':['id'],'include':[{'model':db[_0x7c0a('0x6e')],'as':_0x7c0a('0x7d'),'attributes':['id',_0x7c0a('0x44'),_0x7c0a('0x7e'),_0x7c0a('0x7f'),_0x7c0a('0x80')],'raw':!![]}]})['then'](function(_0x579cb3){if(_0x579cb3){var _0xb643ea=_[_0x7c0a('0x81')](_0x579cb3,function(_0x3bae40){var _0xe82f32=_0x3bae40[_0x7c0a('0x40')]({'plain':!![]});return _0xe82f32['Agents'];});return db[_0x7c0a('0x47')][_0x7c0a('0x62')]({'where':{'id':_0x3c0058['params']['id']}})[_0x7c0a('0x26')](function(_0xeff6ac){return db['sequelize']['transaction'](function(_0x26b310){return _0xeff6ac['addTeams'](_0x7658a8,{'transaction':_0x26b310})[_0x7c0a('0x26')](function(){return BPromise[_0x7c0a('0x82')](_0xb643ea,function(_0x10f1b3){return db[_0x7c0a('0x6d')][_0x7c0a('0x83')]({'where':{'UserId':_0x10f1b3['id'],'ChatQueueId':_0x3c0058[_0x7c0a('0x5f')]['id']},'transaction':_0x26b310});});})['then'](function(){_0xb643ea[_0x7c0a('0x84')](function(_0x66dd83){socket[_0x7c0a('0x85')](_0x7c0a('0x86'),{'UserId':_0x66dd83['id'],'ChatQueueId':_0xeff6ac['id']});});});});});}})['then'](respondWithStatusCode(_0x3b2701,null))['catch'](handleError(_0x3b2701,null));};exports['removeTeams']=function(_0x85553c,_0x1b14bf,_0x51955f){return db[_0x7c0a('0x7c')][_0x7c0a('0x5d')]({'where':{'id':_0x85553c[_0x7c0a('0x4c')][_0x7c0a('0x7b')]},'attributes':['id'],'include':[{'model':db[_0x7c0a('0x6e')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x1b14bf,null))[_0x7c0a('0x26')](function(_0x4bb514){var _0x52a10e=_[_0x7c0a('0x46')](_0x4bb514,'id');var _0x11c5b3=[];var _0x33382b=[];var _0x4bfdb3=squel[_0x7c0a('0x87')]();_0x4bfdb3[_0x7c0a('0x88')](_0x7c0a('0x89'))[_0x7c0a('0x8a')](_0x7c0a('0x8b'),'tq')[_0x7c0a('0x8c')](_0x7c0a('0x8d'),'ut',_0x7c0a('0x8e'))[_0x7c0a('0x56')](_0x7c0a('0x8f'),_0x85553c[_0x7c0a('0x5f')]['id']);for(var _0xe89ebf=0x0;_0xe89ebf<_0x4bb514[_0x7c0a('0x60')];_0xe89ebf+=0x1){let _0x380e70=_0x4bb514[_0xe89ebf];for(var _0x42d4cf=0x0;_0x42d4cf<_0x380e70[_0x7c0a('0x7d')][_0x7c0a('0x60')];_0x42d4cf+=0x1){let _0x194837=_0x380e70['Agents'][_0x42d4cf];var _0x37e4d1=_0x4bfdb3['clone']();_0x37e4d1[_0x7c0a('0x56')]('ut.UserId\x20=\x20?',_0x194837['id']);_0x33382b['push'](db[_0x7c0a('0x90')][_0x7c0a('0x4c')](_0x37e4d1[_0x7c0a('0x91')](),{'type':db[_0x7c0a('0x90')][_0x7c0a('0x92')]['SELECT']})[_0x7c0a('0x26')](function(_0x4233e1){if(_0x4233e1[_0x7c0a('0x60')]===0x1){return _0x194837['id'];}else{var _0x4f5444=_[_0x7c0a('0x93')](_['map'](_0x4233e1,'TeamId'),function(_0x2cdf81){return _[_0x7c0a('0x94')](_0x52a10e,_0x2cdf81);});if(_0x4f5444){return _0x194837['id'];}}}));}}return BPromise['all'](_0x33382b)[_0x7c0a('0x26')](function(_0x3ab0f5){_0x11c5b3=_(_0x11c5b3)[_0x7c0a('0x95')](_0x3ab0f5)[_0x7c0a('0x96')]()['value']();return db['ChatQueue']['find']({'where':{'id':_0x85553c['params']['id']}})[_0x7c0a('0x26')](function(_0x3cce7f){return db[_0x7c0a('0x90')]['transaction'](function(_0x449028){return _0x3cce7f[_0x7c0a('0x97')](_0x85553c[_0x7c0a('0x4c')][_0x7c0a('0x7b')],{'transaction':_0x449028})['then'](function(){if(!_[_0x7c0a('0x98')](_0x11c5b3)){return _0x3cce7f[_0x7c0a('0x99')](_0x11c5b3,{'transaction':_0x449028});}})[_0x7c0a('0x26')](function(){_0x11c5b3[_0x7c0a('0x84')](function(_0x5ef1af){socket[_0x7c0a('0x85')](_0x7c0a('0x9a'),{'UserId':_0x5ef1af,'ChatQueueId':_0x3cce7f['id']});});});});});});})[_0x7c0a('0x26')](respondWithStatusCode(_0x1b14bf,null))[_0x7c0a('0x30')](handleError(_0x1b14bf,null));};exports[_0x7c0a('0x9b')]=function(_0x179110,_0xb0d25b,_0x4b0889){return db['ChatQueue'][_0x7c0a('0x62')]({'where':{'id':_0x179110[_0x7c0a('0x5f')]['id']}})[_0x7c0a('0x26')](handleEntityNotFound(_0xb0d25b,null))[_0x7c0a('0x26')](function(_0x50a070){if(_0x50a070){return _0x50a070['addAgents'](_0x179110[_0x7c0a('0x6a')]['ids'],_['omit'](_0x179110['body'],[_0x7c0a('0x7b'),'id'])||{})['spread'](function(_0x17d7c0){for(var _0x344bc4=0x0;_0x344bc4<_0x179110[_0x7c0a('0x6a')][_0x7c0a('0x7b')]['length'];_0x344bc4+=0x1){socket['emit'](_0x7c0a('0x86'),{'UserId':Number(_0x179110[_0x7c0a('0x6a')][_0x7c0a('0x7b')][_0x344bc4]),'ChatQueueId':Number(_0x179110[_0x7c0a('0x5f')]['id'])});}return _0x17d7c0;});}})['then'](respondWithResult(_0xb0d25b,null))['catch'](handleError(_0xb0d25b,null));};exports[_0x7c0a('0x99')]=function(_0xa9f568,_0x4b4df9,_0x222605){return db[_0x7c0a('0x47')][_0x7c0a('0x62')]({'where':{'id':_0xa9f568['params']['id']}})['then'](handleEntityNotFound(_0x4b4df9,null))[_0x7c0a('0x26')](function(_0xf03111){if(_0xf03111){return _0xf03111[_0x7c0a('0x99')](_0xa9f568['query'][_0x7c0a('0x7b')])[_0x7c0a('0x26')](function(){if(_[_0x7c0a('0x9c')](_0xa9f568[_0x7c0a('0x4c')][_0x7c0a('0x7b')])){for(var _0x9030fd=0x0;_0x9030fd<_0xa9f568[_0x7c0a('0x4c')]['ids'][_0x7c0a('0x60')];_0x9030fd+=0x1){socket[_0x7c0a('0x85')]('userChatQueue:remove',{'UserId':Number(_0xa9f568['query'][_0x7c0a('0x7b')][_0x9030fd]),'ChatQueueId':Number(_0xa9f568[_0x7c0a('0x5f')]['id'])});}}else{socket[_0x7c0a('0x85')](_0x7c0a('0x9a'),{'UserId':Number(_0xa9f568[_0x7c0a('0x4c')][_0x7c0a('0x7b')]),'ChatQueueId':Number(_0xa9f568[_0x7c0a('0x5f')]['id'])});}});}})[_0x7c0a('0x26')](respondWithStatusCode(_0x4b4df9,null))[_0x7c0a('0x30')](handleError(_0x4b4df9,null));};exports['getAgents']=function(_0x1d6b4b,_0x3f5872,_0x210cc0){var _0x53d65f={};var _0x5081c2={};var _0x180bfb;var _0x38fbc7;return db[_0x7c0a('0x47')][_0x7c0a('0x6c')]({'where':{'id':_0x1d6b4b[_0x7c0a('0x5f')]['id']}})['then'](handleEntityNotFound(_0x3f5872,null))[_0x7c0a('0x26')](function(_0x515b96){if(_0x515b96){_0x180bfb=_0x515b96;_0x5081c2[_0x7c0a('0x50')]=_[_0x7c0a('0x4d')](db[_0x7c0a('0x6e')]['rawAttributes']);_0x5081c2[_0x7c0a('0x4c')]=_['keys'](_0x1d6b4b[_0x7c0a('0x4c')]);_0x5081c2[_0x7c0a('0x4e')]=_[_0x7c0a('0x4f')](_0x5081c2[_0x7c0a('0x50')],_0x5081c2[_0x7c0a('0x4c')]);_0x53d65f[_0x7c0a('0x52')]=_[_0x7c0a('0x4f')](_0x5081c2[_0x7c0a('0x50')],qs[_0x7c0a('0x51')](_0x1d6b4b[_0x7c0a('0x4c')][_0x7c0a('0x51')]));_0x53d65f['attributes']=_0x53d65f[_0x7c0a('0x52')][_0x7c0a('0x60')]?_0x53d65f[_0x7c0a('0x52')]:_0x5081c2[_0x7c0a('0x50')];_0x53d65f['order']=qs['sort'](_0x1d6b4b[_0x7c0a('0x4c')]['sort']);_0x53d65f[_0x7c0a('0x56')]=qs[_0x7c0a('0x4e')](_[_0x7c0a('0x57')](_0x1d6b4b[_0x7c0a('0x4c')],_0x5081c2[_0x7c0a('0x4e')]));if(_0x1d6b4b[_0x7c0a('0x4c')][_0x7c0a('0x58')]){_0x53d65f[_0x7c0a('0x56')]=_[_0x7c0a('0x59')](_0x53d65f[_0x7c0a('0x56')],{'$or':_[_0x7c0a('0x46')](_0x53d65f['attributes'],function(_0x46c1ce){var _0x3a1ec0={};_0x3a1ec0[_0x46c1ce]={'$like':'%'+_0x1d6b4b[_0x7c0a('0x4c')][_0x7c0a('0x58')]+'%'};return _0x3a1ec0;})});}_0x53d65f=_[_0x7c0a('0x59')]({},_0x53d65f,_0x1d6b4b['options']);return _0x180bfb[_0x7c0a('0x9d')](_0x53d65f);}})[_0x7c0a('0x26')](function(_0xcfb445){if(_0xcfb445){_0x38fbc7=_0xcfb445[_0x7c0a('0x60')];if(!_0x1d6b4b[_0x7c0a('0x4c')][_0x7c0a('0x79')](_0x7c0a('0x53'))){_0x53d65f[_0x7c0a('0x37')]=qs[_0x7c0a('0x37')](_0x1d6b4b[_0x7c0a('0x4c')][_0x7c0a('0x37')]);_0x53d65f[_0x7c0a('0x35')]=qs[_0x7c0a('0x35')](_0x1d6b4b[_0x7c0a('0x4c')]['offset']);}return _0x180bfb[_0x7c0a('0x9d')](_0x53d65f);}})[_0x7c0a('0x26')](function(_0x3591e0){if(_0x3591e0){return _0x3591e0?{'count':_0x38fbc7,'rows':_0x3591e0}:null;}})[_0x7c0a('0x26')](respondWithResult(_0x3f5872,null))[_0x7c0a('0x30')](handleError(_0x3f5872,null));}; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.events.js b/server/api/chatQueue/chatQueue.events.js new file mode 100644 index 0000000..8da1c02 --- /dev/null +++ b/server/api/chatQueue/chatQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd13d=['save','update','hasOwnProperty','hook','exports','events','ChatQueue','setMaxListeners'];(function(_0x33b3c7,_0x403382){var _0x4dadc7=function(_0x314e85){while(--_0x314e85){_0x33b3c7['push'](_0x33b3c7['shift']());}};_0x4dadc7(++_0x403382);}(_0xd13d,0x155));var _0xdd13=function(_0x2d74d5,_0x15971b){_0x2d74d5=_0x2d74d5-0x0;var _0x342a67=_0xd13d[_0x2d74d5];return _0x342a67;};'use strict';var EventEmitter=require(_0xdd13('0x0'));var ChatQueue=require('../../mysqldb')['db'][_0xdd13('0x1')];var ChatQueueEvents=new EventEmitter();ChatQueueEvents[_0xdd13('0x2')](0x0);var events={'afterCreate':_0xdd13('0x3'),'afterUpdate':_0xdd13('0x4'),'afterDestroy':'remove'};function emitEvent(_0x577016){return function(_0x40a980,_0x363c43,_0xca2d72){ChatQueueEvents['emit'](_0x577016+':'+_0x40a980['id'],_0x40a980);ChatQueueEvents['emit'](_0x577016,_0x40a980);_0xca2d72(null);};}for(var e in events){if(events[_0xdd13('0x5')](e)){var event=events[e];ChatQueue[_0xdd13('0x6')](e,emitEvent(event));}}module[_0xdd13('0x7')]=ChatQueueEvents; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.model.js b/server/api/chatQueue/chatQueue.model.js new file mode 100644 index 0000000..ff12ece --- /dev/null +++ b/server/api/chatQueue/chatQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1200=['ChatQueue','chat_queues','util','../../config/logger','moment','bluebird','request-promise','rimraf','./chatQueue.attributes','exports','define'];(function(_0x40158f,_0x2d156a){var _0x486d65=function(_0x2e0d46){while(--_0x2e0d46){_0x40158f['push'](_0x40158f['shift']());}};_0x486d65(++_0x2d156a);}(_0x1200,0x16d));var _0x0120=function(_0x45783c,_0x49c56d){_0x45783c=_0x45783c-0x0;var _0x1161da=_0x1200[_0x45783c];return _0x1161da;};'use strict';var _=require('lodash');var util=require(_0x0120('0x0'));var logger=require(_0x0120('0x1'))('api');var moment=require(_0x0120('0x2'));var BPromise=require(_0x0120('0x3'));var rp=require(_0x0120('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0x0120('0x5'));var config=require('../../config/environment');var attributes=require(_0x0120('0x6'));module[_0x0120('0x7')]=function(_0x5019ae,_0x488d7f){return _0x5019ae[_0x0120('0x8')](_0x0120('0x9'),attributes,{'tableName':_0x0120('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.rpc.js b/server/api/chatQueue/chatQueue.rpc.js new file mode 100644 index 0000000..cc8d4e3 --- /dev/null +++ b/server/api/chatQueue/chatQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xafa7=['error','message','result','catch','GetChatQueue','ChatQueue','findAll','options','raw','where','map','include','model','attributes','debug','ShowChatQueue','find','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x15f306,_0x4b7328){var _0x2138bb=function(_0x393e5d){while(--_0x393e5d){_0x15f306['push'](_0x15f306['shift']());}};_0x2138bb(++_0x4b7328);}(_0xafa7,0x122));var _0x7afa=function(_0x4a0e68,_0x45c08c){_0x4a0e68=_0x4a0e68-0x0;var _0x4fb274=_0xafa7[_0x4a0e68];return _0x4fb274;};'use strict';var _=require(_0x7afa('0x0'));var util=require(_0x7afa('0x1'));var moment=require('moment');var BPromise=require(_0x7afa('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7afa('0x3'));var db=require(_0x7afa('0x4'))['db'];var utils=require(_0x7afa('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x7afa('0x6'));var jayson=require(_0x7afa('0x7'));var client=jayson[_0x7afa('0x8')][_0x7afa('0x9')]({'port':0x232a});config[_0x7afa('0xa')]=_[_0x7afa('0xb')](config['redis'],{'host':_0x7afa('0xc'),'port':0x18eb});var socket=require(_0x7afa('0xd'))(new Redis(config[_0x7afa('0xa')]));require(_0x7afa('0xe'))[_0x7afa('0xf')](socket);function respondWithRpcPromise(_0x2ba3dd,_0xb3aee5,_0x4a5f44){return new BPromise(function(_0x2eaa82,_0xde0626){return client[_0x7afa('0x10')](_0x2ba3dd,_0x4a5f44)[_0x7afa('0x11')](function(_0x32f85c){logger[_0x7afa('0x12')](_0x7afa('0x13'),_0xb3aee5,_0x7afa('0x14'));logger['debug']('ChatQueue,\x20%s,\x20%s,\x20%s',_0xb3aee5,'request\x20sent',JSON[_0x7afa('0x15')](_0x32f85c));if(_0x32f85c[_0x7afa('0x16')]){if(_0x32f85c[_0x7afa('0x16')]['code']===0x1f4){logger[_0x7afa('0x16')](_0x7afa('0x13'),_0xb3aee5,_0x32f85c[_0x7afa('0x16')]['message']);return _0xde0626(_0x32f85c['error'][_0x7afa('0x17')]);}logger['error'](_0x7afa('0x13'),_0xb3aee5,_0x32f85c['error']['message']);return _0x2eaa82(_0x32f85c[_0x7afa('0x16')][_0x7afa('0x17')]);}else{logger[_0x7afa('0x12')](_0x7afa('0x13'),_0xb3aee5,'request\x20sent');_0x2eaa82(_0x32f85c[_0x7afa('0x18')][_0x7afa('0x17')]);}})[_0x7afa('0x19')](function(_0x5015fc){logger['error'](_0x7afa('0x13'),_0xb3aee5,_0x5015fc);_0xde0626(_0x5015fc);});});}exports[_0x7afa('0x1a')]=function(_0x4b86b0){var _0x4fc800=this;return new Promise(function(_0x1f1bcf,_0x30aa81){return db[_0x7afa('0x1b')][_0x7afa('0x1c')]({'raw':_0x4b86b0[_0x7afa('0x1d')]?_0x4b86b0['options'][_0x7afa('0x1e')]===undefined?!![]:![]:!![],'where':_0x4b86b0[_0x7afa('0x1d')]?_0x4b86b0[_0x7afa('0x1d')][_0x7afa('0x1f')]||null:null,'attributes':_0x4b86b0[_0x7afa('0x1d')]?_0x4b86b0[_0x7afa('0x1d')]['attributes']||null:null,'limit':_0x4b86b0[_0x7afa('0x1d')]?_0x4b86b0[_0x7afa('0x1d')]['limit']||null:null,'include':_0x4b86b0['options']?_0x4b86b0['options']['include']?_[_0x7afa('0x20')](_0x4b86b0[_0x7afa('0x1d')][_0x7afa('0x21')],function(_0x26d0e0){return{'model':db[_0x26d0e0[_0x7afa('0x22')]],'as':_0x26d0e0['as'],'attributes':_0x26d0e0[_0x7afa('0x23')],'include':_0x26d0e0[_0x7afa('0x21')]?_[_0x7afa('0x20')](_0x26d0e0[_0x7afa('0x21')],function(_0x449c4d){return{'model':db[_0x449c4d[_0x7afa('0x22')]],'as':_0x449c4d['as'],'attributes':_0x449c4d[_0x7afa('0x23')],'include':_0x449c4d[_0x7afa('0x21')]?_['map'](_0x449c4d[_0x7afa('0x21')],function(_0xbb3dff){return{'model':db[_0xbb3dff[_0x7afa('0x22')]],'as':_0xbb3dff['as'],'attributes':_0xbb3dff['attributes']};}):[]};}):[]};}):[]:[]})[_0x7afa('0x11')](function(_0x24e0c){logger[_0x7afa('0x12')]('GetChatQueue',_0x4b86b0);logger[_0x7afa('0x24')](_0x7afa('0x1a'),_0x4b86b0,JSON[_0x7afa('0x15')](_0x24e0c));_0x1f1bcf(_0x24e0c);})['catch'](function(_0x43e3ae){logger[_0x7afa('0x16')](_0x7afa('0x1a'),_0x43e3ae[_0x7afa('0x17')],_0x4b86b0);_0x30aa81(_0x4fc800[_0x7afa('0x16')](0x1f4,_0x43e3ae['message']));});});};exports[_0x7afa('0x25')]=function(_0x599af7){var _0x5c396f=this;return new Promise(function(_0x29c000,_0x169b7b){return db[_0x7afa('0x1b')][_0x7afa('0x26')]({'raw':_0x599af7[_0x7afa('0x1d')]?_0x599af7['options'][_0x7afa('0x1e')]===undefined?!![]:![]:!![],'where':_0x599af7[_0x7afa('0x1d')]?_0x599af7[_0x7afa('0x1d')][_0x7afa('0x1f')]||null:null,'attributes':_0x599af7[_0x7afa('0x1d')]?_0x599af7[_0x7afa('0x1d')][_0x7afa('0x23')]||null:null,'include':_0x599af7[_0x7afa('0x1d')]?_0x599af7[_0x7afa('0x1d')]['include']?_[_0x7afa('0x20')](_0x599af7[_0x7afa('0x1d')]['include'],function(_0x3b49d3){return{'model':db[_0x3b49d3[_0x7afa('0x22')]],'as':_0x3b49d3['as'],'attributes':_0x3b49d3[_0x7afa('0x23')],'include':_0x3b49d3[_0x7afa('0x21')]?_[_0x7afa('0x20')](_0x3b49d3[_0x7afa('0x21')],function(_0xda9fa6){return{'model':db[_0xda9fa6[_0x7afa('0x22')]],'as':_0xda9fa6['as'],'attributes':_0xda9fa6[_0x7afa('0x23')],'include':_0xda9fa6[_0x7afa('0x21')]?_['map'](_0xda9fa6[_0x7afa('0x21')],function(_0x9c0763){return{'model':db[_0x9c0763[_0x7afa('0x22')]],'as':_0x9c0763['as'],'attributes':_0x9c0763['attributes']};}):[]};}):[]};}):[]:[]})[_0x7afa('0x11')](function(_0x433adc){logger[_0x7afa('0x12')]('ShowChatQueue',_0x599af7);logger['debug'](_0x7afa('0x25'),_0x599af7,JSON[_0x7afa('0x15')](_0x433adc));_0x29c000(_0x433adc);})[_0x7afa('0x19')](function(_0x57e9b4){logger['error'](_0x7afa('0x25'),_0x57e9b4[_0x7afa('0x17')],_0x599af7);_0x169b7b(_0x5c396f['error'](0x1f4,_0x57e9b4[_0x7afa('0x17')]));});});}; \ No newline at end of file diff --git a/server/api/chatQueue/chatQueue.socket.js b/server/api/chatQueue/chatQueue.socket.js new file mode 100644 index 0000000..4baf5a9 --- /dev/null +++ b/server/api/chatQueue/chatQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x72b1=['register','length','./chatQueue.events','remove','update','emit','removeListener'];(function(_0xf50820,_0x56f041){var _0x2a9b10=function(_0x33f0f4){while(--_0x33f0f4){_0xf50820['push'](_0xf50820['shift']());}};_0x2a9b10(++_0x56f041);}(_0x72b1,0x16e));var _0x172b=function(_0x2563b8,_0x1b7fa1){_0x2563b8=_0x2563b8-0x0;var _0x1da178=_0x72b1[_0x2563b8];return _0x1da178;};'use strict';var ChatQueueEvents=require(_0x172b('0x0'));var events=['save',_0x172b('0x1'),_0x172b('0x2')];function createListener(_0x42b795,_0x18fd16){return function(_0x23bc7a){_0x18fd16[_0x172b('0x3')](_0x42b795,_0x23bc7a);};}function removeListener(_0x2c1d6e,_0x558038){return function(){ChatQueueEvents[_0x172b('0x4')](_0x2c1d6e,_0x558038);};}exports[_0x172b('0x5')]=function(_0x475fd6){for(var _0x222624=0x0,_0x571994=events[_0x172b('0x6')];_0x222624<_0x571994;_0x222624++){var _0x517363=events[_0x222624];var _0x1f98e9=createListener('chatQueue:'+_0x517363,_0x475fd6);ChatQueueEvents['on'](_0x517363,_0x1f98e9);}}; \ No newline at end of file diff --git a/server/api/chatQueue/index.js b/server/api/chatQueue/index.js new file mode 100644 index 0000000..d05dbd4 --- /dev/null +++ b/server/api/chatQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e74=['../../config/environment','./chatQueue.controller','get','isAuthenticated','index','/describe','describe','/:id','show','getMembers','/:id/teams','getTeams','getAgents','post','addTeams','addAgents','put','delete','removeTeams','/:id/users','removeAgents','exports','multer','path','connect-timeout','express','../../components/auth/service'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x3e74,0x175));var _0x43e7=function(_0x48c15e,_0x3b1130){_0x48c15e=_0x48c15e-0x0;var _0x32f80a=_0x3e74[_0x48c15e];return _0x32f80a;};'use strict';var multer=require(_0x43e7('0x0'));var util=require('util');var path=require(_0x43e7('0x1'));var timeout=require(_0x43e7('0x2'));var express=require(_0x43e7('0x3'));var router=express['Router']();var fs_extra=require('fs-extra');var auth=require(_0x43e7('0x4'));var interaction=require('../../components/interaction/service');var config=require(_0x43e7('0x5'));var controller=require(_0x43e7('0x6'));router[_0x43e7('0x7')]('/',auth[_0x43e7('0x8')](),controller[_0x43e7('0x9')]);router['get'](_0x43e7('0xa'),auth[_0x43e7('0x8')](),controller[_0x43e7('0xb')]);router[_0x43e7('0x7')](_0x43e7('0xc'),auth['isAuthenticated'](),controller[_0x43e7('0xd')]);router['get']('/:id/members',auth[_0x43e7('0x8')](),controller[_0x43e7('0xe')]);router['get'](_0x43e7('0xf'),auth['isAuthenticated'](),controller[_0x43e7('0x10')]);router[_0x43e7('0x7')]('/:id/users',auth[_0x43e7('0x8')](),controller[_0x43e7('0x11')]);router[_0x43e7('0x12')]('/',auth[_0x43e7('0x8')](),controller['create']);router['post'](_0x43e7('0xf'),auth[_0x43e7('0x8')](),controller[_0x43e7('0x13')]);router['post']('/:id/users',auth[_0x43e7('0x8')](),controller[_0x43e7('0x14')]);router[_0x43e7('0x15')](_0x43e7('0xc'),auth['isAuthenticated'](),controller['update']);router[_0x43e7('0x16')](_0x43e7('0xc'),auth[_0x43e7('0x8')](),controller['destroy']);router['delete'](_0x43e7('0xf'),auth[_0x43e7('0x8')](),controller[_0x43e7('0x17')]);router[_0x43e7('0x16')](_0x43e7('0x18'),auth[_0x43e7('0x8')](),controller[_0x43e7('0x19')]);module[_0x43e7('0x1a')]=router; \ No newline at end of file diff --git a/server/api/chatQueueReport/chatQueueReport.attributes.js b/server/api/chatQueueReport/chatQueueReport.attributes.js new file mode 100644 index 0000000..6fe7d32 --- /dev/null +++ b/server/api/chatQueueReport/chatQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb8ba=['sequelize','exports','STRING','DATE','moment'];(function(_0x426560,_0x297102){var _0x1ef7ed=function(_0x15bc67){while(--_0x15bc67){_0x426560['push'](_0x426560['shift']());}};_0x1ef7ed(++_0x297102);}(_0xb8ba,0x6d));var _0xab8b=function(_0x1c80a3,_0x286877){_0x1c80a3=_0x1c80a3-0x0;var _0x23f9c8=_0xb8ba[_0x1c80a3];return _0x23f9c8;};'use strict';var moment=require(_0xab8b('0x0'));var Sequelize=require(_0xab8b('0x1'));module[_0xab8b('0x2')]={'uniqueid':{'type':Sequelize['STRING'],'allowNull':![]},'from':{'type':Sequelize[_0xab8b('0x3')]},'joinAt':{'type':Sequelize[_0xab8b('0x4')]},'leaveAt':{'type':Sequelize[_0xab8b('0x4')]},'acceptAt':{'type':Sequelize[_0xab8b('0x4')]},'exitAt':{'type':Sequelize[_0xab8b('0x4')]},'reason':{'type':Sequelize[_0xab8b('0x3')]}}; \ No newline at end of file diff --git a/server/api/chatQueueReport/chatQueueReport.controller.js b/server/api/chatQueueReport/chatQueueReport.controller.js new file mode 100644 index 0000000..7f2b35e --- /dev/null +++ b/server/api/chatQueueReport/chatQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc0f9=['../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','json','apply','update','then','error','stack','name','index','fieldName','type','key','map','query','keys','filters','intersection','attributes','model','fields','length','order','sort','pick','filter','merge','VIRTUAL','options','ChatQueueReport','includeAll','include','findAll','rows','catch','show','params','find','create','body','destroy','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x4dcca3,_0x3b88d2){var _0x4b2703=function(_0xa5e865){while(--_0xa5e865){_0x4dcca3['push'](_0x4dcca3['shift']());}};_0x4b2703(++_0x3b88d2);}(_0xc0f9,0xc5));var _0x9c0f=function(_0x1f1fb4,_0x15a561){_0x1f1fb4=_0x1f1fb4-0x0;var _0x12fa15=_0xc0f9[_0x1f1fb4];return _0x12fa15;};'use strict';var emlformat=require(_0x9c0f('0x0'));var rimraf=require(_0x9c0f('0x1'));var zipdir=require(_0x9c0f('0x2'));var jsonpatch=require(_0x9c0f('0x3'));var rp=require(_0x9c0f('0x4'));var moment=require(_0x9c0f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x9c0f('0x6'));var util=require(_0x9c0f('0x7'));var path=require(_0x9c0f('0x8'));var sox=require('sox');var csv=require(_0x9c0f('0x9'));var ejs=require(_0x9c0f('0xa'));var fs=require('fs');var fs_extra=require(_0x9c0f('0xb'));var _=require(_0x9c0f('0xc'));var squel=require('squel');var crypto=require(_0x9c0f('0xd'));var jsforce=require(_0x9c0f('0xe'));var deskjs=require(_0x9c0f('0xf'));var toCsv=require(_0x9c0f('0x9'));var querystring=require('querystring');var Papa=require(_0x9c0f('0x10'));var Redis=require(_0x9c0f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x9c0f('0x12'));var as=require(_0x9c0f('0x13'));var hardwareService=require(_0x9c0f('0x14'));var logger=require(_0x9c0f('0x15'))(_0x9c0f('0x16'));var utils=require(_0x9c0f('0x17'));var config=require(_0x9c0f('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x9c0f('0x19'))['db'];function respondWithStatusCode(_0x31b2b6,_0x2c269c){_0x2c269c=_0x2c269c||0xcc;return function(_0x150d35){if(_0x150d35){return _0x31b2b6[_0x9c0f('0x1a')](_0x2c269c);}return _0x31b2b6[_0x9c0f('0x1b')](_0x2c269c)[_0x9c0f('0x1c')]();};}function respondWithResult(_0x2daf5c,_0x14a724){_0x14a724=_0x14a724||0xc8;return function(_0x1201db){if(_0x1201db){return _0x2daf5c[_0x9c0f('0x1b')](_0x14a724)['json'](_0x1201db);}};}function respondWithFilteredResult(_0xa3d1a9,_0x484f8f){return function(_0x392de2){if(_0x392de2){var _0x4d2611=typeof _0x484f8f[_0x9c0f('0x1d')]===_0x9c0f('0x1e')&&typeof _0x484f8f[_0x9c0f('0x1f')]==='undefined';var _0x58a631=_0x392de2[_0x9c0f('0x20')];var _0x339c47=_0x4d2611?0x0:_0x484f8f[_0x9c0f('0x1d')];var _0x40ac5c=_0x4d2611?_0x392de2[_0x9c0f('0x20')]:_0x484f8f['offset']+_0x484f8f[_0x9c0f('0x1f')];var _0x2aa887;if(_0x40ac5c>=_0x58a631){_0x40ac5c=_0x58a631;_0x2aa887=0xc8;}else{_0x2aa887=0xce;}_0xa3d1a9[_0x9c0f('0x1b')](_0x2aa887);return _0xa3d1a9[_0x9c0f('0x21')]('Content-Range',_0x339c47+'-'+_0x40ac5c+'/'+_0x58a631)[_0x9c0f('0x22')](_0x392de2);}return null;};}function patchUpdates(_0x24a892){return function(_0x27fbed){try{jsonpatch[_0x9c0f('0x23')](_0x27fbed,_0x24a892,!![]);}catch(_0x2485dc){return BPromise['reject'](_0x2485dc);}return _0x27fbed['save']();};}function saveUpdates(_0xd84d31,_0x1b4dc8){return function(_0x3b16dc){if(_0x3b16dc){return _0x3b16dc[_0x9c0f('0x24')](_0xd84d31)[_0x9c0f('0x25')](function(_0x4f5f61){return _0x4f5f61;});}return null;};}function removeEntity(_0x5a2277,_0x43856e){return function(_0x463ea6){if(_0x463ea6){return _0x463ea6['destroy']()[_0x9c0f('0x25')](function(){_0x5a2277[_0x9c0f('0x1b')](0xcc)[_0x9c0f('0x1c')]();});}};}function handleEntityNotFound(_0x1af538,_0x56e12e){return function(_0x540842){if(!_0x540842){_0x1af538[_0x9c0f('0x1a')](0x194);}return _0x540842;};}function handleError(_0x3d1dc7,_0xe2f0f5){_0xe2f0f5=_0xe2f0f5||0x1f4;return function(_0x46fef1){logger[_0x9c0f('0x26')](_0x46fef1[_0x9c0f('0x27')]);if(_0x46fef1[_0x9c0f('0x28')]){delete _0x46fef1[_0x9c0f('0x28')];}_0x3d1dc7[_0x9c0f('0x1b')](_0xe2f0f5)['send'](_0x46fef1);};}exports[_0x9c0f('0x29')]=function(_0x497f24,_0xe724b){var _0x22a88d={},_0x1622ba={},_0x3bbc35={'count':0x0,'rows':[]};var _0x4fdd61=_['map'](db['ChatQueueReport']['rawAttributes'],function(_0x222d97){return{'name':_0x222d97[_0x9c0f('0x2a')],'type':_0x222d97[_0x9c0f('0x2b')][_0x9c0f('0x2c')]};});_0x1622ba['model']=_[_0x9c0f('0x2d')](_0x4fdd61,'name');_0x1622ba[_0x9c0f('0x2e')]=_[_0x9c0f('0x2f')](_0x497f24['query']);_0x1622ba[_0x9c0f('0x30')]=_[_0x9c0f('0x31')](_0x1622ba['model'],_0x1622ba[_0x9c0f('0x2e')]);_0x22a88d[_0x9c0f('0x32')]=_[_0x9c0f('0x31')](_0x1622ba[_0x9c0f('0x33')],qs[_0x9c0f('0x34')](_0x497f24[_0x9c0f('0x2e')]['fields']));_0x22a88d[_0x9c0f('0x32')]=_0x22a88d['attributes'][_0x9c0f('0x35')]?_0x22a88d[_0x9c0f('0x32')]:_0x1622ba[_0x9c0f('0x33')];if(!_0x497f24[_0x9c0f('0x2e')]['hasOwnProperty']('nolimit')){_0x22a88d['limit']=qs['limit'](_0x497f24[_0x9c0f('0x2e')][_0x9c0f('0x1f')]);_0x22a88d['offset']=qs[_0x9c0f('0x1d')](_0x497f24[_0x9c0f('0x2e')][_0x9c0f('0x1d')]);}_0x22a88d[_0x9c0f('0x36')]=qs[_0x9c0f('0x37')](_0x497f24['query'][_0x9c0f('0x37')]);_0x22a88d['where']=qs[_0x9c0f('0x30')](_[_0x9c0f('0x38')](_0x497f24[_0x9c0f('0x2e')],_0x1622ba[_0x9c0f('0x30')]),_0x4fdd61);if(_0x497f24[_0x9c0f('0x2e')][_0x9c0f('0x39')]){_0x22a88d['where']=_[_0x9c0f('0x3a')](_0x22a88d['where'],{'$or':_[_0x9c0f('0x2d')](_0x4fdd61,function(_0x4e36be){if(_0x4e36be[_0x9c0f('0x2b')]!==_0x9c0f('0x3b')){var _0x145790={};_0x145790[_0x4e36be[_0x9c0f('0x28')]]={'$like':'%'+_0x497f24['query'][_0x9c0f('0x39')]+'%'};return _0x145790;}})});}_0x22a88d=_[_0x9c0f('0x3a')]({},_0x22a88d,_0x497f24[_0x9c0f('0x3c')]);var _0x59cf7f={'where':_0x22a88d['where']};return db[_0x9c0f('0x3d')]['count'](_0x59cf7f)[_0x9c0f('0x25')](function(_0x132193){_0x3bbc35['count']=_0x132193;if(_0x497f24[_0x9c0f('0x2e')][_0x9c0f('0x3e')]){_0x22a88d[_0x9c0f('0x3f')]=[{'all':!![]}];}return db[_0x9c0f('0x3d')][_0x9c0f('0x40')](_0x22a88d);})['then'](function(_0x25af2b){_0x3bbc35[_0x9c0f('0x41')]=_0x25af2b;return _0x3bbc35;})[_0x9c0f('0x25')](respondWithFilteredResult(_0xe724b,_0x22a88d))[_0x9c0f('0x42')](handleError(_0xe724b,null));};exports[_0x9c0f('0x43')]=function(_0x2bc11c,_0x5f2340){var _0x2c397a={'raw':!![],'where':{'id':_0x2bc11c[_0x9c0f('0x44')]['id']}},_0x59696a={};_0x59696a[_0x9c0f('0x33')]=_[_0x9c0f('0x2f')](db['ChatQueueReport']['rawAttributes']);_0x59696a[_0x9c0f('0x2e')]=_[_0x9c0f('0x2f')](_0x2bc11c['query']);_0x59696a[_0x9c0f('0x30')]=_['intersection'](_0x59696a[_0x9c0f('0x33')],_0x59696a[_0x9c0f('0x2e')]);_0x2c397a[_0x9c0f('0x32')]=_[_0x9c0f('0x31')](_0x59696a[_0x9c0f('0x33')],qs['fields'](_0x2bc11c[_0x9c0f('0x2e')][_0x9c0f('0x34')]));_0x2c397a[_0x9c0f('0x32')]=_0x2c397a[_0x9c0f('0x32')][_0x9c0f('0x35')]?_0x2c397a['attributes']:_0x59696a['model'];if(_0x2bc11c[_0x9c0f('0x2e')][_0x9c0f('0x3e')]){_0x2c397a[_0x9c0f('0x3f')]=[{'all':!![]}];}_0x2c397a=_[_0x9c0f('0x3a')]({},_0x2c397a,_0x2bc11c[_0x9c0f('0x3c')]);return db[_0x9c0f('0x3d')][_0x9c0f('0x45')](_0x2c397a)[_0x9c0f('0x25')](handleEntityNotFound(_0x5f2340,null))[_0x9c0f('0x25')](respondWithResult(_0x5f2340,null))[_0x9c0f('0x42')](handleError(_0x5f2340,null));};exports['create']=function(_0x41cbee,_0x42afb0){return db[_0x9c0f('0x3d')][_0x9c0f('0x46')](_0x41cbee[_0x9c0f('0x47')],{})[_0x9c0f('0x25')](respondWithResult(_0x42afb0,0xc9))[_0x9c0f('0x42')](handleError(_0x42afb0,null));};exports['update']=function(_0x26f562,_0x1ab16c){if(_0x26f562[_0x9c0f('0x47')]['id']){delete _0x26f562[_0x9c0f('0x47')]['id'];}return db[_0x9c0f('0x3d')][_0x9c0f('0x45')]({'where':{'id':_0x26f562[_0x9c0f('0x44')]['id']}})[_0x9c0f('0x25')](handleEntityNotFound(_0x1ab16c,null))[_0x9c0f('0x25')](saveUpdates(_0x26f562[_0x9c0f('0x47')],null))[_0x9c0f('0x25')](respondWithResult(_0x1ab16c,null))[_0x9c0f('0x42')](handleError(_0x1ab16c,null));};exports[_0x9c0f('0x48')]=function(_0x127b51,_0x155b54){return db[_0x9c0f('0x3d')]['find']({'where':{'id':_0x127b51[_0x9c0f('0x44')]['id']}})[_0x9c0f('0x25')](handleEntityNotFound(_0x155b54,null))[_0x9c0f('0x25')](removeEntity(_0x155b54,null))['catch'](handleError(_0x155b54,null));};exports[_0x9c0f('0x49')]=function(_0x283c08,_0x6f7da7){return db[_0x9c0f('0x3d')][_0x9c0f('0x49')]()[_0x9c0f('0x25')](respondWithResult(_0x6f7da7,null))[_0x9c0f('0x42')](handleError(_0x6f7da7,null));}; \ No newline at end of file diff --git a/server/api/chatQueueReport/chatQueueReport.model.js b/server/api/chatQueueReport/chatQueueReport.model.js new file mode 100644 index 0000000..7f62fe5 --- /dev/null +++ b/server/api/chatQueueReport/chatQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb7e7=['../../config/logger','moment','request-promise','rimraf','../../config/environment','./chatQueueReport.attributes','define','ChatQueueReport','uniqueid','lodash'];(function(_0x21d589,_0x1e07f5){var _0x4ccf43=function(_0x55a33c){while(--_0x55a33c){_0x21d589['push'](_0x21d589['shift']());}};_0x4ccf43(++_0x1e07f5);}(_0xb7e7,0x121));var _0x7b7e=function(_0x2b4411,_0x2625ed){_0x2b4411=_0x2b4411-0x0;var _0x8e41ef=_0xb7e7[_0x2b4411];return _0x8e41ef;};'use strict';var _=require(_0x7b7e('0x0'));var util=require('util');var logger=require(_0x7b7e('0x1'))('api');var moment=require(_0x7b7e('0x2'));var BPromise=require('bluebird');var rp=require(_0x7b7e('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0x7b7e('0x4'));var config=require(_0x7b7e('0x5'));var attributes=require(_0x7b7e('0x6'));module['exports']=function(_0x53ed64,_0x333fa4){return _0x53ed64[_0x7b7e('0x7')](_0x7b7e('0x8'),attributes,{'tableName':'report_chat_queue','paranoid':![],'indexes':[{'name':_0x7b7e('0x9'),'fields':[_0x7b7e('0x9')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatQueueReport/chatQueueReport.rpc.js b/server/api/chatQueueReport/chatQueueReport.rpc.js new file mode 100644 index 0000000..130d022 --- /dev/null +++ b/server/api/chatQueueReport/chatQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdef5=['code','message','info','CreateChatQueueReport','ChatQueueReport','create','body','options','catch','UpdateChatQueueReport','update','attributes','limit','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x42245d,_0x51758f){var _0x4b211a=function(_0x2634e){while(--_0x2634e){_0x42245d['push'](_0x42245d['shift']());}};_0x4b211a(++_0x51758f);}(_0xdef5,0x183));var _0x5def=function(_0x44b604,_0x21c079){_0x44b604=_0x44b604-0x0;var _0x3968ac=_0xdef5[_0x44b604];return _0x3968ac;};'use strict';var _=require(_0x5def('0x0'));var util=require(_0x5def('0x1'));var moment=require(_0x5def('0x2'));var BPromise=require(_0x5def('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5def('0x4'));var db=require(_0x5def('0x5'))['db'];var utils=require(_0x5def('0x6'));var logger=require(_0x5def('0x7'))(_0x5def('0x8'));var config=require(_0x5def('0x9'));var jayson=require(_0x5def('0xa'));var client=jayson[_0x5def('0xb')][_0x5def('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x30ae9f,_0x4687d5,_0x3c9df1){return new BPromise(function(_0x37db5a,_0x1abd2a){return client[_0x5def('0xd')](_0x30ae9f,_0x3c9df1)[_0x5def('0xe')](function(_0x151948){logger['info'](_0x5def('0xf'),_0x4687d5,_0x5def('0x10'));logger[_0x5def('0x11')](_0x5def('0x12'),_0x4687d5,_0x5def('0x10'),JSON[_0x5def('0x13')](_0x151948));if(_0x151948[_0x5def('0x14')]){if(_0x151948[_0x5def('0x14')][_0x5def('0x15')]===0x1f4){logger['error'](_0x5def('0xf'),_0x4687d5,_0x151948[_0x5def('0x14')]['message']);return _0x1abd2a(_0x151948['error'][_0x5def('0x16')]);}logger[_0x5def('0x14')](_0x5def('0xf'),_0x4687d5,_0x151948['error']['message']);return _0x37db5a(_0x151948['error']['message']);}else{logger[_0x5def('0x17')](_0x5def('0xf'),_0x4687d5,_0x5def('0x10'));_0x37db5a(_0x151948['result']['message']);}})['catch'](function(_0x27a55e){logger[_0x5def('0x14')](_0x5def('0xf'),_0x4687d5,_0x27a55e);_0x1abd2a(_0x27a55e);});});}exports[_0x5def('0x18')]=function(_0xde58f7){var _0x3c306a=this;return new Promise(function(_0x4f4da2,_0x54712f){return db[_0x5def('0x19')][_0x5def('0x1a')](_0xde58f7[_0x5def('0x1b')],{'raw':_0xde58f7[_0x5def('0x1c')]?_0xde58f7['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x4c5f8e){logger['info'](_0x5def('0x18'),_0xde58f7);logger[_0x5def('0x11')](_0x5def('0x18'),_0xde58f7,JSON[_0x5def('0x13')](_0x4c5f8e));_0x4f4da2(_0x4c5f8e);})[_0x5def('0x1d')](function(_0x849ea2){logger[_0x5def('0x14')]('CreateChatQueueReport',_0x849ea2['message'],_0xde58f7);_0x54712f(_0x3c306a[_0x5def('0x14')](0x1f4,_0x849ea2['message']));});});};exports[_0x5def('0x1e')]=function(_0x3ff7c9){var _0x205ad9=this;return new Promise(function(_0x311f05,_0x257db3){return db[_0x5def('0x19')][_0x5def('0x1f')](_0x3ff7c9[_0x5def('0x1b')],{'raw':_0x3ff7c9[_0x5def('0x1c')]?_0x3ff7c9['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3ff7c9[_0x5def('0x1c')]?_0x3ff7c9[_0x5def('0x1c')]['where']||null:null,'attributes':_0x3ff7c9[_0x5def('0x1c')]?_0x3ff7c9[_0x5def('0x1c')][_0x5def('0x20')]||null:null,'limit':_0x3ff7c9['options']?_0x3ff7c9[_0x5def('0x1c')][_0x5def('0x21')]||null:null})[_0x5def('0xe')](function(_0x33c0af){logger[_0x5def('0x17')]('UpdateChatQueueReport',_0x3ff7c9);logger[_0x5def('0x11')]('UpdateChatQueueReport',_0x3ff7c9,JSON[_0x5def('0x13')](_0x33c0af));_0x311f05(_0x33c0af);})[_0x5def('0x1d')](function(_0x401464){logger[_0x5def('0x14')](_0x5def('0x1e'),_0x401464[_0x5def('0x16')],_0x3ff7c9);_0x257db3(_0x205ad9[_0x5def('0x14')](0x1f4,_0x401464[_0x5def('0x16')]));});});}; \ No newline at end of file diff --git a/server/api/chatQueueReport/index.js b/server/api/chatQueueReport/index.js new file mode 100644 index 0000000..9509012 --- /dev/null +++ b/server/api/chatQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x52c0=['connect-timeout','Router','../../components/auth/service','../../components/interaction/service','./chatQueueReport.controller','get','isAuthenticated','index','/describe','/:id','show','post','create','put','update','delete','destroy','exports','multer','util','path'];(function(_0x813d0a,_0x4fd3d7){var _0x241352=function(_0x3ca375){while(--_0x3ca375){_0x813d0a['push'](_0x813d0a['shift']());}};_0x241352(++_0x4fd3d7);}(_0x52c0,0xa5));var _0x052c=function(_0x2f81f4,_0xee02fd){_0x2f81f4=_0x2f81f4-0x0;var _0x29b0ea=_0x52c0[_0x2f81f4];return _0x29b0ea;};'use strict';var multer=require(_0x052c('0x0'));var util=require(_0x052c('0x1'));var path=require(_0x052c('0x2'));var timeout=require(_0x052c('0x3'));var express=require('express');var router=express[_0x052c('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x052c('0x5'));var interaction=require(_0x052c('0x6'));var config=require('../../config/environment');var controller=require(_0x052c('0x7'));router[_0x052c('0x8')]('/',auth[_0x052c('0x9')](),controller[_0x052c('0xa')]);router['get'](_0x052c('0xb'),auth[_0x052c('0x9')](),controller['describe']);router[_0x052c('0x8')](_0x052c('0xc'),auth[_0x052c('0x9')](),controller[_0x052c('0xd')]);router[_0x052c('0xe')]('/',auth['isAuthenticated'](),controller[_0x052c('0xf')]);router[_0x052c('0x10')]('/:id',auth[_0x052c('0x9')](),controller[_0x052c('0x11')]);router[_0x052c('0x12')](_0x052c('0xc'),auth['isAuthenticated'](),controller[_0x052c('0x13')]);module[_0x052c('0x14')]=router; \ No newline at end of file diff --git a/server/api/chatTransferReport/chatTransferReport.attributes.js b/server/api/chatTransferReport/chatTransferReport.attributes.js new file mode 100644 index 0000000..f78d618 --- /dev/null +++ b/server/api/chatTransferReport/chatTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9bde=['NOW','sequelize','STRING','account','agent','queue','DATE'];(function(_0x54ea7a,_0x19df9b){var _0x65a10d=function(_0x1bf936){while(--_0x1bf936){_0x54ea7a['push'](_0x54ea7a['shift']());}};_0x65a10d(++_0x19df9b);}(_0x9bde,0xe1));var _0xe9bd=function(_0x21de91,_0x389fd8){_0x21de91=_0x21de91-0x0;var _0x18d348=_0x9bde[_0x21de91];return _0x18d348;};'use strict';var moment=require('moment');var Sequelize=require(_0xe9bd('0x0'));module['exports']={'uniqueid':{'type':Sequelize[_0xe9bd('0x1')],'allowNull':![]},'type':{'type':Sequelize['ENUM'](_0xe9bd('0x2'),_0xe9bd('0x3'),_0xe9bd('0x4')),'allowNull':![],'defaultValue':_0xe9bd('0x4')},'transferredAt':{'type':Sequelize[_0xe9bd('0x5')],'allowNull':![],'defaultValue':Sequelize[_0xe9bd('0x6')]}}; \ No newline at end of file diff --git a/server/api/chatTransferReport/chatTransferReport.controller.js b/server/api/chatTransferReport/chatTransferReport.controller.js new file mode 100644 index 0000000..e6be113 --- /dev/null +++ b/server/api/chatTransferReport/chatTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9991=['index','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','map','options','ChatTransferReport','includeAll','include','findAll','rows','catch','params','merge','find','create','body','describe','eml-format','rimraf','request-promise','moment','mustache','path','sox','to-csv','fs-extra','crypto','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','update','destroy','then','stack','name'];(function(_0xeff08e,_0x33b36f){var _0x372099=function(_0x10e875){while(--_0x10e875){_0xeff08e['push'](_0xeff08e['shift']());}};_0x372099(++_0x33b36f);}(_0x9991,0xf2));var _0x1999=function(_0x437314,_0x979155){_0x437314=_0x437314-0x0;var _0x56c465=_0x9991[_0x437314];return _0x56c465;};'use strict';var emlformat=require(_0x1999('0x0'));var rimraf=require(_0x1999('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x1999('0x2'));var moment=require(_0x1999('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x1999('0x4'));var util=require('util');var path=require(_0x1999('0x5'));var sox=require(_0x1999('0x6'));var csv=require(_0x1999('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1999('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x1999('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x1999('0xa'));var toCsv=require('to-csv');var querystring=require(_0x1999('0xb'));var Papa=require('papaparse');var Redis=require(_0x1999('0xc'));var authService=require('../../components/auth/service');var qs=require(_0x1999('0xd'));var as=require(_0x1999('0xe'));var hardwareService=require(_0x1999('0xf'));var logger=require(_0x1999('0x10'))(_0x1999('0x11'));var utils=require(_0x1999('0x12'));var config=require(_0x1999('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x1999('0x14'))['db'];function respondWithStatusCode(_0x554ee4,_0x44fd50){_0x44fd50=_0x44fd50||0xcc;return function(_0x4d981a){if(_0x4d981a){return _0x554ee4[_0x1999('0x15')](_0x44fd50);}return _0x554ee4[_0x1999('0x16')](_0x44fd50)[_0x1999('0x17')]();};}function respondWithResult(_0x27accf,_0x1aef8e){_0x1aef8e=_0x1aef8e||0xc8;return function(_0x22e63e){if(_0x22e63e){return _0x27accf[_0x1999('0x16')](_0x1aef8e)[_0x1999('0x18')](_0x22e63e);}};}function respondWithFilteredResult(_0x37796e,_0x5b6c18){return function(_0x58467f){if(_0x58467f){var _0x6b978f=typeof _0x5b6c18[_0x1999('0x19')]==='undefined'&&typeof _0x5b6c18[_0x1999('0x1a')]===_0x1999('0x1b');var _0x2fc3cc=_0x58467f[_0x1999('0x1c')];var _0x2c7cd7=_0x6b978f?0x0:_0x5b6c18[_0x1999('0x19')];var _0x464369=_0x6b978f?_0x58467f['count']:_0x5b6c18[_0x1999('0x19')]+_0x5b6c18[_0x1999('0x1a')];var _0x4aca69;if(_0x464369>=_0x2fc3cc){_0x464369=_0x2fc3cc;_0x4aca69=0xc8;}else{_0x4aca69=0xce;}_0x37796e[_0x1999('0x16')](_0x4aca69);return _0x37796e[_0x1999('0x1d')](_0x1999('0x1e'),_0x2c7cd7+'-'+_0x464369+'/'+_0x2fc3cc)['json'](_0x58467f);}return null;};}function patchUpdates(_0x106732){return function(_0xee83ec){try{jsonpatch[_0x1999('0x1f')](_0xee83ec,_0x106732,!![]);}catch(_0x590801){return BPromise[_0x1999('0x20')](_0x590801);}return _0xee83ec['save']();};}function saveUpdates(_0x395a58,_0x199641){return function(_0x34b4c5){if(_0x34b4c5){return _0x34b4c5[_0x1999('0x21')](_0x395a58)['then'](function(_0x4a0045){return _0x4a0045;});}return null;};}function removeEntity(_0x4d34da,_0x564edb){return function(_0x46c902){if(_0x46c902){return _0x46c902[_0x1999('0x22')]()[_0x1999('0x23')](function(){_0x4d34da['status'](0xcc)[_0x1999('0x17')]();});}};}function handleEntityNotFound(_0x25d9b1,_0x1ab3e4){return function(_0x2ac5cf){if(!_0x2ac5cf){_0x25d9b1['sendStatus'](0x194);}return _0x2ac5cf;};}function handleError(_0x1ea108,_0x2f1975){_0x2f1975=_0x2f1975||0x1f4;return function(_0x4c28a5){logger['error'](_0x4c28a5[_0x1999('0x24')]);if(_0x4c28a5[_0x1999('0x25')]){delete _0x4c28a5[_0x1999('0x25')];}_0x1ea108[_0x1999('0x16')](_0x2f1975)['send'](_0x4c28a5);};}exports[_0x1999('0x26')]=function(_0x5110f6,_0x4fc5da){var _0x2d92ea={},_0x43b6a6={},_0x2ddf9e={'count':0x0,'rows':[]};var _0x25558f=_['map'](db['ChatTransferReport'][_0x1999('0x27')],function(_0x59e821){return{'name':_0x59e821['fieldName'],'type':_0x59e821[_0x1999('0x28')][_0x1999('0x29')]};});_0x43b6a6[_0x1999('0x2a')]=_['map'](_0x25558f,'name');_0x43b6a6[_0x1999('0x2b')]=_[_0x1999('0x2c')](_0x5110f6[_0x1999('0x2b')]);_0x43b6a6['filters']=_[_0x1999('0x2d')](_0x43b6a6[_0x1999('0x2a')],_0x43b6a6[_0x1999('0x2b')]);_0x2d92ea[_0x1999('0x2e')]=_[_0x1999('0x2d')](_0x43b6a6[_0x1999('0x2a')],qs[_0x1999('0x2f')](_0x5110f6[_0x1999('0x2b')][_0x1999('0x2f')]));_0x2d92ea['attributes']=_0x2d92ea[_0x1999('0x2e')][_0x1999('0x30')]?_0x2d92ea[_0x1999('0x2e')]:_0x43b6a6[_0x1999('0x2a')];if(!_0x5110f6['query'][_0x1999('0x31')]('nolimit')){_0x2d92ea[_0x1999('0x1a')]=qs[_0x1999('0x1a')](_0x5110f6[_0x1999('0x2b')][_0x1999('0x1a')]);_0x2d92ea[_0x1999('0x19')]=qs[_0x1999('0x19')](_0x5110f6['query']['offset']);}_0x2d92ea[_0x1999('0x32')]=qs[_0x1999('0x33')](_0x5110f6[_0x1999('0x2b')][_0x1999('0x33')]);_0x2d92ea[_0x1999('0x34')]=qs[_0x1999('0x35')](_[_0x1999('0x36')](_0x5110f6[_0x1999('0x2b')],_0x43b6a6[_0x1999('0x35')]),_0x25558f);if(_0x5110f6[_0x1999('0x2b')][_0x1999('0x37')]){_0x2d92ea[_0x1999('0x34')]=_['merge'](_0x2d92ea[_0x1999('0x34')],{'$or':_[_0x1999('0x38')](_0x25558f,function(_0x549145){if(_0x549145[_0x1999('0x28')]!=='VIRTUAL'){var _0x2d2613={};_0x2d2613[_0x549145['name']]={'$like':'%'+_0x5110f6['query'][_0x1999('0x37')]+'%'};return _0x2d2613;}})});}_0x2d92ea=_['merge']({},_0x2d92ea,_0x5110f6[_0x1999('0x39')]);var _0xa8b231={'where':_0x2d92ea['where']};return db[_0x1999('0x3a')][_0x1999('0x1c')](_0xa8b231)[_0x1999('0x23')](function(_0x1936da){_0x2ddf9e['count']=_0x1936da;if(_0x5110f6[_0x1999('0x2b')][_0x1999('0x3b')]){_0x2d92ea[_0x1999('0x3c')]=[{'all':!![]}];}return db[_0x1999('0x3a')][_0x1999('0x3d')](_0x2d92ea);})['then'](function(_0x4c869a){_0x2ddf9e[_0x1999('0x3e')]=_0x4c869a;return _0x2ddf9e;})['then'](respondWithFilteredResult(_0x4fc5da,_0x2d92ea))[_0x1999('0x3f')](handleError(_0x4fc5da,null));};exports['show']=function(_0x38747e,_0xbd91b6){var _0x2ab5cc={'raw':!![],'where':{'id':_0x38747e[_0x1999('0x40')]['id']}},_0x4ffb0e={};_0x4ffb0e[_0x1999('0x2a')]=_[_0x1999('0x2c')](db['ChatTransferReport'][_0x1999('0x27')]);_0x4ffb0e[_0x1999('0x2b')]=_[_0x1999('0x2c')](_0x38747e['query']);_0x4ffb0e[_0x1999('0x35')]=_[_0x1999('0x2d')](_0x4ffb0e[_0x1999('0x2a')],_0x4ffb0e[_0x1999('0x2b')]);_0x2ab5cc[_0x1999('0x2e')]=_['intersection'](_0x4ffb0e[_0x1999('0x2a')],qs[_0x1999('0x2f')](_0x38747e[_0x1999('0x2b')][_0x1999('0x2f')]));_0x2ab5cc[_0x1999('0x2e')]=_0x2ab5cc[_0x1999('0x2e')]['length']?_0x2ab5cc[_0x1999('0x2e')]:_0x4ffb0e[_0x1999('0x2a')];if(_0x38747e[_0x1999('0x2b')][_0x1999('0x3b')]){_0x2ab5cc['include']=[{'all':!![]}];}_0x2ab5cc=_[_0x1999('0x41')]({},_0x2ab5cc,_0x38747e[_0x1999('0x39')]);return db[_0x1999('0x3a')][_0x1999('0x42')](_0x2ab5cc)['then'](handleEntityNotFound(_0xbd91b6,null))[_0x1999('0x23')](respondWithResult(_0xbd91b6,null))['catch'](handleError(_0xbd91b6,null));};exports[_0x1999('0x43')]=function(_0x3a237a,_0x3fe14f){return db[_0x1999('0x3a')]['create'](_0x3a237a[_0x1999('0x44')],{})[_0x1999('0x23')](respondWithResult(_0x3fe14f,0xc9))[_0x1999('0x3f')](handleError(_0x3fe14f,null));};exports['update']=function(_0x3a5b7a,_0x503627){if(_0x3a5b7a[_0x1999('0x44')]['id']){delete _0x3a5b7a[_0x1999('0x44')]['id'];}return db[_0x1999('0x3a')][_0x1999('0x42')]({'where':{'id':_0x3a5b7a[_0x1999('0x40')]['id']}})['then'](handleEntityNotFound(_0x503627,null))['then'](saveUpdates(_0x3a5b7a[_0x1999('0x44')],null))[_0x1999('0x23')](respondWithResult(_0x503627,null))[_0x1999('0x3f')](handleError(_0x503627,null));};exports['destroy']=function(_0x732292,_0x378fbf){return db[_0x1999('0x3a')][_0x1999('0x42')]({'where':{'id':_0x732292[_0x1999('0x40')]['id']}})[_0x1999('0x23')](handleEntityNotFound(_0x378fbf,null))[_0x1999('0x23')](removeEntity(_0x378fbf,null))[_0x1999('0x3f')](handleError(_0x378fbf,null));};exports[_0x1999('0x45')]=function(_0x13289b,_0x3bb3c2){return db[_0x1999('0x3a')]['describe']()[_0x1999('0x23')](respondWithResult(_0x3bb3c2,null))['catch'](handleError(_0x3bb3c2,null));}; \ No newline at end of file diff --git a/server/api/chatTransferReport/chatTransferReport.model.js b/server/api/chatTransferReport/chatTransferReport.model.js new file mode 100644 index 0000000..f479f27 --- /dev/null +++ b/server/api/chatTransferReport/chatTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3eb3=['path','rimraf','../../config/environment','./chatTransferReport.attributes','report_chat_transfer','uniqueid','lodash','util','../../config/logger','bluebird','request-promise'];(function(_0x3088bf,_0x4f34b1){var _0x226d9f=function(_0x224579){while(--_0x224579){_0x3088bf['push'](_0x3088bf['shift']());}};_0x226d9f(++_0x4f34b1);}(_0x3eb3,0xcc));var _0x33eb=function(_0x29adfe,_0x4593aa){_0x29adfe=_0x29adfe-0x0;var _0x295dc1=_0x3eb3[_0x29adfe];return _0x295dc1;};'use strict';var _=require(_0x33eb('0x0'));var util=require(_0x33eb('0x1'));var logger=require(_0x33eb('0x2'))('api');var moment=require('moment');var BPromise=require(_0x33eb('0x3'));var rp=require(_0x33eb('0x4'));var fs=require('fs');var path=require(_0x33eb('0x5'));var rimraf=require(_0x33eb('0x6'));var config=require(_0x33eb('0x7'));var attributes=require(_0x33eb('0x8'));module['exports']=function(_0x38ec6b,_0x495e26){return _0x38ec6b['define']('ChatTransferReport',attributes,{'tableName':_0x33eb('0x9'),'paranoid':![],'indexes':[{'name':_0x33eb('0xa'),'fields':[_0x33eb('0xa')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatTransferReport/chatTransferReport.rpc.js b/server/api/chatTransferReport/chatTransferReport.rpc.js new file mode 100644 index 0000000..2175a9d --- /dev/null +++ b/server/api/chatTransferReport/chatTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcfc8=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ChatTransferReport,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','lodash','util','bluebird','randomstring','../../mysqldb'];(function(_0x268ad0,_0x3cdfcd){var _0xc8139a=function(_0x248abd){while(--_0x248abd){_0x268ad0['push'](_0x268ad0['shift']());}};_0xc8139a(++_0x3cdfcd);}(_0xcfc8,0x17b));var _0x8cfc=function(_0x5945a3,_0x3cb745){_0x5945a3=_0x5945a3-0x0;var _0xa4949d=_0xcfc8[_0x5945a3];return _0xa4949d;};'use strict';var _=require(_0x8cfc('0x0'));var util=require(_0x8cfc('0x1'));var moment=require('moment');var BPromise=require(_0x8cfc('0x2'));var rs=require(_0x8cfc('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8cfc('0x4'))['db'];var utils=require(_0x8cfc('0x5'));var logger=require(_0x8cfc('0x6'))(_0x8cfc('0x7'));var config=require(_0x8cfc('0x8'));var jayson=require(_0x8cfc('0x9'));var client=jayson[_0x8cfc('0xa')][_0x8cfc('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4d6192,_0x3ec99d,_0x2df522){return new BPromise(function(_0x1a0450,_0x4f333d){return client[_0x8cfc('0xc')](_0x4d6192,_0x2df522)[_0x8cfc('0xd')](function(_0x133f3d){logger[_0x8cfc('0xe')](_0x8cfc('0xf'),_0x3ec99d,'request\x20sent');logger[_0x8cfc('0x10')]('ChatTransferReport,\x20%s,\x20%s,\x20%s',_0x3ec99d,_0x8cfc('0x11'),JSON[_0x8cfc('0x12')](_0x133f3d));if(_0x133f3d[_0x8cfc('0x13')]){if(_0x133f3d['error'][_0x8cfc('0x14')]===0x1f4){logger[_0x8cfc('0x13')]('ChatTransferReport,\x20%s,\x20%s',_0x3ec99d,_0x133f3d[_0x8cfc('0x13')][_0x8cfc('0x15')]);return _0x4f333d(_0x133f3d[_0x8cfc('0x13')][_0x8cfc('0x15')]);}logger[_0x8cfc('0x13')](_0x8cfc('0xf'),_0x3ec99d,_0x133f3d[_0x8cfc('0x13')]['message']);return _0x1a0450(_0x133f3d[_0x8cfc('0x13')]['message']);}else{logger['info'](_0x8cfc('0xf'),_0x3ec99d,'request\x20sent');_0x1a0450(_0x133f3d[_0x8cfc('0x16')]['message']);}})[_0x8cfc('0x17')](function(_0x378965){logger[_0x8cfc('0x13')](_0x8cfc('0xf'),_0x3ec99d,_0x378965);_0x4f333d(_0x378965);});});} \ No newline at end of file diff --git a/server/api/chatTransferReport/index.js b/server/api/chatTransferReport/index.js new file mode 100644 index 0000000..437c505 --- /dev/null +++ b/server/api/chatTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2071=['describe','/:id','show','create','put','update','delete','destroy','exports','multer','util','path','express','Router','fs-extra','../../components/interaction/service','../../config/environment','./chatTransferReport.controller','isAuthenticated','index','get'];(function(_0x10bb2b,_0x4f1976){var _0x2946d7=function(_0x3274d6){while(--_0x3274d6){_0x10bb2b['push'](_0x10bb2b['shift']());}};_0x2946d7(++_0x4f1976);}(_0x2071,0xb1));var _0x1207=function(_0x326d35,_0x4f65b3){_0x326d35=_0x326d35-0x0;var _0xd3f8f3=_0x2071[_0x326d35];return _0xd3f8f3;};'use strict';var multer=require(_0x1207('0x0'));var util=require(_0x1207('0x1'));var path=require(_0x1207('0x2'));var timeout=require('connect-timeout');var express=require(_0x1207('0x3'));var router=express[_0x1207('0x4')]();var fs_extra=require(_0x1207('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x1207('0x6'));var config=require(_0x1207('0x7'));var controller=require(_0x1207('0x8'));router['get']('/',auth[_0x1207('0x9')](),controller[_0x1207('0xa')]);router[_0x1207('0xb')]('/describe',auth[_0x1207('0x9')](),controller[_0x1207('0xc')]);router[_0x1207('0xb')](_0x1207('0xd'),auth[_0x1207('0x9')](),controller[_0x1207('0xe')]);router['post']('/',auth[_0x1207('0x9')](),controller[_0x1207('0xf')]);router[_0x1207('0x10')]('/:id',auth[_0x1207('0x9')](),controller[_0x1207('0x11')]);router[_0x1207('0x12')](_0x1207('0xd'),auth[_0x1207('0x9')](),controller[_0x1207('0x13')]);module[_0x1207('0x14')]=router; \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.attributes.js b/server/api/chatWebsite/chatWebsite.attributes.js new file mode 100644 index 0000000..22245bf --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1be1=['textarea','Comments','Leave\x20your\x20comments','offlineForm','generate','All\x20of\x20our\x20agents\x20are\x20busy\x20at\x20this\x20time.\x20Your\x20chat\x20is\x20very\x20important\x20to\x20us.','Please\x20hold\x20and\x20we\x20will\x20answer\x20your\x20request\x20as\x20soon\x20as\x20possible.','New\x20offline\x20message\x20from\x20websiteName','Your\x20request\x20has\x20not\x20been\x20processed.','Skip','CHAT','alternate','#fafafa','System','Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled','mandatoryDisposition','Generated\x20by\x20XCALLY\x20Motion','Meeting\x20generated\x20for\x20interaction\x20#{{interaction.id}}\x20by\x20{{agent.name}}','exports','STRING','address','email','#011F6A','#ffffff','INTEGER','BOOLEAN','ENUM','rounded','squared','We\x20are\x20here!','Send','Contact\x20us','Do\x20you\x20want\x20to\x20close\x20the\x20interaction?','Form\x20properly\x20submitted','Form\x20submission\x20error','Type\x20a\x20message','Thanks\x20you\x20for\x20your\x20time!','Feedback','star','thumb','TEXT','stringify','input','name','getDataValue','onlineForm','parse','setDataValue'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x1be1,0x192));var _0x11be=function(_0x298832,_0x152118){_0x298832=_0x298832-0x0;var _0x366814=_0x1be1[_0x298832];return _0x366814;};'use strict';var Sequelize=require('sequelize');var rs=require('randomstring');module[_0x11be('0x0')]={'name':{'type':Sequelize[_0x11be('0x1')],'allowNull':![]},'address':{'type':Sequelize['STRING'],'allowNull':![],'unique':_0x11be('0x2')},'description':{'type':Sequelize[_0x11be('0x1')]},'mapKey':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x3')},'mapKeyOffline':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x3')},'key':{'type':Sequelize[_0x11be('0x1')],'allowNull':![]},'agentAlias':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'Agent'},'customerAlias':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'Me'},'color':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0x11be('0x4'),'validate':{'notEmpty':!![]}},'color_button':{'type':Sequelize[_0x11be('0x1')],'allowNull':![],'defaultValue':_0x11be('0x4'),'validate':{'notEmpty':!![]}},'textColor':{'type':Sequelize[_0x11be('0x1')],'allowNull':![],'defaultValue':_0x11be('0x5'),'validate':{'notEmpty':!![]}},'textButtonColor':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0x11be('0x5'),'validate':{'notEmpty':!![]}},'fontSize':{'type':Sequelize[_0x11be('0x6')],'defaultValue':0xf},'remote':{'type':Sequelize['STRING']},'animation':{'type':Sequelize[_0x11be('0x7')],'defaultValue':!![]},'header_shape':{'type':Sequelize[_0x11be('0x8')](_0x11be('0x9'),_0x11be('0xa')),'defaultValue':'rounded'},'header_online':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0xb')},'start_chat_button':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'Chat'},'offline_chat_button':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0xc')},'header_offline':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0xd')},'download_transcript':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'timeout':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'whiteLabel':{'type':Sequelize['STRING'],'defaultValue':'Powered\x20by\x20xCALLY'},'defaultWhiteLabel':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'sitepic':{'type':Sequelize['TEXT']},'closingQuestion':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0xe')},'formSubmitSuccessMessage':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0xf')},'formSubmitFailureMessage':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x10')},'noteTitle':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'Note'},'placeholderMessage':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x11')},'closingMessage':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x12')},'closingMessageButton':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0xc')},'skipMessageButton':{'type':Sequelize['STRING'],'defaultValue':'Skip'},'conditionAgreement':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'enableRating':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'enableFeedback':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'enableSendButton':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'feedbackTitle':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x13')},'ratingType':{'type':Sequelize[_0x11be('0x8')](_0x11be('0x14'),_0x11be('0x15')),'defaultValue':_0x11be('0x14')},'ratingStarsNumber':{'type':Sequelize[_0x11be('0x6')],'defaultValue':0x5},'onlineForm':{'type':Sequelize[_0x11be('0x16')],'defaultValue':function(){return JSON[_0x11be('0x17')]({'items':[{'type':_0x11be('0x18'),'variable':null,'config':{'placeholder':_0x11be('0x19'),'type':'text','required':!![]},'props':{'title':_0x11be('0x19'),'helpText':''}},{'type':_0x11be('0x18'),'props':{'title':_0x11be('0x3'),'helpText':''},'config':{'required':!![],'placeholder':'email','type':'email'},'variable':null}],'fromKey':0x1});},'get':function(){return this[_0x11be('0x1a')](_0x11be('0x1b'))?JSON[_0x11be('0x1c')](this['getDataValue'](_0x11be('0x1b'))):{};},'set':function(_0x518e2b){return this[_0x11be('0x1d')]('onlineForm',JSON[_0x11be('0x17')](_0x518e2b));}},'offlineForm':{'type':Sequelize[_0x11be('0x16')],'defaultValue':function(){return JSON['stringify']({'items':[{'type':_0x11be('0x18'),'props':{'title':_0x11be('0x3'),'helpText':''},'config':{'required':!![],'placeholder':_0x11be('0x3'),'type':_0x11be('0x3')},'variable':null},{'type':_0x11be('0x1e'),'config':{'placeholder':_0x11be('0x1f')},'props':{'title':_0x11be('0x1f'),'helpText':_0x11be('0x20')}}],'fromKey':0x0});},'get':function(){return this[_0x11be('0x1a')]('offlineForm')?JSON[_0x11be('0x1c')](this['getDataValue'](_0x11be('0x21'))):{};},'set':function(_0x147b62){return this['setDataValue']('offlineForm',JSON[_0x11be('0x17')](_0x147b62));}},'token':{'type':Sequelize[_0x11be('0x1')],'defaultValue':function(){return rs[_0x11be('0x22')]();}},'autoclose':{'type':Sequelize[_0x11be('0x7')],'defaultValue':!![]},'enableCustomerWriting':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'forwardTranscript':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'forwardTranscriptMessage':{'type':Sequelize[_0x11be('0x1')]},'forwardOffline':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'forwardOfflineAddress':{'type':Sequelize[_0x11be('0x1')]},'waitingTitle':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x23')},'waitingMessage':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x24')},'offlineMessageSubject':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x25')},'offlineMessageBody':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'You\x20received\x20a\x20new\x20offline\x20message\x20from\x20websiteName.\x20Here\x20you\x20can\x20find\x20the\x20details\x20of\x20the\x20request:'},'enableUnmanagedNote':{'type':Sequelize[_0x11be('0x7')],'defaultValue':!![]},'unmanagedMessage':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x26')},'skipUnmanaged':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x27')},'sendUnmanaged':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0xc')},'enableCustomerAttachment':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'enableCustomerCheckmarks':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'agentAvatar':{'type':Sequelize['TEXT']},'showAgentAvatar':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'timezone':{'type':Sequelize['STRING']},'notificationTemplate':{'type':Sequelize['TEXT'],'defaultValue':function(){return'Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}';}},'notificationSound':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'notificationShake':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'hideWhenOffline':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'agentIdentifier':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'website_alias'},'waitForTheAssignedAgent':{'type':Sequelize[_0x11be('0x6')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'alignment':{'type':Sequelize[_0x11be('0x1')],'defaultValue':'bottom_right'},'verticalAlignment':{'type':Sequelize[_0x11be('0x6')],'defaultValue':0x1e},'labelText':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x28')},'messagesAlignment':{'type':Sequelize['STRING'],'defaultValue':_0x11be('0x29')},'defaultTitle':{'type':Sequelize[_0x11be('0x1')]},'customerAvatar':{'type':Sequelize[_0x11be('0x16')]},'showCustomerAvatar':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'messageFontSize':{'type':Sequelize['INTEGER'],'defaultValue':0xc},'backgroundColor':{'type':Sequelize[_0x11be('0x1')],'allowNull':![],'defaultValue':_0x11be('0x2a'),'validate':{'notEmpty':!![]}},'queueTransfer':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize[_0x11be('0x6')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0x11be('0x6')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'systemAlias':{'type':Sequelize[_0x11be('0x1')],'defaultValue':_0x11be('0x2b')},'systemAvatar':{'type':Sequelize[_0x11be('0x16')]},'mandatoryDispositionPauseId':{'type':Sequelize[_0x11be('0x6')],'comment':_0x11be('0x2c')},'mandatoryDisposition':{'type':Sequelize[_0x11be('0x7')],'defaultValue':![],'comment':'Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','set':function(_0x2618f5){if(!_0x2618f5)this[_0x11be('0x1d')]('mandatoryDispositionPauseId',null);this[_0x11be('0x1d')](_0x11be('0x2d'),_0x2618f5);}},'vidaooEscalation':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'vidaooApiKey':{'type':Sequelize[_0x11be('0x1')]},'vidaooTopic':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0x11be('0x2e')},'vidaooNote':{'type':Sequelize['STRING'],'defaultValue':function(){return _0x11be('0x2f');}},'vidaooMetadata':{'type':Sequelize[_0x11be('0x16')],'defaultValue':null},'openNewInteraction':{'type':Sequelize['BOOLEAN'],'defaultValue':![],'allowNull':!![]},'subjectOffline':{'type':Sequelize[_0x11be('0x16')]}}; \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.controller.js b/server/api/chatWebsite/chatWebsite.controller.js new file mode 100644 index 0000000..dfcd795 --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3f0b=['getDispositions','findOne','order','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','sitepic','file','filename','agentAvatar','systemAvatar','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','isNil','existsSync','join','server/files/images/logos/','root','server/files/images/avatars/','download','getCustomerAvatar','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','headers','user-agent','getResult','chat','CmContact','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','Sequelize','ValidationError','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','DESC','ChatApplication','Applications','applications','list','orderBy','account','Contacts','contact','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','lastName','x-real-port','referer','browser','format','%s\x20%s','version','unknown','%s\x20%s\x20%s','device','vendor','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','close','unmanaged','ChatMessage','UserId','User','unshift','agent','*,*,*,*','forcedOwnership','startRouting','EventManager','notify','offline','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','MailAccount','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','ChatOfflineMessage','originalname','mimetype','server','files','attachments','offline-chat','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','Smtp','CloudProvider','forwardOfflineAddress','getSmtpOptions','SendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','Chat','MailAccountId','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','Owner','fullname','internal','color','tag','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','getProactiveActions','virtual','License','increment','chatLicenseExceeded','Intervals','push','some','server/files/chat/iframe.ejs','URL','address','3.1.0','remote','x-real-ip','connection','replace','labelText','textColor','textButtonColor','color_button','hideWhenOffline','IntervalId','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','priority','finally','getApplications','omit','ChatProactiveAction','getFields','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','util','ejs','querystring','ioredis','../../components/parsers/qs','api','../../config/environment','url','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','html-to-text','jayson/promise','client','http','request','then','info','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','undefined','limit','offset','set','Content-Range','destroy','get','ChatWebsites','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','type','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','map','VIRTUAL','options','count','includeAll','include','findAll','rows','show','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','addDisposition','ChatWebsiteId','Disposition'];(function(_0x448f76,_0x466124){var _0x165970=function(_0x2c15b6){while(--_0x2c15b6){_0x448f76['push'](_0x448f76['shift']());}};_0x165970(++_0x466124);}(_0x3f0b,0x1ee));var _0xb3f0=function(_0x513aa5,_0x1fba79){_0x513aa5=_0x513aa5-0x0;var _0x1a1a7c=_0x3f0b[_0x513aa5];return _0x1a1a7c;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0xb3f0('0x0'));var util=require(_0xb3f0('0x1'));var path=require('path');var ejs=require(_0xb3f0('0x2'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var querystring=require(_0xb3f0('0x3'));var Redis=require(_0xb3f0('0x4'));var qs=require(_0xb3f0('0x5'));var logger=require('../../config/logger')(_0xb3f0('0x6'));var config=require(_0xb3f0('0x7'));var url=require(_0xb3f0('0x8'));var db=require(_0xb3f0('0x9'))['db'];config[_0xb3f0('0xa')]=_[_0xb3f0('0xb')](config[_0xb3f0('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xb3f0('0xc'))(new Redis(config[_0xb3f0('0xa')]));require(_0xb3f0('0xd'))['register'](socket);var htmlToText=require(_0xb3f0('0xe'));var jayson=require(_0xb3f0('0xf'));var client=jayson[_0xb3f0('0x10')][_0xb3f0('0x11')]({'port':0x232c});var client9002=jayson[_0xb3f0('0x10')]['http']({'port':0x232a});var client9003=jayson['client'][_0xb3f0('0x11')]({'port':0x232b});var client9001=jayson[_0xb3f0('0x10')]['http']({'port':0x2329});function respondWithRpcPromise(_0x26ebaf,_0x2e9b97,_0x10af85,_0x150167){return new BPromise(function(_0x14e13f,_0x2de4d4){var _0x58f87f=_0x150167||client;return _0x58f87f[_0xb3f0('0x12')](_0x26ebaf,_0x10af85)[_0xb3f0('0x13')](function(_0x23966b){logger[_0xb3f0('0x14')]('ChatWebsite,\x20%s,\x20%s',_0x2e9b97,'request\x20sent');logger[_0xb3f0('0x15')](_0xb3f0('0x16'),_0x2e9b97,_0xb3f0('0x17'),JSON['stringify'](_0x23966b));if(_0x23966b[_0xb3f0('0x18')]){if(_0x23966b[_0xb3f0('0x18')][_0xb3f0('0x19')]===0x1f4){logger[_0xb3f0('0x18')](_0xb3f0('0x1a'),_0x2e9b97,_0x23966b[_0xb3f0('0x18')][_0xb3f0('0x1b')]);return _0x2de4d4(_0x23966b[_0xb3f0('0x18')][_0xb3f0('0x1b')]);}logger['error'](_0xb3f0('0x1a'),_0x2e9b97,_0x23966b[_0xb3f0('0x18')][_0xb3f0('0x1b')]);return _0x14e13f(_0x23966b['error'][_0xb3f0('0x1b')]);}else{logger['info'](_0xb3f0('0x1a'),_0x2e9b97,_0xb3f0('0x17'));_0x14e13f(_0x23966b[_0xb3f0('0x1c')][_0xb3f0('0x1b')]);}})[_0xb3f0('0x1d')](function(_0x35b3b5){logger[_0xb3f0('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x2e9b97,_0x35b3b5);_0x2de4d4(_0x35b3b5);});});}function respondWithStatusCode(_0x4ae9de,_0x2baf56){_0x2baf56=_0x2baf56||0xcc;return function(_0x526e7f){if(_0x526e7f){return _0x4ae9de[_0xb3f0('0x1e')](_0x2baf56);}return _0x4ae9de[_0xb3f0('0x1f')](_0x2baf56)[_0xb3f0('0x20')]();};}function respondWithResult(_0x36443d,_0x473295){_0x473295=_0x473295||0xc8;return function(_0x2f9bd5){if(_0x2f9bd5){return _0x36443d['status'](_0x473295)[_0xb3f0('0x21')](_0x2f9bd5);}};}function respondWithFilteredResult(_0x4b4856,_0x436fb1){return function(_0x4f046b){if(_0x4f046b){var _0x3f7a7a=typeof _0x436fb1['offset']===_0xb3f0('0x22')&&typeof _0x436fb1[_0xb3f0('0x23')]===_0xb3f0('0x22');var _0xbfad27=_0x4f046b['count'];var _0x4d0c44=_0x3f7a7a?0x0:_0x436fb1['offset'];var _0xdb486b=_0x3f7a7a?_0x4f046b['count']:_0x436fb1[_0xb3f0('0x24')]+_0x436fb1[_0xb3f0('0x23')];var _0x3f8c92;if(_0xdb486b>=_0xbfad27){_0xdb486b=_0xbfad27;_0x3f8c92=0xc8;}else{_0x3f8c92=0xce;}_0x4b4856[_0xb3f0('0x1f')](_0x3f8c92);return _0x4b4856[_0xb3f0('0x25')](_0xb3f0('0x26'),_0x4d0c44+'-'+_0xdb486b+'/'+_0xbfad27)[_0xb3f0('0x21')](_0x4f046b);}return null;};}function saveUpdates(_0x1fc89b){return function(_0x2bfe4b){if(_0x2bfe4b){return _0x2bfe4b['update'](_0x1fc89b)[_0xb3f0('0x13')](function(_0xfa6297){return _0xfa6297;});}return null;};}function removeEntity(_0x2edcae){return function(_0x5bad58){if(_0x5bad58){return _0x5bad58[_0xb3f0('0x27')]()[_0xb3f0('0x13')](function(){var _0x2ddac8=_0x5bad58[_0xb3f0('0x28')]({'plain':!![]});var _0x23f1a2=_0xb3f0('0x29');return db[_0xb3f0('0x2a')]['destroy']({'where':{'type':_0x23f1a2,'resourceId':_0x2ddac8['id']}})[_0xb3f0('0x13')](function(){return _0x5bad58;});})[_0xb3f0('0x13')](function(){_0x2edcae[_0xb3f0('0x1f')](0xcc)[_0xb3f0('0x20')]();});}};}function handleEntityNotFound(_0x1a5516){return function(_0x26e198){if(!_0x26e198){_0x1a5516[_0xb3f0('0x1e')](0x194);}return _0x26e198;};}function handleError(_0x560f03,_0x1ffdc8){_0x1ffdc8=_0x1ffdc8||0x1f4;return function(_0x1c21ac){logger[_0xb3f0('0x18')](_0x1c21ac[_0xb3f0('0x2b')]);if(_0x1c21ac[_0xb3f0('0x2c')]){delete _0x1c21ac[_0xb3f0('0x2c')];}_0x560f03[_0xb3f0('0x1f')](_0x1ffdc8)[_0xb3f0('0x2d')](_0x1c21ac);};}exports[_0xb3f0('0x2e')]=function(_0x5e7aa7,_0x1fea84){var _0x54ff46={'include':[{'model':db[_0xb3f0('0x2f')],'as':_0xb3f0('0x30')}]},_0x22dc1a={},_0x27535d={'count':0x0,'rows':[]};var _0x5e8eff=_['map'](db[_0xb3f0('0x31')][_0xb3f0('0x32')],function(_0x58f93a){return{'name':_0x58f93a[_0xb3f0('0x33')],'type':_0x58f93a[_0xb3f0('0x34')]['key']};});_0x22dc1a['model']=_['map'](_0x5e8eff,_0xb3f0('0x2c'));_0x22dc1a[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x5e7aa7['query']);_0x22dc1a[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0x22dc1a[_0xb3f0('0x39')],_0x22dc1a[_0xb3f0('0x35')]);_0x54ff46[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0x22dc1a[_0xb3f0('0x39')],qs[_0xb3f0('0x3b')](_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x54ff46[_0xb3f0('0x3a')]=_0x54ff46[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x54ff46[_0xb3f0('0x3a')]:_0x22dc1a[_0xb3f0('0x39')];if(!_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x54ff46[_0xb3f0('0x23')]=qs[_0xb3f0('0x23')](_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x23')]);_0x54ff46[_0xb3f0('0x24')]=qs[_0xb3f0('0x24')](_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x24')]);}_0x54ff46['order']=qs[_0xb3f0('0x3f')](_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x54ff46['where']=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x5e7aa7[_0xb3f0('0x35')],_0x22dc1a[_0xb3f0('0x37')]),_0x5e8eff);if(_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x41')]){_0x54ff46[_0xb3f0('0x42')]=_[_0xb3f0('0x43')](_0x54ff46[_0xb3f0('0x42')],{'$or':_[_0xb3f0('0x44')](_0x5e8eff,function(_0x216419){if(_0x216419[_0xb3f0('0x34')]!==_0xb3f0('0x45')){var _0x5f2aa2={};_0x5f2aa2[_0x216419[_0xb3f0('0x2c')]]={'$like':'%'+_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x41')]+'%'};return _0x5f2aa2;}})});}_0x54ff46=_[_0xb3f0('0x43')]({},_0x54ff46,_0x5e7aa7[_0xb3f0('0x46')]);var _0x443143={'where':_0x54ff46[_0xb3f0('0x42')]};return db[_0xb3f0('0x31')][_0xb3f0('0x47')](_0x443143)[_0xb3f0('0x13')](function(_0x5dcfc3){_0x27535d[_0xb3f0('0x47')]=_0x5dcfc3;if(_0x5e7aa7[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x54ff46[_0xb3f0('0x49')]=[{'all':!![]}];}return db[_0xb3f0('0x31')][_0xb3f0('0x4a')](_0x54ff46);})['then'](function(_0x1feae4){_0x27535d[_0xb3f0('0x4b')]=_0x1feae4;return _0x27535d;})['then'](respondWithFilteredResult(_0x1fea84,_0x54ff46))[_0xb3f0('0x1d')](handleError(_0x1fea84,null));};exports[_0xb3f0('0x4c')]=function(_0x54e03d,_0x635a17){var _0x294613={'raw':![],'where':{'id':_0x54e03d['params']['id']},'include':[{'model':db[_0xb3f0('0x2f')],'as':_0xb3f0('0x30')}]},_0x5175cf={};_0x5175cf['model']=_['keys'](db[_0xb3f0('0x31')][_0xb3f0('0x32')]);_0x5175cf[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x54e03d[_0xb3f0('0x35')]);_0x5175cf[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0x5175cf[_0xb3f0('0x39')],_0x5175cf[_0xb3f0('0x35')]);_0x294613['attributes']=_[_0xb3f0('0x38')](_0x5175cf[_0xb3f0('0x39')],qs[_0xb3f0('0x3b')](_0x54e03d['query'][_0xb3f0('0x3b')]));_0x294613[_0xb3f0('0x3a')]=_0x294613[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x294613[_0xb3f0('0x3a')]:_0x5175cf[_0xb3f0('0x39')];if(_0x54e03d[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x294613['include']=[{'all':!![]}];}_0x294613=_['merge']({},_0x294613,_0x54e03d[_0xb3f0('0x46')]);return db[_0xb3f0('0x31')][_0xb3f0('0x4d')](_0x294613)['then'](handleEntityNotFound(_0x635a17,null))[_0xb3f0('0x13')](respondWithResult(_0x635a17,null))[_0xb3f0('0x1d')](handleError(_0x635a17,null));};exports[_0xb3f0('0x4e')]=function(_0x5f4c19,_0x1d5beb){return db['ChatWebsite'][_0xb3f0('0x4e')](_0x5f4c19[_0xb3f0('0x4f')],{})[_0xb3f0('0x13')](function(_0x59d10a){var _0x1b0311=_0x5f4c19[_0xb3f0('0x50')][_0xb3f0('0x28')]({'plain':!![]});if(!_0x1b0311)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1b0311[_0xb3f0('0x51')]===_0xb3f0('0x50')){var _0x4ca1ad=_0x59d10a[_0xb3f0('0x28')]({'plain':!![]});var _0x46152e=_0xb3f0('0x29');return db[_0xb3f0('0x52')]['find']({'where':{'name':_0x46152e,'userProfileId':_0x1b0311[_0xb3f0('0x53')]},'raw':!![]})[_0xb3f0('0x13')](function(_0x268444){if(_0x268444&&_0x268444[_0xb3f0('0x54')]===0x0){return db[_0xb3f0('0x2a')][_0xb3f0('0x4e')]({'name':_0x4ca1ad[_0xb3f0('0x2c')],'resourceId':_0x4ca1ad['id'],'type':_0x268444[_0xb3f0('0x2c')],'sectionId':_0x268444['id']},{})['then'](function(){return _0x59d10a;});}else{return _0x59d10a;}})[_0xb3f0('0x1d')](function(_0x169b77){logger['error'](_0xb3f0('0x55'),_0x169b77);throw _0x169b77;});}return _0x59d10a;})[_0xb3f0('0x13')](respondWithResult(_0x1d5beb,0xc9))[_0xb3f0('0x1d')](handleError(_0x1d5beb,null));};exports[_0xb3f0('0x56')]=function(_0x494f5c,_0x2a9f1e){if(_0x494f5c['body']['id']){delete _0x494f5c['body']['id'];}return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x494f5c[_0xb3f0('0x57')]['id']},'include':[{'model':db[_0xb3f0('0x2f')],'as':_0xb3f0('0x30')}]})['then'](handleEntityNotFound(_0x2a9f1e,null))['then'](saveUpdates(_0x494f5c[_0xb3f0('0x4f')],null))[_0xb3f0('0x13')](respondWithResult(_0x2a9f1e,null))[_0xb3f0('0x1d')](handleError(_0x2a9f1e,null));};exports['destroy']=function(_0x2d1d7a,_0x441b3f){return db[_0xb3f0('0x31')]['find']({'where':{'id':_0x2d1d7a['params']['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x441b3f,null))['then'](removeEntity(_0x441b3f,null))['catch'](handleError(_0x441b3f,null));};exports[_0xb3f0('0x58')]=function(_0x21a405,_0x284240){return db['ChatWebsite'][_0xb3f0('0x58')]()[_0xb3f0('0x13')](respondWithResult(_0x284240,null))['catch'](handleError(_0x284240,null));};exports[_0xb3f0('0x59')]=function(_0x3368c9,_0x3c3cfd){if(_0x3368c9[_0xb3f0('0x4f')]['id']){delete _0x3368c9[_0xb3f0('0x4f')]['id'];}return db[_0xb3f0('0x31')]['find']({'where':{'id':_0x3368c9[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x3c3cfd,null))[_0xb3f0('0x13')](function(_0x30732c){if(_0x30732c){_0x3368c9[_0xb3f0('0x4f')][_0xb3f0('0x5a')]=_0x30732c['id'];return db[_0xb3f0('0x5b')][_0xb3f0('0x4e')](_0x3368c9[_0xb3f0('0x4f')]);}})[_0xb3f0('0x13')](respondWithResult(_0x3c3cfd,null))[_0xb3f0('0x1d')](handleError(_0x3c3cfd,null));};exports[_0xb3f0('0x5c')]=function(_0x168998,_0x4e738a){var _0x58d0ea={'raw':![],'where':{}};var _0x58981d={};var _0x3e6d2b={'count':0x0,'rows':[]};return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x168998[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x4e738a,null))[_0xb3f0('0x13')](function(_0x3fee2f){if(_0x3fee2f){_0x58981d[_0xb3f0('0x39')]=_[_0xb3f0('0x36')](db[_0xb3f0('0x5b')][_0xb3f0('0x32')]);_0x58981d[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x168998[_0xb3f0('0x35')]);_0x58981d[_0xb3f0('0x37')]=_['intersection'](_0x58981d[_0xb3f0('0x39')],_0x58981d[_0xb3f0('0x35')]);_0x58d0ea[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0x58981d['model'],qs[_0xb3f0('0x3b')](_0x168998[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x58d0ea[_0xb3f0('0x3a')]=_0x58d0ea[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x58d0ea[_0xb3f0('0x3a')]:_0x58981d['model'];if(!_0x168998[_0xb3f0('0x35')][_0xb3f0('0x3d')]('nolimit')){_0x58d0ea[_0xb3f0('0x23')]=qs[_0xb3f0('0x23')](_0x168998['query'][_0xb3f0('0x23')]);_0x58d0ea[_0xb3f0('0x24')]=qs['offset'](_0x168998[_0xb3f0('0x35')]['offset']);}_0x58d0ea[_0xb3f0('0x5e')]=qs['sort'](_0x168998['query'][_0xb3f0('0x3f')]);_0x58d0ea[_0xb3f0('0x42')]=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x168998[_0xb3f0('0x35')],_0x58981d[_0xb3f0('0x37')]));_0x58d0ea[_0xb3f0('0x42')][_0xb3f0('0x5a')]=_0x3fee2f['id'];if(_0x168998[_0xb3f0('0x35')][_0xb3f0('0x41')]){_0x58d0ea[_0xb3f0('0x42')]=_['merge'](_0x58d0ea[_0xb3f0('0x42')],{'$or':_['map'](_0x58d0ea[_0xb3f0('0x3a')],function(_0x279c02){var _0x356874={};_0x356874[_0x279c02]={'$like':'%'+_0x168998['query'][_0xb3f0('0x41')]+'%'};return _0x356874;})});}_0x58d0ea=_['merge']({},_0x58d0ea,_0x168998[_0xb3f0('0x46')]);return db['Disposition'][_0xb3f0('0x47')]({'where':_0x58d0ea[_0xb3f0('0x42')]})[_0xb3f0('0x13')](function(_0x2f86a0){_0x3e6d2b['count']=_0x2f86a0;if(_0x168998[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x58d0ea[_0xb3f0('0x49')]=[{'all':!![]}];}return db[_0xb3f0('0x5b')][_0xb3f0('0x4a')](_0x58d0ea);})[_0xb3f0('0x13')](function(_0x3c0f55){_0x3e6d2b[_0xb3f0('0x4b')]=_0x3c0f55;return _0x3e6d2b;});}})[_0xb3f0('0x13')](respondWithFilteredResult(_0x4e738a,_0x58d0ea))['catch'](handleError(_0x4e738a,null));};exports[_0xb3f0('0x5f')]=function(_0x4c2f37,_0x1c217c){return db[_0xb3f0('0x31')]['find']({'where':{'id':_0x4c2f37[_0xb3f0('0x57')]['id']}})['then'](handleEntityNotFound(_0x1c217c,null))[_0xb3f0('0x13')](function(_0x3cb81c){if(_0x3cb81c){return _0x3cb81c[_0xb3f0('0x5f')](_0x4c2f37[_0xb3f0('0x35')][_0xb3f0('0x60')]);}})[_0xb3f0('0x13')](respondWithStatusCode(_0x1c217c,null))[_0xb3f0('0x1d')](handleError(_0x1c217c,null));};exports[_0xb3f0('0x61')]=function(_0x1d0176,_0x5d53e4){if(_0x1d0176[_0xb3f0('0x4f')]['id']){delete _0x1d0176[_0xb3f0('0x4f')]['id'];}return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x1d0176[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x5d53e4,null))[_0xb3f0('0x13')](function(_0x467110){if(_0x467110){_0x1d0176[_0xb3f0('0x4f')][_0xb3f0('0x5a')]=_0x467110['id'];return db[_0xb3f0('0x62')]['create'](_0x1d0176[_0xb3f0('0x4f')]);}})['then'](respondWithResult(_0x5d53e4,null))[_0xb3f0('0x1d')](handleError(_0x5d53e4,null));};exports[_0xb3f0('0x63')]=function(_0x53c02b,_0xca0040){var _0x458225={'raw':![],'where':{}};var _0x46b4d7={};var _0x5d0289={'count':0x0,'rows':[]};return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x53c02b[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0xca0040,null))['then'](function(_0x2f274c){if(_0x2f274c){_0x46b4d7['model']=_[_0xb3f0('0x36')](db[_0xb3f0('0x62')][_0xb3f0('0x32')]);_0x46b4d7[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x53c02b['query']);_0x46b4d7[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0x46b4d7['model'],_0x46b4d7[_0xb3f0('0x35')]);_0x458225[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0x46b4d7[_0xb3f0('0x39')],qs[_0xb3f0('0x3b')](_0x53c02b[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x458225[_0xb3f0('0x3a')]=_0x458225[_0xb3f0('0x3a')]['length']?_0x458225[_0xb3f0('0x3a')]:_0x46b4d7[_0xb3f0('0x39')];if(!_0x53c02b[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x458225[_0xb3f0('0x23')]=qs['limit'](_0x53c02b[_0xb3f0('0x35')][_0xb3f0('0x23')]);_0x458225[_0xb3f0('0x24')]=qs[_0xb3f0('0x24')](_0x53c02b[_0xb3f0('0x35')]['offset']);}_0x458225[_0xb3f0('0x5e')]=qs['sort'](_0x53c02b[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x458225[_0xb3f0('0x42')]=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x53c02b[_0xb3f0('0x35')],_0x46b4d7['filters']));_0x458225[_0xb3f0('0x42')][_0xb3f0('0x5a')]=_0x2f274c['id'];if(_0x53c02b['query']['filter']){_0x458225['where']=_[_0xb3f0('0x43')](_0x458225[_0xb3f0('0x42')],{'$or':_[_0xb3f0('0x44')](_0x458225[_0xb3f0('0x3a')],function(_0x4ea61b){var _0x23ce1b={};_0x23ce1b[_0x4ea61b]={'$like':'%'+_0x53c02b['query']['filter']+'%'};return _0x23ce1b;})});}_0x458225=_['merge']({},_0x458225,_0x53c02b[_0xb3f0('0x46')]);return db[_0xb3f0('0x62')][_0xb3f0('0x47')]({'where':_0x458225[_0xb3f0('0x42')]})['then'](function(_0x2ae805){_0x5d0289[_0xb3f0('0x47')]=_0x2ae805;if(_0x53c02b[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x458225[_0xb3f0('0x49')]=[{'all':!![]}];}return db[_0xb3f0('0x62')][_0xb3f0('0x4a')](_0x458225);})['then'](function(_0x1b3310){_0x5d0289['rows']=_0x1b3310;return _0x5d0289;});}})[_0xb3f0('0x13')](respondWithFilteredResult(_0xca0040,_0x458225))[_0xb3f0('0x1d')](handleError(_0xca0040,null));};exports['removeAnswers']=function(_0x127a4d,_0x272189){return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x127a4d[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x272189,null))['then'](function(_0x5789f2){if(_0x5789f2){return _0x5789f2[_0xb3f0('0x64')](_0x127a4d['query'][_0xb3f0('0x60')]);}})[_0xb3f0('0x13')](respondWithStatusCode(_0x272189,null))['catch'](handleError(_0x272189,null));};exports['addLogo']=function(_0x2f380d,_0x5b3f24){_0x2f380d[_0xb3f0('0x4f')][_0xb3f0('0x65')]=_0x2f380d[_0xb3f0('0x66')][_0xb3f0('0x67')];return db['ChatWebsite']['find']({'where':{'id':_0x2f380d[_0xb3f0('0x57')]['id']}})['then'](handleEntityNotFound(_0x5b3f24,null))[_0xb3f0('0x13')](saveUpdates(_0x2f380d[_0xb3f0('0x4f')],null))[_0xb3f0('0x13')](respondWithResult(_0x5b3f24,null))[_0xb3f0('0x1d')](handleError(_0x5b3f24,null));};exports['addAvatar']=function(_0x4482df,_0x43956b){_0x4482df[_0xb3f0('0x4f')][_0xb3f0('0x68')]=_0x4482df[_0xb3f0('0x66')]['filename'];return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x4482df[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x43956b,null))[_0xb3f0('0x13')](saveUpdates(_0x4482df[_0xb3f0('0x4f')],null))[_0xb3f0('0x13')](respondWithResult(_0x43956b,null))[_0xb3f0('0x1d')](handleError(_0x43956b,null));};exports['addCustomerAvatar']=function(_0x21c2d5,_0x43639b){_0x21c2d5['body']['customerAvatar']=_0x21c2d5['file'][_0xb3f0('0x67')];return db['ChatWebsite'][_0xb3f0('0x4d')]({'where':{'id':_0x21c2d5[_0xb3f0('0x57')]['id']}})['then'](handleEntityNotFound(_0x43639b,null))[_0xb3f0('0x13')](saveUpdates(_0x21c2d5[_0xb3f0('0x4f')],null))['then'](respondWithResult(_0x43639b,null))[_0xb3f0('0x1d')](handleError(_0x43639b,null));};exports['addSystemAvatar']=function(_0x47976e,_0x49149d){_0x47976e['body'][_0xb3f0('0x69')]=_0x47976e['file'][_0xb3f0('0x67')];return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x47976e[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x49149d,null))[_0xb3f0('0x13')](saveUpdates(_0x47976e[_0xb3f0('0x4f')],null))['then'](respondWithResult(_0x49149d,null))[_0xb3f0('0x1d')](handleError(_0x49149d,null));};exports['getLogo']=function(_0x3845e0,_0x22d72c){var _0x2afa0c=path['join'](config['root'],_0xb3f0('0x6a'));var _0x4be3e8={'where':{'id':_0x3845e0[_0xb3f0('0x57')]['id']},'attributes':['id',_0xb3f0('0x65')],'raw':!![]};var _0x3dc649=![];return require(_0xb3f0('0x6b'))[_0xb3f0('0x6c')]()[_0xb3f0('0x13')](function(_0x463519){if(_0x463519){_0x3dc649=_0x463519[_0xb3f0('0x6d')];}})[_0xb3f0('0x13')](function(){return db[_0xb3f0('0x31')]['find'](_0x4be3e8);})[_0xb3f0('0x13')](handleEntityNotFound(_0x22d72c,null))[_0xb3f0('0x13')](function(_0x5ebc1c){if(_0x5ebc1c){if(!_[_0xb3f0('0x6e')](_0x5ebc1c['sitepic'])){if(fs[_0xb3f0('0x6f')](path[_0xb3f0('0x70')](config['root'],_0xb3f0('0x71'),_0x5ebc1c[_0xb3f0('0x65')]))&&_0x3dc649){_0x2afa0c=path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],'server/files/images/logos/',_0x5ebc1c[_0xb3f0('0x65')]);}}return _0x22d72c['download'](_0x2afa0c);}})[_0xb3f0('0x1d')](handleError(_0x22d72c,null));};exports['getAvatar']=function(_0x37bcb9,_0x4ea8df){var _0xd570a7=path[_0xb3f0('0x70')](config['root'],'server/files/images/avatars/default_avatar.png');var _0x35b5c1={'where':{'id':_0x37bcb9['params']['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0xb3f0('0x31')][_0xb3f0('0x4d')](_0x35b5c1)[_0xb3f0('0x13')](handleEntityNotFound(_0x4ea8df,null))[_0xb3f0('0x13')](function(_0x17993f){if(_0x17993f){if(!_['isNil'](_0x17993f[_0xb3f0('0x68')])){if(fs['existsSync'](path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0x73'),_0x17993f['agentAvatar']))){_0xd570a7=path['join'](config[_0xb3f0('0x72')],_0xb3f0('0x73'),_0x17993f[_0xb3f0('0x68')]);}}return _0x4ea8df[_0xb3f0('0x74')](_0xd570a7);}})[_0xb3f0('0x1d')](handleError(_0x4ea8df,null));};exports[_0xb3f0('0x75')]=function(_0x50d256,_0x17dc1d){var _0x147357=path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],'server/files/images/avatars/customer_avatar.png');var _0x21f657={'where':{'id':_0x50d256['params']['id']},'attributes':['id',_0xb3f0('0x76'),_0xb3f0('0x77')],'raw':!![]};return db[_0xb3f0('0x31')][_0xb3f0('0x4d')](_0x21f657)[_0xb3f0('0x13')](handleEntityNotFound(_0x17dc1d,null))[_0xb3f0('0x13')](function(_0x246aeb){if(_0x246aeb){if(!_['isNil'](_0x246aeb['customerAvatar'])){if(fs[_0xb3f0('0x6f')](path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0x73'),_0x246aeb[_0xb3f0('0x76')]))&&_0x246aeb[_0xb3f0('0x77')]){_0x147357=path['join'](config[_0xb3f0('0x72')],_0xb3f0('0x73'),_0x246aeb[_0xb3f0('0x76')]);}}return _0x17dc1d[_0xb3f0('0x74')](_0x147357);}})[_0xb3f0('0x1d')](handleError(_0x17dc1d,null));};exports[_0xb3f0('0x78')]=function(_0x2f9edd,_0x42087e){var _0x2b80ef=path[_0xb3f0('0x70')](config['root'],_0xb3f0('0x79'));var _0x254d2c={'where':{'id':_0x2f9edd[_0xb3f0('0x57')]['id']},'attributes':['id',_0xb3f0('0x69')],'raw':!![]};return db['ChatWebsite'][_0xb3f0('0x4d')](_0x254d2c)[_0xb3f0('0x13')](handleEntityNotFound(_0x42087e,null))[_0xb3f0('0x13')](function(_0x501ae2){if(_0x501ae2){if(!_[_0xb3f0('0x6e')](_0x501ae2[_0xb3f0('0x69')])){if(fs['existsSync'](path[_0xb3f0('0x70')](config['root'],'server/files/images/avatars/',_0x501ae2[_0xb3f0('0x69')]))){_0x2b80ef=path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0x73'),_0x501ae2[_0xb3f0('0x69')]);}}return _0x42087e[_0xb3f0('0x74')](_0x2b80ef);}})[_0xb3f0('0x1d')](handleError(_0x42087e,null));};exports['notify']=function(_0x5a1c66,_0x23efdd){var _0x3c8e81=require(_0xb3f0('0x7a'));var _0x4f5d69=new _0x3c8e81();var _0x4b3ee1=_0x4f5d69[_0xb3f0('0x7b')](_0x5a1c66[_0xb3f0('0x7c')][_0xb3f0('0x7d')])[_0xb3f0('0x7e')]();var _0x221f5f={'body':_0x5a1c66[_0xb3f0('0x4f')],'channel':_0xb3f0('0x7f')};var _0x3279e1=[];var _0x1b99b5=[];var _0x2106c3={};var _0x3a2805=![];return db[_0xb3f0('0x80')][_0xb3f0('0x58')]()[_0xb3f0('0x13')](function(_0x544fde){if(!_0x544fde){throw new db['Sequelize']['ValidationError'](_0xb3f0('0x81'));}_0x3279e1=_[_0xb3f0('0x82')](_[_0xb3f0('0x36')](_0x544fde),[_0xb3f0('0x83'),_0xb3f0('0x84')]);_0x1b99b5=_['difference'](_['keys'](_0x544fde),[_0xb3f0('0x83'),_0xb3f0('0x84'),_0xb3f0('0x85'),_0xb3f0('0x86')]);if(_0x5a1c66['body']['id']){delete _0x5a1c66['body']['id'];}if(_['isNil'](_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x87')])){throw new db[(_0xb3f0('0x88'))][(_0xb3f0('0x89'))](_0xb3f0('0x8a'));}if(_[_0xb3f0('0x6e')](_0x5a1c66['body'][_0xb3f0('0x4f')])||_0x5a1c66['body'][_0xb3f0('0x4f')]===''){throw new db['Sequelize'][(_0xb3f0('0x89'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xb3f0('0x6e')](_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x8b')])){throw new db[(_0xb3f0('0x88'))][(_0xb3f0('0x89'))](_0xb3f0('0x8c')+_0x1b99b5);}if(!_[_0xb3f0('0x8d')](_0x1b99b5,_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x8b')])){throw new db[(_0xb3f0('0x88'))][(_0xb3f0('0x89'))](_0xb3f0('0x8e')+_0x1b99b5);}_0x2106c3[_0x5a1c66[_0xb3f0('0x4f')]['mapKey']]=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x87')];})[_0xb3f0('0x13')](function(){return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x5a1c66[_0xb3f0('0x57')]['id']},'include':[{'model':db[_0xb3f0('0x8f')],'as':_0xb3f0('0x90'),'include':[{'model':db[_0xb3f0('0x80')],'as':'Contacts','where':_0x2106c3,'limit':0x1,'order':[[_0xb3f0('0x84'),_0xb3f0('0x91')]]}]},{'model':db[_0xb3f0('0x92')],'as':_0xb3f0('0x93')}]});})[_0xb3f0('0x13')](handleEntityNotFound(_0x23efdd,null))[_0xb3f0('0x13')](function(_0x2362aa){if(_0x2362aa&&_0x2362aa[_0xb3f0('0x90')]){_0x221f5f['account']=_0x2362aa;_0x221f5f[_0xb3f0('0x94')]=_0x2362aa[_0xb3f0('0x93')];_0x221f5f[_0xb3f0('0x95')]=_0x2362aa[_0xb3f0('0x90')];_0x221f5f[_0xb3f0('0x94')]=_[_0xb3f0('0x96')](_0x221f5f[_0xb3f0('0x94')],['priority'],['asc']);if(_0x221f5f[_0xb3f0('0x97')][_0xb3f0('0x93')]){delete _0x221f5f[_0xb3f0('0x97')][_0xb3f0('0x93')];}if(_0x221f5f[_0xb3f0('0x97')][_0xb3f0('0x90')]&&_0x221f5f['account']['List'][_0xb3f0('0x98')][_0xb3f0('0x3c')]){return _0x221f5f[_0xb3f0('0x97')]['List'][_0xb3f0('0x98')][0x0];}var _0xe0613d=_[_0xb3f0('0xb')](_0x5a1c66[_0xb3f0('0x4f')],{'firstName':_0x5a1c66['body']['from'],'ListId':_0x2362aa[_0xb3f0('0x86')]});_0xe0613d[_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x8b')]]=_0x5a1c66['body'][_0xb3f0('0x87')];return db[_0xb3f0('0x80')]['create'](_0xe0613d,{'fields':_0x3279e1,'raw':!![]});}})[_0xb3f0('0x13')](handleEntityNotFound(_0x23efdd,null))[_0xb3f0('0x13')](function(_0x5a487e){_0x221f5f[_0xb3f0('0x99')]=_0x5a487e;var _0x4d5825=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0x9a')];if(_0x5a1c66[_0xb3f0('0x7c')]['cf-connecting-ip']){_0x4d5825=_0x5a1c66[_0xb3f0('0x7c')][_0xb3f0('0x9b')];}else if(_0x5a1c66[_0xb3f0('0x7c')]['x-forwarded-for']){_0x4d5825=_['first'](_0x5a1c66[_0xb3f0('0x7c')][_0xb3f0('0x9c')][_0xb3f0('0x9d')](','));}if(_0x5a487e){var _0x44deb8={'ContactId':_0x5a487e['id'],'ChatWebsiteId':_0x5a1c66[_0xb3f0('0x57')]['id'],'from':(_0x5a487e[_0xb3f0('0x9e')]||'')+'\x20'+(_0x5a487e[_0xb3f0('0x9f')]||''),'customerIp':_0x4d5825,'customerPort':_0x5a1c66[_0xb3f0('0x7c')][_0xb3f0('0xa0')]?_0x5a1c66[_0xb3f0('0x7c')][_0xb3f0('0xa0')]:null,'referer':_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xa1')],'browserName':_0x4b3ee1[_0xb3f0('0xa2')][_0xb3f0('0x2c')]&&_0x4b3ee1[_0xb3f0('0xa2')]['version']?util[_0xb3f0('0xa3')](_0xb3f0('0xa4'),_0x4b3ee1[_0xb3f0('0xa2')][_0xb3f0('0x2c')],_0x4b3ee1[_0xb3f0('0xa2')][_0xb3f0('0xa5')]):_0xb3f0('0xa6'),'browserVersion':_0x4b3ee1[_0xb3f0('0xa2')]['version']||_0xb3f0('0xa6'),'osName':util[_0xb3f0('0xa3')](_0xb3f0('0xa4'),_0x4b3ee1['os']['name'],_0x4b3ee1['os'][_0xb3f0('0xa5')]),'osVersion':_0x4b3ee1['os']['version'],'deviceModel':_0x4b3ee1['device'][_0xb3f0('0x39')]&&_0x4b3ee1['device']['vendor']?util[_0xb3f0('0xa3')](_0xb3f0('0xa7'),_0x4b3ee1[_0xb3f0('0xa8')][_0xb3f0('0x39')],_0x4b3ee1[_0xb3f0('0xa8')]['vendor'],_0x4b3ee1[_0xb3f0('0xa8')][_0xb3f0('0x34')]):null,'deviceVendor':_0x4b3ee1[_0xb3f0('0xa8')][_0xb3f0('0xa9')],'deviceType':_0x4b3ee1['device'][_0xb3f0('0x34')],'formData':JSON[_0xb3f0('0xaa')](_0x5a1c66[_0xb3f0('0x4f')])};var _0x5d64db={'ChatWebsiteId':_0x5a1c66[_0xb3f0('0x57')]['id'],'closed':![]};if(_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xab')]){_0x5d64db['threadId']=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xab')];return db[_0xb3f0('0xac')][_0xb3f0('0x4d')]({'where':_0x5d64db})['then'](function(_0x99b86f){if(_0x99b86f){return[_0x99b86f,![]];}_0x44deb8['threadId']=_0x5a1c66['body'][_0xb3f0('0xab')];_0x44deb8[_0xb3f0('0xad')]=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xad')];return db[_0xb3f0('0xac')]['create'](_0x44deb8)['then'](function(_0x4e99b7){return[_0x4e99b7,!![]];});});}_0x5d64db[_0xb3f0('0xae')]=_0x5a487e['id'];if(_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xaf')]&&_0x5a1c66['body']['interaction']['id']){_0x5d64db['id']=_0x5a1c66['body']['interaction']['id'];return db[_0xb3f0('0xac')][_0xb3f0('0x4d')]({'where':_0x5d64db})[_0xb3f0('0x13')](function(_0x52b941){if(_0x52b941){return[_0x52b941,![]];}return db[_0xb3f0('0xac')]['create'](_0x44deb8)[_0xb3f0('0x13')](function(_0xb3e5bb){return[_0xb3e5bb,!![]];});});}return db[_0xb3f0('0xac')][_0xb3f0('0x4e')](_0x44deb8)[_0xb3f0('0x13')](function(_0xbd433d){return[_0xbd433d,!![]];});}})[_0xb3f0('0xb0')](function(_0x2f8407,_0x5cda95){if(_0x2f8407){_0x3a2805=_0x5cda95;if(!_0x5cda95){var _0x5dedcf={'from':(_0x221f5f['contact'][_0xb3f0('0x9e')]||'')+'\x20'+(_0x221f5f[_0xb3f0('0x99')][_0xb3f0('0x9f')]||'')};if(_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xab')]&&_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xb1')]&&_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xab')]!=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xb1')]){_0x5dedcf[_0xb3f0('0xab')]=_0x5a1c66[_0xb3f0('0x4f')][_0xb3f0('0xb1')];}return _0x2f8407[_0xb3f0('0x56')](_0x5dedcf);}else{return _0x2f8407;}}})[_0xb3f0('0x13')](function(_0xb93c2e){_0x221f5f[_0xb3f0('0xaf')]=_0xb93c2e[_0xb3f0('0x28')]({'plain':!![]});_0x221f5f[_0xb3f0('0xaf')][_0xb3f0('0xb2')]=_0x3a2805;if(_0x221f5f[_0xb3f0('0xaf')][_0xb3f0('0xb2')]){if(_0x221f5f[_0xb3f0('0x97')]['autoclose']){_0x221f5f['applications']['push']({'id':0x0,'priority':_0x221f5f[_0xb3f0('0x94')][_0xb3f0('0x3c')]+0x1,'app':_0xb3f0('0xb3'),'appdata':_0xb3f0('0xb4'),'interval':'*,*,*,*'});}}return db[_0xb3f0('0xb5')][_0xb3f0('0x4e')]({'body':_0x5a1c66['body'][_0xb3f0('0x4f')],'ChatWebsiteId':_0x5a1c66[_0xb3f0('0x57')]['id'],'ChatInteractionId':_0xb93c2e['id'],'direction':'in','ContactId':_0x221f5f[_0xb3f0('0x99')]['id'],'AttachmentId':_0x5a1c66['body']['AttachmentId']});})['then'](function(_0x2f9a0d){_0x221f5f[_0xb3f0('0x1b')]=_0x2f9a0d;if(_0x221f5f[_0xb3f0('0xaf')][_0xb3f0('0xb6')]){return db[_0xb3f0('0xb7')][_0xb3f0('0x4d')]({'attributes':['id',_0xb3f0('0x2c')],'where':{'id':_0x221f5f[_0xb3f0('0xaf')][_0xb3f0('0xb6')]}})[_0xb3f0('0x13')](function(_0x59bb69){if(_0x59bb69){_0x221f5f[_0xb3f0('0x94')][_0xb3f0('0xb8')]({'id':0x0,'priority':0x0,'app':_0xb3f0('0xb9'),'appdata':_0x59bb69[_0xb3f0('0x2c')]+','+(_0x221f5f[_0xb3f0('0x97')]['waitForTheAssignedAgent']||0xa),'interval':_0xb3f0('0xba')});_0x221f5f[_0xb3f0('0xbb')]=!![];}return respondWithRpcPromise('Start',_0xb3f0('0xbc'),_0x221f5f);});}return respondWithRpcPromise('Start',_0xb3f0('0xbc'),_0x221f5f);})['then'](function(_0x783ba0){respondWithRpcPromise(_0xb3f0('0xbd'),_0xb3f0('0xbd'),{'event':_0xb3f0('0xbe'),'message':_0x783ba0},client9002);return _0x783ba0;})[_0xb3f0('0x13')](respondWithResult(_0x23efdd,null))[_0xb3f0('0x1d')](handleError(_0x23efdd,null));};exports[_0xb3f0('0xbf')]=function(_0x2a52ba,_0x3e3021){var _0x49e913,_0x465f15,_0x38b5d9;var _0x1c2ba7=[];var _0x4a3828={};var _0x48ba32=_0x2a52ba['files']||[];var _0xddec5e=[];var _0x2ad981;return db[_0xb3f0('0x80')]['describe']()['then'](function(_0x33228c){if(!_0x33228c){throw new db[(_0xb3f0('0x88'))][(_0xb3f0('0x89'))](_0xb3f0('0x81'));}_0x1c2ba7=_[_0xb3f0('0x82')](_['keys'](_0x33228c),['createdAt',_0xb3f0('0x84'),'CompanyId',_0xb3f0('0x86')]);if(_0x2a52ba['body']['id']){delete _0x2a52ba['body']['id'];}if(_[_0xb3f0('0x6e')](_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0x87')])){throw _0x3e3021[_0xb3f0('0x1f')](0x1f4)[_0xb3f0('0x2d')](new db['Sequelize'][(_0xb3f0('0x89'))]('from\x20is\x20mandatory'));}if(_[_0xb3f0('0x6e')](_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0x4f')])||_0x2a52ba['body']['body']===''){throw _0x3e3021[_0xb3f0('0x1f')](0x1f4)[_0xb3f0('0x2d')](new db[(_0xb3f0('0x88'))]['ValidationError'](_0xb3f0('0xc0')));}if(_[_0xb3f0('0x6e')](_0x2a52ba[_0xb3f0('0x4f')]['mapKeyOffline'])){throw _0x3e3021['status'](0x1f4)[_0xb3f0('0x2d')](new db[(_0xb3f0('0x88'))]['ValidationError'](_0xb3f0('0xc1')+_0x1c2ba7));}if(!_[_0xb3f0('0x8d')](_0x1c2ba7,_0x2a52ba[_0xb3f0('0x4f')]['mapKeyOffline'])){throw _0x3e3021['status'](0x1f4)[_0xb3f0('0x2d')](new db[(_0xb3f0('0x88'))][(_0xb3f0('0x89'))](_0xb3f0('0xc2')+_0x1c2ba7));}_0x4a3828[_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0xc3')]]=_0x2a52ba['body'][_0xb3f0('0x87')];})['then'](function(){return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x2a52ba[_0xb3f0('0x57')]['id']},'include':[{'model':db['CmList'],'as':_0xb3f0('0x90')},{'model':db[_0xb3f0('0xc4')],'as':_0xb3f0('0xc4')}]});})[_0xb3f0('0x13')](handleEntityNotFound(_0x3e3021,null))['then'](function(_0x170cc5){if(_0x170cc5&&_0x170cc5[_0xb3f0('0x90')]){_0x465f15=_0x170cc5;var _0x40e2fa=_[_0xb3f0('0xb')](_0x2a52ba[_0xb3f0('0x4f')],{'firstName':_0x2a52ba['body'][_0xb3f0('0x87')],'phone':_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0x87')],'ListId':_0x170cc5['ListId']});_0x40e2fa[_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0xc3')]]=_0x2a52ba[_0xb3f0('0x4f')]['from'];return db['CmContact']['findOrCreate']({'where':_0x4a3828,'defaults':_0x40e2fa});}})[_0xb3f0('0xb0')](function(_0xadd3cc){if(_0xadd3cc){_0x38b5d9=_0xadd3cc;var _0x2ce352=fs[_0xb3f0('0xc5')](path['join'](config[_0xb3f0('0x72')],_0xb3f0('0xc6')),_0xb3f0('0xc7'));var _0x217651=ejs[_0xb3f0('0xc8')](_0x2ce352,{'body':_['toPairs'](_0x2a52ba[_0xb3f0('0x4f')][_0xb3f0('0x4f')]),'bodyTitle':_0x465f15['offlineMessageBody']});return db[_0xb3f0('0xc9')]['create']({'body':_0x217651,'plainBody':htmlToText['fromString'](_0x217651),'ContactId':_0xadd3cc['id'],'ChatWebsiteId':_0x465f15['id']});}})[_0xb3f0('0x13')](function(_0x172ef0){_0x2ad981=_0x172ef0;if(_0x48ba32[_0xb3f0('0x3c')]){var _0x3f5504=_0x48ba32['map'](function(_0x35a6cb){return{'name':_0x35a6cb[_0xb3f0('0xca')],'basename':_0x35a6cb[_0xb3f0('0x67')],'type':_0x35a6cb[_0xb3f0('0xcb')],'ChatOfflineMessageId':_0x172ef0['id']};});_0xddec5e=_0x3f5504['map'](_0x21b6fa=>{var _0x56357a={'filename':_0x21b6fa[_0xb3f0('0x2c')],'path':path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0xcc'),_0xb3f0('0xcd'),_0xb3f0('0xce'),_0xb3f0('0xcf'),_0x21b6fa['basename'])};return _0x56357a;});if(!_0x465f15[_0xb3f0('0xd0')]){return db[_0xb3f0('0xd1')][_0xb3f0('0xd2')](function(_0x5e884d){return db[_0xb3f0('0xd3')][_0xb3f0('0xd4')](_0x3f5504,{'transaction':_0x5e884d});});}}})[_0xb3f0('0x13')](function(){if(_0x2ad981){_0x49e913=_0x2ad981;return db[_0xb3f0('0xc4')]['findOne']({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xb3f0('0xd5'),'raw':!![],'include':[{'model':db[_0xb3f0('0xd6')],'as':_0xb3f0('0xd6'),'raw':!![]}]}]});}})['then'](function(_0x58e593){if(_0x58e593&&_0x58e593[_0xb3f0('0xd5')]&&_0x465f15['forwardOffline']&&_0x465f15[_0xb3f0('0xd7')]){var _0x5f266d=_0x58e593[_0xb3f0('0xd8')]();return respondWithRpcPromise(_0xb3f0('0xd9'),'sendMail',{'account':_0x5f266d,'message':{'from':util[_0xb3f0('0xa3')](_0xb3f0('0xda'),_0x58e593[_0xb3f0('0x2c')],_0x58e593[_0xb3f0('0xdb')]||_0x58e593[_0xb3f0('0xd5')][_0xb3f0('0x50')]),'to':_0x465f15[_0xb3f0('0xd7')],'subject':_0x465f15[_0xb3f0('0xdc')],'html':_0x49e913['body'],'attachments':_0xddec5e}},client9003)[_0xb3f0('0x13')](function(){return _0x49e913;})['catch'](function(_0x2748ca){logger[_0xb3f0('0x18')](_0x2748ca);});}})[_0xb3f0('0x13')](function(){if(_0x465f15&&_0x465f15[_0xb3f0('0xd0')]&&_0x465f15['MailAccountId']){var _0x252dbd=[];if(_0x48ba32['length']){_0x252dbd=_0x48ba32[_0xb3f0('0x44')](function(_0x3da7d5){return{'name':_0x3da7d5[_0xb3f0('0xca')],'basename':_0x3da7d5[_0xb3f0('0x67')],'type':_0x3da7d5['mimetype'],'ChatOfflineMessageId':_0x2ad981['id']};});}var _0x653f99;if(!_[_0xb3f0('0x6e')](_0x465f15[_0xb3f0('0xdd')])){var _0x39db37=_['map'](_0x2a52ba['body'],function(_0x573e74){return _0x573e74;});var _0x1c6010=_[_0xb3f0('0xde')](_0x39db37)[0x0];var _0x4c6c6e=_[_0xb3f0('0xdf')](_0x1c6010,function(_0x5ecae3){return _0x5ecae3;});_0x653f99=_0x4c6c6e[0x1][_0x465f15[_0xb3f0('0xdd')]];}var _0x11d84f={'from':_0x38b5d9[_0xb3f0('0xdb')],'firstName':_0x38b5d9[_0xb3f0('0x9e')],'lastName':_0x38b5d9[_0xb3f0('0x9f')],'mapKey':_0xb3f0('0xdb'),'message':{'from':_0x38b5d9['email'],'to':_0x465f15[_0xb3f0('0xc4')][_0xb3f0('0xdb')],'cc':'','subject':_['isNil'](_0x653f99)?_0x465f15['offlineMessageSubject']:_0x653f99,'messageId':'','sentAt':new Date(),'attach':_0x252dbd[_0xb3f0('0x3c')],'attachments':_0x252dbd,'originChannel':_0xb3f0('0xe0'),'ChatWebsiteId':_0x465f15['id'],'ChatOfflineMessageId':_0x49e913['id'],'originTo':_0x465f15['MailAccount'][_0xb3f0('0xdb')]},'body':_0x49e913[_0xb3f0('0x4f')]};var _0x153197={'account':{'id':_0x465f15[_0xb3f0('0xe1')]},'body':_0x11d84f,'log':'NotifyMailAccount'};return respondWithRpcPromise('NotifyMailAccount',_0xb3f0('0xe2'),_0x153197,client9001)['then'](function(){return _0x49e913;})[_0xb3f0('0x1d')](function(_0x4b16f2){logger[_0xb3f0('0x18')](_0x4b16f2);});}return;})[_0xb3f0('0x13')](function(){if(_0x49e913){return _0x49e913;}})[_0xb3f0('0x13')](respondWithResult(_0x3e3021,null))[_0xb3f0('0x1d')](function(_0x17c921){logger[_0xb3f0('0x18')](_0xb3f0('0x1d'),_0x17c921);for(var _0x4ce163 of _0x48ba32){var _0x224566=path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0xcc'),_0xb3f0('0xcd'),_0xb3f0('0xce'),_0xb3f0('0xcf'),_0x4ce163['filename']);fs_extra[_0xb3f0('0xe3')](_0x224566)[_0xb3f0('0x1d')](function(_0x5c44d5){logger[_0xb3f0('0x18')](_0xb3f0('0xe4'),_0x224566,_0x5c44d5);});}});};exports['addInteraction']=function(_0x3e61f8,_0x2770d5){return db[_0xb3f0('0xac')][_0xb3f0('0x4d')]({'where':{'id':_0x3e61f8[_0xb3f0('0x57')]['id']}})['then'](handleEntityNotFound(_0x2770d5,null))[_0xb3f0('0x13')](function(_0xe413cb){if(_0xe413cb){return _0xe413cb[_0xb3f0('0xe5')](_0x3e61f8['body'][_0xb3f0('0x60')],_['omit'](_0x3e61f8[_0xb3f0('0x4f')],[_0xb3f0('0x60'),'id'])||{});}})['then'](respondWithResult(_0x2770d5,null))[_0xb3f0('0x1d')](handleError(_0x2770d5,null));};exports['getInteractions']=function(_0x4c13bd,_0x1db8d3){var _0x51ae42={'raw':![],'where':{}};var _0x48df58={};var _0x8394cd={'count':0x0,'rows':[]};return db[_0xb3f0('0x31')]['findOne']({'where':{'id':_0x4c13bd[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x1db8d3,null))[_0xb3f0('0x13')](function(_0x2cac1c){if(_0x2cac1c){_0x48df58[_0xb3f0('0x39')]=_['keys'](db[_0xb3f0('0xac')][_0xb3f0('0x32')]);_0x48df58[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x4c13bd[_0xb3f0('0x35')]);_0x48df58['filters']=_['intersection'](_0x48df58[_0xb3f0('0x39')],_0x48df58['query']);_0x51ae42[_0xb3f0('0x3a')]=_['intersection'](_0x48df58['model'],qs[_0xb3f0('0x3b')](_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x51ae42[_0xb3f0('0x3a')]=_0x51ae42[_0xb3f0('0x3a')]['length']?_0x51ae42['attributes']:_0x48df58[_0xb3f0('0x39')];if(!_0x4c13bd['query'][_0xb3f0('0x3d')]('nolimit')){_0x51ae42['limit']=qs['limit'](_0x4c13bd[_0xb3f0('0x35')]['limit']);_0x51ae42[_0xb3f0('0x24')]=qs[_0xb3f0('0x24')](_0x4c13bd['query'][_0xb3f0('0x24')]);}_0x51ae42['order']=qs[_0xb3f0('0x3f')](_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x51ae42[_0xb3f0('0x42')]=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x4c13bd[_0xb3f0('0x35')],_0x48df58['filters']));_0x51ae42[_0xb3f0('0x42')][_0xb3f0('0x5a')]=_0x2cac1c['id'];if(_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0x41')]){_0x51ae42['where']=_[_0xb3f0('0x43')](_0x51ae42[_0xb3f0('0x42')],{'$or':_[_0xb3f0('0x44')](_0x51ae42[_0xb3f0('0x3a')],function(_0x96998c){var _0x3862cd={};_0x3862cd[_0x96998c]={'$like':'%'+_0x4c13bd[_0xb3f0('0x35')]['filter']+'%'};return _0x3862cd;})});}_0x51ae42=_[_0xb3f0('0x43')]({},_0x51ae42,_0x4c13bd[_0xb3f0('0x46')]);return db[_0xb3f0('0xac')][_0xb3f0('0x47')]({'where':_0x51ae42[_0xb3f0('0x42')]})[_0xb3f0('0x13')](function(_0x453e1c){_0x8394cd[_0xb3f0('0x47')]=_0x453e1c;if(_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x51ae42[_0xb3f0('0x49')]=[{'model':db[_0xb3f0('0x80')],'as':'Contact','required':![]},{'model':db[_0xb3f0('0xb7')],'as':_0xb3f0('0xe6'),'attributes':[_0xb3f0('0x2c'),_0xb3f0('0xe7'),_0xb3f0('0xe8')],'required':![]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0xb3f0('0x2c'),_0xb3f0('0xe9')],'where':_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0xea')]?{'id':_0x4c13bd[_0xb3f0('0x35')][_0xb3f0('0xea')]}:undefined,'required':_0x4c13bd[_0xb3f0('0x35')]['tag']?!![]:![]}];}return db[_0xb3f0('0xac')]['findAll'](_0x51ae42);})[_0xb3f0('0x13')](function(_0x455779){_0x8394cd[_0xb3f0('0x4b')]=_0x455779;return _0x8394cd;});}})[_0xb3f0('0x13')](respondWithFilteredResult(_0x1db8d3,_0x51ae42))[_0xb3f0('0x1d')](handleError(_0x1db8d3,null));};function iftimePromise(_0x16cbe7,_0x32c6e1){return respondWithRpcPromise('Command',_0xb3f0('0xeb'),{'command':_0x32c6e1[_0xb3f0('0xec')]?util[_0xb3f0('0xa3')](_0xb3f0('0xed'),_0x16cbe7[_0xb3f0('0xee')],_0x32c6e1['timezone']):util[_0xb3f0('0xa3')](_0xb3f0('0xef'),_0x16cbe7[_0xb3f0('0xee')])},client9002)[_0xb3f0('0x13')](function(_0x349dff){var _0x6f32bf=_0x349dff&&_0x349dff['indexOf'](_0xb3f0('0xf0'))>=0x0?!![]:![];logger[_0xb3f0('0x14')](_0xb3f0('0xf1'),_0x32c6e1['id'],_0x16cbe7['id'],_0x16cbe7[_0xb3f0('0xee')],_0x6f32bf?_0xb3f0('0xf2'):_0xb3f0('0xf3'),_0x32c6e1[_0xb3f0('0xec')]?_0x32c6e1[_0xb3f0('0xec')]:_0xb3f0('0xf4'));return _0x6f32bf;})[_0xb3f0('0x1d')](function(_0xfadeef){logger[_0xb3f0('0x18')](_0xb3f0('0xf1'),_0x32c6e1['id'],_0x16cbe7['id'],_0x16cbe7['interval'],util[_0xb3f0('0xf5')](_0xfadeef,{'showHidden':![],'depth':null}),_0x32c6e1['timezone']?_0x32c6e1[_0xb3f0('0xec')]:_0xb3f0('0xf4'));return![];});}exports[_0xb3f0('0xeb')]=function(_0x2393d5,_0x140993){var _0x57495b=0x0;var _0x4c90e7=0x0;var _0x2425ee=![];var _0x595163;var _0x5d953e;return db['ChatWebsite'][_0xb3f0('0x4d')]({'where':{'id':_0x2393d5[_0xb3f0('0x57')]['id']},'include':[{'model':db[_0xb3f0('0xf6')],'as':_0xb3f0('0xf6'),'include':[{'model':db[_0xb3f0('0xf6')],'as':'Intervals','attributes':['id','interval'],'raw':!![]}]}]})[_0xb3f0('0x13')](handleEntityNotFound(_0x140993,null))['then'](function(_0x3048bf){if(_0x3048bf){_0x595163=_0x3048bf;return _0x3048bf[_0xb3f0('0xf7')]({'raw':!![]});}})['then'](function(_0x2d4336){if(_0x595163){if(_0x2d4336){_0x5d953e=_0x2d4336;}}return require(_0xb3f0('0x6b'))[_0xb3f0('0x6c')]();})['then'](function(_0x1dbdf4){if(_0x1dbdf4){_0x4c90e7=_0x1dbdf4[_0xb3f0('0xf8')];_0x2425ee=_0x1dbdf4['custom'];}})[_0xb3f0('0x13')](function(){return db[_0xb3f0('0xac')]['count']({'where':{'closed':![]}});})[_0xb3f0('0x13')](function(_0x3c252d){_0x57495b=_0x3c252d;if(_0x4c90e7&&_0x3c252d>_0x4c90e7){return db[_0xb3f0('0xf9')][_0xb3f0('0x5d')]({'where':{'id':0x1}})[_0xb3f0('0x13')](function(_0x126622){if(_0x126622){_0x126622[_0xb3f0('0xfa')](_0xb3f0('0xfb'));}});}})[_0xb3f0('0x13')](function(){if(_0x595163[_0xb3f0('0xf6')]&&_0x595163[_0xb3f0('0xf6')][_0xb3f0('0xfc')]){var _0x58dc9f=[];for(var _0x239c49=0x0;_0x239c49<_0x595163[_0xb3f0('0xf6')][_0xb3f0('0xfc')][_0xb3f0('0x3c')];_0x239c49++){var _0x28b3d1=_0x595163[_0xb3f0('0xf6')]['Intervals'][_0x239c49][_0xb3f0('0x28')]({'plain':!![]});_0x58dc9f[_0xb3f0('0xfd')](iftimePromise(_0x28b3d1,_0x595163));}return BPromise['all'](_0x58dc9f)[_0xb3f0('0x13')](function(_0x11eb67){return _[_0xb3f0('0xfe')](_0x11eb67);});}else{return!![];}})['then'](function(_0x16cff3){var _0x180611=fs[_0xb3f0('0xc5')](path[_0xb3f0('0x70')](config[_0xb3f0('0x72')],_0xb3f0('0xff')),_0xb3f0('0xc7'));var _0x53e6db=new url[(_0xb3f0('0x100'))](_0x595163[_0xb3f0('0x101')])['origin'];var _0x3d9d5d=_0xb3f0('0x102');var _0xe04bd6=![];var _0x12d02d={'chatVersion':_0x3d9d5d,'chatWebsiteAddressOrigin':_0x53e6db,'remote':_0x595163[_0xb3f0('0x103')],'query':querystring[_0xb3f0('0xaa')](_[_0xb3f0('0x43')](_0x595163[_0xb3f0('0x28')]({'plain':!![]}),{'customerIp':_0x2393d5['headers'][_0xb3f0('0x9c')]||_0x2393d5[_0xb3f0('0x7c')][_0xb3f0('0x104')]||_0x2393d5[_0xb3f0('0x105')]['remoteAddress']||_0x2393d5['ip'],'referer':_0x2393d5[_0xb3f0('0x7c')][_0xb3f0('0xa1')],'openedInteractions':_0x57495b,'maxInteractions':_0x4c90e7,'virtual':_0x2425ee[_0xb3f0('0xf8')],'online':_0x16cff3,'custom':_0x2425ee}))[_0xb3f0('0x106')](/'/g,'\x5c\x27')};_0x140993[_0xb3f0('0x2d')](ejs[_0xb3f0('0xc8')](Mustache[_0xb3f0('0xc8')](_0x180611,_0x12d02d),{'proactiveActions':_0x5d953e,'alignment':_0x595163['alignment'],'verticalAlignment':_0x595163['verticalAlignment'],'div_color':_0x595163[_0xb3f0('0xe9')],'labelText':_0x595163[_0xb3f0('0x107')],'text_color':_0x595163[_0xb3f0('0x108')],'text_button_color':_0x595163[_0xb3f0('0x109')],'button_color':_0x595163[_0xb3f0('0x10a')],'background_color':_0x595163['backgroundColor'],'hideWhenOffline':_0x595163[_0xb3f0('0x10b')],'intervalId':_0x595163[_0xb3f0('0x10c')],'isDevelopment':_0xe04bd6,'chatVersion':_0x3d9d5d}));})['catch'](handleError(_0x140993,null));};exports['addApplications']=function(_0x345700,_0x506a67){var _0x7746c9=_0x345700[_0xb3f0('0x57')]['id'];var _0x200d23=_0x345700[_0xb3f0('0x4f')];var _0x511263=0xc8;var _0x12a6f1=null;return db[_0xb3f0('0xd1')][_0xb3f0('0xd2')]({'isolationLevel':db[_0xb3f0('0xd1')][_0xb3f0('0x10d')][_0xb3f0('0x10e')][_0xb3f0('0x10f')]},function(_0x16036d){return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x7746c9},'transaction':_0x16036d})['then'](function(_0x456ade){if(_0x456ade){return db[_0xb3f0('0x92')]['destroy']({'where':{'ChatWebsiteId':_0x7746c9},'transaction':_0x16036d})['then'](function(){var _0x2a81e4=_[_0xb3f0('0x44')](_0x200d23,function(_0x345a27){_0x345a27['ChatWebsiteId']=_0x7746c9;return _0x345a27;});return db[_0xb3f0('0x92')][_0xb3f0('0xd4')](_0x2a81e4,{'transaction':_0x16036d});});}else{_0x511263=0x194;_0x12a6f1=[];}});})[_0xb3f0('0x13')](function(){if(_0x511263!==0x194){return db[_0xb3f0('0x92')][_0xb3f0('0x110')]({'where':{'ChatWebsiteId':_0x7746c9},'order':_0xb3f0('0x111')})[_0xb3f0('0x13')](function(_0x514fc4){_0x12a6f1=_0x514fc4;});}})['catch'](function(_0x2e1ac5){_0x511263=0x1f4;logger['error'](_0x2e1ac5[_0xb3f0('0x2b')]);if(_0x2e1ac5[_0xb3f0('0x2c')]){delete _0x2e1ac5['name'];}_0x12a6f1=_0x2e1ac5;})[_0xb3f0('0x112')](function(){if(_0x12a6f1===null){_0x506a67[_0xb3f0('0x1e')](_0x511263);}else{if(_0x511263===0x1f4){_0x506a67[_0xb3f0('0x1f')](_0x511263)['send'](_0x12a6f1);}else{_0x506a67['status'](_0x511263)[_0xb3f0('0x21')](_0x12a6f1);}}});};exports[_0xb3f0('0x113')]=function(_0x54e7df,_0x289d3b){var _0x17b7af={};var _0x57a441={};var _0x433a9f;var _0x5d67b1;return db[_0xb3f0('0x31')]['findOne']({'where':{'id':_0x54e7df[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x289d3b,null))['then'](function(_0x4eff45){if(_0x4eff45){_0x433a9f=_0x4eff45;_0x57a441[_0xb3f0('0x39')]=_['keys'](db[_0xb3f0('0x92')][_0xb3f0('0x32')]);_0x57a441[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x54e7df[_0xb3f0('0x35')]);_0x57a441[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0x57a441[_0xb3f0('0x39')],_0x57a441[_0xb3f0('0x35')]);_0x17b7af[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0x57a441[_0xb3f0('0x39')],qs['fields'](_0x54e7df[_0xb3f0('0x35')]['fields']));_0x17b7af[_0xb3f0('0x3a')]=_0x17b7af[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x17b7af[_0xb3f0('0x3a')]:_0x57a441['model'];_0x17b7af[_0xb3f0('0x5e')]=qs[_0xb3f0('0x3f')](_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x17b7af[_0xb3f0('0x42')]=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x54e7df['query'],_0x57a441[_0xb3f0('0x37')]));if(_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x41')]){_0x17b7af[_0xb3f0('0x42')]=_[_0xb3f0('0x43')](_0x17b7af[_0xb3f0('0x42')],{'$or':_[_0xb3f0('0x44')](_0x17b7af[_0xb3f0('0x3a')],function(_0x4ebc10){var _0x304bcf={};_0x304bcf[_0x4ebc10]={'$like':'%'+_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x41')]+'%'};return _0x304bcf;})});}_0x17b7af=_[_0xb3f0('0x43')]({},_0x17b7af,_0x54e7df[_0xb3f0('0x46')]);return _0x433a9f[_0xb3f0('0x113')](_0x17b7af);}})[_0xb3f0('0x13')](function(_0x2b8629){if(_0x2b8629){_0x5d67b1=_0x2b8629[_0xb3f0('0x3c')];if(!_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x17b7af[_0xb3f0('0x23')]=qs['limit'](_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x23')]);_0x17b7af[_0xb3f0('0x24')]=qs[_0xb3f0('0x24')](_0x54e7df[_0xb3f0('0x35')][_0xb3f0('0x24')]);}return _0x433a9f[_0xb3f0('0x113')](_0x17b7af);}})['then'](function(_0x5b7dfc){if(_0x5b7dfc){return _0x5b7dfc?{'count':_0x5d67b1,'rows':_0x5b7dfc}:null;}})[_0xb3f0('0x13')](respondWithResult(_0x289d3b,null))[_0xb3f0('0x1d')](handleError(_0x289d3b,null));};exports['addProactiveActions']=function(_0xa828d1,_0x33b2c6){return db['chatProactiveAction'][_0xb3f0('0x4d')]({'where':{'id':_0xa828d1['params']['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x33b2c6,null))[_0xb3f0('0x13')](function(_0x1ce5e3){if(_0x1ce5e3){return _0x1ce5e3['addProactiveActions'](_0xa828d1[_0xb3f0('0x4f')][_0xb3f0('0x60')],_[_0xb3f0('0x114')](_0xa828d1[_0xb3f0('0x4f')],['ids','id'])||{});}})['then'](respondWithResult(_0x33b2c6,null))['catch'](handleError(_0x33b2c6,null));};exports[_0xb3f0('0xf7')]=function(_0x5b43d2,_0x11c4a7){var _0x586aef={};var _0x5daef9={};var _0x3b0bae;var _0x4ed00f;return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x5b43d2[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x11c4a7,null))['then'](function(_0xb74082){if(_0xb74082){_0x3b0bae=_0xb74082;_0x5daef9['model']=_[_0xb3f0('0x36')](db[_0xb3f0('0x115')]['rawAttributes']);_0x5daef9[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x5b43d2[_0xb3f0('0x35')]);_0x5daef9[_0xb3f0('0x37')]=_['intersection'](_0x5daef9[_0xb3f0('0x39')],_0x5daef9[_0xb3f0('0x35')]);_0x586aef['attributes']=_[_0xb3f0('0x38')](_0x5daef9['model'],qs[_0xb3f0('0x3b')](_0x5b43d2[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x586aef[_0xb3f0('0x3a')]=_0x586aef[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x586aef[_0xb3f0('0x3a')]:_0x5daef9[_0xb3f0('0x39')];_0x586aef['order']=qs[_0xb3f0('0x3f')](_0x5b43d2[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x586aef[_0xb3f0('0x42')]=qs[_0xb3f0('0x37')](_[_0xb3f0('0x40')](_0x5b43d2[_0xb3f0('0x35')],_0x5daef9['filters']));if(_0x5b43d2['query'][_0xb3f0('0x41')]){_0x586aef['where']=_['merge'](_0x586aef['where'],{'$or':_['map'](_0x586aef['attributes'],function(_0x22fc46){var _0x2fbf01={};_0x2fbf01[_0x22fc46]={'$like':'%'+_0x5b43d2['query'][_0xb3f0('0x41')]+'%'};return _0x2fbf01;})});}_0x586aef=_[_0xb3f0('0x43')]({},_0x586aef,_0x5b43d2[_0xb3f0('0x46')]);return _0x3b0bae[_0xb3f0('0xf7')](_0x586aef);}})[_0xb3f0('0x13')](function(_0x19a6b1){if(_0x19a6b1){_0x4ed00f=_0x19a6b1['length'];if(!_0x5b43d2[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x586aef[_0xb3f0('0x23')]=qs['limit'](_0x5b43d2[_0xb3f0('0x35')][_0xb3f0('0x23')]);_0x586aef['offset']=qs['offset'](_0x5b43d2[_0xb3f0('0x35')][_0xb3f0('0x24')]);}return _0x3b0bae[_0xb3f0('0xf7')](_0x586aef);}})[_0xb3f0('0x13')](function(_0x2e769c){if(_0x2e769c){return _0x2e769c?{'count':_0x4ed00f,'rows':_0x2e769c}:null;}})['then'](respondWithResult(_0x11c4a7,null))['catch'](handleError(_0x11c4a7,null));};exports[_0xb3f0('0x116')]=function(_0x39a53e,_0x7d8845){var _0x307952=_0x39a53e[_0xb3f0('0x35')][_0xb3f0('0x117')]==='false'?_0xb3f0('0x118'):_0xb3f0('0x119');return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'attributes':['id',_0x307952],'where':{'id':_0x39a53e[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x7d8845,null))[_0xb3f0('0x13')](function(_0x2dc103){if(_0x2dc103){var _0x1dbeff=_0x2dc103[_0x307952];var _0x4fb6a1=_0x1dbeff&&_0x1dbeff[_0xb3f0('0x11a')]?_0x1dbeff['items']:[];_0x7d8845['send']({'fromKey':_[_0xb3f0('0x6e')](_0x1dbeff[_0xb3f0('0x11b')])?undefined:_0x1dbeff[_0xb3f0('0x11b')],'count':_0x4fb6a1[_0xb3f0('0x3c')],'rows':_0x4fb6a1});}})['catch'](handleError(_0x7d8845,null));};exports[_0xb3f0('0x11c')]=function(_0x454956,_0xdeb8b3){var _0x246d7f={'raw':![],'where':{}};var _0xe1a53b={};var _0x4e1f19={'count':0x0,'rows':[]};return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x454956[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0xdeb8b3,null))[_0xb3f0('0x13')](function(_0x3f80d8){if(_0x3f80d8){_0xe1a53b['model']=_[_0xb3f0('0x36')](db[_0xb3f0('0xc9')]['rawAttributes']);_0xe1a53b[_0xb3f0('0x35')]=_[_0xb3f0('0x36')](_0x454956[_0xb3f0('0x35')]);_0xe1a53b[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0xe1a53b[_0xb3f0('0x39')],_0xe1a53b[_0xb3f0('0x35')]);_0x246d7f[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0xe1a53b[_0xb3f0('0x39')],qs[_0xb3f0('0x3b')](_0x454956['query'][_0xb3f0('0x3b')]));_0x246d7f[_0xb3f0('0x3a')]=_0x246d7f[_0xb3f0('0x3a')]['length']?_0x246d7f['attributes']:_0xe1a53b['model'];if(!_0x454956[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x246d7f[_0xb3f0('0x23')]=qs['limit'](_0x454956[_0xb3f0('0x35')][_0xb3f0('0x23')]);_0x246d7f['offset']=qs[_0xb3f0('0x24')](_0x454956['query'][_0xb3f0('0x24')]);}_0x246d7f[_0xb3f0('0x5e')]=qs['sort'](_0x454956['query'][_0xb3f0('0x3f')]);_0x246d7f['where']=qs[_0xb3f0('0x37')](_['pick'](_0x454956[_0xb3f0('0x35')],_0xe1a53b['filters']));_0x246d7f[_0xb3f0('0x42')]['ChatWebsiteId']=_0x3f80d8['id'];if(_0x454956['query'][_0xb3f0('0x41')]){_0x246d7f[_0xb3f0('0x42')]=_[_0xb3f0('0x43')](_0x246d7f[_0xb3f0('0x42')],{'$or':_[_0xb3f0('0x44')](_0x246d7f[_0xb3f0('0x3a')],function(_0x491843){var _0x3f9962={};_0x3f9962[_0x491843]={'$like':'%'+_0x454956[_0xb3f0('0x35')][_0xb3f0('0x41')]+'%'};return _0x3f9962;})});}_0x246d7f=_['merge']({},_0x246d7f,_0x454956[_0xb3f0('0x46')]);return db['ChatOfflineMessage'][_0xb3f0('0x47')]({'where':_0x246d7f['where']})['then'](function(_0x5ba4e8){_0x4e1f19['count']=_0x5ba4e8;if(_0x454956[_0xb3f0('0x35')][_0xb3f0('0x48')]){_0x246d7f[_0xb3f0('0x49')]=[{'all':!![]}];}else{_0x246d7f['include']=[{'model':db[_0xb3f0('0x80')],'as':'Contact','required':![]},{'model':db[_0xb3f0('0xd3')],'as':_0xb3f0('0x11d'),'required':![]}];}return db[_0xb3f0('0xc9')]['findAll'](_0x246d7f);})[_0xb3f0('0x13')](function(_0xe11320){_0x4e1f19[_0xb3f0('0x4b')]=_0xe11320;return _0x4e1f19;});}})[_0xb3f0('0x13')](respondWithFilteredResult(_0xdeb8b3,_0x246d7f))[_0xb3f0('0x1d')](handleError(_0xdeb8b3,null));};exports[_0xb3f0('0x11e')]=function(_0x519389,_0x35479d){return db[_0xb3f0('0x31')]['find']({'where':{'id':_0x519389[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x35479d,null))['then'](function(_0x50d640){if(_0x50d640){return _0x50d640[_0xb3f0('0x11e')](_0x519389[_0xb3f0('0x4f')]['ids'],_[_0xb3f0('0x114')](_0x519389[_0xb3f0('0x4f')],['ids','id'])||{})[_0xb3f0('0xb0')](function(_0x3f1f30){for(var _0x2c9b4f=0x0;_0x2c9b4f<_0x519389['body']['ids'][_0xb3f0('0x3c')];_0x2c9b4f+=0x1){socket[_0xb3f0('0x11f')](_0xb3f0('0x120'),{'UserId':Number(_0x519389[_0xb3f0('0x4f')]['ids'][_0x2c9b4f]),'ChatWebsiteId':Number(_0x519389[_0xb3f0('0x57')]['id'])});}return _0x3f1f30;});}})['then'](respondWithResult(_0x35479d,null))[_0xb3f0('0x1d')](handleError(_0x35479d,null));};exports[_0xb3f0('0x121')]=function(_0x3ce121,_0x3ea082){return db[_0xb3f0('0x31')][_0xb3f0('0x4d')]({'where':{'id':_0x3ce121[_0xb3f0('0x57')]['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x3ea082,null))[_0xb3f0('0x13')](function(_0x237b91){if(_0x237b91){return _0x237b91['removeAgents'](_0x3ce121[_0xb3f0('0x35')][_0xb3f0('0x60')])[_0xb3f0('0x13')](function(){if(_[_0xb3f0('0x122')](_0x3ce121['query'][_0xb3f0('0x60')])){for(var _0x5579a4=0x0;_0x5579a4<_0x3ce121[_0xb3f0('0x35')][_0xb3f0('0x60')]['length'];_0x5579a4+=0x1){socket[_0xb3f0('0x11f')](_0xb3f0('0x123'),{'UserId':Number(_0x3ce121[_0xb3f0('0x35')]['ids'][_0x5579a4]),'ChatWebsiteId':Number(_0x3ce121[_0xb3f0('0x57')]['id'])});}}else{socket[_0xb3f0('0x11f')](_0xb3f0('0x123'),{'UserId':Number(_0x3ce121[_0xb3f0('0x35')][_0xb3f0('0x60')]),'ChatWebsiteId':Number(_0x3ce121[_0xb3f0('0x57')]['id'])});}});}})[_0xb3f0('0x13')](respondWithStatusCode(_0x3ea082,null))[_0xb3f0('0x1d')](handleError(_0x3ea082,null));};exports['getAgents']=function(_0x4081f4,_0x364302){var _0x44d09a={};var _0xbbebae={};var _0x48104b;var _0x3d1535;return db[_0xb3f0('0x31')][_0xb3f0('0x5d')]({'where':{'id':_0x4081f4['params']['id']}})[_0xb3f0('0x13')](handleEntityNotFound(_0x364302,null))[_0xb3f0('0x13')](function(_0x5145f7){if(_0x5145f7){_0x48104b=_0x5145f7;_0xbbebae[_0xb3f0('0x39')]=_['keys'](db[_0xb3f0('0xb7')][_0xb3f0('0x32')]);_0xbbebae['query']=_['keys'](_0x4081f4[_0xb3f0('0x35')]);_0xbbebae[_0xb3f0('0x37')]=_[_0xb3f0('0x38')](_0xbbebae[_0xb3f0('0x39')],_0xbbebae[_0xb3f0('0x35')]);_0x44d09a[_0xb3f0('0x3a')]=_[_0xb3f0('0x38')](_0xbbebae[_0xb3f0('0x39')],qs['fields'](_0x4081f4[_0xb3f0('0x35')][_0xb3f0('0x3b')]));_0x44d09a[_0xb3f0('0x3a')]=_0x44d09a[_0xb3f0('0x3a')][_0xb3f0('0x3c')]?_0x44d09a[_0xb3f0('0x3a')]:_0xbbebae['model'];_0x44d09a[_0xb3f0('0x5e')]=qs[_0xb3f0('0x3f')](_0x4081f4[_0xb3f0('0x35')][_0xb3f0('0x3f')]);_0x44d09a[_0xb3f0('0x42')]=qs['filters'](_[_0xb3f0('0x40')](_0x4081f4[_0xb3f0('0x35')],_0xbbebae[_0xb3f0('0x37')]));if(_0x4081f4[_0xb3f0('0x35')]['filter']){_0x44d09a['where']=_[_0xb3f0('0x43')](_0x44d09a['where'],{'$or':_[_0xb3f0('0x44')](_0x44d09a[_0xb3f0('0x3a')],function(_0x5a0197){var _0x64ba7={};_0x64ba7[_0x5a0197]={'$like':'%'+_0x4081f4[_0xb3f0('0x35')][_0xb3f0('0x41')]+'%'};return _0x64ba7;})});}_0x44d09a=_[_0xb3f0('0x43')]({},_0x44d09a,_0x4081f4[_0xb3f0('0x46')]);return _0x48104b[_0xb3f0('0x124')](_0x44d09a);}})[_0xb3f0('0x13')](function(_0x5a985a){if(_0x5a985a){_0x3d1535=_0x5a985a[_0xb3f0('0x3c')];if(!_0x4081f4[_0xb3f0('0x35')][_0xb3f0('0x3d')](_0xb3f0('0x3e'))){_0x44d09a['limit']=qs['limit'](_0x4081f4[_0xb3f0('0x35')]['limit']);_0x44d09a[_0xb3f0('0x24')]=qs['offset'](_0x4081f4['query'][_0xb3f0('0x24')]);}return _0x48104b[_0xb3f0('0x124')](_0x44d09a);}})['then'](function(_0x2b71fc){if(_0x2b71fc){return _0x2b71fc?{'count':_0x3d1535,'rows':_0x2b71fc}:null;}})[_0xb3f0('0x13')](respondWithResult(_0x364302,null))[_0xb3f0('0x1d')](handleError(_0x364302,null));}; \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.events.js b/server/api/chatWebsite/chatWebsite.events.js new file mode 100644 index 0000000..84917af --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7da7=['remove','emit','hook','events','../../mysqldb','ChatWebsite','update'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x7da7,0x10d));var _0x77da=function(_0x243b2f,_0x30aa15){_0x243b2f=_0x243b2f-0x0;var _0xcb3c2d=_0x7da7[_0x243b2f];return _0xcb3c2d;};'use strict';var EventEmitter=require(_0x77da('0x0'));var ChatWebsite=require(_0x77da('0x1'))['db'][_0x77da('0x2')];var ChatWebsiteEvents=new EventEmitter();ChatWebsiteEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0x77da('0x3'),'afterDestroy':_0x77da('0x4')};function emitEvent(_0x4f60c3){return function(_0x3a9fa6,_0x37b3d9,_0x56458c){ChatWebsiteEvents[_0x77da('0x5')](_0x4f60c3+':'+_0x3a9fa6['id'],_0x3a9fa6);ChatWebsiteEvents[_0x77da('0x5')](_0x4f60c3,_0x3a9fa6);_0x56458c(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];ChatWebsite[_0x77da('0x6')](e,emitEvent(event));}}module['exports']=ChatWebsiteEvents; \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.model.js b/server/api/chatWebsite/chatWebsite.model.js new file mode 100644 index 0000000..ca1dfc4 --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x83c0=['api','moment','request-promise','path','rimraf','../../config/environment','./chatWebsite.attributes','exports','chat_websites'];(function(_0x229f2f,_0x4e7bd3){var _0x46913a=function(_0x3b9283){while(--_0x3b9283){_0x229f2f['push'](_0x229f2f['shift']());}};_0x46913a(++_0x4e7bd3);}(_0x83c0,0x6c));var _0x083c=function(_0x441395,_0x432826){_0x441395=_0x441395-0x0;var _0x3b8eb2=_0x83c0[_0x441395];return _0x3b8eb2;};'use strict';var _=require('lodash');var util=require('util');var logger=require('../../config/logger')(_0x083c('0x0'));var moment=require(_0x083c('0x1'));var BPromise=require('bluebird');var rp=require(_0x083c('0x2'));var fs=require('fs');var path=require(_0x083c('0x3'));var rimraf=require(_0x083c('0x4'));var config=require(_0x083c('0x5'));var attributes=require(_0x083c('0x6'));module[_0x083c('0x7')]=function(_0x19cbf0,_0x3b3076){return _0x19cbf0['define']('ChatWebsite',attributes,{'tableName':_0x083c('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.rpc.js b/server/api/chatWebsite/chatWebsite.rpc.js new file mode 100644 index 0000000..b85924f --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x41c7=['debug','ChatWebsite,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','ChatWebsite,\x20%s,\x20%s','message','info','result','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','localhost','socket.io-emitter','./chatWebsite.socket','register','request','then'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x41c7,0x1e5));var _0x741c=function(_0x19c66b,_0x4cb7e2){_0x19c66b=_0x19c66b-0x0;var _0x2cc1d9=_0x41c7[_0x19c66b];return _0x2cc1d9;};'use strict';var _=require('lodash');var util=require(_0x741c('0x0'));var moment=require(_0x741c('0x1'));var BPromise=require(_0x741c('0x2'));var rs=require(_0x741c('0x3'));var fs=require('fs');var Redis=require(_0x741c('0x4'));var db=require(_0x741c('0x5'))['db'];var utils=require(_0x741c('0x6'));var logger=require(_0x741c('0x7'))(_0x741c('0x8'));var config=require(_0x741c('0x9'));var jayson=require(_0x741c('0xa'));var client=jayson[_0x741c('0xb')][_0x741c('0xc')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x741c('0xd'),'port':0x18eb});var socket=require(_0x741c('0xe'))(new Redis(config['redis']));require(_0x741c('0xf'))[_0x741c('0x10')](socket);function respondWithRpcPromise(_0x2e9c14,_0x4654d8,_0x503dd1){return new BPromise(function(_0x5c8c3a,_0x5c7b5b){return client[_0x741c('0x11')](_0x2e9c14,_0x503dd1)[_0x741c('0x12')](function(_0x575905){logger['info']('ChatWebsite,\x20%s,\x20%s',_0x4654d8,'request\x20sent');logger[_0x741c('0x13')](_0x741c('0x14'),_0x4654d8,_0x741c('0x15'),JSON['stringify'](_0x575905));if(_0x575905['error']){if(_0x575905[_0x741c('0x16')][_0x741c('0x17')]===0x1f4){logger['error'](_0x741c('0x18'),_0x4654d8,_0x575905[_0x741c('0x16')][_0x741c('0x19')]);return _0x5c7b5b(_0x575905[_0x741c('0x16')][_0x741c('0x19')]);}logger[_0x741c('0x16')](_0x741c('0x18'),_0x4654d8,_0x575905[_0x741c('0x16')][_0x741c('0x19')]);return _0x5c8c3a(_0x575905['error']['message']);}else{logger[_0x741c('0x1a')](_0x741c('0x18'),_0x4654d8,_0x741c('0x15'));_0x5c8c3a(_0x575905[_0x741c('0x1b')][_0x741c('0x19')]);}})['catch'](function(_0x2ecd23){logger['error']('ChatWebsite,\x20%s,\x20%s',_0x4654d8,_0x2ecd23);_0x5c7b5b(_0x2ecd23);});});} \ No newline at end of file diff --git a/server/api/chatWebsite/chatWebsite.socket.js b/server/api/chatWebsite/chatWebsite.socket.js new file mode 100644 index 0000000..8ee5792 --- /dev/null +++ b/server/api/chatWebsite/chatWebsite.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf3b7=['emit','removeListener','register','length','./chatWebsite.events'];(function(_0x7fd20b,_0x440d27){var _0x1b94d8=function(_0x22b2b0){while(--_0x22b2b0){_0x7fd20b['push'](_0x7fd20b['shift']());}};_0x1b94d8(++_0x440d27);}(_0xf3b7,0x16c));var _0x7f3b=function(_0x1948c6,_0xe9c670){_0x1948c6=_0x1948c6-0x0;var _0x316cd0=_0xf3b7[_0x1948c6];return _0x316cd0;};'use strict';var ChatWebsiteEvents=require(_0x7f3b('0x0'));var events=['save','remove','update'];function createListener(_0x31969f,_0x2eb821){return function(_0x1ce13c){_0x2eb821[_0x7f3b('0x1')](_0x31969f,_0x1ce13c);};}function removeListener(_0x5032a1,_0x40919b){return function(){ChatWebsiteEvents[_0x7f3b('0x2')](_0x5032a1,_0x40919b);};}exports[_0x7f3b('0x3')]=function(_0x4665a3){for(var _0x36b784=0x0,_0x510dd1=events[_0x7f3b('0x4')];_0x36b784<_0x510dd1;_0x36b784++){var _0x12381b=events[_0x36b784];var _0x28bbb5=createListener('chatWebsite:'+_0x12381b,_0x4665a3);ChatWebsiteEvents['on'](_0x12381b,_0x28bbb5);}}; \ No newline at end of file diff --git a/server/api/chatWebsite/index.js b/server/api/chatWebsite/index.js new file mode 100644 index 0000000..cbe0c14 --- /dev/null +++ b/server/api/chatWebsite/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x745c=['/:id/avatar','getAvatar','/:id/customer_avatar','getCustomerAvatar','/:id/system_avatar','/:id/interactions','getInteractions','/:id/snippet','/:id/applications','getApplications','getProactiveActions','/:id/fields','/:id/offline_messages','getOfflineMessages','/:id/users','post','addDisposition','addAnswer','diskStorage','join','root','server/files/images/logos/','format','now','originalname','single','file','addLogo','server/files/images/avatars/','%s-%s','addAvatar','addSystemAvatar','server/files','attachments','offline-chat','ensureDir','replace','extname','/:id/offline','any','addApplications','/:id/proactive_actions','addAgents','put','delete','destroy','removeDispositions','removeAnswers','exports','multer','path','connect-timeout','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','isAuthenticated','index','/describe','describe','get','/:id','show','/:id/dispositions','getDispositions','/:id/canned_answers','getAnswers','/:id/logo'];(function(_0x2be8c2,_0x14a4b5){var _0x97f531=function(_0xcee58d){while(--_0xcee58d){_0x2be8c2['push'](_0x2be8c2['shift']());}};_0x97f531(++_0x14a4b5);}(_0x745c,0x75));var _0xc745=function(_0x20d8d3,_0x118ad0){_0x20d8d3=_0x20d8d3-0x0;var _0x7c229e=_0x745c[_0x20d8d3];return _0x7c229e;};'use strict';var multer=require(_0xc745('0x0'));var util=require('util');var path=require(_0xc745('0x1'));var timeout=require(_0xc745('0x2'));var express=require('express');var router=express[_0xc745('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0xc745('0x4'));var interaction=require(_0xc745('0x5'));var config=require(_0xc745('0x6'));var controller=require('./chatWebsite.controller');router['get']('/',auth[_0xc745('0x7')](),controller[_0xc745('0x8')]);router['get'](_0xc745('0x9'),auth[_0xc745('0x7')](),controller[_0xc745('0xa')]);router[_0xc745('0xb')](_0xc745('0xc'),auth['isAuthenticated'](),controller[_0xc745('0xd')]);router['get'](_0xc745('0xe'),auth[_0xc745('0x7')](),controller[_0xc745('0xf')]);router[_0xc745('0xb')](_0xc745('0x10'),auth[_0xc745('0x7')](),controller[_0xc745('0x11')]);router[_0xc745('0xb')](_0xc745('0x12'),controller['getLogo']);router[_0xc745('0xb')](_0xc745('0x13'),controller[_0xc745('0x14')]);router['get'](_0xc745('0x15'),controller[_0xc745('0x16')]);router[_0xc745('0xb')](_0xc745('0x17'),controller['getSystemAvatar']);router[_0xc745('0xb')](_0xc745('0x18'),auth[_0xc745('0x7')](),controller[_0xc745('0x19')]);router[_0xc745('0xb')](_0xc745('0x1a'),controller['getSnippet']);router[_0xc745('0xb')](_0xc745('0x1b'),auth[_0xc745('0x7')](),controller[_0xc745('0x1c')]);router[_0xc745('0xb')]('/:id/proactive_actions',auth[_0xc745('0x7')](),controller[_0xc745('0x1d')]);router[_0xc745('0xb')](_0xc745('0x1e'),controller['getFields']);router[_0xc745('0xb')](_0xc745('0x1f'),auth['isAuthenticated'](),controller[_0xc745('0x20')]);router[_0xc745('0xb')](_0xc745('0x21'),auth[_0xc745('0x7')](),controller['getAgents']);router[_0xc745('0x22')]('/',auth[_0xc745('0x7')](),controller['create']);router[_0xc745('0x22')](_0xc745('0xe'),auth[_0xc745('0x7')](),controller[_0xc745('0x23')]);router[_0xc745('0x22')](_0xc745('0x10'),auth[_0xc745('0x7')](),controller[_0xc745('0x24')]);var upload=multer({'storage':multer[_0xc745('0x25')]({'destination':function(_0x5c794a,_0x1f7b6b,_0x461b28){_0x461b28(null,path[_0xc745('0x26')](config[_0xc745('0x27')],_0xc745('0x28')));},'filename':function(_0x530c05,_0x2478b5,_0x4fb0a7){_0x4fb0a7(null,util[_0xc745('0x29')]('%s-%s',Date[_0xc745('0x2a')](),_0x2478b5[_0xc745('0x2b')]));}})});router[_0xc745('0x22')]('/:id/logo',upload[_0xc745('0x2c')](_0xc745('0x2d')),controller[_0xc745('0x2e')]);var upload=multer({'storage':multer['diskStorage']({'destination':function(_0xbdea62,_0x46d333,_0x342d64){_0x342d64(null,path[_0xc745('0x26')](config[_0xc745('0x27')],_0xc745('0x2f')));},'filename':function(_0xbe1911,_0x1e20f3,_0x501fd4){_0x501fd4(null,util[_0xc745('0x29')](_0xc745('0x30'),Date['now'](),_0x1e20f3['originalname']));}})});router[_0xc745('0x22')]('/:id/avatar',upload[_0xc745('0x2c')](_0xc745('0x2d')),controller[_0xc745('0x31')]);var upload=multer({'storage':multer[_0xc745('0x25')]({'destination':function(_0x17be7d,_0x3c70ca,_0x4f1c8d){_0x4f1c8d(null,path[_0xc745('0x26')](config[_0xc745('0x27')],_0xc745('0x2f')));},'filename':function(_0x3b0c61,_0x13a4c8,_0x489312){_0x489312(null,util[_0xc745('0x29')](_0xc745('0x30'),Date[_0xc745('0x2a')](),_0x13a4c8['originalname']));}})});router[_0xc745('0x22')](_0xc745('0x15'),upload[_0xc745('0x2c')](_0xc745('0x2d')),controller['addCustomerAvatar']);var upload=multer({'storage':multer[_0xc745('0x25')]({'destination':function(_0x2c0586,_0x3b62b4,_0xedfb9f){_0xedfb9f(null,path[_0xc745('0x26')](config[_0xc745('0x27')],'server/files/images/avatars/'));},'filename':function(_0xed3b15,_0x24b038,_0x407e1a){_0x407e1a(null,util['format'](_0xc745('0x30'),Date[_0xc745('0x2a')](),_0x24b038[_0xc745('0x2b')]));}})});router['post'](_0xc745('0x17'),upload[_0xc745('0x2c')](_0xc745('0x2d')),controller[_0xc745('0x32')]);router[_0xc745('0x22')]('/:id/notify',controller['notify']);const offlineUploadMulter=multer({'storage':multer[_0xc745('0x25')]({'destination':function(_0x16bf11,_0x39f988,_0x26eeb5){const _0x428709=path[_0xc745('0x26')](config[_0xc745('0x27')],_0xc745('0x33'),_0xc745('0x34'),_0xc745('0x35'));fs_extra[_0xc745('0x36')](_0x428709,function(){_0x26eeb5(null,_0x428709);});},'filename':function(_0x31915e,_0x4968ce,_0x8583ba){const _0x1c83e6=_0x4968ce[_0xc745('0x2b')][_0xc745('0x37')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');const _0x5c2a17=path[_0xc745('0x38')](_0x1c83e6);const _0x5888a9=Date[_0xc745('0x2a')]()+'-'+_0x1c83e6[_0xc745('0x37')](_0x5c2a17,'')+_0x5c2a17;_0x8583ba(null,_0x5888a9);}})});router[_0xc745('0x22')](_0xc745('0x39'),offlineUploadMulter[_0xc745('0x3a')](),controller['offline']);router[_0xc745('0x22')]('/:id/interactions',auth[_0xc745('0x7')](),controller['addInteraction']);router[_0xc745('0x22')](_0xc745('0x1b'),auth[_0xc745('0x7')](),controller[_0xc745('0x3b')]);router[_0xc745('0x22')](_0xc745('0x3c'),auth[_0xc745('0x7')](),controller['addProactiveActions']);router['post']('/:id/users',auth[_0xc745('0x7')](),controller[_0xc745('0x3d')]);router[_0xc745('0x3e')]('/:id',auth[_0xc745('0x7')](),controller['update']);router[_0xc745('0x3f')]('/:id',auth[_0xc745('0x7')](),controller[_0xc745('0x40')]);router[_0xc745('0x3f')](_0xc745('0xe'),auth[_0xc745('0x7')](),controller[_0xc745('0x41')]);router['delete'](_0xc745('0x10'),auth[_0xc745('0x7')](),controller[_0xc745('0x42')]);router['delete']('/:id/users',auth[_0xc745('0x7')](),controller['removeAgents']);module[_0xc745('0x43')]=router; \ No newline at end of file diff --git a/server/api/client-side-logs.js b/server/api/client-side-logs.js new file mode 100644 index 0000000..626a56e --- /dev/null +++ b/server/api/client-side-logs.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x47c0=['expressEndpoint','/client-logs','isAuthenticated','exports','beaver-logger/server','../config/environment','Router','app','get','client-side-logger','Client-Side\x20logger\x20not\x20found!'];(function(_0x2c24ba,_0x3d089f){var _0xd68a3=function(_0x41a345){while(--_0x41a345){_0x2c24ba['push'](_0x2c24ba['shift']());}};_0xd68a3(++_0x3d089f);}(_0x47c0,0xa9));var _0x047c=function(_0x190674,_0x457608){_0x190674=_0x190674-0x0;var _0x3914c7=_0x47c0[_0x190674];return _0x3914c7;};var beaverLogger=require(_0x047c('0x0'));var express=require('express');var auth=require('../components/auth/service');var config=require(_0x047c('0x1'));var router=express[_0x047c('0x2')]();var isProduction=config['env']==='production'||![];function clientSideLogs(_0x468c93,_0x199ee2,_0x47b3d9){var _0x59cafa=_0x468c93[_0x047c('0x3')][_0x047c('0x4')](_0x047c('0x5'));if(!_0x59cafa){throw new Error(_0x047c('0x6'));}return beaverLogger[_0x047c('0x7')]({'uri':_0x047c('0x8'),'logger':_0x59cafa,'enableCors':!isProduction})(_0x468c93,_0x199ee2,_0x47b3d9);}router['use'](auth[_0x047c('0x9')](),clientSideLogs);module[_0x047c('0xa')]=router; \ No newline at end of file diff --git a/server/api/cloudProvider/cloudProvider.attributes.js b/server/api/cloudProvider/cloudProvider.attributes.js new file mode 100644 index 0000000..c067442 --- /dev/null +++ b/server/api/cloudProvider/cloudProvider.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xad65=['MicrosoftAzure\x20=>\x20access_token','MicrosoftAzure\x20=>\x20Dynamics365\x20=>\x20remote_uri','sequelize','exports','STRING','ENUM','MicrosoftAzure','Outlook365','Dynamics365','MicrosoftAzure\x20=>\x20client_id','MicrosoftAzure\x20=>\x20tenant','MicrosoftAzure\x20=>\x20client_secret','TEXT'];(function(_0x5e2a0f,_0x447ab4){var _0x3e8c10=function(_0x56dd4e){while(--_0x56dd4e){_0x5e2a0f['push'](_0x5e2a0f['shift']());}};_0x3e8c10(++_0x447ab4);}(_0xad65,0xdf));var _0x5ad6=function(_0x527354,_0x1e0a5b){_0x527354=_0x527354-0x0;var _0xc1f444=_0xad65[_0x527354];return _0xc1f444;};'use strict';var Sequelize=require(_0x5ad6('0x0'));module[_0x5ad6('0x1')]={'name':{'type':Sequelize[_0x5ad6('0x2')],'allowNull':![],'validate':{'notEmpty':!![]}},'service':{'type':Sequelize[_0x5ad6('0x3')]('AmazonAWS','Google',_0x5ad6('0x4')),'allowNull':![],'validate':{'notEmpty':!![]}},'type':{'type':Sequelize['ENUM'](_0x5ad6('0x5'),_0x5ad6('0x6'))},'data1':{'type':Sequelize[_0x5ad6('0x2')],'comment':_0x5ad6('0x7')},'data2':{'type':Sequelize[_0x5ad6('0x2')],'comment':_0x5ad6('0x8')},'data3':{'type':Sequelize[_0x5ad6('0x2')],'comment':_0x5ad6('0x9')},'data4':{'type':Sequelize[_0x5ad6('0x2')],'comment':'MicrosoftAzure\x20=>\x20redirect_uri'},'data5':{'type':Sequelize[_0x5ad6('0xa')],'comment':_0x5ad6('0xb')},'data6':{'type':Sequelize['TEXT'],'comment':'MicrosoftAzure\x20=>\x20refresh_token'},'data7':{'type':Sequelize[_0x5ad6('0xa')],'comment':_0x5ad6('0xc')}}; \ No newline at end of file diff --git a/server/api/cloudProvider/cloudProvider.controller.js b/server/api/cloudProvider/cloudProvider.controller.js new file mode 100644 index 0000000..05971cf --- /dev/null +++ b/server/api/cloudProvider/cloudProvider.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe58d=['MicrosoftAzure','decryptString','data3','catch','show','params','rawAttributes','includeAll','create','body','values','includes','find','generateMicrosoftAuthorizationUrl','oauth2MicrosoftCallback','error','get','state','Invalid\x20state\x20parameter','parse','from','base64','ascii','isValidIdToken','Unable\x20to\x20validate\x20id_token','getOauth2MicrosoftAccessToken','code','data5','access_token','refresh_token','update','data6','startRefreshInterval','emit','microsoftAuthorization:success','microsoftAuthorization:error','Invalid\x20authentication\x20state\x20parameter','send','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','../../components/parsers/qs','../../components/encryptor','../../config/environment','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','redis','localhost','socket.io-emitter','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','then','destroy','stack','name','index','map','CloudProvider','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','service'];(function(_0x2c91e9,_0x2fb965){var _0x13f0ff=function(_0xb39edf){while(--_0xb39edf){_0x2c91e9['push'](_0x2c91e9['shift']());}};_0x13f0ff(++_0x2fb965);}(_0xe58d,0x139));var _0xde58=function(_0x1ed7e7,_0x546a7f){_0x1ed7e7=_0x1ed7e7-0x0;var _0xc8da5=_0xe58d[_0x1ed7e7];return _0xc8da5;};'use strict';var _=require(_0xde58('0x0'));var Redis=require('ioredis');var qs=require(_0xde58('0x1'));var encryptor=require(_0xde58('0x2'));var config=require(_0xde58('0x3'));var logger=require(_0xde58('0x4'))(_0xde58('0x5'));var db=require(_0xde58('0x6'))['db'];var oauth=require(_0xde58('0x7'));config[_0xde58('0x8')]=_['defaults'](config[_0xde58('0x8')],{'host':_0xde58('0x9'),'port':0x18eb});var socket=require(_0xde58('0xa'))(new Redis(config[_0xde58('0x8')]));var redis=new Redis(config[_0xde58('0x8')]);function respondWithStatusCode(_0x45cfce,_0x565356){_0x565356=_0x565356||0xcc;return function(_0xbf0ad7){if(_0xbf0ad7){return _0x45cfce[_0xde58('0xb')](_0x565356);}return _0x45cfce[_0xde58('0xc')](_0x565356)[_0xde58('0xd')]();};}function respondWithResult(_0x3e4b6c,_0x2d24cd){_0x2d24cd=_0x2d24cd||0xc8;return function(_0x3507b8){if(_0x3507b8){return _0x3e4b6c[_0xde58('0xc')](_0x2d24cd)[_0xde58('0xe')](_0x3507b8);}};}function respondWithFilteredResult(_0x540ffb,_0x53fab9){return function(_0x528c9d){if(_0x528c9d){var _0x3affcd=typeof _0x53fab9[_0xde58('0xf')]===_0xde58('0x10')&&typeof _0x53fab9[_0xde58('0x11')]==='undefined';var _0x2a4891=_0x528c9d['count'];var _0x252591=_0x3affcd?0x0:_0x53fab9['offset'];var _0x47ca7f=_0x3affcd?_0x528c9d[_0xde58('0x12')]:_0x53fab9[_0xde58('0xf')]+_0x53fab9[_0xde58('0x11')];var _0x5d844b;if(_0x47ca7f>=_0x2a4891){_0x47ca7f=_0x2a4891;_0x5d844b=0xc8;}else{_0x5d844b=0xce;}_0x540ffb[_0xde58('0xc')](_0x5d844b);return _0x540ffb[_0xde58('0x13')](_0xde58('0x14'),_0x252591+'-'+_0x47ca7f+'/'+_0x2a4891)[_0xde58('0xe')](_0x528c9d);}return null;};}function saveUpdates(_0x5f2e43){return function(_0xdc9a){if(_0xdc9a){return _0xdc9a['update'](_0x5f2e43)[_0xde58('0x15')](function(_0x23dfbf){return _0x23dfbf;});}return null;};}function removeEntity(_0x23e70d){return function(_0x1d988d){if(_0x1d988d){return _0x1d988d[_0xde58('0x16')]()['then'](function(){_0x23e70d[_0xde58('0xc')](0xcc)[_0xde58('0xd')]();});}};}function handleEntityNotFound(_0x5385a2){return function(_0x2451b0){if(!_0x2451b0){_0x5385a2[_0xde58('0xb')](0x194);}return _0x2451b0;};}function handleError(_0x48c587,_0x31d017){_0x31d017=_0x31d017||0x1f4;return function(_0x54f7aa){logger['error'](_0x54f7aa[_0xde58('0x17')]);if(_0x54f7aa[_0xde58('0x18')]){delete _0x54f7aa[_0xde58('0x18')];}_0x48c587['status'](_0x31d017)['send'](_0x54f7aa);};}function maskClientSecret(_0x5d1f67){return _['padEnd'](_0x5d1f67['slice'](0x0,0x3),0x14,'*');}exports[_0xde58('0x19')]=function(_0x2b6eeb,_0x4d7792){var _0x204557={},_0x2abf4f={},_0x162c35={'count':0x0,'rows':[]};var _0x297da8=_[_0xde58('0x1a')](db[_0xde58('0x1b')]['rawAttributes'],function(_0x33241b){return{'name':_0x33241b[_0xde58('0x1c')],'type':_0x33241b[_0xde58('0x1d')]['key']};});_0x2abf4f[_0xde58('0x1e')]=_[_0xde58('0x1a')](_0x297da8,'name');_0x2abf4f[_0xde58('0x1f')]=_[_0xde58('0x20')](_0x2b6eeb[_0xde58('0x1f')]);_0x2abf4f[_0xde58('0x21')]=_[_0xde58('0x22')](_0x2abf4f[_0xde58('0x1e')],_0x2abf4f[_0xde58('0x1f')]);_0x204557[_0xde58('0x23')]=_[_0xde58('0x22')](_0x2abf4f[_0xde58('0x1e')],qs[_0xde58('0x24')](_0x2b6eeb[_0xde58('0x1f')]['fields']));_0x204557[_0xde58('0x23')]=_0x204557['attributes'][_0xde58('0x25')]?_0x204557[_0xde58('0x23')]:_0x2abf4f[_0xde58('0x1e')];if(!_0x2b6eeb[_0xde58('0x1f')][_0xde58('0x26')](_0xde58('0x27'))){_0x204557[_0xde58('0x11')]=qs[_0xde58('0x11')](_0x2b6eeb[_0xde58('0x1f')][_0xde58('0x11')]);_0x204557[_0xde58('0xf')]=qs[_0xde58('0xf')](_0x2b6eeb['query'][_0xde58('0xf')]);}_0x204557[_0xde58('0x28')]=qs['sort'](_0x2b6eeb[_0xde58('0x1f')][_0xde58('0x29')]);_0x204557[_0xde58('0x2a')]=qs[_0xde58('0x21')](_[_0xde58('0x2b')](_0x2b6eeb['query'],_0x2abf4f[_0xde58('0x21')]),_0x297da8);if(_0x2b6eeb[_0xde58('0x1f')][_0xde58('0x2c')]){_0x204557[_0xde58('0x2a')]=_[_0xde58('0x2d')](_0x204557[_0xde58('0x2a')],{'$or':_['map'](_0x297da8,function(_0x3ee583){if(_0x3ee583[_0xde58('0x1d')]!==_0xde58('0x2e')){var _0x5c3321={};_0x5c3321[_0x3ee583[_0xde58('0x18')]]={'$like':'%'+_0x2b6eeb['query']['filter']+'%'};return _0x5c3321;}})});}_0x204557=_['merge']({},_0x204557,_0x2b6eeb[_0xde58('0x2f')]);var _0x2a30ea={'where':_0x204557[_0xde58('0x2a')]};return db[_0xde58('0x1b')][_0xde58('0x12')](_0x2a30ea)['then'](function(_0xbc0f08){_0x162c35[_0xde58('0x12')]=_0xbc0f08;if(_0x2b6eeb[_0xde58('0x1f')]['includeAll']){_0x204557[_0xde58('0x30')]=[{'all':!![]}];}return db[_0xde58('0x1b')]['findAll'](_0x204557);})['then'](function(_0x3256b7){_0x162c35[_0xde58('0x31')]=_[_0xde58('0x1a')](_0x3256b7,function(_0x500cbb){if(_0x500cbb[_0xde58('0x32')]===_0xde58('0x33')){var _0x5bef89=encryptor[_0xde58('0x34')](_0x500cbb[_0xde58('0x35')]);_0x500cbb[_0xde58('0x35')]=maskClientSecret(_0x5bef89);}return _0x500cbb;});return _0x162c35;})[_0xde58('0x15')](respondWithFilteredResult(_0x4d7792,_0x204557))[_0xde58('0x36')](handleError(_0x4d7792,null));};exports[_0xde58('0x37')]=function(_0x166bd4,_0xfe182a){var _0x466f61={'raw':!![],'where':{'id':_0x166bd4[_0xde58('0x38')]['id']}},_0x15681a={};_0x15681a['model']=_[_0xde58('0x20')](db[_0xde58('0x1b')][_0xde58('0x39')]);_0x15681a[_0xde58('0x1f')]=_['keys'](_0x166bd4[_0xde58('0x1f')]);_0x15681a[_0xde58('0x21')]=_[_0xde58('0x22')](_0x15681a['model'],_0x15681a[_0xde58('0x1f')]);_0x466f61[_0xde58('0x23')]=_[_0xde58('0x22')](_0x15681a['model'],qs['fields'](_0x166bd4[_0xde58('0x1f')][_0xde58('0x24')]));_0x466f61[_0xde58('0x23')]=_0x466f61[_0xde58('0x23')][_0xde58('0x25')]?_0x466f61['attributes']:_0x15681a['model'];if(_0x166bd4[_0xde58('0x1f')][_0xde58('0x3a')]){_0x466f61['include']=[{'all':!![]}];}_0x466f61=_[_0xde58('0x2d')]({},_0x466f61,_0x166bd4['options']);return db['CloudProvider']['find'](_0x466f61)[_0xde58('0x15')](handleEntityNotFound(_0xfe182a,null))[_0xde58('0x15')](function(_0x172b7a){if(_0x172b7a[_0xde58('0x32')]==='MicrosoftAzure'){var _0x571187=encryptor['decryptString'](_0x172b7a['data3']);_0x172b7a[_0xde58('0x35')]=maskClientSecret(_0x571187);}return _0x172b7a;})[_0xde58('0x15')](respondWithResult(_0xfe182a,null))['catch'](handleError(_0xfe182a,null));};exports[_0xde58('0x3b')]=function(_0x214836,_0x15b8f4){if(!_0x214836[_0xde58('0x3c')][_0xde58('0x18')])throw new Error('Name\x20parameter\x20not\x20specified');if(!_0x214836[_0xde58('0x3c')][_0xde58('0x32')])throw new Error('Service\x20parameter\x20not\x20specified');var _0x3485b5=db['CloudProvider'][_0xde58('0x39')]['service'][_0xde58('0x3d')];if(!_0x3485b5[_0xde58('0x3e')](_0x214836[_0xde58('0x3c')][_0xde58('0x32')]))throw new Error('Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20'+_0x3485b5['join'](',\x20'));if(_0x214836[_0xde58('0x3c')][_0xde58('0x32')]===_0xde58('0x33')&&_0x214836[_0xde58('0x3c')][_0xde58('0x35')]){_0x214836[_0xde58('0x3c')][_0xde58('0x35')]=encryptor['encryptString'](_0x214836['body'][_0xde58('0x35')]);}return db['CloudProvider']['create'](_0x214836[_0xde58('0x3c')],{})[_0xde58('0x15')](respondWithResult(_0x15b8f4,0xc9))[_0xde58('0x36')](handleError(_0x15b8f4,null));};exports['update']=function(_0x5e53e4,_0x3aa83d){if(_0x5e53e4[_0xde58('0x3c')]['id']){delete _0x5e53e4[_0xde58('0x3c')]['id'];}return db[_0xde58('0x1b')][_0xde58('0x3f')]({'where':{'id':_0x5e53e4[_0xde58('0x38')]['id']}})['then'](handleEntityNotFound(_0x3aa83d,null))[_0xde58('0x15')](function(_0x283d29){if(_0x283d29[_0xde58('0x32')]===_0xde58('0x33')&&_0x5e53e4[_0xde58('0x3c')]['data3']){_0x5e53e4[_0xde58('0x3c')][_0xde58('0x35')]=encryptor['encryptString'](_0x5e53e4['body'][_0xde58('0x35')]);}return _0x283d29;})[_0xde58('0x15')](saveUpdates(_0x5e53e4[_0xde58('0x3c')],null))[_0xde58('0x15')](respondWithResult(_0x3aa83d,null))[_0xde58('0x36')](handleError(_0x3aa83d,null));};exports['destroy']=function(_0x4cc5b0,_0x1affae){return db['CloudProvider'][_0xde58('0x3f')]({'where':{'id':_0x4cc5b0['params']['id']}})[_0xde58('0x15')](handleEntityNotFound(_0x1affae,null))[_0xde58('0x15')](removeEntity(_0x1affae,null))[_0xde58('0x36')](handleError(_0x1affae,null));};exports['oauth2MicrosoftAuthorize']=function(_0x2537a6,_0x21706d){return db[_0xde58('0x1b')]['findOne']({'where':{'id':_0x2537a6[_0xde58('0x38')]['id']},'raw':!![]})[_0xde58('0x15')](function(_0x2d2a26){if(!_0x2d2a26)return _0x21706d[_0xde58('0xb')](0x194);return{'url':oauth[_0xde58('0x40')](_0x2d2a26,_0x2537a6['user']['id'])};})[_0xde58('0x15')](respondWithResult(_0x21706d,null))[_0xde58('0x36')](handleError(_0x21706d,null));};exports[_0xde58('0x41')]=function(_0x48ba4b,_0x5e2354){var _0x46339f=_0x48ba4b[_0xde58('0x3c')];var _0x4f3d15;var _0x1ce4e5;if(_0x46339f[_0xde58('0x42')])throw _0x46339f;redis[_0xde58('0x43')](_0x46339f[_0xde58('0x44')])['then'](function(_0x49cd28){if(!_0x49cd28)throw new Error(_0xde58('0x45'));_0x4f3d15=JSON[_0xde58('0x46')](_0x49cd28);var _0x498e3e=Buffer[_0xde58('0x47')](_0x46339f['state'],_0xde58('0x48'))['toString'](_0xde58('0x49'));_0x1ce4e5=JSON[_0xde58('0x46')](_0x498e3e);if(!oauth[_0xde58('0x4a')](_0x46339f['id_token'],_0x4f3d15['oauth2Claims']))throw new Error(_0xde58('0x4b'));redis['del'](_0x46339f['state']);return oauth[_0xde58('0x4c')](_0x46339f[_0xde58('0x4d')],_0x4f3d15);})[_0xde58('0x15')](function(_0x4bcb6a){_0x4f3d15[_0xde58('0x4e')]=_0x4bcb6a[_0xde58('0x4f')];_0x4f3d15['data6']=_0x4bcb6a[_0xde58('0x50')];return db[_0xde58('0x1b')][_0xde58('0x51')]({'data5':_0x4f3d15[_0xde58('0x4e')],'data6':_0x4f3d15[_0xde58('0x52')]},{'where':{'id':_0x4f3d15['id']}});})['then'](function(){oauth[_0xde58('0x53')](_0x4f3d15);socket[_0xde58('0x54')](_0xde58('0x55'),{'id':_0x1ce4e5['id']});return;})[_0xde58('0x15')](respondWithStatusCode(_0x5e2354,null))['catch'](function(_0x4714d7){if(_0x1ce4e5){socket[_0xde58('0x54')](_0xde58('0x56'),{'id':_0x1ce4e5['id']});}if(!_0x4f3d15){logger['error'](_0xde58('0x57'),_0x4714d7);return _0x5e2354[_0xde58('0xc')](0x1f4)[_0xde58('0x58')](_0x4714d7['message']);}logger[_0xde58('0x42')](_0xde58('0x59'),_0x4f3d15['id'],JSON[_0xde58('0x5a')](_0x4714d7));});}; \ No newline at end of file diff --git a/server/api/cloudProvider/cloudProvider.model.js b/server/api/cloudProvider/cloudProvider.model.js new file mode 100644 index 0000000..90398a2 --- /dev/null +++ b/server/api/cloudProvider/cloudProvider.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x580e=['api','moment','bluebird','path','rimraf','./cloudProvider.attributes','exports','CloudProvider','cloud_providers','lodash','util','../../config/logger'];(function(_0x40ac5e,_0x2de228){var _0x2839d6=function(_0x123d47){while(--_0x123d47){_0x40ac5e['push'](_0x40ac5e['shift']());}};_0x2839d6(++_0x2de228);}(_0x580e,0xf9));var _0xe580=function(_0x8c43de,_0x90ff31){_0x8c43de=_0x8c43de-0x0;var _0xa6591b=_0x580e[_0x8c43de];return _0xa6591b;};'use strict';var _=require(_0xe580('0x0'));var util=require(_0xe580('0x1'));var logger=require(_0xe580('0x2'))(_0xe580('0x3'));var moment=require(_0xe580('0x4'));var BPromise=require(_0xe580('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xe580('0x6'));var rimraf=require(_0xe580('0x7'));var config=require('../../config/environment');var attributes=require(_0xe580('0x8'));module[_0xe580('0x9')]=function(_0x3156b9,_0x1acb27){return _0x3156b9['define'](_0xe580('0xa'),attributes,{'tableName':_0xe580('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cloudProvider/cloudProvider.oauth.js b/server/api/cloudProvider/cloudProvider.oauth.js new file mode 100644 index 0000000..022518e --- /dev/null +++ b/server/api/cloudProvider/cloudProvider.oauth.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xba16=['Dynamics365','replace','{TENANT_ID}','data2','from','stringify','toString','base64','randomBytes','hex','client_id','data1','response_type','state','nonce','prompt','login','map','key','value','oauth2/','set','decode','issuer','aud','unix','exp','data3','then','refresh_token','data6','POST','data5','update','catch','error','Failed\x20to\x20refresh\x20access\x20token\x20for\x20cloud\x20provider\x20#%s,\x20-\x20err:%s','decryptString','intervals','bind','CloudProvider','all','inspect','[CLOUD_PROVIDER]\x20Error\x20while\x20refreshing\x20the\x20tokens\x20after\x20service\x20restart\x20error:%s','crypto','jsonwebtoken','moment','request-promise','util','../../components/encryptor','../../config/environment','../../config/logger','../../config/schedule/cloud-provider','../../mysqldb','redis','defaults','https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0','openid','profile','email','offline_access','https://outlook.office365.com/IMAP.AccessAsUser.All','https://outlook.office.com/POP.AccessAsUser.All','https://outlook.office.com/SMTP.Send','/authorize','/token','type','push','/.default','join'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xba16,0x1d0));var _0x6ba1=function(_0x385c76,_0xb97335){_0x385c76=_0x385c76-0x0;var _0x5c8367=_0xba16[_0x385c76];return _0x5c8367;};'use strict';var _=require('lodash');var crypto=require(_0x6ba1('0x0'));var jwt=require(_0x6ba1('0x1'));var moment=require(_0x6ba1('0x2'));var Redis=require('ioredis');var rp=require(_0x6ba1('0x3'));var util=require(_0x6ba1('0x4'));var encryptor=require(_0x6ba1('0x5'));var config=require(_0x6ba1('0x6'));var logger=require(_0x6ba1('0x7'))('api');var schedule=require(_0x6ba1('0x8'));var db=require(_0x6ba1('0x9'))['db'];config[_0x6ba1('0xa')]=_[_0x6ba1('0xb')](config[_0x6ba1('0xa')],{'host':'localhost','port':0x18eb});var redis=new Redis(config['redis']);var MICROSOFT_AUTH_URL=_0x6ba1('0xc');var AZURE_AUTH_SCOPES={'Outlook365':[_0x6ba1('0xd'),_0x6ba1('0xe'),_0x6ba1('0xf'),_0x6ba1('0x10'),_0x6ba1('0x11'),_0x6ba1('0x12'),_0x6ba1('0x13')],'Dynamics365':['openid','offline_access']};var MICROSOFT_AUTH_ENDPOINT=_0x6ba1('0x14');var MICROSOFT_TOKEN_ENDPOINT=_0x6ba1('0x15');var OAUTH_REFRESH_INTERVAL=0xfa;function getAuthorizationScopes(_0x5814a4){var _0x444637=_['map'](AZURE_AUTH_SCOPES[_0x5814a4[_0x6ba1('0x16')]]);if(_0x5814a4['type']==='Dynamics365')_0x444637[_0x6ba1('0x17')](_0x5814a4['data7']+_0x6ba1('0x18'));return _0x444637[_0x6ba1('0x19')]('\x20');}function getAccessTokenScope(_0x50d10c){if(_0x50d10c[_0x6ba1('0x16')]==='Outlook365')return'https://outlook.office365.com/IMAP.AccessAsUser.All';if(_0x50d10c[_0x6ba1('0x16')]===_0x6ba1('0x1a'))return _0x50d10c['data7']+_0x6ba1('0x18');}function generateMicrosoftAuthorizationUrl(_0x1edb53,_0x258254){var _0x2392ea=MICROSOFT_AUTH_URL[_0x6ba1('0x1b')](_0x6ba1('0x1c'),_0x1edb53[_0x6ba1('0x1d')]);var _0x130bf8=['code','id_token'];var _0x559f42=Buffer[_0x6ba1('0x1e')](JSON[_0x6ba1('0x1f')]({'id':_0x258254}))[_0x6ba1('0x20')](_0x6ba1('0x21'));var _0x1e6173=crypto[_0x6ba1('0x22')](0x10)[_0x6ba1('0x20')](_0x6ba1('0x23'));var _0x444cd1=getAuthorizationScopes(_0x1edb53);var _0x26b86f=[{'key':_0x6ba1('0x24'),'value':_0x1edb53[_0x6ba1('0x25')]},{'key':_0x6ba1('0x26'),'value':encodeURIComponent(_0x130bf8[_0x6ba1('0x19')]('\x20'))},{'key':'redirect_uri','value':_0x1edb53['data4']},{'key':'response_mode','value':'form_post'},{'key':'scope','value':encodeURIComponent(_0x444cd1)},{'key':_0x6ba1('0x27'),'value':_0x559f42},{'key':_0x6ba1('0x28'),'value':_0x1e6173},{'key':_0x6ba1('0x29'),'value':_0x6ba1('0x2a')}];var _0x1d55c5=_0x2392ea+MICROSOFT_AUTH_ENDPOINT+'?'+_[_0x6ba1('0x2b')](_0x26b86f,function(_0x271a61){return _0x271a61[_0x6ba1('0x2c')]+'='+_0x271a61[_0x6ba1('0x2d')];})['join']('&');_0x1edb53['oauth2Claims']={'issuer':_0x2392ea[_0x6ba1('0x1b')](_0x6ba1('0x2e'),''),'audience':_0x1edb53[_0x6ba1('0x25')],'state':_0x559f42,'nonce':_0x1e6173};redis[_0x6ba1('0x2f')](_0x559f42,JSON[_0x6ba1('0x1f')](_0x1edb53));return _0x1d55c5;}function isValidIdToken(_0x31a558,_0x5f53cd){try{var _0x557458=jwt[_0x6ba1('0x30')](_0x31a558,{'complete':!![]});var _0x3d8e75=_0x557458['payload'];if(_0x3d8e75['iss']!==_0x5f53cd[_0x6ba1('0x31')])return![];if(_0x3d8e75[_0x6ba1('0x32')]!==_0x5f53cd['audience'])return![];if(_0x3d8e75[_0x6ba1('0x28')]!==_0x5f53cd[_0x6ba1('0x28')])return![];if(moment()['isAfter'](moment[_0x6ba1('0x33')](_0x3d8e75[_0x6ba1('0x34')])))return![];return!![];}catch(_0x59d31c){throw _0x59d31c;}}function refreshOauth2MicrosoftAccessToken(_0x4c1d6e){return Promise['resolve']()['then'](function(){if(_0x4c1d6e[_0x6ba1('0x35')])return _0x4c1d6e;return db['CloudProvider']['findOne']({'where':{'id':_0x4c1d6e['id']},'raw':!![]});})[_0x6ba1('0x36')](function(_0x51b798){var _0x484110={'grant_type':_0x6ba1('0x37'),'refresh_token':_0x51b798[_0x6ba1('0x38')],'scope':getAccessTokenScope(_0x51b798),'redirect_uri':_0x51b798['data4'],'client_id':_0x51b798[_0x6ba1('0x25')],'client_secret':encryptor['decryptString'](_0x51b798[_0x6ba1('0x35')])};var _0x3c1b68={'method':_0x6ba1('0x39'),'uri':MICROSOFT_AUTH_URL[_0x6ba1('0x1b')](_0x6ba1('0x1c'),_0x51b798[_0x6ba1('0x1d')])+MICROSOFT_TOKEN_ENDPOINT,'form':_0x484110,'json':!![]};return rp(_0x3c1b68);})[_0x6ba1('0x36')](function(_0x4937e0){_0x4c1d6e[_0x6ba1('0x3a')]=_0x4937e0['access_token'];_0x4c1d6e[_0x6ba1('0x38')]=_0x4937e0[_0x6ba1('0x37')];return db['CloudProvider'][_0x6ba1('0x3b')]({'data5':_0x4c1d6e[_0x6ba1('0x3a')],'data6':_0x4c1d6e[_0x6ba1('0x38')]},{'where':{'id':_0x4c1d6e['id']}});})[_0x6ba1('0x36')](function(){return _0x4c1d6e;})[_0x6ba1('0x3c')](function(_0x45daae){logger[_0x6ba1('0x3d')](_0x6ba1('0x3e'),_0x4c1d6e['id'],_0x45daae);});}function getOauth2MicrosoftAccessToken(_0xee32e2,_0x544b36){var _0x4767f0={'grant_type':'authorization_code','code':_0xee32e2,'scope':getAccessTokenScope(_0x544b36),'redirect_uri':_0x544b36['data4'],'client_id':_0x544b36[_0x6ba1('0x25')],'client_secret':encryptor[_0x6ba1('0x3f')](_0x544b36[_0x6ba1('0x35')])};var _0x266428={'method':_0x6ba1('0x39'),'uri':MICROSOFT_AUTH_URL[_0x6ba1('0x1b')](_0x6ba1('0x1c'),_0x544b36[_0x6ba1('0x1d')])+MICROSOFT_TOKEN_ENDPOINT,'form':_0x4767f0,'json':!![]};return rp(_0x266428);}function startRefreshInterval(_0x297c12){var _0xbe6e2b=schedule[_0x6ba1('0x40')];if(_0xbe6e2b[_0x297c12['id']])clearInterval(_0xbe6e2b[_0x297c12['id']]);_0xbe6e2b[_0x297c12['id']]=setInterval(refreshOauth2MicrosoftAccessToken[_0x6ba1('0x41')](this,{'id':_0x297c12['id']}),OAUTH_REFRESH_INTERVAL*0x3e8);schedule[_0x6ba1('0x40')]=_0xbe6e2b;}function startAllRefreshIntervals(){return db[_0x6ba1('0x42')]['findAll']({'where':{'data6':{'$ne':null}},'raw':!![]})[_0x6ba1('0x36')](function(_0x4a68ae){var _0x423dd5=_0x4a68ae[_0x6ba1('0x2b')](function(_0x5c880d){return refreshOauth2MicrosoftAccessToken(_0x5c880d)[_0x6ba1('0x36')](function(_0x3e8c45){startRefreshInterval(_0x3e8c45);});});return Promise[_0x6ba1('0x43')](_0x423dd5);})[_0x6ba1('0x3c')](function(_0x369c79){var _0xe77464=_0x369c79?util[_0x6ba1('0x44')](_0x369c79,{'showHidden':![],'depth':null}):'';logger['error'](_0x6ba1('0x45'),_0xe77464);});}module['exports']={'generateMicrosoftAuthorizationUrl':generateMicrosoftAuthorizationUrl,'getOauth2MicrosoftAccessToken':getOauth2MicrosoftAccessToken,'isValidIdToken':isValidIdToken,'startAllRefreshIntervals':startAllRefreshIntervals,'refreshOauth2MicrosoftAccessToken':refreshOauth2MicrosoftAccessToken,'startRefreshInterval':startRefreshInterval}; \ No newline at end of file diff --git a/server/api/cloudProvider/cloudProvider.rpc.js b/server/api/cloudProvider/cloudProvider.rpc.js new file mode 100644 index 0000000..c57d284 --- /dev/null +++ b/server/api/cloudProvider/cloudProvider.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5453=['randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','request','info','CloudProvider,\x20%s,\x20%s','request\x20sent','debug','CloudProvider,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','lodash','util','moment','bluebird'];(function(_0x1bd6b1,_0x57e4c5){var _0x199e9=function(_0x5ae181){while(--_0x5ae181){_0x1bd6b1['push'](_0x1bd6b1['shift']());}};_0x199e9(++_0x57e4c5);}(_0x5453,0x18b));var _0x3545=function(_0x13d07a,_0x41efc3){_0x13d07a=_0x13d07a-0x0;var _0x5ee0ee=_0x5453[_0x13d07a];return _0x5ee0ee;};'use strict';var _=require(_0x3545('0x0'));var util=require(_0x3545('0x1'));var moment=require(_0x3545('0x2'));var BPromise=require(_0x3545('0x3'));var rs=require(_0x3545('0x4'));var fs=require('fs');var Redis=require(_0x3545('0x5'));var db=require(_0x3545('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3545('0x7'));var config=require(_0x3545('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x3545('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x290aa5,_0x496d6b,_0x5d5808){return new BPromise(function(_0x2974ae,_0x3cf0cc){return client[_0x3545('0xa')](_0x290aa5,_0x5d5808)['then'](function(_0x21dc51){logger[_0x3545('0xb')](_0x3545('0xc'),_0x496d6b,_0x3545('0xd'));logger[_0x3545('0xe')](_0x3545('0xf'),_0x496d6b,_0x3545('0xd'),JSON['stringify'](_0x21dc51));if(_0x21dc51['error']){if(_0x21dc51[_0x3545('0x10')][_0x3545('0x11')]===0x1f4){logger[_0x3545('0x10')](_0x3545('0xc'),_0x496d6b,_0x21dc51['error']['message']);return _0x3cf0cc(_0x21dc51['error'][_0x3545('0x12')]);}logger[_0x3545('0x10')]('CloudProvider,\x20%s,\x20%s',_0x496d6b,_0x21dc51[_0x3545('0x10')]['message']);return _0x2974ae(_0x21dc51['error'][_0x3545('0x12')]);}else{logger[_0x3545('0xb')]('CloudProvider,\x20%s,\x20%s',_0x496d6b,_0x3545('0xd'));_0x2974ae(_0x21dc51[_0x3545('0x13')]['message']);}})[_0x3545('0x14')](function(_0x51f69b){logger[_0x3545('0x10')](_0x3545('0xc'),_0x496d6b,_0x51f69b);_0x3cf0cc(_0x51f69b);});});} \ No newline at end of file diff --git a/server/api/cloudProvider/index.js b/server/api/cloudProvider/index.js new file mode 100644 index 0000000..366ba9b --- /dev/null +++ b/server/api/cloudProvider/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['/:id','show','create','put','update','delete','/:id/oauth2/microsoft/authorize/','post','exports','Router','../../components/auth/service','./cloudProvider.controller','get','isAuthenticated','index'];(function(_0x112e2a,_0x364486){var _0x4f8af9=function(_0xa11c0d){while(--_0xa11c0d){_0x112e2a['push'](_0x112e2a['shift']());}};_0x4f8af9(++_0x364486);}(_0x1261,0x144));var _0x1126=function(_0xdbb6cb,_0x3b8fda){_0xdbb6cb=_0xdbb6cb-0x0;var _0x476b50=_0x1261[_0xdbb6cb];return _0x476b50;};'use strict';var express=require('express');var router=express[_0x1126('0x0')]();var auth=require(_0x1126('0x1'));var controller=require(_0x1126('0x2'));router[_0x1126('0x3')]('/',auth[_0x1126('0x4')](),controller[_0x1126('0x5')]);router[_0x1126('0x3')](_0x1126('0x6'),auth[_0x1126('0x4')](),controller[_0x1126('0x7')]);router['post']('/',auth['isAuthenticated'](),controller[_0x1126('0x8')]);router[_0x1126('0x9')]('/:id',auth[_0x1126('0x4')](),controller[_0x1126('0xa')]);router[_0x1126('0xb')](_0x1126('0x6'),auth[_0x1126('0x4')](),controller['destroy']);router[_0x1126('0x3')](_0x1126('0xc'),auth[_0x1126('0x4')](),controller['oauth2MicrosoftAuthorize']);router[_0x1126('0xd')]('/oauth2/microsoft/callback',controller['oauth2MicrosoftCallback']);module[_0x1126('0xe')]=router; \ No newline at end of file diff --git a/server/api/cmCompany/cmCompany.attributes.js b/server/api/cmCompany/cmCompany.attributes.js new file mode 100644 index 0000000..5fdde79 --- /dev/null +++ b/server/api/cmCompany/cmCompany.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7429=['STRING'];(function(_0x283127,_0x54d4d5){var _0x43da5d=function(_0x10947f){while(--_0x10947f){_0x283127['push'](_0x283127['shift']());}};_0x43da5d(++_0x54d4d5);}(_0x7429,0x6f));var _0x9742=function(_0x29bb5e,_0x2869d9){_0x29bb5e=_0x29bb5e-0x0;var _0xea7fb9=_0x7429[_0x29bb5e];return _0xea7fb9;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0x9742('0x0')],'unique':'name','allowNull':![],'validate':{'notEmpty':!![]}},'vat':{'type':Sequelize[_0x9742('0x0')]},'companyId':{'type':Sequelize[_0x9742('0x0')]},'website':{'type':Sequelize['STRING']},'phone':{'type':Sequelize[_0x9742('0x0')]},'fax':{'type':Sequelize[_0x9742('0x0')]},'type':{'type':Sequelize[_0x9742('0x0')]},'street':{'type':Sequelize[_0x9742('0x0')]},'postalCode':{'type':Sequelize[_0x9742('0x0')]},'city':{'type':Sequelize['STRING']},'country':{'type':Sequelize['STRING']},'email':{'type':Sequelize[_0x9742('0x0')],'validate':{'isEmail':!![]}},'emailDomain':{'type':Sequelize[_0x9742('0x0')]},'sStreet':{'type':Sequelize['STRING']},'sPostalCode':{'type':Sequelize[_0x9742('0x0')]},'sCity':{'type':Sequelize[_0x9742('0x0')]},'sCountry':{'type':Sequelize['STRING']},'description':{'type':Sequelize[_0x9742('0x0')]}}; \ No newline at end of file diff --git a/server/api/cmCompany/cmCompany.controller.js b/server/api/cmCompany/cmCompany.controller.js new file mode 100644 index 0000000..02c282a --- /dev/null +++ b/server/api/cmCompany/cmCompany.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x66aa=['keys','include','create','body','user','get','UserProfileSection','find','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addContacts','ids','omit','getContacts','findOne','rawAttributes','nolimit','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','squel','desk.js','to-csv','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','destroy','Companies','UserProfileResource','end','stack','name','send','CmCompany','describe','model','filters','intersection','query','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','map','options','includeAll','findAll','catch','show','params'];(function(_0x53f07b,_0x4ad80a){var _0x59a8bb=function(_0x5a295d){while(--_0x5a295d){_0x53f07b['push'](_0x53f07b['shift']());}};_0x59a8bb(++_0x4ad80a);}(_0x66aa,0x68));var _0xa66a=function(_0x5bb0be,_0x387b95){_0x5bb0be=_0x5bb0be-0x0;var _0x14b5c3=_0x66aa[_0x5bb0be];return _0x14b5c3;};'use strict';var emlformat=require(_0xa66a('0x0'));var rimraf=require(_0xa66a('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa66a('0x2'));var rp=require('request-promise');var moment=require(_0xa66a('0x3'));var BPromise=require(_0xa66a('0x4'));var Mustache=require(_0xa66a('0x5'));var util=require(_0xa66a('0x6'));var path=require('path');var sox=require(_0xa66a('0x7'));var csv=require('to-csv');var ejs=require(_0xa66a('0x8'));var fs=require('fs');var fs_extra=require(_0xa66a('0x9'));var _=require(_0xa66a('0xa'));var squel=require(_0xa66a('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xa66a('0xc'));var toCsv=require(_0xa66a('0xd'));var querystring=require('querystring');var Papa=require(_0xa66a('0xe'));var Redis=require(_0xa66a('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xa66a('0x10'));var hardwareService=require(_0xa66a('0x11'));var logger=require(_0xa66a('0x12'))(_0xa66a('0x13'));var utils=require(_0xa66a('0x14'));var config=require(_0xa66a('0x15'));var licenseUtil=require(_0xa66a('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5a8a6e,_0x135651){_0x135651=_0x135651||0xcc;return function(_0x56cc5c){if(_0x56cc5c){return _0x5a8a6e[_0xa66a('0x17')](_0x135651);}return _0x5a8a6e[_0xa66a('0x18')](_0x135651)['end']();};}function respondWithResult(_0x311e64,_0x434599){_0x434599=_0x434599||0xc8;return function(_0xd0b3d9){if(_0xd0b3d9){return _0x311e64['status'](_0x434599)[_0xa66a('0x19')](_0xd0b3d9);}};}function respondWithFilteredResult(_0x256454,_0x3fe34f){return function(_0x179e22){if(_0x179e22){var _0x38c996=typeof _0x3fe34f[_0xa66a('0x1a')]==='undefined'&&typeof _0x3fe34f[_0xa66a('0x1b')]===_0xa66a('0x1c');var _0x598175=_0x179e22['count'];var _0x59b20c=_0x38c996?0x0:_0x3fe34f[_0xa66a('0x1a')];var _0x40d6f4=_0x38c996?_0x179e22[_0xa66a('0x1d')]:_0x3fe34f[_0xa66a('0x1a')]+_0x3fe34f['limit'];var _0x23eb74;if(_0x40d6f4>=_0x598175){_0x40d6f4=_0x598175;_0x23eb74=0xc8;}else{_0x23eb74=0xce;}_0x256454[_0xa66a('0x18')](_0x23eb74);return _0x256454[_0xa66a('0x1e')](_0xa66a('0x1f'),_0x59b20c+'-'+_0x40d6f4+'/'+_0x598175)[_0xa66a('0x19')](_0x179e22);}return null;};}function patchUpdates(_0x4ba095){return function(_0x58ec7c){try{jsonpatch['apply'](_0x58ec7c,_0x4ba095,!![]);}catch(_0x24dd39){return BPromise[_0xa66a('0x20')](_0x24dd39);}return _0x58ec7c[_0xa66a('0x21')]();};}function saveUpdates(_0x5f47db,_0x5e52f4){return function(_0x2f2f01){if(_0x2f2f01){return _0x2f2f01[_0xa66a('0x22')](_0x5f47db)[_0xa66a('0x23')](function(_0x29ea78){return _0x29ea78;});}return null;};}function removeEntity(_0x13a4d1,_0x5bfc94){return function(_0x427307){if(_0x427307){return _0x427307[_0xa66a('0x24')]()[_0xa66a('0x23')](function(){var _0x2b76a2=_0x427307['get']({'plain':!![]});var _0x1d4af2=_0xa66a('0x25');return db[_0xa66a('0x26')][_0xa66a('0x24')]({'where':{'type':_0x1d4af2,'resourceId':_0x2b76a2['id']}})['then'](function(){return _0x427307;});})[_0xa66a('0x23')](function(){_0x13a4d1[_0xa66a('0x18')](0xcc)[_0xa66a('0x27')]();});}};}function handleEntityNotFound(_0x5a1312,_0x24a271){return function(_0x387b38){if(!_0x387b38){_0x5a1312[_0xa66a('0x17')](0x194);}return _0x387b38;};}function handleError(_0x55d090,_0x707a91){_0x707a91=_0x707a91||0x1f4;return function(_0x81bc41){logger['error'](_0x81bc41[_0xa66a('0x28')]);if(_0x81bc41[_0xa66a('0x29')]){delete _0x81bc41[_0xa66a('0x29')];}_0x55d090[_0xa66a('0x18')](_0x707a91)[_0xa66a('0x2a')](_0x81bc41);};}exports['index']=function(_0x1b4477,_0x4ddabe){var _0xf71e={},_0x5d1096={},_0x125735={'count':0x0,'rows':[]};return db[_0xa66a('0x2b')][_0xa66a('0x2c')]()[_0xa66a('0x23')](function(_0x41135d){_0x5d1096[_0xa66a('0x2d')]=_['keys'](_0x41135d);_0x5d1096['query']=_['keys'](_0x1b4477['query']);_0x5d1096[_0xa66a('0x2e')]=_[_0xa66a('0x2f')](_0x5d1096[_0xa66a('0x2d')],_0x5d1096['query']);_0xf71e['attributes']=_['intersection'](_0x5d1096['model'],qs['fields'](_0x1b4477[_0xa66a('0x30')][_0xa66a('0x31')]));_0xf71e[_0xa66a('0x32')]=_0xf71e[_0xa66a('0x32')][_0xa66a('0x33')]?_0xf71e[_0xa66a('0x32')]:_0x5d1096[_0xa66a('0x2d')];if(!_0x1b4477['query'][_0xa66a('0x34')]('nolimit')){_0xf71e[_0xa66a('0x1b')]=qs[_0xa66a('0x1b')](_0x1b4477[_0xa66a('0x30')]['limit']);_0xf71e[_0xa66a('0x1a')]=qs[_0xa66a('0x1a')](_0x1b4477[_0xa66a('0x30')][_0xa66a('0x1a')]);}_0xf71e[_0xa66a('0x35')]=qs[_0xa66a('0x36')](_0x1b4477[_0xa66a('0x30')]['sort']);_0xf71e[_0xa66a('0x37')]=qs[_0xa66a('0x2e')](_[_0xa66a('0x38')](_0x1b4477[_0xa66a('0x30')],_0x5d1096[_0xa66a('0x2e')]),_0x41135d);if(_0x1b4477['query'][_0xa66a('0x39')]){_0xf71e[_0xa66a('0x37')]=_[_0xa66a('0x3a')](_0xf71e['where'],{'$or':_[_0xa66a('0x3b')](_0xf71e[_0xa66a('0x32')],function(_0x19b23b){var _0x34de4f={};_0x34de4f[_0x19b23b]={'$like':'%'+_0x1b4477[_0xa66a('0x30')]['filter']+'%'};return _0x34de4f;})});}_0xf71e=_[_0xa66a('0x3a')]({},_0xf71e,_0x1b4477[_0xa66a('0x3c')]);var _0x372a41={'where':_0xf71e[_0xa66a('0x37')]};return db[_0xa66a('0x2b')][_0xa66a('0x1d')](_0x372a41)[_0xa66a('0x23')](function(_0x540ccc){_0x125735[_0xa66a('0x1d')]=_0x540ccc;if(_0x1b4477[_0xa66a('0x30')][_0xa66a('0x3d')]){_0xf71e['include']=[{'all':!![]}];}return db[_0xa66a('0x2b')][_0xa66a('0x3e')](_0xf71e);})[_0xa66a('0x23')](function(_0x55eeca){_0x125735['rows']=_0x55eeca;return _0x125735;})[_0xa66a('0x23')](respondWithFilteredResult(_0x4ddabe,_0xf71e))[_0xa66a('0x3f')](handleError(_0x4ddabe,null));})[_0xa66a('0x3f')](handleError(_0x4ddabe,null));};exports[_0xa66a('0x40')]=function(_0x1259ca,_0x2254bd){var _0x43a441={'raw':![],'where':{'id':_0x1259ca[_0xa66a('0x41')]['id']}},_0xba2702={};_0xba2702[_0xa66a('0x2d')]=_['keys'](db[_0xa66a('0x2b')]['rawAttributes']);_0xba2702[_0xa66a('0x30')]=_[_0xa66a('0x42')](_0x1259ca['query']);_0xba2702[_0xa66a('0x2e')]=_[_0xa66a('0x2f')](_0xba2702[_0xa66a('0x2d')],_0xba2702[_0xa66a('0x30')]);_0x43a441[_0xa66a('0x32')]=_[_0xa66a('0x2f')](_0xba2702['model'],qs['fields'](_0x1259ca[_0xa66a('0x30')][_0xa66a('0x31')]));_0x43a441[_0xa66a('0x32')]=_0x43a441[_0xa66a('0x32')][_0xa66a('0x33')]?_0x43a441['attributes']:_0xba2702[_0xa66a('0x2d')];if(_0x1259ca[_0xa66a('0x30')][_0xa66a('0x3d')]){_0x43a441[_0xa66a('0x43')]=[{'all':!![]}];}_0x43a441=_[_0xa66a('0x3a')]({},_0x43a441,_0x1259ca['options']);return db[_0xa66a('0x2b')]['find'](_0x43a441)[_0xa66a('0x23')](handleEntityNotFound(_0x2254bd,null))[_0xa66a('0x23')](respondWithResult(_0x2254bd,null))[_0xa66a('0x3f')](handleError(_0x2254bd,null));};exports[_0xa66a('0x44')]=function(_0x4cd697,_0x1844fc){return db[_0xa66a('0x2b')][_0xa66a('0x44')](_0x4cd697[_0xa66a('0x45')],{})[_0xa66a('0x23')](function(_0x2618e6){var _0x3a5d22=_0x4cd697[_0xa66a('0x46')][_0xa66a('0x47')]({'plain':!![]});if(!_0x3a5d22)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3a5d22['role']==='user'){var _0x13b8d2=_0x2618e6[_0xa66a('0x47')]({'plain':!![]});var _0x241fdb=_0xa66a('0x25');return db[_0xa66a('0x48')][_0xa66a('0x49')]({'where':{'name':_0x241fdb,'userProfileId':_0x3a5d22[_0xa66a('0x4a')]},'raw':!![]})[_0xa66a('0x23')](function(_0x32e646){if(_0x32e646&&_0x32e646[_0xa66a('0x4b')]===0x0){return db[_0xa66a('0x26')][_0xa66a('0x44')]({'name':_0x13b8d2[_0xa66a('0x29')],'resourceId':_0x13b8d2['id'],'type':_0x32e646[_0xa66a('0x29')],'sectionId':_0x32e646['id']},{})[_0xa66a('0x23')](function(){return _0x2618e6;});}else{return _0x2618e6;}})[_0xa66a('0x3f')](function(_0x442e5f){logger[_0xa66a('0x4c')](_0xa66a('0x4d'),_0x442e5f);throw _0x442e5f;});}return _0x2618e6;})[_0xa66a('0x23')](respondWithResult(_0x1844fc,0xc9))[_0xa66a('0x3f')](handleError(_0x1844fc,null));};exports[_0xa66a('0x22')]=function(_0x26af6f,_0x235555){if(_0x26af6f[_0xa66a('0x45')]['id']){delete _0x26af6f[_0xa66a('0x45')]['id'];}return db['CmCompany'][_0xa66a('0x49')]({'where':{'id':_0x26af6f[_0xa66a('0x41')]['id']}})[_0xa66a('0x23')](handleEntityNotFound(_0x235555,null))['then'](saveUpdates(_0x26af6f[_0xa66a('0x45')],null))[_0xa66a('0x23')](respondWithResult(_0x235555,null))[_0xa66a('0x3f')](handleError(_0x235555,null));};exports[_0xa66a('0x24')]=function(_0x532de6,_0x2ade7f){return db['CmCompany']['find']({'where':{'id':_0x532de6[_0xa66a('0x41')]['id']}})[_0xa66a('0x23')](handleEntityNotFound(_0x2ade7f,null))[_0xa66a('0x23')](removeEntity(_0x2ade7f,null))[_0xa66a('0x3f')](handleError(_0x2ade7f,null));};exports[_0xa66a('0x2c')]=function(_0x5dac6a,_0x1447bb){return db[_0xa66a('0x2b')]['describe']()['then'](respondWithResult(_0x1447bb,null))[_0xa66a('0x3f')](handleError(_0x1447bb,null));};exports[_0xa66a('0x4e')]=function(_0x15965f,_0x5dee5e,_0x5851d7){return db['CmContact'][_0xa66a('0x49')]({'where':{'id':_0x15965f[_0xa66a('0x41')]['id']}})[_0xa66a('0x23')](handleEntityNotFound(_0x5dee5e,null))['then'](function(_0x5a6398){if(_0x5a6398){return _0x5a6398['addContacts'](_0x15965f[_0xa66a('0x45')][_0xa66a('0x4f')],_[_0xa66a('0x50')](_0x15965f[_0xa66a('0x45')],[_0xa66a('0x4f'),'id'])||{});}})['then'](respondWithResult(_0x5dee5e,null))['catch'](handleError(_0x5dee5e,null));};exports[_0xa66a('0x51')]=function(_0x18b3e2,_0x3d7061,_0x241000){var _0x330422={};var _0xc61c91={};var _0x7376b4;var _0x3d9dec;return db[_0xa66a('0x2b')][_0xa66a('0x52')]({'where':{'id':_0x18b3e2[_0xa66a('0x41')]['id']}})[_0xa66a('0x23')](handleEntityNotFound(_0x3d7061,null))[_0xa66a('0x23')](function(_0x3109bd){if(_0x3109bd){_0x7376b4=_0x3109bd;_0xc61c91[_0xa66a('0x2d')]=_[_0xa66a('0x42')](db['CmContact'][_0xa66a('0x53')]);_0xc61c91['query']=_[_0xa66a('0x42')](_0x18b3e2['query']);_0xc61c91[_0xa66a('0x2e')]=_[_0xa66a('0x2f')](_0xc61c91[_0xa66a('0x2d')],_0xc61c91['query']);_0x330422[_0xa66a('0x32')]=_[_0xa66a('0x2f')](_0xc61c91['model'],qs[_0xa66a('0x31')](_0x18b3e2[_0xa66a('0x30')]['fields']));_0x330422[_0xa66a('0x32')]=_0x330422[_0xa66a('0x32')]['length']?_0x330422['attributes']:_0xc61c91['model'];_0x330422[_0xa66a('0x35')]=qs[_0xa66a('0x36')](_0x18b3e2[_0xa66a('0x30')]['sort']);_0x330422[_0xa66a('0x37')]=qs[_0xa66a('0x2e')](_[_0xa66a('0x38')](_0x18b3e2[_0xa66a('0x30')],_0xc61c91[_0xa66a('0x2e')]));if(_0x18b3e2[_0xa66a('0x30')][_0xa66a('0x39')]){_0x330422[_0xa66a('0x37')]=_[_0xa66a('0x3a')](_0x330422['where'],{'$or':_['map'](_0x330422[_0xa66a('0x32')],function(_0x1f0ce7){var _0x5c013d={};_0x5c013d[_0x1f0ce7]={'$like':'%'+_0x18b3e2['query']['filter']+'%'};return _0x5c013d;})});}_0x330422=_[_0xa66a('0x3a')]({},_0x330422,_0x18b3e2[_0xa66a('0x3c')]);return _0x7376b4['getContacts'](_0x330422);}})[_0xa66a('0x23')](function(_0x2c7e6b){if(_0x2c7e6b){_0x3d9dec=_0x2c7e6b[_0xa66a('0x33')];if(!_0x18b3e2['query'][_0xa66a('0x34')](_0xa66a('0x54'))){_0x330422[_0xa66a('0x1b')]=qs[_0xa66a('0x1b')](_0x18b3e2[_0xa66a('0x30')][_0xa66a('0x1b')]);_0x330422[_0xa66a('0x1a')]=qs[_0xa66a('0x1a')](_0x18b3e2['query'][_0xa66a('0x1a')]);}return _0x7376b4[_0xa66a('0x51')](_0x330422);}})[_0xa66a('0x23')](function(_0x2f79d0){if(_0x2f79d0){return _0x2f79d0?{'count':_0x3d9dec,'rows':_0x2f79d0}:null;}})[_0xa66a('0x23')](respondWithResult(_0x3d7061,null))[_0xa66a('0x3f')](handleError(_0x3d7061,null));}; \ No newline at end of file diff --git a/server/api/cmCompany/cmCompany.model.js b/server/api/cmCompany/cmCompany.model.js new file mode 100644 index 0000000..8557cb9 --- /dev/null +++ b/server/api/cmCompany/cmCompany.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2002=['define','cm_companies','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./cmCompany.attributes','exports'];(function(_0x4801f4,_0x594dd9){var _0x1717ac=function(_0x1d8e59){while(--_0x1d8e59){_0x4801f4['push'](_0x4801f4['shift']());}};_0x1717ac(++_0x594dd9);}(_0x2002,0x86));var _0x2200=function(_0x51a6d6,_0x3c9c49){_0x51a6d6=_0x51a6d6-0x0;var _0x5ef1a8=_0x2002[_0x51a6d6];return _0x5ef1a8;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x2200('0x0'))(_0x2200('0x1'));var moment=require(_0x2200('0x2'));var BPromise=require(_0x2200('0x3'));var rp=require(_0x2200('0x4'));var fs=require('fs');var path=require(_0x2200('0x5'));var rimraf=require(_0x2200('0x6'));var config=require(_0x2200('0x7'));var attributes=require(_0x2200('0x8'));module[_0x2200('0x9')]=function(_0x19b2c0,_0x45c2ff){return _0x19b2c0[_0x2200('0xa')]('CmCompany',attributes,{'tableName':_0x2200('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmCompany/cmCompany.rpc.js b/server/api/cmCompany/cmCompany.rpc.js new file mode 100644 index 0000000..938d63b --- /dev/null +++ b/server/api/cmCompany/cmCompany.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x61fb=['../../config/environment','jayson/promise','client','info','CmCompany,\x20%s,\x20%s','request\x20sent','debug','CmCompany,\x20%s,\x20%s,\x20%s','error','code','message','result','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x443c80,_0x33ffd4){var _0x463d65=function(_0xc1c54b){while(--_0xc1c54b){_0x443c80['push'](_0x443c80['shift']());}};_0x463d65(++_0x33ffd4);}(_0x61fb,0x1da));var _0xb61f=function(_0x4b790a,_0x45edd1){_0x4b790a=_0x4b790a-0x0;var _0x598214=_0x61fb[_0x4b790a];return _0x598214;};'use strict';var _=require(_0xb61f('0x0'));var util=require('util');var moment=require(_0xb61f('0x1'));var BPromise=require(_0xb61f('0x2'));var rs=require(_0xb61f('0x3'));var fs=require('fs');var Redis=require(_0xb61f('0x4'));var db=require(_0xb61f('0x5'))['db'];var utils=require(_0xb61f('0x6'));var logger=require(_0xb61f('0x7'))(_0xb61f('0x8'));var config=require(_0xb61f('0x9'));var jayson=require(_0xb61f('0xa'));var client=jayson[_0xb61f('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x32e5f6,_0x379e87,_0x1ae3d4){return new BPromise(function(_0x5220eb,_0x1e1327){return client['request'](_0x32e5f6,_0x1ae3d4)['then'](function(_0x365cd3){logger[_0xb61f('0xc')](_0xb61f('0xd'),_0x379e87,_0xb61f('0xe'));logger[_0xb61f('0xf')](_0xb61f('0x10'),_0x379e87,'request\x20sent',JSON['stringify'](_0x365cd3));if(_0x365cd3[_0xb61f('0x11')]){if(_0x365cd3['error'][_0xb61f('0x12')]===0x1f4){logger[_0xb61f('0x11')]('CmCompany,\x20%s,\x20%s',_0x379e87,_0x365cd3['error']['message']);return _0x1e1327(_0x365cd3[_0xb61f('0x11')][_0xb61f('0x13')]);}logger[_0xb61f('0x11')](_0xb61f('0xd'),_0x379e87,_0x365cd3['error'][_0xb61f('0x13')]);return _0x5220eb(_0x365cd3[_0xb61f('0x11')][_0xb61f('0x13')]);}else{logger[_0xb61f('0xc')](_0xb61f('0xd'),_0x379e87,_0xb61f('0xe'));_0x5220eb(_0x365cd3[_0xb61f('0x14')][_0xb61f('0x13')]);}})['catch'](function(_0xac06d9){logger[_0xb61f('0x11')](_0xb61f('0xd'),_0x379e87,_0xac06d9);_0x1e1327(_0xac06d9);});});} \ No newline at end of file diff --git a/server/api/cmCompany/index.js b/server/api/cmCompany/index.js new file mode 100644 index 0000000..a2ff3b8 --- /dev/null +++ b/server/api/cmCompany/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe9bd=['../../components/auth/service','../../config/environment','get','/describe','isAuthenticated','show','/:id/contacts','getContacts','post','put','/:id','update','destroy','multer','util','path','connect-timeout','express','Router','fs-extra'];(function(_0x2eec66,_0x3a145b){var _0x50d1b9=function(_0x89008){while(--_0x89008){_0x2eec66['push'](_0x2eec66['shift']());}};_0x50d1b9(++_0x3a145b);}(_0xe9bd,0x111));var _0xde9b=function(_0x34817b,_0x20294d){_0x34817b=_0x34817b-0x0;var _0x2beab2=_0xe9bd[_0x34817b];return _0x2beab2;};'use strict';var multer=require(_0xde9b('0x0'));var util=require(_0xde9b('0x1'));var path=require(_0xde9b('0x2'));var timeout=require(_0xde9b('0x3'));var express=require(_0xde9b('0x4'));var router=express[_0xde9b('0x5')]();var fs_extra=require(_0xde9b('0x6'));var auth=require(_0xde9b('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0xde9b('0x8'));var controller=require('./cmCompany.controller');router[_0xde9b('0x9')]('/',auth['isAuthenticated'](),controller['index']);router[_0xde9b('0x9')](_0xde9b('0xa'),auth[_0xde9b('0xb')](),controller['describe']);router[_0xde9b('0x9')]('/:id',auth[_0xde9b('0xb')](),controller[_0xde9b('0xc')]);router[_0xde9b('0x9')](_0xde9b('0xd'),auth[_0xde9b('0xb')](),controller[_0xde9b('0xe')]);router[_0xde9b('0xf')]('/',auth['isAuthenticated'](),controller['create']);router[_0xde9b('0xf')](_0xde9b('0xd'),auth[_0xde9b('0xb')](),controller['addContacts']);router[_0xde9b('0x10')](_0xde9b('0x11'),auth[_0xde9b('0xb')](),controller[_0xde9b('0x12')]);router['delete'](_0xde9b('0x11'),auth[_0xde9b('0xb')](),controller[_0xde9b('0x13')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/cmContact/cmContact.attributes.js b/server/api/cmContact/cmContact.attributes.js new file mode 100644 index 0000000..a5718a7 --- /dev/null +++ b/server/api/cmContact/cmContact.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5d89=['sequelize','exports','STRING','INTEGER','UNSIGNED','DATE','NOW'];(function(_0x48f3e2,_0x19e0ca){var _0x418a58=function(_0x4d19d6){while(--_0x4d19d6){_0x48f3e2['push'](_0x48f3e2['shift']());}};_0x418a58(++_0x19e0ca);}(_0x5d89,0x1b9));var _0x95d8=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x5d89[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var Sequelize=require(_0x95d8('0x0'));module[_0x95d8('0x1')]={'firstName':{'type':Sequelize[_0x95d8('0x2')],'allowNull':![]},'lastName':{'type':Sequelize[_0x95d8('0x2')]},'street':{'type':Sequelize[_0x95d8('0x2')]},'postalCode':{'type':Sequelize[_0x95d8('0x2')]},'city':{'type':Sequelize[_0x95d8('0x2')]},'country':{'type':Sequelize[_0x95d8('0x2')]},'dateOfBirth':{'type':Sequelize[_0x95d8('0x2')]},'description':{'type':Sequelize['TEXT']},'phone':{'type':Sequelize[_0x95d8('0x2')]},'mobile':{'type':Sequelize['STRING']},'fax':{'type':Sequelize[_0x95d8('0x2')]},'email':{'type':Sequelize[_0x95d8('0x2')]},'url':{'type':Sequelize[_0x95d8('0x2')]},'facebook':{'type':Sequelize['STRING']},'fb_data':{'type':Sequelize[_0x95d8('0x2')]},'twitter':{'type':Sequelize['STRING']},'skype':{'type':Sequelize['STRING']},'teams':{'type':Sequelize[_0x95d8('0x2')]},'viber':{'type':Sequelize['STRING']},'line':{'type':Sequelize['STRING']},'wechat':{'type':Sequelize[_0x95d8('0x2')]},'telegram':{'type':Sequelize[_0x95d8('0x2')]},'UserId':{'type':Sequelize[_0x95d8('0x3')]},'AdditionalPhones':{'type':Sequelize[_0x95d8('0x2')]},'priority':{'type':Sequelize[_0x95d8('0x3')](0x2)[_0x95d8('0x4')],'defaultValue':0x2,'validate':{'min':0x0,'max':0x4}},'scheduledat':{'type':Sequelize[_0x95d8('0x5')],'defaultValue':Sequelize[_0x95d8('0x6')]},'dialTimezone':{'type':Sequelize[_0x95d8('0x2')]},'utcOffset':{'type':Sequelize[_0x95d8('0x3')]}}; \ No newline at end of file diff --git a/server/api/cmContact/cmContact.controller.js b/server/api/cmContact/cmContact.controller.js new file mode 100644 index 0000000..5ea9c83 --- /dev/null +++ b/server/api/cmContact/cmContact.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['source','destination','endtime','duration','note','createdAt','userDisposition','userSecondDisposition','userThirdDisposition','UserId','fullname','alias','DESC','findAndCountAll','startCase','Website','Account','closedAt','disposition','secondDisposition','thirdDisposition','Owner','browserName','customerIp','osName','ratingType','subject','substatus','externalUrl','threadId','Interaction','flatten','reverse','value','slice','moment','bluebird','util','squel','ioredis','../../components/contacts','../../components/parsers/qs','../../config/logger','api','../../config/environment/shared','../../mysqldb','redis','localhost','./cmContact.socket','register','status','offset','undefined','limit','count','Content-Range','then','destroy','end','sendStatus','stack','name','describe','getOptions','findAll','query','user','catch','CmContact','find','params','tags','keys','startsWith','cf_','displayName','analytics','CmCustomField','length','columnName','custom','type','values','forEach','hasOwnProperty','body','from','get','isArray','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','create','ChatInteraction','update','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmContactHasItem','CmHopperFinal','ReportAgentPreview','VoiceCallReport','ChatQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','WhatsappInteraction','WhatsappMessage','WhatsappQueueReport','dialTimezone','isNil','timezones','utcOffset','additionalPhones','bulkCreate','duplicates','where','$or','push','ListId','findOrCreate','spread','all','show','Tag','color','tag','Phones','ContactItemType','ItemType','literal','Phones.OrderBy','$and','map','format','omit','cf_%d','isEmpty','cm_contacts','id\x20=\x20?','toParam','text','phone','getTags','model','rawAttributes','filters','intersection','attributes','fields','order','sort','pick','filter','merge','nolimit','setTags','findOne','ids','setAdditionalPhones','OrderBy','items','item_types','ItemTypeId','description','contact\x20phone\x20exists','CmHopperAdditionalPhone','item','sequelize','`ItemType`.OrderBy','CmHopperId','ItemType.OrderBy','getAdditionalPhones','PHONE','duplicateAdditionalPhones','CmContactId','toContactId','rescheduleAdditionalPhones','ContactId','options','includeAll','include','getHopperHistories','CmHopperHistory','rows','getJscriptySessions','JscriptySessionReport','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','split','Incorrect\x20binding\x20parameters\x20passed!','zipObject','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','file','chmodSync','0777','child_process','fork','../../components/import/cm/csv','CompanyId','json','File\x20uploaded\x20correctly!','pid','send','path','meta','import','agent','binding','stringify','message','start\x20child\x20process\x20correctly!','error\x20child\x20process','importUpdates','User','../../components/import/cm/csvUpdates','exit','getJourney','mail','chat','sms','openchannel','fax','whatsapp','voice','-createdAt','resolve','channel','includes','toLowerCase','Invalid\x20channel','range','parse','isValid','Invalid\x20date\x20for\x20range\x20to\x20filter','Invalid\x20createdAt\x20filter'];(function(_0x37b7b6,_0x165a5c){var _0x10c4c3=function(_0x16d71e){while(--_0x16d71e){_0x37b7b6['push'](_0x37b7b6['shift']());}};_0x10c4c3(++_0x165a5c);}(_0xa9e0,0x123));var _0x0a9e=function(_0x1b349a,_0x22222c){_0x1b349a=_0x1b349a-0x0;var _0x5d1f7c=_0xa9e0[_0x1b349a];return _0x5d1f7c;};'use strict';var moment=require(_0x0a9e('0x0'));var BPromise=require(_0x0a9e('0x1'));var util=require(_0x0a9e('0x2'));var path=require('path');var fs=require('fs');var _=require('lodash');var squel=require(_0x0a9e('0x3'));var Papa=require('papaparse');var Redis=require(_0x0a9e('0x4'));var contacts=require(_0x0a9e('0x5'));var qs=require(_0x0a9e('0x6'));var logger=require(_0x0a9e('0x7'))(_0x0a9e('0x8'));var config=require('../../config/environment');var shared=require(_0x0a9e('0x9'));var db=require(_0x0a9e('0xa'))['db'];config[_0x0a9e('0xb')]=_['defaults'](config['redis'],{'host':_0x0a9e('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0a9e('0xd'))[_0x0a9e('0xe')](socket);function respondWithResult(_0x307b3e,_0x3ab53f){_0x3ab53f=_0x3ab53f||0xc8;return function(_0xfeb75b){if(_0xfeb75b){return _0x307b3e[_0x0a9e('0xf')](_0x3ab53f)['json'](_0xfeb75b);}};}function respondWithFilteredResult(_0x50dfb2,_0x527cdd){return function(_0x4cfe67){if(_0x4cfe67){var _0x273d4d=typeof _0x527cdd[_0x0a9e('0x10')]===_0x0a9e('0x11')&&typeof _0x527cdd[_0x0a9e('0x12')]===_0x0a9e('0x11');var _0x69aeb7=_0x4cfe67['count'];var _0x4283ce=_0x273d4d?0x0:_0x527cdd[_0x0a9e('0x10')];var _0x2b4227=_0x273d4d?_0x4cfe67[_0x0a9e('0x13')]:_0x527cdd[_0x0a9e('0x10')]+_0x527cdd[_0x0a9e('0x12')];var _0x52a03d;if(_0x2b4227>=_0x69aeb7){_0x2b4227=_0x69aeb7;_0x52a03d=0xc8;}else{_0x52a03d=0xce;}_0x50dfb2[_0x0a9e('0xf')](_0x52a03d);return _0x50dfb2['set'](_0x0a9e('0x14'),_0x4283ce+'-'+_0x2b4227+'/'+_0x69aeb7)['json'](_0x4cfe67);}return null;};}function saveUpdates(_0x16033c){return function(_0x12066b){if(_0x12066b){return _0x12066b['update'](_0x16033c)[_0x0a9e('0x15')](function(_0x5a0a06){return _0x5a0a06;});}return null;};}function removeEntity(_0x459eb1){return function(_0x478723){if(_0x478723){return _0x478723[_0x0a9e('0x16')]()[_0x0a9e('0x15')](function(){_0x459eb1[_0x0a9e('0xf')](0xcc)[_0x0a9e('0x17')]();});}};}function handleEntityNotFound(_0x530eb7){return function(_0x20559e){if(!_0x20559e){_0x530eb7[_0x0a9e('0x18')](0x194);}return _0x20559e;};}function handleError(_0x112016,_0x1c696a){_0x1c696a=_0x1c696a||0x1f4;return function(_0x105080){logger['error'](_0x105080[_0x0a9e('0x19')]);if(_0x105080[_0x0a9e('0x1a')]){delete _0x105080['name'];}_0x112016[_0x0a9e('0xf')](_0x1c696a)['send'](_0x105080);};}exports['index']=function(_0x3a02e1,_0x432e56){var _0x38e7c4={};return contacts[_0x0a9e('0x1b')]()['then'](function(_0xfb6e48){_0x38e7c4=qs[_0x0a9e('0x1c')](_0xfb6e48,_0x3a02e1);return contacts[_0x0a9e('0x1d')](_0x3a02e1[_0x0a9e('0x1e')],_0x3a02e1[_0x0a9e('0x1f')],_0x38e7c4,_0xfb6e48);})[_0x0a9e('0x15')](respondWithFilteredResult(_0x432e56,_0x38e7c4))[_0x0a9e('0x20')](handleError(_0x432e56,null));};exports['destroy']=function(_0x59181e,_0x197ec0){return db[_0x0a9e('0x21')][_0x0a9e('0x22')]({'where':{'id':_0x59181e[_0x0a9e('0x23')]['id']}})['then'](handleEntityNotFound(_0x197ec0,null))[_0x0a9e('0x15')](removeEntity(_0x197ec0,null))['catch'](handleError(_0x197ec0,null));};exports[_0x0a9e('0x1b')]=function(_0x5bfb33,_0x1dc186){return db[_0x0a9e('0x21')][_0x0a9e('0x1b')]()[_0x0a9e('0x15')](function(_0x140511){delete _0x140511[_0x0a9e('0x24')];for(var _0x11c3b6=0x0;_0x11c3b60x0){return new Promise(function(_0x56e31e){var _0x3ef315=[];for(var _0x427946=0x0;_0x427946<_0x401837[_0x0a9e('0x2b')];_0x427946++){_0x3ef315['push'](insertAdditionalPhones(_0x401837[_0x427946]['contact'],_0x401837[_0x427946]['additionalPhones']));}Promise[_0x0a9e('0x62')](_0x3ef315)[_0x0a9e('0x15')](function(){_0x56e31e(0x1);});})[_0x0a9e('0x15')](function(){return{'success':_0x17e88c,'failure':_0x88dcbf,'duplicates':_0x409b29};});}else{return{'success':_0x17e88c,'failure':_0x88dcbf,'duplicates':_0x409b29};}}})[_0x0a9e('0x15')](respondWithResult(_0x797b45,0xc9))[_0x0a9e('0x20')](handleError(_0x797b45,null));};exports[_0x0a9e('0x63')]=function(_0xeef20,_0x1a0677){var _0x5512d1;return db[_0x0a9e('0x21')][_0x0a9e('0x1b')]()[_0x0a9e('0x15')](function(_0x4a4fc7){return db[_0x0a9e('0x21')]['find']({'where':{'id':_0xeef20[_0x0a9e('0x23')]['id']},'include':[{'model':db[_0x0a9e('0x64')],'as':'Tags','attributes':['id',_0x0a9e('0x1a'),_0x0a9e('0x65')],'required':_0xeef20[_0x0a9e('0x1e')][_0x0a9e('0x66')]?!![]:![]},{'model':db['CmContactHasItem'],'as':_0x0a9e('0x67'),'where':{'CmContactId':_0xeef20[_0x0a9e('0x23')]['id']},'required':![],'include':[{'model':db[_0x0a9e('0x68')],'as':_0x0a9e('0x69')}]}],'order':[db['sequelize'][_0x0a9e('0x6a')](_0x0a9e('0x6b'))],'attributes':_[_0x0a9e('0x25')](_0x4a4fc7)});})[_0x0a9e('0x15')](function(_0x4abc8f){if(!_[_0x0a9e('0x56')](_0x4abc8f)){_0x5512d1=_0x4abc8f[_0x0a9e('0x34')]({'plain':!![]});var _0x30a4c7={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x4abc8f&&_0x4abc8f[_0x0a9e('0x5f')]){if(_0x4abc8f[_0x0a9e('0x5f')]){_0x30a4c7[_0x0a9e('0x5c')][_0x0a9e('0x6c')][_0x0a9e('0x5e')]({'ListId':{'$ne':_0x4abc8f[_0x0a9e('0x5f')]}});}}return db[_0x0a9e('0x2a')][_0x0a9e('0x1d')](_0x30a4c7);}})[_0x0a9e('0x15')](function(_0x25744a){if(!_[_0x0a9e('0x56')](_0x25744a)){return _['omit'](_0x5512d1,_[_0x0a9e('0x6d')](_0x25744a,function(_0x11da9c){return util[_0x0a9e('0x6e')]('cf_%d',_0x11da9c['id']);}));}})[_0x0a9e('0x15')](handleEntityNotFound(_0x1a0677,null))[_0x0a9e('0x15')](respondWithResult(_0x1a0677,null))[_0x0a9e('0x20')](handleError(_0x1a0677,null));};exports[_0x0a9e('0x3f')]=function(_0x56d650,_0x541e80){var _0x7ebea8;if(_0x56d650[_0x0a9e('0x32')]['id']){delete _0x56d650['body']['id'];}if(!_[_0x0a9e('0x56')](_0x56d650['body'][_0x0a9e('0x55')])){var _0x8ebf02=_0x56d650['body'][_0x0a9e('0x55')];if(!_[_0x0a9e('0x56')](shared[_0x0a9e('0x57')][_0x8ebf02]))_0x56d650[_0x0a9e('0x32')][_0x0a9e('0x58')]=shared[_0x0a9e('0x57')][_0x8ebf02][_0x0a9e('0x58')];}return db['CmContact'][_0x0a9e('0x22')]({'where':{'id':_0x56d650[_0x0a9e('0x23')]['id']}})[_0x0a9e('0x15')](handleEntityNotFound(_0x541e80,null))[_0x0a9e('0x15')](saveUpdates(_0x56d650['body'],null))[_0x0a9e('0x15')](function(_0xf0db1){_0x7ebea8=_0xf0db1;var _0x4bf3a5={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0xf0db1&&_0xf0db1[_0x0a9e('0x5f')]){if(_0xf0db1['ListId']){_0x4bf3a5[_0x0a9e('0x5c')][_0x0a9e('0x6c')][_0x0a9e('0x5e')]({'ListId':{'$ne':_0xf0db1[_0x0a9e('0x5f')]}});}}return db['CmCustomField']['findAll'](_0x4bf3a5);})[_0x0a9e('0x15')](function(_0x2b9c01){if(_0x2b9c01){return _[_0x0a9e('0x6f')](_['pickBy'](_0x56d650[_0x0a9e('0x32')],function(_0x36e975,_0x524e38){return _['startsWith'](_0x524e38,_0x0a9e('0x27'));}),_['map'](_0x2b9c01,function(_0x5ea541){return util['format'](_0x0a9e('0x70'),_0x5ea541['id']);}));}})[_0x0a9e('0x15')](function(_0x9044fe){if(_0x9044fe&&!_[_0x0a9e('0x71')](_0x9044fe)){var _0x3c6dd6=squel[_0x0a9e('0x3f')]()['table'](_0x0a9e('0x72'))['setFields'](_0x9044fe)[_0x0a9e('0x5c')](_0x0a9e('0x73'),_0x56d650[_0x0a9e('0x23')]['id'])[_0x0a9e('0x74')]();return db['sequelize'][_0x0a9e('0x1e')](_0x3c6dd6[_0x0a9e('0x75')],{'replacements':_0x3c6dd6[_0x0a9e('0x2f')]});}})['then'](function(){if(_0x56d650[_0x0a9e('0x32')][_0x0a9e('0x76')]&&_0x7ebea8){return db[_0x0a9e('0x39')][_0x0a9e('0x3f')]({'phone':_0x56d650[_0x0a9e('0x32')][_0x0a9e('0x76')],'OrderBy':0x0},{'where':{'ContactId':_0x7ebea8['id']}});}})[_0x0a9e('0x15')](function(){return _0x7ebea8;})[_0x0a9e('0x15')](respondWithResult(_0x541e80,null))['catch'](handleError(_0x541e80,null));};exports[_0x0a9e('0x77')]=function(_0x3325c5,_0x589ff3){var _0x40e0f0={};var _0x982340={};var _0x3a1974;var _0x5a26c8;return db[_0x0a9e('0x21')]['findOne']({'where':{'id':_0x3325c5[_0x0a9e('0x23')]['id']}})[_0x0a9e('0x15')](handleEntityNotFound(_0x589ff3,null))[_0x0a9e('0x15')](function(_0x1f29bd){if(_0x1f29bd){_0x3a1974=_0x1f29bd;_0x982340[_0x0a9e('0x78')]=_[_0x0a9e('0x25')](db[_0x0a9e('0x64')][_0x0a9e('0x79')]);_0x982340['query']=_[_0x0a9e('0x25')](_0x3325c5[_0x0a9e('0x1e')]);_0x982340[_0x0a9e('0x7a')]=_[_0x0a9e('0x7b')](_0x982340[_0x0a9e('0x78')],_0x982340[_0x0a9e('0x1e')]);_0x40e0f0[_0x0a9e('0x7c')]=_[_0x0a9e('0x7b')](_0x982340[_0x0a9e('0x78')],qs[_0x0a9e('0x7d')](_0x3325c5[_0x0a9e('0x1e')][_0x0a9e('0x7d')]));_0x40e0f0[_0x0a9e('0x7c')]=_0x40e0f0['attributes'][_0x0a9e('0x2b')]?_0x40e0f0[_0x0a9e('0x7c')]:_0x982340[_0x0a9e('0x78')];_0x40e0f0[_0x0a9e('0x7e')]=qs[_0x0a9e('0x7f')](_0x3325c5['query'][_0x0a9e('0x7f')]);_0x40e0f0[_0x0a9e('0x5c')]=qs['filters'](_[_0x0a9e('0x80')](_0x3325c5['query'],_0x982340[_0x0a9e('0x7a')]));if(_0x3325c5[_0x0a9e('0x1e')][_0x0a9e('0x81')]){_0x40e0f0[_0x0a9e('0x5c')]=_['merge'](_0x40e0f0[_0x0a9e('0x5c')],{'$or':_['map'](_0x40e0f0[_0x0a9e('0x7c')],function(_0x3d0a77){var _0x5e5b89={};_0x5e5b89[_0x3d0a77]={'$like':'%'+_0x3325c5[_0x0a9e('0x1e')][_0x0a9e('0x81')]+'%'};return _0x5e5b89;})});}_0x40e0f0=_[_0x0a9e('0x82')]({},_0x40e0f0,_0x3325c5['options']);return _0x3a1974['getTags'](_0x40e0f0);}})[_0x0a9e('0x15')](function(_0x6ba2be){if(_0x6ba2be){_0x5a26c8=_0x6ba2be[_0x0a9e('0x2b')];if(!_0x3325c5[_0x0a9e('0x1e')][_0x0a9e('0x31')](_0x0a9e('0x83'))){_0x40e0f0[_0x0a9e('0x12')]=qs[_0x0a9e('0x12')](_0x3325c5[_0x0a9e('0x1e')]['limit']);_0x40e0f0[_0x0a9e('0x10')]=qs['offset'](_0x3325c5[_0x0a9e('0x1e')][_0x0a9e('0x10')]);}return _0x3a1974[_0x0a9e('0x77')](_0x40e0f0);}})[_0x0a9e('0x15')](function(_0x1b61d5){if(_0x1b61d5){return _0x1b61d5?{'count':_0x5a26c8,'rows':_0x1b61d5}:null;}})['then'](respondWithResult(_0x589ff3,null))[_0x0a9e('0x20')](handleError(_0x589ff3,null));};exports[_0x0a9e('0x84')]=function(_0x2791c5,_0x2aa5f2){if(_0x2791c5[_0x0a9e('0x32')]['id']){delete _0x2791c5['body']['id'];}return db['CmContact'][_0x0a9e('0x85')]({'where':{'id':_0x2791c5['params']['id']}})[_0x0a9e('0x15')](handleEntityNotFound(_0x2aa5f2,null))[_0x0a9e('0x15')](function(_0x4672e1){if(_0x4672e1){return _0x4672e1[_0x0a9e('0x84')](_0x2791c5[_0x0a9e('0x32')][_0x0a9e('0x86')]||[]);}return null;})['then'](respondWithResult(_0x2aa5f2,null))['catch'](handleError(_0x2aa5f2,null));};exports[_0x0a9e('0x87')]=function(_0x5dfbe2,_0x2469d1){var _0x5c689c=[];_0x5c689c[_0x0a9e('0x5e')](addAdditionalPhones(_0x5dfbe2['body']));Promise['all'](_0x5c689c)[_0x0a9e('0x15')](function(){_0x5c689c=[];_0x5c689c[_0x0a9e('0x5e')](deleteCmHopperPhones(_0x5dfbe2['body']['id']));_0x5c689c[_0x0a9e('0x5e')](addCmHopperPhones(_0x5dfbe2[_0x0a9e('0x32')]['id']));Promise[_0x0a9e('0x62')](_0x5c689c)[_0x0a9e('0x15')](function(){return[0x1];})[_0x0a9e('0x15')](respondWithResult(_0x2469d1,null));});};function addAdditionalPhones(_0x5ab0bc){var _0x5505f4;return new Promise(function(_0x16449b){return db[_0x0a9e('0x4a')][_0x0a9e('0x16')]({'where':{'CmContactId':_0x5ab0bc['id']}})[_0x0a9e('0x15')](function(){db[_0x0a9e('0x68')]['findAll']({'raw':!![],'attributes':['id',_0x0a9e('0x88')]})[_0x0a9e('0x15')](function(_0x5416a9){var _0x3c313d=[];for(var _0x19fd11=0x0;_0x19fd11<_0x5ab0bc[_0x0a9e('0x89')][_0x0a9e('0x2b')];_0x19fd11++){var _0x23b25b=_0x5ab0bc[_0x0a9e('0x8a')]?_[_0x0a9e('0x56')](_0x5ab0bc[_0x0a9e('0x8a')][_0x19fd11])?'':_0x5ab0bc[_0x0a9e('0x8a')][_0x19fd11]:_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11]['ItemTypeId']?_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11][_0x0a9e('0x8b')]:'';var _0x2ada60=_[_0x0a9e('0x56')](_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11]['description'])?'':_0x5ab0bc['items'][_0x19fd11][_0x0a9e('0x8c')];var _0x16ae1a=_0x23b25b+':'+_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11][_0x0a9e('0x76')]+'§'+_0x2ada60;if(_[_0x0a9e('0x56')](_0x5505f4))_0x5505f4=_0x16ae1a;else _0x5505f4+=';'+_0x16ae1a;var _0x59e46f=null;var _0x1339d0=null;if(_0x5ab0bc[_0x0a9e('0x8a')]){if(!_[_0x0a9e('0x56')](_0x5ab0bc['item_types'][_0x19fd11])){_0x1339d0=_[_0x0a9e('0x22')](_0x5416a9,function(_0x59aa7b){return _0x59aa7b['id']===_0x5ab0bc[_0x0a9e('0x8a')][_0x19fd11];});if(!_['isNil'](_0x1339d0)){_0x59e46f=_0x1339d0[_0x0a9e('0x88')];}}}else{if(!_[_0x0a9e('0x56')](_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11])){_0x1339d0=_['find'](_0x5416a9,function(_0xc9529d){return _0xc9529d['id']===_0x5ab0bc['items'][_0x19fd11][_0x0a9e('0x8b')];});if(!_[_0x0a9e('0x56')](_0x1339d0)){_0x59e46f=_0x19fd11;}}}if(_[_0x0a9e('0x56')](_0x59e46f)){_0x59e46f=0x64;}_0x3c313d[_0x0a9e('0x5e')](addAdditionalPhone(_0x5ab0bc['id'],_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11][_0x0a9e('0x76')],_0x5ab0bc[_0x0a9e('0x8a')]?_[_0x0a9e('0x56')](_0x5ab0bc[_0x0a9e('0x8a')][_0x19fd11])?null:_0x5ab0bc[_0x0a9e('0x8a')][_0x19fd11]:_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11][_0x0a9e('0x8b')]?_0x5ab0bc[_0x0a9e('0x89')][_0x19fd11][_0x0a9e('0x8b')]:null,_0x59e46f,_0x2ada60));}Promise[_0x0a9e('0x62')](_0x3c313d)[_0x0a9e('0x15')](function(){db['CmContact']['update']({'AdditionalPhones':_0x5505f4},{'where':{'id':_0x5ab0bc['id']}})[_0x0a9e('0x15')](function(){_0x16449b(0x1);});});});});});}function addAdditionalPhone(_0x5c4be0,_0x1d999b,_0x3428c9,_0x5d6b69,_0x1a3754){return db[_0x0a9e('0x4a')][_0x0a9e('0x22')]({'where':{'CmContactId':_0x5c4be0,'item':_0x1d999b}})[_0x0a9e('0x15')](function(_0x5585d5){if(_0x5585d5)logger[_0x0a9e('0x37')](_0x0a9e('0x8d'),_0x5585d5);else{db[_0x0a9e('0x4a')][_0x0a9e('0x3d')]({'CmContactId':_0x5c4be0,'item':_0x1d999b,'ItemTypeId':_0x3428c9,'OrderBy':_0x5d6b69,'ItemClass':'PHONE','description':_0x1a3754});}});}function deleteCmHopperPhones(_0x19e9ed){return new Promise(function(_0x1a0b08){return db[_0x0a9e('0x39')]['findAll']({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x19e9ed}})[_0x0a9e('0x15')](function(_0x270df8){db[_0x0a9e('0x8e')]['destroy']({'where':{'CmHopperId':{'$in':_[_0x0a9e('0x6d')](_0x270df8,'id')}}});})[_0x0a9e('0x15')](function(){_0x1a0b08(0x1);});});}function addCmHopperPhones(_0x1d9b57){return new Promise(function(_0x1a7f58){return db[_0x0a9e('0x39')]['findAll']({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x1d9b57}})[_0x0a9e('0x15')](function(_0x289e65){var _0x4795ae=[];_[_0x0a9e('0x6d')](_0x289e65,function(_0x1fcfe6){_0x4795ae[_0x0a9e('0x5e')](createCmHopperPhone(_0x1d9b57,_0x1fcfe6['id']));});Promise['all'](_0x4795ae)['then'](function(){_0x1a7f58(0x1);});});});}function createCmHopperPhone(_0x523d08,_0x1015aa){return new Promise(function(_0x4a70ce){db['CmContactHasItem'][_0x0a9e('0x1d')]({'raw':!![],'attributes':[_0x0a9e('0x8f'),_0x0a9e('0x88')],'where':{'CmContactId':_0x523d08,'ItemClass':'PHONE'},'include':[{'model':db[_0x0a9e('0x68')],'attributes':[_0x0a9e('0x88')],'as':_0x0a9e('0x69')}],'order':[_0x0a9e('0x88'),db[_0x0a9e('0x90')][_0x0a9e('0x6a')](_0x0a9e('0x91'))]})[_0x0a9e('0x15')](function(_0x3b5bda){var _0x5a1848=0x1;var _0x43c397=_['map'](_0x3b5bda,function(_0x138cf5){_0x138cf5[_0x0a9e('0x92')]=_0x1015aa;_0x138cf5[_0x0a9e('0x76')]=_0x138cf5[_0x0a9e('0x8f')];_0x138cf5[_0x0a9e('0x88')]=_0x5a1848;delete _0x138cf5[_0x0a9e('0x93')];_0x5a1848=_0x5a1848+0x1;return _0x138cf5;});return db['CmHopperAdditionalPhone'][_0x0a9e('0x5a')](_0x43c397,{});})[_0x0a9e('0x15')](function(){_0x4a70ce(0x1);});});}function insertAdditionalPhones(_0xe25eb5,_0x1af799){return new Promise(function(_0x51aa2f){var _0x2e4887=[];for(var _0x3c9135=0x0;_0x3c9135<_0x1af799[_0x0a9e('0x2b')];_0x3c9135++){var _0x1c9539=_0x1af799[_0x3c9135];_0x2e4887[_0x0a9e('0x5e')](parseContactItemType(_0x1c9539));}Promise[_0x0a9e('0x62')](_0x2e4887)[_0x0a9e('0x15')](function(){var _0x25931e={'id':_0xe25eb5['id'],'items':_0x1af799};return addAdditionalPhones(_0x25931e)[_0x0a9e('0x15')](function(){return addCmHopperPhones(_0xe25eb5['id']);});})[_0x0a9e('0x15')](function(){_0x51aa2f(_0xe25eb5);});});}function parseContactItemType(_0x57f0ad){return new Promise(function(_0x2272bc){if(_0x57f0ad[_0x0a9e('0x31')](_0x0a9e('0x8b'))){_0x2272bc(_0x57f0ad);}else{return db[_0x0a9e('0x68')][_0x0a9e('0x22')]({'where':{'name':_0x57f0ad[_0x0a9e('0x69')]}})[_0x0a9e('0x15')](function(_0x20ae21){if(_['isNil'](_0x20ae21))_0x57f0ad[_0x0a9e('0x8b')]=null;else _0x57f0ad[_0x0a9e('0x8b')]=_0x20ae21['id'];_0x2272bc(_0x57f0ad);});}});}exports[_0x0a9e('0x94')]=function(_0x5c65fc,_0x1402c7){return db[_0x0a9e('0x4a')][_0x0a9e('0x1d')]({'raw':!![],'where':{'CmContactId':_0x5c65fc[_0x0a9e('0x23')]['id'],'ItemClass':_0x0a9e('0x95')},'include':[{'model':db[_0x0a9e('0x68')],'as':_0x0a9e('0x69')}],'order':[[_0x0a9e('0x88')],[db[_0x0a9e('0x90')][_0x0a9e('0x6a')]('`ItemType`.OrderBy')]]})[_0x0a9e('0x15')](function(_0x446e6){return _0x446e6;})[_0x0a9e('0x15')](respondWithResult(_0x1402c7,null))[_0x0a9e('0x20')](handleError(_0x1402c7,null));};exports[_0x0a9e('0x96')]=function(_0x3942fd,_0x5cb48d){return db[_0x0a9e('0x4a')]['findAll']({'raw':!![],'where':{'CmContactId':_0x3942fd['body']['fromContactId']}})[_0x0a9e('0x15')](function(_0x3fa3f2){var _0x426cb4=_[_0x0a9e('0x6d')](_0x3fa3f2,function(_0x4d99a8){_0x4d99a8[_0x0a9e('0x97')]=_0x3942fd[_0x0a9e('0x32')][_0x0a9e('0x98')];return _0x4d99a8;});return db[_0x0a9e('0x4a')][_0x0a9e('0x5a')](_0x426cb4,{});})['then'](function(){return addCmHopperPhones(_0x3942fd['body'][_0x0a9e('0x98')]);})[_0x0a9e('0x15')](function(){return['ok'];})[_0x0a9e('0x15')](respondWithResult(_0x5cb48d,null))['catch'](handleError(_0x5cb48d,null));};exports[_0x0a9e('0x99')]=function(_0x248a9a,_0x422f0a){var _0x4cee8c=[];_0x4cee8c[_0x0a9e('0x5e')](createCmHopperPhone(_0x248a9a[_0x0a9e('0x32')]['id'],_0x248a9a[_0x0a9e('0x32')]['hopperId']));Promise[_0x0a9e('0x62')](_0x4cee8c)[_0x0a9e('0x15')](function(){return[0x1];})[_0x0a9e('0x15')](respondWithResult(_0x422f0a,null));};exports['getHoppers']=function(_0x549697,_0x53ef46){var _0x3b04fd={'raw':![],'where':{}};var _0x1f50db={};var _0xcbc73c={'count':0x0,'rows':[]};return db[_0x0a9e('0x21')]['findOne']({'where':{'id':_0x549697[_0x0a9e('0x23')]['id']}})['then'](handleEntityNotFound(_0x53ef46,null))[_0x0a9e('0x15')](function(_0x2ff2ab){if(_0x2ff2ab){_0x1f50db[_0x0a9e('0x78')]=_['keys'](db[_0x0a9e('0x39')][_0x0a9e('0x79')]);_0x1f50db[_0x0a9e('0x1e')]=_['keys'](_0x549697[_0x0a9e('0x1e')]);_0x1f50db['filters']=_[_0x0a9e('0x7b')](_0x1f50db['model'],_0x1f50db[_0x0a9e('0x1e')]);_0x3b04fd['attributes']=_[_0x0a9e('0x7b')](_0x1f50db[_0x0a9e('0x78')],qs[_0x0a9e('0x7d')](_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x7d')]));_0x3b04fd[_0x0a9e('0x7c')]=_0x3b04fd[_0x0a9e('0x7c')]['length']?_0x3b04fd[_0x0a9e('0x7c')]:_0x1f50db[_0x0a9e('0x78')];if(!_0x549697['query'][_0x0a9e('0x31')](_0x0a9e('0x83'))){_0x3b04fd['limit']=qs[_0x0a9e('0x12')](_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x12')]);_0x3b04fd['offset']=qs[_0x0a9e('0x10')](_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x10')]);}_0x3b04fd[_0x0a9e('0x7e')]=qs[_0x0a9e('0x7f')](_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x7f')]);_0x3b04fd[_0x0a9e('0x5c')]=qs[_0x0a9e('0x7a')](_[_0x0a9e('0x80')](_0x549697['query'],_0x1f50db[_0x0a9e('0x7a')]));_0x3b04fd['where'][_0x0a9e('0x9a')]=_0x2ff2ab['id'];if(_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x81')]){_0x3b04fd[_0x0a9e('0x5c')]=_[_0x0a9e('0x82')](_0x3b04fd[_0x0a9e('0x5c')],{'$or':_['map'](_0x3b04fd[_0x0a9e('0x7c')],function(_0x469035){var _0x2977a7={};_0x2977a7[_0x469035]={'$like':'%'+_0x549697['query'][_0x0a9e('0x81')]+'%'};return _0x2977a7;})});}_0x3b04fd=_[_0x0a9e('0x82')]({},_0x3b04fd,_0x549697[_0x0a9e('0x9b')]);return db[_0x0a9e('0x39')][_0x0a9e('0x13')]({'where':_0x3b04fd[_0x0a9e('0x5c')]})[_0x0a9e('0x15')](function(_0x5f2c51){_0xcbc73c[_0x0a9e('0x13')]=_0x5f2c51;if(_0x549697[_0x0a9e('0x1e')][_0x0a9e('0x9c')]){_0x3b04fd[_0x0a9e('0x9d')]=[{'all':!![]}];}return db[_0x0a9e('0x39')][_0x0a9e('0x1d')](_0x3b04fd);})[_0x0a9e('0x15')](function(_0x5d6a48){_0xcbc73c['rows']=_0x5d6a48;return _0xcbc73c;});}})[_0x0a9e('0x15')](respondWithFilteredResult(_0x53ef46,_0x3b04fd))[_0x0a9e('0x20')](handleError(_0x53ef46,null));};exports[_0x0a9e('0x9e')]=function(_0x1bf692,_0x40e2da){var _0x131da8={'raw':!![],'where':{}};var _0x609711={};var _0x584854={'count':0x0,'rows':[]};return db[_0x0a9e('0x21')][_0x0a9e('0x85')]({'where':{'id':_0x1bf692[_0x0a9e('0x23')]['id']}})[_0x0a9e('0x15')](handleEntityNotFound(_0x40e2da,null))[_0x0a9e('0x15')](function(_0x3c6082){if(_0x3c6082){_0x609711[_0x0a9e('0x78')]=_['keys'](db[_0x0a9e('0x9f')][_0x0a9e('0x79')]);_0x609711[_0x0a9e('0x1e')]=_['keys'](_0x1bf692[_0x0a9e('0x1e')]);_0x609711[_0x0a9e('0x7a')]=_[_0x0a9e('0x7b')](_0x609711[_0x0a9e('0x78')],_0x609711['query']);_0x131da8[_0x0a9e('0x7c')]=_[_0x0a9e('0x7b')](_0x609711[_0x0a9e('0x78')],qs[_0x0a9e('0x7d')](_0x1bf692[_0x0a9e('0x1e')][_0x0a9e('0x7d')]));_0x131da8[_0x0a9e('0x7c')]=_0x131da8[_0x0a9e('0x7c')]['length']?_0x131da8[_0x0a9e('0x7c')]:_0x609711[_0x0a9e('0x78')];if(!_0x1bf692[_0x0a9e('0x1e')][_0x0a9e('0x31')]('nolimit')){_0x131da8['limit']=qs[_0x0a9e('0x12')](_0x1bf692[_0x0a9e('0x1e')][_0x0a9e('0x12')]);_0x131da8['offset']=qs[_0x0a9e('0x10')](_0x1bf692[_0x0a9e('0x1e')]['offset']);}_0x131da8[_0x0a9e('0x7e')]=qs['sort'](_0x1bf692[_0x0a9e('0x1e')]['sort']);_0x131da8['where']=qs['filters'](_[_0x0a9e('0x80')](_0x1bf692[_0x0a9e('0x1e')],_0x609711[_0x0a9e('0x7a')]));_0x131da8[_0x0a9e('0x5c')][_0x0a9e('0x9a')]=_0x3c6082['id'];if(_0x1bf692[_0x0a9e('0x1e')]['filter']){_0x131da8[_0x0a9e('0x5c')]=_[_0x0a9e('0x82')](_0x131da8[_0x0a9e('0x5c')],{'$or':_[_0x0a9e('0x6d')](_0x131da8[_0x0a9e('0x7c')],function(_0x18dccf){var _0x31c937={};_0x31c937[_0x18dccf]={'$like':'%'+_0x1bf692['query']['filter']+'%'};return _0x31c937;})});}_0x131da8=_[_0x0a9e('0x82')]({},_0x131da8,_0x1bf692['options']);return db[_0x0a9e('0x9f')][_0x0a9e('0x13')]({'where':_0x131da8[_0x0a9e('0x5c')]})[_0x0a9e('0x15')](function(_0x37a448){_0x584854[_0x0a9e('0x13')]=_0x37a448;if(_0x1bf692['query'][_0x0a9e('0x9c')]){_0x131da8['include']=[{'all':!![]}];}return db['CmHopperHistory'][_0x0a9e('0x1d')](_0x131da8);})['then'](function(_0x38dceb){_0x584854['rows']=_0x38dceb;return _0x584854;});}})['then'](respondWithFilteredResult(_0x40e2da,_0x131da8))[_0x0a9e('0x20')](handleError(_0x40e2da,null));};exports['getHopperFinals']=function(_0x24470a,_0x142e53){var _0xe1ab0d={'raw':!![],'where':{}};var _0x48f532={};var _0x4152cd={'count':0x0,'rows':[]};return db[_0x0a9e('0x21')][_0x0a9e('0x85')]({'where':{'id':_0x24470a['params']['id']}})['then'](handleEntityNotFound(_0x142e53,null))[_0x0a9e('0x15')](function(_0x948aab){if(_0x948aab){_0x48f532[_0x0a9e('0x78')]=_[_0x0a9e('0x25')](db[_0x0a9e('0x4b')][_0x0a9e('0x79')]);_0x48f532[_0x0a9e('0x1e')]=_[_0x0a9e('0x25')](_0x24470a[_0x0a9e('0x1e')]);_0x48f532[_0x0a9e('0x7a')]=_['intersection'](_0x48f532['model'],_0x48f532['query']);_0xe1ab0d[_0x0a9e('0x7c')]=_[_0x0a9e('0x7b')](_0x48f532[_0x0a9e('0x78')],qs[_0x0a9e('0x7d')](_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x7d')]));_0xe1ab0d[_0x0a9e('0x7c')]=_0xe1ab0d[_0x0a9e('0x7c')]['length']?_0xe1ab0d['attributes']:_0x48f532[_0x0a9e('0x78')];if(!_0x24470a[_0x0a9e('0x1e')]['hasOwnProperty'](_0x0a9e('0x83'))){_0xe1ab0d[_0x0a9e('0x12')]=qs[_0x0a9e('0x12')](_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x12')]);_0xe1ab0d[_0x0a9e('0x10')]=qs[_0x0a9e('0x10')](_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x10')]);}_0xe1ab0d[_0x0a9e('0x7e')]=qs[_0x0a9e('0x7f')](_0x24470a[_0x0a9e('0x1e')]['sort']);_0xe1ab0d[_0x0a9e('0x5c')]=qs[_0x0a9e('0x7a')](_[_0x0a9e('0x80')](_0x24470a[_0x0a9e('0x1e')],_0x48f532[_0x0a9e('0x7a')]));_0xe1ab0d[_0x0a9e('0x5c')][_0x0a9e('0x9a')]=_0x948aab['id'];if(_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x81')]){_0xe1ab0d[_0x0a9e('0x5c')]=_[_0x0a9e('0x82')](_0xe1ab0d[_0x0a9e('0x5c')],{'$or':_['map'](_0xe1ab0d['attributes'],function(_0x3e5182){var _0x401207={};_0x401207[_0x3e5182]={'$like':'%'+_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x81')]+'%'};return _0x401207;})});}_0xe1ab0d=_[_0x0a9e('0x82')]({},_0xe1ab0d,_0x24470a[_0x0a9e('0x9b')]);return db[_0x0a9e('0x4b')]['count']({'where':_0xe1ab0d[_0x0a9e('0x5c')]})['then'](function(_0x26aa44){_0x4152cd[_0x0a9e('0x13')]=_0x26aa44;if(_0x24470a[_0x0a9e('0x1e')][_0x0a9e('0x9c')]){_0xe1ab0d[_0x0a9e('0x9d')]=[{'all':!![]}];}return db[_0x0a9e('0x4b')][_0x0a9e('0x1d')](_0xe1ab0d);})[_0x0a9e('0x15')](function(_0xa7a754){_0x4152cd[_0x0a9e('0xa0')]=_0xa7a754;return _0x4152cd;});}})[_0x0a9e('0x15')](respondWithFilteredResult(_0x142e53,_0xe1ab0d))[_0x0a9e('0x20')](handleError(_0x142e53,null));};exports[_0x0a9e('0xa1')]=function(_0x3f7cb6,_0x3c8a9a){var _0x2d5e00={'raw':!![],'where':{}};var _0x5b78a8={};var _0x54cf62={'count':0x0,'rows':[]};return db[_0x0a9e('0x21')][_0x0a9e('0x85')]({'where':{'id':_0x3f7cb6['params']['id']}})['then'](handleEntityNotFound(_0x3c8a9a,null))[_0x0a9e('0x15')](function(_0x1feb9){if(_0x1feb9){_0x5b78a8[_0x0a9e('0x78')]=_['keys'](db[_0x0a9e('0xa2')]['rawAttributes']);_0x5b78a8[_0x0a9e('0x1e')]=_['keys'](_0x3f7cb6[_0x0a9e('0x1e')]);_0x5b78a8['filters']=_[_0x0a9e('0x7b')](_0x5b78a8[_0x0a9e('0x78')],_0x5b78a8[_0x0a9e('0x1e')]);_0x2d5e00['attributes']=_[_0x0a9e('0x7b')](_0x5b78a8['model'],qs['fields'](_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x7d')]));_0x2d5e00[_0x0a9e('0x7c')]=_0x2d5e00[_0x0a9e('0x7c')][_0x0a9e('0x2b')]?_0x2d5e00[_0x0a9e('0x7c')]:_0x5b78a8[_0x0a9e('0x78')];if(!_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x31')](_0x0a9e('0x83'))){_0x2d5e00[_0x0a9e('0x12')]=qs[_0x0a9e('0x12')](_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x12')]);_0x2d5e00[_0x0a9e('0x10')]=qs[_0x0a9e('0x10')](_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x10')]);}_0x2d5e00[_0x0a9e('0x7e')]=qs['sort'](_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x7f')]);_0x2d5e00[_0x0a9e('0x5c')]=qs[_0x0a9e('0x7a')](_['pick'](_0x3f7cb6['query'],_0x5b78a8['filters']));_0x2d5e00[_0x0a9e('0x5c')]['ContactId']=_0x1feb9['id'];if(_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x81')]){_0x2d5e00[_0x0a9e('0x5c')]=_[_0x0a9e('0x82')](_0x2d5e00[_0x0a9e('0x5c')],{'$or':_[_0x0a9e('0x6d')](_0x2d5e00[_0x0a9e('0x7c')],function(_0x1cc73e){var _0x2154d8={};_0x2154d8[_0x1cc73e]={'$like':'%'+_0x3f7cb6[_0x0a9e('0x1e')]['filter']+'%'};return _0x2154d8;})});}_0x2d5e00=_[_0x0a9e('0x82')]({},_0x2d5e00,_0x3f7cb6['options']);return db[_0x0a9e('0xa2')]['count']({'where':_0x2d5e00[_0x0a9e('0x5c')]})[_0x0a9e('0x15')](function(_0x216791){_0x54cf62['count']=_0x216791;if(_0x3f7cb6[_0x0a9e('0x1e')][_0x0a9e('0x9c')]){_0x2d5e00['include']=[{'all':!![]}];}return db['JscriptySessionReport'][_0x0a9e('0x1d')](_0x2d5e00);})[_0x0a9e('0x15')](function(_0x1262ff){_0x54cf62['rows']=_0x1262ff;return _0x54cf62;});}})['then'](respondWithFilteredResult(_0x3c8a9a,_0x2d5e00))['catch'](handleError(_0x3c8a9a,null));};exports[_0x0a9e('0xa3')]=function(_0x22c591,_0x2b7ba9){try{if(!_0x22c591[_0x0a9e('0x32')][_0x0a9e('0x5f')]){throw new Error(_0x0a9e('0xa4'));}if(!_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa5')]){throw new Error(_0x0a9e('0xa6'));}if(!_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa7')]){throw new Error(_0x0a9e('0xa8'));}if(!_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa9')]){throw new Error(_0x0a9e('0xaa'));}var _0x1a74c4=_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa5')]['split'](',');var _0xb33e27=_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa7')][_0x0a9e('0xab')](',');if(!_0x1a74c4[_0x0a9e('0x2b')]||!_0xb33e27[_0x0a9e('0x2b')]||_0x1a74c4['length']!==_0xb33e27[_0x0a9e('0x2b')]){throw new Error(_0x0a9e('0xac'));}_0x22c591[_0x0a9e('0x32')][_0x0a9e('0x7d')]=_[_0x0a9e('0xad')](_0x1a74c4,_0xb33e27);if(!_0x22c591[_0x0a9e('0x32')][_0x0a9e('0x7d')][_0x0a9e('0x76')]){throw new Error(_0x0a9e('0xae'));}if(!_0x22c591['body']['fields'][_0x0a9e('0xaf')]){throw new Error(_0x0a9e('0xb0'));}var _0x5c2996=path[_0x0a9e('0x36')](config[_0x0a9e('0xb1')],'server/files/tmp',_0x22c591[_0x0a9e('0xb2')]['filename']);fs[_0x0a9e('0xb3')](_0x5c2996,parseInt(_0x0a9e('0xb4'),0x8));var _0x58c53c=require(_0x0a9e('0xb5'))[_0x0a9e('0xb6')](path['join'](__dirname,_0x0a9e('0xb7')),[_0x5c2996,_0x22c591[_0x0a9e('0x32')]['binding_keys'],_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xa7')],_0x22c591[_0x0a9e('0x32')][_0x0a9e('0x5f')],_0x22c591[_0x0a9e('0x32')][_0x0a9e('0xb8')],_0x22c591['body'][_0x0a9e('0x5b')],_0x22c591[_0x0a9e('0x32')]['socket_timestamp']]);return _0x2b7ba9[_0x0a9e('0xf')](0xc8)[_0x0a9e('0xb9')]({'message':_0x0a9e('0xba'),'pid':_0x58c53c[_0x0a9e('0xbb')]});}catch(_0x3fae71){return _0x2b7ba9[_0x0a9e('0xf')](0x1f4)[_0x0a9e('0xbc')](_0x3fae71);}};exports['upload']=function(_0x49e1b8,_0x5a2013){var _0x55d764=fs['createReadStream'](_0x49e1b8[_0x0a9e('0xb2')][_0x0a9e('0xbd')]);Papa['parse'](_0x55d764,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x5c23aa){return _0x5a2013[_0x0a9e('0xf')](0xc8)['json']({'file':_0x49e1b8[_0x0a9e('0xb2')],'fields':_0x5c23aa[_0x0a9e('0xbe')][_0x0a9e('0x7d')]});}});};exports[_0x0a9e('0xbf')]=function(_0x336518,_0x14a683){return db['User'][_0x0a9e('0x1d')]({'raw':!![],'attributes':['id'],'where':{'role':_0x0a9e('0xc0')}})['then'](function(_0x44cdb8){var _0x1c0d54=![];if(!_0x336518[_0x0a9e('0x32')][_0x0a9e('0x5f')]){throw new Error(_0x0a9e('0xa4'));}if(!_0x336518[_0x0a9e('0x32')][_0x0a9e('0xc1')]['phone']){throw new Error(_0x0a9e('0xae'));}if(!_0x336518['body'][_0x0a9e('0xc1')][_0x0a9e('0xaf')]){throw new Error('No\x20firstName\x20column\x20specified');}if(!_0x336518[_0x0a9e('0x32')][_0x0a9e('0xa9')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x78a398=require('child_process')[_0x0a9e('0xb6')](path[_0x0a9e('0x36')](__dirname,'../../components/import/cm/csv2'),[_0x336518[_0x0a9e('0x23')]['id'],JSON['stringify'](_0x336518[_0x0a9e('0x32')]),JSON[_0x0a9e('0xc2')](_0x44cdb8)]);_0x78a398['on'](_0x0a9e('0xc3'),function(){_0x1c0d54=!![];return _0x14a683[_0x0a9e('0xf')](0xc8)[_0x0a9e('0xb9')]({'message':_0x0a9e('0xc4'),'pid':_0x78a398[_0x0a9e('0xbb')]});});_0x78a398['on']('exit',function(_0x36318d){if(_0x36318d&&!_0x1c0d54){return _0x14a683[_0x0a9e('0xf')](0x1f4)[_0x0a9e('0xb9')]({'message':_0x0a9e('0xc5'),'pid':_0x78a398[_0x0a9e('0xbb')]});}});})['catch'](handleError(_0x14a683,null));};exports[_0x0a9e('0xc6')]=function(_0x49a6b2,_0x5d1159){return db[_0x0a9e('0xc7')]['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0x0a9e('0xc0')}})[_0x0a9e('0x15')](function(_0x58d5fd){var _0x171a69=![];if(!_0x49a6b2[_0x0a9e('0x32')][_0x0a9e('0x5f')]){throw new Error(_0x0a9e('0xa4'));}if(!_0x49a6b2[_0x0a9e('0x32')][_0x0a9e('0xc1')][_0x0a9e('0x76')]){throw new Error(_0x0a9e('0xae'));}if(!_0x49a6b2[_0x0a9e('0x32')]['binding'][_0x0a9e('0xaf')]){throw new Error(_0x0a9e('0xb0'));}if(!_0x49a6b2[_0x0a9e('0x32')][_0x0a9e('0xa9')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x38d95a=require(_0x0a9e('0xb5'))[_0x0a9e('0xb6')](path['join'](__dirname,_0x0a9e('0xc8')),[_0x49a6b2[_0x0a9e('0x23')]['id'],JSON[_0x0a9e('0xc2')](_0x49a6b2['body']),JSON[_0x0a9e('0xc2')](_0x58d5fd)]);_0x38d95a['on']('message',function(){_0x171a69=!![];return _0x5d1159[_0x0a9e('0xf')](0xc8)[_0x0a9e('0xb9')]({'message':_0x0a9e('0xc4'),'pid':_0x38d95a[_0x0a9e('0xbb')]});});_0x38d95a['on'](_0x0a9e('0xc9'),function(_0x1b86e6){if(_0x1b86e6&&!_0x171a69){return _0x5d1159[_0x0a9e('0xf')](0x1f4)['json']({'message':_0x0a9e('0xc5'),'pid':_0x38d95a[_0x0a9e('0xbb')]});}});})[_0x0a9e('0x20')](handleError(_0x5d1159,null));};exports[_0x0a9e('0xca')]=function(_0x1eb768,_0x117694){var _0x3a4def=[_0x0a9e('0xcb'),_0x0a9e('0xcc'),_0x0a9e('0xcd'),_0x0a9e('0xce'),_0x0a9e('0xcf'),_0x0a9e('0xd0'),_0x0a9e('0xd1')];var _0xdce963={'offset':0x0,'order':qs[_0x0a9e('0x7f')](_0x0a9e('0xd2'))},_0xfc4f={'count':0x0,'rows':[]};Promise[_0x0a9e('0xd3')]()[_0x0a9e('0x15')](function(){if(_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0xd4')]){if(!_[_0x0a9e('0xd5')](_0x3a4def,_0x1eb768['query'][_0x0a9e('0xd4')][_0x0a9e('0xd6')]())){throw new Error(_0x0a9e('0xd7'));}_0x3a4def=[_0x1eb768['query'][_0x0a9e('0xd4')]['toLowerCase']()];}if(_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0xd8')]){try{var _0x20a292=JSON[_0x0a9e('0xd9')](_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0xd8')]);if(!moment(_0x20a292[_0x0a9e('0x33')])[_0x0a9e('0xda')]()){throw new Error('Invalid\x20date\x20for\x20range\x20from\x20filter');}if(!moment(_0x20a292['to'])[_0x0a9e('0xda')]()){throw new Error(_0x0a9e('0xdb'));}}catch(_0x4d6f2d){throw new Error(_0x0a9e('0xdc'));}}if(!_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0x31')]('nolimit')){_0xdce963[_0x0a9e('0x12')]=qs[_0x0a9e('0x12')](_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0x12')]||0xa);_0xdce963['offset']=qs[_0x0a9e('0x10')](_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0x10')]);}var _0x2b8eed=_0x3a4def[_0x0a9e('0x6d')](function(_0x4ea917){if(_0x4ea917===_0x0a9e('0xd1')){var _0x3fc431={'attributes':['id','uniqueid',_0x0a9e('0x2e'),_0x0a9e('0xdd'),_0x0a9e('0xde'),'callerid','starttime',_0x0a9e('0xdf'),_0x0a9e('0xe0'),_0x0a9e('0xe1'),_0x0a9e('0xe2'),_0x0a9e('0xe3'),_0x0a9e('0xe4'),_0x0a9e('0xe5'),_0x0a9e('0xe6')],'where':{'ContactId':_0x1eb768['params']['id']},'include':[{'model':db['User'],'as':_0x0a9e('0xc7'),'attributes':['id','name',_0x0a9e('0xe7'),_0x0a9e('0xe8')]}],'order':[[_0x0a9e('0xe2'),_0x0a9e('0xe9')]]};if(_0x1eb768['query'][_0x0a9e('0xd8')]){_0x3fc431[_0x0a9e('0x5c')]['createdAt']={'$gte':_0x20a292[_0x0a9e('0x33')],'$lte':_0x20a292['to']};}return db['VoiceCallReport'][_0x0a9e('0xea')](_0x3fc431)[_0x0a9e('0x15')](function(_0xd63c87){_0xfc4f[_0x0a9e('0x13')]+=_0xd63c87[_0x0a9e('0x13')];return _[_0x0a9e('0x6d')](_0xd63c87['rows'],function(_0x16d50b){var _0x580dd2=_0x16d50b[_0x0a9e('0x34')]({'plain':!![]});_0x580dd2[_0x0a9e('0xd4')]=_0x4ea917;if(_0x580dd2[_0x0a9e('0xc7')]){_0x580dd2[_0x0a9e('0xc7')]={'id':_0x580dd2[_0x0a9e('0xc7')]['id'],'name':_0x580dd2[_0x0a9e('0xc7')][_0x0a9e('0x1a')],'fullname':_0x580dd2['User'][_0x0a9e('0xe7')],'alias':_0x580dd2[_0x0a9e('0xc7')][_0x0a9e('0xe8')]};}return _0x580dd2;});});}else{var _0x188231=_[_0x0a9e('0xeb')](_0x4ea917)+(_0x4ea917==='chat'?_0x0a9e('0xec'):_0x0a9e('0xed'));var _0x488d6c={'attributes':['id','closed',_0x0a9e('0xee'),_0x0a9e('0xe2'),_0x0a9e('0xe1'),_0x0a9e('0xef'),_0x0a9e('0xf0'),_0x0a9e('0xf1'),'UserId',_0x188231+'Id'],'where':{'ContactId':_0x1eb768[_0x0a9e('0x23')]['id']},'include':[{'model':db[_0x188231],'as':_0x0a9e('0xed'),'attributes':['id',_0x0a9e('0x1a'),'key']},{'model':db[_0x0a9e('0xc7')],'as':_0x0a9e('0xf2'),'attributes':['id',_0x0a9e('0x1a'),_0x0a9e('0xe7')]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0x0a9e('0x1a'),_0x0a9e('0x65')],'through':{'attributes':[]}}],'order':[[_0x0a9e('0xe2'),_0x0a9e('0xe9')]]};if(_0x1eb768[_0x0a9e('0x1e')][_0x0a9e('0xd8')]){_0x488d6c[_0x0a9e('0x5c')][_0x0a9e('0xe2')]={'$gte':_0x20a292['from'],'$lte':_0x20a292['to']};}switch(_0x4ea917){case _0x0a9e('0xcc'):_0x488d6c['attributes'][_0x0a9e('0x5e')](_0x0a9e('0xf3'),_0x0a9e('0xf4'),'customerPort','deviceModel',_0x0a9e('0xf5'),'ratingMessage',_0x0a9e('0xf6'),'ratingValue','referer');break;case _0x0a9e('0xcb'):_0x488d6c[_0x0a9e('0x7c')][_0x0a9e('0x5e')](_0x0a9e('0xf7'),_0x0a9e('0xf8'));break;case _0x0a9e('0xce'):_0x488d6c[_0x0a9e('0x7c')][_0x0a9e('0x5e')](_0x0a9e('0xf9'),_0x0a9e('0xfa'));break;}return db[_[_0x0a9e('0xeb')](_0x4ea917)+_0x0a9e('0xfb')][_0x0a9e('0xea')](_0x488d6c)['then'](function(_0x58f251){_0xfc4f[_0x0a9e('0x13')]+=_0x58f251['count'];return _[_0x0a9e('0x6d')](_0x58f251[_0x0a9e('0xa0')],function(_0x27be90){var _0x54befc=_0x27be90['get']({'plain':!![]});_0x54befc[_0x0a9e('0xd4')]=_0x4ea917;if(_0x54befc[_0x0a9e('0xf2')]){_0x54befc[_0x0a9e('0xf2')]={'id':_0x54befc[_0x0a9e('0xf2')]['id'],'name':_0x54befc[_0x0a9e('0xf2')][_0x0a9e('0x1a')],'fullname':_0x54befc[_0x0a9e('0xf2')]['fullname']};}return _0x54befc;});});}});return Promise[_0x0a9e('0x62')](_0x2b8eed);})['then'](function(_0x46b11b){return _(_0x46b11b)[_0x0a9e('0xfc')]()['sortBy'](_0x0a9e('0xe2'))[_0x0a9e('0xfd')]()[_0x0a9e('0xfe')]();})[_0x0a9e('0x15')](function(_0xb0fb60){_0xfc4f[_0x0a9e('0xa0')]=_0xdce963['limit']?_0xb0fb60[_0x0a9e('0xff')](_0xdce963[_0x0a9e('0x10')],_0xdce963[_0x0a9e('0x10')]+_0xdce963['limit']):_0xb0fb60;return _0xfc4f;})[_0x0a9e('0x15')](respondWithFilteredResult(_0x117694,_0xdce963))[_0x0a9e('0x20')](handleError(_0x117694,null));}; \ No newline at end of file diff --git a/server/api/cmContact/cmContact.events.js b/server/api/cmContact/cmContact.events.js new file mode 100644 index 0000000..91899e0 --- /dev/null +++ b/server/api/cmContact/cmContact.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb72c=['update','remove','emit','hasOwnProperty','hook','exports','../../mysqldb','setMaxListeners','save'];(function(_0x4c12ec,_0x2e9103){var _0x3ae42c=function(_0x5a728f){while(--_0x5a728f){_0x4c12ec['push'](_0x4c12ec['shift']());}};_0x3ae42c(++_0x2e9103);}(_0xb72c,0x7b));var _0xcb72=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xb72c[_0x3dd15e];return _0x231fd0;};'use strict';var EventEmitter=require('events');var CmContact=require(_0xcb72('0x0'))['db']['CmContact'];var CmContactEvents=new EventEmitter();CmContactEvents[_0xcb72('0x1')](0x0);var events={'afterCreate':_0xcb72('0x2'),'afterUpdate':_0xcb72('0x3'),'afterDestroy':_0xcb72('0x4')};function emitEvent(_0x3ae533){return function(_0x2afe3a,_0x3abde2,_0xfa3487){CmContactEvents['emit'](_0x3ae533+':'+_0x2afe3a['id'],_0x2afe3a);CmContactEvents[_0xcb72('0x5')](_0x3ae533,_0x2afe3a);_0xfa3487(null);};}for(var e in events){if(events[_0xcb72('0x6')](e)){var event=events[e];CmContact[_0xcb72('0x7')](e,emitEvent(event));}}module[_0xcb72('0x8')]=CmContactEvents; \ No newline at end of file diff --git a/server/api/cmContact/cmContact.model.js b/server/api/cmContact/cmContact.model.js new file mode 100644 index 0000000..a9b2267 --- /dev/null +++ b/server/api/cmContact/cmContact.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa55a=['YYYY-MM-DD\x20HH:mm:ss','isNil','findOne','then','dialTimezone','timezones','utcOffset','add','minutes','format','ret','cmContact,\x20afterCreate\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','CmHopper','create','ListId','priority','callbackUniqueid','catch','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20VoiceQueue\x20','CmHopperFinal','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20VoiceQueue\x20','error','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20onlyIfOpen,\x20exist\x20in\x20hopper\x20Campaign\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopper\x20Campaign\x20','cmContact,\x20afterCreate,\x20','\x20contact\x20not\x20insert\x20in\x20hopper,\x20check\x20duplicate\x20always,\x20exist\x20in\x20hopperFinal\x20Campaign\x20','VoiceQueue','outbound','dialCheckDuplicateType','CmList','Lists','length','get','onlyIfOpen','BlackLists','CmHopperBlack','cmContact,\x20%s,\x20%s','afterCreate','message','Campaign','findAll','always','List\x20not\x20found','isEmpty','ContactId','VoiceQueueId','push','all','[CmContact][afterDestroy][Succesfull]','lodash','util','../../config/logger','api','moment','path','rimraf','../../config/environment','../../config/environment/shared','define','CmContact','cm_contacts','phone','firstName','lastName','fax','FULLTEXT','utf8mb4','models','cmContact','inspect','scheduledat'];(function(_0x3f4dd9,_0xe0b819){var _0x31c54a=function(_0x25e6c6){while(--_0x25e6c6){_0x3f4dd9['push'](_0x3f4dd9['shift']());}};_0x31c54a(++_0xe0b819);}(_0xa55a,0x7a));var _0xaa55=function(_0x1d8499,_0x20642f){_0x1d8499=_0x1d8499-0x0;var _0x17abc7=_0xa55a[_0x1d8499];return _0x17abc7;};'use strict';var _=require(_0xaa55('0x0'));var util=require(_0xaa55('0x1'));var logger=require(_0xaa55('0x2'))(_0xaa55('0x3'));var moment=require(_0xaa55('0x4'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0xaa55('0x5'));var rimraf=require(_0xaa55('0x6'));var config=require(_0xaa55('0x7'));var shared=require(_0xaa55('0x8'));var attributes=require('./cmContact.attributes');module['exports']=function(_0x220faa,_0x45bcbb){return _0x220faa[_0xaa55('0x9')](_0xaa55('0xa'),attributes,{'tableName':_0xaa55('0xb'),'paranoid':!![],'indexes':[{'name':'phone','fields':[_0xaa55('0xc')]},{'name':'fti_cm_contacts','fields':[_0xaa55('0xd'),_0xaa55('0xe'),_0xaa55('0xc'),'mobile',_0xaa55('0xf'),'email'],'type':_0xaa55('0x10')}],'timestamps':!![],'charset':_0xaa55('0x11'),'collate':'utf8mb4_unicode_ci','hooks':{'afterCreate':function(_0x559618,_0x5cc1bb,_0x167eaf){var _0x570d76=_0x220faa[_0xaa55('0x12')];var _0x3027d6=_0x559618['get']({'plain':!![]});function _0x437b11(){return function(_0x1b02e9){logger['error'](_0xaa55('0x13'),'afterCreate',util[_0xaa55('0x14')](_0x1b02e9,{'showHidden':![],'depth':null}));};}function _0xfece9a(_0x630e71,_0x15081d){var _0x124b52=_0x15081d[_0xaa55('0x15')]?_0x15081d['scheduledat']:moment()['format'](_0xaa55('0x16'));return new BPromise(function(_0x5691a2,_0x491404){if(_[_0xaa55('0x17')](_0x15081d['dialTimezone'])){_0x5691a2({'ret':_0x124b52});}else{_0x570d76['VoiceQueue'][_0xaa55('0x18')]({'where':{'id':_0x630e71['id']}})[_0xaa55('0x19')](function(_0xd09430){if(!_[_0xaa55('0x17')](_0xd09430)){var _0x5e85f6=_0xd09430[_0xaa55('0x1a')];if(!_['isNil'](_0x5e85f6)){var _0x5e0cbb=shared[_0xaa55('0x1b')];var _0x3389e4=_0x5e0cbb[_0x5e85f6];var _0x3c937b=_0x5e0cbb[_0x15081d[_0xaa55('0x1a')]];if(!_['isNil'](_0x3389e4)&&!_[_0xaa55('0x17')](_0x3c937b)){var _0x120387=_0x3389e4[_0xaa55('0x1c')]-_0x3c937b[_0xaa55('0x1c')];_0x124b52=_0x15081d['scheduledat']?_0x15081d[_0xaa55('0x15')]:moment();var _0x4e0198=moment(_0x124b52)[_0xaa55('0x1d')](_0x120387,_0xaa55('0x1e'));_0x5691a2({'ret':_0x4e0198[_0xaa55('0x1f')](_0xaa55('0x16'))});}else _0x5691a2({'ret':_0x124b52});}else _0x5691a2({'ret':_0x124b52});}else{_0x5691a2({'ret':_0x124b52});}});}});return 0xa;}var _0x238f73=function(_0xa12a3a){return new BPromise(function(_0x46402f,_0x3d4128){_0xfece9a(_0xa12a3a,_0x3027d6)[_0xaa55('0x19')](function(_0x2eeda9){_0x3027d6['scheduledat']=_0x2eeda9[_0xaa55('0x20')];_0x570d76['CmHopper'][_0xaa55('0x18')]({'where':{'phone':_0x3027d6[_0xaa55('0xc')],'VoiceQueueId':_0xa12a3a['id']}})['then'](function(_0x183265){if(!_[_0xaa55('0x17')](_0x183265)){throw new Error(_0xaa55('0x21')+_0x3027d6['phone']+_0xaa55('0x22')+_0xa12a3a['id']);}return _0x570d76[_0xaa55('0x23')][_0xaa55('0x24')]({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6[_0xaa55('0x26')]:0x2,'scheduledat':_0x3027d6[_0xaa55('0x15')]?_0x3027d6['scheduledat']:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'callback':_0x3027d6['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x3027d6[_0xaa55('0x27')]?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6['callbackUniqueid']?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'VoiceQueueId':_0xa12a3a['id']});})[_0xaa55('0x28')](function(_0x38ce3c){_0x3d4128(_0x38ce3c);});});});};var _0x29a423=function(_0x48f5e6){return new BPromise(function(_0x5a49c1,_0x546b16){_0xfece9a(_0x48f5e6,_0x3027d6)[_0xaa55('0x19')](function(_0x184bd7){_0x3027d6[_0xaa55('0x15')]=_0x184bd7[_0xaa55('0x20')];_0x570d76[_0xaa55('0x23')][_0xaa55('0x18')]({'where':{'phone':_0x3027d6['phone'],'VoiceQueueId':_0x48f5e6['id']}})[_0xaa55('0x19')](function(_0x25a923){if(!_[_0xaa55('0x17')](_0x25a923)){throw new Error('cmContact,\x20afterCreate\x20'+_0x3027d6[_0xaa55('0xc')]+_0xaa55('0x29')+_0x48f5e6['id']);}return _0x570d76[_0xaa55('0x2a')]['findOne']({'where':{'calleridnum':_0x3027d6[_0xaa55('0xc')],'VoiceQueueId':_0x48f5e6['id']}});})[_0xaa55('0x19')](function(_0x2298cb){if(!_[_0xaa55('0x17')](_0x2298cb)){throw new Error('cmContact,\x20afterCreate,\x20'+_0x3027d6[_0xaa55('0xc')]+_0xaa55('0x2b')+_0x48f5e6['id']);}return _0x570d76[_0xaa55('0x23')]['create']({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6[_0xaa55('0x26')]:0x2,'scheduledat':_0x3027d6[_0xaa55('0x15')]?_0x3027d6[_0xaa55('0x15')]:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'callback':_0x3027d6[_0xaa55('0x27')]?!![]:![],'callbackuniqueid':_0x3027d6[_0xaa55('0x27')]?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6[_0xaa55('0x27')]?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'VoiceQueueId':_0x48f5e6['id']});})[_0xaa55('0x28')](function(_0x36c4f2){_0x546b16(_0x36c4f2);});});});};function _0x39d07f(){return function(_0x534380){logger[_0xaa55('0x2c')](_0xaa55('0x13'),'afterCreate',util['inspect'](_0x534380,{'showHidden':![],'depth':null}));};}function _0x427c5a(_0x2e9b24,_0x55f428){var _0x536456=_0x55f428[_0xaa55('0x15')]?_0x55f428[_0xaa55('0x15')]:moment()[_0xaa55('0x1f')](_0xaa55('0x16'));return new BPromise(function(_0x3cdc20,_0x3ee085){if(_[_0xaa55('0x17')](_0x55f428[_0xaa55('0x1a')])){_0x3cdc20({'ret':_0x536456});}else{_0x570d76['Campaign']['findOne']({'where':{'id':_0x2e9b24['id']}})[_0xaa55('0x19')](function(_0x32b30d){if(!_[_0xaa55('0x17')](_0x32b30d)){var _0x56188f=_0x32b30d[_0xaa55('0x1a')];if(!_['isNil'](_0x56188f)){var _0x5068ac=shared[_0xaa55('0x1b')];var _0x2f7992=_0x5068ac[_0x56188f];var _0x21dccd=_0x5068ac[_0x55f428[_0xaa55('0x1a')]];if(!_[_0xaa55('0x17')](_0x2f7992)&&!_['isNil'](_0x21dccd)){var _0x4d4404=_0x2f7992[_0xaa55('0x1c')]-_0x21dccd[_0xaa55('0x1c')];_0x536456=_0x55f428[_0xaa55('0x15')]?_0x55f428[_0xaa55('0x15')]:moment();var _0x32b682=moment(_0x536456)[_0xaa55('0x1d')](_0x4d4404,_0xaa55('0x1e'));_0x3cdc20({'ret':_0x32b682[_0xaa55('0x1f')](_0xaa55('0x16'))});}else _0x3cdc20({'ret':_0x536456});}else _0x3cdc20({'ret':_0x536456});}else{_0x3cdc20({'ret':_0x536456});}});}});return 0xa;}var _0x1f04da=function(_0x1ec27a){return new BPromise(function(_0x58895b,_0x449ddb){_0x427c5a(_0x1ec27a,_0x3027d6)[_0xaa55('0x19')](function(_0x4f51d5){_0x3027d6[_0xaa55('0x15')]=_0x4f51d5['ret'];_0x570d76[_0xaa55('0x23')][_0xaa55('0x18')]({'where':{'phone':_0x3027d6[_0xaa55('0xc')],'CampaignId':_0x1ec27a['id']}})[_0xaa55('0x19')](function(_0x5c1df3){if(!_[_0xaa55('0x17')](_0x5c1df3)){throw new Error(_0xaa55('0x21')+_0x3027d6[_0xaa55('0xc')]+_0xaa55('0x2d')+_0x1ec27a['id']);}return _0x570d76[_0xaa55('0x23')][_0xaa55('0x24')]({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6['priority']:0x2,'scheduledat':_0x3027d6['scheduledat']?_0x3027d6[_0xaa55('0x15')]:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'callback':_0x3027d6[_0xaa55('0x27')]?!![]:![],'callbackuniqueid':_0x3027d6['callbackUniqueid']?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6['callbackUniqueid']?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'CampaignId':_0x1ec27a['id']});})[_0xaa55('0x28')](function(_0x501346){_0x449ddb(_0x501346);});});});};var _0x236c58=function(_0x3ff4f3){return new BPromise(function(_0x455d36,_0x47cd42){_0x427c5a(_0x3ff4f3,_0x3027d6)['then'](function(_0x1f37eb){_0x3027d6['scheduledat']=_0x1f37eb[_0xaa55('0x20')];_0x570d76[_0xaa55('0x23')][_0xaa55('0x18')]({'where':{'phone':_0x3027d6[_0xaa55('0xc')],'CampaignId':_0x3ff4f3['id']}})[_0xaa55('0x19')](function(_0x5038b0){if(!_[_0xaa55('0x17')](_0x5038b0)){throw new Error(_0xaa55('0x21')+_0x3027d6[_0xaa55('0xc')]+_0xaa55('0x2e')+_0x3ff4f3['id']);}return _0x570d76[_0xaa55('0x2a')][_0xaa55('0x18')]({'where':{'calleridnum':_0x3027d6[_0xaa55('0xc')],'CampaignId':_0x3ff4f3['id']}});})[_0xaa55('0x19')](function(_0x578657){if(!_[_0xaa55('0x17')](_0x578657)){throw new Error(_0xaa55('0x2f')+_0x3027d6[_0xaa55('0xc')]+_0xaa55('0x30')+_0x3ff4f3['id']);}return _0x570d76[_0xaa55('0x23')]['create']({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6[_0xaa55('0x26')]:0x2,'scheduledat':_0x3027d6[_0xaa55('0x15')]?_0x3027d6['scheduledat']:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'callback':_0x3027d6['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x3027d6[_0xaa55('0x27')]?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6[_0xaa55('0x27')]?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'CampaignId':_0x3ff4f3['id']});})[_0xaa55('0x28')](function(_0x4b9ef9){_0x47cd42(_0x4b9ef9);});});});};if(_0x3027d6[_0xaa55('0x25')]){_0x570d76[_0xaa55('0x31')]['findAll']({'where':{'type':_0xaa55('0x32')},'attributes':['id',_0xaa55('0x33'),_0xaa55('0x1a')],'include':[{'model':_0x570d76[_0xaa55('0x34')],'as':_0xaa55('0x35'),'where':{'id':_0x3027d6[_0xaa55('0x25')]}}]})[_0xaa55('0x19')](function(_0x2e855d){if(_0x2e855d){var _0x4d3de4=[];for(var _0x73ca73=0x0,_0x13b4b2;_0x73ca73<_0x2e855d[_0xaa55('0x36')];_0x73ca73+=0x1){_0x13b4b2=_0x2e855d[_0x73ca73][_0xaa55('0x37')]({'plain':!![]});switch(_0x13b4b2[_0xaa55('0x33')]){case'always':_0x29a423(_0x13b4b2)[_0xaa55('0x28')](_0x437b11());break;case _0xaa55('0x38'):_0x238f73(_0x13b4b2)['catch'](_0x437b11());break;default:_0x427c5a(_0x13b4b2,_0x3027d6)[_0xaa55('0x19')](function(_0x3a6cdc){_0x3027d6[_0xaa55('0x15')]=_0x3a6cdc[_0xaa55('0x20')];_0x570d76[_0xaa55('0x23')]['create']({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'scheduledat':_0x3027d6['scheduledat']?_0x3027d6[_0xaa55('0x15')]:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6[_0xaa55('0x26')]:0x2,'callback':_0x3027d6[_0xaa55('0x27')]?!![]:![],'callbackuniqueid':_0x3027d6['callbackUniqueid']?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6[_0xaa55('0x27')]?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'VoiceQueueId':_0x13b4b2['id']})[_0xaa55('0x28')](_0x437b11());});}}}})[_0xaa55('0x19')](function(){return _0x570d76['VoiceQueue']['findAll']({'where':{'type':_0xaa55('0x32')},'attributes':['id'],'include':[{'model':_0x570d76[_0xaa55('0x34')],'as':_0xaa55('0x39'),'where':{'id':_0x3027d6[_0xaa55('0x25')]}}]})[_0xaa55('0x19')](function(_0x32eb65){if(_0x32eb65){var _0xc9e583=[];for(var _0x9e5ec7=0x0,_0x551783;_0x9e5ec7<_0x32eb65[_0xaa55('0x36')];_0x9e5ec7+=0x1){_0x551783=_0x32eb65[_0x9e5ec7]['get']({'plain':!![]});_0x570d76[_0xaa55('0x3a')][_0xaa55('0x24')]({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6['ListId'],'VoiceQueueId':_0x551783['id']})['catch'](function(_0x1a9ccf){logger[_0xaa55('0x2c')](_0xaa55('0x3b'),_0xaa55('0x3c'),_0x1a9ccf[_0xaa55('0x3d')]);});}}});})['then'](function(){return _0x570d76[_0xaa55('0x3e')][_0xaa55('0x3f')]({'attributes':['id',_0xaa55('0x33'),_0xaa55('0x1a')],'include':[{'model':_0x570d76['CmList'],'as':_0xaa55('0x35'),'where':{'id':_0x3027d6[_0xaa55('0x25')]}}]})['then'](function(_0x441740){if(_0x441740){var _0x3dcaf4=[];for(var _0x8672ad=0x0,_0x3fdfb8;_0x8672ad<_0x441740[_0xaa55('0x36')];_0x8672ad+=0x1){_0x3fdfb8=_0x441740[_0x8672ad][_0xaa55('0x37')]({'plain':!![]});switch(_0x3fdfb8['dialCheckDuplicateType']){case _0xaa55('0x40'):_0x236c58(_0x3fdfb8)[_0xaa55('0x28')](_0x39d07f());break;case'onlyIfOpen':_0x1f04da(_0x3fdfb8)[_0xaa55('0x28')](_0x39d07f());break;default:_0x570d76[_0xaa55('0x23')][_0xaa55('0x24')]({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'scheduledat':_0x3027d6['scheduledat']?_0x3027d6['scheduledat']:moment()[_0xaa55('0x1f')](_0xaa55('0x16')),'priority':_0x3027d6[_0xaa55('0x26')]?_0x3027d6[_0xaa55('0x26')]:0x2,'callback':_0x3027d6['callbackUniqueid']?!![]:![],'callbackuniqueid':_0x3027d6[_0xaa55('0x27')]?_0x3027d6[_0xaa55('0x27')]:undefined,'callbackat':_0x3027d6[_0xaa55('0x27')]?moment()[_0xaa55('0x1f')](_0xaa55('0x16')):undefined,'CampaignId':_0x3fdfb8['id']})[_0xaa55('0x28')](_0x39d07f());}}}});})[_0xaa55('0x19')](function(){return _0x570d76[_0xaa55('0x3e')][_0xaa55('0x3f')]({'attributes':['id'],'include':[{'model':_0x570d76[_0xaa55('0x34')],'as':_0xaa55('0x39'),'where':{'id':_0x3027d6[_0xaa55('0x25')]}}]})[_0xaa55('0x19')](function(_0x4d4d7e){if(_0x4d4d7e){var _0x225dd6=[];for(var _0x734e48=0x0,_0x3a9cd1;_0x734e48<_0x4d4d7e['length'];_0x734e48+=0x1){_0x3a9cd1=_0x4d4d7e[_0x734e48]['get']({'plain':!![]});_0x570d76[_0xaa55('0x3a')][_0xaa55('0x24')]({'phone':_0x3027d6[_0xaa55('0xc')],'ContactId':_0x3027d6['id'],'ListId':_0x3027d6[_0xaa55('0x25')],'CampaignId':_0x3a9cd1['id']})['catch'](function(_0x3ce6e0){logger[_0xaa55('0x2c')](_0xaa55('0x3b'),_0xaa55('0x3c'),_0x3ce6e0[_0xaa55('0x3d')]);});}}});})[_0xaa55('0x19')](function(){_0x167eaf();})[_0xaa55('0x28')](function(_0x1c6359){logger[_0xaa55('0x2c')](_0xaa55('0x3b'),_0xaa55('0x3c'),_0x1c6359[_0xaa55('0x3d')]);_0x167eaf(_0x1c6359);});}else{_0x167eaf(new Error(_0xaa55('0x41')));}},'afterDestroy':function(_0x1d0d7b,_0x37bcce,_0x3f1342){var _0x242dca=_0x220faa[_0xaa55('0x12')];var _0x43b12f=_0x1d0d7b[_0xaa55('0x37')]({'plain':!![]});return _0x242dca['CmHopper'][_0xaa55('0x3f')]({'raw':!![],'where':{'ListId':_0x43b12f[_0xaa55('0x25')],'ContactId':_0x43b12f['id']}})[_0xaa55('0x19')](function(_0xcbb2b){if(!_[_0xaa55('0x42')](_0xcbb2b)){var _0x1bbaaa=[];for(var _0x30861a=0x0;_0x30861a<_0xcbb2b['length'];_0x30861a+=0x1){var _0x90e409=_0x242dca[_0xaa55('0x23')]['destroy']({'where':{'ListId':_0xcbb2b[_0x30861a][_0xaa55('0x25')],'ContactId':_0xcbb2b[_0x30861a][_0xaa55('0x43')],'VoiceQueueId':_0xcbb2b[_0x30861a][_0xaa55('0x44')],'CampaignId':_0xcbb2b[_0x30861a]['CampaignId']}});_0x1bbaaa[_0xaa55('0x45')](_0x90e409);}return BPromise[_0xaa55('0x46')](_0x1bbaaa);}})['then'](function(_0x2817db){logger['info'](_0xaa55('0x47'),util[_0xaa55('0x14')](_0x2817db,{'showHidden':![],'depth':null}));_0x3f1342();})[_0xaa55('0x28')](function(_0x506b19){logger[_0xaa55('0x2c')]('[CmContact][afterDestroy][Error]',util[_0xaa55('0x14')](_0x506b19,{'showHidden':![],'depth':null}));_0x3f1342(_0x506b19);});}}});}; \ No newline at end of file diff --git a/server/api/cmContact/cmContact.rpc.js b/server/api/cmContact/cmContact.rpc.js new file mode 100644 index 0000000..e05c1f6 --- /dev/null +++ b/server/api/cmContact/cmContact.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['phone','ListId','Contact','CmContactId','create','body','keys','length','startsWith','update','table','cm_contacts','id\x20=\x20?','sequelize','query','CreateCmContact','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','./cmContact.socket','register','info','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetCmContact','CmContact','findAll','options','where','limit','include','map','model','attributes','then','stringify','CmContactHasItem','find'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xa9e0,0x123));var _0x0a9e=function(_0x18a79d,_0x57bd2c){_0x18a79d=_0x18a79d-0x0;var _0x4f8848=_0xa9e0[_0x18a79d];return _0x4f8848;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a9e('0x3'));var squel=require('squel');var db=require(_0x0a9e('0x4'))['db'];var utils=require(_0x0a9e('0x5'));var logger=require(_0x0a9e('0x6'))(_0x0a9e('0x7'));var config=require(_0x0a9e('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x0a9e('0x9')][_0x0a9e('0xa')]({'port':0x232a});config[_0x0a9e('0xb')]=_['defaults'](config['redis'],{'host':_0x0a9e('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0a9e('0xd'))[_0x0a9e('0xe')](socket);function respondWithRpcPromise(_0x307b3e,_0x3ab53f,_0xfeb75b){return new BPromise(function(_0xbd1168,_0x4a4c56){return client['request'](_0x307b3e,_0xfeb75b)['then'](function(_0x4cfe67){logger[_0x0a9e('0xf')](_0x0a9e('0x10'),_0x3ab53f,_0x0a9e('0x11'));logger[_0x0a9e('0x12')](_0x0a9e('0x13'),_0x3ab53f,_0x0a9e('0x11'),JSON['stringify'](_0x4cfe67));if(_0x4cfe67[_0x0a9e('0x14')]){if(_0x4cfe67[_0x0a9e('0x14')][_0x0a9e('0x15')]===0x1f4){logger[_0x0a9e('0x14')](_0x0a9e('0x10'),_0x3ab53f,_0x4cfe67[_0x0a9e('0x14')]['message']);return _0x4a4c56(_0x4cfe67[_0x0a9e('0x14')]['message']);}logger[_0x0a9e('0x14')]('CmContact,\x20%s,\x20%s',_0x3ab53f,_0x4cfe67[_0x0a9e('0x14')][_0x0a9e('0x16')]);return _0xbd1168(_0x4cfe67['error'][_0x0a9e('0x16')]);}else{logger['info'](_0x0a9e('0x10'),_0x3ab53f,_0x0a9e('0x11'));_0xbd1168(_0x4cfe67[_0x0a9e('0x17')][_0x0a9e('0x16')]);}})[_0x0a9e('0x18')](function(_0x2eb11f){logger[_0x0a9e('0x14')](_0x0a9e('0x10'),_0x3ab53f,_0x2eb11f);_0x4a4c56(_0x2eb11f);});});}exports[_0x0a9e('0x19')]=function(_0x112016){var _0x1c696a=this;return new Promise(function(_0x105080,_0x4bb1e3){return db[_0x0a9e('0x1a')][_0x0a9e('0x1b')]({'raw':_0x112016['options']?_0x112016[_0x0a9e('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x112016['options']?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1d')]||null:null,'attributes':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')]['attributes']||null:null,'limit':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1e')]||null:null,'include':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1f')]?_[_0x0a9e('0x20')](_0x112016['options']['include'],function(_0x197ec0){return{'model':db[_0x197ec0[_0x0a9e('0x21')]],'as':_0x197ec0['as'],'attributes':_0x197ec0[_0x0a9e('0x22')],'include':_0x197ec0[_0x0a9e('0x1f')]?_['map'](_0x197ec0[_0x0a9e('0x1f')],function(_0x479bc4){return{'model':db[_0x479bc4[_0x0a9e('0x21')]],'as':_0x479bc4['as'],'attributes':_0x479bc4['attributes'],'include':_0x479bc4[_0x0a9e('0x1f')]?_[_0x0a9e('0x20')](_0x479bc4[_0x0a9e('0x1f')],function(_0x14433c){return{'model':db[_0x14433c[_0x0a9e('0x21')]],'as':_0x14433c['as'],'attributes':_0x14433c[_0x0a9e('0x22')]};}):[]};}):[]};}):[]:[]})[_0x0a9e('0x23')](function(_0x14de77){logger['info'](_0x0a9e('0x19'),_0x112016);logger[_0x0a9e('0x12')](_0x0a9e('0x19'),_0x112016,JSON[_0x0a9e('0x24')](_0x14de77));if(_0x14de77['length']==0x0){return db[_0x0a9e('0x25')][_0x0a9e('0x26')]({'raw':!![],'where':{'item':_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x27')]},'include':[{'model':db[_0x0a9e('0x1a')],'where':{'ListId':_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1d')][_0x0a9e('0x28')],'deletedAt':{'$eq':null}},'as':_0x0a9e('0x29')}]})['then'](function(_0x426950){if(_['isNil'](_0x426950)){_0x105080(_0x14de77);}else{var _0x2407f9=_0x426950[_0x0a9e('0x2a')];return db[_0x0a9e('0x1a')][_0x0a9e('0x1b')]({'raw':!![],'where':{'id':_0x2407f9},'attributes':_0x112016[_0x0a9e('0x1c')]?_0x112016['options'][_0x0a9e('0x22')]||null:null})[_0x0a9e('0x23')](function(_0x40cb85){_0x105080(_0x40cb85);});}});}else{_0x105080(_0x14de77);}})[_0x0a9e('0x18')](function(_0x2b45ea){logger[_0x0a9e('0x14')](_0x0a9e('0x19'),_0x2b45ea[_0x0a9e('0x16')],_0x112016);_0x4bb1e3(_0x1c696a['error'](0x1f4,_0x2b45ea[_0x0a9e('0x16')]));});});};exports['CreateCmContact']=function(_0x2cc7a0){var _0x14b13f=this;return new Promise(function(_0x2b7e7f,_0x3f3d41){return db['CmContact'][_0x0a9e('0x2b')](_0x2cc7a0[_0x0a9e('0x2c')],{'raw':_0x2cc7a0[_0x0a9e('0x1c')]?_0x2cc7a0[_0x0a9e('0x1c')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x1e8694){var _0x5640eb;for(var _0x24936a=0x0;_0x24936a{}\s\\|]/g,'-');_0x59181e(null,util[_0x0a9e('0x26')]('%s-%s%s',path[_0x0a9e('0x27')](_0x5ea472['originalname'],path[_0x0a9e('0x28')](_0x5ea472['originalname'])),Date[_0x0a9e('0x29')](),path[_0x0a9e('0x28')](_0x5ea472[_0x0a9e('0x24')])));}})});router[_0x0a9e('0x18')](_0x0a9e('0x2a'),upload[_0x0a9e('0x2b')](_0x0a9e('0x2c')),controller[_0x0a9e('0x2d')]);var upload=multer({'storage':multer['diskStorage']({'destination':function(_0x3652a7,_0x468813,_0x2b1f27){_0x2b1f27(null,path[_0x0a9e('0x21')](config['root'],_0x0a9e('0x23')));},'filename':function(_0x40e7a3,_0x1843b2,_0x824a4f){_0x1843b2[_0x0a9e('0x24')]=_0x1843b2[_0x0a9e('0x24')][_0x0a9e('0x25')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');_0x824a4f(null,util[_0x0a9e('0x26')](_0x0a9e('0x2e'),path['basename'](_0x1843b2[_0x0a9e('0x24')],path['extname'](_0x1843b2[_0x0a9e('0x24')])),Date[_0x0a9e('0x29')](),path[_0x0a9e('0x28')](_0x1843b2[_0x0a9e('0x24')])));}})});router[_0x0a9e('0x18')]('/upload',upload[_0x0a9e('0x2b')](_0x0a9e('0x2c')),controller[_0x0a9e('0x2f')]);router[_0x0a9e('0x18')](_0x0a9e('0x30'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x31')]);router[_0x0a9e('0x18')]('/uploadUpdates/:id',auth[_0x0a9e('0xd')](),controller['importUpdates']);router[_0x0a9e('0x32')](_0x0a9e('0x33'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x34')]);router['delete'](_0x0a9e('0x33'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x35')]);module[_0x0a9e('0x36')]=router; \ No newline at end of file diff --git a/server/api/cmContactHasItem/cmContactHasItem.attributes.js b/server/api/cmContactHasItem/cmContactHasItem.attributes.js new file mode 100644 index 0000000..e9d34d5 --- /dev/null +++ b/server/api/cmContactHasItem/cmContactHasItem.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa98d=['STRING','sequelize','INTEGER'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0xa98d,0xa3));var _0xda98=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xa98d[_0x122ef9];return _0x42fba0;};'use strict';var Sequelize=require(_0xda98('0x0'));module['exports']={'CmContactId':{'type':Sequelize[_0xda98('0x1')],'primaryKey':!![]},'item':{'type':Sequelize['STRING'],'defaultValue':'','primaryKey':!![]},'ItemTypeId':{'type':Sequelize[_0xda98('0x1')],'defaultValue':null},'ItemClass':{'type':Sequelize[_0xda98('0x2')],'defaultValue':'PHONE'},'OrderBy':{'type':Sequelize[_0xda98('0x1')],'defaultValue':null},'description':{'type':Sequelize[_0xda98('0x2')],'defaultValue':null}}; \ No newline at end of file diff --git a/server/api/cmContactHasItem/cmContactHasItem.controller.js b/server/api/cmContactHasItem/cmContactHasItem.controller.js new file mode 100644 index 0000000..cd6de2f --- /dev/null +++ b/server/api/cmContactHasItem/cmContactHasItem.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x03ee=['../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','reject','save','update','then','destroy','CmContactHasItems','UserProfileResource','stack','name','send','index','map','fieldName','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','CmContactHasItem','includeAll','include','findAll','rows','catch','rawAttributes','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','error','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring'];(function(_0x6228e7,_0x295d6a){var _0x4809a8=function(_0xa70e5){while(--_0xa70e5){_0x6228e7['push'](_0x6228e7['shift']());}};_0x4809a8(++_0x295d6a);}(_0x03ee,0xe8));var _0xe03e=function(_0x1cbcb2,_0x1237a3){_0x1cbcb2=_0x1cbcb2-0x0;var _0x41ac9f=_0x03ee[_0x1cbcb2];return _0x41ac9f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe03e('0x0'));var zipdir=require(_0xe03e('0x1'));var jsonpatch=require(_0xe03e('0x2'));var rp=require(_0xe03e('0x3'));var moment=require(_0xe03e('0x4'));var BPromise=require(_0xe03e('0x5'));var Mustache=require(_0xe03e('0x6'));var util=require(_0xe03e('0x7'));var path=require(_0xe03e('0x8'));var sox=require(_0xe03e('0x9'));var csv=require(_0xe03e('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe03e('0xb'));var _=require(_0xe03e('0xc'));var squel=require(_0xe03e('0xd'));var crypto=require(_0xe03e('0xe'));var jsforce=require(_0xe03e('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xe03e('0xa'));var querystring=require(_0xe03e('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe03e('0x11'));var qs=require(_0xe03e('0x12'));var as=require(_0xe03e('0x13'));var hardwareService=require(_0xe03e('0x14'));var logger=require(_0xe03e('0x15'))(_0xe03e('0x16'));var utils=require(_0xe03e('0x17'));var config=require(_0xe03e('0x18'));var licenseUtil=require(_0xe03e('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x56fa89,_0x110947){_0x110947=_0x110947||0xcc;return function(_0x35dd67){if(_0x35dd67){return _0x56fa89[_0xe03e('0x1a')](_0x110947);}return _0x56fa89[_0xe03e('0x1b')](_0x110947)[_0xe03e('0x1c')]();};}function respondWithResult(_0x4cff9b,_0x476752){_0x476752=_0x476752||0xc8;return function(_0x166a2d){if(_0x166a2d){return _0x4cff9b[_0xe03e('0x1b')](_0x476752)[_0xe03e('0x1d')](_0x166a2d);}};}function respondWithFilteredResult(_0x2bf7d3,_0x9e7457){return function(_0x54748c){if(_0x54748c){var _0x18ebe0=typeof _0x9e7457[_0xe03e('0x1e')]===_0xe03e('0x1f')&&typeof _0x9e7457[_0xe03e('0x20')]===_0xe03e('0x1f');var _0x50fb35=_0x54748c[_0xe03e('0x21')];var _0xabd802=_0x18ebe0?0x0:_0x9e7457['offset'];var _0x307258=_0x18ebe0?_0x54748c[_0xe03e('0x21')]:_0x9e7457[_0xe03e('0x1e')]+_0x9e7457['limit'];var _0x1816a9;if(_0x307258>=_0x50fb35){_0x307258=_0x50fb35;_0x1816a9=0xc8;}else{_0x1816a9=0xce;}_0x2bf7d3[_0xe03e('0x1b')](_0x1816a9);return _0x2bf7d3['set'](_0xe03e('0x22'),_0xabd802+'-'+_0x307258+'/'+_0x50fb35)[_0xe03e('0x1d')](_0x54748c);}return null;};}function patchUpdates(_0x564e28){return function(_0x3f43c0){try{jsonpatch['apply'](_0x3f43c0,_0x564e28,!![]);}catch(_0x2f9685){return BPromise[_0xe03e('0x23')](_0x2f9685);}return _0x3f43c0[_0xe03e('0x24')]();};}function saveUpdates(_0x5dab9a,_0x28adeb){return function(_0x25cc60){if(_0x25cc60){return _0x25cc60[_0xe03e('0x25')](_0x5dab9a)[_0xe03e('0x26')](function(_0x4bb654){return _0x4bb654;});}return null;};}function removeEntity(_0xbfe5c1,_0x13abb1){return function(_0x374405){if(_0x374405){return _0x374405[_0xe03e('0x27')]()[_0xe03e('0x26')](function(){var _0x25c461=_0x374405['get']({'plain':!![]});var _0x2f314f=_0xe03e('0x28');return db[_0xe03e('0x29')][_0xe03e('0x27')]({'where':{'type':_0x2f314f,'resourceId':_0x25c461['id']}})[_0xe03e('0x26')](function(){return _0x374405;});})[_0xe03e('0x26')](function(){_0xbfe5c1['status'](0xcc)[_0xe03e('0x1c')]();});}};}function handleEntityNotFound(_0x57cf57,_0x2c53d2){return function(_0x3b2ce7){if(!_0x3b2ce7){_0x57cf57['sendStatus'](0x194);}return _0x3b2ce7;};}function handleError(_0x2b7257,_0x5a0607){_0x5a0607=_0x5a0607||0x1f4;return function(_0x2b9c47){logger['error'](_0x2b9c47[_0xe03e('0x2a')]);if(_0x2b9c47[_0xe03e('0x2b')]){delete _0x2b9c47[_0xe03e('0x2b')];}_0x2b7257['status'](_0x5a0607)[_0xe03e('0x2c')](_0x2b9c47);};}exports[_0xe03e('0x2d')]=function(_0x3fa85c,_0x4695d4){var _0x211b3f={},_0x4ae8e2={},_0x43273b={'count':0x0,'rows':[]};var _0x527b9b=_[_0xe03e('0x2e')](db['CmContactHasItem']['rawAttributes'],function(_0xaec64e){return{'name':_0xaec64e[_0xe03e('0x2f')],'type':_0xaec64e['type']['key']};});_0x4ae8e2[_0xe03e('0x30')]=_[_0xe03e('0x2e')](_0x527b9b,_0xe03e('0x2b'));_0x4ae8e2['query']=_[_0xe03e('0x31')](_0x3fa85c[_0xe03e('0x32')]);_0x4ae8e2[_0xe03e('0x33')]=_[_0xe03e('0x34')](_0x4ae8e2['model'],_0x4ae8e2[_0xe03e('0x32')]);_0x211b3f[_0xe03e('0x35')]=_[_0xe03e('0x34')](_0x4ae8e2[_0xe03e('0x30')],qs[_0xe03e('0x36')](_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x36')]));_0x211b3f[_0xe03e('0x35')]=_0x211b3f[_0xe03e('0x35')]['length']?_0x211b3f[_0xe03e('0x35')]:_0x4ae8e2['model'];if(!_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x37')](_0xe03e('0x38'))){_0x211b3f['limit']=qs[_0xe03e('0x20')](_0x3fa85c[_0xe03e('0x32')]['limit']);_0x211b3f[_0xe03e('0x1e')]=qs[_0xe03e('0x1e')](_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x1e')]);}_0x211b3f[_0xe03e('0x39')]=qs['sort'](_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x3a')]);_0x211b3f[_0xe03e('0x3b')]=qs[_0xe03e('0x33')](_['pick'](_0x3fa85c[_0xe03e('0x32')],_0x4ae8e2[_0xe03e('0x33')]),_0x527b9b);if(_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x3c')]){_0x211b3f[_0xe03e('0x3b')]=_[_0xe03e('0x3d')](_0x211b3f[_0xe03e('0x3b')],{'$or':_['map'](_0x527b9b,function(_0x4f7d3a){if(_0x4f7d3a['type']!==_0xe03e('0x3e')){var _0x1dcafa={};_0x1dcafa[_0x4f7d3a['name']]={'$like':'%'+_0x3fa85c[_0xe03e('0x32')][_0xe03e('0x3c')]+'%'};return _0x1dcafa;}})});}_0x211b3f=_['merge']({},_0x211b3f,_0x3fa85c[_0xe03e('0x3f')]);var _0xde64a4={'where':_0x211b3f[_0xe03e('0x3b')]};return db[_0xe03e('0x40')][_0xe03e('0x21')](_0xde64a4)[_0xe03e('0x26')](function(_0x3192dd){_0x43273b[_0xe03e('0x21')]=_0x3192dd;if(_0x3fa85c['query'][_0xe03e('0x41')]){_0x211b3f[_0xe03e('0x42')]=[{'all':!![]}];}return db[_0xe03e('0x40')][_0xe03e('0x43')](_0x211b3f);})['then'](function(_0x4f07cd){_0x43273b[_0xe03e('0x44')]=_0x4f07cd;return _0x43273b;})[_0xe03e('0x26')](respondWithFilteredResult(_0x4695d4,_0x211b3f))[_0xe03e('0x45')](handleError(_0x4695d4,null));};exports['show']=function(_0x4d52d8,_0x5cfca2){var _0x1b383c={'raw':!![],'where':{'id':_0x4d52d8['params']['id']}},_0x10a7d0={};_0x10a7d0[_0xe03e('0x30')]=_[_0xe03e('0x31')](db[_0xe03e('0x40')][_0xe03e('0x46')]);_0x10a7d0[_0xe03e('0x32')]=_[_0xe03e('0x31')](_0x4d52d8['query']);_0x10a7d0[_0xe03e('0x33')]=_[_0xe03e('0x34')](_0x10a7d0[_0xe03e('0x30')],_0x10a7d0[_0xe03e('0x32')]);_0x1b383c[_0xe03e('0x35')]=_[_0xe03e('0x34')](_0x10a7d0[_0xe03e('0x30')],qs[_0xe03e('0x36')](_0x4d52d8[_0xe03e('0x32')]['fields']));_0x1b383c[_0xe03e('0x35')]=_0x1b383c[_0xe03e('0x35')]['length']?_0x1b383c['attributes']:_0x10a7d0[_0xe03e('0x30')];if(_0x4d52d8[_0xe03e('0x32')]['includeAll']){_0x1b383c[_0xe03e('0x42')]=[{'all':!![]}];}_0x1b383c=_[_0xe03e('0x3d')]({},_0x1b383c,_0x4d52d8['options']);return db[_0xe03e('0x40')]['find'](_0x1b383c)[_0xe03e('0x26')](handleEntityNotFound(_0x5cfca2,null))['then'](respondWithResult(_0x5cfca2,null))[_0xe03e('0x45')](handleError(_0x5cfca2,null));};exports[_0xe03e('0x47')]=function(_0x42561c,_0x3e1a9d){return db[_0xe03e('0x40')][_0xe03e('0x47')](_0x42561c[_0xe03e('0x48')],{})[_0xe03e('0x26')](function(_0x20d75d){var _0x23e69f=_0x42561c[_0xe03e('0x49')][_0xe03e('0x4a')]({'plain':!![]});if(!_0x23e69f)throw new Error(_0xe03e('0x4b'));if(_0x23e69f[_0xe03e('0x4c')]===_0xe03e('0x49')){var _0x10116e=_0x20d75d[_0xe03e('0x4a')]({'plain':!![]});var _0x31edef=_0xe03e('0x28');return db[_0xe03e('0x4d')][_0xe03e('0x4e')]({'where':{'name':_0x31edef,'userProfileId':_0x23e69f[_0xe03e('0x4f')]},'raw':!![]})[_0xe03e('0x26')](function(_0x31a821){if(_0x31a821&&_0x31a821[_0xe03e('0x50')]===0x0){return db['UserProfileResource'][_0xe03e('0x47')]({'name':_0x10116e[_0xe03e('0x2b')],'resourceId':_0x10116e['id'],'type':_0x31a821['name'],'sectionId':_0x31a821['id']},{})[_0xe03e('0x26')](function(){return _0x20d75d;});}else{return _0x20d75d;}})[_0xe03e('0x45')](function(_0x54c5fb){logger[_0xe03e('0x51')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x54c5fb);throw _0x54c5fb;});}return _0x20d75d;})[_0xe03e('0x26')](respondWithResult(_0x3e1a9d,0xc9))[_0xe03e('0x45')](handleError(_0x3e1a9d,null));};exports['update']=function(_0x343247,_0x150968){if(_0x343247[_0xe03e('0x48')]['id']){delete _0x343247[_0xe03e('0x48')]['id'];}return db[_0xe03e('0x40')][_0xe03e('0x4e')]({'where':{'id':_0x343247[_0xe03e('0x52')]['id']}})[_0xe03e('0x26')](handleEntityNotFound(_0x150968,null))['then'](saveUpdates(_0x343247[_0xe03e('0x48')],null))['then'](respondWithResult(_0x150968,null))[_0xe03e('0x45')](handleError(_0x150968,null));};exports['destroy']=function(_0x46be99,_0x2c4b03){return db[_0xe03e('0x40')][_0xe03e('0x4e')]({'where':{'id':_0x46be99[_0xe03e('0x52')]['id']}})[_0xe03e('0x26')](handleEntityNotFound(_0x2c4b03,null))[_0xe03e('0x26')](removeEntity(_0x2c4b03,null))['catch'](handleError(_0x2c4b03,null));}; \ No newline at end of file diff --git a/server/api/cmContactHasItem/cmContactHasItem.model.js b/server/api/cmContactHasItem/cmContactHasItem.model.js new file mode 100644 index 0000000..8b0c7e8 --- /dev/null +++ b/server/api/cmContactHasItem/cmContactHasItem.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x59f5=['exports','define','cm_contact_has_items','lodash','util','../../config/logger','api','moment','bluebird','request-promise','rimraf','../../config/environment','./cmContactHasItem.attributes'];(function(_0x4b6c16,_0x1e2006){var _0x214d6d=function(_0x4c5f96){while(--_0x4c5f96){_0x4b6c16['push'](_0x4b6c16['shift']());}};_0x214d6d(++_0x1e2006);}(_0x59f5,0x16f));var _0x559f=function(_0x6b4306,_0x394520){_0x6b4306=_0x6b4306-0x0;var _0xf7568c=_0x59f5[_0x6b4306];return _0xf7568c;};'use strict';var _=require(_0x559f('0x0'));var util=require(_0x559f('0x1'));var logger=require(_0x559f('0x2'))(_0x559f('0x3'));var moment=require(_0x559f('0x4'));var BPromise=require(_0x559f('0x5'));var rp=require(_0x559f('0x6'));var fs=require('fs');var path=require('path');var rimraf=require(_0x559f('0x7'));var config=require(_0x559f('0x8'));var attributes=require(_0x559f('0x9'));module[_0x559f('0xa')]=function(_0x21b84a,_0x225968){return _0x21b84a[_0x559f('0xb')]('CmContactHasItem',attributes,{'tableName':_0x559f('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmContactHasItem/cmContactHasItem.rpc.js b/server/api/cmContactHasItem/cmContactHasItem.rpc.js new file mode 100644 index 0000000..4e50a41 --- /dev/null +++ b/server/api/cmContactHasItem/cmContactHasItem.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6456=['error','code','CmContactHasItem,\x20%s,\x20%s','message','info','result','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','debug','CmContactHasItem,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x4a6edc,_0x43edab){var _0x5a9617=function(_0x4b0a67){while(--_0x4b0a67){_0x4a6edc['push'](_0x4a6edc['shift']());}};_0x5a9617(++_0x43edab);}(_0x6456,0x1e2));var _0x6645=function(_0x3ef45a,_0x4b6756){_0x3ef45a=_0x3ef45a-0x0;var _0x86f9aa=_0x6456[_0x3ef45a];return _0x86f9aa;};'use strict';var _=require('lodash');var util=require(_0x6645('0x0'));var moment=require(_0x6645('0x1'));var BPromise=require(_0x6645('0x2'));var rs=require(_0x6645('0x3'));var fs=require('fs');var Redis=require(_0x6645('0x4'));var db=require(_0x6645('0x5'))['db'];var utils=require(_0x6645('0x6'));var logger=require(_0x6645('0x7'))(_0x6645('0x8'));var config=require(_0x6645('0x9'));var jayson=require(_0x6645('0xa'));var client=jayson[_0x6645('0xb')][_0x6645('0xc')]({'port':0x232a});function respondWithRpcPromise(_0xa99c4f,_0x12cb8a,_0x1f3c8b){return new BPromise(function(_0x36a200,_0x1c7c38){return client['request'](_0xa99c4f,_0x1f3c8b)[_0x6645('0xd')](function(_0x31a3ea){logger['info']('CmContactHasItem,\x20%s,\x20%s',_0x12cb8a,'request\x20sent');logger[_0x6645('0xe')](_0x6645('0xf'),_0x12cb8a,_0x6645('0x10'),JSON[_0x6645('0x11')](_0x31a3ea));if(_0x31a3ea[_0x6645('0x12')]){if(_0x31a3ea[_0x6645('0x12')][_0x6645('0x13')]===0x1f4){logger['error'](_0x6645('0x14'),_0x12cb8a,_0x31a3ea['error'][_0x6645('0x15')]);return _0x1c7c38(_0x31a3ea[_0x6645('0x12')]['message']);}logger[_0x6645('0x12')](_0x6645('0x14'),_0x12cb8a,_0x31a3ea[_0x6645('0x12')][_0x6645('0x15')]);return _0x36a200(_0x31a3ea['error']['message']);}else{logger[_0x6645('0x16')](_0x6645('0x14'),_0x12cb8a,_0x6645('0x10'));_0x36a200(_0x31a3ea[_0x6645('0x17')][_0x6645('0x15')]);}})[_0x6645('0x18')](function(_0x35f122){logger[_0x6645('0x12')](_0x6645('0x14'),_0x12cb8a,_0x35f122);_0x1c7c38(_0x35f122);});});} \ No newline at end of file diff --git a/server/api/cmContactHasItem/index.js b/server/api/cmContactHasItem/index.js new file mode 100644 index 0000000..b0de380 --- /dev/null +++ b/server/api/cmContactHasItem/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xed73=['Router','fs-extra','./cmContactHasItem.controller','get','isAuthenticated','index','/:id','create','update','delete','destroy','exports','multer','connect-timeout'];(function(_0x4a6a00,_0x4471b8){var _0x73d8c8=function(_0x4c2608){while(--_0x4c2608){_0x4a6a00['push'](_0x4a6a00['shift']());}};_0x73d8c8(++_0x4471b8);}(_0xed73,0x132));var _0x3ed7=function(_0x3d846e,_0x31ec6e){_0x3d846e=_0x3d846e-0x0;var _0x145539=_0xed73[_0x3d846e];return _0x145539;};'use strict';var multer=require(_0x3ed7('0x0'));var util=require('util');var path=require('path');var timeout=require(_0x3ed7('0x1'));var express=require('express');var router=express[_0x3ed7('0x2')]();var fs_extra=require(_0x3ed7('0x3'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x3ed7('0x4'));router[_0x3ed7('0x5')]('/',auth[_0x3ed7('0x6')](),controller[_0x3ed7('0x7')]);router[_0x3ed7('0x5')](_0x3ed7('0x8'),auth[_0x3ed7('0x6')](),controller['show']);router['post']('/',auth[_0x3ed7('0x6')](),controller[_0x3ed7('0x9')]);router['put']('/:id',auth['isAuthenticated'](),controller[_0x3ed7('0xa')]);router[_0x3ed7('0xb')](_0x3ed7('0x8'),auth[_0x3ed7('0x6')](),controller[_0x3ed7('0xc')]);module[_0x3ed7('0xd')]=router; \ No newline at end of file diff --git a/server/api/cmCustomField/cmCustomField.attributes.js b/server/api/cmCustomField/cmCustomField.attributes.js new file mode 100644 index 0000000..d52aff4 --- /dev/null +++ b/server/api/cmCustomField/cmCustomField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2497=['sequelize','getDataValue','alias','STRING','setDataValue','name','select','values','isArray','stringify','BOOLEAN'];(function(_0x23aa41,_0x2944df){var _0x293abb=function(_0x96c603){while(--_0x96c603){_0x23aa41['push'](_0x23aa41['shift']());}};_0x293abb(++_0x2944df);}(_0x2497,0x14a));var _0x7249=function(_0x542d43,_0x581432){_0x542d43=_0x542d43-0x0;var _0x3fb854=_0x2497[_0x542d43];return _0x3fb854;};'use strict';var Sequelize=require(_0x7249('0x0'));var _=require('lodash');module['exports']={'name':{'type':Sequelize['VIRTUAL'],'get':function(_0x17cea2){return this[_0x7249('0x1')](_0x7249('0x2'));}},'alias':{'type':Sequelize[_0x7249('0x3')],'allowNull':![],'set':function(_0x362342){this[_0x7249('0x4')]('alias',_0x362342?_0x362342:this[_0x7249('0x1')](_0x7249('0x5')));}},'type':{'type':Sequelize[_0x7249('0x3')],'allowNull':![]},'values':{'type':Sequelize['TEXT']('long'),'get':function(){if(this[_0x7249('0x1')]('type')===_0x7249('0x6')){return JSON['parse'](this['getDataValue'](_0x7249('0x7')));}else{return this[_0x7249('0x1')](_0x7249('0x7'));}},'set':function(_0x32fc6e){if(Array[_0x7249('0x8')](_0x32fc6e)){this[_0x7249('0x4')](_0x7249('0x7'),JSON[_0x7249('0x9')](_0x32fc6e));}else{this[_0x7249('0x4')](_0x7249('0x7'),_0x32fc6e);}}},'required':{'type':Sequelize[_0x7249('0xa')],'defaultValue':![]},'clickToAction':{'type':Sequelize[_0x7249('0xa')],'defaultValue':![]},'actionType':{'type':Sequelize['ENUM']('voice')}}; \ No newline at end of file diff --git a/server/api/cmCustomField/cmCustomField.controller.js b/server/api/cmCustomField/cmCustomField.controller.js new file mode 100644 index 0000000..e27d406 --- /dev/null +++ b/server/api/cmCustomField/cmCustomField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfd69=['model','intersection','fields','length','attributes','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','findAll','catch','show','params','include','find','body','create','sequelize','transaction','Sequelize','text','TEXT','number','type','INTEGER','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cm_contacts','format','cf_%d','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','CmCustomField','rawAttributes','key','query','keys'];(function(_0x2ba436,_0xa0adbc){var _0x3a6706=function(_0x4b9d89){while(--_0x4b9d89){_0x2ba436['push'](_0x2ba436['shift']());}};_0x3a6706(++_0xa0adbc);}(_0xfd69,0x146));var _0x9fd6=function(_0x3ae10d,_0x1a7d1d){_0x3ae10d=_0x3ae10d-0x0;var _0x27e528=_0xfd69[_0x3ae10d];return _0x27e528;};'use strict';var emlformat=require(_0x9fd6('0x0'));var rimraf=require(_0x9fd6('0x1'));var zipdir=require(_0x9fd6('0x2'));var jsonpatch=require(_0x9fd6('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x9fd6('0x4'));var Mustache=require(_0x9fd6('0x5'));var util=require(_0x9fd6('0x6'));var path=require('path');var sox=require(_0x9fd6('0x7'));var csv=require(_0x9fd6('0x8'));var ejs=require(_0x9fd6('0x9'));var fs=require('fs');var fs_extra=require(_0x9fd6('0xa'));var _=require(_0x9fd6('0xb'));var squel=require(_0x9fd6('0xc'));var crypto=require(_0x9fd6('0xd'));var jsforce=require(_0x9fd6('0xe'));var deskjs=require(_0x9fd6('0xf'));var toCsv=require(_0x9fd6('0x8'));var querystring=require(_0x9fd6('0x10'));var Papa=require(_0x9fd6('0x11'));var Redis=require(_0x9fd6('0x12'));var authService=require(_0x9fd6('0x13'));var qs=require(_0x9fd6('0x14'));var as=require(_0x9fd6('0x15'));var hardwareService=require(_0x9fd6('0x16'));var logger=require(_0x9fd6('0x17'))(_0x9fd6('0x18'));var utils=require(_0x9fd6('0x19'));var config=require(_0x9fd6('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5cb155,_0x4f9821){_0x4f9821=_0x4f9821||0xcc;return function(_0x1add84){if(_0x1add84){return _0x5cb155[_0x9fd6('0x1b')](_0x4f9821);}return _0x5cb155[_0x9fd6('0x1c')](_0x4f9821)[_0x9fd6('0x1d')]();};}function respondWithResult(_0x339c9b,_0x1a59a0){_0x1a59a0=_0x1a59a0||0xc8;return function(_0x3036e2){if(_0x3036e2){return _0x339c9b[_0x9fd6('0x1c')](_0x1a59a0)[_0x9fd6('0x1e')](_0x3036e2);}};}function respondWithFilteredResult(_0x1ac3c4,_0xe35ea){return function(_0x375c1e){if(_0x375c1e){var _0x5ed9dd=typeof _0xe35ea[_0x9fd6('0x1f')]===_0x9fd6('0x20')&&typeof _0xe35ea[_0x9fd6('0x21')]===_0x9fd6('0x20');var _0x5e865a=_0x375c1e['count'];var _0x41e521=_0x5ed9dd?0x0:_0xe35ea[_0x9fd6('0x1f')];var _0x5cebe2=_0x5ed9dd?_0x375c1e[_0x9fd6('0x22')]:_0xe35ea[_0x9fd6('0x1f')]+_0xe35ea[_0x9fd6('0x21')];var _0x47ee61;if(_0x5cebe2>=_0x5e865a){_0x5cebe2=_0x5e865a;_0x47ee61=0xc8;}else{_0x47ee61=0xce;}_0x1ac3c4[_0x9fd6('0x1c')](_0x47ee61);return _0x1ac3c4[_0x9fd6('0x23')](_0x9fd6('0x24'),_0x41e521+'-'+_0x5cebe2+'/'+_0x5e865a)[_0x9fd6('0x1e')](_0x375c1e);}return null;};}function patchUpdates(_0xb9c54b){return function(_0x11283e){try{jsonpatch[_0x9fd6('0x25')](_0x11283e,_0xb9c54b,!![]);}catch(_0x6325f0){return BPromise[_0x9fd6('0x26')](_0x6325f0);}return _0x11283e[_0x9fd6('0x27')]();};}function saveUpdates(_0x3a81ba,_0x24412a){return function(_0x232d9e){if(_0x232d9e){return _0x232d9e[_0x9fd6('0x28')](_0x3a81ba)[_0x9fd6('0x29')](function(_0x5c85d4){return _0x5c85d4;});}return null;};}function removeEntity(_0xea3d56,_0x1254ab){return function(_0x5c59fa){if(_0x5c59fa){return _0x5c59fa[_0x9fd6('0x2a')]()[_0x9fd6('0x29')](function(){_0xea3d56[_0x9fd6('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5902ef,_0x51bca8){return function(_0x90d4c8){if(!_0x90d4c8){_0x5902ef[_0x9fd6('0x1b')](0x194);}return _0x90d4c8;};}function handleError(_0xb7c4b2,_0x52c57){_0x52c57=_0x52c57||0x1f4;return function(_0x40ef61){logger[_0x9fd6('0x2b')](_0x40ef61[_0x9fd6('0x2c')]);if(_0x40ef61[_0x9fd6('0x2d')]){delete _0x40ef61['name'];}_0xb7c4b2[_0x9fd6('0x1c')](_0x52c57)[_0x9fd6('0x2e')](_0x40ef61);};}exports[_0x9fd6('0x2f')]=function(_0x2a3105,_0x273a62){var _0x414d8c={},_0x37b002={},_0x1c5be0={'count':0x0,'rows':[]};var _0x10339c=_[_0x9fd6('0x30')](db[_0x9fd6('0x31')][_0x9fd6('0x32')],function(_0x3887eb){return{'name':_0x3887eb['fieldName'],'type':_0x3887eb['type'][_0x9fd6('0x33')]};});_0x37b002['model']=_['differenceBy'](_[_0x9fd6('0x30')](_0x10339c,_0x9fd6('0x2d')),[_0x9fd6('0x2d')]);_0x37b002[_0x9fd6('0x34')]=_[_0x9fd6('0x35')](_0x2a3105[_0x9fd6('0x34')]);_0x37b002['filters']=_['intersection'](_0x37b002[_0x9fd6('0x36')],_0x37b002[_0x9fd6('0x34')]);_0x414d8c['attributes']=_[_0x9fd6('0x37')](_0x37b002[_0x9fd6('0x36')],qs[_0x9fd6('0x38')](_0x2a3105[_0x9fd6('0x34')][_0x9fd6('0x38')]));_0x414d8c['attributes']=_0x414d8c['attributes'][_0x9fd6('0x39')]?_0x414d8c[_0x9fd6('0x3a')]:_0x37b002[_0x9fd6('0x36')];if(!_0x2a3105['query'][_0x9fd6('0x3b')](_0x9fd6('0x3c'))){_0x414d8c['limit']=qs[_0x9fd6('0x21')](_0x2a3105[_0x9fd6('0x34')]['limit']);_0x414d8c[_0x9fd6('0x1f')]=qs[_0x9fd6('0x1f')](_0x2a3105[_0x9fd6('0x34')][_0x9fd6('0x1f')]);}_0x414d8c[_0x9fd6('0x3d')]=qs[_0x9fd6('0x3e')](_0x2a3105[_0x9fd6('0x34')][_0x9fd6('0x3e')]);_0x414d8c[_0x9fd6('0x3f')]=qs[_0x9fd6('0x40')](_[_0x9fd6('0x41')](_0x2a3105[_0x9fd6('0x34')],_0x37b002[_0x9fd6('0x40')]),_0x10339c);if(_0x2a3105[_0x9fd6('0x34')][_0x9fd6('0x42')]){_0x414d8c[_0x9fd6('0x3f')]=_[_0x9fd6('0x43')](_0x414d8c[_0x9fd6('0x3f')],{'$or':_[_0x9fd6('0x30')](_0x10339c,function(_0x51475b){if(_0x51475b['type']!==_0x9fd6('0x44')){var _0x5a2dcb={};_0x5a2dcb[_0x51475b[_0x9fd6('0x2d')]]={'$like':'%'+_0x2a3105['query'][_0x9fd6('0x42')]+'%'};return _0x5a2dcb;}})});}_0x414d8c=_[_0x9fd6('0x43')]({},_0x414d8c,_0x2a3105[_0x9fd6('0x45')]);var _0x524567={'where':_0x414d8c['where']};return db[_0x9fd6('0x31')][_0x9fd6('0x22')](_0x524567)[_0x9fd6('0x29')](function(_0x482c04){_0x1c5be0['count']=_0x482c04;if(_0x2a3105[_0x9fd6('0x34')][_0x9fd6('0x46')]){_0x414d8c['include']=[{'all':!![]}];}return db[_0x9fd6('0x31')][_0x9fd6('0x47')](_0x414d8c);})[_0x9fd6('0x29')](function(_0x1de446){_0x1c5be0['rows']=_0x1de446;return _0x1c5be0;})['then'](respondWithFilteredResult(_0x273a62,_0x414d8c))[_0x9fd6('0x48')](handleError(_0x273a62,null));};exports[_0x9fd6('0x49')]=function(_0x268160,_0x15fab9){var _0x4b973e={'raw':!![],'where':{'id':_0x268160[_0x9fd6('0x4a')]['id']}},_0x423098={};_0x423098['model']=_[_0x9fd6('0x35')](db[_0x9fd6('0x31')][_0x9fd6('0x32')]);_0x423098['query']=_[_0x9fd6('0x35')](_0x268160[_0x9fd6('0x34')]);_0x423098[_0x9fd6('0x40')]=_[_0x9fd6('0x37')](_0x423098[_0x9fd6('0x36')],_0x423098[_0x9fd6('0x34')]);_0x4b973e[_0x9fd6('0x3a')]=_[_0x9fd6('0x37')](_0x423098[_0x9fd6('0x36')],qs['fields'](_0x268160[_0x9fd6('0x34')]['fields']));_0x4b973e[_0x9fd6('0x3a')]=_0x4b973e['attributes'][_0x9fd6('0x39')]?_0x4b973e[_0x9fd6('0x3a')]:_0x423098['model'];if(_0x268160['query'][_0x9fd6('0x46')]){_0x4b973e[_0x9fd6('0x4b')]=[{'all':!![]}];}_0x4b973e=_[_0x9fd6('0x43')]({},_0x4b973e,_0x268160[_0x9fd6('0x45')]);return db[_0x9fd6('0x31')][_0x9fd6('0x4c')](_0x4b973e)[_0x9fd6('0x29')](handleEntityNotFound(_0x15fab9,null))[_0x9fd6('0x29')](respondWithResult(_0x15fab9,null))['catch'](handleError(_0x15fab9,null));};exports[_0x9fd6('0x28')]=function(_0x25e773,_0x283aec){if(_0x25e773[_0x9fd6('0x4d')]['id']){delete _0x25e773['body']['id'];}return db[_0x9fd6('0x31')][_0x9fd6('0x4c')]({'where':{'id':_0x25e773['params']['id']}})[_0x9fd6('0x29')](handleEntityNotFound(_0x283aec,null))[_0x9fd6('0x29')](saveUpdates(_0x25e773['body'],null))[_0x9fd6('0x29')](respondWithResult(_0x283aec,null))[_0x9fd6('0x48')](handleError(_0x283aec,null));};exports['destroy']=function(_0x1e5ef4,_0x232776){return db[_0x9fd6('0x31')][_0x9fd6('0x4c')]({'where':{'id':_0x1e5ef4[_0x9fd6('0x4a')]['id']}})[_0x9fd6('0x29')](handleEntityNotFound(_0x232776,null))[_0x9fd6('0x29')](removeEntity(_0x232776,null))['catch'](handleError(_0x232776,null));};exports[_0x9fd6('0x4e')]=function(_0x468894,_0x56a3be){var _0x147da6;return db[_0x9fd6('0x4f')][_0x9fd6('0x50')](function(_0x45eab0){return db[_0x9fd6('0x31')][_0x9fd6('0x4e')](_0x468894[_0x9fd6('0x4d')],{'transaction':_0x45eab0})[_0x9fd6('0x29')](function(_0x34dc39){_0x147da6=_0x34dc39;var _0x103bce={'type':db[_0x9fd6('0x51')]['TEXT'],'transaction':_0x45eab0};switch(_0x468894[_0x9fd6('0x4d')]['type']){case _0x9fd6('0x52'):_0x103bce['type']=db[_0x9fd6('0x51')][_0x9fd6('0x53')];break;case _0x9fd6('0x54'):_0x103bce[_0x9fd6('0x55')]=db['Sequelize'][_0x9fd6('0x56')];break;case _0x9fd6('0x57'):_0x103bce[_0x9fd6('0x55')]=db[_0x9fd6('0x51')][_0x9fd6('0x58')];_0x103bce[_0x9fd6('0x59')]=![];break;default:}return db[_0x9fd6('0x4f')][_0x9fd6('0x5a')][_0x9fd6('0x5b')](_0x9fd6('0x5c'),util[_0x9fd6('0x5d')](_0x9fd6('0x5e'),_0x147da6['id']),_0x103bce);})['then'](function(){return _0x147da6;});})[_0x9fd6('0x29')](respondWithResult(_0x56a3be,0xc9))[_0x9fd6('0x48')](handleError(_0x56a3be,null));}; \ No newline at end of file diff --git a/server/api/cmCustomField/cmCustomField.model.js b/server/api/cmCustomField/cmCustomField.model.js new file mode 100644 index 0000000..c7e5670 --- /dev/null +++ b/server/api/cmCustomField/cmCustomField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2d6a=['path','rimraf','../../config/environment','./cmCustomField.attributes','define','CmCustomField','cm_custom_fields','../../config/logger','api','moment','request-promise'];(function(_0x10d3b1,_0x35db4d){var _0x15c8aa=function(_0x182f0a){while(--_0x182f0a){_0x10d3b1['push'](_0x10d3b1['shift']());}};_0x15c8aa(++_0x35db4d);}(_0x2d6a,0x10f));var _0xa2d6=function(_0x4f63b2,_0x3d1472){_0x4f63b2=_0x4f63b2-0x0;var _0x1a86d5=_0x2d6a[_0x4f63b2];return _0x1a86d5;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xa2d6('0x0'))(_0xa2d6('0x1'));var moment=require(_0xa2d6('0x2'));var BPromise=require('bluebird');var rp=require(_0xa2d6('0x3'));var fs=require('fs');var path=require(_0xa2d6('0x4'));var rimraf=require(_0xa2d6('0x5'));var config=require(_0xa2d6('0x6'));var attributes=require(_0xa2d6('0x7'));module['exports']=function(_0x2ab5ab,_0x4e47f8){return _0x2ab5ab[_0xa2d6('0x8')](_0xa2d6('0x9'),attributes,{'tableName':_0xa2d6('0xa'),'paranoid':!![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmCustomField/cmCustomField.rpc.js b/server/api/cmCustomField/cmCustomField.rpc.js new file mode 100644 index 0000000..29e5ee3 --- /dev/null +++ b/server/api/cmCustomField/cmCustomField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd820=['then','info','CmCustomField,\x20%s,\x20%s','request\x20sent','CmCustomField,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x4117af,_0x147e60){var _0x71c88=function(_0x513e29){while(--_0x513e29){_0x4117af['push'](_0x4117af['shift']());}};_0x71c88(++_0x147e60);}(_0xd820,0x18b));var _0x0d82=function(_0x240625,_0x5521aa){_0x240625=_0x240625-0x0;var _0x5d3a5d=_0xd820[_0x240625];return _0x5d3a5d;};'use strict';var _=require(_0x0d82('0x0'));var util=require('util');var moment=require(_0x0d82('0x1'));var BPromise=require(_0x0d82('0x2'));var rs=require(_0x0d82('0x3'));var fs=require('fs');var Redis=require(_0x0d82('0x4'));var db=require(_0x0d82('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x0d82('0x6'))(_0x0d82('0x7'));var config=require(_0x0d82('0x8'));var jayson=require(_0x0d82('0x9'));var client=jayson[_0x0d82('0xa')][_0x0d82('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5da97f,_0x14054a,_0x2a13f1){return new BPromise(function(_0x40b6fa,_0x30e5b0){return client[_0x0d82('0xc')](_0x5da97f,_0x2a13f1)[_0x0d82('0xd')](function(_0x372778){logger[_0x0d82('0xe')](_0x0d82('0xf'),_0x14054a,_0x0d82('0x10'));logger['debug'](_0x0d82('0x11'),_0x14054a,_0x0d82('0x10'),JSON[_0x0d82('0x12')](_0x372778));if(_0x372778['error']){if(_0x372778[_0x0d82('0x13')][_0x0d82('0x14')]===0x1f4){logger['error'](_0x0d82('0xf'),_0x14054a,_0x372778[_0x0d82('0x13')]['message']);return _0x30e5b0(_0x372778[_0x0d82('0x13')]['message']);}logger[_0x0d82('0x13')]('CmCustomField,\x20%s,\x20%s',_0x14054a,_0x372778[_0x0d82('0x13')][_0x0d82('0x15')]);return _0x40b6fa(_0x372778['error'][_0x0d82('0x15')]);}else{logger['info'](_0x0d82('0xf'),_0x14054a,_0x0d82('0x10'));_0x40b6fa(_0x372778[_0x0d82('0x16')][_0x0d82('0x15')]);}})[_0x0d82('0x17')](function(_0x9273de){logger[_0x0d82('0x13')](_0x0d82('0xf'),_0x14054a,_0x9273de);_0x30e5b0(_0x9273de);});});} \ No newline at end of file diff --git a/server/api/cmCustomField/index.js b/server/api/cmCustomField/index.js new file mode 100644 index 0000000..5715d4e --- /dev/null +++ b/server/api/cmCustomField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xecb2=['show','post','put','delete','destroy','exports','multer','connect-timeout','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./cmCustomField.controller','get','/:id','isAuthenticated'];(function(_0x36b098,_0x2003d5){var _0x333d3c=function(_0x336df3){while(--_0x336df3){_0x36b098['push'](_0x36b098['shift']());}};_0x333d3c(++_0x2003d5);}(_0xecb2,0xf6));var _0x2ecb=function(_0x5d5f5e,_0x3d8f31){_0x5d5f5e=_0x5d5f5e-0x0;var _0x5dd032=_0xecb2[_0x5d5f5e];return _0x5dd032;};'use strict';var multer=require(_0x2ecb('0x0'));var util=require('util');var path=require('path');var timeout=require(_0x2ecb('0x1'));var express=require('express');var router=express['Router']();var fs_extra=require(_0x2ecb('0x2'));var auth=require(_0x2ecb('0x3'));var interaction=require(_0x2ecb('0x4'));var config=require(_0x2ecb('0x5'));var controller=require(_0x2ecb('0x6'));router[_0x2ecb('0x7')]('/',auth['isAuthenticated'](),controller['index']);router['get'](_0x2ecb('0x8'),auth[_0x2ecb('0x9')](),controller[_0x2ecb('0xa')]);router[_0x2ecb('0xb')]('/',auth[_0x2ecb('0x9')](),controller['create']);router[_0x2ecb('0xc')](_0x2ecb('0x8'),auth[_0x2ecb('0x9')](),controller['update']);router[_0x2ecb('0xd')](_0x2ecb('0x8'),auth[_0x2ecb('0x9')](),controller[_0x2ecb('0xe')]);module[_0x2ecb('0xf')]=router; \ No newline at end of file diff --git a/server/api/cmHopper/cmHopper.attributes.js b/server/api/cmHopper/cmHopper.attributes.js new file mode 100644 index 0000000..86ff9df --- /dev/null +++ b/server/api/cmHopper/cmHopper.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4f26=['YYYY-MM-DD\x20HH:mm:ss','INTEGER','DATE','UNSIGNED','contactListQueue','moment','sequelize','STRING','BOOLEAN'];(function(_0xd9954b,_0x228faa){var _0x4f5c1b=function(_0x1b2ed1){while(--_0x1b2ed1){_0xd9954b['push'](_0xd9954b['shift']());}};_0x4f5c1b(++_0x228faa);}(_0x4f26,0x125));var _0x64f2=function(_0x546b2c,_0x30f8fa){_0x546b2c=_0x546b2c-0x0;var _0x4ae298=_0x4f26[_0x546b2c];return _0x4ae298;};'use strict';var moment=require(_0x64f2('0x0'));var Sequelize=require(_0x64f2('0x1'));module['exports']={'phone':{'type':Sequelize[_0x64f2('0x2')],'allowNull':![]},'active':{'type':Sequelize[_0x64f2('0x3')],'defaultValue':![]},'scheduledat':{'type':Sequelize['DATE'],'defaultValue':moment()['format'](_0x64f2('0x4'))},'countbusyretry':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'countcongestionretry':{'type':Sequelize[_0x64f2('0x5')],'defaultValue':0x0},'countnoanswerretry':{'type':Sequelize[_0x64f2('0x5')],'defaultValue':0x0},'callback':{'type':Sequelize[_0x64f2('0x3')],'defaultValue':![]},'callbackuniqueid':{'type':Sequelize['STRING'],'defaultValue':null},'callbackat':{'type':Sequelize[_0x64f2('0x6')]},'priority':{'type':Sequelize[_0x64f2('0x5')](0x2)[_0x64f2('0x7')],'defaultValue':0x2,'validate':{'min':0x0,'max':0x4}},'recallme':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'ContactId':{'type':Sequelize['INTEGER'],'unique':'contactListQueue'},'ListId':{'type':Sequelize[_0x64f2('0x5')],'unique':_0x64f2('0x8')},'UserId':{'type':Sequelize[_0x64f2('0x5')]},'VoiceQueueId':{'type':Sequelize[_0x64f2('0x5')],'unique':_0x64f2('0x8')},'CampaignId':{'type':Sequelize[_0x64f2('0x5')]},'countnosuchnumberretry':{'type':Sequelize[_0x64f2('0x5')],'defaultValue':0x0},'countdropretry':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'countabandonedretry':{'type':Sequelize[_0x64f2('0x5')],'defaultValue':0x0},'countmachineretry':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'countagentrejectretry':{'type':Sequelize[_0x64f2('0x5')],'defaultValue':0x0},'OrderBy':{'type':Sequelize[_0x64f2('0x5')],'allowNull':!![],'defaultValue':0x0},'dialTimezone':{'type':Sequelize[_0x64f2('0x2')]},'recallmeNotifiedDate':{'type':Sequelize[_0x64f2('0x6')],'allowNull':!![],'defaultValue':null}}; \ No newline at end of file diff --git a/server/api/cmHopper/cmHopper.controller.js b/server/api/cmHopper/cmHopper.controller.js new file mode 100644 index 0000000..cfdcccc --- /dev/null +++ b/server/api/cmHopper/cmHopper.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe0c3=['$contained','$any','attributes','model','fields','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','options','include','findAll','rows','catch','show','includeAll','find','create','body','params','describe','destroy','VoiceQueueId','CampaignId','VoiceQueue','Campaign','omit','dataValues','createdAt','updatedAt','state','statedesc','deleted','membername','user','UserId','deletedat','format','YYYY-MM-DD\x20HH:mm:ss','calleridnum','phone','campaigntype','ivr','CmContact','ContactId','lastName','isNil','firstName','calleridname','finally','CmHopperFinal','CmHopperAdditionalPhone','end','getPreview','getVoiceQueues','outbound','preview','dialOrderByScheduledAt','dialPreviewAutoRecallMe','transaction','direction','prev','isEmpty','hopperIds','priority','ASC','scheduledAt','DESC','sequelize','COALESCE(CmHopper.UserId,\x200)\x20ASC','COALESCE(CmHopper.UserId,\x200)\x20DESC','findOne','scheduledat','recallme','UPDATE','Contact','Company','CmList','List','Queue','dialActive','getPreviewRecall','LOCK','CmCompany','getOpenContacts','CmHopper,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','getTimezones','timezones','utcOffset','getTimezone','moment','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','status','offset','undefined','limit','count','set','Content-Range','json','update','then','sendStatus','error','stack','name','CmHopper','rawAttributes','type','map','query','keys','intersection','filters','concat','$or','$gt','$lt','$lte','$ne','$eq','$between','$notBetween','$in','$notIn','$notLike','$like','$overlap'];(function(_0x35dd73,_0xd88195){var _0x54c68e=function(_0x388e51){while(--_0x388e51){_0x35dd73['push'](_0x35dd73['shift']());}};_0x54c68e(++_0xd88195);}(_0xe0c3,0xea));var _0x3e0c=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xe0c3[_0x321bb2];return _0x9c12ed;};'use strict';var moment=require(_0x3e0c('0x0'));var _=require('lodash');var qs=require(_0x3e0c('0x1'));var logger=require(_0x3e0c('0x2'))(_0x3e0c('0x3'));var shared=require(_0x3e0c('0x4'));var db=require(_0x3e0c('0x5'))['db'];function respondWithResult(_0x410ec4,_0x31851c){_0x31851c=_0x31851c||0xc8;return function(_0x26c964){if(_0x26c964){return _0x410ec4[_0x3e0c('0x6')](_0x31851c)['json'](_0x26c964);}};}function respondWithFilteredResult(_0x530ebf,_0x163adf){return function(_0x1e339a){if(_0x1e339a){var _0x3f6607=typeof _0x163adf[_0x3e0c('0x7')]===_0x3e0c('0x8')&&typeof _0x163adf[_0x3e0c('0x9')]===_0x3e0c('0x8');var _0x448907=_0x1e339a[_0x3e0c('0xa')];var _0x35d56f=_0x3f6607?0x0:_0x163adf[_0x3e0c('0x7')];var _0x4f7e71=_0x3f6607?_0x1e339a['count']:_0x163adf[_0x3e0c('0x7')]+_0x163adf[_0x3e0c('0x9')];var _0x13ce3e;if(_0x4f7e71>=_0x448907){_0x4f7e71=_0x448907;_0x13ce3e=0xc8;}else{_0x13ce3e=0xce;}_0x530ebf[_0x3e0c('0x6')](_0x13ce3e);return _0x530ebf[_0x3e0c('0xb')](_0x3e0c('0xc'),_0x35d56f+'-'+_0x4f7e71+'/'+_0x448907)[_0x3e0c('0xd')](_0x1e339a);}return null;};}function saveUpdates(_0x5dc732,_0x38b416){return function(_0x491432){if(_0x491432){return _0x491432[_0x3e0c('0xe')](_0x5dc732)[_0x3e0c('0xf')](function(_0x5d0ab7){return _0x5d0ab7;});}return null;};}function handleEntityNotFound(_0x5f2654,_0x6d9c61){return function(_0x409b2c){if(!_0x409b2c){_0x5f2654[_0x3e0c('0x10')](0x194);}return _0x409b2c;};}function handleError(_0xea4ed,_0x15a269){_0x15a269=_0x15a269||0x1f4;return function(_0x24fcf9){logger[_0x3e0c('0x11')](_0x24fcf9[_0x3e0c('0x12')]);if(_0x24fcf9[_0x3e0c('0x13')]){delete _0x24fcf9[_0x3e0c('0x13')];}_0xea4ed[_0x3e0c('0x6')](_0x15a269)['send'](_0x24fcf9);};}exports['index']=function(_0x20db28,_0x216993){var _0x1b2e17={},_0x41b19f={},_0x108d4a={'count':0x0,'rows':[]};var _0x8825b7=_['map'](db[_0x3e0c('0x14')][_0x3e0c('0x15')],function(_0x95ce16){return{'name':_0x95ce16['fieldName'],'type':_0x95ce16[_0x3e0c('0x16')]['key']};});_0x41b19f['model']=_[_0x3e0c('0x17')](_0x8825b7,_0x3e0c('0x13'));_0x41b19f[_0x3e0c('0x18')]=_[_0x3e0c('0x19')](_0x20db28['query']);_0x41b19f['filters']=_[_0x3e0c('0x1a')](_0x41b19f['model'],_0x41b19f['query']);_0x41b19f[_0x3e0c('0x1b')]=_[_0x3e0c('0x1c')](_0x41b19f[_0x3e0c('0x1b')],['$and',_0x3e0c('0x1d'),_0x3e0c('0x1e'),'$gte',_0x3e0c('0x1f'),_0x3e0c('0x20'),_0x3e0c('0x21'),_0x3e0c('0x22'),'$not',_0x3e0c('0x23'),_0x3e0c('0x24'),_0x3e0c('0x25'),_0x3e0c('0x26'),'$like',_0x3e0c('0x27'),'$iLike','$notILike',_0x3e0c('0x28'),_0x3e0c('0x29'),'$contains',_0x3e0c('0x2a'),_0x3e0c('0x2b')]);_0x1b2e17[_0x3e0c('0x2c')]=_['intersection'](_0x41b19f[_0x3e0c('0x2d')],qs[_0x3e0c('0x2e')](_0x20db28['query'][_0x3e0c('0x2e')]));_0x1b2e17[_0x3e0c('0x2c')]=_0x1b2e17[_0x3e0c('0x2c')][_0x3e0c('0x2f')]?_0x1b2e17['attributes']:_0x41b19f[_0x3e0c('0x2d')];if(!_0x20db28[_0x3e0c('0x18')][_0x3e0c('0x30')]('nolimit')){_0x1b2e17[_0x3e0c('0x9')]=qs[_0x3e0c('0x9')](_0x20db28[_0x3e0c('0x18')]['limit']);_0x1b2e17[_0x3e0c('0x7')]=qs[_0x3e0c('0x7')](_0x20db28[_0x3e0c('0x18')][_0x3e0c('0x7')]);}_0x1b2e17[_0x3e0c('0x31')]=qs[_0x3e0c('0x32')](_0x20db28[_0x3e0c('0x18')][_0x3e0c('0x32')]);_0x1b2e17[_0x3e0c('0x33')]=qs[_0x3e0c('0x1b')](_[_0x3e0c('0x34')](_0x20db28[_0x3e0c('0x18')],_0x41b19f[_0x3e0c('0x1b')]),_0x8825b7);if(_0x20db28[_0x3e0c('0x18')]['filter']){_0x1b2e17[_0x3e0c('0x33')]=_[_0x3e0c('0x35')](_0x1b2e17[_0x3e0c('0x33')],{'$or':_[_0x3e0c('0x17')](_0x8825b7,function(_0xd89af9){if(_0xd89af9[_0x3e0c('0x16')]!==_0x3e0c('0x36')){var _0x2ef238={};_0x2ef238[_0xd89af9['name']]={'$like':'%'+_0x20db28['query'][_0x3e0c('0x37')]+'%'};return _0x2ef238;}})});}_0x1b2e17=_[_0x3e0c('0x35')]({},_0x1b2e17,_0x20db28[_0x3e0c('0x38')]);var _0x319cd4={'where':_0x1b2e17[_0x3e0c('0x33')]};return db[_0x3e0c('0x14')]['count'](_0x319cd4)[_0x3e0c('0xf')](function(_0x168784){_0x108d4a['count']=_0x168784;if(_0x20db28['query']['includeAll']){_0x1b2e17[_0x3e0c('0x39')]=[{'all':!![]}];}return db[_0x3e0c('0x14')][_0x3e0c('0x3a')](_0x1b2e17);})[_0x3e0c('0xf')](function(_0x320bf1){_0x108d4a[_0x3e0c('0x3b')]=_0x320bf1;return _0x108d4a;})[_0x3e0c('0xf')](respondWithFilteredResult(_0x216993,_0x1b2e17))[_0x3e0c('0x3c')](handleError(_0x216993,null));};exports[_0x3e0c('0x3d')]=function(_0xb38f09,_0x427207){var _0x20135d={'raw':!![],'where':{'id':_0xb38f09['params']['id']}},_0x4f0e6c={};_0x4f0e6c['model']=_[_0x3e0c('0x19')](db[_0x3e0c('0x14')]['rawAttributes']);_0x4f0e6c['query']=_[_0x3e0c('0x19')](_0xb38f09[_0x3e0c('0x18')]);_0x4f0e6c[_0x3e0c('0x1b')]=_[_0x3e0c('0x1a')](_0x4f0e6c['model'],_0x4f0e6c[_0x3e0c('0x18')]);_0x20135d[_0x3e0c('0x2c')]=_[_0x3e0c('0x1a')](_0x4f0e6c[_0x3e0c('0x2d')],qs[_0x3e0c('0x2e')](_0xb38f09['query'][_0x3e0c('0x2e')]));_0x20135d['attributes']=_0x20135d[_0x3e0c('0x2c')][_0x3e0c('0x2f')]?_0x20135d['attributes']:_0x4f0e6c['model'];if(_0xb38f09[_0x3e0c('0x18')][_0x3e0c('0x3e')]){_0x20135d['include']=[{'all':!![]}];}_0x20135d=_[_0x3e0c('0x35')]({},_0x20135d,_0xb38f09[_0x3e0c('0x38')]);return db[_0x3e0c('0x14')][_0x3e0c('0x3f')](_0x20135d)[_0x3e0c('0xf')](handleEntityNotFound(_0x427207,null))[_0x3e0c('0xf')](respondWithResult(_0x427207,null))['catch'](handleError(_0x427207,null));};exports[_0x3e0c('0x40')]=function(_0x20a85f,_0xec802a){return db[_0x3e0c('0x14')][_0x3e0c('0x40')](_0x20a85f[_0x3e0c('0x41')],{})['then'](respondWithResult(_0xec802a,0xc9))[_0x3e0c('0x3c')](handleError(_0xec802a,null));};exports[_0x3e0c('0xe')]=function(_0x323246,_0x563251){if(_0x323246[_0x3e0c('0x41')]['id']){delete _0x323246[_0x3e0c('0x41')]['id'];}return db['CmHopper'][_0x3e0c('0x3f')]({'where':{'id':_0x323246[_0x3e0c('0x42')]['id']}})[_0x3e0c('0xf')](handleEntityNotFound(_0x563251,null))['then'](saveUpdates(_0x323246[_0x3e0c('0x41')],null))[_0x3e0c('0xf')](respondWithResult(_0x563251,null))[_0x3e0c('0x3c')](handleError(_0x563251,null));};exports[_0x3e0c('0x43')]=function(_0x109078,_0x2e0a90){return db[_0x3e0c('0x14')][_0x3e0c('0x43')]()[_0x3e0c('0xf')](respondWithResult(_0x2e0a90,null))[_0x3e0c('0x3c')](handleError(_0x2e0a90,null));};exports[_0x3e0c('0x44')]=function(_0x4efbf2,_0x20c9df){var _0x58dac7;var _0x4b2062=_0x4efbf2[_0x3e0c('0x42')]['id'];return db['CmHopper'][_0x3e0c('0x3f')]({'where':{'id':_0x4efbf2[_0x3e0c('0x42')]['id']}})['then'](handleEntityNotFound(_0x20c9df,null))[_0x3e0c('0xf')](function(_0x14b718){if(_0x14b718){return _0x14b718['destroy']()[_0x3e0c('0xf')](function(_0x3e04c9){return _0x3e04c9;});}})[_0x3e0c('0xf')](function(_0x20b0bc){_0x58dac7=_0x20b0bc;if(_0x20b0bc){if(_0x20b0bc[_0x3e0c('0x45')]||_0x20b0bc[_0x3e0c('0x46')]){return db[_0x20b0bc[_0x3e0c('0x45')]?_0x3e0c('0x47'):_0x3e0c('0x48')][_0x3e0c('0x3f')]({'where':{'id':_0x20b0bc['VoiceQueueId']?_0x20b0bc[_0x3e0c('0x45')]:_0x20b0bc[_0x3e0c('0x46')]},'attributes':['id',_0x3e0c('0x13')],'raw':!![]});}}})[_0x3e0c('0xf')](function(_0x1a2cf2){var _0x14299c={};if(_0x1a2cf2){_[_0x3e0c('0x35')](_0x14299c,_[_0x3e0c('0x49')](_0x58dac7[_0x3e0c('0x4a')],[_0x3e0c('0x4b'),_0x3e0c('0x4c'),'id']));_0x14299c[_0x3e0c('0x4d')]=0x15;_0x14299c[_0x3e0c('0x4e')]=_0x3e0c('0x4f');_0x14299c['campaign']=_0x1a2cf2[_0x3e0c('0x13')];_0x14299c[_0x3e0c('0x50')]=_0x4efbf2[_0x3e0c('0x51')]['name'];_0x14299c[_0x3e0c('0x52')]=_0x4efbf2[_0x3e0c('0x51')]['id'];_0x14299c[_0x3e0c('0x4f')]=!![];_0x14299c[_0x3e0c('0x53')]=moment()[_0x3e0c('0x54')](_0x3e0c('0x55'));_0x14299c[_0x3e0c('0x56')]=_0x58dac7[_0x3e0c('0x57')];_0x14299c[_0x3e0c('0x58')]=_0x58dac7[_0x3e0c('0x45')]?'queue':_0x3e0c('0x59');return db[_0x3e0c('0x5a')]['find']({'where':{'id':_0x14299c[_0x3e0c('0x5b')]},'attributes':['firstName',_0x3e0c('0x5c')]})[_0x3e0c('0xf')](function(_0x28b2d5){if(!_[_0x3e0c('0x5d')](_0x20c9df)&&!_[_0x3e0c('0x5d')](_0x28b2d5[_0x3e0c('0x5e')])){_0x14299c[_0x3e0c('0x5f')]=_0x28b2d5[_0x3e0c('0x5e')];if(!_[_0x3e0c('0x5d')](_0x28b2d5[_0x3e0c('0x5c')])){_0x14299c[_0x3e0c('0x5f')]+='\x20'+_0x28b2d5[_0x3e0c('0x5c')];}}})[_0x3e0c('0x60')](function(){return db[_0x3e0c('0x61')][_0x3e0c('0x40')](_0x14299c);});}})[_0x3e0c('0xf')](function(_0x117e2f){return db[_0x3e0c('0x62')][_0x3e0c('0x44')]({'where':{'CmHopperId':_0x4b2062}});})[_0x3e0c('0xf')](function(){return _0x20c9df[_0x3e0c('0x6')](0xcc)[_0x3e0c('0x63')]();})[_0x3e0c('0x3c')](handleError(_0x20c9df,null));};exports[_0x3e0c('0x64')]=function(_0x2f6666,_0xcc965b){var _0x58aa5d=[];return db[_0x3e0c('0x5a')][_0x3e0c('0x43')]()[_0x3e0c('0xf')](function(_0x874b04){_0x58aa5d=_['keys'](_0x874b04);return _0x2f6666[_0x3e0c('0x51')][_0x3e0c('0x65')]({'where':{'type':_0x3e0c('0x66'),'dialActive':!![],'dialMethod':_0x3e0c('0x67')},'attributes':['id',_0x3e0c('0x68'),_0x3e0c('0x69')],'raw':!![]});})['then'](function(_0x3e1c8a){if(_0x3e1c8a&&_0x3e1c8a[_0x3e0c('0x2f')]){return db['sequelize'][_0x3e0c('0x6a')](function(_0x368b04){var _0x2b0eae={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x3e0c('0x54')](_0x3e0c('0x55'))},'VoiceQueueId':{'$in':_['map'](_0x3e1c8a,'id')},'$or':[{'UserId':null},{'UserId':_0x2f6666['user']['id']}]};var _0x1b57dd={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x3e1c8a)[_0x3e0c('0x37')](['dialPreviewAutoRecallMe',0x0])['map']('id')['value']()},'$or':[{'UserId':null},{'UserId':_0x2f6666[_0x3e0c('0x51')]['id']}]};var _0x274fcc={'$or':[_0x2b0eae,_0x1b57dd]};var _0x10e951=[];if(_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6b')]&&_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6b')]===_0x3e0c('0x6c')){if(!_[_0x3e0c('0x6d')](_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6e')])){_0x274fcc['id']={'$in':_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6e')]};}_0x10e951=[[_0x3e0c('0x6f'),_0x3e0c('0x70')],[_0x3e0c('0x71'),_0x3e1c8a[0x0][_0x3e0c('0x68')]==='ASC'?_0x3e0c('0x72'):_0x3e0c('0x70')],db[_0x3e0c('0x73')]['literal'](_0x3e0c('0x74')),['id',_0x3e0c('0x72')]];}else{if(!_[_0x3e0c('0x6d')](_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6e')])){_0x274fcc['id']={'$notIn':_0x2f6666[_0x3e0c('0x41')][_0x3e0c('0x6e')]};}_0x10e951=[[_0x3e0c('0x6f'),'DESC'],[_0x3e0c('0x71'),_0x3e1c8a[0x0][_0x3e0c('0x68')]],db[_0x3e0c('0x73')]['literal'](_0x3e0c('0x75')),['id',_0x3e0c('0x70')]];}return db['CmHopper'][_0x3e0c('0x76')]({'attributes':['id',_0x3e0c('0x77'),'phone',_0x3e0c('0x78')],'where':_0x274fcc,'order':_0x10e951,'transaction':_0x368b04,'lock':_0x368b04['LOCK'][_0x3e0c('0x79')],'include':[{'model':db[_0x3e0c('0x5a')],'as':_0x3e0c('0x7a'),'attributes':_0x58aa5d,'include':[{'model':db['CmCompany'],'as':_0x3e0c('0x7b'),'attributes':['id',_0x3e0c('0x13')]}]},{'model':db[_0x3e0c('0x7c')],'as':_0x3e0c('0x7d'),'attributes':['id','name']},{'model':db[_0x3e0c('0x47')],'as':_0x3e0c('0x7e'),'attributes':['id','name',_0x3e0c('0x7f')]}]})[_0x3e0c('0xf')](function(_0x13cca3){if(_0x13cca3){return _0x13cca3[_0x3e0c('0xe')]({'UserId':_0x2f6666['user']['id']},{'transaction':_0x368b04});}});});}})[_0x3e0c('0xf')](handleEntityNotFound(_0xcc965b,null))['then'](respondWithResult(_0xcc965b,null))[_0x3e0c('0x3c')](handleError(_0xcc965b,null));};exports[_0x3e0c('0x80')]=function(_0x32f787,_0x7a867b,_0xe2533b){var _0x1474f5=[];var _0x345108=_0x32f787[_0x3e0c('0x42')]['id'];var _0x518f39=_0x32f787['user']['id'];return db[_0x3e0c('0x5a')]['describe']()[_0x3e0c('0xf')](function(_0x573576){_0x1474f5=_[_0x3e0c('0x19')](_0x573576);return db['sequelize'][_0x3e0c('0x6a')](function(_0x2ad053){const _0x383387={'id':_0x345108};return db['CmHopper'][_0x3e0c('0x76')]({'attributes':['id',_0x3e0c('0x77'),_0x3e0c('0x78')],'where':_0x383387,'transaction':_0x2ad053,'lock':_0x2ad053[_0x3e0c('0x81')][_0x3e0c('0x79')],'include':[{'model':db[_0x3e0c('0x5a')],'as':_0x3e0c('0x7a'),'attributes':_0x1474f5,'include':[{'model':db[_0x3e0c('0x82')],'as':_0x3e0c('0x7b'),'attributes':['id','name']}]},{'model':db[_0x3e0c('0x7c')],'as':_0x3e0c('0x7d'),'attributes':['id',_0x3e0c('0x13')]},{'model':db[_0x3e0c('0x47')],'as':'Queue','attributes':['id',_0x3e0c('0x13'),_0x3e0c('0x7f')]}]})[_0x3e0c('0xf')](function(_0x234fae){if(_0x234fae){return _0x234fae['update']({'UserId':_0x518f39},{'transaction':_0x2ad053});}});});})[_0x3e0c('0xf')](handleEntityNotFound(_0x7a867b,null))[_0x3e0c('0xf')](respondWithResult(_0x7a867b,null))[_0x3e0c('0x3c')](handleError(_0x7a867b,null));};exports[_0x3e0c('0x83')]=function(_0x15fc4b,_0xed0325){return _0x15fc4b[_0x3e0c('0x51')][_0x3e0c('0x65')]({'where':{'type':_0x3e0c('0x66'),'dialActive':!![],'dialMethod':_0x3e0c('0x67')},'attributes':['id'],'raw':!![]})[_0x3e0c('0xf')](function(_0x2eec6a){if(_0x2eec6a&&_0x2eec6a[_0x3e0c('0x2f')]){return db[_0x3e0c('0x14')]['count']({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0x3e0c('0x54')](_0x3e0c('0x55'))},'VoiceQueueId':{'$in':_[_0x3e0c('0x17')](_0x2eec6a,'id')},'$or':[{'UserId':null},{'UserId':_0x15fc4b[_0x3e0c('0x51')]['id']}]}});}return 0x0;})[_0x3e0c('0xf')](function(_0x11b2d0){if(!_['isNil'](_0x11b2d0)&&_['isNumber'](_0x11b2d0)){return _0xed0325[_0x3e0c('0x6')](0xc8)['json']({'contacts':_0x11b2d0});}else{logger[_0x3e0c('0x11')](_0x3e0c('0x84'),_0x3e0c('0x83'),0x194,_0x3e0c('0x85'));_0xed0325[_0x3e0c('0x10')](0x194);}})[_0x3e0c('0x3c')](handleError(_0xed0325,null));};exports[_0x3e0c('0x86')]=function(_0x4cd2d0,_0x3283d0){var _0x1efb21=shared[_0x3e0c('0x87')];var _0x20dc9c=[];_[_0x3e0c('0x17')](_0x1efb21,function(_0x373b81){_0x20dc9c['push']({'id':_0x373b81[_0x3e0c('0x13')],'name':_0x373b81[_0x3e0c('0x13')],'utcOffset':_0x373b81[_0x3e0c('0x88')]});});return _0x3283d0[_0x3e0c('0x6')](0xc8)['json']({'tz':_0x20dc9c});};exports[_0x3e0c('0x89')]=function(_0x489b45,_0x5f56e9){var _0x181bd8=shared[_0x3e0c('0x87')];var _0xd83a3c={};if(!_[_0x3e0c('0x5d')](_0x181bd8[_0x489b45['body']['id']]))_0xd83a3c=_0x181bd8[_0x489b45['body']['id']];return _0x5f56e9[_0x3e0c('0x6')](0xc8)[_0x3e0c('0xd')](_0xd83a3c);}; \ No newline at end of file diff --git a/server/api/cmHopper/cmHopper.model.js b/server/api/cmHopper/cmHopper.model.js new file mode 100644 index 0000000..64e387d --- /dev/null +++ b/server/api/cmHopper/cmHopper.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x038b=['util','../../config/logger','api','bluebird','path','rimraf','./cmHopper.attributes','exports','define','CmHopper','cm_hopper','phone'];(function(_0x46becb,_0x7dd620){var _0x30bfe5=function(_0x36c3c1){while(--_0x36c3c1){_0x46becb['push'](_0x46becb['shift']());}};_0x30bfe5(++_0x7dd620);}(_0x038b,0x114));var _0xb038=function(_0x3cf314,_0x332fc3){_0x3cf314=_0x3cf314-0x0;var _0x34276f=_0x038b[_0x3cf314];return _0x34276f;};'use strict';var _=require('lodash');var util=require(_0xb038('0x0'));var logger=require(_0xb038('0x1'))(_0xb038('0x2'));var moment=require('moment');var BPromise=require(_0xb038('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xb038('0x4'));var rimraf=require(_0xb038('0x5'));var config=require('../../config/environment');var attributes=require(_0xb038('0x6'));module[_0xb038('0x7')]=function(_0x4fe092,_0x54e1e7){return _0x4fe092[_0xb038('0x8')](_0xb038('0x9'),attributes,{'tableName':_0xb038('0xa'),'paranoid':![],'indexes':[{'name':'scheduledat','fields':['scheduledat']},{'name':_0xb038('0xb'),'fields':[_0xb038('0xb')]},{'name':'priority','fields':['priority']}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmHopper/cmHopper.rpc.js b/server/api/cmHopper/cmHopper.rpc.js new file mode 100644 index 0000000..6e9f95b --- /dev/null +++ b/server/api/cmHopper/cmHopper.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc28b=['model','then','info','GetCmHopper','debug','stringify','catch','error','message','ShowCmHopper','CmHopper','find','CreateCmHopper','create','UpdateCmHopper','update','body','active','DestroyCmHopper','destroy','CmContact','sequelize','LOCK','UPDATE','keys','User','Agent','voicePause','length','UserId','push','includes','GetContactDialer\x20hopperId\x20[%s]\x20-\x20contactId\x20[%s]\x20-\x20active\x20status\x20[%s]','dataValues','ContactId','GetContactDialer','MoveContactManagedDialer','MoveContactManagedDialer\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]','CountReScheduled','COUNT','`scheduledat`\x20>=\x20','format','\x22%s\x22','\x20,\x201,\x20null','contactsRescheduled','transaction','order','GetContactRecallMe','GetCmHopperPreview','describe','Contact','GetContactByPhone','findOne','phone','dialTimezone','DESC','getContactByPhone','ResetActiveCalls','voiceQueueIds','interval','literal','NOW()\x20+\x20INTERVAL\x20','\x20MINUTE','name','List','CmHopperHandlePreviewRecallNotifications','lodash','util','moment','bluebird','../../mysqldb','../../config/logger','rpc','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x1997d2,_0x3ee494){var _0x1e3df7=function(_0x35ce26){while(--_0x35ce26){_0x1997d2['push'](_0x1997d2['shift']());}};_0x1e3df7(++_0x3ee494);}(_0xc28b,0x93));var _0xbc28=function(_0x1920f7,_0x13552f){_0x1920f7=_0x1920f7-0x0;var _0x5d2cb0=_0xc28b[_0x1920f7];return _0x5d2cb0;};'use strict';var _=require(_0xbc28('0x0'));var util=require(_0xbc28('0x1'));var moment=require(_0xbc28('0x2'));var BPromise=require(_0xbc28('0x3'));var db=require(_0xbc28('0x4'))['db'];var logger=require(_0xbc28('0x5'))(_0xbc28('0x6'));exports['GetCmHopper']=function(_0xb01412){var _0x1836ac=this;return new Promise(function(_0x16e184,_0x164901){return db['CmHopper'][_0xbc28('0x7')]({'raw':_0xb01412[_0xbc28('0x8')]?_0xb01412[_0xbc28('0x8')][_0xbc28('0x9')]===undefined?!![]:![]:!![],'where':_0xb01412[_0xbc28('0x8')]?_0xb01412[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':_0xb01412[_0xbc28('0x8')]?_0xb01412[_0xbc28('0x8')][_0xbc28('0xb')]||null:null,'limit':_0xb01412['options']?_0xb01412['options'][_0xbc28('0xc')]||null:null,'include':_0xb01412[_0xbc28('0x8')]?_0xb01412['options'][_0xbc28('0xd')]?_['map'](_0xb01412[_0xbc28('0x8')][_0xbc28('0xd')],function(_0x17b74d){return{'model':db[_0x17b74d['model']],'as':_0x17b74d['as'],'attributes':_0x17b74d[_0xbc28('0xb')],'include':_0x17b74d[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x17b74d[_0xbc28('0xd')],function(_0x2fcd4c){return{'model':db[_0x2fcd4c['model']],'as':_0x2fcd4c['as'],'attributes':_0x2fcd4c['attributes'],'include':_0x2fcd4c[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x2fcd4c[_0xbc28('0xd')],function(_0x32d5d9){return{'model':db[_0x32d5d9[_0xbc28('0xf')]],'as':_0x32d5d9['as'],'attributes':_0x32d5d9[_0xbc28('0xb')]};}):[]};}):[]};}):[]:[]})[_0xbc28('0x10')](function(_0xdbfa37){logger[_0xbc28('0x11')](_0xbc28('0x12'),_0xb01412);logger[_0xbc28('0x13')](_0xbc28('0x12'),_0xb01412,JSON[_0xbc28('0x14')](_0xdbfa37));_0x16e184(_0xdbfa37);})[_0xbc28('0x15')](function(_0xf22079){logger[_0xbc28('0x16')](_0xbc28('0x12'),_0xf22079[_0xbc28('0x17')],_0xb01412);_0x164901(_0x1836ac['error'](0x1f4,_0xf22079[_0xbc28('0x17')]));});});};exports[_0xbc28('0x18')]=function(_0x5e9125){var _0x336edf=this;return new Promise(function(_0x349e51,_0x38cc20){return db[_0xbc28('0x19')][_0xbc28('0x1a')]({'raw':_0x5e9125[_0xbc28('0x8')]?_0x5e9125['options'][_0xbc28('0x9')]===undefined?!![]:![]:!![],'where':_0x5e9125[_0xbc28('0x8')]?_0x5e9125[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':_0x5e9125[_0xbc28('0x8')]?_0x5e9125[_0xbc28('0x8')][_0xbc28('0xb')]||null:null,'include':_0x5e9125['options']?_0x5e9125['options']['include']?_[_0xbc28('0xe')](_0x5e9125[_0xbc28('0x8')]['include'],function(_0x57dde2){return{'model':db[_0x57dde2[_0xbc28('0xf')]],'as':_0x57dde2['as'],'attributes':_0x57dde2['attributes'],'include':_0x57dde2[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x57dde2[_0xbc28('0xd')],function(_0x5a1e7b){return{'model':db[_0x5a1e7b[_0xbc28('0xf')]],'as':_0x5a1e7b['as'],'attributes':_0x5a1e7b[_0xbc28('0xb')],'include':_0x5a1e7b[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x5a1e7b[_0xbc28('0xd')],function(_0x432892){return{'model':db[_0x432892[_0xbc28('0xf')]],'as':_0x432892['as'],'attributes':_0x432892[_0xbc28('0xb')]};}):[]};}):[]};}):[]:[]})[_0xbc28('0x10')](function(_0x129f12){logger[_0xbc28('0x11')](_0xbc28('0x18'),_0x5e9125);logger[_0xbc28('0x13')]('ShowCmHopper',_0x5e9125,JSON[_0xbc28('0x14')](_0x129f12));_0x349e51(_0x129f12);})[_0xbc28('0x15')](function(_0x4b9e90){logger['error'](_0xbc28('0x18'),_0x4b9e90['message'],_0x5e9125);_0x38cc20(_0x336edf[_0xbc28('0x16')](0x1f4,_0x4b9e90['message']));});});};exports[_0xbc28('0x1b')]=function(_0x145702){var _0x1c57b9=this;return new Promise(function(_0x5887af,_0x5dfd35){return db[_0xbc28('0x19')][_0xbc28('0x1c')](_0x145702['body'],{'raw':_0x145702[_0xbc28('0x8')]?_0x145702['options'][_0xbc28('0x9')]===undefined?!![]:![]:!![]})[_0xbc28('0x10')](function(_0x322376){logger['info'](_0xbc28('0x1b'),_0x145702);logger['debug']('CreateCmHopper',_0x145702,JSON[_0xbc28('0x14')](_0x322376));_0x5887af(_0x322376);})[_0xbc28('0x15')](function(_0x262267){logger[_0xbc28('0x16')](_0xbc28('0x1b'),_0x262267['message'],_0x145702);_0x5dfd35(_0x1c57b9[_0xbc28('0x16')](0x1f4,_0x262267[_0xbc28('0x17')]));});});};exports[_0xbc28('0x1d')]=function(_0x211cd2){var _0x391e41=this;return new Promise(function(_0x2fc05e,_0x3bad10){return db['CmHopper'][_0xbc28('0x1e')](_0x211cd2[_0xbc28('0x1f')],{'raw':_0x211cd2[_0xbc28('0x8')]?_0x211cd2[_0xbc28('0x8')][_0xbc28('0x9')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x211cd2[_0xbc28('0x8')]?_0x211cd2[_0xbc28('0x8')]['where']||null:null,'attributes':_0x211cd2[_0xbc28('0x8')]?_0x211cd2[_0xbc28('0x8')]['attributes']||null:null,'limit':_0x211cd2[_0xbc28('0x8')]?_0x211cd2['options'][_0xbc28('0xc')]||null:null})[_0xbc28('0x10')](function(_0x2f8ae3){logger['info'](_0xbc28('0x1d'),_0x211cd2);logger['info']('UpdateCmHopper\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]',JSON[_0xbc28('0x14')](_0x211cd2[_0xbc28('0x8')]['where']),_0x211cd2[_0xbc28('0x1f')][_0xbc28('0x20')]);logger[_0xbc28('0x13')](_0xbc28('0x1d'),_0x211cd2,JSON['stringify'](_0x2f8ae3));_0x2fc05e(_0x2f8ae3);})[_0xbc28('0x15')](function(_0x2f1693){logger[_0xbc28('0x16')](_0xbc28('0x1d'),_0x2f1693[_0xbc28('0x17')],_0x211cd2);_0x3bad10(_0x391e41[_0xbc28('0x16')](0x1f4,_0x2f1693['message']));});});};exports[_0xbc28('0x21')]=function(_0x825539){var _0x1958f8=this;return new Promise(function(_0x456361,_0x79581a){return db[_0xbc28('0x19')][_0xbc28('0x22')]({'where':_0x825539[_0xbc28('0x8')]?_0x825539[_0xbc28('0x8')][_0xbc28('0xa')]||null:null})[_0xbc28('0x10')](function(_0x132fe2){logger['info'](_0xbc28('0x21'),_0x825539);logger[_0xbc28('0x13')](_0xbc28('0x21'),_0x825539,JSON[_0xbc28('0x14')](_0x132fe2));_0x456361(_0x132fe2);})['catch'](function(_0x5c50f9){logger[_0xbc28('0x16')](_0xbc28('0x21'),_0x5c50f9[_0xbc28('0x17')],_0x825539);_0x79581a(_0x1958f8['error'](0x1f4,_0x5c50f9[_0xbc28('0x17')]));});});};exports['GetContactDialer']=function(_0x5033b9){var _0x5bea82=this;return new Promise(function(_0x5bedb3,_0x4dc3df){return db[_0xbc28('0x23')]['describe']()[_0xbc28('0x10')](function(_0x5455a3){return db[_0xbc28('0x24')]['transaction'](function(_0x2204d3){return db['CmHopper']['findAll']({'where':_0x5033b9[_0xbc28('0x8')]?_0x5033b9[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':_0x5033b9[_0xbc28('0x8')]?_0x5033b9[_0xbc28('0x8')][_0xbc28('0xb')]||null:null,'limit':_0x5033b9[_0xbc28('0x8')]?_0x5033b9[_0xbc28('0x8')][_0xbc28('0xc')]||null:null,'order':_0x5033b9[_0xbc28('0x8')]?_0x5033b9[_0xbc28('0x8')]['order']||null:null,'transaction':_0x2204d3,'lock':_0x2204d3[_0xbc28('0x25')][_0xbc28('0x26')],'include':[{'model':db[_0xbc28('0x23')],'as':'Contact','attributes':_[_0xbc28('0x27')](_0x5455a3)},{'model':db[_0xbc28('0x28')],'as':_0xbc28('0x29'),'attributes':['id','name',_0xbc28('0x2a')]}]})[_0xbc28('0x10')](function(_0x575004){var _0x537d34=[];var _0x3e8931=[];for(var _0x54dcb7=0x0;_0x54dcb7<_0x575004[_0xbc28('0x2b')];_0x54dcb7+=0x1){var _0x1d840b=_0x575004[_0x54dcb7][_0xbc28('0x2c')];if(_0x1d840b===null){_0x537d34[_0xbc28('0x2d')](_0x575004[_0x54dcb7][_0xbc28('0x1e')](_0x5033b9['body'],{'transaction':_0x2204d3}));}else if(!_0x3e8931[_0xbc28('0x2e')](_0x1d840b)){_0x3e8931[_0xbc28('0x2d')](_0x1d840b);_0x537d34[_0xbc28('0x2d')](_0x575004[_0x54dcb7][_0xbc28('0x1e')](_0x5033b9[_0xbc28('0x1f')],{'transaction':_0x2204d3}));}}return BPromise['all'](_0x537d34);});})[_0xbc28('0x10')](function(_0x224dc8){logger[_0xbc28('0x11')]('GetContactDialer',_0x5033b9);if(_0x224dc8['length']>0x0){logger['info'](_0xbc28('0x2f'),_0x224dc8[0x0][_0xbc28('0x30')]['id'],_0x224dc8[0x0][_0xbc28('0x30')][_0xbc28('0x31')],_0x224dc8[0x0][_0xbc28('0x30')][_0xbc28('0x20')]);}logger[_0xbc28('0x13')](_0xbc28('0x32'),_0x5033b9,JSON[_0xbc28('0x14')](_0x224dc8));_0x5bedb3(_0x224dc8);})[_0xbc28('0x15')](function(_0x10a1ae){logger[_0xbc28('0x16')](_0xbc28('0x32'),_0x10a1ae['message'],_0x5033b9);_0x4dc3df(_0x5bea82[_0xbc28('0x16')](0x1f4,_0x10a1ae[_0xbc28('0x17')]));});});});};exports[_0xbc28('0x33')]=function(_0x538f43){var _0x41dcf8=this;return new Promise(function(_0x279c18,_0x4955a1){return db['sequelize']['transaction'](function(_0xb322a3){return db['CmHopperFinal']['create'](_0x538f43[_0xbc28('0x1f')],{'raw':_0x538f43['options']?_0x538f43[_0xbc28('0x8')]['raw']===undefined?!![]:![]:!![],'transaction':_0xb322a3})[_0xbc28('0x10')](function(){logger[_0xbc28('0x11')](_0xbc28('0x34'),JSON['stringify'](_0x538f43[_0xbc28('0x8')][_0xbc28('0xa')]),_0x538f43[_0xbc28('0x8')][_0xbc28('0xa')]['active']);return db['CmHopper']['destroy']({'where':_0x538f43[_0xbc28('0x8')]?_0x538f43['options'][_0xbc28('0xa')]||null:null,'transaction':_0xb322a3});});})['then'](function(_0x52ceef){logger[_0xbc28('0x11')](_0xbc28('0x33'),_0x538f43);logger[_0xbc28('0x13')](_0xbc28('0x33'),_0x538f43,JSON['stringify'](_0x52ceef));_0x279c18(_0x52ceef);})[_0xbc28('0x15')](function(_0x5e4429){logger['error'](_0xbc28('0x33'),_0x5e4429['message'],_0x538f43);_0x4955a1(_0x41dcf8['error'](0x1f4,_0x5e4429[_0xbc28('0x17')]));});});};exports[_0xbc28('0x35')]=function(_0x10a30e){var _0x1a274b=this;return new Promise(function(_0x8b99b0,_0x29d250){return db[_0xbc28('0x19')]['findAll']({'raw':_0x10a30e['options']?_0x10a30e['options'][_0xbc28('0x9')]===undefined?!![]:![]:!![],'where':_0x10a30e['options']?_0x10a30e[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':[[db['sequelize']['fn'](_0xbc28('0x36'),db['sequelize']['fn']('IF',db[_0xbc28('0x24')]['literal'](_0xbc28('0x37')+util[_0xbc28('0x38')](_0xbc28('0x39'),moment()['format']('YYYY-MM-DD\x20HH:mm:ss'))+_0xbc28('0x3a')))),_0xbc28('0x3b')]]})['then'](function(_0x51abb1){logger[_0xbc28('0x11')](_0xbc28('0x35'),_0x10a30e);logger[_0xbc28('0x13')]('CountReScheduled',_0x10a30e,JSON[_0xbc28('0x14')](_0x51abb1));_0x8b99b0(_0x51abb1);})[_0xbc28('0x15')](function(_0x203293){logger[_0xbc28('0x16')](_0xbc28('0x35'),_0x203293[_0xbc28('0x17')],_0x10a30e);_0x29d250(_0x1a274b[_0xbc28('0x16')](0x1f4,_0x203293[_0xbc28('0x17')]));});});};exports['GetContactRecallMe']=function(_0x16ee06){var _0x5168e3=this;return new Promise(function(_0x19051e,_0x7e03e1){return db[_0xbc28('0x23')]['describe']()[_0xbc28('0x10')](function(){return db['sequelize'][_0xbc28('0x3c')](function(_0x14685a){return db[_0xbc28('0x19')]['findAll']({'where':_0x16ee06['options']?_0x16ee06[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':_0x16ee06[_0xbc28('0x8')]?_0x16ee06[_0xbc28('0x8')][_0xbc28('0xb')]||null:null,'limit':0x1,'order':_0x16ee06[_0xbc28('0x8')]?_0x16ee06[_0xbc28('0x8')][_0xbc28('0x3d')]||null:null,'group':db[_0xbc28('0x19')][_0xbc28('0x2c')],'transaction':_0x14685a,'lock':_0x14685a[_0xbc28('0x25')][_0xbc28('0x26')],'include':_0x16ee06[_0xbc28('0x8')]?_0x16ee06[_0xbc28('0x8')][_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x16ee06[_0xbc28('0x8')][_0xbc28('0xd')],function(_0x84188d){return{'model':db[_0x84188d['model']],'as':_0x84188d['as'],'attributes':_0x84188d['attributes'],'include':_0x84188d['include']?_[_0xbc28('0xe')](_0x84188d[_0xbc28('0xd')],function(_0xbb582c){return{'model':db[_0xbb582c['model']],'as':_0xbb582c['as'],'attributes':_0xbb582c[_0xbc28('0xb')],'include':_0xbb582c[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0xbb582c['include'],function(_0x331610){return{'model':db[_0x331610['model']],'as':_0x331610['as'],'attributes':_0x331610[_0xbc28('0xb')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2644a3){var _0x5013c6=[];for(var _0x667652=0x0;_0x667652<_0x2644a3[_0xbc28('0x2b')];_0x667652+=0x1){_0x5013c6[_0xbc28('0x2d')](_0x2644a3[_0x667652][_0xbc28('0x1e')](_0x16ee06[_0xbc28('0x1f')],{'transaction':_0x14685a}));}return BPromise['all'](_0x5013c6);});})[_0xbc28('0x10')](function(_0x4d4bb0){logger['info']('GetContactRecallMe',_0x16ee06);logger[_0xbc28('0x13')](_0xbc28('0x3e'),_0x16ee06,JSON[_0xbc28('0x14')](_0x4d4bb0));_0x19051e(_0x4d4bb0);})[_0xbc28('0x15')](function(_0x557d7f){logger['error']('GetContactRecallMe',_0x557d7f[_0xbc28('0x17')],_0x16ee06);_0x7e03e1(_0x5168e3[_0xbc28('0x16')](0x1f4,_0x557d7f[_0xbc28('0x17')]));});});});};exports[_0xbc28('0x3f')]=function(_0x351fc1){var _0x400e54=this;return new Promise(function(_0x4f2c60,_0x1909d0){db['CmContact'][_0xbc28('0x40')]()[_0xbc28('0x10')](function(_0xb84202){return db[_0xbc28('0x19')][_0xbc28('0x7')]({'raw':_0x351fc1['options']?_0x351fc1[_0xbc28('0x8')][_0xbc28('0x9')]===undefined?!![]:![]:!![],'where':_0x351fc1[_0xbc28('0x8')]?_0x351fc1[_0xbc28('0x8')][_0xbc28('0xa')]||null:null,'attributes':_0x351fc1[_0xbc28('0x8')]?_0x351fc1['options']['attributes']||null:null,'limit':_0x351fc1['options']?_0x351fc1[_0xbc28('0x8')][_0xbc28('0xc')]||null:null,'include':_0x351fc1[_0xbc28('0x8')]?_0x351fc1['options'][_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x351fc1['options'][_0xbc28('0xd')],function(_0x1c7a18){return{'model':db[_0x1c7a18['model']],'as':_0x1c7a18['as'],'attributes':_0x1c7a18['as']===_0xbc28('0x41')?_[_0xbc28('0x27')](_0xb84202):_0x1c7a18[_0xbc28('0xb')],'include':_0x1c7a18[_0xbc28('0xd')]?_[_0xbc28('0xe')](_0x1c7a18['include'],function(_0x2ed734){return{'model':db[_0x2ed734[_0xbc28('0xf')]],'as':_0x2ed734['as'],'attributes':_0x2ed734['attributes'],'include':_0x2ed734['include']?_[_0xbc28('0xe')](_0x2ed734[_0xbc28('0xd')],function(_0x58dadd){return{'model':db[_0x58dadd[_0xbc28('0xf')]],'as':_0x58dadd['as'],'attributes':_0x58dadd[_0xbc28('0xb')]};}):[]};}):[]};}):[]:[]})[_0xbc28('0x10')](function(_0x320fcc){logger['info'](_0xbc28('0x12'),_0x351fc1);logger[_0xbc28('0x13')]('GetCmHopper',_0x351fc1,JSON[_0xbc28('0x14')](_0x320fcc));_0x4f2c60(_0x320fcc);})['catch'](function(_0x9a37ad){logger[_0xbc28('0x16')](_0xbc28('0x12'),_0x9a37ad[_0xbc28('0x17')],_0x351fc1);_0x1909d0(_0x400e54[_0xbc28('0x16')](0x1f4,_0x9a37ad[_0xbc28('0x17')]));});});});};exports[_0xbc28('0x42')]=function(_0x4eb239){var _0x4c1cc1=this;return new Promise(function(_0x5017c0,_0x393bb5){return db[_0xbc28('0x23')][_0xbc28('0x43')]({'raw':!![],'where':{'phone':_0x4eb239[_0xbc28('0x8')][_0xbc28('0xa')][_0xbc28('0x44')]},'attributes':['id',_0xbc28('0x45')],'order':[['id',_0xbc28('0x46')]]})['then'](function(_0x1ad0b5){logger['info']('getContactByPhone',_0x4eb239);logger[_0xbc28('0x13')]('getContactByPhone',_0x4eb239,JSON[_0xbc28('0x14')](_0x1ad0b5));_0x5017c0(_0x1ad0b5);})[_0xbc28('0x15')](function(_0x177390){logger['error'](_0xbc28('0x47'),_0x177390[_0xbc28('0x17')],_0x4eb239);_0x393bb5(_0x4c1cc1[_0xbc28('0x16')](0x1f4,_0x177390[_0xbc28('0x17')]));});});};exports[_0xbc28('0x48')]=function(_0x2918f4){var _0x5c6d17=this;return new Promise(function(_0x3c3d83,_0x335bfd){return db[_0xbc28('0x24')][_0xbc28('0x3c')](function(_0x2cf53b){var _0x40c9fc=_0x2918f4[_0xbc28('0x8')]&&_0x2918f4[_0xbc28('0x8')][_0xbc28('0xa')]?_0x2918f4[_0xbc28('0x8')]['where']:{};return db[_0xbc28('0x19')][_0xbc28('0x1e')](_0x2918f4[_0xbc28('0x1f')],{'where':_0x40c9fc,'transaction':_0x2cf53b})[_0xbc28('0x10')](function(_0x23b249){logger[_0xbc28('0x11')](_0xbc28('0x48'),_0x2918f4);logger[_0xbc28('0x13')](_0xbc28('0x48'),_0x2918f4,JSON['stringify'](_0x23b249));_0x3c3d83(_0x23b249);})[_0xbc28('0x15')](function(_0x1aa2c7){logger[_0xbc28('0x16')]('ResetActiveCalls',_0x1aa2c7[_0xbc28('0x17')],_0x2918f4);_0x335bfd(_0x5c6d17[_0xbc28('0x16')](0x1f4,_0x1aa2c7[_0xbc28('0x17')]));});});});};exports['CmHopperHandlePreviewRecallNotifications']=function(_0x35cd18){var _0x20e0c9=this;var _0x4f169f=_0x35cd18[_0xbc28('0x1f')][_0xbc28('0xa')][_0xbc28('0x49')];var _0x2f47e8=_0x35cd18[_0xbc28('0x1f')][_0xbc28('0xa')][_0xbc28('0x4a')];var _0x5b7b60=_0x35cd18[_0xbc28('0x1f')][_0xbc28('0xa')]['availableAgentsIds'];return new Promise(function(_0x5c7327,_0x4c38d1){return db[_0xbc28('0x19')][_0xbc28('0x7')]({'where':{'voiceQueueId':{'$in':_0x4f169f},'recallme':0x1,'active':0x0,'recallmeNotifiedDate':{'$eq':null},'scheduledat':{'$and':{'$lte':db['sequelize'][_0xbc28('0x4b')](_0xbc28('0x4c')+_0x2f47e8+_0xbc28('0x4d')),'$gt':db[_0xbc28('0x24')][_0xbc28('0x4b')]('NOW()')}},'UserId':{'$in':_0x5b7b60}},'include':[{'model':db[_0xbc28('0x23')],'as':_0xbc28('0x41')},{'model':db[_0xbc28('0x28')],'as':_0xbc28('0x29'),'attributes':['id',_0xbc28('0x4e'),_0xbc28('0x2a')]},{'model':db['CmList'],'as':_0xbc28('0x4f')}]})[_0xbc28('0x10')](function(_0x34711f){if(_0x34711f[_0xbc28('0x2b')]>0x0){return db['sequelize']['transaction'](function(_0x19b635){return db['CmHopper'][_0xbc28('0x1e')]({'recallmeNotifiedDate':db[_0xbc28('0x24')][_0xbc28('0x4b')]('NOW()')},{'where':{'id':{'$in':_['map'](_0x34711f,'id')}},'transaction':_0x19b635})[_0xbc28('0x10')](function(){_0x5c7327(_0x34711f);})[_0xbc28('0x15')](function(_0x1c309e){logger[_0xbc28('0x16')](_0xbc28('0x50'),_0x1c309e[_0xbc28('0x17')],_0x35cd18);_0x4c38d1(_0x20e0c9[_0xbc28('0x16')](0x1f4,_0x1c309e[_0xbc28('0x17')]));});})[_0xbc28('0x15')](function(_0xbdfc5d){logger[_0xbc28('0x16')](_0xbc28('0x50'),_0xbdfc5d[_0xbc28('0x17')],_0x35cd18);_0x4c38d1(_0x20e0c9['error'](0x1f4,_0xbdfc5d['message']));});}else{_0x5c7327(_0x34711f);}});});}; \ No newline at end of file diff --git a/server/api/cmHopper/index.js b/server/api/cmHopper/index.js new file mode 100644 index 0000000..66b8b92 --- /dev/null +++ b/server/api/cmHopper/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaf11=['getPreviewRecall','post','create','/preview','getPreview','/timezone','getTimezone','put','destroy','exports','express','Router','../../components/auth/service','isAuthenticated','index','get','/describe','describe','getOpenContacts','/timezones','/:id','show','/:id/previewrecall'];(function(_0x55006e,_0x49c1f9){var _0x507a85=function(_0x549386){while(--_0x549386){_0x55006e['push'](_0x55006e['shift']());}};_0x507a85(++_0x49c1f9);}(_0xaf11,0x7d));var _0x1af1=function(_0x3152f0,_0x3cb3e0){_0x3152f0=_0x3152f0-0x0;var _0x3d0e49=_0xaf11[_0x3152f0];return _0x3d0e49;};'use strict';var express=require(_0x1af1('0x0'));var router=express[_0x1af1('0x1')]();var auth=require(_0x1af1('0x2'));var controller=require('./cmHopper.controller');router['get']('/',auth[_0x1af1('0x3')](),controller[_0x1af1('0x4')]);router[_0x1af1('0x5')](_0x1af1('0x6'),auth[_0x1af1('0x3')](),controller[_0x1af1('0x7')]);router[_0x1af1('0x5')]('/opencontacts',auth['isAuthenticated'](),controller[_0x1af1('0x8')]);router[_0x1af1('0x5')](_0x1af1('0x9'),auth[_0x1af1('0x3')](),controller['getTimezones']);router[_0x1af1('0x5')](_0x1af1('0xa'),auth[_0x1af1('0x3')](),controller[_0x1af1('0xb')]);router['get'](_0x1af1('0xc'),auth[_0x1af1('0x3')](),controller[_0x1af1('0xd')]);router[_0x1af1('0xe')]('/',auth['isAuthenticated'](),controller[_0x1af1('0xf')]);router[_0x1af1('0xe')](_0x1af1('0x10'),auth[_0x1af1('0x3')](),controller[_0x1af1('0x11')]);router[_0x1af1('0xe')](_0x1af1('0x12'),auth[_0x1af1('0x3')](),controller[_0x1af1('0x13')]);router[_0x1af1('0x14')](_0x1af1('0xa'),auth[_0x1af1('0x3')](),controller['update']);router['delete'](_0x1af1('0xa'),auth[_0x1af1('0x3')](),controller[_0x1af1('0x15')]);module[_0x1af1('0x16')]=router; \ No newline at end of file diff --git a/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.attributes.js b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.attributes.js new file mode 100644 index 0000000..4d11a03 --- /dev/null +++ b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1c31=['INTEGER','STRING','format','YYYY-MM-DD\x20HH:mm:ss','moment','sequelize','exports'];(function(_0x442661,_0x759662){var _0x529b61=function(_0x17c5a8){while(--_0x17c5a8){_0x442661['push'](_0x442661['shift']());}};_0x529b61(++_0x759662);}(_0x1c31,0x1ee));var _0x11c3=function(_0x502c7d,_0x2f1285){_0x502c7d=_0x502c7d-0x0;var _0x30b7ed=_0x1c31[_0x502c7d];return _0x30b7ed;};'use strict';var moment=require(_0x11c3('0x0'));var Sequelize=require(_0x11c3('0x1'));module[_0x11c3('0x2')]={'CmHopperId':{'type':Sequelize[_0x11c3('0x3')]},'phone':{'type':Sequelize[_0x11c3('0x4')],'allowNull':![]},'OrderBy':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'scheduledat':{'type':Sequelize['DATE'],'defaultValue':moment()[_0x11c3('0x5')](_0x11c3('0x6'))},'countbusyretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countcongestionretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countnoanswerretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countnosuchnumberretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countdropretry':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'countabandonedretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countmachineretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0},'countagentrejectretry':{'type':Sequelize[_0x11c3('0x3')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.controller.js b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.controller.js new file mode 100644 index 0000000..e640d62 --- /dev/null +++ b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7258=['apply','reject','save','update','then','destroy','CmHopperAdditionalPhones','UserProfileResource','error','stack','name','send','index','map','CmHopperAdditionalPhone','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','show','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','catch','params','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','undefined','limit','offset','count','json'];(function(_0x56930f,_0x978287){var _0x1e32ca=function(_0x1cdb91){while(--_0x1cdb91){_0x56930f['push'](_0x56930f['shift']());}};_0x1e32ca(++_0x978287);}(_0x7258,0xd7));var _0x8725=function(_0xae4dcb,_0x301073){_0xae4dcb=_0xae4dcb-0x0;var _0x5afccb=_0x7258[_0xae4dcb];return _0x5afccb;};'use strict';var emlformat=require(_0x8725('0x0'));var rimraf=require(_0x8725('0x1'));var zipdir=require(_0x8725('0x2'));var jsonpatch=require(_0x8725('0x3'));var rp=require('request-promise');var moment=require(_0x8725('0x4'));var BPromise=require(_0x8725('0x5'));var Mustache=require(_0x8725('0x6'));var util=require(_0x8725('0x7'));var path=require(_0x8725('0x8'));var sox=require(_0x8725('0x9'));var csv=require('to-csv');var ejs=require(_0x8725('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8725('0xb'));var squel=require('squel');var crypto=require(_0x8725('0xc'));var jsforce=require(_0x8725('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x8725('0xe'));var querystring=require(_0x8725('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x8725('0x10'));var qs=require(_0x8725('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8725('0x12'));var logger=require(_0x8725('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x8725('0x14'));var licenseUtil=require(_0x8725('0x15'));var db=require(_0x8725('0x16'))['db'];function respondWithStatusCode(_0x1caa49,_0x3577f9){_0x3577f9=_0x3577f9||0xcc;return function(_0x2aa5b6){if(_0x2aa5b6){return _0x1caa49[_0x8725('0x17')](_0x3577f9);}return _0x1caa49[_0x8725('0x18')](_0x3577f9)[_0x8725('0x19')]();};}function respondWithResult(_0x48d16f,_0x472c5d){_0x472c5d=_0x472c5d||0xc8;return function(_0xb57340){if(_0xb57340){return _0x48d16f[_0x8725('0x18')](_0x472c5d)['json'](_0xb57340);}};}function respondWithFilteredResult(_0x4715c7,_0x4cbf70){return function(_0x2d11de){if(_0x2d11de){var _0x1ce73f=typeof _0x4cbf70['offset']===_0x8725('0x1a')&&typeof _0x4cbf70[_0x8725('0x1b')]===_0x8725('0x1a');var _0x5621a4=_0x2d11de['count'];var _0x2e9e36=_0x1ce73f?0x0:_0x4cbf70[_0x8725('0x1c')];var _0x4ba158=_0x1ce73f?_0x2d11de[_0x8725('0x1d')]:_0x4cbf70[_0x8725('0x1c')]+_0x4cbf70['limit'];var _0x4f5b96;if(_0x4ba158>=_0x5621a4){_0x4ba158=_0x5621a4;_0x4f5b96=0xc8;}else{_0x4f5b96=0xce;}_0x4715c7[_0x8725('0x18')](_0x4f5b96);return _0x4715c7['set']('Content-Range',_0x2e9e36+'-'+_0x4ba158+'/'+_0x5621a4)[_0x8725('0x1e')](_0x2d11de);}return null;};}function patchUpdates(_0x2c7808){return function(_0x2c8363){try{jsonpatch[_0x8725('0x1f')](_0x2c8363,_0x2c7808,!![]);}catch(_0xdb673c){return BPromise[_0x8725('0x20')](_0xdb673c);}return _0x2c8363[_0x8725('0x21')]();};}function saveUpdates(_0xf6572f,_0x1acf21){return function(_0x3b6004){if(_0x3b6004){return _0x3b6004[_0x8725('0x22')](_0xf6572f)[_0x8725('0x23')](function(_0x311631){return _0x311631;});}return null;};}function removeEntity(_0x2ae6a5,_0x3535f5){return function(_0x83deeb){if(_0x83deeb){return _0x83deeb[_0x8725('0x24')]()[_0x8725('0x23')](function(){var _0x555c26=_0x83deeb['get']({'plain':!![]});var _0x58496e=_0x8725('0x25');return db[_0x8725('0x26')][_0x8725('0x24')]({'where':{'type':_0x58496e,'resourceId':_0x555c26['id']}})[_0x8725('0x23')](function(){return _0x83deeb;});})[_0x8725('0x23')](function(){_0x2ae6a5['status'](0xcc)[_0x8725('0x19')]();});}};}function handleEntityNotFound(_0x50c24f,_0x19b273){return function(_0x619813){if(!_0x619813){_0x50c24f[_0x8725('0x17')](0x194);}return _0x619813;};}function handleError(_0x548c7d,_0x2bcc3a){_0x2bcc3a=_0x2bcc3a||0x1f4;return function(_0x3cca66){logger[_0x8725('0x27')](_0x3cca66[_0x8725('0x28')]);if(_0x3cca66['name']){delete _0x3cca66[_0x8725('0x29')];}_0x548c7d['status'](_0x2bcc3a)[_0x8725('0x2a')](_0x3cca66);};}exports[_0x8725('0x2b')]=function(_0x4861d5,_0x14468a){var _0x5c0d17={},_0x3f3dab={},_0x42772a={'count':0x0,'rows':[]};var _0xe3f73=_[_0x8725('0x2c')](db[_0x8725('0x2d')][_0x8725('0x2e')],function(_0xd1158f){return{'name':_0xd1158f[_0x8725('0x2f')],'type':_0xd1158f[_0x8725('0x30')]['key']};});_0x3f3dab[_0x8725('0x31')]=_[_0x8725('0x2c')](_0xe3f73,_0x8725('0x29'));_0x3f3dab[_0x8725('0x32')]=_[_0x8725('0x33')](_0x4861d5[_0x8725('0x32')]);_0x3f3dab[_0x8725('0x34')]=_[_0x8725('0x35')](_0x3f3dab[_0x8725('0x31')],_0x3f3dab[_0x8725('0x32')]);_0x5c0d17[_0x8725('0x36')]=_[_0x8725('0x35')](_0x3f3dab[_0x8725('0x31')],qs['fields'](_0x4861d5['query'][_0x8725('0x37')]));_0x5c0d17[_0x8725('0x36')]=_0x5c0d17[_0x8725('0x36')][_0x8725('0x38')]?_0x5c0d17[_0x8725('0x36')]:_0x3f3dab[_0x8725('0x31')];if(!_0x4861d5[_0x8725('0x32')][_0x8725('0x39')](_0x8725('0x3a'))){_0x5c0d17['limit']=qs['limit'](_0x4861d5[_0x8725('0x32')]['limit']);_0x5c0d17[_0x8725('0x1c')]=qs['offset'](_0x4861d5[_0x8725('0x32')]['offset']);}_0x5c0d17[_0x8725('0x3b')]=qs[_0x8725('0x3c')](_0x4861d5[_0x8725('0x32')][_0x8725('0x3c')]);_0x5c0d17[_0x8725('0x3d')]=qs[_0x8725('0x34')](_[_0x8725('0x3e')](_0x4861d5['query'],_0x3f3dab[_0x8725('0x34')]),_0xe3f73);if(_0x4861d5[_0x8725('0x32')][_0x8725('0x3f')]){_0x5c0d17['where']=_[_0x8725('0x40')](_0x5c0d17[_0x8725('0x3d')],{'$or':_[_0x8725('0x2c')](_0xe3f73,function(_0xca0b1){if(_0xca0b1[_0x8725('0x30')]!=='VIRTUAL'){var _0x270e02={};_0x270e02[_0xca0b1[_0x8725('0x29')]]={'$like':'%'+_0x4861d5['query']['filter']+'%'};return _0x270e02;}})});}_0x5c0d17=_[_0x8725('0x40')]({},_0x5c0d17,_0x4861d5[_0x8725('0x41')]);var _0x11befd={'where':_0x5c0d17[_0x8725('0x3d')]};return db[_0x8725('0x2d')][_0x8725('0x1d')](_0x11befd)[_0x8725('0x23')](function(_0x5dee10){_0x42772a['count']=_0x5dee10;if(_0x4861d5[_0x8725('0x32')][_0x8725('0x42')]){_0x5c0d17[_0x8725('0x43')]=[{'all':!![]}];}return db[_0x8725('0x2d')][_0x8725('0x44')](_0x5c0d17);})[_0x8725('0x23')](function(_0x2a860b){_0x42772a[_0x8725('0x45')]=_0x2a860b;return _0x42772a;})[_0x8725('0x23')](respondWithFilteredResult(_0x14468a,_0x5c0d17))['catch'](handleError(_0x14468a,null));};exports[_0x8725('0x46')]=function(_0x2c2562,_0xdb4f81){var _0x1f9e34={'raw':!![],'where':{'id':_0x2c2562['params']['id']}},_0x5b8b2a={};_0x5b8b2a[_0x8725('0x31')]=_['keys'](db['CmHopperAdditionalPhone'][_0x8725('0x2e')]);_0x5b8b2a['query']=_['keys'](_0x2c2562[_0x8725('0x32')]);_0x5b8b2a['filters']=_['intersection'](_0x5b8b2a['model'],_0x5b8b2a[_0x8725('0x32')]);_0x1f9e34[_0x8725('0x36')]=_[_0x8725('0x35')](_0x5b8b2a[_0x8725('0x31')],qs[_0x8725('0x37')](_0x2c2562[_0x8725('0x32')][_0x8725('0x37')]));_0x1f9e34[_0x8725('0x36')]=_0x1f9e34[_0x8725('0x36')]['length']?_0x1f9e34[_0x8725('0x36')]:_0x5b8b2a['model'];if(_0x2c2562[_0x8725('0x32')][_0x8725('0x42')]){_0x1f9e34[_0x8725('0x43')]=[{'all':!![]}];}_0x1f9e34=_[_0x8725('0x40')]({},_0x1f9e34,_0x2c2562[_0x8725('0x41')]);return db[_0x8725('0x2d')][_0x8725('0x47')](_0x1f9e34)['then'](handleEntityNotFound(_0xdb4f81,null))[_0x8725('0x23')](respondWithResult(_0xdb4f81,null))['catch'](handleError(_0xdb4f81,null));};exports[_0x8725('0x48')]=function(_0x483d40,_0x122561){return db[_0x8725('0x2d')][_0x8725('0x48')](_0x483d40[_0x8725('0x49')],{})[_0x8725('0x23')](function(_0x141b4c){var _0xcad5ac=_0x483d40[_0x8725('0x4a')][_0x8725('0x4b')]({'plain':!![]});if(!_0xcad5ac)throw new Error(_0x8725('0x4c'));if(_0xcad5ac[_0x8725('0x4d')]===_0x8725('0x4a')){var _0x5936a1=_0x141b4c[_0x8725('0x4b')]({'plain':!![]});var _0x18998f='CmHopperAdditionalPhones';return db[_0x8725('0x4e')]['find']({'where':{'name':_0x18998f,'userProfileId':_0xcad5ac['userProfileId']},'raw':!![]})[_0x8725('0x23')](function(_0x2fb20b){if(_0x2fb20b&&_0x2fb20b[_0x8725('0x4f')]===0x0){return db['UserProfileResource'][_0x8725('0x48')]({'name':_0x5936a1[_0x8725('0x29')],'resourceId':_0x5936a1['id'],'type':_0x2fb20b['name'],'sectionId':_0x2fb20b['id']},{})[_0x8725('0x23')](function(){return _0x141b4c;});}else{return _0x141b4c;}})[_0x8725('0x50')](function(_0x3b2ba9){logger[_0x8725('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3b2ba9);throw _0x3b2ba9;});}return _0x141b4c;})[_0x8725('0x23')](respondWithResult(_0x122561,0xc9))[_0x8725('0x50')](handleError(_0x122561,null));};exports['update']=function(_0x543469,_0x2883e6){if(_0x543469[_0x8725('0x49')]['id']){delete _0x543469[_0x8725('0x49')]['id'];}return db[_0x8725('0x2d')][_0x8725('0x47')]({'where':{'id':_0x543469[_0x8725('0x51')]['id']}})['then'](handleEntityNotFound(_0x2883e6,null))['then'](saveUpdates(_0x543469[_0x8725('0x49')],null))[_0x8725('0x23')](respondWithResult(_0x2883e6,null))[_0x8725('0x50')](handleError(_0x2883e6,null));};exports['destroy']=function(_0x4a82cc,_0x8f14c3){return db[_0x8725('0x2d')][_0x8725('0x47')]({'where':{'id':_0x4a82cc[_0x8725('0x51')]['id']}})[_0x8725('0x23')](handleEntityNotFound(_0x8f14c3,null))[_0x8725('0x23')](removeEntity(_0x8f14c3,null))[_0x8725('0x50')](handleError(_0x8f14c3,null));}; \ No newline at end of file diff --git a/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.model.js b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.model.js new file mode 100644 index 0000000..0c02572 --- /dev/null +++ b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x072c=['cm_hopper_additional_phones','lodash','api','moment','bluebird','request-promise','path','./cmHopperAdditionalPhone.attributes','define','CmHopperAdditionalPhone'];(function(_0x2d6c9c,_0x1ad5b0){var _0x157313=function(_0x584070){while(--_0x584070){_0x2d6c9c['push'](_0x2d6c9c['shift']());}};_0x157313(++_0x1ad5b0);}(_0x072c,0x10f));var _0xc072=function(_0xe18a3a,_0x405850){_0xe18a3a=_0xe18a3a-0x0;var _0x2d01d1=_0x072c[_0xe18a3a];return _0x2d01d1;};'use strict';var _=require(_0xc072('0x0'));var util=require('util');var logger=require('../../config/logger')(_0xc072('0x1'));var moment=require(_0xc072('0x2'));var BPromise=require(_0xc072('0x3'));var rp=require(_0xc072('0x4'));var fs=require('fs');var path=require(_0xc072('0x5'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0xc072('0x6'));module['exports']=function(_0x852f18,_0x2fdd9a){return _0x852f18[_0xc072('0x7')](_0xc072('0x8'),attributes,{'tableName':_0xc072('0x9'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.rpc.js b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.rpc.js new file mode 100644 index 0000000..f44ae75 --- /dev/null +++ b/server/api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbef1=['IncrementPreviewCounters','field','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','request','then','info','CmHopperAdditionalPhone,\x20%s,\x20%s','request\x20sent','debug','CmHopperAdditionalPhone,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VerifyAdditionalPhones','CmHopper','findOne','ListId','body','VoiceQueueId','CampaignId','CmHopperAdditionalPhone','OrderBy','ASC','countcongestionretry','countnoanswerretry','countnosuchnumberretry','countdropretry','countabandonedretry','countmachineretry','countagentrejectretry','entity','dialGlobalMaxRetry','countbusyretry','catch','SwapAdditionalPhones','ContactId','duration','waitTime','isNil','scheduledat','minutes','add','phone','createdAt','updatedAt','transaction','update','activateAdditionalPhone'];(function(_0x13b8f3,_0x442821){var _0x1a6d06=function(_0x5126f2){while(--_0x5126f2){_0x13b8f3['push'](_0x13b8f3['shift']());}};_0x1a6d06(++_0x442821);}(_0xbef1,0x78));var _0x1bef=function(_0x109f4d,_0x39dabd){_0x109f4d=_0x109f4d-0x0;var _0x541706=_0xbef1[_0x109f4d];return _0x541706;};'use strict';var _=require(_0x1bef('0x0'));var util=require('util');var moment=require(_0x1bef('0x1'));var BPromise=require(_0x1bef('0x2'));var rs=require(_0x1bef('0x3'));var fs=require('fs');var Redis=require(_0x1bef('0x4'));var db=require(_0x1bef('0x5'))['db'];var utils=require(_0x1bef('0x6'));var logger=require(_0x1bef('0x7'))(_0x1bef('0x8'));var config=require(_0x1bef('0x9'));var jayson=require(_0x1bef('0xa'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2e54bf,_0x484355,_0x224fc5){return new BPromise(function(_0x491c49,_0x348de9){return client[_0x1bef('0xb')](_0x2e54bf,_0x224fc5)[_0x1bef('0xc')](function(_0x3a59fb){logger[_0x1bef('0xd')](_0x1bef('0xe'),_0x484355,_0x1bef('0xf'));logger[_0x1bef('0x10')](_0x1bef('0x11'),_0x484355,'request\x20sent',JSON[_0x1bef('0x12')](_0x3a59fb));if(_0x3a59fb[_0x1bef('0x13')]){if(_0x3a59fb[_0x1bef('0x13')][_0x1bef('0x14')]===0x1f4){logger[_0x1bef('0x13')]('CmHopperAdditionalPhone,\x20%s,\x20%s',_0x484355,_0x3a59fb['error']['message']);return _0x348de9(_0x3a59fb[_0x1bef('0x13')]['message']);}logger[_0x1bef('0x13')](_0x1bef('0xe'),_0x484355,_0x3a59fb['error'][_0x1bef('0x15')]);return _0x491c49(_0x3a59fb[_0x1bef('0x13')][_0x1bef('0x15')]);}else{logger[_0x1bef('0xd')](_0x1bef('0xe'),_0x484355,_0x1bef('0xf'));_0x491c49(_0x3a59fb['result']['message']);}})['catch'](function(_0x434db3){logger[_0x1bef('0x13')](_0x1bef('0xe'),_0x484355,_0x434db3);_0x348de9(_0x434db3);});});}exports[_0x1bef('0x16')]=function(_0x185585){var _0xfc4686=this;return new Promise(function(_0x3fde6c,_0x521e66){return db[_0x1bef('0x17')][_0x1bef('0x18')]({'raw':!![],'where':{'ContactId':_0x185585['body']['ContactId'],'ListId':_0x185585['body'][_0x1bef('0x19')],'VoiceQueueId':_0x185585[_0x1bef('0x1a')][_0x1bef('0x1b')]===undefined?null:_0x185585['body']['VoiceQueueId'],'CampaignId':_0x185585[_0x1bef('0x1a')][_0x1bef('0x1c')]===undefined?null:_0x185585[_0x1bef('0x1a')]['CampaignId']}})[_0x1bef('0xc')](function(_0x5960fb){if(_0x5960fb!=null){return db[_0x1bef('0x1d')][_0x1bef('0x18')]({'raw':!![],'where':{'CmHopperId':_0x5960fb['id'],'OrderBy':{'$gt':_0x5960fb[_0x1bef('0x1e')]}},'order':[[_0x1bef('0x1e'),_0x1bef('0x1f')]]})[_0x1bef('0xc')](function(_0x1d7dd0){var _0x2d642f=0x0;if(_0x1d7dd0){if(_0x1d7dd0['countbusyretry']+_0x1d7dd0[_0x1bef('0x20')]+_0x1d7dd0[_0x1bef('0x21')]+_0x1d7dd0[_0x1bef('0x22')]+_0x1d7dd0[_0x1bef('0x23')]+_0x1d7dd0[_0x1bef('0x24')]+_0x1d7dd0[_0x1bef('0x25')]+_0x1d7dd0[_0x1bef('0x26')]<_0x185585[_0x1bef('0x27')][_0x1bef('0x28')])_0x2d642f=0x1;_0x3fde6c({'additional':_0x2d642f});}else{return db[_0x1bef('0x1d')][_0x1bef('0x18')]({'raw':!![],'where':{'CmHopperId':_0x5960fb['id']},'order':[['OrderBy','ASC']]})[_0x1bef('0xc')](function(_0x56a6ff){var _0x47d995=0x0;if(_0x56a6ff){if(_0x56a6ff[_0x1bef('0x29')]+_0x56a6ff['countcongestionretry']+_0x56a6ff[_0x1bef('0x21')]+_0x56a6ff['countnosuchnumberretry']+_0x56a6ff[_0x1bef('0x23')]+_0x56a6ff[_0x1bef('0x24')]+_0x56a6ff[_0x1bef('0x25')]+_0x56a6ff[_0x1bef('0x26')]<_0x185585[_0x1bef('0x27')][_0x1bef('0x28')])_0x47d995=0x1;_0x3fde6c({'additional':_0x47d995});}else{_0x3fde6c({'additional':0x0});}})[_0x1bef('0x2a')](function(_0x15cd15){logger[_0x1bef('0x13')](_0x1bef('0x16'),_0x15cd15[_0x1bef('0x15')]);_0x521e66(_0xfc4686[_0x1bef('0x13')](0x1f4,_0x15cd15[_0x1bef('0x15')]));});}})[_0x1bef('0x2a')](function(_0x47e6dc){logger[_0x1bef('0x13')](_0x1bef('0x16'),_0x47e6dc['message']);_0x521e66(_0xfc4686[_0x1bef('0x13')](0x1f4,_0x47e6dc['message']));});}else _0x3fde6c({'additional':0x0});});});};exports[_0x1bef('0x2b')]=function(_0x26d810){var _0x56f0fa=this;return new Promise(function(_0x19fa9d,_0x3764a0){return db[_0x1bef('0x17')][_0x1bef('0x18')]({'raw':!![],'where':{'ContactId':_0x26d810[_0x1bef('0x1a')][_0x1bef('0x2c')],'ListId':_0x26d810['body'][_0x1bef('0x19')],'VoiceQueueId':_0x26d810[_0x1bef('0x1a')][_0x1bef('0x1b')]===undefined?null:_0x26d810[_0x1bef('0x1a')][_0x1bef('0x1b')],'CampaignId':_0x26d810[_0x1bef('0x1a')][_0x1bef('0x1c')]===undefined?null:_0x26d810['body'][_0x1bef('0x1c')]}})[_0x1bef('0xc')](function(_0xef510a){if(_0xef510a!=null){return db[_0x1bef('0x1d')][_0x1bef('0x18')]({'raw':!![],'where':{'CmHopperId':_0xef510a['id'],'OrderBy':{'$gte':_0xef510a[_0x1bef('0x1e')]}},'order':[[_0x1bef('0x1e'),_0x1bef('0x1f')]]})[_0x1bef('0xc')](function(_0x5c8512){if(_0x5c8512)return activateAdditionalPhone(_0xef510a,_0x26d810[_0x1bef('0x1a')],_0x5c8512,_0x26d810[_0x1bef('0x2d')],_0x26d810['waitTime'])[_0x1bef('0xc')](function(_0x178c81){_0x19fa9d(_0x178c81);});else{return db[_0x1bef('0x1d')][_0x1bef('0x18')]({'raw':!![],'where':{'CmHopperId':_0xef510a['id']},'order':[['OrderBy',_0x1bef('0x1f')]]})[_0x1bef('0xc')](function(_0x3c2eb5){if(_0x3c2eb5)return activateAdditionalPhone(_0xef510a,_0x26d810[_0x1bef('0x1a')],_0x3c2eb5,_0x26d810[_0x1bef('0x2d')],_0x26d810[_0x1bef('0x2e')])['then'](function(_0x45e5b7){_0x19fa9d(_0x45e5b7);});else{_0x19fa9d({'id':_0xef510a['id'],'phone':''});}})['catch'](function(_0x3fb28c){logger[_0x1bef('0x13')](_0x1bef('0x16'),_0x3fb28c[_0x1bef('0x15')]);_0x3764a0(_0x56f0fa['error'](0x1f4,_0x3fb28c['message']));});}})['catch'](function(_0x17865d){logger[_0x1bef('0x13')]('VerifyAdditionalPhones',_0x17865d[_0x1bef('0x15')]);_0x3764a0(_0x56f0fa['error'](0x1f4,_0x17865d[_0x1bef('0x15')]));});}else _0x19fa9d(0x1);});});};function activateAdditionalPhone(_0x2ed5b4,_0xe24bc,_0x342203,_0x55859e,_0x46efe4){return new Promise(function(_0x3b50bd,_0x666a61){var _0x4c240d;if(_[_0x1bef('0x2f')](_0x342203[_0x1bef('0x30')])){_0x342203[_0x1bef('0x30')]=moment();}if(moment()>moment(_0x342203[_0x1bef('0x30')])){_0x4c240d=moment()['add'](_0x46efe4||0x3,_0x1bef('0x31'));}else{if(_0x342203[_0x1bef('0x1e')]==0x0){_0x4c240d=moment(_0x342203[_0x1bef('0x30')]);}else{_0x4c240d=moment()[_0x1bef('0x32')](_0x46efe4||0x3,'minutes');}}if(_[_0x1bef('0x2f')](_0x4c240d)){_0x4c240d=moment()[_0x1bef('0x32')](_0x46efe4||0x3,_0x1bef('0x31'));}var _0x514d4a={'phone':_0x2ed5b4[_0x1bef('0x33')],'active':0x0,'OrderBy':_[_0x1bef('0x2f')](_0x2ed5b4[_0x1bef('0x1e')])?0x0:_0x2ed5b4[_0x1bef('0x1e')],'scheduledat':moment()[_0x1bef('0x32')](_0x55859e||0x1,_0x1bef('0x31')),'countbusyretry':_0xe24bc['countbusyretry'],'countcongestionretry':_0xe24bc['countcongestionretry'],'countnoanswerretry':_0xe24bc['countnoanswerretry'],'countnosuchnumberretry':_0xe24bc['countnosuchnumberretry'],'countdropretry':_0xe24bc[_0x1bef('0x23')],'countabandonedretry':_0xe24bc['countabandonedretry'],'countmachineretry':_0xe24bc[_0x1bef('0x25')],'countagentrejectretry':_0xe24bc['countagentrejectretry'],'createdAt':_0xe24bc[_0x1bef('0x34')],'updatedAt':_0xe24bc['updatedAt']};var _0x584ecc={'CmHopperId':_0x2ed5b4['id'],'phone':_0x342203[_0x1bef('0x33')],'active':0x0,'OrderBy':_['isNil'](_0x342203[_0x1bef('0x1e')])?0x0:_0x342203[_0x1bef('0x1e')],'scheduledat':_0x4c240d,'countbusyretry':_0x342203[_0x1bef('0x29')],'countcongestionretry':_0x342203[_0x1bef('0x20')],'countnoanswerretry':_0x342203[_0x1bef('0x21')],'countnosuchnumberretry':_0x342203[_0x1bef('0x22')],'countdropretry':_0x342203['countdropretry'],'countabandonedretry':_0x342203['countabandonedretry'],'countmachineretry':_0x342203[_0x1bef('0x25')],'countagentrejectretry':_0x342203[_0x1bef('0x26')],'createdAt':_0x342203[_0x1bef('0x34')],'updatedAt':_0x342203[_0x1bef('0x35')]};return db['sequelize'][_0x1bef('0x36')](function(_0x1daac0){return db[_0x1bef('0x1d')][_0x1bef('0x37')](_0x514d4a,{'where':{'id':_0x342203['id']}},{'transaction':_0x1daac0})[_0x1bef('0xc')](function(){return db[_0x1bef('0x17')][_0x1bef('0x37')](_0x584ecc,{'where':{'id':_0x2ed5b4['id']}},{'transaction':_0x1daac0});});})[_0x1bef('0xc')](function(_0x1faaae){_0x3b50bd({'id':_0x2ed5b4['id'],'phone':_0x342203[_0x1bef('0x33')]});})['catch'](function(_0x6a8daf){logger[_0x1bef('0x13')](_0x1bef('0x38'),_0x6a8daf[_0x1bef('0x15')]);_0x666a61({'error':_0x6a8daf[_0x1bef('0x15')]});});});}exports[_0x1bef('0x39')]=function(_0x4c25dc){var _0x3bbb78=this;return new Promise(function(_0x31153b,_0x2c1b92){return db[_0x1bef('0x17')][_0x1bef('0x37')](_0x4c25dc[_0x1bef('0x1a')][_0x1bef('0x3a')],{'where':{'id':_0x4c25dc[_0x1bef('0x1a')]['id']}})[_0x1bef('0xc')](function(_0x4f4574){_0x31153b(_0x4f4574);})[_0x1bef('0x2a')](function(_0x3bc96a){logger[_0x1bef('0x13')](_0x1bef('0x39'),_0x3bc96a['message']);_0x2c1b92(_0x3bbb78[_0x1bef('0x13')](0x1f4,_0x3bc96a['message']));});});}; \ No newline at end of file diff --git a/server/api/cmHopperAdditionalPhone/index.js b/server/api/cmHopperAdditionalPhone/index.js new file mode 100644 index 0000000..d13629a --- /dev/null +++ b/server/api/cmHopperAdditionalPhone/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x55f4=['create','put','delete','util','path','connect-timeout','Router','fs-extra','./cmHopperAdditionalPhone.controller','get','isAuthenticated','/:id','show','post'];(function(_0x5cead4,_0x95c854){var _0x25c561=function(_0x564dec){while(--_0x564dec){_0x5cead4['push'](_0x5cead4['shift']());}};_0x25c561(++_0x95c854);}(_0x55f4,0x129));var _0x455f=function(_0x2e01e6,_0x53731d){_0x2e01e6=_0x2e01e6-0x0;var _0x3f00dd=_0x55f4[_0x2e01e6];return _0x3f00dd;};'use strict';var multer=require('multer');var util=require(_0x455f('0x0'));var path=require(_0x455f('0x1'));var timeout=require(_0x455f('0x2'));var express=require('express');var router=express[_0x455f('0x3')]();var fs_extra=require(_0x455f('0x4'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x455f('0x5'));router[_0x455f('0x6')]('/',auth[_0x455f('0x7')](),controller['index']);router['get'](_0x455f('0x8'),auth[_0x455f('0x7')](),controller[_0x455f('0x9')]);router[_0x455f('0xa')]('/',auth['isAuthenticated'](),controller[_0x455f('0xb')]);router[_0x455f('0xc')](_0x455f('0x8'),auth[_0x455f('0x7')](),controller['update']);router[_0x455f('0xd')](_0x455f('0x8'),auth[_0x455f('0x7')](),controller['destroy']);module['exports']=router; \ No newline at end of file diff --git a/server/api/cmHopperBlack/cmHopperBlack.attributes.js b/server/api/cmHopperBlack/cmHopperBlack.attributes.js new file mode 100644 index 0000000..07e0e61 --- /dev/null +++ b/server/api/cmHopperBlack/cmHopperBlack.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3b1c=['sequelize','exports','STRING','contactListQueue','INTEGER','moment'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x3b1c,0xe9));var _0xc3b1=function(_0x5d3de6,_0x2dfe87){_0x5d3de6=_0x5d3de6-0x0;var _0x55b331=_0x3b1c[_0x5d3de6];return _0x55b331;};'use strict';var moment=require(_0xc3b1('0x0'));var Sequelize=require(_0xc3b1('0x1'));module[_0xc3b1('0x2')]={'phone':{'type':Sequelize[_0xc3b1('0x3')],'allowNull':![]},'ContactId':{'type':Sequelize['INTEGER'],'unique':_0xc3b1('0x4')},'ListId':{'type':Sequelize[_0xc3b1('0x5')],'unique':'contactListQueue'},'VoiceQueueId':{'type':Sequelize[_0xc3b1('0x5')],'unique':_0xc3b1('0x4')}}; \ No newline at end of file diff --git a/server/api/cmHopperBlack/cmHopperBlack.controller.js b/server/api/cmHopperBlack/cmHopperBlack.controller.js new file mode 100644 index 0000000..e145807 --- /dev/null +++ b/server/api/cmHopperBlack/cmHopperBlack.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8c48=['Content-Range','apply','reject','save','update','error','stack','name','send','index','map','rawAttributes','type','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','CmHopperBlack','then','includeAll','findAll','rows','show','model','filters','include','options','find','catch','body','params','destroy','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set'];(function(_0x45411c,_0x424a3a){var _0x61af2d=function(_0x1ccadf){while(--_0x1ccadf){_0x45411c['push'](_0x45411c['shift']());}};_0x61af2d(++_0x424a3a);}(_0x8c48,0x7b));var _0x88c4=function(_0x28ad5b,_0x18078e){_0x28ad5b=_0x28ad5b-0x0;var _0x56f9b3=_0x8c48[_0x28ad5b];return _0x56f9b3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x88c4('0x0'));var zipdir=require(_0x88c4('0x1'));var jsonpatch=require(_0x88c4('0x2'));var rp=require(_0x88c4('0x3'));var moment=require(_0x88c4('0x4'));var BPromise=require(_0x88c4('0x5'));var Mustache=require(_0x88c4('0x6'));var util=require(_0x88c4('0x7'));var path=require('path');var sox=require(_0x88c4('0x8'));var csv=require(_0x88c4('0x9'));var ejs=require(_0x88c4('0xa'));var fs=require('fs');var fs_extra=require(_0x88c4('0xb'));var _=require(_0x88c4('0xc'));var squel=require(_0x88c4('0xd'));var crypto=require('crypto');var jsforce=require(_0x88c4('0xe'));var deskjs=require(_0x88c4('0xf'));var toCsv=require(_0x88c4('0x9'));var querystring=require('querystring');var Papa=require(_0x88c4('0x10'));var Redis=require(_0x88c4('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x88c4('0x12'));var as=require(_0x88c4('0x13'));var hardwareService=require(_0x88c4('0x14'));var logger=require(_0x88c4('0x15'))(_0x88c4('0x16'));var utils=require(_0x88c4('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x88c4('0x18'));var db=require(_0x88c4('0x19'))['db'];function respondWithStatusCode(_0x1dc86c,_0x12e161){_0x12e161=_0x12e161||0xcc;return function(_0x5cf947){if(_0x5cf947){return _0x1dc86c[_0x88c4('0x1a')](_0x12e161);}return _0x1dc86c[_0x88c4('0x1b')](_0x12e161)[_0x88c4('0x1c')]();};}function respondWithResult(_0x3df3d3,_0x1c6677){_0x1c6677=_0x1c6677||0xc8;return function(_0x1076ca){if(_0x1076ca){return _0x3df3d3[_0x88c4('0x1b')](_0x1c6677)[_0x88c4('0x1d')](_0x1076ca);}};}function respondWithFilteredResult(_0x5ecd46,_0x105ac7){return function(_0x9d58cf){if(_0x9d58cf){var _0x2318ed=typeof _0x105ac7[_0x88c4('0x1e')]===_0x88c4('0x1f')&&typeof _0x105ac7['limit']==='undefined';var _0x2fbe46=_0x9d58cf[_0x88c4('0x20')];var _0x9d9511=_0x2318ed?0x0:_0x105ac7['offset'];var _0x796366=_0x2318ed?_0x9d58cf[_0x88c4('0x20')]:_0x105ac7[_0x88c4('0x1e')]+_0x105ac7[_0x88c4('0x21')];var _0x30049c;if(_0x796366>=_0x2fbe46){_0x796366=_0x2fbe46;_0x30049c=0xc8;}else{_0x30049c=0xce;}_0x5ecd46['status'](_0x30049c);return _0x5ecd46[_0x88c4('0x22')](_0x88c4('0x23'),_0x9d9511+'-'+_0x796366+'/'+_0x2fbe46)[_0x88c4('0x1d')](_0x9d58cf);}return null;};}function patchUpdates(_0x2738d3){return function(_0x3e7639){try{jsonpatch[_0x88c4('0x24')](_0x3e7639,_0x2738d3,!![]);}catch(_0x789cd){return BPromise[_0x88c4('0x25')](_0x789cd);}return _0x3e7639[_0x88c4('0x26')]();};}function saveUpdates(_0x5a573a,_0x2b0b86){return function(_0x47f072){if(_0x47f072){return _0x47f072[_0x88c4('0x27')](_0x5a573a)['then'](function(_0x32e35c){return _0x32e35c;});}return null;};}function removeEntity(_0x252143,_0x2e9324){return function(_0x5bc0b2){if(_0x5bc0b2){return _0x5bc0b2['destroy']()['then'](function(){_0x252143[_0x88c4('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x647e76,_0xbb2c87){return function(_0x123724){if(!_0x123724){_0x647e76[_0x88c4('0x1a')](0x194);}return _0x123724;};}function handleError(_0x524fd1,_0x37e81a){_0x37e81a=_0x37e81a||0x1f4;return function(_0x1a9f52){logger[_0x88c4('0x28')](_0x1a9f52[_0x88c4('0x29')]);if(_0x1a9f52[_0x88c4('0x2a')]){delete _0x1a9f52[_0x88c4('0x2a')];}_0x524fd1[_0x88c4('0x1b')](_0x37e81a)[_0x88c4('0x2b')](_0x1a9f52);};}exports[_0x88c4('0x2c')]=function(_0x3df699,_0x5cd194){var _0x26a979={},_0x5331a7={},_0xa356cd={'count':0x0,'rows':[]};var _0x35c11f=_[_0x88c4('0x2d')](db['CmHopperBlack'][_0x88c4('0x2e')],function(_0x1f9b9b){return{'name':_0x1f9b9b['fieldName'],'type':_0x1f9b9b[_0x88c4('0x2f')]['key']};});_0x5331a7['model']=_[_0x88c4('0x2d')](_0x35c11f,_0x88c4('0x2a'));_0x5331a7['query']=_[_0x88c4('0x30')](_0x3df699[_0x88c4('0x31')]);_0x5331a7['filters']=_[_0x88c4('0x32')](_0x5331a7['model'],_0x5331a7[_0x88c4('0x31')]);_0x26a979[_0x88c4('0x33')]=_[_0x88c4('0x32')](_0x5331a7['model'],qs[_0x88c4('0x34')](_0x3df699['query'][_0x88c4('0x34')]));_0x26a979[_0x88c4('0x33')]=_0x26a979[_0x88c4('0x33')][_0x88c4('0x35')]?_0x26a979[_0x88c4('0x33')]:_0x5331a7['model'];if(!_0x3df699[_0x88c4('0x31')][_0x88c4('0x36')](_0x88c4('0x37'))){_0x26a979['limit']=qs[_0x88c4('0x21')](_0x3df699[_0x88c4('0x31')][_0x88c4('0x21')]);_0x26a979[_0x88c4('0x1e')]=qs[_0x88c4('0x1e')](_0x3df699[_0x88c4('0x31')][_0x88c4('0x1e')]);}_0x26a979[_0x88c4('0x38')]=qs[_0x88c4('0x39')](_0x3df699['query'][_0x88c4('0x39')]);_0x26a979[_0x88c4('0x3a')]=qs['filters'](_[_0x88c4('0x3b')](_0x3df699[_0x88c4('0x31')],_0x5331a7['filters']),_0x35c11f);if(_0x3df699[_0x88c4('0x31')][_0x88c4('0x3c')]){_0x26a979['where']=_['merge'](_0x26a979[_0x88c4('0x3a')],{'$or':_[_0x88c4('0x2d')](_0x35c11f,function(_0x4cca19){if(_0x4cca19[_0x88c4('0x2f')]!==_0x88c4('0x3d')){var _0xba9273={};_0xba9273[_0x4cca19['name']]={'$like':'%'+_0x3df699['query'][_0x88c4('0x3c')]+'%'};return _0xba9273;}})});}_0x26a979=_[_0x88c4('0x3e')]({},_0x26a979,_0x3df699['options']);var _0x252ca1={'where':_0x26a979['where']};return db[_0x88c4('0x3f')][_0x88c4('0x20')](_0x252ca1)[_0x88c4('0x40')](function(_0x1f6810){_0xa356cd[_0x88c4('0x20')]=_0x1f6810;if(_0x3df699[_0x88c4('0x31')][_0x88c4('0x41')]){_0x26a979['include']=[{'all':!![]}];}return db['CmHopperBlack'][_0x88c4('0x42')](_0x26a979);})[_0x88c4('0x40')](function(_0x518bb6){_0xa356cd[_0x88c4('0x43')]=_0x518bb6;return _0xa356cd;})['then'](respondWithFilteredResult(_0x5cd194,_0x26a979))['catch'](handleError(_0x5cd194,null));};exports[_0x88c4('0x44')]=function(_0x17795a,_0x1798e1){var _0x26b2ad={'raw':!![],'where':{'id':_0x17795a['params']['id']}},_0x5306ec={};_0x5306ec[_0x88c4('0x45')]=_[_0x88c4('0x30')](db[_0x88c4('0x3f')]['rawAttributes']);_0x5306ec['query']=_['keys'](_0x17795a['query']);_0x5306ec[_0x88c4('0x46')]=_[_0x88c4('0x32')](_0x5306ec[_0x88c4('0x45')],_0x5306ec[_0x88c4('0x31')]);_0x26b2ad[_0x88c4('0x33')]=_[_0x88c4('0x32')](_0x5306ec['model'],qs[_0x88c4('0x34')](_0x17795a[_0x88c4('0x31')][_0x88c4('0x34')]));_0x26b2ad[_0x88c4('0x33')]=_0x26b2ad[_0x88c4('0x33')]['length']?_0x26b2ad[_0x88c4('0x33')]:_0x5306ec[_0x88c4('0x45')];if(_0x17795a[_0x88c4('0x31')][_0x88c4('0x41')]){_0x26b2ad[_0x88c4('0x47')]=[{'all':!![]}];}_0x26b2ad=_[_0x88c4('0x3e')]({},_0x26b2ad,_0x17795a[_0x88c4('0x48')]);return db[_0x88c4('0x3f')][_0x88c4('0x49')](_0x26b2ad)[_0x88c4('0x40')](handleEntityNotFound(_0x1798e1,null))[_0x88c4('0x40')](respondWithResult(_0x1798e1,null))[_0x88c4('0x4a')](handleError(_0x1798e1,null));};exports[_0x88c4('0x27')]=function(_0x1b46ad,_0x4d9cb0){if(_0x1b46ad[_0x88c4('0x4b')]['id']){delete _0x1b46ad[_0x88c4('0x4b')]['id'];}return db[_0x88c4('0x3f')][_0x88c4('0x49')]({'where':{'id':_0x1b46ad[_0x88c4('0x4c')]['id']}})[_0x88c4('0x40')](handleEntityNotFound(_0x4d9cb0,null))[_0x88c4('0x40')](saveUpdates(_0x1b46ad[_0x88c4('0x4b')],null))[_0x88c4('0x40')](respondWithResult(_0x4d9cb0,null))[_0x88c4('0x4a')](handleError(_0x4d9cb0,null));};exports[_0x88c4('0x4d')]=function(_0x5c7299,_0xa2b1e9){return db['CmHopperBlack']['find']({'where':{'id':_0x5c7299[_0x88c4('0x4c')]['id']}})[_0x88c4('0x40')](handleEntityNotFound(_0xa2b1e9,null))['then'](removeEntity(_0xa2b1e9,null))[_0x88c4('0x4a')](handleError(_0xa2b1e9,null));};exports[_0x88c4('0x4e')]=function(_0x1e3587,_0x463e5c){return db['CmHopperBlack'][_0x88c4('0x4e')]()[_0x88c4('0x40')](respondWithResult(_0x463e5c,null))[_0x88c4('0x4a')](handleError(_0x463e5c,null));}; \ No newline at end of file diff --git a/server/api/cmHopperBlack/cmHopperBlack.model.js b/server/api/cmHopperBlack/cmHopperBlack.model.js new file mode 100644 index 0000000..ca31190 --- /dev/null +++ b/server/api/cmHopperBlack/cmHopperBlack.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9643=['../../config/logger','api','bluebird','path','rimraf','../../config/environment','./cmHopperBlack.attributes','exports','define','cm_hopper_black','lodash','util'];(function(_0x3fbc36,_0x4f3451){var _0xed45c6=function(_0x486713){while(--_0x486713){_0x3fbc36['push'](_0x3fbc36['shift']());}};_0xed45c6(++_0x4f3451);}(_0x9643,0x8e));var _0x3964=function(_0xcdcdf,_0x3c71b2){_0xcdcdf=_0xcdcdf-0x0;var _0x193b2a=_0x9643[_0xcdcdf];return _0x193b2a;};'use strict';var _=require(_0x3964('0x0'));var util=require(_0x3964('0x1'));var logger=require(_0x3964('0x2'))(_0x3964('0x3'));var moment=require('moment');var BPromise=require(_0x3964('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x3964('0x5'));var rimraf=require(_0x3964('0x6'));var config=require(_0x3964('0x7'));var attributes=require(_0x3964('0x8'));module[_0x3964('0x9')]=function(_0x57c1eb,_0x563890){return _0x57c1eb[_0x3964('0xa')]('CmHopperBlack',attributes,{'tableName':_0x3964('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmHopperBlack/cmHopperBlack.rpc.js b/server/api/cmHopperBlack/cmHopperBlack.rpc.js new file mode 100644 index 0000000..cd2642a --- /dev/null +++ b/server/api/cmHopperBlack/cmHopperBlack.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5bdd=['../../mysqldb','../../config/utils','../../config/logger','client','http','then','info','CmHopperBlack,\x20%s,\x20%s','request\x20sent','debug','CmHopperBlack,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetCmHopperBlack','CmHopperBlack','options','where','attributes','limit','include','map','model','stringify','UpdateCmHopperBlack','DestroyCmHopperBlack','destroy','lodash','randomstring','ioredis'];(function(_0x3779c3,_0xf6b0db){var _0x4ee760=function(_0x497686){while(--_0x497686){_0x3779c3['push'](_0x3779c3['shift']());}};_0x4ee760(++_0xf6b0db);}(_0x5bdd,0x1af));var _0xd5bd=function(_0x3bd83b,_0x5b882b){_0x3bd83b=_0x3bd83b-0x0;var _0x4de274=_0x5bdd[_0x3bd83b];return _0x4de274;};'use strict';var _=require(_0xd5bd('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xd5bd('0x1'));var fs=require('fs');var Redis=require(_0xd5bd('0x2'));var db=require(_0xd5bd('0x3'))['db'];var utils=require(_0xd5bd('0x4'));var logger=require(_0xd5bd('0x5'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xd5bd('0x6')][_0xd5bd('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1f836a,_0x28e70d,_0x4f913d){return new BPromise(function(_0x4e8a0d,_0x37df77){return client['request'](_0x1f836a,_0x4f913d)[_0xd5bd('0x8')](function(_0x54a6b0){logger[_0xd5bd('0x9')](_0xd5bd('0xa'),_0x28e70d,_0xd5bd('0xb'));logger[_0xd5bd('0xc')](_0xd5bd('0xd'),_0x28e70d,_0xd5bd('0xb'),JSON['stringify'](_0x54a6b0));if(_0x54a6b0['error']){if(_0x54a6b0[_0xd5bd('0xe')][_0xd5bd('0xf')]===0x1f4){logger[_0xd5bd('0xe')](_0xd5bd('0xa'),_0x28e70d,_0x54a6b0[_0xd5bd('0xe')]['message']);return _0x37df77(_0x54a6b0[_0xd5bd('0xe')][_0xd5bd('0x10')]);}logger[_0xd5bd('0xe')](_0xd5bd('0xa'),_0x28e70d,_0x54a6b0[_0xd5bd('0xe')][_0xd5bd('0x10')]);return _0x4e8a0d(_0x54a6b0[_0xd5bd('0xe')][_0xd5bd('0x10')]);}else{logger['info'](_0xd5bd('0xa'),_0x28e70d,_0xd5bd('0xb'));_0x4e8a0d(_0x54a6b0['result'][_0xd5bd('0x10')]);}})[_0xd5bd('0x11')](function(_0xdbb3f){logger[_0xd5bd('0xe')]('CmHopperBlack,\x20%s,\x20%s',_0x28e70d,_0xdbb3f);_0x37df77(_0xdbb3f);});});}exports[_0xd5bd('0x12')]=function(_0x3ec794){var _0x491825=this;return new Promise(function(_0x4a26b6,_0xbfb80e){return db[_0xd5bd('0x13')]['findAll']({'raw':_0x3ec794[_0xd5bd('0x14')]?_0x3ec794[_0xd5bd('0x14')]['raw']===undefined?!![]:![]:!![],'where':_0x3ec794[_0xd5bd('0x14')]?_0x3ec794['options'][_0xd5bd('0x15')]||null:null,'attributes':_0x3ec794[_0xd5bd('0x14')]?_0x3ec794['options'][_0xd5bd('0x16')]||null:null,'limit':_0x3ec794['options']?_0x3ec794[_0xd5bd('0x14')][_0xd5bd('0x17')]||null:null,'include':_0x3ec794['options']?_0x3ec794[_0xd5bd('0x14')][_0xd5bd('0x18')]?_[_0xd5bd('0x19')](_0x3ec794['options']['include'],function(_0x246774){return{'model':db[_0x246774[_0xd5bd('0x1a')]],'as':_0x246774['as'],'attributes':_0x246774[_0xd5bd('0x16')],'include':_0x246774[_0xd5bd('0x18')]?_[_0xd5bd('0x19')](_0x246774['include'],function(_0x23ca22){return{'model':db[_0x23ca22[_0xd5bd('0x1a')]],'as':_0x23ca22['as'],'attributes':_0x23ca22[_0xd5bd('0x16')],'include':_0x23ca22[_0xd5bd('0x18')]?_[_0xd5bd('0x19')](_0x23ca22[_0xd5bd('0x18')],function(_0x9578e6){return{'model':db[_0x9578e6['model']],'as':_0x9578e6['as'],'attributes':_0x9578e6[_0xd5bd('0x16')]};}):[]};}):[]};}):[]:[]})[_0xd5bd('0x8')](function(_0x522ce0){logger['info'](_0xd5bd('0x12'),_0x3ec794);logger[_0xd5bd('0xc')](_0xd5bd('0x12'),_0x3ec794,JSON[_0xd5bd('0x1b')](_0x522ce0));_0x4a26b6(_0x522ce0);})['catch'](function(_0x2bdb21){logger[_0xd5bd('0xe')](_0xd5bd('0x12'),_0x2bdb21[_0xd5bd('0x10')],_0x3ec794);_0xbfb80e(_0x491825[_0xd5bd('0xe')](0x1f4,_0x2bdb21[_0xd5bd('0x10')]));});});};exports[_0xd5bd('0x1c')]=function(_0x3e87f6){var _0x443cbb=this;return new Promise(function(_0x55c6c6,_0x3c24e6){return db[_0xd5bd('0x13')]['update'](_0x3e87f6['body'],{'raw':_0x3e87f6[_0xd5bd('0x14')]?_0x3e87f6[_0xd5bd('0x14')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3e87f6[_0xd5bd('0x14')]?_0x3e87f6[_0xd5bd('0x14')]['where']||null:null,'attributes':_0x3e87f6[_0xd5bd('0x14')]?_0x3e87f6['options'][_0xd5bd('0x16')]||null:null,'limit':_0x3e87f6[_0xd5bd('0x14')]?_0x3e87f6[_0xd5bd('0x14')][_0xd5bd('0x17')]||null:null})[_0xd5bd('0x8')](function(_0x530a7c){logger[_0xd5bd('0x9')]('UpdateCmHopperBlack',_0x3e87f6);logger[_0xd5bd('0xc')](_0xd5bd('0x1c'),_0x3e87f6,JSON['stringify'](_0x530a7c));_0x55c6c6(_0x530a7c);})[_0xd5bd('0x11')](function(_0x19b737){logger[_0xd5bd('0xe')](_0xd5bd('0x1c'),_0x19b737[_0xd5bd('0x10')],_0x3e87f6);_0x3c24e6(_0x443cbb[_0xd5bd('0xe')](0x1f4,_0x19b737[_0xd5bd('0x10')]));});});};exports[_0xd5bd('0x1d')]=function(_0x29f216){var _0x495e37=this;return new Promise(function(_0x31b32f,_0x2b8853){return db['CmHopperBlack'][_0xd5bd('0x1e')]({'where':_0x29f216[_0xd5bd('0x14')]?_0x29f216['options'][_0xd5bd('0x15')]||null:null})[_0xd5bd('0x8')](function(_0x41efcd){logger['info'](_0xd5bd('0x1d'),_0x29f216);logger[_0xd5bd('0xc')](_0xd5bd('0x1d'),_0x29f216,JSON[_0xd5bd('0x1b')](_0x41efcd));_0x31b32f(_0x41efcd);})['catch'](function(_0x54e012){logger['error'](_0xd5bd('0x1d'),_0x54e012[_0xd5bd('0x10')],_0x29f216);_0x2b8853(_0x495e37[_0xd5bd('0xe')](0x1f4,_0x54e012['message']));});});}; \ No newline at end of file diff --git a/server/api/cmHopperBlack/index.js b/server/api/cmHopperBlack/index.js new file mode 100644 index 0000000..b3a4e24 --- /dev/null +++ b/server/api/cmHopperBlack/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5162=['/:id','show','update','exports','multer','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./cmHopperBlack.controller','get','/describe','isAuthenticated','describe'];(function(_0x258532,_0x704f6b){var _0x8cd3e0=function(_0x502e4d){while(--_0x502e4d){_0x258532['push'](_0x258532['shift']());}};_0x8cd3e0(++_0x704f6b);}(_0x5162,0x103));var _0x2516=function(_0x1ec65c,_0x354923){_0x1ec65c=_0x1ec65c-0x0;var _0x5249c2=_0x5162[_0x1ec65c];return _0x5249c2;};'use strict';var multer=require(_0x2516('0x0'));var util=require('util');var path=require('path');var timeout=require('connect-timeout');var express=require('express');var router=express[_0x2516('0x1')]();var fs_extra=require(_0x2516('0x2'));var auth=require(_0x2516('0x3'));var interaction=require(_0x2516('0x4'));var config=require(_0x2516('0x5'));var controller=require(_0x2516('0x6'));router[_0x2516('0x7')]('/',auth['isAuthenticated'](),controller['index']);router['get'](_0x2516('0x8'),auth[_0x2516('0x9')](),controller[_0x2516('0xa')]);router[_0x2516('0x7')](_0x2516('0xb'),auth[_0x2516('0x9')](),controller[_0x2516('0xc')]);router['put'](_0x2516('0xb'),auth[_0x2516('0x9')](),controller[_0x2516('0xd')]);router['delete']('/:id',auth['isAuthenticated'](),controller['destroy']);module[_0x2516('0xe')]=router; \ No newline at end of file diff --git a/server/api/cmHopperFinal/cmHopperFinal.attributes.js b/server/api/cmHopperFinal/cmHopperFinal.attributes.js new file mode 100644 index 0000000..b302647 --- /dev/null +++ b/server/api/cmHopperFinal/cmHopperFinal.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb9b1=['moment','exports','INTEGER','STRING','DATE','getDataValue','endtime','followuptime','BOOLEAN','sequelize'];(function(_0x490249,_0x4c01a1){var _0x5c6453=function(_0x5ec246){while(--_0x5ec246){_0x490249['push'](_0x490249['shift']());}};_0x5c6453(++_0x4c01a1);}(_0xb9b1,0xb3));var _0x1b9b=function(_0x2a4f5b,_0x11bd88){_0x2a4f5b=_0x2a4f5b-0x0;var _0x501954=_0xb9b1[_0x2a4f5b];return _0x501954;};'use strict';var Sequelize=require(_0x1b9b('0x0'));var moment=require(_0x1b9b('0x1'));module[_0x1b9b('0x2')]={'state':{'type':Sequelize[_0x1b9b('0x3')](0x2)},'statedesc':{'type':Sequelize['STRING']},'scheduledat':{'type':Sequelize['DATE']},'countbusyretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countcongestionretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countnoanswerretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countglobal':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'uniqueid':{'type':Sequelize['STRING']},'originatecalleridnum':{'type':Sequelize['STRING']},'originatecalleridname':{'type':Sequelize[_0x1b9b('0x4')]},'calleridnum':{'type':Sequelize['STRING']},'calleridname':{'type':Sequelize['STRING']},'starttime':{'type':Sequelize[_0x1b9b('0x5')]},'responsetime':{'type':Sequelize[_0x1b9b('0x5')]},'answertime':{'type':Sequelize[_0x1b9b('0x5')]},'droptime':{'type':Sequelize[_0x1b9b('0x5')]},'endtime':{'type':Sequelize[_0x1b9b('0x5')]},'ringtime':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'holdtime':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'talktime':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'followuptime':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'dropreason':{'type':Sequelize[_0x1b9b('0x4')]},'campaign':{'type':Sequelize['STRING']},'campaigntype':{'type':Sequelize[_0x1b9b('0x4')]},'membername':{'type':Sequelize['STRING']},'reason':{'type':Sequelize[_0x1b9b('0x4')]},'disposition':{'type':Sequelize[_0x1b9b('0x4')]},'secondDisposition':{'type':Sequelize['STRING']},'thirdDisposition':{'type':Sequelize[_0x1b9b('0x4')]},'dispositionat':{'type':Sequelize[_0x1b9b('0x5')],'set':function(_0x21a1d7){var _0x104ff7=this[_0x1b9b('0x6')](_0x1b9b('0x7'));if(_0x104ff7&&_0x21a1d7){this['setDataValue'](_0x1b9b('0x8'),moment(_0x21a1d7)['diff'](moment(_0x104ff7),'seconds'));}}},'amd':{'type':Sequelize[_0x1b9b('0x9')],'defaultValue':![]},'fax':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'blacklist':{'type':Sequelize[_0x1b9b('0x9')],'defaultValue':![]},'rescheduled':{'type':Sequelize[_0x1b9b('0x9')],'defaultValue':![]},'rescheduledat':{'type':Sequelize[_0x1b9b('0x5')]},'callback':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'callbackuniqueid':{'type':Sequelize[_0x1b9b('0x4')],'defaultValue':null},'callbackat':{'type':Sequelize[_0x1b9b('0x5')]},'deleted':{'type':Sequelize[_0x1b9b('0x4')],'defaultValue':null},'deletedat':{'type':Sequelize[_0x1b9b('0x5')]},'recallme':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'agiafterat':{'type':Sequelize[_0x1b9b('0x5')]},'countnosuchnumberretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countdropretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countabandonedretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countmachineretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0},'countagentrejectretry':{'type':Sequelize[_0x1b9b('0x3')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/cmHopperFinal/cmHopperFinal.controller.js b/server/api/cmHopperFinal/cmHopperFinal.controller.js new file mode 100644 index 0000000..76de23c --- /dev/null +++ b/server/api/cmHopperFinal/cmHopperFinal.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2542=['Content-Range','apply','update','then','error','stack','name','index','map','CmHopperFinal','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','length','find','describe','body','uniqueid','sequelize','COUNT','literal','`state`\x20=\x200,\x201,\x20null','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','`state`\x20=\x205,\x201,\x20null','busyContacts','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','`state`\x20=\x2022,\x201,\x20null','reCallContacts','`state`\x20=\x2019,\x201,\x20null','answeringMachine','countContactsIvrCampaignHopperFinal','noSuchContacts','`state`\x20=\x208,\x201,\x20null','congestionContacts','abandonedContacts','VoiceQueue','into','fromQuery','phone','ListId','VoiceQueueId','createdAt','updatedAt','field','ANY_VALUE(calleridnum)','scheduledAt','ContactId','ANY_VALUE(ListId)','NOW()','from','cm_hopper_final','VoiceQueueId\x20=\x20?','state\x20=\x20?','state','toString','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','select','calleridnum','group','moveContactsIvrCampaignHopperFinal','Campaign','CampaignId','ANY_VALUE(ContactId)','ANY_VALUE(CampaignId)','CampaignId\x20=\x20?','cm_hopper','state\x20=\x204','checkContactHopper','CmHopper','findOne','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','limit','undefined','count','set'];(function(_0x14653a,_0x2851cd){var _0x451eb1=function(_0x58d25d){while(--_0x58d25d){_0x14653a['push'](_0x14653a['shift']());}};_0x451eb1(++_0x2851cd);}(_0x2542,0x169));var _0x2254=function(_0xe7eb9,_0x256394){_0xe7eb9=_0xe7eb9-0x0;var _0xd7e40d=_0x2542[_0xe7eb9];return _0xd7e40d;};'use strict';var emlformat=require(_0x2254('0x0'));var rimraf=require(_0x2254('0x1'));var zipdir=require(_0x2254('0x2'));var jsonpatch=require(_0x2254('0x3'));var rp=require('request-promise');var moment=require(_0x2254('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x2254('0x5'));var util=require(_0x2254('0x6'));var path=require(_0x2254('0x7'));var sox=require(_0x2254('0x8'));var csv=require(_0x2254('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x2254('0xa'));var _=require(_0x2254('0xb'));var squel=require(_0x2254('0xc'));var crypto=require(_0x2254('0xd'));var jsforce=require(_0x2254('0xe'));var deskjs=require(_0x2254('0xf'));var toCsv=require(_0x2254('0x9'));var querystring=require(_0x2254('0x10'));var Papa=require(_0x2254('0x11'));var Redis=require(_0x2254('0x12'));var authService=require(_0x2254('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x2254('0x14'));var hardwareService=require(_0x2254('0x15'));var logger=require(_0x2254('0x16'))(_0x2254('0x17'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x2254('0x18'));var db=require(_0x2254('0x19'))['db'];function respondWithStatusCode(_0x116b70,_0xdcb670){_0xdcb670=_0xdcb670||0xcc;return function(_0x3c326b){if(_0x3c326b){return _0x116b70[_0x2254('0x1a')](_0xdcb670);}return _0x116b70['status'](_0xdcb670)[_0x2254('0x1b')]();};}function respondWithResult(_0x7c7ab0,_0x504749){_0x504749=_0x504749||0xc8;return function(_0x2f4de){if(_0x2f4de){return _0x7c7ab0[_0x2254('0x1c')](_0x504749)[_0x2254('0x1d')](_0x2f4de);}};}function respondWithFilteredResult(_0x145272,_0x26285a){return function(_0xbc5548){if(_0xbc5548){var _0x50f137=typeof _0x26285a[_0x2254('0x1e')]==='undefined'&&typeof _0x26285a[_0x2254('0x1f')]===_0x2254('0x20');var _0x170ffa=_0xbc5548[_0x2254('0x21')];var _0x1ae11e=_0x50f137?0x0:_0x26285a[_0x2254('0x1e')];var _0x497724=_0x50f137?_0xbc5548['count']:_0x26285a['offset']+_0x26285a[_0x2254('0x1f')];var _0x3a79f8;if(_0x497724>=_0x170ffa){_0x497724=_0x170ffa;_0x3a79f8=0xc8;}else{_0x3a79f8=0xce;}_0x145272[_0x2254('0x1c')](_0x3a79f8);return _0x145272[_0x2254('0x22')](_0x2254('0x23'),_0x1ae11e+'-'+_0x497724+'/'+_0x170ffa)[_0x2254('0x1d')](_0xbc5548);}return null;};}function patchUpdates(_0x487f72){return function(_0x28381e){try{jsonpatch[_0x2254('0x24')](_0x28381e,_0x487f72,!![]);}catch(_0x906cde){return BPromise['reject'](_0x906cde);}return _0x28381e['save']();};}function saveUpdates(_0x5bd982,_0x1e8a98){return function(_0x559af4){if(_0x559af4){return _0x559af4[_0x2254('0x25')](_0x5bd982)['then'](function(_0x5713e4){return _0x5713e4;});}return null;};}function removeEntity(_0x4d8faf,_0x540020){return function(_0x5e5edb){if(_0x5e5edb){return _0x5e5edb['destroy']()[_0x2254('0x26')](function(){_0x4d8faf[_0x2254('0x1c')](0xcc)[_0x2254('0x1b')]();});}};}function handleEntityNotFound(_0x265467,_0x13522d){return function(_0x1349c9){if(!_0x1349c9){_0x265467['sendStatus'](0x194);}return _0x1349c9;};}function handleError(_0x4a8274,_0x1ada42){_0x1ada42=_0x1ada42||0x1f4;return function(_0x4f6877){logger[_0x2254('0x27')](_0x4f6877[_0x2254('0x28')]);if(_0x4f6877[_0x2254('0x29')]){delete _0x4f6877[_0x2254('0x29')];}_0x4a8274[_0x2254('0x1c')](_0x1ada42)['send'](_0x4f6877);};}exports[_0x2254('0x2a')]=function(_0x2a789b,_0x21285d){var _0x37af8b={},_0x13366a={},_0x377c41={'count':0x0,'rows':[]};var _0x3214a7=_[_0x2254('0x2b')](db[_0x2254('0x2c')][_0x2254('0x2d')],function(_0x21c641){return{'name':_0x21c641[_0x2254('0x2e')],'type':_0x21c641[_0x2254('0x2f')][_0x2254('0x30')]};});_0x13366a[_0x2254('0x31')]=_[_0x2254('0x2b')](_0x3214a7,_0x2254('0x29'));_0x13366a[_0x2254('0x32')]=_[_0x2254('0x33')](_0x2a789b['query']);_0x13366a[_0x2254('0x34')]=_[_0x2254('0x35')](_0x13366a[_0x2254('0x31')],_0x13366a[_0x2254('0x32')]);_0x37af8b[_0x2254('0x36')]=_[_0x2254('0x35')](_0x13366a[_0x2254('0x31')],qs[_0x2254('0x37')](_0x2a789b[_0x2254('0x32')]['fields']));_0x37af8b[_0x2254('0x36')]=_0x37af8b[_0x2254('0x36')]['length']?_0x37af8b[_0x2254('0x36')]:_0x13366a[_0x2254('0x31')];if(!_0x2a789b[_0x2254('0x32')][_0x2254('0x38')]('nolimit')){_0x37af8b['limit']=qs[_0x2254('0x1f')](_0x2a789b['query'][_0x2254('0x1f')]);_0x37af8b[_0x2254('0x1e')]=qs[_0x2254('0x1e')](_0x2a789b[_0x2254('0x32')][_0x2254('0x1e')]);}_0x37af8b[_0x2254('0x39')]=qs[_0x2254('0x3a')](_0x2a789b['query'][_0x2254('0x3a')]);_0x37af8b[_0x2254('0x3b')]=qs[_0x2254('0x34')](_[_0x2254('0x3c')](_0x2a789b[_0x2254('0x32')],_0x13366a[_0x2254('0x34')]),_0x3214a7);if(_0x2a789b[_0x2254('0x32')][_0x2254('0x3d')]){_0x37af8b[_0x2254('0x3b')]=_[_0x2254('0x3e')](_0x37af8b['where'],{'$or':_[_0x2254('0x2b')](_0x3214a7,function(_0xde3e4a){if(_0xde3e4a[_0x2254('0x2f')]!==_0x2254('0x3f')){var _0x4c7cc3={};_0x4c7cc3[_0xde3e4a[_0x2254('0x29')]]={'$like':'%'+_0x2a789b[_0x2254('0x32')][_0x2254('0x3d')]+'%'};return _0x4c7cc3;}})});}_0x37af8b=_[_0x2254('0x3e')]({},_0x37af8b,_0x2a789b[_0x2254('0x40')]);var _0x2602db={'where':_0x37af8b[_0x2254('0x3b')]};return db[_0x2254('0x2c')]['count'](_0x2602db)[_0x2254('0x26')](function(_0x5c15d7){_0x377c41[_0x2254('0x21')]=_0x5c15d7;if(_0x2a789b[_0x2254('0x32')][_0x2254('0x41')]){_0x37af8b[_0x2254('0x42')]=[{'all':!![]}];}return db[_0x2254('0x2c')][_0x2254('0x43')](_0x37af8b);})[_0x2254('0x26')](function(_0x568ec9){_0x377c41[_0x2254('0x44')]=_0x568ec9;return _0x377c41;})[_0x2254('0x26')](respondWithFilteredResult(_0x21285d,_0x37af8b))[_0x2254('0x45')](handleError(_0x21285d,null));};exports[_0x2254('0x46')]=function(_0x40d4da,_0x57cda2){var _0x22bb98={'raw':!![],'where':{'id':_0x40d4da[_0x2254('0x47')]['id']}},_0x1dec43={};_0x1dec43[_0x2254('0x31')]=_[_0x2254('0x33')](db['CmHopperFinal'][_0x2254('0x2d')]);_0x1dec43['query']=_[_0x2254('0x33')](_0x40d4da[_0x2254('0x32')]);_0x1dec43[_0x2254('0x34')]=_[_0x2254('0x35')](_0x1dec43[_0x2254('0x31')],_0x1dec43[_0x2254('0x32')]);_0x22bb98[_0x2254('0x36')]=_[_0x2254('0x35')](_0x1dec43[_0x2254('0x31')],qs[_0x2254('0x37')](_0x40d4da[_0x2254('0x32')][_0x2254('0x37')]));_0x22bb98[_0x2254('0x36')]=_0x22bb98['attributes'][_0x2254('0x48')]?_0x22bb98[_0x2254('0x36')]:_0x1dec43[_0x2254('0x31')];if(_0x40d4da['query'][_0x2254('0x41')]){_0x22bb98[_0x2254('0x42')]=[{'all':!![]}];}_0x22bb98=_[_0x2254('0x3e')]({},_0x22bb98,_0x40d4da[_0x2254('0x40')]);return db[_0x2254('0x2c')][_0x2254('0x49')](_0x22bb98)[_0x2254('0x26')](handleEntityNotFound(_0x57cda2,null))[_0x2254('0x26')](respondWithResult(_0x57cda2,null))[_0x2254('0x45')](handleError(_0x57cda2,null));};exports['describe']=function(_0x239ba0,_0x405eb2){return db[_0x2254('0x2c')][_0x2254('0x4a')]()[_0x2254('0x26')](respondWithResult(_0x405eb2,null))[_0x2254('0x45')](handleError(_0x405eb2,null));};exports[_0x2254('0x25')]=function(_0x438922,_0x3ac691){if(_0x438922[_0x2254('0x4b')]['uniqueid']){delete _0x438922[_0x2254('0x4b')][_0x2254('0x4c')];}return db['CmHopperFinal'][_0x2254('0x49')]({'where':{'uniqueid':_0x438922[_0x2254('0x47')]['id']}})[_0x2254('0x26')](handleEntityNotFound(_0x3ac691,null))[_0x2254('0x26')](saveUpdates(_0x438922['body'],null))[_0x2254('0x26')](respondWithResult(_0x3ac691,null))[_0x2254('0x45')](handleError(_0x3ac691,null));};exports['countContactsQueueCampaignHopperFinal']=function(_0x26d01a,_0x3f0670,_0x23014b){return db[_0x2254('0x2c')]['findAll']({'raw':![],'where':{'VoiceQueueId':_0x26d01a[_0x2254('0x47')]['id']},'attributes':[[db[_0x2254('0x4d')]['fn'](_0x2254('0x4e'),db['sequelize']['fn']('IF',db['sequelize'][_0x2254('0x4f')](_0x2254('0x50')))),'noSuchContacts'],[db[_0x2254('0x4d')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')](_0x2254('0x51')))),_0x2254('0x52')],[db[_0x2254('0x4d')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x2254('0x4d')]['literal'](_0x2254('0x53')))),_0x2254('0x54')],[db[_0x2254('0x4d')]['fn'](_0x2254('0x4e'),db['sequelize']['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')]('`state`\x20=\x208,\x201,\x20null'))),'congestionContacts'],[db[_0x2254('0x4d')]['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')](_0x2254('0x55')))),_0x2254('0x56')],[db['sequelize']['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db['sequelize'][_0x2254('0x4f')]('`state`\x20=\x2011\x20,\x201,\x20null'))),'abandonedContacts'],[db['sequelize']['fn'](_0x2254('0x4e'),db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')](_0x2254('0x57')))),_0x2254('0x58')],[db[_0x2254('0x4d')]['fn'](_0x2254('0x4e'),db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')](_0x2254('0x59')))),_0x2254('0x5a')]]})[_0x2254('0x26')](handleEntityNotFound(_0x3f0670,null))[_0x2254('0x26')](respondWithResult(_0x3f0670,null))[_0x2254('0x45')](handleError(_0x3f0670,null));};exports[_0x2254('0x5b')]=function(_0x399ba2,_0x179cf1,_0x5b8909){return db[_0x2254('0x2c')][_0x2254('0x43')]({'raw':![],'where':{'CampaignId':_0x399ba2[_0x2254('0x47')]['id']},'attributes':[[db[_0x2254('0x4d')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')](_0x2254('0x50')))),_0x2254('0x5c')],[db[_0x2254('0x4d')]['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')]('`state`\x20=\x203,\x201,\x20null'))),'noAnswerContacts'],[db[_0x2254('0x4d')]['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')]['literal'](_0x2254('0x53')))),_0x2254('0x54')],[db['sequelize']['fn'](_0x2254('0x4e'),db[_0x2254('0x4d')]['fn']('IF',db['sequelize']['literal'](_0x2254('0x5d')))),_0x2254('0x5e')],[db['sequelize']['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db['sequelize'][_0x2254('0x4f')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0x2254('0x56')],[db[_0x2254('0x4d')]['fn'](_0x2254('0x4e'),db[_0x2254('0x4d')]['fn']('IF',db['sequelize'][_0x2254('0x4f')]('`state`\x20=\x2011\x20,\x201,\x20null'))),_0x2254('0x5f')],[db[_0x2254('0x4d')]['fn']('COUNT',db[_0x2254('0x4d')]['fn']('IF',db[_0x2254('0x4d')]['literal'](_0x2254('0x57')))),_0x2254('0x58')],[db[_0x2254('0x4d')]['fn'](_0x2254('0x4e'),db['sequelize']['fn']('IF',db[_0x2254('0x4d')][_0x2254('0x4f')]('`state`\x20=\x2019,\x201,\x20null'))),_0x2254('0x5a')]]})[_0x2254('0x26')](handleEntityNotFound(_0x179cf1,null))['then'](respondWithResult(_0x179cf1,null))[_0x2254('0x45')](handleError(_0x179cf1,null));};exports['moveContactsQueueCampaignHopperFinal']=function(_0x7075b1,_0x516595,_0x3cbd35){return db[_0x2254('0x60')]['find']({'where':{'id':_0x7075b1[_0x2254('0x47')]['id']}})['then'](handleEntityNotFound(_0x516595,null))[_0x2254('0x26')](function(_0x3e6070){var _0x38294d;if(_0x3e6070){_0x38294d=squel['insert']()[_0x2254('0x61')]('cm_hopper')[_0x2254('0x62')]([_0x2254('0x63'),'scheduledAt','ContactId',_0x2254('0x64'),_0x2254('0x65'),_0x2254('0x66'),_0x2254('0x67')],squel['select']()[_0x2254('0x68')](_0x2254('0x69'),_0x2254('0x63'))[_0x2254('0x68')]('NOW()',_0x2254('0x6a'))[_0x2254('0x68')]('ANY_VALUE(ContactId)',_0x2254('0x6b'))['field'](_0x2254('0x6c'),'ListId')['field']('ANY_VALUE(VoiceQueueId)',_0x2254('0x65'))['field'](_0x2254('0x6d'),_0x2254('0x66'))['field'](_0x2254('0x6d'),_0x2254('0x67'))[_0x2254('0x6e')](_0x2254('0x6f'))[_0x2254('0x3b')](_0x2254('0x70'),_0x7075b1['params']['id']['toString']())[_0x2254('0x3b')](_0x2254('0x71'),_0x7075b1[_0x2254('0x4b')][_0x2254('0x72')][_0x2254('0x73')]())[_0x2254('0x3b')](_0x2254('0x74'))[_0x2254('0x3b')](_0x2254('0x75'),squel[_0x2254('0x76')]()['field'](_0x2254('0x63'))[_0x2254('0x6e')]('cm_hopper')[_0x2254('0x3b')]('VoiceQueueId\x20=\x20?',_0x7075b1[_0x2254('0x47')]['id'][_0x2254('0x73')]()))['where'](_0x2254('0x75'),squel['select']()[_0x2254('0x68')](_0x2254('0x77'))[_0x2254('0x6e')](_0x2254('0x6f'))['where'](_0x2254('0x70'),_0x7075b1[_0x2254('0x47')]['id'][_0x2254('0x73')]())[_0x2254('0x3b')]('state\x20=\x204'))[_0x2254('0x78')](_0x2254('0x6b')))['toString']();return db[_0x2254('0x4d')][_0x2254('0x32')](_0x38294d);}return[];})['then'](respondWithResult(_0x516595,null))['catch'](handleError(_0x516595,null));};exports[_0x2254('0x79')]=function(_0x2f3650,_0x1a3fd9,_0x3058d9){return db[_0x2254('0x7a')][_0x2254('0x49')]({'where':{'id':_0x2f3650[_0x2254('0x47')]['id']}})[_0x2254('0x26')](handleEntityNotFound(_0x1a3fd9,null))[_0x2254('0x26')](function(_0x5df20f){var _0x10c44;if(_0x5df20f){_0x10c44=squel['insert']()[_0x2254('0x61')]('cm_hopper')[_0x2254('0x62')]([_0x2254('0x63'),_0x2254('0x6a'),'ContactId',_0x2254('0x64'),_0x2254('0x7b'),_0x2254('0x66'),_0x2254('0x67')],squel[_0x2254('0x76')]()[_0x2254('0x68')](_0x2254('0x69'),_0x2254('0x63'))[_0x2254('0x68')](_0x2254('0x6d'),_0x2254('0x6a'))[_0x2254('0x68')](_0x2254('0x7c'),'ContactId')[_0x2254('0x68')]('ANY_VALUE(ListId)',_0x2254('0x64'))[_0x2254('0x68')](_0x2254('0x7d'),_0x2254('0x7b'))[_0x2254('0x68')](_0x2254('0x6d'),_0x2254('0x66'))['field'](_0x2254('0x6d'),'updatedAt')[_0x2254('0x6e')]('cm_hopper_final')[_0x2254('0x3b')](_0x2254('0x7e'),_0x2f3650[_0x2254('0x47')]['id']['toString']())[_0x2254('0x3b')](_0x2254('0x71'),_0x2f3650[_0x2254('0x4b')][_0x2254('0x72')][_0x2254('0x73')]())[_0x2254('0x3b')](_0x2254('0x74'))[_0x2254('0x3b')]('calleridnum\x20NOT\x20IN\x20(?)',squel['select']()[_0x2254('0x68')]('phone')[_0x2254('0x6e')](_0x2254('0x7f'))[_0x2254('0x3b')](_0x2254('0x7e'),_0x2f3650[_0x2254('0x47')]['id'][_0x2254('0x73')]()))[_0x2254('0x3b')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x2254('0x76')]()[_0x2254('0x68')](_0x2254('0x77'))['from'](_0x2254('0x6f'))[_0x2254('0x3b')](_0x2254('0x7e'),_0x2f3650[_0x2254('0x47')]['id'][_0x2254('0x73')]())[_0x2254('0x3b')](_0x2254('0x80')))[_0x2254('0x78')](_0x2254('0x6b')))['toString']();return db[_0x2254('0x4d')][_0x2254('0x32')](_0x10c44);}return[];})['then'](respondWithResult(_0x1a3fd9,null))['catch'](handleError(_0x1a3fd9,null));};exports[_0x2254('0x81')]=function(_0x54339e,_0x226c19,_0x10645f){return db[_0x2254('0x82')][_0x2254('0x83')]({'where':{'VoiceQueueId':_0x54339e[_0x2254('0x4b')][_0x2254('0x65')],'CampaignId':_0x54339e[_0x2254('0x4b')][_0x2254('0x7b')],'ContactId':_0x54339e['body']['ContactId']}})[_0x2254('0x26')](handleEntityNotFound(_0x226c19,null))[_0x2254('0x26')](function(_0x1e8617){if(_0x1e8617){return _0x1e8617;}return null;})[_0x2254('0x26')](respondWithResult(_0x226c19,null))[_0x2254('0x45')](handleError(_0x226c19,null));}; \ No newline at end of file diff --git a/server/api/cmHopperFinal/cmHopperFinal.model.js b/server/api/cmHopperFinal/cmHopperFinal.model.js new file mode 100644 index 0000000..90abb51 --- /dev/null +++ b/server/api/cmHopperFinal/cmHopperFinal.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7b0e=['exports','define','CmHopperFinal','cm_hopper_final','calleridnum','uniqueid','lodash','util','moment','path','rimraf','../../config/environment','./cmHopperFinal.attributes'];(function(_0x3d53b6,_0x3d468e){var _0x483f66=function(_0x5a88bc){while(--_0x5a88bc){_0x3d53b6['push'](_0x3d53b6['shift']());}};_0x483f66(++_0x3d468e);}(_0x7b0e,0xaf));var _0xe7b0=function(_0x21e752,_0x11e729){_0x21e752=_0x21e752-0x0;var _0x1db54c=_0x7b0e[_0x21e752];return _0x1db54c;};'use strict';var _=require(_0xe7b0('0x0'));var util=require(_0xe7b0('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0xe7b0('0x2'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0xe7b0('0x3'));var rimraf=require(_0xe7b0('0x4'));var config=require(_0xe7b0('0x5'));var attributes=require(_0xe7b0('0x6'));module[_0xe7b0('0x7')]=function(_0xefe9b5,_0x482030){return _0xefe9b5[_0xe7b0('0x8')](_0xe7b0('0x9'),attributes,{'tableName':_0xe7b0('0xa'),'paranoid':![],'indexes':[{'name':_0xe7b0('0xb'),'fields':[_0xe7b0('0xb')]},{'name':'uniqueid','fields':[_0xe7b0('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmHopperFinal/cmHopperFinal.rpc.js b/server/api/cmHopperFinal/cmHopperFinal.rpc.js new file mode 100644 index 0000000..0c091f8 --- /dev/null +++ b/server/api/cmHopperFinal/cmHopperFinal.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb10b=['debug','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','CmHopperFinal,\x20%s,\x20%s','CmHopperFinal,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','CreateCmHopperFinal','CmHopperFinal','create','options','raw'];(function(_0x2f4832,_0x5ddd74){var _0x426743=function(_0x37dcf3){while(--_0x37dcf3){_0x2f4832['push'](_0x2f4832['shift']());}};_0x426743(++_0x5ddd74);}(_0xb10b,0x12a));var _0xbb10=function(_0x34e4a0,_0x1fd446){_0x34e4a0=_0x34e4a0-0x0;var _0x3ead3e=_0xb10b[_0x34e4a0];return _0x3ead3e;};'use strict';var _=require(_0xbb10('0x0'));var util=require('util');var moment=require(_0xbb10('0x1'));var BPromise=require(_0xbb10('0x2'));var rs=require(_0xbb10('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbb10('0x4'))['db'];var utils=require(_0xbb10('0x5'));var logger=require(_0xbb10('0x6'))(_0xbb10('0x7'));var config=require(_0xbb10('0x8'));var jayson=require(_0xbb10('0x9'));var client=jayson['client'][_0xbb10('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3cdd53,_0x513741,_0x1b9e94){return new BPromise(function(_0x3fb675,_0x21370f){return client[_0xbb10('0xb')](_0x3cdd53,_0x1b9e94)[_0xbb10('0xc')](function(_0x1ce33e){logger[_0xbb10('0xd')](_0xbb10('0xe'),_0x513741,'request\x20sent');logger['debug'](_0xbb10('0xf'),_0x513741,_0xbb10('0x10'),JSON[_0xbb10('0x11')](_0x1ce33e));if(_0x1ce33e['error']){if(_0x1ce33e[_0xbb10('0x12')]['code']===0x1f4){logger[_0xbb10('0x12')](_0xbb10('0xe'),_0x513741,_0x1ce33e[_0xbb10('0x12')][_0xbb10('0x13')]);return _0x21370f(_0x1ce33e[_0xbb10('0x12')][_0xbb10('0x13')]);}logger['error'](_0xbb10('0xe'),_0x513741,_0x1ce33e[_0xbb10('0x12')][_0xbb10('0x13')]);return _0x3fb675(_0x1ce33e[_0xbb10('0x12')][_0xbb10('0x13')]);}else{logger[_0xbb10('0xd')](_0xbb10('0xe'),_0x513741,_0xbb10('0x10'));_0x3fb675(_0x1ce33e[_0xbb10('0x14')][_0xbb10('0x13')]);}})['catch'](function(_0x2eca0f){logger[_0xbb10('0x12')](_0xbb10('0xe'),_0x513741,_0x2eca0f);_0x21370f(_0x2eca0f);});});}exports[_0xbb10('0x15')]=function(_0x378da8){var _0x1682a4=this;return new Promise(function(_0x575cca,_0x30efc6){return db[_0xbb10('0x16')][_0xbb10('0x17')](_0x378da8['body'],{'raw':_0x378da8[_0xbb10('0x18')]?_0x378da8[_0xbb10('0x18')][_0xbb10('0x19')]===undefined?!![]:![]:!![]})[_0xbb10('0xc')](function(_0xdf237d){logger[_0xbb10('0xd')]('CreateCmHopperFinal',_0x378da8);logger[_0xbb10('0x1a')](_0xbb10('0x15'),_0x378da8,JSON['stringify'](_0xdf237d));_0x575cca(_0xdf237d);})['catch'](function(_0x8e2b97){logger[_0xbb10('0x12')](_0xbb10('0x15'),_0x8e2b97[_0xbb10('0x13')],_0x378da8);_0x30efc6(_0x1682a4[_0xbb10('0x12')](0x1f4,_0x8e2b97[_0xbb10('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/cmHopperFinal/index.js b/server/api/cmHopperFinal/index.js new file mode 100644 index 0000000..693a38c --- /dev/null +++ b/server/api/cmHopperFinal/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2ef3=['../../components/auth/service','../../components/interaction/service','./cmHopperFinal.controller','get','/describe','isAuthenticated','describe','/:id','show','/voice/queue/countAttributes/:id','/campaign/countAttributes/:id','countContactsIvrCampaignHopperFinal','/voice/queue/moveContacts/:id','moveContactsQueueCampaignHopperFinal','/voice/campaign/moveContacts/:id','/checkContactHopper','checkContactHopper','put','multer','util','path','connect-timeout','express','Router'];(function(_0x524c09,_0xb22408){var _0x17f290=function(_0x10a0aa){while(--_0x10a0aa){_0x524c09['push'](_0x524c09['shift']());}};_0x17f290(++_0xb22408);}(_0x2ef3,0xba));var _0x32ef=function(_0x2fbade,_0x4a3a21){_0x2fbade=_0x2fbade-0x0;var _0x23e8ef=_0x2ef3[_0x2fbade];return _0x23e8ef;};'use strict';var multer=require(_0x32ef('0x0'));var util=require(_0x32ef('0x1'));var path=require(_0x32ef('0x2'));var timeout=require(_0x32ef('0x3'));var express=require(_0x32ef('0x4'));var router=express[_0x32ef('0x5')]();var fs_extra=require('fs-extra');var auth=require(_0x32ef('0x6'));var interaction=require(_0x32ef('0x7'));var config=require('../../config/environment');var controller=require(_0x32ef('0x8'));router[_0x32ef('0x9')]('/',auth['isAuthenticated'](),controller['index']);router[_0x32ef('0x9')](_0x32ef('0xa'),auth[_0x32ef('0xb')](),controller[_0x32ef('0xc')]);router[_0x32ef('0x9')](_0x32ef('0xd'),auth[_0x32ef('0xb')](),controller[_0x32ef('0xe')]);router[_0x32ef('0x9')](_0x32ef('0xf'),auth['isAuthenticated'](),controller['countContactsQueueCampaignHopperFinal']);router[_0x32ef('0x9')](_0x32ef('0x10'),auth[_0x32ef('0xb')](),controller[_0x32ef('0x11')]);router['post'](_0x32ef('0x12'),auth['isAuthenticated'](),controller[_0x32ef('0x13')]);router['post'](_0x32ef('0x14'),auth[_0x32ef('0xb')](),controller['moveContactsIvrCampaignHopperFinal']);router['post'](_0x32ef('0x15'),auth['isAuthenticated'](),controller[_0x32ef('0x16')]);router[_0x32ef('0x17')](_0x32ef('0xd'),auth[_0x32ef('0xb')](),controller['update']);module['exports']=router; \ No newline at end of file diff --git a/server/api/cmHopperHistory/cmHopperHistory.attributes.js b/server/api/cmHopperHistory/cmHopperHistory.attributes.js new file mode 100644 index 0000000..5986eda --- /dev/null +++ b/server/api/cmHopperHistory/cmHopperHistory.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd677=['STRING','INTEGER','DATE','BOOLEAN'];(function(_0x2671bc,_0x103d4b){var _0x1c5f76=function(_0x31f05f){while(--_0x31f05f){_0x2671bc['push'](_0x2671bc['shift']());}};_0x1c5f76(++_0x103d4b);}(_0xd677,0x94));var _0x7d67=function(_0x59aeb3,_0x32f513){_0x59aeb3=_0x59aeb3-0x0;var _0x3c6521=_0xd677[_0x59aeb3];return _0x3c6521;};'use strict';var Sequelize=require('sequelize');module['exports']={'state':{'type':Sequelize['INTEGER'](0x2)},'statedesc':{'type':Sequelize[_0x7d67('0x0')]},'scheduledat':{'type':Sequelize['DATE']},'countbusyretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countcongestionretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countnoanswerretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countglobal':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'uniqueid':{'type':Sequelize[_0x7d67('0x0')]},'originatecalleridnum':{'type':Sequelize[_0x7d67('0x0')]},'originatecalleridname':{'type':Sequelize[_0x7d67('0x0')]},'calleridnum':{'type':Sequelize['STRING']},'calleridname':{'type':Sequelize[_0x7d67('0x0')]},'starttime':{'type':Sequelize[_0x7d67('0x2')]},'responsetime':{'type':Sequelize[_0x7d67('0x2')]},'answertime':{'type':Sequelize['DATE']},'droptime':{'type':Sequelize[_0x7d67('0x2')]},'endtime':{'type':Sequelize[_0x7d67('0x2')]},'ringtime':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'holdtime':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'talktime':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'followuptime':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'dropreason':{'type':Sequelize[_0x7d67('0x0')]},'campaign':{'type':Sequelize[_0x7d67('0x0')]},'campaigntype':{'type':Sequelize[_0x7d67('0x0')]},'membername':{'type':Sequelize['STRING']},'reason':{'type':Sequelize['STRING']},'amd':{'type':Sequelize[_0x7d67('0x3')],'defaultValue':![]},'fax':{'type':Sequelize[_0x7d67('0x3')],'defaultValue':![]},'callback':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'callbackuniqueid':{'type':Sequelize[_0x7d67('0x0')],'defaultValue':null},'callbackat':{'type':Sequelize[_0x7d67('0x2')]},'recallme':{'type':Sequelize[_0x7d67('0x3')],'defaultValue':![]},'editedat':{'type':Sequelize[_0x7d67('0x2')]},'edited':{'type':Sequelize[_0x7d67('0x3')],'defaultValue':![]},'countnosuchnumberretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countdropretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countabandonedretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countmachineretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'countagentrejectretry':{'type':Sequelize[_0x7d67('0x1')],'defaultValue':0x0},'dialTimezone':{'type':Sequelize[_0x7d67('0x0')]}}; \ No newline at end of file diff --git a/server/api/cmHopperHistory/cmHopperHistory.controller.js b/server/api/cmHopperHistory/cmHopperHistory.controller.js new file mode 100644 index 0000000..f326df5 --- /dev/null +++ b/server/api/cmHopperHistory/cmHopperHistory.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x48c7=['status','end','json','undefined','limit','offset','count','Content-Range','apply','reject','save','then','error','stack','name','send','index','map','CmHopperHistory','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','includeAll','include','rows','catch','show','params','merge','options','find','create','body','describe','update','uniqueid','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','sox','ejs','fs-extra','squel','crypto','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/environment','sendStatus'];(function(_0xf2c879,_0x48258e){var _0x3c28d9=function(_0x1343fb){while(--_0x1343fb){_0xf2c879['push'](_0xf2c879['shift']());}};_0x3c28d9(++_0x48258e);}(_0x48c7,0xbe));var _0x748c=function(_0x38045f,_0x551f77){_0x38045f=_0x38045f-0x0;var _0xfd4f8c=_0x48c7[_0x38045f];return _0xfd4f8c;};'use strict';var emlformat=require(_0x748c('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x748c('0x1'));var rp=require(_0x748c('0x2'));var moment=require('moment');var BPromise=require(_0x748c('0x3'));var Mustache=require(_0x748c('0x4'));var util=require(_0x748c('0x5'));var path=require('path');var sox=require(_0x748c('0x6'));var csv=require('to-csv');var ejs=require(_0x748c('0x7'));var fs=require('fs');var fs_extra=require(_0x748c('0x8'));var _=require('lodash');var squel=require(_0x748c('0x9'));var crypto=require(_0x748c('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x748c('0xb'));var toCsv=require(_0x748c('0xc'));var querystring=require('querystring');var Papa=require(_0x748c('0xd'));var Redis=require(_0x748c('0xe'));var authService=require(_0x748c('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x748c('0x10'));var logger=require('../../config/logger')(_0x748c('0x11'));var utils=require('../../config/utils');var config=require(_0x748c('0x12'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3c3b82,_0x294d6c){_0x294d6c=_0x294d6c||0xcc;return function(_0x40ea48){if(_0x40ea48){return _0x3c3b82[_0x748c('0x13')](_0x294d6c);}return _0x3c3b82[_0x748c('0x14')](_0x294d6c)[_0x748c('0x15')]();};}function respondWithResult(_0x238cb2,_0x684407){_0x684407=_0x684407||0xc8;return function(_0x3ece1e){if(_0x3ece1e){return _0x238cb2['status'](_0x684407)[_0x748c('0x16')](_0x3ece1e);}};}function respondWithFilteredResult(_0x4ff2f5,_0x5e8aab){return function(_0x57b1a0){if(_0x57b1a0){var _0x3c0553=typeof _0x5e8aab['offset']===_0x748c('0x17')&&typeof _0x5e8aab[_0x748c('0x18')]===_0x748c('0x17');var _0x3b5d28=_0x57b1a0['count'];var _0x503ef1=_0x3c0553?0x0:_0x5e8aab[_0x748c('0x19')];var _0x5a7eca=_0x3c0553?_0x57b1a0[_0x748c('0x1a')]:_0x5e8aab[_0x748c('0x19')]+_0x5e8aab[_0x748c('0x18')];var _0x25d9ad;if(_0x5a7eca>=_0x3b5d28){_0x5a7eca=_0x3b5d28;_0x25d9ad=0xc8;}else{_0x25d9ad=0xce;}_0x4ff2f5['status'](_0x25d9ad);return _0x4ff2f5['set'](_0x748c('0x1b'),_0x503ef1+'-'+_0x5a7eca+'/'+_0x3b5d28)[_0x748c('0x16')](_0x57b1a0);}return null;};}function patchUpdates(_0x586782){return function(_0x1ab753){try{jsonpatch[_0x748c('0x1c')](_0x1ab753,_0x586782,!![]);}catch(_0x367fe0){return BPromise[_0x748c('0x1d')](_0x367fe0);}return _0x1ab753[_0x748c('0x1e')]();};}function saveUpdates(_0x17e2b7,_0x6a4bd3){return function(_0x572f8b){if(_0x572f8b){return _0x572f8b['update'](_0x17e2b7)[_0x748c('0x1f')](function(_0x5b2143){return _0x5b2143;});}return null;};}function removeEntity(_0x52f753,_0x4e305d){return function(_0x34beec){if(_0x34beec){return _0x34beec['destroy']()[_0x748c('0x1f')](function(){_0x52f753[_0x748c('0x14')](0xcc)[_0x748c('0x15')]();});}};}function handleEntityNotFound(_0x5d3f8d,_0x1b5c55){return function(_0xf8c38f){if(!_0xf8c38f){_0x5d3f8d[_0x748c('0x13')](0x194);}return _0xf8c38f;};}function handleError(_0x2745c3,_0x2f9f78){_0x2f9f78=_0x2f9f78||0x1f4;return function(_0x56193c){logger[_0x748c('0x20')](_0x56193c[_0x748c('0x21')]);if(_0x56193c[_0x748c('0x22')]){delete _0x56193c[_0x748c('0x22')];}_0x2745c3['status'](_0x2f9f78)[_0x748c('0x23')](_0x56193c);};}exports[_0x748c('0x24')]=function(_0x3283bf,_0x2aa534){var _0x3fa0ff={},_0x14f570={},_0x1d05a1={'count':0x0,'rows':[]};var _0x151ddc=_[_0x748c('0x25')](db[_0x748c('0x26')]['rawAttributes'],function(_0x51ba89){return{'name':_0x51ba89['fieldName'],'type':_0x51ba89[_0x748c('0x27')][_0x748c('0x28')]};});_0x14f570[_0x748c('0x29')]=_[_0x748c('0x25')](_0x151ddc,'name');_0x14f570[_0x748c('0x2a')]=_[_0x748c('0x2b')](_0x3283bf[_0x748c('0x2a')]);_0x14f570[_0x748c('0x2c')]=_[_0x748c('0x2d')](_0x14f570['model'],_0x14f570[_0x748c('0x2a')]);_0x3fa0ff['attributes']=_['intersection'](_0x14f570[_0x748c('0x29')],qs[_0x748c('0x2e')](_0x3283bf['query'][_0x748c('0x2e')]));_0x3fa0ff[_0x748c('0x2f')]=_0x3fa0ff[_0x748c('0x2f')][_0x748c('0x30')]?_0x3fa0ff['attributes']:_0x14f570['model'];if(!_0x3283bf[_0x748c('0x2a')][_0x748c('0x31')](_0x748c('0x32'))){_0x3fa0ff[_0x748c('0x18')]=qs[_0x748c('0x18')](_0x3283bf['query'][_0x748c('0x18')]);_0x3fa0ff[_0x748c('0x19')]=qs[_0x748c('0x19')](_0x3283bf[_0x748c('0x2a')]['offset']);}_0x3fa0ff[_0x748c('0x33')]=qs[_0x748c('0x34')](_0x3283bf['query'][_0x748c('0x34')]);_0x3fa0ff[_0x748c('0x35')]=qs[_0x748c('0x2c')](_[_0x748c('0x36')](_0x3283bf[_0x748c('0x2a')],_0x14f570['filters']),_0x151ddc);if(_0x3283bf[_0x748c('0x2a')][_0x748c('0x37')]){_0x3fa0ff[_0x748c('0x35')]=_['merge'](_0x3fa0ff['where'],{'$or':_[_0x748c('0x25')](_0x151ddc,function(_0x42658c){if(_0x42658c['type']!=='VIRTUAL'){var _0xa77b65={};_0xa77b65[_0x42658c[_0x748c('0x22')]]={'$like':'%'+_0x3283bf[_0x748c('0x2a')]['filter']+'%'};return _0xa77b65;}})});}_0x3fa0ff=_['merge']({},_0x3fa0ff,_0x3283bf['options']);var _0x3553bd={'where':_0x3fa0ff[_0x748c('0x35')]};return db[_0x748c('0x26')][_0x748c('0x1a')](_0x3553bd)[_0x748c('0x1f')](function(_0x474df5){_0x1d05a1[_0x748c('0x1a')]=_0x474df5;if(_0x3283bf[_0x748c('0x2a')][_0x748c('0x38')]){_0x3fa0ff[_0x748c('0x39')]=[{'all':!![]}];}return db['CmHopperHistory']['findAll'](_0x3fa0ff);})['then'](function(_0x5d527b){_0x1d05a1[_0x748c('0x3a')]=_0x5d527b;return _0x1d05a1;})['then'](respondWithFilteredResult(_0x2aa534,_0x3fa0ff))[_0x748c('0x3b')](handleError(_0x2aa534,null));};exports[_0x748c('0x3c')]=function(_0x1ab600,_0x192acf){var _0x1d82ff={'raw':!![],'where':{'id':_0x1ab600[_0x748c('0x3d')]['id']}},_0x55da0={};_0x55da0[_0x748c('0x29')]=_['keys'](db[_0x748c('0x26')]['rawAttributes']);_0x55da0[_0x748c('0x2a')]=_[_0x748c('0x2b')](_0x1ab600[_0x748c('0x2a')]);_0x55da0[_0x748c('0x2c')]=_[_0x748c('0x2d')](_0x55da0[_0x748c('0x29')],_0x55da0[_0x748c('0x2a')]);_0x1d82ff[_0x748c('0x2f')]=_['intersection'](_0x55da0[_0x748c('0x29')],qs[_0x748c('0x2e')](_0x1ab600[_0x748c('0x2a')]['fields']));_0x1d82ff['attributes']=_0x1d82ff['attributes'][_0x748c('0x30')]?_0x1d82ff[_0x748c('0x2f')]:_0x55da0[_0x748c('0x29')];if(_0x1ab600[_0x748c('0x2a')][_0x748c('0x38')]){_0x1d82ff['include']=[{'all':!![]}];}_0x1d82ff=_[_0x748c('0x3e')]({},_0x1d82ff,_0x1ab600[_0x748c('0x3f')]);return db[_0x748c('0x26')][_0x748c('0x40')](_0x1d82ff)[_0x748c('0x1f')](handleEntityNotFound(_0x192acf,null))[_0x748c('0x1f')](respondWithResult(_0x192acf,null))[_0x748c('0x3b')](handleError(_0x192acf,null));};exports[_0x748c('0x41')]=function(_0x48f8a7,_0x3c05c7){return db[_0x748c('0x26')]['create'](_0x48f8a7[_0x748c('0x42')],{})[_0x748c('0x1f')](respondWithResult(_0x3c05c7,0xc9))[_0x748c('0x3b')](handleError(_0x3c05c7,null));};exports[_0x748c('0x43')]=function(_0x3496a8,_0x581f81){return db[_0x748c('0x26')][_0x748c('0x43')]()[_0x748c('0x1f')](respondWithResult(_0x581f81,null))[_0x748c('0x3b')](handleError(_0x581f81,null));};exports[_0x748c('0x44')]=function(_0x303d6a,_0x433681){if(_0x303d6a[_0x748c('0x42')][_0x748c('0x45')]){delete _0x303d6a[_0x748c('0x42')][_0x748c('0x45')];}return db[_0x748c('0x26')]['find']({'where':{'uniqueid':_0x303d6a['params']['id']}})[_0x748c('0x1f')](handleEntityNotFound(_0x433681,null))[_0x748c('0x1f')](saveUpdates(_0x303d6a[_0x748c('0x42')],null))[_0x748c('0x1f')](respondWithResult(_0x433681,null))[_0x748c('0x3b')](handleError(_0x433681,null));}; \ No newline at end of file diff --git a/server/api/cmHopperHistory/cmHopperHistory.model.js b/server/api/cmHopperHistory/cmHopperHistory.model.js new file mode 100644 index 0000000..8238a06 --- /dev/null +++ b/server/api/cmHopperHistory/cmHopperHistory.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x77e6=['path','../../config/environment','./cmHopperHistory.attributes','define','endtime','uniqueid','lodash','util','../../config/logger','api','moment','bluebird','request-promise'];(function(_0x28d225,_0x43be18){var _0x1f79e1=function(_0x362c23){while(--_0x362c23){_0x28d225['push'](_0x28d225['shift']());}};_0x1f79e1(++_0x43be18);}(_0x77e6,0x1a6));var _0x677e=function(_0x573e4d,_0x539620){_0x573e4d=_0x573e4d-0x0;var _0x703958=_0x77e6[_0x573e4d];return _0x703958;};'use strict';var _=require(_0x677e('0x0'));var util=require(_0x677e('0x1'));var logger=require(_0x677e('0x2'))(_0x677e('0x3'));var moment=require(_0x677e('0x4'));var BPromise=require(_0x677e('0x5'));var rp=require(_0x677e('0x6'));var fs=require('fs');var path=require(_0x677e('0x7'));var rimraf=require('rimraf');var config=require(_0x677e('0x8'));var attributes=require(_0x677e('0x9'));module['exports']=function(_0x18c5e1,_0x591b21){return _0x18c5e1[_0x677e('0xa')]('CmHopperHistory',attributes,{'tableName':'cm_hopper_history','paranoid':![],'indexes':[{'name':_0x677e('0xb'),'fields':[_0x677e('0xb')]},{'name':_0x677e('0xc'),'fields':[_0x677e('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmHopperHistory/cmHopperHistory.rpc.js b/server/api/cmHopperHistory/cmHopperHistory.rpc.js new file mode 100644 index 0000000..2a39380 --- /dev/null +++ b/server/api/cmHopperHistory/cmHopperHistory.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc961=['options','catch','AvgHandleTime','where','sequelize','col','COUNT','predictiveIntervalAnsweredCalls','literal','`state`\x20=\x2010,\x201,\x20null','predictiveIntervalDroppedCallsTimeout','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgHoldtime','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','raw','campaign','name','outboundNoSuchCallsDay','`state`\x20=\x203,\x201,\x20null','outboundNoAnswerCallsDay','`state`\x20=\x204,\x201,\x20null','outboundAnswerCallsDay','`state`\x20=\x205,\x201,\x20null','`state`\x20=\x208,\x201,\x20null','outboundCongestionCallsDay','`state`\x20=\x2010\x20,\x201,\x20null','outboundDropCallsDayTimeout','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','GetCampaignHopperHistory','findAll','ivrTotalCallsDays','lodash','util','moment','bluebird','randomstring','ioredis','rpc','jayson/promise','http','then','info','CmHopperHistory,\x20%s,\x20%s','request\x20sent','debug','CmHopperHistory,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','CreateCmHopperHistory','CmHopperHistory','create','body'];(function(_0x2c91e9,_0x2fb965){var _0x13f0ff=function(_0xb39edf){while(--_0xb39edf){_0x2c91e9['push'](_0x2c91e9['shift']());}};_0x13f0ff(++_0x2fb965);}(_0xc961,0x17a));var _0x1c96=function(_0x232d09,_0x30a518){_0x232d09=_0x232d09-0x0;var _0x454385=_0xc961[_0x232d09];return _0x454385;};'use strict';var _=require(_0x1c96('0x0'));var util=require(_0x1c96('0x1'));var moment=require(_0x1c96('0x2'));var BPromise=require(_0x1c96('0x3'));var rs=require(_0x1c96('0x4'));var fs=require('fs');var Redis=require(_0x1c96('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x1c96('0x6'));var config=require('../../config/environment');var jayson=require(_0x1c96('0x7'));var client=jayson['client'][_0x1c96('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2d4b23,_0x1f09ff,_0x307846){return new BPromise(function(_0x2e4fa5,_0x473a4c){return client['request'](_0x2d4b23,_0x307846)[_0x1c96('0x9')](function(_0x362e46){logger[_0x1c96('0xa')](_0x1c96('0xb'),_0x1f09ff,_0x1c96('0xc'));logger[_0x1c96('0xd')](_0x1c96('0xe'),_0x1f09ff,_0x1c96('0xc'),JSON[_0x1c96('0xf')](_0x362e46));if(_0x362e46[_0x1c96('0x10')]){if(_0x362e46[_0x1c96('0x10')][_0x1c96('0x11')]===0x1f4){logger['error'](_0x1c96('0xb'),_0x1f09ff,_0x362e46[_0x1c96('0x10')]['message']);return _0x473a4c(_0x362e46[_0x1c96('0x10')][_0x1c96('0x12')]);}logger[_0x1c96('0x10')](_0x1c96('0xb'),_0x1f09ff,_0x362e46[_0x1c96('0x10')][_0x1c96('0x12')]);return _0x2e4fa5(_0x362e46[_0x1c96('0x10')][_0x1c96('0x12')]);}else{logger[_0x1c96('0xa')](_0x1c96('0xb'),_0x1f09ff,_0x1c96('0xc'));_0x2e4fa5(_0x362e46[_0x1c96('0x13')][_0x1c96('0x12')]);}})['catch'](function(_0x32596e){logger['error'](_0x1c96('0xb'),_0x1f09ff,_0x32596e);_0x473a4c(_0x32596e);});});}exports[_0x1c96('0x14')]=function(_0x595429){var _0x29dafb=this;return new Promise(function(_0x491875,_0x57efce){return db[_0x1c96('0x15')][_0x1c96('0x16')](_0x595429[_0x1c96('0x17')],{'raw':_0x595429['options']?_0x595429[_0x1c96('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x1c96('0x9')](function(_0x174ebf){logger['info'](_0x1c96('0x14'),_0x595429);logger['debug'](_0x1c96('0x14'),_0x595429,JSON[_0x1c96('0xf')](_0x174ebf));_0x491875(_0x174ebf);})[_0x1c96('0x19')](function(_0x3f4293){logger[_0x1c96('0x10')](_0x1c96('0x14'),_0x3f4293[_0x1c96('0x12')],_0x595429);_0x57efce(_0x29dafb[_0x1c96('0x10')](0x1f4,_0x3f4293[_0x1c96('0x12')]));});});};exports[_0x1c96('0x1a')]=function(_0x4d2c9c){var _0x24c60c=this;return new Promise(function(_0x18b849,_0x289ee5){return db['CmHopperHistory']['findAll']({'raw':_0x4d2c9c[_0x1c96('0x18')]?_0x4d2c9c[_0x1c96('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x4d2c9c[_0x1c96('0x18')]?_0x4d2c9c[_0x1c96('0x18')][_0x1c96('0x1b')]||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0x1c96('0x1c')][_0x1c96('0x1d')]('id')),'predictiveIntervalTotalCalls'],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')]['literal']('`state`\x20=\x204,\x201,\x20null'))),_0x1c96('0x1f')],[db['sequelize']['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db['sequelize'][_0x1c96('0x20')](_0x1c96('0x21')))),_0x1c96('0x22')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db['sequelize']['literal'](_0x1c96('0x23')))),_0x1c96('0x24')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x25'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x26')))),_0x1c96('0x27')],[db['sequelize']['fn'](_0x1c96('0x25'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x28')))),_0x1c96('0x29')]]})['then'](function(_0x353732){logger[_0x1c96('0xa')]('AvgHandleTime',_0x4d2c9c);logger[_0x1c96('0xd')](_0x1c96('0x1a'),_0x4d2c9c,JSON[_0x1c96('0xf')](_0x353732));_0x18b849(_0x353732);})[_0x1c96('0x19')](function(_0x2c812c){logger[_0x1c96('0x10')](_0x1c96('0x1a'),_0x2c812c['message'],_0x4d2c9c);_0x289ee5(_0x24c60c['error'](0x1f4,_0x2c812c[_0x1c96('0x12')]));});});};exports[_0x1c96('0x2a')]=function(_0x51fd52){var _0x30a200=this;return new Promise(function(_0x53214a,_0x2adcb3){return db[_0x1c96('0x15')]['findAll']({'raw':_0x51fd52['options']?_0x51fd52[_0x1c96('0x18')][_0x1c96('0x2b')]===undefined?!![]:![]:!![],'where':_0x51fd52[_0x1c96('0x18')]?_0x51fd52[_0x1c96('0x18')][_0x1c96('0x1b')]||null:null,'attributes':[[_0x1c96('0x2c'),_0x1c96('0x2d')],[db['sequelize']['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db['sequelize'][_0x1c96('0x20')]('`state`\x20=\x200,\x201,\x20null'))),_0x1c96('0x2e')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db['sequelize'][_0x1c96('0x20')](_0x1c96('0x2f')))),_0x1c96('0x30')],[db[_0x1c96('0x1c')]['fn']('COUNT',db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')]['literal'](_0x1c96('0x31')))),_0x1c96('0x32')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x33')))),'outboundBusyCallsDay'],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x34')))),_0x1c96('0x35')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db['sequelize'][_0x1c96('0x20')](_0x1c96('0x36')))),_0x1c96('0x37')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db['sequelize'][_0x1c96('0x20')](_0x1c96('0x38')))),_0x1c96('0x39')],[db['sequelize']['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db['sequelize'][_0x1c96('0x20')]('`state`\x20=\x2012,\x201,\x20null'))),'outboundUnknownCallsDay'],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x2013,\x201,\x20null'))),_0x1c96('0x3a')],[db['sequelize']['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x3b')))),_0x1c96('0x3c')],[db['sequelize']['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')]('`state`\x20=\x2018,\x201,\x20null'))),_0x1c96('0x3d')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x3e')))),'outboundAnswerAgiCallsDay'],[db[_0x1c96('0x1c')]['fn']('COUNT',db[_0x1c96('0x1c')]['fn']('IF',db[_0x1c96('0x1c')]['literal']('`state`\x20=\x2020,\x201,\x20null'))),_0x1c96('0x3d')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x3f')))),'outboundReCallsDay']],'group':['campaign']})[_0x1c96('0x9')](function(_0x534f61){logger['info']('GetVoiceQueueHopperHistory',_0x51fd52);logger['debug'](_0x1c96('0x2a'),_0x51fd52,JSON['stringify'](_0x534f61));_0x53214a(_0x534f61);})['catch'](function(_0x5c896e){logger[_0x1c96('0x10')](_0x1c96('0x2a'),_0x5c896e[_0x1c96('0x12')],_0x51fd52);_0x2adcb3(_0x30a200[_0x1c96('0x10')](0x1f4,_0x5c896e[_0x1c96('0x12')]));});});};exports[_0x1c96('0x40')]=function(_0x42ac0d){var _0x365116=this;return new Promise(function(_0x9e73ff,_0x4e4342){return db[_0x1c96('0x15')][_0x1c96('0x41')]({'raw':_0x42ac0d[_0x1c96('0x18')]?_0x42ac0d[_0x1c96('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x42ac0d[_0x1c96('0x18')]?_0x42ac0d[_0x1c96('0x18')][_0x1c96('0x1b')]||null:null,'attributes':[[_0x1c96('0x2c'),_0x1c96('0x2d')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db[_0x1c96('0x1c')]['col']('id')),_0x1c96('0x42')],[db[_0x1c96('0x1c')]['fn'](_0x1c96('0x1e'),db['sequelize']['fn']('IF',db[_0x1c96('0x1c')][_0x1c96('0x20')](_0x1c96('0x31')))),'ivrAnswerCallsDay']],'group':['campaign']})[_0x1c96('0x9')](function(_0x457332){logger['info']('GetCampaignHopperHistory',_0x42ac0d);logger['debug'](_0x1c96('0x40'),_0x42ac0d,JSON[_0x1c96('0xf')](_0x457332));_0x9e73ff(_0x457332);})[_0x1c96('0x19')](function(_0x1f63ac){logger['error'](_0x1c96('0x40'),_0x1f63ac[_0x1c96('0x12')],_0x42ac0d);_0x4e4342(_0x365116[_0x1c96('0x10')](0x1f4,_0x1f63ac[_0x1c96('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/cmHopperHistory/index.js b/server/api/cmHopperHistory/index.js new file mode 100644 index 0000000..d681ef6 --- /dev/null +++ b/server/api/cmHopperHistory/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeb41=['create','put','/:id','update','exports','multer','util','connect-timeout','express','Router','../../components/auth/service','../../components/interaction/service','get','isAuthenticated','index','/describe','describe','show','post'];(function(_0x183a3c,_0x3f8402){var _0x31f8f1=function(_0x532279){while(--_0x532279){_0x183a3c['push'](_0x183a3c['shift']());}};_0x31f8f1(++_0x3f8402);}(_0xeb41,0x122));var _0x1eb4=function(_0x3ab51d,_0x2fa01d){_0x3ab51d=_0x3ab51d-0x0;var _0x29a04e=_0xeb41[_0x3ab51d];return _0x29a04e;};'use strict';var multer=require(_0x1eb4('0x0'));var util=require(_0x1eb4('0x1'));var path=require('path');var timeout=require(_0x1eb4('0x2'));var express=require(_0x1eb4('0x3'));var router=express[_0x1eb4('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x1eb4('0x5'));var interaction=require(_0x1eb4('0x6'));var config=require('../../config/environment');var controller=require('./cmHopperHistory.controller');router[_0x1eb4('0x7')]('/',auth[_0x1eb4('0x8')](),controller[_0x1eb4('0x9')]);router[_0x1eb4('0x7')](_0x1eb4('0xa'),auth[_0x1eb4('0x8')](),controller[_0x1eb4('0xb')]);router[_0x1eb4('0x7')]('/:id',auth[_0x1eb4('0x8')](),controller[_0x1eb4('0xc')]);router[_0x1eb4('0xd')]('/',auth[_0x1eb4('0x8')](),controller[_0x1eb4('0xe')]);router[_0x1eb4('0xf')](_0x1eb4('0x10'),auth['isAuthenticated'](),controller[_0x1eb4('0x11')]);module[_0x1eb4('0x12')]=router; \ No newline at end of file diff --git a/server/api/cmList/cmList.attributes.js b/server/api/cmList/cmList.attributes.js new file mode 100644 index 0000000..b0b89e7 --- /dev/null +++ b/server/api/cmList/cmList.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3a0f=['STRING'];(function(_0x532112,_0x37d94b){var _0x23e5fb=function(_0x690ac8){while(--_0x690ac8){_0x532112['push'](_0x532112['shift']());}};_0x23e5fb(++_0x37d94b);}(_0x3a0f,0x145));var _0xf3a0=function(_0x55e001,_0x82fc54){_0x55e001=_0x55e001-0x0;var _0xf487fa=_0x3a0f[_0x55e001];return _0xf487fa;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0xf3a0('0x0')],'unique':'name','allowNull':![],'validate':{'notEmpty':!![]}},'description':{'type':Sequelize['STRING']},'dialPrefix':{'type':Sequelize[_0xf3a0('0x0')]}}; \ No newline at end of file diff --git a/server/api/cmList/cmList.controller.js b/server/api/cmList/cmList.controller.js new file mode 100644 index 0000000..63d603b --- /dev/null +++ b/server/api/cmList/cmList.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa0e6=['raw','getContactsCsv','ContactItemType','OrderBy','alias','select','cm_contacts','c.ListId\x20=\x20?','field','c.cf_','item','from','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','description_additionalPhone_','toString','/tmp/list_%d_%s.csv','setHeader','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','findOne','transaction','addCustomFields','Sequelize','TEXT','number','INTEGER','switch','sequelize','queryInterface','addColumn','findAndCountAll','getGlobalCustomFields','addAgents','spread','removeAgents','emit','userCmList:remove','getAgents','info','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','get','Lists','UserProfileResource','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','offset','order','sort','where','pick','filter','merge','options','includeAll','CmList','findAll','rows','catch','show','params','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ListId','Disposition','removeDispositions','CmContact','tags','isArray','push','each','omit','ids','success','errors','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','format','cf_%d'];(function(_0x39f9ac,_0x2dae2d){var _0x500e6=function(_0x4b6bd4){while(--_0x4b6bd4){_0x39f9ac['push'](_0x39f9ac['shift']());}};_0x500e6(++_0x2dae2d);}(_0xa0e6,0xca));var _0x6a0e=function(_0x43eab0,_0x22ca92){_0x43eab0=_0x43eab0-0x0;var _0x1635bc=_0xa0e6[_0x43eab0];return _0x1635bc;};'use strict';var emlformat=require(_0x6a0e('0x0'));var rimraf=require(_0x6a0e('0x1'));var zipdir=require(_0x6a0e('0x2'));var jsonpatch=require(_0x6a0e('0x3'));var rp=require('request-promise');var moment=require(_0x6a0e('0x4'));var BPromise=require(_0x6a0e('0x5'));var Mustache=require(_0x6a0e('0x6'));var util=require(_0x6a0e('0x7'));var path=require(_0x6a0e('0x8'));var sox=require(_0x6a0e('0x9'));var csv=require(_0x6a0e('0xa'));var ejs=require(_0x6a0e('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x6a0e('0xc'));var crypto=require('crypto');var jsforce=require(_0x6a0e('0xd'));var deskjs=require(_0x6a0e('0xe'));var toCsv=require(_0x6a0e('0xa'));var querystring=require(_0x6a0e('0xf'));var Papa=require('papaparse');var Redis=require(_0x6a0e('0x10'));var authService=require(_0x6a0e('0x11'));var qs=require(_0x6a0e('0x12'));var as=require(_0x6a0e('0x13'));var hardwareService=require(_0x6a0e('0x14'));var logger=require('../../config/logger')(_0x6a0e('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x6a0e('0x16'));var db=require(_0x6a0e('0x17'))['db'];var csv_results;config['redis']=_[_0x6a0e('0x18')](config[_0x6a0e('0x19')],{'host':_0x6a0e('0x1a'),'port':0x18eb});var socket=require(_0x6a0e('0x1b'))(new Redis(config[_0x6a0e('0x19')]));require('./cmList.socket')[_0x6a0e('0x1c')](socket);function respondWithStatusCode(_0x1d848f,_0x4ef6c1){_0x4ef6c1=_0x4ef6c1||0xcc;return function(_0x1f8449){if(_0x1f8449){return _0x1d848f[_0x6a0e('0x1d')](_0x4ef6c1);}return _0x1d848f[_0x6a0e('0x1e')](_0x4ef6c1)[_0x6a0e('0x1f')]();};}function respondWithResult(_0x14583f,_0x445222){_0x445222=_0x445222||0xc8;return function(_0x5762fc){if(_0x5762fc){return _0x14583f[_0x6a0e('0x1e')](_0x445222)[_0x6a0e('0x20')](_0x5762fc);}};}function respondWithFilteredResult(_0x49c482,_0xe7825){return function(_0x54a100){if(_0x54a100){var _0x585629=typeof _0xe7825['offset']===_0x6a0e('0x21')&&typeof _0xe7825[_0x6a0e('0x22')]===_0x6a0e('0x21');var _0x555899=_0x54a100[_0x6a0e('0x23')];var _0x1fe84f=_0x585629?0x0:_0xe7825['offset'];var _0x5a8983=_0x585629?_0x54a100[_0x6a0e('0x23')]:_0xe7825['offset']+_0xe7825[_0x6a0e('0x22')];var _0x39a1be;if(_0x5a8983>=_0x555899){_0x5a8983=_0x555899;_0x39a1be=0xc8;}else{_0x39a1be=0xce;}_0x49c482[_0x6a0e('0x1e')](_0x39a1be);return _0x49c482[_0x6a0e('0x24')](_0x6a0e('0x25'),_0x1fe84f+'-'+_0x5a8983+'/'+_0x555899)[_0x6a0e('0x20')](_0x54a100);}return null;};}function patchUpdates(_0x5246cf){return function(_0x210596){try{jsonpatch[_0x6a0e('0x26')](_0x210596,_0x5246cf,!![]);}catch(_0x38e92f){return BPromise[_0x6a0e('0x27')](_0x38e92f);}return _0x210596[_0x6a0e('0x28')]();};}function saveUpdates(_0x22c863,_0x52f42a){return function(_0x24304b){if(_0x24304b){return _0x24304b[_0x6a0e('0x29')](_0x22c863)[_0x6a0e('0x2a')](function(_0x2dc853){return _0x2dc853;});}return null;};}function removeEntity(_0x21e549,_0x2966b0){return function(_0x2fcdd5){if(_0x2fcdd5){return _0x2fcdd5[_0x6a0e('0x2b')]()[_0x6a0e('0x2a')](function(){var _0x426a62=_0x2fcdd5[_0x6a0e('0x2c')]({'plain':!![]});var _0x4efb4e=_0x6a0e('0x2d');return db[_0x6a0e('0x2e')]['destroy']({'where':{'type':_0x4efb4e,'resourceId':_0x426a62['id']}})['then'](function(){return _0x2fcdd5;});})[_0x6a0e('0x2a')](function(){_0x21e549[_0x6a0e('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5eb1a4,_0x5ad5d6){return function(_0x3160fc){if(!_0x3160fc){_0x5eb1a4[_0x6a0e('0x1d')](0x194);}return _0x3160fc;};}function handleError(_0x3374fa,_0x13604f){_0x13604f=_0x13604f||0x1f4;return function(_0x4effd3){logger[_0x6a0e('0x2f')](_0x4effd3[_0x6a0e('0x30')]);if(_0x4effd3[_0x6a0e('0x31')]){delete _0x4effd3[_0x6a0e('0x31')];}_0x3374fa['status'](_0x13604f)[_0x6a0e('0x32')](_0x4effd3);};}exports[_0x6a0e('0x33')]=function(_0x1b7dd5,_0x40a3f7){var _0x4ad104={},_0x53c4f0={},_0x7679ad={'count':0x0,'rows':[]};var _0x541dd2=_[_0x6a0e('0x34')](db['CmList'][_0x6a0e('0x35')],function(_0x453fb8){return{'name':_0x453fb8[_0x6a0e('0x36')],'type':_0x453fb8[_0x6a0e('0x37')]['key']};});_0x53c4f0[_0x6a0e('0x38')]=_[_0x6a0e('0x34')](_0x541dd2,_0x6a0e('0x31'));_0x53c4f0['query']=_[_0x6a0e('0x39')](_0x1b7dd5[_0x6a0e('0x3a')]);_0x53c4f0[_0x6a0e('0x3b')]=_[_0x6a0e('0x3c')](_0x53c4f0[_0x6a0e('0x38')],_0x53c4f0[_0x6a0e('0x3a')]);_0x4ad104['attributes']=_['intersection'](_0x53c4f0['model'],qs[_0x6a0e('0x3d')](_0x1b7dd5[_0x6a0e('0x3a')]['fields']));_0x4ad104[_0x6a0e('0x3e')]=_0x4ad104[_0x6a0e('0x3e')][_0x6a0e('0x3f')]?_0x4ad104[_0x6a0e('0x3e')]:_0x53c4f0[_0x6a0e('0x38')];if(!_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x40')](_0x6a0e('0x41'))){_0x4ad104[_0x6a0e('0x22')]=qs[_0x6a0e('0x22')](_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x22')]);_0x4ad104[_0x6a0e('0x42')]=qs[_0x6a0e('0x42')](_0x1b7dd5['query'][_0x6a0e('0x42')]);}_0x4ad104[_0x6a0e('0x43')]=qs[_0x6a0e('0x44')](_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x44')]);_0x4ad104[_0x6a0e('0x45')]=qs['filters'](_[_0x6a0e('0x46')](_0x1b7dd5[_0x6a0e('0x3a')],_0x53c4f0[_0x6a0e('0x3b')]),_0x541dd2);if(_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x47')]){_0x4ad104[_0x6a0e('0x45')]=_['merge'](_0x4ad104[_0x6a0e('0x45')],{'$or':_[_0x6a0e('0x34')](_0x541dd2,function(_0x1342ab){if(_0x1342ab[_0x6a0e('0x37')]!=='VIRTUAL'){var _0x432962={};_0x432962[_0x1342ab[_0x6a0e('0x31')]]={'$like':'%'+_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x47')]+'%'};return _0x432962;}})});}_0x4ad104=_[_0x6a0e('0x48')]({},_0x4ad104,_0x1b7dd5[_0x6a0e('0x49')]);var _0x306bd6={'where':_0x4ad104[_0x6a0e('0x45')]};return db['CmList']['count'](_0x306bd6)['then'](function(_0x114b67){_0x7679ad[_0x6a0e('0x23')]=_0x114b67;if(_0x1b7dd5[_0x6a0e('0x3a')][_0x6a0e('0x4a')]){_0x4ad104['include']=[{'all':!![]}];}return db[_0x6a0e('0x4b')][_0x6a0e('0x4c')](_0x4ad104);})[_0x6a0e('0x2a')](function(_0x13f413){_0x7679ad[_0x6a0e('0x4d')]=_0x13f413;return _0x7679ad;})[_0x6a0e('0x2a')](respondWithFilteredResult(_0x40a3f7,_0x4ad104))[_0x6a0e('0x4e')](handleError(_0x40a3f7,null));};exports[_0x6a0e('0x4f')]=function(_0x5ce5d8,_0x1fa36b){var _0x5327ef={'raw':![],'where':{'id':_0x5ce5d8[_0x6a0e('0x50')]['id']}},_0x2d057b={};_0x2d057b['model']=_[_0x6a0e('0x39')](db[_0x6a0e('0x4b')]['rawAttributes']);_0x2d057b[_0x6a0e('0x3a')]=_[_0x6a0e('0x39')](_0x5ce5d8[_0x6a0e('0x3a')]);_0x2d057b[_0x6a0e('0x3b')]=_[_0x6a0e('0x3c')](_0x2d057b[_0x6a0e('0x38')],_0x2d057b[_0x6a0e('0x3a')]);_0x5327ef[_0x6a0e('0x3e')]=_[_0x6a0e('0x3c')](_0x2d057b[_0x6a0e('0x38')],qs[_0x6a0e('0x3d')](_0x5ce5d8['query'][_0x6a0e('0x3d')]));_0x5327ef[_0x6a0e('0x3e')]=_0x5327ef[_0x6a0e('0x3e')][_0x6a0e('0x3f')]?_0x5327ef['attributes']:_0x2d057b[_0x6a0e('0x38')];if(_0x5ce5d8[_0x6a0e('0x3a')][_0x6a0e('0x4a')]){_0x5327ef[_0x6a0e('0x51')]=[{'all':!![]}];}_0x5327ef=_[_0x6a0e('0x48')]({},_0x5327ef,_0x5ce5d8[_0x6a0e('0x49')]);return db[_0x6a0e('0x4b')]['find'](_0x5327ef)[_0x6a0e('0x2a')](handleEntityNotFound(_0x1fa36b,null))['then'](respondWithResult(_0x1fa36b,null))[_0x6a0e('0x4e')](handleError(_0x1fa36b,null));};exports[_0x6a0e('0x52')]=function(_0x5983a0,_0x3cb2fa){return db[_0x6a0e('0x4b')][_0x6a0e('0x52')](_0x5983a0[_0x6a0e('0x53')],{})['then'](function(_0x3acc80){var _0x4c2959=_0x5983a0[_0x6a0e('0x54')]['get']({'plain':!![]});if(!_0x4c2959)throw new Error(_0x6a0e('0x55'));if(_0x4c2959[_0x6a0e('0x56')]===_0x6a0e('0x54')){var _0x5b7b49=_0x3acc80['get']({'plain':!![]});var _0x16e15b=_0x6a0e('0x2d');return db[_0x6a0e('0x57')][_0x6a0e('0x58')]({'where':{'name':_0x16e15b,'userProfileId':_0x4c2959['userProfileId']},'raw':!![]})[_0x6a0e('0x2a')](function(_0x447f97){if(_0x447f97&&_0x447f97[_0x6a0e('0x59')]===0x0){return db[_0x6a0e('0x2e')][_0x6a0e('0x52')]({'name':_0x5b7b49['name'],'resourceId':_0x5b7b49['id'],'type':_0x447f97[_0x6a0e('0x31')],'sectionId':_0x447f97['id']},{})[_0x6a0e('0x2a')](function(){return _0x3acc80;});}else{return _0x3acc80;}})[_0x6a0e('0x4e')](function(_0x3fdfdd){logger[_0x6a0e('0x2f')](_0x6a0e('0x5a'),_0x3fdfdd);throw _0x3fdfdd;});}return _0x3acc80;})[_0x6a0e('0x2a')](respondWithResult(_0x3cb2fa,0xc9))[_0x6a0e('0x4e')](handleError(_0x3cb2fa,null));};exports['update']=function(_0x111434,_0x28b72a){if(_0x111434[_0x6a0e('0x53')]['id']){delete _0x111434[_0x6a0e('0x53')]['id'];}return db['CmList']['find']({'where':{'id':_0x111434[_0x6a0e('0x50')]['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x28b72a,null))['then'](saveUpdates(_0x111434[_0x6a0e('0x53')],null))[_0x6a0e('0x2a')](respondWithResult(_0x28b72a,null))[_0x6a0e('0x4e')](handleError(_0x28b72a,null));};exports['destroy']=function(_0x547395,_0x73f09f){return db[_0x6a0e('0x4b')]['find']({'where':{'id':_0x547395[_0x6a0e('0x50')]['id']}})['then'](handleEntityNotFound(_0x73f09f,null))[_0x6a0e('0x2a')](removeEntity(_0x73f09f,null))[_0x6a0e('0x4e')](handleError(_0x73f09f,null));};exports[_0x6a0e('0x5b')]=function(_0x387a1e,_0x4f734b){return db[_0x6a0e('0x4b')][_0x6a0e('0x5b')]()[_0x6a0e('0x2a')](respondWithResult(_0x4f734b,null))[_0x6a0e('0x4e')](handleError(_0x4f734b,null));};exports[_0x6a0e('0x5c')]=function(_0x3819d8,_0xd425d5,_0x4bcb80){if(_0x3819d8[_0x6a0e('0x53')]['id']){delete _0x3819d8[_0x6a0e('0x53')]['id'];}return db[_0x6a0e('0x4b')][_0x6a0e('0x58')]({'where':{'id':_0x3819d8[_0x6a0e('0x50')]['id']}})['then'](handleEntityNotFound(_0xd425d5,null))[_0x6a0e('0x2a')](function(_0x209d2c){if(_0x209d2c){_0x3819d8['body'][_0x6a0e('0x5d')]=_0x209d2c['id'];return db[_0x6a0e('0x5e')][_0x6a0e('0x52')](_0x3819d8[_0x6a0e('0x53')]);}})[_0x6a0e('0x2a')](respondWithResult(_0xd425d5,null))[_0x6a0e('0x4e')](handleError(_0xd425d5,null));};exports['getDispositions']=function(_0x37a4a1,_0x99cc1c,_0x2abc26){var _0xe30717={'raw':![],'where':{}};var _0x488ba2={};var _0x591a1f={'count':0x0,'rows':[]};return db[_0x6a0e('0x4b')]['findOne']({'where':{'id':_0x37a4a1[_0x6a0e('0x50')]['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x99cc1c,null))[_0x6a0e('0x2a')](function(_0x1c44aa){if(_0x1c44aa){_0x488ba2[_0x6a0e('0x38')]=_[_0x6a0e('0x39')](db[_0x6a0e('0x5e')][_0x6a0e('0x35')]);_0x488ba2[_0x6a0e('0x3a')]=_[_0x6a0e('0x39')](_0x37a4a1['query']);_0x488ba2['filters']=_[_0x6a0e('0x3c')](_0x488ba2[_0x6a0e('0x38')],_0x488ba2[_0x6a0e('0x3a')]);_0xe30717[_0x6a0e('0x3e')]=_[_0x6a0e('0x3c')](_0x488ba2['model'],qs[_0x6a0e('0x3d')](_0x37a4a1[_0x6a0e('0x3a')][_0x6a0e('0x3d')]));_0xe30717['attributes']=_0xe30717['attributes'][_0x6a0e('0x3f')]?_0xe30717[_0x6a0e('0x3e')]:_0x488ba2[_0x6a0e('0x38')];if(!_0x37a4a1[_0x6a0e('0x3a')]['hasOwnProperty']('nolimit')){_0xe30717[_0x6a0e('0x22')]=qs[_0x6a0e('0x22')](_0x37a4a1['query']['limit']);_0xe30717[_0x6a0e('0x42')]=qs[_0x6a0e('0x42')](_0x37a4a1['query'][_0x6a0e('0x42')]);}_0xe30717[_0x6a0e('0x43')]=qs[_0x6a0e('0x44')](_0x37a4a1[_0x6a0e('0x3a')][_0x6a0e('0x44')]);_0xe30717[_0x6a0e('0x45')]=qs[_0x6a0e('0x3b')](_[_0x6a0e('0x46')](_0x37a4a1[_0x6a0e('0x3a')],_0x488ba2[_0x6a0e('0x3b')]));_0xe30717[_0x6a0e('0x45')]['ListId']=_0x1c44aa['id'];if(_0x37a4a1['query'][_0x6a0e('0x47')]){_0xe30717[_0x6a0e('0x45')]=_[_0x6a0e('0x48')](_0xe30717[_0x6a0e('0x45')],{'$or':_['map'](_0xe30717[_0x6a0e('0x3e')],function(_0x2bf3be){var _0x1e502f={};_0x1e502f[_0x2bf3be]={'$like':'%'+_0x37a4a1['query'][_0x6a0e('0x47')]+'%'};return _0x1e502f;})});}_0xe30717=_['merge']({},_0xe30717,_0x37a4a1['options']);return db['Disposition'][_0x6a0e('0x23')]({'where':_0xe30717[_0x6a0e('0x45')]})['then'](function(_0x2e54be){_0x591a1f[_0x6a0e('0x23')]=_0x2e54be;if(_0x37a4a1[_0x6a0e('0x3a')][_0x6a0e('0x4a')]){_0xe30717['include']=[{'all':!![]}];}return db['Disposition'][_0x6a0e('0x4c')](_0xe30717);})[_0x6a0e('0x2a')](function(_0x523869){_0x591a1f[_0x6a0e('0x4d')]=_0x523869;return _0x591a1f;});}})['then'](respondWithFilteredResult(_0x99cc1c,_0xe30717))[_0x6a0e('0x4e')](handleError(_0x99cc1c,null));};exports[_0x6a0e('0x5f')]=function(_0x936c7a,_0x76ec97,_0x58766e){return db['CmList']['find']({'where':{'id':_0x936c7a['params']['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x76ec97,null))['then'](function(_0xc9d562){if(_0xc9d562){return _0xc9d562[_0x6a0e('0x5f')](_0x936c7a[_0x6a0e('0x3a')]['ids']);}})[_0x6a0e('0x2a')](respondWithStatusCode(_0x76ec97,null))[_0x6a0e('0x4e')](handleError(_0x76ec97,null));};exports['addContacts']=function(_0xb55ed6,_0x27b4d2,_0x4b1a2b){return db[_0x6a0e('0x4b')][_0x6a0e('0x58')]({'where':{'id':_0xb55ed6[_0x6a0e('0x50')]['id']}})['then'](handleEntityNotFound(_0x27b4d2,null))[_0x6a0e('0x2a')](function(_0x32f9c6){if(_0x32f9c6){var _0x383156=[];var _0x10b89f={'success':[],'errors':[]};return db[_0x6a0e('0x60')][_0x6a0e('0x5b')]()[_0x6a0e('0x2a')](function(_0x2e6f26){if(_0xb55ed6['body']['tags']&&_['isArray'](_0xb55ed6['body'][_0x6a0e('0x61')])){if(_0xb55ed6[_0x6a0e('0x53')]['tags'][_0x6a0e('0x3f')]){_0xb55ed6[_0x6a0e('0x53')]['tags']=_0xb55ed6[_0x6a0e('0x53')][_0x6a0e('0x61')]['join'](';')+';';}else{_0xb55ed6[_0x6a0e('0x53')][_0x6a0e('0x61')]=null;}}else{_0xb55ed6[_0x6a0e('0x53')][_0x6a0e('0x61')]=null;}if(_0xb55ed6[_0x6a0e('0x53')]&&_[_0x6a0e('0x62')](_0xb55ed6['body'])){for(var _0x11d897=0x0;_0x11d897<_0xb55ed6[_0x6a0e('0x53')][_0x6a0e('0x3f')];_0x11d897+=0x1){_0xb55ed6['body'][_0x11d897][_0x6a0e('0x5d')]=_0xb55ed6[_0x6a0e('0x50')]['id'];_0x383156[_0x6a0e('0x63')](_0xb55ed6['body'][_0x11d897]);}return BPromise[_0x6a0e('0x64')](_0x383156,function(_0x303587){return db['CmContact'][_0x6a0e('0x52')](_[_0x6a0e('0x65')](_0x303587,[_0x6a0e('0x66'),'id'])||{},{'fields':_['keys'](_0x2e6f26),'raw':!![]})[_0x6a0e('0x2a')](function(_0x4ed313){_0x10b89f[_0x6a0e('0x67')]['push'](_0x4ed313['dataValues']);})[_0x6a0e('0x4e')](function(_0x37bc89){_0x10b89f[_0x6a0e('0x68')]['push']({'data':_0x303587,'error':_0x37bc89['message']});});})['then'](function(_0x5442b1){return _0x10b89f;})[_0x6a0e('0x4e')](function(_0x237b10){return _0x237b10;});}else{_0x27b4d2[_0x6a0e('0x1e')](0x190)[_0x6a0e('0x20')]({'message':_0x6a0e('0x69')});}});}})[_0x6a0e('0x2a')](respondWithResult(_0x27b4d2,null))['catch'](handleError(_0x27b4d2,null));};exports[_0x6a0e('0x6a')]=function(_0x4426b3,_0x3233d8,_0x4ae3ba){var _0x20f520;return db[_0x6a0e('0x4b')]['find']({'where':{'id':_0x4426b3[_0x6a0e('0x50')]['id']},'include':[{'model':db[_0x6a0e('0x6b')],'as':_0x6a0e('0x6c')}]})[_0x6a0e('0x2a')](handleEntityNotFound(_0x3233d8,null))[_0x6a0e('0x2a')](function(_0x26adf0){if(_0x26adf0){_0x20f520=_0x26adf0;return db[_0x6a0e('0x60')][_0x6a0e('0x35')];}})[_0x6a0e('0x2a')](function(_0x94917f){if(_0x94917f){var _0x405633={};var _0x317cec={};_0x317cec[_0x6a0e('0x38')]=_[_0x6a0e('0x6d')](_['keys'](_0x94917f),_[_0x6a0e('0x34')](_0x20f520[_0x6a0e('0x6c')],function(_0x3a3872){return util[_0x6a0e('0x6e')](_0x6a0e('0x6f'),_0x3a3872['id']);}));_0x317cec[_0x6a0e('0x3a')]=_[_0x6a0e('0x39')](_0x4426b3[_0x6a0e('0x3a')]);_0x317cec[_0x6a0e('0x3b')]=_[_0x6a0e('0x3c')](_0x317cec[_0x6a0e('0x38')],_0x317cec['query']);_0x405633[_0x6a0e('0x3e')]=_[_0x6a0e('0x3c')](_0x317cec['model'],qs[_0x6a0e('0x3d')](_0x4426b3[_0x6a0e('0x3a')][_0x6a0e('0x3d')]));_0x405633[_0x6a0e('0x3e')]=_0x405633[_0x6a0e('0x3e')][_0x6a0e('0x3f')]?_0x405633[_0x6a0e('0x3e')]:_0x317cec[_0x6a0e('0x38')];if(!_0x4426b3['query'][_0x6a0e('0x40')](_0x6a0e('0x41'))){_0x405633[_0x6a0e('0x22')]=qs['limit'](_0x4426b3['query'][_0x6a0e('0x22')]);_0x405633[_0x6a0e('0x42')]=qs[_0x6a0e('0x42')](_0x4426b3['query'][_0x6a0e('0x42')]);}_0x405633['order']=qs['sort'](_0x4426b3['query'][_0x6a0e('0x44')]);_0x405633[_0x6a0e('0x45')]=qs['filters'](_[_0x6a0e('0x46')](_0x4426b3[_0x6a0e('0x3a')],_0x317cec[_0x6a0e('0x3b')]));_0x405633[_0x6a0e('0x70')]=!![];if(_0x4426b3[_0x6a0e('0x3a')][_0x6a0e('0x47')]){_0x405633[_0x6a0e('0x45')]=_['merge'](_0x405633[_0x6a0e('0x45')],{'$or':_[_0x6a0e('0x34')](_0x405633[_0x6a0e('0x3e')],function(_0x2b9554){var _0x1166c0={};_0x1166c0[_0x2b9554]={'$like':'%'+_0x4426b3[_0x6a0e('0x3a')][_0x6a0e('0x47')]+'%'};return _0x1166c0;})});}_0x405633=_[_0x6a0e('0x48')]({},_0x405633,_0x4426b3['options']);return _0x20f520[_0x6a0e('0x6a')](_0x405633);}})[_0x6a0e('0x2a')](respondWithResult(_0x3233d8,null))[_0x6a0e('0x4e')](handleError(_0x3233d8,null));};exports[_0x6a0e('0x71')]=function(_0x2017f6,_0x450cba,_0x1755c4){var _0x305566;var _0x2852d0;var _0x52a256;var _0xd8af5f=_0x2017f6[_0x6a0e('0x50')]['id'];csv_results=[];return db[_0x6a0e('0x72')][_0x6a0e('0x4c')]({'attributes':['id','name'],'raw':!![],'order':[_0x6a0e('0x73')]})[_0x6a0e('0x2a')](function(_0x181401){_0x305566=_0x181401;var _0x208198=_[_0x6a0e('0x39')](db[_0x6a0e('0x60')][_0x6a0e('0x35')]);return db[_0x6a0e('0x6b')][_0x6a0e('0x4c')]({'raw':!![],'attributes':['id',_0x6a0e('0x74')]})[_0x6a0e('0x2a')](function(_0x521e5d){_0x2852d0=_0x521e5d;var _0x269c29=squel[_0x6a0e('0x75')]()['fields'](_0x208198)['from'](_0x6a0e('0x76'),'c')[_0x6a0e('0x45')](_0x6a0e('0x77'),_0xd8af5f)[_0x6a0e('0x45')]('c.deletedAt\x20is\x20null')['distinct']();for(var _0x18dd17=0x0;_0x18dd17<_0x2852d0[_0x6a0e('0x3f')];_0x18dd17++){_0x269c29[_0x6a0e('0x78')](_0x6a0e('0x79')+_0x2852d0[_0x18dd17]['id'],'customField_'+_0x2852d0[_0x18dd17]['alias']);}for(var _0x18dd17=0x0;_0x18dd17<_0x305566[_0x6a0e('0x3f')];_0x18dd17++){_0x269c29[_0x6a0e('0x78')](squel[_0x6a0e('0x75')]()['field'](_0x6a0e('0x7a'))[_0x6a0e('0x7b')](_0x6a0e('0x7c'))[_0x6a0e('0x45')](_0x6a0e('0x7d'),_0x305566[_0x18dd17]['id'])[_0x6a0e('0x45')](_0x6a0e('0x7e')),'additionalPhone_'+_0x305566[_0x18dd17][_0x6a0e('0x31')]);_0x269c29[_0x6a0e('0x78')](squel['select']()[_0x6a0e('0x78')]('description')[_0x6a0e('0x7b')]('cm_contact_has_items')['where'](_0x6a0e('0x7d'),_0x305566[_0x18dd17]['id'])['where'](_0x6a0e('0x7e')),_0x6a0e('0x7f')+_0x305566[_0x18dd17]['name']);}var _0x704691=[];_0x704691[_0x6a0e('0x63')](_0x269c29[_0x6a0e('0x80')]());BPromise['each'](_0x704691,handleQuery)[_0x6a0e('0x2a')](function(_0x320f74){handleQuery(_0x269c29['toString']());var _0x4c5bc5=csv_results[0x0];if(!_['isEmpty'](_0x4c5bc5)){var _0x471dd5=toCsv(_0x4c5bc5);var _0x11889a=Date['now']();fs['writeFileSync'](util[_0x6a0e('0x6e')](_0x6a0e('0x81'),_0xd8af5f,_0x11889a),_0x471dd5);_0x450cba[_0x6a0e('0x82')]('Content-disposition',_0x6a0e('0x83')+util[_0x6a0e('0x6e')](_0x6a0e('0x84'),_0xd8af5f,_0x11889a));_0x450cba[_0x6a0e('0x82')](_0x6a0e('0x85'),_0x6a0e('0x86'));return _0x450cba[_0x6a0e('0x87')](util[_0x6a0e('0x6e')]('/tmp/list_%d_%s.csv',_0xd8af5f,_0x11889a));}else{return _0x450cba['sendStatus'](0xcc);}});});});};exports[_0x6a0e('0x88')]=function(_0x169866,_0x1ec278,_0x1d66ec){var _0x46adc8;delete _0x169866[_0x6a0e('0x53')]['id'];return db[_0x6a0e('0x4b')][_0x6a0e('0x89')]({'where':{'id':_0x169866[_0x6a0e('0x50')]['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x1ec278,null))['then'](function(_0x32b462){if(_0x32b462){return db['sequelize'][_0x6a0e('0x8a')](function(_0x47648b){return db[_0x6a0e('0x6b')][_0x6a0e('0x52')](_0x169866[_0x6a0e('0x53')],{'transaction':_0x47648b})['then'](function(_0x1605f6){_0x46adc8=_0x1605f6;return _0x32b462[_0x6a0e('0x8b')](_0x1605f6,{'transaction':_0x47648b});})[_0x6a0e('0x2a')](function(){var _0x16c0c8={'type':db[_0x6a0e('0x8c')][_0x6a0e('0x8d')],'transaction':_0x47648b};switch(_0x169866[_0x6a0e('0x53')]['type']){case'text':_0x16c0c8['type']=db[_0x6a0e('0x8c')][_0x6a0e('0x8d')];break;case _0x6a0e('0x8e'):_0x16c0c8[_0x6a0e('0x37')]=db[_0x6a0e('0x8c')][_0x6a0e('0x8f')];break;case _0x6a0e('0x90'):_0x16c0c8[_0x6a0e('0x37')]=db[_0x6a0e('0x8c')]['BOOLEAN'];_0x16c0c8['defaultValue']=![];break;default:}return db[_0x6a0e('0x91')][_0x6a0e('0x92')][_0x6a0e('0x93')]('cm_contacts',util[_0x6a0e('0x6e')]('cf_%s',_0x46adc8['id']),_0x16c0c8);})['then'](function(){return _0x46adc8;});});}})[_0x6a0e('0x2a')](respondWithResult(_0x1ec278,null))['catch'](handleError(_0x1ec278,null));};exports['getCustomFields']=function(_0x272306,_0x34f7a8,_0x3c4533){var _0x250dca={};var _0x212eb0={};var _0x1dd6af;var _0x130412;return db['CmList'][_0x6a0e('0x89')]({'where':{'id':_0x272306['params']['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x34f7a8,null))['then'](function(_0x5499e6){if(_0x5499e6){_0x1dd6af=_0x5499e6;_0x212eb0[_0x6a0e('0x38')]=_['keys'](db['CmCustomField']['rawAttributes']);_0x212eb0[_0x6a0e('0x3a')]=_[_0x6a0e('0x39')](_0x272306[_0x6a0e('0x3a')]);_0x212eb0['filters']=_[_0x6a0e('0x3c')](_0x212eb0[_0x6a0e('0x38')],_0x212eb0['query']);_0x250dca[_0x6a0e('0x3e')]=_[_0x6a0e('0x3c')](_0x212eb0['model'],qs[_0x6a0e('0x3d')](_0x272306[_0x6a0e('0x3a')][_0x6a0e('0x3d')]));_0x250dca['attributes']=_0x250dca[_0x6a0e('0x3e')][_0x6a0e('0x3f')]?_0x250dca[_0x6a0e('0x3e')]:_0x212eb0[_0x6a0e('0x38')];_0x250dca[_0x6a0e('0x43')]=qs[_0x6a0e('0x44')](_0x272306[_0x6a0e('0x3a')]['sort']);_0x250dca['where']=qs[_0x6a0e('0x3b')](_[_0x6a0e('0x46')](_0x272306[_0x6a0e('0x3a')],_0x212eb0[_0x6a0e('0x3b')]));_0x250dca['where']=_[_0x6a0e('0x48')](_0x250dca[_0x6a0e('0x45')],{'$or':[{'ListId':_0x5499e6['id']},{'ListId':null}]});if(_0x272306[_0x6a0e('0x3a')][_0x6a0e('0x47')]){_0x250dca[_0x6a0e('0x45')]=_[_0x6a0e('0x48')](_0x250dca[_0x6a0e('0x45')],{'$or':_['map'](_0x250dca['attributes'],function(_0x17dbaf){var _0x508089={};_0x508089[_0x17dbaf]={'$like':'%'+_0x272306[_0x6a0e('0x3a')][_0x6a0e('0x47')]+'%'};return _0x508089;})});}_0x250dca=_['merge']({},_0x250dca,_0x272306[_0x6a0e('0x49')]);return db[_0x6a0e('0x6b')][_0x6a0e('0x94')](_0x250dca);}})['then'](respondWithResult(_0x34f7a8,null))['catch'](handleError(_0x34f7a8,null));};exports[_0x6a0e('0x95')]=function(_0x4e9066,_0x1ef0ed){return db['CmCustomField'][_0x6a0e('0x94')]({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x1ef0ed,null))[_0x6a0e('0x2a')](function(_0x33f4ae){return _0x33f4ae;})['then'](respondWithResult(_0x1ef0ed,null))[_0x6a0e('0x4e')](handleError(_0x1ef0ed,null));};exports[_0x6a0e('0x96')]=function(_0x2ea1b9,_0x4d317c,_0x1f93c8){return db[_0x6a0e('0x4b')][_0x6a0e('0x58')]({'where':{'id':_0x2ea1b9[_0x6a0e('0x50')]['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x4d317c,null))[_0x6a0e('0x2a')](function(_0x14a22e){if(_0x14a22e){return _0x14a22e[_0x6a0e('0x96')](_0x2ea1b9['body'][_0x6a0e('0x66')],_['omit'](_0x2ea1b9['body'],['ids','id'])||{})[_0x6a0e('0x97')](function(_0x323b64){for(var _0x1c35ab=0x0;_0x1c35ab<_0x2ea1b9[_0x6a0e('0x53')][_0x6a0e('0x66')][_0x6a0e('0x3f')];_0x1c35ab+=0x1){socket['emit']('userCmList:save',{'UserId':Number(_0x2ea1b9[_0x6a0e('0x53')][_0x6a0e('0x66')][_0x1c35ab]),'CmListId':Number(_0x2ea1b9[_0x6a0e('0x50')]['id'])});}return _0x323b64;});}})[_0x6a0e('0x2a')](respondWithResult(_0x4d317c,null))[_0x6a0e('0x4e')](handleError(_0x4d317c,null));};exports[_0x6a0e('0x98')]=function(_0x1c7a47,_0x54c9f1,_0x5d4677){return db[_0x6a0e('0x4b')]['find']({'where':{'id':_0x1c7a47[_0x6a0e('0x50')]['id']}})['then'](handleEntityNotFound(_0x54c9f1,null))[_0x6a0e('0x2a')](function(_0x4baf05){if(_0x4baf05){return _0x4baf05[_0x6a0e('0x98')](_0x1c7a47[_0x6a0e('0x3a')][_0x6a0e('0x66')])[_0x6a0e('0x2a')](function(){if(_[_0x6a0e('0x62')](_0x1c7a47[_0x6a0e('0x3a')]['ids'])){for(var _0xb40b53=0x0;_0xb40b53<_0x1c7a47[_0x6a0e('0x3a')][_0x6a0e('0x66')][_0x6a0e('0x3f')];_0xb40b53+=0x1){socket[_0x6a0e('0x99')](_0x6a0e('0x9a'),{'UserId':Number(_0x1c7a47[_0x6a0e('0x3a')][_0x6a0e('0x66')][_0xb40b53]),'CmListId':Number(_0x1c7a47[_0x6a0e('0x50')]['id'])});}}else{socket[_0x6a0e('0x99')](_0x6a0e('0x9a'),{'UserId':Number(_0x1c7a47[_0x6a0e('0x3a')][_0x6a0e('0x66')]),'CmListId':Number(_0x1c7a47[_0x6a0e('0x50')]['id'])});}});}})[_0x6a0e('0x2a')](respondWithStatusCode(_0x54c9f1,null))['catch'](handleError(_0x54c9f1,null));};exports[_0x6a0e('0x9b')]=function(_0x8e0702,_0x370310,_0x36f141){var _0x4f3d77={};var _0x1a0465={};var _0x50c4a6;var _0x4a5467;return db['CmList'][_0x6a0e('0x89')]({'where':{'id':_0x8e0702[_0x6a0e('0x50')]['id']}})[_0x6a0e('0x2a')](handleEntityNotFound(_0x370310,null))[_0x6a0e('0x2a')](function(_0x1ab68f){if(_0x1ab68f){_0x50c4a6=_0x1ab68f;_0x1a0465[_0x6a0e('0x38')]=_[_0x6a0e('0x39')](db['User'][_0x6a0e('0x35')]);_0x1a0465[_0x6a0e('0x3a')]=_[_0x6a0e('0x39')](_0x8e0702[_0x6a0e('0x3a')]);_0x1a0465[_0x6a0e('0x3b')]=_[_0x6a0e('0x3c')](_0x1a0465[_0x6a0e('0x38')],_0x1a0465[_0x6a0e('0x3a')]);_0x4f3d77[_0x6a0e('0x3e')]=_['intersection'](_0x1a0465[_0x6a0e('0x38')],qs['fields'](_0x8e0702[_0x6a0e('0x3a')][_0x6a0e('0x3d')]));_0x4f3d77[_0x6a0e('0x3e')]=_0x4f3d77[_0x6a0e('0x3e')][_0x6a0e('0x3f')]?_0x4f3d77[_0x6a0e('0x3e')]:_0x1a0465[_0x6a0e('0x38')];_0x4f3d77[_0x6a0e('0x43')]=qs[_0x6a0e('0x44')](_0x8e0702['query'][_0x6a0e('0x44')]);_0x4f3d77[_0x6a0e('0x45')]=qs['filters'](_[_0x6a0e('0x46')](_0x8e0702[_0x6a0e('0x3a')],_0x1a0465['filters']));if(_0x8e0702[_0x6a0e('0x3a')][_0x6a0e('0x47')]){_0x4f3d77[_0x6a0e('0x45')]=_[_0x6a0e('0x48')](_0x4f3d77['where'],{'$or':_[_0x6a0e('0x34')](_0x4f3d77['attributes'],function(_0x2e1043){var _0x5a98e8={};_0x5a98e8[_0x2e1043]={'$like':'%'+_0x8e0702[_0x6a0e('0x3a')][_0x6a0e('0x47')]+'%'};return _0x5a98e8;})});}_0x4f3d77=_[_0x6a0e('0x48')]({},_0x4f3d77,_0x8e0702[_0x6a0e('0x49')]);return _0x50c4a6[_0x6a0e('0x9b')](_0x4f3d77);}})[_0x6a0e('0x2a')](function(_0x163492){if(_0x163492){_0x4a5467=_0x163492['length'];if(!_0x8e0702[_0x6a0e('0x3a')]['hasOwnProperty'](_0x6a0e('0x41'))){_0x4f3d77[_0x6a0e('0x22')]=qs[_0x6a0e('0x22')](_0x8e0702['query']['limit']);_0x4f3d77['offset']=qs['offset'](_0x8e0702['query'][_0x6a0e('0x42')]);}return _0x50c4a6[_0x6a0e('0x9b')](_0x4f3d77);}})[_0x6a0e('0x2a')](function(_0xbba243){if(_0xbba243){return _0xbba243?{'count':_0x4a5467,'rows':_0xbba243}:null;}})[_0x6a0e('0x2a')](respondWithResult(_0x370310,null))[_0x6a0e('0x4e')](handleError(_0x370310,null));};function handleQuery(_0x4acdf0){logger[_0x6a0e('0x9c')](_0x4acdf0);return db[_0x6a0e('0x91')][_0x6a0e('0x3a')](_0x4acdf0)[_0x6a0e('0x97')](function(_0x3c62c2){csv_results['push'](_0x3c62c2);})[_0x6a0e('0x4e')](function(_0x28b3f2){logger[_0x6a0e('0x2f')](_0x28b3f2['message']);});} \ No newline at end of file diff --git a/server/api/cmList/cmList.events.js b/server/api/cmList/cmList.events.js new file mode 100644 index 0000000..1c6c2b5 --- /dev/null +++ b/server/api/cmList/cmList.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e74=['hasOwnProperty','exports','events','CmList','setMaxListeners','save','emit'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3e74,0x175));var _0x43e7=function(_0x59c0f4,_0x1074e6){_0x59c0f4=_0x59c0f4-0x0;var _0x4a87a3=_0x3e74[_0x59c0f4];return _0x4a87a3;};'use strict';var EventEmitter=require(_0x43e7('0x0'));var CmList=require('../../mysqldb')['db'][_0x43e7('0x1')];var CmListEvents=new EventEmitter();CmListEvents[_0x43e7('0x2')](0x0);var events={'afterCreate':_0x43e7('0x3'),'afterUpdate':'update','afterDestroy':'remove'};function emitEvent(_0xc58479){return function(_0x4f9bbe,_0x128b0f,_0xe838b4){CmListEvents[_0x43e7('0x4')](_0xc58479+':'+_0x4f9bbe['id'],_0x4f9bbe);CmListEvents[_0x43e7('0x4')](_0xc58479,_0x4f9bbe);_0xe838b4(null);};}for(var e in events){if(events[_0x43e7('0x5')](e)){var event=events[e];CmList['hook'](e,emitEvent(event));}}module[_0x43e7('0x6')]=CmListEvents; \ No newline at end of file diff --git a/server/api/cmList/cmList.model.js b/server/api/cmList/cmList.model.js new file mode 100644 index 0000000..ad2d43d --- /dev/null +++ b/server/api/cmList/cmList.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6f0d=['./cmList.attributes','define','CmList','cm_lists','util','../../config/logger','api','moment','request-promise','path','rimraf','../../config/environment'];(function(_0x29d94e,_0xf386d6){var _0x106237=function(_0x327501){while(--_0x327501){_0x29d94e['push'](_0x29d94e['shift']());}};_0x106237(++_0xf386d6);}(_0x6f0d,0x16c));var _0xd6f0=function(_0x2f1a01,_0x17cd42){_0x2f1a01=_0x2f1a01-0x0;var _0x323b3e=_0x6f0d[_0x2f1a01];return _0x323b3e;};'use strict';var _=require('lodash');var util=require(_0xd6f0('0x0'));var logger=require(_0xd6f0('0x1'))(_0xd6f0('0x2'));var moment=require(_0xd6f0('0x3'));var BPromise=require('bluebird');var rp=require(_0xd6f0('0x4'));var fs=require('fs');var path=require(_0xd6f0('0x5'));var rimraf=require(_0xd6f0('0x6'));var config=require(_0xd6f0('0x7'));var attributes=require(_0xd6f0('0x8'));module['exports']=function(_0x2d2ce6,_0x4a8b0c){return _0x2d2ce6[_0xd6f0('0x9')](_0xd6f0('0xa'),attributes,{'tableName':_0xd6f0('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/cmList/cmList.rpc.js b/server/api/cmList/cmList.rpc.js new file mode 100644 index 0000000..a0ddec1 --- /dev/null +++ b/server/api/cmList/cmList.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xec35=['info','catch','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','register','request','then','debug','CmList,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','CmList,\x20%s,\x20%s','message'];(function(_0x2b4411,_0x2625ed){var _0x8e41ef=function(_0x2aa8c1){while(--_0x2aa8c1){_0x2b4411['push'](_0x2b4411['shift']());}};_0x8e41ef(++_0x2625ed);}(_0xec35,0x172));var _0x5ec3=function(_0x416391,_0x390681){_0x416391=_0x416391-0x0;var _0x4e48e9=_0xec35[_0x416391];return _0x4e48e9;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x5ec3('0x0'));var rs=require(_0x5ec3('0x1'));var fs=require('fs');var Redis=require(_0x5ec3('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x5ec3('0x3'));var logger=require(_0x5ec3('0x4'))(_0x5ec3('0x5'));var config=require(_0x5ec3('0x6'));var jayson=require(_0x5ec3('0x7'));var client=jayson['client'][_0x5ec3('0x8')]({'port':0x232a});config[_0x5ec3('0x9')]=_['defaults'](config[_0x5ec3('0x9')],{'host':_0x5ec3('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5ec3('0x9')]));require('./cmList.socket')[_0x5ec3('0xb')](socket);function respondWithRpcPromise(_0x3fea0d,_0x2d22b6,_0x2cf6db){return new BPromise(function(_0x2466b6,_0x244fb6){return client[_0x5ec3('0xc')](_0x3fea0d,_0x2cf6db)[_0x5ec3('0xd')](function(_0x4a2a47){logger['info']('CmList,\x20%s,\x20%s',_0x2d22b6,'request\x20sent');logger[_0x5ec3('0xe')](_0x5ec3('0xf'),_0x2d22b6,_0x5ec3('0x10'),JSON['stringify'](_0x4a2a47));if(_0x4a2a47[_0x5ec3('0x11')]){if(_0x4a2a47[_0x5ec3('0x11')][_0x5ec3('0x12')]===0x1f4){logger['error'](_0x5ec3('0x13'),_0x2d22b6,_0x4a2a47[_0x5ec3('0x11')][_0x5ec3('0x14')]);return _0x244fb6(_0x4a2a47['error'][_0x5ec3('0x14')]);}logger['error']('CmList,\x20%s,\x20%s',_0x2d22b6,_0x4a2a47['error'][_0x5ec3('0x14')]);return _0x2466b6(_0x4a2a47[_0x5ec3('0x11')][_0x5ec3('0x14')]);}else{logger[_0x5ec3('0x15')]('CmList,\x20%s,\x20%s',_0x2d22b6,_0x5ec3('0x10'));_0x2466b6(_0x4a2a47['result']['message']);}})[_0x5ec3('0x16')](function(_0x46bca1){logger[_0x5ec3('0x11')](_0x5ec3('0x13'),_0x2d22b6,_0x46bca1);_0x244fb6(_0x46bca1);});});} \ No newline at end of file diff --git a/server/api/cmList/cmList.socket.js b/server/api/cmList/cmList.socket.js new file mode 100644 index 0000000..4bf364e --- /dev/null +++ b/server/api/cmList/cmList.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x96ad=['save','remove','emit','removeListener','register','length','cmList:','./cmList.events'];(function(_0x20cb20,_0x256051){var _0x2fcf4b=function(_0x26200b){while(--_0x26200b){_0x20cb20['push'](_0x20cb20['shift']());}};_0x2fcf4b(++_0x256051);}(_0x96ad,0x147));var _0xd96a=function(_0x35da42,_0x5c2610){_0x35da42=_0x35da42-0x0;var _0x370035=_0x96ad[_0x35da42];return _0x370035;};'use strict';var CmListEvents=require(_0xd96a('0x0'));var events=[_0xd96a('0x1'),_0xd96a('0x2'),'update'];function createListener(_0x17b71c,_0x4615a6){return function(_0x27b133){_0x4615a6[_0xd96a('0x3')](_0x17b71c,_0x27b133);};}function removeListener(_0x4f91a2,_0x558f82){return function(){CmListEvents[_0xd96a('0x4')](_0x4f91a2,_0x558f82);};}exports[_0xd96a('0x5')]=function(_0x5ea4ca){for(var _0x309300=0x0,_0x4bb53a=events[_0xd96a('0x6')];_0x309300<_0x4bb53a;_0x309300++){var _0x2aaae0=events[_0x309300];var _0x260d30=createListener(_0xd96a('0x7')+_0x2aaae0,_0x5ea4ca);CmListEvents['on'](_0x2aaae0,_0x260d30);}}; \ No newline at end of file diff --git a/server/api/cmList/index.js b/server/api/cmList/index.js new file mode 100644 index 0000000..da16ac2 --- /dev/null +++ b/server/api/cmList/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x952f=['update','delete','exports','multer','util','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./cmList.controller','get','isAuthenticated','index','/describe','describe','/global_fields','getGlobalCustomFields','/:id','show','getDispositions','getContacts','/:id/fields','getCustomFields','/:id/users','getAgents','create','post','/:id/dispositions','addDisposition','/:id/contacts','addContacts','addCustomField','put'];(function(_0x4d033a,_0x2aed96){var _0xddc28=function(_0x167936){while(--_0x167936){_0x4d033a['push'](_0x4d033a['shift']());}};_0xddc28(++_0x2aed96);}(_0x952f,0xad));var _0xf952=function(_0x45fc6a,_0x166adb){_0x45fc6a=_0x45fc6a-0x0;var _0x14bcfd=_0x952f[_0x45fc6a];return _0x14bcfd;};'use strict';var multer=require(_0xf952('0x0'));var util=require(_0xf952('0x1'));var path=require('path');var timeout=require(_0xf952('0x2'));var express=require('express');var router=express[_0xf952('0x3')]();var fs_extra=require(_0xf952('0x4'));var auth=require(_0xf952('0x5'));var interaction=require(_0xf952('0x6'));var config=require('../../config/environment');var controller=require(_0xf952('0x7'));router[_0xf952('0x8')]('/',auth[_0xf952('0x9')](),controller[_0xf952('0xa')]);router['get'](_0xf952('0xb'),auth[_0xf952('0x9')](),controller[_0xf952('0xc')]);router[_0xf952('0x8')](_0xf952('0xd'),auth[_0xf952('0x9')](),controller[_0xf952('0xe')]);router[_0xf952('0x8')](_0xf952('0xf'),auth[_0xf952('0x9')](),controller[_0xf952('0x10')]);router[_0xf952('0x8')]('/:id/dispositions',auth['isAuthenticated'](),controller[_0xf952('0x11')]);router[_0xf952('0x8')]('/:id/contacts',auth[_0xf952('0x9')](),controller[_0xf952('0x12')]);router['get']('/:id/contacts/csv',auth[_0xf952('0x9')](),controller['getContactsCsv']);router[_0xf952('0x8')](_0xf952('0x13'),auth['isAuthenticated'](),controller[_0xf952('0x14')]);router[_0xf952('0x8')](_0xf952('0x15'),auth[_0xf952('0x9')](),controller[_0xf952('0x16')]);router['post']('/',auth[_0xf952('0x9')](),controller[_0xf952('0x17')]);router[_0xf952('0x18')](_0xf952('0x19'),auth['isAuthenticated'](),controller[_0xf952('0x1a')]);router[_0xf952('0x18')](_0xf952('0x1b'),auth[_0xf952('0x9')](),controller[_0xf952('0x1c')]);router['post'](_0xf952('0x13'),auth['isAuthenticated'](),controller[_0xf952('0x1d')]);router[_0xf952('0x18')](_0xf952('0x15'),auth['isAuthenticated'](),controller['addAgents']);router[_0xf952('0x1e')]('/:id',auth[_0xf952('0x9')](),controller[_0xf952('0x1f')]);router[_0xf952('0x20')](_0xf952('0xf'),auth[_0xf952('0x9')](),controller['destroy']);router['delete'](_0xf952('0x19'),auth[_0xf952('0x9')](),controller['removeDispositions']);router[_0xf952('0x20')](_0xf952('0x15'),auth[_0xf952('0x9')](),controller['removeAgents']);module[_0xf952('0x21')]=router; \ No newline at end of file diff --git a/server/api/condition/condition.attributes.js b/server/api/condition/condition.attributes.js new file mode 100644 index 0000000..efb9516 --- /dev/null +++ b/server/api/condition/condition.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6253=['exports','getDataValue','field','STRING'];(function(_0x3d39d4,_0x28426d){var _0x18f002=function(_0x3e6d34){while(--_0x3e6d34){_0x3d39d4['push'](_0x3d39d4['shift']());}};_0x18f002(++_0x28426d);}(_0x6253,0x1a0));var _0x3625=function(_0x3200ca,_0x23d1b3){_0x3200ca=_0x3200ca-0x0;var _0x562715=_0x6253[_0x3200ca];return _0x562715;};'use strict';var Sequelize=require('sequelize');module[_0x3625('0x0')]={'name':{'type':Sequelize['VIRTUAL'],'get':function(_0x48acff){return this[_0x3625('0x1')](_0x3625('0x2'));}},'field':{'type':Sequelize[_0x3625('0x3')],'allowNull':![]},'operator':{'type':Sequelize['STRING'],'allowNull':![]},'value':{'type':Sequelize[_0x3625('0x3')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/condition/condition.controller.js b/server/api/condition/condition.controller.js new file mode 100644 index 0000000..d51f65a --- /dev/null +++ b/server/api/condition/condition.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['sox','to-csv','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','body','Condition','find','catch','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path'];(function(_0x32eca1,_0xa4a407){var _0x202f7b=function(_0x41a85){while(--_0x41a85){_0x32eca1['push'](_0x32eca1['shift']());}};_0x202f7b(++_0xa4a407);}(_0x7a54,0x106));var _0x47a5=function(_0x7dda2e,_0x15f6d4){_0x7dda2e=_0x7dda2e-0x0;var _0x48db53=_0x7a54[_0x7dda2e];return _0x48db53;};'use strict';var emlformat=require(_0x47a5('0x0'));var rimraf=require(_0x47a5('0x1'));var zipdir=require(_0x47a5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x47a5('0x3'));var moment=require(_0x47a5('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x47a5('0x5'));var util=require(_0x47a5('0x6'));var path=require(_0x47a5('0x7'));var sox=require(_0x47a5('0x8'));var csv=require(_0x47a5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x47a5('0xa'));var _=require('lodash');var squel=require(_0x47a5('0xb'));var crypto=require(_0x47a5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x47a5('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x47a5('0xe'));var authService=require(_0x47a5('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x47a5('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x47a5('0x11'));var utils=require(_0x47a5('0x12'));var config=require(_0x47a5('0x13'));var licenseUtil=require(_0x47a5('0x14'));var db=require(_0x47a5('0x15'))['db'];function respondWithStatusCode(_0xd308b8,_0x1eae59){_0x1eae59=_0x1eae59||0xcc;return function(_0x5beb89){if(_0x5beb89){return _0xd308b8[_0x47a5('0x16')](_0x1eae59);}return _0xd308b8[_0x47a5('0x17')](_0x1eae59)[_0x47a5('0x18')]();};}function respondWithResult(_0x711793,_0x139f25){_0x139f25=_0x139f25||0xc8;return function(_0x620ee9){if(_0x620ee9){return _0x711793[_0x47a5('0x17')](_0x139f25)[_0x47a5('0x19')](_0x620ee9);}};}function respondWithFilteredResult(_0x4e99a8,_0x362359){return function(_0x11faf5){if(_0x11faf5){var _0x3b001e=typeof _0x362359[_0x47a5('0x1a')]===_0x47a5('0x1b')&&typeof _0x362359['limit']==='undefined';var _0x138bc0=_0x11faf5['count'];var _0x5247fd=_0x3b001e?0x0:_0x362359[_0x47a5('0x1a')];var _0xaf70a6=_0x3b001e?_0x11faf5[_0x47a5('0x1c')]:_0x362359[_0x47a5('0x1a')]+_0x362359[_0x47a5('0x1d')];var _0x12b98e;if(_0xaf70a6>=_0x138bc0){_0xaf70a6=_0x138bc0;_0x12b98e=0xc8;}else{_0x12b98e=0xce;}_0x4e99a8[_0x47a5('0x17')](_0x12b98e);return _0x4e99a8[_0x47a5('0x1e')](_0x47a5('0x1f'),_0x5247fd+'-'+_0xaf70a6+'/'+_0x138bc0)['json'](_0x11faf5);}return null;};}function patchUpdates(_0x1570bc){return function(_0xf160ba){try{jsonpatch['apply'](_0xf160ba,_0x1570bc,!![]);}catch(_0x2b0360){return BPromise[_0x47a5('0x20')](_0x2b0360);}return _0xf160ba[_0x47a5('0x21')]();};}function saveUpdates(_0x4c5910,_0xb8ae6c){return function(_0x2f142b){if(_0x2f142b){return _0x2f142b[_0x47a5('0x22')](_0x4c5910)[_0x47a5('0x23')](function(_0x5ef1b1){return _0x5ef1b1;});}return null;};}function removeEntity(_0xe2dea9,_0x385687){return function(_0x513981){if(_0x513981){return _0x513981[_0x47a5('0x24')]()[_0x47a5('0x23')](function(){_0xe2dea9[_0x47a5('0x17')](0xcc)[_0x47a5('0x18')]();});}};}function handleEntityNotFound(_0x3abd6a,_0x50bf17){return function(_0x53078a){if(!_0x53078a){_0x3abd6a[_0x47a5('0x16')](0x194);}return _0x53078a;};}function handleError(_0x5686db,_0x1ea9c8){_0x1ea9c8=_0x1ea9c8||0x1f4;return function(_0x5b6c4e){logger[_0x47a5('0x25')](_0x5b6c4e[_0x47a5('0x26')]);if(_0x5b6c4e[_0x47a5('0x27')]){delete _0x5b6c4e[_0x47a5('0x27')];}_0x5686db[_0x47a5('0x17')](_0x1ea9c8)[_0x47a5('0x28')](_0x5b6c4e);};}exports[_0x47a5('0x22')]=function(_0x136b14,_0x16631f){if(_0x136b14[_0x47a5('0x29')]['id']){delete _0x136b14[_0x47a5('0x29')]['id'];}return db[_0x47a5('0x2a')][_0x47a5('0x2b')]({'where':{'id':_0x136b14['params']['id']}})[_0x47a5('0x23')](handleEntityNotFound(_0x16631f,null))['then'](saveUpdates(_0x136b14[_0x47a5('0x29')],null))[_0x47a5('0x23')](respondWithResult(_0x16631f,null))[_0x47a5('0x2c')](handleError(_0x16631f,null));};exports['destroy']=function(_0x256650,_0x625952){return db[_0x47a5('0x2a')][_0x47a5('0x2b')]({'where':{'id':_0x256650['params']['id']}})['then'](handleEntityNotFound(_0x625952,null))[_0x47a5('0x23')](removeEntity(_0x625952,null))[_0x47a5('0x2c')](handleError(_0x625952,null));}; \ No newline at end of file diff --git a/server/api/condition/condition.model.js b/server/api/condition/condition.model.js new file mode 100644 index 0000000..76d2802 --- /dev/null +++ b/server/api/condition/condition.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe57a=['rimraf','../../config/environment','./condition.attributes','exports','define','util','../../config/logger','api','moment','bluebird','request-promise','path'];(function(_0x180c82,_0x2613c4){var _0x48b115=function(_0x1bbb9d){while(--_0x1bbb9d){_0x180c82['push'](_0x180c82['shift']());}};_0x48b115(++_0x2613c4);}(_0xe57a,0x13d));var _0xae57=function(_0x2fa9da,_0x2fb5ee){_0x2fa9da=_0x2fa9da-0x0;var _0x5ae45b=_0xe57a[_0x2fa9da];return _0x5ae45b;};'use strict';var _=require('lodash');var util=require(_0xae57('0x0'));var logger=require(_0xae57('0x1'))(_0xae57('0x2'));var moment=require(_0xae57('0x3'));var BPromise=require(_0xae57('0x4'));var rp=require(_0xae57('0x5'));var fs=require('fs');var path=require(_0xae57('0x6'));var rimraf=require(_0xae57('0x7'));var config=require(_0xae57('0x8'));var attributes=require(_0xae57('0x9'));module[_0xae57('0xa')]=function(_0x588e2e,_0x39dffe){return _0x588e2e[_0xae57('0xb')]('Condition',attributes,{'tableName':'tools_conditions','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/condition/condition.rpc.js b/server/api/condition/condition.rpc.js new file mode 100644 index 0000000..04c004e --- /dev/null +++ b/server/api/condition/condition.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8bb9=['bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','info','Condition,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','lodash','util','moment'];(function(_0x38f8e8,_0x35eccc){var _0x4860f8=function(_0x3dd6eb){while(--_0x3dd6eb){_0x38f8e8['push'](_0x38f8e8['shift']());}};_0x4860f8(++_0x35eccc);}(_0x8bb9,0x1cb));var _0x98bb=function(_0x587fb5,_0x59cb3b){_0x587fb5=_0x587fb5-0x0;var _0x551105=_0x8bb9[_0x587fb5];return _0x551105;};'use strict';var _=require(_0x98bb('0x0'));var util=require(_0x98bb('0x1'));var moment=require(_0x98bb('0x2'));var BPromise=require(_0x98bb('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x98bb('0x4'));var db=require(_0x98bb('0x5'))['db'];var utils=require(_0x98bb('0x6'));var logger=require('../../config/logger')(_0x98bb('0x7'));var config=require(_0x98bb('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x98bb('0x9')][_0x98bb('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x58e9fb,_0x28c082,_0x2bb2db){return new BPromise(function(_0x28f287,_0x3d4d9e){return client[_0x98bb('0xb')](_0x58e9fb,_0x2bb2db)[_0x98bb('0xc')](function(_0x43ada6){logger[_0x98bb('0xd')](_0x98bb('0xe'),_0x28c082,_0x98bb('0xf'));logger[_0x98bb('0x10')]('Condition,\x20%s,\x20%s,\x20%s',_0x28c082,_0x98bb('0xf'),JSON['stringify'](_0x43ada6));if(_0x43ada6[_0x98bb('0x11')]){if(_0x43ada6[_0x98bb('0x11')][_0x98bb('0x12')]===0x1f4){logger['error'](_0x98bb('0xe'),_0x28c082,_0x43ada6['error']['message']);return _0x3d4d9e(_0x43ada6['error'][_0x98bb('0x13')]);}logger[_0x98bb('0x11')](_0x98bb('0xe'),_0x28c082,_0x43ada6[_0x98bb('0x11')][_0x98bb('0x13')]);return _0x28f287(_0x43ada6[_0x98bb('0x11')][_0x98bb('0x13')]);}else{logger[_0x98bb('0xd')](_0x98bb('0xe'),_0x28c082,_0x98bb('0xf'));_0x28f287(_0x43ada6[_0x98bb('0x14')]['message']);}})['catch'](function(_0x6b19da){logger[_0x98bb('0x11')](_0x98bb('0xe'),_0x28c082,_0x6b19da);_0x3d4d9e(_0x6b19da);});});} \ No newline at end of file diff --git a/server/api/condition/index.js b/server/api/condition/index.js new file mode 100644 index 0000000..a1c130b --- /dev/null +++ b/server/api/condition/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2b34=['express','Router','../../components/auth/service','../../components/interaction/service','./condition.controller','put','isAuthenticated','update','exports','multer','util','path'];(function(_0x519990,_0x57672f){var _0x4cf293=function(_0x4df638){while(--_0x4df638){_0x519990['push'](_0x519990['shift']());}};_0x4cf293(++_0x57672f);}(_0x2b34,0x1e9));var _0x42b3=function(_0x1e7b16,_0x4607a1){_0x1e7b16=_0x1e7b16-0x0;var _0x37fadc=_0x2b34[_0x1e7b16];return _0x37fadc;};'use strict';var multer=require(_0x42b3('0x0'));var util=require(_0x42b3('0x1'));var path=require(_0x42b3('0x2'));var timeout=require('connect-timeout');var express=require(_0x42b3('0x3'));var router=express[_0x42b3('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x42b3('0x5'));var interaction=require(_0x42b3('0x6'));var config=require('../../config/environment');var controller=require(_0x42b3('0x7'));router[_0x42b3('0x8')]('/:id',auth[_0x42b3('0x9')](),controller[_0x42b3('0xa')]);router['delete']('/:id',auth[_0x42b3('0x9')](),controller['destroy']);module[_0x42b3('0xb')]=router; \ No newline at end of file diff --git a/server/api/contactItemType/contactItemType.attributes.js b/server/api/contactItemType/contactItemType.attributes.js new file mode 100644 index 0000000..5a4659d --- /dev/null +++ b/server/api/contactItemType/contactItemType.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7dab=['STRING','sequelize','exports','name','INTEGER'];(function(_0xd21f28,_0x483c59){var _0x3405bf=function(_0x19e330){while(--_0x19e330){_0xd21f28['push'](_0xd21f28['shift']());}};_0x3405bf(++_0x483c59);}(_0x7dab,0x10a));var _0xb7da=function(_0x388334,_0x488ec6){_0x388334=_0x388334-0x0;var _0x42b7f5=_0x7dab[_0x388334];return _0x42b7f5;};'use strict';var Sequelize=require(_0xb7da('0x0'));module[_0xb7da('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![],'unique':_0xb7da('0x2')},'OrderBy':{'type':Sequelize[_0xb7da('0x3')],'allowNull':!![]},'rgbBackgroundColor':{'type':Sequelize[_0xb7da('0x4')],'allowNull':!![]}}; \ No newline at end of file diff --git a/server/api/contactItemType/contactItemType.controller.js b/server/api/contactItemType/contactItemType.controller.js new file mode 100644 index 0000000..0be3596 --- /dev/null +++ b/server/api/contactItemType/contactItemType.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x28f2=['api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','Content-Range','apply','reject','save','update','then','destroy','get','ContactItemTypes','UserProfileResource','error','stack','name','send','index','map','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','where','merge','ContactItemType','count','include','findAll','rows','catch','show','keys','includeAll','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','params','CmContactHasItem','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger'];(function(_0x38c189,_0x2a4e79){var _0x6a730e=function(_0x5b9cbe){while(--_0x5b9cbe){_0x38c189['push'](_0x38c189['shift']());}};_0x6a730e(++_0x2a4e79);}(_0x28f2,0x193));var _0x228f=function(_0x23ed25,_0x555ded){_0x23ed25=_0x23ed25-0x0;var _0x411de2=_0x28f2[_0x23ed25];return _0x411de2;};'use strict';var emlformat=require(_0x228f('0x0'));var rimraf=require(_0x228f('0x1'));var zipdir=require(_0x228f('0x2'));var jsonpatch=require(_0x228f('0x3'));var rp=require(_0x228f('0x4'));var moment=require('moment');var BPromise=require(_0x228f('0x5'));var Mustache=require(_0x228f('0x6'));var util=require(_0x228f('0x7'));var path=require(_0x228f('0x8'));var sox=require(_0x228f('0x9'));var csv=require(_0x228f('0xa'));var ejs=require(_0x228f('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x228f('0xc'));var squel=require('squel');var crypto=require(_0x228f('0xd'));var jsforce=require(_0x228f('0xe'));var deskjs=require(_0x228f('0xf'));var toCsv=require('to-csv');var querystring=require(_0x228f('0x10'));var Papa=require('papaparse');var Redis=require(_0x228f('0x11'));var authService=require(_0x228f('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x228f('0x13'));var hardwareService=require(_0x228f('0x14'));var logger=require(_0x228f('0x15'))(_0x228f('0x16'));var utils=require(_0x228f('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x228f('0x18'));var db=require(_0x228f('0x19'))['db'];function respondWithStatusCode(_0x24f69c,_0x14073a){_0x14073a=_0x14073a||0xcc;return function(_0x2e1a43){if(_0x2e1a43){return _0x24f69c[_0x228f('0x1a')](_0x14073a);}return _0x24f69c[_0x228f('0x1b')](_0x14073a)[_0x228f('0x1c')]();};}function respondWithResult(_0x572535,_0x2fab95){_0x2fab95=_0x2fab95||0xc8;return function(_0xfb6aff){if(_0xfb6aff){return _0x572535[_0x228f('0x1b')](_0x2fab95)[_0x228f('0x1d')](_0xfb6aff);}};}function respondWithFilteredResult(_0x2a4d87,_0x21a913){return function(_0x272723){if(_0x272723){var _0x5b5abb=typeof _0x21a913[_0x228f('0x1e')]==='undefined'&&typeof _0x21a913[_0x228f('0x1f')]===_0x228f('0x20');var _0x195e65=_0x272723['count'];var _0x2d4819=_0x5b5abb?0x0:_0x21a913['offset'];var _0x33e32e=_0x5b5abb?_0x272723['count']:_0x21a913[_0x228f('0x1e')]+_0x21a913['limit'];var _0x5aa203;if(_0x33e32e>=_0x195e65){_0x33e32e=_0x195e65;_0x5aa203=0xc8;}else{_0x5aa203=0xce;}_0x2a4d87[_0x228f('0x1b')](_0x5aa203);return _0x2a4d87['set'](_0x228f('0x21'),_0x2d4819+'-'+_0x33e32e+'/'+_0x195e65)[_0x228f('0x1d')](_0x272723);}return null;};}function patchUpdates(_0x1294a8){return function(_0x3a623a){try{jsonpatch[_0x228f('0x22')](_0x3a623a,_0x1294a8,!![]);}catch(_0x313cf2){return BPromise[_0x228f('0x23')](_0x313cf2);}return _0x3a623a[_0x228f('0x24')]();};}function saveUpdates(_0x15d54f,_0x4ee0c9){return function(_0x1e96d4){if(_0x1e96d4){return _0x1e96d4[_0x228f('0x25')](_0x15d54f)[_0x228f('0x26')](function(_0x3c00ad){return _0x3c00ad;});}return null;};}function removeEntity(_0x1dad27,_0x194d1a){return function(_0x33e882){if(_0x33e882){return _0x33e882[_0x228f('0x27')]()[_0x228f('0x26')](function(){var _0x56fbc2=_0x33e882[_0x228f('0x28')]({'plain':!![]});var _0x306928=_0x228f('0x29');return db[_0x228f('0x2a')][_0x228f('0x27')]({'where':{'type':_0x306928,'resourceId':_0x56fbc2['id']}})['then'](function(){return _0x33e882;});})[_0x228f('0x26')](function(){_0x1dad27['status'](0xcc)[_0x228f('0x1c')]();});}};}function handleEntityNotFound(_0x5afa52,_0x58a151){return function(_0x2b9802){if(!_0x2b9802){_0x5afa52[_0x228f('0x1a')](0x194);}return _0x2b9802;};}function handleError(_0x2a7842,_0x3ab339){_0x3ab339=_0x3ab339||0x1f4;return function(_0x34c735){logger[_0x228f('0x2b')](_0x34c735[_0x228f('0x2c')]);if(_0x34c735[_0x228f('0x2d')]){delete _0x34c735[_0x228f('0x2d')];}_0x2a7842[_0x228f('0x1b')](_0x3ab339)[_0x228f('0x2e')](_0x34c735);};}exports[_0x228f('0x2f')]=function(_0xc25917,_0xc6921f){var _0x2a3677={},_0x4e9ca8={},_0x4148ff={'count':0x0,'rows':[]};var _0x40bf17=_[_0x228f('0x30')](db['ContactItemType'][_0x228f('0x31')],function(_0x41be2d){return{'name':_0x41be2d['fieldName'],'type':_0x41be2d[_0x228f('0x32')][_0x228f('0x33')]};});_0x4e9ca8[_0x228f('0x34')]=_[_0x228f('0x30')](_0x40bf17,'name');_0x4e9ca8[_0x228f('0x35')]=_['keys'](_0xc25917[_0x228f('0x35')]);_0x4e9ca8[_0x228f('0x36')]=_[_0x228f('0x37')](_0x4e9ca8[_0x228f('0x34')],_0x4e9ca8['query']);_0x2a3677[_0x228f('0x38')]=_[_0x228f('0x37')](_0x4e9ca8['model'],qs['fields'](_0xc25917['query'][_0x228f('0x39')]));_0x2a3677[_0x228f('0x38')]=_0x2a3677[_0x228f('0x38')][_0x228f('0x3a')]?_0x2a3677[_0x228f('0x38')]:_0x4e9ca8[_0x228f('0x34')];if(!_0xc25917[_0x228f('0x35')][_0x228f('0x3b')](_0x228f('0x3c'))){_0x2a3677['limit']=qs['limit'](_0xc25917[_0x228f('0x35')][_0x228f('0x1f')]);_0x2a3677[_0x228f('0x1e')]=qs[_0x228f('0x1e')](_0xc25917[_0x228f('0x35')][_0x228f('0x1e')]);}_0x2a3677[_0x228f('0x3d')]=qs[_0x228f('0x3e')](_0xc25917[_0x228f('0x35')][_0x228f('0x3e')]);_0x2a3677['where']=qs['filters'](_[_0x228f('0x3f')](_0xc25917[_0x228f('0x35')],_0x4e9ca8[_0x228f('0x36')]),_0x40bf17);if(_0xc25917[_0x228f('0x35')]['filter']){_0x2a3677[_0x228f('0x40')]=_[_0x228f('0x41')](_0x2a3677['where'],{'$or':_['map'](_0x40bf17,function(_0x3da115){if(_0x3da115[_0x228f('0x32')]!=='VIRTUAL'){var _0x12a750={};_0x12a750[_0x3da115[_0x228f('0x2d')]]={'$like':'%'+_0xc25917['query']['filter']+'%'};return _0x12a750;}})});}_0x2a3677=_[_0x228f('0x41')]({},_0x2a3677,_0xc25917['options']);var _0x323d68={'where':_0x2a3677[_0x228f('0x40')]};return db[_0x228f('0x42')][_0x228f('0x43')](_0x323d68)[_0x228f('0x26')](function(_0x20c178){_0x4148ff['count']=_0x20c178;if(_0xc25917[_0x228f('0x35')]['includeAll']){_0x2a3677[_0x228f('0x44')]=[{'all':!![]}];}return db[_0x228f('0x42')][_0x228f('0x45')](_0x2a3677);})[_0x228f('0x26')](function(_0x41cba5){_0x4148ff[_0x228f('0x46')]=_0x41cba5;return _0x4148ff;})[_0x228f('0x26')](respondWithFilteredResult(_0xc6921f,_0x2a3677))[_0x228f('0x47')](handleError(_0xc6921f,null));};exports[_0x228f('0x48')]=function(_0x2592a1,_0x788e8b){var _0x345114={'raw':!![],'where':{'id':_0x2592a1['params']['id']}},_0x19839d={};_0x19839d['model']=_[_0x228f('0x49')](db[_0x228f('0x42')][_0x228f('0x31')]);_0x19839d[_0x228f('0x35')]=_[_0x228f('0x49')](_0x2592a1[_0x228f('0x35')]);_0x19839d[_0x228f('0x36')]=_[_0x228f('0x37')](_0x19839d[_0x228f('0x34')],_0x19839d[_0x228f('0x35')]);_0x345114['attributes']=_[_0x228f('0x37')](_0x19839d[_0x228f('0x34')],qs['fields'](_0x2592a1[_0x228f('0x35')]['fields']));_0x345114[_0x228f('0x38')]=_0x345114['attributes'][_0x228f('0x3a')]?_0x345114['attributes']:_0x19839d[_0x228f('0x34')];if(_0x2592a1[_0x228f('0x35')][_0x228f('0x4a')]){_0x345114[_0x228f('0x44')]=[{'all':!![]}];}_0x345114=_[_0x228f('0x41')]({},_0x345114,_0x2592a1[_0x228f('0x4b')]);return db[_0x228f('0x42')][_0x228f('0x4c')](_0x345114)[_0x228f('0x26')](handleEntityNotFound(_0x788e8b,null))[_0x228f('0x26')](respondWithResult(_0x788e8b,null))[_0x228f('0x47')](handleError(_0x788e8b,null));};exports[_0x228f('0x4d')]=function(_0x4099d4,_0x250345){return db[_0x228f('0x42')][_0x228f('0x4d')](_0x4099d4[_0x228f('0x4e')],{})[_0x228f('0x26')](function(_0x1872e2){var _0x55e140=_0x4099d4['user'][_0x228f('0x28')]({'plain':!![]});if(!_0x55e140)throw new Error(_0x228f('0x4f'));if(_0x55e140[_0x228f('0x50')]==='user'){var _0x17bcd9=_0x1872e2[_0x228f('0x28')]({'plain':!![]});var _0x28f91e='ContactItemTypes';return db['UserProfileSection']['find']({'where':{'name':_0x28f91e,'userProfileId':_0x55e140[_0x228f('0x51')]},'raw':!![]})[_0x228f('0x26')](function(_0x208397){if(_0x208397&&_0x208397[_0x228f('0x52')]===0x0){return db[_0x228f('0x2a')][_0x228f('0x4d')]({'name':_0x17bcd9[_0x228f('0x2d')],'resourceId':_0x17bcd9['id'],'type':_0x208397[_0x228f('0x2d')],'sectionId':_0x208397['id']},{})[_0x228f('0x26')](function(){return _0x1872e2;});}else{return _0x1872e2;}})[_0x228f('0x47')](function(_0x43bbd2){logger[_0x228f('0x2b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x43bbd2);throw _0x43bbd2;});}return _0x1872e2;})[_0x228f('0x26')](respondWithResult(_0x250345,0xc9))[_0x228f('0x47')](handleError(_0x250345,null));};exports[_0x228f('0x25')]=function(_0x561144,_0x3e9f76){if(_0x561144[_0x228f('0x4e')]['id']){delete _0x561144[_0x228f('0x4e')]['id'];}return db[_0x228f('0x42')]['find']({'where':{'id':_0x561144[_0x228f('0x53')]['id']}})[_0x228f('0x26')](handleEntityNotFound(_0x3e9f76,null))[_0x228f('0x26')](saveUpdates(_0x561144[_0x228f('0x4e')],null))['then'](respondWithResult(_0x3e9f76,null))[_0x228f('0x47')](handleError(_0x3e9f76,null));};exports[_0x228f('0x27')]=function(_0x4b516e,_0x32787c){return db[_0x228f('0x42')][_0x228f('0x4c')]({'where':{'id':_0x4b516e[_0x228f('0x53')]['id']}})[_0x228f('0x26')](handleEntityNotFound(_0x32787c,null))[_0x228f('0x26')](db[_0x228f('0x54')][_0x228f('0x25')]({'ItemTypeId':null},{'where':{'ItemTypeId':_0x4b516e[_0x228f('0x53')]['id']}}))[_0x228f('0x26')](removeEntity(_0x32787c,null))['catch'](handleError(_0x32787c,null));}; \ No newline at end of file diff --git a/server/api/contactItemType/contactItemType.model.js b/server/api/contactItemType/contactItemType.model.js new file mode 100644 index 0000000..eeb9356 --- /dev/null +++ b/server/api/contactItemType/contactItemType.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf2a8=['lodash','util','../../config/logger','api','bluebird','request-promise','path','rimraf','./contactItemType.attributes','exports','ContactItemType'];(function(_0x5c1b40,_0x52af49){var _0x28c4e7=function(_0x3f2c8a){while(--_0x3f2c8a){_0x5c1b40['push'](_0x5c1b40['shift']());}};_0x28c4e7(++_0x52af49);}(_0xf2a8,0x14a));var _0x8f2a=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xf2a8[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x8f2a('0x0'));var util=require(_0x8f2a('0x1'));var logger=require(_0x8f2a('0x2'))(_0x8f2a('0x3'));var moment=require('moment');var BPromise=require(_0x8f2a('0x4'));var rp=require(_0x8f2a('0x5'));var fs=require('fs');var path=require(_0x8f2a('0x6'));var rimraf=require(_0x8f2a('0x7'));var config=require('../../config/environment');var attributes=require(_0x8f2a('0x8'));module[_0x8f2a('0x9')]=function(_0x19b13,_0x40041e){return _0x19b13['define'](_0x8f2a('0xa'),attributes,{'tableName':'tools_contact_item_types','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/contactItemType/contactItemType.rpc.js b/server/api/contactItemType/contactItemType.rpc.js new file mode 100644 index 0000000..fbc1e88 --- /dev/null +++ b/server/api/contactItemType/contactItemType.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8882=['rpc','../../config/environment','client','http','request','then','info','ContactItemType,\x20%s,\x20%s','debug','ContactItemType,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','catch','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger'];(function(_0xf6c630,_0x4c374b){var _0x45823c=function(_0x36f396){while(--_0x36f396){_0xf6c630['push'](_0xf6c630['shift']());}};_0x45823c(++_0x4c374b);}(_0x8882,0x169));var _0x2888=function(_0x446699,_0x25ae79){_0x446699=_0x446699-0x0;var _0x3b4e51=_0x8882[_0x446699];return _0x3b4e51;};'use strict';var _=require(_0x2888('0x0'));var util=require(_0x2888('0x1'));var moment=require(_0x2888('0x2'));var BPromise=require(_0x2888('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2888('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x2888('0x5'));var logger=require(_0x2888('0x6'))(_0x2888('0x7'));var config=require(_0x2888('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x2888('0x9')][_0x2888('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xc1fddc,_0x3b22c0,_0x5c46e0){return new BPromise(function(_0x464b20,_0x77683b){return client[_0x2888('0xb')](_0xc1fddc,_0x5c46e0)[_0x2888('0xc')](function(_0x2e38b2){logger[_0x2888('0xd')](_0x2888('0xe'),_0x3b22c0,'request\x20sent');logger[_0x2888('0xf')](_0x2888('0x10'),_0x3b22c0,'request\x20sent',JSON[_0x2888('0x11')](_0x2e38b2));if(_0x2e38b2[_0x2888('0x12')]){if(_0x2e38b2[_0x2888('0x12')][_0x2888('0x13')]===0x1f4){logger['error'](_0x2888('0xe'),_0x3b22c0,_0x2e38b2['error']['message']);return _0x77683b(_0x2e38b2[_0x2888('0x12')][_0x2888('0x14')]);}logger[_0x2888('0x12')](_0x2888('0xe'),_0x3b22c0,_0x2e38b2['error'][_0x2888('0x14')]);return _0x464b20(_0x2e38b2[_0x2888('0x12')][_0x2888('0x14')]);}else{logger[_0x2888('0xd')](_0x2888('0xe'),_0x3b22c0,_0x2888('0x15'));_0x464b20(_0x2e38b2['result'][_0x2888('0x14')]);}})[_0x2888('0x16')](function(_0x5ae430){logger[_0x2888('0x12')](_0x2888('0xe'),_0x3b22c0,_0x5ae430);_0x77683b(_0x5ae430);});});} \ No newline at end of file diff --git a/server/api/contactItemType/index.js b/server/api/contactItemType/index.js new file mode 100644 index 0000000..b0505dd --- /dev/null +++ b/server/api/contactItemType/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x10ce=['show','post','isAuthenticated','create','/:id','update','delete','destroy','exports','multer','util','path','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./contactItemType.controller','get','index'];(function(_0x2fa28d,_0x5cab8f){var _0x4488cb=function(_0x103141){while(--_0x103141){_0x2fa28d['push'](_0x2fa28d['shift']());}};_0x4488cb(++_0x5cab8f);}(_0x10ce,0x1d7));var _0xe10c=function(_0x42900b,_0x47e957){_0x42900b=_0x42900b-0x0;var _0x2ff564=_0x10ce[_0x42900b];return _0x2ff564;};'use strict';var multer=require(_0xe10c('0x0'));var util=require(_0xe10c('0x1'));var path=require(_0xe10c('0x2'));var timeout=require(_0xe10c('0x3'));var express=require(_0xe10c('0x4'));var router=express['Router']();var fs_extra=require(_0xe10c('0x5'));var auth=require(_0xe10c('0x6'));var interaction=require(_0xe10c('0x7'));var config=require(_0xe10c('0x8'));var controller=require(_0xe10c('0x9'));router[_0xe10c('0xa')]('/',auth['isAuthenticated'](),controller[_0xe10c('0xb')]);router['get']('/:id',auth['isAuthenticated'](),controller[_0xe10c('0xc')]);router[_0xe10c('0xd')]('/',auth[_0xe10c('0xe')](),controller[_0xe10c('0xf')]);router['put'](_0xe10c('0x10'),auth[_0xe10c('0xe')](),controller[_0xe10c('0x11')]);router[_0xe10c('0x12')](_0xe10c('0x10'),auth['isAuthenticated'](),controller[_0xe10c('0x13')]);module[_0xe10c('0x14')]=router; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.attributes.js b/server/api/dashboard/dashboard.attributes.js new file mode 100644 index 0000000..9f014fb --- /dev/null +++ b/server/api/dashboard/dashboard.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['exports','sequelize'];(function(_0x212072,_0x203f9a){var _0x39595c=function(_0x269020){while(--_0x269020){_0x212072['push'](_0x212072['shift']());}};_0x39595c(++_0x203f9a);}(_0xd8b0,0xad));var _0x0d8b=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xd8b0[_0x122ef9];return _0x42fba0;};'use strict';var Sequelize=require(_0x0d8b('0x0'));module[_0x0d8b('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![],'unique':'name'},'description':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.controller.js b/server/api/dashboard/dashboard.controller.js new file mode 100644 index 0000000..6060402 --- /dev/null +++ b/server/api/dashboard/dashboard.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1fc7=['crypto','desk.js','querystring','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','destroy','get','CustomDashboards','UserProfileResource','sendStatus','error','send','index','map','Dashboard','rawAttributes','key','model','name','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','options','include','findAll','rows','catch','show','params','length','includeAll','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','updatedAt','createdAt','autoAssociation','create','iframe','attrUrl','attrs','custom','attrPath','value','clock','attrHourFormat','attrTimezone','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','pie-chart','attrSerie1','attrSerie2','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardId','DashboardItem','findOne','order','getItems','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel'];(function(_0x3d42d8,_0x4cffaa){var _0x27fc41=function(_0x3a363b){while(--_0x3a363b){_0x3d42d8['push'](_0x3d42d8['shift']());}};_0x27fc41(++_0x4cffaa);}(_0x1fc7,0x75));var _0x71fc=function(_0x1d1779,_0x284147){_0x1d1779=_0x1d1779-0x0;var _0x2377e9=_0x1fc7[_0x1d1779];return _0x2377e9;};'use strict';var emlformat=require(_0x71fc('0x0'));var rimraf=require(_0x71fc('0x1'));var zipdir=require(_0x71fc('0x2'));var jsonpatch=require(_0x71fc('0x3'));var rp=require(_0x71fc('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x71fc('0x5'));var util=require(_0x71fc('0x6'));var path=require(_0x71fc('0x7'));var sox=require(_0x71fc('0x8'));var csv=require(_0x71fc('0x9'));var ejs=require(_0x71fc('0xa'));var fs=require('fs');var fs_extra=require(_0x71fc('0xb'));var _=require(_0x71fc('0xc'));var squel=require(_0x71fc('0xd'));var crypto=require(_0x71fc('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x71fc('0xf'));var toCsv=require(_0x71fc('0x9'));var querystring=require(_0x71fc('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x71fc('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x71fc('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x71fc('0x13'))(_0x71fc('0x14'));var utils=require(_0x71fc('0x15'));var config=require(_0x71fc('0x16'));var licenseUtil=require(_0x71fc('0x17'));var db=require(_0x71fc('0x18'))['db'];config[_0x71fc('0x19')]=_[_0x71fc('0x1a')](config[_0x71fc('0x19')],{'host':_0x71fc('0x1b'),'port':0x18eb});var socket=require(_0x71fc('0x1c'))(new Redis(config[_0x71fc('0x19')]));require(_0x71fc('0x1d'))[_0x71fc('0x1e')](socket);function respondWithStatusCode(_0x2dde4a,_0x5ee73e){_0x5ee73e=_0x5ee73e||0xcc;return function(_0x5e25b3){if(_0x5e25b3){return _0x2dde4a['sendStatus'](_0x5ee73e);}return _0x2dde4a[_0x71fc('0x1f')](_0x5ee73e)[_0x71fc('0x20')]();};}function respondWithResult(_0x3852d5,_0x298d15){_0x298d15=_0x298d15||0xc8;return function(_0x13692c){if(_0x13692c){return _0x3852d5[_0x71fc('0x1f')](_0x298d15)[_0x71fc('0x21')](_0x13692c);}};}function respondWithFilteredResult(_0x38362d,_0x29908c){return function(_0x23e8dd){if(_0x23e8dd){var _0x1bef37=typeof _0x29908c[_0x71fc('0x22')]===_0x71fc('0x23')&&typeof _0x29908c[_0x71fc('0x24')]===_0x71fc('0x23');var _0x2581cc=_0x23e8dd[_0x71fc('0x25')];var _0xa2b0f=_0x1bef37?0x0:_0x29908c[_0x71fc('0x22')];var _0x5a2333=_0x1bef37?_0x23e8dd[_0x71fc('0x25')]:_0x29908c[_0x71fc('0x22')]+_0x29908c[_0x71fc('0x24')];var _0x2c8a43;if(_0x5a2333>=_0x2581cc){_0x5a2333=_0x2581cc;_0x2c8a43=0xc8;}else{_0x2c8a43=0xce;}_0x38362d['status'](_0x2c8a43);return _0x38362d['set'](_0x71fc('0x26'),_0xa2b0f+'-'+_0x5a2333+'/'+_0x2581cc)['json'](_0x23e8dd);}return null;};}function patchUpdates(_0x464c83){return function(_0x2d5eb1){try{jsonpatch[_0x71fc('0x27')](_0x2d5eb1,_0x464c83,!![]);}catch(_0x400b0f){return BPromise[_0x71fc('0x28')](_0x400b0f);}return _0x2d5eb1[_0x71fc('0x29')]();};}function saveUpdates(_0x5f4145,_0x3a366c){return function(_0x105428){if(_0x105428){return _0x105428[_0x71fc('0x2a')](_0x5f4145)[_0x71fc('0x2b')](function(_0x13cdec){return _0x13cdec;});}return null;};}function removeEntity(_0x26f677,_0x4ee7b6){return function(_0x5631b6){if(_0x5631b6){return _0x5631b6[_0x71fc('0x2c')]()[_0x71fc('0x2b')](function(){var _0x447033=_0x5631b6[_0x71fc('0x2d')]({'plain':!![]});var _0x3bdc4f=_0x71fc('0x2e');return db[_0x71fc('0x2f')][_0x71fc('0x2c')]({'where':{'type':_0x3bdc4f,'resourceId':_0x447033['id']}})[_0x71fc('0x2b')](function(){return _0x5631b6;});})['then'](function(){_0x26f677[_0x71fc('0x1f')](0xcc)[_0x71fc('0x20')]();});}};}function handleEntityNotFound(_0x219629,_0x22d3e7){return function(_0x2034ea){if(!_0x2034ea){_0x219629[_0x71fc('0x30')](0x194);}return _0x2034ea;};}function handleError(_0x40a417,_0x3bcb2b){_0x3bcb2b=_0x3bcb2b||0x1f4;return function(_0x2a9f5a){logger[_0x71fc('0x31')](_0x2a9f5a['stack']);if(_0x2a9f5a['name']){delete _0x2a9f5a['name'];}_0x40a417[_0x71fc('0x1f')](_0x3bcb2b)[_0x71fc('0x32')](_0x2a9f5a);};}exports[_0x71fc('0x33')]=function(_0x20abfe,_0x5ae86e){var _0x45266e={},_0x697941={},_0x3787bc={'count':0x0,'rows':[]};var _0x455db9=_[_0x71fc('0x34')](db[_0x71fc('0x35')][_0x71fc('0x36')],function(_0xeda424){return{'name':_0xeda424['fieldName'],'type':_0xeda424['type'][_0x71fc('0x37')]};});_0x697941[_0x71fc('0x38')]=_[_0x71fc('0x34')](_0x455db9,_0x71fc('0x39'));_0x697941[_0x71fc('0x3a')]=_[_0x71fc('0x3b')](_0x20abfe[_0x71fc('0x3a')]);_0x697941[_0x71fc('0x3c')]=_[_0x71fc('0x3d')](_0x697941['model'],_0x697941[_0x71fc('0x3a')]);_0x45266e[_0x71fc('0x3e')]=_[_0x71fc('0x3d')](_0x697941[_0x71fc('0x38')],qs[_0x71fc('0x3f')](_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x3f')]));_0x45266e[_0x71fc('0x3e')]=_0x45266e[_0x71fc('0x3e')]['length']?_0x45266e[_0x71fc('0x3e')]:_0x697941[_0x71fc('0x38')];if(!_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x40')](_0x71fc('0x41'))){_0x45266e['limit']=qs[_0x71fc('0x24')](_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x24')]);_0x45266e[_0x71fc('0x22')]=qs[_0x71fc('0x22')](_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x22')]);}_0x45266e['order']=qs['sort'](_0x20abfe['query'][_0x71fc('0x42')]);_0x45266e[_0x71fc('0x43')]=qs[_0x71fc('0x3c')](_[_0x71fc('0x44')](_0x20abfe[_0x71fc('0x3a')],_0x697941['filters']),_0x455db9);if(_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x45')]){_0x45266e[_0x71fc('0x43')]=_[_0x71fc('0x46')](_0x45266e[_0x71fc('0x43')],{'$or':_[_0x71fc('0x34')](_0x455db9,function(_0xc11437){if(_0xc11437[_0x71fc('0x47')]!=='VIRTUAL'){var _0x182739={};_0x182739[_0xc11437[_0x71fc('0x39')]]={'$like':'%'+_0x20abfe[_0x71fc('0x3a')][_0x71fc('0x45')]+'%'};return _0x182739;}})});}_0x45266e=_[_0x71fc('0x46')]({},_0x45266e,_0x20abfe[_0x71fc('0x48')]);var _0x33f89b={'where':_0x45266e[_0x71fc('0x43')]};return db[_0x71fc('0x35')][_0x71fc('0x25')](_0x33f89b)[_0x71fc('0x2b')](function(_0x4be7ff){_0x3787bc[_0x71fc('0x25')]=_0x4be7ff;if(_0x20abfe['query']['includeAll']){_0x45266e[_0x71fc('0x49')]=[{'all':!![]}];}return db[_0x71fc('0x35')][_0x71fc('0x4a')](_0x45266e);})['then'](function(_0x5a7f23){_0x3787bc[_0x71fc('0x4b')]=_0x5a7f23;return _0x3787bc;})[_0x71fc('0x2b')](respondWithFilteredResult(_0x5ae86e,_0x45266e))[_0x71fc('0x4c')](handleError(_0x5ae86e,null));};exports[_0x71fc('0x4d')]=function(_0x1e99fd,_0x382319){var _0x6fe2bc={'raw':![],'where':{'id':_0x1e99fd[_0x71fc('0x4e')]['id']}},_0x4010ec={};_0x4010ec[_0x71fc('0x38')]=_[_0x71fc('0x3b')](db[_0x71fc('0x35')][_0x71fc('0x36')]);_0x4010ec[_0x71fc('0x3a')]=_[_0x71fc('0x3b')](_0x1e99fd[_0x71fc('0x3a')]);_0x4010ec[_0x71fc('0x3c')]=_[_0x71fc('0x3d')](_0x4010ec[_0x71fc('0x38')],_0x4010ec['query']);_0x6fe2bc['attributes']=_[_0x71fc('0x3d')](_0x4010ec[_0x71fc('0x38')],qs['fields'](_0x1e99fd['query'][_0x71fc('0x3f')]));_0x6fe2bc[_0x71fc('0x3e')]=_0x6fe2bc[_0x71fc('0x3e')][_0x71fc('0x4f')]?_0x6fe2bc[_0x71fc('0x3e')]:_0x4010ec[_0x71fc('0x38')];if(_0x1e99fd[_0x71fc('0x3a')][_0x71fc('0x50')]){_0x6fe2bc['include']=[{'all':!![]}];}_0x6fe2bc=_[_0x71fc('0x46')]({},_0x6fe2bc,_0x1e99fd[_0x71fc('0x48')]);return db['Dashboard']['find'](_0x6fe2bc)[_0x71fc('0x2b')](handleEntityNotFound(_0x382319,null))['then'](respondWithResult(_0x382319,null))[_0x71fc('0x4c')](handleError(_0x382319,null));};exports['create']=function(_0x39c4aa,_0x2c98a1){return db[_0x71fc('0x35')]['create'](_0x39c4aa[_0x71fc('0x51')],{})[_0x71fc('0x2b')](function(_0x4b5f54){var _0x5e56ab=_0x39c4aa[_0x71fc('0x52')][_0x71fc('0x2d')]({'plain':!![]});if(!_0x5e56ab)throw new Error(_0x71fc('0x53'));if(_0x5e56ab[_0x71fc('0x54')]==='user'){var _0x262037=_0x4b5f54[_0x71fc('0x2d')]({'plain':!![]});var _0x596539=_0x71fc('0x2e');return db['UserProfileSection'][_0x71fc('0x55')]({'where':{'name':_0x596539,'userProfileId':_0x5e56ab[_0x71fc('0x56')]},'raw':!![]})['then'](function(_0xcea7c6){if(_0xcea7c6&&_0xcea7c6['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x262037[_0x71fc('0x39')],'resourceId':_0x262037['id'],'type':_0xcea7c6['name'],'sectionId':_0xcea7c6['id']},{})[_0x71fc('0x2b')](function(){return _0x4b5f54;});}else{return _0x4b5f54;}})['catch'](function(_0x438848){logger['error'](_0x71fc('0x57'),_0x438848);throw _0x438848;});}return _0x4b5f54;})[_0x71fc('0x2b')](respondWithResult(_0x2c98a1,0xc9))[_0x71fc('0x4c')](handleError(_0x2c98a1,null));};exports[_0x71fc('0x58')]=function(_0x4bb791,_0x3a5ca9){var _0x409251={'where':{'id':_0x4bb791[_0x71fc('0x4e')]['id']}},_0x4a16b3={};_0x4a16b3['model']=_['keys'](db[_0x71fc('0x35')][_0x71fc('0x36')]);_0x409251['attributes']=_[_0x71fc('0x3d')](_0x4a16b3[_0x71fc('0x38')],qs[_0x71fc('0x3f')](_0x4bb791[_0x71fc('0x3a')][_0x71fc('0x3f')]));_0x409251[_0x71fc('0x3e')]=_0x409251['attributes'][_0x71fc('0x4f')]?_0x409251['attributes']:_0x4a16b3[_0x71fc('0x38')];if(_0x4bb791[_0x71fc('0x3a')][_0x71fc('0x50')]){_0x409251[_0x71fc('0x49')]=[{'all':!![]}];}_0x409251=_[_0x71fc('0x46')]({},_0x409251,_0x4bb791[_0x71fc('0x48')]);return db['Dashboard'][_0x71fc('0x55')](_0x409251)[_0x71fc('0x2b')](handleEntityNotFound(_0x3a5ca9,null))[_0x71fc('0x2b')](function(_0x449b73){if(_0x449b73){var _0x2d72c6=_0x449b73[_0x71fc('0x2d')]({'plain':!![]});_0x2d72c6=qs[_0x71fc('0x59')](_0x2d72c6,['id','createdAt',_0x71fc('0x5a')]);_0x4bb791[_0x71fc('0x51')]=_['omit'](_0x4bb791['body'],['id',_0x71fc('0x5b'),_0x71fc('0x5a')]);return db[_0x71fc('0x35')]['create'](_[_0x71fc('0x46')](_0x2d72c6,_0x4bb791[_0x71fc('0x51')]),{'include':_0x4bb791['query'][_0x71fc('0x50')]?[{'all':!![]}]:undefined})[_0x71fc('0x2b')](function(_0x44c7af){var _0x30d7e5=_0x4bb791[_0x71fc('0x52')][_0x71fc('0x2d')]({'plain':!![]});if(!_0x30d7e5)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x30d7e5['role']===_0x71fc('0x52')){var _0x5a53ba=_0x44c7af['get']({'plain':!![]});var _0x3f6ecc='CustomDashboards';return db['UserProfileSection'][_0x71fc('0x55')]({'where':{'name':_0x3f6ecc,'userProfileId':_0x30d7e5[_0x71fc('0x56')]},'raw':!![]})[_0x71fc('0x2b')](function(_0x8a8a7b){if(_0x8a8a7b&&_0x8a8a7b[_0x71fc('0x5c')]===0x0){return db[_0x71fc('0x2f')][_0x71fc('0x5d')]({'name':_0x5a53ba['name'],'resourceId':_0x5a53ba['id'],'type':_0x8a8a7b['name'],'sectionId':_0x8a8a7b['id']},{})['then'](function(){return _0x44c7af;});}else{return _0x44c7af;}})[_0x71fc('0x4c')](function(_0x146ce2){logger[_0x71fc('0x31')](_0x71fc('0x57'),_0x146ce2);throw _0x146ce2;});}return _0x44c7af;});}})['then'](respondWithResult(_0x3a5ca9,0xc9))[_0x71fc('0x4c')](handleError(_0x3a5ca9,null));};exports[_0x71fc('0x2a')]=function(_0xbc392b,_0x1d14ab){if(_0xbc392b['body']['id']){delete _0xbc392b[_0x71fc('0x51')]['id'];}return db[_0x71fc('0x35')][_0x71fc('0x55')]({'where':{'id':_0xbc392b['params']['id']}})[_0x71fc('0x2b')](handleEntityNotFound(_0x1d14ab,null))[_0x71fc('0x2b')](saveUpdates(_0xbc392b['body'],null))[_0x71fc('0x2b')](respondWithResult(_0x1d14ab,null))[_0x71fc('0x4c')](handleError(_0x1d14ab,null));};exports[_0x71fc('0x2c')]=function(_0x2c1a2e,_0x8ef06){return db['Dashboard']['find']({'where':{'id':_0x2c1a2e[_0x71fc('0x4e')]['id']}})[_0x71fc('0x2b')](handleEntityNotFound(_0x8ef06,null))[_0x71fc('0x2b')](removeEntity(_0x8ef06,null))[_0x71fc('0x4c')](handleError(_0x8ef06,null));};function widgetAttributes(_0x58c78e){try{switch(_0x58c78e[_0x71fc('0x47')]){case _0x71fc('0x5e'):return[{'name':_0x71fc('0x5f'),'value':_0x58c78e[_0x71fc('0x5f')]||(_0x58c78e['attrs']&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e['attrs'][0x0]['value']:undefined)||'https://'}];case _0x71fc('0x61'):return[{'name':_0x71fc('0x62'),'value':_0x58c78e[_0x71fc('0x62')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e[_0x71fc('0x60')][0x0][_0x71fc('0x63')]:undefined)||''}];case _0x71fc('0x64'):return[{'name':'attrHourFormat','value':_0x58c78e[_0x71fc('0x65')]||(_0x58c78e['attrs']&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e['attrs'][0x0][_0x71fc('0x63')]:undefined)||'HH:mm:ss'},{'name':'attrTimezone','value':_0x58c78e[_0x71fc('0x66')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x1]?_0x58c78e[_0x71fc('0x60')][0x1]['value']:undefined)||'0.00'},{'name':'attrFontSize','value':_0x58c78e[_0x71fc('0x67')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x2]?_0x58c78e[_0x71fc('0x60')][0x2][_0x71fc('0x63')]:undefined)||0xc}];case _0x71fc('0x68'):return[{'name':_0x71fc('0x69'),'value':_0x58c78e[_0x71fc('0x69')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e[_0x71fc('0x60')][0x0]['value']:undefined)||_0x71fc('0x6a')},{'name':_0x71fc('0x6b'),'value':_0x58c78e[_0x71fc('0x6b')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x1]?_0x58c78e[_0x71fc('0x60')][0x1][_0x71fc('0x63')]:undefined)||[]},{'name':_0x71fc('0x67'),'value':_0x58c78e[_0x71fc('0x67')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x2]?_0x58c78e[_0x71fc('0x60')][0x2][_0x71fc('0x63')]:undefined)||0x14},{'name':_0x71fc('0x6c'),'value':_0x58c78e['attrChannel']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x3]?_0x58c78e[_0x71fc('0x60')][0x3][_0x71fc('0x63')]:undefined)||_0x71fc('0x6d')},{'name':_0x71fc('0x6e'),'value':_0x58c78e[_0x71fc('0x6e')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x4]?_0x58c78e[_0x71fc('0x60')][0x4]['value']:undefined)||''},{'name':_0x71fc('0x6f'),'value':_0x58c78e[_0x71fc('0x6f')]||(_0x58c78e['attrs']&&_0x58c78e[_0x71fc('0x60')][0x5]?_0x58c78e['attrs'][0x5][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x70'),'value':_0x58c78e['attrSmsAccounts']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x6]?_0x58c78e[_0x71fc('0x60')][0x6][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x71'),'value':_0x58c78e[_0x71fc('0x71')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x7]?_0x58c78e[_0x71fc('0x60')][0x7][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x72'),'value':_0x58c78e['attrWhatsappAccounts']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x8]?_0x58c78e[_0x71fc('0x60')][0x8]['value']:undefined)||''},{'name':_0x71fc('0x73'),'value':_0x58c78e[_0x71fc('0x73')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x9]?_0x58c78e[_0x71fc('0x60')][0x9][_0x71fc('0x63')]:undefined)||''}];case'multibar-chart':case _0x71fc('0x74'):return[{'name':_0x71fc('0x75'),'value':_0x58c78e[_0x71fc('0x75')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e['attrs'][0x0][_0x71fc('0x63')]:undefined)||_0x71fc('0x6a')},{'name':_0x71fc('0x76'),'value':_0x58c78e[_0x71fc('0x76')]||(_0x58c78e['attrs']&&_0x58c78e['attrs'][0x1]?_0x58c78e[_0x71fc('0x60')][0x1]['value']:undefined)||null},{'name':'attrSerie3','value':_0x58c78e['attrSerie3']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x2]?_0x58c78e[_0x71fc('0x60')][0x2][_0x71fc('0x63')]:undefined)||null},{'name':_0x71fc('0x6b'),'value':_0x58c78e['attrVoiceQueues']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x3]?_0x58c78e['attrs'][0x3][_0x71fc('0x63')]:undefined)||[]},{'name':_0x71fc('0x6c'),'value':_0x58c78e[_0x71fc('0x6c')]||(_0x58c78e['attrs']&&_0x58c78e['attrs'][0x4]?_0x58c78e[_0x71fc('0x60')][0x4][_0x71fc('0x63')]:undefined)||_0x71fc('0x6d')},{'name':_0x71fc('0x6e'),'value':_0x58c78e['attrEmailAccounts']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x5]?_0x58c78e[_0x71fc('0x60')][0x5][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x6f'),'value':_0x58c78e[_0x71fc('0x6f')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x6]?_0x58c78e['attrs'][0x6][_0x71fc('0x63')]:undefined)||''},{'name':'attrSmsAccounts','value':_0x58c78e['attrSmsAccounts']||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e['attrs'][0x7]?_0x58c78e['attrs'][0x7][_0x71fc('0x63')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x58c78e[_0x71fc('0x71')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x8]?_0x58c78e[_0x71fc('0x60')][0x8][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x72'),'value':_0x58c78e['attrWhatsappAccounts']||(_0x58c78e['attrs']&&_0x58c78e[_0x71fc('0x60')][0x9]?_0x58c78e[_0x71fc('0x60')][0x9][_0x71fc('0x63')]:undefined)||''},{'name':_0x71fc('0x73'),'value':_0x58c78e[_0x71fc('0x73')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0xa]?_0x58c78e['attrs'][0xa][_0x71fc('0x63')]:undefined)||''}];case _0x71fc('0x77'):return[{'name':_0x71fc('0x78'),'type':_0x58c78e[_0x71fc('0x79')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e[_0x71fc('0x60')][0x0]['type']:undefined)||null,'value':_0x58c78e[_0x71fc('0x78')]||(_0x58c78e['attrs']&&_0x58c78e[_0x71fc('0x60')][0x0]?_0x58c78e['attrs'][0x0][_0x71fc('0x63')]:undefined)||null},{'name':'attrRefresh','value':_0x58c78e[_0x71fc('0x7a')]||(_0x58c78e[_0x71fc('0x60')]&&_0x58c78e[_0x71fc('0x60')][0x1]?_0x58c78e[_0x71fc('0x60')][0x1][_0x71fc('0x63')]:undefined)||0x0}];default:return[];}}catch(_0x14a5b2){logger[_0x71fc('0x31')](_0x71fc('0x7b'),JSON[_0x71fc('0x7c')](_0x14a5b2));return[];}}exports[_0x71fc('0x7d')]=function(_0x4a2340,_0x5c8a90,_0x4e1dbe){if(_0x4a2340[_0x71fc('0x51')]['id']){delete _0x4a2340[_0x71fc('0x51')]['id'];}return db['Dashboard'][_0x71fc('0x55')]({'where':{'id':_0x4a2340[_0x71fc('0x4e')]['id']}})[_0x71fc('0x2b')](handleEntityNotFound(_0x5c8a90,null))['then'](function(_0x4916b8){if(_0x4916b8){_0x4a2340[_0x71fc('0x51')][_0x71fc('0x7e')]=_0x4916b8['id'];_0x4a2340['body'][_0x71fc('0x60')]=widgetAttributes(_0x4a2340[_0x71fc('0x51')]);return db[_0x71fc('0x7f')][_0x71fc('0x5d')](_0x4a2340['body']);}})[_0x71fc('0x2b')](respondWithResult(_0x5c8a90,null))[_0x71fc('0x4c')](handleError(_0x5c8a90,null));};exports['getItems']=function(_0x37431f,_0x59fc81,_0x1f506f){var _0x1724f6={};var _0x6a49ad={};var _0x2d9401;var _0x15c297;return db['Dashboard'][_0x71fc('0x80')]({'where':{'id':_0x37431f[_0x71fc('0x4e')]['id']}})[_0x71fc('0x2b')](handleEntityNotFound(_0x59fc81,null))[_0x71fc('0x2b')](function(_0x5418d9){if(_0x5418d9){_0x2d9401=_0x5418d9;_0x6a49ad[_0x71fc('0x38')]=_[_0x71fc('0x3b')](db[_0x71fc('0x7f')][_0x71fc('0x36')]);_0x6a49ad[_0x71fc('0x3a')]=_[_0x71fc('0x3b')](_0x37431f['query']);_0x6a49ad[_0x71fc('0x3c')]=_['intersection'](_0x6a49ad[_0x71fc('0x38')],_0x6a49ad['query']);_0x1724f6['attributes']=_[_0x71fc('0x3d')](_0x6a49ad[_0x71fc('0x38')],qs[_0x71fc('0x3f')](_0x37431f['query'][_0x71fc('0x3f')]));_0x1724f6['attributes']=_0x1724f6[_0x71fc('0x3e')]['length']?_0x1724f6['attributes']:_0x6a49ad['model'];_0x1724f6[_0x71fc('0x81')]=qs[_0x71fc('0x42')](_0x37431f[_0x71fc('0x3a')]['sort']);_0x1724f6[_0x71fc('0x43')]=qs[_0x71fc('0x3c')](_[_0x71fc('0x44')](_0x37431f[_0x71fc('0x3a')],_0x6a49ad[_0x71fc('0x3c')]));if(_0x37431f['query'][_0x71fc('0x45')]){_0x1724f6['where']=_[_0x71fc('0x46')](_0x1724f6[_0x71fc('0x43')],{'$or':_['map'](_0x1724f6[_0x71fc('0x3e')],function(_0x18d4fd){var _0x52e006={};_0x52e006[_0x18d4fd]={'$like':'%'+_0x37431f[_0x71fc('0x3a')]['filter']+'%'};return _0x52e006;})});}_0x1724f6=_['merge']({},_0x1724f6,_0x37431f['options']);return _0x2d9401['getItems'](_0x1724f6);}})['then'](function(_0x7573ee){if(_0x7573ee){_0x15c297=_0x7573ee['length'];if(!_0x37431f[_0x71fc('0x3a')]['hasOwnProperty']('nolimit')){_0x1724f6[_0x71fc('0x24')]=qs[_0x71fc('0x24')](_0x37431f[_0x71fc('0x3a')]['limit']);_0x1724f6[_0x71fc('0x22')]=qs[_0x71fc('0x22')](_0x37431f[_0x71fc('0x3a')]['offset']);}return _0x2d9401[_0x71fc('0x82')](_0x1724f6);}})[_0x71fc('0x2b')](function(_0x459a27){if(_0x459a27){return _0x459a27?{'count':_0x15c297,'rows':_0x459a27}:null;}})[_0x71fc('0x2b')](respondWithResult(_0x59fc81,null))[_0x71fc('0x4c')](handleError(_0x59fc81,null));}; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.events.js b/server/api/dashboard/dashboard.events.js new file mode 100644 index 0000000..f7da2e6 --- /dev/null +++ b/server/api/dashboard/dashboard.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0a01=['hasOwnProperty','exports','setMaxListeners','remove','emit'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x0a01,0x10b));var _0x10a0=function(_0x3a9acd,_0x77ca4c){_0x3a9acd=_0x3a9acd-0x0;var _0x4c8cdb=_0x0a01[_0x3a9acd];return _0x4c8cdb;};'use strict';var EventEmitter=require('events');var Dashboard=require('../../mysqldb')['db']['Dashboard'];var DashboardEvents=new EventEmitter();DashboardEvents[_0x10a0('0x0')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0x10a0('0x1')};function emitEvent(_0x4c9f4a){return function(_0x32a034,_0x3fc5fa,_0x290eb9){DashboardEvents[_0x10a0('0x2')](_0x4c9f4a+':'+_0x32a034['id'],_0x32a034);DashboardEvents[_0x10a0('0x2')](_0x4c9f4a,_0x32a034);_0x290eb9(null);};}for(var e in events){if(events[_0x10a0('0x3')](e)){var event=events[e];Dashboard['hook'](e,emitEvent(event));}}module[_0x10a0('0x4')]=DashboardEvents; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.model.js b/server/api/dashboard/dashboard.model.js new file mode 100644 index 0000000..4001c80 --- /dev/null +++ b/server/api/dashboard/dashboard.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x066f=['api','moment','bluebird','request-promise','path','../../config/environment','exports','define','Dashboard','dashboards','lodash','util','../../config/logger'];(function(_0x523710,_0x5c0909){var _0x3e4973=function(_0x450592){while(--_0x450592){_0x523710['push'](_0x523710['shift']());}};_0x3e4973(++_0x5c0909);}(_0x066f,0x101));var _0xf066=function(_0xe6db94,_0x342d69){_0xe6db94=_0xe6db94-0x0;var _0x31abe3=_0x066f[_0xe6db94];return _0x31abe3;};'use strict';var _=require(_0xf066('0x0'));var util=require(_0xf066('0x1'));var logger=require(_0xf066('0x2'))(_0xf066('0x3'));var moment=require(_0xf066('0x4'));var BPromise=require(_0xf066('0x5'));var rp=require(_0xf066('0x6'));var fs=require('fs');var path=require(_0xf066('0x7'));var rimraf=require('rimraf');var config=require(_0xf066('0x8'));var attributes=require('./dashboard.attributes');module[_0xf066('0x9')]=function(_0x45e244,_0xc3ac86){return _0x45e244[_0xf066('0xa')](_0xf066('0xb'),attributes,{'tableName':_0xf066('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/dashboard/dashboard.rpc.js b/server/api/dashboard/dashboard.rpc.js new file mode 100644 index 0000000..313ce12 --- /dev/null +++ b/server/api/dashboard/dashboard.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2224=['register','request','then','info','Dashboard,\x20%s,\x20%s','request\x20sent','debug','Dashboard,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','lodash','util','moment','../../config/logger','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter'];(function(_0x1f07fa,_0x5e2e6c){var _0x48db19=function(_0x3c02ac){while(--_0x3c02ac){_0x1f07fa['push'](_0x1f07fa['shift']());}};_0x48db19(++_0x5e2e6c);}(_0x2224,0x85));var _0x4222=function(_0x1ec8f9,_0x22f5e7){_0x1ec8f9=_0x1ec8f9-0x0;var _0x17cd3d=_0x2224[_0x1ec8f9];return _0x17cd3d;};'use strict';var _=require(_0x4222('0x0'));var util=require(_0x4222('0x1'));var moment=require(_0x4222('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x4222('0x3'))(_0x4222('0x4'));var config=require(_0x4222('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x4222('0x6')]['http']({'port':0x232a});config[_0x4222('0x7')]=_[_0x4222('0x8')](config[_0x4222('0x7')],{'host':_0x4222('0x9'),'port':0x18eb});var socket=require(_0x4222('0xa'))(new Redis(config[_0x4222('0x7')]));require('./dashboard.socket')[_0x4222('0xb')](socket);function respondWithRpcPromise(_0x472660,_0x16eb2d,_0x586f21){return new BPromise(function(_0x313181,_0x323356){return client[_0x4222('0xc')](_0x472660,_0x586f21)[_0x4222('0xd')](function(_0x7fceb7){logger[_0x4222('0xe')](_0x4222('0xf'),_0x16eb2d,_0x4222('0x10'));logger[_0x4222('0x11')](_0x4222('0x12'),_0x16eb2d,'request\x20sent',JSON[_0x4222('0x13')](_0x7fceb7));if(_0x7fceb7[_0x4222('0x14')]){if(_0x7fceb7[_0x4222('0x14')][_0x4222('0x15')]===0x1f4){logger[_0x4222('0x14')](_0x4222('0xf'),_0x16eb2d,_0x7fceb7[_0x4222('0x14')]['message']);return _0x323356(_0x7fceb7[_0x4222('0x14')][_0x4222('0x16')]);}logger[_0x4222('0x14')](_0x4222('0xf'),_0x16eb2d,_0x7fceb7[_0x4222('0x14')][_0x4222('0x16')]);return _0x313181(_0x7fceb7['error']['message']);}else{logger[_0x4222('0xe')]('Dashboard,\x20%s,\x20%s',_0x16eb2d,'request\x20sent');_0x313181(_0x7fceb7['result'][_0x4222('0x16')]);}})[_0x4222('0x17')](function(_0x429c6d){logger[_0x4222('0x14')](_0x4222('0xf'),_0x16eb2d,_0x429c6d);_0x323356(_0x429c6d);});});} \ No newline at end of file diff --git a/server/api/dashboard/dashboard.socket.js b/server/api/dashboard/dashboard.socket.js new file mode 100644 index 0000000..6228f2e --- /dev/null +++ b/server/api/dashboard/dashboard.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2da5=['dashboard:','./dashboard.events','save','remove','update','emit','removeListener','length'];(function(_0x4ee0a8,_0x1e7570){var _0x2ac1e9=function(_0x1be960){while(--_0x1be960){_0x4ee0a8['push'](_0x4ee0a8['shift']());}};_0x2ac1e9(++_0x1e7570);}(_0x2da5,0x71));var _0x52da=function(_0x5eecac,_0x2dcae9){_0x5eecac=_0x5eecac-0x0;var _0x3dea33=_0x2da5[_0x5eecac];return _0x3dea33;};'use strict';var DashboardEvents=require(_0x52da('0x0'));var events=[_0x52da('0x1'),_0x52da('0x2'),_0x52da('0x3')];function createListener(_0x1982ce,_0x5b9f3b){return function(_0xe54e6a){_0x5b9f3b[_0x52da('0x4')](_0x1982ce,_0xe54e6a);};}function removeListener(_0x127e92,_0x4551e7){return function(){DashboardEvents[_0x52da('0x5')](_0x127e92,_0x4551e7);};}exports['register']=function(_0x14c23c){for(var _0x113e54=0x0,_0x3e184e=events[_0x52da('0x6')];_0x113e54<_0x3e184e;_0x113e54++){var _0x585b74=events[_0x113e54];var _0x2bfe40=createListener(_0x52da('0x7')+_0x585b74,_0x14c23c);DashboardEvents['on'](_0x585b74,_0x2bfe40);}}; \ No newline at end of file diff --git a/server/api/dashboard/index.js b/server/api/dashboard/index.js new file mode 100644 index 0000000..61a44fb --- /dev/null +++ b/server/api/dashboard/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x82de=['Router','fs-extra','../../components/auth/service','../../config/environment','./dashboard.controller','get','isAuthenticated','/:id','show','/:id/items','create','/:id/clone','post','addItem','update','destroy','exports','multer','util','path','connect-timeout','express'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0x82de,0x19d));var _0xe82d=function(_0x4a5fa5,_0x51dadc){_0x4a5fa5=_0x4a5fa5-0x0;var _0x241266=_0x82de[_0x4a5fa5];return _0x241266;};'use strict';var multer=require(_0xe82d('0x0'));var util=require(_0xe82d('0x1'));var path=require(_0xe82d('0x2'));var timeout=require(_0xe82d('0x3'));var express=require(_0xe82d('0x4'));var router=express[_0xe82d('0x5')]();var fs_extra=require(_0xe82d('0x6'));var auth=require(_0xe82d('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0xe82d('0x8'));var controller=require(_0xe82d('0x9'));router[_0xe82d('0xa')]('/',auth[_0xe82d('0xb')](),controller['index']);router[_0xe82d('0xa')](_0xe82d('0xc'),auth[_0xe82d('0xb')](),controller[_0xe82d('0xd')]);router[_0xe82d('0xa')](_0xe82d('0xe'),auth[_0xe82d('0xb')](),controller['getItems']);router['post']('/',auth['isAuthenticated'](),controller[_0xe82d('0xf')]);router['post'](_0xe82d('0x10'),auth[_0xe82d('0xb')](),controller['clone']);router[_0xe82d('0x11')](_0xe82d('0xe'),auth[_0xe82d('0xb')](),controller[_0xe82d('0x12')]);router['put'](_0xe82d('0xc'),auth[_0xe82d('0xb')](),controller[_0xe82d('0x13')]);router['delete'](_0xe82d('0xc'),auth[_0xe82d('0xb')](),controller[_0xe82d('0x14')]);module[_0xe82d('0x15')]=router; \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.attributes.js b/server/api/dashboardItem/dashboardItem.attributes.js new file mode 100644 index 0000000..fff6074 --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb4c7=['TEXT','long','parse','getDataValue','attrs','setDataValue','stringify','INTEGER','#ffffff','#2196f3','sequelize','squel','lodash','exports','STRING'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xb4c7,0x1ea));var _0x7b4c=function(_0x384706,_0xd1665b){_0x384706=_0x384706-0x0;var _0x2b67f4=_0xb4c7[_0x384706];return _0x2b67f4;};'use strict';var Sequelize=require(_0x7b4c('0x0'));var squel=require(_0x7b4c('0x1'));var _=require(_0x7b4c('0x2'));module[_0x7b4c('0x3')]={'title':{'type':Sequelize[_0x7b4c('0x4')],'allowNull':![]},'type':{'type':Sequelize['STRING'](0x14),'allowNull':![],'validate':{'len':[0x1,0x14]}},'attrs':{'type':Sequelize[_0x7b4c('0x5')](_0x7b4c('0x6')),'get':function(){try{return JSON[_0x7b4c('0x7')](this[_0x7b4c('0x8')](_0x7b4c('0x9')));}catch(_0x5adec9){return[];}},'set':function(_0x1b0f57){try{this[_0x7b4c('0xa')](_0x7b4c('0x9'),JSON['stringify'](_0x1b0f57));}catch(_0x2d7b7e){this[_0x7b4c('0xa')]('attrs',JSON[_0x7b4c('0xb')]([]));}}},'sizeX':{'type':Sequelize[_0x7b4c('0xc')],'allowNull':![],'defaultValue':0x1},'sizeY':{'type':Sequelize[_0x7b4c('0xc')],'allowNull':![],'defaultValue':0x1},'row':{'type':Sequelize[_0x7b4c('0xc')]},'col':{'type':Sequelize[_0x7b4c('0xc')]},'background':{'type':Sequelize[_0x7b4c('0x4')],'allowNull':![],'defaultValue':_0x7b4c('0xd'),'validate':{'notEmpty':!![]}},'foreground':{'type':Sequelize[_0x7b4c('0x4')],'allowNull':![],'defaultValue':_0x7b4c('0xe'),'validate':{'notEmpty':!![]}},'link':{'type':Sequelize[_0x7b4c('0x4')]},'titleFontSize':{'type':Sequelize['INTEGER'],'defaultValue':0xc}}; \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.controller.js b/server/api/dashboardItem/dashboardItem.controller.js new file mode 100644 index 0000000..f72f95c --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x16ce=['intersection','attributes','fields','length','includeAll','include','merge','options','find','catch','params','type','iframe','attrUrl','attrs','value','https://','attrPath','clock','attrHourFormat','attrTimezone','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrChannel','web-report','reportType','attrRefresh','widgetAttributes:\x20%s','create','body','update','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','./dashboardItem.socket','register','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','name','show','model','keys','DashboardItem','rawAttributes','query','filters'];(function(_0x42fa90,_0x5b8ad7){var _0x3bf801=function(_0x4d645a){while(--_0x4d645a){_0x42fa90['push'](_0x42fa90['shift']());}};_0x3bf801(++_0x5b8ad7);}(_0x16ce,0xfb));var _0xe16c=function(_0x215f6f,_0x233f4e){_0x215f6f=_0x215f6f-0x0;var _0x4250f6=_0x16ce[_0x215f6f];return _0x4250f6;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe16c('0x0'));var zipdir=require(_0xe16c('0x1'));var jsonpatch=require(_0xe16c('0x2'));var rp=require(_0xe16c('0x3'));var moment=require(_0xe16c('0x4'));var BPromise=require(_0xe16c('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xe16c('0x6'));var csv=require('to-csv');var ejs=require(_0xe16c('0x7'));var fs=require('fs');var fs_extra=require(_0xe16c('0x8'));var _=require(_0xe16c('0x9'));var squel=require(_0xe16c('0xa'));var crypto=require(_0xe16c('0xb'));var jsforce=require(_0xe16c('0xc'));var deskjs=require(_0xe16c('0xd'));var toCsv=require(_0xe16c('0xe'));var querystring=require('querystring');var Papa=require(_0xe16c('0xf'));var Redis=require(_0xe16c('0x10'));var authService=require(_0xe16c('0x11'));var qs=require(_0xe16c('0x12'));var as=require(_0xe16c('0x13'));var hardwareService=require(_0xe16c('0x14'));var logger=require(_0xe16c('0x15'))(_0xe16c('0x16'));var utils=require(_0xe16c('0x17'));var config=require(_0xe16c('0x18'));var licenseUtil=require(_0xe16c('0x19'));var db=require('../../mysqldb')['db'];config[_0xe16c('0x1a')]=_[_0xe16c('0x1b')](config[_0xe16c('0x1a')],{'host':_0xe16c('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe16c('0x1d'))[_0xe16c('0x1e')](socket);function respondWithStatusCode(_0xb1f263,_0x14fc33){_0x14fc33=_0x14fc33||0xcc;return function(_0x4a4a21){if(_0x4a4a21){return _0xb1f263[_0xe16c('0x1f')](_0x14fc33);}return _0xb1f263['status'](_0x14fc33)[_0xe16c('0x20')]();};}function respondWithResult(_0x7a62b9,_0x353a5b){_0x353a5b=_0x353a5b||0xc8;return function(_0x5b7439){if(_0x5b7439){return _0x7a62b9[_0xe16c('0x21')](_0x353a5b)[_0xe16c('0x22')](_0x5b7439);}};}function respondWithFilteredResult(_0x3a99db,_0x3bb637){return function(_0x2afddf){if(_0x2afddf){var _0x5121f8=typeof _0x3bb637[_0xe16c('0x23')]===_0xe16c('0x24')&&typeof _0x3bb637[_0xe16c('0x25')]==='undefined';var _0x52ef0f=_0x2afddf['count'];var _0x30e657=_0x5121f8?0x0:_0x3bb637[_0xe16c('0x23')];var _0x611939=_0x5121f8?_0x2afddf[_0xe16c('0x26')]:_0x3bb637[_0xe16c('0x23')]+_0x3bb637[_0xe16c('0x25')];var _0x48beef;if(_0x611939>=_0x52ef0f){_0x611939=_0x52ef0f;_0x48beef=0xc8;}else{_0x48beef=0xce;}_0x3a99db[_0xe16c('0x21')](_0x48beef);return _0x3a99db[_0xe16c('0x27')](_0xe16c('0x28'),_0x30e657+'-'+_0x611939+'/'+_0x52ef0f)[_0xe16c('0x22')](_0x2afddf);}return null;};}function patchUpdates(_0x5a88ed){return function(_0x27eb44){try{jsonpatch[_0xe16c('0x29')](_0x27eb44,_0x5a88ed,!![]);}catch(_0x453aed){return BPromise[_0xe16c('0x2a')](_0x453aed);}return _0x27eb44[_0xe16c('0x2b')]();};}function saveUpdates(_0x18669a,_0x1d888d){return function(_0x8a9b36){if(_0x8a9b36){return _0x8a9b36['update'](_0x18669a)[_0xe16c('0x2c')](function(_0x9fd053){return _0x9fd053;});}return null;};}function removeEntity(_0x4fdc91,_0xd0799){return function(_0x5b6ca6){if(_0x5b6ca6){return _0x5b6ca6[_0xe16c('0x2d')]()['then'](function(){_0x4fdc91[_0xe16c('0x21')](0xcc)[_0xe16c('0x20')]();});}};}function handleEntityNotFound(_0x234c26,_0x156de3){return function(_0x473025){if(!_0x473025){_0x234c26[_0xe16c('0x1f')](0x194);}return _0x473025;};}function handleError(_0xfa565a,_0x69cd87){_0x69cd87=_0x69cd87||0x1f4;return function(_0x3472ef){logger[_0xe16c('0x2e')](_0x3472ef['stack']);if(_0x3472ef[_0xe16c('0x2f')]){delete _0x3472ef[_0xe16c('0x2f')];}_0xfa565a[_0xe16c('0x21')](_0x69cd87)['send'](_0x3472ef);};}exports[_0xe16c('0x30')]=function(_0x48d6b3,_0x4a0548){var _0x1ce8f5={'raw':![],'where':{'id':_0x48d6b3['params']['id']}},_0x25ec64={};_0x25ec64[_0xe16c('0x31')]=_[_0xe16c('0x32')](db[_0xe16c('0x33')][_0xe16c('0x34')]);_0x25ec64[_0xe16c('0x35')]=_[_0xe16c('0x32')](_0x48d6b3['query']);_0x25ec64[_0xe16c('0x36')]=_[_0xe16c('0x37')](_0x25ec64['model'],_0x25ec64[_0xe16c('0x35')]);_0x1ce8f5[_0xe16c('0x38')]=_[_0xe16c('0x37')](_0x25ec64[_0xe16c('0x31')],qs[_0xe16c('0x39')](_0x48d6b3[_0xe16c('0x35')][_0xe16c('0x39')]));_0x1ce8f5['attributes']=_0x1ce8f5[_0xe16c('0x38')][_0xe16c('0x3a')]?_0x1ce8f5[_0xe16c('0x38')]:_0x25ec64[_0xe16c('0x31')];if(_0x48d6b3[_0xe16c('0x35')][_0xe16c('0x3b')]){_0x1ce8f5[_0xe16c('0x3c')]=[{'all':!![]}];}_0x1ce8f5=_[_0xe16c('0x3d')]({},_0x1ce8f5,_0x48d6b3[_0xe16c('0x3e')]);return db[_0xe16c('0x33')][_0xe16c('0x3f')](_0x1ce8f5)[_0xe16c('0x2c')](handleEntityNotFound(_0x4a0548,null))[_0xe16c('0x2c')](respondWithResult(_0x4a0548,null))[_0xe16c('0x40')](handleError(_0x4a0548,null));};exports[_0xe16c('0x2d')]=function(_0x46bc4b,_0x5a3351){return db[_0xe16c('0x33')][_0xe16c('0x3f')]({'where':{'id':_0x46bc4b[_0xe16c('0x41')]['id']}})[_0xe16c('0x2c')](handleEntityNotFound(_0x5a3351,null))[_0xe16c('0x2c')](removeEntity(_0x5a3351,null))['catch'](handleError(_0x5a3351,null));};function widgetAttributes(_0x4e9b4a){try{switch(_0x4e9b4a[_0xe16c('0x42')]){case _0xe16c('0x43'):return[{'name':_0xe16c('0x44'),'value':_0x4e9b4a[_0xe16c('0x44')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x0]?_0x4e9b4a[_0xe16c('0x45')][0x0][_0xe16c('0x46')]:undefined)||_0xe16c('0x47')}];case'custom':return[{'name':_0xe16c('0x48'),'value':_0x4e9b4a[_0xe16c('0x48')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x0]?_0x4e9b4a['attrs'][0x0][_0xe16c('0x46')]:undefined)||''}];case _0xe16c('0x49'):return[{'name':_0xe16c('0x4a'),'value':_0x4e9b4a[_0xe16c('0x4a')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x0]?_0x4e9b4a['attrs'][0x0][_0xe16c('0x46')]:undefined)||'HH:mm:ss'},{'name':_0xe16c('0x4b'),'value':_0x4e9b4a[_0xe16c('0x4b')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x1]?_0x4e9b4a[_0xe16c('0x45')][0x1]['value']:undefined)||_0xe16c('0x4c')},{'name':_0xe16c('0x4d'),'value':_0x4e9b4a[_0xe16c('0x4d')]||(_0x4e9b4a['attrs']&&_0x4e9b4a[_0xe16c('0x45')][0x2]?_0x4e9b4a[_0xe16c('0x45')][0x2][_0xe16c('0x46')]:undefined)||0xc}];case _0xe16c('0x4e'):return[{'name':'attrMetric','value':_0x4e9b4a[_0xe16c('0x4f')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x0]?_0x4e9b4a[_0xe16c('0x45')][0x0]['value']:undefined)||_0xe16c('0x50')},{'name':_0xe16c('0x51'),'value':_0x4e9b4a[_0xe16c('0x51')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x1]?_0x4e9b4a[_0xe16c('0x45')][0x1][_0xe16c('0x46')]:undefined)||[]},{'name':_0xe16c('0x4d'),'value':_0x4e9b4a[_0xe16c('0x4d')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x2]?_0x4e9b4a[_0xe16c('0x45')][0x2][_0xe16c('0x46')]:undefined)||0x14},{'name':'attrChannel','value':_0x4e9b4a['attrChannel']||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x3]?_0x4e9b4a[_0xe16c('0x45')][0x3][_0xe16c('0x46')]:undefined)||_0xe16c('0x52')},{'name':_0xe16c('0x53'),'value':_0x4e9b4a[_0xe16c('0x53')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x4]?_0x4e9b4a[_0xe16c('0x45')][0x4][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x54'),'value':_0x4e9b4a[_0xe16c('0x54')]||(_0x4e9b4a['attrs']&&_0x4e9b4a[_0xe16c('0x45')][0x5]?_0x4e9b4a[_0xe16c('0x45')][0x5][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x55'),'value':_0x4e9b4a[_0xe16c('0x55')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x6]?_0x4e9b4a[_0xe16c('0x45')][0x6][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x56'),'value':_0x4e9b4a[_0xe16c('0x56')]||(_0x4e9b4a['attrs']&&_0x4e9b4a['attrs'][0x7]?_0x4e9b4a['attrs'][0x7][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x57'),'value':_0x4e9b4a[_0xe16c('0x57')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x8]?_0x4e9b4a[_0xe16c('0x45')][0x8]['value']:undefined)||''},{'name':_0xe16c('0x58'),'value':_0x4e9b4a[_0xe16c('0x58')]||(_0x4e9b4a['attrs']&&_0x4e9b4a['attrs'][0x9]?_0x4e9b4a['attrs'][0x9]['value']:undefined)||''}];case _0xe16c('0x59'):case _0xe16c('0x5a'):return[{'name':_0xe16c('0x5b'),'value':_0x4e9b4a[_0xe16c('0x5b')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x0]?_0x4e9b4a[_0xe16c('0x45')][0x0]['value']:undefined)||'total'},{'name':_0xe16c('0x5c'),'value':_0x4e9b4a[_0xe16c('0x5c')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x1]?_0x4e9b4a[_0xe16c('0x45')][0x1]['value']:undefined)||null},{'name':'attrSerie3','value':_0x4e9b4a[_0xe16c('0x5d')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x2]?_0x4e9b4a[_0xe16c('0x45')][0x2][_0xe16c('0x46')]:undefined)||null},{'name':_0xe16c('0x51'),'value':_0x4e9b4a[_0xe16c('0x51')]||(_0x4e9b4a['attrs']&&_0x4e9b4a[_0xe16c('0x45')][0x3]?_0x4e9b4a[_0xe16c('0x45')][0x3][_0xe16c('0x46')]:undefined)||[]},{'name':_0xe16c('0x5e'),'value':_0x4e9b4a['attrChannel']||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x4]?_0x4e9b4a[_0xe16c('0x45')][0x4][_0xe16c('0x46')]:undefined)||_0xe16c('0x52')},{'name':_0xe16c('0x53'),'value':_0x4e9b4a[_0xe16c('0x53')]||(_0x4e9b4a['attrs']&&_0x4e9b4a[_0xe16c('0x45')][0x5]?_0x4e9b4a[_0xe16c('0x45')][0x5]['value']:undefined)||''},{'name':_0xe16c('0x54'),'value':_0x4e9b4a[_0xe16c('0x54')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x6]?_0x4e9b4a[_0xe16c('0x45')][0x6][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x55'),'value':_0x4e9b4a[_0xe16c('0x55')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x7]?_0x4e9b4a['attrs'][0x7][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x56'),'value':_0x4e9b4a[_0xe16c('0x56')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x8]?_0x4e9b4a['attrs'][0x8]['value']:undefined)||''},{'name':_0xe16c('0x57'),'value':_0x4e9b4a[_0xe16c('0x57')]||(_0x4e9b4a['attrs']&&_0x4e9b4a['attrs'][0x9]?_0x4e9b4a[_0xe16c('0x45')][0x9][_0xe16c('0x46')]:undefined)||''},{'name':_0xe16c('0x58'),'value':_0x4e9b4a[_0xe16c('0x58')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0xa]?_0x4e9b4a[_0xe16c('0x45')][0xa][_0xe16c('0x46')]:undefined)||''}];case _0xe16c('0x5f'):return[{'name':'attrReport','type':_0x4e9b4a[_0xe16c('0x60')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a[_0xe16c('0x45')][0x0]?_0x4e9b4a['attrs'][0x0]['type']:undefined)||null,'value':_0x4e9b4a['attrReport']||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x0]?_0x4e9b4a['attrs'][0x0][_0xe16c('0x46')]:undefined)||null},{'name':_0xe16c('0x61'),'value':_0x4e9b4a[_0xe16c('0x61')]||(_0x4e9b4a[_0xe16c('0x45')]&&_0x4e9b4a['attrs'][0x1]?_0x4e9b4a[_0xe16c('0x45')][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x1937e3){logger[_0xe16c('0x2e')](_0xe16c('0x62'),JSON['stringify'](_0x1937e3));return[];}}exports[_0xe16c('0x63')]=function(_0x4f8e03,_0x998487){if(_0x4f8e03[_0xe16c('0x64')]){_0x4f8e03[_0xe16c('0x64')][_0xe16c('0x45')]=widgetAttributes(_0x4f8e03['body']);}return db[_0xe16c('0x33')][_0xe16c('0x63')](_0x4f8e03['body'],{})[_0xe16c('0x2c')](respondWithResult(_0x998487,0xc9))['catch'](handleError(_0x998487,null));};exports[_0xe16c('0x65')]=function(_0x18ed00,_0x33b10d){if(_0x18ed00[_0xe16c('0x64')]['id']){delete _0x18ed00['body']['id'];}_0x18ed00['body'][_0xe16c('0x45')]=widgetAttributes(_0x18ed00[_0xe16c('0x64')]);return db['DashboardItem'][_0xe16c('0x3f')]({'where':{'id':_0x18ed00[_0xe16c('0x41')]['id']}})['then'](handleEntityNotFound(_0x33b10d,null))['then'](saveUpdates(_0x18ed00[_0xe16c('0x64')],null))[_0xe16c('0x2c')](respondWithResult(_0x33b10d,null))['catch'](handleError(_0x33b10d,null));}; \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.events.js b/server/api/dashboardItem/dashboardItem.events.js new file mode 100644 index 0000000..0ac87e6 --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6ad6=['hook','events','../../mysqldb','DashboardItem','setMaxListeners','save','update','emit','hasOwnProperty'];(function(_0x31ea8f,_0x2d1cbe){var _0x3bc2ac=function(_0xb57e34){while(--_0xb57e34){_0x31ea8f['push'](_0x31ea8f['shift']());}};_0x3bc2ac(++_0x2d1cbe);}(_0x6ad6,0x1e7));var _0x66ad=function(_0x3dc7c3,_0x369f51){_0x3dc7c3=_0x3dc7c3-0x0;var _0x147d13=_0x6ad6[_0x3dc7c3];return _0x147d13;};'use strict';var EventEmitter=require(_0x66ad('0x0'));var DashboardItem=require(_0x66ad('0x1'))['db'][_0x66ad('0x2')];var DashboardItemEvents=new EventEmitter();DashboardItemEvents[_0x66ad('0x3')](0x0);var events={'afterCreate':_0x66ad('0x4'),'afterUpdate':_0x66ad('0x5'),'afterDestroy':'remove'};function emitEvent(_0x25dad2){return function(_0x1b3e06,_0x1ef58f,_0x375e22){DashboardItemEvents[_0x66ad('0x6')](_0x25dad2+':'+_0x1b3e06['id'],_0x1b3e06);DashboardItemEvents[_0x66ad('0x6')](_0x25dad2,_0x1b3e06);_0x375e22(null);};}for(var e in events){if(events[_0x66ad('0x7')](e)){var event=events[e];DashboardItem[_0x66ad('0x8')](e,emitEvent(event));}}module['exports']=DashboardItemEvents; \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.model.js b/server/api/dashboardItem/dashboardItem.model.js new file mode 100644 index 0000000..8c97227 --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb9e1=['./dashboardItem.attributes','exports','define','DashboardItem','dashboard_items','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','../../config/environment'];(function(_0x27e7c3,_0x4d10cf){var _0x3a866f=function(_0x1848cf){while(--_0x1848cf){_0x27e7c3['push'](_0x27e7c3['shift']());}};_0x3a866f(++_0x4d10cf);}(_0xb9e1,0xad));var _0x1b9e=function(_0x4913a8,_0x5a8cbd){_0x4913a8=_0x4913a8-0x0;var _0x50a4de=_0xb9e1[_0x4913a8];return _0x50a4de;};'use strict';var _=require(_0x1b9e('0x0'));var util=require(_0x1b9e('0x1'));var logger=require(_0x1b9e('0x2'))(_0x1b9e('0x3'));var moment=require(_0x1b9e('0x4'));var BPromise=require(_0x1b9e('0x5'));var rp=require(_0x1b9e('0x6'));var fs=require('fs');var path=require(_0x1b9e('0x7'));var rimraf=require('rimraf');var config=require(_0x1b9e('0x8'));var attributes=require(_0x1b9e('0x9'));module[_0x1b9e('0xa')]=function(_0x1ab7b7,_0xbe882){return _0x1ab7b7[_0x1b9e('0xb')](_0x1b9e('0xc'),attributes,{'tableName':_0x1b9e('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.rpc.js b/server/api/dashboardItem/dashboardItem.rpc.js new file mode 100644 index 0000000..adb2698 --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa116=['stringify','error','code','message','result','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./dashboardItem.socket','register','request','then','info','DashboardItem,\x20%s,\x20%s','request\x20sent','debug','DashboardItem,\x20%s,\x20%s,\x20%s'];(function(_0x1bca90,_0x5560af){var _0x244736=function(_0x4453b2){while(--_0x4453b2){_0x1bca90['push'](_0x1bca90['shift']());}};_0x244736(++_0x5560af);}(_0xa116,0x1a9));var _0x6a11=function(_0x6987b,_0x5b3226){_0x6987b=_0x6987b-0x0;var _0x29703b=_0xa116[_0x6987b];return _0x29703b;};'use strict';var _=require('lodash');var util=require(_0x6a11('0x0'));var moment=require(_0x6a11('0x1'));var BPromise=require(_0x6a11('0x2'));var rs=require(_0x6a11('0x3'));var fs=require('fs');var Redis=require(_0x6a11('0x4'));var db=require(_0x6a11('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x6a11('0x6'))(_0x6a11('0x7'));var config=require(_0x6a11('0x8'));var jayson=require(_0x6a11('0x9'));var client=jayson[_0x6a11('0xa')][_0x6a11('0xb')]({'port':0x232a});config[_0x6a11('0xc')]=_[_0x6a11('0xd')](config[_0x6a11('0xc')],{'host':_0x6a11('0xe'),'port':0x18eb});var socket=require(_0x6a11('0xf'))(new Redis(config['redis']));require(_0x6a11('0x10'))[_0x6a11('0x11')](socket);function respondWithRpcPromise(_0x38bba9,_0x50192d,_0x471fb5){return new BPromise(function(_0x5691b1,_0x495f56){return client[_0x6a11('0x12')](_0x38bba9,_0x471fb5)[_0x6a11('0x13')](function(_0x50d2ab){logger[_0x6a11('0x14')](_0x6a11('0x15'),_0x50192d,_0x6a11('0x16'));logger[_0x6a11('0x17')](_0x6a11('0x18'),_0x50192d,_0x6a11('0x16'),JSON[_0x6a11('0x19')](_0x50d2ab));if(_0x50d2ab[_0x6a11('0x1a')]){if(_0x50d2ab[_0x6a11('0x1a')][_0x6a11('0x1b')]===0x1f4){logger[_0x6a11('0x1a')]('DashboardItem,\x20%s,\x20%s',_0x50192d,_0x50d2ab['error']['message']);return _0x495f56(_0x50d2ab['error'][_0x6a11('0x1c')]);}logger[_0x6a11('0x1a')]('DashboardItem,\x20%s,\x20%s',_0x50192d,_0x50d2ab[_0x6a11('0x1a')]['message']);return _0x5691b1(_0x50d2ab[_0x6a11('0x1a')][_0x6a11('0x1c')]);}else{logger['info']('DashboardItem,\x20%s,\x20%s',_0x50192d,'request\x20sent');_0x5691b1(_0x50d2ab[_0x6a11('0x1d')][_0x6a11('0x1c')]);}})['catch'](function(_0x40c1e7){logger[_0x6a11('0x1a')](_0x6a11('0x15'),_0x50192d,_0x40c1e7);_0x495f56(_0x40c1e7);});});} \ No newline at end of file diff --git a/server/api/dashboardItem/dashboardItem.socket.js b/server/api/dashboardItem/dashboardItem.socket.js new file mode 100644 index 0000000..a47cdcb --- /dev/null +++ b/server/api/dashboardItem/dashboardItem.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2984=['register','length','./dashboardItem.events','remove','update','emit','removeListener'];(function(_0x3c5945,_0x3ff23b){var _0x571d02=function(_0x5972ec){while(--_0x5972ec){_0x3c5945['push'](_0x3c5945['shift']());}};_0x571d02(++_0x3ff23b);}(_0x2984,0x198));var _0x4298=function(_0xf285c1,_0x420382){_0xf285c1=_0xf285c1-0x0;var _0x1598a0=_0x2984[_0xf285c1];return _0x1598a0;};'use strict';var DashboardItemEvents=require(_0x4298('0x0'));var events=['save',_0x4298('0x1'),_0x4298('0x2')];function createListener(_0x3892e7,_0x574652){return function(_0x6f9a07){_0x574652[_0x4298('0x3')](_0x3892e7,_0x6f9a07);};}function removeListener(_0x4dca7d,_0x1ae389){return function(){DashboardItemEvents[_0x4298('0x4')](_0x4dca7d,_0x1ae389);};}exports[_0x4298('0x5')]=function(_0xef3ef4){for(var _0x3d7364=0x0,_0x1ea092=events[_0x4298('0x6')];_0x3d7364<_0x1ea092;_0x3d7364++){var _0x4f7e3d=events[_0x3d7364];var _0x326c52=createListener('dashboardItem:'+_0x4f7e3d,_0xef3ef4);DashboardItemEvents['on'](_0x4f7e3d,_0x326c52);}}; \ No newline at end of file diff --git a/server/api/dashboardItem/index.js b/server/api/dashboardItem/index.js new file mode 100644 index 0000000..a2ab5f8 --- /dev/null +++ b/server/api/dashboardItem/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe58a=['isAuthenticated','create','put','update','exports','multer','util','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','/:id','show'];(function(_0x9ee10f,_0xafc95c){var _0x507077=function(_0x227d80){while(--_0x227d80){_0x9ee10f['push'](_0x9ee10f['shift']());}};_0x507077(++_0xafc95c);}(_0xe58a,0x85));var _0xae58=function(_0x542f22,_0x10db96){_0x542f22=_0x542f22-0x0;var _0x52a182=_0xe58a[_0x542f22];return _0x52a182;};'use strict';var multer=require(_0xae58('0x0'));var util=require(_0xae58('0x1'));var path=require('path');var timeout=require(_0xae58('0x2'));var express=require(_0xae58('0x3'));var router=express[_0xae58('0x4')]();var fs_extra=require(_0xae58('0x5'));var auth=require(_0xae58('0x6'));var interaction=require(_0xae58('0x7'));var config=require(_0xae58('0x8'));var controller=require('./dashboardItem.controller');router['get'](_0xae58('0x9'),auth['isAuthenticated'](),controller[_0xae58('0xa')]);router['post']('/',auth[_0xae58('0xb')](),controller[_0xae58('0xc')]);router[_0xae58('0xd')](_0xae58('0x9'),auth['isAuthenticated'](),controller[_0xae58('0xe')]);router['delete'](_0xae58('0x9'),auth[_0xae58('0xb')](),controller['destroy']);module[_0xae58('0xf')]=router; \ No newline at end of file diff --git a/server/api/disposition/disposition.attributes.js b/server/api/disposition/disposition.attributes.js new file mode 100644 index 0000000..e5662fd --- /dev/null +++ b/server/api/disposition/disposition.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6d4f=['first','second','third','sequelize','exports','STRING','ENUM'];(function(_0x26d636,_0x2f9033){var _0x5c2902=function(_0x23c7c3){while(--_0x23c7c3){_0x26d636['push'](_0x26d636['shift']());}};_0x5c2902(++_0x2f9033);}(_0x6d4f,0x15a));var _0xf6d4=function(_0x543bf6,_0x763bd7){_0x543bf6=_0x543bf6-0x0;var _0x4187b3=_0x6d4f[_0x543bf6];return _0x4187b3;};'use strict';var Sequelize=require(_0xf6d4('0x0'));module[_0xf6d4('0x1')]={'name':{'type':Sequelize[_0xf6d4('0x2')],'allowNull':![]},'level':{'type':Sequelize[_0xf6d4('0x3')](_0xf6d4('0x4'),_0xf6d4('0x5'),_0xf6d4('0x6')),'allowNull':![],'defaultValue':_0xf6d4('0x4')},'description':{'type':Sequelize[_0xf6d4('0x2')]}}; \ No newline at end of file diff --git a/server/api/disposition/disposition.controller.js b/server/api/disposition/disposition.controller.js new file mode 100644 index 0000000..b6c691c --- /dev/null +++ b/server/api/disposition/disposition.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5941=['name','send','index','map','Disposition','rawAttributes','type','query','keys','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','findAll','show','includeAll','options','catch','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','Dispositions','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','reject','save','update','then','destroy','get','stack'];(function(_0xbc6b83,_0x35652f){var _0x5ef384=function(_0x407f02){while(--_0x407f02){_0xbc6b83['push'](_0xbc6b83['shift']());}};_0x5ef384(++_0x35652f);}(_0x5941,0x74));var _0x1594=function(_0x590f0c,_0x366f61){_0x590f0c=_0x590f0c-0x0;var _0x5dc4b6=_0x5941[_0x590f0c];return _0x5dc4b6;};'use strict';var emlformat=require(_0x1594('0x0'));var rimraf=require(_0x1594('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x1594('0x2'));var rp=require(_0x1594('0x3'));var moment=require(_0x1594('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x1594('0x5'));var util=require(_0x1594('0x6'));var path=require('path');var sox=require(_0x1594('0x7'));var csv=require(_0x1594('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1594('0x9'));var _=require(_0x1594('0xa'));var squel=require('squel');var crypto=require(_0x1594('0xb'));var jsforce=require(_0x1594('0xc'));var deskjs=require(_0x1594('0xd'));var toCsv=require(_0x1594('0x8'));var querystring=require(_0x1594('0xe'));var Papa=require('papaparse');var Redis=require(_0x1594('0xf'));var authService=require(_0x1594('0x10'));var qs=require(_0x1594('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1594('0x12'));var logger=require(_0x1594('0x13'))('api');var utils=require(_0x1594('0x14'));var config=require(_0x1594('0x15'));var licenseUtil=require(_0x1594('0x16'));var db=require(_0x1594('0x17'))['db'];function respondWithStatusCode(_0x5d7084,_0x40c68f){_0x40c68f=_0x40c68f||0xcc;return function(_0x12de5a){if(_0x12de5a){return _0x5d7084[_0x1594('0x18')](_0x40c68f);}return _0x5d7084['status'](_0x40c68f)[_0x1594('0x19')]();};}function respondWithResult(_0x16953e,_0x13bdee){_0x13bdee=_0x13bdee||0xc8;return function(_0x2e0c58){if(_0x2e0c58){return _0x16953e[_0x1594('0x1a')](_0x13bdee)[_0x1594('0x1b')](_0x2e0c58);}};}function respondWithFilteredResult(_0x1ba0eb,_0x28ee51){return function(_0x5c9587){if(_0x5c9587){var _0x33063e=typeof _0x28ee51[_0x1594('0x1c')]===_0x1594('0x1d')&&typeof _0x28ee51['limit']==='undefined';var _0x328d69=_0x5c9587[_0x1594('0x1e')];var _0x2926bb=_0x33063e?0x0:_0x28ee51[_0x1594('0x1c')];var _0xe1bb78=_0x33063e?_0x5c9587[_0x1594('0x1e')]:_0x28ee51[_0x1594('0x1c')]+_0x28ee51[_0x1594('0x1f')];var _0x3a6cda;if(_0xe1bb78>=_0x328d69){_0xe1bb78=_0x328d69;_0x3a6cda=0xc8;}else{_0x3a6cda=0xce;}_0x1ba0eb[_0x1594('0x1a')](_0x3a6cda);return _0x1ba0eb[_0x1594('0x20')]('Content-Range',_0x2926bb+'-'+_0xe1bb78+'/'+_0x328d69)[_0x1594('0x1b')](_0x5c9587);}return null;};}function patchUpdates(_0x5a5508){return function(_0x179b8e){try{jsonpatch['apply'](_0x179b8e,_0x5a5508,!![]);}catch(_0x22354e){return BPromise[_0x1594('0x21')](_0x22354e);}return _0x179b8e[_0x1594('0x22')]();};}function saveUpdates(_0x1f3531,_0x5ae541){return function(_0x5b46da){if(_0x5b46da){return _0x5b46da[_0x1594('0x23')](_0x1f3531)[_0x1594('0x24')](function(_0x84fec7){return _0x84fec7;});}return null;};}function removeEntity(_0x412a20,_0x4e6a19){return function(_0x5ec175){if(_0x5ec175){return _0x5ec175[_0x1594('0x25')]()[_0x1594('0x24')](function(){var _0x2fc26e=_0x5ec175[_0x1594('0x26')]({'plain':!![]});var _0x2bf790='Dispositions';return db['UserProfileResource'][_0x1594('0x25')]({'where':{'type':_0x2bf790,'resourceId':_0x2fc26e['id']}})[_0x1594('0x24')](function(){return _0x5ec175;});})[_0x1594('0x24')](function(){_0x412a20[_0x1594('0x1a')](0xcc)[_0x1594('0x19')]();});}};}function handleEntityNotFound(_0x11a7a9,_0x557a78){return function(_0x246fe7){if(!_0x246fe7){_0x11a7a9['sendStatus'](0x194);}return _0x246fe7;};}function handleError(_0x4939a6,_0x57197b){_0x57197b=_0x57197b||0x1f4;return function(_0x12b70e){logger['error'](_0x12b70e[_0x1594('0x27')]);if(_0x12b70e[_0x1594('0x28')]){delete _0x12b70e[_0x1594('0x28')];}_0x4939a6[_0x1594('0x1a')](_0x57197b)[_0x1594('0x29')](_0x12b70e);};}exports[_0x1594('0x2a')]=function(_0x43bcc9,_0x4b9f75){var _0x578335={},_0x93dcf3={},_0x530e42={'count':0x0,'rows':[]};var _0x30a7d=_[_0x1594('0x2b')](db[_0x1594('0x2c')][_0x1594('0x2d')],function(_0x18732e){return{'name':_0x18732e['fieldName'],'type':_0x18732e[_0x1594('0x2e')]['key']};});_0x93dcf3['model']=_[_0x1594('0x2b')](_0x30a7d,_0x1594('0x28'));_0x93dcf3[_0x1594('0x2f')]=_[_0x1594('0x30')](_0x43bcc9[_0x1594('0x2f')]);_0x93dcf3['filters']=_['intersection'](_0x93dcf3[_0x1594('0x31')],_0x93dcf3[_0x1594('0x2f')]);_0x578335[_0x1594('0x32')]=_['intersection'](_0x93dcf3['model'],qs[_0x1594('0x33')](_0x43bcc9[_0x1594('0x2f')]['fields']));_0x578335['attributes']=_0x578335[_0x1594('0x32')][_0x1594('0x34')]?_0x578335['attributes']:_0x93dcf3[_0x1594('0x31')];if(!_0x43bcc9['query'][_0x1594('0x35')](_0x1594('0x36'))){_0x578335[_0x1594('0x1f')]=qs[_0x1594('0x1f')](_0x43bcc9[_0x1594('0x2f')][_0x1594('0x1f')]);_0x578335[_0x1594('0x1c')]=qs[_0x1594('0x1c')](_0x43bcc9[_0x1594('0x2f')][_0x1594('0x1c')]);}_0x578335[_0x1594('0x37')]=qs[_0x1594('0x38')](_0x43bcc9[_0x1594('0x2f')][_0x1594('0x38')]);_0x578335[_0x1594('0x39')]=qs['filters'](_[_0x1594('0x3a')](_0x43bcc9['query'],_0x93dcf3[_0x1594('0x3b')]),_0x30a7d);if(_0x43bcc9[_0x1594('0x2f')][_0x1594('0x3c')]){_0x578335['where']=_[_0x1594('0x3d')](_0x578335[_0x1594('0x39')],{'$or':_[_0x1594('0x2b')](_0x30a7d,function(_0x498950){if(_0x498950['type']!==_0x1594('0x3e')){var _0x39df6b={};_0x39df6b[_0x498950[_0x1594('0x28')]]={'$like':'%'+_0x43bcc9['query'][_0x1594('0x3c')]+'%'};return _0x39df6b;}})});}_0x578335=_[_0x1594('0x3d')]({},_0x578335,_0x43bcc9['options']);var _0x1124aa={'where':_0x578335[_0x1594('0x39')]};return db[_0x1594('0x2c')][_0x1594('0x1e')](_0x1124aa)[_0x1594('0x24')](function(_0x591eab){_0x530e42[_0x1594('0x1e')]=_0x591eab;if(_0x43bcc9[_0x1594('0x2f')]['includeAll']){_0x578335['include']=[{'all':!![]}];}return db[_0x1594('0x2c')][_0x1594('0x3f')](_0x578335);})[_0x1594('0x24')](function(_0x5d6abc){_0x530e42['rows']=_0x5d6abc;return _0x530e42;})[_0x1594('0x24')](respondWithFilteredResult(_0x4b9f75,_0x578335))['catch'](handleError(_0x4b9f75,null));};exports[_0x1594('0x40')]=function(_0x14637e,_0x1ef110){var _0x2011c2={'raw':!![],'where':{'id':_0x14637e['params']['id']}},_0x811ade={};_0x811ade['model']=_['keys'](db[_0x1594('0x2c')][_0x1594('0x2d')]);_0x811ade[_0x1594('0x2f')]=_[_0x1594('0x30')](_0x14637e[_0x1594('0x2f')]);_0x811ade[_0x1594('0x3b')]=_['intersection'](_0x811ade[_0x1594('0x31')],_0x811ade['query']);_0x2011c2['attributes']=_['intersection'](_0x811ade[_0x1594('0x31')],qs[_0x1594('0x33')](_0x14637e[_0x1594('0x2f')][_0x1594('0x33')]));_0x2011c2['attributes']=_0x2011c2[_0x1594('0x32')][_0x1594('0x34')]?_0x2011c2['attributes']:_0x811ade[_0x1594('0x31')];if(_0x14637e[_0x1594('0x2f')][_0x1594('0x41')]){_0x2011c2['include']=[{'all':!![]}];}_0x2011c2=_[_0x1594('0x3d')]({},_0x2011c2,_0x14637e[_0x1594('0x42')]);return db[_0x1594('0x2c')]['find'](_0x2011c2)[_0x1594('0x24')](handleEntityNotFound(_0x1ef110,null))[_0x1594('0x24')](respondWithResult(_0x1ef110,null))[_0x1594('0x43')](handleError(_0x1ef110,null));};exports[_0x1594('0x44')]=function(_0x44a5a8,_0x41af24){return db['Disposition'][_0x1594('0x44')](_0x44a5a8[_0x1594('0x45')],{})[_0x1594('0x24')](function(_0x406bbc){var _0x194a3c=_0x44a5a8['user'][_0x1594('0x26')]({'plain':!![]});if(!_0x194a3c)throw new Error(_0x1594('0x46'));if(_0x194a3c['role']===_0x1594('0x47')){var _0x32dd13=_0x406bbc[_0x1594('0x26')]({'plain':!![]});var _0x122f86=_0x1594('0x48');return db[_0x1594('0x49')][_0x1594('0x4a')]({'where':{'name':_0x122f86,'userProfileId':_0x194a3c['userProfileId']},'raw':!![]})[_0x1594('0x24')](function(_0x499b4d){if(_0x499b4d&&_0x499b4d[_0x1594('0x4b')]===0x0){return db['UserProfileResource']['create']({'name':_0x32dd13[_0x1594('0x28')],'resourceId':_0x32dd13['id'],'type':_0x499b4d[_0x1594('0x28')],'sectionId':_0x499b4d['id']},{})[_0x1594('0x24')](function(){return _0x406bbc;});}else{return _0x406bbc;}})[_0x1594('0x43')](function(_0x1b4418){logger['error'](_0x1594('0x4c'),_0x1b4418);throw _0x1b4418;});}return _0x406bbc;})[_0x1594('0x24')](respondWithResult(_0x41af24,0xc9))[_0x1594('0x43')](handleError(_0x41af24,null));};exports[_0x1594('0x23')]=function(_0x2e035d,_0x2fc36d){if(_0x2e035d[_0x1594('0x45')]['id']){delete _0x2e035d[_0x1594('0x45')]['id'];}return db[_0x1594('0x2c')][_0x1594('0x4a')]({'where':{'id':_0x2e035d[_0x1594('0x4d')]['id']}})[_0x1594('0x24')](handleEntityNotFound(_0x2fc36d,null))[_0x1594('0x24')](saveUpdates(_0x2e035d[_0x1594('0x45')],null))[_0x1594('0x24')](respondWithResult(_0x2fc36d,null))['catch'](handleError(_0x2fc36d,null));};exports[_0x1594('0x25')]=function(_0x46aa15,_0x54b23b){return db[_0x1594('0x2c')]['find']({'where':{'id':_0x46aa15[_0x1594('0x4d')]['id']}})[_0x1594('0x24')](handleEntityNotFound(_0x54b23b,null))[_0x1594('0x24')](removeEntity(_0x54b23b,null))[_0x1594('0x43')](handleError(_0x54b23b,null));}; \ No newline at end of file diff --git a/server/api/disposition/disposition.model.js b/server/api/disposition/disposition.model.js new file mode 100644 index 0000000..4a7f02f --- /dev/null +++ b/server/api/disposition/disposition.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8537=['moment','bluebird','request-promise','path','rimraf','../../config/environment','exports','define','Disposition','name','ListId','name_chat','ChatWebsiteId','name_mail','MailAccountId','name_sms','name_fax','name_openchannel','OpenchannelAccountId','WhatsappAccountId','lodash','../../config/logger','api'];(function(_0x46db90,_0x267ff5){var _0x153352=function(_0x1e9feb){while(--_0x1e9feb){_0x46db90['push'](_0x46db90['shift']());}};_0x153352(++_0x267ff5);}(_0x8537,0xe3));var _0x7853=function(_0x3eff71,_0x37fc3b){_0x3eff71=_0x3eff71-0x0;var _0xe29c5d=_0x8537[_0x3eff71];return _0xe29c5d;};'use strict';var _=require(_0x7853('0x0'));var util=require('util');var logger=require(_0x7853('0x1'))(_0x7853('0x2'));var moment=require(_0x7853('0x3'));var BPromise=require(_0x7853('0x4'));var rp=require(_0x7853('0x5'));var fs=require('fs');var path=require(_0x7853('0x6'));var rimraf=require(_0x7853('0x7'));var config=require(_0x7853('0x8'));var attributes=require('./disposition.attributes');module[_0x7853('0x9')]=function(_0x45f681,_0x59d52d){return _0x45f681[_0x7853('0xa')](_0x7853('0xb'),attributes,{'tableName':'tools_dispositions','paranoid':![],'indexes':[{'unique':!![],'name':'name_voice','fields':[_0x7853('0xc'),_0x7853('0xd')]},{'unique':!![],'name':_0x7853('0xe'),'fields':[_0x7853('0xc'),_0x7853('0xf')]},{'unique':!![],'name':_0x7853('0x10'),'fields':['name',_0x7853('0x11')]},{'unique':!![],'name':_0x7853('0x12'),'fields':[_0x7853('0xc'),'SmsAccountId']},{'unique':!![],'name':_0x7853('0x13'),'fields':[_0x7853('0xc'),'FaxAccountId']},{'unique':!![],'name':_0x7853('0x14'),'fields':[_0x7853('0xc'),_0x7853('0x15')]},{'unique':!![],'name':'name_whatsapp','fields':[_0x7853('0xc'),_0x7853('0x16')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/disposition/disposition.rpc.js b/server/api/disposition/disposition.rpc.js new file mode 100644 index 0000000..2e6ada1 --- /dev/null +++ b/server/api/disposition/disposition.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['http','info','Disposition,\x20%s,\x20%s','request\x20sent','debug','Disposition,\x20%s,\x20%s,\x20%s','code','error','message','result','catch','lodash','util','moment','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x4dd6c8,_0x551d14){var _0x5ce168=function(_0x5614f1){while(--_0x5614f1){_0x4dd6c8['push'](_0x4dd6c8['shift']());}};_0x5ce168(++_0x551d14);}(_0xa9e0,0x123));var _0x0a9e=function(_0x373dee,_0x1a8c45){_0x373dee=_0x373dee-0x0;var _0x46798f=_0xa9e0[_0x373dee];return _0x46798f;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a9e('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x0a9e('0x4'));var logger=require(_0x0a9e('0x5'))(_0x0a9e('0x6'));var config=require(_0x0a9e('0x7'));var jayson=require(_0x0a9e('0x8'));var client=jayson['client'][_0x0a9e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x441e3a,_0x2cc193,_0x5f41ea){return new BPromise(function(_0x503809,_0xe42b77){return client['request'](_0x441e3a,_0x5f41ea)['then'](function(_0x39753a){logger[_0x0a9e('0xa')](_0x0a9e('0xb'),_0x2cc193,_0x0a9e('0xc'));logger[_0x0a9e('0xd')](_0x0a9e('0xe'),_0x2cc193,'request\x20sent',JSON['stringify'](_0x39753a));if(_0x39753a['error']){if(_0x39753a['error'][_0x0a9e('0xf')]===0x1f4){logger[_0x0a9e('0x10')](_0x0a9e('0xb'),_0x2cc193,_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);return _0xe42b77(_0x39753a[_0x0a9e('0x10')]['message']);}logger[_0x0a9e('0x10')](_0x0a9e('0xb'),_0x2cc193,_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);return _0x503809(_0x39753a[_0x0a9e('0x10')][_0x0a9e('0x11')]);}else{logger['info'](_0x0a9e('0xb'),_0x2cc193,'request\x20sent');_0x503809(_0x39753a[_0x0a9e('0x12')]['message']);}})[_0x0a9e('0x13')](function(_0x12066b){logger['error'](_0x0a9e('0xb'),_0x2cc193,_0x12066b);_0xe42b77(_0x12066b);});});} \ No newline at end of file diff --git a/server/api/disposition/index.js b/server/api/disposition/index.js new file mode 100644 index 0000000..cf76f1a --- /dev/null +++ b/server/api/disposition/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3788=['connect-timeout','fs-extra','../../components/interaction/service','../../config/environment','./disposition.controller','get','index','/:id','isAuthenticated','show','post','create','update','exports','multer','util','path'];(function(_0x570504,_0x13b26a){var _0x48b63e=function(_0x129c8a){while(--_0x129c8a){_0x570504['push'](_0x570504['shift']());}};_0x48b63e(++_0x13b26a);}(_0x3788,0x1a6));var _0x8378=function(_0x37d567,_0xe34ef6){_0x37d567=_0x37d567-0x0;var _0x5d2a27=_0x3788[_0x37d567];return _0x5d2a27;};'use strict';var multer=require(_0x8378('0x0'));var util=require(_0x8378('0x1'));var path=require(_0x8378('0x2'));var timeout=require(_0x8378('0x3'));var express=require('express');var router=express['Router']();var fs_extra=require(_0x8378('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x8378('0x5'));var config=require(_0x8378('0x6'));var controller=require(_0x8378('0x7'));router[_0x8378('0x8')]('/',auth['isAuthenticated'](),controller[_0x8378('0x9')]);router[_0x8378('0x8')](_0x8378('0xa'),auth[_0x8378('0xb')](),controller[_0x8378('0xc')]);router[_0x8378('0xd')]('/',auth['isAuthenticated'](),controller[_0x8378('0xe')]);router['put'](_0x8378('0xa'),auth[_0x8378('0xb')](),controller[_0x8378('0xf')]);router['delete'](_0x8378('0xa'),auth[_0x8378('0xb')](),controller['destroy']);module[_0x8378('0x10')]=router; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.attributes.js b/server/api/faxAccount/faxAccount.attributes.js new file mode 100644 index 0000000..a1863a0 --- /dev/null +++ b/server/api/faxAccount/faxAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8f64=['Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled','Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','mandatoryDispositionPauseId','setDataValue','mandatoryDisposition','sequelize','exports','STRING','ENUM','yes','2400','4800','9600','12000','14400','7200','v17,v27,v29','INTEGER','SIP','BOOLEAN'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x8f64,0x69));var _0x48f6=function(_0x3bba27,_0x4416d7){_0x3bba27=_0x3bba27-0x0;var _0x20888c=_0x8f64[_0x3bba27];return _0x20888c;};'use strict';var Sequelize=require(_0x48f6('0x0'));module[_0x48f6('0x1')]={'name':{'type':Sequelize[_0x48f6('0x2')],'allowNull':![],'validate':{'notEmpty':!![]}},'description':{'type':Sequelize[_0x48f6('0x2')]},'ecm':{'type':Sequelize[_0x48f6('0x3')](_0x48f6('0x4'),'no'),'defaultValue':_0x48f6('0x4')},'headerinfo':{'type':Sequelize[_0x48f6('0x2')],'defaultValue':'xCALLY\x20Motion\x20Fax'},'localstationid':{'type':Sequelize[_0x48f6('0x2')],'unique':'localstationid'},'minrate':{'type':Sequelize[_0x48f6('0x3')](_0x48f6('0x5'),_0x48f6('0x6'),'7200',_0x48f6('0x7'),_0x48f6('0x8'),_0x48f6('0x9')),'defaultValue':'4800'},'maxrate':{'type':Sequelize['ENUM']('2400','4800',_0x48f6('0xa'),_0x48f6('0x7'),_0x48f6('0x8'),_0x48f6('0x9')),'defaultValue':'14400'},'modem':{'type':Sequelize[_0x48f6('0x2')],'defaultValue':_0x48f6('0xb')},'gateway':{'type':Sequelize[_0x48f6('0x2')],'defaultValue':'no','validate':{'is':/^(?:yes|no|[0-9]+)$/}},'faxdetect':{'type':Sequelize['STRING'],'defaultValue':'no','validate':{'is':/^(?:yes|no|t38|cng|[0-9]+)$/}},'t38timeout':{'type':Sequelize[_0x48f6('0xc')],'defaultValue':0x1388,'validate':{'min':0x3e8}},'tech':{'type':Sequelize[_0x48f6('0x3')](_0x48f6('0xd'),'IAX','DADHI','KHOMP'),'defaultValue':_0x48f6('0xd')},'key':{'type':Sequelize[_0x48f6('0x2')],'allowNull':![]},'notificationTemplate':{'type':Sequelize['TEXT'],'defaultValue':function(){return'Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}';}},'notificationSound':{'type':Sequelize[_0x48f6('0xe')],'defaultValue':!![]},'notificationShake':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'waitForTheAssignedAgent':{'type':Sequelize[_0x48f6('0xc')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'queueTransfer':{'type':Sequelize[_0x48f6('0xe')],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize['INTEGER'],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0x48f6('0xc')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'mandatoryDispositionPauseId':{'type':Sequelize['INTEGER'],'allowNull':!![],'defaultValue':null,'comment':_0x48f6('0xf')},'mandatoryDisposition':{'type':Sequelize['BOOLEAN'],'defaultValue':![],'comment':_0x48f6('0x10'),'set':function(_0x56cd78){if(!_0x56cd78)this['setDataValue'](_0x48f6('0x11'),null);this[_0x48f6('0x12')](_0x48f6('0x13'),_0x56cd78);}}}; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.controller.js b/server/api/faxAccount/faxAccount.controller.js new file mode 100644 index 0000000..36cde27 --- /dev/null +++ b/server/api/faxAccount/faxAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe695=['addAgents','omit','spread','removeAgents','isArray','emit','userFaxAccount:remove','getAgents','User','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','register','http','client','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','reject','update','destroy','FaxAccounts','UserProfileResource','stack','name','index','mandatoryDispositionPause','map','FaxAccount','rawAttributes','fieldName','key','keys','query','filters','model','intersection','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','include','rows','show','params','Pause','attributes','includeAll','options','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','FaxAccountId','Disposition','getDispositions','findOne','findAll','removeDispositions','addAnswer','CannedAnswer','removeAnswers','ids','FaxInteraction','addInteraction','getInteractions','CmContact','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','transaction','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','FaxApplication','findAndCountAll','priority','finally','send','getApplications','context','from-voip-provider','exten','localstationid','app','type','system','Fax\x20Extension','appdata','push','Answer','CDR(type)=inbound-fax','Set','ecm','gateway','faxdetect','headerinfo','maxrate','minrate','modem','t38timeout','Wait','ReceiveFax','addAccountApplications','updateAccountApplications','VoiceExtension','bulkCreate','tech','updatedAt','TrunkId','ListId','findById','FaxMessage','$gte','split','YYYY-MM-DD\x20HH:mm:ss','CmList','List','Contacts','DESC','attachments','server/files/attachments','CheckAfterSend','isNil','from','format','\x22%s\x22\x20<%s>','fax','Send\x20Fax\x20failed','out','filename','Messages','Contact\x20not\x20found','ContactId','dataValues','SendFax','SendFaxRpc,\x20%s'];(function(_0x265517,_0x4e3929){var _0xd024de=function(_0x801724){while(--_0x801724){_0x265517['push'](_0x265517['shift']());}};_0xd024de(++_0x4e3929);}(_0xe695,0xd0));var _0x5e69=function(_0x14f553,_0x2a4c41){_0x14f553=_0x14f553-0x0;var _0x22165f=_0xe695[_0x14f553];return _0x22165f;};'use strict';var emlformat=require(_0x5e69('0x0'));var rimraf=require(_0x5e69('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5e69('0x2'));var rp=require('request-promise');var moment=require(_0x5e69('0x3'));var BPromise=require(_0x5e69('0x4'));var Mustache=require(_0x5e69('0x5'));var util=require(_0x5e69('0x6'));var path=require(_0x5e69('0x7'));var sox=require(_0x5e69('0x8'));var csv=require(_0x5e69('0x9'));var ejs=require(_0x5e69('0xa'));var fs=require('fs');var fs_extra=require(_0x5e69('0xb'));var _=require(_0x5e69('0xc'));var squel=require(_0x5e69('0xd'));var crypto=require('crypto');var jsforce=require(_0x5e69('0xe'));var deskjs=require(_0x5e69('0xf'));var toCsv=require(_0x5e69('0x9'));var querystring=require(_0x5e69('0x10'));var Papa=require('papaparse');var Redis=require(_0x5e69('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x5e69('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x5e69('0x13'));var config=require(_0x5e69('0x14'));var licenseUtil=require(_0x5e69('0x15'));var db=require(_0x5e69('0x16'))['db'];config[_0x5e69('0x17')]=_[_0x5e69('0x18')](config[_0x5e69('0x17')],{'host':_0x5e69('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5e69('0x17')]));require('./faxAccount.socket')[_0x5e69('0x1a')](socket);var jayson=require('jayson/promise');var client=jayson['client'][_0x5e69('0x1b')]({'port':0x232c});var client9002=jayson[_0x5e69('0x1c')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2e5c68,_0x207609,_0x25e0dc,_0x54697f){return new BPromise(function(_0x5eba48,_0x22e43f){var _0x1b25ce=_0x54697f||client;return _0x1b25ce[_0x5e69('0x1d')](_0x2e5c68,_0x25e0dc)[_0x5e69('0x1e')](function(_0x38b01a){logger[_0x5e69('0x1f')](_0x5e69('0x20'),_0x207609,_0x5e69('0x21'));logger[_0x5e69('0x22')](_0x5e69('0x23'),_0x207609,_0x5e69('0x21'),JSON[_0x5e69('0x24')](_0x38b01a));if(_0x38b01a[_0x5e69('0x25')]){if(_0x38b01a[_0x5e69('0x25')]['code']===0x1f4){logger[_0x5e69('0x25')](_0x5e69('0x20'),_0x207609,_0x38b01a['error'][_0x5e69('0x26')]);return _0x22e43f(_0x38b01a['error']['message']);}logger[_0x5e69('0x25')](_0x5e69('0x20'),_0x207609,_0x38b01a[_0x5e69('0x25')][_0x5e69('0x26')]);return _0x5eba48(_0x38b01a['error']['message']);}else{logger[_0x5e69('0x1f')](_0x5e69('0x20'),_0x207609,_0x5e69('0x21'));_0x5eba48(_0x38b01a['result']['message']);}})[_0x5e69('0x27')](function(_0x4069ce){logger['error'](_0x5e69('0x20'),_0x207609,_0x4069ce);_0x22e43f(_0x4069ce);});});}function respondWithStatusCode(_0x1be0ed,_0x2a05b3){_0x2a05b3=_0x2a05b3||0xcc;return function(_0x1c1851){if(_0x1c1851){return _0x1be0ed[_0x5e69('0x28')](_0x2a05b3);}return _0x1be0ed[_0x5e69('0x29')](_0x2a05b3)[_0x5e69('0x2a')]();};}function respondWithResult(_0x297fb3,_0x42c4c8){_0x42c4c8=_0x42c4c8||0xc8;return function(_0x12b91a){if(_0x12b91a){return _0x297fb3['status'](_0x42c4c8)[_0x5e69('0x2b')](_0x12b91a);}};}function respondWithFilteredResult(_0x28cda0,_0x516c43){return function(_0x2328f4){if(_0x2328f4){var _0x2ec0b3=typeof _0x516c43['offset']===_0x5e69('0x2c')&&typeof _0x516c43[_0x5e69('0x2d')]===_0x5e69('0x2c');var _0x470928=_0x2328f4[_0x5e69('0x2e')];var _0x368ef2=_0x2ec0b3?0x0:_0x516c43[_0x5e69('0x2f')];var _0x3f506c=_0x2ec0b3?_0x2328f4[_0x5e69('0x2e')]:_0x516c43['offset']+_0x516c43[_0x5e69('0x2d')];var _0x19981a;if(_0x3f506c>=_0x470928){_0x3f506c=_0x470928;_0x19981a=0xc8;}else{_0x19981a=0xce;}_0x28cda0[_0x5e69('0x29')](_0x19981a);return _0x28cda0[_0x5e69('0x30')](_0x5e69('0x31'),_0x368ef2+'-'+_0x3f506c+'/'+_0x470928)['json'](_0x2328f4);}return null;};}function patchUpdates(_0x5cb7ef){return function(_0x41d8ea){try{jsonpatch['apply'](_0x41d8ea,_0x5cb7ef,!![]);}catch(_0x386a58){return BPromise[_0x5e69('0x32')](_0x386a58);}return _0x41d8ea['save']();};}function saveUpdates(_0x2a361d,_0x289026){return function(_0xfb400e){if(_0xfb400e){return _0xfb400e[_0x5e69('0x33')](_0x2a361d)[_0x5e69('0x1e')](function(_0x12c19d){return _0x12c19d;});}return null;};}function removeEntity(_0x6a01b3,_0x57c5aa){return function(_0x18cd15){if(_0x18cd15){return _0x18cd15[_0x5e69('0x34')]()['then'](function(){var _0x382b0=_0x18cd15['get']({'plain':!![]});var _0x27a310=_0x5e69('0x35');return db[_0x5e69('0x36')][_0x5e69('0x34')]({'where':{'type':_0x27a310,'resourceId':_0x382b0['id']}})['then'](function(){return _0x18cd15;});})['then'](function(){_0x6a01b3[_0x5e69('0x29')](0xcc)[_0x5e69('0x2a')]();});}};}function handleEntityNotFound(_0x5a9e6a,_0x284578){return function(_0x529383){if(!_0x529383){_0x5a9e6a[_0x5e69('0x28')](0x194);}return _0x529383;};}function handleError(_0x4743ac,_0x2d09f4){_0x2d09f4=_0x2d09f4||0x1f4;return function(_0x30964e){logger[_0x5e69('0x25')](_0x30964e[_0x5e69('0x37')]);if(_0x30964e[_0x5e69('0x38')]){delete _0x30964e[_0x5e69('0x38')];}_0x4743ac[_0x5e69('0x29')](_0x2d09f4)['send'](_0x30964e);};}exports[_0x5e69('0x39')]=function(_0x41b3f5,_0x4f99a8){var _0x51f6a7={'include':[{'model':db['Pause'],'as':_0x5e69('0x3a')}]},_0x5c0572={},_0x39b28e={'count':0x0,'rows':[]};var _0xcf145c=_[_0x5e69('0x3b')](db[_0x5e69('0x3c')][_0x5e69('0x3d')],function(_0x260695){return{'name':_0x260695[_0x5e69('0x3e')],'type':_0x260695['type'][_0x5e69('0x3f')]};});_0x5c0572['model']=_['map'](_0xcf145c,'name');_0x5c0572['query']=_[_0x5e69('0x40')](_0x41b3f5[_0x5e69('0x41')]);_0x5c0572[_0x5e69('0x42')]=_['intersection'](_0x5c0572[_0x5e69('0x43')],_0x5c0572['query']);_0x51f6a7['attributes']=_[_0x5e69('0x44')](_0x5c0572[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x41b3f5[_0x5e69('0x41')]['fields']));_0x51f6a7['attributes']=_0x51f6a7['attributes'][_0x5e69('0x46')]?_0x51f6a7['attributes']:_0x5c0572['model'];if(!_0x41b3f5[_0x5e69('0x41')][_0x5e69('0x47')](_0x5e69('0x48'))){_0x51f6a7[_0x5e69('0x2d')]=qs['limit'](_0x41b3f5[_0x5e69('0x41')][_0x5e69('0x2d')]);_0x51f6a7[_0x5e69('0x2f')]=qs[_0x5e69('0x2f')](_0x41b3f5[_0x5e69('0x41')][_0x5e69('0x2f')]);}_0x51f6a7[_0x5e69('0x49')]=qs[_0x5e69('0x4a')](_0x41b3f5['query'][_0x5e69('0x4a')]);_0x51f6a7['where']=qs['filters'](_[_0x5e69('0x4b')](_0x41b3f5[_0x5e69('0x41')],_0x5c0572[_0x5e69('0x42')]),_0xcf145c);if(_0x41b3f5[_0x5e69('0x41')][_0x5e69('0x4c')]){_0x51f6a7[_0x5e69('0x4d')]=_[_0x5e69('0x4e')](_0x51f6a7['where'],{'$or':_[_0x5e69('0x3b')](_0xcf145c,function(_0x2c68f4){if(_0x2c68f4['type']!==_0x5e69('0x4f')){var _0x352eaf={};_0x352eaf[_0x2c68f4[_0x5e69('0x38')]]={'$like':'%'+_0x41b3f5[_0x5e69('0x41')][_0x5e69('0x4c')]+'%'};return _0x352eaf;}})});}_0x51f6a7=_['merge']({},_0x51f6a7,_0x41b3f5['options']);var _0x299b5a={'where':_0x51f6a7['where']};return db[_0x5e69('0x3c')][_0x5e69('0x2e')](_0x299b5a)['then'](function(_0x294ae7){_0x39b28e[_0x5e69('0x2e')]=_0x294ae7;if(_0x41b3f5['query']['includeAll']){_0x51f6a7[_0x5e69('0x50')]=[{'all':!![]}];}return db[_0x5e69('0x3c')]['findAll'](_0x51f6a7);})['then'](function(_0x1c3d81){_0x39b28e[_0x5e69('0x51')]=_0x1c3d81;return _0x39b28e;})['then'](respondWithFilteredResult(_0x4f99a8,_0x51f6a7))['catch'](handleError(_0x4f99a8,null));};exports[_0x5e69('0x52')]=function(_0x4c33df,_0x4609c7){var _0x21831c={'raw':![],'where':{'id':_0x4c33df[_0x5e69('0x53')]['id']},'include':[{'model':db[_0x5e69('0x54')],'as':_0x5e69('0x3a')}]},_0x4f589a={};_0x4f589a['model']=_[_0x5e69('0x40')](db[_0x5e69('0x3c')][_0x5e69('0x3d')]);_0x4f589a['query']=_[_0x5e69('0x40')](_0x4c33df[_0x5e69('0x41')]);_0x4f589a[_0x5e69('0x42')]=_['intersection'](_0x4f589a[_0x5e69('0x43')],_0x4f589a[_0x5e69('0x41')]);_0x21831c[_0x5e69('0x55')]=_[_0x5e69('0x44')](_0x4f589a[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x4c33df[_0x5e69('0x41')][_0x5e69('0x45')]));_0x21831c[_0x5e69('0x55')]=_0x21831c[_0x5e69('0x55')][_0x5e69('0x46')]?_0x21831c['attributes']:_0x4f589a[_0x5e69('0x43')];if(_0x4c33df[_0x5e69('0x41')][_0x5e69('0x56')]){_0x21831c[_0x5e69('0x50')]=[{'all':!![]}];}_0x21831c=_[_0x5e69('0x4e')]({},_0x21831c,_0x4c33df[_0x5e69('0x57')]);return db[_0x5e69('0x3c')][_0x5e69('0x58')](_0x21831c)[_0x5e69('0x1e')](handleEntityNotFound(_0x4609c7,null))[_0x5e69('0x1e')](respondWithResult(_0x4609c7,null))['catch'](handleError(_0x4609c7,null));};exports[_0x5e69('0x59')]=function(_0x36f8cb,_0x6ad79e){return db[_0x5e69('0x3c')][_0x5e69('0x59')](_0x36f8cb[_0x5e69('0x5a')],{})[_0x5e69('0x1e')](function(_0x5b7bb3){var _0x150c8f=_0x36f8cb[_0x5e69('0x5b')][_0x5e69('0x5c')]({'plain':!![]});if(!_0x150c8f)throw new Error(_0x5e69('0x5d'));if(_0x150c8f[_0x5e69('0x5e')]==='user'){var _0x2d9eaa=_0x5b7bb3[_0x5e69('0x5c')]({'plain':!![]});var _0x37113c=_0x5e69('0x35');return db[_0x5e69('0x5f')][_0x5e69('0x58')]({'where':{'name':_0x37113c,'userProfileId':_0x150c8f[_0x5e69('0x60')]},'raw':!![]})[_0x5e69('0x1e')](function(_0x477742){if(_0x477742&&_0x477742[_0x5e69('0x61')]===0x0){return db[_0x5e69('0x36')][_0x5e69('0x59')]({'name':_0x2d9eaa[_0x5e69('0x38')],'resourceId':_0x2d9eaa['id'],'type':_0x477742[_0x5e69('0x38')],'sectionId':_0x477742['id']},{})[_0x5e69('0x1e')](function(){return _0x5b7bb3;});}else{return _0x5b7bb3;}})[_0x5e69('0x27')](function(_0x45281c){logger[_0x5e69('0x25')](_0x5e69('0x62'),_0x45281c);throw _0x45281c;});}return _0x5b7bb3;})[_0x5e69('0x1e')](respondWithResult(_0x6ad79e,0xc9))['catch'](handleError(_0x6ad79e,null));};exports[_0x5e69('0x33')]=function(_0x307ea7,_0xb3a4f3){if(_0x307ea7[_0x5e69('0x5a')]['id']){delete _0x307ea7[_0x5e69('0x5a')]['id'];}return db[_0x5e69('0x3c')][_0x5e69('0x58')]({'where':{'id':_0x307ea7[_0x5e69('0x53')]['id']},'include':[{'model':db[_0x5e69('0x54')],'as':_0x5e69('0x3a')}]})[_0x5e69('0x1e')](handleEntityNotFound(_0xb3a4f3,null))['then'](saveUpdates(_0x307ea7[_0x5e69('0x5a')],null))['then'](respondWithResult(_0xb3a4f3,null))[_0x5e69('0x27')](handleError(_0xb3a4f3,null));};exports[_0x5e69('0x34')]=function(_0xbe1b32,_0x55ac22){return db[_0x5e69('0x3c')][_0x5e69('0x58')]({'where':{'id':_0xbe1b32[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x55ac22,null))[_0x5e69('0x1e')](removeEntity(_0x55ac22,null))[_0x5e69('0x27')](handleError(_0x55ac22,null));};exports[_0x5e69('0x63')]=function(_0x331a3f,_0x12fd44){return db['FaxAccount'][_0x5e69('0x63')]()[_0x5e69('0x1e')](respondWithResult(_0x12fd44,null))[_0x5e69('0x27')](handleError(_0x12fd44,null));};exports['addDisposition']=function(_0x683aaa,_0x4919db,_0x3ec1e0){if(_0x683aaa['body']['id']){delete _0x683aaa[_0x5e69('0x5a')]['id'];}return db['FaxAccount'][_0x5e69('0x58')]({'where':{'id':_0x683aaa[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x4919db,null))[_0x5e69('0x1e')](function(_0xe1d7b4){if(_0xe1d7b4){_0x683aaa['body'][_0x5e69('0x64')]=_0xe1d7b4['id'];return db[_0x5e69('0x65')][_0x5e69('0x59')](_0x683aaa[_0x5e69('0x5a')]);}})[_0x5e69('0x1e')](respondWithResult(_0x4919db,null))[_0x5e69('0x27')](handleError(_0x4919db,null));};exports[_0x5e69('0x66')]=function(_0x55a97f,_0x2a91ba,_0x42e3d8){var _0x3a040a={'raw':![],'where':{}};var _0x350382={};var _0x124b9b={'count':0x0,'rows':[]};return db[_0x5e69('0x3c')][_0x5e69('0x67')]({'where':{'id':_0x55a97f['params']['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x2a91ba,null))[_0x5e69('0x1e')](function(_0x4475ff){if(_0x4475ff){_0x350382[_0x5e69('0x43')]=_[_0x5e69('0x40')](db[_0x5e69('0x65')][_0x5e69('0x3d')]);_0x350382[_0x5e69('0x41')]=_[_0x5e69('0x40')](_0x55a97f[_0x5e69('0x41')]);_0x350382[_0x5e69('0x42')]=_[_0x5e69('0x44')](_0x350382[_0x5e69('0x43')],_0x350382[_0x5e69('0x41')]);_0x3a040a[_0x5e69('0x55')]=_[_0x5e69('0x44')](_0x350382[_0x5e69('0x43')],qs['fields'](_0x55a97f['query']['fields']));_0x3a040a[_0x5e69('0x55')]=_0x3a040a['attributes'][_0x5e69('0x46')]?_0x3a040a[_0x5e69('0x55')]:_0x350382[_0x5e69('0x43')];if(!_0x55a97f['query'][_0x5e69('0x47')](_0x5e69('0x48'))){_0x3a040a[_0x5e69('0x2d')]=qs[_0x5e69('0x2d')](_0x55a97f['query'][_0x5e69('0x2d')]);_0x3a040a[_0x5e69('0x2f')]=qs['offset'](_0x55a97f['query'][_0x5e69('0x2f')]);}_0x3a040a['order']=qs[_0x5e69('0x4a')](_0x55a97f[_0x5e69('0x41')][_0x5e69('0x4a')]);_0x3a040a['where']=qs[_0x5e69('0x42')](_[_0x5e69('0x4b')](_0x55a97f[_0x5e69('0x41')],_0x350382['filters']));_0x3a040a[_0x5e69('0x4d')][_0x5e69('0x64')]=_0x4475ff['id'];if(_0x55a97f['query']['filter']){_0x3a040a[_0x5e69('0x4d')]=_['merge'](_0x3a040a['where'],{'$or':_['map'](_0x3a040a['attributes'],function(_0x3b6c47){var _0x414380={};_0x414380[_0x3b6c47]={'$like':'%'+_0x55a97f[_0x5e69('0x41')][_0x5e69('0x4c')]+'%'};return _0x414380;})});}_0x3a040a=_[_0x5e69('0x4e')]({},_0x3a040a,_0x55a97f[_0x5e69('0x57')]);return db[_0x5e69('0x65')][_0x5e69('0x2e')]({'where':_0x3a040a[_0x5e69('0x4d')]})[_0x5e69('0x1e')](function(_0x4ea1cb){_0x124b9b[_0x5e69('0x2e')]=_0x4ea1cb;if(_0x55a97f[_0x5e69('0x41')][_0x5e69('0x56')]){_0x3a040a['include']=[{'all':!![]}];}return db['Disposition'][_0x5e69('0x68')](_0x3a040a);})[_0x5e69('0x1e')](function(_0x3e5efb){_0x124b9b[_0x5e69('0x51')]=_0x3e5efb;return _0x124b9b;});}})['then'](respondWithFilteredResult(_0x2a91ba,_0x3a040a))[_0x5e69('0x27')](handleError(_0x2a91ba,null));};exports['removeDispositions']=function(_0x411841,_0x17dd1a,_0x52f7bb){return db[_0x5e69('0x3c')][_0x5e69('0x58')]({'where':{'id':_0x411841[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x17dd1a,null))[_0x5e69('0x1e')](function(_0x5bf625){if(_0x5bf625){return _0x5bf625[_0x5e69('0x69')](_0x411841[_0x5e69('0x41')]['ids']);}})['then'](respondWithStatusCode(_0x17dd1a,null))[_0x5e69('0x27')](handleError(_0x17dd1a,null));};exports[_0x5e69('0x6a')]=function(_0x195785,_0x5c1343,_0x24ca37){if(_0x195785[_0x5e69('0x5a')]['id']){delete _0x195785[_0x5e69('0x5a')]['id'];}return db[_0x5e69('0x3c')]['find']({'where':{'id':_0x195785[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x5c1343,null))[_0x5e69('0x1e')](function(_0x2df7e9){if(_0x2df7e9){_0x195785[_0x5e69('0x5a')]['FaxAccountId']=_0x2df7e9['id'];return db[_0x5e69('0x6b')][_0x5e69('0x59')](_0x195785[_0x5e69('0x5a')]);}})[_0x5e69('0x1e')](respondWithResult(_0x5c1343,null))[_0x5e69('0x27')](handleError(_0x5c1343,null));};exports['getAnswers']=function(_0x7e7a99,_0x2d7c9b,_0x1fe5ee){var _0x10ad1f={'raw':![],'where':{}};var _0xc09c={};var _0x2232f2={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x7e7a99[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x2d7c9b,null))[_0x5e69('0x1e')](function(_0xe4fe8){if(_0xe4fe8){_0xc09c['model']=_[_0x5e69('0x40')](db[_0x5e69('0x6b')][_0x5e69('0x3d')]);_0xc09c[_0x5e69('0x41')]=_[_0x5e69('0x40')](_0x7e7a99['query']);_0xc09c[_0x5e69('0x42')]=_[_0x5e69('0x44')](_0xc09c['model'],_0xc09c['query']);_0x10ad1f[_0x5e69('0x55')]=_[_0x5e69('0x44')](_0xc09c[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x7e7a99[_0x5e69('0x41')][_0x5e69('0x45')]));_0x10ad1f[_0x5e69('0x55')]=_0x10ad1f['attributes']['length']?_0x10ad1f[_0x5e69('0x55')]:_0xc09c[_0x5e69('0x43')];if(!_0x7e7a99['query'][_0x5e69('0x47')](_0x5e69('0x48'))){_0x10ad1f['limit']=qs[_0x5e69('0x2d')](_0x7e7a99[_0x5e69('0x41')]['limit']);_0x10ad1f[_0x5e69('0x2f')]=qs[_0x5e69('0x2f')](_0x7e7a99[_0x5e69('0x41')]['offset']);}_0x10ad1f[_0x5e69('0x49')]=qs['sort'](_0x7e7a99[_0x5e69('0x41')]['sort']);_0x10ad1f[_0x5e69('0x4d')]=qs[_0x5e69('0x42')](_[_0x5e69('0x4b')](_0x7e7a99[_0x5e69('0x41')],_0xc09c['filters']));_0x10ad1f[_0x5e69('0x4d')]['FaxAccountId']=_0xe4fe8['id'];if(_0x7e7a99['query'][_0x5e69('0x4c')]){_0x10ad1f[_0x5e69('0x4d')]=_['merge'](_0x10ad1f[_0x5e69('0x4d')],{'$or':_[_0x5e69('0x3b')](_0x10ad1f[_0x5e69('0x55')],function(_0x5b3aab){var _0x2db7c2={};_0x2db7c2[_0x5b3aab]={'$like':'%'+_0x7e7a99[_0x5e69('0x41')]['filter']+'%'};return _0x2db7c2;})});}_0x10ad1f=_['merge']({},_0x10ad1f,_0x7e7a99[_0x5e69('0x57')]);return db[_0x5e69('0x6b')][_0x5e69('0x2e')]({'where':_0x10ad1f[_0x5e69('0x4d')]})[_0x5e69('0x1e')](function(_0x121774){_0x2232f2[_0x5e69('0x2e')]=_0x121774;if(_0x7e7a99[_0x5e69('0x41')][_0x5e69('0x56')]){_0x10ad1f[_0x5e69('0x50')]=[{'all':!![]}];}return db['CannedAnswer'][_0x5e69('0x68')](_0x10ad1f);})[_0x5e69('0x1e')](function(_0x20c7c5){_0x2232f2[_0x5e69('0x51')]=_0x20c7c5;return _0x2232f2;});}})[_0x5e69('0x1e')](respondWithFilteredResult(_0x2d7c9b,_0x10ad1f))['catch'](handleError(_0x2d7c9b,null));};exports[_0x5e69('0x6c')]=function(_0xe32600,_0x11cd7e,_0x337ad0){return db['FaxAccount'][_0x5e69('0x58')]({'where':{'id':_0xe32600[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x11cd7e,null))[_0x5e69('0x1e')](function(_0x1980af){if(_0x1980af){return _0x1980af[_0x5e69('0x6c')](_0xe32600[_0x5e69('0x41')][_0x5e69('0x6d')]);}})[_0x5e69('0x1e')](respondWithStatusCode(_0x11cd7e,null))['catch'](handleError(_0x11cd7e,null));};exports['addInteraction']=function(_0x331bc3,_0x3db60e,_0x50992e){return db[_0x5e69('0x6e')][_0x5e69('0x58')]({'where':{'id':_0x331bc3['params']['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x3db60e,null))[_0x5e69('0x1e')](function(_0x52f7b7){if(_0x52f7b7){return _0x52f7b7[_0x5e69('0x6f')](_0x331bc3[_0x5e69('0x5a')][_0x5e69('0x6d')],_['omit'](_0x331bc3['body'],[_0x5e69('0x6d'),'id'])||{});}})[_0x5e69('0x1e')](respondWithResult(_0x3db60e,null))[_0x5e69('0x27')](handleError(_0x3db60e,null));};exports[_0x5e69('0x70')]=function(_0x13a43e,_0x1c465a,_0x17b393){var _0x46939a={'raw':![],'where':{}};var _0x1f5b3b={};var _0x78ee2f={'count':0x0,'rows':[]};return db[_0x5e69('0x3c')][_0x5e69('0x67')]({'where':{'id':_0x13a43e[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x1c465a,null))[_0x5e69('0x1e')](function(_0x3baf06){if(_0x3baf06){_0x1f5b3b['model']=_[_0x5e69('0x40')](db[_0x5e69('0x6e')]['rawAttributes']);_0x1f5b3b[_0x5e69('0x41')]=_['keys'](_0x13a43e[_0x5e69('0x41')]);_0x1f5b3b[_0x5e69('0x42')]=_[_0x5e69('0x44')](_0x1f5b3b[_0x5e69('0x43')],_0x1f5b3b['query']);_0x46939a['attributes']=_[_0x5e69('0x44')](_0x1f5b3b[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x13a43e['query'][_0x5e69('0x45')]));_0x46939a[_0x5e69('0x55')]=_0x46939a['attributes'][_0x5e69('0x46')]?_0x46939a['attributes']:_0x1f5b3b[_0x5e69('0x43')];if(!_0x13a43e[_0x5e69('0x41')]['hasOwnProperty'](_0x5e69('0x48'))){_0x46939a[_0x5e69('0x2d')]=qs['limit'](_0x13a43e[_0x5e69('0x41')][_0x5e69('0x2d')]);_0x46939a[_0x5e69('0x2f')]=qs[_0x5e69('0x2f')](_0x13a43e[_0x5e69('0x41')][_0x5e69('0x2f')]);}_0x46939a['order']=qs[_0x5e69('0x4a')](_0x13a43e[_0x5e69('0x41')][_0x5e69('0x4a')]);_0x46939a[_0x5e69('0x4d')]=qs[_0x5e69('0x42')](_[_0x5e69('0x4b')](_0x13a43e[_0x5e69('0x41')],_0x1f5b3b['filters']));_0x46939a[_0x5e69('0x4d')][_0x5e69('0x64')]=_0x3baf06['id'];if(_0x13a43e['query']['filter']){_0x46939a[_0x5e69('0x4d')]=_[_0x5e69('0x4e')](_0x46939a[_0x5e69('0x4d')],{'$or':_[_0x5e69('0x3b')](_0x46939a[_0x5e69('0x55')],function(_0x4ee006){var _0xe4dce9={};_0xe4dce9[_0x4ee006]={'$like':'%'+_0x13a43e[_0x5e69('0x41')][_0x5e69('0x4c')]+'%'};return _0xe4dce9;})});}_0x46939a=_[_0x5e69('0x4e')]({},_0x46939a,_0x13a43e[_0x5e69('0x57')]);return db[_0x5e69('0x6e')][_0x5e69('0x2e')]({'where':_0x46939a['where']})[_0x5e69('0x1e')](function(_0x14943e){_0x78ee2f[_0x5e69('0x2e')]=_0x14943e;if(_0x13a43e[_0x5e69('0x41')]['includeAll']){_0x46939a[_0x5e69('0x50')]=[{'model':db[_0x5e69('0x71')],'as':'Contact','required':![]},{'model':db['User'],'as':_0x5e69('0x72'),'attributes':[_0x5e69('0x38'),_0x5e69('0x73'),_0x5e69('0x74')],'required':![]},{'model':db[_0x5e69('0x75')],'as':_0x5e69('0x76'),'attributes':['id',_0x5e69('0x38'),_0x5e69('0x77')],'where':_0x13a43e['query'][_0x5e69('0x78')]?{'id':_0x13a43e[_0x5e69('0x41')][_0x5e69('0x78')]}:undefined,'required':_0x13a43e[_0x5e69('0x41')][_0x5e69('0x78')]?!![]:![]}];}return db['FaxInteraction'][_0x5e69('0x68')](_0x46939a);})[_0x5e69('0x1e')](function(_0x57ded4){_0x78ee2f[_0x5e69('0x51')]=_0x57ded4;return _0x78ee2f;});}})[_0x5e69('0x1e')](respondWithFilteredResult(_0x1c465a,_0x46939a))[_0x5e69('0x27')](handleError(_0x1c465a,null));};exports[_0x5e69('0x79')]=function(_0x3b7b84,_0x3f5235){var _0x6b6b00=_0x3b7b84[_0x5e69('0x53')]['id'];var _0x5a9068=_0x3b7b84[_0x5e69('0x5a')];var _0x585077=0xc8;var _0x59ae05=null;return db['sequelize'][_0x5e69('0x7a')]({'isolationLevel':db[_0x5e69('0x7b')][_0x5e69('0x7c')][_0x5e69('0x7d')][_0x5e69('0x7e')]},function(_0xc74076){return db['FaxAccount'][_0x5e69('0x67')]({'where':{'id':_0x6b6b00},'transaction':_0xc74076})['then'](function(_0x266201){if(_0x266201){return db[_0x5e69('0x7f')][_0x5e69('0x34')]({'where':{'FaxAccountId':_0x6b6b00},'transaction':_0xc74076})[_0x5e69('0x1e')](function(){var _0x36f0db=_[_0x5e69('0x3b')](_0x5a9068,function(_0x6c8a32){_0x6c8a32['FaxAccountId']=_0x6b6b00;return _0x6c8a32;});return db[_0x5e69('0x7f')]['bulkCreate'](_0x36f0db,{'transaction':_0xc74076});});}else{_0x585077=0x194;_0x59ae05=[];}});})[_0x5e69('0x1e')](function(){if(_0x585077!==0x194){return db[_0x5e69('0x7f')][_0x5e69('0x80')]({'where':{'FaxAccountId':_0x6b6b00},'order':_0x5e69('0x81')})['then'](function(_0x494989){_0x59ae05=_0x494989;});}})[_0x5e69('0x27')](function(_0x2db16a){_0x585077=0x1f4;logger['error'](_0x2db16a[_0x5e69('0x37')]);if(_0x2db16a[_0x5e69('0x38')]){delete _0x2db16a[_0x5e69('0x38')];}_0x59ae05=_0x2db16a;})[_0x5e69('0x82')](function(){if(_0x59ae05===null){_0x3f5235['sendStatus'](_0x585077);}else{if(_0x585077===0x1f4){_0x3f5235[_0x5e69('0x29')](_0x585077)[_0x5e69('0x83')](_0x59ae05);}else{_0x3f5235['status'](_0x585077)[_0x5e69('0x2b')](_0x59ae05);}}});};exports[_0x5e69('0x84')]=function(_0x51a54d,_0x41a006,_0x385398){var _0x3a21ae={};var _0x4eed1c={};var _0x1221ad;var _0x17801f;return db[_0x5e69('0x3c')][_0x5e69('0x67')]({'where':{'id':_0x51a54d[_0x5e69('0x53')]['id']}})['then'](handleEntityNotFound(_0x41a006,null))[_0x5e69('0x1e')](function(_0x5d75e5){if(_0x5d75e5){_0x1221ad=_0x5d75e5;_0x4eed1c[_0x5e69('0x43')]=_['keys'](db[_0x5e69('0x7f')]['rawAttributes']);_0x4eed1c['query']=_[_0x5e69('0x40')](_0x51a54d['query']);_0x4eed1c['filters']=_[_0x5e69('0x44')](_0x4eed1c[_0x5e69('0x43')],_0x4eed1c['query']);_0x3a21ae[_0x5e69('0x55')]=_[_0x5e69('0x44')](_0x4eed1c[_0x5e69('0x43')],qs['fields'](_0x51a54d[_0x5e69('0x41')][_0x5e69('0x45')]));_0x3a21ae[_0x5e69('0x55')]=_0x3a21ae[_0x5e69('0x55')][_0x5e69('0x46')]?_0x3a21ae['attributes']:_0x4eed1c[_0x5e69('0x43')];_0x3a21ae[_0x5e69('0x49')]=qs[_0x5e69('0x4a')](_0x51a54d['query'][_0x5e69('0x4a')]);_0x3a21ae[_0x5e69('0x4d')]=qs[_0x5e69('0x42')](_['pick'](_0x51a54d[_0x5e69('0x41')],_0x4eed1c[_0x5e69('0x42')]));if(_0x51a54d[_0x5e69('0x41')]['filter']){_0x3a21ae[_0x5e69('0x4d')]=_[_0x5e69('0x4e')](_0x3a21ae[_0x5e69('0x4d')],{'$or':_['map'](_0x3a21ae['attributes'],function(_0x3c5f01){var _0xba0dc3={};_0xba0dc3[_0x3c5f01]={'$like':'%'+_0x51a54d[_0x5e69('0x41')][_0x5e69('0x4c')]+'%'};return _0xba0dc3;})});}_0x3a21ae=_['merge']({},_0x3a21ae,_0x51a54d[_0x5e69('0x57')]);return _0x1221ad[_0x5e69('0x84')](_0x3a21ae);}})[_0x5e69('0x1e')](function(_0x2e4fb8){if(_0x2e4fb8){_0x17801f=_0x2e4fb8[_0x5e69('0x46')];if(!_0x51a54d[_0x5e69('0x41')][_0x5e69('0x47')](_0x5e69('0x48'))){_0x3a21ae[_0x5e69('0x2d')]=qs[_0x5e69('0x2d')](_0x51a54d[_0x5e69('0x41')][_0x5e69('0x2d')]);_0x3a21ae[_0x5e69('0x2f')]=qs[_0x5e69('0x2f')](_0x51a54d['query']['offset']);}return _0x1221ad['getApplications'](_0x3a21ae);}})[_0x5e69('0x1e')](function(_0x448a37){if(_0x448a37){return _0x448a37?{'count':_0x17801f,'rows':_0x448a37}:null;}})[_0x5e69('0x1e')](respondWithResult(_0x41a006,null))[_0x5e69('0x27')](handleError(_0x41a006,null));};function Extension(_0x4c8d0d,_0x26b8df,_0x2812cf,_0x40dcca){this[_0x5e69('0x85')]=_0x5e69('0x86');this[_0x5e69('0x87')]=_0x4c8d0d[_0x5e69('0x88')];this[_0x5e69('0x89')]=_0x40dcca;this[_0x5e69('0x8a')]=_0x5e69('0x8b');this['description']=_0x5e69('0x8c');this[_0x5e69('0x64')]=_0x4c8d0d['id'];this['priority']=_0x26b8df;this[_0x5e69('0x8d')]=_0x2812cf;}function createExtensionsReciveFax(_0x350023){var _0x46ae68=0x1;var _0x4b1348=[];_0x4b1348[_0x5e69('0x8e')](new Extension(_0x350023,_0x46ae68,'',_0x5e69('0x8f')));_0x46ae68+=0x1;_0x4b1348[_0x5e69('0x8e')](new Extension(_0x350023,_0x46ae68,_0x5e69('0x90'),_0x5e69('0x91')));_0x46ae68+=0x1;for(var _0x302ade in _0x350023){if(_0x350023[_0x5e69('0x47')](_0x302ade)&&(_0x302ade===_0x5e69('0x92')||_0x302ade===_0x5e69('0x88')||_0x302ade===_0x5e69('0x93')||_0x302ade===_0x5e69('0x94')||_0x302ade===_0x5e69('0x95')||_0x302ade===_0x5e69('0x96')||_0x302ade===_0x5e69('0x97')||_0x302ade===_0x5e69('0x98')||_0x302ade===_0x5e69('0x99'))){_0x4b1348['push'](new Extension(_0x350023,_0x46ae68,'FAXOPT('+_0x302ade+')='+_0x350023[_0x302ade],'Set'));_0x46ae68+=0x1;}}_0x4b1348[_0x5e69('0x8e')](new Extension(_0x350023,_0x46ae68,'6',_0x5e69('0x9a')));_0x46ae68+=0x1;_0x4b1348[_0x5e69('0x8e')](new Extension(_0x350023,_0x46ae68,'/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d',_0x5e69('0x9b')));_0x46ae68=0x0;return _0x4b1348;}exports[_0x5e69('0x9c')]=function(_0x474838,_0xa17b28,_0x4e84a0){var _0x1f12db;return db['sequelize'][_0x5e69('0x7a')](function(_0xac6521){return db[_0x5e69('0x3c')]['create'](_0x474838[_0x5e69('0x5a')],{'transaction':_0xac6521})[_0x5e69('0x1e')](function(_0x5dfb51){_0x1f12db=_0x5dfb51['get']({'plain':!![]});return db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_0x1f12db),{'transaction':_0xac6521});});})[_0x5e69('0x1e')](function(){return _0x1f12db;})['then'](respondWithResult(_0xa17b28,null))[_0x5e69('0x27')](handleError(_0xa17b28,null));};exports[_0x5e69('0x9d')]=function(_0x1d5c18,_0x4d54ca,_0x22030f){var _0x3550b4;return db[_0x5e69('0x7b')][_0x5e69('0x7a')](function(_0x99157f){return db[_0x5e69('0x3c')][_0x5e69('0x33')](_0x1d5c18[_0x5e69('0x5a')],{'where':{'id':_0x1d5c18[_0x5e69('0x5a')]['id']},'transaction':_0x99157f})[_0x5e69('0x1e')](function(_0x32a384){return db[_0x5e69('0x9e')][_0x5e69('0x34')]({'where':{'FaxAccountId':_0x1d5c18[_0x5e69('0x5a')]['id']},'transaction':_0x99157f})['then'](function(_0x2682a3){return db[_0x5e69('0x9e')][_0x5e69('0x9f')](createExtensionsReciveFax(_['omit'](_0x1d5c18[_0x5e69('0x5a')],[_0x5e69('0xa0'),'key','createdAt',_0x5e69('0xa1'),_0x5e69('0xa2'),_0x5e69('0xa3')])),{'transaction':_0x99157f});});});})['then'](function(){return db[_0x5e69('0x3c')][_0x5e69('0xa4')](_0x1d5c18['body']['id']);})[_0x5e69('0x1e')](respondWithResult(_0x4d54ca,null))[_0x5e69('0x27')](handleError(_0x4d54ca,null));};exports['getMessages']=function(_0x5ea585,_0x247d5a,_0x34c189){var _0x1c4b0c={'raw':!![],'where':{}};var _0x3be393={};var _0x30a259={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x5ea585[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x247d5a,null))[_0x5e69('0x1e')](function(_0x5dd015){if(_0x5dd015){_0x3be393[_0x5e69('0x43')]=_['keys'](db[_0x5e69('0xa5')]['rawAttributes']);_0x3be393[_0x5e69('0x41')]=_['keys'](_0x5ea585[_0x5e69('0x41')]);_0x3be393[_0x5e69('0x42')]=_[_0x5e69('0x44')](_0x3be393['model'],_0x3be393[_0x5e69('0x41')]);_0x1c4b0c['attributes']=_[_0x5e69('0x44')](_0x3be393[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x5ea585[_0x5e69('0x41')][_0x5e69('0x45')]));_0x1c4b0c[_0x5e69('0x55')]=_0x1c4b0c[_0x5e69('0x55')][_0x5e69('0x46')]?_0x1c4b0c[_0x5e69('0x55')]:_0x3be393[_0x5e69('0x43')];if(!_0x5ea585[_0x5e69('0x41')][_0x5e69('0x47')](_0x5e69('0x48'))){_0x1c4b0c[_0x5e69('0x2d')]=qs[_0x5e69('0x2d')](_0x5ea585[_0x5e69('0x41')][_0x5e69('0x2d')]);_0x1c4b0c[_0x5e69('0x2f')]=qs[_0x5e69('0x2f')](_0x5ea585['query'][_0x5e69('0x2f')]);}_0x1c4b0c[_0x5e69('0x49')]=qs[_0x5e69('0x4a')](_0x5ea585[_0x5e69('0x41')]['sort']);_0x1c4b0c[_0x5e69('0x4d')]=qs[_0x5e69('0x42')](_[_0x5e69('0x4b')](_0x5ea585[_0x5e69('0x41')],_0x3be393['filters']));_0x1c4b0c['where']['FaxAccountId']=_0x5dd015['id'];if(_0x5ea585['query']['filter']){_0x1c4b0c[_0x5e69('0x4d')]=_[_0x5e69('0x4e')](_0x1c4b0c[_0x5e69('0x4d')],{'$or':_['map'](_0x1c4b0c[_0x5e69('0x55')],function(_0x4374f4){var _0x4d39d8={};_0x4d39d8[_0x4374f4]={'$like':'%'+_0x5ea585['query'][_0x5e69('0x4c')]+'%'};return _0x4d39d8;})});}if(_0x5ea585[_0x5e69('0x41')]['$gte']){var _0x226813=_0x5ea585['query'][_0x5e69('0xa6')][_0x5e69('0xa7')](',');var _0x421092={};_0x421092[_0x226813[0x0]]={'$gte':moment(_0x226813[0x1])['format'](_0x5e69('0xa8'))};_0x1c4b0c['where']=_[_0x5e69('0x4e')](_0x1c4b0c[_0x5e69('0x4d')],_0x421092);}_0x1c4b0c=_['merge']({},_0x1c4b0c,_0x5ea585[_0x5e69('0x57')]);return db[_0x5e69('0xa5')]['count']({'where':_0x1c4b0c['where']})[_0x5e69('0x1e')](function(_0x1aaa29){_0x30a259[_0x5e69('0x2e')]=_0x1aaa29;if(_0x5ea585[_0x5e69('0x41')][_0x5e69('0x56')]){_0x1c4b0c[_0x5e69('0x50')]=[{'all':!![]}];}return db[_0x5e69('0xa5')][_0x5e69('0x68')](_0x1c4b0c);})['then'](function(_0x4247f6){_0x30a259[_0x5e69('0x51')]=_0x4247f6;return _0x30a259;});}})['then'](respondWithFilteredResult(_0x247d5a,_0x1c4b0c))[_0x5e69('0x27')](handleError(_0x247d5a,null));};exports[_0x5e69('0x83')]=function(_0x41090d,_0x20770a,_0x32528c){var _0x491175,_0xd4862={},_0x23fcd1;if(_0x41090d[_0x5e69('0x5a')]['to']){_0x23fcd1=_0x41090d[_0x5e69('0x5a')]['to'][0x0];}return db[_0x5e69('0x3c')][_0x5e69('0x58')]({'where':{'id':_0x41090d[_0x5e69('0x53')]['id']},'include':[{'model':db[_0x5e69('0xa9')],'as':_0x5e69('0xaa'),'include':[{'model':db[_0x5e69('0x71')],'as':_0x5e69('0xab'),'where':{'fax':_0x23fcd1},'limit':0x1,'order':[[_0x5e69('0xa1'),_0x5e69('0xac')]]}]}]})[_0x5e69('0x1e')](handleEntityNotFound(_0x20770a,null))[_0x5e69('0x1e')](function(_0x2d051c){_0x491175=_0x2d051c;if(_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')]&&_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][_0x5e69('0x46')]){for(var _0x5a413a=0x0;_0x5a413a<_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][_0x5e69('0x46')];_0x5a413a+=0x1){_0x41090d[_0x5e69('0x5a')]['attachments'][_0x5a413a]={'filename':_0x41090d['body'][_0x5e69('0xad')][_0x5a413a]['name'],'id':_0x41090d['body'][_0x5e69('0xad')][_0x5a413a]['id'],'path':path['join'](config['root'],_0x5e69('0xae'),_0x41090d[_0x5e69('0x5a')]['attachments'][_0x5a413a]['basename'])};}}return respondWithRpcPromise(_0x5e69('0xaf'),_0x5e69('0xaf'),{'FaxAccountId':_['isNil'](_0x41090d[_0x5e69('0x53')]['id'])?undefined:_0x41090d[_0x5e69('0x53')]['id'],'path':_[_0x5e69('0xb0')](_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][0x0]['path'])?undefined:_0x41090d['body'][_0x5e69('0xad')][0x0][_0x5e69('0x7')],'fax':_[_0x5e69('0xb0')](_0x41090d['body']['to'][0x0])?undefined:_0x41090d[_0x5e69('0x5a')]['to'][0x0]},client9002);})[_0x5e69('0x1e')](function(){if(_0x491175){if(_['isNil'](_0x41090d[_0x5e69('0x5a')][_0x5e69('0xb1')])){_0x41090d[_0x5e69('0x5a')][_0x5e69('0xb1')]=util[_0x5e69('0xb2')](_0x5e69('0xb3'),_0x491175[_0x5e69('0x38')],_0x491175[_0x5e69('0xb4')]);}if(_0x491175[_0x5e69('0xaa')]){if(_0x491175[_0x5e69('0xaa')][_0x5e69('0xab')]['length']){return _0x491175[_0x5e69('0xaa')]['Contacts'][0x0];}else{return db['CmContact'][_0x5e69('0x59')](_['defaults'](_0x41090d[_0x5e69('0x5a')],{'firstName':_0x41090d['body']['to'][0x0],'phone':_0x41090d[_0x5e69('0x5a')]['to'][0x0],'fax':_0x41090d['body']['to'][0x0],'ListId':_0x491175[_0x5e69('0xa3')]}));}}else{throw new Error('List\x20not\x20found');}}else{throw new Error(_0x5e69('0xb5'));}})[_0x5e69('0x1e')](function(_0x195980){if(_0x195980){return db['FaxInteraction']['find']({'where':{'ContactId':_0x195980['id'],'closed':![],'FaxAccountId':_0x491175['id']}})['then'](function(_0x40d856){if(_0x40d856){return[_0x40d856,![]];}return db['FaxInteraction'][_0x5e69('0x59')]({'UserId':_0x41090d['user']['id'],'ContactId':_0x195980['id'],'FaxAccountId':_0x491175['id'],'fax':_0x41090d['body']['to'][0x0],'firstMsgDirection':_0x5e69('0xb6'),'Messages':[_['merge'](_0x41090d[_0x5e69('0x5a')],{'read':![],'body':_0x41090d['body'][_0x5e69('0xad')][0x0][_0x5e69('0xb7')],'FaxAccountId':_0x491175['id'],'UserId':_0x41090d[_0x5e69('0x5b')]['id'],'ContactId':_0x195980['id'],'AttachmentId':_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][0x0]['id']})]},{'include':[{'model':db['FaxMessage'],'as':_0x5e69('0xb8')}]})[_0x5e69('0x1e')](function(_0x866ed7){return[_0x866ed7,!![]];});});}else{throw new Error(_0x5e69('0xb9'));}})['spread'](function(_0x213787,_0x1d774c){if(_0x1d774c){return _0x213787;}return db[_0x5e69('0xa5')][_0x5e69('0x59')]({'direction':_0x5e69('0xb6'),'read':![],'body':_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][0x0][_0x5e69('0xb7')],'FaxAccountId':_0x491175['id'],'FaxInteractionId':_0x213787['id'],'UserId':_0x41090d[_0x5e69('0x5b')]['id'],'ContactId':_0x213787[_0x5e69('0xba')],'AttachmentId':_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][0x0]['id']})['then'](function(_0x17cabd){_0x213787[_0x5e69('0xbb')][_0x5e69('0xb8')]=[];_0x213787['dataValues'][_0x5e69('0xb8')][_0x5e69('0x8e')](_0x17cabd[_0x5e69('0xbb')]);return _0x213787;});})[_0x5e69('0x1e')](function(_0x1bdd0a){respondWithRpcPromise(_0x5e69('0xbc'),_0x5e69('0xbc'),{'FaxAccountId':_[_0x5e69('0xb0')](_0x41090d[_0x5e69('0x53')]['id'])?undefined:_0x41090d[_0x5e69('0x53')]['id'],'path':_[_0x5e69('0xb0')](_0x41090d[_0x5e69('0x5a')]['attachments'][0x0][_0x5e69('0x7')])?undefined:_0x41090d[_0x5e69('0x5a')]['attachments'][0x0][_0x5e69('0x7')],'fax':_[_0x5e69('0xb0')](_0x41090d[_0x5e69('0x5a')]['to'][0x0])?undefined:_0x41090d[_0x5e69('0x5a')]['to'][0x0],'AttachmentId':_0x41090d[_0x5e69('0x5a')][_0x5e69('0xad')][0x0]['id']},client9002)[_0x5e69('0x1e')](function(_0xf52a40){logger[_0x5e69('0x1f')](_0x5e69('0xbd'),_0xf52a40);})[_0x5e69('0x27')](function(_0x1570b3){logger[_0x5e69('0x1f')](_0x5e69('0xbd'),_0x1570b3);});return _0x1bdd0a;})[_0x5e69('0x1e')](respondWithResult(_0x20770a,null))[_0x5e69('0x27')](handleError(_0x20770a,null));};exports['addAgents']=function(_0x253253,_0x80d7e6,_0xc889d9){return db['FaxAccount']['find']({'where':{'id':_0x253253['params']['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x80d7e6,null))[_0x5e69('0x1e')](function(_0x42ba98){if(_0x42ba98){return _0x42ba98[_0x5e69('0xbe')](_0x253253['body']['ids'],_[_0x5e69('0xbf')](_0x253253[_0x5e69('0x5a')],[_0x5e69('0x6d'),'id'])||{})[_0x5e69('0xc0')](function(_0x2d27b2){for(var _0x23d97c=0x0;_0x23d97c<_0x253253[_0x5e69('0x5a')]['ids']['length'];_0x23d97c+=0x1){socket['emit']('userFaxAccount:save',{'UserId':Number(_0x253253[_0x5e69('0x5a')][_0x5e69('0x6d')][_0x23d97c]),'FaxAccountId':Number(_0x253253[_0x5e69('0x53')]['id'])});}return _0x2d27b2;});}})[_0x5e69('0x1e')](respondWithResult(_0x80d7e6,null))[_0x5e69('0x27')](handleError(_0x80d7e6,null));};exports[_0x5e69('0xc1')]=function(_0x89bebf,_0x408adb,_0x1848b2){return db[_0x5e69('0x3c')][_0x5e69('0x58')]({'where':{'id':_0x89bebf['params']['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x408adb,null))[_0x5e69('0x1e')](function(_0x4ec826){if(_0x4ec826){return _0x4ec826['removeAgents'](_0x89bebf['query'][_0x5e69('0x6d')])[_0x5e69('0x1e')](function(){if(_[_0x5e69('0xc2')](_0x89bebf['query']['ids'])){for(var _0x3fbc2c=0x0;_0x3fbc2c<_0x89bebf[_0x5e69('0x41')][_0x5e69('0x6d')][_0x5e69('0x46')];_0x3fbc2c+=0x1){socket['emit']('userFaxAccount:remove',{'UserId':Number(_0x89bebf[_0x5e69('0x41')]['ids'][_0x3fbc2c]),'FaxAccountId':Number(_0x89bebf[_0x5e69('0x53')]['id'])});}}else{socket[_0x5e69('0xc3')](_0x5e69('0xc4'),{'UserId':Number(_0x89bebf[_0x5e69('0x41')][_0x5e69('0x6d')]),'FaxAccountId':Number(_0x89bebf[_0x5e69('0x53')]['id'])});}});}})[_0x5e69('0x1e')](respondWithStatusCode(_0x408adb,null))[_0x5e69('0x27')](handleError(_0x408adb,null));};exports[_0x5e69('0xc5')]=function(_0x4d31f7,_0x35e5d8,_0x2f163f){var _0x54c821={};var _0x3fb082={};var _0x424546;var _0x53c95f;return db[_0x5e69('0x3c')][_0x5e69('0x67')]({'where':{'id':_0x4d31f7[_0x5e69('0x53')]['id']}})[_0x5e69('0x1e')](handleEntityNotFound(_0x35e5d8,null))['then'](function(_0x376882){if(_0x376882){_0x424546=_0x376882;_0x3fb082[_0x5e69('0x43')]=_[_0x5e69('0x40')](db[_0x5e69('0xc6')][_0x5e69('0x3d')]);_0x3fb082[_0x5e69('0x41')]=_[_0x5e69('0x40')](_0x4d31f7[_0x5e69('0x41')]);_0x3fb082[_0x5e69('0x42')]=_[_0x5e69('0x44')](_0x3fb082[_0x5e69('0x43')],_0x3fb082[_0x5e69('0x41')]);_0x54c821['attributes']=_[_0x5e69('0x44')](_0x3fb082[_0x5e69('0x43')],qs[_0x5e69('0x45')](_0x4d31f7['query'][_0x5e69('0x45')]));_0x54c821[_0x5e69('0x55')]=_0x54c821['attributes'][_0x5e69('0x46')]?_0x54c821[_0x5e69('0x55')]:_0x3fb082[_0x5e69('0x43')];_0x54c821[_0x5e69('0x49')]=qs[_0x5e69('0x4a')](_0x4d31f7['query'][_0x5e69('0x4a')]);_0x54c821[_0x5e69('0x4d')]=qs[_0x5e69('0x42')](_[_0x5e69('0x4b')](_0x4d31f7['query'],_0x3fb082[_0x5e69('0x42')]));if(_0x4d31f7[_0x5e69('0x41')][_0x5e69('0x4c')]){_0x54c821[_0x5e69('0x4d')]=_['merge'](_0x54c821[_0x5e69('0x4d')],{'$or':_['map'](_0x54c821[_0x5e69('0x55')],function(_0x16addf){var _0x4844d4={};_0x4844d4[_0x16addf]={'$like':'%'+_0x4d31f7[_0x5e69('0x41')][_0x5e69('0x4c')]+'%'};return _0x4844d4;})});}_0x54c821=_[_0x5e69('0x4e')]({},_0x54c821,_0x4d31f7['options']);return _0x424546['getAgents'](_0x54c821);}})[_0x5e69('0x1e')](function(_0x1d7675){if(_0x1d7675){_0x53c95f=_0x1d7675[_0x5e69('0x46')];if(!_0x4d31f7[_0x5e69('0x41')]['hasOwnProperty']('nolimit')){_0x54c821[_0x5e69('0x2d')]=qs[_0x5e69('0x2d')](_0x4d31f7['query']['limit']);_0x54c821['offset']=qs[_0x5e69('0x2f')](_0x4d31f7[_0x5e69('0x41')][_0x5e69('0x2f')]);}return _0x424546['getAgents'](_0x54c821);}})['then'](function(_0x44f365){if(_0x44f365){return _0x44f365?{'count':_0x53c95f,'rows':_0x44f365}:null;}})[_0x5e69('0x1e')](respondWithResult(_0x35e5d8,null))['catch'](handleError(_0x35e5d8,null));}; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.events.js b/server/api/faxAccount/faxAccount.events.js new file mode 100644 index 0000000..dc00a52 --- /dev/null +++ b/server/api/faxAccount/faxAccount.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x01dd=['hasOwnProperty','hook','exports','events','../../mysqldb','FaxAccount','setMaxListeners','save','update','remove','emit'];(function(_0x3d6897,_0x49156b){var _0x33a9f9=function(_0x2947e4){while(--_0x2947e4){_0x3d6897['push'](_0x3d6897['shift']());}};_0x33a9f9(++_0x49156b);}(_0x01dd,0x1b0));var _0xd01d=function(_0x238671,_0x34aea0){_0x238671=_0x238671-0x0;var _0x474844=_0x01dd[_0x238671];return _0x474844;};'use strict';var EventEmitter=require(_0xd01d('0x0'));var FaxAccount=require(_0xd01d('0x1'))['db'][_0xd01d('0x2')];var FaxAccountEvents=new EventEmitter();FaxAccountEvents[_0xd01d('0x3')](0x0);var events={'afterCreate':_0xd01d('0x4'),'afterUpdate':_0xd01d('0x5'),'afterDestroy':_0xd01d('0x6')};function emitEvent(_0x389eff){return function(_0x4fcf16,_0x1eee02,_0x32f59b){FaxAccountEvents[_0xd01d('0x7')](_0x389eff+':'+_0x4fcf16['id'],_0x4fcf16);FaxAccountEvents[_0xd01d('0x7')](_0x389eff,_0x4fcf16);_0x32f59b(null);};}for(var e in events){if(events[_0xd01d('0x8')](e)){var event=events[e];FaxAccount[_0xd01d('0x9')](e,emitEvent(event));}}module[_0xd01d('0xa')]=FaxAccountEvents; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.model.js b/server/api/faxAccount/faxAccount.model.js new file mode 100644 index 0000000..727b5d7 --- /dev/null +++ b/server/api/faxAccount/faxAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4415=['bluebird','path','rimraf','../../config/environment','./faxAccount.attributes','exports','define','fax_accounts','lodash','util','../../config/logger','api','moment'];(function(_0x141d9d,_0x19f8b2){var _0x5e89e8=function(_0x4df965){while(--_0x4df965){_0x141d9d['push'](_0x141d9d['shift']());}};_0x5e89e8(++_0x19f8b2);}(_0x4415,0x133));var _0x5441=function(_0x368fb9,_0x1a9895){_0x368fb9=_0x368fb9-0x0;var _0x4892fb=_0x4415[_0x368fb9];return _0x4892fb;};'use strict';var _=require(_0x5441('0x0'));var util=require(_0x5441('0x1'));var logger=require(_0x5441('0x2'))(_0x5441('0x3'));var moment=require(_0x5441('0x4'));var BPromise=require(_0x5441('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x5441('0x6'));var rimraf=require(_0x5441('0x7'));var config=require(_0x5441('0x8'));var attributes=require(_0x5441('0x9'));module[_0x5441('0xa')]=function(_0x4466fa,_0x170322){return _0x4466fa[_0x5441('0xb')]('FaxAccount',attributes,{'tableName':_0x5441('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.rpc.js b/server/api/faxAccount/faxAccount.rpc.js new file mode 100644 index 0000000..24dd92d --- /dev/null +++ b/server/api/faxAccount/faxAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3d0c=['http','redis','socket.io-emitter','./faxAccount.socket','register','request','then','info','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxAccount,\x20%s,\x20%s','message','catch','FaxAccount','findAll','options','where','attributes','include','map','model','GetFaxAccount','debug','NotifyFaxAccount','body','CmContact','describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','account','CmList','List','Contacts','DESC','FaxApplication','Applications','get','list','orderBy','applications','priority','asc','length','create','contact','fax','FaxInteraction','Contact\x20not\x20found','autoclose','push','close','unmanaged','*,*,*,*','created','interaction','FaxMessage','ContactId','UserId','User','name','unshift','agent','waitForTheAssignedAgent','Start','startRouting','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client'];(function(_0x51bbb0,_0xd9ea53){var _0x4afad1=function(_0x25f2a3){while(--_0x25f2a3){_0x51bbb0['push'](_0x51bbb0['shift']());}};_0x4afad1(++_0xd9ea53);}(_0x3d0c,0x1c7));var _0xc3d0=function(_0x290694,_0x281935){_0x290694=_0x290694-0x0;var _0x5a0f2e=_0x3d0c[_0x290694];return _0x5a0f2e;};'use strict';var _=require(_0xc3d0('0x0'));var util=require(_0xc3d0('0x1'));var moment=require(_0xc3d0('0x2'));var BPromise=require(_0xc3d0('0x3'));var rs=require(_0xc3d0('0x4'));var fs=require('fs');var Redis=require(_0xc3d0('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xc3d0('0x6'))('rpc');var config=require(_0xc3d0('0x7'));var jayson=require(_0xc3d0('0x8'));var client=jayson[_0xc3d0('0x9')][_0xc3d0('0xa')]({'port':0x232c});config[_0xc3d0('0xb')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xc3d0('0xc'))(new Redis(config[_0xc3d0('0xb')]));require(_0xc3d0('0xd'))[_0xc3d0('0xe')](socket);function respondWithRpcPromise(_0x1051e2,_0x5e8b21,_0x525aa5){return new BPromise(function(_0x35acf9,_0x10b7b0){return client[_0xc3d0('0xf')](_0x1051e2,_0x525aa5)[_0xc3d0('0x10')](function(_0x33c86b){logger[_0xc3d0('0x11')]('FaxAccount,\x20%s,\x20%s',_0x5e8b21,_0xc3d0('0x12'));logger['debug'](_0xc3d0('0x13'),_0x5e8b21,'request\x20sent',JSON[_0xc3d0('0x14')](_0x33c86b));if(_0x33c86b[_0xc3d0('0x15')]){if(_0x33c86b[_0xc3d0('0x15')][_0xc3d0('0x16')]===0x1f4){logger[_0xc3d0('0x15')](_0xc3d0('0x17'),_0x5e8b21,_0x33c86b[_0xc3d0('0x15')]['message']);return _0x10b7b0(_0x33c86b[_0xc3d0('0x15')][_0xc3d0('0x18')]);}logger[_0xc3d0('0x15')](_0xc3d0('0x17'),_0x5e8b21,_0x33c86b[_0xc3d0('0x15')][_0xc3d0('0x18')]);return _0x35acf9(_0x33c86b[_0xc3d0('0x15')][_0xc3d0('0x18')]);}else{logger['info'](_0xc3d0('0x17'),_0x5e8b21,_0xc3d0('0x12'));_0x35acf9(_0x33c86b['result'][_0xc3d0('0x18')]);}})[_0xc3d0('0x19')](function(_0x40eab7){logger[_0xc3d0('0x15')](_0xc3d0('0x17'),_0x5e8b21,_0x40eab7);_0x10b7b0(_0x40eab7);});});}exports['GetFaxAccount']=function(_0x3b87b1){var _0x57e440=this;return new Promise(function(_0x573e13,_0x2b4c17){return db[_0xc3d0('0x1a')][_0xc3d0('0x1b')]({'raw':_0x3b87b1['options']?_0x3b87b1['options']['raw']===undefined?!![]:![]:!![],'where':_0x3b87b1['options']?_0x3b87b1[_0xc3d0('0x1c')][_0xc3d0('0x1d')]||null:null,'attributes':_0x3b87b1['options']?_0x3b87b1[_0xc3d0('0x1c')][_0xc3d0('0x1e')]||null:null,'limit':_0x3b87b1['options']?_0x3b87b1['options']['limit']||null:null,'include':_0x3b87b1[_0xc3d0('0x1c')]?_0x3b87b1[_0xc3d0('0x1c')][_0xc3d0('0x1f')]?_[_0xc3d0('0x20')](_0x3b87b1[_0xc3d0('0x1c')][_0xc3d0('0x1f')],function(_0x152182){return{'model':db[_0x152182[_0xc3d0('0x21')]],'as':_0x152182['as'],'attributes':_0x152182[_0xc3d0('0x1e')],'include':_0x152182[_0xc3d0('0x1f')]?_[_0xc3d0('0x20')](_0x152182[_0xc3d0('0x1f')],function(_0x4f03d8){return{'model':db[_0x4f03d8[_0xc3d0('0x21')]],'as':_0x4f03d8['as'],'attributes':_0x4f03d8[_0xc3d0('0x1e')],'include':_0x4f03d8[_0xc3d0('0x1f')]?_[_0xc3d0('0x20')](_0x4f03d8[_0xc3d0('0x1f')],function(_0x216c11){return{'model':db[_0x216c11[_0xc3d0('0x21')]],'as':_0x216c11['as'],'attributes':_0x216c11[_0xc3d0('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x766cca){logger['info'](_0xc3d0('0x22'),_0x3b87b1);logger[_0xc3d0('0x23')](_0xc3d0('0x22'),_0x3b87b1,JSON['stringify'](_0x766cca));_0x573e13(_0x766cca);})[_0xc3d0('0x19')](function(_0x91ee70){logger[_0xc3d0('0x15')]('GetFaxAccount',_0x91ee70['message'],_0x3b87b1);_0x2b4c17(_0x57e440[_0xc3d0('0x15')](0x1f4,_0x91ee70[_0xc3d0('0x18')]));});});};exports[_0xc3d0('0x24')]=function(_0x4c9540,_0x501d85,_0x31d516){var _0xeb84df=this;return new Promise(function(_0x100ef8,_0xdf95a6){var _0x18735a={'body':_0x4c9540[_0xc3d0('0x25')],'channel':'fax'};var _0x58eb7c=[];var _0x3c4936=[];var _0x14294d={};return db[_0xc3d0('0x26')][_0xc3d0('0x27')]()[_0xc3d0('0x10')](function(_0x14684f){if(!_0x14684f){throw new db[(_0xc3d0('0x28'))][(_0xc3d0('0x29'))](_0xc3d0('0x2a'));}_0x58eb7c=_[_0xc3d0('0x2b')](_[_0xc3d0('0x2c')](_0x14684f),[_0xc3d0('0x2d'),_0xc3d0('0x2e')]);_0x3c4936=_[_0xc3d0('0x2b')](_['keys'](_0x14684f),[_0xc3d0('0x2d'),_0xc3d0('0x2e'),_0xc3d0('0x2f'),_0xc3d0('0x30')]);if(_0x4c9540[_0xc3d0('0x25')]['id']){delete _0x4c9540['body']['id'];}if(_[_0xc3d0('0x31')](_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x32')])){throw new db[(_0xc3d0('0x28'))][(_0xc3d0('0x29'))](_0xc3d0('0x33'));}if(_[_0xc3d0('0x31')](_0x4c9540['body'][_0xc3d0('0x25')])||_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x25')]===''){throw new db['Sequelize'][(_0xc3d0('0x29'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xc3d0('0x31')](_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x34')])){throw new db[(_0xc3d0('0x28'))][(_0xc3d0('0x29'))](_0xc3d0('0x35')+_0x3c4936);}if(!_[_0xc3d0('0x36')](_0x3c4936,_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x34')])){throw new db[(_0xc3d0('0x28'))]['ValidationError'](_0xc3d0('0x37')+_0x3c4936);}_0x14294d[_0x4c9540['body'][_0xc3d0('0x34')]]=_0x4c9540['body'][_0xc3d0('0x32')];})['then'](function(){return db['FaxAccount'][_0xc3d0('0x38')]({'where':{'id':_0x4c9540[_0xc3d0('0x39')]['id']},'include':[{'model':db[_0xc3d0('0x3a')],'as':_0xc3d0('0x3b'),'include':[{'model':db[_0xc3d0('0x26')],'as':_0xc3d0('0x3c'),'where':_0x14294d,'limit':0x1,'order':[[_0xc3d0('0x2e'),_0xc3d0('0x3d')]]}]},{'model':db[_0xc3d0('0x3e')],'as':_0xc3d0('0x3f')}]});})[_0xc3d0('0x10')](function(_0x3af87d){if(_0x3af87d&&_0x3af87d[_0xc3d0('0x3b')]){var _0x178102=_0x3af87d[_0xc3d0('0x40')]({'plain':!![]});_0x18735a[_0xc3d0('0x39')]=_0x178102;_0x18735a['applications']=_0x178102[_0xc3d0('0x3f')];_0x18735a[_0xc3d0('0x41')]=_0x178102[_0xc3d0('0x3b')];_0x18735a['applications']=_[_0xc3d0('0x42')](_0x18735a[_0xc3d0('0x43')],[_0xc3d0('0x44')],[_0xc3d0('0x45')]);if(_0x18735a[_0xc3d0('0x39')]['Applications']){delete _0x18735a[_0xc3d0('0x39')][_0xc3d0('0x3f')];}if(_0x18735a[_0xc3d0('0x39')][_0xc3d0('0x3b')]&&_0x18735a[_0xc3d0('0x39')][_0xc3d0('0x3b')][_0xc3d0('0x3c')][_0xc3d0('0x46')]){return _0x18735a[_0xc3d0('0x39')]['List']['Contacts'][0x0];}var _0x2d0973=_['defaults'](_0x4c9540[_0xc3d0('0x25')],{'firstName':_0x4c9540['body'][_0xc3d0('0x32')],'ListId':_0x178102[_0xc3d0('0x30')]});_0x2d0973[_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x34')]]=_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x32')];return db['CmContact'][_0xc3d0('0x47')](_0x2d0973,{'fields':_0x58eb7c,'raw':!![]});}})[_0xc3d0('0x10')](function(_0x538add){_0x18735a[_0xc3d0('0x48')]=_0x538add;if(_0x538add){var _0x1ec40f={'ContactId':_0x538add['id'],'FaxAccountId':_0x4c9540[_0xc3d0('0x39')]['id'],'fax':_0x538add[_0xc3d0('0x49')]};return db['FaxInteraction'][_0xc3d0('0x38')]({'where':{'ContactId':_0x538add['id'],'closed':![],'FaxAccountId':_0x4c9540['account']['id']}})[_0xc3d0('0x10')](function(_0x43256d){if(_0x43256d){return[_0x43256d,![]];}return db[_0xc3d0('0x4a')][_0xc3d0('0x47')](_0x1ec40f)[_0xc3d0('0x10')](function(_0x4cab94){return[_0x4cab94,!![]];});});}else{throw new Error(_0xc3d0('0x4b'));}})['spread'](function(_0x58bc3c,_0x578a5a){var _0x5da6dd=_0x58bc3c['get']({'plain':!![]});if(_0x578a5a){if(_0x18735a[_0xc3d0('0x39')][_0xc3d0('0x4c')]){_0x18735a[_0xc3d0('0x43')][_0xc3d0('0x4d')]({'id':0x0,'priority':_0x18735a['applications'][_0xc3d0('0x46')]+0x1,'app':_0xc3d0('0x4e'),'appdata':_0xc3d0('0x4f'),'interval':_0xc3d0('0x50')});}_0x5da6dd[_0xc3d0('0x51')]=!![];}else{_0x5da6dd[_0xc3d0('0x51')]=![];}_0x18735a[_0xc3d0('0x52')]=_0x5da6dd;return db[_0xc3d0('0x53')][_0xc3d0('0x47')]({'body':_0x4c9540[_0xc3d0('0x25')][_0xc3d0('0x25')],'FaxAccountId':_0x4c9540[_0xc3d0('0x39')]['id'],'FaxInteractionId':_0x58bc3c['id'],'direction':'in','ContactId':_0x58bc3c[_0xc3d0('0x54')],'AttachmentId':_0x4c9540[_0xc3d0('0x25')]['AttachmentId']});})[_0xc3d0('0x10')](function(_0x418da2){_0x18735a[_0xc3d0('0x18')]=_0x418da2;if(_0x18735a[_0xc3d0('0x52')][_0xc3d0('0x55')]){return db[_0xc3d0('0x56')][_0xc3d0('0x38')]({'attributes':['id',_0xc3d0('0x57')],'where':{'id':_0x18735a[_0xc3d0('0x52')][_0xc3d0('0x55')]}})[_0xc3d0('0x10')](function(_0x584a6b){if(_0x584a6b){_0x18735a[_0xc3d0('0x43')][_0xc3d0('0x58')]({'id':0x0,'priority':0x0,'app':_0xc3d0('0x59'),'appdata':_0x584a6b[_0xc3d0('0x57')]+','+(_0x18735a['account'][_0xc3d0('0x5a')]||0xa),'interval':_0xc3d0('0x50')});}return respondWithRpcPromise(_0xc3d0('0x5b'),_0xc3d0('0x5c'),_0x18735a);});}return respondWithRpcPromise(_0xc3d0('0x5b'),'startRouting',_0x18735a);})[_0xc3d0('0x10')](function(_0x559416){_0x100ef8(_0x559416);})[_0xc3d0('0x19')](function(_0x5de807){_0xdf95a6(_0xeb84df[_0xc3d0('0x15')](0x1f4,_0x5de807[_0xc3d0('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/faxAccount/faxAccount.socket.js b/server/api/faxAccount/faxAccount.socket.js new file mode 100644 index 0000000..4b3e1b4 --- /dev/null +++ b/server/api/faxAccount/faxAccount.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x404e=['save','update','emit','removeListener','register','length','faxAccount:','./faxAccount.events'];(function(_0x21f4e4,_0x326a84){var _0x5d7709=function(_0x572f77){while(--_0x572f77){_0x21f4e4['push'](_0x21f4e4['shift']());}};_0x5d7709(++_0x326a84);}(_0x404e,0x8f));var _0xe404=function(_0x39bc44,_0x1d4373){_0x39bc44=_0x39bc44-0x0;var _0x2916d8=_0x404e[_0x39bc44];return _0x2916d8;};'use strict';var FaxAccountEvents=require(_0xe404('0x0'));var events=[_0xe404('0x1'),'remove',_0xe404('0x2')];function createListener(_0x18249e,_0x31463e){return function(_0x4d0a2f){_0x31463e[_0xe404('0x3')](_0x18249e,_0x4d0a2f);};}function removeListener(_0x1764b0,_0x20ca04){return function(){FaxAccountEvents[_0xe404('0x4')](_0x1764b0,_0x20ca04);};}exports[_0xe404('0x5')]=function(_0xd51058){for(var _0x3f12d8=0x0,_0x39a1ef=events[_0xe404('0x6')];_0x3f12d8<_0x39a1ef;_0x3f12d8++){var _0x1fc0df=events[_0x3f12d8];var _0x535a92=createListener(_0xe404('0x7')+_0x1fc0df,_0xd51058);FaxAccountEvents['on'](_0x1fc0df,_0x535a92);}}; \ No newline at end of file diff --git a/server/api/faxAccount/index.js b/server/api/faxAccount/index.js new file mode 100644 index 0000000..072641e --- /dev/null +++ b/server/api/faxAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./faxAccount.controller','get','index','/describe','show','/:id/dispositions','isAuthenticated','getDispositions','/:id/interactions','getInteractions','/:id/applications','/:id/messages','getMessages','/:id/users','getAgents','post','addDisposition','/:id/canned_answers','addAnswer','addInteraction','addApplications','addAccountApplications','/updateaccountapplications','/:id/send','send','addAgents','put','/:id','update','destroy','delete','removeDispositions','removeAnswers','removeAgents','exports','multer','util','path'];(function(_0x17a0b0,_0x247cb7){var _0x445ead=function(_0x36dcdc){while(--_0x36dcdc){_0x17a0b0['push'](_0x17a0b0['shift']());}};_0x445ead(++_0x247cb7);}(_0xa9e0,0x123));var _0x0a9e=function(_0x49ca18,_0x5e6d05){_0x49ca18=_0x49ca18-0x0;var _0x145d54=_0xa9e0[_0x49ca18];return _0x145d54;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['describe']);router[_0x0a9e('0x8')]('/:id',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);router[_0x0a9e('0x8')](_0x0a9e('0xc'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0x8')]('/:id/canned_answers',auth['isAuthenticated'](),controller['getAnswers']);router['get'](_0x0a9e('0xf'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x10')]);router[_0x0a9e('0x8')](_0x0a9e('0x11'),auth[_0x0a9e('0xd')](),controller['getApplications']);router[_0x0a9e('0x8')](_0x0a9e('0x12'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x13')]);router[_0x0a9e('0x8')](_0x0a9e('0x14'),auth['isAuthenticated'](),controller[_0x0a9e('0x15')]);router['post']('/',auth[_0x0a9e('0xd')](),controller['create']);router[_0x0a9e('0x16')](_0x0a9e('0xc'),auth['isAuthenticated'](),controller[_0x0a9e('0x17')]);router['post'](_0x0a9e('0x18'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x19')]);router[_0x0a9e('0x16')](_0x0a9e('0xf'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x1a')]);router[_0x0a9e('0x16')](_0x0a9e('0x11'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x1b')]);router[_0x0a9e('0x16')]('/addaccountapplications',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x1c')]);router['post'](_0x0a9e('0x1d'),auth['isAuthenticated'](),controller['updateAccountApplications']);router[_0x0a9e('0x16')](_0x0a9e('0x1e'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x1f')]);router['post'](_0x0a9e('0x14'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x20')]);router[_0x0a9e('0x21')](_0x0a9e('0x22'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x23')]);router['delete']('/:id',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x24')]);router[_0x0a9e('0x25')](_0x0a9e('0xc'),auth['isAuthenticated'](),controller[_0x0a9e('0x26')]);router['delete'](_0x0a9e('0x18'),auth['isAuthenticated'](),controller[_0x0a9e('0x27')]);router[_0x0a9e('0x25')](_0x0a9e('0x14'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x28')]);module[_0x0a9e('0x29')]=router; \ No newline at end of file diff --git a/server/api/faxApplication/faxApplication.attributes.js b/server/api/faxApplication/faxApplication.attributes.js new file mode 100644 index 0000000..c945150 --- /dev/null +++ b/server/api/faxApplication/faxApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4119=['sequelize','exports','STRING','noop'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0x4119,0x11c));var _0x9411=function(_0x40ac5e,_0x2de228){_0x40ac5e=_0x40ac5e-0x0;var _0x2839d6=_0x4119[_0x40ac5e];return _0x2839d6;};'use strict';var Sequelize=require(_0x9411('0x0'));module[_0x9411('0x1')]={'priority':{'type':Sequelize['INTEGER'],'allowNull':![]},'app':{'type':Sequelize[_0x9411('0x2')],'allowNull':![],'defaultValue':_0x9411('0x3')},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize[_0x9411('0x2')]},'interval':{'type':Sequelize[_0x9411('0x2')],'defaultValue':'*,*,*,*'}}; \ No newline at end of file diff --git a/server/api/faxApplication/faxApplication.controller.js b/server/api/faxApplication/faxApplication.controller.js new file mode 100644 index 0000000..87de51b --- /dev/null +++ b/server/api/faxApplication/faxApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf57d=['findAll','rows','catch','show','params','merge','find','create','body','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','reject','save','destroy','then','error','stack','name','index','map','FaxApplication','fieldName','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','type','VIRTUAL','options','includeAll','include'];(function(_0x19b834,_0x590212){var _0x43f4f1=function(_0x5a5834){while(--_0x5a5834){_0x19b834['push'](_0x19b834['shift']());}};_0x43f4f1(++_0x590212);}(_0xf57d,0x17b));var _0xdf57=function(_0x583761,_0x119f81){_0x583761=_0x583761-0x0;var _0x4b72f0=_0xf57d[_0x583761];return _0x4b72f0;};'use strict';var emlformat=require(_0xdf57('0x0'));var rimraf=require(_0xdf57('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xdf57('0x2'));var moment=require(_0xdf57('0x3'));var BPromise=require(_0xdf57('0x4'));var Mustache=require(_0xdf57('0x5'));var util=require(_0xdf57('0x6'));var path=require('path');var sox=require(_0xdf57('0x7'));var csv=require(_0xdf57('0x8'));var ejs=require(_0xdf57('0x9'));var fs=require('fs');var fs_extra=require(_0xdf57('0xa'));var _=require('lodash');var squel=require(_0xdf57('0xb'));var crypto=require(_0xdf57('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xdf57('0xd'));var toCsv=require(_0xdf57('0x8'));var querystring=require(_0xdf57('0xe'));var Papa=require(_0xdf57('0xf'));var Redis=require(_0xdf57('0x10'));var authService=require(_0xdf57('0x11'));var qs=require(_0xdf57('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xdf57('0x13'));var logger=require(_0xdf57('0x14'))(_0xdf57('0x15'));var utils=require(_0xdf57('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xdf57('0x17'));var db=require(_0xdf57('0x18'))['db'];function respondWithStatusCode(_0x4e90c7,_0x425759){_0x425759=_0x425759||0xcc;return function(_0xee7d62){if(_0xee7d62){return _0x4e90c7[_0xdf57('0x19')](_0x425759);}return _0x4e90c7[_0xdf57('0x1a')](_0x425759)[_0xdf57('0x1b')]();};}function respondWithResult(_0x46a3c2,_0x1aff25){_0x1aff25=_0x1aff25||0xc8;return function(_0x5b54c0){if(_0x5b54c0){return _0x46a3c2[_0xdf57('0x1a')](_0x1aff25)['json'](_0x5b54c0);}};}function respondWithFilteredResult(_0x5b8c49,_0x19a0c2){return function(_0x477e2e){if(_0x477e2e){var _0x2f6f99=typeof _0x19a0c2[_0xdf57('0x1c')]===_0xdf57('0x1d')&&typeof _0x19a0c2[_0xdf57('0x1e')]===_0xdf57('0x1d');var _0x236d83=_0x477e2e[_0xdf57('0x1f')];var _0x3d2dbc=_0x2f6f99?0x0:_0x19a0c2[_0xdf57('0x1c')];var _0x5cc730=_0x2f6f99?_0x477e2e[_0xdf57('0x1f')]:_0x19a0c2[_0xdf57('0x1c')]+_0x19a0c2['limit'];var _0x1e76e3;if(_0x5cc730>=_0x236d83){_0x5cc730=_0x236d83;_0x1e76e3=0xc8;}else{_0x1e76e3=0xce;}_0x5b8c49[_0xdf57('0x1a')](_0x1e76e3);return _0x5b8c49[_0xdf57('0x20')](_0xdf57('0x21'),_0x3d2dbc+'-'+_0x5cc730+'/'+_0x236d83)[_0xdf57('0x22')](_0x477e2e);}return null;};}function patchUpdates(_0x229c80){return function(_0x41d856){try{jsonpatch['apply'](_0x41d856,_0x229c80,!![]);}catch(_0x4347c7){return BPromise[_0xdf57('0x23')](_0x4347c7);}return _0x41d856[_0xdf57('0x24')]();};}function saveUpdates(_0x19b5b3,_0x15f95b){return function(_0x5d2dfa){if(_0x5d2dfa){return _0x5d2dfa['update'](_0x19b5b3)['then'](function(_0x4b63d4){return _0x4b63d4;});}return null;};}function removeEntity(_0x1a00ef,_0x34a5cd){return function(_0x1db38e){if(_0x1db38e){return _0x1db38e[_0xdf57('0x25')]()[_0xdf57('0x26')](function(){_0x1a00ef[_0xdf57('0x1a')](0xcc)[_0xdf57('0x1b')]();});}};}function handleEntityNotFound(_0x251008,_0x49dd57){return function(_0x2720c2){if(!_0x2720c2){_0x251008['sendStatus'](0x194);}return _0x2720c2;};}function handleError(_0x2fe1da,_0x588ff6){_0x588ff6=_0x588ff6||0x1f4;return function(_0x1dd057){logger[_0xdf57('0x27')](_0x1dd057[_0xdf57('0x28')]);if(_0x1dd057[_0xdf57('0x29')]){delete _0x1dd057[_0xdf57('0x29')];}_0x2fe1da[_0xdf57('0x1a')](_0x588ff6)['send'](_0x1dd057);};}exports[_0xdf57('0x2a')]=function(_0x1c232d,_0x4e95ea){var _0x31b11c={},_0x3ffd01={},_0x543537={'count':0x0,'rows':[]};var _0x4c75d6=_[_0xdf57('0x2b')](db[_0xdf57('0x2c')]['rawAttributes'],function(_0x5b2733){return{'name':_0x5b2733[_0xdf57('0x2d')],'type':_0x5b2733['type']['key']};});_0x3ffd01[_0xdf57('0x2e')]=_[_0xdf57('0x2b')](_0x4c75d6,_0xdf57('0x29'));_0x3ffd01[_0xdf57('0x2f')]=_[_0xdf57('0x30')](_0x1c232d[_0xdf57('0x2f')]);_0x3ffd01[_0xdf57('0x31')]=_['intersection'](_0x3ffd01[_0xdf57('0x2e')],_0x3ffd01[_0xdf57('0x2f')]);_0x31b11c['attributes']=_[_0xdf57('0x32')](_0x3ffd01[_0xdf57('0x2e')],qs['fields'](_0x1c232d[_0xdf57('0x2f')][_0xdf57('0x33')]));_0x31b11c['attributes']=_0x31b11c[_0xdf57('0x34')][_0xdf57('0x35')]?_0x31b11c[_0xdf57('0x34')]:_0x3ffd01['model'];if(!_0x1c232d['query'][_0xdf57('0x36')](_0xdf57('0x37'))){_0x31b11c[_0xdf57('0x1e')]=qs['limit'](_0x1c232d[_0xdf57('0x2f')][_0xdf57('0x1e')]);_0x31b11c[_0xdf57('0x1c')]=qs['offset'](_0x1c232d[_0xdf57('0x2f')][_0xdf57('0x1c')]);}_0x31b11c[_0xdf57('0x38')]=qs[_0xdf57('0x39')](_0x1c232d[_0xdf57('0x2f')][_0xdf57('0x39')]);_0x31b11c[_0xdf57('0x3a')]=qs['filters'](_[_0xdf57('0x3b')](_0x1c232d[_0xdf57('0x2f')],_0x3ffd01[_0xdf57('0x31')]),_0x4c75d6);if(_0x1c232d[_0xdf57('0x2f')]['filter']){_0x31b11c[_0xdf57('0x3a')]=_['merge'](_0x31b11c['where'],{'$or':_[_0xdf57('0x2b')](_0x4c75d6,function(_0x49da44){if(_0x49da44[_0xdf57('0x3c')]!==_0xdf57('0x3d')){var _0x197e5e={};_0x197e5e[_0x49da44[_0xdf57('0x29')]]={'$like':'%'+_0x1c232d[_0xdf57('0x2f')]['filter']+'%'};return _0x197e5e;}})});}_0x31b11c=_['merge']({},_0x31b11c,_0x1c232d[_0xdf57('0x3e')]);var _0x5c9789={'where':_0x31b11c[_0xdf57('0x3a')]};return db[_0xdf57('0x2c')]['count'](_0x5c9789)[_0xdf57('0x26')](function(_0x4051dd){_0x543537['count']=_0x4051dd;if(_0x1c232d['query'][_0xdf57('0x3f')]){_0x31b11c[_0xdf57('0x40')]=[{'all':!![]}];}return db['FaxApplication'][_0xdf57('0x41')](_0x31b11c);})[_0xdf57('0x26')](function(_0x39290e){_0x543537[_0xdf57('0x42')]=_0x39290e;return _0x543537;})[_0xdf57('0x26')](respondWithFilteredResult(_0x4e95ea,_0x31b11c))[_0xdf57('0x43')](handleError(_0x4e95ea,null));};exports[_0xdf57('0x44')]=function(_0x40f5da,_0x44fdaf){var _0x166436={'raw':!![],'where':{'id':_0x40f5da[_0xdf57('0x45')]['id']}},_0x1ce387={};_0x1ce387[_0xdf57('0x2e')]=_['keys'](db['FaxApplication']['rawAttributes']);_0x1ce387[_0xdf57('0x2f')]=_['keys'](_0x40f5da[_0xdf57('0x2f')]);_0x1ce387[_0xdf57('0x31')]=_['intersection'](_0x1ce387[_0xdf57('0x2e')],_0x1ce387[_0xdf57('0x2f')]);_0x166436['attributes']=_[_0xdf57('0x32')](_0x1ce387[_0xdf57('0x2e')],qs[_0xdf57('0x33')](_0x40f5da[_0xdf57('0x2f')][_0xdf57('0x33')]));_0x166436['attributes']=_0x166436['attributes'][_0xdf57('0x35')]?_0x166436[_0xdf57('0x34')]:_0x1ce387[_0xdf57('0x2e')];if(_0x40f5da[_0xdf57('0x2f')][_0xdf57('0x3f')]){_0x166436[_0xdf57('0x40')]=[{'all':!![]}];}_0x166436=_[_0xdf57('0x46')]({},_0x166436,_0x40f5da[_0xdf57('0x3e')]);return db['FaxApplication'][_0xdf57('0x47')](_0x166436)[_0xdf57('0x26')](handleEntityNotFound(_0x44fdaf,null))[_0xdf57('0x26')](respondWithResult(_0x44fdaf,null))['catch'](handleError(_0x44fdaf,null));};exports[_0xdf57('0x48')]=function(_0x4859a6,_0x14061e){return db[_0xdf57('0x2c')][_0xdf57('0x48')](_0x4859a6[_0xdf57('0x49')],{})['then'](respondWithResult(_0x14061e,0xc9))[_0xdf57('0x43')](handleError(_0x14061e,null));};exports['update']=function(_0x5696a8,_0x305367){if(_0x5696a8[_0xdf57('0x49')]['id']){delete _0x5696a8[_0xdf57('0x49')]['id'];}return db[_0xdf57('0x2c')][_0xdf57('0x47')]({'where':{'id':_0x5696a8[_0xdf57('0x45')]['id']}})[_0xdf57('0x26')](handleEntityNotFound(_0x305367,null))[_0xdf57('0x26')](saveUpdates(_0x5696a8[_0xdf57('0x49')],null))[_0xdf57('0x26')](respondWithResult(_0x305367,null))['catch'](handleError(_0x305367,null));};exports['destroy']=function(_0x45fab3,_0x4d04e9){return db[_0xdf57('0x2c')][_0xdf57('0x47')]({'where':{'id':_0x45fab3['params']['id']}})[_0xdf57('0x26')](handleEntityNotFound(_0x4d04e9,null))[_0xdf57('0x26')](removeEntity(_0x4d04e9,null))[_0xdf57('0x43')](handleError(_0x4d04e9,null));}; \ No newline at end of file diff --git a/server/api/faxApplication/faxApplication.model.js b/server/api/faxApplication/faxApplication.model.js new file mode 100644 index 0000000..a2260a2 --- /dev/null +++ b/server/api/faxApplication/faxApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe549=['rimraf','../../config/environment','./faxApplication.attributes','exports','FaxApplication','fax_applications','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','request-promise','path'];(function(_0x106bfb,_0x28322a){var _0x5696c9=function(_0xd7b678){while(--_0xd7b678){_0x106bfb['push'](_0x106bfb['shift']());}};_0x5696c9(++_0x28322a);}(_0xe549,0xe4));var _0x9e54=function(_0x4a53ad,_0x1c13bd){_0x4a53ad=_0x4a53ad-0x0;var _0x449ced=_0xe549[_0x4a53ad];return _0x449ced;};'use strict';var _=require(_0x9e54('0x0'));var util=require('util');var logger=require(_0x9e54('0x1'))('api');var moment=require(_0x9e54('0x2'));var BPromise=require(_0x9e54('0x3'));var rp=require(_0x9e54('0x4'));var fs=require('fs');var path=require(_0x9e54('0x5'));var rimraf=require(_0x9e54('0x6'));var config=require(_0x9e54('0x7'));var attributes=require(_0x9e54('0x8'));module[_0x9e54('0x9')]=function(_0x15f901,_0x1f83e4){return _0x15f901['define'](_0x9e54('0xa'),attributes,{'tableName':_0x9e54('0xb'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':'utf8mb4','collate':_0x9e54('0xc')});}; \ No newline at end of file diff --git a/server/api/faxApplication/faxApplication.rpc.js b/server/api/faxApplication/faxApplication.rpc.js new file mode 100644 index 0000000..2e6cecb --- /dev/null +++ b/server/api/faxApplication/faxApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0bc7=['stringify','error','code','FaxApplication,\x20%s,\x20%s','message','result','catch','UpdateFaxApplication','FaxApplication','options','raw','where','attributes','limit','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','FaxApplication,\x20%s,\x20%s,\x20%s'];(function(_0xb37185,_0x3ec508){var _0x575b45=function(_0x2d9b5a){while(--_0x2d9b5a){_0xb37185['push'](_0xb37185['shift']());}};_0x575b45(++_0x3ec508);}(_0x0bc7,0x1dc));var _0x70bc=function(_0x5d2543,_0xa0a4d6){_0x5d2543=_0x5d2543-0x0;var _0x420a20=_0x0bc7[_0x5d2543];return _0x420a20;};'use strict';var _=require(_0x70bc('0x0'));var util=require(_0x70bc('0x1'));var moment=require(_0x70bc('0x2'));var BPromise=require(_0x70bc('0x3'));var rs=require(_0x70bc('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x70bc('0x5'))['db'];var utils=require(_0x70bc('0x6'));var logger=require(_0x70bc('0x7'))(_0x70bc('0x8'));var config=require(_0x70bc('0x9'));var jayson=require(_0x70bc('0xa'));var client=jayson[_0x70bc('0xb')][_0x70bc('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x5c0f09,_0x4855b7,_0x477f3b){return new BPromise(function(_0xe2f258,_0x3bd95a){return client[_0x70bc('0xd')](_0x5c0f09,_0x477f3b)[_0x70bc('0xe')](function(_0x3d1d5e){logger[_0x70bc('0xf')]('FaxApplication,\x20%s,\x20%s',_0x4855b7,_0x70bc('0x10'));logger[_0x70bc('0x11')](_0x70bc('0x12'),_0x4855b7,_0x70bc('0x10'),JSON[_0x70bc('0x13')](_0x3d1d5e));if(_0x3d1d5e['error']){if(_0x3d1d5e[_0x70bc('0x14')][_0x70bc('0x15')]===0x1f4){logger[_0x70bc('0x14')](_0x70bc('0x16'),_0x4855b7,_0x3d1d5e[_0x70bc('0x14')][_0x70bc('0x17')]);return _0x3bd95a(_0x3d1d5e[_0x70bc('0x14')][_0x70bc('0x17')]);}logger['error'](_0x70bc('0x16'),_0x4855b7,_0x3d1d5e[_0x70bc('0x14')][_0x70bc('0x17')]);return _0xe2f258(_0x3d1d5e[_0x70bc('0x14')][_0x70bc('0x17')]);}else{logger[_0x70bc('0xf')](_0x70bc('0x16'),_0x4855b7,_0x70bc('0x10'));_0xe2f258(_0x3d1d5e[_0x70bc('0x18')][_0x70bc('0x17')]);}})[_0x70bc('0x19')](function(_0x553c77){logger['error'](_0x70bc('0x16'),_0x4855b7,_0x553c77);_0x3bd95a(_0x553c77);});});}exports[_0x70bc('0x1a')]=function(_0x40f5ee){var _0x1eb278=this;return new Promise(function(_0x37ee81,_0x1c20f8){return db[_0x70bc('0x1b')]['update'](_0x40f5ee['body'],{'raw':_0x40f5ee[_0x70bc('0x1c')]?_0x40f5ee[_0x70bc('0x1c')][_0x70bc('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x40f5ee[_0x70bc('0x1c')]?_0x40f5ee['options'][_0x70bc('0x1e')]||null:null,'attributes':_0x40f5ee[_0x70bc('0x1c')]?_0x40f5ee[_0x70bc('0x1c')][_0x70bc('0x1f')]||null:null,'limit':_0x40f5ee['options']?_0x40f5ee[_0x70bc('0x1c')][_0x70bc('0x20')]||null:null})[_0x70bc('0xe')](function(_0x56efa1){logger[_0x70bc('0xf')]('UpdateFaxApplication',_0x40f5ee);logger[_0x70bc('0x11')](_0x70bc('0x1a'),_0x40f5ee,JSON[_0x70bc('0x13')](_0x56efa1));_0x37ee81(_0x56efa1);})['catch'](function(_0x79a74b){logger[_0x70bc('0x14')]('UpdateFaxApplication',_0x79a74b['message'],_0x40f5ee);_0x1c20f8(_0x1eb278[_0x70bc('0x14')](0x1f4,_0x79a74b['message']));});});}; \ No newline at end of file diff --git a/server/api/faxApplication/index.js b/server/api/faxApplication/index.js new file mode 100644 index 0000000..4ea6ccd --- /dev/null +++ b/server/api/faxApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf4f4=['../../config/environment','get','isAuthenticated','index','/:id','show','post','create','put','update','delete','multer','util','connect-timeout','express','Router','fs-extra','../../components/auth/service'];(function(_0x34efa6,_0x343fe2){var _0x469490=function(_0xc1d725){while(--_0xc1d725){_0x34efa6['push'](_0x34efa6['shift']());}};_0x469490(++_0x343fe2);}(_0xf4f4,0xe3));var _0x4f4f=function(_0x2c24df,_0x2e46a3){_0x2c24df=_0x2c24df-0x0;var _0x309b15=_0xf4f4[_0x2c24df];return _0x309b15;};'use strict';var multer=require(_0x4f4f('0x0'));var util=require(_0x4f4f('0x1'));var path=require('path');var timeout=require(_0x4f4f('0x2'));var express=require(_0x4f4f('0x3'));var router=express[_0x4f4f('0x4')]();var fs_extra=require(_0x4f4f('0x5'));var auth=require(_0x4f4f('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0x4f4f('0x7'));var controller=require('./faxApplication.controller');router[_0x4f4f('0x8')]('/',auth[_0x4f4f('0x9')](),controller[_0x4f4f('0xa')]);router[_0x4f4f('0x8')](_0x4f4f('0xb'),auth[_0x4f4f('0x9')](),controller[_0x4f4f('0xc')]);router[_0x4f4f('0xd')]('/',auth['isAuthenticated'](),controller[_0x4f4f('0xe')]);router[_0x4f4f('0xf')](_0x4f4f('0xb'),auth[_0x4f4f('0x9')](),controller[_0x4f4f('0x10')]);router[_0x4f4f('0x11')](_0x4f4f('0xb'),auth[_0x4f4f('0x9')](),controller['destroy']);module['exports']=router; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.attributes.js b/server/api/faxInteraction/faxInteraction.attributes.js new file mode 100644 index 0000000..d17ab5a --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5a2c=['STRING','DATE','ENUM','out','sequelize','exports','BOOLEAN'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5a2c,0xc1));var _0xc5a2=function(_0x3b1106,_0x4bd523){_0x3b1106=_0x3b1106-0x0;var _0x1fbeef=_0x5a2c[_0x3b1106];return _0x1fbeef;};'use strict';var Sequelize=require(_0xc5a2('0x0'));module[_0xc5a2('0x1')]={'closed':{'type':Sequelize[_0xc5a2('0x2')],'defaultValue':![]},'closedAt':{'type':Sequelize['DATE']},'disposition':{'type':Sequelize[_0xc5a2('0x3')]},'secondDisposition':{'type':Sequelize[_0xc5a2('0x3')]},'thirdDisposition':{'type':Sequelize['STRING']},'note':{'type':Sequelize['STRING']},'read1stAt':{'type':Sequelize[_0xc5a2('0x4')]},'fax':{'type':Sequelize[_0xc5a2('0x3')]},'firstMsgDirection':{'type':Sequelize[_0xc5a2('0x5')]('in',_0xc5a2('0x6')),'defaultValue':'in','allowNull':![]},'lastMsgAt':{'type':Sequelize[_0xc5a2('0x4')]},'lastMsgDirection':{'type':Sequelize['ENUM']('in',_0xc5a2('0x6')),'defaultValue':'in','allowNull':![]}}; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.controller.js b/server/api/faxInteraction/faxInteraction.controller.js new file mode 100644 index 0000000..f3adb6b --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37b3=['toString','join','server','root','files','attachments','Attachment','createdAt','Messages','get','mkdirSync','basename','createReadStream','pipe','resolve','download','err','unlinkSync','rimraf','zip-dir','moment','bluebird','util','path','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','end','json','offset','undefined','count','limit','Content-Range','update','then','destroy','error','name','send','index','map','FaxInteraction','rawAttributes','getOptions','findAll','fax','query','user','catch','show','model','keys','filters','attributes','intersection','fields','length','includeAll','include','merge','options','find','create','body','params','describe','addMessage','FaxMessage','ids','omit','getMessages','findOne','nolimit','order','sort','where','pick','FaxInteractionId','filter','$gte','split','format','rows','addTags','setTags','spread','Tag','color','emit','faxInteractionTags:save','unix'];(function(_0x55951f,_0x303696){var _0x497677=function(_0x1ba98f){while(--_0x1ba98f){_0x55951f['push'](_0x55951f['shift']());}};_0x497677(++_0x303696);}(_0x37b3,0xdc));var _0x337b=function(_0x378720,_0xa711f1){_0x378720=_0x378720-0x0;var _0x47920a=_0x37b3[_0x378720];return _0x47920a;};'use strict';var rimraf=require(_0x337b('0x0'));var zipdir=require(_0x337b('0x1'));var moment=require(_0x337b('0x2'));var BPromise=require(_0x337b('0x3'));var util=require(_0x337b('0x4'));var path=require(_0x337b('0x5'));var fs=require('fs');var _=require('lodash');var Redis=require(_0x337b('0x6'));var interaction=require(_0x337b('0x7'));var qs=require(_0x337b('0x8'));var logger=require(_0x337b('0x9'))(_0x337b('0xa'));var config=require('../../config/environment');var db=require(_0x337b('0xb'))['db'];config[_0x337b('0xc')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x337b('0xd'))(new Redis(config[_0x337b('0xc')]));require(_0x337b('0xe'))[_0x337b('0xf')](socket);function respondWithStatusCode(_0x3df8e6,_0x3f1e90){_0x3f1e90=_0x3f1e90||0xcc;return function(_0x22aec6){if(_0x22aec6){return _0x3df8e6[_0x337b('0x10')](_0x3f1e90);}return _0x3df8e6[_0x337b('0x11')](_0x3f1e90)[_0x337b('0x12')]();};}function respondWithResult(_0x2a4f22,_0x751167){_0x751167=_0x751167||0xc8;return function(_0x2f8b64){if(_0x2f8b64){return _0x2a4f22['status'](_0x751167)[_0x337b('0x13')](_0x2f8b64);}};}function respondWithFilteredResult(_0x20c468,_0x15d90b){return function(_0xa80aef){if(_0xa80aef){var _0xc4274e=typeof _0x15d90b[_0x337b('0x14')]===_0x337b('0x15')&&typeof _0x15d90b['limit']===_0x337b('0x15');var _0x278e33=_0xa80aef['count'];var _0x5e679d=_0xc4274e?0x0:_0x15d90b['offset'];var _0x4a0b03=_0xc4274e?_0xa80aef[_0x337b('0x16')]:_0x15d90b[_0x337b('0x14')]+_0x15d90b[_0x337b('0x17')];var _0x1b9d6d;if(_0x4a0b03>=_0x278e33){_0x4a0b03=_0x278e33;_0x1b9d6d=0xc8;}else{_0x1b9d6d=0xce;}_0x20c468['status'](_0x1b9d6d);return _0x20c468['set'](_0x337b('0x18'),_0x5e679d+'-'+_0x4a0b03+'/'+_0x278e33)['json'](_0xa80aef);}return null;};}function saveUpdates(_0x26d323){return function(_0x43fe7c){if(_0x43fe7c){return _0x43fe7c[_0x337b('0x19')](_0x26d323)[_0x337b('0x1a')](function(_0x270998){return _0x270998;});}return null;};}function removeEntity(_0x4028b6){return function(_0x3f849f){if(_0x3f849f){return _0x3f849f[_0x337b('0x1b')]()['then'](function(){_0x4028b6[_0x337b('0x11')](0xcc)['end']();});}};}function handleEntityNotFound(_0x214beb){return function(_0x1ccce0){if(!_0x1ccce0){_0x214beb[_0x337b('0x10')](0x194);}return _0x1ccce0;};}function handleError(_0x5aa089,_0x2aed0e){_0x2aed0e=_0x2aed0e||0x1f4;return function(_0x3b20bd){logger[_0x337b('0x1c')](_0x3b20bd['stack']);if(_0x3b20bd[_0x337b('0x1d')]){delete _0x3b20bd[_0x337b('0x1d')];}_0x5aa089['status'](_0x2aed0e)[_0x337b('0x1e')](_0x3b20bd);};}exports[_0x337b('0x1f')]=function(_0xf506cf,_0x34bad1){var _0x528deb={};var _0xdad715=_[_0x337b('0x20')](db[_0x337b('0x21')][_0x337b('0x22')],function(_0x4e9ee2){return{'name':_0x4e9ee2['fieldName'],'type':_0x4e9ee2['type']['key']};});_0x528deb=qs[_0x337b('0x23')](_0xdad715,_0xf506cf);return interaction[_0x337b('0x24')](_0x337b('0x25'),_0xf506cf[_0x337b('0x26')],_0xf506cf[_0x337b('0x27')],_0x528deb,_0xdad715)['then'](respondWithFilteredResult(_0x34bad1,_0x528deb))[_0x337b('0x28')](handleError(_0x34bad1,null));};exports[_0x337b('0x29')]=function(_0x1ad2b8,_0x27cd84){var _0x24f0c9={'raw':![],'where':{'id':_0x1ad2b8['params']['id']}},_0x4b7e99={};_0x4b7e99[_0x337b('0x2a')]=_[_0x337b('0x2b')](db[_0x337b('0x21')][_0x337b('0x22')]);_0x4b7e99[_0x337b('0x26')]=_[_0x337b('0x2b')](_0x1ad2b8['query']);_0x4b7e99[_0x337b('0x2c')]=_['intersection'](_0x4b7e99[_0x337b('0x2a')],_0x4b7e99[_0x337b('0x26')]);_0x24f0c9[_0x337b('0x2d')]=_[_0x337b('0x2e')](_0x4b7e99[_0x337b('0x2a')],qs[_0x337b('0x2f')](_0x1ad2b8[_0x337b('0x26')]['fields']));_0x24f0c9['attributes']=_0x24f0c9[_0x337b('0x2d')][_0x337b('0x30')]?_0x24f0c9[_0x337b('0x2d')]:_0x4b7e99[_0x337b('0x2a')];if(_0x1ad2b8[_0x337b('0x26')][_0x337b('0x31')]){_0x24f0c9[_0x337b('0x32')]=[{'all':!![]}];}_0x24f0c9=_[_0x337b('0x33')]({},_0x24f0c9,_0x1ad2b8[_0x337b('0x34')]);return db[_0x337b('0x21')][_0x337b('0x35')](_0x24f0c9)[_0x337b('0x1a')](handleEntityNotFound(_0x27cd84,null))[_0x337b('0x1a')](respondWithResult(_0x27cd84,null))[_0x337b('0x28')](handleError(_0x27cd84,null));};exports[_0x337b('0x36')]=function(_0x20cbb9,_0x21e4c6){return db[_0x337b('0x21')]['create'](_0x20cbb9['body'],{})['then'](respondWithResult(_0x21e4c6,0xc9))[_0x337b('0x28')](handleError(_0x21e4c6,null));};exports[_0x337b('0x19')]=function(_0x38b954,_0x1474c6){if(_0x38b954[_0x337b('0x37')]['id']){delete _0x38b954['body']['id'];}return db[_0x337b('0x21')][_0x337b('0x35')]({'where':{'id':_0x38b954[_0x337b('0x38')]['id']}})['then'](handleEntityNotFound(_0x1474c6,null))[_0x337b('0x1a')](saveUpdates(_0x38b954['body'],null))['then'](respondWithResult(_0x1474c6,null))['catch'](handleError(_0x1474c6,null));};exports[_0x337b('0x1b')]=function(_0x5f247c,_0x506ff2){return db[_0x337b('0x21')][_0x337b('0x35')]({'where':{'id':_0x5f247c[_0x337b('0x38')]['id']}})['then'](handleEntityNotFound(_0x506ff2,null))['then'](removeEntity(_0x506ff2,null))[_0x337b('0x28')](handleError(_0x506ff2,null));};exports[_0x337b('0x39')]=function(_0x4f46f5,_0x23e847){return db['FaxInteraction'][_0x337b('0x39')]()[_0x337b('0x1a')](respondWithResult(_0x23e847,null))['catch'](handleError(_0x23e847,null));};exports[_0x337b('0x3a')]=function(_0x2f08f7,_0x2ce239){return db[_0x337b('0x3b')][_0x337b('0x35')]({'where':{'id':_0x2f08f7[_0x337b('0x38')]['id']}})[_0x337b('0x1a')](handleEntityNotFound(_0x2ce239,null))[_0x337b('0x1a')](function(_0x26351d){if(_0x26351d){return _0x26351d['addMessage'](_0x2f08f7['body'][_0x337b('0x3c')],_[_0x337b('0x3d')](_0x2f08f7[_0x337b('0x37')],[_0x337b('0x3c'),'id'])||{});}})['then'](respondWithResult(_0x2ce239,null))[_0x337b('0x28')](handleError(_0x2ce239,null));};exports[_0x337b('0x3e')]=function(_0x57a49d,_0x47387f){var _0xdfc095={'raw':![],'where':{}};var _0x2b93d6={};var _0x3463f0={'count':0x0,'rows':[]};return db['FaxInteraction'][_0x337b('0x3f')]({'where':{'id':_0x57a49d[_0x337b('0x38')]['id']}})[_0x337b('0x1a')](handleEntityNotFound(_0x47387f,null))[_0x337b('0x1a')](function(_0x5b351f){if(_0x5b351f){_0x2b93d6['model']=_[_0x337b('0x2b')](db[_0x337b('0x3b')][_0x337b('0x22')]);_0x2b93d6[_0x337b('0x26')]=_['keys'](_0x57a49d[_0x337b('0x26')]);_0x2b93d6[_0x337b('0x2c')]=_[_0x337b('0x2e')](_0x2b93d6[_0x337b('0x2a')],_0x2b93d6[_0x337b('0x26')]);_0xdfc095[_0x337b('0x2d')]=_[_0x337b('0x2e')](_0x2b93d6[_0x337b('0x2a')],qs[_0x337b('0x2f')](_0x57a49d['query'][_0x337b('0x2f')]));_0xdfc095[_0x337b('0x2d')]=_0xdfc095[_0x337b('0x2d')][_0x337b('0x30')]?_0xdfc095[_0x337b('0x2d')]:_0x2b93d6[_0x337b('0x2a')];if(!_0x57a49d[_0x337b('0x26')]['hasOwnProperty'](_0x337b('0x40'))){_0xdfc095[_0x337b('0x17')]=qs[_0x337b('0x17')](_0x57a49d['query'][_0x337b('0x17')]);_0xdfc095[_0x337b('0x14')]=qs[_0x337b('0x14')](_0x57a49d[_0x337b('0x26')][_0x337b('0x14')]);}_0xdfc095[_0x337b('0x41')]=qs[_0x337b('0x42')](_0x57a49d[_0x337b('0x26')][_0x337b('0x42')]);_0xdfc095[_0x337b('0x43')]=qs[_0x337b('0x2c')](_[_0x337b('0x44')](_0x57a49d[_0x337b('0x26')],_0x2b93d6[_0x337b('0x2c')]));_0xdfc095[_0x337b('0x43')][_0x337b('0x45')]=_0x5b351f['id'];if(_0x57a49d['query'][_0x337b('0x46')]){_0xdfc095[_0x337b('0x43')]=_[_0x337b('0x33')](_0xdfc095['where'],{'$or':_['map'](_0xdfc095[_0x337b('0x2d')],function(_0x1ac42a){var _0x49158f={};_0x49158f[_0x1ac42a]={'$like':'%'+_0x57a49d[_0x337b('0x26')][_0x337b('0x46')]+'%'};return _0x49158f;})});}if(_0x57a49d['query'][_0x337b('0x47')]){var _0x622a97=_0x57a49d['query'][_0x337b('0x47')][_0x337b('0x48')](',');var _0x199adb={};_0x199adb[_0x622a97[0x0]]={'$gte':moment(_0x622a97[0x1])[_0x337b('0x49')]('YYYY-MM-DD\x20HH:mm:ss')};_0xdfc095[_0x337b('0x43')]=_[_0x337b('0x33')](_0xdfc095[_0x337b('0x43')],_0x199adb);}_0xdfc095=_[_0x337b('0x33')]({},_0xdfc095,_0x57a49d['options']);return db['FaxMessage'][_0x337b('0x16')]({'where':_0xdfc095[_0x337b('0x43')]})['then'](function(_0x1c834f){_0x3463f0[_0x337b('0x16')]=_0x1c834f;if(_0x57a49d[_0x337b('0x26')]['includeAll']){_0xdfc095[_0x337b('0x32')]=[{'all':!![]}];}return db[_0x337b('0x3b')][_0x337b('0x24')](_0xdfc095);})[_0x337b('0x1a')](function(_0xacfb48){_0x3463f0[_0x337b('0x4a')]=_0xacfb48;return _0x3463f0;});}})[_0x337b('0x1a')](respondWithFilteredResult(_0x47387f,_0xdfc095))[_0x337b('0x28')](handleError(_0x47387f,null));};exports[_0x337b('0x4b')]=function(_0x490e56,_0x2b3634){return db['FaxInteraction']['find']({'where':{'id':_0x490e56['params']['id']}})['then'](handleEntityNotFound(_0x2b3634,null))[_0x337b('0x1a')](function(_0x3b9b85){if(_0x3b9b85){return _0x3b9b85[_0x337b('0x4c')](_0x490e56[_0x337b('0x37')][_0x337b('0x3c')],_[_0x337b('0x3d')](_0x490e56[_0x337b('0x37')],[_0x337b('0x3c'),'id'])||{})[_0x337b('0x4d')](function(){return db[_0x337b('0x4e')][_0x337b('0x24')]({'attributes':['id','name',_0x337b('0x4f')],'where':{'id':_0x490e56[_0x337b('0x37')][_0x337b('0x3c')]}});})[_0x337b('0x1a')](function(_0x4b94e0){socket[_0x337b('0x50')](_0x337b('0x51'),{'id':Number(_0x490e56[_0x337b('0x38')]['id']),'tags':_0x4b94e0||[]});return{'id':Number(_0x490e56[_0x337b('0x38')]['id']),'tags':_0x4b94e0||[]};});}})[_0x337b('0x1a')](respondWithResult(_0x2b3634,null))[_0x337b('0x28')](handleError(_0x2b3634,null));};exports['removeTags']=function(_0x1434e9,_0x498e45){return db[_0x337b('0x21')][_0x337b('0x35')]({'where':{'id':_0x1434e9[_0x337b('0x38')]['id']}})[_0x337b('0x1a')](handleEntityNotFound(_0x498e45,null))['then'](function(_0x319cc0){if(_0x319cc0){return _0x319cc0['removeTags'](_0x1434e9[_0x337b('0x26')][_0x337b('0x3c')]);}})[_0x337b('0x1a')](respondWithStatusCode(_0x498e45,null))['catch'](handleError(_0x498e45,null));};exports['download']=function(_0x6bcc71,_0x4ae9bd){var _0x1ff56d=moment()[_0x337b('0x52')]()[_0x337b('0x53')]();var _0x5a26b6=path[_0x337b('0x54')](config['root'],_0x337b('0x55'),'files','tmp');var _0x31e554=path[_0x337b('0x54')](config[_0x337b('0x56')],'server',_0x337b('0x57'),_0x337b('0x58'));var _0x46bdb8=path[_0x337b('0x54')](_0x5a26b6,_0x1ff56d);var _0x300163=util[_0x337b('0x49')]('transcript-%d-%s.zip',_0x6bcc71[_0x337b('0x38')]['id'],_0x1ff56d);var _0x4e859f=path[_0x337b('0x54')](_0x5a26b6,_0x300163);var _0x308960=[];_0x308960['push']({'model':db['Attachment'],'as':_0x337b('0x59'),'raw':!![]});var _0x1850bf=[{'model':db[_0x337b('0x3b')],'as':'Messages','attributes':['id',_0x337b('0x37'),_0x337b('0x5a')],'include':_0x308960}];return db[_0x337b('0x21')]['find']({'where':{'id':_0x6bcc71[_0x337b('0x38')]['id']},'include':_0x1850bf})['then'](handleEntityNotFound(_0x4ae9bd,null))[_0x337b('0x1a')](function(_0x30709c){if(_0x30709c&&_0x30709c[_0x337b('0x5b')]){var _0xb4ea6=_0x30709c[_0x337b('0x5c')]({'plain':!![]});fs[_0x337b('0x5d')](_0x46bdb8);for(var _0x377a0d=0x0;_0x377a0d<_0xb4ea6['Messages'][_0x337b('0x30')];_0x377a0d++){var _0x5a628c=_0xb4ea6['Messages'][_0x377a0d][_0x337b('0x59')];if(_0x5a628c){var _0x58d579=path['join'](_0x31e554,_0x5a628c[_0x337b('0x5e')]);if(fs['existsSync'](_0x58d579)){fs[_0x337b('0x5f')](_0x58d579)[_0x337b('0x60')](fs['createWriteStream'](path[_0x337b('0x54')](_0x46bdb8,_0x5a628c[_0x337b('0x5e')])));}}}return BPromise[_0x337b('0x61')]()[_0x337b('0x1a')](function(){return new BPromise(function(_0x1e61fd,_0x9086f7){zipdir(_0x46bdb8,{'saveTo':_0x4e859f},function(_0x4f81d6,_0x15098e){if(_0x4f81d6)return _0x9086f7(_0x4f81d6);return _0x1e61fd(_0x15098e);});})[_0x337b('0x1a')](function(){return new BPromise(function(_0x49338,_0x303196){rimraf(_0x46bdb8,function(_0x45bef6){if(_0x45bef6)_0x303196(_0x45bef6);return _0x49338();});});})[_0x337b('0x1a')](function(){return _0x4ae9bd[_0x337b('0x62')](_0x4e859f,_0x300163,function(_0x4e939c){if(_0x4e939c){console['log'](_0x337b('0x63'),_0x4e939c);}else{fs[_0x337b('0x64')](_0x4e859f);}});});});}else{return _0x4ae9bd['sendStatus'](0xc8);}})[_0x337b('0x28')](handleError(_0x4ae9bd,null));}; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.events.js b/server/api/faxInteraction/faxInteraction.events.js new file mode 100644 index 0000000..e8abea7 --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9baf=['unreadMessages','emit','catch','hook','exports','events','FaxInteraction','FaxMessage','setMaxListeners','update','remove','then','setDataValue'];(function(_0x32e7bb,_0x1cc16a){var _0x165e4a=function(_0x33ae3e){while(--_0x33ae3e){_0x32e7bb['push'](_0x32e7bb['shift']());}};_0x165e4a(++_0x1cc16a);}(_0x9baf,0x1cc));var _0xf9ba=function(_0x377ad1,_0xa4961b){_0x377ad1=_0x377ad1-0x0;var _0x533aff=_0x9baf[_0x377ad1];return _0x533aff;};'use strict';var EventEmitter=require(_0xf9ba('0x0'));var FaxInteraction=require('../../mysqldb')['db'][_0xf9ba('0x1')];var FaxMessage=require('../../mysqldb')['db'][_0xf9ba('0x2')];var FaxInteractionEvents=new EventEmitter();FaxInteractionEvents[_0xf9ba('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0xf9ba('0x4'),'afterDestroy':_0xf9ba('0x5')};function emitEvent(_0x2eb71e){return function(_0x1c3507,_0xf5a13a,_0x1a5493){_0x1c3507['getUsers']({'attributes':['id'],'raw':!![]})[_0xf9ba('0x6')](function(_0x238d7d){_0x1c3507[_0xf9ba('0x7')]('Users',_0x238d7d['map'](function(_0x19805b){return{'id':_0x19805b['id']};}));return FaxMessage['findAll']({'where':{'FaxInteractionId':_0x1c3507['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x370f4a){_0x1c3507['setDataValue'](_0xf9ba('0x8'),_0x370f4a['length']);FaxInteractionEvents['emit'](_0x2eb71e+':'+_0x1c3507['id'],_0x1c3507);FaxInteractionEvents[_0xf9ba('0x9')](_0x2eb71e,_0x1c3507);_0x1a5493(null);})[_0xf9ba('0xa')](_0x1a5493(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxInteraction[_0xf9ba('0xb')](e,emitEvent(event));}}module[_0xf9ba('0xc')]=FaxInteractionEvents; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.model.js b/server/api/faxInteraction/faxInteraction.model.js new file mode 100644 index 0000000..43b9157 --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb032=['bluebird','path','rimraf','../../config/environment','./faxInteraction.attributes','exports','define','FaxInteraction','fax_interactions','changed','closed','format','YYYY-MM-DD\x20HH:mm:ss','lodash','../../config/logger','api','moment'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xb032,0x84));var _0x2b03=function(_0x3c9def,_0x5384ea){_0x3c9def=_0x3c9def-0x0;var _0x591e39=_0xb032[_0x3c9def];return _0x591e39;};'use strict';var _=require(_0x2b03('0x0'));var util=require('util');var logger=require(_0x2b03('0x1'))(_0x2b03('0x2'));var moment=require(_0x2b03('0x3'));var BPromise=require(_0x2b03('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x2b03('0x5'));var rimraf=require(_0x2b03('0x6'));var config=require(_0x2b03('0x7'));var attributes=require(_0x2b03('0x8'));module[_0x2b03('0x9')]=function(_0x2bad8d,_0x556bda){return _0x2bad8d[_0x2b03('0xa')](_0x2b03('0xb'),attributes,{'tableName':_0x2b03('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x24cc52,_0x4df225,_0xe44606){if(_0x24cc52[_0x2b03('0xd')](_0x2b03('0xe'))){_0x24cc52['closedAt']=moment()[_0x2b03('0xf')](_0x2b03('0x10'));}_0xe44606(null,_0x24cc52);}}});}; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.rpc.js b/server/api/faxInteraction/faxInteraction.rpc.js new file mode 100644 index 0000000..75a39c3 --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6d65=['rpc','jayson/promise','client','http','redis','defaults','socket.io-emitter','./faxInteraction.socket','register','request','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','UpdateFaxInteraction','FaxInteraction','body','options','raw','limit','where','addTags','ids','AddTags','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x89efd1,_0xe83371){var _0x3af8f=function(_0x50b3f2){while(--_0x50b3f2){_0x89efd1['push'](_0x89efd1['shift']());}};_0x3af8f(++_0xe83371);}(_0x6d65,0x95));var _0x56d6=function(_0x421654,_0x5e8e8b){_0x421654=_0x421654-0x0;var _0x34a250=_0x6d65[_0x421654];return _0x34a250;};'use strict';var _=require(_0x56d6('0x0'));var util=require(_0x56d6('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x56d6('0x2'));var fs=require('fs');var Redis=require(_0x56d6('0x3'));var db=require(_0x56d6('0x4'))['db'];var utils=require(_0x56d6('0x5'));var logger=require(_0x56d6('0x6'))(_0x56d6('0x7'));var config=require('../../config/environment');var jayson=require(_0x56d6('0x8'));var client=jayson[_0x56d6('0x9')][_0x56d6('0xa')]({'port':0x232a});config[_0x56d6('0xb')]=_[_0x56d6('0xc')](config[_0x56d6('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x56d6('0xd'))(new Redis(config[_0x56d6('0xb')]));require(_0x56d6('0xe'))[_0x56d6('0xf')](socket);function respondWithRpcPromise(_0x129aee,_0x266f2c,_0x2267f5){return new BPromise(function(_0x54a928,_0x84f41f){return client[_0x56d6('0x10')](_0x129aee,_0x2267f5)[_0x56d6('0x11')](function(_0xe12779){logger[_0x56d6('0x12')](_0x56d6('0x13'),_0x266f2c,_0x56d6('0x14'));logger[_0x56d6('0x15')](_0x56d6('0x16'),_0x266f2c,'request\x20sent',JSON[_0x56d6('0x17')](_0xe12779));if(_0xe12779[_0x56d6('0x18')]){if(_0xe12779[_0x56d6('0x18')][_0x56d6('0x19')]===0x1f4){logger[_0x56d6('0x18')]('FaxInteraction,\x20%s,\x20%s',_0x266f2c,_0xe12779[_0x56d6('0x18')][_0x56d6('0x1a')]);return _0x84f41f(_0xe12779[_0x56d6('0x18')][_0x56d6('0x1a')]);}logger['error']('FaxInteraction,\x20%s,\x20%s',_0x266f2c,_0xe12779[_0x56d6('0x18')][_0x56d6('0x1a')]);return _0x54a928(_0xe12779[_0x56d6('0x18')][_0x56d6('0x1a')]);}else{logger[_0x56d6('0x12')](_0x56d6('0x13'),_0x266f2c,_0x56d6('0x14'));_0x54a928(_0xe12779[_0x56d6('0x1b')][_0x56d6('0x1a')]);}})[_0x56d6('0x1c')](function(_0x545768){logger[_0x56d6('0x18')]('FaxInteraction,\x20%s,\x20%s',_0x266f2c,_0x545768);_0x84f41f(_0x545768);});});}exports[_0x56d6('0x1d')]=function(_0x534563){var _0x4616ab=this;return new Promise(function(_0x3b246c,_0x28dc24){return db[_0x56d6('0x1e')]['update'](_0x534563[_0x56d6('0x1f')],{'raw':_0x534563[_0x56d6('0x20')]?_0x534563[_0x56d6('0x20')][_0x56d6('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x534563[_0x56d6('0x20')]?_0x534563[_0x56d6('0x20')]['where']||null:null,'attributes':_0x534563['options']?_0x534563[_0x56d6('0x20')]['attributes']||null:null,'limit':_0x534563[_0x56d6('0x20')]?_0x534563[_0x56d6('0x20')][_0x56d6('0x22')]||null:null})[_0x56d6('0x11')](function(_0x414665){logger['info']('UpdateFaxInteraction',_0x534563);logger['debug'](_0x56d6('0x1d'),_0x534563,JSON['stringify'](_0x414665));_0x3b246c(_0x414665);})[_0x56d6('0x1c')](function(_0x225b35){logger['error'](_0x56d6('0x1d'),_0x225b35[_0x56d6('0x1a')],_0x534563);_0x28dc24(_0x4616ab[_0x56d6('0x18')](0x1f4,_0x225b35['message']));});});};exports['AddTagsToFaxInteraction']=function(_0x1a32df){return new Promise(function(_0x5d79e0,_0x4abd04){return db[_0x56d6('0x1e')]['find']({'where':_0x1a32df['options']?_0x1a32df['options'][_0x56d6('0x23')]||null:null})['then'](function(_0x3c49ff){if(_0x3c49ff){return _0x3c49ff[_0x56d6('0x24')](_0x1a32df[_0x56d6('0x1f')][_0x56d6('0x25')],_['omit'](_0x1a32df[_0x56d6('0x1f')],[_0x56d6('0x25'),'id'])||{});}})['spread'](function(_0x2dad6c){logger[_0x56d6('0x12')](_0x56d6('0x26'),_0x1a32df);logger[_0x56d6('0x15')]('AddTags',_0x1a32df,JSON[_0x56d6('0x17')](_0x2dad6c));_0x5d79e0(_0x2dad6c);})[_0x56d6('0x1c')](function(_0x2c9c5f){logger[_0x56d6('0x18')](_0x56d6('0x26'),_0x2c9c5f[_0x56d6('0x1a')],_0x1a32df);_0x4abd04(_this['error'](0x1f4,_0x2c9c5f['message']));});});}; \ No newline at end of file diff --git a/server/api/faxInteraction/faxInteraction.socket.js b/server/api/faxInteraction/faxInteraction.socket.js new file mode 100644 index 0000000..0e5781a --- /dev/null +++ b/server/api/faxInteraction/faxInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7e8b=['remove','emit','removeListener','length','./faxInteraction.events'];(function(_0x396fdf,_0x928686){var _0x1c0868=function(_0x35efc9){while(--_0x35efc9){_0x396fdf['push'](_0x396fdf['shift']());}};_0x1c0868(++_0x928686);}(_0x7e8b,0x72));var _0xb7e8=function(_0x2a702f,_0x377aa7){_0x2a702f=_0x2a702f-0x0;var _0x52106f=_0x7e8b[_0x2a702f];return _0x52106f;};'use strict';var FaxInteractionEvents=require(_0xb7e8('0x0'));var events=['save',_0xb7e8('0x1'),'update'];function createListener(_0x5a4da0,_0x22571e){return function(_0x13cbdd){_0x22571e[_0xb7e8('0x2')](_0x5a4da0,_0x13cbdd);};}function removeListener(_0x3b1418,_0x3ef1e1){return function(){FaxInteractionEvents[_0xb7e8('0x3')](_0x3b1418,_0x3ef1e1);};}exports['register']=function(_0x41dbac){for(var _0x56203c=0x0,_0xf36f42=events[_0xb7e8('0x4')];_0x56203c<_0xf36f42;_0x56203c++){var _0x12dd3a=events[_0x56203c];var _0x4348c0=createListener('faxInteraction:'+_0x12dd3a,_0x41dbac);FaxInteractionEvents['on'](_0x12dd3a,_0x4348c0);}}; \ No newline at end of file diff --git a/server/api/faxInteraction/index.js b/server/api/faxInteraction/index.js new file mode 100644 index 0000000..7b80499 --- /dev/null +++ b/server/api/faxInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0f50=['/:id/download','create','post','addMessage','/:id/tags','tracked','fax','faxinteraction:addtags','addTags','put','faxinteraction:update','delete','faxinteraction:destroy','destroy','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/interaction/service','../../config/environment','./faxInteraction.controller','get','index','/describe','isAuthenticated','describe','/:id','show','/:id/messages'];(function(_0x24c46d,_0x52b2ac){var _0x127ad6=function(_0x16ae2a){while(--_0x16ae2a){_0x24c46d['push'](_0x24c46d['shift']());}};_0x127ad6(++_0x52b2ac);}(_0x0f50,0x6f));var _0x00f5=function(_0x474f01,_0x352417){_0x474f01=_0x474f01-0x0;var _0x15e5f4=_0x0f50[_0x474f01];return _0x15e5f4;};'use strict';var multer=require('multer');var util=require(_0x00f5('0x0'));var path=require(_0x00f5('0x1'));var timeout=require(_0x00f5('0x2'));var express=require(_0x00f5('0x3'));var router=express[_0x00f5('0x4')]();var fs_extra=require(_0x00f5('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x00f5('0x6'));var config=require(_0x00f5('0x7'));var controller=require(_0x00f5('0x8'));router[_0x00f5('0x9')]('/',auth['isAuthenticated'](),controller[_0x00f5('0xa')]);router[_0x00f5('0x9')](_0x00f5('0xb'),auth[_0x00f5('0xc')](),controller[_0x00f5('0xd')]);router[_0x00f5('0x9')](_0x00f5('0xe'),auth['isAuthenticated'](),controller[_0x00f5('0xf')]);router[_0x00f5('0x9')](_0x00f5('0x10'),auth[_0x00f5('0xc')](),controller['getMessages']);router[_0x00f5('0x9')](_0x00f5('0x11'),auth[_0x00f5('0xc')](),controller['download']);router['post']('/',auth[_0x00f5('0xc')](),controller[_0x00f5('0x12')]);router[_0x00f5('0x13')](_0x00f5('0x10'),auth[_0x00f5('0xc')](),controller[_0x00f5('0x14')]);router[_0x00f5('0x13')](_0x00f5('0x15'),auth[_0x00f5('0xc')](),interaction[_0x00f5('0x16')](_0x00f5('0x17'),_0x00f5('0x18')),controller[_0x00f5('0x19')]);router[_0x00f5('0x1a')](_0x00f5('0xe'),auth[_0x00f5('0xc')](),interaction['tracked'](_0x00f5('0x17'),_0x00f5('0x1b')),controller['update']);router[_0x00f5('0x1c')](_0x00f5('0xe'),auth[_0x00f5('0xc')](),interaction[_0x00f5('0x16')](_0x00f5('0x17'),_0x00f5('0x1d')),controller[_0x00f5('0x1e')]);router[_0x00f5('0x1c')](_0x00f5('0x15'),auth[_0x00f5('0xc')](),controller['removeTags']);module[_0x00f5('0x1f')]=router; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.attributes.js b/server/api/faxMessage/faxMessage.attributes.js new file mode 100644 index 0000000..ecd1c9d --- /dev/null +++ b/server/api/faxMessage/faxMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe107=['TEXT','medium','BOOLEAN','out','DATE','sequelize'];(function(_0x1c15a4,_0x32948a){var _0x1ae3be=function(_0x459c93){while(--_0x459c93){_0x1c15a4['push'](_0x1c15a4['shift']());}};_0x1ae3be(++_0x32948a);}(_0xe107,0xb3));var _0x7e10=function(_0x48b37a,_0x3e41d2){_0x48b37a=_0x48b37a-0x0;var _0x373c73=_0xe107[_0x48b37a];return _0x373c73;};'use strict';var Sequelize=require(_0x7e10('0x0'));module['exports']={'body':{'type':Sequelize[_0x7e10('0x1')](_0x7e10('0x2')),'allowNull':![]},'read':{'type':Sequelize[_0x7e10('0x3')],'defaultValue':![]},'direction':{'type':Sequelize['ENUM']('in',_0x7e10('0x4')),'defaultValue':'out','allowNull':![]},'failMessage':{'type':Sequelize['TEXT'],'defaultValue':null},'readAt':{'type':Sequelize[_0x7e10('0x5')]}}; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.controller.js b/server/api/faxMessage/faxMessage.controller.js new file mode 100644 index 0000000..f80c2a3 --- /dev/null +++ b/server/api/faxMessage/faxMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4469=['intersection','fields','attributes','length','hasOwnProperty','order','sort','where','filters','pick','filter','options','includeAll','rows','catch','show','params','rawAttributes','include','merge','find','update','body','describe','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','FaxInteractionId','isNil','read1stAt','interaction','role','null','AcceptMessage','sequelize','QueryTypes','SELECT','contact','fullname','email','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','Sequelize','User','internal','rejectmessage','create','CmContact','findOne','ContactId','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','root','files','attachments','join','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../mysqldb','localhost','socket.io-emitter','redis','register','jayson/promise','client','http','then','info','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FaxMessage,\x20%s,\x20%s','result','status','end','json','offset','limit','undefined','count','set','apply','reject','save','sendStatus','stack','name','send','index','map','FaxMessage','fieldName','type','key','query','keys','model'];(function(_0x89f8ed,_0x235a5d){var _0x33cdae=function(_0x4eb382){while(--_0x4eb382){_0x89f8ed['push'](_0x89f8ed['shift']());}};_0x33cdae(++_0x235a5d);}(_0x4469,0x1f1));var _0x9446=function(_0x557286,_0x8c1f6f){_0x557286=_0x557286-0x0;var _0x5ec9c4=_0x4469[_0x557286];return _0x5ec9c4;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9446('0x0'));var jsonpatch=require(_0x9446('0x1'));var rp=require(_0x9446('0x2'));var moment=require('moment');var BPromise=require(_0x9446('0x3'));var Mustache=require(_0x9446('0x4'));var util=require(_0x9446('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0x9446('0x6'));var ejs=require(_0x9446('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9446('0x8'));var squel=require(_0x9446('0x9'));var crypto=require(_0x9446('0xa'));var jsforce=require(_0x9446('0xb'));var deskjs=require(_0x9446('0xc'));var toCsv=require(_0x9446('0x6'));var querystring=require(_0x9446('0xd'));var Papa=require(_0x9446('0xe'));var Redis=require('ioredis');var authService=require(_0x9446('0xf'));var qs=require(_0x9446('0x10'));var as=require(_0x9446('0x11'));var hardwareService=require(_0x9446('0x12'));var logger=require(_0x9446('0x13'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x9446('0x14'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0x9446('0x15'),'port':0x18eb});var socket=require(_0x9446('0x16'))(new Redis(config[_0x9446('0x17')]));require('./faxMessage.socket')[_0x9446('0x18')](socket);var jayson=require(_0x9446('0x19'));var client=jayson[_0x9446('0x1a')][_0x9446('0x1b')]({'port':0x232c});var client9002=jayson[_0x9446('0x1a')][_0x9446('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x4e5d36,_0x570d88,_0x38162f,_0x34ed07){return new BPromise(function(_0x135d7a,_0x2f4a29){var _0x474e93=_0x34ed07||client;return _0x474e93['request'](_0x4e5d36,_0x38162f)[_0x9446('0x1c')](function(_0x2ef100){logger[_0x9446('0x1d')]('FaxMessage,\x20%s,\x20%s',_0x570d88,_0x9446('0x1e'));logger[_0x9446('0x1f')](_0x9446('0x20'),_0x570d88,_0x9446('0x1e'),JSON[_0x9446('0x21')](_0x2ef100));if(_0x2ef100[_0x9446('0x22')]){if(_0x2ef100[_0x9446('0x22')][_0x9446('0x23')]===0x1f4){logger[_0x9446('0x22')]('FaxMessage,\x20%s,\x20%s',_0x570d88,_0x2ef100[_0x9446('0x22')]['message']);return _0x2f4a29(_0x2ef100['error'][_0x9446('0x24')]);}logger['error']('FaxMessage,\x20%s,\x20%s',_0x570d88,_0x2ef100['error'][_0x9446('0x24')]);return _0x135d7a(_0x2ef100[_0x9446('0x22')][_0x9446('0x24')]);}else{logger[_0x9446('0x1d')](_0x9446('0x25'),_0x570d88,'request\x20sent');_0x135d7a(_0x2ef100[_0x9446('0x26')][_0x9446('0x24')]);}})['catch'](function(_0x3d69b7){logger[_0x9446('0x22')](_0x9446('0x25'),_0x570d88,_0x3d69b7);_0x2f4a29(_0x3d69b7);});});}function respondWithStatusCode(_0x602b3e,_0x237aba){_0x237aba=_0x237aba||0xcc;return function(_0x51cf73){if(_0x51cf73){return _0x602b3e['sendStatus'](_0x237aba);}return _0x602b3e[_0x9446('0x27')](_0x237aba)[_0x9446('0x28')]();};}function respondWithResult(_0x3519bc,_0x538096){_0x538096=_0x538096||0xc8;return function(_0x22ded0){if(_0x22ded0){return _0x3519bc[_0x9446('0x27')](_0x538096)[_0x9446('0x29')](_0x22ded0);}};}function respondWithFilteredResult(_0x51142c,_0x35ac96){return function(_0x355f45){if(_0x355f45){var _0x404c80=typeof _0x35ac96[_0x9446('0x2a')]==='undefined'&&typeof _0x35ac96[_0x9446('0x2b')]===_0x9446('0x2c');var _0x429dec=_0x355f45['count'];var _0x256728=_0x404c80?0x0:_0x35ac96[_0x9446('0x2a')];var _0x5ae619=_0x404c80?_0x355f45[_0x9446('0x2d')]:_0x35ac96[_0x9446('0x2a')]+_0x35ac96[_0x9446('0x2b')];var _0x1c9e7f;if(_0x5ae619>=_0x429dec){_0x5ae619=_0x429dec;_0x1c9e7f=0xc8;}else{_0x1c9e7f=0xce;}_0x51142c[_0x9446('0x27')](_0x1c9e7f);return _0x51142c[_0x9446('0x2e')]('Content-Range',_0x256728+'-'+_0x5ae619+'/'+_0x429dec)['json'](_0x355f45);}return null;};}function patchUpdates(_0x5bbdca){return function(_0x2d721b){try{jsonpatch[_0x9446('0x2f')](_0x2d721b,_0x5bbdca,!![]);}catch(_0x5e9dd5){return BPromise[_0x9446('0x30')](_0x5e9dd5);}return _0x2d721b[_0x9446('0x31')]();};}function saveUpdates(_0x3042ba,_0x4d8830){return function(_0x428509){if(_0x428509){return _0x428509['update'](_0x3042ba)[_0x9446('0x1c')](function(_0x278ebb){return _0x278ebb;});}return null;};}function removeEntity(_0x4f17cf,_0x5f278f){return function(_0x4c1dcb){if(_0x4c1dcb){return _0x4c1dcb['destroy']()[_0x9446('0x1c')](function(){_0x4f17cf[_0x9446('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5c62c2,_0x11e648){return function(_0x1b4014){if(!_0x1b4014){_0x5c62c2[_0x9446('0x32')](0x194);}return _0x1b4014;};}function handleError(_0x50ab03,_0x51ac8b){_0x51ac8b=_0x51ac8b||0x1f4;return function(_0x311bbc){logger[_0x9446('0x22')](_0x311bbc[_0x9446('0x33')]);if(_0x311bbc[_0x9446('0x34')]){delete _0x311bbc[_0x9446('0x34')];}_0x50ab03[_0x9446('0x27')](_0x51ac8b)[_0x9446('0x35')](_0x311bbc);};}exports[_0x9446('0x36')]=function(_0x268d9b,_0x54bd49){var _0xe8a8eb={},_0x1dea04={},_0x16546b={'count':0x0,'rows':[]};var _0x420325=_[_0x9446('0x37')](db[_0x9446('0x38')]['rawAttributes'],function(_0x412404){return{'name':_0x412404[_0x9446('0x39')],'type':_0x412404[_0x9446('0x3a')][_0x9446('0x3b')]};});_0x1dea04['model']=_['map'](_0x420325,'name');_0x1dea04[_0x9446('0x3c')]=_[_0x9446('0x3d')](_0x268d9b[_0x9446('0x3c')]);_0x1dea04['filters']=_['intersection'](_0x1dea04[_0x9446('0x3e')],_0x1dea04[_0x9446('0x3c')]);_0xe8a8eb['attributes']=_[_0x9446('0x3f')](_0x1dea04[_0x9446('0x3e')],qs[_0x9446('0x40')](_0x268d9b[_0x9446('0x3c')][_0x9446('0x40')]));_0xe8a8eb[_0x9446('0x41')]=_0xe8a8eb[_0x9446('0x41')][_0x9446('0x42')]?_0xe8a8eb[_0x9446('0x41')]:_0x1dea04[_0x9446('0x3e')];if(!_0x268d9b[_0x9446('0x3c')][_0x9446('0x43')]('nolimit')){_0xe8a8eb[_0x9446('0x2b')]=qs[_0x9446('0x2b')](_0x268d9b[_0x9446('0x3c')][_0x9446('0x2b')]);_0xe8a8eb[_0x9446('0x2a')]=qs[_0x9446('0x2a')](_0x268d9b['query'][_0x9446('0x2a')]);}_0xe8a8eb[_0x9446('0x44')]=qs[_0x9446('0x45')](_0x268d9b['query'][_0x9446('0x45')]);_0xe8a8eb[_0x9446('0x46')]=qs[_0x9446('0x47')](_[_0x9446('0x48')](_0x268d9b[_0x9446('0x3c')],_0x1dea04[_0x9446('0x47')]),_0x420325);if(_0x268d9b[_0x9446('0x3c')][_0x9446('0x49')]){_0xe8a8eb[_0x9446('0x46')]=_['merge'](_0xe8a8eb['where'],{'$or':_[_0x9446('0x37')](_0x420325,function(_0x887035){if(_0x887035[_0x9446('0x3a')]!=='VIRTUAL'){var _0x28b34d={};_0x28b34d[_0x887035['name']]={'$like':'%'+_0x268d9b[_0x9446('0x3c')][_0x9446('0x49')]+'%'};return _0x28b34d;}})});}_0xe8a8eb=_['merge']({},_0xe8a8eb,_0x268d9b[_0x9446('0x4a')]);var _0x250c21={'where':_0xe8a8eb[_0x9446('0x46')]};return db[_0x9446('0x38')][_0x9446('0x2d')](_0x250c21)[_0x9446('0x1c')](function(_0x38dfa2){_0x16546b[_0x9446('0x2d')]=_0x38dfa2;if(_0x268d9b[_0x9446('0x3c')][_0x9446('0x4b')]){_0xe8a8eb['include']=[{'all':!![]}];}return db[_0x9446('0x38')]['findAll'](_0xe8a8eb);})['then'](function(_0x399b00){_0x16546b[_0x9446('0x4c')]=_0x399b00;return _0x16546b;})['then'](respondWithFilteredResult(_0x54bd49,_0xe8a8eb))[_0x9446('0x4d')](handleError(_0x54bd49,null));};exports[_0x9446('0x4e')]=function(_0x1d3f9f,_0x8939e6){var _0x1d3889={'raw':!![],'where':{'id':_0x1d3f9f[_0x9446('0x4f')]['id']}},_0x47c133={};_0x47c133[_0x9446('0x3e')]=_[_0x9446('0x3d')](db['FaxMessage'][_0x9446('0x50')]);_0x47c133[_0x9446('0x3c')]=_[_0x9446('0x3d')](_0x1d3f9f[_0x9446('0x3c')]);_0x47c133[_0x9446('0x47')]=_[_0x9446('0x3f')](_0x47c133[_0x9446('0x3e')],_0x47c133[_0x9446('0x3c')]);_0x1d3889[_0x9446('0x41')]=_[_0x9446('0x3f')](_0x47c133[_0x9446('0x3e')],qs[_0x9446('0x40')](_0x1d3f9f[_0x9446('0x3c')]['fields']));_0x1d3889[_0x9446('0x41')]=_0x1d3889[_0x9446('0x41')][_0x9446('0x42')]?_0x1d3889[_0x9446('0x41')]:_0x47c133[_0x9446('0x3e')];if(_0x1d3f9f[_0x9446('0x3c')][_0x9446('0x4b')]){_0x1d3889[_0x9446('0x51')]=[{'all':!![]}];}_0x1d3889=_[_0x9446('0x52')]({},_0x1d3889,_0x1d3f9f[_0x9446('0x4a')]);return db[_0x9446('0x38')][_0x9446('0x53')](_0x1d3889)[_0x9446('0x1c')](handleEntityNotFound(_0x8939e6,null))[_0x9446('0x1c')](respondWithResult(_0x8939e6,null))[_0x9446('0x4d')](handleError(_0x8939e6,null));};exports[_0x9446('0x54')]=function(_0x53e9d2,_0x2058d8){if(_0x53e9d2[_0x9446('0x55')]['id']){delete _0x53e9d2[_0x9446('0x55')]['id'];}return db[_0x9446('0x38')]['find']({'where':{'id':_0x53e9d2[_0x9446('0x4f')]['id']}})[_0x9446('0x1c')](handleEntityNotFound(_0x2058d8,null))[_0x9446('0x1c')](saveUpdates(_0x53e9d2[_0x9446('0x55')],null))[_0x9446('0x1c')](respondWithResult(_0x2058d8,null))[_0x9446('0x4d')](handleError(_0x2058d8,null));};exports['destroy']=function(_0x152e6e,_0x2b14c8){return db[_0x9446('0x38')][_0x9446('0x53')]({'where':{'id':_0x152e6e['params']['id']}})[_0x9446('0x1c')](handleEntityNotFound(_0x2b14c8,null))[_0x9446('0x1c')](removeEntity(_0x2b14c8,null))[_0x9446('0x4d')](handleError(_0x2b14c8,null));};exports[_0x9446('0x56')]=function(_0x16528c,_0x2b04b4){return db['FaxMessage']['describe']()[_0x9446('0x1c')](respondWithResult(_0x2b04b4,null))[_0x9446('0x4d')](handleError(_0x2b04b4,null));};var interaction_log=require(_0x9446('0x13'))('fax-interactions');exports[_0x9446('0x57')]=function(_0x43f543,_0x597d93,_0x3aae50){var _0x1519ed={'agent':{},'channel':_0x9446('0x58')};if(_0x43f543['body']['id']){delete _0x43f543[_0x9446('0x55')]['id'];}_0x43f543[_0x9446('0x55')][_0x9446('0x59')]=!![];_0x43f543[_0x9446('0x55')][_0x9446('0x5a')]=moment()[_0x9446('0x5b')](_0x9446('0x5c'));_0x43f543['body'][_0x9446('0x5d')]=_0x43f543[_0x9446('0x55')][_0x9446('0x5d')]||_0x43f543[_0x9446('0x5e')]['id'];_0x1519ed[_0x9446('0x5f')]['id']=_0x43f543[_0x9446('0x55')][_0x9446('0x5d')];return db['FaxMessage'][_0x9446('0x53')]({'where':{'id':_0x43f543[_0x9446('0x4f')]['id'],'UserId':null}})[_0x9446('0x1c')](handleEntityNotFound(_0x597d93,null))[_0x9446('0x1c')](saveUpdates(_0x43f543[_0x9446('0x55')],null))[_0x9446('0x1c')](function(_0xe5da15){if(_0xe5da15){_0x1519ed[_0x9446('0x24')]=_0xe5da15[_0x9446('0x60')]({'plain':!![]});return db['FaxInteraction']['find']({'where':{'id':_0xe5da15[_0x9446('0x61')]}});}return null;})[_0x9446('0x1c')](handleEntityNotFound(_0x597d93,null))[_0x9446('0x1c')](function(_0x8c37de){if(_0x8c37de){return _0x8c37de[_0x9446('0x54')]({'UserId':_0x43f543['body'][_0x9446('0x5d')],'read1stAt':_[_0x9446('0x62')](_0x8c37de[_0x9446('0x63')])?moment()[_0x9446('0x5b')](_0x9446('0x5c')):undefined});}return null;})[_0x9446('0x1c')](function(_0x31065c){if(_0x31065c){_0x1519ed[_0x9446('0x64')]=_0x31065c[_0x9446('0x60')]({'plain':!![]});interaction_log[_0x9446('0x1d')]('[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x43f543[_0x9446('0x5e')]['id'],_0x43f543[_0x9446('0x5e')][_0x9446('0x34')],_0x43f543[_0x9446('0x5e')][_0x9446('0x65')],_0x1519ed['interaction']['id'],_0x43f543[_0x9446('0x55')]?JSON['stringify'](_0x43f543[_0x9446('0x55')]):_0x9446('0x66'));return respondWithRpcPromise(_0x9446('0x67'),'acceptMessage',_0x1519ed);}return null;})['then'](function(_0x5b8099){var _0x439b87='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x5b8099[_0x9446('0x24')]['ContactId'];return db[_0x9446('0x68')]['query'](_0x439b87,{'type':db['Sequelize'][_0x9446('0x69')][_0x9446('0x6a')],'raw':!![]})['then'](function(_0x54dd41){return _0x54dd41;});})[_0x9446('0x1c')](function(_0x45d5f9){if(_0x45d5f9){_0x1519ed[_0x9446('0x24')][_0x9446('0x6b')]=_0x45d5f9[0x0];if(!_0x43f543['body'][_0x9446('0x5d')])return;return db['User'][_0x9446('0x53')]({'where':{'id':_0x43f543[_0x9446('0x55')][_0x9446('0x5d')],'role':_0x9446('0x5f')},'attributes':['id','name',_0x9446('0x6c'),_0x9446('0x6d'),'internal'],'raw':!![]});}return null;})[_0x9446('0x1c')](function(_0x59b1e9){if(!_0x59b1e9)return null;_0x1519ed['message'][_0x9446('0x5f')]=_0x59b1e9;return _0x1519ed;})['then'](function(_0x1236ce){if(_0x1236ce){if(_0x43f543[_0x9446('0x55')][_0x9446('0x6e')]){_0x1519ed[_0x9446('0x24')][_0x9446('0x6f')]=util[_0x9446('0x5b')](_0x9446('0x70'),_0x43f543[_0x9446('0x5e')][_0x9446('0x34')]);_0x1519ed['message'][_0x9446('0x71')]=_0x1519ed['channel'];_0x1519ed[_0x9446('0x24')][_0x9446('0x72')]=_0x1519ed[_0x9446('0x71')];_0x1519ed['message'][_0x9446('0x73')]=_0x9446('0x57');return respondWithRpcPromise('EventManager',_0x9446('0x74'),{'event':'acceptmessage','message':_0x1519ed['message']},client9002)[_0x9446('0x1c')](function(){return _0x1519ed;});}return _0x1519ed;}return null;})['then'](respondWithResult(_0x597d93,null))[_0x9446('0x4d')](handleError(_0x597d93,null));};var interaction_log=require('../../config/logger')('fax-interactions');exports[_0x9446('0x30')]=function(_0x36994b,_0x3af6a3,_0x47d8ea){var _0x29a8bf={'agent':{},'channel':_0x9446('0x58')};if(_0x36994b[_0x9446('0x55')]['id']){delete _0x36994b[_0x9446('0x55')]['id'];}_0x36994b[_0x9446('0x55')][_0x9446('0x5d')]=_0x36994b[_0x9446('0x55')][_0x9446('0x5d')]||_0x36994b['user']['id'];_0x29a8bf['agent']['id']=_0x36994b[_0x9446('0x55')][_0x9446('0x5d')];return db['FaxMessage']['find']({'where':{'id':_0x36994b['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x3af6a3,null))['then'](function(_0x3c1221){if(_0x3c1221){_0x29a8bf[_0x9446('0x24')]=_0x3c1221[_0x9446('0x60')]({'plain':!![]});return db[_0x9446('0x75')][_0x9446('0x53')]({'where':{'id':_0x3c1221['FaxInteractionId']}});}return null;})[_0x9446('0x1c')](handleEntityNotFound(_0x3af6a3,null))[_0x9446('0x1c')](function(_0x21c726){if(_0x21c726){_0x29a8bf[_0x9446('0x64')]=_0x21c726[_0x9446('0x60')]({'plain':!![]});interaction_log['info'](_0x9446('0x76'),_0x36994b['user']['id'],_0x36994b[_0x9446('0x5e')][_0x9446('0x34')],_0x36994b['user'][_0x9446('0x65')],_0x29a8bf[_0x9446('0x64')]['id'],_0x36994b[_0x9446('0x55')]?JSON['stringify'](_0x36994b[_0x9446('0x55')]):_0x9446('0x66'));return respondWithRpcPromise(_0x9446('0x77'),'rejectMessage',_0x29a8bf);}return null;})[_0x9446('0x1c')](function(_0x30a15c){var _0x54b916=_0x9446('0x78')+_0x30a15c[_0x9446('0x24')]['ContactId'];return db[_0x9446('0x68')][_0x9446('0x3c')](_0x54b916,{'type':db[_0x9446('0x79')][_0x9446('0x69')][_0x9446('0x6a')],'raw':!![]})[_0x9446('0x1c')](function(_0x290dfd){return _0x290dfd;});})[_0x9446('0x1c')](function(_0xbf849e){if(_0xbf849e){_0x29a8bf[_0x9446('0x24')][_0x9446('0x6b')]=_0xbf849e[0x0];if(!_0x36994b[_0x9446('0x55')][_0x9446('0x5d')])return;return db[_0x9446('0x7a')]['find']({'where':{'id':_0x36994b[_0x9446('0x55')][_0x9446('0x5d')],'role':_0x9446('0x5f')},'attributes':['id',_0x9446('0x34'),_0x9446('0x6c'),'email',_0x9446('0x7b')],'raw':!![]});}return null;})[_0x9446('0x1c')](function(_0x2bfd1d){if(!_0x2bfd1d)return null;_0x29a8bf['message'][_0x9446('0x5f')]=_0x2bfd1d;return _0x29a8bf;})[_0x9446('0x1c')](function(_0x1b0f0d){if(_0x1b0f0d){_0x1b0f0d[_0x9446('0x24')][_0x9446('0x6f')]=util[_0x9446('0x5b')]('SIP/%s',_0x36994b[_0x9446('0x5e')]['name']);_0x1b0f0d[_0x9446('0x24')][_0x9446('0x71')]=_0x29a8bf['channel'];_0x1b0f0d[_0x9446('0x24')][_0x9446('0x72')]=_0x29a8bf[_0x9446('0x71')];_0x1b0f0d[_0x9446('0x24')]['event']=_0x9446('0x30');respondWithRpcPromise(_0x9446('0x74'),'EventManager',{'event':_0x9446('0x7c'),'message':_0x1b0f0d['message']},client9002);return _0x29a8bf;}return null;})['then'](respondWithResult(_0x3af6a3,null))[_0x9446('0x4d')](handleError(_0x3af6a3,null));};exports['create']=function(_0x474506,_0x36e15a){var _0x520a46;return db['FaxMessage'][_0x9446('0x7d')](_0x474506[_0x9446('0x55')],{})[_0x9446('0x1c')](function(_0x16a8e3){_0x520a46=_0x16a8e3;return db[_0x9446('0x7e')][_0x9446('0x7f')]({'where':{'id':_0x520a46[_0x9446('0x80')]}});})[_0x9446('0x1c')](function(_0x341268){if(_[_0x9446('0x62')](_0x341268)){return;}else{_0x520a46[_0x9446('0x58')]=_0x341268[_0x9446('0x58')];return db[_0x9446('0x81')][_0x9446('0x7f')]({'where':{'id':_0x520a46[_0x9446('0x82')]}});}})['then'](function(_0x1c579e){return respondWithRpcPromise('SendFax',_0x9446('0x83'),{'FaxAccountId':_[_0x9446('0x62')](_0x474506['body'])?undefined:_0x474506['body'][_0x9446('0x84')],'path':_['isNil'](_0x1c579e)?undefined:util[_0x9446('0x5b')](_0x9446('0x85'),_0x1c579e[_0x9446('0x86')]),'fax':_[_0x9446('0x62')](_0x520a46[_0x9446('0x58')])?undefined:_0x520a46[_0x9446('0x58')],'AttachmentId':_0x520a46[_0x9446('0x82')]},client9002);})[_0x9446('0x1c')](respondWithResult(_0x36e15a,0xc9))[_0x9446('0x4d')](handleError(_0x36e15a,null));};exports[_0x9446('0x87')]=function(_0x3cb913,_0x1f98fb){var _0x2992b9=path['join'](config[_0x9446('0x88')],'server',_0x9446('0x89'),_0x9446('0x8a'));return db['FaxMessage'][_0x9446('0x53')]({'where':{'id':_0x3cb913[_0x9446('0x4f')]['id']},'include':[{'model':db[_0x9446('0x81')],'as':_0x9446('0x81')}]})[_0x9446('0x1c')](handleEntityNotFound(_0x1f98fb,null))[_0x9446('0x1c')](function(_0x372cf4){if(_0x372cf4){return _0x1f98fb[_0x9446('0x87')](path[_0x9446('0x8b')](_0x2992b9,_0x372cf4[_0x9446('0x81')][_0x9446('0x86')]));}})['catch'](handleError(_0x1f98fb,null));}; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.events.js b/server/api/faxMessage/faxMessage.events.js new file mode 100644 index 0000000..e7ce966 --- /dev/null +++ b/server/api/faxMessage/faxMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5a99=['emit','hook','exports','events','../../mysqldb','FaxMessage','save','update','remove'];(function(_0x2db3b3,_0x12b434){var _0x3201b0=function(_0x198a1f){while(--_0x198a1f){_0x2db3b3['push'](_0x2db3b3['shift']());}};_0x3201b0(++_0x12b434);}(_0x5a99,0xc9));var _0x95a9=function(_0x106c82,_0x2ea593){_0x106c82=_0x106c82-0x0;var _0x461376=_0x5a99[_0x106c82];return _0x461376;};'use strict';var EventEmitter=require(_0x95a9('0x0'));var FaxMessage=require(_0x95a9('0x1'))['db'][_0x95a9('0x2')];var FaxMessageEvents=new EventEmitter();FaxMessageEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x95a9('0x3'),'afterUpdate':_0x95a9('0x4'),'afterDestroy':_0x95a9('0x5')};function emitEvent(_0x475a71){return function(_0x4b30e2,_0x2c8e52,_0x3ff50a){FaxMessageEvents[_0x95a9('0x6')](_0x475a71+':'+_0x4b30e2['id'],_0x4b30e2);FaxMessageEvents[_0x95a9('0x6')](_0x475a71,_0x4b30e2);_0x3ff50a(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];FaxMessage[_0x95a9('0x7')](e,emitEvent(event));}}module[_0x95a9('0x8')]=FaxMessageEvents; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.model.js b/server/api/faxMessage/faxMessage.model.js new file mode 100644 index 0000000..ded601c --- /dev/null +++ b/server/api/faxMessage/faxMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8761=['models','get','direction','toLowerCase','out','secret','isNil','UserId','FaxInteraction','findOne','FaxInteractionId','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','bluebird','request-promise','path','rimraf','../../config/environment','./faxMessage.attributes','exports','define','fax_messages','fti_fax_messages','body','FULLTEXT'];(function(_0x44cb92,_0x59afa3){var _0x56b9e6=function(_0x2841e0){while(--_0x2841e0){_0x44cb92['push'](_0x44cb92['shift']());}};_0x56b9e6(++_0x59afa3);}(_0x8761,0x166));var _0x1876=function(_0xd4f1ad,_0x4cea69){_0xd4f1ad=_0xd4f1ad-0x0;var _0x116c2f=_0x8761[_0xd4f1ad];return _0x116c2f;};'use strict';var _=require('lodash');var util=require(_0x1876('0x0'));var logger=require(_0x1876('0x1'))('api');var moment=require('moment');var BPromise=require(_0x1876('0x2'));var rp=require(_0x1876('0x3'));var fs=require('fs');var path=require(_0x1876('0x4'));var rimraf=require(_0x1876('0x5'));var config=require(_0x1876('0x6'));var attributes=require(_0x1876('0x7'));module[_0x1876('0x8')]=function(_0x29e74a,_0x2105c0){return _0x29e74a[_0x1876('0x9')]('FaxMessage',attributes,{'tableName':_0x1876('0xa'),'paranoid':![],'indexes':[{'name':_0x1876('0xb'),'fields':[_0x1876('0xc')],'type':_0x1876('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x284243,_0xc197b6,_0x6660a3){var _0x5de806=_0x29e74a[_0x1876('0xe')];var _0x265d4a=_0x284243[_0x1876('0xf')]({'plain':!![]});if(_0x265d4a[_0x1876('0x10')][_0x1876('0x11')]()==='in'||_0x265d4a[_0x1876('0x10')][_0x1876('0x11')]()===_0x1876('0x12')&&!_0x265d4a[_0x1876('0x13')]&&!_[_0x1876('0x14')](_0x265d4a[_0x1876('0x15')])){_0x5de806[_0x1876('0x16')][_0x1876('0x17')]({'where':{'id':_0x265d4a[_0x1876('0x18')]}})['then'](function(_0x3c0fa0){if(_0x3c0fa0){_0x3c0fa0[_0x1876('0x19')]({'lastMsgAt':_0x265d4a[_0x1876('0x1a')],'lastMsgDirection':_0x265d4a['direction'][_0x1876('0x11')]()});}})[_0x1876('0x1b')](function(_0x5d1c88){console[_0x1876('0x1c')](_0x5d1c88);});}_0x6660a3();}},'charset':_0x1876('0x1d'),'collate':_0x1876('0x1e')});}; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.rpc.js b/server/api/faxMessage/faxMessage.rpc.js new file mode 100644 index 0000000..c75b382 --- /dev/null +++ b/server/api/faxMessage/faxMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa8a8=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','request','then','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','FaxMessage','create','body','options','raw','CreateFaxMessage','UpdateFaxMessage','where','attributes','limit','lodash','util','moment','bluebird'];(function(_0x1a36a5,_0x746928){var _0x746243=function(_0x481966){while(--_0x481966){_0x1a36a5['push'](_0x1a36a5['shift']());}};_0x746243(++_0x746928);}(_0xa8a8,0xec));var _0x8a8a=function(_0x4ae8cc,_0xf40f50){_0x4ae8cc=_0x4ae8cc-0x0;var _0x59855b=_0xa8a8[_0x4ae8cc];return _0x59855b;};'use strict';var _=require(_0x8a8a('0x0'));var util=require(_0x8a8a('0x1'));var moment=require(_0x8a8a('0x2'));var BPromise=require(_0x8a8a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8a8a('0x4'));var db=require(_0x8a8a('0x5'))['db'];var utils=require(_0x8a8a('0x6'));var logger=require(_0x8a8a('0x7'))(_0x8a8a('0x8'));var config=require(_0x8a8a('0x9'));var jayson=require(_0x8a8a('0xa'));var client=jayson[_0x8a8a('0xb')][_0x8a8a('0xc')]({'port':0x232a});config[_0x8a8a('0xd')]=_[_0x8a8a('0xe')](config[_0x8a8a('0xd')],{'host':_0x8a8a('0xf'),'port':0x18eb});var socket=require(_0x8a8a('0x10'))(new Redis(config[_0x8a8a('0xd')]));require('./faxMessage.socket')['register'](socket);function respondWithRpcPromise(_0x3c01cd,_0x497b8a,_0x11788d){return new BPromise(function(_0x3d3a00,_0x532621){return client[_0x8a8a('0x11')](_0x3c01cd,_0x11788d)[_0x8a8a('0x12')](function(_0xb13fca){logger['info'](_0x8a8a('0x13'),_0x497b8a,_0x8a8a('0x14'));logger[_0x8a8a('0x15')](_0x8a8a('0x16'),_0x497b8a,'request\x20sent',JSON[_0x8a8a('0x17')](_0xb13fca));if(_0xb13fca['error']){if(_0xb13fca[_0x8a8a('0x18')][_0x8a8a('0x19')]===0x1f4){logger[_0x8a8a('0x18')](_0x8a8a('0x13'),_0x497b8a,_0xb13fca[_0x8a8a('0x18')][_0x8a8a('0x1a')]);return _0x532621(_0xb13fca[_0x8a8a('0x18')]['message']);}logger[_0x8a8a('0x18')]('FaxMessage,\x20%s,\x20%s',_0x497b8a,_0xb13fca[_0x8a8a('0x18')][_0x8a8a('0x1a')]);return _0x3d3a00(_0xb13fca[_0x8a8a('0x18')][_0x8a8a('0x1a')]);}else{logger[_0x8a8a('0x1b')]('FaxMessage,\x20%s,\x20%s',_0x497b8a,_0x8a8a('0x14'));_0x3d3a00(_0xb13fca[_0x8a8a('0x1c')][_0x8a8a('0x1a')]);}})[_0x8a8a('0x1d')](function(_0x299827){logger[_0x8a8a('0x18')]('FaxMessage,\x20%s,\x20%s',_0x497b8a,_0x299827);_0x532621(_0x299827);});});}exports['CreateFaxMessage']=function(_0x5181b2){var _0x4e3d0a=this;return new Promise(function(_0x4a6601,_0x3a9b2f){return db[_0x8a8a('0x1e')][_0x8a8a('0x1f')](_0x5181b2[_0x8a8a('0x20')],{'raw':_0x5181b2[_0x8a8a('0x21')]?_0x5181b2[_0x8a8a('0x21')][_0x8a8a('0x22')]===undefined?!![]:![]:!![]})[_0x8a8a('0x12')](function(_0x25d5d4){logger[_0x8a8a('0x1b')](_0x8a8a('0x23'),_0x5181b2);logger[_0x8a8a('0x15')](_0x8a8a('0x23'),_0x5181b2,JSON[_0x8a8a('0x17')](_0x25d5d4));_0x4a6601(_0x25d5d4);})[_0x8a8a('0x1d')](function(_0x545a38){logger[_0x8a8a('0x18')](_0x8a8a('0x23'),_0x545a38[_0x8a8a('0x1a')],_0x5181b2);_0x3a9b2f(_0x4e3d0a[_0x8a8a('0x18')](0x1f4,_0x545a38[_0x8a8a('0x1a')]));});});};exports[_0x8a8a('0x24')]=function(_0x3aa46d){var _0x5f4dcc=this;return new Promise(function(_0x31d21a,_0x38c1e0){return db[_0x8a8a('0x1e')]['update'](_0x3aa46d['body'],{'raw':_0x3aa46d[_0x8a8a('0x21')]?_0x3aa46d[_0x8a8a('0x21')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3aa46d['options']?_0x3aa46d['options'][_0x8a8a('0x25')]||null:null,'attributes':_0x3aa46d['options']?_0x3aa46d[_0x8a8a('0x21')][_0x8a8a('0x26')]||null:null,'limit':_0x3aa46d['options']?_0x3aa46d[_0x8a8a('0x21')][_0x8a8a('0x27')]||null:null})[_0x8a8a('0x12')](function(_0x8df0cb){logger[_0x8a8a('0x1b')](_0x8a8a('0x24'),_0x3aa46d);logger[_0x8a8a('0x15')](_0x8a8a('0x24'),_0x3aa46d,JSON['stringify'](_0x8df0cb));_0x31d21a(_0x8df0cb);})['catch'](function(_0x56e79e){logger[_0x8a8a('0x18')](_0x8a8a('0x24'),_0x56e79e['message'],_0x3aa46d);_0x38c1e0(_0x5f4dcc[_0x8a8a('0x18')](0x1f4,_0x56e79e[_0x8a8a('0x1a')]));});});}; \ No newline at end of file diff --git a/server/api/faxMessage/faxMessage.socket.js b/server/api/faxMessage/faxMessage.socket.js new file mode 100644 index 0000000..1f4bc7f --- /dev/null +++ b/server/api/faxMessage/faxMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7808=['removeListener','register','length','faxMessage:','./faxMessage.events','save','remove','emit'];(function(_0x5b8f6d,_0x15ecd0){var _0x729fba=function(_0xfeecfc){while(--_0xfeecfc){_0x5b8f6d['push'](_0x5b8f6d['shift']());}};_0x729fba(++_0x15ecd0);}(_0x7808,0x14c));var _0x8780=function(_0x1f3782,_0x2f30d3){_0x1f3782=_0x1f3782-0x0;var _0x334338=_0x7808[_0x1f3782];return _0x334338;};'use strict';var FaxMessageEvents=require(_0x8780('0x0'));var events=[_0x8780('0x1'),_0x8780('0x2'),'update'];function createListener(_0x43539d,_0x47aad5){return function(_0x2d5107){_0x47aad5[_0x8780('0x3')](_0x43539d,_0x2d5107);};}function removeListener(_0x25fdc0,_0x2d6c43){return function(){FaxMessageEvents[_0x8780('0x4')](_0x25fdc0,_0x2d6c43);};}exports[_0x8780('0x5')]=function(_0x147818){for(var _0x1ea952=0x0,_0x58f60f=events[_0x8780('0x6')];_0x1ea952<_0x58f60f;_0x1ea952++){var _0x1dfe59=events[_0x1ea952];var _0x5c932d=createListener(_0x8780('0x7')+_0x1dfe59,_0x147818);FaxMessageEvents['on'](_0x1dfe59,_0x5c932d);}}; \ No newline at end of file diff --git a/server/api/faxMessage/index.js b/server/api/faxMessage/index.js new file mode 100644 index 0000000..1e1d402 --- /dev/null +++ b/server/api/faxMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1be1=['create','put','update','/:id/accept','destroy','exports','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./faxMessage.controller','get','isAuthenticated','describe','/:id','/:id/download','download','post','tracked','faxmessage:create'];(function(_0x60286b,_0x3247c1){var _0x5dff69=function(_0x4ecfcf){while(--_0x4ecfcf){_0x60286b['push'](_0x60286b['shift']());}};_0x5dff69(++_0x3247c1);}(_0x1be1,0x192));var _0x11be=function(_0x57722d,_0x4ad65b){_0x57722d=_0x57722d-0x0;var _0x5f5768=_0x1be1[_0x57722d];return _0x5f5768;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x11be('0x0'));var timeout=require(_0x11be('0x1'));var express=require('express');var router=express[_0x11be('0x2')]();var fs_extra=require(_0x11be('0x3'));var auth=require(_0x11be('0x4'));var interaction=require(_0x11be('0x5'));var config=require('../../config/environment');var controller=require(_0x11be('0x6'));router[_0x11be('0x7')]('/',auth[_0x11be('0x8')](),controller['index']);router[_0x11be('0x7')]('/describe',auth[_0x11be('0x8')](),controller[_0x11be('0x9')]);router[_0x11be('0x7')](_0x11be('0xa'),auth[_0x11be('0x8')](),controller['show']);router[_0x11be('0x7')](_0x11be('0xb'),auth['isAuthenticated'](),controller[_0x11be('0xc')]);router[_0x11be('0xd')]('/',auth[_0x11be('0x8')](),interaction[_0x11be('0xe')]('fax',_0x11be('0xf')),controller[_0x11be('0x10')]);router[_0x11be('0x11')]('/:id',auth[_0x11be('0x8')](),controller[_0x11be('0x12')]);router['put'](_0x11be('0x13'),auth['isAuthenticated'](),controller['accept']);router['put']('/:id/reject',auth['isAuthenticated'](),controller['reject']);router['delete'](_0x11be('0xa'),auth['isAuthenticated'](),controller[_0x11be('0x14')]);module[_0x11be('0x15')]=router; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.attributes.js b/server/api/faxQueue/faxQueue.attributes.js new file mode 100644 index 0000000..743cce8 --- /dev/null +++ b/server/api/faxQueue/faxQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf6fa=['INTEGER','beepall','roundrobin','exports','name','STRING'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xf6fa,0x87));var _0xaf6f=function(_0x126558,_0x143c9a){_0x126558=_0x126558-0x0;var _0x1f6d14=_0xf6fa[_0x126558];return _0x1f6d14;};'use strict';var Sequelize=require('sequelize');module[_0xaf6f('0x0')]={'name':{'type':Sequelize['STRING'],'unique':_0xaf6f('0x1'),'allowNull':![],'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'description':{'type':Sequelize[_0xaf6f('0x2')]},'timeout':{'type':Sequelize[_0xaf6f('0x3')],'allowNull':![],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize['ENUM']('rrmemory',_0xaf6f('0x4'),_0xaf6f('0x5')),'allowNull':![]},'lastAgent':{'type':Sequelize[_0xaf6f('0x3')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.controller.js b/server/api/faxQueue/faxQueue.controller.js new file mode 100644 index 0000000..025ba12 --- /dev/null +++ b/server/api/faxQueue/faxQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0caf=['getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./faxQueue.socket','register','status','end','undefined','limit','count','offset','set','json','apply','reject','save','update','then','destroy','get','FaxQueues','UserProfileResource','sendStatus','error','stack','name','index','map','rawAttributes','fieldName','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','where','merge','type','VIRTUAL','filter','options','FaxQueue','includeAll','include','findAll','rows','show','filters','length','find','catch','create','user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','findOne','FaxQueueId','UserId','agent','faxPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','User','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','UserFaxQueue','findOrCreate','forEach','emit','userFaxQueue:save','select','field','tq.TeamId','team_has_fax_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','toString','QueryTypes','every','TeamId','includes','all','compact','removeTeams','isEmpty','userFaxQueue:remove','addAgents','omit','removeAgents'];(function(_0x539df4,_0x33a85e){var _0x283d08=function(_0x112923){while(--_0x112923){_0x539df4['push'](_0x539df4['shift']());}};_0x283d08(++_0x33a85e);}(_0x0caf,0x94));var _0xf0ca=function(_0x1a75e3,_0x38e4f3){_0x1a75e3=_0x1a75e3-0x0;var _0x5b6815=_0x0caf[_0x1a75e3];return _0x5b6815;};'use strict';var emlformat=require(_0xf0ca('0x0'));var rimraf=require(_0xf0ca('0x1'));var zipdir=require(_0xf0ca('0x2'));var jsonpatch=require(_0xf0ca('0x3'));var rp=require(_0xf0ca('0x4'));var moment=require(_0xf0ca('0x5'));var BPromise=require(_0xf0ca('0x6'));var Mustache=require(_0xf0ca('0x7'));var util=require('util');var path=require(_0xf0ca('0x8'));var sox=require(_0xf0ca('0x9'));var csv=require(_0xf0ca('0xa'));var ejs=require(_0xf0ca('0xb'));var fs=require('fs');var fs_extra=require(_0xf0ca('0xc'));var _=require(_0xf0ca('0xd'));var squel=require(_0xf0ca('0xe'));var crypto=require(_0xf0ca('0xf'));var jsforce=require(_0xf0ca('0x10'));var deskjs=require(_0xf0ca('0x11'));var toCsv=require(_0xf0ca('0xa'));var querystring=require(_0xf0ca('0x12'));var Papa=require(_0xf0ca('0x13'));var Redis=require(_0xf0ca('0x14'));var authService=require(_0xf0ca('0x15'));var qs=require('../../components/parsers/qs');var as=require(_0xf0ca('0x16'));var hardwareService=require(_0xf0ca('0x17'));var logger=require(_0xf0ca('0x18'))(_0xf0ca('0x19'));var utils=require(_0xf0ca('0x1a'));var config=require(_0xf0ca('0x1b'));var licenseUtil=require(_0xf0ca('0x1c'));var db=require(_0xf0ca('0x1d'))['db'];config['redis']=_[_0xf0ca('0x1e')](config[_0xf0ca('0x1f')],{'host':_0xf0ca('0x20'),'port':0x18eb});var socket=require(_0xf0ca('0x21'))(new Redis(config[_0xf0ca('0x1f')]));require(_0xf0ca('0x22'))[_0xf0ca('0x23')](socket);function respondWithStatusCode(_0x5a58aa,_0xecf980){_0xecf980=_0xecf980||0xcc;return function(_0x1962db){if(_0x1962db){return _0x5a58aa['sendStatus'](_0xecf980);}return _0x5a58aa[_0xf0ca('0x24')](_0xecf980)[_0xf0ca('0x25')]();};}function respondWithResult(_0x20b49b,_0x5188a0){_0x5188a0=_0x5188a0||0xc8;return function(_0x1e6243){if(_0x1e6243){return _0x20b49b[_0xf0ca('0x24')](_0x5188a0)['json'](_0x1e6243);}};}function respondWithFilteredResult(_0x53e8a5,_0x34ee44){return function(_0x48906d){if(_0x48906d){var _0x4dedae=typeof _0x34ee44['offset']===_0xf0ca('0x26')&&typeof _0x34ee44[_0xf0ca('0x27')]==='undefined';var _0x32d362=_0x48906d[_0xf0ca('0x28')];var _0x155e92=_0x4dedae?0x0:_0x34ee44[_0xf0ca('0x29')];var _0x1f38c6=_0x4dedae?_0x48906d[_0xf0ca('0x28')]:_0x34ee44[_0xf0ca('0x29')]+_0x34ee44[_0xf0ca('0x27')];var _0x54c012;if(_0x1f38c6>=_0x32d362){_0x1f38c6=_0x32d362;_0x54c012=0xc8;}else{_0x54c012=0xce;}_0x53e8a5[_0xf0ca('0x24')](_0x54c012);return _0x53e8a5[_0xf0ca('0x2a')]('Content-Range',_0x155e92+'-'+_0x1f38c6+'/'+_0x32d362)[_0xf0ca('0x2b')](_0x48906d);}return null;};}function patchUpdates(_0x270928){return function(_0x5d1897){try{jsonpatch[_0xf0ca('0x2c')](_0x5d1897,_0x270928,!![]);}catch(_0x855a93){return BPromise[_0xf0ca('0x2d')](_0x855a93);}return _0x5d1897[_0xf0ca('0x2e')]();};}function saveUpdates(_0x9f62ed,_0x3c141e){return function(_0x57c2aa){if(_0x57c2aa){return _0x57c2aa[_0xf0ca('0x2f')](_0x9f62ed)[_0xf0ca('0x30')](function(_0x11e8d6){return _0x11e8d6;});}return null;};}function removeEntity(_0x11d4d6,_0x45cc37){return function(_0x2433a9){if(_0x2433a9){return _0x2433a9[_0xf0ca('0x31')]()[_0xf0ca('0x30')](function(){var _0x2d3399=_0x2433a9[_0xf0ca('0x32')]({'plain':!![]});var _0x4a902c=_0xf0ca('0x33');return db[_0xf0ca('0x34')]['destroy']({'where':{'type':_0x4a902c,'resourceId':_0x2d3399['id']}})[_0xf0ca('0x30')](function(){return _0x2433a9;});})[_0xf0ca('0x30')](function(){_0x11d4d6[_0xf0ca('0x24')](0xcc)[_0xf0ca('0x25')]();});}};}function handleEntityNotFound(_0x24551f,_0x4c8d59){return function(_0x19b1b9){if(!_0x19b1b9){_0x24551f[_0xf0ca('0x35')](0x194);}return _0x19b1b9;};}function handleError(_0x1a8d06,_0x417a68){_0x417a68=_0x417a68||0x1f4;return function(_0x5a6e71){logger[_0xf0ca('0x36')](_0x5a6e71[_0xf0ca('0x37')]);if(_0x5a6e71[_0xf0ca('0x38')]){delete _0x5a6e71[_0xf0ca('0x38')];}_0x1a8d06[_0xf0ca('0x24')](_0x417a68)['send'](_0x5a6e71);};}exports[_0xf0ca('0x39')]=function(_0x28832f,_0xa067f6){var _0x190370={},_0x143173={},_0x219bce={'count':0x0,'rows':[]};var _0x54c391=_[_0xf0ca('0x3a')](db['FaxQueue'][_0xf0ca('0x3b')],function(_0x5cfa7b){return{'name':_0x5cfa7b[_0xf0ca('0x3c')],'type':_0x5cfa7b['type'][_0xf0ca('0x3d')]};});_0x143173[_0xf0ca('0x3e')]=_['map'](_0x54c391,_0xf0ca('0x38'));_0x143173[_0xf0ca('0x3f')]=_[_0xf0ca('0x40')](_0x28832f[_0xf0ca('0x3f')]);_0x143173['filters']=_[_0xf0ca('0x41')](_0x143173[_0xf0ca('0x3e')],_0x143173[_0xf0ca('0x3f')]);_0x190370[_0xf0ca('0x42')]=_[_0xf0ca('0x41')](_0x143173[_0xf0ca('0x3e')],qs[_0xf0ca('0x43')](_0x28832f[_0xf0ca('0x3f')]['fields']));_0x190370['attributes']=_0x190370['attributes']['length']?_0x190370[_0xf0ca('0x42')]:_0x143173[_0xf0ca('0x3e')];if(!_0x28832f[_0xf0ca('0x3f')][_0xf0ca('0x44')](_0xf0ca('0x45'))){_0x190370['limit']=qs[_0xf0ca('0x27')](_0x28832f[_0xf0ca('0x3f')][_0xf0ca('0x27')]);_0x190370[_0xf0ca('0x29')]=qs['offset'](_0x28832f[_0xf0ca('0x3f')]['offset']);}_0x190370[_0xf0ca('0x46')]=qs[_0xf0ca('0x47')](_0x28832f['query']['sort']);_0x190370['where']=qs['filters'](_[_0xf0ca('0x48')](_0x28832f[_0xf0ca('0x3f')],_0x143173['filters']),_0x54c391);if(_0x28832f[_0xf0ca('0x3f')]['filter']){_0x190370[_0xf0ca('0x49')]=_[_0xf0ca('0x4a')](_0x190370[_0xf0ca('0x49')],{'$or':_['map'](_0x54c391,function(_0x11d59b){if(_0x11d59b[_0xf0ca('0x4b')]!==_0xf0ca('0x4c')){var _0x177318={};_0x177318[_0x11d59b[_0xf0ca('0x38')]]={'$like':'%'+_0x28832f[_0xf0ca('0x3f')][_0xf0ca('0x4d')]+'%'};return _0x177318;}})});}_0x190370=_[_0xf0ca('0x4a')]({},_0x190370,_0x28832f[_0xf0ca('0x4e')]);var _0x20243c={'where':_0x190370['where']};return db[_0xf0ca('0x4f')][_0xf0ca('0x28')](_0x20243c)[_0xf0ca('0x30')](function(_0x3eb8d0){_0x219bce[_0xf0ca('0x28')]=_0x3eb8d0;if(_0x28832f['query'][_0xf0ca('0x50')]){_0x190370[_0xf0ca('0x51')]=[{'all':!![]}];}return db[_0xf0ca('0x4f')][_0xf0ca('0x52')](_0x190370);})[_0xf0ca('0x30')](function(_0x59fa3b){_0x219bce[_0xf0ca('0x53')]=_0x59fa3b;return _0x219bce;})['then'](respondWithFilteredResult(_0xa067f6,_0x190370))['catch'](handleError(_0xa067f6,null));};exports[_0xf0ca('0x54')]=function(_0x525404,_0xa19590){var _0x4097ab={'raw':!![],'where':{'id':_0x525404['params']['id']}},_0x26ded9={};_0x26ded9[_0xf0ca('0x3e')]=_[_0xf0ca('0x40')](db[_0xf0ca('0x4f')][_0xf0ca('0x3b')]);_0x26ded9[_0xf0ca('0x3f')]=_[_0xf0ca('0x40')](_0x525404[_0xf0ca('0x3f')]);_0x26ded9[_0xf0ca('0x55')]=_[_0xf0ca('0x41')](_0x26ded9['model'],_0x26ded9[_0xf0ca('0x3f')]);_0x4097ab[_0xf0ca('0x42')]=_[_0xf0ca('0x41')](_0x26ded9['model'],qs[_0xf0ca('0x43')](_0x525404[_0xf0ca('0x3f')][_0xf0ca('0x43')]));_0x4097ab[_0xf0ca('0x42')]=_0x4097ab[_0xf0ca('0x42')][_0xf0ca('0x56')]?_0x4097ab[_0xf0ca('0x42')]:_0x26ded9[_0xf0ca('0x3e')];if(_0x525404[_0xf0ca('0x3f')][_0xf0ca('0x50')]){_0x4097ab['include']=[{'all':!![]}];}_0x4097ab=_[_0xf0ca('0x4a')]({},_0x4097ab,_0x525404[_0xf0ca('0x4e')]);return db[_0xf0ca('0x4f')][_0xf0ca('0x57')](_0x4097ab)[_0xf0ca('0x30')](handleEntityNotFound(_0xa19590,null))[_0xf0ca('0x30')](respondWithResult(_0xa19590,null))[_0xf0ca('0x58')](handleError(_0xa19590,null));};exports[_0xf0ca('0x59')]=function(_0x22a0ba,_0x578c11){return db[_0xf0ca('0x4f')][_0xf0ca('0x59')](_0x22a0ba['body'],{})[_0xf0ca('0x30')](function(_0x56424f){var _0xcbe72c=_0x22a0ba[_0xf0ca('0x5a')][_0xf0ca('0x32')]({'plain':!![]});if(!_0xcbe72c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xcbe72c[_0xf0ca('0x5b')]===_0xf0ca('0x5a')){var _0x3f77c4=_0x56424f['get']({'plain':!![]});var _0x382901='FaxQueues';return db[_0xf0ca('0x5c')]['find']({'where':{'name':_0x382901,'userProfileId':_0xcbe72c['userProfileId']},'raw':!![]})['then'](function(_0x1883a0){if(_0x1883a0&&_0x1883a0[_0xf0ca('0x5d')]===0x0){return db[_0xf0ca('0x34')][_0xf0ca('0x59')]({'name':_0x3f77c4[_0xf0ca('0x38')],'resourceId':_0x3f77c4['id'],'type':_0x1883a0[_0xf0ca('0x38')],'sectionId':_0x1883a0['id']},{})[_0xf0ca('0x30')](function(){return _0x56424f;});}else{return _0x56424f;}})['catch'](function(_0x9ca603){logger[_0xf0ca('0x36')](_0xf0ca('0x5e'),_0x9ca603);throw _0x9ca603;});}return _0x56424f;})[_0xf0ca('0x30')](respondWithResult(_0x578c11,0xc9))[_0xf0ca('0x58')](handleError(_0x578c11,null));};exports[_0xf0ca('0x2f')]=function(_0x3ef354,_0x1749e5){if(_0x3ef354[_0xf0ca('0x5f')]['id']){delete _0x3ef354['body']['id'];}return db['FaxQueue'][_0xf0ca('0x57')]({'where':{'id':_0x3ef354[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](handleEntityNotFound(_0x1749e5,null))[_0xf0ca('0x30')](saveUpdates(_0x3ef354[_0xf0ca('0x5f')],null))[_0xf0ca('0x30')](respondWithResult(_0x1749e5,null))[_0xf0ca('0x58')](handleError(_0x1749e5,null));};exports[_0xf0ca('0x31')]=function(_0x1e4243,_0x36f2c8){return db['FaxQueue']['find']({'where':{'id':_0x1e4243[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](handleEntityNotFound(_0x36f2c8,null))[_0xf0ca('0x30')](removeEntity(_0x36f2c8,null))[_0xf0ca('0x58')](handleError(_0x36f2c8,null));};exports[_0xf0ca('0x61')]=function(_0x3ce1a1,_0x413794){return db[_0xf0ca('0x4f')][_0xf0ca('0x61')]()[_0xf0ca('0x30')](respondWithResult(_0x413794,null))[_0xf0ca('0x58')](handleError(_0x413794,null));};exports['getMembers']=function(_0xfa2436,_0xb6ed34,_0x135aed){var _0x581765={'raw':!![],'where':{}},_0x2cb570={},_0xf4d07;return db[_0xf0ca('0x4f')][_0xf0ca('0x62')]({'where':{'id':_0xfa2436[_0xf0ca('0x60')]['id']}})['then'](handleEntityNotFound(_0xb6ed34,null))[_0xf0ca('0x30')](function(_0x131cba){if(_0x131cba){_0xf4d07=_0x131cba[_0xf0ca('0x32')]({'plain':!![]});_0x2cb570[_0xf0ca('0x3e')]=_[_0xf0ca('0x40')](db['UserFaxQueue'][_0xf0ca('0x3b')]);_0x2cb570[_0xf0ca('0x3f')]=_['keys'](_0xfa2436[_0xf0ca('0x3f')]);_0x2cb570[_0xf0ca('0x55')]=_[_0xf0ca('0x41')](_0x2cb570['model'],_0x2cb570[_0xf0ca('0x3f')]);_0x581765[_0xf0ca('0x42')]=_['intersection'](_0x2cb570[_0xf0ca('0x3e')],qs[_0xf0ca('0x43')](_0xfa2436['query'][_0xf0ca('0x43')]));_0x581765[_0xf0ca('0x42')]=_0x581765['attributes'][_0xf0ca('0x56')]?_0x581765[_0xf0ca('0x42')]:_0x2cb570[_0xf0ca('0x3e')];if(!_0xfa2436[_0xf0ca('0x3f')][_0xf0ca('0x44')](_0xf0ca('0x45'))){_0x581765[_0xf0ca('0x27')]=qs[_0xf0ca('0x27')](_0xfa2436[_0xf0ca('0x3f')]['limit']);_0x581765[_0xf0ca('0x29')]=qs[_0xf0ca('0x29')](_0xfa2436[_0xf0ca('0x3f')]['offset']);}_0x581765[_0xf0ca('0x46')]=qs[_0xf0ca('0x47')](_0xfa2436['query'][_0xf0ca('0x47')]);_0x581765[_0xf0ca('0x49')]=qs[_0xf0ca('0x55')](_[_0xf0ca('0x48')](_0xfa2436['query'],_0x2cb570[_0xf0ca('0x55')]));_0x581765[_0xf0ca('0x49')][_0xf0ca('0x63')]=_0x131cba['id'];if(_0xfa2436[_0xf0ca('0x3f')]['filter']){_0x581765[_0xf0ca('0x49')]=_['merge'](_0x581765[_0xf0ca('0x49')],{'$or':_[_0xf0ca('0x3a')](_0x581765['attributes'],function(_0x33b2f7){var _0xa49432={};_0xa49432[_0x33b2f7]={'$like':'%'+_0xfa2436[_0xf0ca('0x3f')]['filter']+'%'};return _0xa49432;})});}_0x581765=_['merge']({},_0x581765,_0xfa2436[_0xf0ca('0x4e')]);return db['UserFaxQueue']['findAll'](_0x581765);}})['then'](function(_0x3ce7cb){if(_0x3ce7cb){return db['User']['findAndCountAll']({'where':{'id':_[_0xf0ca('0x3a')](_0x3ce7cb,_0xf0ca('0x64')),'role':_0xf0ca('0x65')},'attributes':['id',_0xf0ca('0x38'),_0xf0ca('0x66'),_0xf0ca('0x67'),_0xf0ca('0x68')]});}})[_0xf0ca('0x30')](function(_0x1d839a){if(_0x1d839a){return{'count':_0x1d839a[_0xf0ca('0x28')],'rows':_[_0xf0ca('0x3a')](_0x1d839a[_0xf0ca('0x53')],function(_0x2c1620){return{'membername':_0x2c1620['name'],'UserId':_0x2c1620['id'],'queue_name':_0xf4d07[_0xf0ca('0x38')],'FaxQueueId':_0xf4d07['id'],'interface':util[_0xf0ca('0x69')](_0xf0ca('0x6a'),_0xf0ca('0x6b'),_0x2c1620[_0xf0ca('0x38')]),'penalty':0x0,'paused':_0x2c1620[_0xf0ca('0x66')],'createdAt':_0x2c1620[_0xf0ca('0x68')],'updatedAt':_0x2c1620[_0xf0ca('0x67')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf0ca('0x30')](respondWithFilteredResult(_0xb6ed34,_0x581765))['catch'](handleError(_0xb6ed34,null));};exports[_0xf0ca('0x6c')]=function(_0x855c56,_0xbe38d2,_0x1c34a9){var _0x5c4eec={};var _0x58e36c={};var _0x2e0fcb;var _0x44249c;return db[_0xf0ca('0x4f')][_0xf0ca('0x62')]({'where':{'id':_0x855c56[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](handleEntityNotFound(_0xbe38d2,null))['then'](function(_0x856a31){if(_0x856a31){_0x2e0fcb=_0x856a31;_0x58e36c[_0xf0ca('0x3e')]=_[_0xf0ca('0x40')](db[_0xf0ca('0x6d')][_0xf0ca('0x3b')]);_0x58e36c[_0xf0ca('0x3f')]=_['keys'](_0x855c56[_0xf0ca('0x3f')]);_0x58e36c[_0xf0ca('0x55')]=_['intersection'](_0x58e36c[_0xf0ca('0x3e')],_0x58e36c[_0xf0ca('0x3f')]);_0x5c4eec[_0xf0ca('0x42')]=_['intersection'](_0x58e36c[_0xf0ca('0x3e')],qs[_0xf0ca('0x43')](_0x855c56[_0xf0ca('0x3f')][_0xf0ca('0x43')]));_0x5c4eec[_0xf0ca('0x42')]=_0x5c4eec[_0xf0ca('0x42')][_0xf0ca('0x56')]?_0x5c4eec[_0xf0ca('0x42')]:_0x58e36c[_0xf0ca('0x3e')];_0x5c4eec[_0xf0ca('0x46')]=qs[_0xf0ca('0x47')](_0x855c56['query']['sort']);_0x5c4eec[_0xf0ca('0x49')]=qs[_0xf0ca('0x55')](_['pick'](_0x855c56['query'],_0x58e36c['filters']));if(_0x855c56[_0xf0ca('0x3f')][_0xf0ca('0x4d')]){_0x5c4eec[_0xf0ca('0x49')]=_[_0xf0ca('0x4a')](_0x5c4eec[_0xf0ca('0x49')],{'$or':_[_0xf0ca('0x3a')](_0x5c4eec[_0xf0ca('0x42')],function(_0x1cd571){var _0x2b0128={};_0x2b0128[_0x1cd571]={'$like':'%'+_0x855c56[_0xf0ca('0x3f')][_0xf0ca('0x4d')]+'%'};return _0x2b0128;})});}_0x5c4eec=_[_0xf0ca('0x4a')]({},_0x5c4eec,_0x855c56['options']);return _0x2e0fcb['getTeams'](_0x5c4eec);}})['then'](function(_0x2e93d8){if(_0x2e93d8){_0x44249c=_0x2e93d8[_0xf0ca('0x56')];if(!_0x855c56[_0xf0ca('0x3f')][_0xf0ca('0x44')]('nolimit')){_0x5c4eec['limit']=qs[_0xf0ca('0x27')](_0x855c56['query'][_0xf0ca('0x27')]);_0x5c4eec[_0xf0ca('0x29')]=qs[_0xf0ca('0x29')](_0x855c56[_0xf0ca('0x3f')]['offset']);}return _0x2e0fcb[_0xf0ca('0x6c')](_0x5c4eec);}})['then'](function(_0x3c3952){if(_0x3c3952){return _0x3c3952?{'count':_0x44249c,'rows':_0x3c3952}:null;}})['then'](respondWithResult(_0xbe38d2,null))[_0xf0ca('0x58')](handleError(_0xbe38d2,null));};exports[_0xf0ca('0x6e')]=function(_0x593c42,_0x2733e6,_0x3edacb){var _0x2ecf2d=_0x593c42[_0xf0ca('0x5f')][_0xf0ca('0x6f')];return db[_0xf0ca('0x6d')]['findAll']({'where':{'id':_0x2ecf2d},'attributes':['id'],'include':[{'model':db[_0xf0ca('0x70')],'as':_0xf0ca('0x71'),'attributes':['id',_0xf0ca('0x38'),_0xf0ca('0x72'),_0xf0ca('0x73'),_0xf0ca('0x74')],'raw':!![]}]})[_0xf0ca('0x30')](function(_0x47a4ba){if(_0x47a4ba){var _0xa829f2=_[_0xf0ca('0x75')](_0x47a4ba,function(_0x4d278a){var _0x3ebf1c=_0x4d278a[_0xf0ca('0x32')]({'plain':!![]});return _0x3ebf1c[_0xf0ca('0x71')];});return db[_0xf0ca('0x4f')][_0xf0ca('0x57')]({'where':{'id':_0x593c42[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](function(_0x2ae210){return db[_0xf0ca('0x76')][_0xf0ca('0x77')](function(_0x3b6941){return _0x2ae210[_0xf0ca('0x6e')](_0x2ecf2d,{'transaction':_0x3b6941})['then'](function(){return BPromise[_0xf0ca('0x78')](_0xa829f2,function(_0xd59ba0){return db[_0xf0ca('0x79')][_0xf0ca('0x7a')]({'where':{'UserId':_0xd59ba0['id'],'FaxQueueId':_0x593c42[_0xf0ca('0x60')]['id']},'transaction':_0x3b6941});});})[_0xf0ca('0x30')](function(){_0xa829f2[_0xf0ca('0x7b')](function(_0x1aeddc){socket[_0xf0ca('0x7c')](_0xf0ca('0x7d'),{'UserId':_0x1aeddc['id'],'FaxQueueId':_0x2ae210['id']});});});});});}})['then'](respondWithStatusCode(_0x2733e6,null))[_0xf0ca('0x58')](handleError(_0x2733e6,null));};exports['removeTeams']=function(_0x4e73c5,_0x461207,_0x3fcd9b){return db['Team'][_0xf0ca('0x52')]({'where':{'id':_0x4e73c5[_0xf0ca('0x3f')][_0xf0ca('0x6f')]},'attributes':['id'],'include':[{'model':db[_0xf0ca('0x70')],'as':_0xf0ca('0x71'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x461207,null))[_0xf0ca('0x30')](function(_0x4ec19b){var _0x1e6e9=_[_0xf0ca('0x3a')](_0x4ec19b,'id');var _0x2876e0=[];var _0x73a7f3=[];var _0x5a69d4=squel[_0xf0ca('0x7e')]();_0x5a69d4[_0xf0ca('0x7f')](_0xf0ca('0x80'))['from'](_0xf0ca('0x81'),'tq')['join'](_0xf0ca('0x82'),'ut',_0xf0ca('0x83'))['where']('FaxQueueId\x20=\x20?',_0x4e73c5[_0xf0ca('0x60')]['id']);for(var _0x5c42d4=0x0;_0x5c42d4<_0x4ec19b[_0xf0ca('0x56')];_0x5c42d4+=0x1){let _0x15fa4a=_0x4ec19b[_0x5c42d4];for(var _0xf41037=0x0;_0xf41037<_0x15fa4a[_0xf0ca('0x71')][_0xf0ca('0x56')];_0xf41037+=0x1){let _0x40a0ee=_0x15fa4a[_0xf0ca('0x71')][_0xf41037];var _0x2b7d82=_0x5a69d4[_0xf0ca('0x84')]();_0x2b7d82[_0xf0ca('0x49')]('ut.UserId\x20=\x20?',_0x40a0ee['id']);_0x73a7f3['push'](db[_0xf0ca('0x76')]['query'](_0x2b7d82[_0xf0ca('0x85')](),{'type':db[_0xf0ca('0x76')][_0xf0ca('0x86')]['SELECT']})['then'](function(_0x18f9ac){if(_0x18f9ac[_0xf0ca('0x56')]===0x1){return _0x40a0ee['id'];}else{var _0x2fb457=_[_0xf0ca('0x87')](_[_0xf0ca('0x3a')](_0x18f9ac,_0xf0ca('0x88')),function(_0x23b6d8){return _[_0xf0ca('0x89')](_0x1e6e9,_0x23b6d8);});if(_0x2fb457){return _0x40a0ee['id'];}}}));}}return BPromise[_0xf0ca('0x8a')](_0x73a7f3)[_0xf0ca('0x30')](function(_0x3376c7){_0x2876e0=_(_0x2876e0)['union'](_0x3376c7)[_0xf0ca('0x8b')]()['value']();return db[_0xf0ca('0x4f')][_0xf0ca('0x57')]({'where':{'id':_0x4e73c5[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](function(_0x18f131){return db[_0xf0ca('0x76')]['transaction'](function(_0x39a464){return _0x18f131[_0xf0ca('0x8c')](_0x4e73c5[_0xf0ca('0x3f')][_0xf0ca('0x6f')],{'transaction':_0x39a464})['then'](function(){if(!_[_0xf0ca('0x8d')](_0x2876e0)){return _0x18f131['removeAgents'](_0x2876e0,{'transaction':_0x39a464});}})[_0xf0ca('0x30')](function(){_0x2876e0[_0xf0ca('0x7b')](function(_0x518eaf){socket[_0xf0ca('0x7c')](_0xf0ca('0x8e'),{'UserId':_0x518eaf,'FaxQueueId':_0x18f131['id']});});});});});});})[_0xf0ca('0x30')](respondWithStatusCode(_0x461207,null))['catch'](handleError(_0x461207,null));};exports[_0xf0ca('0x8f')]=function(_0x45d25a,_0x2cd8e5,_0x5aad4c){return db['FaxQueue'][_0xf0ca('0x57')]({'where':{'id':_0x45d25a[_0xf0ca('0x60')]['id']}})['then'](handleEntityNotFound(_0x2cd8e5,null))[_0xf0ca('0x30')](function(_0x5de79e){if(_0x5de79e){return _0x5de79e[_0xf0ca('0x8f')](_0x45d25a[_0xf0ca('0x5f')]['ids'],_[_0xf0ca('0x90')](_0x45d25a[_0xf0ca('0x5f')],[_0xf0ca('0x6f'),'id'])||{})['spread'](function(_0x4ff343){for(var _0x9db3=0x0;_0x9db3<_0x45d25a[_0xf0ca('0x5f')][_0xf0ca('0x6f')]['length'];_0x9db3+=0x1){socket[_0xf0ca('0x7c')]('userFaxQueue:save',{'UserId':Number(_0x45d25a['body'][_0xf0ca('0x6f')][_0x9db3]),'FaxQueueId':Number(_0x45d25a[_0xf0ca('0x60')]['id'])});}return _0x4ff343;});}})[_0xf0ca('0x30')](respondWithResult(_0x2cd8e5,null))['catch'](handleError(_0x2cd8e5,null));};exports[_0xf0ca('0x91')]=function(_0x229b27,_0x545008,_0x2c2fda){return db[_0xf0ca('0x4f')]['find']({'where':{'id':_0x229b27['params']['id']}})['then'](handleEntityNotFound(_0x545008,null))['then'](function(_0x16700b){if(_0x16700b){return _0x16700b[_0xf0ca('0x91')](_0x229b27[_0xf0ca('0x3f')]['ids'])[_0xf0ca('0x30')](function(){if(_['isArray'](_0x229b27[_0xf0ca('0x3f')][_0xf0ca('0x6f')])){for(var _0x53f164=0x0;_0x53f164<_0x229b27[_0xf0ca('0x3f')]['ids']['length'];_0x53f164+=0x1){socket[_0xf0ca('0x7c')](_0xf0ca('0x8e'),{'UserId':Number(_0x229b27[_0xf0ca('0x3f')]['ids'][_0x53f164]),'FaxQueueId':Number(_0x229b27['params']['id'])});}}else{socket['emit']('userFaxQueue:remove',{'UserId':Number(_0x229b27['query'][_0xf0ca('0x6f')]),'FaxQueueId':Number(_0x229b27[_0xf0ca('0x60')]['id'])});}});}})[_0xf0ca('0x30')](respondWithStatusCode(_0x545008,null))[_0xf0ca('0x58')](handleError(_0x545008,null));};exports[_0xf0ca('0x92')]=function(_0x63fecd,_0x2a0c66,_0x56ed8d){var _0x30cc34={};var _0x2115e5={};var _0x20c378;var _0x3432b5;return db[_0xf0ca('0x4f')][_0xf0ca('0x62')]({'where':{'id':_0x63fecd[_0xf0ca('0x60')]['id']}})[_0xf0ca('0x30')](handleEntityNotFound(_0x2a0c66,null))[_0xf0ca('0x30')](function(_0x45bf6b){if(_0x45bf6b){_0x20c378=_0x45bf6b;_0x2115e5[_0xf0ca('0x3e')]=_['keys'](db[_0xf0ca('0x70')][_0xf0ca('0x3b')]);_0x2115e5['query']=_[_0xf0ca('0x40')](_0x63fecd[_0xf0ca('0x3f')]);_0x2115e5[_0xf0ca('0x55')]=_['intersection'](_0x2115e5[_0xf0ca('0x3e')],_0x2115e5[_0xf0ca('0x3f')]);_0x30cc34['attributes']=_['intersection'](_0x2115e5['model'],qs[_0xf0ca('0x43')](_0x63fecd[_0xf0ca('0x3f')]['fields']));_0x30cc34[_0xf0ca('0x42')]=_0x30cc34[_0xf0ca('0x42')][_0xf0ca('0x56')]?_0x30cc34['attributes']:_0x2115e5[_0xf0ca('0x3e')];_0x30cc34['order']=qs[_0xf0ca('0x47')](_0x63fecd[_0xf0ca('0x3f')][_0xf0ca('0x47')]);_0x30cc34[_0xf0ca('0x49')]=qs[_0xf0ca('0x55')](_[_0xf0ca('0x48')](_0x63fecd[_0xf0ca('0x3f')],_0x2115e5[_0xf0ca('0x55')]));if(_0x63fecd[_0xf0ca('0x3f')][_0xf0ca('0x4d')]){_0x30cc34[_0xf0ca('0x49')]=_[_0xf0ca('0x4a')](_0x30cc34[_0xf0ca('0x49')],{'$or':_[_0xf0ca('0x3a')](_0x30cc34['attributes'],function(_0x3ad78c){var _0x5e0b67={};_0x5e0b67[_0x3ad78c]={'$like':'%'+_0x63fecd[_0xf0ca('0x3f')][_0xf0ca('0x4d')]+'%'};return _0x5e0b67;})});}_0x30cc34=_['merge']({},_0x30cc34,_0x63fecd[_0xf0ca('0x4e')]);return _0x20c378[_0xf0ca('0x92')](_0x30cc34);}})['then'](function(_0x50eefb){if(_0x50eefb){_0x3432b5=_0x50eefb[_0xf0ca('0x56')];if(!_0x63fecd[_0xf0ca('0x3f')][_0xf0ca('0x44')](_0xf0ca('0x45'))){_0x30cc34[_0xf0ca('0x27')]=qs['limit'](_0x63fecd[_0xf0ca('0x3f')][_0xf0ca('0x27')]);_0x30cc34[_0xf0ca('0x29')]=qs['offset'](_0x63fecd['query'][_0xf0ca('0x29')]);}return _0x20c378[_0xf0ca('0x92')](_0x30cc34);}})[_0xf0ca('0x30')](function(_0x21e5a3){if(_0x21e5a3){return _0x21e5a3?{'count':_0x3432b5,'rows':_0x21e5a3}:null;}})[_0xf0ca('0x30')](respondWithResult(_0x2a0c66,null))[_0xf0ca('0x58')](handleError(_0x2a0c66,null));}; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.events.js b/server/api/faxQueue/faxQueue.events.js new file mode 100644 index 0000000..c6cb750 --- /dev/null +++ b/server/api/faxQueue/faxQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7662=['hook','exports','../../mysqldb','FaxQueue','setMaxListeners','save','update','remove','emit','hasOwnProperty'];(function(_0x3e27c9,_0x405b8e){var _0x190107=function(_0x4ffbb5){while(--_0x4ffbb5){_0x3e27c9['push'](_0x3e27c9['shift']());}};_0x190107(++_0x405b8e);}(_0x7662,0xde));var _0x2766=function(_0x591a2d,_0x29f758){_0x591a2d=_0x591a2d-0x0;var _0x27cd88=_0x7662[_0x591a2d];return _0x27cd88;};'use strict';var EventEmitter=require('events');var FaxQueue=require(_0x2766('0x0'))['db'][_0x2766('0x1')];var FaxQueueEvents=new EventEmitter();FaxQueueEvents[_0x2766('0x2')](0x0);var events={'afterCreate':_0x2766('0x3'),'afterUpdate':_0x2766('0x4'),'afterDestroy':_0x2766('0x5')};function emitEvent(_0x542c6e){return function(_0x343af4,_0x7bad87,_0x1bc69e){FaxQueueEvents[_0x2766('0x6')](_0x542c6e+':'+_0x343af4['id'],_0x343af4);FaxQueueEvents['emit'](_0x542c6e,_0x343af4);_0x1bc69e(null);};}for(var e in events){if(events[_0x2766('0x7')](e)){var event=events[e];FaxQueue[_0x2766('0x8')](e,emitEvent(event));}}module[_0x2766('0x9')]=FaxQueueEvents; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.model.js b/server/api/faxQueue/faxQueue.model.js new file mode 100644 index 0000000..1ebe0bf --- /dev/null +++ b/server/api/faxQueue/faxQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3f53=['request-promise','path','rimraf','../../config/environment','./faxQueue.attributes','exports','fax_queues','lodash','util','api','bluebird'];(function(_0x2f42d3,_0x362e7a){var _0x25a67e=function(_0x103ce2){while(--_0x103ce2){_0x2f42d3['push'](_0x2f42d3['shift']());}};_0x25a67e(++_0x362e7a);}(_0x3f53,0x193));var _0x33f5=function(_0x58dce3,_0x50e978){_0x58dce3=_0x58dce3-0x0;var _0x55794f=_0x3f53[_0x58dce3];return _0x55794f;};'use strict';var _=require(_0x33f5('0x0'));var util=require(_0x33f5('0x1'));var logger=require('../../config/logger')(_0x33f5('0x2'));var moment=require('moment');var BPromise=require(_0x33f5('0x3'));var rp=require(_0x33f5('0x4'));var fs=require('fs');var path=require(_0x33f5('0x5'));var rimraf=require(_0x33f5('0x6'));var config=require(_0x33f5('0x7'));var attributes=require(_0x33f5('0x8'));module[_0x33f5('0x9')]=function(_0x1b3a49,_0x371a2a){return _0x1b3a49['define']('FaxQueue',attributes,{'tableName':_0x33f5('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.rpc.js b/server/api/faxQueue/faxQueue.rpc.js new file mode 100644 index 0000000..593a62f --- /dev/null +++ b/server/api/faxQueue/faxQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1af6=['options','raw','where','attributes','limit','include','map','model','then','catch','ShowFaxQueue','FaxQueue','lodash','util','moment','bluebird','ioredis','../../config/logger','rpc','../../config/environment','http','redis','defaults','./faxQueue.socket','register','request','info','FaxQueue,\x20%s,\x20%s','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','GetFaxQueue','findAll'];(function(_0x1c367a,_0x4f872b){var _0xc3001f=function(_0x3a53a8){while(--_0x3a53a8){_0x1c367a['push'](_0x1c367a['shift']());}};_0xc3001f(++_0x4f872b);}(_0x1af6,0x108));var _0x61af=function(_0x5c5587,_0x367180){_0x5c5587=_0x5c5587-0x0;var _0x41c868=_0x1af6[_0x5c5587];return _0x41c868;};'use strict';var _=require(_0x61af('0x0'));var util=require(_0x61af('0x1'));var moment=require(_0x61af('0x2'));var BPromise=require(_0x61af('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x61af('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x61af('0x5'))(_0x61af('0x6'));var config=require(_0x61af('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x61af('0x8')]({'port':0x232a});config[_0x61af('0x9')]=_[_0x61af('0xa')](config[_0x61af('0x9')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x61af('0x9')]));require(_0x61af('0xb'))[_0x61af('0xc')](socket);function respondWithRpcPromise(_0x4ac6d7,_0x32dc37,_0x228eb6){return new BPromise(function(_0xbdb5d6,_0x195ff2){return client[_0x61af('0xd')](_0x4ac6d7,_0x228eb6)['then'](function(_0x51b327){logger[_0x61af('0xe')](_0x61af('0xf'),_0x32dc37,'request\x20sent');logger[_0x61af('0x10')](_0x61af('0x11'),_0x32dc37,'request\x20sent',JSON[_0x61af('0x12')](_0x51b327));if(_0x51b327[_0x61af('0x13')]){if(_0x51b327[_0x61af('0x13')]['code']===0x1f4){logger[_0x61af('0x13')](_0x61af('0xf'),_0x32dc37,_0x51b327[_0x61af('0x13')]['message']);return _0x195ff2(_0x51b327[_0x61af('0x13')][_0x61af('0x14')]);}logger[_0x61af('0x13')](_0x61af('0xf'),_0x32dc37,_0x51b327[_0x61af('0x13')][_0x61af('0x14')]);return _0xbdb5d6(_0x51b327[_0x61af('0x13')][_0x61af('0x14')]);}else{logger[_0x61af('0xe')](_0x61af('0xf'),_0x32dc37,_0x61af('0x15'));_0xbdb5d6(_0x51b327['result'][_0x61af('0x14')]);}})['catch'](function(_0x3f0c97){logger['error'](_0x61af('0xf'),_0x32dc37,_0x3f0c97);_0x195ff2(_0x3f0c97);});});}exports[_0x61af('0x16')]=function(_0x25e41d){var _0x55f394=this;return new Promise(function(_0x9dfff7,_0x3a8dbb){return db['FaxQueue'][_0x61af('0x17')]({'raw':_0x25e41d[_0x61af('0x18')]?_0x25e41d[_0x61af('0x18')][_0x61af('0x19')]===undefined?!![]:![]:!![],'where':_0x25e41d['options']?_0x25e41d['options'][_0x61af('0x1a')]||null:null,'attributes':_0x25e41d['options']?_0x25e41d['options'][_0x61af('0x1b')]||null:null,'limit':_0x25e41d[_0x61af('0x18')]?_0x25e41d[_0x61af('0x18')][_0x61af('0x1c')]||null:null,'include':_0x25e41d[_0x61af('0x18')]?_0x25e41d[_0x61af('0x18')][_0x61af('0x1d')]?_[_0x61af('0x1e')](_0x25e41d[_0x61af('0x18')]['include'],function(_0x40a1b5){return{'model':db[_0x40a1b5[_0x61af('0x1f')]],'as':_0x40a1b5['as'],'attributes':_0x40a1b5[_0x61af('0x1b')],'include':_0x40a1b5['include']?_[_0x61af('0x1e')](_0x40a1b5[_0x61af('0x1d')],function(_0x110873){return{'model':db[_0x110873[_0x61af('0x1f')]],'as':_0x110873['as'],'attributes':_0x110873['attributes'],'include':_0x110873[_0x61af('0x1d')]?_[_0x61af('0x1e')](_0x110873['include'],function(_0xb4c2c5){return{'model':db[_0xb4c2c5[_0x61af('0x1f')]],'as':_0xb4c2c5['as'],'attributes':_0xb4c2c5[_0x61af('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x61af('0x20')](function(_0x473dc1){logger[_0x61af('0xe')](_0x61af('0x16'),_0x25e41d);logger[_0x61af('0x10')]('GetFaxQueue',_0x25e41d,JSON[_0x61af('0x12')](_0x473dc1));_0x9dfff7(_0x473dc1);})[_0x61af('0x21')](function(_0x38d05e){logger[_0x61af('0x13')](_0x61af('0x16'),_0x38d05e[_0x61af('0x14')],_0x25e41d);_0x3a8dbb(_0x55f394[_0x61af('0x13')](0x1f4,_0x38d05e[_0x61af('0x14')]));});});};exports[_0x61af('0x22')]=function(_0x36e68d){var _0x49f8cf=this;return new Promise(function(_0x16410a,_0x105c3e){return db[_0x61af('0x23')]['find']({'raw':_0x36e68d[_0x61af('0x18')]?_0x36e68d['options'][_0x61af('0x19')]===undefined?!![]:![]:!![],'where':_0x36e68d[_0x61af('0x18')]?_0x36e68d[_0x61af('0x18')][_0x61af('0x1a')]||null:null,'attributes':_0x36e68d[_0x61af('0x18')]?_0x36e68d[_0x61af('0x18')]['attributes']||null:null,'include':_0x36e68d[_0x61af('0x18')]?_0x36e68d[_0x61af('0x18')]['include']?_[_0x61af('0x1e')](_0x36e68d[_0x61af('0x18')]['include'],function(_0x10b7bb){return{'model':db[_0x10b7bb['model']],'as':_0x10b7bb['as'],'attributes':_0x10b7bb['attributes'],'include':_0x10b7bb[_0x61af('0x1d')]?_['map'](_0x10b7bb[_0x61af('0x1d')],function(_0xf08351){return{'model':db[_0xf08351[_0x61af('0x1f')]],'as':_0xf08351['as'],'attributes':_0xf08351[_0x61af('0x1b')],'include':_0xf08351['include']?_[_0x61af('0x1e')](_0xf08351['include'],function(_0x1eaae8){return{'model':db[_0x1eaae8[_0x61af('0x1f')]],'as':_0x1eaae8['as'],'attributes':_0x1eaae8[_0x61af('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x29928a){logger[_0x61af('0xe')](_0x61af('0x22'),_0x36e68d);logger[_0x61af('0x10')](_0x61af('0x22'),_0x36e68d,JSON[_0x61af('0x12')](_0x29928a));_0x16410a(_0x29928a);})['catch'](function(_0xc3b7c9){logger['error']('ShowFaxQueue',_0xc3b7c9[_0x61af('0x14')],_0x36e68d);_0x105c3e(_0x49f8cf[_0x61af('0x13')](0x1f4,_0xc3b7c9['message']));});});}; \ No newline at end of file diff --git a/server/api/faxQueue/faxQueue.socket.js b/server/api/faxQueue/faxQueue.socket.js new file mode 100644 index 0000000..1a55f05 --- /dev/null +++ b/server/api/faxQueue/faxQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc12=['remove','update','emit','removeListener','length','./faxQueue.events','save'];(function(_0x4e9f29,_0x1bbcbf){var _0x8e1ab3=function(_0x4a4e6b){while(--_0x4a4e6b){_0x4e9f29['push'](_0x4e9f29['shift']());}};_0x8e1ab3(++_0x1bbcbf);}(_0xdc12,0x10f));var _0x2dc1=function(_0x1e82cb,_0xd849d0){_0x1e82cb=_0x1e82cb-0x0;var _0x57bbda=_0xdc12[_0x1e82cb];return _0x57bbda;};'use strict';var FaxQueueEvents=require(_0x2dc1('0x0'));var events=[_0x2dc1('0x1'),_0x2dc1('0x2'),_0x2dc1('0x3')];function createListener(_0x2c15fd,_0x1e22a8){return function(_0x4f1ca5){_0x1e22a8[_0x2dc1('0x4')](_0x2c15fd,_0x4f1ca5);};}function removeListener(_0x4caa07,_0x5c4b4e){return function(){FaxQueueEvents[_0x2dc1('0x5')](_0x4caa07,_0x5c4b4e);};}exports['register']=function(_0x526f5c){for(var _0x2296a4=0x0,_0x36751e=events[_0x2dc1('0x6')];_0x2296a4<_0x36751e;_0x2296a4++){var _0x1c2b83=events[_0x2296a4];var _0x1aeb2b=createListener('faxQueue:'+_0x1c2b83,_0x526f5c);FaxQueueEvents['on'](_0x1c2b83,_0x1aeb2b);}}; \ No newline at end of file diff --git a/server/api/faxQueue/index.js b/server/api/faxQueue/index.js new file mode 100644 index 0000000..0670114 --- /dev/null +++ b/server/api/faxQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x964b=['/:id/members','getMembers','/:id/teams','getTeams','/:id/users','post','addTeams','put','update','delete','destroy','removeTeams','removeAgents','exports','multer','util','connect-timeout','express','Router','../../components/interaction/service','./faxQueue.controller','get','isAuthenticated','index','/describe','/:id'];(function(_0x549d30,_0x2e827c){var _0x46b0f2=function(_0x27e331){while(--_0x27e331){_0x549d30['push'](_0x549d30['shift']());}};_0x46b0f2(++_0x2e827c);}(_0x964b,0x112));var _0xb964=function(_0x147975,_0x41fe99){_0x147975=_0x147975-0x0;var _0x1db28a=_0x964b[_0x147975];return _0x1db28a;};'use strict';var multer=require(_0xb964('0x0'));var util=require(_0xb964('0x1'));var path=require('path');var timeout=require(_0xb964('0x2'));var express=require(_0xb964('0x3'));var router=express[_0xb964('0x4')]();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require(_0xb964('0x5'));var config=require('../../config/environment');var controller=require(_0xb964('0x6'));router[_0xb964('0x7')]('/',auth[_0xb964('0x8')](),controller[_0xb964('0x9')]);router[_0xb964('0x7')](_0xb964('0xa'),auth[_0xb964('0x8')](),controller['describe']);router['get'](_0xb964('0xb'),auth['isAuthenticated'](),controller['show']);router[_0xb964('0x7')](_0xb964('0xc'),auth[_0xb964('0x8')](),controller[_0xb964('0xd')]);router[_0xb964('0x7')](_0xb964('0xe'),auth['isAuthenticated'](),controller[_0xb964('0xf')]);router[_0xb964('0x7')](_0xb964('0x10'),auth[_0xb964('0x8')](),controller['getAgents']);router[_0xb964('0x11')]('/',auth['isAuthenticated'](),controller['create']);router[_0xb964('0x11')](_0xb964('0xe'),auth[_0xb964('0x8')](),controller[_0xb964('0x12')]);router[_0xb964('0x11')](_0xb964('0x10'),auth[_0xb964('0x8')](),controller['addAgents']);router[_0xb964('0x13')]('/:id',auth['isAuthenticated'](),controller[_0xb964('0x14')]);router[_0xb964('0x15')](_0xb964('0xb'),auth[_0xb964('0x8')](),controller[_0xb964('0x16')]);router[_0xb964('0x15')](_0xb964('0xe'),auth[_0xb964('0x8')](),controller[_0xb964('0x17')]);router['delete']('/:id/users',auth['isAuthenticated'](),controller[_0xb964('0x18')]);module[_0xb964('0x19')]=router; \ No newline at end of file diff --git a/server/api/faxQueueReport/faxQueueReport.attributes.js b/server/api/faxQueueReport/faxQueueReport.attributes.js new file mode 100644 index 0000000..13595a8 --- /dev/null +++ b/server/api/faxQueueReport/faxQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4ee6=['exports','STRING','DATE','moment','sequelize'];(function(_0x130705,_0x2d266b){var _0x1fa991=function(_0x395639){while(--_0x395639){_0x130705['push'](_0x130705['shift']());}};_0x1fa991(++_0x2d266b);}(_0x4ee6,0x193));var _0x64ee=function(_0x2422e5,_0x18fbfa){_0x2422e5=_0x2422e5-0x0;var _0x434454=_0x4ee6[_0x2422e5];return _0x434454;};'use strict';var moment=require(_0x64ee('0x0'));var Sequelize=require(_0x64ee('0x1'));module[_0x64ee('0x2')]={'uniqueid':{'type':Sequelize['STRING'],'allowNull':![]},'from':{'type':Sequelize[_0x64ee('0x3')]},'joinAt':{'type':Sequelize[_0x64ee('0x4')]},'leaveAt':{'type':Sequelize[_0x64ee('0x4')]},'acceptAt':{'type':Sequelize[_0x64ee('0x4')]},'exitAt':{'type':Sequelize['DATE']},'reason':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/faxQueueReport/faxQueueReport.controller.js b/server/api/faxQueueReport/faxQueueReport.controller.js new file mode 100644 index 0000000..1293623 --- /dev/null +++ b/server/api/faxQueueReport/faxQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8ebf=['crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','save','then','destroy','error','name','send','index','map','FaxQueueReport','rawAttributes','fieldName','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','sort','where','pick','filter','merge','type','options','includeAll','include','model','catch','create','body','update','find','params','describe','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','to-csv','ejs','lodash','squel'];(function(_0x3c643d,_0xff5bf0){var _0x5e93ff=function(_0x5c53ed){while(--_0x5c53ed){_0x3c643d['push'](_0x3c643d['shift']());}};_0x5e93ff(++_0xff5bf0);}(_0x8ebf,0x15c));var _0xf8eb=function(_0x41d432,_0x20e878){_0x41d432=_0x41d432-0x0;var _0x1650f9=_0x8ebf[_0x41d432];return _0x1650f9;};'use strict';var emlformat=require(_0xf8eb('0x0'));var rimraf=require(_0xf8eb('0x1'));var zipdir=require(_0xf8eb('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf8eb('0x3'));var moment=require(_0xf8eb('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf8eb('0x5'));var util=require(_0xf8eb('0x6'));var path=require(_0xf8eb('0x7'));var sox=require('sox');var csv=require(_0xf8eb('0x8'));var ejs=require(_0xf8eb('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf8eb('0xa'));var squel=require(_0xf8eb('0xb'));var crypto=require(_0xf8eb('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xf8eb('0xd'));var toCsv=require('to-csv');var querystring=require(_0xf8eb('0xe'));var Papa=require('papaparse');var Redis=require(_0xf8eb('0xf'));var authService=require(_0xf8eb('0x10'));var qs=require(_0xf8eb('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf8eb('0x12'));var logger=require(_0xf8eb('0x13'))(_0xf8eb('0x14'));var utils=require(_0xf8eb('0x15'));var config=require(_0xf8eb('0x16'));var licenseUtil=require(_0xf8eb('0x17'));var db=require(_0xf8eb('0x18'))['db'];function respondWithStatusCode(_0x253455,_0x4c6109){_0x4c6109=_0x4c6109||0xcc;return function(_0x325dcd){if(_0x325dcd){return _0x253455[_0xf8eb('0x19')](_0x4c6109);}return _0x253455[_0xf8eb('0x1a')](_0x4c6109)[_0xf8eb('0x1b')]();};}function respondWithResult(_0x4bed5d,_0x55ee4b){_0x55ee4b=_0x55ee4b||0xc8;return function(_0x5f24bc){if(_0x5f24bc){return _0x4bed5d['status'](_0x55ee4b)[_0xf8eb('0x1c')](_0x5f24bc);}};}function respondWithFilteredResult(_0x22af2e,_0x48e97f){return function(_0x24277e){if(_0x24277e){var _0x10415f=typeof _0x48e97f[_0xf8eb('0x1d')]==='undefined'&&typeof _0x48e97f[_0xf8eb('0x1e')]===_0xf8eb('0x1f');var _0x2f052d=_0x24277e[_0xf8eb('0x20')];var _0x3038b7=_0x10415f?0x0:_0x48e97f[_0xf8eb('0x1d')];var _0x4b6e70=_0x10415f?_0x24277e['count']:_0x48e97f[_0xf8eb('0x1d')]+_0x48e97f[_0xf8eb('0x1e')];var _0xce86f9;if(_0x4b6e70>=_0x2f052d){_0x4b6e70=_0x2f052d;_0xce86f9=0xc8;}else{_0xce86f9=0xce;}_0x22af2e[_0xf8eb('0x1a')](_0xce86f9);return _0x22af2e[_0xf8eb('0x21')](_0xf8eb('0x22'),_0x3038b7+'-'+_0x4b6e70+'/'+_0x2f052d)[_0xf8eb('0x1c')](_0x24277e);}return null;};}function patchUpdates(_0x139b1d){return function(_0x5a577a){try{jsonpatch[_0xf8eb('0x23')](_0x5a577a,_0x139b1d,!![]);}catch(_0x4b7d89){return BPromise['reject'](_0x4b7d89);}return _0x5a577a[_0xf8eb('0x24')]();};}function saveUpdates(_0x1bf4fc,_0xb9ea72){return function(_0x17a27e){if(_0x17a27e){return _0x17a27e['update'](_0x1bf4fc)[_0xf8eb('0x25')](function(_0x301f40){return _0x301f40;});}return null;};}function removeEntity(_0xd71d3a,_0x3f153f){return function(_0x58f0b3){if(_0x58f0b3){return _0x58f0b3[_0xf8eb('0x26')]()[_0xf8eb('0x25')](function(){_0xd71d3a[_0xf8eb('0x1a')](0xcc)[_0xf8eb('0x1b')]();});}};}function handleEntityNotFound(_0xa208f0,_0x3547ee){return function(_0x2aaeaf){if(!_0x2aaeaf){_0xa208f0[_0xf8eb('0x19')](0x194);}return _0x2aaeaf;};}function handleError(_0x674c51,_0x6164d5){_0x6164d5=_0x6164d5||0x1f4;return function(_0x20738e){logger[_0xf8eb('0x27')](_0x20738e['stack']);if(_0x20738e[_0xf8eb('0x28')]){delete _0x20738e['name'];}_0x674c51[_0xf8eb('0x1a')](_0x6164d5)[_0xf8eb('0x29')](_0x20738e);};}exports[_0xf8eb('0x2a')]=function(_0xa39e74,_0x45348a){var _0x1716db={},_0x5bf35a={},_0x3c8448={'count':0x0,'rows':[]};var _0x3618bb=_[_0xf8eb('0x2b')](db[_0xf8eb('0x2c')][_0xf8eb('0x2d')],function(_0x2951cd){return{'name':_0x2951cd[_0xf8eb('0x2e')],'type':_0x2951cd['type']['key']};});_0x5bf35a['model']=_[_0xf8eb('0x2b')](_0x3618bb,_0xf8eb('0x28'));_0x5bf35a[_0xf8eb('0x2f')]=_[_0xf8eb('0x30')](_0xa39e74['query']);_0x5bf35a[_0xf8eb('0x31')]=_['intersection'](_0x5bf35a['model'],_0x5bf35a['query']);_0x1716db['attributes']=_[_0xf8eb('0x32')](_0x5bf35a['model'],qs[_0xf8eb('0x33')](_0xa39e74[_0xf8eb('0x2f')][_0xf8eb('0x33')]));_0x1716db[_0xf8eb('0x34')]=_0x1716db[_0xf8eb('0x34')][_0xf8eb('0x35')]?_0x1716db[_0xf8eb('0x34')]:_0x5bf35a['model'];if(!_0xa39e74[_0xf8eb('0x2f')][_0xf8eb('0x36')]('nolimit')){_0x1716db[_0xf8eb('0x1e')]=qs['limit'](_0xa39e74[_0xf8eb('0x2f')][_0xf8eb('0x1e')]);_0x1716db[_0xf8eb('0x1d')]=qs['offset'](_0xa39e74[_0xf8eb('0x2f')]['offset']);}_0x1716db['order']=qs[_0xf8eb('0x37')](_0xa39e74[_0xf8eb('0x2f')][_0xf8eb('0x37')]);_0x1716db[_0xf8eb('0x38')]=qs[_0xf8eb('0x31')](_[_0xf8eb('0x39')](_0xa39e74['query'],_0x5bf35a[_0xf8eb('0x31')]),_0x3618bb);if(_0xa39e74['query'][_0xf8eb('0x3a')]){_0x1716db[_0xf8eb('0x38')]=_[_0xf8eb('0x3b')](_0x1716db[_0xf8eb('0x38')],{'$or':_[_0xf8eb('0x2b')](_0x3618bb,function(_0x1b9e5f){if(_0x1b9e5f[_0xf8eb('0x3c')]!=='VIRTUAL'){var _0x31ca46={};_0x31ca46[_0x1b9e5f[_0xf8eb('0x28')]]={'$like':'%'+_0xa39e74[_0xf8eb('0x2f')]['filter']+'%'};return _0x31ca46;}})});}_0x1716db=_['merge']({},_0x1716db,_0xa39e74[_0xf8eb('0x3d')]);var _0x597cfc={'where':_0x1716db[_0xf8eb('0x38')]};return db[_0xf8eb('0x2c')][_0xf8eb('0x20')](_0x597cfc)[_0xf8eb('0x25')](function(_0xeae7b8){_0x3c8448[_0xf8eb('0x20')]=_0xeae7b8;if(_0xa39e74[_0xf8eb('0x2f')][_0xf8eb('0x3e')]){_0x1716db[_0xf8eb('0x3f')]=[{'all':!![]}];}return db['FaxQueueReport']['findAll'](_0x1716db);})[_0xf8eb('0x25')](function(_0x4cc676){_0x3c8448['rows']=_0x4cc676;return _0x3c8448;})[_0xf8eb('0x25')](respondWithFilteredResult(_0x45348a,_0x1716db))['catch'](handleError(_0x45348a,null));};exports['show']=function(_0x469ec0,_0x418610){var _0xe6d395={'raw':!![],'where':{'id':_0x469ec0['params']['id']}},_0x4abd69={};_0x4abd69['model']=_['keys'](db['FaxQueueReport'][_0xf8eb('0x2d')]);_0x4abd69[_0xf8eb('0x2f')]=_[_0xf8eb('0x30')](_0x469ec0[_0xf8eb('0x2f')]);_0x4abd69[_0xf8eb('0x31')]=_['intersection'](_0x4abd69[_0xf8eb('0x40')],_0x4abd69[_0xf8eb('0x2f')]);_0xe6d395[_0xf8eb('0x34')]=_[_0xf8eb('0x32')](_0x4abd69[_0xf8eb('0x40')],qs[_0xf8eb('0x33')](_0x469ec0[_0xf8eb('0x2f')][_0xf8eb('0x33')]));_0xe6d395[_0xf8eb('0x34')]=_0xe6d395[_0xf8eb('0x34')]['length']?_0xe6d395[_0xf8eb('0x34')]:_0x4abd69['model'];if(_0x469ec0['query'][_0xf8eb('0x3e')]){_0xe6d395[_0xf8eb('0x3f')]=[{'all':!![]}];}_0xe6d395=_[_0xf8eb('0x3b')]({},_0xe6d395,_0x469ec0[_0xf8eb('0x3d')]);return db[_0xf8eb('0x2c')]['find'](_0xe6d395)['then'](handleEntityNotFound(_0x418610,null))[_0xf8eb('0x25')](respondWithResult(_0x418610,null))[_0xf8eb('0x41')](handleError(_0x418610,null));};exports['create']=function(_0x354c2d,_0x1b313b){return db[_0xf8eb('0x2c')][_0xf8eb('0x42')](_0x354c2d[_0xf8eb('0x43')],{})[_0xf8eb('0x25')](respondWithResult(_0x1b313b,0xc9))['catch'](handleError(_0x1b313b,null));};exports[_0xf8eb('0x44')]=function(_0x4023f8,_0x5e9502){if(_0x4023f8[_0xf8eb('0x43')]['id']){delete _0x4023f8[_0xf8eb('0x43')]['id'];}return db[_0xf8eb('0x2c')][_0xf8eb('0x45')]({'where':{'id':_0x4023f8[_0xf8eb('0x46')]['id']}})['then'](handleEntityNotFound(_0x5e9502,null))['then'](saveUpdates(_0x4023f8[_0xf8eb('0x43')],null))[_0xf8eb('0x25')](respondWithResult(_0x5e9502,null))[_0xf8eb('0x41')](handleError(_0x5e9502,null));};exports[_0xf8eb('0x26')]=function(_0x3589e3,_0x1fce7d){return db['FaxQueueReport'][_0xf8eb('0x45')]({'where':{'id':_0x3589e3[_0xf8eb('0x46')]['id']}})[_0xf8eb('0x25')](handleEntityNotFound(_0x1fce7d,null))[_0xf8eb('0x25')](removeEntity(_0x1fce7d,null))[_0xf8eb('0x41')](handleError(_0x1fce7d,null));};exports[_0xf8eb('0x47')]=function(_0x393138,_0x53f0fc){return db[_0xf8eb('0x2c')]['describe']()[_0xf8eb('0x25')](respondWithResult(_0x53f0fc,null))[_0xf8eb('0x41')](handleError(_0x53f0fc,null));}; \ No newline at end of file diff --git a/server/api/faxQueueReport/faxQueueReport.model.js b/server/api/faxQueueReport/faxQueueReport.model.js new file mode 100644 index 0000000..e67a132 --- /dev/null +++ b/server/api/faxQueueReport/faxQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe14b=['bluebird','path','./faxQueueReport.attributes','exports','define','FaxQueueReport','report_fax_queue','lodash','util','moment'];(function(_0x1ec620,_0x4c3cac){var _0x4a8711=function(_0x19a9b0){while(--_0x19a9b0){_0x1ec620['push'](_0x1ec620['shift']());}};_0x4a8711(++_0x4c3cac);}(_0xe14b,0x93));var _0xbe14=function(_0x3c3cfe,_0x3d2e5a){_0x3c3cfe=_0x3c3cfe-0x0;var _0x338384=_0xe14b[_0x3c3cfe];return _0x338384;};'use strict';var _=require(_0xbe14('0x0'));var util=require(_0xbe14('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0xbe14('0x2'));var BPromise=require(_0xbe14('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xbe14('0x4'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0xbe14('0x5'));module[_0xbe14('0x6')]=function(_0x1fe204,_0x1ff100){return _0x1fe204[_0xbe14('0x7')](_0xbe14('0x8'),attributes,{'tableName':_0xbe14('0x9'),'paranoid':![],'indexes':[{'name':'uniqueid','fields':['uniqueid']}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/faxQueueReport/faxQueueReport.rpc.js b/server/api/faxQueueReport/faxQueueReport.rpc.js new file mode 100644 index 0000000..f48ab9e --- /dev/null +++ b/server/api/faxQueueReport/faxQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4f98=['debug','FaxQueueReport','update','options','where','attributes','limit','UpdateFaxQueueReport','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/environment','client','http','request','then','info','FaxQueueReport,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','body','raw','CreateFaxQueueReport'];(function(_0x491a7f,_0x28bb80){var _0x3d8f44=function(_0xdaa716){while(--_0xdaa716){_0x491a7f['push'](_0x491a7f['shift']());}};_0x3d8f44(++_0x28bb80);}(_0x4f98,0x15d));var _0x84f9=function(_0x3c504b,_0x437693){_0x3c504b=_0x3c504b-0x0;var _0x2e5354=_0x4f98[_0x3c504b];return _0x2e5354;};'use strict';var _=require(_0x84f9('0x0'));var util=require(_0x84f9('0x1'));var moment=require(_0x84f9('0x2'));var BPromise=require('bluebird');var rs=require(_0x84f9('0x3'));var fs=require('fs');var Redis=require(_0x84f9('0x4'));var db=require(_0x84f9('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x84f9('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x84f9('0x7')][_0x84f9('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1f50b5,_0x35f042,_0x4e529b){return new BPromise(function(_0x303543,_0x141a7f){return client[_0x84f9('0x9')](_0x1f50b5,_0x4e529b)[_0x84f9('0xa')](function(_0x2eed80){logger[_0x84f9('0xb')](_0x84f9('0xc'),_0x35f042,_0x84f9('0xd'));logger['debug']('FaxQueueReport,\x20%s,\x20%s,\x20%s',_0x35f042,_0x84f9('0xd'),JSON[_0x84f9('0xe')](_0x2eed80));if(_0x2eed80['error']){if(_0x2eed80[_0x84f9('0xf')][_0x84f9('0x10')]===0x1f4){logger[_0x84f9('0xf')](_0x84f9('0xc'),_0x35f042,_0x2eed80[_0x84f9('0xf')][_0x84f9('0x11')]);return _0x141a7f(_0x2eed80[_0x84f9('0xf')][_0x84f9('0x11')]);}logger['error'](_0x84f9('0xc'),_0x35f042,_0x2eed80['error'][_0x84f9('0x11')]);return _0x303543(_0x2eed80[_0x84f9('0xf')][_0x84f9('0x11')]);}else{logger[_0x84f9('0xb')](_0x84f9('0xc'),_0x35f042,_0x84f9('0xd'));_0x303543(_0x2eed80[_0x84f9('0x12')]['message']);}})[_0x84f9('0x13')](function(_0x19245e){logger[_0x84f9('0xf')]('FaxQueueReport,\x20%s,\x20%s',_0x35f042,_0x19245e);_0x141a7f(_0x19245e);});});}exports['CreateFaxQueueReport']=function(_0x192e94){var _0x37d8ef=this;return new Promise(function(_0x371f1f,_0x4858bb){return db['FaxQueueReport']['create'](_0x192e94[_0x84f9('0x14')],{'raw':_0x192e94['options']?_0x192e94['options'][_0x84f9('0x15')]===undefined?!![]:![]:!![]})[_0x84f9('0xa')](function(_0x4a7627){logger[_0x84f9('0xb')](_0x84f9('0x16'),_0x192e94);logger[_0x84f9('0x17')](_0x84f9('0x16'),_0x192e94,JSON[_0x84f9('0xe')](_0x4a7627));_0x371f1f(_0x4a7627);})[_0x84f9('0x13')](function(_0x419ca2){logger['error']('CreateFaxQueueReport',_0x419ca2[_0x84f9('0x11')],_0x192e94);_0x4858bb(_0x37d8ef[_0x84f9('0xf')](0x1f4,_0x419ca2[_0x84f9('0x11')]));});});};exports['UpdateFaxQueueReport']=function(_0x2c165c){var _0x84783d=this;return new Promise(function(_0x210120,_0x3ea33f){return db[_0x84f9('0x18')][_0x84f9('0x19')](_0x2c165c[_0x84f9('0x14')],{'raw':_0x2c165c[_0x84f9('0x1a')]?_0x2c165c[_0x84f9('0x1a')][_0x84f9('0x15')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2c165c[_0x84f9('0x1a')]?_0x2c165c[_0x84f9('0x1a')][_0x84f9('0x1b')]||null:null,'attributes':_0x2c165c['options']?_0x2c165c[_0x84f9('0x1a')][_0x84f9('0x1c')]||null:null,'limit':_0x2c165c['options']?_0x2c165c[_0x84f9('0x1a')][_0x84f9('0x1d')]||null:null})[_0x84f9('0xa')](function(_0x22dcc0){logger[_0x84f9('0xb')](_0x84f9('0x1e'),_0x2c165c);logger[_0x84f9('0x17')](_0x84f9('0x1e'),_0x2c165c,JSON['stringify'](_0x22dcc0));_0x210120(_0x22dcc0);})['catch'](function(_0x1508f4){logger['error']('UpdateFaxQueueReport',_0x1508f4[_0x84f9('0x11')],_0x2c165c);_0x3ea33f(_0x84783d['error'](0x1f4,_0x1508f4['message']));});});}; \ No newline at end of file diff --git a/server/api/faxQueueReport/index.js b/server/api/faxQueueReport/index.js new file mode 100644 index 0000000..e1a8f5d --- /dev/null +++ b/server/api/faxQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe65a=['get','index','/describe','describe','/:id','isAuthenticated','show','post','create','update','delete','destroy','exports','util','path','express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./faxQueueReport.controller'];(function(_0x289035,_0x76742c){var _0x4c8db5=function(_0x26a333){while(--_0x26a333){_0x289035['push'](_0x289035['shift']());}};_0x4c8db5(++_0x76742c);}(_0xe65a,0x1b1));var _0xae65=function(_0x420b24,_0x382adc){_0x420b24=_0x420b24-0x0;var _0x4da552=_0xe65a[_0x420b24];return _0x4da552;};'use strict';var multer=require('multer');var util=require(_0xae65('0x0'));var path=require(_0xae65('0x1'));var timeout=require('connect-timeout');var express=require(_0xae65('0x2'));var router=express['Router']();var fs_extra=require(_0xae65('0x3'));var auth=require(_0xae65('0x4'));var interaction=require(_0xae65('0x5'));var config=require(_0xae65('0x6'));var controller=require(_0xae65('0x7'));router[_0xae65('0x8')]('/',auth['isAuthenticated'](),controller[_0xae65('0x9')]);router[_0xae65('0x8')](_0xae65('0xa'),auth['isAuthenticated'](),controller[_0xae65('0xb')]);router['get'](_0xae65('0xc'),auth[_0xae65('0xd')](),controller[_0xae65('0xe')]);router[_0xae65('0xf')]('/',auth['isAuthenticated'](),controller[_0xae65('0x10')]);router['put'](_0xae65('0xc'),auth[_0xae65('0xd')](),controller[_0xae65('0x11')]);router[_0xae65('0x12')]('/:id',auth[_0xae65('0xd')](),controller[_0xae65('0x13')]);module[_0xae65('0x14')]=router; \ No newline at end of file diff --git a/server/api/faxTransferReport/faxTransferReport.attributes.js b/server/api/faxTransferReport/faxTransferReport.attributes.js new file mode 100644 index 0000000..c149cec --- /dev/null +++ b/server/api/faxTransferReport/faxTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf3cd=['exports','STRING','ENUM','account','queue','DATE','moment','sequelize'];(function(_0xd549e9,_0x45f009){var _0x4febe4=function(_0x1bcf97){while(--_0x1bcf97){_0xd549e9['push'](_0xd549e9['shift']());}};_0x4febe4(++_0x45f009);}(_0xf3cd,0xfe));var _0xdf3c=function(_0x8bb4c1,_0x2d6e53){_0x8bb4c1=_0x8bb4c1-0x0;var _0x67a6e1=_0xf3cd[_0x8bb4c1];return _0x67a6e1;};'use strict';var moment=require(_0xdf3c('0x0'));var Sequelize=require(_0xdf3c('0x1'));module[_0xdf3c('0x2')]={'uniqueid':{'type':Sequelize[_0xdf3c('0x3')],'allowNull':![]},'type':{'type':Sequelize[_0xdf3c('0x4')](_0xdf3c('0x5'),'agent',_0xdf3c('0x6')),'allowNull':![],'defaultValue':_0xdf3c('0x6')},'transferredAt':{'type':Sequelize[_0xdf3c('0x7')],'allowNull':![],'defaultValue':Sequelize['NOW']}}; \ No newline at end of file diff --git a/server/api/faxTransferReport/faxTransferReport.controller.js b/server/api/faxTransferReport/faxTransferReport.controller.js new file mode 100644 index 0000000..2ad7c24 --- /dev/null +++ b/server/api/faxTransferReport/faxTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1650=['../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','undefined','limit','count','status','set','Content-Range','apply','reject','save','update','destroy','then','error','name','send','FaxTransferReport','rawAttributes','fieldName','model','map','query','filters','intersection','fields','attributes','nolimit','offset','order','sort','where','pick','merge','type','VIRTUAL','filter','findAll','rows','catch','params','keys','length','includeAll','include','options','find','create','body','describe','rimraf','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis'];(function(_0xc36b,_0x1650bd){var _0x44a4b6=function(_0x30cd77){while(--_0x30cd77){_0xc36b['push'](_0xc36b['shift']());}};_0x44a4b6(++_0x1650bd);}(_0x1650,0xd3));var _0x0165=function(_0x403fc7,_0x32931a){_0x403fc7=_0x403fc7-0x0;var _0x5d0827=_0x1650[_0x403fc7];return _0x5d0827;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0165('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0165('0x1'));var moment=require('moment');var BPromise=require(_0x0165('0x2'));var Mustache=require(_0x0165('0x3'));var util=require(_0x0165('0x4'));var path=require(_0x0165('0x5'));var sox=require(_0x0165('0x6'));var csv=require(_0x0165('0x7'));var ejs=require(_0x0165('0x8'));var fs=require('fs');var fs_extra=require(_0x0165('0x9'));var _=require(_0x0165('0xa'));var squel=require('squel');var crypto=require(_0x0165('0xb'));var jsforce=require(_0x0165('0xc'));var deskjs=require(_0x0165('0xd'));var toCsv=require(_0x0165('0x7'));var querystring=require(_0x0165('0xe'));var Papa=require(_0x0165('0xf'));var Redis=require(_0x0165('0x10'));var authService=require(_0x0165('0x11'));var qs=require(_0x0165('0x12'));var as=require(_0x0165('0x13'));var hardwareService=require(_0x0165('0x14'));var logger=require('../../config/logger')(_0x0165('0x15'));var utils=require(_0x0165('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x0165('0x17'));var db=require(_0x0165('0x18'))['db'];function respondWithStatusCode(_0x31ead2,_0x58f962){_0x58f962=_0x58f962||0xcc;return function(_0x1e68f1){if(_0x1e68f1){return _0x31ead2[_0x0165('0x19')](_0x58f962);}return _0x31ead2['status'](_0x58f962)[_0x0165('0x1a')]();};}function respondWithResult(_0x27010d,_0x5bb7c7){_0x5bb7c7=_0x5bb7c7||0xc8;return function(_0x3c5e4e){if(_0x3c5e4e){return _0x27010d['status'](_0x5bb7c7)[_0x0165('0x1b')](_0x3c5e4e);}};}function respondWithFilteredResult(_0x141dd2,_0x4c535d){return function(_0x1c2e86){if(_0x1c2e86){var _0x47ee14=typeof _0x4c535d['offset']===_0x0165('0x1c')&&typeof _0x4c535d[_0x0165('0x1d')]===_0x0165('0x1c');var _0x3697fe=_0x1c2e86['count'];var _0x2853d9=_0x47ee14?0x0:_0x4c535d['offset'];var _0x5a5e0a=_0x47ee14?_0x1c2e86[_0x0165('0x1e')]:_0x4c535d['offset']+_0x4c535d[_0x0165('0x1d')];var _0x211080;if(_0x5a5e0a>=_0x3697fe){_0x5a5e0a=_0x3697fe;_0x211080=0xc8;}else{_0x211080=0xce;}_0x141dd2[_0x0165('0x1f')](_0x211080);return _0x141dd2[_0x0165('0x20')](_0x0165('0x21'),_0x2853d9+'-'+_0x5a5e0a+'/'+_0x3697fe)['json'](_0x1c2e86);}return null;};}function patchUpdates(_0x2d723f){return function(_0x470f34){try{jsonpatch[_0x0165('0x22')](_0x470f34,_0x2d723f,!![]);}catch(_0x277428){return BPromise[_0x0165('0x23')](_0x277428);}return _0x470f34[_0x0165('0x24')]();};}function saveUpdates(_0x19d318,_0x123d04){return function(_0x28210f){if(_0x28210f){return _0x28210f[_0x0165('0x25')](_0x19d318)['then'](function(_0x3d9748){return _0x3d9748;});}return null;};}function removeEntity(_0xb92b75,_0x77ea3c){return function(_0x585db5){if(_0x585db5){return _0x585db5[_0x0165('0x26')]()[_0x0165('0x27')](function(){_0xb92b75[_0x0165('0x1f')](0xcc)[_0x0165('0x1a')]();});}};}function handleEntityNotFound(_0x4ef64b,_0x5a190d){return function(_0x37b0e6){if(!_0x37b0e6){_0x4ef64b[_0x0165('0x19')](0x194);}return _0x37b0e6;};}function handleError(_0x48aa81,_0xd93177){_0xd93177=_0xd93177||0x1f4;return function(_0xeb260a){logger[_0x0165('0x28')](_0xeb260a['stack']);if(_0xeb260a['name']){delete _0xeb260a[_0x0165('0x29')];}_0x48aa81[_0x0165('0x1f')](_0xd93177)[_0x0165('0x2a')](_0xeb260a);};}exports['index']=function(_0x352cd4,_0x2b78a2){var _0x4b1393={},_0x5531fc={},_0x3f3482={'count':0x0,'rows':[]};var _0x1063f6=_['map'](db[_0x0165('0x2b')][_0x0165('0x2c')],function(_0x141427){return{'name':_0x141427[_0x0165('0x2d')],'type':_0x141427['type']['key']};});_0x5531fc[_0x0165('0x2e')]=_[_0x0165('0x2f')](_0x1063f6,_0x0165('0x29'));_0x5531fc['query']=_['keys'](_0x352cd4[_0x0165('0x30')]);_0x5531fc[_0x0165('0x31')]=_[_0x0165('0x32')](_0x5531fc[_0x0165('0x2e')],_0x5531fc[_0x0165('0x30')]);_0x4b1393['attributes']=_['intersection'](_0x5531fc[_0x0165('0x2e')],qs[_0x0165('0x33')](_0x352cd4[_0x0165('0x30')][_0x0165('0x33')]));_0x4b1393['attributes']=_0x4b1393[_0x0165('0x34')]['length']?_0x4b1393['attributes']:_0x5531fc[_0x0165('0x2e')];if(!_0x352cd4[_0x0165('0x30')]['hasOwnProperty'](_0x0165('0x35'))){_0x4b1393[_0x0165('0x1d')]=qs[_0x0165('0x1d')](_0x352cd4['query']['limit']);_0x4b1393[_0x0165('0x36')]=qs[_0x0165('0x36')](_0x352cd4['query'][_0x0165('0x36')]);}_0x4b1393[_0x0165('0x37')]=qs[_0x0165('0x38')](_0x352cd4[_0x0165('0x30')]['sort']);_0x4b1393[_0x0165('0x39')]=qs['filters'](_[_0x0165('0x3a')](_0x352cd4[_0x0165('0x30')],_0x5531fc[_0x0165('0x31')]),_0x1063f6);if(_0x352cd4['query']['filter']){_0x4b1393[_0x0165('0x39')]=_[_0x0165('0x3b')](_0x4b1393[_0x0165('0x39')],{'$or':_[_0x0165('0x2f')](_0x1063f6,function(_0x1f9cc1){if(_0x1f9cc1[_0x0165('0x3c')]!==_0x0165('0x3d')){var _0x41ea9c={};_0x41ea9c[_0x1f9cc1[_0x0165('0x29')]]={'$like':'%'+_0x352cd4[_0x0165('0x30')][_0x0165('0x3e')]+'%'};return _0x41ea9c;}})});}_0x4b1393=_[_0x0165('0x3b')]({},_0x4b1393,_0x352cd4['options']);var _0x57b093={'where':_0x4b1393[_0x0165('0x39')]};return db[_0x0165('0x2b')][_0x0165('0x1e')](_0x57b093)[_0x0165('0x27')](function(_0x4738c0){_0x3f3482[_0x0165('0x1e')]=_0x4738c0;if(_0x352cd4['query']['includeAll']){_0x4b1393['include']=[{'all':!![]}];}return db[_0x0165('0x2b')][_0x0165('0x3f')](_0x4b1393);})[_0x0165('0x27')](function(_0x31833e){_0x3f3482[_0x0165('0x40')]=_0x31833e;return _0x3f3482;})[_0x0165('0x27')](respondWithFilteredResult(_0x2b78a2,_0x4b1393))[_0x0165('0x41')](handleError(_0x2b78a2,null));};exports['show']=function(_0x28cea5,_0xb93535){var _0x317e7e={'raw':!![],'where':{'id':_0x28cea5[_0x0165('0x42')]['id']}},_0x391086={};_0x391086['model']=_[_0x0165('0x43')](db['FaxTransferReport'][_0x0165('0x2c')]);_0x391086['query']=_[_0x0165('0x43')](_0x28cea5['query']);_0x391086[_0x0165('0x31')]=_[_0x0165('0x32')](_0x391086[_0x0165('0x2e')],_0x391086[_0x0165('0x30')]);_0x317e7e[_0x0165('0x34')]=_['intersection'](_0x391086[_0x0165('0x2e')],qs[_0x0165('0x33')](_0x28cea5[_0x0165('0x30')][_0x0165('0x33')]));_0x317e7e[_0x0165('0x34')]=_0x317e7e[_0x0165('0x34')][_0x0165('0x44')]?_0x317e7e[_0x0165('0x34')]:_0x391086[_0x0165('0x2e')];if(_0x28cea5[_0x0165('0x30')][_0x0165('0x45')]){_0x317e7e[_0x0165('0x46')]=[{'all':!![]}];}_0x317e7e=_[_0x0165('0x3b')]({},_0x317e7e,_0x28cea5[_0x0165('0x47')]);return db[_0x0165('0x2b')][_0x0165('0x48')](_0x317e7e)[_0x0165('0x27')](handleEntityNotFound(_0xb93535,null))[_0x0165('0x27')](respondWithResult(_0xb93535,null))[_0x0165('0x41')](handleError(_0xb93535,null));};exports['create']=function(_0x10b9c6,_0x2f8dec){return db['FaxTransferReport'][_0x0165('0x49')](_0x10b9c6[_0x0165('0x4a')],{})['then'](respondWithResult(_0x2f8dec,0xc9))[_0x0165('0x41')](handleError(_0x2f8dec,null));};exports[_0x0165('0x25')]=function(_0x398476,_0x4193f1){if(_0x398476[_0x0165('0x4a')]['id']){delete _0x398476[_0x0165('0x4a')]['id'];}return db[_0x0165('0x2b')][_0x0165('0x48')]({'where':{'id':_0x398476['params']['id']}})[_0x0165('0x27')](handleEntityNotFound(_0x4193f1,null))[_0x0165('0x27')](saveUpdates(_0x398476[_0x0165('0x4a')],null))[_0x0165('0x27')](respondWithResult(_0x4193f1,null))[_0x0165('0x41')](handleError(_0x4193f1,null));};exports[_0x0165('0x26')]=function(_0x222d48,_0x5d6379){return db[_0x0165('0x2b')][_0x0165('0x48')]({'where':{'id':_0x222d48[_0x0165('0x42')]['id']}})['then'](handleEntityNotFound(_0x5d6379,null))[_0x0165('0x27')](removeEntity(_0x5d6379,null))['catch'](handleError(_0x5d6379,null));};exports[_0x0165('0x4b')]=function(_0xd22673,_0xa7ea4e){return db['FaxTransferReport'][_0x0165('0x4b')]()[_0x0165('0x27')](respondWithResult(_0xa7ea4e,null))['catch'](handleError(_0xa7ea4e,null));}; \ No newline at end of file diff --git a/server/api/faxTransferReport/faxTransferReport.model.js b/server/api/faxTransferReport/faxTransferReport.model.js new file mode 100644 index 0000000..0a5923a --- /dev/null +++ b/server/api/faxTransferReport/faxTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf84a=['bluebird','path','rimraf','./faxTransferReport.attributes','exports','FaxTransferReport','report_fax_transfer','uniqueid','../../config/logger','api','moment'];(function(_0x46e363,_0x45d7e2){var _0x3fb059=function(_0x5e6274){while(--_0x5e6274){_0x46e363['push'](_0x46e363['shift']());}};_0x3fb059(++_0x45d7e2);}(_0xf84a,0x97));var _0xaf84=function(_0x31fd85,_0x2e7c56){_0x31fd85=_0x31fd85-0x0;var _0x406165=_0xf84a[_0x31fd85];return _0x406165;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xaf84('0x0'))(_0xaf84('0x1'));var moment=require(_0xaf84('0x2'));var BPromise=require(_0xaf84('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xaf84('0x4'));var rimraf=require(_0xaf84('0x5'));var config=require('../../config/environment');var attributes=require(_0xaf84('0x6'));module[_0xaf84('0x7')]=function(_0x246ab7,_0x3db4e9){return _0x246ab7['define'](_0xaf84('0x8'),attributes,{'tableName':_0xaf84('0x9'),'paranoid':![],'indexes':[{'name':_0xaf84('0xa'),'fields':[_0xaf84('0xa')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/faxTransferReport/faxTransferReport.rpc.js b/server/api/faxTransferReport/faxTransferReport.rpc.js new file mode 100644 index 0000000..324f1c6 --- /dev/null +++ b/server/api/faxTransferReport/faxTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x17ee=['client','http','request','then','info','FaxTransferReport,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','lodash','util','moment','randomstring','ioredis','rpc','../../config/environment','jayson/promise'];(function(_0x4c4bd,_0x1cb75a){var _0x59cd87=function(_0x127042){while(--_0x127042){_0x4c4bd['push'](_0x4c4bd['shift']());}};_0x59cd87(++_0x1cb75a);}(_0x17ee,0x1d3));var _0xe17e=function(_0x4ec64d,_0x248423){_0x4ec64d=_0x4ec64d-0x0;var _0x246fc8=_0x17ee[_0x4ec64d];return _0x246fc8;};'use strict';var _=require(_0xe17e('0x0'));var util=require(_0xe17e('0x1'));var moment=require(_0xe17e('0x2'));var BPromise=require('bluebird');var rs=require(_0xe17e('0x3'));var fs=require('fs');var Redis=require(_0xe17e('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xe17e('0x5'));var config=require(_0xe17e('0x6'));var jayson=require(_0xe17e('0x7'));var client=jayson[_0xe17e('0x8')][_0xe17e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x14a119,_0x2d9f2a,_0xe71e37){return new BPromise(function(_0x4d2744,_0x50ac4d){return client[_0xe17e('0xa')](_0x14a119,_0xe71e37)[_0xe17e('0xb')](function(_0x487e5d){logger[_0xe17e('0xc')](_0xe17e('0xd'),_0x2d9f2a,_0xe17e('0xe'));logger['debug']('FaxTransferReport,\x20%s,\x20%s,\x20%s',_0x2d9f2a,_0xe17e('0xe'),JSON[_0xe17e('0xf')](_0x487e5d));if(_0x487e5d[_0xe17e('0x10')]){if(_0x487e5d[_0xe17e('0x10')]['code']===0x1f4){logger['error'](_0xe17e('0xd'),_0x2d9f2a,_0x487e5d[_0xe17e('0x10')][_0xe17e('0x11')]);return _0x50ac4d(_0x487e5d['error'][_0xe17e('0x11')]);}logger[_0xe17e('0x10')](_0xe17e('0xd'),_0x2d9f2a,_0x487e5d[_0xe17e('0x10')][_0xe17e('0x11')]);return _0x4d2744(_0x487e5d[_0xe17e('0x10')][_0xe17e('0x11')]);}else{logger[_0xe17e('0xc')](_0xe17e('0xd'),_0x2d9f2a,'request\x20sent');_0x4d2744(_0x487e5d[_0xe17e('0x12')][_0xe17e('0x11')]);}})['catch'](function(_0x4d651){logger[_0xe17e('0x10')](_0xe17e('0xd'),_0x2d9f2a,_0x4d651);_0x50ac4d(_0x4d651);});});} \ No newline at end of file diff --git a/server/api/faxTransferReport/index.js b/server/api/faxTransferReport/index.js new file mode 100644 index 0000000..4ba5d02 --- /dev/null +++ b/server/api/faxTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7e7b=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','./faxTransferReport.controller','get','isAuthenticated','/describe','describe','show','post','put','update','/:id','destroy','exports','multer','util','path','connect-timeout','express'];(function(_0x3b5250,_0x7a0b2c){var _0xc844a1=function(_0x2fbc98){while(--_0x2fbc98){_0x3b5250['push'](_0x3b5250['shift']());}};_0xc844a1(++_0x7a0b2c);}(_0x7e7b,0x8e));var _0xb7e7=function(_0x357681,_0x7447cc){_0x357681=_0x357681-0x0;var _0xa009ba=_0x7e7b[_0x357681];return _0xa009ba;};'use strict';var multer=require(_0xb7e7('0x0'));var util=require(_0xb7e7('0x1'));var path=require(_0xb7e7('0x2'));var timeout=require(_0xb7e7('0x3'));var express=require(_0xb7e7('0x4'));var router=express[_0xb7e7('0x5')]();var fs_extra=require(_0xb7e7('0x6'));var auth=require(_0xb7e7('0x7'));var interaction=require(_0xb7e7('0x8'));var config=require('../../config/environment');var controller=require(_0xb7e7('0x9'));router[_0xb7e7('0xa')]('/',auth[_0xb7e7('0xb')](),controller['index']);router['get'](_0xb7e7('0xc'),auth[_0xb7e7('0xb')](),controller[_0xb7e7('0xd')]);router['get']('/:id',auth[_0xb7e7('0xb')](),controller[_0xb7e7('0xe')]);router[_0xb7e7('0xf')]('/',auth['isAuthenticated'](),controller['create']);router[_0xb7e7('0x10')]('/:id',auth['isAuthenticated'](),controller[_0xb7e7('0x11')]);router['delete'](_0xb7e7('0x12'),auth[_0xb7e7('0xb')](),controller[_0xb7e7('0x13')]);module[_0xb7e7('0x14')]=router; \ No newline at end of file diff --git a/server/api/intDeskAccount/index.js b/server/api/intDeskAccount/index.js new file mode 100644 index 0000000..f2a6523 --- /dev/null +++ b/server/api/intDeskAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5226=['getConfigurations','/:id/fields','getFields','post','create','/:id/configurations','addConfiguration','put','update','delete','exports','multer','util','path','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','./intDeskAccount.controller','isAuthenticated','index','get','/:id','show'];(function(_0x3c7350,_0xbff380){var _0x5a0666=function(_0x435607){while(--_0x435607){_0x3c7350['push'](_0x3c7350['shift']());}};_0x5a0666(++_0xbff380);}(_0x5226,0x137));var _0x6522=function(_0x5b6a49,_0x3621d3){_0x5b6a49=_0x5b6a49-0x0;var _0x52cb4d=_0x5226[_0x5b6a49];return _0x52cb4d;};'use strict';var multer=require(_0x6522('0x0'));var util=require(_0x6522('0x1'));var path=require(_0x6522('0x2'));var timeout=require(_0x6522('0x3'));var express=require(_0x6522('0x4'));var router=express['Router']();var fs_extra=require(_0x6522('0x5'));var auth=require(_0x6522('0x6'));var interaction=require(_0x6522('0x7'));var config=require('../../config/environment');var controller=require(_0x6522('0x8'));router['get']('/',auth[_0x6522('0x9')](),controller[_0x6522('0xa')]);router[_0x6522('0xb')](_0x6522('0xc'),auth[_0x6522('0x9')](),controller[_0x6522('0xd')]);router[_0x6522('0xb')]('/:id/configurations',auth['isAuthenticated'](),controller[_0x6522('0xe')]);router[_0x6522('0xb')](_0x6522('0xf'),auth[_0x6522('0x9')](),controller[_0x6522('0x10')]);router[_0x6522('0x11')]('/',auth[_0x6522('0x9')](),controller[_0x6522('0x12')]);router[_0x6522('0x11')](_0x6522('0x13'),auth[_0x6522('0x9')](),controller[_0x6522('0x14')]);router[_0x6522('0x15')]('/:id',auth[_0x6522('0x9')](),controller[_0x6522('0x16')]);router[_0x6522('0x17')](_0x6522('0xc'),auth[_0x6522('0x9')](),controller['destroy']);module[_0x6522('0x18')]=router; \ No newline at end of file diff --git a/server/api/intDeskAccount/intDeskAccount.attributes.js b/server/api/intDeskAccount/intDeskAccount.attributes.js new file mode 100644 index 0000000..25e6bc1 --- /dev/null +++ b/server/api/intDeskAccount/intDeskAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xae88=['newTab','sequelize','exports','STRING','ENUM','basic','integrationTab'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xae88,0x1a5));var _0x8ae8=function(_0x3fdfff,_0x3a02b6){_0x3fdfff=_0x3fdfff-0x0;var _0x3c7681=_0xae88[_0x3fdfff];return _0x3c7681;};'use strict';var Sequelize=require(_0x8ae8('0x0'));module[_0x8ae8('0x1')]={'name':{'type':Sequelize[_0x8ae8('0x2')]},'description':{'type':Sequelize[_0x8ae8('0x2')]},'username':{'type':Sequelize[_0x8ae8('0x2')]},'remoteUri':{'type':Sequelize[_0x8ae8('0x2')]},'authType':{'type':Sequelize[_0x8ae8('0x3')](_0x8ae8('0x4')),'defaultValue':'basic'},'password':{'type':Sequelize[_0x8ae8('0x2')]},'consumerKey':{'type':Sequelize[_0x8ae8('0x2')]},'consumerSecret':{'type':Sequelize[_0x8ae8('0x2')]},'token':{'type':Sequelize[_0x8ae8('0x2')]},'tokenSecret':{'type':Sequelize['STRING']},'serverUrl':{'type':Sequelize[_0x8ae8('0x2')],'allowNull':![]},'type':{'type':Sequelize[_0x8ae8('0x3')](_0x8ae8('0x5'),_0x8ae8('0x6')),'defaultValue':_0x8ae8('0x5')}}; \ No newline at end of file diff --git a/server/api/intDeskAccount/intDeskAccount.controller.js b/server/api/intDeskAccount/intDeskAccount.controller.js new file mode 100644 index 0000000..c0d1d5b --- /dev/null +++ b/server/api/intDeskAccount/intDeskAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe3b7=['length','Subjects','getSubjects','channel','getDescriptions','DeskField','Descriptions','priority','authType','username','consumerSecret','token','tokenSecret','remoteUri','substring','lastIndexOf','format','application/json','basic','headers','Authorization','Basic\x20%s','%s:%s','password','toString','concat','_embedded','active','label','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','path','sox','ejs','fs-extra','lodash','squel','crypto','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','status','set','reject','save','update','destroy','then','error','name','send','index','map','DeskAccount','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','include','findAll','rows','catch','show','params','includeAll','options','find','create','body','getConfigurations','findOne','DeskConfiguration'];(function(_0x56fd04,_0x5da37b){var _0x362197=function(_0x491948){while(--_0x491948){_0x56fd04['push'](_0x56fd04['shift']());}};_0x362197(++_0x5da37b);}(_0xe3b7,0x1d0));var _0x7e3b=function(_0x40bffc,_0x3a45d7){_0x40bffc=_0x40bffc-0x0;var _0x3007e9=_0xe3b7[_0x40bffc];return _0x3007e9;};'use strict';var emlformat=require(_0x7e3b('0x0'));var rimraf=require(_0x7e3b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x7e3b('0x2'));var rp=require(_0x7e3b('0x3'));var moment=require(_0x7e3b('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x7e3b('0x5'));var util=require('util');var path=require(_0x7e3b('0x6'));var sox=require(_0x7e3b('0x7'));var csv=require('to-csv');var ejs=require(_0x7e3b('0x8'));var fs=require('fs');var fs_extra=require(_0x7e3b('0x9'));var _=require(_0x7e3b('0xa'));var squel=require(_0x7e3b('0xb'));var crypto=require(_0x7e3b('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x7e3b('0xd'));var querystring=require(_0x7e3b('0xe'));var Papa=require(_0x7e3b('0xf'));var Redis=require(_0x7e3b('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x7e3b('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7e3b('0x12'))(_0x7e3b('0x13'));var utils=require(_0x7e3b('0x14'));var config=require(_0x7e3b('0x15'));var licenseUtil=require(_0x7e3b('0x16'));var db=require(_0x7e3b('0x17'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x28aa72,_0x39628a){_0x39628a=_0x39628a||0xcc;return function(_0x424676){if(_0x424676){return _0x28aa72[_0x7e3b('0x18')](_0x39628a);}return _0x28aa72['status'](_0x39628a)[_0x7e3b('0x19')]();};}function respondWithResult(_0x1f108c,_0x503518){_0x503518=_0x503518||0xc8;return function(_0x532333){if(_0x532333){return _0x1f108c['status'](_0x503518)[_0x7e3b('0x1a')](_0x532333);}};}function respondWithFilteredResult(_0x5324a7,_0x1909ca){return function(_0x4e7967){if(_0x4e7967){var _0x179dc8=typeof _0x1909ca[_0x7e3b('0x1b')]===_0x7e3b('0x1c')&&typeof _0x1909ca[_0x7e3b('0x1d')]===_0x7e3b('0x1c');var _0x1967df=_0x4e7967[_0x7e3b('0x1e')];var _0x15c0e=_0x179dc8?0x0:_0x1909ca[_0x7e3b('0x1b')];var _0x236e6=_0x179dc8?_0x4e7967[_0x7e3b('0x1e')]:_0x1909ca[_0x7e3b('0x1b')]+_0x1909ca[_0x7e3b('0x1d')];var _0x34be79;if(_0x236e6>=_0x1967df){_0x236e6=_0x1967df;_0x34be79=0xc8;}else{_0x34be79=0xce;}_0x5324a7[_0x7e3b('0x1f')](_0x34be79);return _0x5324a7[_0x7e3b('0x20')]('Content-Range',_0x15c0e+'-'+_0x236e6+'/'+_0x1967df)[_0x7e3b('0x1a')](_0x4e7967);}return null;};}function patchUpdates(_0x33393f){return function(_0x11607a){try{jsonpatch['apply'](_0x11607a,_0x33393f,!![]);}catch(_0xf8a244){return BPromise[_0x7e3b('0x21')](_0xf8a244);}return _0x11607a[_0x7e3b('0x22')]();};}function saveUpdates(_0x21f098,_0x356423){return function(_0x1b319d){if(_0x1b319d){return _0x1b319d[_0x7e3b('0x23')](_0x21f098)['then'](function(_0x5b2559){return _0x5b2559;});}return null;};}function removeEntity(_0x9e6ec3,_0x5214c5){return function(_0xf6a900){if(_0xf6a900){return _0xf6a900[_0x7e3b('0x24')]()[_0x7e3b('0x25')](function(){_0x9e6ec3['status'](0xcc)[_0x7e3b('0x19')]();});}};}function handleEntityNotFound(_0x59a92f,_0x12b36b){return function(_0x5d54ba){if(!_0x5d54ba){_0x59a92f[_0x7e3b('0x18')](0x194);}return _0x5d54ba;};}function handleError(_0x3b96d3,_0x60e7c2){_0x60e7c2=_0x60e7c2||0x1f4;return function(_0x1fc199){logger[_0x7e3b('0x26')](_0x1fc199['stack']);if(_0x1fc199['name']){delete _0x1fc199[_0x7e3b('0x27')];}_0x3b96d3[_0x7e3b('0x1f')](_0x60e7c2)[_0x7e3b('0x28')](_0x1fc199);};}exports[_0x7e3b('0x29')]=function(_0x1d7303,_0x1a21ce){var _0xa54046={},_0x1f3d9d={},_0x208992={'count':0x0,'rows':[]};var _0x9ba38c=_[_0x7e3b('0x2a')](db[_0x7e3b('0x2b')][_0x7e3b('0x2c')],function(_0x37ecf8){return{'name':_0x37ecf8['fieldName'],'type':_0x37ecf8['type'][_0x7e3b('0x2d')]};});_0x1f3d9d[_0x7e3b('0x2e')]=_['map'](_0x9ba38c,_0x7e3b('0x27'));_0x1f3d9d[_0x7e3b('0x2f')]=_[_0x7e3b('0x30')](_0x1d7303[_0x7e3b('0x2f')]);_0x1f3d9d[_0x7e3b('0x31')]=_[_0x7e3b('0x32')](_0x1f3d9d[_0x7e3b('0x2e')],_0x1f3d9d[_0x7e3b('0x2f')]);_0xa54046[_0x7e3b('0x33')]=_['intersection'](_0x1f3d9d[_0x7e3b('0x2e')],qs[_0x7e3b('0x34')](_0x1d7303['query'][_0x7e3b('0x34')]));_0xa54046[_0x7e3b('0x33')]=_0xa54046[_0x7e3b('0x33')]['length']?_0xa54046['attributes']:_0x1f3d9d[_0x7e3b('0x2e')];if(!_0x1d7303[_0x7e3b('0x2f')][_0x7e3b('0x35')](_0x7e3b('0x36'))){_0xa54046[_0x7e3b('0x1d')]=qs[_0x7e3b('0x1d')](_0x1d7303[_0x7e3b('0x2f')][_0x7e3b('0x1d')]);_0xa54046['offset']=qs[_0x7e3b('0x1b')](_0x1d7303[_0x7e3b('0x2f')][_0x7e3b('0x1b')]);}_0xa54046[_0x7e3b('0x37')]=qs[_0x7e3b('0x38')](_0x1d7303[_0x7e3b('0x2f')]['sort']);_0xa54046['where']=qs[_0x7e3b('0x31')](_[_0x7e3b('0x39')](_0x1d7303[_0x7e3b('0x2f')],_0x1f3d9d['filters']),_0x9ba38c);if(_0x1d7303['query'][_0x7e3b('0x3a')]){_0xa54046[_0x7e3b('0x3b')]=_[_0x7e3b('0x3c')](_0xa54046[_0x7e3b('0x3b')],{'$or':_[_0x7e3b('0x2a')](_0x9ba38c,function(_0x36f600){if(_0x36f600[_0x7e3b('0x3d')]!=='VIRTUAL'){var _0xeef891={};_0xeef891[_0x36f600[_0x7e3b('0x27')]]={'$like':'%'+_0x1d7303[_0x7e3b('0x2f')][_0x7e3b('0x3a')]+'%'};return _0xeef891;}})});}_0xa54046=_[_0x7e3b('0x3c')]({},_0xa54046,_0x1d7303['options']);var _0x58dc87={'where':_0xa54046[_0x7e3b('0x3b')]};return db[_0x7e3b('0x2b')][_0x7e3b('0x1e')](_0x58dc87)[_0x7e3b('0x25')](function(_0x173827){_0x208992[_0x7e3b('0x1e')]=_0x173827;if(_0x1d7303[_0x7e3b('0x2f')]['includeAll']){_0xa54046[_0x7e3b('0x3e')]=[{'all':!![]}];}return db[_0x7e3b('0x2b')][_0x7e3b('0x3f')](_0xa54046);})[_0x7e3b('0x25')](function(_0x4e6ccf){_0x208992[_0x7e3b('0x40')]=_0x4e6ccf;return _0x208992;})[_0x7e3b('0x25')](respondWithFilteredResult(_0x1a21ce,_0xa54046))[_0x7e3b('0x41')](handleError(_0x1a21ce,null));};exports[_0x7e3b('0x42')]=function(_0x4e8cfb,_0x2e292c){var _0x38ad2a={'raw':![],'where':{'id':_0x4e8cfb[_0x7e3b('0x43')]['id']}},_0x1b4e12={};_0x1b4e12[_0x7e3b('0x2e')]=_[_0x7e3b('0x30')](db[_0x7e3b('0x2b')][_0x7e3b('0x2c')]);_0x1b4e12['query']=_['keys'](_0x4e8cfb[_0x7e3b('0x2f')]);_0x1b4e12[_0x7e3b('0x31')]=_[_0x7e3b('0x32')](_0x1b4e12[_0x7e3b('0x2e')],_0x1b4e12[_0x7e3b('0x2f')]);_0x38ad2a[_0x7e3b('0x33')]=_[_0x7e3b('0x32')](_0x1b4e12[_0x7e3b('0x2e')],qs[_0x7e3b('0x34')](_0x4e8cfb[_0x7e3b('0x2f')][_0x7e3b('0x34')]));_0x38ad2a['attributes']=_0x38ad2a[_0x7e3b('0x33')]['length']?_0x38ad2a[_0x7e3b('0x33')]:_0x1b4e12[_0x7e3b('0x2e')];if(_0x4e8cfb[_0x7e3b('0x2f')][_0x7e3b('0x44')]){_0x38ad2a[_0x7e3b('0x3e')]=[{'all':!![]}];}_0x38ad2a=_['merge']({},_0x38ad2a,_0x4e8cfb[_0x7e3b('0x45')]);return db[_0x7e3b('0x2b')][_0x7e3b('0x46')](_0x38ad2a)[_0x7e3b('0x25')](handleEntityNotFound(_0x2e292c,null))[_0x7e3b('0x25')](respondWithResult(_0x2e292c,null))[_0x7e3b('0x41')](handleError(_0x2e292c,null));};exports[_0x7e3b('0x47')]=function(_0xb4a844,_0x2e5a8d){return db[_0x7e3b('0x2b')][_0x7e3b('0x47')](_0xb4a844[_0x7e3b('0x48')],{})['then'](respondWithResult(_0x2e5a8d,0xc9))[_0x7e3b('0x41')](handleError(_0x2e5a8d,null));};exports[_0x7e3b('0x23')]=function(_0x15c8fb,_0x4f39c5){if(_0x15c8fb[_0x7e3b('0x48')]['id']){delete _0x15c8fb[_0x7e3b('0x48')]['id'];}return db[_0x7e3b('0x2b')][_0x7e3b('0x46')]({'where':{'id':_0x15c8fb[_0x7e3b('0x43')]['id']}})[_0x7e3b('0x25')](handleEntityNotFound(_0x4f39c5,null))[_0x7e3b('0x25')](saveUpdates(_0x15c8fb[_0x7e3b('0x48')],null))[_0x7e3b('0x25')](respondWithResult(_0x4f39c5,null))[_0x7e3b('0x41')](handleError(_0x4f39c5,null));};exports[_0x7e3b('0x24')]=function(_0x116cc2,_0x2ce0fd){return db[_0x7e3b('0x2b')]['find']({'where':{'id':_0x116cc2['params']['id']}})[_0x7e3b('0x25')](handleEntityNotFound(_0x2ce0fd,null))['then'](removeEntity(_0x2ce0fd,null))[_0x7e3b('0x41')](handleError(_0x2ce0fd,null));};exports[_0x7e3b('0x49')]=function(_0x2064c9,_0x3917f2,_0x2b93c5){var _0x527e4b={};var _0x4f6b2d={};var _0x358bf9;var _0x1a48c9;return db[_0x7e3b('0x2b')][_0x7e3b('0x4a')]({'where':{'id':_0x2064c9[_0x7e3b('0x43')]['id']}})['then'](handleEntityNotFound(_0x3917f2,null))[_0x7e3b('0x25')](function(_0x6baaa){if(_0x6baaa){_0x358bf9=_0x6baaa;_0x4f6b2d[_0x7e3b('0x2e')]=_[_0x7e3b('0x30')](db[_0x7e3b('0x4b')]['rawAttributes']);_0x4f6b2d[_0x7e3b('0x2f')]=_[_0x7e3b('0x30')](_0x2064c9[_0x7e3b('0x2f')]);_0x4f6b2d[_0x7e3b('0x31')]=_[_0x7e3b('0x32')](_0x4f6b2d[_0x7e3b('0x2e')],_0x4f6b2d[_0x7e3b('0x2f')]);_0x527e4b[_0x7e3b('0x33')]=_['intersection'](_0x4f6b2d['model'],qs[_0x7e3b('0x34')](_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x34')]));_0x527e4b['attributes']=_0x527e4b['attributes'][_0x7e3b('0x4c')]?_0x527e4b[_0x7e3b('0x33')]:_0x4f6b2d['model'];_0x527e4b['order']=qs['sort'](_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x38')]);_0x527e4b['where']=qs[_0x7e3b('0x31')](_['pick'](_0x2064c9[_0x7e3b('0x2f')],_0x4f6b2d[_0x7e3b('0x31')]));if(_0x2064c9['query'][_0x7e3b('0x3a')]){_0x527e4b[_0x7e3b('0x3b')]=_[_0x7e3b('0x3c')](_0x527e4b[_0x7e3b('0x3b')],{'$or':_['map'](_0x527e4b[_0x7e3b('0x33')],function(_0x11c29e){var _0x5d7acf={};_0x5d7acf[_0x11c29e]={'$like':'%'+_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x3a')]+'%'};return _0x5d7acf;})});}_0x527e4b=_[_0x7e3b('0x3c')]({},_0x527e4b,_0x2064c9[_0x7e3b('0x45')]);return _0x358bf9[_0x7e3b('0x49')](_0x527e4b);}})[_0x7e3b('0x25')](function(_0x44c65b){if(_0x44c65b){_0x1a48c9=_0x44c65b[_0x7e3b('0x4c')];if(!_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x35')](_0x7e3b('0x36'))){_0x527e4b['limit']=qs['limit'](_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x1d')]);_0x527e4b[_0x7e3b('0x1b')]=qs[_0x7e3b('0x1b')](_0x2064c9[_0x7e3b('0x2f')][_0x7e3b('0x1b')]);}return _0x358bf9[_0x7e3b('0x49')](_0x527e4b);}})['then'](function(_0x412699){if(_0x412699){return _0x412699?{'count':_0x1a48c9,'rows':_0x412699}:null;}})[_0x7e3b('0x25')](respondWithResult(_0x3917f2,null))[_0x7e3b('0x41')](handleError(_0x3917f2,null));};exports['addConfiguration']=function(_0x68a221,_0x323272,_0x5ef0b0){if(_0x68a221[_0x7e3b('0x48')]['id']){delete _0x68a221[_0x7e3b('0x48')]['id'];}return db[_0x7e3b('0x2b')][_0x7e3b('0x4a')]({'where':{'id':_0x68a221['params']['id']}})[_0x7e3b('0x25')](handleEntityNotFound(_0x323272,null))[_0x7e3b('0x25')](function(_0x5566ff){if(_0x5566ff){_0x68a221[_0x7e3b('0x48')]['AccountId']=_0x5566ff['id'];_0x68a221[_0x7e3b('0x48')][_0x7e3b('0x4d')]=integrations[_0x7e3b('0x4e')](_0x68a221[_0x7e3b('0x48')][_0x7e3b('0x4f')],_0x68a221['body']['type']);_0x68a221['body']['Descriptions']=integrations[_0x7e3b('0x50')](_0x68a221[_0x7e3b('0x48')][_0x7e3b('0x4f')],_0x68a221[_0x7e3b('0x48')][_0x7e3b('0x3d')]);return db[_0x7e3b('0x4b')][_0x7e3b('0x47')](_0x68a221[_0x7e3b('0x48')],{'include':[{'model':db[_0x7e3b('0x51')],'as':_0x7e3b('0x4d')},{'model':db[_0x7e3b('0x51')],'as':_0x7e3b('0x52')}]});}return null;})[_0x7e3b('0x25')](respondWithResult(_0x323272,null))[_0x7e3b('0x41')](handleError(_0x323272,null));};exports['getFields']=function(_0x52d727,_0x15534f,_0x2e8af2){var _0x1fbd00=[{'name':_0x7e3b('0x53'),'label':_0x7e3b('0x53'),'custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x5e1699='';return db[_0x7e3b('0x2b')][_0x7e3b('0x4a')]({'where':{'id':_0x52d727[_0x7e3b('0x43')]['id']},'attributes':['id','remoteUri',_0x7e3b('0x54'),_0x7e3b('0x55'),'password','consumerKey',_0x7e3b('0x56'),_0x7e3b('0x57'),_0x7e3b('0x58')]})[_0x7e3b('0x25')](handleEntityNotFound(_0x15534f,null))[_0x7e3b('0x25')](function(_0x102814){if(_0x102814){_0x5e1699=_0x102814[_0x7e3b('0x59')];var _0x5b3101=_0x5e1699['slice'](-0x1);if(_0x5b3101==='/'){_0x5e1699=_0x5e1699[_0x7e3b('0x5a')](0x0,_0x5e1699[_0x7e3b('0x5b')](_0x5b3101));}var _0x33cd3e={'method':'GET','uri':util[_0x7e3b('0x5c')]('%s/custom_fields',_0x5e1699),'headers':{'Content-Type':_0x7e3b('0x5d'),'Accept':'application/json'},'json':!![]};if(_0x102814[_0x7e3b('0x54')]===_0x7e3b('0x5e')){_0x33cd3e[_0x7e3b('0x5f')][_0x7e3b('0x60')]=util[_0x7e3b('0x5c')](_0x7e3b('0x61'),new Buffer(util[_0x7e3b('0x5c')](_0x7e3b('0x62'),_0x102814[_0x7e3b('0x55')],_0x102814[_0x7e3b('0x63')]))[_0x7e3b('0x64')]('base64'));}return rp(_0x33cd3e)[_0x7e3b('0x25')](function(_0x318fa0){return _0x1fbd00[_0x7e3b('0x65')](_[_0x7e3b('0x2a')](_0x318fa0[_0x7e3b('0x66')]['entries'],function(_0x2490cf){return{'id':_0x2490cf['name'],'name':_0x2490cf[_0x7e3b('0x27')],'type':_0x2490cf[_0x7e3b('0x3d')],'active':_0x2490cf[_0x7e3b('0x67')],'label':_0x2490cf[_0x7e3b('0x68')],'custom':!![]};}));});}})['then'](function(_0x4f8b56){return{'count':_0x4f8b56[_0x7e3b('0x4c')],'rows':_0x4f8b56};})[_0x7e3b('0x25')](respondWithResult(_0x15534f,null))[_0x7e3b('0x41')](function(_0x337cce){var _0x2d5b49=_0x52d727['query']['test']?0x1f4:_0x337cce['statusCode']||0x1f4;logger[_0x7e3b('0x26')](_0x7e3b('0x69'),'getFields',_0x2d5b49,JSON[_0x7e3b('0x6a')](_0x337cce));delete _0x337cce['name'];if(_0x2d5b49===0x191){_0x2d5b49=0x190;}_0x15534f[_0x7e3b('0x1f')](_0x2d5b49)['send'](_0x52d727[_0x7e3b('0x2f')]['test']?{'message':_0x7e3b('0x6b'),'statusCode':_0x337cce['statusCode']}:_0x337cce);});}; \ No newline at end of file diff --git a/server/api/intDeskAccount/intDeskAccount.model.js b/server/api/intDeskAccount/intDeskAccount.model.js new file mode 100644 index 0000000..0f9ba27 --- /dev/null +++ b/server/api/intDeskAccount/intDeskAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf839=['../../components/integrations/configuration','define','DeskAccount','int_desk_accounts','util','../../config/logger','api','moment','bluebird','request-promise','path','../../config/environment','./intDeskAccount.attributes'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0xf839,0x1cb));var _0x9f83=function(_0x4370a3,_0x3adfa3){_0x4370a3=_0x4370a3-0x0;var _0x21fb72=_0xf839[_0x4370a3];return _0x21fb72;};'use strict';var _=require('lodash');var util=require(_0x9f83('0x0'));var logger=require(_0x9f83('0x1'))(_0x9f83('0x2'));var moment=require(_0x9f83('0x3'));var BPromise=require(_0x9f83('0x4'));var rp=require(_0x9f83('0x5'));var fs=require('fs');var path=require(_0x9f83('0x6'));var rimraf=require('rimraf');var config=require(_0x9f83('0x7'));var attributes=require(_0x9f83('0x8'));var integrations=require(_0x9f83('0x9'));module['exports']=function(_0x5560f9,_0x2964e0){return _0x5560f9[_0x9f83('0xa')](_0x9f83('0xb'),attributes,{'tableName':_0x9f83('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDeskAccount/intDeskAccount.rpc.js b/server/api/intDeskAccount/intDeskAccount.rpc.js new file mode 100644 index 0000000..4a0af1b --- /dev/null +++ b/server/api/intDeskAccount/intDeskAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf9c7=['then','info','DeskAccount,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','catch','GetDeskAccount','findAll','options','raw','attributes','include','model','map','ShowDeskAccount','DeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xf9c7,0x1e9));var _0x7f9c=function(_0x49fb35,_0x121edc){_0x49fb35=_0x49fb35-0x0;var _0xd05ed7=_0xf9c7[_0x49fb35];return _0xd05ed7;};'use strict';var _=require(_0x7f9c('0x0'));var util=require(_0x7f9c('0x1'));var moment=require(_0x7f9c('0x2'));var BPromise=require(_0x7f9c('0x3'));var rs=require(_0x7f9c('0x4'));var fs=require('fs');var Redis=require(_0x7f9c('0x5'));var db=require(_0x7f9c('0x6'))['db'];var utils=require(_0x7f9c('0x7'));var logger=require(_0x7f9c('0x8'))(_0x7f9c('0x9'));var config=require(_0x7f9c('0xa'));var jayson=require(_0x7f9c('0xb'));var client=jayson[_0x7f9c('0xc')][_0x7f9c('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x130e95,_0x2f6891,_0x47d406){return new BPromise(function(_0x2128e6,_0x2421ea){return client[_0x7f9c('0xe')](_0x130e95,_0x47d406)[_0x7f9c('0xf')](function(_0x2e122d){logger[_0x7f9c('0x10')](_0x7f9c('0x11'),_0x2f6891,'request\x20sent');logger[_0x7f9c('0x12')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x2f6891,'request\x20sent',JSON[_0x7f9c('0x13')](_0x2e122d));if(_0x2e122d[_0x7f9c('0x14')]){if(_0x2e122d[_0x7f9c('0x14')][_0x7f9c('0x15')]===0x1f4){logger[_0x7f9c('0x14')](_0x7f9c('0x11'),_0x2f6891,_0x2e122d[_0x7f9c('0x14')][_0x7f9c('0x16')]);return _0x2421ea(_0x2e122d[_0x7f9c('0x14')][_0x7f9c('0x16')]);}logger[_0x7f9c('0x14')](_0x7f9c('0x11'),_0x2f6891,_0x2e122d[_0x7f9c('0x14')]['message']);return _0x2128e6(_0x2e122d[_0x7f9c('0x14')][_0x7f9c('0x16')]);}else{logger['info'](_0x7f9c('0x11'),_0x2f6891,_0x7f9c('0x17'));_0x2128e6(_0x2e122d['result']['message']);}})[_0x7f9c('0x18')](function(_0x2b74ed){logger['error'](_0x7f9c('0x11'),_0x2f6891,_0x2b74ed);_0x2421ea(_0x2b74ed);});});}exports[_0x7f9c('0x19')]=function(_0x15e08c){var _0x186599=this;return new Promise(function(_0x4fb29c,_0x3113e4){return db['DeskAccount'][_0x7f9c('0x1a')]({'raw':_0x15e08c[_0x7f9c('0x1b')]?_0x15e08c['options'][_0x7f9c('0x1c')]===undefined?!![]:![]:!![],'where':_0x15e08c[_0x7f9c('0x1b')]?_0x15e08c[_0x7f9c('0x1b')]['where']||null:null,'attributes':_0x15e08c[_0x7f9c('0x1b')]?_0x15e08c[_0x7f9c('0x1b')][_0x7f9c('0x1d')]||null:null,'limit':_0x15e08c['options']?_0x15e08c[_0x7f9c('0x1b')]['limit']||null:null,'include':_0x15e08c['options']?_0x15e08c[_0x7f9c('0x1b')]['include']?_['map'](_0x15e08c[_0x7f9c('0x1b')][_0x7f9c('0x1e')],function(_0xf879a6){return{'model':db[_0xf879a6[_0x7f9c('0x1f')]],'as':_0xf879a6['as'],'attributes':_0xf879a6[_0x7f9c('0x1d')],'include':_0xf879a6[_0x7f9c('0x1e')]?_[_0x7f9c('0x20')](_0xf879a6[_0x7f9c('0x1e')],function(_0x181d42){return{'model':db[_0x181d42[_0x7f9c('0x1f')]],'as':_0x181d42['as'],'attributes':_0x181d42['attributes'],'include':_0x181d42[_0x7f9c('0x1e')]?_[_0x7f9c('0x20')](_0x181d42[_0x7f9c('0x1e')],function(_0x2c49d8){return{'model':db[_0x2c49d8[_0x7f9c('0x1f')]],'as':_0x2c49d8['as'],'attributes':_0x2c49d8[_0x7f9c('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x7f9c('0xf')](function(_0x2787b2){logger[_0x7f9c('0x10')]('GetDeskAccount',_0x15e08c);logger[_0x7f9c('0x12')](_0x7f9c('0x19'),_0x15e08c,JSON[_0x7f9c('0x13')](_0x2787b2));_0x4fb29c(_0x2787b2);})[_0x7f9c('0x18')](function(_0xf43824){logger['error']('GetDeskAccount',_0xf43824[_0x7f9c('0x16')],_0x15e08c);_0x3113e4(_0x186599[_0x7f9c('0x14')](0x1f4,_0xf43824[_0x7f9c('0x16')]));});});};exports[_0x7f9c('0x21')]=function(_0x4d77e8){var _0x13f6bd=this;return new Promise(function(_0x3b5baa,_0x1c67c2){return db[_0x7f9c('0x22')][_0x7f9c('0x23')]({'raw':_0x4d77e8[_0x7f9c('0x1b')]?_0x4d77e8[_0x7f9c('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x4d77e8['options']?_0x4d77e8[_0x7f9c('0x1b')]['where']||null:null,'attributes':_0x4d77e8[_0x7f9c('0x1b')]?_0x4d77e8[_0x7f9c('0x1b')][_0x7f9c('0x1d')]||null:null,'include':_0x4d77e8[_0x7f9c('0x1b')]?_0x4d77e8['options'][_0x7f9c('0x1e')]?_['map'](_0x4d77e8[_0x7f9c('0x1b')][_0x7f9c('0x1e')],function(_0x1382e6){return{'model':db[_0x1382e6[_0x7f9c('0x1f')]],'as':_0x1382e6['as'],'attributes':_0x1382e6[_0x7f9c('0x1d')],'include':_0x1382e6[_0x7f9c('0x1e')]?_[_0x7f9c('0x20')](_0x1382e6[_0x7f9c('0x1e')],function(_0x267be4){return{'model':db[_0x267be4[_0x7f9c('0x1f')]],'as':_0x267be4['as'],'attributes':_0x267be4[_0x7f9c('0x1d')],'include':_0x267be4[_0x7f9c('0x1e')]?_['map'](_0x267be4[_0x7f9c('0x1e')],function(_0xba2c71){return{'model':db[_0xba2c71['model']],'as':_0xba2c71['as'],'attributes':_0xba2c71[_0x7f9c('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x351ee4){logger['info'](_0x7f9c('0x21'),_0x4d77e8);logger[_0x7f9c('0x12')]('ShowDeskAccount',_0x4d77e8,JSON[_0x7f9c('0x13')](_0x351ee4));_0x3b5baa(_0x351ee4);})['catch'](function(_0x34a733){logger[_0x7f9c('0x14')](_0x7f9c('0x21'),_0x34a733[_0x7f9c('0x16')],_0x4d77e8);_0x1c67c2(_0x13f6bd[_0x7f9c('0x14')](0x1f4,_0x34a733[_0x7f9c('0x16')]));});});}; \ No newline at end of file diff --git a/server/api/intDeskConfiguration/index.js b/server/api/intDeskConfiguration/index.js new file mode 100644 index 0000000..415296f --- /dev/null +++ b/server/api/intDeskConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c44=['destroy','exports','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','./intDeskConfiguration.controller','isAuthenticated','index','get','/:id','/:id/fields','getFields','getSubjects','/:id/descriptions','/:id/tags','post','setTags','put','update'];(function(_0x3eee0a,_0x915548){var _0x1051b4=function(_0x309bb8){while(--_0x309bb8){_0x3eee0a['push'](_0x3eee0a['shift']());}};_0x1051b4(++_0x915548);}(_0x9c44,0x178));var _0x49c4=function(_0x565c49,_0x54acd0){_0x565c49=_0x565c49-0x0;var _0x20ca34=_0x9c44[_0x565c49];return _0x20ca34;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x49c4('0x0'));var timeout=require(_0x49c4('0x1'));var express=require(_0x49c4('0x2'));var router=express[_0x49c4('0x3')]();var fs_extra=require(_0x49c4('0x4'));var auth=require(_0x49c4('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x49c4('0x6'));router['get']('/',auth[_0x49c4('0x7')](),controller[_0x49c4('0x8')]);router[_0x49c4('0x9')](_0x49c4('0xa'),auth[_0x49c4('0x7')](),controller['show']);router[_0x49c4('0x9')](_0x49c4('0xb'),auth[_0x49c4('0x7')](),controller[_0x49c4('0xc')]);router['get']('/:id/subjects',auth[_0x49c4('0x7')](),controller[_0x49c4('0xd')]);router['get'](_0x49c4('0xe'),auth[_0x49c4('0x7')](),controller['getDescriptions']);router['get'](_0x49c4('0xf'),auth[_0x49c4('0x7')](),controller['getTags']);router[_0x49c4('0x10')]('/',auth[_0x49c4('0x7')](),controller['create']);router[_0x49c4('0x10')](_0x49c4('0xf'),auth[_0x49c4('0x7')](),controller[_0x49c4('0x11')]);router[_0x49c4('0x12')](_0x49c4('0xa'),auth[_0x49c4('0x7')](),controller[_0x49c4('0x13')]);router['delete'](_0x49c4('0xa'),auth[_0x49c4('0x7')](),controller[_0x49c4('0x14')]);module[_0x49c4('0x15')]=router; \ No newline at end of file diff --git a/server/api/intDeskConfiguration/intDeskConfiguration.attributes.js b/server/api/intDeskConfiguration/intDeskConfiguration.attributes.js new file mode 100644 index 0000000..9c796e3 --- /dev/null +++ b/server/api/intDeskConfiguration/intDeskConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x71f9=['STRING','sequelize'];(function(_0x56d0d0,_0x36961a){var _0x20b608=function(_0x1657c4){while(--_0x1657c4){_0x56d0d0['push'](_0x56d0d0['shift']());}};_0x20b608(++_0x36961a);}(_0x71f9,0xff));var _0x971f=function(_0xed1ba6,_0x23f317){_0xed1ba6=_0xed1ba6-0x0;var _0xd9036b=_0x71f9[_0xed1ba6];return _0xd9036b;};'use strict';var Sequelize=require(_0x971f('0x0'));module['exports']={'name':{'type':Sequelize[_0x971f('0x1')]},'description':{'type':Sequelize[_0x971f('0x1')]}}; \ No newline at end of file diff --git a/server/api/intDeskConfiguration/intDeskConfiguration.controller.js b/server/api/intDeskConfiguration/intDeskConfiguration.controller.js new file mode 100644 index 0000000..2d214d4 --- /dev/null +++ b/server/api/intDeskConfiguration/intDeskConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c5e=['nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','catch','show','includeAll','include','find','create','body','update','getFields','findOne','params','DeskField','getSubjects','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','save','then','destroy','error','stack','name','send','index','map','DeskConfiguration','rawAttributes','fieldName','key','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty'];(function(_0x3542d2,_0x4586bb){var _0x175eac=function(_0x471df9){while(--_0x471df9){_0x3542d2['push'](_0x3542d2['shift']());}};_0x175eac(++_0x4586bb);}(_0x4c5e,0x73));var _0xe4c5=function(_0x367954,_0x54cdcc){_0x367954=_0x367954-0x0;var _0x4268aa=_0x4c5e[_0x367954];return _0x4268aa;};'use strict';var emlformat=require(_0xe4c5('0x0'));var rimraf=require(_0xe4c5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xe4c5('0x2'));var rp=require(_0xe4c5('0x3'));var moment=require(_0xe4c5('0x4'));var BPromise=require(_0xe4c5('0x5'));var Mustache=require(_0xe4c5('0x6'));var util=require(_0xe4c5('0x7'));var path=require(_0xe4c5('0x8'));var sox=require(_0xe4c5('0x9'));var csv=require(_0xe4c5('0xa'));var ejs=require(_0xe4c5('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xe4c5('0xc'));var crypto=require(_0xe4c5('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xe4c5('0xe'));var toCsv=require('to-csv');var querystring=require(_0xe4c5('0xf'));var Papa=require(_0xe4c5('0x10'));var Redis=require('ioredis');var authService=require(_0xe4c5('0x11'));var qs=require(_0xe4c5('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe4c5('0x13'));var logger=require(_0xe4c5('0x14'))(_0xe4c5('0x15'));var utils=require('../../config/utils');var config=require(_0xe4c5('0x16'));var licenseUtil=require(_0xe4c5('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x253dde,_0x103844){_0x103844=_0x103844||0xcc;return function(_0xe673ed){if(_0xe673ed){return _0x253dde[_0xe4c5('0x18')](_0x103844);}return _0x253dde[_0xe4c5('0x19')](_0x103844)[_0xe4c5('0x1a')]();};}function respondWithResult(_0x5c8819,_0x1e91a7){_0x1e91a7=_0x1e91a7||0xc8;return function(_0x3e98b4){if(_0x3e98b4){return _0x5c8819[_0xe4c5('0x19')](_0x1e91a7)[_0xe4c5('0x1b')](_0x3e98b4);}};}function respondWithFilteredResult(_0x70094d,_0x20a4aa){return function(_0x4d834f){if(_0x4d834f){var _0x2c7e3c=typeof _0x20a4aa['offset']==='undefined'&&typeof _0x20a4aa[_0xe4c5('0x1c')]===_0xe4c5('0x1d');var _0x3ba63c=_0x4d834f[_0xe4c5('0x1e')];var _0x1cbb32=_0x2c7e3c?0x0:_0x20a4aa[_0xe4c5('0x1f')];var _0x2a9178=_0x2c7e3c?_0x4d834f['count']:_0x20a4aa[_0xe4c5('0x1f')]+_0x20a4aa[_0xe4c5('0x1c')];var _0x477a2e;if(_0x2a9178>=_0x3ba63c){_0x2a9178=_0x3ba63c;_0x477a2e=0xc8;}else{_0x477a2e=0xce;}_0x70094d[_0xe4c5('0x19')](_0x477a2e);return _0x70094d[_0xe4c5('0x20')](_0xe4c5('0x21'),_0x1cbb32+'-'+_0x2a9178+'/'+_0x3ba63c)[_0xe4c5('0x1b')](_0x4d834f);}return null;};}function patchUpdates(_0x86454b){return function(_0x59ac74){try{jsonpatch[_0xe4c5('0x22')](_0x59ac74,_0x86454b,!![]);}catch(_0x3b6f68){return BPromise['reject'](_0x3b6f68);}return _0x59ac74[_0xe4c5('0x23')]();};}function saveUpdates(_0x17c980,_0xe0cf68){return function(_0x496540){if(_0x496540){return _0x496540['update'](_0x17c980)[_0xe4c5('0x24')](function(_0xd0669e){return _0xd0669e;});}return null;};}function removeEntity(_0x23c08b,_0x4505d3){return function(_0x4fd9f3){if(_0x4fd9f3){return _0x4fd9f3[_0xe4c5('0x25')]()[_0xe4c5('0x24')](function(){_0x23c08b[_0xe4c5('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4b516f,_0x4507bf){return function(_0x5c85c8){if(!_0x5c85c8){_0x4b516f['sendStatus'](0x194);}return _0x5c85c8;};}function handleError(_0x5f5d53,_0x366949){_0x366949=_0x366949||0x1f4;return function(_0x47dd35){logger[_0xe4c5('0x26')](_0x47dd35[_0xe4c5('0x27')]);if(_0x47dd35['name']){delete _0x47dd35[_0xe4c5('0x28')];}_0x5f5d53[_0xe4c5('0x19')](_0x366949)[_0xe4c5('0x29')](_0x47dd35);};}exports[_0xe4c5('0x2a')]=function(_0x35ef84,_0x56a802){var _0x44e92b={},_0x450e1f={},_0x4205fc={'count':0x0,'rows':[]};var _0x4179aa=_[_0xe4c5('0x2b')](db[_0xe4c5('0x2c')][_0xe4c5('0x2d')],function(_0x4f2bbf){return{'name':_0x4f2bbf[_0xe4c5('0x2e')],'type':_0x4f2bbf['type'][_0xe4c5('0x2f')]};});_0x450e1f['model']=_[_0xe4c5('0x2b')](_0x4179aa,_0xe4c5('0x28'));_0x450e1f[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x35ef84['query']);_0x450e1f[_0xe4c5('0x32')]=_['intersection'](_0x450e1f[_0xe4c5('0x33')],_0x450e1f[_0xe4c5('0x30')]);_0x44e92b[_0xe4c5('0x34')]=_[_0xe4c5('0x35')](_0x450e1f['model'],qs[_0xe4c5('0x36')](_0x35ef84[_0xe4c5('0x30')][_0xe4c5('0x36')]));_0x44e92b['attributes']=_0x44e92b[_0xe4c5('0x34')][_0xe4c5('0x37')]?_0x44e92b['attributes']:_0x450e1f[_0xe4c5('0x33')];if(!_0x35ef84[_0xe4c5('0x30')][_0xe4c5('0x38')](_0xe4c5('0x39'))){_0x44e92b['limit']=qs[_0xe4c5('0x1c')](_0x35ef84[_0xe4c5('0x30')]['limit']);_0x44e92b[_0xe4c5('0x1f')]=qs[_0xe4c5('0x1f')](_0x35ef84[_0xe4c5('0x30')][_0xe4c5('0x1f')]);}_0x44e92b[_0xe4c5('0x3a')]=qs[_0xe4c5('0x3b')](_0x35ef84['query'][_0xe4c5('0x3b')]);_0x44e92b[_0xe4c5('0x3c')]=qs[_0xe4c5('0x32')](_[_0xe4c5('0x3d')](_0x35ef84[_0xe4c5('0x30')],_0x450e1f[_0xe4c5('0x32')]),_0x4179aa);if(_0x35ef84[_0xe4c5('0x30')][_0xe4c5('0x3e')]){_0x44e92b[_0xe4c5('0x3c')]=_[_0xe4c5('0x3f')](_0x44e92b[_0xe4c5('0x3c')],{'$or':_[_0xe4c5('0x2b')](_0x4179aa,function(_0x58297d){if(_0x58297d['type']!==_0xe4c5('0x40')){var _0x2254a4={};_0x2254a4[_0x58297d['name']]={'$like':'%'+_0x35ef84[_0xe4c5('0x30')][_0xe4c5('0x3e')]+'%'};return _0x2254a4;}})});}_0x44e92b=_[_0xe4c5('0x3f')]({},_0x44e92b,_0x35ef84[_0xe4c5('0x41')]);var _0xd52523={'where':_0x44e92b[_0xe4c5('0x3c')]};return db['DeskConfiguration'][_0xe4c5('0x1e')](_0xd52523)['then'](function(_0x491f60){_0x4205fc['count']=_0x491f60;if(_0x35ef84['query']['includeAll']){_0x44e92b['include']=[{'all':!![]}];}return db['DeskConfiguration'][_0xe4c5('0x42')](_0x44e92b);})['then'](function(_0x7b502c){_0x4205fc[_0xe4c5('0x43')]=_0x7b502c;return _0x4205fc;})[_0xe4c5('0x24')](respondWithFilteredResult(_0x56a802,_0x44e92b))[_0xe4c5('0x44')](handleError(_0x56a802,null));};exports[_0xe4c5('0x45')]=function(_0x33b768,_0x4989d4){var _0x4d2c41={'raw':![],'where':{'id':_0x33b768['params']['id']}},_0x145437={};_0x145437[_0xe4c5('0x33')]=_[_0xe4c5('0x31')](db['DeskConfiguration'][_0xe4c5('0x2d')]);_0x145437[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x33b768[_0xe4c5('0x30')]);_0x145437[_0xe4c5('0x32')]=_['intersection'](_0x145437[_0xe4c5('0x33')],_0x145437['query']);_0x4d2c41['attributes']=_[_0xe4c5('0x35')](_0x145437['model'],qs[_0xe4c5('0x36')](_0x33b768[_0xe4c5('0x30')]['fields']));_0x4d2c41[_0xe4c5('0x34')]=_0x4d2c41[_0xe4c5('0x34')]['length']?_0x4d2c41[_0xe4c5('0x34')]:_0x145437[_0xe4c5('0x33')];if(_0x33b768[_0xe4c5('0x30')][_0xe4c5('0x46')]){_0x4d2c41[_0xe4c5('0x47')]=[{'all':!![]}];}_0x4d2c41=_[_0xe4c5('0x3f')]({},_0x4d2c41,_0x33b768[_0xe4c5('0x41')]);return db[_0xe4c5('0x2c')][_0xe4c5('0x48')](_0x4d2c41)[_0xe4c5('0x24')](handleEntityNotFound(_0x4989d4,null))[_0xe4c5('0x24')](respondWithResult(_0x4989d4,null))['catch'](handleError(_0x4989d4,null));};exports['create']=function(_0x3f0f6c,_0x41f381){return db[_0xe4c5('0x2c')][_0xe4c5('0x49')](_0x3f0f6c[_0xe4c5('0x4a')],{})[_0xe4c5('0x24')](respondWithResult(_0x41f381,0xc9))[_0xe4c5('0x44')](handleError(_0x41f381,null));};exports[_0xe4c5('0x4b')]=function(_0x3c3a93,_0x162fa0){if(_0x3c3a93[_0xe4c5('0x4a')]['id']){delete _0x3c3a93[_0xe4c5('0x4a')]['id'];}return db[_0xe4c5('0x2c')][_0xe4c5('0x48')]({'where':{'id':_0x3c3a93['params']['id']}})['then'](handleEntityNotFound(_0x162fa0,null))[_0xe4c5('0x24')](saveUpdates(_0x3c3a93[_0xe4c5('0x4a')],null))[_0xe4c5('0x24')](respondWithResult(_0x162fa0,null))[_0xe4c5('0x44')](handleError(_0x162fa0,null));};exports[_0xe4c5('0x25')]=function(_0x5c7d7c,_0x3753af){return db[_0xe4c5('0x2c')]['find']({'where':{'id':_0x5c7d7c['params']['id']}})[_0xe4c5('0x24')](handleEntityNotFound(_0x3753af,null))[_0xe4c5('0x24')](removeEntity(_0x3753af,null))[_0xe4c5('0x44')](handleError(_0x3753af,null));};exports[_0xe4c5('0x4c')]=function(_0x10d13c,_0x21292b,_0x22201a){var _0x7860f8={};var _0x55edf9={};var _0x4540b4;var _0x357774;return db[_0xe4c5('0x2c')][_0xe4c5('0x4d')]({'where':{'id':_0x10d13c[_0xe4c5('0x4e')]['id']}})['then'](handleEntityNotFound(_0x21292b,null))[_0xe4c5('0x24')](function(_0x23c6f7){if(_0x23c6f7){_0x4540b4=_0x23c6f7;_0x55edf9['model']=_['keys'](db[_0xe4c5('0x4f')][_0xe4c5('0x2d')]);_0x55edf9[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x10d13c['query']);_0x55edf9[_0xe4c5('0x32')]=_[_0xe4c5('0x35')](_0x55edf9['model'],_0x55edf9[_0xe4c5('0x30')]);_0x7860f8['attributes']=_[_0xe4c5('0x35')](_0x55edf9[_0xe4c5('0x33')],qs[_0xe4c5('0x36')](_0x10d13c[_0xe4c5('0x30')]['fields']));_0x7860f8[_0xe4c5('0x34')]=_0x7860f8[_0xe4c5('0x34')][_0xe4c5('0x37')]?_0x7860f8[_0xe4c5('0x34')]:_0x55edf9['model'];_0x7860f8[_0xe4c5('0x3a')]=qs[_0xe4c5('0x3b')](_0x10d13c['query'][_0xe4c5('0x3b')]);_0x7860f8[_0xe4c5('0x3c')]=qs['filters'](_[_0xe4c5('0x3d')](_0x10d13c['query'],_0x55edf9[_0xe4c5('0x32')]));if(_0x10d13c[_0xe4c5('0x30')][_0xe4c5('0x3e')]){_0x7860f8[_0xe4c5('0x3c')]=_[_0xe4c5('0x3f')](_0x7860f8['where'],{'$or':_[_0xe4c5('0x2b')](_0x7860f8[_0xe4c5('0x34')],function(_0x1270a8){var _0x10e0ee={};_0x10e0ee[_0x1270a8]={'$like':'%'+_0x10d13c['query'][_0xe4c5('0x3e')]+'%'};return _0x10e0ee;})});}_0x7860f8=_[_0xe4c5('0x3f')]({},_0x7860f8,_0x10d13c['options']);return _0x4540b4[_0xe4c5('0x4c')](_0x7860f8);}})['then'](function(_0x12ed92){if(_0x12ed92){_0x357774=_0x12ed92[_0xe4c5('0x37')];if(!_0x10d13c['query'][_0xe4c5('0x38')](_0xe4c5('0x39'))){_0x7860f8[_0xe4c5('0x1c')]=qs[_0xe4c5('0x1c')](_0x10d13c['query'][_0xe4c5('0x1c')]);_0x7860f8['offset']=qs['offset'](_0x10d13c[_0xe4c5('0x30')][_0xe4c5('0x1f')]);}return _0x4540b4[_0xe4c5('0x4c')](_0x7860f8);}})[_0xe4c5('0x24')](function(_0x1df1d0){if(_0x1df1d0){return _0x1df1d0?{'count':_0x357774,'rows':_0x1df1d0}:null;}})[_0xe4c5('0x24')](respondWithResult(_0x21292b,null))[_0xe4c5('0x44')](handleError(_0x21292b,null));};exports[_0xe4c5('0x50')]=function(_0x54ae1f,_0x277c3c,_0x53f346){var _0x137adf={};var _0x54bf20={};var _0x2f3f04;var _0x257cdd;return db[_0xe4c5('0x2c')]['findOne']({'where':{'id':_0x54ae1f[_0xe4c5('0x4e')]['id']}})['then'](handleEntityNotFound(_0x277c3c,null))[_0xe4c5('0x24')](function(_0x4925f0){if(_0x4925f0){_0x2f3f04=_0x4925f0;_0x54bf20[_0xe4c5('0x33')]=_['keys'](db[_0xe4c5('0x4f')][_0xe4c5('0x2d')]);_0x54bf20[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x54ae1f['query']);_0x54bf20[_0xe4c5('0x32')]=_['intersection'](_0x54bf20['model'],_0x54bf20[_0xe4c5('0x30')]);_0x137adf[_0xe4c5('0x34')]=_[_0xe4c5('0x35')](_0x54bf20[_0xe4c5('0x33')],qs[_0xe4c5('0x36')](_0x54ae1f['query'][_0xe4c5('0x36')]));_0x137adf[_0xe4c5('0x34')]=_0x137adf['attributes']['length']?_0x137adf[_0xe4c5('0x34')]:_0x54bf20[_0xe4c5('0x33')];_0x137adf[_0xe4c5('0x3a')]=qs[_0xe4c5('0x3b')](_0x54ae1f[_0xe4c5('0x30')][_0xe4c5('0x3b')]);_0x137adf[_0xe4c5('0x3c')]=qs[_0xe4c5('0x32')](_['pick'](_0x54ae1f[_0xe4c5('0x30')],_0x54bf20[_0xe4c5('0x32')]));if(_0x54ae1f['query'][_0xe4c5('0x3e')]){_0x137adf['where']=_['merge'](_0x137adf[_0xe4c5('0x3c')],{'$or':_['map'](_0x137adf[_0xe4c5('0x34')],function(_0x322ec2){var _0x436ff2={};_0x436ff2[_0x322ec2]={'$like':'%'+_0x54ae1f[_0xe4c5('0x30')][_0xe4c5('0x3e')]+'%'};return _0x436ff2;})});}_0x137adf=_[_0xe4c5('0x3f')]({},_0x137adf,_0x54ae1f[_0xe4c5('0x41')]);return _0x2f3f04['getSubjects'](_0x137adf);}})[_0xe4c5('0x24')](function(_0x3ea1b8){if(_0x3ea1b8){_0x257cdd=_0x3ea1b8[_0xe4c5('0x37')];if(!_0x54ae1f[_0xe4c5('0x30')][_0xe4c5('0x38')]('nolimit')){_0x137adf[_0xe4c5('0x1c')]=qs['limit'](_0x54ae1f[_0xe4c5('0x30')][_0xe4c5('0x1c')]);_0x137adf[_0xe4c5('0x1f')]=qs['offset'](_0x54ae1f[_0xe4c5('0x30')][_0xe4c5('0x1f')]);}return _0x2f3f04['getSubjects'](_0x137adf);}})[_0xe4c5('0x24')](function(_0x17662e){if(_0x17662e){return _0x17662e?{'count':_0x257cdd,'rows':_0x17662e}:null;}})['then'](respondWithResult(_0x277c3c,null))[_0xe4c5('0x44')](handleError(_0x277c3c,null));};exports['getDescriptions']=function(_0x1a0992,_0x4ccee8,_0x12edba){var _0x1e3fab={};var _0x533490={};var _0x287390;var _0x18feea;return db[_0xe4c5('0x2c')][_0xe4c5('0x4d')]({'where':{'id':_0x1a0992[_0xe4c5('0x4e')]['id']}})[_0xe4c5('0x24')](handleEntityNotFound(_0x4ccee8,null))[_0xe4c5('0x24')](function(_0x3952ab){if(_0x3952ab){_0x287390=_0x3952ab;_0x533490[_0xe4c5('0x33')]=_[_0xe4c5('0x31')](db['DeskField'][_0xe4c5('0x2d')]);_0x533490[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x1a0992[_0xe4c5('0x30')]);_0x533490['filters']=_[_0xe4c5('0x35')](_0x533490[_0xe4c5('0x33')],_0x533490[_0xe4c5('0x30')]);_0x1e3fab[_0xe4c5('0x34')]=_['intersection'](_0x533490[_0xe4c5('0x33')],qs[_0xe4c5('0x36')](_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x36')]));_0x1e3fab['attributes']=_0x1e3fab[_0xe4c5('0x34')]['length']?_0x1e3fab['attributes']:_0x533490[_0xe4c5('0x33')];_0x1e3fab['order']=qs[_0xe4c5('0x3b')](_0x1a0992[_0xe4c5('0x30')]['sort']);_0x1e3fab[_0xe4c5('0x3c')]=qs['filters'](_['pick'](_0x1a0992['query'],_0x533490[_0xe4c5('0x32')]));if(_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x3e')]){_0x1e3fab[_0xe4c5('0x3c')]=_[_0xe4c5('0x3f')](_0x1e3fab['where'],{'$or':_[_0xe4c5('0x2b')](_0x1e3fab[_0xe4c5('0x34')],function(_0x4babb0){var _0x354c1e={};_0x354c1e[_0x4babb0]={'$like':'%'+_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x3e')]+'%'};return _0x354c1e;})});}_0x1e3fab=_[_0xe4c5('0x3f')]({},_0x1e3fab,_0x1a0992[_0xe4c5('0x41')]);return _0x287390[_0xe4c5('0x51')](_0x1e3fab);}})[_0xe4c5('0x24')](function(_0x2e27f1){if(_0x2e27f1){_0x18feea=_0x2e27f1[_0xe4c5('0x37')];if(!_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x38')](_0xe4c5('0x39'))){_0x1e3fab['limit']=qs[_0xe4c5('0x1c')](_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x1c')]);_0x1e3fab[_0xe4c5('0x1f')]=qs['offset'](_0x1a0992[_0xe4c5('0x30')][_0xe4c5('0x1f')]);}return _0x287390[_0xe4c5('0x51')](_0x1e3fab);}})['then'](function(_0x32dfcc){if(_0x32dfcc){return _0x32dfcc?{'count':_0x18feea,'rows':_0x32dfcc}:null;}})[_0xe4c5('0x24')](respondWithResult(_0x4ccee8,null))[_0xe4c5('0x44')](handleError(_0x4ccee8,null));};exports[_0xe4c5('0x52')]=function(_0x2ad71e,_0x432115,_0xacfba3){var _0x312d0d={};var _0x222c49={};var _0x1cf87c;var _0x32fd7f;return db['DeskConfiguration']['findOne']({'where':{'id':_0x2ad71e[_0xe4c5('0x4e')]['id']}})[_0xe4c5('0x24')](handleEntityNotFound(_0x432115,null))[_0xe4c5('0x24')](function(_0x12fd09){if(_0x12fd09){_0x1cf87c=_0x12fd09;_0x222c49[_0xe4c5('0x33')]=_[_0xe4c5('0x31')](db[_0xe4c5('0x53')][_0xe4c5('0x2d')]);_0x222c49[_0xe4c5('0x30')]=_[_0xe4c5('0x31')](_0x2ad71e[_0xe4c5('0x30')]);_0x222c49['filters']=_[_0xe4c5('0x35')](_0x222c49['model'],_0x222c49[_0xe4c5('0x30')]);_0x312d0d[_0xe4c5('0x34')]=_[_0xe4c5('0x35')](_0x222c49[_0xe4c5('0x33')],qs[_0xe4c5('0x36')](_0x2ad71e['query'][_0xe4c5('0x36')]));_0x312d0d[_0xe4c5('0x34')]=_0x312d0d[_0xe4c5('0x34')][_0xe4c5('0x37')]?_0x312d0d['attributes']:_0x222c49['model'];_0x312d0d[_0xe4c5('0x3a')]=qs['sort'](_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x3b')]);_0x312d0d[_0xe4c5('0x3c')]=qs[_0xe4c5('0x32')](_['pick'](_0x2ad71e[_0xe4c5('0x30')],_0x222c49['filters']));if(_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x3e')]){_0x312d0d[_0xe4c5('0x3c')]=_[_0xe4c5('0x3f')](_0x312d0d[_0xe4c5('0x3c')],{'$or':_['map'](_0x312d0d[_0xe4c5('0x34')],function(_0x3d358f){var _0xd898f0={};_0xd898f0[_0x3d358f]={'$like':'%'+_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x3e')]+'%'};return _0xd898f0;})});}_0x312d0d=_['merge']({},_0x312d0d,_0x2ad71e[_0xe4c5('0x41')]);return _0x1cf87c[_0xe4c5('0x52')](_0x312d0d);}})[_0xe4c5('0x24')](function(_0x4445c3){if(_0x4445c3){_0x32fd7f=_0x4445c3[_0xe4c5('0x37')];if(!_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x38')](_0xe4c5('0x39'))){_0x312d0d[_0xe4c5('0x1c')]=qs[_0xe4c5('0x1c')](_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x1c')]);_0x312d0d[_0xe4c5('0x1f')]=qs['offset'](_0x2ad71e[_0xe4c5('0x30')][_0xe4c5('0x1f')]);}return _0x1cf87c[_0xe4c5('0x52')](_0x312d0d);}})['then'](function(_0x7038bd){if(_0x7038bd){return _0x7038bd?{'count':_0x32fd7f,'rows':_0x7038bd}:null;}})[_0xe4c5('0x24')](respondWithResult(_0x432115,null))[_0xe4c5('0x44')](handleError(_0x432115,null));};exports[_0xe4c5('0x54')]=function(_0x2a7d28,_0x185c32,_0x1079fc){if(_0x2a7d28['body']['id']){delete _0x2a7d28[_0xe4c5('0x4a')]['id'];}return db[_0xe4c5('0x2c')][_0xe4c5('0x4d')]({'where':{'id':_0x2a7d28['params']['id']}})[_0xe4c5('0x24')](handleEntityNotFound(_0x185c32,null))[_0xe4c5('0x24')](function(_0x47e83a){if(_0x47e83a){return _0x47e83a['setTags'](_0x2a7d28[_0xe4c5('0x4a')][_0xe4c5('0x55')]||[]);}return null;})[_0xe4c5('0x24')](respondWithResult(_0x185c32,null))[_0xe4c5('0x44')](handleError(_0x185c32,null));}; \ No newline at end of file diff --git a/server/api/intDeskConfiguration/intDeskConfiguration.model.js b/server/api/intDeskConfiguration/intDeskConfiguration.model.js new file mode 100644 index 0000000..7831b23 --- /dev/null +++ b/server/api/intDeskConfiguration/intDeskConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8808=['lodash','util','api','bluebird','request-promise','path','./intDeskConfiguration.attributes','exports','define','DeskConfiguration','int_desk_configurations'];(function(_0x2ab3d9,_0x50e716){var _0x210a54=function(_0x24c479){while(--_0x24c479){_0x2ab3d9['push'](_0x2ab3d9['shift']());}};_0x210a54(++_0x50e716);}(_0x8808,0x8f));var _0x8880=function(_0x465028,_0x4570ac){_0x465028=_0x465028-0x0;var _0xb783d4=_0x8808[_0x465028];return _0xb783d4;};'use strict';var _=require(_0x8880('0x0'));var util=require(_0x8880('0x1'));var logger=require('../../config/logger')(_0x8880('0x2'));var moment=require('moment');var BPromise=require(_0x8880('0x3'));var rp=require(_0x8880('0x4'));var fs=require('fs');var path=require(_0x8880('0x5'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x8880('0x6'));module[_0x8880('0x7')]=function(_0x3897fc,_0x5cc732){return _0x3897fc[_0x8880('0x8')](_0x8880('0x9'),attributes,{'tableName':_0x8880('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDeskConfiguration/intDeskConfiguration.rpc.js b/server/api/intDeskConfiguration/intDeskConfiguration.rpc.js new file mode 100644 index 0000000..4a6081b --- /dev/null +++ b/server/api/intDeskConfiguration/intDeskConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4d4e=['../../mysqldb','../../config/utils','../../config/logger','rpc','client','request','then','DeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','DeskConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','lodash','moment','bluebird','ioredis'];(function(_0x602ca8,_0x568e82){var _0x26e8ab=function(_0x3fb700){while(--_0x3fb700){_0x602ca8['push'](_0x602ca8['shift']());}};_0x26e8ab(++_0x568e82);}(_0x4d4e,0xa4));var _0xe4d4=function(_0x1e6db3,_0x5643ac){_0x1e6db3=_0x1e6db3-0x0;var _0x1de886=_0x4d4e[_0x1e6db3];return _0x1de886;};'use strict';var _=require(_0xe4d4('0x0'));var util=require('util');var moment=require(_0xe4d4('0x1'));var BPromise=require(_0xe4d4('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe4d4('0x3'));var db=require(_0xe4d4('0x4'))['db'];var utils=require(_0xe4d4('0x5'));var logger=require(_0xe4d4('0x6'))(_0xe4d4('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xe4d4('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5b6652,_0x4e9d70,_0xf010c6){return new BPromise(function(_0x3e422b,_0x14ec7a){return client[_0xe4d4('0x9')](_0x5b6652,_0xf010c6)[_0xe4d4('0xa')](function(_0x58cce7){logger['info'](_0xe4d4('0xb'),_0x4e9d70,_0xe4d4('0xc'));logger[_0xe4d4('0xd')](_0xe4d4('0xe'),_0x4e9d70,_0xe4d4('0xc'),JSON[_0xe4d4('0xf')](_0x58cce7));if(_0x58cce7[_0xe4d4('0x10')]){if(_0x58cce7[_0xe4d4('0x10')]['code']===0x1f4){logger[_0xe4d4('0x10')](_0xe4d4('0xb'),_0x4e9d70,_0x58cce7[_0xe4d4('0x10')]['message']);return _0x14ec7a(_0x58cce7[_0xe4d4('0x10')][_0xe4d4('0x11')]);}logger[_0xe4d4('0x10')](_0xe4d4('0xb'),_0x4e9d70,_0x58cce7['error']['message']);return _0x3e422b(_0x58cce7[_0xe4d4('0x10')]['message']);}else{logger[_0xe4d4('0x12')](_0xe4d4('0xb'),_0x4e9d70,'request\x20sent');_0x3e422b(_0x58cce7[_0xe4d4('0x13')][_0xe4d4('0x11')]);}})[_0xe4d4('0x14')](function(_0xad05a7){logger[_0xe4d4('0x10')](_0xe4d4('0xb'),_0x4e9d70,_0xad05a7);_0x14ec7a(_0xad05a7);});});} \ No newline at end of file diff --git a/server/api/intDeskField/index.js b/server/api/intDeskField/index.js new file mode 100644 index 0000000..b61485b --- /dev/null +++ b/server/api/intDeskField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5746=['update','destroy','multer','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intDeskField.controller','get','isAuthenticated','index','/:id','post','put'];(function(_0x324a9e,_0x15c28a){var _0x15b6fd=function(_0x45594b){while(--_0x45594b){_0x324a9e['push'](_0x324a9e['shift']());}};_0x15b6fd(++_0x15c28a);}(_0x5746,0x1f2));var _0x6574=function(_0x232162,_0x56a665){_0x232162=_0x232162-0x0;var _0x15b4c5=_0x5746[_0x232162];return _0x15b4c5;};'use strict';var multer=require(_0x6574('0x0'));var util=require('util');var path=require('path');var timeout=require(_0x6574('0x1'));var express=require(_0x6574('0x2'));var router=express['Router']();var fs_extra=require(_0x6574('0x3'));var auth=require(_0x6574('0x4'));var interaction=require(_0x6574('0x5'));var config=require(_0x6574('0x6'));var controller=require(_0x6574('0x7'));router[_0x6574('0x8')]('/',auth[_0x6574('0x9')](),controller[_0x6574('0xa')]);router['get'](_0x6574('0xb'),auth[_0x6574('0x9')](),controller['show']);router[_0x6574('0xc')]('/',auth[_0x6574('0x9')](),controller['create']);router[_0x6574('0xd')](_0x6574('0xb'),auth[_0x6574('0x9')](),controller[_0x6574('0xe')]);router['delete']('/:id',auth[_0x6574('0x9')](),controller[_0x6574('0xf')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/intDeskField/intDeskField.attributes.js b/server/api/intDeskField/intDeskField.attributes.js new file mode 100644 index 0000000..a8c236e --- /dev/null +++ b/server/api/intDeskField/intDeskField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc0d4=['variable','keyValue','picklist','string','STRING','customVariable','BOOLEAN','sequelize'];(function(_0xdd42ac,_0x1d31f1){var _0x4ddf3f=function(_0x2b4543){while(--_0x2b4543){_0xdd42ac['push'](_0xdd42ac['shift']());}};_0x4ddf3f(++_0x1d31f1);}(_0xc0d4,0x197));var _0x4c0d=function(_0x189b3b,_0x484de8){_0x189b3b=_0x189b3b-0x0;var _0x7c4721=_0xc0d4[_0x189b3b];return _0x7c4721;};'use strict';var Sequelize=require(_0x4c0d('0x0'));module['exports']={'type':{'type':Sequelize['ENUM']('string',_0x4c0d('0x1'),'customVariable',_0x4c0d('0x2'),_0x4c0d('0x3')),'defaultValue':_0x4c0d('0x4')},'content':{'type':Sequelize[_0x4c0d('0x5')]},'key':{'type':Sequelize[_0x4c0d('0x5')]},'keyType':{'type':Sequelize['ENUM']('string',_0x4c0d('0x1'),_0x4c0d('0x6'))},'keyContent':{'type':Sequelize['STRING']},'idField':{'type':Sequelize[_0x4c0d('0x5')]},'nameField':{'type':Sequelize[_0x4c0d('0x5')]},'customField':{'type':Sequelize[_0x4c0d('0x7')],'defaultValue':!![]},'variableName':{'type':Sequelize[_0x4c0d('0x5')]}}; \ No newline at end of file diff --git a/server/api/intDeskField/intDeskField.controller.js b/server/api/intDeskField/intDeskField.controller.js new file mode 100644 index 0000000..3b798b4 --- /dev/null +++ b/server/api/intDeskField/intDeskField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd0d=['error','stack','name','send','index','map','DeskField','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filters','filter','where','merge','VIRTUAL','options','findAll','rows','show','params','length','includeAll','find','catch','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','util','sox','to-csv','ejs','fs-extra','lodash','squel','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','json','offset','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus'];(function(_0x598ad4,_0xce00c){var _0x498436=function(_0x35702e){while(--_0x35702e){_0x598ad4['push'](_0x598ad4['shift']());}};_0x498436(++_0xce00c);}(_0xcd0d,0x10a));var _0xdcd0=function(_0x36bc58,_0x27f03c){_0x36bc58=_0x36bc58-0x0;var _0x4a547e=_0xcd0d[_0x36bc58];return _0x4a547e;};'use strict';var emlformat=require(_0xdcd0('0x0'));var rimraf=require(_0xdcd0('0x1'));var zipdir=require(_0xdcd0('0x2'));var jsonpatch=require(_0xdcd0('0x3'));var rp=require(_0xdcd0('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xdcd0('0x5'));var path=require('path');var sox=require(_0xdcd0('0x6'));var csv=require(_0xdcd0('0x7'));var ejs=require(_0xdcd0('0x8'));var fs=require('fs');var fs_extra=require(_0xdcd0('0x9'));var _=require(_0xdcd0('0xa'));var squel=require(_0xdcd0('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xdcd0('0x7'));var querystring=require(_0xdcd0('0xc'));var Papa=require(_0xdcd0('0xd'));var Redis=require('ioredis');var authService=require(_0xdcd0('0xe'));var qs=require(_0xdcd0('0xf'));var as=require(_0xdcd0('0x10'));var hardwareService=require(_0xdcd0('0x11'));var logger=require(_0xdcd0('0x12'))(_0xdcd0('0x13'));var utils=require(_0xdcd0('0x14'));var config=require(_0xdcd0('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xdcd0('0x16'))['db'];function respondWithStatusCode(_0x30cbff,_0x25e3db){_0x25e3db=_0x25e3db||0xcc;return function(_0x1a7407){if(_0x1a7407){return _0x30cbff['sendStatus'](_0x25e3db);}return _0x30cbff[_0xdcd0('0x17')](_0x25e3db)['end']();};}function respondWithResult(_0x367d7d,_0x5c1640){_0x5c1640=_0x5c1640||0xc8;return function(_0x2a4bf1){if(_0x2a4bf1){return _0x367d7d['status'](_0x5c1640)[_0xdcd0('0x18')](_0x2a4bf1);}};}function respondWithFilteredResult(_0x3ec4f7,_0x26e8d6){return function(_0x5a4584){if(_0x5a4584){var _0x488387=typeof _0x26e8d6['offset']==='undefined'&&typeof _0x26e8d6['limit']==='undefined';var _0x261c23=_0x5a4584['count'];var _0x3c45f3=_0x488387?0x0:_0x26e8d6[_0xdcd0('0x19')];var _0x10bf00=_0x488387?_0x5a4584[_0xdcd0('0x1a')]:_0x26e8d6[_0xdcd0('0x19')]+_0x26e8d6[_0xdcd0('0x1b')];var _0x53890d;if(_0x10bf00>=_0x261c23){_0x10bf00=_0x261c23;_0x53890d=0xc8;}else{_0x53890d=0xce;}_0x3ec4f7[_0xdcd0('0x17')](_0x53890d);return _0x3ec4f7[_0xdcd0('0x1c')](_0xdcd0('0x1d'),_0x3c45f3+'-'+_0x10bf00+'/'+_0x261c23)[_0xdcd0('0x18')](_0x5a4584);}return null;};}function patchUpdates(_0x10af21){return function(_0x3b2262){try{jsonpatch[_0xdcd0('0x1e')](_0x3b2262,_0x10af21,!![]);}catch(_0x88154a){return BPromise[_0xdcd0('0x1f')](_0x88154a);}return _0x3b2262[_0xdcd0('0x20')]();};}function saveUpdates(_0x394c93,_0x56ebe8){return function(_0x2a9925){if(_0x2a9925){return _0x2a9925[_0xdcd0('0x21')](_0x394c93)[_0xdcd0('0x22')](function(_0x4eca7f){return _0x4eca7f;});}return null;};}function removeEntity(_0x3535ff,_0x5debf0){return function(_0x3f96aa){if(_0x3f96aa){return _0x3f96aa[_0xdcd0('0x23')]()[_0xdcd0('0x22')](function(){_0x3535ff[_0xdcd0('0x17')](0xcc)[_0xdcd0('0x24')]();});}};}function handleEntityNotFound(_0x13697d,_0x2d128d){return function(_0x2810d0){if(!_0x2810d0){_0x13697d[_0xdcd0('0x25')](0x194);}return _0x2810d0;};}function handleError(_0x3f3013,_0x535e9f){_0x535e9f=_0x535e9f||0x1f4;return function(_0x249b5c){logger[_0xdcd0('0x26')](_0x249b5c[_0xdcd0('0x27')]);if(_0x249b5c[_0xdcd0('0x28')]){delete _0x249b5c[_0xdcd0('0x28')];}_0x3f3013[_0xdcd0('0x17')](_0x535e9f)[_0xdcd0('0x29')](_0x249b5c);};}exports[_0xdcd0('0x2a')]=function(_0x4f75f8,_0x4ac778){var _0x6bd7d={},_0x2c5334={},_0x22f04d={'count':0x0,'rows':[]};var _0x1e769a=_[_0xdcd0('0x2b')](db[_0xdcd0('0x2c')][_0xdcd0('0x2d')],function(_0x2ae3ac){return{'name':_0x2ae3ac[_0xdcd0('0x2e')],'type':_0x2ae3ac[_0xdcd0('0x2f')][_0xdcd0('0x30')]};});_0x2c5334[_0xdcd0('0x31')]=_[_0xdcd0('0x2b')](_0x1e769a,_0xdcd0('0x28'));_0x2c5334[_0xdcd0('0x32')]=_[_0xdcd0('0x33')](_0x4f75f8[_0xdcd0('0x32')]);_0x2c5334['filters']=_[_0xdcd0('0x34')](_0x2c5334['model'],_0x2c5334[_0xdcd0('0x32')]);_0x6bd7d[_0xdcd0('0x35')]=_[_0xdcd0('0x34')](_0x2c5334[_0xdcd0('0x31')],qs[_0xdcd0('0x36')](_0x4f75f8['query'][_0xdcd0('0x36')]));_0x6bd7d[_0xdcd0('0x35')]=_0x6bd7d[_0xdcd0('0x35')]['length']?_0x6bd7d[_0xdcd0('0x35')]:_0x2c5334[_0xdcd0('0x31')];if(!_0x4f75f8['query'][_0xdcd0('0x37')](_0xdcd0('0x38'))){_0x6bd7d['limit']=qs[_0xdcd0('0x1b')](_0x4f75f8[_0xdcd0('0x32')]['limit']);_0x6bd7d[_0xdcd0('0x19')]=qs[_0xdcd0('0x19')](_0x4f75f8[_0xdcd0('0x32')][_0xdcd0('0x19')]);}_0x6bd7d[_0xdcd0('0x39')]=qs[_0xdcd0('0x3a')](_0x4f75f8[_0xdcd0('0x32')][_0xdcd0('0x3a')]);_0x6bd7d['where']=qs['filters'](_[_0xdcd0('0x3b')](_0x4f75f8[_0xdcd0('0x32')],_0x2c5334[_0xdcd0('0x3c')]),_0x1e769a);if(_0x4f75f8[_0xdcd0('0x32')][_0xdcd0('0x3d')]){_0x6bd7d[_0xdcd0('0x3e')]=_[_0xdcd0('0x3f')](_0x6bd7d[_0xdcd0('0x3e')],{'$or':_[_0xdcd0('0x2b')](_0x1e769a,function(_0x1da43e){if(_0x1da43e['type']!==_0xdcd0('0x40')){var _0x5476bb={};_0x5476bb[_0x1da43e['name']]={'$like':'%'+_0x4f75f8[_0xdcd0('0x32')][_0xdcd0('0x3d')]+'%'};return _0x5476bb;}})});}_0x6bd7d=_[_0xdcd0('0x3f')]({},_0x6bd7d,_0x4f75f8[_0xdcd0('0x41')]);var _0x1efa35={'where':_0x6bd7d[_0xdcd0('0x3e')]};return db[_0xdcd0('0x2c')]['count'](_0x1efa35)['then'](function(_0xb927ae){_0x22f04d[_0xdcd0('0x1a')]=_0xb927ae;if(_0x4f75f8[_0xdcd0('0x32')]['includeAll']){_0x6bd7d['include']=[{'all':!![]}];}return db[_0xdcd0('0x2c')][_0xdcd0('0x42')](_0x6bd7d);})[_0xdcd0('0x22')](function(_0x5078aa){_0x22f04d[_0xdcd0('0x43')]=_0x5078aa;return _0x22f04d;})[_0xdcd0('0x22')](respondWithFilteredResult(_0x4ac778,_0x6bd7d))['catch'](handleError(_0x4ac778,null));};exports[_0xdcd0('0x44')]=function(_0x4c8049,_0x3910cd){var _0x1bd8af={'raw':!![],'where':{'id':_0x4c8049[_0xdcd0('0x45')]['id']}},_0x3034e0={};_0x3034e0[_0xdcd0('0x31')]=_['keys'](db[_0xdcd0('0x2c')][_0xdcd0('0x2d')]);_0x3034e0[_0xdcd0('0x32')]=_[_0xdcd0('0x33')](_0x4c8049['query']);_0x3034e0[_0xdcd0('0x3c')]=_[_0xdcd0('0x34')](_0x3034e0['model'],_0x3034e0['query']);_0x1bd8af[_0xdcd0('0x35')]=_['intersection'](_0x3034e0['model'],qs['fields'](_0x4c8049['query'][_0xdcd0('0x36')]));_0x1bd8af['attributes']=_0x1bd8af[_0xdcd0('0x35')][_0xdcd0('0x46')]?_0x1bd8af[_0xdcd0('0x35')]:_0x3034e0[_0xdcd0('0x31')];if(_0x4c8049['query'][_0xdcd0('0x47')]){_0x1bd8af['include']=[{'all':!![]}];}_0x1bd8af=_[_0xdcd0('0x3f')]({},_0x1bd8af,_0x4c8049[_0xdcd0('0x41')]);return db[_0xdcd0('0x2c')][_0xdcd0('0x48')](_0x1bd8af)[_0xdcd0('0x22')](handleEntityNotFound(_0x3910cd,null))['then'](respondWithResult(_0x3910cd,null))[_0xdcd0('0x49')](handleError(_0x3910cd,null));};exports[_0xdcd0('0x4a')]=function(_0x2e8e47,_0x383636){return db[_0xdcd0('0x2c')][_0xdcd0('0x4a')](_0x2e8e47['body'],{})['then'](respondWithResult(_0x383636,0xc9))[_0xdcd0('0x49')](handleError(_0x383636,null));};exports[_0xdcd0('0x21')]=function(_0x2e7d4d,_0x4bf058){if(_0x2e7d4d['body']['id']){delete _0x2e7d4d['body']['id'];}return db[_0xdcd0('0x2c')][_0xdcd0('0x48')]({'where':{'id':_0x2e7d4d[_0xdcd0('0x45')]['id']}})['then'](handleEntityNotFound(_0x4bf058,null))[_0xdcd0('0x22')](saveUpdates(_0x2e7d4d[_0xdcd0('0x4b')],null))['then'](respondWithResult(_0x4bf058,null))['catch'](handleError(_0x4bf058,null));};exports[_0xdcd0('0x23')]=function(_0x1dddcd,_0xcc0262){return db[_0xdcd0('0x2c')]['find']({'where':{'id':_0x1dddcd[_0xdcd0('0x45')]['id']}})[_0xdcd0('0x22')](handleEntityNotFound(_0xcc0262,null))[_0xdcd0('0x22')](removeEntity(_0xcc0262,null))[_0xdcd0('0x49')](handleError(_0xcc0262,null));}; \ No newline at end of file diff --git a/server/api/intDeskField/intDeskField.model.js b/server/api/intDeskField/intDeskField.model.js new file mode 100644 index 0000000..820e505 --- /dev/null +++ b/server/api/intDeskField/intDeskField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe48c=['DeskField','desk_unique_index','idField','FieldId','lodash','../../config/logger','api','moment','bluebird','path','rimraf','../../config/environment','./intDeskField.attributes','exports','define'];(function(_0x455d37,_0x9b1de3){var _0x10d3e1=function(_0x7a6ba2){while(--_0x7a6ba2){_0x455d37['push'](_0x455d37['shift']());}};_0x10d3e1(++_0x9b1de3);}(_0xe48c,0xf4));var _0xce48=function(_0x26df27,_0x163361){_0x26df27=_0x26df27-0x0;var _0x2fa81c=_0xe48c[_0x26df27];return _0x2fa81c;};'use strict';var _=require(_0xce48('0x0'));var util=require('util');var logger=require(_0xce48('0x1'))(_0xce48('0x2'));var moment=require(_0xce48('0x3'));var BPromise=require(_0xce48('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xce48('0x5'));var rimraf=require(_0xce48('0x6'));var config=require(_0xce48('0x7'));var attributes=require(_0xce48('0x8'));module[_0xce48('0x9')]=function(_0x577fd0,_0x3a4856){return _0x577fd0[_0xce48('0xa')](_0xce48('0xb'),attributes,{'tableName':'int_desk_fields','paranoid':![],'indexes':[{'name':_0xce48('0xc'),'fields':[_0xce48('0xd'),_0xce48('0xe')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDeskField/intDeskField.rpc.js b/server/api/intDeskField/intDeskField.rpc.js new file mode 100644 index 0000000..6928765 --- /dev/null +++ b/server/api/intDeskField/intDeskField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc8c=['error','code','message','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','DeskField,\x20%s,\x20%s','request\x20sent','debug','DeskField,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x209941,_0x5c9988){var _0x1e8729=function(_0x51a9b8){while(--_0x51a9b8){_0x209941['push'](_0x209941['shift']());}};_0x1e8729(++_0x5c9988);}(_0xfc8c,0x1a1));var _0xcfc8=function(_0x1ac053,_0x39267a){_0x1ac053=_0x1ac053-0x0;var _0x2d209a=_0xfc8c[_0x1ac053];return _0x2d209a;};'use strict';var _=require(_0xcfc8('0x0'));var util=require(_0xcfc8('0x1'));var moment=require(_0xcfc8('0x2'));var BPromise=require(_0xcfc8('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcfc8('0x4'));var db=require(_0xcfc8('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xcfc8('0x6'))(_0xcfc8('0x7'));var config=require(_0xcfc8('0x8'));var jayson=require(_0xcfc8('0x9'));var client=jayson[_0xcfc8('0xa')][_0xcfc8('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x486f64,_0x1a0043,_0x3df924){return new BPromise(function(_0x3cbfe2,_0x53c23f){return client[_0xcfc8('0xc')](_0x486f64,_0x3df924)[_0xcfc8('0xd')](function(_0x3e43bc){logger[_0xcfc8('0xe')](_0xcfc8('0xf'),_0x1a0043,_0xcfc8('0x10'));logger[_0xcfc8('0x11')](_0xcfc8('0x12'),_0x1a0043,_0xcfc8('0x10'),JSON[_0xcfc8('0x13')](_0x3e43bc));if(_0x3e43bc[_0xcfc8('0x14')]){if(_0x3e43bc[_0xcfc8('0x14')][_0xcfc8('0x15')]===0x1f4){logger[_0xcfc8('0x14')](_0xcfc8('0xf'),_0x1a0043,_0x3e43bc[_0xcfc8('0x14')][_0xcfc8('0x16')]);return _0x53c23f(_0x3e43bc['error'][_0xcfc8('0x16')]);}logger['error'](_0xcfc8('0xf'),_0x1a0043,_0x3e43bc[_0xcfc8('0x14')]['message']);return _0x3cbfe2(_0x3e43bc[_0xcfc8('0x14')][_0xcfc8('0x16')]);}else{logger['info']('DeskField,\x20%s,\x20%s',_0x1a0043,'request\x20sent');_0x3cbfe2(_0x3e43bc['result'][_0xcfc8('0x16')]);}})['catch'](function(_0x21cf5d){logger['error'](_0xcfc8('0xf'),_0x1a0043,_0x21cf5d);_0x53c23f(_0x21cf5d);});});} \ No newline at end of file diff --git a/server/api/intDynamics365Account/index.js b/server/api/intDynamics365Account/index.js new file mode 100644 index 0000000..7139770 --- /dev/null +++ b/server/api/intDynamics365Account/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd3b0=['express','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./intDynamics365Account.controller','get','/:id','show','/:id/configurations','isAuthenticated','getConfigurations','/:id/fields','post','create','put','update','delete','destroy','exports','multer','util','path','connect-timeout'];(function(_0x4f1eb9,_0x27e51d){var _0x5151c5=function(_0xdd7174){while(--_0xdd7174){_0x4f1eb9['push'](_0x4f1eb9['shift']());}};_0x5151c5(++_0x27e51d);}(_0xd3b0,0xa4));var _0x0d3b=function(_0x6b8ca3,_0x18bfa2){_0x6b8ca3=_0x6b8ca3-0x0;var _0x382b4a=_0xd3b0[_0x6b8ca3];return _0x382b4a;};'use strict';var multer=require(_0x0d3b('0x0'));var util=require(_0x0d3b('0x1'));var path=require(_0x0d3b('0x2'));var timeout=require(_0x0d3b('0x3'));var express=require(_0x0d3b('0x4'));var router=express[_0x0d3b('0x5')]();var fs_extra=require('fs-extra');var auth=require(_0x0d3b('0x6'));var interaction=require(_0x0d3b('0x7'));var config=require(_0x0d3b('0x8'));var controller=require(_0x0d3b('0x9'));router[_0x0d3b('0xa')]('/',auth['isAuthenticated'](),controller['index']);router['get'](_0x0d3b('0xb'),auth['isAuthenticated'](),controller[_0x0d3b('0xc')]);router[_0x0d3b('0xa')](_0x0d3b('0xd'),auth[_0x0d3b('0xe')](),controller[_0x0d3b('0xf')]);router[_0x0d3b('0xa')](_0x0d3b('0x10'),auth[_0x0d3b('0xe')](),controller['getFields']);router[_0x0d3b('0x11')]('/',auth[_0x0d3b('0xe')](),controller[_0x0d3b('0x12')]);router[_0x0d3b('0x11')](_0x0d3b('0xd'),auth[_0x0d3b('0xe')](),controller['addConfiguration']);router[_0x0d3b('0x13')](_0x0d3b('0xb'),auth[_0x0d3b('0xe')](),controller[_0x0d3b('0x14')]);router[_0x0d3b('0x15')](_0x0d3b('0xb'),auth['isAuthenticated'](),controller[_0x0d3b('0x16')]);module[_0x0d3b('0x17')]=router; \ No newline at end of file diff --git a/server/api/intDynamics365Account/intDynamics365Account.attributes.js b/server/api/intDynamics365Account/intDynamics365Account.attributes.js new file mode 100644 index 0000000..2720e4c --- /dev/null +++ b/server/api/intDynamics365Account/intDynamics365Account.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaa48=['STRING','BOOLEAN','sequelize','exports'];(function(_0x3f0eae,_0x3477b9){var _0x334345=function(_0x6f2cf4){while(--_0x6f2cf4){_0x3f0eae['push'](_0x3f0eae['shift']());}};_0x334345(++_0x3477b9);}(_0xaa48,0x15a));var _0x8aa4=function(_0x3c02a9,_0x3e383b){_0x3c02a9=_0x3c02a9-0x0;var _0x43433f=_0xaa48[_0x3c02a9];return _0x43433f;};'use strict';var Sequelize=require(_0x8aa4('0x0'));module[_0x8aa4('0x1')]={'name':{'type':Sequelize[_0x8aa4('0x2')]},'username':{'type':Sequelize[_0x8aa4('0x2')]},'password':{'type':Sequelize[_0x8aa4('0x2')]},'remoteUri':{'type':Sequelize[_0x8aa4('0x2')]},'tenantId':{'type':Sequelize[_0x8aa4('0x2')]},'clientId':{'type':Sequelize[_0x8aa4('0x2')]},'clientSecret':{'type':Sequelize[_0x8aa4('0x2')]},'serverUrl':{'type':Sequelize[_0x8aa4('0x2')],'allowNull':![]},'description':{'type':Sequelize[_0x8aa4('0x2')]},'modernAuthentication':{'type':Sequelize[_0x8aa4('0x3')],'defaultValue':!![]}}; \ No newline at end of file diff --git a/server/api/intDynamics365Account/intDynamics365Account.controller.js b/server/api/intDynamics365Account/intDynamics365Account.controller.js new file mode 100644 index 0000000..80033a8 --- /dev/null +++ b/server/api/intDynamics365Account/intDynamics365Account.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x00d0=['Dynamics365Account','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','create','body','destroy','find','getConfigurations','findOne','Dynamics365Configuration','addConfiguration','Subjects','getSubjects','channel','Dynamics365Field','slice','substring','lastIndexOf','%s/api/data/v9.0/','getFields','ticketType','incident','title','description','customerid','ownerid','caseorigincode','subject','phonenumber','directioncode','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyyominame','modifiedbyyominame','modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidname','prioritycodename','productidname','productserialnumber','resolveby','responseby','responsiblecontactidname','responsiblecontactidyominame','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','remoteUri','tenantId','clientId','clientSecret','CloudProvider','data7','access_token','data5','/oauth2/token','password','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','value','MetadataId','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','4.0','Attributes','remove','includes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','push','all','BooleanAttributeMetadata','StringAttributeMetadata','BigIntAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','StateAttributeMetadata','test','statusCode','Wrong\x20credentials',')/Attributes(','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','UserLocalizedLabel','Label','Value','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','true','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','../../components/parsers/qs','../../config/logger','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','update','then','sendStatus','error','stack','name','send','map'];(function(_0x44946b,_0xf874ec){var _0x249bc4=function(_0x40a23e){while(--_0x40a23e){_0x44946b['push'](_0x44946b['shift']());}};_0x249bc4(++_0xf874ec);}(_0x00d0,0x163));var _0x000d=function(_0x4a36b1,_0x3759b6){_0x4a36b1=_0x4a36b1-0x0;var _0x265219=_0x00d0[_0x4a36b1];return _0x265219;};'use strict';var rp=require(_0x000d('0x0'));var util=require(_0x000d('0x1'));var _=require('lodash');var qs=require(_0x000d('0x2'));var logger=require(_0x000d('0x3'))('api');var db=require('../../mysqldb')['db'];var integrations=require(_0x000d('0x4'));function respondWithResult(_0x6d02aa,_0x55cade){_0x55cade=_0x55cade||0xc8;return function(_0x1bd3fc){if(_0x1bd3fc){return _0x6d02aa[_0x000d('0x5')](_0x55cade)[_0x000d('0x6')](_0x1bd3fc);}};}function respondWithFilteredResult(_0x442d81,_0x5a80e3){return function(_0x5af8bf){if(_0x5af8bf){var _0x3da096=typeof _0x5a80e3[_0x000d('0x7')]===_0x000d('0x8')&&typeof _0x5a80e3[_0x000d('0x9')]===_0x000d('0x8');var _0xaeffc=_0x5af8bf['count'];var _0x35ac59=_0x3da096?0x0:_0x5a80e3[_0x000d('0x7')];var _0x5689a4=_0x3da096?_0x5af8bf[_0x000d('0xa')]:_0x5a80e3['offset']+_0x5a80e3[_0x000d('0x9')];var _0x31c8cc;if(_0x5689a4>=_0xaeffc){_0x5689a4=_0xaeffc;_0x31c8cc=0xc8;}else{_0x31c8cc=0xce;}_0x442d81[_0x000d('0x5')](_0x31c8cc);return _0x442d81[_0x000d('0xb')](_0x000d('0xc'),_0x35ac59+'-'+_0x5689a4+'/'+_0xaeffc)[_0x000d('0x6')](_0x5af8bf);}return null;};}function saveUpdates(_0x85debd){return function(_0x5c3ece){if(_0x5c3ece){return _0x5c3ece[_0x000d('0xd')](_0x85debd)[_0x000d('0xe')](function(_0xbe54a9){return _0xbe54a9;});}return null;};}function removeEntity(_0x198089){return function(_0x2616ff){if(_0x2616ff){return _0x2616ff['destroy']()[_0x000d('0xe')](function(){_0x198089[_0x000d('0x5')](0xcc)['end']();});}};}function handleEntityNotFound(_0x457923){return function(_0x336835){if(!_0x336835){_0x457923[_0x000d('0xf')](0x194);}return _0x336835;};}function handleError(_0x3955c3,_0x4091bd){_0x4091bd=_0x4091bd||0x1f4;return function(_0x173d69){logger[_0x000d('0x10')](_0x173d69[_0x000d('0x11')]);if(_0x173d69['name']){delete _0x173d69[_0x000d('0x12')];}_0x3955c3['status'](_0x4091bd)[_0x000d('0x13')](_0x173d69);};}exports['index']=function(_0x5fc197,_0x262d25){var _0x416fd3={},_0x36469a={},_0x322d20={'count':0x0,'rows':[]};var _0x3f36f5=_[_0x000d('0x14')](db[_0x000d('0x15')][_0x000d('0x16')],function(_0x48d5b1){return{'name':_0x48d5b1[_0x000d('0x17')],'type':_0x48d5b1[_0x000d('0x18')][_0x000d('0x19')]};});_0x36469a['model']=_[_0x000d('0x14')](_0x3f36f5,'name');_0x36469a['query']=_[_0x000d('0x1a')](_0x5fc197[_0x000d('0x1b')]);_0x36469a[_0x000d('0x1c')]=_[_0x000d('0x1d')](_0x36469a[_0x000d('0x1e')],_0x36469a[_0x000d('0x1b')]);_0x416fd3[_0x000d('0x1f')]=_[_0x000d('0x1d')](_0x36469a[_0x000d('0x1e')],qs[_0x000d('0x20')](_0x5fc197[_0x000d('0x1b')]['fields']));_0x416fd3[_0x000d('0x1f')]=_0x416fd3['attributes'][_0x000d('0x21')]?_0x416fd3[_0x000d('0x1f')]:_0x36469a[_0x000d('0x1e')];if(!_0x5fc197['query'][_0x000d('0x22')](_0x000d('0x23'))){_0x416fd3[_0x000d('0x9')]=qs[_0x000d('0x9')](_0x5fc197[_0x000d('0x1b')][_0x000d('0x9')]);_0x416fd3['offset']=qs['offset'](_0x5fc197[_0x000d('0x1b')][_0x000d('0x7')]);}_0x416fd3[_0x000d('0x24')]=qs[_0x000d('0x25')](_0x5fc197[_0x000d('0x1b')]['sort']);_0x416fd3[_0x000d('0x26')]=qs[_0x000d('0x1c')](_[_0x000d('0x27')](_0x5fc197['query'],_0x36469a[_0x000d('0x1c')]),_0x3f36f5);if(_0x5fc197['query'][_0x000d('0x28')]){_0x416fd3[_0x000d('0x26')]=_[_0x000d('0x29')](_0x416fd3['where'],{'$or':_[_0x000d('0x14')](_0x3f36f5,function(_0x2e5a02){if(_0x2e5a02[_0x000d('0x18')]!==_0x000d('0x2a')){var _0x395779={};_0x395779[_0x2e5a02[_0x000d('0x12')]]={'$like':'%'+_0x5fc197[_0x000d('0x1b')][_0x000d('0x28')]+'%'};return _0x395779;}})});}_0x416fd3=_['merge']({},_0x416fd3,_0x5fc197[_0x000d('0x2b')]);var _0x48a0d7={'where':_0x416fd3[_0x000d('0x26')]};return db['Dynamics365Account'][_0x000d('0xa')](_0x48a0d7)['then'](function(_0x1c9637){_0x322d20[_0x000d('0xa')]=_0x1c9637;if(_0x5fc197[_0x000d('0x1b')][_0x000d('0x2c')]){_0x416fd3[_0x000d('0x2d')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x000d('0x2e')](_0x416fd3);})[_0x000d('0xe')](function(_0xa9e9dd){_0x322d20[_0x000d('0x2f')]=_0xa9e9dd;return _0x322d20;})['then'](respondWithFilteredResult(_0x262d25,_0x416fd3))[_0x000d('0x30')](handleError(_0x262d25,null));};exports['show']=function(_0x2ac3ac,_0x566fc2){var _0x5cd99b={'raw':![],'where':{'id':_0x2ac3ac[_0x000d('0x31')]['id']}},_0x57594f={};_0x57594f[_0x000d('0x1e')]=_[_0x000d('0x1a')](db[_0x000d('0x15')][_0x000d('0x16')]);_0x57594f[_0x000d('0x1b')]=_[_0x000d('0x1a')](_0x2ac3ac[_0x000d('0x1b')]);_0x57594f[_0x000d('0x1c')]=_['intersection'](_0x57594f['model'],_0x57594f[_0x000d('0x1b')]);_0x5cd99b[_0x000d('0x1f')]=_[_0x000d('0x1d')](_0x57594f[_0x000d('0x1e')],qs[_0x000d('0x20')](_0x2ac3ac['query'][_0x000d('0x20')]));_0x5cd99b['attributes']=_0x5cd99b['attributes'][_0x000d('0x21')]?_0x5cd99b[_0x000d('0x1f')]:_0x57594f['model'];if(_0x2ac3ac['query'][_0x000d('0x2c')]){_0x5cd99b[_0x000d('0x2d')]=[{'all':!![]}];}_0x5cd99b=_[_0x000d('0x29')]({},_0x5cd99b,_0x2ac3ac[_0x000d('0x2b')]);return db[_0x000d('0x15')]['find'](_0x5cd99b)[_0x000d('0xe')](handleEntityNotFound(_0x566fc2,null))[_0x000d('0xe')](respondWithResult(_0x566fc2,null))[_0x000d('0x30')](handleError(_0x566fc2,null));};exports[_0x000d('0x32')]=function(_0x830c67,_0x3c52d6){return db[_0x000d('0x15')][_0x000d('0x32')](_0x830c67['body'],{})[_0x000d('0xe')](respondWithResult(_0x3c52d6,0xc9))[_0x000d('0x30')](handleError(_0x3c52d6,null));};exports[_0x000d('0xd')]=function(_0x4db665,_0x2d3599){if(_0x4db665[_0x000d('0x33')]['id']){delete _0x4db665['body']['id'];}return db[_0x000d('0x15')]['find']({'where':{'id':_0x4db665['params']['id']}})[_0x000d('0xe')](handleEntityNotFound(_0x2d3599,null))[_0x000d('0xe')](saveUpdates(_0x4db665[_0x000d('0x33')],null))[_0x000d('0xe')](respondWithResult(_0x2d3599,null))[_0x000d('0x30')](handleError(_0x2d3599,null));};exports[_0x000d('0x34')]=function(_0x4bdf62,_0x23284b){return db[_0x000d('0x15')][_0x000d('0x35')]({'where':{'id':_0x4bdf62[_0x000d('0x31')]['id']}})[_0x000d('0xe')](handleEntityNotFound(_0x23284b,null))[_0x000d('0xe')](removeEntity(_0x23284b,null))['catch'](handleError(_0x23284b,null));};exports[_0x000d('0x36')]=function(_0x335821,_0x97eb75){var _0x583201={};var _0x542270={};var _0x414b97;var _0x17a968;return db[_0x000d('0x15')][_0x000d('0x37')]({'where':{'id':_0x335821[_0x000d('0x31')]['id']}})[_0x000d('0xe')](handleEntityNotFound(_0x97eb75,null))[_0x000d('0xe')](function(_0x54fd9c){if(_0x54fd9c){_0x414b97=_0x54fd9c;_0x542270[_0x000d('0x1e')]=_['keys'](db[_0x000d('0x38')][_0x000d('0x16')]);_0x542270[_0x000d('0x1b')]=_[_0x000d('0x1a')](_0x335821[_0x000d('0x1b')]);_0x542270[_0x000d('0x1c')]=_[_0x000d('0x1d')](_0x542270[_0x000d('0x1e')],_0x542270[_0x000d('0x1b')]);_0x583201[_0x000d('0x1f')]=_[_0x000d('0x1d')](_0x542270[_0x000d('0x1e')],qs[_0x000d('0x20')](_0x335821[_0x000d('0x1b')][_0x000d('0x20')]));_0x583201['attributes']=_0x583201[_0x000d('0x1f')][_0x000d('0x21')]?_0x583201['attributes']:_0x542270['model'];_0x583201[_0x000d('0x24')]=qs[_0x000d('0x25')](_0x335821[_0x000d('0x1b')][_0x000d('0x25')]);_0x583201['where']=qs[_0x000d('0x1c')](_['pick'](_0x335821[_0x000d('0x1b')],_0x542270[_0x000d('0x1c')]));if(_0x335821[_0x000d('0x1b')][_0x000d('0x28')]){_0x583201[_0x000d('0x26')]=_[_0x000d('0x29')](_0x583201[_0x000d('0x26')],{'$or':_[_0x000d('0x14')](_0x583201['attributes'],function(_0x296de3){var _0x5df25a={};_0x5df25a[_0x296de3]={'$like':'%'+_0x335821[_0x000d('0x1b')][_0x000d('0x28')]+'%'};return _0x5df25a;})});}_0x583201=_[_0x000d('0x29')]({},_0x583201,_0x335821[_0x000d('0x2b')]);return _0x414b97[_0x000d('0x36')](_0x583201);}})[_0x000d('0xe')](function(_0x4c47ef){if(_0x4c47ef){_0x17a968=_0x4c47ef[_0x000d('0x21')];if(!_0x335821[_0x000d('0x1b')][_0x000d('0x22')](_0x000d('0x23'))){_0x583201[_0x000d('0x9')]=qs[_0x000d('0x9')](_0x335821[_0x000d('0x1b')]['limit']);_0x583201[_0x000d('0x7')]=qs[_0x000d('0x7')](_0x335821[_0x000d('0x1b')]['offset']);}return _0x414b97['getConfigurations'](_0x583201);}})['then'](function(_0x4c879b){if(_0x4c879b){return _0x4c879b?{'count':_0x17a968,'rows':_0x4c879b}:null;}})[_0x000d('0xe')](respondWithResult(_0x97eb75,null))[_0x000d('0x30')](handleError(_0x97eb75,null));};exports[_0x000d('0x39')]=function(_0x56d61a,_0x230f57){if(_0x56d61a['body']['id']){delete _0x56d61a[_0x000d('0x33')]['id'];}return db[_0x000d('0x15')][_0x000d('0x37')]({'where':{'id':_0x56d61a[_0x000d('0x31')]['id']}})[_0x000d('0xe')](handleEntityNotFound(_0x230f57,null))[_0x000d('0xe')](function(_0x43b932){if(_0x43b932){_0x56d61a[_0x000d('0x33')]['AccountId']=_0x43b932['id'];_0x56d61a[_0x000d('0x33')][_0x000d('0x3a')]=integrations[_0x000d('0x3b')](_0x56d61a[_0x000d('0x33')][_0x000d('0x3c')],_0x56d61a[_0x000d('0x33')]['type']);_0x56d61a[_0x000d('0x33')]['Descriptions']=integrations['getDescriptions'](_0x56d61a[_0x000d('0x33')][_0x000d('0x3c')],_0x56d61a['body'][_0x000d('0x18')]);return db[_0x000d('0x38')][_0x000d('0x32')](_0x56d61a['body'],{'include':[{'model':db[_0x000d('0x3d')],'as':_0x000d('0x3a')},{'model':db[_0x000d('0x3d')],'as':'Descriptions'}]});}return null;})[_0x000d('0xe')](respondWithResult(_0x230f57,null))[_0x000d('0x30')](handleError(_0x230f57,null));};function sanitizeRemoteUri(_0x325c58){var _0xec7f32=_0x325c58[_0x000d('0x3e')](-0x1);if(_0xec7f32==='/')return _0x325c58[_0x000d('0x3f')](0x0,_0x325c58[_0x000d('0x40')](_0xec7f32));return _0x325c58;}function getWebApiUrl(_0x3853b6){return util['format'](_0x000d('0x41'),_0x3853b6);}exports[_0x000d('0x42')]=function(_0x33918d,_0x3a0960){var _0x2a3921=_0x33918d[_0x000d('0x1b')][_0x000d('0x43')];var _0x35b886=_0x2a3921===_0x000d('0x44')?'Incident':'PhoneCall';var _0x33c6e5='';var _0x135e2e='';var _0x1d25bd='';var _0x59ffc2='';var _0x643b36='';var _0x2414ec='';var _0x5548da='';var _0x583f64='';var _0x22410e=[_0x000d('0x45'),_0x000d('0x46'),_0x000d('0x47'),_0x000d('0x48'),_0x000d('0x49'),_0x000d('0x4a'),_0x000d('0x4b'),'regardingobjectid',_0x000d('0x4c'),'phonecall_activity_parties'];var _0x2c49d1=[_0x000d('0x4d'),_0x000d('0x4e'),_0x000d('0x4f'),_0x000d('0x50'),_0x000d('0x51'),'contactidyominame',_0x000d('0x52'),_0x000d('0x53'),_0x000d('0x54'),'createdbyexternalpartyyominame',_0x000d('0x55'),'createdbyyominame','createdon','createdonbehalfbyname',_0x000d('0x56'),_0x000d('0x57'),_0x000d('0x58'),_0x000d('0x59'),_0x000d('0x5a'),_0x000d('0x5b'),_0x000d('0x5c'),_0x000d('0x5d'),_0x000d('0x5e'),_0x000d('0x5f'),'firstresponsebykpiidname',_0x000d('0x60'),_0x000d('0x61'),_0x000d('0x62'),_0x000d('0x63'),_0x000d('0x64'),_0x000d('0x65'),'modifiedbyexternalpartyname',_0x000d('0x66'),'modifiedbyname',_0x000d('0x67'),_0x000d('0x68'),_0x000d('0x69'),_0x000d('0x6a'),_0x000d('0x6b'),_0x000d('0x6c'),_0x000d('0x6d'),_0x000d('0x6e'),_0x000d('0x6f'),_0x000d('0x70'),_0x000d('0x71'),_0x000d('0x72'),_0x000d('0x73'),_0x000d('0x74'),'primarycontactidyominame',_0x000d('0x75'),_0x000d('0x76'),_0x000d('0x77'),_0x000d('0x78'),'resolvebykpiidname',_0x000d('0x79'),_0x000d('0x7a'),_0x000d('0x7b'),'sentimentvalue',_0x000d('0x7c'),_0x000d('0x7d'),_0x000d('0x7e'),_0x000d('0x7f'),_0x000d('0x80'),'subjectidname',_0x000d('0x81'),_0x000d('0x82'),_0x000d('0x83'),_0x000d('0x84'),_0x000d('0x85'),_0x000d('0x86')];var _0x312283=_0x22410e[_0x000d('0x87')](_0x2c49d1);return db['Dynamics365Account']['findOne']({'where':{'id':_0x33918d[_0x000d('0x31')]['id']},'attributes':['id',_0x000d('0x88'),'password',_0x000d('0x89'),_0x000d('0x8a'),_0x000d('0x8b'),_0x000d('0x8c'),'modernAuthentication'],'include':[{'model':db['CloudProvider'],'as':_0x000d('0x8d'),'attributes':['id','data5',_0x000d('0x8e')]}]})[_0x000d('0xe')](handleEntityNotFound(_0x3a0960,null))['then'](function(_0x3bae4d){if(_0x3bae4d){if(_0x3bae4d['modernAuthentication']){_0x3bae4d[_0x000d('0x8f')]=_0x3bae4d[_0x000d('0x8d')][_0x000d('0x90')];_0x583f64=sanitizeRemoteUri(_0x3bae4d[_0x000d('0x8d')]['data7']);_0x5548da=getWebApiUrl(_0x583f64);return _0x3bae4d;}_0x583f64=sanitizeRemoteUri(_0x3bae4d[_0x000d('0x89')]);_0x5548da=getWebApiUrl(_0x583f64);var _0x25b227={'method':'POST','uri':'https://login.microsoftonline.com/'+_0x3bae4d['tenantId']+_0x000d('0x91'),'form':{'client_id':_0x3bae4d[_0x000d('0x8b')],'resource':_0x583f64,'username':_0x3bae4d['username'],'password':_0x3bae4d[_0x000d('0x92')],'grant_type':_0x000d('0x92'),'client_secret':_0x3bae4d[_0x000d('0x8c')]},'json':!![]};return rp(_0x25b227);}})[_0x000d('0xe')](function(_0x404a1b){_0x2414ec=_0x404a1b[_0x000d('0x8f')];var _0x580979={'method':_0x000d('0x93'),'uri':encodeURI(_0x5548da+_0x000d('0x94')+_0x35b886+'\x27'),'headers':{'Authorization':_0x000d('0x95')+_0x2414ec,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x580979);})[_0x000d('0xe')](function(_0x22c529){var _0x4a3c7d=_0x22c529[_0x000d('0x96')][0x0];var _0x539ee9=_0x4a3c7d[_0x000d('0x97')];var _0x2ce680={'method':'GET','uri':_0x5548da+_0x000d('0x98')+_0x539ee9+_0x000d('0x99'),'headers':{'Authorization':_0x000d('0x95')+_0x2414ec,'If-None-Match':null,'OData-Version':_0x000d('0x9a')},'json':!![]};return rp(_0x2ce680);})['then'](function(_0x5e6b28){_0x33c6e5=_0x5e6b28;_0x135e2e=_0x33c6e5[_0x000d('0x9b')];_0x135e2e=_[_0x000d('0x9c')](_0x135e2e,function(_0x1fe661){return!_0x312283[_0x000d('0x9d')](_0x1fe661[_0x000d('0x9e')]);});var _0x4ff887=[];var _0x36f54e=[];_0x135e2e[_0x000d('0x9f')](function(_0x55c220){if(_0x55c220['@odata.type']){var _0x3a4d07=_0x55c220[_0x000d('0xa0')][_0x000d('0x3f')](_0x55c220[_0x000d('0xa0')][_0x000d('0x40')]('.')+0x1);if(_0x3a4d07===_0x000d('0xa1')){_0x4ff887[_0x000d('0xa2')](getSelectList(_0x5548da,_0x2a3921,_0x36f54e,_0x33c6e5[_0x000d('0x97')],_0x55c220[_0x000d('0x97')],_0x2414ec));}}});return Promise[_0x000d('0xa3')](_0x4ff887);})[_0x000d('0xe')](function(_0x40cf09){_0x1d25bd=_0x40cf09[0x0];var _0x2c8cf8=[];var _0x5bdd14=[];_0x135e2e[_0x000d('0x9f')](function(_0x47455a){if(!_['isNil'](_0x47455a[_0x000d('0xa0')])){var _0xcd54c8=_0x47455a[_0x000d('0xa0')][_0x000d('0x3f')](_0x47455a['@odata.type'][_0x000d('0x40')]('.')+0x1);if(_0xcd54c8===_0x000d('0xa4')){_0x2c8cf8[_0x000d('0xa2')](getBooleanList(_0x5548da,_0x2a3921,_0x5bdd14,_0x33c6e5['MetadataId'],_0x47455a[_0x000d('0x97')],_0x2414ec));}}});return Promise['all'](_0x2c8cf8);})[_0x000d('0xe')](function(_0x3273d3){_0x59ffc2=_0x3273d3[0x0];var _0x41ad5b=[];var _0xab8d3b=[];_0x135e2e[_0x000d('0x9f')](function(_0x4e4854){if(_0x4e4854['@odata.type']){var _0x731476=_0x4e4854[_0x000d('0xa0')][_0x000d('0x3f')](_0x4e4854[_0x000d('0xa0')][_0x000d('0x40')]('.')+0x1);if(_0x731476===_0x000d('0xa5')||_0x731476==='DoubleAttributeMetadata'||_0x731476===_0x000d('0xa6')||_0x731476==='IntegerAttributeMetadata'||_0x731476===_0x000d('0xa7')||_0x731476===_0x000d('0xa8')||_0x731476===_0x000d('0xa9')||_0x731476==='EntityNameAttributeMetadata'||_0x731476===_0x000d('0xaa')||_0x731476==='DecimalAttributeMetadata'){_0x41ad5b[_0x000d('0xa2')](getInputList(_0x5548da,_0x2a3921,_0x731476,_0xab8d3b,_0x33c6e5[_0x000d('0x97')],_0x4e4854[_0x000d('0x97')],_0x2414ec));}}});return Promise[_0x000d('0xa3')](_0x41ad5b);})[_0x000d('0xe')](function(_0x3daaef){_0x643b36=_0x3daaef[0x0];var _0xdb2fb3=_0x1d25bd[_0x000d('0x87')](_0x59ffc2)[_0x000d('0x87')](_0x643b36);var _0x329455={'count':_0xdb2fb3['length'],'rows':_0xdb2fb3};return _0x329455;})[_0x000d('0xe')](respondWithResult(_0x3a0960,null))[_0x000d('0x30')](function(_0xaf0e91){var _0x3c6fc9=_0x33918d['query'][_0x000d('0xab')]?0x1f4:_0xaf0e91[_0x000d('0xac')]||0x1f4;logger[_0x000d('0x10')](_0xaf0e91[_0x000d('0x11')]);delete _0xaf0e91['name'];if(_0x3c6fc9===0x191){_0x3c6fc9=0x190;}_0x3a0960[_0x000d('0x5')](_0x3c6fc9)[_0x000d('0x13')](_0x33918d[_0x000d('0x1b')]['test']?{'message':_0x000d('0xad'),'statusCode':_0xaf0e91['statusCode']}:_0xaf0e91);});};function getSelectList(_0x381028,_0x1844f1,_0x8260c2,_0x7881d2,_0x3fa8d7,_0x5db68a){var _0x5b210e={'method':_0x000d('0x93'),'uri':_0x381028+_0x000d('0x98')+_0x7881d2+_0x000d('0xae')+_0x3fa8d7+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+_0x000d('0xaf'),'headers':{'Authorization':_0x000d('0x95')+_0x5db68a,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x5b210e)['then'](function(_0x2dc352){var _0x4600c9=[];var _0x11d870=_0x2dc352[_0x000d('0xb0')]['Options'];_0x11d870[_0x000d('0x9f')](function(_0x4e1a08){_0x4600c9[_0x000d('0xa2')]({'name':_0x4e1a08['Label'][_0x000d('0xb1')][_0x000d('0xb2')],'value':String(_0x4e1a08[_0x000d('0xb3')])});});var _0x9c993d={'id':_0x1844f1+'_'+_0x2dc352['LogicalName'],'name':_0x2dc352[_0x000d('0xb4')][_0x000d('0xb1')][_0x000d('0xb2')],'custom':![],'options':_0x4600c9};_0x8260c2[_0x000d('0xa2')](_0x9c993d);return _0x8260c2;});}function getBooleanList(_0x33e32b,_0x3ec12b,_0x376ce0,_0x92acf9,_0x35dfaf,_0x2365ef){var _0x2a1a22={'method':_0x000d('0x93'),'uri':_0x33e32b+_0x000d('0x98')+_0x92acf9+_0x000d('0xae')+_0x35dfaf+_0x000d('0xb5'),'headers':{'Authorization':_0x000d('0x95')+_0x2365ef,'If-None-Match':null,'OData-Version':_0x000d('0x9a')},'json':!![]};return rp(_0x2a1a22)[_0x000d('0xe')](function(_0x2d8f54){var _0x58db2d=[];_0x58db2d[_0x000d('0xa2')]({'name':_0x2d8f54['OptionSet'][_0x000d('0xb6')][_0x000d('0xb2')][_0x000d('0xb1')][_0x000d('0xb2')],'value':_0x000d('0xb7')},{'name':_0x2d8f54['OptionSet'][_0x000d('0xb8')][_0x000d('0xb2')][_0x000d('0xb1')][_0x000d('0xb2')],'value':_0x000d('0xb9')});var _0xe73f26={'id':_0x3ec12b+'_'+_0x2d8f54['LogicalName'],'name':_0x2d8f54[_0x000d('0xb4')][_0x000d('0xb1')][_0x000d('0xb2')],'custom':![],'options':_0x58db2d};_0x376ce0[_0x000d('0xa2')](_0xe73f26);return _0x376ce0;});}function getInputList(_0x2c360f,_0x4d1ab3,_0x590f87,_0x1c3291,_0x13aaa1,_0x24f8d6,_0x969d2d){var _0x3d74d6={'method':_0x000d('0x93'),'uri':_0x2c360f+_0x000d('0x98')+_0x13aaa1+')/Attributes('+_0x24f8d6+_0x000d('0xba')+_0x590f87+_0x000d('0xbb'),'headers':{'Authorization':_0x000d('0x95')+_0x969d2d,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x3d74d6)[_0x000d('0xe')](function(_0x39d1c9){var _0x18a83f={'id':_0x4d1ab3+'_'+_0x39d1c9['LogicalName'],'name':_0x39d1c9[_0x000d('0xb4')][_0x000d('0xb1')]?_0x39d1c9['DisplayName'][_0x000d('0xb1')][_0x000d('0xb2')]:_0x39d1c9['LogicalName'],'custom':![],'options':[]};_0x1c3291[_0x000d('0xa2')](_0x18a83f);return _0x1c3291;});} \ No newline at end of file diff --git a/server/api/intDynamics365Account/intDynamics365Account.model.js b/server/api/intDynamics365Account/intDynamics365Account.model.js new file mode 100644 index 0000000..06c207c --- /dev/null +++ b/server/api/intDynamics365Account/intDynamics365Account.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb7e7=['int_dynamics365_accounts','lodash','../../config/logger','moment','request-promise','rimraf','../../config/environment','./intDynamics365Account.attributes','define'];(function(_0x57143c,_0x576da8){var _0x4d4410=function(_0x332ddd){while(--_0x332ddd){_0x57143c['push'](_0x57143c['shift']());}};_0x4d4410(++_0x576da8);}(_0xb7e7,0x121));var _0x7b7e=function(_0x369151,_0x179f72){_0x369151=_0x369151-0x0;var _0x4292d5=_0xb7e7[_0x369151];return _0x4292d5;};'use strict';var _=require(_0x7b7e('0x0'));var util=require('util');var logger=require(_0x7b7e('0x1'))('api');var moment=require(_0x7b7e('0x2'));var BPromise=require('bluebird');var rp=require(_0x7b7e('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0x7b7e('0x4'));var config=require(_0x7b7e('0x5'));var attributes=require(_0x7b7e('0x6'));var integrations=require('../../components/integrations/configuration');module['exports']=function(_0x333fa4,_0x372bde){return _0x333fa4[_0x7b7e('0x7')]('Dynamics365Account',attributes,{'tableName':_0x7b7e('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDynamics365Account/intDynamics365Account.rpc.js b/server/api/intDynamics365Account/intDynamics365Account.rpc.js new file mode 100644 index 0000000..306bc0b --- /dev/null +++ b/server/api/intDynamics365Account/intDynamics365Account.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbddc=['message','catch','GetDynamics365Account','Dynamics365Account','options','where','attributes','limit','include','map','model','ShowDynamics365Account','find','raw','debug','lodash','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x4a5ed5,_0x80fce9){var _0x2410de=function(_0x520865){while(--_0x520865){_0x4a5ed5['push'](_0x4a5ed5['shift']());}};_0x2410de(++_0x80fce9);}(_0xbddc,0xfd));var _0xcbdd=function(_0xde81cc,_0x26c733){_0xde81cc=_0xde81cc-0x0;var _0x53a3fc=_0xbddc[_0xde81cc];return _0x53a3fc;};'use strict';var _=require(_0xcbdd('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xcbdd('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcbdd('0x2'));var db=require(_0xcbdd('0x3'))['db'];var utils=require(_0xcbdd('0x4'));var logger=require(_0xcbdd('0x5'))(_0xcbdd('0x6'));var config=require(_0xcbdd('0x7'));var jayson=require(_0xcbdd('0x8'));var client=jayson[_0xcbdd('0x9')][_0xcbdd('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2f1dd9,_0x32c764,_0x7b69ad){return new BPromise(function(_0x43c1d6,_0x1560be){return client[_0xcbdd('0xb')](_0x2f1dd9,_0x7b69ad)[_0xcbdd('0xc')](function(_0x55636c){logger[_0xcbdd('0xd')](_0xcbdd('0xe'),_0x32c764,_0xcbdd('0xf'));logger['debug'](_0xcbdd('0x10'),_0x32c764,_0xcbdd('0xf'),JSON[_0xcbdd('0x11')](_0x55636c));if(_0x55636c[_0xcbdd('0x12')]){if(_0x55636c['error']['code']===0x1f4){logger[_0xcbdd('0x12')]('Dynamics365Account,\x20%s,\x20%s',_0x32c764,_0x55636c[_0xcbdd('0x12')][_0xcbdd('0x13')]);return _0x1560be(_0x55636c['error'][_0xcbdd('0x13')]);}logger[_0xcbdd('0x12')](_0xcbdd('0xe'),_0x32c764,_0x55636c[_0xcbdd('0x12')][_0xcbdd('0x13')]);return _0x43c1d6(_0x55636c['error']['message']);}else{logger[_0xcbdd('0xd')](_0xcbdd('0xe'),_0x32c764,_0xcbdd('0xf'));_0x43c1d6(_0x55636c['result'][_0xcbdd('0x13')]);}})[_0xcbdd('0x14')](function(_0x31d976){logger[_0xcbdd('0x12')](_0xcbdd('0xe'),_0x32c764,_0x31d976);_0x1560be(_0x31d976);});});}exports[_0xcbdd('0x15')]=function(_0x5169c7){var _0x335fc9=this;return new Promise(function(_0x4de712,_0x16ac2e){return db[_0xcbdd('0x16')]['findAll']({'raw':_0x5169c7['options']?_0x5169c7[_0xcbdd('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x5169c7[_0xcbdd('0x17')]?_0x5169c7['options'][_0xcbdd('0x18')]||null:null,'attributes':_0x5169c7['options']?_0x5169c7[_0xcbdd('0x17')][_0xcbdd('0x19')]||null:null,'limit':_0x5169c7[_0xcbdd('0x17')]?_0x5169c7['options'][_0xcbdd('0x1a')]||null:null,'include':_0x5169c7['options']?_0x5169c7[_0xcbdd('0x17')][_0xcbdd('0x1b')]?_[_0xcbdd('0x1c')](_0x5169c7[_0xcbdd('0x17')][_0xcbdd('0x1b')],function(_0x4b658e){return{'model':db[_0x4b658e[_0xcbdd('0x1d')]],'as':_0x4b658e['as'],'attributes':_0x4b658e[_0xcbdd('0x19')],'include':_0x4b658e['include']?_[_0xcbdd('0x1c')](_0x4b658e[_0xcbdd('0x1b')],function(_0x5e3d59){return{'model':db[_0x5e3d59['model']],'as':_0x5e3d59['as'],'attributes':_0x5e3d59[_0xcbdd('0x19')],'include':_0x5e3d59[_0xcbdd('0x1b')]?_[_0xcbdd('0x1c')](_0x5e3d59[_0xcbdd('0x1b')],function(_0x8547e4){return{'model':db[_0x8547e4[_0xcbdd('0x1d')]],'as':_0x8547e4['as'],'attributes':_0x8547e4[_0xcbdd('0x19')]};}):[]};}):[]};}):[]:[]})[_0xcbdd('0xc')](function(_0xab2eed){logger[_0xcbdd('0xd')]('GetDynamics365Account',_0x5169c7);logger['debug'](_0xcbdd('0x15'),_0x5169c7,JSON['stringify'](_0xab2eed));_0x4de712(_0xab2eed);})[_0xcbdd('0x14')](function(_0x493757){logger[_0xcbdd('0x12')](_0xcbdd('0x15'),_0x493757[_0xcbdd('0x13')],_0x5169c7);_0x16ac2e(_0x335fc9[_0xcbdd('0x12')](0x1f4,_0x493757[_0xcbdd('0x13')]));});});};exports[_0xcbdd('0x1e')]=function(_0x361f3b){var _0x25335e=this;return new Promise(function(_0x5bf494,_0x57c15d){return db[_0xcbdd('0x16')][_0xcbdd('0x1f')]({'raw':_0x361f3b[_0xcbdd('0x17')]?_0x361f3b[_0xcbdd('0x17')][_0xcbdd('0x20')]===undefined?!![]:![]:!![],'where':_0x361f3b[_0xcbdd('0x17')]?_0x361f3b[_0xcbdd('0x17')][_0xcbdd('0x18')]||null:null,'attributes':_0x361f3b[_0xcbdd('0x17')]?_0x361f3b[_0xcbdd('0x17')][_0xcbdd('0x19')]||null:null,'include':_0x361f3b[_0xcbdd('0x17')]?_0x361f3b[_0xcbdd('0x17')][_0xcbdd('0x1b')]?_[_0xcbdd('0x1c')](_0x361f3b['options'][_0xcbdd('0x1b')],function(_0x47dcab){return{'model':db[_0x47dcab['model']],'as':_0x47dcab['as'],'attributes':_0x47dcab[_0xcbdd('0x19')],'include':_0x47dcab[_0xcbdd('0x1b')]?_[_0xcbdd('0x1c')](_0x47dcab['include'],function(_0x949f33){return{'model':db[_0x949f33[_0xcbdd('0x1d')]],'as':_0x949f33['as'],'attributes':_0x949f33[_0xcbdd('0x19')],'include':_0x949f33[_0xcbdd('0x1b')]?_[_0xcbdd('0x1c')](_0x949f33['include'],function(_0x18a99e){return{'model':db[_0x18a99e['model']],'as':_0x18a99e['as'],'attributes':_0x18a99e[_0xcbdd('0x19')]};}):[]};}):[]};}):[]:[]})[_0xcbdd('0xc')](function(_0x3c5a16){logger['info'](_0xcbdd('0x1e'),_0x361f3b);logger[_0xcbdd('0x21')](_0xcbdd('0x1e'),_0x361f3b,JSON[_0xcbdd('0x11')](_0x3c5a16));_0x5bf494(_0x3c5a16);})['catch'](function(_0xa1d4b1){logger[_0xcbdd('0x12')]('ShowDynamics365Account',_0xa1d4b1[_0xcbdd('0x13')],_0x361f3b);_0x57c15d(_0x25335e[_0xcbdd('0x12')](0x1f4,_0xa1d4b1['message']));});});}; \ No newline at end of file diff --git a/server/api/intDynamics365Configuration/index.js b/server/api/intDynamics365Configuration/index.js new file mode 100644 index 0000000..0ab02ce --- /dev/null +++ b/server/api/intDynamics365Configuration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2143=['create','destroy','exports','multer','util','path','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intDynamics365Configuration.controller','get','isAuthenticated','index','/:id','show','getFields','/:id/subjects','getSubjects','post'];(function(_0xe544e9,_0x101cb6){var _0x567259=function(_0x50705d){while(--_0x50705d){_0xe544e9['push'](_0xe544e9['shift']());}};_0x567259(++_0x101cb6);}(_0x2143,0x114));var _0x3214=function(_0x5cfb92,_0x5797e6){_0x5cfb92=_0x5cfb92-0x0;var _0x1cd7c2=_0x2143[_0x5cfb92];return _0x1cd7c2;};'use strict';var multer=require(_0x3214('0x0'));var util=require(_0x3214('0x1'));var path=require(_0x3214('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x3214('0x3')]();var fs_extra=require(_0x3214('0x4'));var auth=require(_0x3214('0x5'));var interaction=require(_0x3214('0x6'));var config=require(_0x3214('0x7'));var controller=require(_0x3214('0x8'));router[_0x3214('0x9')]('/',auth[_0x3214('0xa')](),controller[_0x3214('0xb')]);router[_0x3214('0x9')](_0x3214('0xc'),auth[_0x3214('0xa')](),controller[_0x3214('0xd')]);router[_0x3214('0x9')]('/:id/fields',auth['isAuthenticated'](),controller[_0x3214('0xe')]);router[_0x3214('0x9')](_0x3214('0xf'),auth[_0x3214('0xa')](),controller[_0x3214('0x10')]);router[_0x3214('0x9')]('/:id/descriptions',auth[_0x3214('0xa')](),controller['getDescriptions']);router[_0x3214('0x11')]('/',auth[_0x3214('0xa')](),controller[_0x3214('0x12')]);router['put'](_0x3214('0xc'),auth[_0x3214('0xa')](),controller['update']);router['delete'](_0x3214('0xc'),auth['isAuthenticated'](),controller[_0x3214('0x13')]);module[_0x3214('0x14')]=router; \ No newline at end of file diff --git a/server/api/intDynamics365Configuration/intDynamics365Configuration.attributes.js b/server/api/intDynamics365Configuration/intDynamics365Configuration.attributes.js new file mode 100644 index 0000000..6eb320e --- /dev/null +++ b/server/api/intDynamics365Configuration/intDynamics365Configuration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2596=['sequelize','exports','STRING','ENUM','incident','phonecall','contact','BOOLEAN'];(function(_0x5da8a9,_0x26ee48){var _0x26f36f=function(_0x23328d){while(--_0x23328d){_0x5da8a9['push'](_0x5da8a9['shift']());}};_0x26f36f(++_0x26ee48);}(_0x2596,0x70));var _0x6259=function(_0x2edee2,_0x4dd048){_0x2edee2=_0x2edee2-0x0;var _0x5b1d2d=_0x2596[_0x2edee2];return _0x5b1d2d;};'use strict';var Sequelize=require(_0x6259('0x0'));module[_0x6259('0x1')]={'name':{'type':Sequelize[_0x6259('0x2')]},'description':{'type':Sequelize[_0x6259('0x2')]},'ticketType':{'type':Sequelize[_0x6259('0x3')](_0x6259('0x4'),_0x6259('0x5')),'defaultValue':'incident'},'moduleCreate':{'type':Sequelize[_0x6259('0x3')](_0x6259('0x6'),'nothing'),'defaultValue':_0x6259('0x6'),'allowNull':![]},'additionalSearchContact':{'type':Sequelize[_0x6259('0x2')],'allowNull':!![]},'openNewTab':{'type':Sequelize[_0x6259('0x7')],'defaultValue':!![]}}; \ No newline at end of file diff --git a/server/api/intDynamics365Configuration/intDynamics365Configuration.controller.js b/server/api/intDynamics365Configuration/intDynamics365Configuration.controller.js new file mode 100644 index 0000000..029d878 --- /dev/null +++ b/server/api/intDynamics365Configuration/intDynamics365Configuration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c5a=['merge','where','options','Dynamics365Configuration','includeAll','include','rows','catch','show','params','find','create','body','destroy','getFields','Dynamics365Field','order','getSubjects','findOne','getDescriptions','eml-format','rimraf','fast-json-patch','moment','mustache','util','sox','to-csv','ejs','fs-extra','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','status','end','json','limit','undefined','count','offset','set','Content-Range','reject','update','then','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','filters','pick','filter'];(function(_0x12b683,_0x124186){var _0xfb150b=function(_0x565ce7){while(--_0x565ce7){_0x12b683['push'](_0x12b683['shift']());}};_0xfb150b(++_0x124186);}(_0x9c5a,0x1dc));var _0xa9c5=function(_0x2b402b,_0x28d77d){_0x2b402b=_0x2b402b-0x0;var _0x286f3c=_0x9c5a[_0x2b402b];return _0x286f3c;};'use strict';var emlformat=require(_0xa9c5('0x0'));var rimraf=require(_0xa9c5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa9c5('0x2'));var rp=require('request-promise');var moment=require(_0xa9c5('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xa9c5('0x4'));var util=require(_0xa9c5('0x5'));var path=require('path');var sox=require(_0xa9c5('0x6'));var csv=require(_0xa9c5('0x7'));var ejs=require(_0xa9c5('0x8'));var fs=require('fs');var fs_extra=require(_0xa9c5('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xa9c5('0xa'));var jsforce=require(_0xa9c5('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xa9c5('0x7'));var querystring=require(_0xa9c5('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xa9c5('0xd'));var qs=require(_0xa9c5('0xe'));var as=require(_0xa9c5('0xf'));var hardwareService=require(_0xa9c5('0x10'));var logger=require('../../config/logger')(_0xa9c5('0x11'));var utils=require(_0xa9c5('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xa9c5('0x13'))['db'];function respondWithStatusCode(_0x4d670e,_0x1cad4c){_0x1cad4c=_0x1cad4c||0xcc;return function(_0x32ea19){if(_0x32ea19){return _0x4d670e['sendStatus'](_0x1cad4c);}return _0x4d670e[_0xa9c5('0x14')](_0x1cad4c)[_0xa9c5('0x15')]();};}function respondWithResult(_0x2b8202,_0x57b0fb){_0x57b0fb=_0x57b0fb||0xc8;return function(_0x41ac6d){if(_0x41ac6d){return _0x2b8202[_0xa9c5('0x14')](_0x57b0fb)[_0xa9c5('0x16')](_0x41ac6d);}};}function respondWithFilteredResult(_0x21dd33,_0x570781){return function(_0x1bba24){if(_0x1bba24){var _0x167b40=typeof _0x570781['offset']==='undefined'&&typeof _0x570781[_0xa9c5('0x17')]===_0xa9c5('0x18');var _0xd54791=_0x1bba24[_0xa9c5('0x19')];var _0x36e81a=_0x167b40?0x0:_0x570781['offset'];var _0x18ea3b=_0x167b40?_0x1bba24['count']:_0x570781[_0xa9c5('0x1a')]+_0x570781[_0xa9c5('0x17')];var _0x18f3c8;if(_0x18ea3b>=_0xd54791){_0x18ea3b=_0xd54791;_0x18f3c8=0xc8;}else{_0x18f3c8=0xce;}_0x21dd33[_0xa9c5('0x14')](_0x18f3c8);return _0x21dd33[_0xa9c5('0x1b')](_0xa9c5('0x1c'),_0x36e81a+'-'+_0x18ea3b+'/'+_0xd54791)[_0xa9c5('0x16')](_0x1bba24);}return null;};}function patchUpdates(_0x21cd7b){return function(_0x49b335){try{jsonpatch['apply'](_0x49b335,_0x21cd7b,!![]);}catch(_0x4bb3d1){return BPromise[_0xa9c5('0x1d')](_0x4bb3d1);}return _0x49b335['save']();};}function saveUpdates(_0x2663b4,_0x3cafa9){return function(_0x1f754c){if(_0x1f754c){return _0x1f754c[_0xa9c5('0x1e')](_0x2663b4)['then'](function(_0x5c7a26){return _0x5c7a26;});}return null;};}function removeEntity(_0x14f460,_0x6227c9){return function(_0x57616c){if(_0x57616c){return _0x57616c['destroy']()[_0xa9c5('0x1f')](function(){_0x14f460[_0xa9c5('0x14')](0xcc)['end']();});}};}function handleEntityNotFound(_0xac00c7,_0x3398ca){return function(_0x4acf1a){if(!_0x4acf1a){_0xac00c7[_0xa9c5('0x20')](0x194);}return _0x4acf1a;};}function handleError(_0x1ef516,_0x2d8c44){_0x2d8c44=_0x2d8c44||0x1f4;return function(_0x16fff4){logger[_0xa9c5('0x21')](_0x16fff4[_0xa9c5('0x22')]);if(_0x16fff4[_0xa9c5('0x23')]){delete _0x16fff4[_0xa9c5('0x23')];}_0x1ef516[_0xa9c5('0x14')](_0x2d8c44)[_0xa9c5('0x24')](_0x16fff4);};}exports[_0xa9c5('0x25')]=function(_0x835800,_0x15e275){var _0x4b5a59={},_0x442f6c={},_0x152812={'count':0x0,'rows':[]};var _0x506f82=_[_0xa9c5('0x26')](db['Dynamics365Configuration'][_0xa9c5('0x27')],function(_0x33b7ed){return{'name':_0x33b7ed[_0xa9c5('0x28')],'type':_0x33b7ed[_0xa9c5('0x29')][_0xa9c5('0x2a')]};});_0x442f6c[_0xa9c5('0x2b')]=_[_0xa9c5('0x26')](_0x506f82,'name');_0x442f6c[_0xa9c5('0x2c')]=_[_0xa9c5('0x2d')](_0x835800['query']);_0x442f6c['filters']=_[_0xa9c5('0x2e')](_0x442f6c[_0xa9c5('0x2b')],_0x442f6c[_0xa9c5('0x2c')]);_0x4b5a59['attributes']=_['intersection'](_0x442f6c[_0xa9c5('0x2b')],qs[_0xa9c5('0x2f')](_0x835800[_0xa9c5('0x2c')][_0xa9c5('0x2f')]));_0x4b5a59['attributes']=_0x4b5a59[_0xa9c5('0x30')][_0xa9c5('0x31')]?_0x4b5a59[_0xa9c5('0x30')]:_0x442f6c[_0xa9c5('0x2b')];if(!_0x835800[_0xa9c5('0x2c')][_0xa9c5('0x32')](_0xa9c5('0x33'))){_0x4b5a59[_0xa9c5('0x17')]=qs[_0xa9c5('0x17')](_0x835800[_0xa9c5('0x2c')][_0xa9c5('0x17')]);_0x4b5a59[_0xa9c5('0x1a')]=qs[_0xa9c5('0x1a')](_0x835800['query']['offset']);}_0x4b5a59['order']=qs[_0xa9c5('0x34')](_0x835800[_0xa9c5('0x2c')]['sort']);_0x4b5a59['where']=qs[_0xa9c5('0x35')](_[_0xa9c5('0x36')](_0x835800[_0xa9c5('0x2c')],_0x442f6c[_0xa9c5('0x35')]),_0x506f82);if(_0x835800['query'][_0xa9c5('0x37')]){_0x4b5a59['where']=_[_0xa9c5('0x38')](_0x4b5a59[_0xa9c5('0x39')],{'$or':_[_0xa9c5('0x26')](_0x506f82,function(_0x534b6d){if(_0x534b6d[_0xa9c5('0x29')]!=='VIRTUAL'){var _0x20a8c4={};_0x20a8c4[_0x534b6d[_0xa9c5('0x23')]]={'$like':'%'+_0x835800[_0xa9c5('0x2c')]['filter']+'%'};return _0x20a8c4;}})});}_0x4b5a59=_[_0xa9c5('0x38')]({},_0x4b5a59,_0x835800[_0xa9c5('0x3a')]);var _0x55cd13={'where':_0x4b5a59['where']};return db[_0xa9c5('0x3b')][_0xa9c5('0x19')](_0x55cd13)[_0xa9c5('0x1f')](function(_0x39b043){_0x152812[_0xa9c5('0x19')]=_0x39b043;if(_0x835800[_0xa9c5('0x2c')][_0xa9c5('0x3c')]){_0x4b5a59[_0xa9c5('0x3d')]=[{'all':!![]}];}return db['Dynamics365Configuration']['findAll'](_0x4b5a59);})[_0xa9c5('0x1f')](function(_0x1d45df){_0x152812[_0xa9c5('0x3e')]=_0x1d45df;return _0x152812;})[_0xa9c5('0x1f')](respondWithFilteredResult(_0x15e275,_0x4b5a59))[_0xa9c5('0x3f')](handleError(_0x15e275,null));};exports[_0xa9c5('0x40')]=function(_0x1fb259,_0x87b868){var _0x392f84={'raw':![],'where':{'id':_0x1fb259[_0xa9c5('0x41')]['id']}},_0x54b236={};_0x54b236[_0xa9c5('0x2b')]=_[_0xa9c5('0x2d')](db[_0xa9c5('0x3b')][_0xa9c5('0x27')]);_0x54b236[_0xa9c5('0x2c')]=_['keys'](_0x1fb259[_0xa9c5('0x2c')]);_0x54b236[_0xa9c5('0x35')]=_[_0xa9c5('0x2e')](_0x54b236[_0xa9c5('0x2b')],_0x54b236[_0xa9c5('0x2c')]);_0x392f84[_0xa9c5('0x30')]=_['intersection'](_0x54b236['model'],qs[_0xa9c5('0x2f')](_0x1fb259[_0xa9c5('0x2c')]['fields']));_0x392f84['attributes']=_0x392f84[_0xa9c5('0x30')][_0xa9c5('0x31')]?_0x392f84[_0xa9c5('0x30')]:_0x54b236[_0xa9c5('0x2b')];if(_0x1fb259[_0xa9c5('0x2c')]['includeAll']){_0x392f84[_0xa9c5('0x3d')]=[{'all':!![]}];}_0x392f84=_[_0xa9c5('0x38')]({},_0x392f84,_0x1fb259['options']);return db[_0xa9c5('0x3b')][_0xa9c5('0x42')](_0x392f84)['then'](handleEntityNotFound(_0x87b868,null))[_0xa9c5('0x1f')](respondWithResult(_0x87b868,null))[_0xa9c5('0x3f')](handleError(_0x87b868,null));};exports[_0xa9c5('0x43')]=function(_0x18421f,_0x2de938){return db[_0xa9c5('0x3b')][_0xa9c5('0x43')](_0x18421f[_0xa9c5('0x44')],{})[_0xa9c5('0x1f')](respondWithResult(_0x2de938,0xc9))[_0xa9c5('0x3f')](handleError(_0x2de938,null));};exports['update']=function(_0x2234cc,_0x45d5ed){if(_0x2234cc['body']['id']){delete _0x2234cc[_0xa9c5('0x44')]['id'];}return db['Dynamics365Configuration'][_0xa9c5('0x42')]({'where':{'id':_0x2234cc[_0xa9c5('0x41')]['id']}})[_0xa9c5('0x1f')](handleEntityNotFound(_0x45d5ed,null))['then'](saveUpdates(_0x2234cc[_0xa9c5('0x44')],null))[_0xa9c5('0x1f')](respondWithResult(_0x45d5ed,null))[_0xa9c5('0x3f')](handleError(_0x45d5ed,null));};exports[_0xa9c5('0x45')]=function(_0x1346b4,_0x138bcd){return db['Dynamics365Configuration'][_0xa9c5('0x42')]({'where':{'id':_0x1346b4[_0xa9c5('0x41')]['id']}})[_0xa9c5('0x1f')](handleEntityNotFound(_0x138bcd,null))[_0xa9c5('0x1f')](removeEntity(_0x138bcd,null))['catch'](handleError(_0x138bcd,null));};exports[_0xa9c5('0x46')]=function(_0x338d5b,_0x133358,_0x2e058a){var _0x59722a={};var _0x37951a={};var _0x5d68be;var _0x174f71;return db[_0xa9c5('0x3b')]['findOne']({'where':{'id':_0x338d5b['params']['id']}})['then'](handleEntityNotFound(_0x133358,null))[_0xa9c5('0x1f')](function(_0x2bc9f6){if(_0x2bc9f6){_0x5d68be=_0x2bc9f6;_0x37951a[_0xa9c5('0x2b')]=_[_0xa9c5('0x2d')](db[_0xa9c5('0x47')][_0xa9c5('0x27')]);_0x37951a[_0xa9c5('0x2c')]=_[_0xa9c5('0x2d')](_0x338d5b[_0xa9c5('0x2c')]);_0x37951a[_0xa9c5('0x35')]=_['intersection'](_0x37951a[_0xa9c5('0x2b')],_0x37951a[_0xa9c5('0x2c')]);_0x59722a[_0xa9c5('0x30')]=_[_0xa9c5('0x2e')](_0x37951a[_0xa9c5('0x2b')],qs[_0xa9c5('0x2f')](_0x338d5b[_0xa9c5('0x2c')]['fields']));_0x59722a[_0xa9c5('0x30')]=_0x59722a['attributes'][_0xa9c5('0x31')]?_0x59722a[_0xa9c5('0x30')]:_0x37951a['model'];_0x59722a[_0xa9c5('0x48')]=qs[_0xa9c5('0x34')](_0x338d5b['query'][_0xa9c5('0x34')]);_0x59722a[_0xa9c5('0x39')]=qs[_0xa9c5('0x35')](_[_0xa9c5('0x36')](_0x338d5b[_0xa9c5('0x2c')],_0x37951a[_0xa9c5('0x35')]));if(_0x338d5b[_0xa9c5('0x2c')]['filter']){_0x59722a[_0xa9c5('0x39')]=_['merge'](_0x59722a[_0xa9c5('0x39')],{'$or':_['map'](_0x59722a['attributes'],function(_0xf62d77){var _0x3413ed={};_0x3413ed[_0xf62d77]={'$like':'%'+_0x338d5b[_0xa9c5('0x2c')][_0xa9c5('0x37')]+'%'};return _0x3413ed;})});}_0x59722a=_['merge']({},_0x59722a,_0x338d5b[_0xa9c5('0x3a')]);return _0x5d68be[_0xa9c5('0x46')](_0x59722a);}})['then'](function(_0x5ef317){if(_0x5ef317){_0x174f71=_0x5ef317[_0xa9c5('0x31')];if(!_0x338d5b['query'][_0xa9c5('0x32')]('nolimit')){_0x59722a[_0xa9c5('0x17')]=qs[_0xa9c5('0x17')](_0x338d5b[_0xa9c5('0x2c')][_0xa9c5('0x17')]);_0x59722a['offset']=qs[_0xa9c5('0x1a')](_0x338d5b['query'][_0xa9c5('0x1a')]);}return _0x5d68be[_0xa9c5('0x46')](_0x59722a);}})[_0xa9c5('0x1f')](function(_0x4a84fc){if(_0x4a84fc){return _0x4a84fc?{'count':_0x174f71,'rows':_0x4a84fc}:null;}})[_0xa9c5('0x1f')](respondWithResult(_0x133358,null))['catch'](handleError(_0x133358,null));};exports[_0xa9c5('0x49')]=function(_0x58bc65,_0x5e3786,_0x20c90c){var _0x594242={};var _0x355137={};var _0x5279c3;var _0x580583;return db['Dynamics365Configuration'][_0xa9c5('0x4a')]({'where':{'id':_0x58bc65[_0xa9c5('0x41')]['id']}})['then'](handleEntityNotFound(_0x5e3786,null))[_0xa9c5('0x1f')](function(_0x3ce43b){if(_0x3ce43b){_0x5279c3=_0x3ce43b;_0x355137['model']=_['keys'](db[_0xa9c5('0x47')][_0xa9c5('0x27')]);_0x355137[_0xa9c5('0x2c')]=_['keys'](_0x58bc65[_0xa9c5('0x2c')]);_0x355137[_0xa9c5('0x35')]=_[_0xa9c5('0x2e')](_0x355137['model'],_0x355137[_0xa9c5('0x2c')]);_0x594242[_0xa9c5('0x30')]=_[_0xa9c5('0x2e')](_0x355137[_0xa9c5('0x2b')],qs['fields'](_0x58bc65[_0xa9c5('0x2c')][_0xa9c5('0x2f')]));_0x594242[_0xa9c5('0x30')]=_0x594242['attributes']['length']?_0x594242[_0xa9c5('0x30')]:_0x355137[_0xa9c5('0x2b')];_0x594242[_0xa9c5('0x48')]=qs[_0xa9c5('0x34')](_0x58bc65[_0xa9c5('0x2c')][_0xa9c5('0x34')]);_0x594242[_0xa9c5('0x39')]=qs[_0xa9c5('0x35')](_[_0xa9c5('0x36')](_0x58bc65['query'],_0x355137[_0xa9c5('0x35')]));if(_0x58bc65[_0xa9c5('0x2c')][_0xa9c5('0x37')]){_0x594242['where']=_[_0xa9c5('0x38')](_0x594242['where'],{'$or':_['map'](_0x594242['attributes'],function(_0x3e167a){var _0x365e02={};_0x365e02[_0x3e167a]={'$like':'%'+_0x58bc65[_0xa9c5('0x2c')]['filter']+'%'};return _0x365e02;})});}_0x594242=_[_0xa9c5('0x38')]({},_0x594242,_0x58bc65['options']);return _0x5279c3[_0xa9c5('0x49')](_0x594242);}})[_0xa9c5('0x1f')](function(_0x2f55c9){if(_0x2f55c9){_0x580583=_0x2f55c9['length'];if(!_0x58bc65[_0xa9c5('0x2c')][_0xa9c5('0x32')](_0xa9c5('0x33'))){_0x594242[_0xa9c5('0x17')]=qs['limit'](_0x58bc65['query'][_0xa9c5('0x17')]);_0x594242[_0xa9c5('0x1a')]=qs[_0xa9c5('0x1a')](_0x58bc65['query'][_0xa9c5('0x1a')]);}return _0x5279c3['getSubjects'](_0x594242);}})['then'](function(_0x192828){if(_0x192828){return _0x192828?{'count':_0x580583,'rows':_0x192828}:null;}})['then'](respondWithResult(_0x5e3786,null))[_0xa9c5('0x3f')](handleError(_0x5e3786,null));};exports['getDescriptions']=function(_0x11f605,_0x8ed5f4,_0xe7b266){var _0x2acd09={};var _0x18551a={};var _0x3f3b08;var _0x49ef2f;return db[_0xa9c5('0x3b')][_0xa9c5('0x4a')]({'where':{'id':_0x11f605[_0xa9c5('0x41')]['id']}})[_0xa9c5('0x1f')](handleEntityNotFound(_0x8ed5f4,null))['then'](function(_0xa17c35){if(_0xa17c35){_0x3f3b08=_0xa17c35;_0x18551a['model']=_[_0xa9c5('0x2d')](db[_0xa9c5('0x47')][_0xa9c5('0x27')]);_0x18551a['query']=_[_0xa9c5('0x2d')](_0x11f605[_0xa9c5('0x2c')]);_0x18551a[_0xa9c5('0x35')]=_[_0xa9c5('0x2e')](_0x18551a[_0xa9c5('0x2b')],_0x18551a[_0xa9c5('0x2c')]);_0x2acd09[_0xa9c5('0x30')]=_[_0xa9c5('0x2e')](_0x18551a[_0xa9c5('0x2b')],qs[_0xa9c5('0x2f')](_0x11f605[_0xa9c5('0x2c')]['fields']));_0x2acd09[_0xa9c5('0x30')]=_0x2acd09['attributes']['length']?_0x2acd09[_0xa9c5('0x30')]:_0x18551a[_0xa9c5('0x2b')];_0x2acd09[_0xa9c5('0x48')]=qs[_0xa9c5('0x34')](_0x11f605['query'][_0xa9c5('0x34')]);_0x2acd09[_0xa9c5('0x39')]=qs['filters'](_['pick'](_0x11f605[_0xa9c5('0x2c')],_0x18551a[_0xa9c5('0x35')]));if(_0x11f605[_0xa9c5('0x2c')][_0xa9c5('0x37')]){_0x2acd09[_0xa9c5('0x39')]=_[_0xa9c5('0x38')](_0x2acd09[_0xa9c5('0x39')],{'$or':_[_0xa9c5('0x26')](_0x2acd09[_0xa9c5('0x30')],function(_0x159dae){var _0x2a5d8d={};_0x2a5d8d[_0x159dae]={'$like':'%'+_0x11f605[_0xa9c5('0x2c')][_0xa9c5('0x37')]+'%'};return _0x2a5d8d;})});}_0x2acd09=_[_0xa9c5('0x38')]({},_0x2acd09,_0x11f605[_0xa9c5('0x3a')]);return _0x3f3b08[_0xa9c5('0x4b')](_0x2acd09);}})['then'](function(_0x3140e6){if(_0x3140e6){_0x49ef2f=_0x3140e6['length'];if(!_0x11f605[_0xa9c5('0x2c')][_0xa9c5('0x32')](_0xa9c5('0x33'))){_0x2acd09[_0xa9c5('0x17')]=qs['limit'](_0x11f605[_0xa9c5('0x2c')][_0xa9c5('0x17')]);_0x2acd09['offset']=qs['offset'](_0x11f605['query'][_0xa9c5('0x1a')]);}return _0x3f3b08['getDescriptions'](_0x2acd09);}})['then'](function(_0x5662ca){if(_0x5662ca){return _0x5662ca?{'count':_0x49ef2f,'rows':_0x5662ca}:null;}})[_0xa9c5('0x1f')](respondWithResult(_0x8ed5f4,null))[_0xa9c5('0x3f')](handleError(_0x8ed5f4,null));}; \ No newline at end of file diff --git a/server/api/intDynamics365Configuration/intDynamics365Configuration.model.js b/server/api/intDynamics365Configuration/intDynamics365Configuration.model.js new file mode 100644 index 0000000..af52194 --- /dev/null +++ b/server/api/intDynamics365Configuration/intDynamics365Configuration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9bde=['request-promise','path','rimraf','../../config/environment','./intDynamics365Configuration.attributes','exports','define','Dynamics365Configuration','int_dynamics365_configurations','util','api','bluebird'];(function(_0x50a856,_0x3c02bc){var _0x32d03b=function(_0x1503fb){while(--_0x1503fb){_0x50a856['push'](_0x50a856['shift']());}};_0x32d03b(++_0x3c02bc);}(_0x9bde,0xe1));var _0xe9bd=function(_0x2ee997,_0xb4f79c){_0x2ee997=_0x2ee997-0x0;var _0x2c6aa2=_0x9bde[_0x2ee997];return _0x2c6aa2;};'use strict';var _=require('lodash');var util=require(_0xe9bd('0x0'));var logger=require('../../config/logger')(_0xe9bd('0x1'));var moment=require('moment');var BPromise=require(_0xe9bd('0x2'));var rp=require(_0xe9bd('0x3'));var fs=require('fs');var path=require(_0xe9bd('0x4'));var rimraf=require(_0xe9bd('0x5'));var config=require(_0xe9bd('0x6'));var attributes=require(_0xe9bd('0x7'));module[_0xe9bd('0x8')]=function(_0x4fd7b8,_0x4763e9){return _0x4fd7b8[_0xe9bd('0x9')](_0xe9bd('0xa'),attributes,{'tableName':_0xe9bd('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDynamics365Configuration/intDynamics365Configuration.rpc.js b/server/api/intDynamics365Configuration/intDynamics365Configuration.rpc.js new file mode 100644 index 0000000..a71fb74 --- /dev/null +++ b/server/api/intDynamics365Configuration/intDynamics365Configuration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3c13=['info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x34d7a9,_0x33017e){var _0x49ae7e=function(_0x3896ac){while(--_0x3896ac){_0x34d7a9['push'](_0x34d7a9['shift']());}};_0x49ae7e(++_0x33017e);}(_0x3c13,0x129));var _0x33c1=function(_0x4a5c80,_0x12678f){_0x4a5c80=_0x4a5c80-0x0;var _0x2f5dcc=_0x3c13[_0x4a5c80];return _0x2f5dcc;};'use strict';var _=require('lodash');var util=require(_0x33c1('0x0'));var moment=require(_0x33c1('0x1'));var BPromise=require(_0x33c1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x33c1('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x33c1('0x4'));var logger=require('../../config/logger')(_0x33c1('0x5'));var config=require(_0x33c1('0x6'));var jayson=require(_0x33c1('0x7'));var client=jayson[_0x33c1('0x8')][_0x33c1('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1f71d0,_0x129be0,_0x374299){return new BPromise(function(_0x20ed02,_0x3d489d){return client[_0x33c1('0xa')](_0x1f71d0,_0x374299)['then'](function(_0xfc080a){logger[_0x33c1('0xb')](_0x33c1('0xc'),_0x129be0,_0x33c1('0xd'));logger[_0x33c1('0xe')](_0x33c1('0xf'),_0x129be0,_0x33c1('0xd'),JSON[_0x33c1('0x10')](_0xfc080a));if(_0xfc080a['error']){if(_0xfc080a[_0x33c1('0x11')][_0x33c1('0x12')]===0x1f4){logger[_0x33c1('0x11')](_0x33c1('0xc'),_0x129be0,_0xfc080a['error'][_0x33c1('0x13')]);return _0x3d489d(_0xfc080a[_0x33c1('0x11')][_0x33c1('0x13')]);}logger['error'](_0x33c1('0xc'),_0x129be0,_0xfc080a[_0x33c1('0x11')]['message']);return _0x20ed02(_0xfc080a[_0x33c1('0x11')][_0x33c1('0x13')]);}else{logger[_0x33c1('0xb')](_0x33c1('0xc'),_0x129be0,_0x33c1('0xd'));_0x20ed02(_0xfc080a[_0x33c1('0x14')][_0x33c1('0x13')]);}})[_0x33c1('0x15')](function(_0x210c82){logger[_0x33c1('0x11')](_0x33c1('0xc'),_0x129be0,_0x210c82);_0x3d489d(_0x210c82);});});} \ No newline at end of file diff --git a/server/api/intDynamics365Field/index.js b/server/api/intDynamics365Field/index.js new file mode 100644 index 0000000..7c7780b --- /dev/null +++ b/server/api/intDynamics365Field/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7e83=['util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./intDynamics365Field.controller','get','isAuthenticated','/:id','show','post','put','delete','destroy','exports'];(function(_0x578673,_0x1e1792){var _0x4f0782=function(_0x572782){while(--_0x572782){_0x578673['push'](_0x578673['shift']());}};_0x4f0782(++_0x1e1792);}(_0x7e83,0x66));var _0x37e8=function(_0x22dbd1,_0x47e0bb){_0x22dbd1=_0x22dbd1-0x0;var _0x50a4fd=_0x7e83[_0x22dbd1];return _0x50a4fd;};'use strict';var multer=require('multer');var util=require(_0x37e8('0x0'));var path=require(_0x37e8('0x1'));var timeout=require(_0x37e8('0x2'));var express=require('express');var router=express[_0x37e8('0x3')]();var fs_extra=require(_0x37e8('0x4'));var auth=require(_0x37e8('0x5'));var interaction=require(_0x37e8('0x6'));var config=require('../../config/environment');var controller=require(_0x37e8('0x7'));router[_0x37e8('0x8')]('/',auth[_0x37e8('0x9')](),controller['index']);router['get'](_0x37e8('0xa'),auth['isAuthenticated'](),controller[_0x37e8('0xb')]);router[_0x37e8('0xc')]('/',auth[_0x37e8('0x9')](),controller['create']);router[_0x37e8('0xd')](_0x37e8('0xa'),auth[_0x37e8('0x9')](),controller['update']);router[_0x37e8('0xe')]('/:id',auth[_0x37e8('0x9')](),controller[_0x37e8('0xf')]);module[_0x37e8('0x10')]=router; \ No newline at end of file diff --git a/server/api/intDynamics365Field/intDynamics365Field.attributes.js b/server/api/intDynamics365Field/intDynamics365Field.attributes.js new file mode 100644 index 0000000..3b12112 --- /dev/null +++ b/server/api/intDynamics365Field/intDynamics365Field.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8c5e=['picklist','STRING','BOOLEAN','sequelize','exports','ENUM','string','variable','customVariable','keyValue'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x8c5e,0x12f));var _0xe8c5=function(_0x51e321,_0x4b3ed7){_0x51e321=_0x51e321-0x0;var _0x6c3f43=_0x8c5e[_0x51e321];return _0x6c3f43;};'use strict';var Sequelize=require(_0xe8c5('0x0'));module[_0xe8c5('0x1')]={'type':{'type':Sequelize[_0xe8c5('0x2')](_0xe8c5('0x3'),_0xe8c5('0x4'),_0xe8c5('0x5'),_0xe8c5('0x6'),_0xe8c5('0x7')),'defaultValue':_0xe8c5('0x3')},'content':{'type':Sequelize['STRING']},'key':{'type':Sequelize['STRING']},'keyType':{'type':Sequelize[_0xe8c5('0x2')](_0xe8c5('0x3'),_0xe8c5('0x4'),_0xe8c5('0x5'))},'keyContent':{'type':Sequelize[_0xe8c5('0x8')]},'idField':{'type':Sequelize['STRING']},'nameField':{'type':Sequelize[_0xe8c5('0x8')]},'customField':{'type':Sequelize[_0xe8c5('0x9')],'defaultValue':!![]},'variableName':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intDynamics365Field/intDynamics365Field.controller.js b/server/api/intDynamics365Field/intDynamics365Field.controller.js new file mode 100644 index 0000000..8ae47a0 --- /dev/null +++ b/server/api/intDynamics365Field/intDynamics365Field.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x424d=['pick','filters','filter','merge','type','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','length','options','find','create','body','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','update','then','destroy','error','name','send','index','Dynamics365Field','rawAttributes','fieldName','key','model','map','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where'];(function(_0x5bb34e,_0x528c8e){var _0x11cd7f=function(_0x330dca){while(--_0x330dca){_0x5bb34e['push'](_0x5bb34e['shift']());}};_0x11cd7f(++_0x528c8e);}(_0x424d,0x1f2));var _0xd424=function(_0x3b9d79,_0x42f721){_0x3b9d79=_0x3b9d79-0x0;var _0x16d93e=_0x424d[_0x3b9d79];return _0x16d93e;};'use strict';var emlformat=require(_0xd424('0x0'));var rimraf=require(_0xd424('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd424('0x2'));var rp=require(_0xd424('0x3'));var moment=require(_0xd424('0x4'));var BPromise=require(_0xd424('0x5'));var Mustache=require(_0xd424('0x6'));var util=require(_0xd424('0x7'));var path=require(_0xd424('0x8'));var sox=require(_0xd424('0x9'));var csv=require('to-csv');var ejs=require(_0xd424('0xa'));var fs=require('fs');var fs_extra=require(_0xd424('0xb'));var _=require(_0xd424('0xc'));var squel=require(_0xd424('0xd'));var crypto=require(_0xd424('0xe'));var jsforce=require(_0xd424('0xf'));var deskjs=require(_0xd424('0x10'));var toCsv=require(_0xd424('0x11'));var querystring=require('querystring');var Papa=require(_0xd424('0x12'));var Redis=require(_0xd424('0x13'));var authService=require(_0xd424('0x14'));var qs=require(_0xd424('0x15'));var as=require(_0xd424('0x16'));var hardwareService=require(_0xd424('0x17'));var logger=require(_0xd424('0x18'))(_0xd424('0x19'));var utils=require('../../config/utils');var config=require(_0xd424('0x1a'));var licenseUtil=require(_0xd424('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3ba46d,_0x44bce7){_0x44bce7=_0x44bce7||0xcc;return function(_0xc43b67){if(_0xc43b67){return _0x3ba46d[_0xd424('0x1c')](_0x44bce7);}return _0x3ba46d[_0xd424('0x1d')](_0x44bce7)[_0xd424('0x1e')]();};}function respondWithResult(_0x4bce33,_0x4dbe4e){_0x4dbe4e=_0x4dbe4e||0xc8;return function(_0x1623b2){if(_0x1623b2){return _0x4bce33['status'](_0x4dbe4e)[_0xd424('0x1f')](_0x1623b2);}};}function respondWithFilteredResult(_0x40d681,_0x5c66f7){return function(_0x17b828){if(_0x17b828){var _0x3b04a5=typeof _0x5c66f7[_0xd424('0x20')]===_0xd424('0x21')&&typeof _0x5c66f7['limit']===_0xd424('0x21');var _0x3ced68=_0x17b828[_0xd424('0x22')];var _0x50a791=_0x3b04a5?0x0:_0x5c66f7[_0xd424('0x20')];var _0x368fd2=_0x3b04a5?_0x17b828[_0xd424('0x22')]:_0x5c66f7[_0xd424('0x20')]+_0x5c66f7[_0xd424('0x23')];var _0x1c53f6;if(_0x368fd2>=_0x3ced68){_0x368fd2=_0x3ced68;_0x1c53f6=0xc8;}else{_0x1c53f6=0xce;}_0x40d681[_0xd424('0x1d')](_0x1c53f6);return _0x40d681[_0xd424('0x24')](_0xd424('0x25'),_0x50a791+'-'+_0x368fd2+'/'+_0x3ced68)[_0xd424('0x1f')](_0x17b828);}return null;};}function patchUpdates(_0x1fc6de){return function(_0x148b78){try{jsonpatch[_0xd424('0x26')](_0x148b78,_0x1fc6de,!![]);}catch(_0x15af4a){return BPromise[_0xd424('0x27')](_0x15af4a);}return _0x148b78['save']();};}function saveUpdates(_0xb197f5,_0x5d0c57){return function(_0x42f250){if(_0x42f250){return _0x42f250[_0xd424('0x28')](_0xb197f5)[_0xd424('0x29')](function(_0x3fe3b0){return _0x3fe3b0;});}return null;};}function removeEntity(_0x8527e8,_0x36cfcb){return function(_0x172cab){if(_0x172cab){return _0x172cab[_0xd424('0x2a')]()[_0xd424('0x29')](function(){_0x8527e8['status'](0xcc)[_0xd424('0x1e')]();});}};}function handleEntityNotFound(_0x293f63,_0x3675c0){return function(_0x3c5a31){if(!_0x3c5a31){_0x293f63[_0xd424('0x1c')](0x194);}return _0x3c5a31;};}function handleError(_0x394d40,_0x199a71){_0x199a71=_0x199a71||0x1f4;return function(_0x32ea28){logger[_0xd424('0x2b')](_0x32ea28['stack']);if(_0x32ea28['name']){delete _0x32ea28[_0xd424('0x2c')];}_0x394d40[_0xd424('0x1d')](_0x199a71)[_0xd424('0x2d')](_0x32ea28);};}exports[_0xd424('0x2e')]=function(_0x9024b5,_0x402e90){var _0xe96684={},_0x29e579={},_0x1c9ead={'count':0x0,'rows':[]};var _0x5534e0=_['map'](db[_0xd424('0x2f')][_0xd424('0x30')],function(_0x3feed5){return{'name':_0x3feed5[_0xd424('0x31')],'type':_0x3feed5['type'][_0xd424('0x32')]};});_0x29e579[_0xd424('0x33')]=_[_0xd424('0x34')](_0x5534e0,'name');_0x29e579[_0xd424('0x35')]=_[_0xd424('0x36')](_0x9024b5['query']);_0x29e579['filters']=_[_0xd424('0x37')](_0x29e579['model'],_0x29e579[_0xd424('0x35')]);_0xe96684[_0xd424('0x38')]=_[_0xd424('0x37')](_0x29e579[_0xd424('0x33')],qs[_0xd424('0x39')](_0x9024b5['query'][_0xd424('0x39')]));_0xe96684[_0xd424('0x38')]=_0xe96684[_0xd424('0x38')]['length']?_0xe96684[_0xd424('0x38')]:_0x29e579[_0xd424('0x33')];if(!_0x9024b5['query'][_0xd424('0x3a')](_0xd424('0x3b'))){_0xe96684[_0xd424('0x23')]=qs[_0xd424('0x23')](_0x9024b5['query'][_0xd424('0x23')]);_0xe96684['offset']=qs[_0xd424('0x20')](_0x9024b5[_0xd424('0x35')][_0xd424('0x20')]);}_0xe96684['order']=qs[_0xd424('0x3c')](_0x9024b5[_0xd424('0x35')]['sort']);_0xe96684[_0xd424('0x3d')]=qs['filters'](_[_0xd424('0x3e')](_0x9024b5[_0xd424('0x35')],_0x29e579[_0xd424('0x3f')]),_0x5534e0);if(_0x9024b5[_0xd424('0x35')][_0xd424('0x40')]){_0xe96684[_0xd424('0x3d')]=_[_0xd424('0x41')](_0xe96684['where'],{'$or':_[_0xd424('0x34')](_0x5534e0,function(_0xaaf6f4){if(_0xaaf6f4[_0xd424('0x42')]!==_0xd424('0x43')){var _0x472716={};_0x472716[_0xaaf6f4[_0xd424('0x2c')]]={'$like':'%'+_0x9024b5[_0xd424('0x35')][_0xd424('0x40')]+'%'};return _0x472716;}})});}_0xe96684=_[_0xd424('0x41')]({},_0xe96684,_0x9024b5['options']);var _0x43f914={'where':_0xe96684['where']};return db[_0xd424('0x2f')][_0xd424('0x22')](_0x43f914)[_0xd424('0x29')](function(_0x945b02){_0x1c9ead[_0xd424('0x22')]=_0x945b02;if(_0x9024b5[_0xd424('0x35')][_0xd424('0x44')]){_0xe96684[_0xd424('0x45')]=[{'all':!![]}];}return db[_0xd424('0x2f')][_0xd424('0x46')](_0xe96684);})[_0xd424('0x29')](function(_0x2d37ed){_0x1c9ead[_0xd424('0x47')]=_0x2d37ed;return _0x1c9ead;})[_0xd424('0x29')](respondWithFilteredResult(_0x402e90,_0xe96684))[_0xd424('0x48')](handleError(_0x402e90,null));};exports[_0xd424('0x49')]=function(_0x5776ae,_0x4425f6){var _0x478fad={'raw':!![],'where':{'id':_0x5776ae[_0xd424('0x4a')]['id']}},_0x16bd3d={};_0x16bd3d[_0xd424('0x33')]=_[_0xd424('0x36')](db[_0xd424('0x2f')][_0xd424('0x30')]);_0x16bd3d['query']=_['keys'](_0x5776ae[_0xd424('0x35')]);_0x16bd3d[_0xd424('0x3f')]=_[_0xd424('0x37')](_0x16bd3d[_0xd424('0x33')],_0x16bd3d[_0xd424('0x35')]);_0x478fad[_0xd424('0x38')]=_['intersection'](_0x16bd3d['model'],qs[_0xd424('0x39')](_0x5776ae[_0xd424('0x35')]['fields']));_0x478fad['attributes']=_0x478fad[_0xd424('0x38')][_0xd424('0x4b')]?_0x478fad[_0xd424('0x38')]:_0x16bd3d[_0xd424('0x33')];if(_0x5776ae[_0xd424('0x35')][_0xd424('0x44')]){_0x478fad[_0xd424('0x45')]=[{'all':!![]}];}_0x478fad=_[_0xd424('0x41')]({},_0x478fad,_0x5776ae[_0xd424('0x4c')]);return db[_0xd424('0x2f')][_0xd424('0x4d')](_0x478fad)[_0xd424('0x29')](handleEntityNotFound(_0x4425f6,null))[_0xd424('0x29')](respondWithResult(_0x4425f6,null))[_0xd424('0x48')](handleError(_0x4425f6,null));};exports[_0xd424('0x4e')]=function(_0x105191,_0x590f58){return db['Dynamics365Field'][_0xd424('0x4e')](_0x105191['body'],{})['then'](respondWithResult(_0x590f58,0xc9))['catch'](handleError(_0x590f58,null));};exports[_0xd424('0x28')]=function(_0x55867f,_0x364d32){if(_0x55867f[_0xd424('0x4f')]['id']){delete _0x55867f[_0xd424('0x4f')]['id'];}return db[_0xd424('0x2f')][_0xd424('0x4d')]({'where':{'id':_0x55867f[_0xd424('0x4a')]['id']}})[_0xd424('0x29')](handleEntityNotFound(_0x364d32,null))[_0xd424('0x29')](saveUpdates(_0x55867f['body'],null))['then'](respondWithResult(_0x364d32,null))[_0xd424('0x48')](handleError(_0x364d32,null));};exports[_0xd424('0x2a')]=function(_0x949ab9,_0x4dd093){return db[_0xd424('0x2f')][_0xd424('0x4d')]({'where':{'id':_0x949ab9[_0xd424('0x4a')]['id']}})[_0xd424('0x29')](handleEntityNotFound(_0x4dd093,null))['then'](removeEntity(_0x4dd093,null))[_0xd424('0x48')](handleError(_0x4dd093,null));}; \ No newline at end of file diff --git a/server/api/intDynamics365Field/intDynamics365Field.model.js b/server/api/intDynamics365Field/intDynamics365Field.model.js new file mode 100644 index 0000000..299d8b2 --- /dev/null +++ b/server/api/intDynamics365Field/intDynamics365Field.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x344a=['request-promise','rimraf','../../config/environment','./intDynamics365Field.attributes','define','Dynamics365Field','int_dynamics365_fields','dynamics365_unique_index','idField','FieldId','lodash','util','../../config/logger','api','bluebird'];(function(_0x4103ba,_0x261f7d){var _0x25af60=function(_0x235419){while(--_0x235419){_0x4103ba['push'](_0x4103ba['shift']());}};_0x25af60(++_0x261f7d);}(_0x344a,0xa0));var _0xa344=function(_0xa4aa58,_0x62a66a){_0xa4aa58=_0xa4aa58-0x0;var _0x159c8c=_0x344a[_0xa4aa58];return _0x159c8c;};'use strict';var _=require(_0xa344('0x0'));var util=require(_0xa344('0x1'));var logger=require(_0xa344('0x2'))(_0xa344('0x3'));var moment=require('moment');var BPromise=require(_0xa344('0x4'));var rp=require(_0xa344('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xa344('0x6'));var config=require(_0xa344('0x7'));var attributes=require(_0xa344('0x8'));module['exports']=function(_0xcd737d,_0x15cc63){return _0xcd737d[_0xa344('0x9')](_0xa344('0xa'),attributes,{'tableName':_0xa344('0xb'),'paranoid':![],'indexes':[{'name':_0xa344('0xc'),'fields':[_0xa344('0xd'),_0xa344('0xe')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intDynamics365Field/intDynamics365Field.rpc.js b/server/api/intDynamics365Field/intDynamics365Field.rpc.js new file mode 100644 index 0000000..9393278 --- /dev/null +++ b/server/api/intDynamics365Field/intDynamics365Field.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfdbc=['debug','error','code','message','result','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','request','info','Dynamics365Field,\x20%s,\x20%s','request\x20sent'];(function(_0x56ed28,_0x5bedfe){var _0x1c2f7f=function(_0x27c9bc){while(--_0x27c9bc){_0x56ed28['push'](_0x56ed28['shift']());}};_0x1c2f7f(++_0x5bedfe);}(_0xfdbc,0xba));var _0xcfdb=function(_0x570845,_0x4935ca){_0x570845=_0x570845-0x0;var _0x393e6c=_0xfdbc[_0x570845];return _0x393e6c;};'use strict';var _=require(_0xcfdb('0x0'));var util=require(_0xcfdb('0x1'));var moment=require(_0xcfdb('0x2'));var BPromise=require('bluebird');var rs=require(_0xcfdb('0x3'));var fs=require('fs');var Redis=require(_0xcfdb('0x4'));var db=require(_0xcfdb('0x5'))['db'];var utils=require(_0xcfdb('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xcfdb('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xcfdb('0x8')][_0xcfdb('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x318adb,_0x465b6f,_0x514512){return new BPromise(function(_0x37b30a,_0x12ddf6){return client[_0xcfdb('0xa')](_0x318adb,_0x514512)['then'](function(_0x3e9e83){logger[_0xcfdb('0xb')](_0xcfdb('0xc'),_0x465b6f,_0xcfdb('0xd'));logger[_0xcfdb('0xe')]('Dynamics365Field,\x20%s,\x20%s,\x20%s',_0x465b6f,'request\x20sent',JSON['stringify'](_0x3e9e83));if(_0x3e9e83[_0xcfdb('0xf')]){if(_0x3e9e83[_0xcfdb('0xf')][_0xcfdb('0x10')]===0x1f4){logger[_0xcfdb('0xf')](_0xcfdb('0xc'),_0x465b6f,_0x3e9e83[_0xcfdb('0xf')][_0xcfdb('0x11')]);return _0x12ddf6(_0x3e9e83[_0xcfdb('0xf')][_0xcfdb('0x11')]);}logger[_0xcfdb('0xf')](_0xcfdb('0xc'),_0x465b6f,_0x3e9e83[_0xcfdb('0xf')][_0xcfdb('0x11')]);return _0x37b30a(_0x3e9e83['error'][_0xcfdb('0x11')]);}else{logger['info'](_0xcfdb('0xc'),_0x465b6f,_0xcfdb('0xd'));_0x37b30a(_0x3e9e83[_0xcfdb('0x12')]['message']);}})[_0xcfdb('0x13')](function(_0x25aece){logger['error'](_0xcfdb('0xc'),_0x465b6f,_0x25aece);_0x12ddf6(_0x25aece);});});} \ No newline at end of file diff --git a/server/api/intFreshdeskAccount/index.js b/server/api/intFreshdeskAccount/index.js new file mode 100644 index 0000000..820681e --- /dev/null +++ b/server/api/intFreshdeskAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe4a6=['/:id','show','/:id/configurations','/:id/fields','getFields','create','post','addConfiguration','put','delete','destroy','exports','multer','path','express','Router','fs-extra','../../components/interaction/service','../../config/environment','./intFreshdeskAccount.controller','get','isAuthenticated','index'];(function(_0x79496f,_0x2f9747){var _0x39f0bc=function(_0x368044){while(--_0x368044){_0x79496f['push'](_0x79496f['shift']());}};_0x39f0bc(++_0x2f9747);}(_0xe4a6,0x68));var _0x6e4a=function(_0x16b13d,_0x2faf09){_0x16b13d=_0x16b13d-0x0;var _0x1f1e77=_0xe4a6[_0x16b13d];return _0x1f1e77;};'use strict';var multer=require(_0x6e4a('0x0'));var util=require('util');var path=require(_0x6e4a('0x1'));var timeout=require('connect-timeout');var express=require(_0x6e4a('0x2'));var router=express[_0x6e4a('0x3')]();var fs_extra=require(_0x6e4a('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x6e4a('0x5'));var config=require(_0x6e4a('0x6'));var controller=require(_0x6e4a('0x7'));router[_0x6e4a('0x8')]('/',auth[_0x6e4a('0x9')](),controller[_0x6e4a('0xa')]);router[_0x6e4a('0x8')](_0x6e4a('0xb'),auth[_0x6e4a('0x9')](),controller[_0x6e4a('0xc')]);router[_0x6e4a('0x8')](_0x6e4a('0xd'),auth[_0x6e4a('0x9')](),controller['getConfigurations']);router['get'](_0x6e4a('0xe'),auth[_0x6e4a('0x9')](),controller[_0x6e4a('0xf')]);router['post']('/',auth['isAuthenticated'](),controller[_0x6e4a('0x10')]);router[_0x6e4a('0x11')]('/:id/configurations',auth[_0x6e4a('0x9')](),controller[_0x6e4a('0x12')]);router[_0x6e4a('0x13')](_0x6e4a('0xb'),auth['isAuthenticated'](),controller['update']);router[_0x6e4a('0x14')](_0x6e4a('0xb'),auth[_0x6e4a('0x9')](),controller[_0x6e4a('0x15')]);module[_0x6e4a('0x16')]=router; \ No newline at end of file diff --git a/server/api/intFreshdeskAccount/intFreshdeskAccount.attributes.js b/server/api/intFreshdeskAccount/intFreshdeskAccount.attributes.js new file mode 100644 index 0000000..28b1651 --- /dev/null +++ b/server/api/intFreshdeskAccount/intFreshdeskAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3423=['username','remoteUri','STRING'];(function(_0x34843e,_0x4c4224){var _0x598f7f=function(_0x12a44c){while(--_0x12a44c){_0x34843e['push'](_0x34843e['shift']());}};_0x598f7f(++_0x4c4224);}(_0x3423,0x188));var _0x3342=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3423[_0x3dd15e];return _0x231fd0;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0x3342('0x0')]},'description':{'type':Sequelize[_0x3342('0x0')]},'username':{'type':Sequelize[_0x3342('0x0')],'unique':_0x3342('0x1')},'apiKey':{'type':Sequelize[_0x3342('0x0')]},'remoteUri':{'type':Sequelize[_0x3342('0x0')],'unique':_0x3342('0x2')},'serverUrl':{'type':Sequelize[_0x3342('0x0')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/intFreshdeskAccount/intFreshdeskAccount.controller.js b/server/api/intFreshdeskAccount/intFreshdeskAccount.controller.js new file mode 100644 index 0000000..113ee27 --- /dev/null +++ b/server/api/intFreshdeskAccount/intFreshdeskAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e5c=['ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','end','json','offset','undefined','limit','count','status','apply','reject','save','then','error','stack','name','index','map','rawAttributes','fieldName','key','keys','query','filters','intersection','attributes','model','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','FreshdeskAccount','rows','catch','show','params','include','create','body','update','destroy','find','findOne','FreshdeskConfiguration','getConfigurations','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshdeskField','remoteUri','apiKey','slice','substring','lastIndexOf','format','%s/%s','api/v2/ticket_fields','toString','base64','subject','agent','priority','group','ticket_type','company','remove','default','custom_text','choices','test','statusCode','getFields','stringify','eml-format','zip-dir','request-promise','moment','bluebird','sox','to-csv'];(function(_0x313de9,_0x4ecb09){var _0x3ca6a7=function(_0x23f961){while(--_0x23f961){_0x313de9['push'](_0x313de9['shift']());}};_0x3ca6a7(++_0x4ecb09);}(_0x4e5c,0x149));var _0xc4e5=function(_0xaa1b3e,_0x47d976){_0xaa1b3e=_0xaa1b3e-0x0;var _0x454d7d=_0x4e5c[_0xaa1b3e];return _0x454d7d;};'use strict';var emlformat=require(_0xc4e5('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc4e5('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc4e5('0x2'));var moment=require(_0xc4e5('0x3'));var BPromise=require(_0xc4e5('0x4'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xc4e5('0x5'));var csv=require(_0xc4e5('0x6'));var ejs=require(_0xc4e5('0x7'));var fs=require('fs');var fs_extra=require(_0xc4e5('0x8'));var _=require(_0xc4e5('0x9'));var squel=require(_0xc4e5('0xa'));var crypto=require(_0xc4e5('0xb'));var jsforce=require(_0xc4e5('0xc'));var deskjs=require(_0xc4e5('0xd'));var toCsv=require(_0xc4e5('0x6'));var querystring=require(_0xc4e5('0xe'));var Papa=require(_0xc4e5('0xf'));var Redis=require('ioredis');var authService=require(_0xc4e5('0x10'));var qs=require(_0xc4e5('0x11'));var as=require(_0xc4e5('0x12'));var hardwareService=require(_0xc4e5('0x13'));var logger=require('../../config/logger')(_0xc4e5('0x14'));var utils=require(_0xc4e5('0x15'));var config=require(_0xc4e5('0x16'));var licenseUtil=require(_0xc4e5('0x17'));var db=require(_0xc4e5('0x18'))['db'];var integrations=require(_0xc4e5('0x19'));function respondWithStatusCode(_0x3fa318,_0x54c5a7){_0x54c5a7=_0x54c5a7||0xcc;return function(_0x5f00d8){if(_0x5f00d8){return _0x3fa318[_0xc4e5('0x1a')](_0x54c5a7);}return _0x3fa318['status'](_0x54c5a7)[_0xc4e5('0x1b')]();};}function respondWithResult(_0x7cd002,_0x303037){_0x303037=_0x303037||0xc8;return function(_0x2404a7){if(_0x2404a7){return _0x7cd002['status'](_0x303037)[_0xc4e5('0x1c')](_0x2404a7);}};}function respondWithFilteredResult(_0x528de4,_0x338c37){return function(_0x3beb59){if(_0x3beb59){var _0x2937d9=typeof _0x338c37[_0xc4e5('0x1d')]===_0xc4e5('0x1e')&&typeof _0x338c37[_0xc4e5('0x1f')]===_0xc4e5('0x1e');var _0x1156ce=_0x3beb59[_0xc4e5('0x20')];var _0x57042c=_0x2937d9?0x0:_0x338c37[_0xc4e5('0x1d')];var _0x154486=_0x2937d9?_0x3beb59['count']:_0x338c37[_0xc4e5('0x1d')]+_0x338c37[_0xc4e5('0x1f')];var _0x5003e5;if(_0x154486>=_0x1156ce){_0x154486=_0x1156ce;_0x5003e5=0xc8;}else{_0x5003e5=0xce;}_0x528de4[_0xc4e5('0x21')](_0x5003e5);return _0x528de4['set']('Content-Range',_0x57042c+'-'+_0x154486+'/'+_0x1156ce)[_0xc4e5('0x1c')](_0x3beb59);}return null;};}function patchUpdates(_0x7dbe6d){return function(_0x4933b7){try{jsonpatch[_0xc4e5('0x22')](_0x4933b7,_0x7dbe6d,!![]);}catch(_0x5be68b){return BPromise[_0xc4e5('0x23')](_0x5be68b);}return _0x4933b7[_0xc4e5('0x24')]();};}function saveUpdates(_0x505078,_0x546949){return function(_0x45abe3){if(_0x45abe3){return _0x45abe3['update'](_0x505078)[_0xc4e5('0x25')](function(_0x41467f){return _0x41467f;});}return null;};}function removeEntity(_0x4bb973,_0x4ed1ff){return function(_0x44299a){if(_0x44299a){return _0x44299a['destroy']()[_0xc4e5('0x25')](function(){_0x4bb973['status'](0xcc)[_0xc4e5('0x1b')]();});}};}function handleEntityNotFound(_0x234b31,_0x53f7cd){return function(_0x5f48fc){if(!_0x5f48fc){_0x234b31['sendStatus'](0x194);}return _0x5f48fc;};}function handleError(_0x23889c,_0x183ec7){_0x183ec7=_0x183ec7||0x1f4;return function(_0x143e66){logger[_0xc4e5('0x26')](_0x143e66[_0xc4e5('0x27')]);if(_0x143e66[_0xc4e5('0x28')]){delete _0x143e66[_0xc4e5('0x28')];}_0x23889c[_0xc4e5('0x21')](_0x183ec7)['send'](_0x143e66);};}exports[_0xc4e5('0x29')]=function(_0x2ad4be,_0x261b88){var _0x23383b={},_0x94dcd0={},_0x4805b2={'count':0x0,'rows':[]};var _0x205f41=_[_0xc4e5('0x2a')](db['FreshdeskAccount'][_0xc4e5('0x2b')],function(_0x598212){return{'name':_0x598212[_0xc4e5('0x2c')],'type':_0x598212['type'][_0xc4e5('0x2d')]};});_0x94dcd0['model']=_[_0xc4e5('0x2a')](_0x205f41,'name');_0x94dcd0['query']=_[_0xc4e5('0x2e')](_0x2ad4be[_0xc4e5('0x2f')]);_0x94dcd0[_0xc4e5('0x30')]=_[_0xc4e5('0x31')](_0x94dcd0['model'],_0x94dcd0[_0xc4e5('0x2f')]);_0x23383b[_0xc4e5('0x32')]=_[_0xc4e5('0x31')](_0x94dcd0[_0xc4e5('0x33')],qs['fields'](_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x34')]));_0x23383b[_0xc4e5('0x32')]=_0x23383b[_0xc4e5('0x32')][_0xc4e5('0x35')]?_0x23383b['attributes']:_0x94dcd0[_0xc4e5('0x33')];if(!_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x36')]('nolimit')){_0x23383b[_0xc4e5('0x1f')]=qs[_0xc4e5('0x1f')](_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x1f')]);_0x23383b['offset']=qs['offset'](_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x1d')]);}_0x23383b[_0xc4e5('0x37')]=qs[_0xc4e5('0x38')](_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x38')]);_0x23383b[_0xc4e5('0x39')]=qs[_0xc4e5('0x30')](_[_0xc4e5('0x3a')](_0x2ad4be['query'],_0x94dcd0['filters']),_0x205f41);if(_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x3b')]){_0x23383b[_0xc4e5('0x39')]=_[_0xc4e5('0x3c')](_0x23383b[_0xc4e5('0x39')],{'$or':_['map'](_0x205f41,function(_0x2a77dd){if(_0x2a77dd[_0xc4e5('0x3d')]!==_0xc4e5('0x3e')){var _0x2c754b={};_0x2c754b[_0x2a77dd[_0xc4e5('0x28')]]={'$like':'%'+_0x2ad4be['query'][_0xc4e5('0x3b')]+'%'};return _0x2c754b;}})});}_0x23383b=_[_0xc4e5('0x3c')]({},_0x23383b,_0x2ad4be[_0xc4e5('0x3f')]);var _0x35f940={'where':_0x23383b['where']};return db['FreshdeskAccount']['count'](_0x35f940)[_0xc4e5('0x25')](function(_0x5292a4){_0x4805b2[_0xc4e5('0x20')]=_0x5292a4;if(_0x2ad4be[_0xc4e5('0x2f')][_0xc4e5('0x40')]){_0x23383b['include']=[{'all':!![]}];}return db[_0xc4e5('0x41')]['findAll'](_0x23383b);})[_0xc4e5('0x25')](function(_0x46184f){_0x4805b2[_0xc4e5('0x42')]=_0x46184f;return _0x4805b2;})['then'](respondWithFilteredResult(_0x261b88,_0x23383b))[_0xc4e5('0x43')](handleError(_0x261b88,null));};exports[_0xc4e5('0x44')]=function(_0x1117e1,_0xba5c47){var _0x2ea4a8={'raw':![],'where':{'id':_0x1117e1[_0xc4e5('0x45')]['id']}},_0x409a3f={};_0x409a3f[_0xc4e5('0x33')]=_['keys'](db[_0xc4e5('0x41')][_0xc4e5('0x2b')]);_0x409a3f[_0xc4e5('0x2f')]=_[_0xc4e5('0x2e')](_0x1117e1[_0xc4e5('0x2f')]);_0x409a3f[_0xc4e5('0x30')]=_[_0xc4e5('0x31')](_0x409a3f[_0xc4e5('0x33')],_0x409a3f[_0xc4e5('0x2f')]);_0x2ea4a8[_0xc4e5('0x32')]=_[_0xc4e5('0x31')](_0x409a3f[_0xc4e5('0x33')],qs['fields'](_0x1117e1['query'][_0xc4e5('0x34')]));_0x2ea4a8[_0xc4e5('0x32')]=_0x2ea4a8[_0xc4e5('0x32')][_0xc4e5('0x35')]?_0x2ea4a8['attributes']:_0x409a3f[_0xc4e5('0x33')];if(_0x1117e1['query']['includeAll']){_0x2ea4a8[_0xc4e5('0x46')]=[{'all':!![]}];}_0x2ea4a8=_[_0xc4e5('0x3c')]({},_0x2ea4a8,_0x1117e1['options']);return db[_0xc4e5('0x41')]['find'](_0x2ea4a8)[_0xc4e5('0x25')](handleEntityNotFound(_0xba5c47,null))[_0xc4e5('0x25')](respondWithResult(_0xba5c47,null))[_0xc4e5('0x43')](handleError(_0xba5c47,null));};exports[_0xc4e5('0x47')]=function(_0xd73e5c,_0x347d7c){return db[_0xc4e5('0x41')][_0xc4e5('0x47')](_0xd73e5c[_0xc4e5('0x48')],{})['then'](respondWithResult(_0x347d7c,0xc9))[_0xc4e5('0x43')](handleError(_0x347d7c,null));};exports[_0xc4e5('0x49')]=function(_0x452a5e,_0x14614b){if(_0x452a5e[_0xc4e5('0x48')]['id']){delete _0x452a5e[_0xc4e5('0x48')]['id'];}return db[_0xc4e5('0x41')]['find']({'where':{'id':_0x452a5e[_0xc4e5('0x45')]['id']}})['then'](handleEntityNotFound(_0x14614b,null))[_0xc4e5('0x25')](saveUpdates(_0x452a5e[_0xc4e5('0x48')],null))['then'](respondWithResult(_0x14614b,null))[_0xc4e5('0x43')](handleError(_0x14614b,null));};exports[_0xc4e5('0x4a')]=function(_0x5c536c,_0x51e1d6){return db[_0xc4e5('0x41')][_0xc4e5('0x4b')]({'where':{'id':_0x5c536c[_0xc4e5('0x45')]['id']}})[_0xc4e5('0x25')](handleEntityNotFound(_0x51e1d6,null))['then'](removeEntity(_0x51e1d6,null))[_0xc4e5('0x43')](handleError(_0x51e1d6,null));};exports['getConfigurations']=function(_0x15fb9c,_0x466da5,_0x235d25){var _0x37bed4={};var _0x42c752={};var _0x4a7244;var _0x2c067c;return db[_0xc4e5('0x41')][_0xc4e5('0x4c')]({'where':{'id':_0x15fb9c[_0xc4e5('0x45')]['id']}})[_0xc4e5('0x25')](handleEntityNotFound(_0x466da5,null))[_0xc4e5('0x25')](function(_0x465e27){if(_0x465e27){_0x4a7244=_0x465e27;_0x42c752['model']=_[_0xc4e5('0x2e')](db[_0xc4e5('0x4d')][_0xc4e5('0x2b')]);_0x42c752[_0xc4e5('0x2f')]=_[_0xc4e5('0x2e')](_0x15fb9c[_0xc4e5('0x2f')]);_0x42c752[_0xc4e5('0x30')]=_[_0xc4e5('0x31')](_0x42c752[_0xc4e5('0x33')],_0x42c752[_0xc4e5('0x2f')]);_0x37bed4[_0xc4e5('0x32')]=_['intersection'](_0x42c752['model'],qs[_0xc4e5('0x34')](_0x15fb9c['query']['fields']));_0x37bed4[_0xc4e5('0x32')]=_0x37bed4[_0xc4e5('0x32')][_0xc4e5('0x35')]?_0x37bed4['attributes']:_0x42c752[_0xc4e5('0x33')];_0x37bed4[_0xc4e5('0x37')]=qs[_0xc4e5('0x38')](_0x15fb9c[_0xc4e5('0x2f')][_0xc4e5('0x38')]);_0x37bed4['where']=qs[_0xc4e5('0x30')](_[_0xc4e5('0x3a')](_0x15fb9c[_0xc4e5('0x2f')],_0x42c752[_0xc4e5('0x30')]));if(_0x15fb9c[_0xc4e5('0x2f')][_0xc4e5('0x3b')]){_0x37bed4[_0xc4e5('0x39')]=_[_0xc4e5('0x3c')](_0x37bed4[_0xc4e5('0x39')],{'$or':_[_0xc4e5('0x2a')](_0x37bed4[_0xc4e5('0x32')],function(_0x237c7f){var _0x66c974={};_0x66c974[_0x237c7f]={'$like':'%'+_0x15fb9c[_0xc4e5('0x2f')][_0xc4e5('0x3b')]+'%'};return _0x66c974;})});}_0x37bed4=_[_0xc4e5('0x3c')]({},_0x37bed4,_0x15fb9c[_0xc4e5('0x3f')]);return _0x4a7244[_0xc4e5('0x4e')](_0x37bed4);}})[_0xc4e5('0x25')](function(_0x505aae){if(_0x505aae){_0x2c067c=_0x505aae['length'];if(!_0x15fb9c[_0xc4e5('0x2f')]['hasOwnProperty'](_0xc4e5('0x4f'))){_0x37bed4[_0xc4e5('0x1f')]=qs[_0xc4e5('0x1f')](_0x15fb9c[_0xc4e5('0x2f')][_0xc4e5('0x1f')]);_0x37bed4[_0xc4e5('0x1d')]=qs[_0xc4e5('0x1d')](_0x15fb9c['query'][_0xc4e5('0x1d')]);}return _0x4a7244['getConfigurations'](_0x37bed4);}})[_0xc4e5('0x25')](function(_0x5dbeee){if(_0x5dbeee){return _0x5dbeee?{'count':_0x2c067c,'rows':_0x5dbeee}:null;}})[_0xc4e5('0x25')](respondWithResult(_0x466da5,null))['catch'](handleError(_0x466da5,null));};exports[_0xc4e5('0x50')]=function(_0x23a43e,_0xf776e0,_0x4b5a6a){if(_0x23a43e[_0xc4e5('0x48')]['id']){delete _0x23a43e['body']['id'];}return db[_0xc4e5('0x41')][_0xc4e5('0x4c')]({'where':{'id':_0x23a43e[_0xc4e5('0x45')]['id']}})[_0xc4e5('0x25')](handleEntityNotFound(_0xf776e0,null))[_0xc4e5('0x25')](function(_0x2d528b){if(_0x2d528b){_0x23a43e['body'][_0xc4e5('0x51')]=_0x2d528b['id'];_0x23a43e[_0xc4e5('0x48')][_0xc4e5('0x52')]=integrations[_0xc4e5('0x53')](_0x23a43e[_0xc4e5('0x48')][_0xc4e5('0x54')],_0x23a43e[_0xc4e5('0x48')][_0xc4e5('0x3d')]);_0x23a43e[_0xc4e5('0x48')][_0xc4e5('0x55')]=integrations[_0xc4e5('0x56')](_0x23a43e['body'][_0xc4e5('0x54')],_0x23a43e[_0xc4e5('0x48')]['type']);return db[_0xc4e5('0x4d')][_0xc4e5('0x47')](_0x23a43e[_0xc4e5('0x48')],{'include':[{'model':db[_0xc4e5('0x57')],'as':_0xc4e5('0x52')},{'model':db[_0xc4e5('0x57')],'as':'Descriptions'}]});}return null;})[_0xc4e5('0x25')](respondWithResult(_0xf776e0,null))[_0xc4e5('0x43')](handleError(_0xf776e0,null));};exports['getFields']=function(_0x37da48,_0x267886,_0x5d953b){var _0x4bc266='';return db[_0xc4e5('0x41')][_0xc4e5('0x4c')]({'where':{'id':_0x37da48[_0xc4e5('0x45')]['id']},'attributes':['id',_0xc4e5('0x58'),_0xc4e5('0x59')]})[_0xc4e5('0x25')](handleEntityNotFound(_0x267886,null))['then'](function(_0x5ba867){if(_0x5ba867){_0x4bc266=_0x5ba867[_0xc4e5('0x58')];var _0xc14634=_0x4bc266[_0xc4e5('0x5a')](-0x1);if(_0xc14634==='/'){_0x4bc266=_0x4bc266[_0xc4e5('0x5b')](0x0,_0x4bc266[_0xc4e5('0x5c')](_0xc14634));}return rp({'method':'GET','uri':util[_0xc4e5('0x5d')](_0xc4e5('0x5e'),_0x4bc266,_0xc4e5('0x5f')),'headers':{'Authorization':util[_0xc4e5('0x5d')]('Basic\x20%s',new Buffer(util[_0xc4e5('0x5d')]('%s:X',_0x5ba867[_0xc4e5('0x59')]))[_0xc4e5('0x60')](_0xc4e5('0x61')))},'json':!![]});}})['then'](function(_0x52e2e5){if(_0x52e2e5){var _0x5ad018=['requester',_0xc4e5('0x62'),_0xc4e5('0x63'),'description','status',_0xc4e5('0x64'),_0xc4e5('0x65'),'source',_0xc4e5('0x66'),_0xc4e5('0x65'),_0xc4e5('0x67')];_[_0xc4e5('0x68')](_0x52e2e5,function(_0x255e96){return _0x5ad018['includes'](_0x255e96[_0xc4e5('0x28')])||!_0x255e96[_0xc4e5('0x69')]&&_0x255e96[_0xc4e5('0x3d')]!==_0xc4e5('0x6a')&&_0x255e96['type']!=='custom_dropdown';});return{'count':_0x52e2e5[_0xc4e5('0x35')],'rows':_[_0xc4e5('0x2a')](_0x52e2e5,function(_0xec7a48){return{'id':_0xec7a48['name'],'name':_0xec7a48['label'],'custom':!_0xec7a48[_0xc4e5('0x69')],'options':_0xec7a48[_0xc4e5('0x6b')]?_['map'](_0xec7a48[_0xc4e5('0x6b')],function(_0x44367f){return{'name':_['capitalize'](_0x44367f),'value':_0x44367f};}):[]};})};}})['then'](respondWithResult(_0x267886,null))[_0xc4e5('0x43')](function(_0x213aa7){var _0x3492e6=_0x37da48[_0xc4e5('0x2f')][_0xc4e5('0x6c')]?0x1f4:_0x213aa7[_0xc4e5('0x6d')]||0x1f4;logger[_0xc4e5('0x26')]('getFields,\x20%s,\x20%s,\x20%s',_0xc4e5('0x6e'),_0x3492e6,JSON[_0xc4e5('0x6f')](_0x213aa7));delete _0x213aa7['name'];if(_0x3492e6===0x191){_0x3492e6=0x190;}_0x267886[_0xc4e5('0x21')](_0x3492e6)['send'](_0x37da48[_0xc4e5('0x2f')][_0xc4e5('0x6c')]?{'message':'Wrong\x20credentials','statusCode':_0x213aa7[_0xc4e5('0x6d')]}:_0x213aa7);});}; \ No newline at end of file diff --git a/server/api/intFreshdeskAccount/intFreshdeskAccount.model.js b/server/api/intFreshdeskAccount/intFreshdeskAccount.model.js new file mode 100644 index 0000000..fc70dea --- /dev/null +++ b/server/api/intFreshdeskAccount/intFreshdeskAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xad5e=['bluebird','request-promise','path','rimraf','../../config/environment','exports','define','int_freshdesk_accounts','lodash','util','../../config/logger','moment'];(function(_0x56fd29,_0x17790b){var _0x2a0bf7=function(_0x568f20){while(--_0x568f20){_0x56fd29['push'](_0x56fd29['shift']());}};_0x2a0bf7(++_0x17790b);}(_0xad5e,0x68));var _0xead5=function(_0x529bde,_0x32d640){_0x529bde=_0x529bde-0x0;var _0xb7109c=_0xad5e[_0x529bde];return _0xb7109c;};'use strict';var _=require(_0xead5('0x0'));var util=require(_0xead5('0x1'));var logger=require(_0xead5('0x2'))('api');var moment=require(_0xead5('0x3'));var BPromise=require(_0xead5('0x4'));var rp=require(_0xead5('0x5'));var fs=require('fs');var path=require(_0xead5('0x6'));var rimraf=require(_0xead5('0x7'));var config=require(_0xead5('0x8'));var attributes=require('./intFreshdeskAccount.attributes');var integrations=require('../../components/integrations/configuration');module[_0xead5('0x9')]=function(_0x3dc137,_0x236585){return _0x3dc137[_0xead5('0xa')]('FreshdeskAccount',attributes,{'tableName':_0xead5('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshdeskAccount/intFreshdeskAccount.rpc.js b/server/api/intFreshdeskAccount/intFreshdeskAccount.rpc.js new file mode 100644 index 0000000..3565a35 --- /dev/null +++ b/server/api/intFreshdeskAccount/intFreshdeskAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7aa7=['limit','include','map','model','attributes','ShowFreshdeskAccount','find','raw','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','FreshdeskAccount,\x20%s,\x20%s','FreshdeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','catch','GetFreshdeskAccount','FreshdeskAccount','findAll','options','where'];(function(_0x4a0355,_0xd5f57){var _0x40727b=function(_0x501ab7){while(--_0x501ab7){_0x4a0355['push'](_0x4a0355['shift']());}};_0x40727b(++_0xd5f57);}(_0x7aa7,0xfd));var _0x77aa=function(_0x56ca45,_0x4b2e91){_0x56ca45=_0x56ca45-0x0;var _0x588fd4=_0x7aa7[_0x56ca45];return _0x588fd4;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x77aa('0x0'));var BPromise=require(_0x77aa('0x1'));var rs=require(_0x77aa('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x77aa('0x3'))['db'];var utils=require(_0x77aa('0x4'));var logger=require(_0x77aa('0x5'))(_0x77aa('0x6'));var config=require(_0x77aa('0x7'));var jayson=require(_0x77aa('0x8'));var client=jayson[_0x77aa('0x9')][_0x77aa('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x549193,_0x45a4f1,_0x16aae6){return new BPromise(function(_0x4e28b,_0x62d7a7){return client[_0x77aa('0xb')](_0x549193,_0x16aae6)[_0x77aa('0xc')](function(_0x2e837b){logger['info'](_0x77aa('0xd'),_0x45a4f1,'request\x20sent');logger['debug'](_0x77aa('0xe'),_0x45a4f1,_0x77aa('0xf'),JSON[_0x77aa('0x10')](_0x2e837b));if(_0x2e837b[_0x77aa('0x11')]){if(_0x2e837b[_0x77aa('0x11')]['code']===0x1f4){logger[_0x77aa('0x11')](_0x77aa('0xd'),_0x45a4f1,_0x2e837b[_0x77aa('0x11')][_0x77aa('0x12')]);return _0x62d7a7(_0x2e837b['error'][_0x77aa('0x12')]);}logger[_0x77aa('0x11')](_0x77aa('0xd'),_0x45a4f1,_0x2e837b['error'][_0x77aa('0x12')]);return _0x4e28b(_0x2e837b['error'][_0x77aa('0x12')]);}else{logger[_0x77aa('0x13')](_0x77aa('0xd'),_0x45a4f1,_0x77aa('0xf'));_0x4e28b(_0x2e837b[_0x77aa('0x14')][_0x77aa('0x12')]);}})[_0x77aa('0x15')](function(_0x2f8d7d){logger[_0x77aa('0x11')]('FreshdeskAccount,\x20%s,\x20%s',_0x45a4f1,_0x2f8d7d);_0x62d7a7(_0x2f8d7d);});});}exports[_0x77aa('0x16')]=function(_0x2febb6){var _0x2f51fe=this;return new Promise(function(_0x609e37,_0x56f087){return db[_0x77aa('0x17')][_0x77aa('0x18')]({'raw':_0x2febb6[_0x77aa('0x19')]?_0x2febb6[_0x77aa('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x2febb6[_0x77aa('0x19')]?_0x2febb6['options'][_0x77aa('0x1a')]||null:null,'attributes':_0x2febb6[_0x77aa('0x19')]?_0x2febb6['options']['attributes']||null:null,'limit':_0x2febb6[_0x77aa('0x19')]?_0x2febb6[_0x77aa('0x19')][_0x77aa('0x1b')]||null:null,'include':_0x2febb6[_0x77aa('0x19')]?_0x2febb6['options'][_0x77aa('0x1c')]?_[_0x77aa('0x1d')](_0x2febb6[_0x77aa('0x19')]['include'],function(_0x5af6b9){return{'model':db[_0x5af6b9[_0x77aa('0x1e')]],'as':_0x5af6b9['as'],'attributes':_0x5af6b9['attributes'],'include':_0x5af6b9['include']?_['map'](_0x5af6b9[_0x77aa('0x1c')],function(_0x445c45){return{'model':db[_0x445c45[_0x77aa('0x1e')]],'as':_0x445c45['as'],'attributes':_0x445c45[_0x77aa('0x1f')],'include':_0x445c45[_0x77aa('0x1c')]?_[_0x77aa('0x1d')](_0x445c45[_0x77aa('0x1c')],function(_0x286691){return{'model':db[_0x286691['model']],'as':_0x286691['as'],'attributes':_0x286691[_0x77aa('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x77aa('0xc')](function(_0x3eb851){logger['info']('GetFreshdeskAccount',_0x2febb6);logger['debug'](_0x77aa('0x16'),_0x2febb6,JSON['stringify'](_0x3eb851));_0x609e37(_0x3eb851);})['catch'](function(_0x58f427){logger['error'](_0x77aa('0x16'),_0x58f427[_0x77aa('0x12')],_0x2febb6);_0x56f087(_0x2f51fe['error'](0x1f4,_0x58f427['message']));});});};exports[_0x77aa('0x20')]=function(_0x1ec1ab){var _0x5c29b0=this;return new Promise(function(_0xab7732,_0x26e0db){return db['FreshdeskAccount'][_0x77aa('0x21')]({'raw':_0x1ec1ab[_0x77aa('0x19')]?_0x1ec1ab['options'][_0x77aa('0x22')]===undefined?!![]:![]:!![],'where':_0x1ec1ab[_0x77aa('0x19')]?_0x1ec1ab[_0x77aa('0x19')][_0x77aa('0x1a')]||null:null,'attributes':_0x1ec1ab[_0x77aa('0x19')]?_0x1ec1ab[_0x77aa('0x19')][_0x77aa('0x1f')]||null:null,'include':_0x1ec1ab['options']?_0x1ec1ab[_0x77aa('0x19')]['include']?_[_0x77aa('0x1d')](_0x1ec1ab['options']['include'],function(_0x32594f){return{'model':db[_0x32594f[_0x77aa('0x1e')]],'as':_0x32594f['as'],'attributes':_0x32594f['attributes'],'include':_0x32594f[_0x77aa('0x1c')]?_[_0x77aa('0x1d')](_0x32594f[_0x77aa('0x1c')],function(_0x418e04){return{'model':db[_0x418e04[_0x77aa('0x1e')]],'as':_0x418e04['as'],'attributes':_0x418e04[_0x77aa('0x1f')],'include':_0x418e04[_0x77aa('0x1c')]?_[_0x77aa('0x1d')](_0x418e04[_0x77aa('0x1c')],function(_0x32bc30){return{'model':db[_0x32bc30[_0x77aa('0x1e')]],'as':_0x32bc30['as'],'attributes':_0x32bc30['attributes']};}):[]};}):[]};}):[]:[]})[_0x77aa('0xc')](function(_0x46553d){logger[_0x77aa('0x13')](_0x77aa('0x20'),_0x1ec1ab);logger['debug'](_0x77aa('0x20'),_0x1ec1ab,JSON[_0x77aa('0x10')](_0x46553d));_0xab7732(_0x46553d);})['catch'](function(_0x5c5ea3){logger[_0x77aa('0x11')]('ShowFreshdeskAccount',_0x5c5ea3['message'],_0x1ec1ab);_0x26e0db(_0x5c29b0['error'](0x1f4,_0x5c5ea3[_0x77aa('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/intFreshdeskConfiguration/index.js b/server/api/intFreshdeskConfiguration/index.js new file mode 100644 index 0000000..0ececfd --- /dev/null +++ b/server/api/intFreshdeskConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7c94=['fs-extra','../../components/interaction/service','./intFreshdeskConfiguration.controller','get','isAuthenticated','index','/:id','show','/:id/fields','getFields','getSubjects','/:id/descriptions','getDescriptions','/:id/tags','getTags','post','create','put','update','destroy','exports','multer','util','path','connect-timeout','express'];(function(_0x24c2e3,_0x988100){var _0xf129fc=function(_0x268069){while(--_0x268069){_0x24c2e3['push'](_0x24c2e3['shift']());}};_0xf129fc(++_0x988100);}(_0x7c94,0x119));var _0x47c9=function(_0x2c66ed,_0x158377){_0x2c66ed=_0x2c66ed-0x0;var _0x2f0974=_0x7c94[_0x2c66ed];return _0x2f0974;};'use strict';var multer=require(_0x47c9('0x0'));var util=require(_0x47c9('0x1'));var path=require(_0x47c9('0x2'));var timeout=require(_0x47c9('0x3'));var express=require(_0x47c9('0x4'));var router=express['Router']();var fs_extra=require(_0x47c9('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x47c9('0x6'));var config=require('../../config/environment');var controller=require(_0x47c9('0x7'));router[_0x47c9('0x8')]('/',auth[_0x47c9('0x9')](),controller[_0x47c9('0xa')]);router[_0x47c9('0x8')](_0x47c9('0xb'),auth[_0x47c9('0x9')](),controller[_0x47c9('0xc')]);router[_0x47c9('0x8')](_0x47c9('0xd'),auth[_0x47c9('0x9')](),controller[_0x47c9('0xe')]);router[_0x47c9('0x8')]('/:id/subjects',auth[_0x47c9('0x9')](),controller[_0x47c9('0xf')]);router[_0x47c9('0x8')](_0x47c9('0x10'),auth[_0x47c9('0x9')](),controller[_0x47c9('0x11')]);router['get'](_0x47c9('0x12'),auth[_0x47c9('0x9')](),controller[_0x47c9('0x13')]);router[_0x47c9('0x14')]('/',auth['isAuthenticated'](),controller[_0x47c9('0x15')]);router[_0x47c9('0x14')](_0x47c9('0x12'),auth[_0x47c9('0x9')](),controller['setTags']);router[_0x47c9('0x16')](_0x47c9('0xb'),auth[_0x47c9('0x9')](),controller[_0x47c9('0x17')]);router['delete'](_0x47c9('0xb'),auth[_0x47c9('0x9')](),controller[_0x47c9('0x18')]);module[_0x47c9('0x19')]=router; \ No newline at end of file diff --git a/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.attributes.js b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.attributes.js new file mode 100644 index 0000000..6f6db7a --- /dev/null +++ b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb61a=['exports','STRING'];(function(_0x412c8f,_0x11ec94){var _0x27c005=function(_0x127059){while(--_0x127059){_0x412c8f['push'](_0x412c8f['shift']());}};_0x27c005(++_0x11ec94);}(_0xb61a,0xfa));var _0xab61=function(_0x335b86,_0x848570){_0x335b86=_0x335b86-0x0;var _0x47f662=_0xb61a[_0x335b86];return _0x47f662;};'use strict';var Sequelize=require('sequelize');module[_0xab61('0x0')]={'name':{'type':Sequelize[_0xab61('0x1')]},'description':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.controller.js b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.controller.js new file mode 100644 index 0000000..e29e0fb --- /dev/null +++ b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9514=['reject','then','error','stack','name','send','index','map','FreshdeskConfiguration','fieldName','type','key','model','query','keys','intersection','attributes','length','hasOwnProperty','nolimit','sort','where','filters','filter','merge','VIRTUAL','include','findAll','rows','show','params','rawAttributes','fields','includeAll','options','find','catch','create','body','update','findOne','FreshdeskField','order','pick','getFields','getSubjects','getDescriptions','getTags','Tag','setTags','ids','eml-format','zip-dir','fast-json-patch','request-promise','moment','path','sox','to-csv','ejs','lodash','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','offset','limit','count','Content-Range','json','apply'];(function(_0x4a7a63,_0x529128){var _0x682e4e=function(_0x2179d5){while(--_0x2179d5){_0x4a7a63['push'](_0x4a7a63['shift']());}};_0x682e4e(++_0x529128);}(_0x9514,0x129));var _0x4951=function(_0x27aa1d,_0x211021){_0x27aa1d=_0x27aa1d-0x0;var _0x46deb2=_0x9514[_0x27aa1d];return _0x46deb2;};'use strict';var emlformat=require(_0x4951('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4951('0x1'));var jsonpatch=require(_0x4951('0x2'));var rp=require(_0x4951('0x3'));var moment=require(_0x4951('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x4951('0x5'));var sox=require(_0x4951('0x6'));var csv=require(_0x4951('0x7'));var ejs=require(_0x4951('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x4951('0x9'));var squel=require(_0x4951('0xa'));var crypto=require(_0x4951('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x4951('0xc'));var Redis=require(_0x4951('0xd'));var authService=require(_0x4951('0xe'));var qs=require(_0x4951('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4951('0x10'));var logger=require(_0x4951('0x11'))(_0x4951('0x12'));var utils=require(_0x4951('0x13'));var config=require(_0x4951('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0x4951('0x15'))['db'];function respondWithStatusCode(_0x31ef65,_0x58f6b6){_0x58f6b6=_0x58f6b6||0xcc;return function(_0x2377e3){if(_0x2377e3){return _0x31ef65[_0x4951('0x16')](_0x58f6b6);}return _0x31ef65[_0x4951('0x17')](_0x58f6b6)[_0x4951('0x18')]();};}function respondWithResult(_0x391e2f,_0x37d9fa){_0x37d9fa=_0x37d9fa||0xc8;return function(_0x5c4009){if(_0x5c4009){return _0x391e2f[_0x4951('0x17')](_0x37d9fa)['json'](_0x5c4009);}};}function respondWithFilteredResult(_0x4bd69e,_0x29a9ea){return function(_0x3ba497){if(_0x3ba497){var _0x18f1a8=typeof _0x29a9ea[_0x4951('0x19')]==='undefined'&&typeof _0x29a9ea[_0x4951('0x1a')]==='undefined';var _0x1474f8=_0x3ba497[_0x4951('0x1b')];var _0x3440a9=_0x18f1a8?0x0:_0x29a9ea['offset'];var _0x3848f7=_0x18f1a8?_0x3ba497['count']:_0x29a9ea[_0x4951('0x19')]+_0x29a9ea['limit'];var _0x55cea5;if(_0x3848f7>=_0x1474f8){_0x3848f7=_0x1474f8;_0x55cea5=0xc8;}else{_0x55cea5=0xce;}_0x4bd69e[_0x4951('0x17')](_0x55cea5);return _0x4bd69e['set'](_0x4951('0x1c'),_0x3440a9+'-'+_0x3848f7+'/'+_0x1474f8)[_0x4951('0x1d')](_0x3ba497);}return null;};}function patchUpdates(_0x4c6155){return function(_0x33cc16){try{jsonpatch[_0x4951('0x1e')](_0x33cc16,_0x4c6155,!![]);}catch(_0x947b29){return BPromise[_0x4951('0x1f')](_0x947b29);}return _0x33cc16['save']();};}function saveUpdates(_0x579a74,_0x21a757){return function(_0x58e1d6){if(_0x58e1d6){return _0x58e1d6['update'](_0x579a74)[_0x4951('0x20')](function(_0xb85998){return _0xb85998;});}return null;};}function removeEntity(_0x4337aa,_0x139238){return function(_0x53e36d){if(_0x53e36d){return _0x53e36d['destroy']()['then'](function(){_0x4337aa[_0x4951('0x17')](0xcc)[_0x4951('0x18')]();});}};}function handleEntityNotFound(_0x4bfba3,_0x48dbb3){return function(_0x1a819a){if(!_0x1a819a){_0x4bfba3[_0x4951('0x16')](0x194);}return _0x1a819a;};}function handleError(_0x19ce64,_0xbdbc95){_0xbdbc95=_0xbdbc95||0x1f4;return function(_0x463c1e){logger[_0x4951('0x21')](_0x463c1e[_0x4951('0x22')]);if(_0x463c1e[_0x4951('0x23')]){delete _0x463c1e['name'];}_0x19ce64[_0x4951('0x17')](_0xbdbc95)[_0x4951('0x24')](_0x463c1e);};}exports[_0x4951('0x25')]=function(_0x58d7ab,_0x1c04a9){var _0x2321c0={},_0x3d915b={},_0x40976c={'count':0x0,'rows':[]};var _0x1582d2=_[_0x4951('0x26')](db[_0x4951('0x27')]['rawAttributes'],function(_0x528043){return{'name':_0x528043[_0x4951('0x28')],'type':_0x528043[_0x4951('0x29')][_0x4951('0x2a')]};});_0x3d915b[_0x4951('0x2b')]=_['map'](_0x1582d2,'name');_0x3d915b[_0x4951('0x2c')]=_[_0x4951('0x2d')](_0x58d7ab['query']);_0x3d915b['filters']=_[_0x4951('0x2e')](_0x3d915b[_0x4951('0x2b')],_0x3d915b[_0x4951('0x2c')]);_0x2321c0[_0x4951('0x2f')]=_['intersection'](_0x3d915b[_0x4951('0x2b')],qs['fields'](_0x58d7ab[_0x4951('0x2c')]['fields']));_0x2321c0[_0x4951('0x2f')]=_0x2321c0[_0x4951('0x2f')][_0x4951('0x30')]?_0x2321c0[_0x4951('0x2f')]:_0x3d915b['model'];if(!_0x58d7ab[_0x4951('0x2c')][_0x4951('0x31')](_0x4951('0x32'))){_0x2321c0[_0x4951('0x1a')]=qs[_0x4951('0x1a')](_0x58d7ab[_0x4951('0x2c')][_0x4951('0x1a')]);_0x2321c0[_0x4951('0x19')]=qs['offset'](_0x58d7ab[_0x4951('0x2c')][_0x4951('0x19')]);}_0x2321c0['order']=qs[_0x4951('0x33')](_0x58d7ab[_0x4951('0x2c')][_0x4951('0x33')]);_0x2321c0[_0x4951('0x34')]=qs[_0x4951('0x35')](_['pick'](_0x58d7ab[_0x4951('0x2c')],_0x3d915b[_0x4951('0x35')]),_0x1582d2);if(_0x58d7ab[_0x4951('0x2c')][_0x4951('0x36')]){_0x2321c0['where']=_[_0x4951('0x37')](_0x2321c0[_0x4951('0x34')],{'$or':_[_0x4951('0x26')](_0x1582d2,function(_0x2ced64){if(_0x2ced64[_0x4951('0x29')]!==_0x4951('0x38')){var _0x129d1a={};_0x129d1a[_0x2ced64[_0x4951('0x23')]]={'$like':'%'+_0x58d7ab[_0x4951('0x2c')][_0x4951('0x36')]+'%'};return _0x129d1a;}})});}_0x2321c0=_['merge']({},_0x2321c0,_0x58d7ab['options']);var _0x47fdb6={'where':_0x2321c0['where']};return db['FreshdeskConfiguration']['count'](_0x47fdb6)['then'](function(_0x48aa43){_0x40976c[_0x4951('0x1b')]=_0x48aa43;if(_0x58d7ab['query']['includeAll']){_0x2321c0[_0x4951('0x39')]=[{'all':!![]}];}return db[_0x4951('0x27')][_0x4951('0x3a')](_0x2321c0);})[_0x4951('0x20')](function(_0xc023ad){_0x40976c[_0x4951('0x3b')]=_0xc023ad;return _0x40976c;})[_0x4951('0x20')](respondWithFilteredResult(_0x1c04a9,_0x2321c0))['catch'](handleError(_0x1c04a9,null));};exports[_0x4951('0x3c')]=function(_0x21af43,_0x38e4b8){var _0x45a15e={'raw':![],'where':{'id':_0x21af43[_0x4951('0x3d')]['id']}},_0x1009e1={};_0x1009e1[_0x4951('0x2b')]=_[_0x4951('0x2d')](db[_0x4951('0x27')][_0x4951('0x3e')]);_0x1009e1[_0x4951('0x2c')]=_['keys'](_0x21af43[_0x4951('0x2c')]);_0x1009e1[_0x4951('0x35')]=_['intersection'](_0x1009e1[_0x4951('0x2b')],_0x1009e1[_0x4951('0x2c')]);_0x45a15e['attributes']=_[_0x4951('0x2e')](_0x1009e1['model'],qs[_0x4951('0x3f')](_0x21af43[_0x4951('0x2c')][_0x4951('0x3f')]));_0x45a15e[_0x4951('0x2f')]=_0x45a15e['attributes'][_0x4951('0x30')]?_0x45a15e[_0x4951('0x2f')]:_0x1009e1[_0x4951('0x2b')];if(_0x21af43[_0x4951('0x2c')][_0x4951('0x40')]){_0x45a15e[_0x4951('0x39')]=[{'all':!![]}];}_0x45a15e=_[_0x4951('0x37')]({},_0x45a15e,_0x21af43[_0x4951('0x41')]);return db['FreshdeskConfiguration'][_0x4951('0x42')](_0x45a15e)[_0x4951('0x20')](handleEntityNotFound(_0x38e4b8,null))[_0x4951('0x20')](respondWithResult(_0x38e4b8,null))[_0x4951('0x43')](handleError(_0x38e4b8,null));};exports[_0x4951('0x44')]=function(_0x186430,_0x154c5c){return db[_0x4951('0x27')][_0x4951('0x44')](_0x186430[_0x4951('0x45')],{})[_0x4951('0x20')](respondWithResult(_0x154c5c,0xc9))[_0x4951('0x43')](handleError(_0x154c5c,null));};exports[_0x4951('0x46')]=function(_0x1019fc,_0x301b18){if(_0x1019fc['body']['id']){delete _0x1019fc['body']['id'];}return db[_0x4951('0x27')][_0x4951('0x42')]({'where':{'id':_0x1019fc[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x301b18,null))[_0x4951('0x20')](saveUpdates(_0x1019fc['body'],null))[_0x4951('0x20')](respondWithResult(_0x301b18,null))['catch'](handleError(_0x301b18,null));};exports['destroy']=function(_0x2352ad,_0xa0c8ed){return db['FreshdeskConfiguration']['find']({'where':{'id':_0x2352ad[_0x4951('0x3d')]['id']}})['then'](handleEntityNotFound(_0xa0c8ed,null))[_0x4951('0x20')](removeEntity(_0xa0c8ed,null))[_0x4951('0x43')](handleError(_0xa0c8ed,null));};exports['getFields']=function(_0x3cefe4,_0x499776,_0x24f97d){var _0x41e84c={};var _0x4e4ba3={};var _0x3ab91c;var _0x3370e9;return db[_0x4951('0x27')][_0x4951('0x47')]({'where':{'id':_0x3cefe4[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x499776,null))['then'](function(_0x444ab0){if(_0x444ab0){_0x3ab91c=_0x444ab0;_0x4e4ba3['model']=_[_0x4951('0x2d')](db[_0x4951('0x48')]['rawAttributes']);_0x4e4ba3['query']=_[_0x4951('0x2d')](_0x3cefe4['query']);_0x4e4ba3[_0x4951('0x35')]=_[_0x4951('0x2e')](_0x4e4ba3[_0x4951('0x2b')],_0x4e4ba3['query']);_0x41e84c[_0x4951('0x2f')]=_[_0x4951('0x2e')](_0x4e4ba3[_0x4951('0x2b')],qs[_0x4951('0x3f')](_0x3cefe4[_0x4951('0x2c')][_0x4951('0x3f')]));_0x41e84c[_0x4951('0x2f')]=_0x41e84c['attributes'][_0x4951('0x30')]?_0x41e84c['attributes']:_0x4e4ba3[_0x4951('0x2b')];_0x41e84c[_0x4951('0x49')]=qs[_0x4951('0x33')](_0x3cefe4[_0x4951('0x2c')][_0x4951('0x33')]);_0x41e84c['where']=qs['filters'](_[_0x4951('0x4a')](_0x3cefe4[_0x4951('0x2c')],_0x4e4ba3[_0x4951('0x35')]));if(_0x3cefe4[_0x4951('0x2c')][_0x4951('0x36')]){_0x41e84c[_0x4951('0x34')]=_[_0x4951('0x37')](_0x41e84c[_0x4951('0x34')],{'$or':_[_0x4951('0x26')](_0x41e84c[_0x4951('0x2f')],function(_0x1e1a94){var _0x1c47b7={};_0x1c47b7[_0x1e1a94]={'$like':'%'+_0x3cefe4[_0x4951('0x2c')][_0x4951('0x36')]+'%'};return _0x1c47b7;})});}_0x41e84c=_[_0x4951('0x37')]({},_0x41e84c,_0x3cefe4[_0x4951('0x41')]);return _0x3ab91c[_0x4951('0x4b')](_0x41e84c);}})[_0x4951('0x20')](function(_0x2a685f){if(_0x2a685f){_0x3370e9=_0x2a685f[_0x4951('0x30')];if(!_0x3cefe4[_0x4951('0x2c')]['hasOwnProperty'](_0x4951('0x32'))){_0x41e84c[_0x4951('0x1a')]=qs[_0x4951('0x1a')](_0x3cefe4[_0x4951('0x2c')]['limit']);_0x41e84c[_0x4951('0x19')]=qs[_0x4951('0x19')](_0x3cefe4[_0x4951('0x2c')]['offset']);}return _0x3ab91c[_0x4951('0x4b')](_0x41e84c);}})[_0x4951('0x20')](function(_0x11991d){if(_0x11991d){return _0x11991d?{'count':_0x3370e9,'rows':_0x11991d}:null;}})[_0x4951('0x20')](respondWithResult(_0x499776,null))['catch'](handleError(_0x499776,null));};exports[_0x4951('0x4c')]=function(_0x479337,_0x32dea6,_0x5a6dc2){var _0x59c1fc={};var _0x81d39a={};var _0x22ddcd;var _0x41b19f;return db[_0x4951('0x27')][_0x4951('0x47')]({'where':{'id':_0x479337[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x32dea6,null))[_0x4951('0x20')](function(_0x3df2da){if(_0x3df2da){_0x22ddcd=_0x3df2da;_0x81d39a['model']=_[_0x4951('0x2d')](db[_0x4951('0x48')][_0x4951('0x3e')]);_0x81d39a[_0x4951('0x2c')]=_[_0x4951('0x2d')](_0x479337[_0x4951('0x2c')]);_0x81d39a['filters']=_[_0x4951('0x2e')](_0x81d39a[_0x4951('0x2b')],_0x81d39a[_0x4951('0x2c')]);_0x59c1fc[_0x4951('0x2f')]=_[_0x4951('0x2e')](_0x81d39a['model'],qs[_0x4951('0x3f')](_0x479337['query']['fields']));_0x59c1fc['attributes']=_0x59c1fc[_0x4951('0x2f')][_0x4951('0x30')]?_0x59c1fc[_0x4951('0x2f')]:_0x81d39a['model'];_0x59c1fc[_0x4951('0x49')]=qs[_0x4951('0x33')](_0x479337[_0x4951('0x2c')][_0x4951('0x33')]);_0x59c1fc[_0x4951('0x34')]=qs[_0x4951('0x35')](_[_0x4951('0x4a')](_0x479337[_0x4951('0x2c')],_0x81d39a[_0x4951('0x35')]));if(_0x479337[_0x4951('0x2c')][_0x4951('0x36')]){_0x59c1fc['where']=_['merge'](_0x59c1fc['where'],{'$or':_[_0x4951('0x26')](_0x59c1fc[_0x4951('0x2f')],function(_0x5dc4a8){var _0x3d8cd7={};_0x3d8cd7[_0x5dc4a8]={'$like':'%'+_0x479337[_0x4951('0x2c')][_0x4951('0x36')]+'%'};return _0x3d8cd7;})});}_0x59c1fc=_[_0x4951('0x37')]({},_0x59c1fc,_0x479337[_0x4951('0x41')]);return _0x22ddcd['getSubjects'](_0x59c1fc);}})[_0x4951('0x20')](function(_0x38c01b){if(_0x38c01b){_0x41b19f=_0x38c01b[_0x4951('0x30')];if(!_0x479337['query'][_0x4951('0x31')](_0x4951('0x32'))){_0x59c1fc['limit']=qs[_0x4951('0x1a')](_0x479337[_0x4951('0x2c')][_0x4951('0x1a')]);_0x59c1fc[_0x4951('0x19')]=qs['offset'](_0x479337['query'][_0x4951('0x19')]);}return _0x22ddcd[_0x4951('0x4c')](_0x59c1fc);}})['then'](function(_0x5dda6a){if(_0x5dda6a){return _0x5dda6a?{'count':_0x41b19f,'rows':_0x5dda6a}:null;}})['then'](respondWithResult(_0x32dea6,null))['catch'](handleError(_0x32dea6,null));};exports[_0x4951('0x4d')]=function(_0x464549,_0x8d6581,_0x336484){var _0x33c3b2={};var _0x4cbeb5={};var _0x4bb39a;var _0x5c7809;return db[_0x4951('0x27')][_0x4951('0x47')]({'where':{'id':_0x464549[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x8d6581,null))[_0x4951('0x20')](function(_0x4d0f4){if(_0x4d0f4){_0x4bb39a=_0x4d0f4;_0x4cbeb5[_0x4951('0x2b')]=_[_0x4951('0x2d')](db[_0x4951('0x48')]['rawAttributes']);_0x4cbeb5['query']=_['keys'](_0x464549['query']);_0x4cbeb5[_0x4951('0x35')]=_[_0x4951('0x2e')](_0x4cbeb5['model'],_0x4cbeb5[_0x4951('0x2c')]);_0x33c3b2[_0x4951('0x2f')]=_[_0x4951('0x2e')](_0x4cbeb5[_0x4951('0x2b')],qs[_0x4951('0x3f')](_0x464549[_0x4951('0x2c')]['fields']));_0x33c3b2[_0x4951('0x2f')]=_0x33c3b2[_0x4951('0x2f')]['length']?_0x33c3b2[_0x4951('0x2f')]:_0x4cbeb5[_0x4951('0x2b')];_0x33c3b2[_0x4951('0x49')]=qs[_0x4951('0x33')](_0x464549[_0x4951('0x2c')][_0x4951('0x33')]);_0x33c3b2['where']=qs[_0x4951('0x35')](_['pick'](_0x464549[_0x4951('0x2c')],_0x4cbeb5['filters']));if(_0x464549[_0x4951('0x2c')][_0x4951('0x36')]){_0x33c3b2[_0x4951('0x34')]=_[_0x4951('0x37')](_0x33c3b2['where'],{'$or':_['map'](_0x33c3b2[_0x4951('0x2f')],function(_0x48a15f){var _0x1bcd57={};_0x1bcd57[_0x48a15f]={'$like':'%'+_0x464549[_0x4951('0x2c')][_0x4951('0x36')]+'%'};return _0x1bcd57;})});}_0x33c3b2=_[_0x4951('0x37')]({},_0x33c3b2,_0x464549[_0x4951('0x41')]);return _0x4bb39a[_0x4951('0x4d')](_0x33c3b2);}})[_0x4951('0x20')](function(_0x20dea8){if(_0x20dea8){_0x5c7809=_0x20dea8[_0x4951('0x30')];if(!_0x464549[_0x4951('0x2c')]['hasOwnProperty']('nolimit')){_0x33c3b2[_0x4951('0x1a')]=qs[_0x4951('0x1a')](_0x464549[_0x4951('0x2c')]['limit']);_0x33c3b2['offset']=qs['offset'](_0x464549[_0x4951('0x2c')][_0x4951('0x19')]);}return _0x4bb39a['getDescriptions'](_0x33c3b2);}})[_0x4951('0x20')](function(_0x3f991c){if(_0x3f991c){return _0x3f991c?{'count':_0x5c7809,'rows':_0x3f991c}:null;}})[_0x4951('0x20')](respondWithResult(_0x8d6581,null))[_0x4951('0x43')](handleError(_0x8d6581,null));};exports[_0x4951('0x4e')]=function(_0x23e0a8,_0x3b18e9,_0x1a94f4){var _0x482f4f={};var _0x22eebd={};var _0x3e924f;var _0x30b5f1;return db[_0x4951('0x27')][_0x4951('0x47')]({'where':{'id':_0x23e0a8[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x3b18e9,null))[_0x4951('0x20')](function(_0x3f0b95){if(_0x3f0b95){_0x3e924f=_0x3f0b95;_0x22eebd[_0x4951('0x2b')]=_['keys'](db[_0x4951('0x4f')]['rawAttributes']);_0x22eebd[_0x4951('0x2c')]=_[_0x4951('0x2d')](_0x23e0a8[_0x4951('0x2c')]);_0x22eebd['filters']=_[_0x4951('0x2e')](_0x22eebd['model'],_0x22eebd[_0x4951('0x2c')]);_0x482f4f[_0x4951('0x2f')]=_[_0x4951('0x2e')](_0x22eebd['model'],qs[_0x4951('0x3f')](_0x23e0a8[_0x4951('0x2c')]['fields']));_0x482f4f[_0x4951('0x2f')]=_0x482f4f[_0x4951('0x2f')][_0x4951('0x30')]?_0x482f4f[_0x4951('0x2f')]:_0x22eebd[_0x4951('0x2b')];_0x482f4f['order']=qs['sort'](_0x23e0a8[_0x4951('0x2c')][_0x4951('0x33')]);_0x482f4f[_0x4951('0x34')]=qs['filters'](_[_0x4951('0x4a')](_0x23e0a8[_0x4951('0x2c')],_0x22eebd[_0x4951('0x35')]));if(_0x23e0a8[_0x4951('0x2c')][_0x4951('0x36')]){_0x482f4f['where']=_['merge'](_0x482f4f[_0x4951('0x34')],{'$or':_['map'](_0x482f4f[_0x4951('0x2f')],function(_0x118232){var _0x558a1f={};_0x558a1f[_0x118232]={'$like':'%'+_0x23e0a8[_0x4951('0x2c')]['filter']+'%'};return _0x558a1f;})});}_0x482f4f=_[_0x4951('0x37')]({},_0x482f4f,_0x23e0a8[_0x4951('0x41')]);return _0x3e924f[_0x4951('0x4e')](_0x482f4f);}})['then'](function(_0xe58e89){if(_0xe58e89){_0x30b5f1=_0xe58e89[_0x4951('0x30')];if(!_0x23e0a8[_0x4951('0x2c')][_0x4951('0x31')]('nolimit')){_0x482f4f['limit']=qs[_0x4951('0x1a')](_0x23e0a8[_0x4951('0x2c')]['limit']);_0x482f4f[_0x4951('0x19')]=qs[_0x4951('0x19')](_0x23e0a8['query'][_0x4951('0x19')]);}return _0x3e924f[_0x4951('0x4e')](_0x482f4f);}})[_0x4951('0x20')](function(_0x3402c0){if(_0x3402c0){return _0x3402c0?{'count':_0x30b5f1,'rows':_0x3402c0}:null;}})[_0x4951('0x20')](respondWithResult(_0x3b18e9,null))[_0x4951('0x43')](handleError(_0x3b18e9,null));};exports[_0x4951('0x50')]=function(_0x2d4e18,_0x1d1a12,_0xdc3d8c){if(_0x2d4e18['body']['id']){delete _0x2d4e18[_0x4951('0x45')]['id'];}return db[_0x4951('0x27')]['findOne']({'where':{'id':_0x2d4e18[_0x4951('0x3d')]['id']}})[_0x4951('0x20')](handleEntityNotFound(_0x1d1a12,null))[_0x4951('0x20')](function(_0x4b5cd9){if(_0x4b5cd9){return _0x4b5cd9[_0x4951('0x50')](_0x2d4e18[_0x4951('0x45')][_0x4951('0x51')]||[]);}return null;})[_0x4951('0x20')](respondWithResult(_0x1d1a12,null))[_0x4951('0x43')](handleError(_0x1d1a12,null));}; \ No newline at end of file diff --git a/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.model.js b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.model.js new file mode 100644 index 0000000..9755b24 --- /dev/null +++ b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5498=['bluebird','request-promise','path','rimraf','../../config/environment','./intFreshdeskConfiguration.attributes','define','FreshdeskConfiguration','int_freshdesk_configurations','lodash','util','../../config/logger','api','moment'];(function(_0x5533bc,_0x259123){var _0x5c0c0e=function(_0x49557a){while(--_0x49557a){_0x5533bc['push'](_0x5533bc['shift']());}};_0x5c0c0e(++_0x259123);}(_0x5498,0x1ad));var _0x8549=function(_0x54482d,_0x48e95d){_0x54482d=_0x54482d-0x0;var _0x610d61=_0x5498[_0x54482d];return _0x610d61;};'use strict';var _=require(_0x8549('0x0'));var util=require(_0x8549('0x1'));var logger=require(_0x8549('0x2'))(_0x8549('0x3'));var moment=require(_0x8549('0x4'));var BPromise=require(_0x8549('0x5'));var rp=require(_0x8549('0x6'));var fs=require('fs');var path=require(_0x8549('0x7'));var rimraf=require(_0x8549('0x8'));var config=require(_0x8549('0x9'));var attributes=require(_0x8549('0xa'));module['exports']=function(_0x531c70,_0x8c61a){return _0x531c70[_0x8549('0xb')](_0x8549('0xc'),attributes,{'tableName':_0x8549('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.rpc.js b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.rpc.js new file mode 100644 index 0000000..2a11f4d --- /dev/null +++ b/server/api/intFreshdeskConfiguration/intFreshdeskConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x46ca=['error','code','message','info','result','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','request','then','FreshdeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshdeskConfiguration,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x53f44c,_0x497bdc){var _0x3e8278=function(_0x4d8a93){while(--_0x4d8a93){_0x53f44c['push'](_0x53f44c['shift']());}};_0x3e8278(++_0x497bdc);}(_0x46ca,0x6e));var _0xa46c=function(_0x5c16ad,_0x24312a){_0x5c16ad=_0x5c16ad-0x0;var _0xf9d36e=_0x46ca[_0x5c16ad];return _0xf9d36e;};'use strict';var _=require(_0xa46c('0x0'));var util=require('util');var moment=require(_0xa46c('0x1'));var BPromise=require(_0xa46c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa46c('0x3'));var db=require(_0xa46c('0x4'))['db'];var utils=require(_0xa46c('0x5'));var logger=require(_0xa46c('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0xa46c('0x7'));var client=jayson[_0xa46c('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5c6438,_0x362940,_0x101215){return new BPromise(function(_0x42c85e,_0x54dff2){return client[_0xa46c('0x9')](_0x5c6438,_0x101215)[_0xa46c('0xa')](function(_0x2f40b3){logger['info'](_0xa46c('0xb'),_0x362940,_0xa46c('0xc'));logger[_0xa46c('0xd')](_0xa46c('0xe'),_0x362940,_0xa46c('0xc'),JSON[_0xa46c('0xf')](_0x2f40b3));if(_0x2f40b3[_0xa46c('0x10')]){if(_0x2f40b3[_0xa46c('0x10')][_0xa46c('0x11')]===0x1f4){logger[_0xa46c('0x10')](_0xa46c('0xb'),_0x362940,_0x2f40b3[_0xa46c('0x10')]['message']);return _0x54dff2(_0x2f40b3[_0xa46c('0x10')][_0xa46c('0x12')]);}logger[_0xa46c('0x10')](_0xa46c('0xb'),_0x362940,_0x2f40b3[_0xa46c('0x10')][_0xa46c('0x12')]);return _0x42c85e(_0x2f40b3[_0xa46c('0x10')]['message']);}else{logger[_0xa46c('0x13')](_0xa46c('0xb'),_0x362940,_0xa46c('0xc'));_0x42c85e(_0x2f40b3[_0xa46c('0x14')][_0xa46c('0x12')]);}})['catch'](function(_0x144961){logger[_0xa46c('0x10')](_0xa46c('0xb'),_0x362940,_0x144961);_0x54dff2(_0x144961);});});} \ No newline at end of file diff --git a/server/api/intFreshdeskField/index.js b/server/api/intFreshdeskField/index.js new file mode 100644 index 0000000..3ddfbe1 --- /dev/null +++ b/server/api/intFreshdeskField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xde41=['delete','exports','multer','path','connect-timeout','Router','fs-extra','../../components/auth/service','./intFreshdeskField.controller','get','isAuthenticated','index','/:id','create'];(function(_0x196e6b,_0x5cf260){var _0x3b004f=function(_0x4ac09b){while(--_0x4ac09b){_0x196e6b['push'](_0x196e6b['shift']());}};_0x3b004f(++_0x5cf260);}(_0xde41,0xe2));var _0x1de4=function(_0x1af442,_0x578f22){_0x1af442=_0x1af442-0x0;var _0x1e8244=_0xde41[_0x1af442];return _0x1e8244;};'use strict';var multer=require(_0x1de4('0x0'));var util=require('util');var path=require(_0x1de4('0x1'));var timeout=require(_0x1de4('0x2'));var express=require('express');var router=express[_0x1de4('0x3')]();var fs_extra=require(_0x1de4('0x4'));var auth=require(_0x1de4('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x1de4('0x6'));router[_0x1de4('0x7')]('/',auth[_0x1de4('0x8')](),controller[_0x1de4('0x9')]);router[_0x1de4('0x7')](_0x1de4('0xa'),auth[_0x1de4('0x8')](),controller['show']);router['post']('/',auth[_0x1de4('0x8')](),controller[_0x1de4('0xb')]);router['put']('/:id',auth[_0x1de4('0x8')](),controller['update']);router[_0x1de4('0xc')](_0x1de4('0xa'),auth['isAuthenticated'](),controller['destroy']);module[_0x1de4('0xd')]=router; \ No newline at end of file diff --git a/server/api/intFreshdeskField/intFreshdeskField.attributes.js b/server/api/intFreshdeskField/intFreshdeskField.attributes.js new file mode 100644 index 0000000..bfab2ab --- /dev/null +++ b/server/api/intFreshdeskField/intFreshdeskField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0547=['BOOLEAN','sequelize','exports','ENUM','string','customVariable','keyValue','picklist','STRING','variable'];(function(_0x1b4b23,_0x5dd6d6){var _0x2a325b=function(_0x175462){while(--_0x175462){_0x1b4b23['push'](_0x1b4b23['shift']());}};_0x2a325b(++_0x5dd6d6);}(_0x0547,0x191));var _0x7054=function(_0x57fc56,_0x2b8490){_0x57fc56=_0x57fc56-0x0;var _0x83205b=_0x0547[_0x57fc56];return _0x83205b;};'use strict';var Sequelize=require(_0x7054('0x0'));module[_0x7054('0x1')]={'type':{'type':Sequelize[_0x7054('0x2')](_0x7054('0x3'),'variable',_0x7054('0x4'),_0x7054('0x5'),_0x7054('0x6')),'defaultValue':_0x7054('0x3')},'content':{'type':Sequelize[_0x7054('0x7')]},'key':{'type':Sequelize[_0x7054('0x7')]},'keyType':{'type':Sequelize['ENUM'](_0x7054('0x3'),_0x7054('0x8'),_0x7054('0x4'))},'keyContent':{'type':Sequelize[_0x7054('0x7')]},'idField':{'type':Sequelize[_0x7054('0x7')]},'nameField':{'type':Sequelize[_0x7054('0x7')]},'customField':{'type':Sequelize[_0x7054('0x9')],'defaultValue':!![]},'variableName':{'type':Sequelize[_0x7054('0x7')]}}; \ No newline at end of file diff --git a/server/api/intFreshdeskField/intFreshdeskField.controller.js b/server/api/intFreshdeskField/intFreshdeskField.controller.js new file mode 100644 index 0000000..c3d412e --- /dev/null +++ b/server/api/intFreshdeskField/intFreshdeskField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x04b8=['undefined','count','Content-Range','apply','reject','save','then','destroy','error','name','send','index','map','FreshdeskField','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','type','VIRTUAL','options','include','findAll','rows','catch','show','params','rawAttributes','includeAll','create','body','update','find','rimraf','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','limit'];(function(_0x47745c,_0x1c6c5d){var _0x1ce8cc=function(_0x3e93d5){while(--_0x3e93d5){_0x47745c['push'](_0x47745c['shift']());}};_0x1ce8cc(++_0x1c6c5d);}(_0x04b8,0x159));var _0x804b=function(_0x4ed632,_0x5195a3){_0x4ed632=_0x4ed632-0x0;var _0x3e809e=_0x04b8[_0x4ed632];return _0x3e809e;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x804b('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x804b('0x1'));var rp=require(_0x804b('0x2'));var moment=require('moment');var BPromise=require(_0x804b('0x3'));var Mustache=require(_0x804b('0x4'));var util=require('util');var path=require(_0x804b('0x5'));var sox=require(_0x804b('0x6'));var csv=require(_0x804b('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x804b('0x8'));var _=require(_0x804b('0x9'));var squel=require(_0x804b('0xa'));var crypto=require('crypto');var jsforce=require(_0x804b('0xb'));var deskjs=require(_0x804b('0xc'));var toCsv=require('to-csv');var querystring=require(_0x804b('0xd'));var Papa=require(_0x804b('0xe'));var Redis=require(_0x804b('0xf'));var authService=require(_0x804b('0x10'));var qs=require(_0x804b('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x804b('0x12'));var logger=require(_0x804b('0x13'))(_0x804b('0x14'));var utils=require(_0x804b('0x15'));var config=require(_0x804b('0x16'));var licenseUtil=require(_0x804b('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x15a4eb,_0x5303cc){_0x5303cc=_0x5303cc||0xcc;return function(_0x23ee57){if(_0x23ee57){return _0x15a4eb[_0x804b('0x18')](_0x5303cc);}return _0x15a4eb[_0x804b('0x19')](_0x5303cc)[_0x804b('0x1a')]();};}function respondWithResult(_0x581fbf,_0x215825){_0x215825=_0x215825||0xc8;return function(_0x1b01a7){if(_0x1b01a7){return _0x581fbf[_0x804b('0x19')](_0x215825)[_0x804b('0x1b')](_0x1b01a7);}};}function respondWithFilteredResult(_0x4ff1be,_0x2fd593){return function(_0x8ccbe0){if(_0x8ccbe0){var _0x5e1cfe=typeof _0x2fd593[_0x804b('0x1c')]==='undefined'&&typeof _0x2fd593[_0x804b('0x1d')]===_0x804b('0x1e');var _0x13662e=_0x8ccbe0[_0x804b('0x1f')];var _0x3a05c0=_0x5e1cfe?0x0:_0x2fd593['offset'];var _0x871d6c=_0x5e1cfe?_0x8ccbe0['count']:_0x2fd593[_0x804b('0x1c')]+_0x2fd593[_0x804b('0x1d')];var _0x42cceb;if(_0x871d6c>=_0x13662e){_0x871d6c=_0x13662e;_0x42cceb=0xc8;}else{_0x42cceb=0xce;}_0x4ff1be[_0x804b('0x19')](_0x42cceb);return _0x4ff1be['set'](_0x804b('0x20'),_0x3a05c0+'-'+_0x871d6c+'/'+_0x13662e)[_0x804b('0x1b')](_0x8ccbe0);}return null;};}function patchUpdates(_0x427166){return function(_0x11eaf6){try{jsonpatch[_0x804b('0x21')](_0x11eaf6,_0x427166,!![]);}catch(_0x267878){return BPromise[_0x804b('0x22')](_0x267878);}return _0x11eaf6[_0x804b('0x23')]();};}function saveUpdates(_0xaa9521,_0x2b7271){return function(_0x1acc48){if(_0x1acc48){return _0x1acc48['update'](_0xaa9521)[_0x804b('0x24')](function(_0x5a77e0){return _0x5a77e0;});}return null;};}function removeEntity(_0x5585f8,_0x44a921){return function(_0x367024){if(_0x367024){return _0x367024[_0x804b('0x25')]()[_0x804b('0x24')](function(){_0x5585f8[_0x804b('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2de812,_0x7d9c33){return function(_0x4e7266){if(!_0x4e7266){_0x2de812[_0x804b('0x18')](0x194);}return _0x4e7266;};}function handleError(_0x2366b6,_0x1117a5){_0x1117a5=_0x1117a5||0x1f4;return function(_0x27d5ec){logger[_0x804b('0x26')](_0x27d5ec['stack']);if(_0x27d5ec[_0x804b('0x27')]){delete _0x27d5ec[_0x804b('0x27')];}_0x2366b6[_0x804b('0x19')](_0x1117a5)[_0x804b('0x28')](_0x27d5ec);};}exports[_0x804b('0x29')]=function(_0x4a6079,_0x3eb531){var _0x2931ff={},_0x410871={},_0x5c7026={'count':0x0,'rows':[]};var _0x3dbd41=_[_0x804b('0x2a')](db[_0x804b('0x2b')]['rawAttributes'],function(_0x408857){return{'name':_0x408857[_0x804b('0x2c')],'type':_0x408857['type'][_0x804b('0x2d')]};});_0x410871[_0x804b('0x2e')]=_[_0x804b('0x2a')](_0x3dbd41,_0x804b('0x27'));_0x410871[_0x804b('0x2f')]=_[_0x804b('0x30')](_0x4a6079['query']);_0x410871[_0x804b('0x31')]=_[_0x804b('0x32')](_0x410871[_0x804b('0x2e')],_0x410871[_0x804b('0x2f')]);_0x2931ff[_0x804b('0x33')]=_[_0x804b('0x32')](_0x410871[_0x804b('0x2e')],qs[_0x804b('0x34')](_0x4a6079[_0x804b('0x2f')][_0x804b('0x34')]));_0x2931ff[_0x804b('0x33')]=_0x2931ff[_0x804b('0x33')][_0x804b('0x35')]?_0x2931ff[_0x804b('0x33')]:_0x410871[_0x804b('0x2e')];if(!_0x4a6079[_0x804b('0x2f')][_0x804b('0x36')](_0x804b('0x37'))){_0x2931ff[_0x804b('0x1d')]=qs[_0x804b('0x1d')](_0x4a6079[_0x804b('0x2f')][_0x804b('0x1d')]);_0x2931ff[_0x804b('0x1c')]=qs[_0x804b('0x1c')](_0x4a6079[_0x804b('0x2f')]['offset']);}_0x2931ff['order']=qs['sort'](_0x4a6079[_0x804b('0x2f')][_0x804b('0x38')]);_0x2931ff[_0x804b('0x39')]=qs['filters'](_['pick'](_0x4a6079['query'],_0x410871[_0x804b('0x31')]),_0x3dbd41);if(_0x4a6079[_0x804b('0x2f')][_0x804b('0x3a')]){_0x2931ff[_0x804b('0x39')]=_[_0x804b('0x3b')](_0x2931ff[_0x804b('0x39')],{'$or':_[_0x804b('0x2a')](_0x3dbd41,function(_0xc5eefa){if(_0xc5eefa[_0x804b('0x3c')]!==_0x804b('0x3d')){var _0x878dac={};_0x878dac[_0xc5eefa[_0x804b('0x27')]]={'$like':'%'+_0x4a6079[_0x804b('0x2f')]['filter']+'%'};return _0x878dac;}})});}_0x2931ff=_[_0x804b('0x3b')]({},_0x2931ff,_0x4a6079[_0x804b('0x3e')]);var _0xb877d6={'where':_0x2931ff[_0x804b('0x39')]};return db[_0x804b('0x2b')]['count'](_0xb877d6)['then'](function(_0x203890){_0x5c7026[_0x804b('0x1f')]=_0x203890;if(_0x4a6079[_0x804b('0x2f')]['includeAll']){_0x2931ff[_0x804b('0x3f')]=[{'all':!![]}];}return db['FreshdeskField'][_0x804b('0x40')](_0x2931ff);})[_0x804b('0x24')](function(_0x20ccc7){_0x5c7026[_0x804b('0x41')]=_0x20ccc7;return _0x5c7026;})[_0x804b('0x24')](respondWithFilteredResult(_0x3eb531,_0x2931ff))[_0x804b('0x42')](handleError(_0x3eb531,null));};exports[_0x804b('0x43')]=function(_0x51c8ff,_0x17972a){var _0x1c0363={'raw':!![],'where':{'id':_0x51c8ff[_0x804b('0x44')]['id']}},_0x1dcec8={};_0x1dcec8['model']=_[_0x804b('0x30')](db[_0x804b('0x2b')][_0x804b('0x45')]);_0x1dcec8[_0x804b('0x2f')]=_[_0x804b('0x30')](_0x51c8ff[_0x804b('0x2f')]);_0x1dcec8[_0x804b('0x31')]=_[_0x804b('0x32')](_0x1dcec8['model'],_0x1dcec8[_0x804b('0x2f')]);_0x1c0363['attributes']=_['intersection'](_0x1dcec8['model'],qs[_0x804b('0x34')](_0x51c8ff['query'][_0x804b('0x34')]));_0x1c0363[_0x804b('0x33')]=_0x1c0363[_0x804b('0x33')][_0x804b('0x35')]?_0x1c0363['attributes']:_0x1dcec8[_0x804b('0x2e')];if(_0x51c8ff[_0x804b('0x2f')][_0x804b('0x46')]){_0x1c0363['include']=[{'all':!![]}];}_0x1c0363=_[_0x804b('0x3b')]({},_0x1c0363,_0x51c8ff[_0x804b('0x3e')]);return db[_0x804b('0x2b')]['find'](_0x1c0363)[_0x804b('0x24')](handleEntityNotFound(_0x17972a,null))[_0x804b('0x24')](respondWithResult(_0x17972a,null))[_0x804b('0x42')](handleError(_0x17972a,null));};exports[_0x804b('0x47')]=function(_0x1051e9,_0x3a39f5){return db[_0x804b('0x2b')][_0x804b('0x47')](_0x1051e9[_0x804b('0x48')],{})[_0x804b('0x24')](respondWithResult(_0x3a39f5,0xc9))[_0x804b('0x42')](handleError(_0x3a39f5,null));};exports[_0x804b('0x49')]=function(_0x20862f,_0x2c1796){if(_0x20862f['body']['id']){delete _0x20862f['body']['id'];}return db[_0x804b('0x2b')][_0x804b('0x4a')]({'where':{'id':_0x20862f[_0x804b('0x44')]['id']}})[_0x804b('0x24')](handleEntityNotFound(_0x2c1796,null))[_0x804b('0x24')](saveUpdates(_0x20862f['body'],null))[_0x804b('0x24')](respondWithResult(_0x2c1796,null))[_0x804b('0x42')](handleError(_0x2c1796,null));};exports[_0x804b('0x25')]=function(_0x3ca9ff,_0x47247c){return db[_0x804b('0x2b')]['find']({'where':{'id':_0x3ca9ff['params']['id']}})[_0x804b('0x24')](handleEntityNotFound(_0x47247c,null))[_0x804b('0x24')](removeEntity(_0x47247c,null))['catch'](handleError(_0x47247c,null));}; \ No newline at end of file diff --git a/server/api/intFreshdeskField/intFreshdeskField.model.js b/server/api/intFreshdeskField/intFreshdeskField.model.js new file mode 100644 index 0000000..fb7323a --- /dev/null +++ b/server/api/intFreshdeskField/intFreshdeskField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8d5b=['rimraf','../../config/environment','./intFreshdeskField.attributes','FreshdeskField','int_freshdesk_fields','freshdesk_unique_index','FieldId','lodash','api','moment','bluebird','path'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x8d5b,0x19f));var _0xb8d5=function(_0x5311a1,_0x304912){_0x5311a1=_0x5311a1-0x0;var _0x2acb9f=_0x8d5b[_0x5311a1];return _0x2acb9f;};'use strict';var _=require(_0xb8d5('0x0'));var util=require('util');var logger=require('../../config/logger')(_0xb8d5('0x1'));var moment=require(_0xb8d5('0x2'));var BPromise=require(_0xb8d5('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xb8d5('0x4'));var rimraf=require(_0xb8d5('0x5'));var config=require(_0xb8d5('0x6'));var attributes=require(_0xb8d5('0x7'));module['exports']=function(_0x5eb975,_0x3a841b){return _0x5eb975['define'](_0xb8d5('0x8'),attributes,{'tableName':_0xb8d5('0x9'),'paranoid':![],'indexes':[{'name':_0xb8d5('0xa'),'fields':['idField',_0xb8d5('0xb')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshdeskField/intFreshdeskField.rpc.js b/server/api/intFreshdeskField/intFreshdeskField.rpc.js new file mode 100644 index 0000000..6e96a0c --- /dev/null +++ b/server/api/intFreshdeskField/intFreshdeskField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6501=['request\x20sent','FreshdeskField,\x20%s,\x20%s,\x20%s','stringify','error','code','FreshdeskField,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','then','info'];(function(_0xb30a60,_0x19580f){var _0x381a7b=function(_0x27f846){while(--_0x27f846){_0xb30a60['push'](_0xb30a60['shift']());}};_0x381a7b(++_0x19580f);}(_0x6501,0x179));var _0x1650=function(_0x2ba540,_0x38dc1f){_0x2ba540=_0x2ba540-0x0;var _0x1d611f=_0x6501[_0x2ba540];return _0x1d611f;};'use strict';var _=require(_0x1650('0x0'));var util=require(_0x1650('0x1'));var moment=require(_0x1650('0x2'));var BPromise=require(_0x1650('0x3'));var rs=require(_0x1650('0x4'));var fs=require('fs');var Redis=require(_0x1650('0x5'));var db=require(_0x1650('0x6'))['db'];var utils=require(_0x1650('0x7'));var logger=require(_0x1650('0x8'))(_0x1650('0x9'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x1650('0xa')][_0x1650('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4713cc,_0x31f411,_0xa309f2){return new BPromise(function(_0x86612e,_0x4f1505){return client['request'](_0x4713cc,_0xa309f2)[_0x1650('0xc')](function(_0x348397){logger[_0x1650('0xd')]('FreshdeskField,\x20%s,\x20%s',_0x31f411,_0x1650('0xe'));logger['debug'](_0x1650('0xf'),_0x31f411,_0x1650('0xe'),JSON[_0x1650('0x10')](_0x348397));if(_0x348397[_0x1650('0x11')]){if(_0x348397[_0x1650('0x11')][_0x1650('0x12')]===0x1f4){logger['error'](_0x1650('0x13'),_0x31f411,_0x348397['error'][_0x1650('0x14')]);return _0x4f1505(_0x348397[_0x1650('0x11')][_0x1650('0x14')]);}logger['error'](_0x1650('0x13'),_0x31f411,_0x348397[_0x1650('0x11')][_0x1650('0x14')]);return _0x86612e(_0x348397['error']['message']);}else{logger[_0x1650('0xd')](_0x1650('0x13'),_0x31f411,'request\x20sent');_0x86612e(_0x348397[_0x1650('0x15')][_0x1650('0x14')]);}})[_0x1650('0x16')](function(_0x2dbd13){logger['error']('FreshdeskField,\x20%s,\x20%s',_0x31f411,_0x2dbd13);_0x4f1505(_0x2dbd13);});});} \ No newline at end of file diff --git a/server/api/intFreshsalesAccount/index.js b/server/api/intFreshsalesAccount/index.js new file mode 100644 index 0000000..be79d4f --- /dev/null +++ b/server/api/intFreshsalesAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2547=['addConfiguration','update','delete','destroy','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./intFreshsalesAccount.controller','get','isAuthenticated','index','/:id','show','/:id/configurations','/:id/fields','getFields','post','create'];(function(_0x1b4076,_0x48a507){var _0x1458d4=function(_0x4cbf89){while(--_0x4cbf89){_0x1b4076['push'](_0x1b4076['shift']());}};_0x1458d4(++_0x48a507);}(_0x2547,0x1cd));var _0x7254=function(_0x4fec5c,_0x2e3d55){_0x4fec5c=_0x4fec5c-0x0;var _0x336d9c=_0x2547[_0x4fec5c];return _0x336d9c;};'use strict';var multer=require('multer');var util=require(_0x7254('0x0'));var path=require(_0x7254('0x1'));var timeout=require(_0x7254('0x2'));var express=require(_0x7254('0x3'));var router=express[_0x7254('0x4')]();var fs_extra=require(_0x7254('0x5'));var auth=require(_0x7254('0x6'));var interaction=require(_0x7254('0x7'));var config=require('../../config/environment');var controller=require(_0x7254('0x8'));router[_0x7254('0x9')]('/',auth[_0x7254('0xa')](),controller[_0x7254('0xb')]);router['get'](_0x7254('0xc'),auth[_0x7254('0xa')](),controller[_0x7254('0xd')]);router['get'](_0x7254('0xe'),auth['isAuthenticated'](),controller['getConfigurations']);router['get'](_0x7254('0xf'),auth[_0x7254('0xa')](),controller[_0x7254('0x10')]);router[_0x7254('0x11')]('/',auth[_0x7254('0xa')](),controller[_0x7254('0x12')]);router['post'](_0x7254('0xe'),auth['isAuthenticated'](),controller[_0x7254('0x13')]);router['put'](_0x7254('0xc'),auth[_0x7254('0xa')](),controller[_0x7254('0x14')]);router[_0x7254('0x15')](_0x7254('0xc'),auth[_0x7254('0xa')](),controller[_0x7254('0x16')]);module[_0x7254('0x17')]=router; \ No newline at end of file diff --git a/server/api/intFreshsalesAccount/intFreshsalesAccount.attributes.js b/server/api/intFreshsalesAccount/intFreshsalesAccount.attributes.js new file mode 100644 index 0000000..b9b89d9 --- /dev/null +++ b/server/api/intFreshsalesAccount/intFreshsalesAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7096=['exports','STRING','username','remoteUri'];(function(_0xaf3f37,_0x9c7557){var _0x39966a=function(_0x2442fa){while(--_0x2442fa){_0xaf3f37['push'](_0xaf3f37['shift']());}};_0x39966a(++_0x9c7557);}(_0x7096,0x10c));var _0x6709=function(_0x5b561d,_0x422b7c){_0x5b561d=_0x5b561d-0x0;var _0x431060=_0x7096[_0x5b561d];return _0x431060;};'use strict';var Sequelize=require('sequelize');module[_0x6709('0x0')]={'name':{'type':Sequelize['STRING']},'description':{'type':Sequelize[_0x6709('0x1')]},'username':{'type':Sequelize['STRING'],'unique':_0x6709('0x2')},'apiKey':{'type':Sequelize[_0x6709('0x1')]},'remoteUri':{'type':Sequelize[_0x6709('0x1')],'unique':_0x6709('0x3')},'serverUrl':{'type':Sequelize[_0x6709('0x1')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/intFreshsalesAccount/intFreshsalesAccount.controller.js b/server/api/intFreshsalesAccount/intFreshsalesAccount.controller.js new file mode 100644 index 0000000..f7c38be --- /dev/null +++ b/server/api/intFreshsalesAccount/intFreshsalesAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8ea0=['VIRTUAL','options','includeAll','include','findAll','rows','catch','show','keys','intersection','find','update','body','params','getConfigurations','findOne','FreshsalesConfiguration','filter','addConfiguration','AccountId','getSubjects','Descriptions','channel','FreshsalesField','getFields','username','remoteUri','apiKey','substring','lastIndexOf','format','%s%s','/api/selector/owners','Token\x20token=','users','email','Requested\x20Resource\x20not\x20Found','test','statusCode','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','reject','save','then','destroy','error','name','send','index','map','FreshsalesAccount','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge'];(function(_0x2fb25f,_0x19f264){var _0x2a2ccd=function(_0x270ee9){while(--_0x270ee9){_0x2fb25f['push'](_0x2fb25f['shift']());}};_0x2a2ccd(++_0x19f264);}(_0x8ea0,0xf5));var _0x08ea=function(_0x26b947,_0x561f91){_0x26b947=_0x26b947-0x0;var _0x4fb87a=_0x8ea0[_0x26b947];return _0x4fb87a;};'use strict';var emlformat=require(_0x08ea('0x0'));var rimraf=require(_0x08ea('0x1'));var zipdir=require(_0x08ea('0x2'));var jsonpatch=require(_0x08ea('0x3'));var rp=require('request-promise');var moment=require(_0x08ea('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x08ea('0x5'));var util=require(_0x08ea('0x6'));var path=require(_0x08ea('0x7'));var sox=require(_0x08ea('0x8'));var csv=require(_0x08ea('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x08ea('0xa'));var _=require(_0x08ea('0xb'));var squel=require(_0x08ea('0xc'));var crypto=require(_0x08ea('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x08ea('0xe'));var toCsv=require('to-csv');var querystring=require(_0x08ea('0xf'));var Papa=require('papaparse');var Redis=require(_0x08ea('0x10'));var authService=require(_0x08ea('0x11'));var qs=require(_0x08ea('0x12'));var as=require(_0x08ea('0x13'));var hardwareService=require(_0x08ea('0x14'));var logger=require(_0x08ea('0x15'))(_0x08ea('0x16'));var utils=require('../../config/utils');var config=require(_0x08ea('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x08ea('0x18'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x2b0dd3,_0x4860af){_0x4860af=_0x4860af||0xcc;return function(_0x1d3604){if(_0x1d3604){return _0x2b0dd3[_0x08ea('0x19')](_0x4860af);}return _0x2b0dd3[_0x08ea('0x1a')](_0x4860af)[_0x08ea('0x1b')]();};}function respondWithResult(_0x53453a,_0x178e12){_0x178e12=_0x178e12||0xc8;return function(_0x50c186){if(_0x50c186){return _0x53453a['status'](_0x178e12)[_0x08ea('0x1c')](_0x50c186);}};}function respondWithFilteredResult(_0x43b3d5,_0x70c6d9){return function(_0x5ca343){if(_0x5ca343){var _0x2455bd=typeof _0x70c6d9[_0x08ea('0x1d')]===_0x08ea('0x1e')&&typeof _0x70c6d9['limit']==='undefined';var _0x245022=_0x5ca343[_0x08ea('0x1f')];var _0xff5145=_0x2455bd?0x0:_0x70c6d9[_0x08ea('0x1d')];var _0x1884b5=_0x2455bd?_0x5ca343[_0x08ea('0x1f')]:_0x70c6d9[_0x08ea('0x1d')]+_0x70c6d9[_0x08ea('0x20')];var _0x581caf;if(_0x1884b5>=_0x245022){_0x1884b5=_0x245022;_0x581caf=0xc8;}else{_0x581caf=0xce;}_0x43b3d5['status'](_0x581caf);return _0x43b3d5[_0x08ea('0x21')]('Content-Range',_0xff5145+'-'+_0x1884b5+'/'+_0x245022)[_0x08ea('0x1c')](_0x5ca343);}return null;};}function patchUpdates(_0x383c6b){return function(_0x1fbc74){try{jsonpatch['apply'](_0x1fbc74,_0x383c6b,!![]);}catch(_0x11776e){return BPromise[_0x08ea('0x22')](_0x11776e);}return _0x1fbc74[_0x08ea('0x23')]();};}function saveUpdates(_0x4cf1b8,_0x5b3281){return function(_0x38f762){if(_0x38f762){return _0x38f762['update'](_0x4cf1b8)[_0x08ea('0x24')](function(_0x11f252){return _0x11f252;});}return null;};}function removeEntity(_0x5260bc,_0x23ab6e){return function(_0x37da2a){if(_0x37da2a){return _0x37da2a[_0x08ea('0x25')]()[_0x08ea('0x24')](function(){_0x5260bc['status'](0xcc)[_0x08ea('0x1b')]();});}};}function handleEntityNotFound(_0x8fc50,_0x265187){return function(_0xab63f7){if(!_0xab63f7){_0x8fc50[_0x08ea('0x19')](0x194);}return _0xab63f7;};}function handleError(_0x50bf0d,_0x28d88a){_0x28d88a=_0x28d88a||0x1f4;return function(_0x38871f){logger[_0x08ea('0x26')](_0x38871f['stack']);if(_0x38871f[_0x08ea('0x27')]){delete _0x38871f[_0x08ea('0x27')];}_0x50bf0d[_0x08ea('0x1a')](_0x28d88a)[_0x08ea('0x28')](_0x38871f);};}exports[_0x08ea('0x29')]=function(_0x45a899,_0xb8aab4){var _0x2408a1={},_0x374211={},_0x4d5b1e={'count':0x0,'rows':[]};var _0x174de9=_[_0x08ea('0x2a')](db[_0x08ea('0x2b')][_0x08ea('0x2c')],function(_0x1e450e){return{'name':_0x1e450e[_0x08ea('0x2d')],'type':_0x1e450e[_0x08ea('0x2e')][_0x08ea('0x2f')]};});_0x374211[_0x08ea('0x30')]=_[_0x08ea('0x2a')](_0x174de9,'name');_0x374211[_0x08ea('0x31')]=_['keys'](_0x45a899[_0x08ea('0x31')]);_0x374211[_0x08ea('0x32')]=_['intersection'](_0x374211[_0x08ea('0x30')],_0x374211[_0x08ea('0x31')]);_0x2408a1[_0x08ea('0x33')]=_['intersection'](_0x374211[_0x08ea('0x30')],qs[_0x08ea('0x34')](_0x45a899[_0x08ea('0x31')][_0x08ea('0x34')]));_0x2408a1[_0x08ea('0x33')]=_0x2408a1[_0x08ea('0x33')][_0x08ea('0x35')]?_0x2408a1[_0x08ea('0x33')]:_0x374211['model'];if(!_0x45a899['query'][_0x08ea('0x36')](_0x08ea('0x37'))){_0x2408a1[_0x08ea('0x20')]=qs[_0x08ea('0x20')](_0x45a899[_0x08ea('0x31')][_0x08ea('0x20')]);_0x2408a1['offset']=qs[_0x08ea('0x1d')](_0x45a899['query']['offset']);}_0x2408a1[_0x08ea('0x38')]=qs['sort'](_0x45a899[_0x08ea('0x31')][_0x08ea('0x39')]);_0x2408a1[_0x08ea('0x3a')]=qs[_0x08ea('0x32')](_[_0x08ea('0x3b')](_0x45a899['query'],_0x374211[_0x08ea('0x32')]),_0x174de9);if(_0x45a899[_0x08ea('0x31')]['filter']){_0x2408a1[_0x08ea('0x3a')]=_[_0x08ea('0x3c')](_0x2408a1[_0x08ea('0x3a')],{'$or':_['map'](_0x174de9,function(_0x567831){if(_0x567831[_0x08ea('0x2e')]!==_0x08ea('0x3d')){var _0x28fd67={};_0x28fd67[_0x567831[_0x08ea('0x27')]]={'$like':'%'+_0x45a899[_0x08ea('0x31')]['filter']+'%'};return _0x28fd67;}})});}_0x2408a1=_[_0x08ea('0x3c')]({},_0x2408a1,_0x45a899[_0x08ea('0x3e')]);var _0x129bea={'where':_0x2408a1[_0x08ea('0x3a')]};return db[_0x08ea('0x2b')][_0x08ea('0x1f')](_0x129bea)[_0x08ea('0x24')](function(_0x4f20b7){_0x4d5b1e['count']=_0x4f20b7;if(_0x45a899[_0x08ea('0x31')][_0x08ea('0x3f')]){_0x2408a1[_0x08ea('0x40')]=[{'all':!![]}];}return db['FreshsalesAccount'][_0x08ea('0x41')](_0x2408a1);})[_0x08ea('0x24')](function(_0x4e110a){_0x4d5b1e[_0x08ea('0x42')]=_0x4e110a;return _0x4d5b1e;})[_0x08ea('0x24')](respondWithFilteredResult(_0xb8aab4,_0x2408a1))[_0x08ea('0x43')](handleError(_0xb8aab4,null));};exports[_0x08ea('0x44')]=function(_0x546713,_0x13a33e){var _0x2112d3={'raw':![],'where':{'id':_0x546713['params']['id']}},_0x55d687={};_0x55d687[_0x08ea('0x30')]=_[_0x08ea('0x45')](db[_0x08ea('0x2b')]['rawAttributes']);_0x55d687[_0x08ea('0x31')]=_[_0x08ea('0x45')](_0x546713['query']);_0x55d687[_0x08ea('0x32')]=_[_0x08ea('0x46')](_0x55d687[_0x08ea('0x30')],_0x55d687[_0x08ea('0x31')]);_0x2112d3[_0x08ea('0x33')]=_[_0x08ea('0x46')](_0x55d687[_0x08ea('0x30')],qs[_0x08ea('0x34')](_0x546713['query']['fields']));_0x2112d3[_0x08ea('0x33')]=_0x2112d3['attributes']['length']?_0x2112d3[_0x08ea('0x33')]:_0x55d687[_0x08ea('0x30')];if(_0x546713[_0x08ea('0x31')][_0x08ea('0x3f')]){_0x2112d3[_0x08ea('0x40')]=[{'all':!![]}];}_0x2112d3=_[_0x08ea('0x3c')]({},_0x2112d3,_0x546713[_0x08ea('0x3e')]);return db['FreshsalesAccount'][_0x08ea('0x47')](_0x2112d3)[_0x08ea('0x24')](handleEntityNotFound(_0x13a33e,null))[_0x08ea('0x24')](respondWithResult(_0x13a33e,null))[_0x08ea('0x43')](handleError(_0x13a33e,null));};exports['create']=function(_0x514f77,_0xc0d0aa){return db[_0x08ea('0x2b')]['create'](_0x514f77['body'],{})['then'](respondWithResult(_0xc0d0aa,0xc9))[_0x08ea('0x43')](handleError(_0xc0d0aa,null));};exports[_0x08ea('0x48')]=function(_0x20158d,_0x55577e){if(_0x20158d[_0x08ea('0x49')]['id']){delete _0x20158d['body']['id'];}return db[_0x08ea('0x2b')]['find']({'where':{'id':_0x20158d[_0x08ea('0x4a')]['id']}})[_0x08ea('0x24')](handleEntityNotFound(_0x55577e,null))['then'](saveUpdates(_0x20158d[_0x08ea('0x49')],null))[_0x08ea('0x24')](respondWithResult(_0x55577e,null))['catch'](handleError(_0x55577e,null));};exports[_0x08ea('0x25')]=function(_0x5119bc,_0x219c97){return db[_0x08ea('0x2b')]['find']({'where':{'id':_0x5119bc[_0x08ea('0x4a')]['id']}})['then'](handleEntityNotFound(_0x219c97,null))[_0x08ea('0x24')](removeEntity(_0x219c97,null))[_0x08ea('0x43')](handleError(_0x219c97,null));};exports[_0x08ea('0x4b')]=function(_0x237688,_0x55c31c,_0x324cd6){var _0xe322ea={};var _0x420007={};var _0x305442;var _0x3bf410;return db[_0x08ea('0x2b')][_0x08ea('0x4c')]({'where':{'id':_0x237688[_0x08ea('0x4a')]['id']}})[_0x08ea('0x24')](handleEntityNotFound(_0x55c31c,null))[_0x08ea('0x24')](function(_0x4e3099){if(_0x4e3099){_0x305442=_0x4e3099;_0x420007['model']=_[_0x08ea('0x45')](db[_0x08ea('0x4d')][_0x08ea('0x2c')]);_0x420007['query']=_[_0x08ea('0x45')](_0x237688[_0x08ea('0x31')]);_0x420007[_0x08ea('0x32')]=_[_0x08ea('0x46')](_0x420007[_0x08ea('0x30')],_0x420007[_0x08ea('0x31')]);_0xe322ea['attributes']=_['intersection'](_0x420007[_0x08ea('0x30')],qs[_0x08ea('0x34')](_0x237688[_0x08ea('0x31')][_0x08ea('0x34')]));_0xe322ea[_0x08ea('0x33')]=_0xe322ea['attributes'][_0x08ea('0x35')]?_0xe322ea['attributes']:_0x420007[_0x08ea('0x30')];_0xe322ea['order']=qs[_0x08ea('0x39')](_0x237688[_0x08ea('0x31')][_0x08ea('0x39')]);_0xe322ea['where']=qs[_0x08ea('0x32')](_[_0x08ea('0x3b')](_0x237688[_0x08ea('0x31')],_0x420007['filters']));if(_0x237688['query'][_0x08ea('0x4e')]){_0xe322ea[_0x08ea('0x3a')]=_[_0x08ea('0x3c')](_0xe322ea[_0x08ea('0x3a')],{'$or':_['map'](_0xe322ea[_0x08ea('0x33')],function(_0x4ea71f){var _0x401be2={};_0x401be2[_0x4ea71f]={'$like':'%'+_0x237688['query'][_0x08ea('0x4e')]+'%'};return _0x401be2;})});}_0xe322ea=_[_0x08ea('0x3c')]({},_0xe322ea,_0x237688['options']);return _0x305442['getConfigurations'](_0xe322ea);}})['then'](function(_0x5e410f){if(_0x5e410f){_0x3bf410=_0x5e410f[_0x08ea('0x35')];if(!_0x237688[_0x08ea('0x31')][_0x08ea('0x36')](_0x08ea('0x37'))){_0xe322ea['limit']=qs[_0x08ea('0x20')](_0x237688[_0x08ea('0x31')]['limit']);_0xe322ea['offset']=qs[_0x08ea('0x1d')](_0x237688[_0x08ea('0x31')][_0x08ea('0x1d')]);}return _0x305442[_0x08ea('0x4b')](_0xe322ea);}})[_0x08ea('0x24')](function(_0x45508b){if(_0x45508b){return _0x45508b?{'count':_0x3bf410,'rows':_0x45508b}:null;}})[_0x08ea('0x24')](respondWithResult(_0x55c31c,null))[_0x08ea('0x43')](handleError(_0x55c31c,null));};exports[_0x08ea('0x4f')]=function(_0x12c035,_0x262073,_0x29024b){if(_0x12c035[_0x08ea('0x49')]['id']){delete _0x12c035[_0x08ea('0x49')]['id'];}return db[_0x08ea('0x2b')][_0x08ea('0x4c')]({'where':{'id':_0x12c035[_0x08ea('0x4a')]['id']}})[_0x08ea('0x24')](handleEntityNotFound(_0x262073,null))['then'](function(_0x58fb99){if(_0x58fb99){_0x12c035[_0x08ea('0x49')][_0x08ea('0x50')]=_0x58fb99['id'];_0x12c035[_0x08ea('0x49')]['Subjects']=integrations[_0x08ea('0x51')](_0x12c035['body']['channel'],_0x12c035[_0x08ea('0x49')][_0x08ea('0x2e')]);_0x12c035[_0x08ea('0x49')][_0x08ea('0x52')]=integrations['getDescriptions'](_0x12c035['body'][_0x08ea('0x53')],_0x12c035[_0x08ea('0x49')][_0x08ea('0x2e')]);return db[_0x08ea('0x4d')]['create'](_0x12c035[_0x08ea('0x49')],{'include':[{'model':db[_0x08ea('0x54')],'as':'Subjects'},{'model':db[_0x08ea('0x54')],'as':_0x08ea('0x52')}]});}return null;})[_0x08ea('0x24')](respondWithResult(_0x262073,null))[_0x08ea('0x43')](handleError(_0x262073,null));};exports[_0x08ea('0x55')]=function(_0x4d01d9,_0x32f79c,_0x7b63bb){var _0x44f30a='';var _0x3ea6dd='';return db[_0x08ea('0x2b')]['findOne']({'where':{'id':_0x4d01d9[_0x08ea('0x4a')]['id']},'attributes':['id',_0x08ea('0x56'),_0x08ea('0x57'),_0x08ea('0x58')]})[_0x08ea('0x24')](handleEntityNotFound(_0x32f79c,null))[_0x08ea('0x24')](function(_0x4e27d4){if(_0x4e27d4){_0x3ea6dd=_0x4e27d4['username'];_0x44f30a=_0x4e27d4['remoteUri'];var _0x6f8811=_0x4e27d4['remoteUri']['slice'](-0x1);if(_0x6f8811==='/'){_0x44f30a=_0x44f30a[_0x08ea('0x59')](0x0,_0x44f30a[_0x08ea('0x5a')](_0x6f8811));}return rp({'method':'GET','uri':util[_0x08ea('0x5b')](_0x08ea('0x5c'),_0x44f30a,_0x08ea('0x5d')),'headers':{'Authorization':_0x08ea('0x5e')+_0x4e27d4[_0x08ea('0x58')]},'json':!![]});}})[_0x08ea('0x24')](function(_0x286448){if(_0x286448){var _0x1095ed=_0x286448[_0x08ea('0x5f')];var _0x1d8b06=![];var _0x1b26dc=null;for(_0x1b26dc=0x0;_0x1b26dc<_0x1095ed['length'];_0x1b26dc++){if(_0x1095ed[_0x1b26dc][_0x08ea('0x60')]===_0x3ea6dd){_0x1d8b06=!![];}}if(_0x1d8b06){return!![];}else{throw new Error({'statusCode':0x194,'message':_0x08ea('0x61')});}}})[_0x08ea('0x24')](respondWithResult(_0x32f79c,null))[_0x08ea('0x43')](function(_0xd2b61){var _0x526c2d=_0x4d01d9[_0x08ea('0x31')][_0x08ea('0x62')]?0x1f4:_0xd2b61[_0x08ea('0x63')]||0x1f4;logger[_0x08ea('0x26')]('getFields,\x20%s,\x20%s,\x20%s',_0x08ea('0x55'),_0x526c2d,JSON[_0x08ea('0x64')](_0xd2b61));delete _0xd2b61[_0x08ea('0x27')];if(_0x526c2d===0x191){_0x526c2d=0x190;}_0x32f79c['status'](_0x526c2d)[_0x08ea('0x28')](_0x4d01d9['query'][_0x08ea('0x62')]?{'message':_0x08ea('0x65'),'statusCode':_0xd2b61[_0x08ea('0x63')]}:_0xd2b61);});}; \ No newline at end of file diff --git a/server/api/intFreshsalesAccount/intFreshsalesAccount.model.js b/server/api/intFreshsalesAccount/intFreshsalesAccount.model.js new file mode 100644 index 0000000..57e8e8e --- /dev/null +++ b/server/api/intFreshsalesAccount/intFreshsalesAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0120=['../../config/environment','./intFreshsalesAccount.attributes','../../components/integrations/configuration','define','FreshsalesAccount','int_freshsales_accounts','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf'];(function(_0x15c550,_0x171e41){var _0x512ab4=function(_0x277ad4){while(--_0x277ad4){_0x15c550['push'](_0x15c550['shift']());}};_0x512ab4(++_0x171e41);}(_0x0120,0x6f));var _0x0012=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x0120[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x0012('0x0'));var util=require(_0x0012('0x1'));var logger=require(_0x0012('0x2'))(_0x0012('0x3'));var moment=require(_0x0012('0x4'));var BPromise=require(_0x0012('0x5'));var rp=require(_0x0012('0x6'));var fs=require('fs');var path=require(_0x0012('0x7'));var rimraf=require(_0x0012('0x8'));var config=require(_0x0012('0x9'));var attributes=require(_0x0012('0xa'));var integrations=require(_0x0012('0xb'));module['exports']=function(_0x4b396c,_0x59980a){return _0x4b396c[_0x0012('0xc')](_0x0012('0xd'),attributes,{'tableName':_0x0012('0xe'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshsalesAccount/intFreshsalesAccount.rpc.js b/server/api/intFreshsalesAccount/intFreshsalesAccount.rpc.js new file mode 100644 index 0000000..a266ebd --- /dev/null +++ b/server/api/intFreshsalesAccount/intFreshsalesAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1623=['../../mysqldb','../../config/utils','../../config/environment','client','http','request','then','info','debug','FreshsalesAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','FreshsalesAccount,\x20%s,\x20%s','message','result','catch','GetFreshsalesAccount','FreshsalesAccount','findAll','options','raw','where','limit','include','map','model','attributes','find','ShowFreshsalesAccount','lodash','bluebird','randomstring','ioredis'];(function(_0x39096d,_0x51f8a0){var _0x13da4f=function(_0x11e6b2){while(--_0x11e6b2){_0x39096d['push'](_0x39096d['shift']());}};_0x13da4f(++_0x51f8a0);}(_0x1623,0xab));var _0x3162=function(_0x53326c,_0x47cda1){_0x53326c=_0x53326c-0x0;var _0x471fd3=_0x1623[_0x53326c];return _0x471fd3;};'use strict';var _=require(_0x3162('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x3162('0x1'));var rs=require(_0x3162('0x2'));var fs=require('fs');var Redis=require(_0x3162('0x3'));var db=require(_0x3162('0x4'))['db'];var utils=require(_0x3162('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x3162('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x3162('0x7')][_0x3162('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x53260d,_0xffe9b6,_0x2dc07e){return new BPromise(function(_0x26ee32,_0x36609e){return client[_0x3162('0x9')](_0x53260d,_0x2dc07e)[_0x3162('0xa')](function(_0xe43099){logger[_0x3162('0xb')]('FreshsalesAccount,\x20%s,\x20%s',_0xffe9b6,'request\x20sent');logger[_0x3162('0xc')](_0x3162('0xd'),_0xffe9b6,_0x3162('0xe'),JSON[_0x3162('0xf')](_0xe43099));if(_0xe43099[_0x3162('0x10')]){if(_0xe43099[_0x3162('0x10')][_0x3162('0x11')]===0x1f4){logger[_0x3162('0x10')](_0x3162('0x12'),_0xffe9b6,_0xe43099['error'][_0x3162('0x13')]);return _0x36609e(_0xe43099['error'][_0x3162('0x13')]);}logger[_0x3162('0x10')]('FreshsalesAccount,\x20%s,\x20%s',_0xffe9b6,_0xe43099['error'][_0x3162('0x13')]);return _0x26ee32(_0xe43099[_0x3162('0x10')][_0x3162('0x13')]);}else{logger['info'](_0x3162('0x12'),_0xffe9b6,_0x3162('0xe'));_0x26ee32(_0xe43099[_0x3162('0x14')]['message']);}})[_0x3162('0x15')](function(_0x42cf7d){logger[_0x3162('0x10')](_0x3162('0x12'),_0xffe9b6,_0x42cf7d);_0x36609e(_0x42cf7d);});});}exports[_0x3162('0x16')]=function(_0x1eed46){var _0x391d97=this;return new Promise(function(_0x4b2bf3,_0x42f283){return db[_0x3162('0x17')][_0x3162('0x18')]({'raw':_0x1eed46[_0x3162('0x19')]?_0x1eed46['options'][_0x3162('0x1a')]===undefined?!![]:![]:!![],'where':_0x1eed46['options']?_0x1eed46['options'][_0x3162('0x1b')]||null:null,'attributes':_0x1eed46[_0x3162('0x19')]?_0x1eed46[_0x3162('0x19')]['attributes']||null:null,'limit':_0x1eed46['options']?_0x1eed46[_0x3162('0x19')][_0x3162('0x1c')]||null:null,'include':_0x1eed46[_0x3162('0x19')]?_0x1eed46[_0x3162('0x19')][_0x3162('0x1d')]?_[_0x3162('0x1e')](_0x1eed46[_0x3162('0x19')][_0x3162('0x1d')],function(_0x5a4994){return{'model':db[_0x5a4994[_0x3162('0x1f')]],'as':_0x5a4994['as'],'attributes':_0x5a4994[_0x3162('0x20')],'include':_0x5a4994[_0x3162('0x1d')]?_[_0x3162('0x1e')](_0x5a4994[_0x3162('0x1d')],function(_0x3c543e){return{'model':db[_0x3c543e[_0x3162('0x1f')]],'as':_0x3c543e['as'],'attributes':_0x3c543e[_0x3162('0x20')],'include':_0x3c543e[_0x3162('0x1d')]?_[_0x3162('0x1e')](_0x3c543e[_0x3162('0x1d')],function(_0x2f62d7){return{'model':db[_0x2f62d7[_0x3162('0x1f')]],'as':_0x2f62d7['as'],'attributes':_0x2f62d7['attributes']};}):[]};}):[]};}):[]:[]})[_0x3162('0xa')](function(_0x552469){logger[_0x3162('0xb')](_0x3162('0x16'),_0x1eed46);logger[_0x3162('0xc')]('GetFreshsalesAccount',_0x1eed46,JSON['stringify'](_0x552469));_0x4b2bf3(_0x552469);})[_0x3162('0x15')](function(_0xaa1f35){logger[_0x3162('0x10')](_0x3162('0x16'),_0xaa1f35[_0x3162('0x13')],_0x1eed46);_0x42f283(_0x391d97['error'](0x1f4,_0xaa1f35[_0x3162('0x13')]));});});};exports['ShowFreshsalesAccount']=function(_0xf11765){var _0x3a188e=this;return new Promise(function(_0x41e933,_0x221b38){return db[_0x3162('0x17')][_0x3162('0x21')]({'raw':_0xf11765[_0x3162('0x19')]?_0xf11765[_0x3162('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0xf11765[_0x3162('0x19')]?_0xf11765[_0x3162('0x19')]['where']||null:null,'attributes':_0xf11765[_0x3162('0x19')]?_0xf11765[_0x3162('0x19')]['attributes']||null:null,'include':_0xf11765['options']?_0xf11765[_0x3162('0x19')]['include']?_[_0x3162('0x1e')](_0xf11765[_0x3162('0x19')][_0x3162('0x1d')],function(_0x551442){return{'model':db[_0x551442['model']],'as':_0x551442['as'],'attributes':_0x551442[_0x3162('0x20')],'include':_0x551442[_0x3162('0x1d')]?_['map'](_0x551442[_0x3162('0x1d')],function(_0x4d4f74){return{'model':db[_0x4d4f74[_0x3162('0x1f')]],'as':_0x4d4f74['as'],'attributes':_0x4d4f74[_0x3162('0x20')],'include':_0x4d4f74[_0x3162('0x1d')]?_[_0x3162('0x1e')](_0x4d4f74[_0x3162('0x1d')],function(_0x3b6c91){return{'model':db[_0x3b6c91[_0x3162('0x1f')]],'as':_0x3b6c91['as'],'attributes':_0x3b6c91[_0x3162('0x20')]};}):[]};}):[]};}):[]:[]})[_0x3162('0xa')](function(_0x16c5d6){logger[_0x3162('0xb')]('ShowFreshsalesAccount',_0xf11765);logger[_0x3162('0xc')](_0x3162('0x22'),_0xf11765,JSON[_0x3162('0xf')](_0x16c5d6));_0x41e933(_0x16c5d6);})['catch'](function(_0x59759d){logger[_0x3162('0x10')](_0x3162('0x22'),_0x59759d[_0x3162('0x13')],_0xf11765);_0x221b38(_0x3a188e[_0x3162('0x10')](0x1f4,_0x59759d['message']));});});}; \ No newline at end of file diff --git a/server/api/intFreshsalesConfiguration/index.js b/server/api/intFreshsalesConfiguration/index.js new file mode 100644 index 0000000..8f7511e --- /dev/null +++ b/server/api/intFreshsalesConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4a3a=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intFreshsalesConfiguration.controller','isAuthenticated','index','get','/:id','show','getSubjects','/:id/descriptions','getDescriptions','/:id/fields','getFields','create','delete','destroy','exports','multer','util','connect-timeout','express'];(function(_0x5418e8,_0xb90ac){var _0x3e3481=function(_0x10deb2){while(--_0x10deb2){_0x5418e8['push'](_0x5418e8['shift']());}};_0x3e3481(++_0xb90ac);}(_0x4a3a,0x1c4));var _0xa4a3=function(_0x345be3,_0x140abd){_0x345be3=_0x345be3-0x0;var _0x43efcb=_0x4a3a[_0x345be3];return _0x43efcb;};'use strict';var multer=require(_0xa4a3('0x0'));var util=require(_0xa4a3('0x1'));var path=require('path');var timeout=require(_0xa4a3('0x2'));var express=require(_0xa4a3('0x3'));var router=express[_0xa4a3('0x4')]();var fs_extra=require(_0xa4a3('0x5'));var auth=require(_0xa4a3('0x6'));var interaction=require(_0xa4a3('0x7'));var config=require(_0xa4a3('0x8'));var controller=require(_0xa4a3('0x9'));router['get']('/',auth[_0xa4a3('0xa')](),controller[_0xa4a3('0xb')]);router[_0xa4a3('0xc')](_0xa4a3('0xd'),auth[_0xa4a3('0xa')](),controller[_0xa4a3('0xe')]);router[_0xa4a3('0xc')]('/:id/subjects',auth[_0xa4a3('0xa')](),controller[_0xa4a3('0xf')]);router['get'](_0xa4a3('0x10'),auth[_0xa4a3('0xa')](),controller[_0xa4a3('0x11')]);router[_0xa4a3('0xc')](_0xa4a3('0x12'),auth['isAuthenticated'](),controller[_0xa4a3('0x13')]);router['post']('/',auth[_0xa4a3('0xa')](),controller[_0xa4a3('0x14')]);router['put'](_0xa4a3('0xd'),auth[_0xa4a3('0xa')](),controller['update']);router[_0xa4a3('0x15')](_0xa4a3('0xd'),auth['isAuthenticated'](),controller[_0xa4a3('0x16')]);module[_0xa4a3('0x17')]=router; \ No newline at end of file diff --git a/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.attributes.js b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.attributes.js new file mode 100644 index 0000000..612b6e6 --- /dev/null +++ b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe775=['sequelize','exports','STRING'];(function(_0x1ee119,_0x51fd98){var _0x4c8234=function(_0x20355c){while(--_0x20355c){_0x1ee119['push'](_0x1ee119['shift']());}};_0x4c8234(++_0x51fd98);}(_0xe775,0x17a));var _0x5e77=function(_0x1b1a3b,_0x52a88a){_0x1b1a3b=_0x1b1a3b-0x0;var _0x385347=_0xe775[_0x1b1a3b];return _0x385347;};'use strict';var Sequelize=require(_0x5e77('0x0'));module[_0x5e77('0x1')]={'name':{'type':Sequelize[_0x5e77('0x2')]},'description':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.controller.js b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.controller.js new file mode 100644 index 0000000..17de4be --- /dev/null +++ b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe2d8=['where','filter','merge','map','options','includeAll','include','findAll','catch','show','params','keys','find','create','body','getSubjects','FreshsalesField','getDescriptions','findOne','pick','getFields','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','end','undefined','limit','count','offset','Content-Range','json','save','update','then','destroy','error','stack','name','send','index','FreshsalesConfiguration','rawAttributes','type','key','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort'];(function(_0x2421e3,_0x15e64a){var _0x514927=function(_0x3345ff){while(--_0x3345ff){_0x2421e3['push'](_0x2421e3['shift']());}};_0x514927(++_0x15e64a);}(_0xe2d8,0x102));var _0x8e2d=function(_0xf979e6,_0x1cb147){_0xf979e6=_0xf979e6-0x0;var _0x59217d=_0xe2d8[_0xf979e6];return _0x59217d;};'use strict';var emlformat=require(_0x8e2d('0x0'));var rimraf=require(_0x8e2d('0x1'));var zipdir=require(_0x8e2d('0x2'));var jsonpatch=require(_0x8e2d('0x3'));var rp=require(_0x8e2d('0x4'));var moment=require(_0x8e2d('0x5'));var BPromise=require(_0x8e2d('0x6'));var Mustache=require(_0x8e2d('0x7'));var util=require(_0x8e2d('0x8'));var path=require(_0x8e2d('0x9'));var sox=require('sox');var csv=require(_0x8e2d('0xa'));var ejs=require(_0x8e2d('0xb'));var fs=require('fs');var fs_extra=require(_0x8e2d('0xc'));var _=require(_0x8e2d('0xd'));var squel=require(_0x8e2d('0xe'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x8e2d('0xf'));var toCsv=require('to-csv');var querystring=require(_0x8e2d('0x10'));var Papa=require('papaparse');var Redis=require(_0x8e2d('0x11'));var authService=require(_0x8e2d('0x12'));var qs=require(_0x8e2d('0x13'));var as=require(_0x8e2d('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8e2d('0x15'))(_0x8e2d('0x16'));var utils=require(_0x8e2d('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x8e2d('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x104de7,_0x38a6d6){_0x38a6d6=_0x38a6d6||0xcc;return function(_0x58016d){if(_0x58016d){return _0x104de7[_0x8e2d('0x19')](_0x38a6d6);}return _0x104de7[_0x8e2d('0x1a')](_0x38a6d6)[_0x8e2d('0x1b')]();};}function respondWithResult(_0x20e850,_0x99ca8f){_0x99ca8f=_0x99ca8f||0xc8;return function(_0x4cd6b6){if(_0x4cd6b6){return _0x20e850[_0x8e2d('0x1a')](_0x99ca8f)['json'](_0x4cd6b6);}};}function respondWithFilteredResult(_0x5ef38f,_0x19fcfa){return function(_0x1ba081){if(_0x1ba081){var _0x51cbd9=typeof _0x19fcfa['offset']===_0x8e2d('0x1c')&&typeof _0x19fcfa[_0x8e2d('0x1d')]===_0x8e2d('0x1c');var _0x1869e3=_0x1ba081[_0x8e2d('0x1e')];var _0x26007f=_0x51cbd9?0x0:_0x19fcfa[_0x8e2d('0x1f')];var _0x1aeb23=_0x51cbd9?_0x1ba081[_0x8e2d('0x1e')]:_0x19fcfa['offset']+_0x19fcfa['limit'];var _0x448276;if(_0x1aeb23>=_0x1869e3){_0x1aeb23=_0x1869e3;_0x448276=0xc8;}else{_0x448276=0xce;}_0x5ef38f[_0x8e2d('0x1a')](_0x448276);return _0x5ef38f['set'](_0x8e2d('0x20'),_0x26007f+'-'+_0x1aeb23+'/'+_0x1869e3)[_0x8e2d('0x21')](_0x1ba081);}return null;};}function patchUpdates(_0x21dab1){return function(_0x2ff3dd){try{jsonpatch['apply'](_0x2ff3dd,_0x21dab1,!![]);}catch(_0x495c43){return BPromise['reject'](_0x495c43);}return _0x2ff3dd[_0x8e2d('0x22')]();};}function saveUpdates(_0x4fec9f,_0x21a2fe){return function(_0x1a1eaf){if(_0x1a1eaf){return _0x1a1eaf[_0x8e2d('0x23')](_0x4fec9f)[_0x8e2d('0x24')](function(_0xf1f680){return _0xf1f680;});}return null;};}function removeEntity(_0x7cc37b,_0x29111c){return function(_0x106360){if(_0x106360){return _0x106360[_0x8e2d('0x25')]()[_0x8e2d('0x24')](function(){_0x7cc37b[_0x8e2d('0x1a')](0xcc)[_0x8e2d('0x1b')]();});}};}function handleEntityNotFound(_0x99f422,_0x56a513){return function(_0x3540f8){if(!_0x3540f8){_0x99f422['sendStatus'](0x194);}return _0x3540f8;};}function handleError(_0x287b71,_0x265775){_0x265775=_0x265775||0x1f4;return function(_0x526239){logger[_0x8e2d('0x26')](_0x526239[_0x8e2d('0x27')]);if(_0x526239[_0x8e2d('0x28')]){delete _0x526239[_0x8e2d('0x28')];}_0x287b71[_0x8e2d('0x1a')](_0x265775)[_0x8e2d('0x29')](_0x526239);};}exports[_0x8e2d('0x2a')]=function(_0x58ab0a,_0xed8778){var _0x1dc49e={},_0x169023={},_0x6bd692={'count':0x0,'rows':[]};var _0x4f54cf=_['map'](db[_0x8e2d('0x2b')][_0x8e2d('0x2c')],function(_0x57161b){return{'name':_0x57161b['fieldName'],'type':_0x57161b[_0x8e2d('0x2d')][_0x8e2d('0x2e')]};});_0x169023[_0x8e2d('0x2f')]=_['map'](_0x4f54cf,_0x8e2d('0x28'));_0x169023[_0x8e2d('0x30')]=_['keys'](_0x58ab0a['query']);_0x169023[_0x8e2d('0x31')]=_['intersection'](_0x169023[_0x8e2d('0x2f')],_0x169023[_0x8e2d('0x30')]);_0x1dc49e[_0x8e2d('0x32')]=_[_0x8e2d('0x33')](_0x169023[_0x8e2d('0x2f')],qs[_0x8e2d('0x34')](_0x58ab0a['query'][_0x8e2d('0x34')]));_0x1dc49e['attributes']=_0x1dc49e[_0x8e2d('0x32')][_0x8e2d('0x35')]?_0x1dc49e['attributes']:_0x169023[_0x8e2d('0x2f')];if(!_0x58ab0a[_0x8e2d('0x30')][_0x8e2d('0x36')](_0x8e2d('0x37'))){_0x1dc49e['limit']=qs['limit'](_0x58ab0a[_0x8e2d('0x30')]['limit']);_0x1dc49e[_0x8e2d('0x1f')]=qs[_0x8e2d('0x1f')](_0x58ab0a[_0x8e2d('0x30')]['offset']);}_0x1dc49e[_0x8e2d('0x38')]=qs[_0x8e2d('0x39')](_0x58ab0a[_0x8e2d('0x30')][_0x8e2d('0x39')]);_0x1dc49e[_0x8e2d('0x3a')]=qs[_0x8e2d('0x31')](_['pick'](_0x58ab0a[_0x8e2d('0x30')],_0x169023[_0x8e2d('0x31')]),_0x4f54cf);if(_0x58ab0a[_0x8e2d('0x30')][_0x8e2d('0x3b')]){_0x1dc49e['where']=_[_0x8e2d('0x3c')](_0x1dc49e[_0x8e2d('0x3a')],{'$or':_[_0x8e2d('0x3d')](_0x4f54cf,function(_0x71eb3c){if(_0x71eb3c[_0x8e2d('0x2d')]!=='VIRTUAL'){var _0x4187ee={};_0x4187ee[_0x71eb3c[_0x8e2d('0x28')]]={'$like':'%'+_0x58ab0a[_0x8e2d('0x30')][_0x8e2d('0x3b')]+'%'};return _0x4187ee;}})});}_0x1dc49e=_[_0x8e2d('0x3c')]({},_0x1dc49e,_0x58ab0a[_0x8e2d('0x3e')]);var _0x1cef14={'where':_0x1dc49e[_0x8e2d('0x3a')]};return db[_0x8e2d('0x2b')][_0x8e2d('0x1e')](_0x1cef14)[_0x8e2d('0x24')](function(_0x509d62){_0x6bd692[_0x8e2d('0x1e')]=_0x509d62;if(_0x58ab0a[_0x8e2d('0x30')][_0x8e2d('0x3f')]){_0x1dc49e[_0x8e2d('0x40')]=[{'all':!![]}];}return db[_0x8e2d('0x2b')][_0x8e2d('0x41')](_0x1dc49e);})[_0x8e2d('0x24')](function(_0x45cc74){_0x6bd692['rows']=_0x45cc74;return _0x6bd692;})[_0x8e2d('0x24')](respondWithFilteredResult(_0xed8778,_0x1dc49e))[_0x8e2d('0x42')](handleError(_0xed8778,null));};exports[_0x8e2d('0x43')]=function(_0x3c4061,_0x4ffb59){var _0x3ba365={'raw':![],'where':{'id':_0x3c4061[_0x8e2d('0x44')]['id']}},_0x3c9d34={};_0x3c9d34[_0x8e2d('0x2f')]=_['keys'](db[_0x8e2d('0x2b')][_0x8e2d('0x2c')]);_0x3c9d34['query']=_[_0x8e2d('0x45')](_0x3c4061[_0x8e2d('0x30')]);_0x3c9d34[_0x8e2d('0x31')]=_[_0x8e2d('0x33')](_0x3c9d34['model'],_0x3c9d34[_0x8e2d('0x30')]);_0x3ba365[_0x8e2d('0x32')]=_[_0x8e2d('0x33')](_0x3c9d34['model'],qs[_0x8e2d('0x34')](_0x3c4061[_0x8e2d('0x30')][_0x8e2d('0x34')]));_0x3ba365['attributes']=_0x3ba365[_0x8e2d('0x32')][_0x8e2d('0x35')]?_0x3ba365['attributes']:_0x3c9d34[_0x8e2d('0x2f')];if(_0x3c4061[_0x8e2d('0x30')][_0x8e2d('0x3f')]){_0x3ba365[_0x8e2d('0x40')]=[{'all':!![]}];}_0x3ba365=_[_0x8e2d('0x3c')]({},_0x3ba365,_0x3c4061[_0x8e2d('0x3e')]);return db[_0x8e2d('0x2b')][_0x8e2d('0x46')](_0x3ba365)['then'](handleEntityNotFound(_0x4ffb59,null))[_0x8e2d('0x24')](respondWithResult(_0x4ffb59,null))[_0x8e2d('0x42')](handleError(_0x4ffb59,null));};exports['create']=function(_0x1b99ac,_0x1a74be){return db['FreshsalesConfiguration'][_0x8e2d('0x47')](_0x1b99ac[_0x8e2d('0x48')],{})['then'](respondWithResult(_0x1a74be,0xc9))['catch'](handleError(_0x1a74be,null));};exports[_0x8e2d('0x23')]=function(_0x3efb92,_0x12b457){if(_0x3efb92[_0x8e2d('0x48')]['id']){delete _0x3efb92['body']['id'];}return db[_0x8e2d('0x2b')][_0x8e2d('0x46')]({'where':{'id':_0x3efb92['params']['id']}})[_0x8e2d('0x24')](handleEntityNotFound(_0x12b457,null))[_0x8e2d('0x24')](saveUpdates(_0x3efb92[_0x8e2d('0x48')],null))[_0x8e2d('0x24')](respondWithResult(_0x12b457,null))[_0x8e2d('0x42')](handleError(_0x12b457,null));};exports['destroy']=function(_0x5aa057,_0x2d1a13){return db[_0x8e2d('0x2b')][_0x8e2d('0x46')]({'where':{'id':_0x5aa057['params']['id']}})['then'](handleEntityNotFound(_0x2d1a13,null))['then'](removeEntity(_0x2d1a13,null))[_0x8e2d('0x42')](handleError(_0x2d1a13,null));};exports[_0x8e2d('0x49')]=function(_0xcdd6f7,_0x2abb90,_0x19de84){var _0x319695={};var _0x34c26d={};var _0x162e89;var _0x4ae713;return db['FreshsalesConfiguration']['findOne']({'where':{'id':_0xcdd6f7[_0x8e2d('0x44')]['id']}})[_0x8e2d('0x24')](handleEntityNotFound(_0x2abb90,null))[_0x8e2d('0x24')](function(_0x5b044b){if(_0x5b044b){_0x162e89=_0x5b044b;_0x34c26d['model']=_[_0x8e2d('0x45')](db[_0x8e2d('0x4a')][_0x8e2d('0x2c')]);_0x34c26d[_0x8e2d('0x30')]=_['keys'](_0xcdd6f7[_0x8e2d('0x30')]);_0x34c26d['filters']=_[_0x8e2d('0x33')](_0x34c26d[_0x8e2d('0x2f')],_0x34c26d['query']);_0x319695[_0x8e2d('0x32')]=_[_0x8e2d('0x33')](_0x34c26d[_0x8e2d('0x2f')],qs[_0x8e2d('0x34')](_0xcdd6f7[_0x8e2d('0x30')][_0x8e2d('0x34')]));_0x319695[_0x8e2d('0x32')]=_0x319695[_0x8e2d('0x32')][_0x8e2d('0x35')]?_0x319695[_0x8e2d('0x32')]:_0x34c26d['model'];_0x319695[_0x8e2d('0x38')]=qs[_0x8e2d('0x39')](_0xcdd6f7[_0x8e2d('0x30')][_0x8e2d('0x39')]);_0x319695['where']=qs['filters'](_['pick'](_0xcdd6f7[_0x8e2d('0x30')],_0x34c26d['filters']));if(_0xcdd6f7['query'][_0x8e2d('0x3b')]){_0x319695[_0x8e2d('0x3a')]=_[_0x8e2d('0x3c')](_0x319695[_0x8e2d('0x3a')],{'$or':_[_0x8e2d('0x3d')](_0x319695['attributes'],function(_0x222428){var _0x59d0d4={};_0x59d0d4[_0x222428]={'$like':'%'+_0xcdd6f7[_0x8e2d('0x30')][_0x8e2d('0x3b')]+'%'};return _0x59d0d4;})});}_0x319695=_['merge']({},_0x319695,_0xcdd6f7[_0x8e2d('0x3e')]);return _0x162e89[_0x8e2d('0x49')](_0x319695);}})[_0x8e2d('0x24')](function(_0x3904a8){if(_0x3904a8){_0x4ae713=_0x3904a8[_0x8e2d('0x35')];if(!_0xcdd6f7[_0x8e2d('0x30')]['hasOwnProperty']('nolimit')){_0x319695[_0x8e2d('0x1d')]=qs[_0x8e2d('0x1d')](_0xcdd6f7[_0x8e2d('0x30')][_0x8e2d('0x1d')]);_0x319695['offset']=qs[_0x8e2d('0x1f')](_0xcdd6f7[_0x8e2d('0x30')]['offset']);}return _0x162e89[_0x8e2d('0x49')](_0x319695);}})[_0x8e2d('0x24')](function(_0x39e544){if(_0x39e544){return _0x39e544?{'count':_0x4ae713,'rows':_0x39e544}:null;}})['then'](respondWithResult(_0x2abb90,null))['catch'](handleError(_0x2abb90,null));};exports[_0x8e2d('0x4b')]=function(_0x4b77d4,_0x2f8520,_0x2eda07){var _0x2a82cd={};var _0x96de45={};var _0xe1690c;var _0x1144a0;return db[_0x8e2d('0x2b')][_0x8e2d('0x4c')]({'where':{'id':_0x4b77d4[_0x8e2d('0x44')]['id']}})[_0x8e2d('0x24')](handleEntityNotFound(_0x2f8520,null))['then'](function(_0x1be1c2){if(_0x1be1c2){_0xe1690c=_0x1be1c2;_0x96de45['model']=_[_0x8e2d('0x45')](db[_0x8e2d('0x4a')][_0x8e2d('0x2c')]);_0x96de45[_0x8e2d('0x30')]=_['keys'](_0x4b77d4[_0x8e2d('0x30')]);_0x96de45[_0x8e2d('0x31')]=_[_0x8e2d('0x33')](_0x96de45[_0x8e2d('0x2f')],_0x96de45['query']);_0x2a82cd[_0x8e2d('0x32')]=_[_0x8e2d('0x33')](_0x96de45[_0x8e2d('0x2f')],qs[_0x8e2d('0x34')](_0x4b77d4[_0x8e2d('0x30')]['fields']));_0x2a82cd[_0x8e2d('0x32')]=_0x2a82cd[_0x8e2d('0x32')][_0x8e2d('0x35')]?_0x2a82cd['attributes']:_0x96de45[_0x8e2d('0x2f')];_0x2a82cd[_0x8e2d('0x38')]=qs['sort'](_0x4b77d4['query']['sort']);_0x2a82cd['where']=qs['filters'](_[_0x8e2d('0x4d')](_0x4b77d4[_0x8e2d('0x30')],_0x96de45['filters']));if(_0x4b77d4[_0x8e2d('0x30')]['filter']){_0x2a82cd[_0x8e2d('0x3a')]=_[_0x8e2d('0x3c')](_0x2a82cd[_0x8e2d('0x3a')],{'$or':_[_0x8e2d('0x3d')](_0x2a82cd[_0x8e2d('0x32')],function(_0x4b95e){var _0x18785a={};_0x18785a[_0x4b95e]={'$like':'%'+_0x4b77d4[_0x8e2d('0x30')]['filter']+'%'};return _0x18785a;})});}_0x2a82cd=_[_0x8e2d('0x3c')]({},_0x2a82cd,_0x4b77d4[_0x8e2d('0x3e')]);return _0xe1690c[_0x8e2d('0x4b')](_0x2a82cd);}})[_0x8e2d('0x24')](function(_0x5223e6){if(_0x5223e6){_0x1144a0=_0x5223e6['length'];if(!_0x4b77d4['query'][_0x8e2d('0x36')](_0x8e2d('0x37'))){_0x2a82cd[_0x8e2d('0x1d')]=qs[_0x8e2d('0x1d')](_0x4b77d4[_0x8e2d('0x30')]['limit']);_0x2a82cd['offset']=qs['offset'](_0x4b77d4['query'][_0x8e2d('0x1f')]);}return _0xe1690c[_0x8e2d('0x4b')](_0x2a82cd);}})[_0x8e2d('0x24')](function(_0x5b1191){if(_0x5b1191){return _0x5b1191?{'count':_0x1144a0,'rows':_0x5b1191}:null;}})[_0x8e2d('0x24')](respondWithResult(_0x2f8520,null))['catch'](handleError(_0x2f8520,null));};exports[_0x8e2d('0x4e')]=function(_0x24d51a,_0x35a0d3,_0x3b81c0){var _0x48254c={};var _0x57a66b={};var _0x1b5967;var _0x218adf;return db['FreshsalesConfiguration'][_0x8e2d('0x4c')]({'where':{'id':_0x24d51a[_0x8e2d('0x44')]['id']}})['then'](handleEntityNotFound(_0x35a0d3,null))[_0x8e2d('0x24')](function(_0x35a683){if(_0x35a683){_0x1b5967=_0x35a683;_0x57a66b['model']=_[_0x8e2d('0x45')](db['FreshsalesField']['rawAttributes']);_0x57a66b[_0x8e2d('0x30')]=_[_0x8e2d('0x45')](_0x24d51a[_0x8e2d('0x30')]);_0x57a66b[_0x8e2d('0x31')]=_[_0x8e2d('0x33')](_0x57a66b[_0x8e2d('0x2f')],_0x57a66b[_0x8e2d('0x30')]);_0x48254c[_0x8e2d('0x32')]=_[_0x8e2d('0x33')](_0x57a66b['model'],qs['fields'](_0x24d51a['query'][_0x8e2d('0x34')]));_0x48254c[_0x8e2d('0x32')]=_0x48254c['attributes'][_0x8e2d('0x35')]?_0x48254c[_0x8e2d('0x32')]:_0x57a66b[_0x8e2d('0x2f')];_0x48254c[_0x8e2d('0x38')]=qs[_0x8e2d('0x39')](_0x24d51a[_0x8e2d('0x30')][_0x8e2d('0x39')]);_0x48254c[_0x8e2d('0x3a')]=qs[_0x8e2d('0x31')](_['pick'](_0x24d51a[_0x8e2d('0x30')],_0x57a66b[_0x8e2d('0x31')]));if(_0x24d51a['query'][_0x8e2d('0x3b')]){_0x48254c[_0x8e2d('0x3a')]=_[_0x8e2d('0x3c')](_0x48254c[_0x8e2d('0x3a')],{'$or':_[_0x8e2d('0x3d')](_0x48254c[_0x8e2d('0x32')],function(_0x42d3bf){var _0x232fb9={};_0x232fb9[_0x42d3bf]={'$like':'%'+_0x24d51a[_0x8e2d('0x30')][_0x8e2d('0x3b')]+'%'};return _0x232fb9;})});}_0x48254c=_[_0x8e2d('0x3c')]({},_0x48254c,_0x24d51a[_0x8e2d('0x3e')]);return _0x1b5967[_0x8e2d('0x4e')](_0x48254c);}})[_0x8e2d('0x24')](function(_0x285399){if(_0x285399){_0x218adf=_0x285399[_0x8e2d('0x35')];if(!_0x24d51a[_0x8e2d('0x30')][_0x8e2d('0x36')]('nolimit')){_0x48254c['limit']=qs[_0x8e2d('0x1d')](_0x24d51a[_0x8e2d('0x30')]['limit']);_0x48254c[_0x8e2d('0x1f')]=qs[_0x8e2d('0x1f')](_0x24d51a[_0x8e2d('0x30')][_0x8e2d('0x1f')]);}return _0x1b5967[_0x8e2d('0x4e')](_0x48254c);}})['then'](function(_0x23bce3){if(_0x23bce3){return _0x23bce3?{'count':_0x218adf,'rows':_0x23bce3}:null;}})[_0x8e2d('0x24')](respondWithResult(_0x35a0d3,null))[_0x8e2d('0x42')](handleError(_0x35a0d3,null));}; \ No newline at end of file diff --git a/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.model.js b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.model.js new file mode 100644 index 0000000..96bcfc3 --- /dev/null +++ b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x23f4=['api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intFreshsalesConfiguration.attributes','exports','define','FreshsalesConfiguration','lodash','util','../../config/logger'];(function(_0x5d886b,_0x20b3c1){var _0x22bc5e=function(_0x300aed){while(--_0x300aed){_0x5d886b['push'](_0x5d886b['shift']());}};_0x22bc5e(++_0x20b3c1);}(_0x23f4,0x97));var _0x423f=function(_0x25a8a5,_0x11eb7a){_0x25a8a5=_0x25a8a5-0x0;var _0x3d2ddc=_0x23f4[_0x25a8a5];return _0x3d2ddc;};'use strict';var _=require(_0x423f('0x0'));var util=require(_0x423f('0x1'));var logger=require(_0x423f('0x2'))(_0x423f('0x3'));var moment=require(_0x423f('0x4'));var BPromise=require(_0x423f('0x5'));var rp=require(_0x423f('0x6'));var fs=require('fs');var path=require(_0x423f('0x7'));var rimraf=require(_0x423f('0x8'));var config=require(_0x423f('0x9'));var attributes=require(_0x423f('0xa'));module[_0x423f('0xb')]=function(_0x338aab,_0x2903d3){return _0x338aab[_0x423f('0xc')](_0x423f('0xd'),attributes,{'tableName':'int_freshsales_configurations','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.rpc.js b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.rpc.js new file mode 100644 index 0000000..a5cddd7 --- /dev/null +++ b/server/api/intFreshsalesConfiguration/intFreshsalesConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x929f=['rpc','../../config/environment','client','http','then','info','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshsalesConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x119cd8,_0x556b73){var _0x7072a3=function(_0x5908d1){while(--_0x5908d1){_0x119cd8['push'](_0x119cd8['shift']());}};_0x7072a3(++_0x556b73);}(_0x929f,0x1b2));var _0xf929=function(_0x5f4800,_0x5d31b4){_0x5f4800=_0x5f4800-0x0;var _0x4069ba=_0x929f[_0x5f4800];return _0x4069ba;};'use strict';var _=require(_0xf929('0x0'));var util=require(_0xf929('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf929('0x2'));var fs=require('fs');var Redis=require(_0xf929('0x3'));var db=require(_0xf929('0x4'))['db'];var utils=require(_0xf929('0x5'));var logger=require(_0xf929('0x6'))(_0xf929('0x7'));var config=require(_0xf929('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xf929('0x9')][_0xf929('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x24610c,_0x53c7cb,_0x1397b4){return new BPromise(function(_0x277f56,_0x12a56e){return client['request'](_0x24610c,_0x1397b4)[_0xf929('0xb')](function(_0x2f20d7){logger[_0xf929('0xc')](_0xf929('0xd'),_0x53c7cb,_0xf929('0xe'));logger[_0xf929('0xf')](_0xf929('0x10'),_0x53c7cb,'request\x20sent',JSON[_0xf929('0x11')](_0x2f20d7));if(_0x2f20d7[_0xf929('0x12')]){if(_0x2f20d7[_0xf929('0x12')][_0xf929('0x13')]===0x1f4){logger[_0xf929('0x12')](_0xf929('0xd'),_0x53c7cb,_0x2f20d7[_0xf929('0x12')][_0xf929('0x14')]);return _0x12a56e(_0x2f20d7[_0xf929('0x12')]['message']);}logger[_0xf929('0x12')](_0xf929('0xd'),_0x53c7cb,_0x2f20d7[_0xf929('0x12')][_0xf929('0x14')]);return _0x277f56(_0x2f20d7[_0xf929('0x12')][_0xf929('0x14')]);}else{logger[_0xf929('0xc')](_0xf929('0xd'),_0x53c7cb,'request\x20sent');_0x277f56(_0x2f20d7['result']['message']);}})['catch'](function(_0x597ef9){logger[_0xf929('0x12')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x53c7cb,_0x597ef9);_0x12a56e(_0x597ef9);});});} \ No newline at end of file diff --git a/server/api/intFreshsalesField/index.js b/server/api/intFreshsalesField/index.js new file mode 100644 index 0000000..1ad4d01 --- /dev/null +++ b/server/api/intFreshsalesField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x782e=['/:id','update','delete','destroy','exports','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment','./intFreshsalesField.controller','get','index','isAuthenticated','post','create','put'];(function(_0x3ad462,_0x363c0d){var _0x4c721b=function(_0x11a62f){while(--_0x11a62f){_0x3ad462['push'](_0x3ad462['shift']());}};_0x4c721b(++_0x363c0d);}(_0x782e,0xb9));var _0xe782=function(_0x533b69,_0xfb1251){_0x533b69=_0x533b69-0x0;var _0x426829=_0x782e[_0x533b69];return _0x426829;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0xe782('0x0'));var timeout=require(_0xe782('0x1'));var express=require('express');var router=express[_0xe782('0x2')]();var fs_extra=require(_0xe782('0x3'));var auth=require('../../components/auth/service');var interaction=require(_0xe782('0x4'));var config=require(_0xe782('0x5'));var controller=require(_0xe782('0x6'));router[_0xe782('0x7')]('/',auth['isAuthenticated'](),controller[_0xe782('0x8')]);router['get']('/:id',auth[_0xe782('0x9')](),controller['show']);router[_0xe782('0xa')]('/',auth[_0xe782('0x9')](),controller[_0xe782('0xb')]);router[_0xe782('0xc')](_0xe782('0xd'),auth[_0xe782('0x9')](),controller[_0xe782('0xe')]);router[_0xe782('0xf')](_0xe782('0xd'),auth[_0xe782('0x9')](),controller[_0xe782('0x10')]);module[_0xe782('0x11')]=router; \ No newline at end of file diff --git a/server/api/intFreshsalesField/intFreshsalesField.attributes.js b/server/api/intFreshsalesField/intFreshsalesField.attributes.js new file mode 100644 index 0000000..f67dddc --- /dev/null +++ b/server/api/intFreshsalesField/intFreshsalesField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xebab=['keyValue','picklist','STRING','BOOLEAN','exports','ENUM','string','variable','customVariable'];(function(_0x3c7810,_0x274437){var _0x2645bc=function(_0x210145){while(--_0x210145){_0x3c7810['push'](_0x3c7810['shift']());}};_0x2645bc(++_0x274437);}(_0xebab,0x1bd));var _0xbeba=function(_0x4b3ce7,_0x2d2650){_0x4b3ce7=_0x4b3ce7-0x0;var _0x124bab=_0xebab[_0x4b3ce7];return _0x124bab;};'use strict';var Sequelize=require('sequelize');module[_0xbeba('0x0')]={'type':{'type':Sequelize[_0xbeba('0x1')](_0xbeba('0x2'),_0xbeba('0x3'),_0xbeba('0x4'),_0xbeba('0x5'),_0xbeba('0x6')),'defaultValue':_0xbeba('0x2')},'content':{'type':Sequelize[_0xbeba('0x7')]},'key':{'type':Sequelize[_0xbeba('0x7')]},'keyType':{'type':Sequelize[_0xbeba('0x1')](_0xbeba('0x2'),_0xbeba('0x3'),_0xbeba('0x4'))},'keyContent':{'type':Sequelize['STRING']},'idField':{'type':Sequelize[_0xbeba('0x7')]},'nameField':{'type':Sequelize[_0xbeba('0x7')]},'customField':{'type':Sequelize[_0xbeba('0x8')],'defaultValue':!![]},'variableName':{'type':Sequelize[_0xbeba('0x7')]}}; \ No newline at end of file diff --git a/server/api/intFreshsalesField/intFreshsalesField.controller.js b/server/api/intFreshsalesField/intFreshsalesField.controller.js new file mode 100644 index 0000000..78cea83 --- /dev/null +++ b/server/api/intFreshsalesField/intFreshsalesField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x21ee=['../../config/license/util','../../mysqldb','end','status','json','offset','limit','set','Content-Range','reject','save','update','then','sendStatus','error','name','send','index','map','FreshsalesField','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','count','includeAll','rows','catch','show','params','rawAttributes','include','find','create','body','destroy','eml-format','rimraf','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger'];(function(_0x4e1211,_0x1c0e26){var _0x4ae887=function(_0x6e55ff){while(--_0x6e55ff){_0x4e1211['push'](_0x4e1211['shift']());}};_0x4ae887(++_0x1c0e26);}(_0x21ee,0xc8));var _0xe21e=function(_0x5a07cb,_0x18504c){_0x5a07cb=_0x5a07cb-0x0;var _0x34ece1=_0x21ee[_0x5a07cb];return _0x34ece1;};'use strict';var emlformat=require(_0xe21e('0x0'));var rimraf=require(_0xe21e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xe21e('0x2'));var rp=require(_0xe21e('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xe21e('0x4'));var util=require(_0xe21e('0x5'));var path=require(_0xe21e('0x6'));var sox=require(_0xe21e('0x7'));var csv=require(_0xe21e('0x8'));var ejs=require(_0xe21e('0x9'));var fs=require('fs');var fs_extra=require(_0xe21e('0xa'));var _=require(_0xe21e('0xb'));var squel=require(_0xe21e('0xc'));var crypto=require(_0xe21e('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xe21e('0x8'));var querystring=require(_0xe21e('0xe'));var Papa=require(_0xe21e('0xf'));var Redis=require(_0xe21e('0x10'));var authService=require(_0xe21e('0x11'));var qs=require(_0xe21e('0x12'));var as=require(_0xe21e('0x13'));var hardwareService=require(_0xe21e('0x14'));var logger=require(_0xe21e('0x15'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xe21e('0x16'));var db=require(_0xe21e('0x17'))['db'];function respondWithStatusCode(_0xaaf6eb,_0x4e4c8a){_0x4e4c8a=_0x4e4c8a||0xcc;return function(_0x3cf55e){if(_0x3cf55e){return _0xaaf6eb['sendStatus'](_0x4e4c8a);}return _0xaaf6eb['status'](_0x4e4c8a)[_0xe21e('0x18')]();};}function respondWithResult(_0x529e49,_0x371655){_0x371655=_0x371655||0xc8;return function(_0x8cbf89){if(_0x8cbf89){return _0x529e49[_0xe21e('0x19')](_0x371655)[_0xe21e('0x1a')](_0x8cbf89);}};}function respondWithFilteredResult(_0x5e1f49,_0x364859){return function(_0x4dcba8){if(_0x4dcba8){var _0x583bee=typeof _0x364859[_0xe21e('0x1b')]==='undefined'&&typeof _0x364859[_0xe21e('0x1c')]==='undefined';var _0x11bbc5=_0x4dcba8['count'];var _0x42316a=_0x583bee?0x0:_0x364859[_0xe21e('0x1b')];var _0x59f7ba=_0x583bee?_0x4dcba8['count']:_0x364859[_0xe21e('0x1b')]+_0x364859['limit'];var _0x44f086;if(_0x59f7ba>=_0x11bbc5){_0x59f7ba=_0x11bbc5;_0x44f086=0xc8;}else{_0x44f086=0xce;}_0x5e1f49[_0xe21e('0x19')](_0x44f086);return _0x5e1f49[_0xe21e('0x1d')](_0xe21e('0x1e'),_0x42316a+'-'+_0x59f7ba+'/'+_0x11bbc5)[_0xe21e('0x1a')](_0x4dcba8);}return null;};}function patchUpdates(_0x55d690){return function(_0x245001){try{jsonpatch['apply'](_0x245001,_0x55d690,!![]);}catch(_0x1028f9){return BPromise[_0xe21e('0x1f')](_0x1028f9);}return _0x245001[_0xe21e('0x20')]();};}function saveUpdates(_0x451552,_0x13a5a2){return function(_0x4538f8){if(_0x4538f8){return _0x4538f8[_0xe21e('0x21')](_0x451552)[_0xe21e('0x22')](function(_0x4ac013){return _0x4ac013;});}return null;};}function removeEntity(_0x27291c,_0x30727f){return function(_0x371130){if(_0x371130){return _0x371130['destroy']()[_0xe21e('0x22')](function(){_0x27291c[_0xe21e('0x19')](0xcc)[_0xe21e('0x18')]();});}};}function handleEntityNotFound(_0x5e9ab2,_0x149097){return function(_0x113911){if(!_0x113911){_0x5e9ab2[_0xe21e('0x23')](0x194);}return _0x113911;};}function handleError(_0x3d9101,_0x4ee002){_0x4ee002=_0x4ee002||0x1f4;return function(_0x1f0513){logger[_0xe21e('0x24')](_0x1f0513['stack']);if(_0x1f0513[_0xe21e('0x25')]){delete _0x1f0513[_0xe21e('0x25')];}_0x3d9101[_0xe21e('0x19')](_0x4ee002)[_0xe21e('0x26')](_0x1f0513);};}exports[_0xe21e('0x27')]=function(_0x1f0869,_0x4dfa55){var _0x35839b={},_0x2e9a6b={},_0x4a022d={'count':0x0,'rows':[]};var _0x32e950=_[_0xe21e('0x28')](db[_0xe21e('0x29')]['rawAttributes'],function(_0x58c24b){return{'name':_0x58c24b[_0xe21e('0x2a')],'type':_0x58c24b[_0xe21e('0x2b')][_0xe21e('0x2c')]};});_0x2e9a6b[_0xe21e('0x2d')]=_[_0xe21e('0x28')](_0x32e950,'name');_0x2e9a6b[_0xe21e('0x2e')]=_[_0xe21e('0x2f')](_0x1f0869[_0xe21e('0x2e')]);_0x2e9a6b[_0xe21e('0x30')]=_[_0xe21e('0x31')](_0x2e9a6b[_0xe21e('0x2d')],_0x2e9a6b[_0xe21e('0x2e')]);_0x35839b[_0xe21e('0x32')]=_[_0xe21e('0x31')](_0x2e9a6b[_0xe21e('0x2d')],qs[_0xe21e('0x33')](_0x1f0869[_0xe21e('0x2e')][_0xe21e('0x33')]));_0x35839b[_0xe21e('0x32')]=_0x35839b[_0xe21e('0x32')][_0xe21e('0x34')]?_0x35839b[_0xe21e('0x32')]:_0x2e9a6b['model'];if(!_0x1f0869['query']['hasOwnProperty'](_0xe21e('0x35'))){_0x35839b['limit']=qs[_0xe21e('0x1c')](_0x1f0869['query']['limit']);_0x35839b[_0xe21e('0x1b')]=qs[_0xe21e('0x1b')](_0x1f0869[_0xe21e('0x2e')][_0xe21e('0x1b')]);}_0x35839b[_0xe21e('0x36')]=qs['sort'](_0x1f0869[_0xe21e('0x2e')][_0xe21e('0x37')]);_0x35839b[_0xe21e('0x38')]=qs[_0xe21e('0x30')](_[_0xe21e('0x39')](_0x1f0869[_0xe21e('0x2e')],_0x2e9a6b[_0xe21e('0x30')]),_0x32e950);if(_0x1f0869[_0xe21e('0x2e')][_0xe21e('0x3a')]){_0x35839b[_0xe21e('0x38')]=_[_0xe21e('0x3b')](_0x35839b[_0xe21e('0x38')],{'$or':_['map'](_0x32e950,function(_0x337373){if(_0x337373[_0xe21e('0x2b')]!==_0xe21e('0x3c')){var _0x57a819={};_0x57a819[_0x337373[_0xe21e('0x25')]]={'$like':'%'+_0x1f0869[_0xe21e('0x2e')][_0xe21e('0x3a')]+'%'};return _0x57a819;}})});}_0x35839b=_['merge']({},_0x35839b,_0x1f0869[_0xe21e('0x3d')]);var _0x2aa3d0={'where':_0x35839b['where']};return db['FreshsalesField'][_0xe21e('0x3e')](_0x2aa3d0)[_0xe21e('0x22')](function(_0x1f5e0c){_0x4a022d[_0xe21e('0x3e')]=_0x1f5e0c;if(_0x1f0869['query'][_0xe21e('0x3f')]){_0x35839b['include']=[{'all':!![]}];}return db[_0xe21e('0x29')]['findAll'](_0x35839b);})['then'](function(_0x1d62bf){_0x4a022d[_0xe21e('0x40')]=_0x1d62bf;return _0x4a022d;})[_0xe21e('0x22')](respondWithFilteredResult(_0x4dfa55,_0x35839b))[_0xe21e('0x41')](handleError(_0x4dfa55,null));};exports[_0xe21e('0x42')]=function(_0x135523,_0x2783a8){var _0x1227f1={'raw':!![],'where':{'id':_0x135523[_0xe21e('0x43')]['id']}},_0x34c306={};_0x34c306['model']=_[_0xe21e('0x2f')](db[_0xe21e('0x29')][_0xe21e('0x44')]);_0x34c306[_0xe21e('0x2e')]=_[_0xe21e('0x2f')](_0x135523[_0xe21e('0x2e')]);_0x34c306[_0xe21e('0x30')]=_[_0xe21e('0x31')](_0x34c306[_0xe21e('0x2d')],_0x34c306['query']);_0x1227f1[_0xe21e('0x32')]=_[_0xe21e('0x31')](_0x34c306[_0xe21e('0x2d')],qs[_0xe21e('0x33')](_0x135523['query'][_0xe21e('0x33')]));_0x1227f1[_0xe21e('0x32')]=_0x1227f1[_0xe21e('0x32')][_0xe21e('0x34')]?_0x1227f1[_0xe21e('0x32')]:_0x34c306['model'];if(_0x135523['query'][_0xe21e('0x3f')]){_0x1227f1[_0xe21e('0x45')]=[{'all':!![]}];}_0x1227f1=_[_0xe21e('0x3b')]({},_0x1227f1,_0x135523['options']);return db[_0xe21e('0x29')][_0xe21e('0x46')](_0x1227f1)['then'](handleEntityNotFound(_0x2783a8,null))[_0xe21e('0x22')](respondWithResult(_0x2783a8,null))['catch'](handleError(_0x2783a8,null));};exports[_0xe21e('0x47')]=function(_0x232801,_0x2f089e){return db[_0xe21e('0x29')][_0xe21e('0x47')](_0x232801[_0xe21e('0x48')],{})[_0xe21e('0x22')](respondWithResult(_0x2f089e,0xc9))[_0xe21e('0x41')](handleError(_0x2f089e,null));};exports['update']=function(_0x265f2c,_0x53b0f2){if(_0x265f2c['body']['id']){delete _0x265f2c['body']['id'];}return db[_0xe21e('0x29')][_0xe21e('0x46')]({'where':{'id':_0x265f2c[_0xe21e('0x43')]['id']}})[_0xe21e('0x22')](handleEntityNotFound(_0x53b0f2,null))['then'](saveUpdates(_0x265f2c[_0xe21e('0x48')],null))[_0xe21e('0x22')](respondWithResult(_0x53b0f2,null))[_0xe21e('0x41')](handleError(_0x53b0f2,null));};exports[_0xe21e('0x49')]=function(_0x3b67e7,_0x19f611){return db['FreshsalesField']['find']({'where':{'id':_0x3b67e7[_0xe21e('0x43')]['id']}})[_0xe21e('0x22')](handleEntityNotFound(_0x19f611,null))[_0xe21e('0x22')](removeEntity(_0x19f611,null))[_0xe21e('0x41')](handleError(_0x19f611,null));}; \ No newline at end of file diff --git a/server/api/intFreshsalesField/intFreshsalesField.model.js b/server/api/intFreshsalesField/intFreshsalesField.model.js new file mode 100644 index 0000000..2356d5a --- /dev/null +++ b/server/api/intFreshsalesField/intFreshsalesField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x19cb=['./intFreshsalesField.attributes','exports','define','FreshsalesField','int_freshsales_fields','freshsales_unique_index','util','../../config/logger','moment','request-promise'];(function(_0x3e6af8,_0x116679){var _0x6319b1=function(_0x3f079c){while(--_0x3f079c){_0x3e6af8['push'](_0x3e6af8['shift']());}};_0x6319b1(++_0x116679);}(_0x19cb,0x146));var _0xb19c=function(_0x2091bb,_0x43a2e1){_0x2091bb=_0x2091bb-0x0;var _0x12c345=_0x19cb[_0x2091bb];return _0x12c345;};'use strict';var _=require('lodash');var util=require(_0xb19c('0x0'));var logger=require(_0xb19c('0x1'))('api');var moment=require(_0xb19c('0x2'));var BPromise=require('bluebird');var rp=require(_0xb19c('0x3'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0xb19c('0x4'));module[_0xb19c('0x5')]=function(_0x5a145d,_0x551f8d){return _0x5a145d[_0xb19c('0x6')](_0xb19c('0x7'),attributes,{'tableName':_0xb19c('0x8'),'paranoid':![],'indexes':[{'name':_0xb19c('0x9'),'fields':['idField','FieldId'],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intFreshsalesField/intFreshsalesField.rpc.js b/server/api/intFreshsalesField/intFreshsalesField.rpc.js new file mode 100644 index 0000000..d9b81c9 --- /dev/null +++ b/server/api/intFreshsalesField/intFreshsalesField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadb5=['error','code','message','result','catch','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','FreshsalesField,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x1d5ba8,_0x412a52){var _0x1022a2=function(_0x187f11){while(--_0x187f11){_0x1d5ba8['push'](_0x1d5ba8['shift']());}};_0x1022a2(++_0x412a52);}(_0xadb5,0xad));var _0x5adb=function(_0x5cb640,_0x5166be){_0x5cb640=_0x5cb640-0x0;var _0x7d44e4=_0xadb5[_0x5cb640];return _0x7d44e4;};'use strict';var _=require('lodash');var util=require(_0x5adb('0x0'));var moment=require('moment');var BPromise=require(_0x5adb('0x1'));var rs=require(_0x5adb('0x2'));var fs=require('fs');var Redis=require(_0x5adb('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x5adb('0x4'));var logger=require(_0x5adb('0x5'))(_0x5adb('0x6'));var config=require('../../config/environment');var jayson=require(_0x5adb('0x7'));var client=jayson[_0x5adb('0x8')][_0x5adb('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3213e8,_0xdf3776,_0x353885){return new BPromise(function(_0x47228a,_0x6d1b45){return client[_0x5adb('0xa')](_0x3213e8,_0x353885)[_0x5adb('0xb')](function(_0x34f59d){logger[_0x5adb('0xc')](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));logger['debug']('FreshsalesField,\x20%s,\x20%s,\x20%s',_0xdf3776,_0x5adb('0xe'),JSON[_0x5adb('0xf')](_0x34f59d));if(_0x34f59d[_0x5adb('0x10')]){if(_0x34f59d['error'][_0x5adb('0x11')]===0x1f4){logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d['error'][_0x5adb('0x12')]);return _0x6d1b45(_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);}logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);return _0x47228a(_0x34f59d['error'][_0x5adb('0x12')]);}else{logger['info'](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));_0x47228a(_0x34f59d[_0x5adb('0x13')][_0x5adb('0x12')]);}})[_0x5adb('0x14')](function(_0x39d24d){logger[_0x5adb('0x10')](_0x5adb('0xd'),_0xdf3776,_0x39d24d);_0x6d1b45(_0x39d24d);});});} \ No newline at end of file diff --git a/server/api/intSalesforceAccount/index.js b/server/api/intSalesforceAccount/index.js new file mode 100644 index 0000000..391b568 --- /dev/null +++ b/server/api/intSalesforceAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9957=['connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./intSalesforceAccount.controller','get','isAuthenticated','index','/:id','show','getConfigurations','/:id/fields','getFields','post','create','addConfiguration','put','update','delete','destroy','exports','multer','util','path'];(function(_0x9c3016,_0x2553b7){var _0x858ef3=function(_0x5c57d8){while(--_0x5c57d8){_0x9c3016['push'](_0x9c3016['shift']());}};_0x858ef3(++_0x2553b7);}(_0x9957,0x93));var _0x7995=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x9957[_0x6c993a];return _0x27f547;};'use strict';var multer=require(_0x7995('0x0'));var util=require(_0x7995('0x1'));var path=require(_0x7995('0x2'));var timeout=require(_0x7995('0x3'));var express=require('express');var router=express[_0x7995('0x4')]();var fs_extra=require(_0x7995('0x5'));var auth=require(_0x7995('0x6'));var interaction=require(_0x7995('0x7'));var config=require('../../config/environment');var controller=require(_0x7995('0x8'));router[_0x7995('0x9')]('/',auth[_0x7995('0xa')](),controller[_0x7995('0xb')]);router[_0x7995('0x9')](_0x7995('0xc'),auth['isAuthenticated'](),controller[_0x7995('0xd')]);router[_0x7995('0x9')]('/:id/configurations',auth[_0x7995('0xa')](),controller[_0x7995('0xe')]);router[_0x7995('0x9')](_0x7995('0xf'),auth[_0x7995('0xa')](),controller[_0x7995('0x10')]);router[_0x7995('0x11')]('/',auth['isAuthenticated'](),controller[_0x7995('0x12')]);router[_0x7995('0x11')]('/:id/configurations',auth[_0x7995('0xa')](),controller[_0x7995('0x13')]);router[_0x7995('0x14')](_0x7995('0xc'),auth[_0x7995('0xa')](),controller[_0x7995('0x15')]);router[_0x7995('0x16')]('/:id',auth['isAuthenticated'](),controller[_0x7995('0x17')]);module[_0x7995('0x18')]=router; \ No newline at end of file diff --git a/server/api/intSalesforceAccount/intSalesforceAccount.attributes.js b/server/api/intSalesforceAccount/intSalesforceAccount.attributes.js new file mode 100644 index 0000000..d023b65 --- /dev/null +++ b/server/api/intSalesforceAccount/intSalesforceAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa3d4=['integrationTab','newTab','sequelize','STRING','ENUM'];(function(_0x295cda,_0x5e8b5e){var _0x5517e0=function(_0x41f885){while(--_0x41f885){_0x295cda['push'](_0x295cda['shift']());}};_0x5517e0(++_0x5e8b5e);}(_0xa3d4,0x151));var _0x4a3d=function(_0xb0f7c3,_0x4eae95){_0xb0f7c3=_0xb0f7c3-0x0;var _0x28ea68=_0xa3d4[_0xb0f7c3];return _0x28ea68;};'use strict';var Sequelize=require(_0x4a3d('0x0'));module['exports']={'name':{'type':Sequelize[_0x4a3d('0x1')]},'description':{'type':Sequelize[_0x4a3d('0x1')]},'username':{'type':Sequelize[_0x4a3d('0x1')],'unique':'username'},'remoteUri':{'type':Sequelize[_0x4a3d('0x1')]},'password':{'type':Sequelize['STRING']},'clientId':{'type':Sequelize['STRING']},'clientSecret':{'type':Sequelize['STRING']},'securityToken':{'type':Sequelize['STRING']},'serverUrl':{'type':Sequelize['STRING'],'allowNull':![]},'type':{'type':Sequelize[_0x4a3d('0x2')](_0x4a3d('0x3'),_0x4a3d('0x4')),'defaultValue':_0x4a3d('0x3')}}; \ No newline at end of file diff --git a/server/api/intSalesforceAccount/intSalesforceAccount.controller.js b/server/api/intSalesforceAccount/intSalesforceAccount.controller.js new file mode 100644 index 0000000..44c39df --- /dev/null +++ b/server/api/intSalesforceAccount/intSalesforceAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5fb1=['IsReminderSet','Description','string','int','picklist','boolean','email','phone','remove','includes','label','picklistValues','value','True','False','false','test','statusCode','getFields','stringify','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','status','offset','limit','undefined','count','set','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','catch','show','params','length','find','create','body','getConfigurations','findOne','SalesforceConfiguration','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','Task','remoteUri','clientId','clientSecret','username','securityToken','slice','substring','lastIndexOf','login','concat','isNil','ticketType','describe','OwnerId','ActivityDate'];(function(_0x4959fd,_0x186515){var _0x97de01=function(_0x29e1d0){while(--_0x29e1d0){_0x4959fd['push'](_0x4959fd['shift']());}};_0x97de01(++_0x186515);}(_0x5fb1,0x10a));var _0x15fb=function(_0x5f46e7,_0x62f9f8){_0x5f46e7=_0x5f46e7-0x0;var _0x567e95=_0x5fb1[_0x5f46e7];return _0x567e95;};'use strict';var emlformat=require(_0x15fb('0x0'));var rimraf=require(_0x15fb('0x1'));var zipdir=require(_0x15fb('0x2'));var jsonpatch=require(_0x15fb('0x3'));var rp=require(_0x15fb('0x4'));var moment=require(_0x15fb('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x15fb('0x6'));var util=require(_0x15fb('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x15fb('0x8'));var _=require(_0x15fb('0x9'));var squel=require(_0x15fb('0xa'));var crypto=require(_0x15fb('0xb'));var jsforce=require(_0x15fb('0xc'));var deskjs=require(_0x15fb('0xd'));var toCsv=require(_0x15fb('0xe'));var querystring=require(_0x15fb('0xf'));var Papa=require(_0x15fb('0x10'));var Redis=require(_0x15fb('0x11'));var authService=require(_0x15fb('0x12'));var qs=require(_0x15fb('0x13'));var as=require(_0x15fb('0x14'));var hardwareService=require(_0x15fb('0x15'));var logger=require(_0x15fb('0x16'))(_0x15fb('0x17'));var utils=require(_0x15fb('0x18'));var config=require(_0x15fb('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x15fb('0x1a'))['db'];var integrations=require(_0x15fb('0x1b'));function respondWithStatusCode(_0x3cdd11,_0xb508ee){_0xb508ee=_0xb508ee||0xcc;return function(_0x40f67c){if(_0x40f67c){return _0x3cdd11[_0x15fb('0x1c')](_0xb508ee);}return _0x3cdd11[_0x15fb('0x1d')](_0xb508ee)['end']();};}function respondWithResult(_0x4c58ca,_0x5edb07){_0x5edb07=_0x5edb07||0xc8;return function(_0x1dfbe6){if(_0x1dfbe6){return _0x4c58ca[_0x15fb('0x1d')](_0x5edb07)['json'](_0x1dfbe6);}};}function respondWithFilteredResult(_0x1f12bb,_0x4be145){return function(_0x383f88){if(_0x383f88){var _0x28f5af=typeof _0x4be145[_0x15fb('0x1e')]==='undefined'&&typeof _0x4be145[_0x15fb('0x1f')]===_0x15fb('0x20');var _0x2a7168=_0x383f88[_0x15fb('0x21')];var _0x2b6ec7=_0x28f5af?0x0:_0x4be145[_0x15fb('0x1e')];var _0x258445=_0x28f5af?_0x383f88[_0x15fb('0x21')]:_0x4be145['offset']+_0x4be145[_0x15fb('0x1f')];var _0x324e06;if(_0x258445>=_0x2a7168){_0x258445=_0x2a7168;_0x324e06=0xc8;}else{_0x324e06=0xce;}_0x1f12bb[_0x15fb('0x1d')](_0x324e06);return _0x1f12bb[_0x15fb('0x22')]('Content-Range',_0x2b6ec7+'-'+_0x258445+'/'+_0x2a7168)['json'](_0x383f88);}return null;};}function patchUpdates(_0x3fc12f){return function(_0x3c78d6){try{jsonpatch[_0x15fb('0x23')](_0x3c78d6,_0x3fc12f,!![]);}catch(_0x3e74df){return BPromise[_0x15fb('0x24')](_0x3e74df);}return _0x3c78d6[_0x15fb('0x25')]();};}function saveUpdates(_0x48a2d7,_0x57aad1){return function(_0x446057){if(_0x446057){return _0x446057[_0x15fb('0x26')](_0x48a2d7)[_0x15fb('0x27')](function(_0x35970a){return _0x35970a;});}return null;};}function removeEntity(_0x30cf2f,_0x4adde8){return function(_0x2b7a9a){if(_0x2b7a9a){return _0x2b7a9a[_0x15fb('0x28')]()['then'](function(){_0x30cf2f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x4aef94,_0x1242e1){return function(_0x482800){if(!_0x482800){_0x4aef94[_0x15fb('0x1c')](0x194);}return _0x482800;};}function handleError(_0x32a5dc,_0xd5fac3){_0xd5fac3=_0xd5fac3||0x1f4;return function(_0x41c3c3){logger[_0x15fb('0x29')](_0x41c3c3[_0x15fb('0x2a')]);if(_0x41c3c3[_0x15fb('0x2b')]){delete _0x41c3c3[_0x15fb('0x2b')];}_0x32a5dc[_0x15fb('0x1d')](_0xd5fac3)[_0x15fb('0x2c')](_0x41c3c3);};}exports[_0x15fb('0x2d')]=function(_0xdbefdb,_0x556ef6){var _0x430fcc={},_0x509a15={},_0x2db9b3={'count':0x0,'rows':[]};var _0x543cb4=_[_0x15fb('0x2e')](db[_0x15fb('0x2f')][_0x15fb('0x30')],function(_0x166a27){return{'name':_0x166a27[_0x15fb('0x31')],'type':_0x166a27[_0x15fb('0x32')][_0x15fb('0x33')]};});_0x509a15[_0x15fb('0x34')]=_['map'](_0x543cb4,_0x15fb('0x2b'));_0x509a15['query']=_[_0x15fb('0x35')](_0xdbefdb[_0x15fb('0x36')]);_0x509a15[_0x15fb('0x37')]=_[_0x15fb('0x38')](_0x509a15['model'],_0x509a15[_0x15fb('0x36')]);_0x430fcc['attributes']=_[_0x15fb('0x38')](_0x509a15['model'],qs[_0x15fb('0x39')](_0xdbefdb['query']['fields']));_0x430fcc[_0x15fb('0x3a')]=_0x430fcc[_0x15fb('0x3a')]['length']?_0x430fcc[_0x15fb('0x3a')]:_0x509a15[_0x15fb('0x34')];if(!_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x3b')](_0x15fb('0x3c'))){_0x430fcc[_0x15fb('0x1f')]=qs[_0x15fb('0x1f')](_0xdbefdb['query']['limit']);_0x430fcc['offset']=qs[_0x15fb('0x1e')](_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x1e')]);}_0x430fcc[_0x15fb('0x3d')]=qs[_0x15fb('0x3e')](_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x3e')]);_0x430fcc[_0x15fb('0x3f')]=qs[_0x15fb('0x37')](_[_0x15fb('0x40')](_0xdbefdb[_0x15fb('0x36')],_0x509a15[_0x15fb('0x37')]),_0x543cb4);if(_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x41')]){_0x430fcc[_0x15fb('0x3f')]=_['merge'](_0x430fcc[_0x15fb('0x3f')],{'$or':_[_0x15fb('0x2e')](_0x543cb4,function(_0x4492eb){if(_0x4492eb[_0x15fb('0x32')]!==_0x15fb('0x42')){var _0x280489={};_0x280489[_0x4492eb[_0x15fb('0x2b')]]={'$like':'%'+_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x41')]+'%'};return _0x280489;}})});}_0x430fcc=_[_0x15fb('0x43')]({},_0x430fcc,_0xdbefdb[_0x15fb('0x44')]);var _0x227ab2={'where':_0x430fcc['where']};return db[_0x15fb('0x2f')][_0x15fb('0x21')](_0x227ab2)[_0x15fb('0x27')](function(_0x426b68){_0x2db9b3['count']=_0x426b68;if(_0xdbefdb[_0x15fb('0x36')][_0x15fb('0x45')]){_0x430fcc[_0x15fb('0x46')]=[{'all':!![]}];}return db[_0x15fb('0x2f')][_0x15fb('0x47')](_0x430fcc);})[_0x15fb('0x27')](function(_0x114720){_0x2db9b3['rows']=_0x114720;return _0x2db9b3;})['then'](respondWithFilteredResult(_0x556ef6,_0x430fcc))[_0x15fb('0x48')](handleError(_0x556ef6,null));};exports[_0x15fb('0x49')]=function(_0x3ccaa5,_0x2acb42){var _0x21d95c={'raw':![],'where':{'id':_0x3ccaa5[_0x15fb('0x4a')]['id']}},_0x288a0a={};_0x288a0a[_0x15fb('0x34')]=_[_0x15fb('0x35')](db[_0x15fb('0x2f')][_0x15fb('0x30')]);_0x288a0a['query']=_['keys'](_0x3ccaa5[_0x15fb('0x36')]);_0x288a0a[_0x15fb('0x37')]=_[_0x15fb('0x38')](_0x288a0a[_0x15fb('0x34')],_0x288a0a['query']);_0x21d95c['attributes']=_['intersection'](_0x288a0a[_0x15fb('0x34')],qs[_0x15fb('0x39')](_0x3ccaa5['query']['fields']));_0x21d95c[_0x15fb('0x3a')]=_0x21d95c[_0x15fb('0x3a')][_0x15fb('0x4b')]?_0x21d95c['attributes']:_0x288a0a[_0x15fb('0x34')];if(_0x3ccaa5[_0x15fb('0x36')][_0x15fb('0x45')]){_0x21d95c[_0x15fb('0x46')]=[{'all':!![]}];}_0x21d95c=_[_0x15fb('0x43')]({},_0x21d95c,_0x3ccaa5[_0x15fb('0x44')]);return db[_0x15fb('0x2f')][_0x15fb('0x4c')](_0x21d95c)[_0x15fb('0x27')](handleEntityNotFound(_0x2acb42,null))[_0x15fb('0x27')](respondWithResult(_0x2acb42,null))[_0x15fb('0x48')](handleError(_0x2acb42,null));};exports[_0x15fb('0x4d')]=function(_0x1acb32,_0x592f99){return db[_0x15fb('0x2f')][_0x15fb('0x4d')](_0x1acb32['body'],{})[_0x15fb('0x27')](respondWithResult(_0x592f99,0xc9))[_0x15fb('0x48')](handleError(_0x592f99,null));};exports[_0x15fb('0x26')]=function(_0x4fce15,_0x379eb2){if(_0x4fce15[_0x15fb('0x4e')]['id']){delete _0x4fce15[_0x15fb('0x4e')]['id'];}return db[_0x15fb('0x2f')][_0x15fb('0x4c')]({'where':{'id':_0x4fce15[_0x15fb('0x4a')]['id']}})['then'](handleEntityNotFound(_0x379eb2,null))[_0x15fb('0x27')](saveUpdates(_0x4fce15[_0x15fb('0x4e')],null))[_0x15fb('0x27')](respondWithResult(_0x379eb2,null))['catch'](handleError(_0x379eb2,null));};exports[_0x15fb('0x28')]=function(_0x4e56ed,_0x512548){return db[_0x15fb('0x2f')]['find']({'where':{'id':_0x4e56ed['params']['id']}})['then'](handleEntityNotFound(_0x512548,null))[_0x15fb('0x27')](removeEntity(_0x512548,null))[_0x15fb('0x48')](handleError(_0x512548,null));};exports[_0x15fb('0x4f')]=function(_0x413969,_0x233219,_0x2d9cf7){var _0x589180={};var _0x48cc46={};var _0x1ba68f;var _0x48b5b6;return db[_0x15fb('0x2f')][_0x15fb('0x50')]({'where':{'id':_0x413969[_0x15fb('0x4a')]['id']}})[_0x15fb('0x27')](handleEntityNotFound(_0x233219,null))[_0x15fb('0x27')](function(_0x2ca4d7){if(_0x2ca4d7){_0x1ba68f=_0x2ca4d7;_0x48cc46[_0x15fb('0x34')]=_[_0x15fb('0x35')](db[_0x15fb('0x51')]['rawAttributes']);_0x48cc46[_0x15fb('0x36')]=_['keys'](_0x413969[_0x15fb('0x36')]);_0x48cc46['filters']=_['intersection'](_0x48cc46[_0x15fb('0x34')],_0x48cc46['query']);_0x589180[_0x15fb('0x3a')]=_[_0x15fb('0x38')](_0x48cc46[_0x15fb('0x34')],qs[_0x15fb('0x39')](_0x413969[_0x15fb('0x36')]['fields']));_0x589180['attributes']=_0x589180[_0x15fb('0x3a')][_0x15fb('0x4b')]?_0x589180[_0x15fb('0x3a')]:_0x48cc46[_0x15fb('0x34')];_0x589180[_0x15fb('0x3d')]=qs[_0x15fb('0x3e')](_0x413969['query'][_0x15fb('0x3e')]);_0x589180[_0x15fb('0x3f')]=qs[_0x15fb('0x37')](_['pick'](_0x413969[_0x15fb('0x36')],_0x48cc46['filters']));if(_0x413969[_0x15fb('0x36')][_0x15fb('0x41')]){_0x589180[_0x15fb('0x3f')]=_[_0x15fb('0x43')](_0x589180[_0x15fb('0x3f')],{'$or':_[_0x15fb('0x2e')](_0x589180[_0x15fb('0x3a')],function(_0x5063b0){var _0x2f995b={};_0x2f995b[_0x5063b0]={'$like':'%'+_0x413969['query'][_0x15fb('0x41')]+'%'};return _0x2f995b;})});}_0x589180=_['merge']({},_0x589180,_0x413969[_0x15fb('0x44')]);return _0x1ba68f['getConfigurations'](_0x589180);}})[_0x15fb('0x27')](function(_0x227580){if(_0x227580){_0x48b5b6=_0x227580[_0x15fb('0x4b')];if(!_0x413969['query'][_0x15fb('0x3b')](_0x15fb('0x3c'))){_0x589180[_0x15fb('0x1f')]=qs[_0x15fb('0x1f')](_0x413969['query']['limit']);_0x589180[_0x15fb('0x1e')]=qs[_0x15fb('0x1e')](_0x413969[_0x15fb('0x36')][_0x15fb('0x1e')]);}return _0x1ba68f[_0x15fb('0x4f')](_0x589180);}})['then'](function(_0x5500e4){if(_0x5500e4){return _0x5500e4?{'count':_0x48b5b6,'rows':_0x5500e4}:null;}})['then'](respondWithResult(_0x233219,null))['catch'](handleError(_0x233219,null));};exports['addConfiguration']=function(_0x5a771d,_0x3ce022,_0x4fc31a){if(_0x5a771d[_0x15fb('0x4e')]['id']){delete _0x5a771d['body']['id'];}return db[_0x15fb('0x2f')][_0x15fb('0x50')]({'where':{'id':_0x5a771d[_0x15fb('0x4a')]['id']}})['then'](handleEntityNotFound(_0x3ce022,null))[_0x15fb('0x27')](function(_0x146eb8){if(_0x146eb8){_0x5a771d[_0x15fb('0x4e')]['AccountId']=_0x146eb8['id'];_0x5a771d[_0x15fb('0x4e')]['Subjects']=integrations[_0x15fb('0x52')](_0x5a771d[_0x15fb('0x4e')][_0x15fb('0x53')],_0x5a771d[_0x15fb('0x4e')]['type']);_0x5a771d['body'][_0x15fb('0x54')]=integrations[_0x15fb('0x55')](_0x5a771d[_0x15fb('0x4e')][_0x15fb('0x53')],_0x5a771d[_0x15fb('0x4e')][_0x15fb('0x32')]);return db[_0x15fb('0x51')][_0x15fb('0x4d')](_0x5a771d['body'],{'include':[{'model':db[_0x15fb('0x56')],'as':'Subjects'},{'model':db[_0x15fb('0x56')],'as':'Descriptions'}]});}return null;})[_0x15fb('0x27')](respondWithResult(_0x3ce022,null))[_0x15fb('0x48')](handleError(_0x3ce022,null));};exports['getFields']=function(_0x24fd2b,_0x1d625a,_0x487e76){var _0x4377c8;var _0xf2c889='';var _0x2de0d8=_0x15fb('0x57');return db[_0x15fb('0x2f')][_0x15fb('0x50')]({'where':{'id':_0x24fd2b[_0x15fb('0x4a')]['id']},'attributes':['id',_0x15fb('0x58'),_0x15fb('0x59'),_0x15fb('0x5a'),_0x15fb('0x5b'),'password',_0x15fb('0x5c')]})[_0x15fb('0x27')](handleEntityNotFound(_0x1d625a,null))[_0x15fb('0x27')](function(_0x36f6d1){if(_0x36f6d1){_0xf2c889=_0x36f6d1[_0x15fb('0x58')];var _0x90a122=_0xf2c889[_0x15fb('0x5d')](-0x1);if(_0x90a122==='/'){_0xf2c889=_0xf2c889[_0x15fb('0x5e')](0x0,_0xf2c889[_0x15fb('0x5f')](_0x90a122));}_0x4377c8=new jsforce['Connection']({'oauth2':{'loginUrl':_0xf2c889,'clientId':_0x36f6d1[_0x15fb('0x59')],'clientSecret':_0x36f6d1[_0x15fb('0x5a')]}});return _0x4377c8[_0x15fb('0x60')](_0x36f6d1[_0x15fb('0x5b')],_0x36f6d1['password'][_0x15fb('0x61')](_0x36f6d1[_0x15fb('0x5c')]));}})['then'](function(_0x106a21){if(_0x106a21){if(!_[_0x15fb('0x62')](_0x24fd2b[_0x15fb('0x36')][_0x15fb('0x63')])){_0x2de0d8=_0x24fd2b[_0x15fb('0x36')]['ticketType'];}return _0x4377c8['sobject'](_0x2de0d8)[_0x15fb('0x64')]();}})[_0x15fb('0x27')](function(_0x198a58){var _0x43167d=[_0x15fb('0x65'),_0x15fb('0x66'),_0x15fb('0x67'),'IsRecurrence','Subject',_0x15fb('0x68')];var _0x51d111=[_0x15fb('0x69'),_0x15fb('0x6a'),_0x15fb('0x6b'),_0x15fb('0x6c'),_0x15fb('0x6d'),'textarea',_0x15fb('0x6e')];if(_0x198a58){_[_0x15fb('0x6f')](_0x198a58[_0x15fb('0x39')],function(_0x55a6a4){return _0x43167d[_0x15fb('0x70')](_0x55a6a4[_0x15fb('0x2b')])||!_0x51d111[_0x15fb('0x70')](_0x55a6a4[_0x15fb('0x32')]);});return{'count':_0x198a58[_0x15fb('0x39')]['length'],'rows':_[_0x15fb('0x2e')](_0x198a58[_0x15fb('0x39')],function(_0x1de833){return{'id':_0x1de833[_0x15fb('0x2b')],'name':_0x1de833[_0x15fb('0x71')],'custom':_0x1de833['custom'],'options':_0x1de833['picklistValues'][_0x15fb('0x4b')]>0x0?_[_0x15fb('0x2e')](_0x1de833[_0x15fb('0x72')],function(_0xb8dab2){return{'name':_0xb8dab2[_0x15fb('0x71')],'value':_0xb8dab2[_0x15fb('0x73')]};}):_0x1de833['type']==_0x15fb('0x6c')?[{'name':_0x15fb('0x74'),'value':'true'},{'name':_0x15fb('0x75'),'value':_0x15fb('0x76')}]:[]};})};}})[_0x15fb('0x27')](respondWithResult(_0x1d625a,null))['catch'](function(_0x162d7e){var _0x5b2fd8=_0x24fd2b['query'][_0x15fb('0x77')]?0x1f4:_0x162d7e[_0x15fb('0x78')]||0x1f4;logger[_0x15fb('0x29')]('getFields,\x20%s,\x20%s,\x20%s',_0x15fb('0x79'),_0x5b2fd8,JSON[_0x15fb('0x7a')](_0x162d7e));delete _0x162d7e[_0x15fb('0x2b')];if(_0x5b2fd8===0x191){_0x5b2fd8=0x190;}_0x1d625a[_0x15fb('0x1d')](_0x5b2fd8)['send'](_0x24fd2b[_0x15fb('0x36')][_0x15fb('0x77')]?{'message':'Wrong\x20credentials','statusCode':_0x162d7e['statusCode']}:_0x162d7e);});}; \ No newline at end of file diff --git a/server/api/intSalesforceAccount/intSalesforceAccount.model.js b/server/api/intSalesforceAccount/intSalesforceAccount.model.js new file mode 100644 index 0000000..1e7b079 --- /dev/null +++ b/server/api/intSalesforceAccount/intSalesforceAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1d81=['util','../../config/logger','api','bluebird','path','rimraf','../../config/environment','exports','define','SalesforceAccount','int_salesforce_accounts'];(function(_0x408c68,_0x51f8b4){var _0x3919c9=function(_0xf424b8){while(--_0xf424b8){_0x408c68['push'](_0x408c68['shift']());}};_0x3919c9(++_0x51f8b4);}(_0x1d81,0x155));var _0x11d8=function(_0x3c729b,_0x2a4146){_0x3c729b=_0x3c729b-0x0;var _0x55894c=_0x1d81[_0x3c729b];return _0x55894c;};'use strict';var _=require('lodash');var util=require(_0x11d8('0x0'));var logger=require(_0x11d8('0x1'))(_0x11d8('0x2'));var moment=require('moment');var BPromise=require(_0x11d8('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x11d8('0x4'));var rimraf=require(_0x11d8('0x5'));var config=require(_0x11d8('0x6'));var attributes=require('./intSalesforceAccount.attributes');var integrations=require('../../components/integrations/configuration');module[_0x11d8('0x7')]=function(_0x3e36c6,_0x18276f){return _0x3e36c6[_0x11d8('0x8')](_0x11d8('0x9'),attributes,{'tableName':_0x11d8('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSalesforceAccount/intSalesforceAccount.rpc.js b/server/api/intSalesforceAccount/intSalesforceAccount.rpc.js new file mode 100644 index 0000000..0fd0137 --- /dev/null +++ b/server/api/intSalesforceAccount/intSalesforceAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf777=['util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','then','info','request\x20sent','debug','error','code','message','SalesforceAccount,\x20%s,\x20%s','result','catch','SalesforceAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetSalesforceAccount','stringify','ShowSalesforceAccount','find','lodash'];(function(_0x4578f8,_0x199c11){var _0x1129f1=function(_0x8a4369){while(--_0x8a4369){_0x4578f8['push'](_0x4578f8['shift']());}};_0x1129f1(++_0x199c11);}(_0xf777,0x1a3));var _0x7f77=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xf777[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x7f77('0x0'));var util=require(_0x7f77('0x1'));var moment=require(_0x7f77('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7f77('0x3'));var db=require(_0x7f77('0x4'))['db'];var utils=require(_0x7f77('0x5'));var logger=require(_0x7f77('0x6'))('rpc');var config=require(_0x7f77('0x7'));var jayson=require(_0x7f77('0x8'));var client=jayson[_0x7f77('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x46c80a,_0x5a313d,_0x30edd6){return new BPromise(function(_0x2b4a3f,_0xb95b13){return client[_0x7f77('0xa')](_0x46c80a,_0x30edd6)[_0x7f77('0xb')](function(_0x1ca13a){logger[_0x7f77('0xc')]('SalesforceAccount,\x20%s,\x20%s',_0x5a313d,_0x7f77('0xd'));logger[_0x7f77('0xe')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x5a313d,'request\x20sent',JSON['stringify'](_0x1ca13a));if(_0x1ca13a['error']){if(_0x1ca13a[_0x7f77('0xf')][_0x7f77('0x10')]===0x1f4){logger[_0x7f77('0xf')]('SalesforceAccount,\x20%s,\x20%s',_0x5a313d,_0x1ca13a[_0x7f77('0xf')]['message']);return _0xb95b13(_0x1ca13a[_0x7f77('0xf')][_0x7f77('0x11')]);}logger[_0x7f77('0xf')](_0x7f77('0x12'),_0x5a313d,_0x1ca13a[_0x7f77('0xf')][_0x7f77('0x11')]);return _0x2b4a3f(_0x1ca13a[_0x7f77('0xf')]['message']);}else{logger['info'](_0x7f77('0x12'),_0x5a313d,_0x7f77('0xd'));_0x2b4a3f(_0x1ca13a[_0x7f77('0x13')][_0x7f77('0x11')]);}})[_0x7f77('0x14')](function(_0x55a04a){logger[_0x7f77('0xf')]('SalesforceAccount,\x20%s,\x20%s',_0x5a313d,_0x55a04a);_0xb95b13(_0x55a04a);});});}exports['GetSalesforceAccount']=function(_0x19f6b6){var _0x28daea=this;return new Promise(function(_0x2a94cc,_0xca9fe6){return db[_0x7f77('0x15')][_0x7f77('0x16')]({'raw':_0x19f6b6[_0x7f77('0x17')]?_0x19f6b6['options'][_0x7f77('0x18')]===undefined?!![]:![]:!![],'where':_0x19f6b6['options']?_0x19f6b6['options'][_0x7f77('0x19')]||null:null,'attributes':_0x19f6b6[_0x7f77('0x17')]?_0x19f6b6[_0x7f77('0x17')][_0x7f77('0x1a')]||null:null,'limit':_0x19f6b6['options']?_0x19f6b6[_0x7f77('0x17')][_0x7f77('0x1b')]||null:null,'include':_0x19f6b6[_0x7f77('0x17')]?_0x19f6b6[_0x7f77('0x17')][_0x7f77('0x1c')]?_[_0x7f77('0x1d')](_0x19f6b6[_0x7f77('0x17')]['include'],function(_0x339d5a){return{'model':db[_0x339d5a[_0x7f77('0x1e')]],'as':_0x339d5a['as'],'attributes':_0x339d5a[_0x7f77('0x1a')],'include':_0x339d5a['include']?_[_0x7f77('0x1d')](_0x339d5a[_0x7f77('0x1c')],function(_0x5dc823){return{'model':db[_0x5dc823['model']],'as':_0x5dc823['as'],'attributes':_0x5dc823['attributes'],'include':_0x5dc823[_0x7f77('0x1c')]?_['map'](_0x5dc823[_0x7f77('0x1c')],function(_0x53ff02){return{'model':db[_0x53ff02[_0x7f77('0x1e')]],'as':_0x53ff02['as'],'attributes':_0x53ff02[_0x7f77('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x7f77('0xb')](function(_0x3ca805){logger[_0x7f77('0xc')](_0x7f77('0x1f'),_0x19f6b6);logger[_0x7f77('0xe')]('GetSalesforceAccount',_0x19f6b6,JSON[_0x7f77('0x20')](_0x3ca805));_0x2a94cc(_0x3ca805);})['catch'](function(_0x38be99){logger['error'](_0x7f77('0x1f'),_0x38be99[_0x7f77('0x11')],_0x19f6b6);_0xca9fe6(_0x28daea['error'](0x1f4,_0x38be99[_0x7f77('0x11')]));});});};exports[_0x7f77('0x21')]=function(_0x6f6ff8){var _0x516944=this;return new Promise(function(_0x4ab735,_0x24d1ae){return db[_0x7f77('0x15')][_0x7f77('0x22')]({'raw':_0x6f6ff8['options']?_0x6f6ff8[_0x7f77('0x17')][_0x7f77('0x18')]===undefined?!![]:![]:!![],'where':_0x6f6ff8['options']?_0x6f6ff8['options']['where']||null:null,'attributes':_0x6f6ff8[_0x7f77('0x17')]?_0x6f6ff8[_0x7f77('0x17')][_0x7f77('0x1a')]||null:null,'include':_0x6f6ff8[_0x7f77('0x17')]?_0x6f6ff8[_0x7f77('0x17')][_0x7f77('0x1c')]?_[_0x7f77('0x1d')](_0x6f6ff8[_0x7f77('0x17')][_0x7f77('0x1c')],function(_0x1a09f1){return{'model':db[_0x1a09f1[_0x7f77('0x1e')]],'as':_0x1a09f1['as'],'attributes':_0x1a09f1[_0x7f77('0x1a')],'include':_0x1a09f1[_0x7f77('0x1c')]?_[_0x7f77('0x1d')](_0x1a09f1['include'],function(_0x2cac56){return{'model':db[_0x2cac56[_0x7f77('0x1e')]],'as':_0x2cac56['as'],'attributes':_0x2cac56[_0x7f77('0x1a')],'include':_0x2cac56[_0x7f77('0x1c')]?_[_0x7f77('0x1d')](_0x2cac56[_0x7f77('0x1c')],function(_0x33ccf3){return{'model':db[_0x33ccf3[_0x7f77('0x1e')]],'as':_0x33ccf3['as'],'attributes':_0x33ccf3[_0x7f77('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x52066e){logger[_0x7f77('0xc')](_0x7f77('0x21'),_0x6f6ff8);logger['debug'](_0x7f77('0x21'),_0x6f6ff8,JSON[_0x7f77('0x20')](_0x52066e));_0x4ab735(_0x52066e);})[_0x7f77('0x14')](function(_0x221f6b){logger[_0x7f77('0xf')](_0x7f77('0x21'),_0x221f6b[_0x7f77('0x11')],_0x6f6ff8);_0x24d1ae(_0x516944[_0x7f77('0xf')](0x1f4,_0x221f6b[_0x7f77('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/intSalesforceConfiguration/index.js b/server/api/intSalesforceConfiguration/index.js new file mode 100644 index 0000000..663b937 --- /dev/null +++ b/server/api/intSalesforceConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5f66=['express','Router','fs-extra','../../components/auth/service','../../config/environment','get','isAuthenticated','/:id','show','/:id/fields','/:id/subjects','getSubjects','put','update','delete','destroy','exports','util','connect-timeout'];(function(_0xd13f1f,_0x4ef287){var _0x7ac4c9=function(_0x171a34){while(--_0x171a34){_0xd13f1f['push'](_0xd13f1f['shift']());}};_0x7ac4c9(++_0x4ef287);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3e5086,_0x48f4a2){_0x3e5086=_0x3e5086-0x0;var _0xfeb102=_0x5f66[_0x3e5086];return _0xfeb102;};'use strict';var multer=require('multer');var util=require(_0x65f6('0x0'));var path=require('path');var timeout=require(_0x65f6('0x1'));var express=require(_0x65f6('0x2'));var router=express[_0x65f6('0x3')]();var fs_extra=require(_0x65f6('0x4'));var auth=require(_0x65f6('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0x65f6('0x6'));var controller=require('./intSalesforceConfiguration.controller');router[_0x65f6('0x7')]('/',auth[_0x65f6('0x8')](),controller['index']);router['get'](_0x65f6('0x9'),auth[_0x65f6('0x8')](),controller[_0x65f6('0xa')]);router[_0x65f6('0x7')](_0x65f6('0xb'),auth[_0x65f6('0x8')](),controller['getFields']);router['get'](_0x65f6('0xc'),auth[_0x65f6('0x8')](),controller[_0x65f6('0xd')]);router[_0x65f6('0x7')]('/:id/descriptions',auth[_0x65f6('0x8')](),controller['getDescriptions']);router['post']('/',auth[_0x65f6('0x8')](),controller['create']);router[_0x65f6('0xe')]('/:id',auth[_0x65f6('0x8')](),controller[_0x65f6('0xf')]);router[_0x65f6('0x10')](_0x65f6('0x9'),auth[_0x65f6('0x8')](),controller[_0x65f6('0x11')]);module[_0x65f6('0x12')]=router; \ No newline at end of file diff --git a/server/api/intSalesforceConfiguration/intSalesforceConfiguration.attributes.js b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.attributes.js new file mode 100644 index 0000000..6c4d7d2 --- /dev/null +++ b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x19c7=['nothing','account','exports','STRING','ENUM','Task','Case','contact_lead','contact','lead','account_contact_lead'];(function(_0x51c842,_0x2c47a8){var _0x3977a0=function(_0x521917){while(--_0x521917){_0x51c842['push'](_0x51c842['shift']());}};_0x3977a0(++_0x2c47a8);}(_0x19c7,0x16d));var _0x719c=function(_0x550b3e,_0x3b071b){_0x550b3e=_0x550b3e-0x0;var _0x47e01d=_0x19c7[_0x550b3e];return _0x47e01d;};'use strict';var Sequelize=require('sequelize');module[_0x719c('0x0')]={'name':{'type':Sequelize[_0x719c('0x1')]},'description':{'type':Sequelize[_0x719c('0x1')]},'ticketType':{'type':Sequelize[_0x719c('0x2')](_0x719c('0x3'),_0x719c('0x4')),'defaultValue':_0x719c('0x3')},'moduleSearch':{'type':Sequelize[_0x719c('0x2')](_0x719c('0x5'),_0x719c('0x6'),_0x719c('0x7'),_0x719c('0x8'),'account'),'defaultValue':_0x719c('0x5')},'moduleCreate':{'type':Sequelize[_0x719c('0x2')](_0x719c('0x9'),_0x719c('0x6'),_0x719c('0x7'),_0x719c('0xa')),'defaultValue':'lead'},'leadId':{'type':Sequelize[_0x719c('0x1')]},'additionalSearchAccount':{'type':Sequelize[_0x719c('0x1')]},'additionalSearchContact':{'type':Sequelize[_0x719c('0x1')]},'additionalSearchLead':{'type':Sequelize[_0x719c('0x1')]}}; \ No newline at end of file diff --git a/server/api/intSalesforceConfiguration/intSalesforceConfiguration.controller.js b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.controller.js new file mode 100644 index 0000000..438a239 --- /dev/null +++ b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe12c=['key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','filters','filter','merge','VIRTUAL','options','findAll','rows','catch','show','rawAttributes','include','find','create','body','params','getFields','findOne','SalesforceField','order','pick','getSubjects','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','status','offset','limit','undefined','count','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','index','map','SalesforceConfiguration','fieldName','type'];(function(_0x35e7fb,_0x57b674){var _0x4257e1=function(_0x4a6e04){while(--_0x4a6e04){_0x35e7fb['push'](_0x35e7fb['shift']());}};_0x4257e1(++_0x57b674);}(_0xe12c,0x118));var _0xce12=function(_0x269ee8,_0x477226){_0x269ee8=_0x269ee8-0x0;var _0x4d98bd=_0xe12c[_0x269ee8];return _0x4d98bd;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xce12('0x0'));var zipdir=require(_0xce12('0x1'));var jsonpatch=require(_0xce12('0x2'));var rp=require(_0xce12('0x3'));var moment=require(_0xce12('0x4'));var BPromise=require(_0xce12('0x5'));var Mustache=require(_0xce12('0x6'));var util=require(_0xce12('0x7'));var path=require(_0xce12('0x8'));var sox=require(_0xce12('0x9'));var csv=require(_0xce12('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xce12('0xb'));var _=require(_0xce12('0xc'));var squel=require(_0xce12('0xd'));var crypto=require(_0xce12('0xe'));var jsforce=require(_0xce12('0xf'));var deskjs=require(_0xce12('0x10'));var toCsv=require(_0xce12('0xa'));var querystring=require(_0xce12('0x11'));var Papa=require(_0xce12('0x12'));var Redis=require('ioredis');var authService=require(_0xce12('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xce12('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xce12('0x15'));var utils=require(_0xce12('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xce12('0x17'));var db=require(_0xce12('0x18'))['db'];function respondWithStatusCode(_0x4fceec,_0x3c593b){_0x3c593b=_0x3c593b||0xcc;return function(_0x6a61c7){if(_0x6a61c7){return _0x4fceec[_0xce12('0x19')](_0x3c593b);}return _0x4fceec['status'](_0x3c593b)[_0xce12('0x1a')]();};}function respondWithResult(_0x59458e,_0x5201cf){_0x5201cf=_0x5201cf||0xc8;return function(_0x34f4dd){if(_0x34f4dd){return _0x59458e[_0xce12('0x1b')](_0x5201cf)['json'](_0x34f4dd);}};}function respondWithFilteredResult(_0xf7d36,_0x43c55b){return function(_0x3d3810){if(_0x3d3810){var _0x4979b6=typeof _0x43c55b[_0xce12('0x1c')]==='undefined'&&typeof _0x43c55b[_0xce12('0x1d')]===_0xce12('0x1e');var _0xb481e1=_0x3d3810[_0xce12('0x1f')];var _0x14b630=_0x4979b6?0x0:_0x43c55b['offset'];var _0xe312d=_0x4979b6?_0x3d3810[_0xce12('0x1f')]:_0x43c55b[_0xce12('0x1c')]+_0x43c55b['limit'];var _0x4a5e57;if(_0xe312d>=_0xb481e1){_0xe312d=_0xb481e1;_0x4a5e57=0xc8;}else{_0x4a5e57=0xce;}_0xf7d36[_0xce12('0x1b')](_0x4a5e57);return _0xf7d36['set'](_0xce12('0x20'),_0x14b630+'-'+_0xe312d+'/'+_0xb481e1)[_0xce12('0x21')](_0x3d3810);}return null;};}function patchUpdates(_0x52d237){return function(_0x59d8c6){try{jsonpatch[_0xce12('0x22')](_0x59d8c6,_0x52d237,!![]);}catch(_0x4cd6fd){return BPromise[_0xce12('0x23')](_0x4cd6fd);}return _0x59d8c6[_0xce12('0x24')]();};}function saveUpdates(_0xc6af05,_0x246744){return function(_0x22bc0a){if(_0x22bc0a){return _0x22bc0a[_0xce12('0x25')](_0xc6af05)[_0xce12('0x26')](function(_0x34c1f6){return _0x34c1f6;});}return null;};}function removeEntity(_0x560710,_0x255a22){return function(_0x140c17){if(_0x140c17){return _0x140c17[_0xce12('0x27')]()[_0xce12('0x26')](function(){_0x560710['status'](0xcc)[_0xce12('0x1a')]();});}};}function handleEntityNotFound(_0x18af83,_0x553459){return function(_0xeea774){if(!_0xeea774){_0x18af83[_0xce12('0x19')](0x194);}return _0xeea774;};}function handleError(_0x1bfb4d,_0x1b75d9){_0x1b75d9=_0x1b75d9||0x1f4;return function(_0x30883b){logger[_0xce12('0x28')](_0x30883b[_0xce12('0x29')]);if(_0x30883b['name']){delete _0x30883b[_0xce12('0x2a')];}_0x1bfb4d['status'](_0x1b75d9)['send'](_0x30883b);};}exports[_0xce12('0x2b')]=function(_0x4b59cd,_0x2cf520){var _0xcb48cd={},_0xb9f705={},_0xd5ea3={'count':0x0,'rows':[]};var _0x402c29=_[_0xce12('0x2c')](db[_0xce12('0x2d')]['rawAttributes'],function(_0x2b9f7d){return{'name':_0x2b9f7d[_0xce12('0x2e')],'type':_0x2b9f7d[_0xce12('0x2f')][_0xce12('0x30')]};});_0xb9f705[_0xce12('0x31')]=_['map'](_0x402c29,_0xce12('0x2a'));_0xb9f705[_0xce12('0x32')]=_[_0xce12('0x33')](_0x4b59cd[_0xce12('0x32')]);_0xb9f705['filters']=_['intersection'](_0xb9f705[_0xce12('0x31')],_0xb9f705[_0xce12('0x32')]);_0xcb48cd[_0xce12('0x34')]=_[_0xce12('0x35')](_0xb9f705[_0xce12('0x31')],qs[_0xce12('0x36')](_0x4b59cd[_0xce12('0x32')][_0xce12('0x36')]));_0xcb48cd['attributes']=_0xcb48cd['attributes'][_0xce12('0x37')]?_0xcb48cd[_0xce12('0x34')]:_0xb9f705[_0xce12('0x31')];if(!_0x4b59cd[_0xce12('0x32')][_0xce12('0x38')](_0xce12('0x39'))){_0xcb48cd[_0xce12('0x1d')]=qs['limit'](_0x4b59cd['query'][_0xce12('0x1d')]);_0xcb48cd['offset']=qs[_0xce12('0x1c')](_0x4b59cd['query'][_0xce12('0x1c')]);}_0xcb48cd['order']=qs[_0xce12('0x3a')](_0x4b59cd['query'][_0xce12('0x3a')]);_0xcb48cd[_0xce12('0x3b')]=qs[_0xce12('0x3c')](_['pick'](_0x4b59cd[_0xce12('0x32')],_0xb9f705[_0xce12('0x3c')]),_0x402c29);if(_0x4b59cd[_0xce12('0x32')][_0xce12('0x3d')]){_0xcb48cd[_0xce12('0x3b')]=_[_0xce12('0x3e')](_0xcb48cd[_0xce12('0x3b')],{'$or':_['map'](_0x402c29,function(_0x1d718a){if(_0x1d718a[_0xce12('0x2f')]!==_0xce12('0x3f')){var _0x283446={};_0x283446[_0x1d718a['name']]={'$like':'%'+_0x4b59cd[_0xce12('0x32')][_0xce12('0x3d')]+'%'};return _0x283446;}})});}_0xcb48cd=_[_0xce12('0x3e')]({},_0xcb48cd,_0x4b59cd[_0xce12('0x40')]);var _0x309b7b={'where':_0xcb48cd[_0xce12('0x3b')]};return db[_0xce12('0x2d')]['count'](_0x309b7b)[_0xce12('0x26')](function(_0x4b48c9){_0xd5ea3[_0xce12('0x1f')]=_0x4b48c9;if(_0x4b59cd[_0xce12('0x32')]['includeAll']){_0xcb48cd['include']=[{'all':!![]}];}return db['SalesforceConfiguration'][_0xce12('0x41')](_0xcb48cd);})[_0xce12('0x26')](function(_0x4e7d37){_0xd5ea3[_0xce12('0x42')]=_0x4e7d37;return _0xd5ea3;})[_0xce12('0x26')](respondWithFilteredResult(_0x2cf520,_0xcb48cd))[_0xce12('0x43')](handleError(_0x2cf520,null));};exports[_0xce12('0x44')]=function(_0x59bfc0,_0x4d189e){var _0x2b8ec4={'raw':![],'where':{'id':_0x59bfc0['params']['id']}},_0xc69056={};_0xc69056[_0xce12('0x31')]=_[_0xce12('0x33')](db[_0xce12('0x2d')][_0xce12('0x45')]);_0xc69056[_0xce12('0x32')]=_[_0xce12('0x33')](_0x59bfc0[_0xce12('0x32')]);_0xc69056[_0xce12('0x3c')]=_[_0xce12('0x35')](_0xc69056[_0xce12('0x31')],_0xc69056[_0xce12('0x32')]);_0x2b8ec4[_0xce12('0x34')]=_['intersection'](_0xc69056[_0xce12('0x31')],qs[_0xce12('0x36')](_0x59bfc0[_0xce12('0x32')]['fields']));_0x2b8ec4['attributes']=_0x2b8ec4[_0xce12('0x34')][_0xce12('0x37')]?_0x2b8ec4['attributes']:_0xc69056[_0xce12('0x31')];if(_0x59bfc0[_0xce12('0x32')]['includeAll']){_0x2b8ec4[_0xce12('0x46')]=[{'all':!![]}];}_0x2b8ec4=_['merge']({},_0x2b8ec4,_0x59bfc0[_0xce12('0x40')]);return db[_0xce12('0x2d')][_0xce12('0x47')](_0x2b8ec4)[_0xce12('0x26')](handleEntityNotFound(_0x4d189e,null))[_0xce12('0x26')](respondWithResult(_0x4d189e,null))['catch'](handleError(_0x4d189e,null));};exports[_0xce12('0x48')]=function(_0x5e6627,_0x2e91af){return db['SalesforceConfiguration'][_0xce12('0x48')](_0x5e6627['body'],{})[_0xce12('0x26')](respondWithResult(_0x2e91af,0xc9))[_0xce12('0x43')](handleError(_0x2e91af,null));};exports[_0xce12('0x25')]=function(_0x16ddd5,_0x483b49){if(_0x16ddd5['body']['id']){delete _0x16ddd5[_0xce12('0x49')]['id'];}return db['SalesforceConfiguration'][_0xce12('0x47')]({'where':{'id':_0x16ddd5[_0xce12('0x4a')]['id']}})[_0xce12('0x26')](handleEntityNotFound(_0x483b49,null))[_0xce12('0x26')](saveUpdates(_0x16ddd5['body'],null))[_0xce12('0x26')](respondWithResult(_0x483b49,null))[_0xce12('0x43')](handleError(_0x483b49,null));};exports[_0xce12('0x27')]=function(_0x338e54,_0x45b8ec){return db[_0xce12('0x2d')][_0xce12('0x47')]({'where':{'id':_0x338e54[_0xce12('0x4a')]['id']}})['then'](handleEntityNotFound(_0x45b8ec,null))[_0xce12('0x26')](removeEntity(_0x45b8ec,null))[_0xce12('0x43')](handleError(_0x45b8ec,null));};exports[_0xce12('0x4b')]=function(_0x327ce2,_0x3e1c97,_0xe6c32c){var _0x34cd16={};var _0x323975={};var _0x2a69a0;var _0x365eb6;return db[_0xce12('0x2d')][_0xce12('0x4c')]({'where':{'id':_0x327ce2[_0xce12('0x4a')]['id']}})['then'](handleEntityNotFound(_0x3e1c97,null))['then'](function(_0x55dee7){if(_0x55dee7){_0x2a69a0=_0x55dee7;_0x323975[_0xce12('0x31')]=_[_0xce12('0x33')](db[_0xce12('0x4d')]['rawAttributes']);_0x323975[_0xce12('0x32')]=_['keys'](_0x327ce2[_0xce12('0x32')]);_0x323975[_0xce12('0x3c')]=_[_0xce12('0x35')](_0x323975[_0xce12('0x31')],_0x323975[_0xce12('0x32')]);_0x34cd16[_0xce12('0x34')]=_['intersection'](_0x323975[_0xce12('0x31')],qs[_0xce12('0x36')](_0x327ce2[_0xce12('0x32')][_0xce12('0x36')]));_0x34cd16['attributes']=_0x34cd16['attributes']['length']?_0x34cd16[_0xce12('0x34')]:_0x323975['model'];_0x34cd16[_0xce12('0x4e')]=qs[_0xce12('0x3a')](_0x327ce2['query'][_0xce12('0x3a')]);_0x34cd16[_0xce12('0x3b')]=qs[_0xce12('0x3c')](_[_0xce12('0x4f')](_0x327ce2[_0xce12('0x32')],_0x323975[_0xce12('0x3c')]));if(_0x327ce2[_0xce12('0x32')][_0xce12('0x3d')]){_0x34cd16[_0xce12('0x3b')]=_[_0xce12('0x3e')](_0x34cd16[_0xce12('0x3b')],{'$or':_[_0xce12('0x2c')](_0x34cd16[_0xce12('0x34')],function(_0x4c6bc5){var _0x501128={};_0x501128[_0x4c6bc5]={'$like':'%'+_0x327ce2['query']['filter']+'%'};return _0x501128;})});}_0x34cd16=_['merge']({},_0x34cd16,_0x327ce2['options']);return _0x2a69a0[_0xce12('0x4b')](_0x34cd16);}})[_0xce12('0x26')](function(_0x5bd824){if(_0x5bd824){_0x365eb6=_0x5bd824['length'];if(!_0x327ce2['query']['hasOwnProperty'](_0xce12('0x39'))){_0x34cd16[_0xce12('0x1d')]=qs['limit'](_0x327ce2[_0xce12('0x32')][_0xce12('0x1d')]);_0x34cd16[_0xce12('0x1c')]=qs[_0xce12('0x1c')](_0x327ce2['query'][_0xce12('0x1c')]);}return _0x2a69a0[_0xce12('0x4b')](_0x34cd16);}})['then'](function(_0x1542c1){if(_0x1542c1){return _0x1542c1?{'count':_0x365eb6,'rows':_0x1542c1}:null;}})[_0xce12('0x26')](respondWithResult(_0x3e1c97,null))[_0xce12('0x43')](handleError(_0x3e1c97,null));};exports[_0xce12('0x50')]=function(_0x1a3e46,_0x594ef9,_0x1c6a05){var _0x50e384={};var _0xe959ef={};var _0xa56d30;var _0x375f34;return db[_0xce12('0x2d')]['findOne']({'where':{'id':_0x1a3e46[_0xce12('0x4a')]['id']}})[_0xce12('0x26')](handleEntityNotFound(_0x594ef9,null))[_0xce12('0x26')](function(_0xab2e2a){if(_0xab2e2a){_0xa56d30=_0xab2e2a;_0xe959ef[_0xce12('0x31')]=_[_0xce12('0x33')](db['SalesforceField'][_0xce12('0x45')]);_0xe959ef[_0xce12('0x32')]=_['keys'](_0x1a3e46[_0xce12('0x32')]);_0xe959ef[_0xce12('0x3c')]=_[_0xce12('0x35')](_0xe959ef[_0xce12('0x31')],_0xe959ef[_0xce12('0x32')]);_0x50e384[_0xce12('0x34')]=_[_0xce12('0x35')](_0xe959ef['model'],qs[_0xce12('0x36')](_0x1a3e46['query'][_0xce12('0x36')]));_0x50e384[_0xce12('0x34')]=_0x50e384[_0xce12('0x34')][_0xce12('0x37')]?_0x50e384[_0xce12('0x34')]:_0xe959ef[_0xce12('0x31')];_0x50e384[_0xce12('0x4e')]=qs['sort'](_0x1a3e46['query']['sort']);_0x50e384[_0xce12('0x3b')]=qs[_0xce12('0x3c')](_[_0xce12('0x4f')](_0x1a3e46['query'],_0xe959ef[_0xce12('0x3c')]));if(_0x1a3e46[_0xce12('0x32')][_0xce12('0x3d')]){_0x50e384[_0xce12('0x3b')]=_['merge'](_0x50e384[_0xce12('0x3b')],{'$or':_[_0xce12('0x2c')](_0x50e384[_0xce12('0x34')],function(_0x2696eb){var _0x591e20={};_0x591e20[_0x2696eb]={'$like':'%'+_0x1a3e46[_0xce12('0x32')]['filter']+'%'};return _0x591e20;})});}_0x50e384=_[_0xce12('0x3e')]({},_0x50e384,_0x1a3e46['options']);return _0xa56d30[_0xce12('0x50')](_0x50e384);}})[_0xce12('0x26')](function(_0x28d3dd){if(_0x28d3dd){_0x375f34=_0x28d3dd[_0xce12('0x37')];if(!_0x1a3e46[_0xce12('0x32')][_0xce12('0x38')](_0xce12('0x39'))){_0x50e384[_0xce12('0x1d')]=qs[_0xce12('0x1d')](_0x1a3e46[_0xce12('0x32')][_0xce12('0x1d')]);_0x50e384[_0xce12('0x1c')]=qs['offset'](_0x1a3e46[_0xce12('0x32')]['offset']);}return _0xa56d30['getSubjects'](_0x50e384);}})[_0xce12('0x26')](function(_0x4d523c){if(_0x4d523c){return _0x4d523c?{'count':_0x375f34,'rows':_0x4d523c}:null;}})[_0xce12('0x26')](respondWithResult(_0x594ef9,null))['catch'](handleError(_0x594ef9,null));};exports[_0xce12('0x51')]=function(_0x528963,_0x401ad7,_0x38c58c){var _0x5afbd3={};var _0x3dec1a={};var _0xd8a9e4;var _0x313b9a;return db[_0xce12('0x2d')][_0xce12('0x4c')]({'where':{'id':_0x528963[_0xce12('0x4a')]['id']}})[_0xce12('0x26')](handleEntityNotFound(_0x401ad7,null))[_0xce12('0x26')](function(_0xd40b90){if(_0xd40b90){_0xd8a9e4=_0xd40b90;_0x3dec1a[_0xce12('0x31')]=_['keys'](db[_0xce12('0x4d')][_0xce12('0x45')]);_0x3dec1a[_0xce12('0x32')]=_[_0xce12('0x33')](_0x528963[_0xce12('0x32')]);_0x3dec1a['filters']=_[_0xce12('0x35')](_0x3dec1a['model'],_0x3dec1a[_0xce12('0x32')]);_0x5afbd3[_0xce12('0x34')]=_[_0xce12('0x35')](_0x3dec1a['model'],qs['fields'](_0x528963[_0xce12('0x32')][_0xce12('0x36')]));_0x5afbd3[_0xce12('0x34')]=_0x5afbd3[_0xce12('0x34')][_0xce12('0x37')]?_0x5afbd3[_0xce12('0x34')]:_0x3dec1a[_0xce12('0x31')];_0x5afbd3[_0xce12('0x4e')]=qs[_0xce12('0x3a')](_0x528963[_0xce12('0x32')][_0xce12('0x3a')]);_0x5afbd3[_0xce12('0x3b')]=qs[_0xce12('0x3c')](_[_0xce12('0x4f')](_0x528963['query'],_0x3dec1a[_0xce12('0x3c')]));if(_0x528963[_0xce12('0x32')][_0xce12('0x3d')]){_0x5afbd3[_0xce12('0x3b')]=_[_0xce12('0x3e')](_0x5afbd3[_0xce12('0x3b')],{'$or':_[_0xce12('0x2c')](_0x5afbd3[_0xce12('0x34')],function(_0x13bc85){var _0x227439={};_0x227439[_0x13bc85]={'$like':'%'+_0x528963[_0xce12('0x32')]['filter']+'%'};return _0x227439;})});}_0x5afbd3=_[_0xce12('0x3e')]({},_0x5afbd3,_0x528963[_0xce12('0x40')]);return _0xd8a9e4[_0xce12('0x51')](_0x5afbd3);}})[_0xce12('0x26')](function(_0x3ec44f){if(_0x3ec44f){_0x313b9a=_0x3ec44f['length'];if(!_0x528963[_0xce12('0x32')][_0xce12('0x38')](_0xce12('0x39'))){_0x5afbd3['limit']=qs['limit'](_0x528963[_0xce12('0x32')][_0xce12('0x1d')]);_0x5afbd3[_0xce12('0x1c')]=qs[_0xce12('0x1c')](_0x528963[_0xce12('0x32')][_0xce12('0x1c')]);}return _0xd8a9e4['getDescriptions'](_0x5afbd3);}})[_0xce12('0x26')](function(_0x442477){if(_0x442477){return _0x442477?{'count':_0x313b9a,'rows':_0x442477}:null;}})[_0xce12('0x26')](respondWithResult(_0x401ad7,null))['catch'](handleError(_0x401ad7,null));}; \ No newline at end of file diff --git a/server/api/intSalesforceConfiguration/intSalesforceConfiguration.model.js b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.model.js new file mode 100644 index 0000000..9b4dee9 --- /dev/null +++ b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4232=['int_salesforce_configurations','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','exports','define','SalesforceConfiguration'];(function(_0x123cbd,_0x4086b8){var _0x1b7765=function(_0xd9f45c){while(--_0xd9f45c){_0x123cbd['push'](_0x123cbd['shift']());}};_0x1b7765(++_0x4086b8);}(_0x4232,0x15f));var _0x2423=function(_0x3428cd,_0x2e977d){_0x3428cd=_0x3428cd-0x0;var _0x279bde=_0x4232[_0x3428cd];return _0x279bde;};'use strict';var _=require(_0x2423('0x0'));var util=require(_0x2423('0x1'));var logger=require(_0x2423('0x2'))(_0x2423('0x3'));var moment=require(_0x2423('0x4'));var BPromise=require(_0x2423('0x5'));var rp=require(_0x2423('0x6'));var fs=require('fs');var path=require(_0x2423('0x7'));var rimraf=require(_0x2423('0x8'));var config=require(_0x2423('0x9'));var attributes=require('./intSalesforceConfiguration.attributes');module[_0x2423('0xa')]=function(_0x2c4523,_0x3b95f3){return _0x2c4523[_0x2423('0xb')](_0x2423('0xc'),attributes,{'tableName':_0x2423('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSalesforceConfiguration/intSalesforceConfiguration.rpc.js b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.rpc.js new file mode 100644 index 0000000..896f0ed --- /dev/null +++ b/server/api/intSalesforceConfiguration/intSalesforceConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe4dc=['SalesforceConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','request','then','info','SalesforceConfiguration,\x20%s,\x20%s','debug'];(function(_0x2079f9,_0x5ee952){var _0x2bb75a=function(_0x2199b2){while(--_0x2199b2){_0x2079f9['push'](_0x2079f9['shift']());}};_0x2bb75a(++_0x5ee952);}(_0xe4dc,0x167));var _0xce4d=function(_0x5a8e42,_0x1bdf90){_0x5a8e42=_0x5a8e42-0x0;var _0x3939ef=_0xe4dc[_0x5a8e42];return _0x3939ef;};'use strict';var _=require(_0xce4d('0x0'));var util=require(_0xce4d('0x1'));var moment=require(_0xce4d('0x2'));var BPromise=require('bluebird');var rs=require(_0xce4d('0x3'));var fs=require('fs');var Redis=require(_0xce4d('0x4'));var db=require(_0xce4d('0x5'))['db'];var utils=require(_0xce4d('0x6'));var logger=require(_0xce4d('0x7'))('rpc');var config=require(_0xce4d('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xce4d('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x47363f,_0xde308d,_0x3b8504){return new BPromise(function(_0x464019,_0x168c7f){return client[_0xce4d('0xa')](_0x47363f,_0x3b8504)[_0xce4d('0xb')](function(_0x4df6d5){logger[_0xce4d('0xc')](_0xce4d('0xd'),_0xde308d,'request\x20sent');logger[_0xce4d('0xe')](_0xce4d('0xf'),_0xde308d,_0xce4d('0x10'),JSON[_0xce4d('0x11')](_0x4df6d5));if(_0x4df6d5['error']){if(_0x4df6d5[_0xce4d('0x12')][_0xce4d('0x13')]===0x1f4){logger[_0xce4d('0x12')](_0xce4d('0xd'),_0xde308d,_0x4df6d5[_0xce4d('0x12')]['message']);return _0x168c7f(_0x4df6d5[_0xce4d('0x12')][_0xce4d('0x14')]);}logger['error'](_0xce4d('0xd'),_0xde308d,_0x4df6d5['error'][_0xce4d('0x14')]);return _0x464019(_0x4df6d5[_0xce4d('0x12')][_0xce4d('0x14')]);}else{logger[_0xce4d('0xc')]('SalesforceConfiguration,\x20%s,\x20%s',_0xde308d,'request\x20sent');_0x464019(_0x4df6d5['result'][_0xce4d('0x14')]);}})[_0xce4d('0x15')](function(_0x3a94f8){logger['error'](_0xce4d('0xd'),_0xde308d,_0x3a94f8);_0x168c7f(_0x3a94f8);});});} \ No newline at end of file diff --git a/server/api/intSalesforceField/index.js b/server/api/intSalesforceField/index.js new file mode 100644 index 0000000..74a88f2 --- /dev/null +++ b/server/api/intSalesforceField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd634=['exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intSalesforceField.controller','get','index','/:id','isAuthenticated','show','create','put','update','destroy'];(function(_0x5c85ef,_0x151652){var _0x55675a=function(_0x449ad4){while(--_0x449ad4){_0x5c85ef['push'](_0x5c85ef['shift']());}};_0x55675a(++_0x151652);}(_0xd634,0x7f));var _0x4d63=function(_0x3b594b,_0x5835c3){_0x3b594b=_0x3b594b-0x0;var _0x1ea5f8=_0xd634[_0x3b594b];return _0x1ea5f8;};'use strict';var multer=require(_0x4d63('0x0'));var util=require(_0x4d63('0x1'));var path=require(_0x4d63('0x2'));var timeout=require(_0x4d63('0x3'));var express=require(_0x4d63('0x4'));var router=express[_0x4d63('0x5')]();var fs_extra=require(_0x4d63('0x6'));var auth=require(_0x4d63('0x7'));var interaction=require(_0x4d63('0x8'));var config=require(_0x4d63('0x9'));var controller=require(_0x4d63('0xa'));router[_0x4d63('0xb')]('/',auth['isAuthenticated'](),controller[_0x4d63('0xc')]);router[_0x4d63('0xb')](_0x4d63('0xd'),auth[_0x4d63('0xe')](),controller[_0x4d63('0xf')]);router['post']('/',auth[_0x4d63('0xe')](),controller[_0x4d63('0x10')]);router[_0x4d63('0x11')](_0x4d63('0xd'),auth['isAuthenticated'](),controller[_0x4d63('0x12')]);router['delete']('/:id',auth[_0x4d63('0xe')](),controller[_0x4d63('0x13')]);module[_0x4d63('0x14')]=router; \ No newline at end of file diff --git a/server/api/intSalesforceField/intSalesforceField.attributes.js b/server/api/intSalesforceField/intSalesforceField.attributes.js new file mode 100644 index 0000000..9741938 --- /dev/null +++ b/server/api/intSalesforceField/intSalesforceField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xad89=['keyValue','picklist','string','STRING','ENUM','variable','customVariable'];(function(_0x6dc86a,_0x2aad2f){var _0x5cb20e=function(_0x46c55f){while(--_0x46c55f){_0x6dc86a['push'](_0x6dc86a['shift']());}};_0x5cb20e(++_0x2aad2f);}(_0xad89,0x11c));var _0x9ad8=function(_0x1ee9a1,_0x5f1434){_0x1ee9a1=_0x1ee9a1-0x0;var _0x21270f=_0xad89[_0x1ee9a1];return _0x21270f;};'use strict';var Sequelize=require('sequelize');module['exports']={'type':{'type':Sequelize[_0x9ad8('0x0')]('string',_0x9ad8('0x1'),_0x9ad8('0x2'),_0x9ad8('0x3'),_0x9ad8('0x4')),'defaultValue':_0x9ad8('0x5')},'content':{'type':Sequelize['STRING']},'key':{'type':Sequelize[_0x9ad8('0x6')]},'keyType':{'type':Sequelize['ENUM']('string','variable',_0x9ad8('0x2'))},'keyContent':{'type':Sequelize[_0x9ad8('0x6')]},'idField':{'type':Sequelize[_0x9ad8('0x6')]},'variableName':{'type':Sequelize[_0x9ad8('0x6')]}}; \ No newline at end of file diff --git a/server/api/intSalesforceField/intSalesforceField.controller.js b/server/api/intSalesforceField/intSalesforceField.controller.js new file mode 100644 index 0000000..7b99dcc --- /dev/null +++ b/server/api/intSalesforceField/intSalesforceField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e1a=['rows','show','include','find','catch','create','body','params','eml-format','zip-dir','fast-json-patch','moment','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','Content-Range','update','then','destroy','sendStatus','error','stack','name','send','index','map','SalesforceField','rawAttributes','type','query','keys','filters','intersection','model','fields','attributes','length','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll'];(function(_0x515ef2,_0x19dfa0){var _0x564aa7=function(_0x1b7fa9){while(--_0x1b7fa9){_0x515ef2['push'](_0x515ef2['shift']());}};_0x564aa7(++_0x19dfa0);}(_0x4e1a,0x1cf));var _0xa4e1=function(_0x427b84,_0xcd6a51){_0x427b84=_0x427b84-0x0;var _0x2b8116=_0x4e1a[_0x427b84];return _0x2b8116;};'use strict';var emlformat=require(_0xa4e1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa4e1('0x1'));var jsonpatch=require(_0xa4e1('0x2'));var rp=require('request-promise');var moment=require(_0xa4e1('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xa4e1('0x4'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa4e1('0x5'));var _=require(_0xa4e1('0x6'));var squel=require(_0xa4e1('0x7'));var crypto=require(_0xa4e1('0x8'));var jsforce=require('jsforce');var deskjs=require(_0xa4e1('0x9'));var toCsv=require(_0xa4e1('0x4'));var querystring=require(_0xa4e1('0xa'));var Papa=require(_0xa4e1('0xb'));var Redis=require(_0xa4e1('0xc'));var authService=require(_0xa4e1('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa4e1('0xe'));var logger=require(_0xa4e1('0xf'))('api');var utils=require('../../config/utils');var config=require(_0xa4e1('0x10'));var licenseUtil=require(_0xa4e1('0x11'));var db=require(_0xa4e1('0x12'))['db'];function respondWithStatusCode(_0x4e147d,_0x311748){_0x311748=_0x311748||0xcc;return function(_0x48cc29){if(_0x48cc29){return _0x4e147d['sendStatus'](_0x311748);}return _0x4e147d[_0xa4e1('0x13')](_0x311748)[_0xa4e1('0x14')]();};}function respondWithResult(_0x5a6d24,_0x41b1fa){_0x41b1fa=_0x41b1fa||0xc8;return function(_0x583fa6){if(_0x583fa6){return _0x5a6d24['status'](_0x41b1fa)[_0xa4e1('0x15')](_0x583fa6);}};}function respondWithFilteredResult(_0x4cf6b7,_0x3d5fd9){return function(_0x5f1c9b){if(_0x5f1c9b){var _0x7e01dd=typeof _0x3d5fd9[_0xa4e1('0x16')]==='undefined'&&typeof _0x3d5fd9['limit']===_0xa4e1('0x17');var _0x41c0da=_0x5f1c9b[_0xa4e1('0x18')];var _0x2c7f28=_0x7e01dd?0x0:_0x3d5fd9[_0xa4e1('0x16')];var _0x3b5bc3=_0x7e01dd?_0x5f1c9b[_0xa4e1('0x18')]:_0x3d5fd9[_0xa4e1('0x16')]+_0x3d5fd9[_0xa4e1('0x19')];var _0x3c0d8a;if(_0x3b5bc3>=_0x41c0da){_0x3b5bc3=_0x41c0da;_0x3c0d8a=0xc8;}else{_0x3c0d8a=0xce;}_0x4cf6b7['status'](_0x3c0d8a);return _0x4cf6b7['set'](_0xa4e1('0x1a'),_0x2c7f28+'-'+_0x3b5bc3+'/'+_0x41c0da)[_0xa4e1('0x15')](_0x5f1c9b);}return null;};}function patchUpdates(_0x5f2146){return function(_0x42be0a){try{jsonpatch['apply'](_0x42be0a,_0x5f2146,!![]);}catch(_0x5bc178){return BPromise['reject'](_0x5bc178);}return _0x42be0a['save']();};}function saveUpdates(_0x2824ab,_0x50ed06){return function(_0x4cd1f3){if(_0x4cd1f3){return _0x4cd1f3[_0xa4e1('0x1b')](_0x2824ab)[_0xa4e1('0x1c')](function(_0x8ef957){return _0x8ef957;});}return null;};}function removeEntity(_0x3cf19d,_0x694866){return function(_0x518d42){if(_0x518d42){return _0x518d42[_0xa4e1('0x1d')]()['then'](function(){_0x3cf19d[_0xa4e1('0x13')](0xcc)[_0xa4e1('0x14')]();});}};}function handleEntityNotFound(_0x38ea67,_0xc5298){return function(_0x30dd93){if(!_0x30dd93){_0x38ea67[_0xa4e1('0x1e')](0x194);}return _0x30dd93;};}function handleError(_0x5340d4,_0x5e3f8e){_0x5e3f8e=_0x5e3f8e||0x1f4;return function(_0x45c28d){logger[_0xa4e1('0x1f')](_0x45c28d[_0xa4e1('0x20')]);if(_0x45c28d[_0xa4e1('0x21')]){delete _0x45c28d[_0xa4e1('0x21')];}_0x5340d4[_0xa4e1('0x13')](_0x5e3f8e)[_0xa4e1('0x22')](_0x45c28d);};}exports[_0xa4e1('0x23')]=function(_0x4cc8cc,_0x47d7f3){var _0x284942={},_0x14dafd={},_0x213b20={'count':0x0,'rows':[]};var _0x4e72bc=_[_0xa4e1('0x24')](db[_0xa4e1('0x25')][_0xa4e1('0x26')],function(_0x486105){return{'name':_0x486105['fieldName'],'type':_0x486105[_0xa4e1('0x27')]['key']};});_0x14dafd['model']=_[_0xa4e1('0x24')](_0x4e72bc,'name');_0x14dafd[_0xa4e1('0x28')]=_[_0xa4e1('0x29')](_0x4cc8cc[_0xa4e1('0x28')]);_0x14dafd[_0xa4e1('0x2a')]=_[_0xa4e1('0x2b')](_0x14dafd[_0xa4e1('0x2c')],_0x14dafd[_0xa4e1('0x28')]);_0x284942['attributes']=_['intersection'](_0x14dafd['model'],qs[_0xa4e1('0x2d')](_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x2d')]));_0x284942[_0xa4e1('0x2e')]=_0x284942['attributes'][_0xa4e1('0x2f')]?_0x284942[_0xa4e1('0x2e')]:_0x14dafd['model'];if(!_0x4cc8cc['query']['hasOwnProperty'](_0xa4e1('0x30'))){_0x284942[_0xa4e1('0x19')]=qs[_0xa4e1('0x19')](_0x4cc8cc[_0xa4e1('0x28')]['limit']);_0x284942['offset']=qs['offset'](_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x16')]);}_0x284942[_0xa4e1('0x31')]=qs['sort'](_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x32')]);_0x284942[_0xa4e1('0x33')]=qs[_0xa4e1('0x2a')](_['pick'](_0x4cc8cc[_0xa4e1('0x28')],_0x14dafd[_0xa4e1('0x2a')]),_0x4e72bc);if(_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x34')]){_0x284942[_0xa4e1('0x33')]=_[_0xa4e1('0x35')](_0x284942[_0xa4e1('0x33')],{'$or':_[_0xa4e1('0x24')](_0x4e72bc,function(_0x585074){if(_0x585074[_0xa4e1('0x27')]!==_0xa4e1('0x36')){var _0x2d0831={};_0x2d0831[_0x585074['name']]={'$like':'%'+_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x34')]+'%'};return _0x2d0831;}})});}_0x284942=_[_0xa4e1('0x35')]({},_0x284942,_0x4cc8cc[_0xa4e1('0x37')]);var _0x3ae20e={'where':_0x284942['where']};return db[_0xa4e1('0x25')][_0xa4e1('0x18')](_0x3ae20e)['then'](function(_0x590a15){_0x213b20[_0xa4e1('0x18')]=_0x590a15;if(_0x4cc8cc[_0xa4e1('0x28')][_0xa4e1('0x38')]){_0x284942['include']=[{'all':!![]}];}return db[_0xa4e1('0x25')]['findAll'](_0x284942);})[_0xa4e1('0x1c')](function(_0x5ea04f){_0x213b20[_0xa4e1('0x39')]=_0x5ea04f;return _0x213b20;})[_0xa4e1('0x1c')](respondWithFilteredResult(_0x47d7f3,_0x284942))['catch'](handleError(_0x47d7f3,null));};exports[_0xa4e1('0x3a')]=function(_0x442919,_0x43d324){var _0xf4336b={'raw':!![],'where':{'id':_0x442919['params']['id']}},_0x5a2a8e={};_0x5a2a8e[_0xa4e1('0x2c')]=_[_0xa4e1('0x29')](db[_0xa4e1('0x25')][_0xa4e1('0x26')]);_0x5a2a8e['query']=_[_0xa4e1('0x29')](_0x442919['query']);_0x5a2a8e[_0xa4e1('0x2a')]=_[_0xa4e1('0x2b')](_0x5a2a8e['model'],_0x5a2a8e[_0xa4e1('0x28')]);_0xf4336b[_0xa4e1('0x2e')]=_[_0xa4e1('0x2b')](_0x5a2a8e[_0xa4e1('0x2c')],qs[_0xa4e1('0x2d')](_0x442919[_0xa4e1('0x28')][_0xa4e1('0x2d')]));_0xf4336b[_0xa4e1('0x2e')]=_0xf4336b[_0xa4e1('0x2e')][_0xa4e1('0x2f')]?_0xf4336b[_0xa4e1('0x2e')]:_0x5a2a8e['model'];if(_0x442919[_0xa4e1('0x28')][_0xa4e1('0x38')]){_0xf4336b[_0xa4e1('0x3b')]=[{'all':!![]}];}_0xf4336b=_['merge']({},_0xf4336b,_0x442919[_0xa4e1('0x37')]);return db[_0xa4e1('0x25')][_0xa4e1('0x3c')](_0xf4336b)[_0xa4e1('0x1c')](handleEntityNotFound(_0x43d324,null))['then'](respondWithResult(_0x43d324,null))[_0xa4e1('0x3d')](handleError(_0x43d324,null));};exports['create']=function(_0x1a9090,_0x4963d9){return db[_0xa4e1('0x25')][_0xa4e1('0x3e')](_0x1a9090['body'],{})['then'](respondWithResult(_0x4963d9,0xc9))[_0xa4e1('0x3d')](handleError(_0x4963d9,null));};exports[_0xa4e1('0x1b')]=function(_0x12757d,_0x4c5cc2){if(_0x12757d[_0xa4e1('0x3f')]['id']){delete _0x12757d[_0xa4e1('0x3f')]['id'];}return db[_0xa4e1('0x25')][_0xa4e1('0x3c')]({'where':{'id':_0x12757d[_0xa4e1('0x40')]['id']}})[_0xa4e1('0x1c')](handleEntityNotFound(_0x4c5cc2,null))['then'](saveUpdates(_0x12757d['body'],null))['then'](respondWithResult(_0x4c5cc2,null))[_0xa4e1('0x3d')](handleError(_0x4c5cc2,null));};exports['destroy']=function(_0x301533,_0x27b2c9){return db[_0xa4e1('0x25')][_0xa4e1('0x3c')]({'where':{'id':_0x301533[_0xa4e1('0x40')]['id']}})[_0xa4e1('0x1c')](handleEntityNotFound(_0x27b2c9,null))[_0xa4e1('0x1c')](removeEntity(_0x27b2c9,null))[_0xa4e1('0x3d')](handleError(_0x27b2c9,null));}; \ No newline at end of file diff --git a/server/api/intSalesforceField/intSalesforceField.model.js b/server/api/intSalesforceField/intSalesforceField.model.js new file mode 100644 index 0000000..2f9aff7 --- /dev/null +++ b/server/api/intSalesforceField/intSalesforceField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa305=['../../config/environment','./intSalesforceField.attributes','exports','define','SalesforceField','int_salesforce_fields','salesforce_unique_index','idField','FieldId','util','api','moment','request-promise','path','rimraf'];(function(_0xe2c9bc,_0x11817c){var _0x593d41=function(_0x5ac269){while(--_0x5ac269){_0xe2c9bc['push'](_0xe2c9bc['shift']());}};_0x593d41(++_0x11817c);}(_0xa305,0x72));var _0x5a30=function(_0x2acdd5,_0x38cb93){_0x2acdd5=_0x2acdd5-0x0;var _0x279a99=_0xa305[_0x2acdd5];return _0x279a99;};'use strict';var _=require('lodash');var util=require(_0x5a30('0x0'));var logger=require('../../config/logger')(_0x5a30('0x1'));var moment=require(_0x5a30('0x2'));var BPromise=require('bluebird');var rp=require(_0x5a30('0x3'));var fs=require('fs');var path=require(_0x5a30('0x4'));var rimraf=require(_0x5a30('0x5'));var config=require(_0x5a30('0x6'));var attributes=require(_0x5a30('0x7'));module[_0x5a30('0x8')]=function(_0x7d7ff5,_0x3facc5){return _0x7d7ff5[_0x5a30('0x9')](_0x5a30('0xa'),attributes,{'tableName':_0x5a30('0xb'),'paranoid':![],'indexes':[{'name':_0x5a30('0xc'),'fields':[_0x5a30('0xd'),_0x5a30('0xe')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSalesforceField/intSalesforceField.rpc.js b/server/api/intSalesforceField/intSalesforceField.rpc.js new file mode 100644 index 0000000..0804109 --- /dev/null +++ b/server/api/intSalesforceField/intSalesforceField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf590=['result','catch','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','info','SalesforceField,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message'];(function(_0x27f7a0,_0x45b025){var _0x3f0496=function(_0x581f7f){while(--_0x581f7f){_0x27f7a0['push'](_0x27f7a0['shift']());}};_0x3f0496(++_0x45b025);}(_0xf590,0x120));var _0x0f59=function(_0xff319d,_0x1dfdc0){_0xff319d=_0xff319d-0x0;var _0x4839c7=_0xf590[_0xff319d];return _0x4839c7;};'use strict';var _=require('lodash');var util=require(_0x0f59('0x0'));var moment=require(_0x0f59('0x1'));var BPromise=require(_0x0f59('0x2'));var rs=require(_0x0f59('0x3'));var fs=require('fs');var Redis=require(_0x0f59('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x0f59('0x5'));var logger=require('../../config/logger')(_0x0f59('0x6'));var config=require(_0x0f59('0x7'));var jayson=require(_0x0f59('0x8'));var client=jayson[_0x0f59('0x9')][_0x0f59('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x51943c,_0x4d4fd0,_0x432a91){return new BPromise(function(_0xa5e9ba,_0x29d1eb){return client[_0x0f59('0xb')](_0x51943c,_0x432a91)['then'](function(_0x4135ba){logger[_0x0f59('0xc')](_0x0f59('0xd'),_0x4d4fd0,_0x0f59('0xe'));logger[_0x0f59('0xf')]('SalesforceField,\x20%s,\x20%s,\x20%s',_0x4d4fd0,_0x0f59('0xe'),JSON[_0x0f59('0x10')](_0x4135ba));if(_0x4135ba[_0x0f59('0x11')]){if(_0x4135ba[_0x0f59('0x11')][_0x0f59('0x12')]===0x1f4){logger[_0x0f59('0x11')]('SalesforceField,\x20%s,\x20%s',_0x4d4fd0,_0x4135ba['error'][_0x0f59('0x13')]);return _0x29d1eb(_0x4135ba['error']['message']);}logger['error']('SalesforceField,\x20%s,\x20%s',_0x4d4fd0,_0x4135ba['error']['message']);return _0xa5e9ba(_0x4135ba['error'][_0x0f59('0x13')]);}else{logger[_0x0f59('0xc')](_0x0f59('0xd'),_0x4d4fd0,'request\x20sent');_0xa5e9ba(_0x4135ba[_0x0f59('0x14')]['message']);}})[_0x0f59('0x15')](function(_0x2e0b83){logger['error'](_0x0f59('0xd'),_0x4d4fd0,_0x2e0b83);_0x29d1eb(_0x2e0b83);});});} \ No newline at end of file diff --git a/server/api/intServicenowAccount/index.js b/server/api/intServicenowAccount/index.js new file mode 100644 index 0000000..9a09bfa --- /dev/null +++ b/server/api/intServicenowAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3b59=['/:id/configurations','getConfigurations','getFields','post','create','put','update','delete','destroy','multer','util','path','connect-timeout','express','Router','../../components/auth/service','../../config/environment','./intServicenowAccount.controller','get','isAuthenticated','/:id'];(function(_0x31c478,_0x44056c){var _0x2a270a=function(_0x5bb5b6){while(--_0x5bb5b6){_0x31c478['push'](_0x31c478['shift']());}};_0x2a270a(++_0x44056c);}(_0x3b59,0x9c));var _0x93b5=function(_0x5b5b5f,_0x1d88f8){_0x5b5b5f=_0x5b5b5f-0x0;var _0x380741=_0x3b59[_0x5b5b5f];return _0x380741;};'use strict';var multer=require(_0x93b5('0x0'));var util=require(_0x93b5('0x1'));var path=require(_0x93b5('0x2'));var timeout=require(_0x93b5('0x3'));var express=require(_0x93b5('0x4'));var router=express[_0x93b5('0x5')]();var fs_extra=require('fs-extra');var auth=require(_0x93b5('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0x93b5('0x7'));var controller=require(_0x93b5('0x8'));router[_0x93b5('0x9')]('/',auth[_0x93b5('0xa')](),controller['index']);router[_0x93b5('0x9')](_0x93b5('0xb'),auth[_0x93b5('0xa')](),controller['show']);router[_0x93b5('0x9')](_0x93b5('0xc'),auth[_0x93b5('0xa')](),controller[_0x93b5('0xd')]);router[_0x93b5('0x9')]('/:id/fields',auth[_0x93b5('0xa')](),controller[_0x93b5('0xe')]);router[_0x93b5('0xf')]('/',auth[_0x93b5('0xa')](),controller[_0x93b5('0x10')]);router['post'](_0x93b5('0xc'),auth[_0x93b5('0xa')](),controller['addConfiguration']);router[_0x93b5('0x11')](_0x93b5('0xb'),auth[_0x93b5('0xa')](),controller[_0x93b5('0x12')]);router[_0x93b5('0x13')]('/:id',auth[_0x93b5('0xa')](),controller[_0x93b5('0x14')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/intServicenowAccount/intServicenowAccount.attributes.js b/server/api/intServicenowAccount/intServicenowAccount.attributes.js new file mode 100644 index 0000000..f43ac13 --- /dev/null +++ b/server/api/intServicenowAccount/intServicenowAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa426=['remoteUri','sequelize','STRING','username'];(function(_0x582bd7,_0xc3c370){var _0x188b98=function(_0x3a861a){while(--_0x3a861a){_0x582bd7['push'](_0x582bd7['shift']());}};_0x188b98(++_0xc3c370);}(_0xa426,0x121));var _0x6a42=function(_0x35885a,_0x42fed7){_0x35885a=_0x35885a-0x0;var _0xe86249=_0xa426[_0x35885a];return _0xe86249;};'use strict';var Sequelize=require(_0x6a42('0x0'));module['exports']={'name':{'type':Sequelize[_0x6a42('0x1')]},'description':{'type':Sequelize[_0x6a42('0x1')]},'username':{'type':Sequelize[_0x6a42('0x1')],'unique':_0x6a42('0x2')},'password':{'type':Sequelize['STRING']},'email':{'type':Sequelize[_0x6a42('0x1')]},'remoteUri':{'type':Sequelize[_0x6a42('0x1')],'unique':_0x6a42('0x3')},'serverUrl':{'type':Sequelize[_0x6a42('0x1')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/intServicenowAccount/intServicenowAccount.controller.js b/server/api/intServicenowAccount/intServicenowAccount.controller.js new file mode 100644 index 0000000..e55b793 --- /dev/null +++ b/server/api/intServicenowAccount/intServicenowAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x315e=['sla_due','approval','comments_and_work_notes','sys_mod_count','reopen_count','sys_tags','escalation','correlation_id','location','username','email','remoteUri','substring','lastIndexOf','%s/api/now/doc/table/schema/','format','%s/api/now/table/','password','incident?sysparm_display_value=all','result','log','incident\x20table\x20objects','assign','remove','includes','internalType','label','push','TCL:\x20exports.getEntityFields\x20->\x20_objectsCustom','forEach','all','concat','ServiceNow\x20error:\x20','test','statusCode','Wrong\x20credentials','False','false','GET','sys_choice?sysparm_query=name=incident^element=','inactive','value','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','squel','jsforce','querystring','papaparse','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','sendStatus','error','stack','name','send','index','ServicenowAccount','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','hasOwnProperty','sort','where','filter','merge','map','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','keys','options','find','create','body','destroy','getConfigurations','ServicenowConfiguration','length','order','pick','nolimit','findOne','Subjects','getSubjects','channel','getDescriptions','ServicenowField','getFields','knowledge','subcategory','close_code','notify','incident_state','severity','category','parent','caused_by','upon_reject','sys_updated_on','hold_reason','approval_history','number','resolved_by','user_input','state','sys_created_by','calendar_stc','closed_at','cmdb_ci','delivery_plan','impact','active','work_notes_list','priority','sys_domain_path','rfc','time_worked','expected_start','opened_at','business_duration','work_end','reopened_time','resolved_at','caller_id','approval_set','work_notes','short_description','correlation_display','delivery_task','work_start','business_stc','additional_assignee_list','description','sys_class_name','close_notes','closed_by','follow_up','parent_incident','sys_id','reopened_by','urgency','problem_id','reassignment_count','activity_due','assigned_to'];(function(_0x305016,_0x22a150){var _0x296b99=function(_0x3fa9b8){while(--_0x3fa9b8){_0x305016['push'](_0x305016['shift']());}};_0x296b99(++_0x22a150);}(_0x315e,0xe1));var _0xe315=function(_0xbca1b1,_0x33f0ce){_0xbca1b1=_0xbca1b1-0x0;var _0x4e1686=_0x315e[_0xbca1b1];return _0x4e1686;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe315('0x0'));var zipdir=require(_0xe315('0x1'));var jsonpatch=require(_0xe315('0x2'));var rp=require(_0xe315('0x3'));var moment=require(_0xe315('0x4'));var BPromise=require(_0xe315('0x5'));var Mustache=require(_0xe315('0x6'));var util=require(_0xe315('0x7'));var path=require(_0xe315('0x8'));var sox=require(_0xe315('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xe315('0xa'));var crypto=require('crypto');var jsforce=require(_0xe315('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xe315('0xc'));var Papa=require(_0xe315('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe315('0xe'));var logger=require(_0xe315('0xf'))(_0xe315('0x10'));var utils=require(_0xe315('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0xe315('0x12'));var db=require(_0xe315('0x13'))['db'];var integrations=require(_0xe315('0x14'));function respondWithStatusCode(_0x41a596,_0x51cfe4){_0x51cfe4=_0x51cfe4||0xcc;return function(_0x5e7021){if(_0x5e7021){return _0x41a596['sendStatus'](_0x51cfe4);}return _0x41a596['status'](_0x51cfe4)[_0xe315('0x15')]();};}function respondWithResult(_0x5050b8,_0x11998a){_0x11998a=_0x11998a||0xc8;return function(_0x3601a5){if(_0x3601a5){return _0x5050b8[_0xe315('0x16')](_0x11998a)[_0xe315('0x17')](_0x3601a5);}};}function respondWithFilteredResult(_0x56daef,_0x3045ec){return function(_0x52cdb6){if(_0x52cdb6){var _0x24634b=typeof _0x3045ec[_0xe315('0x18')]===_0xe315('0x19')&&typeof _0x3045ec[_0xe315('0x1a')]===_0xe315('0x19');var _0x9e9395=_0x52cdb6[_0xe315('0x1b')];var _0x2be5a2=_0x24634b?0x0:_0x3045ec[_0xe315('0x18')];var _0x156d37=_0x24634b?_0x52cdb6[_0xe315('0x1b')]:_0x3045ec[_0xe315('0x18')]+_0x3045ec[_0xe315('0x1a')];var _0x5e1888;if(_0x156d37>=_0x9e9395){_0x156d37=_0x9e9395;_0x5e1888=0xc8;}else{_0x5e1888=0xce;}_0x56daef[_0xe315('0x16')](_0x5e1888);return _0x56daef[_0xe315('0x1c')](_0xe315('0x1d'),_0x2be5a2+'-'+_0x156d37+'/'+_0x9e9395)[_0xe315('0x17')](_0x52cdb6);}return null;};}function patchUpdates(_0x4ef555){return function(_0x52946f){try{jsonpatch[_0xe315('0x1e')](_0x52946f,_0x4ef555,!![]);}catch(_0x5625e7){return BPromise['reject'](_0x5625e7);}return _0x52946f[_0xe315('0x1f')]();};}function saveUpdates(_0x1b97de,_0x5d8c13){return function(_0x2436ee){if(_0x2436ee){return _0x2436ee[_0xe315('0x20')](_0x1b97de)[_0xe315('0x21')](function(_0x1ed910){return _0x1ed910;});}return null;};}function removeEntity(_0x476290,_0x335897){return function(_0x5bacc3){if(_0x5bacc3){return _0x5bacc3['destroy']()[_0xe315('0x21')](function(){_0x476290['status'](0xcc)[_0xe315('0x15')]();});}};}function handleEntityNotFound(_0x4ec6d9,_0x461a93){return function(_0x1d3aa2){if(!_0x1d3aa2){_0x4ec6d9[_0xe315('0x22')](0x194);}return _0x1d3aa2;};}function handleError(_0x2acd3c,_0x64ad3f){_0x64ad3f=_0x64ad3f||0x1f4;return function(_0x32f36c){logger[_0xe315('0x23')](_0x32f36c[_0xe315('0x24')]);if(_0x32f36c[_0xe315('0x25')]){delete _0x32f36c[_0xe315('0x25')];}_0x2acd3c['status'](_0x64ad3f)[_0xe315('0x26')](_0x32f36c);};}exports[_0xe315('0x27')]=function(_0x43e46e,_0x1f2c7b){var _0x2cf72f={},_0x56fbbb={},_0x53003f={'count':0x0,'rows':[]};var _0x596fde=_['map'](db[_0xe315('0x28')][_0xe315('0x29')],function(_0x10fdce){return{'name':_0x10fdce[_0xe315('0x2a')],'type':_0x10fdce[_0xe315('0x2b')][_0xe315('0x2c')]};});_0x56fbbb['model']=_['map'](_0x596fde,'name');_0x56fbbb[_0xe315('0x2d')]=_['keys'](_0x43e46e[_0xe315('0x2d')]);_0x56fbbb[_0xe315('0x2e')]=_[_0xe315('0x2f')](_0x56fbbb[_0xe315('0x30')],_0x56fbbb[_0xe315('0x2d')]);_0x2cf72f[_0xe315('0x31')]=_[_0xe315('0x2f')](_0x56fbbb[_0xe315('0x30')],qs[_0xe315('0x32')](_0x43e46e[_0xe315('0x2d')][_0xe315('0x32')]));_0x2cf72f[_0xe315('0x31')]=_0x2cf72f[_0xe315('0x31')]['length']?_0x2cf72f['attributes']:_0x56fbbb[_0xe315('0x30')];if(!_0x43e46e['query'][_0xe315('0x33')]('nolimit')){_0x2cf72f[_0xe315('0x1a')]=qs['limit'](_0x43e46e[_0xe315('0x2d')][_0xe315('0x1a')]);_0x2cf72f[_0xe315('0x18')]=qs[_0xe315('0x18')](_0x43e46e[_0xe315('0x2d')][_0xe315('0x18')]);}_0x2cf72f['order']=qs[_0xe315('0x34')](_0x43e46e[_0xe315('0x2d')][_0xe315('0x34')]);_0x2cf72f[_0xe315('0x35')]=qs[_0xe315('0x2e')](_['pick'](_0x43e46e[_0xe315('0x2d')],_0x56fbbb[_0xe315('0x2e')]),_0x596fde);if(_0x43e46e['query'][_0xe315('0x36')]){_0x2cf72f['where']=_[_0xe315('0x37')](_0x2cf72f[_0xe315('0x35')],{'$or':_[_0xe315('0x38')](_0x596fde,function(_0x396823){if(_0x396823[_0xe315('0x2b')]!==_0xe315('0x39')){var _0x153937={};_0x153937[_0x396823[_0xe315('0x25')]]={'$like':'%'+_0x43e46e[_0xe315('0x2d')]['filter']+'%'};return _0x153937;}})});}_0x2cf72f=_[_0xe315('0x37')]({},_0x2cf72f,_0x43e46e['options']);var _0x5175b5={'where':_0x2cf72f[_0xe315('0x35')]};return db['ServicenowAccount'][_0xe315('0x1b')](_0x5175b5)[_0xe315('0x21')](function(_0x131d46){_0x53003f['count']=_0x131d46;if(_0x43e46e['query'][_0xe315('0x3a')]){_0x2cf72f[_0xe315('0x3b')]=[{'all':!![]}];}return db[_0xe315('0x28')][_0xe315('0x3c')](_0x2cf72f);})[_0xe315('0x21')](function(_0x31ac29){_0x53003f[_0xe315('0x3d')]=_0x31ac29;return _0x53003f;})[_0xe315('0x21')](respondWithFilteredResult(_0x1f2c7b,_0x2cf72f))[_0xe315('0x3e')](handleError(_0x1f2c7b,null));};exports[_0xe315('0x3f')]=function(_0x135ef1,_0x41112f){var _0x510a0b={'raw':![],'where':{'id':_0x135ef1[_0xe315('0x40')]['id']}},_0x46eca2={};_0x46eca2['model']=_[_0xe315('0x41')](db[_0xe315('0x28')][_0xe315('0x29')]);_0x46eca2[_0xe315('0x2d')]=_[_0xe315('0x41')](_0x135ef1[_0xe315('0x2d')]);_0x46eca2['filters']=_['intersection'](_0x46eca2[_0xe315('0x30')],_0x46eca2[_0xe315('0x2d')]);_0x510a0b[_0xe315('0x31')]=_[_0xe315('0x2f')](_0x46eca2[_0xe315('0x30')],qs[_0xe315('0x32')](_0x135ef1[_0xe315('0x2d')][_0xe315('0x32')]));_0x510a0b[_0xe315('0x31')]=_0x510a0b['attributes']['length']?_0x510a0b[_0xe315('0x31')]:_0x46eca2[_0xe315('0x30')];if(_0x135ef1[_0xe315('0x2d')][_0xe315('0x3a')]){_0x510a0b[_0xe315('0x3b')]=[{'all':!![]}];}_0x510a0b=_[_0xe315('0x37')]({},_0x510a0b,_0x135ef1[_0xe315('0x42')]);return db[_0xe315('0x28')][_0xe315('0x43')](_0x510a0b)['then'](handleEntityNotFound(_0x41112f,null))['then'](respondWithResult(_0x41112f,null))[_0xe315('0x3e')](handleError(_0x41112f,null));};exports[_0xe315('0x44')]=function(_0x30e1d3,_0x100649){return db[_0xe315('0x28')][_0xe315('0x44')](_0x30e1d3['body'],{})[_0xe315('0x21')](respondWithResult(_0x100649,0xc9))[_0xe315('0x3e')](handleError(_0x100649,null));};exports[_0xe315('0x20')]=function(_0x5b26e9,_0x183d7f){if(_0x5b26e9['body']['id']){delete _0x5b26e9[_0xe315('0x45')]['id'];}return db[_0xe315('0x28')][_0xe315('0x43')]({'where':{'id':_0x5b26e9[_0xe315('0x40')]['id']}})[_0xe315('0x21')](handleEntityNotFound(_0x183d7f,null))['then'](saveUpdates(_0x5b26e9[_0xe315('0x45')],null))[_0xe315('0x21')](respondWithResult(_0x183d7f,null))[_0xe315('0x3e')](handleError(_0x183d7f,null));};exports[_0xe315('0x46')]=function(_0x744d77,_0x1ac5f3){return db[_0xe315('0x28')]['find']({'where':{'id':_0x744d77[_0xe315('0x40')]['id']}})[_0xe315('0x21')](handleEntityNotFound(_0x1ac5f3,null))[_0xe315('0x21')](removeEntity(_0x1ac5f3,null))['catch'](handleError(_0x1ac5f3,null));};exports[_0xe315('0x47')]=function(_0x13c58d,_0x100733,_0x2530f8){var _0x49461f={};var _0x3b6cce={};var _0x416f8d;var _0x33b6a6;return db[_0xe315('0x28')]['findOne']({'where':{'id':_0x13c58d[_0xe315('0x40')]['id']}})[_0xe315('0x21')](handleEntityNotFound(_0x100733,null))['then'](function(_0x33ed75){if(_0x33ed75){_0x416f8d=_0x33ed75;_0x3b6cce[_0xe315('0x30')]=_[_0xe315('0x41')](db[_0xe315('0x48')][_0xe315('0x29')]);_0x3b6cce[_0xe315('0x2d')]=_['keys'](_0x13c58d[_0xe315('0x2d')]);_0x3b6cce[_0xe315('0x2e')]=_[_0xe315('0x2f')](_0x3b6cce[_0xe315('0x30')],_0x3b6cce[_0xe315('0x2d')]);_0x49461f['attributes']=_['intersection'](_0x3b6cce['model'],qs[_0xe315('0x32')](_0x13c58d[_0xe315('0x2d')][_0xe315('0x32')]));_0x49461f[_0xe315('0x31')]=_0x49461f[_0xe315('0x31')][_0xe315('0x49')]?_0x49461f[_0xe315('0x31')]:_0x3b6cce[_0xe315('0x30')];_0x49461f[_0xe315('0x4a')]=qs[_0xe315('0x34')](_0x13c58d[_0xe315('0x2d')]['sort']);_0x49461f[_0xe315('0x35')]=qs['filters'](_[_0xe315('0x4b')](_0x13c58d['query'],_0x3b6cce[_0xe315('0x2e')]));if(_0x13c58d[_0xe315('0x2d')][_0xe315('0x36')]){_0x49461f[_0xe315('0x35')]=_[_0xe315('0x37')](_0x49461f[_0xe315('0x35')],{'$or':_['map'](_0x49461f[_0xe315('0x31')],function(_0x2e4791){var _0x121c9f={};_0x121c9f[_0x2e4791]={'$like':'%'+_0x13c58d[_0xe315('0x2d')][_0xe315('0x36')]+'%'};return _0x121c9f;})});}_0x49461f=_['merge']({},_0x49461f,_0x13c58d[_0xe315('0x42')]);return _0x416f8d[_0xe315('0x47')](_0x49461f);}})['then'](function(_0x9375c8){if(_0x9375c8){_0x33b6a6=_0x9375c8['length'];if(!_0x13c58d[_0xe315('0x2d')][_0xe315('0x33')](_0xe315('0x4c'))){_0x49461f[_0xe315('0x1a')]=qs[_0xe315('0x1a')](_0x13c58d[_0xe315('0x2d')][_0xe315('0x1a')]);_0x49461f[_0xe315('0x18')]=qs[_0xe315('0x18')](_0x13c58d['query'][_0xe315('0x18')]);}return _0x416f8d[_0xe315('0x47')](_0x49461f);}})[_0xe315('0x21')](function(_0x3c19b3){if(_0x3c19b3){return _0x3c19b3?{'count':_0x33b6a6,'rows':_0x3c19b3}:null;}})[_0xe315('0x21')](respondWithResult(_0x100733,null))[_0xe315('0x3e')](handleError(_0x100733,null));};exports['addConfiguration']=function(_0x1f17bb,_0xf3c956,_0x35d5d2){if(_0x1f17bb[_0xe315('0x45')]['id']){delete _0x1f17bb['body']['id'];}return db['ServicenowAccount'][_0xe315('0x4d')]({'where':{'id':_0x1f17bb[_0xe315('0x40')]['id']}})[_0xe315('0x21')](handleEntityNotFound(_0xf3c956,null))['then'](function(_0x263f31){if(_0x263f31){_0x1f17bb[_0xe315('0x45')]['AccountId']=_0x263f31['id'];_0x1f17bb[_0xe315('0x45')][_0xe315('0x4e')]=integrations[_0xe315('0x4f')](_0x1f17bb[_0xe315('0x45')][_0xe315('0x50')],_0x1f17bb['body']['type']);_0x1f17bb[_0xe315('0x45')]['Descriptions']=integrations[_0xe315('0x51')](_0x1f17bb[_0xe315('0x45')][_0xe315('0x50')],_0x1f17bb[_0xe315('0x45')][_0xe315('0x2b')]);return db['ServicenowConfiguration'][_0xe315('0x44')](_0x1f17bb[_0xe315('0x45')],{'include':[{'model':db[_0xe315('0x52')],'as':_0xe315('0x4e')},{'model':db[_0xe315('0x52')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0xf3c956,null))[_0xe315('0x3e')](handleError(_0xf3c956,null));};exports[_0xe315('0x53')]=function(_0x1e1401,_0x1b3363,_0x200919){var _0x59821e=['made_sla','hold_reason',_0xe315('0x54'),_0xe315('0x55'),_0xe315('0x56'),_0xe315('0x57'),_0xe315('0x58'),_0xe315('0x59'),_0xe315('0x5a')];var _0x4ff6bd=[_0xe315('0x5b'),'made_sla',_0xe315('0x5c'),'watch_list',_0xe315('0x5d'),_0xe315('0x5e'),'child_incidents',_0xe315('0x5f'),_0xe315('0x60'),_0xe315('0x61'),_0xe315('0x62'),'sys_updated_by','opened_by',_0xe315('0x63'),'sys_created_on','sys_domain',_0xe315('0x64'),_0xe315('0x65'),'knowledge','order',_0xe315('0x66'),_0xe315('0x67'),_0xe315('0x68'),_0xe315('0x69'),_0xe315('0x6a'),_0xe315('0x6b'),_0xe315('0x6c'),'business_service',_0xe315('0x6d'),_0xe315('0x6e'),_0xe315('0x6f'),_0xe315('0x70'),_0xe315('0x71'),_0xe315('0x72'),_0xe315('0x73'),'group_list',_0xe315('0x74'),_0xe315('0x75'),_0xe315('0x76'),_0xe315('0x77'),_0xe315('0x78'),_0xe315('0x55'),_0xe315('0x79'),_0xe315('0x7a'),_0xe315('0x56'),_0xe315('0x7b'),_0xe315('0x7c'),_0xe315('0x7d'),'assignment_group',_0xe315('0x7e'),_0xe315('0x7f'),_0xe315('0x80'),'calendar_duration','notify',_0xe315('0x81'),_0xe315('0x82'),_0xe315('0x83'),_0xe315('0x84'),_0xe315('0x85'),_0xe315('0x86'),'contact_type',_0xe315('0x87'),_0xe315('0x58'),_0xe315('0x88'),_0xe315('0x89'),'company',_0xe315('0x8a'),_0xe315('0x8b'),_0xe315('0x8c'),_0xe315('0x59'),'comments',_0xe315('0x8d'),_0xe315('0x8e'),_0xe315('0x8f'),'due_date',_0xe315('0x90'),_0xe315('0x91'),_0xe315('0x92'),_0xe315('0x93'),'upon_approval',_0xe315('0x94'),_0xe315('0x95'),'category'];var _0x52794d='';var _0xc7659='';var _0x2c1a61=[];var _0x1dfa31='';var _0x495710='';var _0x4b6462=[];var _0x3b6493='';var _0x1873e3='';var _0x22cd15={};var _0x5d11ab='';return db['ServicenowAccount'][_0xe315('0x4d')]({'where':{'id':_0x1e1401[_0xe315('0x40')]['id']},'attributes':['id',_0xe315('0x96'),'password',_0xe315('0x97'),_0xe315('0x98'),'serverUrl']})['then'](handleEntityNotFound(_0x1b3363,null))['then'](function(_0x36b10a){if(_0x36b10a){_0x5d11ab=_0x36b10a[_0xe315('0x98')];var _0x2fedd0=_0x5d11ab['slice'](-0x1);if(_0x2fedd0==='/'){_0x5d11ab=_0x5d11ab[_0xe315('0x99')](0x0,_0x5d11ab[_0xe315('0x9a')](_0x2fedd0));}_0x1873e3=util['format'](_0xe315('0x9b'),_0x5d11ab);_0x3b6493=util[_0xe315('0x9c')](_0xe315('0x9d'),_0x5d11ab);_0x22cd15={'user':_0x36b10a[_0xe315('0x96')],'pass':_0x36b10a[_0xe315('0x9e')]};var _0x595c9b={'method':'GET','uri':_0x1873e3+_0xe315('0x9f'),'auth':_0x22cd15,'json':!![]};return rp(_0x595c9b);}})[_0xe315('0x21')](function(_0x4026fb){if(_0x4026fb[_0xe315('0xa0')][_0xe315('0x49')]>0x0){_0x52794d=_0x4026fb[_0xe315('0xa0')];}console[_0xe315('0xa1')](_0xe315('0xa2'),_0x52794d);_0x4b6462=[];_0xc7659=Object[_0xe315('0xa3')]([],_0x52794d);_[_0xe315('0xa4')](_0xc7659,function(_0x46b934){return!_0x59821e[_0xe315('0xa5')](_0x46b934['name']);});_0xc7659['forEach'](function(_0x28bc94){var _0x309f2e=createFieldObject(_0x3b6493,_0x22cd15,_0x28bc94[_0xe315('0xa6')],_0x28bc94[_0xe315('0x25')],_0x28bc94[_0xe315('0xa7')],![]);_0x4b6462[_0xe315('0xa8')](_0x309f2e);});return Promise['all'](_0x4b6462);})['then'](function(_0x1c6893){_0x2c1a61=_0x1c6893;_0x1dfa31=Object[_0xe315('0xa3')]([],_0x52794d);console['log']('TCL:\x20_object',_0x52794d);_['remove'](_0x1dfa31,function(_0x51f974){return _0x4ff6bd[_0xe315('0xa5')](_0x51f974[_0xe315('0x25')]);});console[_0xe315('0xa1')](_0xe315('0xa9'),_0x1dfa31);_0x4b6462=[];_0x1dfa31[_0xe315('0xaa')](function(_0x50059f){var _0x194445=createFieldObject(_0x3b6493,_0x22cd15,_0x50059f[_0xe315('0xa6')],_0x50059f[_0xe315('0x25')],_0x50059f[_0xe315('0xa7')],!![]);_0x4b6462[_0xe315('0xa8')](_0x194445);});return Promise[_0xe315('0xab')](_0x4b6462);})[_0xe315('0x21')](function(_0x577288){_0x495710=_0x577288;var _0x120ef2=_0x2c1a61[_0xe315('0xac')](_0x495710);return{'count':_0x120ef2['length'],'rows':_0x120ef2};})[_0xe315('0x21')](respondWithResult(_0x1b3363,null))[_0xe315('0x3e')](function(_0x2b11ec){console[_0xe315('0xa1')](_0xe315('0xad')+_0x2b11ec);var _0x1cdaa3=_0x1e1401[_0xe315('0x2d')][_0xe315('0xae')]?0x1f4:_0x2b11ec[_0xe315('0xaf')]||0x1f4;logger[_0xe315('0x23')](_0x2b11ec[_0xe315('0x24')]);delete _0x2b11ec[_0xe315('0x25')];if(_0x1cdaa3===0x191){_0x1cdaa3=0x190;}_0x1b3363[_0xe315('0x16')](_0x1cdaa3)[_0xe315('0x26')](_0x1e1401['query'][_0xe315('0xae')]?{'message':_0xe315('0xb0'),'statusCode':_0x2b11ec[_0xe315('0xaf')]}:_0x2b11ec);});};function createFieldObject(_0x65189f,_0x38c141,_0x460e2a,_0x1aedff,_0x3f95b4,_0x247a84){return new Promise(function(_0x2374cd,_0x3581b5){var _0x46babf={'id':_0x1aedff,'name':_0x3f95b4,'custom':_0x247a84};if(_0x460e2a==='boolean'){_0x46babf[_0xe315('0x42')]=[{'name':'True','value':'true'},{'name':_0xe315('0xb1'),'value':_0xe315('0xb2')}];_0x2374cd(_0x46babf);}else{var _0x30276b={'method':_0xe315('0xb3'),'uri':_0x65189f+_0xe315('0xb4')+_0x1aedff,'auth':_0x38c141,'json':!![]};return rp(_0x30276b)[_0xe315('0x21')](function(_0x1b8461){var _0x14353c=[];if(_0x1b8461[_0xe315('0xa0')][_0xe315('0x49')]>0x0){_0x1b8461[_0xe315('0xa0')]['forEach'](function(_0x4cd549){if(_0x4cd549[_0xe315('0xb5')]==='false'){var _0x5955bc={'name':_0x4cd549['label'],'value':_0x4cd549[_0xe315('0xb6')]};_0x14353c[_0xe315('0xa8')](_0x5955bc);}});}_0x46babf[_0xe315('0x42')]=_0x14353c;if(_0x46babf['options']['length']>0x0){_0x2374cd(_0x46babf);}else{if(_0x247a84==![]){_0x2374cd();}else{_0x2374cd(_0x46babf);}}});}});} \ No newline at end of file diff --git a/server/api/intServicenowAccount/intServicenowAccount.model.js b/server/api/intServicenowAccount/intServicenowAccount.model.js new file mode 100644 index 0000000..37c7d6f --- /dev/null +++ b/server/api/intServicenowAccount/intServicenowAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda19=['request-promise','rimraf','../../config/environment','./intServicenowAccount.attributes','../../components/integrations/configuration','exports','define','ServicenowAccount','int_servicenow_accounts','util','../../config/logger','moment'];(function(_0xb1e92d,_0x202387){var _0x4ad932=function(_0x28e266){while(--_0x28e266){_0xb1e92d['push'](_0xb1e92d['shift']());}};_0x4ad932(++_0x202387);}(_0xda19,0xd5));var _0x9da1=function(_0x56bb01,_0x21ba6d){_0x56bb01=_0x56bb01-0x0;var _0x4c7b46=_0xda19[_0x56bb01];return _0x4c7b46;};'use strict';var _=require('lodash');var util=require(_0x9da1('0x0'));var logger=require(_0x9da1('0x1'))('api');var moment=require(_0x9da1('0x2'));var BPromise=require('bluebird');var rp=require(_0x9da1('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0x9da1('0x4'));var config=require(_0x9da1('0x5'));var attributes=require(_0x9da1('0x6'));var integrations=require(_0x9da1('0x7'));module[_0x9da1('0x8')]=function(_0x2dcbc6,_0x23e4f7){return _0x2dcbc6[_0x9da1('0x9')](_0x9da1('0xa'),attributes,{'tableName':_0x9da1('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intServicenowAccount/intServicenowAccount.rpc.js b/server/api/intServicenowAccount/intServicenowAccount.rpc.js new file mode 100644 index 0000000..4f6d82c --- /dev/null +++ b/server/api/intServicenowAccount/intServicenowAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdb62=['request\x20sent','catch','GetServicenowAccount','findAll','options','where','attributes','limit','include','map','ShowServicenowAccount','ServicenowAccount','find','raw','model','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','ServicenowAccount,\x20%s,\x20%s','debug','ServicenowAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x460bf4,_0x9e8009){var _0x4ad8fc=function(_0x456cca){while(--_0x456cca){_0x460bf4['push'](_0x460bf4['shift']());}};_0x4ad8fc(++_0x9e8009);}(_0xdb62,0xb9));var _0x2db6=function(_0x3f2d02,_0x2c7deb){_0x3f2d02=_0x3f2d02-0x0;var _0x54092b=_0xdb62[_0x3f2d02];return _0x54092b;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2db6('0x0'));var BPromise=require(_0x2db6('0x1'));var rs=require(_0x2db6('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2db6('0x3'));var logger=require(_0x2db6('0x4'))(_0x2db6('0x5'));var config=require(_0x2db6('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x2db6('0x7')][_0x2db6('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x409c50,_0x197687,_0x885750){return new BPromise(function(_0x22446d,_0x2b5505){return client[_0x2db6('0x9')](_0x409c50,_0x885750)[_0x2db6('0xa')](function(_0x37b04f){logger[_0x2db6('0xb')](_0x2db6('0xc'),_0x197687,'request\x20sent');logger[_0x2db6('0xd')](_0x2db6('0xe'),_0x197687,'request\x20sent',JSON[_0x2db6('0xf')](_0x37b04f));if(_0x37b04f['error']){if(_0x37b04f[_0x2db6('0x10')][_0x2db6('0x11')]===0x1f4){logger[_0x2db6('0x10')]('ServicenowAccount,\x20%s,\x20%s',_0x197687,_0x37b04f[_0x2db6('0x10')][_0x2db6('0x12')]);return _0x2b5505(_0x37b04f[_0x2db6('0x10')][_0x2db6('0x12')]);}logger[_0x2db6('0x10')](_0x2db6('0xc'),_0x197687,_0x37b04f['error']['message']);return _0x22446d(_0x37b04f[_0x2db6('0x10')][_0x2db6('0x12')]);}else{logger[_0x2db6('0xb')](_0x2db6('0xc'),_0x197687,_0x2db6('0x13'));_0x22446d(_0x37b04f['result'][_0x2db6('0x12')]);}})[_0x2db6('0x14')](function(_0x4aff36){logger[_0x2db6('0x10')](_0x2db6('0xc'),_0x197687,_0x4aff36);_0x2b5505(_0x4aff36);});});}exports[_0x2db6('0x15')]=function(_0x5698f7){var _0x1c2c20=this;return new Promise(function(_0x194938,_0x2121f3){return db['ServicenowAccount'][_0x2db6('0x16')]({'raw':_0x5698f7[_0x2db6('0x17')]?_0x5698f7['options']['raw']===undefined?!![]:![]:!![],'where':_0x5698f7['options']?_0x5698f7[_0x2db6('0x17')][_0x2db6('0x18')]||null:null,'attributes':_0x5698f7[_0x2db6('0x17')]?_0x5698f7[_0x2db6('0x17')][_0x2db6('0x19')]||null:null,'limit':_0x5698f7['options']?_0x5698f7[_0x2db6('0x17')][_0x2db6('0x1a')]||null:null,'include':_0x5698f7[_0x2db6('0x17')]?_0x5698f7[_0x2db6('0x17')][_0x2db6('0x1b')]?_[_0x2db6('0x1c')](_0x5698f7[_0x2db6('0x17')][_0x2db6('0x1b')],function(_0x2d98fe){return{'model':db[_0x2d98fe['model']],'as':_0x2d98fe['as'],'attributes':_0x2d98fe[_0x2db6('0x19')],'include':_0x2d98fe[_0x2db6('0x1b')]?_[_0x2db6('0x1c')](_0x2d98fe['include'],function(_0x10c4db){return{'model':db[_0x10c4db['model']],'as':_0x10c4db['as'],'attributes':_0x10c4db[_0x2db6('0x19')],'include':_0x10c4db[_0x2db6('0x1b')]?_[_0x2db6('0x1c')](_0x10c4db[_0x2db6('0x1b')],function(_0x11a961){return{'model':db[_0x11a961['model']],'as':_0x11a961['as'],'attributes':_0x11a961[_0x2db6('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x229ce0){logger[_0x2db6('0xb')](_0x2db6('0x15'),_0x5698f7);logger[_0x2db6('0xd')]('GetServicenowAccount',_0x5698f7,JSON[_0x2db6('0xf')](_0x229ce0));_0x194938(_0x229ce0);})[_0x2db6('0x14')](function(_0x29d3db){logger['error'](_0x2db6('0x15'),_0x29d3db['message'],_0x5698f7);_0x2121f3(_0x1c2c20[_0x2db6('0x10')](0x1f4,_0x29d3db[_0x2db6('0x12')]));});});};exports[_0x2db6('0x1d')]=function(_0x1bf5ec){var _0x5b1d15=this;return new Promise(function(_0x50e7e5,_0x9a3ab){return db[_0x2db6('0x1e')][_0x2db6('0x1f')]({'raw':_0x1bf5ec[_0x2db6('0x17')]?_0x1bf5ec[_0x2db6('0x17')][_0x2db6('0x20')]===undefined?!![]:![]:!![],'where':_0x1bf5ec[_0x2db6('0x17')]?_0x1bf5ec[_0x2db6('0x17')][_0x2db6('0x18')]||null:null,'attributes':_0x1bf5ec[_0x2db6('0x17')]?_0x1bf5ec[_0x2db6('0x17')][_0x2db6('0x19')]||null:null,'include':_0x1bf5ec[_0x2db6('0x17')]?_0x1bf5ec[_0x2db6('0x17')]['include']?_[_0x2db6('0x1c')](_0x1bf5ec['options'][_0x2db6('0x1b')],function(_0x562a5b){return{'model':db[_0x562a5b[_0x2db6('0x21')]],'as':_0x562a5b['as'],'attributes':_0x562a5b[_0x2db6('0x19')],'include':_0x562a5b[_0x2db6('0x1b')]?_[_0x2db6('0x1c')](_0x562a5b[_0x2db6('0x1b')],function(_0x58ed41){return{'model':db[_0x58ed41['model']],'as':_0x58ed41['as'],'attributes':_0x58ed41[_0x2db6('0x19')],'include':_0x58ed41['include']?_[_0x2db6('0x1c')](_0x58ed41[_0x2db6('0x1b')],function(_0x418f11){return{'model':db[_0x418f11[_0x2db6('0x21')]],'as':_0x418f11['as'],'attributes':_0x418f11['attributes']};}):[]};}):[]};}):[]:[]})[_0x2db6('0xa')](function(_0x2fb066){logger[_0x2db6('0xb')](_0x2db6('0x1d'),_0x1bf5ec);logger['debug']('ShowServicenowAccount',_0x1bf5ec,JSON[_0x2db6('0xf')](_0x2fb066));_0x50e7e5(_0x2fb066);})['catch'](function(_0x2479c6){logger[_0x2db6('0x10')](_0x2db6('0x1d'),_0x2479c6['message'],_0x1bf5ec);_0x9a3ab(_0x5b1d15[_0x2db6('0x10')](0x1f4,_0x2479c6[_0x2db6('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/intServicenowConfiguration/index.js b/server/api/intServicenowConfiguration/index.js new file mode 100644 index 0000000..459f2c3 --- /dev/null +++ b/server/api/intServicenowConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc14d=['connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./intServicenowConfiguration.controller','get','isAuthenticated','index','/:id/fields','getFields','/:id/subjects','getSubjects','post','create','put','/:id','update','delete','destroy','exports','multer','util','path'];(function(_0x3545e2,_0x3c2c69){var _0x218534=function(_0x5e9a14){while(--_0x5e9a14){_0x3545e2['push'](_0x3545e2['shift']());}};_0x218534(++_0x3c2c69);}(_0xc14d,0xed));var _0xdc14=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xc14d[_0x20a584];return _0x4b41a8;};'use strict';var multer=require(_0xdc14('0x0'));var util=require(_0xdc14('0x1'));var path=require(_0xdc14('0x2'));var timeout=require(_0xdc14('0x3'));var express=require('express');var router=express[_0xdc14('0x4')]();var fs_extra=require(_0xdc14('0x5'));var auth=require(_0xdc14('0x6'));var interaction=require(_0xdc14('0x7'));var config=require('../../config/environment');var controller=require(_0xdc14('0x8'));router[_0xdc14('0x9')]('/',auth[_0xdc14('0xa')](),controller[_0xdc14('0xb')]);router[_0xdc14('0x9')]('/:id',auth[_0xdc14('0xa')](),controller['show']);router[_0xdc14('0x9')](_0xdc14('0xc'),auth[_0xdc14('0xa')](),controller[_0xdc14('0xd')]);router['get'](_0xdc14('0xe'),auth[_0xdc14('0xa')](),controller[_0xdc14('0xf')]);router['get']('/:id/descriptions',auth[_0xdc14('0xa')](),controller['getDescriptions']);router[_0xdc14('0x10')]('/',auth[_0xdc14('0xa')](),controller[_0xdc14('0x11')]);router[_0xdc14('0x12')](_0xdc14('0x13'),auth[_0xdc14('0xa')](),controller[_0xdc14('0x14')]);router[_0xdc14('0x15')](_0xdc14('0x13'),auth[_0xdc14('0xa')](),controller[_0xdc14('0x16')]);module[_0xdc14('0x17')]=router; \ No newline at end of file diff --git a/server/api/intServicenowConfiguration/intServicenowConfiguration.attributes.js b/server/api/intServicenowConfiguration/intServicenowConfiguration.attributes.js new file mode 100644 index 0000000..3c069c9 --- /dev/null +++ b/server/api/intServicenowConfiguration/intServicenowConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfcb1=['sequelize','exports','STRING'];(function(_0xcb1763,_0x1b9378){var _0x3dab56=function(_0x4ed540){while(--_0x4ed540){_0xcb1763['push'](_0xcb1763['shift']());}};_0x3dab56(++_0x1b9378);}(_0xfcb1,0x1d1));var _0x1fcb=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xfcb1[_0x20a584];return _0x4b41a8;};'use strict';var Sequelize=require(_0x1fcb('0x0'));module[_0x1fcb('0x1')]={'name':{'type':Sequelize[_0x1fcb('0x2')]},'description':{'type':Sequelize[_0x1fcb('0x2')]}}; \ No newline at end of file diff --git a/server/api/intServicenowConfiguration/intServicenowConfiguration.controller.js b/server/api/intServicenowConfiguration/intServicenowConfiguration.controller.js new file mode 100644 index 0000000..d3237a3 --- /dev/null +++ b/server/api/intServicenowConfiguration/intServicenowConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda6b=['eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','update','then','destroy','error','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filters','filter','merge','options','ServicenowConfiguration','includeAll','include','findAll','rows','catch','show','params','find','create','body','getFields','findOne','ServicenowField','hasOwnProperty','getSubjects','getDescriptions'];(function(_0x4c139c,_0x59071a){var _0x3fbb6a=function(_0x23d7d2){while(--_0x23d7d2){_0x4c139c['push'](_0x4c139c['shift']());}};_0x3fbb6a(++_0x59071a);}(_0xda6b,0xf3));var _0xbda6=function(_0x33dffc,_0x2be66e){_0x33dffc=_0x33dffc-0x0;var _0x1f5420=_0xda6b[_0x33dffc];return _0x1f5420;};'use strict';var emlformat=require(_0xbda6('0x0'));var rimraf=require(_0xbda6('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbda6('0x2'));var rp=require(_0xbda6('0x3'));var moment=require(_0xbda6('0x4'));var BPromise=require(_0xbda6('0x5'));var Mustache=require('mustache');var util=require(_0xbda6('0x6'));var path=require(_0xbda6('0x7'));var sox=require('sox');var csv=require(_0xbda6('0x8'));var ejs=require(_0xbda6('0x9'));var fs=require('fs');var fs_extra=require(_0xbda6('0xa'));var _=require(_0xbda6('0xb'));var squel=require(_0xbda6('0xc'));var crypto=require('crypto');var jsforce=require(_0xbda6('0xd'));var deskjs=require(_0xbda6('0xe'));var toCsv=require(_0xbda6('0x8'));var querystring=require('querystring');var Papa=require(_0xbda6('0xf'));var Redis=require(_0xbda6('0x10'));var authService=require(_0xbda6('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xbda6('0x12'));var hardwareService=require(_0xbda6('0x13'));var logger=require(_0xbda6('0x14'))(_0xbda6('0x15'));var utils=require(_0xbda6('0x16'));var config=require(_0xbda6('0x17'));var licenseUtil=require(_0xbda6('0x18'));var db=require(_0xbda6('0x19'))['db'];function respondWithStatusCode(_0x2eb2d8,_0x5a44cc){_0x5a44cc=_0x5a44cc||0xcc;return function(_0x465b63){if(_0x465b63){return _0x2eb2d8[_0xbda6('0x1a')](_0x5a44cc);}return _0x2eb2d8['status'](_0x5a44cc)[_0xbda6('0x1b')]();};}function respondWithResult(_0x2e1055,_0x4a3b9b){_0x4a3b9b=_0x4a3b9b||0xc8;return function(_0x3508d0){if(_0x3508d0){return _0x2e1055[_0xbda6('0x1c')](_0x4a3b9b)[_0xbda6('0x1d')](_0x3508d0);}};}function respondWithFilteredResult(_0x1aa45b,_0x4d2b75){return function(_0x14a93){if(_0x14a93){var _0x2d6ce5=typeof _0x4d2b75[_0xbda6('0x1e')]===_0xbda6('0x1f')&&typeof _0x4d2b75['limit']==='undefined';var _0x2c7b1f=_0x14a93[_0xbda6('0x20')];var _0x3d38fc=_0x2d6ce5?0x0:_0x4d2b75[_0xbda6('0x1e')];var _0x282f3f=_0x2d6ce5?_0x14a93[_0xbda6('0x20')]:_0x4d2b75[_0xbda6('0x1e')]+_0x4d2b75[_0xbda6('0x21')];var _0x474b79;if(_0x282f3f>=_0x2c7b1f){_0x282f3f=_0x2c7b1f;_0x474b79=0xc8;}else{_0x474b79=0xce;}_0x1aa45b[_0xbda6('0x1c')](_0x474b79);return _0x1aa45b[_0xbda6('0x22')](_0xbda6('0x23'),_0x3d38fc+'-'+_0x282f3f+'/'+_0x2c7b1f)[_0xbda6('0x1d')](_0x14a93);}return null;};}function patchUpdates(_0x401374){return function(_0xf43b53){try{jsonpatch['apply'](_0xf43b53,_0x401374,!![]);}catch(_0x495bf7){return BPromise['reject'](_0x495bf7);}return _0xf43b53['save']();};}function saveUpdates(_0x41c042,_0x4d6edf){return function(_0x432f56){if(_0x432f56){return _0x432f56[_0xbda6('0x24')](_0x41c042)[_0xbda6('0x25')](function(_0x5c9629){return _0x5c9629;});}return null;};}function removeEntity(_0x4c1d8a,_0x20c7ac){return function(_0x45d156){if(_0x45d156){return _0x45d156[_0xbda6('0x26')]()[_0xbda6('0x25')](function(){_0x4c1d8a[_0xbda6('0x1c')](0xcc)[_0xbda6('0x1b')]();});}};}function handleEntityNotFound(_0x5c2507,_0x42af98){return function(_0x51ba8e){if(!_0x51ba8e){_0x5c2507['sendStatus'](0x194);}return _0x51ba8e;};}function handleError(_0x253cf3,_0x461e1f){_0x461e1f=_0x461e1f||0x1f4;return function(_0x4bc38a){logger[_0xbda6('0x27')](_0x4bc38a['stack']);if(_0x4bc38a['name']){delete _0x4bc38a[_0xbda6('0x28')];}_0x253cf3[_0xbda6('0x1c')](_0x461e1f)[_0xbda6('0x29')](_0x4bc38a);};}exports[_0xbda6('0x2a')]=function(_0x5b4e5f,_0x29b0d2){var _0x55e2={},_0x154f2d={},_0x5e3518={'count':0x0,'rows':[]};var _0x1fbaa4=_[_0xbda6('0x2b')](db['ServicenowConfiguration'][_0xbda6('0x2c')],function(_0xf08964){return{'name':_0xf08964[_0xbda6('0x2d')],'type':_0xf08964[_0xbda6('0x2e')][_0xbda6('0x2f')]};});_0x154f2d[_0xbda6('0x30')]=_['map'](_0x1fbaa4,'name');_0x154f2d[_0xbda6('0x31')]=_[_0xbda6('0x32')](_0x5b4e5f[_0xbda6('0x31')]);_0x154f2d['filters']=_[_0xbda6('0x33')](_0x154f2d[_0xbda6('0x30')],_0x154f2d[_0xbda6('0x31')]);_0x55e2[_0xbda6('0x34')]=_[_0xbda6('0x33')](_0x154f2d[_0xbda6('0x30')],qs[_0xbda6('0x35')](_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x35')]));_0x55e2[_0xbda6('0x34')]=_0x55e2[_0xbda6('0x34')][_0xbda6('0x36')]?_0x55e2[_0xbda6('0x34')]:_0x154f2d['model'];if(!_0x5b4e5f['query']['hasOwnProperty'](_0xbda6('0x37'))){_0x55e2[_0xbda6('0x21')]=qs[_0xbda6('0x21')](_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x21')]);_0x55e2[_0xbda6('0x1e')]=qs[_0xbda6('0x1e')](_0x5b4e5f[_0xbda6('0x31')]['offset']);}_0x55e2[_0xbda6('0x38')]=qs[_0xbda6('0x39')](_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x39')]);_0x55e2[_0xbda6('0x3a')]=qs['filters'](_[_0xbda6('0x3b')](_0x5b4e5f['query'],_0x154f2d[_0xbda6('0x3c')]),_0x1fbaa4);if(_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x3d')]){_0x55e2['where']=_[_0xbda6('0x3e')](_0x55e2[_0xbda6('0x3a')],{'$or':_[_0xbda6('0x2b')](_0x1fbaa4,function(_0x1d4f01){if(_0x1d4f01[_0xbda6('0x2e')]!=='VIRTUAL'){var _0x3b8f83={};_0x3b8f83[_0x1d4f01[_0xbda6('0x28')]]={'$like':'%'+_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x3d')]+'%'};return _0x3b8f83;}})});}_0x55e2=_['merge']({},_0x55e2,_0x5b4e5f[_0xbda6('0x3f')]);var _0x5709e5={'where':_0x55e2['where']};return db[_0xbda6('0x40')][_0xbda6('0x20')](_0x5709e5)[_0xbda6('0x25')](function(_0x2991b8){_0x5e3518['count']=_0x2991b8;if(_0x5b4e5f[_0xbda6('0x31')][_0xbda6('0x41')]){_0x55e2[_0xbda6('0x42')]=[{'all':!![]}];}return db[_0xbda6('0x40')][_0xbda6('0x43')](_0x55e2);})[_0xbda6('0x25')](function(_0x27ca2b){_0x5e3518[_0xbda6('0x44')]=_0x27ca2b;return _0x5e3518;})[_0xbda6('0x25')](respondWithFilteredResult(_0x29b0d2,_0x55e2))[_0xbda6('0x45')](handleError(_0x29b0d2,null));};exports[_0xbda6('0x46')]=function(_0xb5093,_0x28caac){var _0x5104b4={'raw':![],'where':{'id':_0xb5093[_0xbda6('0x47')]['id']}},_0x483997={};_0x483997[_0xbda6('0x30')]=_['keys'](db[_0xbda6('0x40')][_0xbda6('0x2c')]);_0x483997['query']=_[_0xbda6('0x32')](_0xb5093[_0xbda6('0x31')]);_0x483997[_0xbda6('0x3c')]=_[_0xbda6('0x33')](_0x483997[_0xbda6('0x30')],_0x483997[_0xbda6('0x31')]);_0x5104b4['attributes']=_['intersection'](_0x483997[_0xbda6('0x30')],qs[_0xbda6('0x35')](_0xb5093['query'][_0xbda6('0x35')]));_0x5104b4[_0xbda6('0x34')]=_0x5104b4[_0xbda6('0x34')]['length']?_0x5104b4[_0xbda6('0x34')]:_0x483997[_0xbda6('0x30')];if(_0xb5093[_0xbda6('0x31')][_0xbda6('0x41')]){_0x5104b4[_0xbda6('0x42')]=[{'all':!![]}];}_0x5104b4=_[_0xbda6('0x3e')]({},_0x5104b4,_0xb5093[_0xbda6('0x3f')]);return db[_0xbda6('0x40')][_0xbda6('0x48')](_0x5104b4)[_0xbda6('0x25')](handleEntityNotFound(_0x28caac,null))['then'](respondWithResult(_0x28caac,null))[_0xbda6('0x45')](handleError(_0x28caac,null));};exports['create']=function(_0x152862,_0x6d93f2){return db[_0xbda6('0x40')][_0xbda6('0x49')](_0x152862['body'],{})[_0xbda6('0x25')](respondWithResult(_0x6d93f2,0xc9))[_0xbda6('0x45')](handleError(_0x6d93f2,null));};exports[_0xbda6('0x24')]=function(_0x458f2a,_0x2f7472){if(_0x458f2a['body']['id']){delete _0x458f2a[_0xbda6('0x4a')]['id'];}return db['ServicenowConfiguration'][_0xbda6('0x48')]({'where':{'id':_0x458f2a[_0xbda6('0x47')]['id']}})['then'](handleEntityNotFound(_0x2f7472,null))[_0xbda6('0x25')](saveUpdates(_0x458f2a['body'],null))[_0xbda6('0x25')](respondWithResult(_0x2f7472,null))[_0xbda6('0x45')](handleError(_0x2f7472,null));};exports['destroy']=function(_0x12953e,_0x76efe){return db[_0xbda6('0x40')][_0xbda6('0x48')]({'where':{'id':_0x12953e[_0xbda6('0x47')]['id']}})[_0xbda6('0x25')](handleEntityNotFound(_0x76efe,null))[_0xbda6('0x25')](removeEntity(_0x76efe,null))['catch'](handleError(_0x76efe,null));};exports[_0xbda6('0x4b')]=function(_0x791708,_0x2d2ed0,_0x483ef3){var _0x1cb2b0={};var _0x21a338={};var _0x465bd2;var _0xa8f204;return db[_0xbda6('0x40')][_0xbda6('0x4c')]({'where':{'id':_0x791708[_0xbda6('0x47')]['id']}})[_0xbda6('0x25')](handleEntityNotFound(_0x2d2ed0,null))['then'](function(_0x2f4fc3){if(_0x2f4fc3){_0x465bd2=_0x2f4fc3;_0x21a338['model']=_[_0xbda6('0x32')](db[_0xbda6('0x4d')]['rawAttributes']);_0x21a338[_0xbda6('0x31')]=_[_0xbda6('0x32')](_0x791708[_0xbda6('0x31')]);_0x21a338[_0xbda6('0x3c')]=_[_0xbda6('0x33')](_0x21a338[_0xbda6('0x30')],_0x21a338[_0xbda6('0x31')]);_0x1cb2b0[_0xbda6('0x34')]=_['intersection'](_0x21a338[_0xbda6('0x30')],qs[_0xbda6('0x35')](_0x791708['query'][_0xbda6('0x35')]));_0x1cb2b0[_0xbda6('0x34')]=_0x1cb2b0['attributes'][_0xbda6('0x36')]?_0x1cb2b0[_0xbda6('0x34')]:_0x21a338[_0xbda6('0x30')];_0x1cb2b0[_0xbda6('0x38')]=qs['sort'](_0x791708['query'][_0xbda6('0x39')]);_0x1cb2b0[_0xbda6('0x3a')]=qs['filters'](_['pick'](_0x791708[_0xbda6('0x31')],_0x21a338[_0xbda6('0x3c')]));if(_0x791708[_0xbda6('0x31')]['filter']){_0x1cb2b0[_0xbda6('0x3a')]=_[_0xbda6('0x3e')](_0x1cb2b0[_0xbda6('0x3a')],{'$or':_['map'](_0x1cb2b0[_0xbda6('0x34')],function(_0x5a732c){var _0x440521={};_0x440521[_0x5a732c]={'$like':'%'+_0x791708[_0xbda6('0x31')]['filter']+'%'};return _0x440521;})});}_0x1cb2b0=_[_0xbda6('0x3e')]({},_0x1cb2b0,_0x791708[_0xbda6('0x3f')]);return _0x465bd2[_0xbda6('0x4b')](_0x1cb2b0);}})[_0xbda6('0x25')](function(_0x20c0c2){if(_0x20c0c2){_0xa8f204=_0x20c0c2[_0xbda6('0x36')];if(!_0x791708[_0xbda6('0x31')][_0xbda6('0x4e')](_0xbda6('0x37'))){_0x1cb2b0[_0xbda6('0x21')]=qs[_0xbda6('0x21')](_0x791708[_0xbda6('0x31')]['limit']);_0x1cb2b0[_0xbda6('0x1e')]=qs[_0xbda6('0x1e')](_0x791708[_0xbda6('0x31')]['offset']);}return _0x465bd2['getFields'](_0x1cb2b0);}})['then'](function(_0x10675b){if(_0x10675b){return _0x10675b?{'count':_0xa8f204,'rows':_0x10675b}:null;}})['then'](respondWithResult(_0x2d2ed0,null))[_0xbda6('0x45')](handleError(_0x2d2ed0,null));};exports[_0xbda6('0x4f')]=function(_0x208806,_0x350566,_0x6fc33d){var _0x427365={};var _0x43230a={};var _0x2dea17;var _0x3114cd;return db[_0xbda6('0x40')]['findOne']({'where':{'id':_0x208806['params']['id']}})[_0xbda6('0x25')](handleEntityNotFound(_0x350566,null))[_0xbda6('0x25')](function(_0x54f01d){if(_0x54f01d){_0x2dea17=_0x54f01d;_0x43230a[_0xbda6('0x30')]=_[_0xbda6('0x32')](db['ServicenowField'][_0xbda6('0x2c')]);_0x43230a[_0xbda6('0x31')]=_['keys'](_0x208806['query']);_0x43230a[_0xbda6('0x3c')]=_['intersection'](_0x43230a['model'],_0x43230a[_0xbda6('0x31')]);_0x427365['attributes']=_[_0xbda6('0x33')](_0x43230a[_0xbda6('0x30')],qs['fields'](_0x208806[_0xbda6('0x31')][_0xbda6('0x35')]));_0x427365[_0xbda6('0x34')]=_0x427365[_0xbda6('0x34')]['length']?_0x427365[_0xbda6('0x34')]:_0x43230a[_0xbda6('0x30')];_0x427365[_0xbda6('0x38')]=qs[_0xbda6('0x39')](_0x208806[_0xbda6('0x31')][_0xbda6('0x39')]);_0x427365[_0xbda6('0x3a')]=qs[_0xbda6('0x3c')](_[_0xbda6('0x3b')](_0x208806[_0xbda6('0x31')],_0x43230a[_0xbda6('0x3c')]));if(_0x208806[_0xbda6('0x31')]['filter']){_0x427365[_0xbda6('0x3a')]=_[_0xbda6('0x3e')](_0x427365[_0xbda6('0x3a')],{'$or':_[_0xbda6('0x2b')](_0x427365[_0xbda6('0x34')],function(_0x2e08f0){var _0x6b2c50={};_0x6b2c50[_0x2e08f0]={'$like':'%'+_0x208806[_0xbda6('0x31')][_0xbda6('0x3d')]+'%'};return _0x6b2c50;})});}_0x427365=_[_0xbda6('0x3e')]({},_0x427365,_0x208806['options']);return _0x2dea17['getSubjects'](_0x427365);}})['then'](function(_0x129ddb){if(_0x129ddb){_0x3114cd=_0x129ddb['length'];if(!_0x208806[_0xbda6('0x31')][_0xbda6('0x4e')](_0xbda6('0x37'))){_0x427365[_0xbda6('0x21')]=qs[_0xbda6('0x21')](_0x208806[_0xbda6('0x31')][_0xbda6('0x21')]);_0x427365['offset']=qs[_0xbda6('0x1e')](_0x208806['query']['offset']);}return _0x2dea17[_0xbda6('0x4f')](_0x427365);}})[_0xbda6('0x25')](function(_0x294e08){if(_0x294e08){return _0x294e08?{'count':_0x3114cd,'rows':_0x294e08}:null;}})[_0xbda6('0x25')](respondWithResult(_0x350566,null))[_0xbda6('0x45')](handleError(_0x350566,null));};exports[_0xbda6('0x50')]=function(_0x4571dd,_0x3288b0,_0x13d3a1){var _0x3f8f67={};var _0xfedbb5={};var _0xc50327;var _0xa12b42;return db['ServicenowConfiguration'][_0xbda6('0x4c')]({'where':{'id':_0x4571dd['params']['id']}})['then'](handleEntityNotFound(_0x3288b0,null))[_0xbda6('0x25')](function(_0x2d82a9){if(_0x2d82a9){_0xc50327=_0x2d82a9;_0xfedbb5['model']=_[_0xbda6('0x32')](db[_0xbda6('0x4d')][_0xbda6('0x2c')]);_0xfedbb5[_0xbda6('0x31')]=_[_0xbda6('0x32')](_0x4571dd[_0xbda6('0x31')]);_0xfedbb5[_0xbda6('0x3c')]=_[_0xbda6('0x33')](_0xfedbb5[_0xbda6('0x30')],_0xfedbb5['query']);_0x3f8f67[_0xbda6('0x34')]=_[_0xbda6('0x33')](_0xfedbb5[_0xbda6('0x30')],qs[_0xbda6('0x35')](_0x4571dd[_0xbda6('0x31')][_0xbda6('0x35')]));_0x3f8f67[_0xbda6('0x34')]=_0x3f8f67['attributes'][_0xbda6('0x36')]?_0x3f8f67['attributes']:_0xfedbb5[_0xbda6('0x30')];_0x3f8f67[_0xbda6('0x38')]=qs[_0xbda6('0x39')](_0x4571dd[_0xbda6('0x31')]['sort']);_0x3f8f67['where']=qs[_0xbda6('0x3c')](_[_0xbda6('0x3b')](_0x4571dd[_0xbda6('0x31')],_0xfedbb5[_0xbda6('0x3c')]));if(_0x4571dd[_0xbda6('0x31')][_0xbda6('0x3d')]){_0x3f8f67[_0xbda6('0x3a')]=_[_0xbda6('0x3e')](_0x3f8f67['where'],{'$or':_[_0xbda6('0x2b')](_0x3f8f67[_0xbda6('0x34')],function(_0x3bcb13){var _0x5536a6={};_0x5536a6[_0x3bcb13]={'$like':'%'+_0x4571dd[_0xbda6('0x31')]['filter']+'%'};return _0x5536a6;})});}_0x3f8f67=_['merge']({},_0x3f8f67,_0x4571dd[_0xbda6('0x3f')]);return _0xc50327[_0xbda6('0x50')](_0x3f8f67);}})['then'](function(_0x2920e8){if(_0x2920e8){_0xa12b42=_0x2920e8[_0xbda6('0x36')];if(!_0x4571dd[_0xbda6('0x31')][_0xbda6('0x4e')](_0xbda6('0x37'))){_0x3f8f67[_0xbda6('0x21')]=qs[_0xbda6('0x21')](_0x4571dd['query']['limit']);_0x3f8f67[_0xbda6('0x1e')]=qs[_0xbda6('0x1e')](_0x4571dd[_0xbda6('0x31')][_0xbda6('0x1e')]);}return _0xc50327[_0xbda6('0x50')](_0x3f8f67);}})[_0xbda6('0x25')](function(_0x5b1ac0){if(_0x5b1ac0){return _0x5b1ac0?{'count':_0xa12b42,'rows':_0x5b1ac0}:null;}})['then'](respondWithResult(_0x3288b0,null))[_0xbda6('0x45')](handleError(_0x3288b0,null));}; \ No newline at end of file diff --git a/server/api/intServicenowConfiguration/intServicenowConfiguration.model.js b/server/api/intServicenowConfiguration/intServicenowConfiguration.model.js new file mode 100644 index 0000000..a0794f0 --- /dev/null +++ b/server/api/intServicenowConfiguration/intServicenowConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3495=['../../config/logger','api','moment','bluebird','request-promise','path','rimraf','./intServicenowConfiguration.attributes','exports','ServicenowConfiguration','lodash','util'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0x3495,0x1de));var _0x5349=function(_0x525ab5,_0x404107){_0x525ab5=_0x525ab5-0x0;var _0x4a5fed=_0x3495[_0x525ab5];return _0x4a5fed;};'use strict';var _=require(_0x5349('0x0'));var util=require(_0x5349('0x1'));var logger=require(_0x5349('0x2'))(_0x5349('0x3'));var moment=require(_0x5349('0x4'));var BPromise=require(_0x5349('0x5'));var rp=require(_0x5349('0x6'));var fs=require('fs');var path=require(_0x5349('0x7'));var rimraf=require(_0x5349('0x8'));var config=require('../../config/environment');var attributes=require(_0x5349('0x9'));module[_0x5349('0xa')]=function(_0x5ce2cd,_0xcb5a1){return _0x5ce2cd['define'](_0x5349('0xb'),attributes,{'tableName':'int_servicenow_configurations','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intServicenowConfiguration/intServicenowConfiguration.rpc.js b/server/api/intServicenowConfiguration/intServicenowConfiguration.rpc.js new file mode 100644 index 0000000..39c1ec1 --- /dev/null +++ b/server/api/intServicenowConfiguration/intServicenowConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf576=['util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','info','ServicenowConfiguration,\x20%s,\x20%s','request\x20sent','debug','ServicenowConfiguration,\x20%s,\x20%s,\x20%s','error','message','result','catch','lodash'];(function(_0x5bee28,_0x1dc7e2){var _0x395d1d=function(_0x33af90){while(--_0x33af90){_0x5bee28['push'](_0x5bee28['shift']());}};_0x395d1d(++_0x1dc7e2);}(_0xf576,0xef));var _0x6f57=function(_0x2c1c95,_0x30915b){_0x2c1c95=_0x2c1c95-0x0;var _0x1b60b8=_0xf576[_0x2c1c95];return _0x1b60b8;};'use strict';var _=require(_0x6f57('0x0'));var util=require(_0x6f57('0x1'));var moment=require(_0x6f57('0x2'));var BPromise=require(_0x6f57('0x3'));var rs=require(_0x6f57('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x6f57('0x5'));var logger=require(_0x6f57('0x6'))(_0x6f57('0x7'));var config=require('../../config/environment');var jayson=require(_0x6f57('0x8'));var client=jayson[_0x6f57('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5a8ced,_0x40647a,_0x6edc9d){return new BPromise(function(_0x4292c8,_0x5951fb){return client['request'](_0x5a8ced,_0x6edc9d)[_0x6f57('0xa')](function(_0x4ecc94){logger[_0x6f57('0xb')](_0x6f57('0xc'),_0x40647a,_0x6f57('0xd'));logger[_0x6f57('0xe')](_0x6f57('0xf'),_0x40647a,_0x6f57('0xd'),JSON['stringify'](_0x4ecc94));if(_0x4ecc94[_0x6f57('0x10')]){if(_0x4ecc94[_0x6f57('0x10')]['code']===0x1f4){logger['error']('ServicenowConfiguration,\x20%s,\x20%s',_0x40647a,_0x4ecc94[_0x6f57('0x10')][_0x6f57('0x11')]);return _0x5951fb(_0x4ecc94[_0x6f57('0x10')][_0x6f57('0x11')]);}logger[_0x6f57('0x10')](_0x6f57('0xc'),_0x40647a,_0x4ecc94[_0x6f57('0x10')]['message']);return _0x4292c8(_0x4ecc94['error'][_0x6f57('0x11')]);}else{logger[_0x6f57('0xb')](_0x6f57('0xc'),_0x40647a,'request\x20sent');_0x4292c8(_0x4ecc94[_0x6f57('0x12')][_0x6f57('0x11')]);}})[_0x6f57('0x13')](function(_0x13565c){logger[_0x6f57('0x10')](_0x6f57('0xc'),_0x40647a,_0x13565c);_0x5951fb(_0x13565c);});});} \ No newline at end of file diff --git a/server/api/intServicenowField/index.js b/server/api/intServicenowField/index.js new file mode 100644 index 0000000..a33292b --- /dev/null +++ b/server/api/intServicenowField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x29b4=['put','update','destroy','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','isAuthenticated','index','get','/:id','show','post','create'];(function(_0x35a686,_0x7167e4){var _0x1ec0e3=function(_0x5db6a4){while(--_0x5db6a4){_0x35a686['push'](_0x35a686['shift']());}};_0x1ec0e3(++_0x7167e4);}(_0x29b4,0x1a5));var _0x429b=function(_0x5130fc,_0x57f935){_0x5130fc=_0x5130fc-0x0;var _0xdde96a=_0x29b4[_0x5130fc];return _0xdde96a;};'use strict';var multer=require(_0x429b('0x0'));var util=require(_0x429b('0x1'));var path=require(_0x429b('0x2'));var timeout=require(_0x429b('0x3'));var express=require(_0x429b('0x4'));var router=express[_0x429b('0x5')]();var fs_extra=require(_0x429b('0x6'));var auth=require(_0x429b('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0x429b('0x8'));var controller=require('./intServicenowField.controller');router['get']('/',auth[_0x429b('0x9')](),controller[_0x429b('0xa')]);router[_0x429b('0xb')](_0x429b('0xc'),auth[_0x429b('0x9')](),controller[_0x429b('0xd')]);router[_0x429b('0xe')]('/',auth[_0x429b('0x9')](),controller[_0x429b('0xf')]);router[_0x429b('0x10')](_0x429b('0xc'),auth[_0x429b('0x9')](),controller[_0x429b('0x11')]);router['delete'](_0x429b('0xc'),auth[_0x429b('0x9')](),controller[_0x429b('0x12')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/intServicenowField/intServicenowField.attributes.js b/server/api/intServicenowField/intServicenowField.attributes.js new file mode 100644 index 0000000..dcac4de --- /dev/null +++ b/server/api/intServicenowField/intServicenowField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xea13=['BOOLEAN','sequelize','exports','ENUM','string','customVariable','keyValue','picklist','STRING','variable'];(function(_0x31a056,_0x39cac3){var _0x5c3717=function(_0x212d17){while(--_0x212d17){_0x31a056['push'](_0x31a056['shift']());}};_0x5c3717(++_0x39cac3);}(_0xea13,0x8d));var _0x3ea1=function(_0x3aa0e0,_0x5cec89){_0x3aa0e0=_0x3aa0e0-0x0;var _0x38dba1=_0xea13[_0x3aa0e0];return _0x38dba1;};'use strict';var Sequelize=require(_0x3ea1('0x0'));module[_0x3ea1('0x1')]={'type':{'type':Sequelize[_0x3ea1('0x2')](_0x3ea1('0x3'),'variable',_0x3ea1('0x4'),_0x3ea1('0x5'),_0x3ea1('0x6')),'defaultValue':'string'},'content':{'type':Sequelize[_0x3ea1('0x7')]},'key':{'type':Sequelize[_0x3ea1('0x7')]},'keyType':{'type':Sequelize['ENUM'](_0x3ea1('0x3'),_0x3ea1('0x8'),_0x3ea1('0x4'))},'keyContent':{'type':Sequelize[_0x3ea1('0x7')]},'idField':{'type':Sequelize['STRING']},'nameField':{'type':Sequelize[_0x3ea1('0x7')]},'customField':{'type':Sequelize[_0x3ea1('0x9')],'defaultValue':!![]},'variableName':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intServicenowField/intServicenowField.controller.js b/server/api/intServicenowField/intServicenowField.controller.js new file mode 100644 index 0000000..402c323 --- /dev/null +++ b/server/api/intServicenowField/intServicenowField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5eac=['../../config/environment','../../mysqldb','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','sendStatus','stack','name','send','index','ServicenowField','fieldName','type','key','map','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','includeAll','rows','catch','params','keys','rawAttributes','include','options','create','body','find','eml-format','rimraf','zip-dir','request-promise','mustache','util','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils'];(function(_0x18ac44,_0x5e525e){var _0x521d09=function(_0x512ee4){while(--_0x512ee4){_0x18ac44['push'](_0x18ac44['shift']());}};_0x521d09(++_0x5e525e);}(_0x5eac,0x112));var _0xc5ea=function(_0x29ab17,_0x1003fb){_0x29ab17=_0x29ab17-0x0;var _0x2d60a8=_0x5eac[_0x29ab17];return _0x2d60a8;};'use strict';var emlformat=require(_0xc5ea('0x0'));var rimraf=require(_0xc5ea('0x1'));var zipdir=require(_0xc5ea('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc5ea('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xc5ea('0x4'));var util=require(_0xc5ea('0x5'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xc5ea('0x6'));var _=require(_0xc5ea('0x7'));var squel=require(_0xc5ea('0x8'));var crypto=require(_0xc5ea('0x9'));var jsforce=require(_0xc5ea('0xa'));var deskjs=require(_0xc5ea('0xb'));var toCsv=require(_0xc5ea('0xc'));var querystring=require(_0xc5ea('0xd'));var Papa=require(_0xc5ea('0xe'));var Redis=require(_0xc5ea('0xf'));var authService=require(_0xc5ea('0x10'));var qs=require(_0xc5ea('0x11'));var as=require(_0xc5ea('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc5ea('0x13'))(_0xc5ea('0x14'));var utils=require(_0xc5ea('0x15'));var config=require(_0xc5ea('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xc5ea('0x17'))['db'];function respondWithStatusCode(_0x29b32a,_0x292342){_0x292342=_0x292342||0xcc;return function(_0x7a5468){if(_0x7a5468){return _0x29b32a['sendStatus'](_0x292342);}return _0x29b32a['status'](_0x292342)[_0xc5ea('0x18')]();};}function respondWithResult(_0xad3805,_0x33349a){_0x33349a=_0x33349a||0xc8;return function(_0x2a5a51){if(_0x2a5a51){return _0xad3805[_0xc5ea('0x19')](_0x33349a)[_0xc5ea('0x1a')](_0x2a5a51);}};}function respondWithFilteredResult(_0x4ec6a1,_0x537a63){return function(_0x1b1e10){if(_0x1b1e10){var _0x37365a=typeof _0x537a63[_0xc5ea('0x1b')]===_0xc5ea('0x1c')&&typeof _0x537a63[_0xc5ea('0x1d')]===_0xc5ea('0x1c');var _0x5c6f10=_0x1b1e10['count'];var _0x218093=_0x37365a?0x0:_0x537a63[_0xc5ea('0x1b')];var _0x4ac438=_0x37365a?_0x1b1e10[_0xc5ea('0x1e')]:_0x537a63[_0xc5ea('0x1b')]+_0x537a63[_0xc5ea('0x1d')];var _0x5bb638;if(_0x4ac438>=_0x5c6f10){_0x4ac438=_0x5c6f10;_0x5bb638=0xc8;}else{_0x5bb638=0xce;}_0x4ec6a1[_0xc5ea('0x19')](_0x5bb638);return _0x4ec6a1[_0xc5ea('0x1f')](_0xc5ea('0x20'),_0x218093+'-'+_0x4ac438+'/'+_0x5c6f10)['json'](_0x1b1e10);}return null;};}function patchUpdates(_0x3e1dc8){return function(_0x58702a){try{jsonpatch[_0xc5ea('0x21')](_0x58702a,_0x3e1dc8,!![]);}catch(_0x33b7d2){return BPromise[_0xc5ea('0x22')](_0x33b7d2);}return _0x58702a['save']();};}function saveUpdates(_0x50ecfa,_0x3f28d2){return function(_0x19074e){if(_0x19074e){return _0x19074e[_0xc5ea('0x23')](_0x50ecfa)[_0xc5ea('0x24')](function(_0x2f5bb2){return _0x2f5bb2;});}return null;};}function removeEntity(_0x3df497,_0x5f5684){return function(_0x5f3452){if(_0x5f3452){return _0x5f3452[_0xc5ea('0x25')]()[_0xc5ea('0x24')](function(){_0x3df497[_0xc5ea('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x191f1a,_0x249dd5){return function(_0x308311){if(!_0x308311){_0x191f1a[_0xc5ea('0x26')](0x194);}return _0x308311;};}function handleError(_0x25fd20,_0xba4001){_0xba4001=_0xba4001||0x1f4;return function(_0x12f3cf){logger['error'](_0x12f3cf[_0xc5ea('0x27')]);if(_0x12f3cf[_0xc5ea('0x28')]){delete _0x12f3cf[_0xc5ea('0x28')];}_0x25fd20[_0xc5ea('0x19')](_0xba4001)[_0xc5ea('0x29')](_0x12f3cf);};}exports[_0xc5ea('0x2a')]=function(_0x459760,_0x37c673){var _0x219dab={},_0x447919={},_0x23ec46={'count':0x0,'rows':[]};var _0x457fff=_['map'](db[_0xc5ea('0x2b')]['rawAttributes'],function(_0x3dd7fe){return{'name':_0x3dd7fe[_0xc5ea('0x2c')],'type':_0x3dd7fe[_0xc5ea('0x2d')][_0xc5ea('0x2e')]};});_0x447919['model']=_[_0xc5ea('0x2f')](_0x457fff,'name');_0x447919['query']=_['keys'](_0x459760[_0xc5ea('0x30')]);_0x447919['filters']=_[_0xc5ea('0x31')](_0x447919[_0xc5ea('0x32')],_0x447919[_0xc5ea('0x30')]);_0x219dab[_0xc5ea('0x33')]=_['intersection'](_0x447919[_0xc5ea('0x32')],qs[_0xc5ea('0x34')](_0x459760[_0xc5ea('0x30')][_0xc5ea('0x34')]));_0x219dab[_0xc5ea('0x33')]=_0x219dab[_0xc5ea('0x33')][_0xc5ea('0x35')]?_0x219dab[_0xc5ea('0x33')]:_0x447919[_0xc5ea('0x32')];if(!_0x459760[_0xc5ea('0x30')][_0xc5ea('0x36')](_0xc5ea('0x37'))){_0x219dab[_0xc5ea('0x1d')]=qs['limit'](_0x459760[_0xc5ea('0x30')][_0xc5ea('0x1d')]);_0x219dab[_0xc5ea('0x1b')]=qs[_0xc5ea('0x1b')](_0x459760['query'][_0xc5ea('0x1b')]);}_0x219dab[_0xc5ea('0x38')]=qs[_0xc5ea('0x39')](_0x459760[_0xc5ea('0x30')][_0xc5ea('0x39')]);_0x219dab[_0xc5ea('0x3a')]=qs[_0xc5ea('0x3b')](_[_0xc5ea('0x3c')](_0x459760[_0xc5ea('0x30')],_0x447919['filters']),_0x457fff);if(_0x459760['query'][_0xc5ea('0x3d')]){_0x219dab[_0xc5ea('0x3a')]=_[_0xc5ea('0x3e')](_0x219dab[_0xc5ea('0x3a')],{'$or':_[_0xc5ea('0x2f')](_0x457fff,function(_0x1b4002){if(_0x1b4002[_0xc5ea('0x2d')]!=='VIRTUAL'){var _0x34a07c={};_0x34a07c[_0x1b4002[_0xc5ea('0x28')]]={'$like':'%'+_0x459760[_0xc5ea('0x30')][_0xc5ea('0x3d')]+'%'};return _0x34a07c;}})});}_0x219dab=_[_0xc5ea('0x3e')]({},_0x219dab,_0x459760['options']);var _0x1fb66c={'where':_0x219dab[_0xc5ea('0x3a')]};return db[_0xc5ea('0x2b')][_0xc5ea('0x1e')](_0x1fb66c)['then'](function(_0x499c29){_0x23ec46[_0xc5ea('0x1e')]=_0x499c29;if(_0x459760[_0xc5ea('0x30')][_0xc5ea('0x3f')]){_0x219dab['include']=[{'all':!![]}];}return db[_0xc5ea('0x2b')]['findAll'](_0x219dab);})[_0xc5ea('0x24')](function(_0x28aac7){_0x23ec46[_0xc5ea('0x40')]=_0x28aac7;return _0x23ec46;})[_0xc5ea('0x24')](respondWithFilteredResult(_0x37c673,_0x219dab))[_0xc5ea('0x41')](handleError(_0x37c673,null));};exports['show']=function(_0x183694,_0x3c944d){var _0x3cca89={'raw':!![],'where':{'id':_0x183694[_0xc5ea('0x42')]['id']}},_0x3ac27d={};_0x3ac27d['model']=_[_0xc5ea('0x43')](db[_0xc5ea('0x2b')][_0xc5ea('0x44')]);_0x3ac27d[_0xc5ea('0x30')]=_[_0xc5ea('0x43')](_0x183694[_0xc5ea('0x30')]);_0x3ac27d[_0xc5ea('0x3b')]=_[_0xc5ea('0x31')](_0x3ac27d[_0xc5ea('0x32')],_0x3ac27d[_0xc5ea('0x30')]);_0x3cca89[_0xc5ea('0x33')]=_['intersection'](_0x3ac27d['model'],qs[_0xc5ea('0x34')](_0x183694[_0xc5ea('0x30')][_0xc5ea('0x34')]));_0x3cca89[_0xc5ea('0x33')]=_0x3cca89[_0xc5ea('0x33')][_0xc5ea('0x35')]?_0x3cca89['attributes']:_0x3ac27d[_0xc5ea('0x32')];if(_0x183694[_0xc5ea('0x30')][_0xc5ea('0x3f')]){_0x3cca89[_0xc5ea('0x45')]=[{'all':!![]}];}_0x3cca89=_[_0xc5ea('0x3e')]({},_0x3cca89,_0x183694[_0xc5ea('0x46')]);return db[_0xc5ea('0x2b')]['find'](_0x3cca89)[_0xc5ea('0x24')](handleEntityNotFound(_0x3c944d,null))[_0xc5ea('0x24')](respondWithResult(_0x3c944d,null))[_0xc5ea('0x41')](handleError(_0x3c944d,null));};exports[_0xc5ea('0x47')]=function(_0x129789,_0x1459df){return db[_0xc5ea('0x2b')][_0xc5ea('0x47')](_0x129789[_0xc5ea('0x48')],{})[_0xc5ea('0x24')](respondWithResult(_0x1459df,0xc9))[_0xc5ea('0x41')](handleError(_0x1459df,null));};exports['update']=function(_0x561706,_0x48e57e){if(_0x561706[_0xc5ea('0x48')]['id']){delete _0x561706['body']['id'];}return db[_0xc5ea('0x2b')]['find']({'where':{'id':_0x561706[_0xc5ea('0x42')]['id']}})[_0xc5ea('0x24')](handleEntityNotFound(_0x48e57e,null))[_0xc5ea('0x24')](saveUpdates(_0x561706[_0xc5ea('0x48')],null))[_0xc5ea('0x24')](respondWithResult(_0x48e57e,null))[_0xc5ea('0x41')](handleError(_0x48e57e,null));};exports[_0xc5ea('0x25')]=function(_0x54435f,_0xee2c0d){return db[_0xc5ea('0x2b')][_0xc5ea('0x49')]({'where':{'id':_0x54435f['params']['id']}})[_0xc5ea('0x24')](handleEntityNotFound(_0xee2c0d,null))['then'](removeEntity(_0xee2c0d,null))[_0xc5ea('0x41')](handleError(_0xee2c0d,null));}; \ No newline at end of file diff --git a/server/api/intServicenowField/intServicenowField.model.js b/server/api/intServicenowField/intServicenowField.model.js new file mode 100644 index 0000000..4df4318 --- /dev/null +++ b/server/api/intServicenowField/intServicenowField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe4c0=['int_servicenow_fields','servicenow_unique_index','idField','FieldId','util','moment','request-promise','path','../../config/environment','./intServicenowField.attributes','exports','define','ServicenowField'];(function(_0x222d6e,_0x35dec2){var _0x1208e1=function(_0x4bd22b){while(--_0x4bd22b){_0x222d6e['push'](_0x222d6e['shift']());}};_0x1208e1(++_0x35dec2);}(_0xe4c0,0xe1));var _0x0e4c=function(_0x369a98,_0x32250c){_0x369a98=_0x369a98-0x0;var _0x29565c=_0xe4c0[_0x369a98];return _0x29565c;};'use strict';var _=require('lodash');var util=require(_0x0e4c('0x0'));var logger=require('../../config/logger')('api');var moment=require(_0x0e4c('0x1'));var BPromise=require('bluebird');var rp=require(_0x0e4c('0x2'));var fs=require('fs');var path=require(_0x0e4c('0x3'));var rimraf=require('rimraf');var config=require(_0x0e4c('0x4'));var attributes=require(_0x0e4c('0x5'));module[_0x0e4c('0x6')]=function(_0xb998da,_0x572204){return _0xb998da[_0x0e4c('0x7')](_0x0e4c('0x8'),attributes,{'tableName':_0x0e4c('0x9'),'paranoid':![],'indexes':[{'name':_0x0e4c('0xa'),'fields':[_0x0e4c('0xb'),_0x0e4c('0xc')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intServicenowField/intServicenowField.rpc.js b/server/api/intServicenowField/intServicenowField.rpc.js new file mode 100644 index 0000000..9d62fc1 --- /dev/null +++ b/server/api/intServicenowField/intServicenowField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9ffd=['ServicenowField,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','ServicenowField,\x20%s,\x20%s','info','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','debug'];(function(_0x3abde4,_0x5e0d86){var _0x59c745=function(_0x302fb5){while(--_0x302fb5){_0x3abde4['push'](_0x3abde4['shift']());}};_0x59c745(++_0x5e0d86);}(_0x9ffd,0xaa));var _0xd9ff=function(_0x2cddd3,_0x1b6680){_0x2cddd3=_0x2cddd3-0x0;var _0x3501eb=_0x9ffd[_0x2cddd3];return _0x3501eb;};'use strict';var _=require(_0xd9ff('0x0'));var util=require(_0xd9ff('0x1'));var moment=require(_0xd9ff('0x2'));var BPromise=require('bluebird');var rs=require(_0xd9ff('0x3'));var fs=require('fs');var Redis=require(_0xd9ff('0x4'));var db=require(_0xd9ff('0x5'))['db'];var utils=require(_0xd9ff('0x6'));var logger=require('../../config/logger')(_0xd9ff('0x7'));var config=require(_0xd9ff('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xd9ff('0x9')][_0xd9ff('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x13ea8c,_0x270eb2,_0x45c60a){return new BPromise(function(_0x66282d,_0x13954e){return client[_0xd9ff('0xb')](_0x13ea8c,_0x45c60a)[_0xd9ff('0xc')](function(_0x58e728){logger['info']('ServicenowField,\x20%s,\x20%s',_0x270eb2,'request\x20sent');logger[_0xd9ff('0xd')](_0xd9ff('0xe'),_0x270eb2,_0xd9ff('0xf'),JSON[_0xd9ff('0x10')](_0x58e728));if(_0x58e728[_0xd9ff('0x11')]){if(_0x58e728[_0xd9ff('0x11')][_0xd9ff('0x12')]===0x1f4){logger[_0xd9ff('0x11')]('ServicenowField,\x20%s,\x20%s',_0x270eb2,_0x58e728['error'][_0xd9ff('0x13')]);return _0x13954e(_0x58e728[_0xd9ff('0x11')][_0xd9ff('0x13')]);}logger[_0xd9ff('0x11')](_0xd9ff('0x14'),_0x270eb2,_0x58e728['error'][_0xd9ff('0x13')]);return _0x66282d(_0x58e728[_0xd9ff('0x11')]['message']);}else{logger[_0xd9ff('0x15')]('ServicenowField,\x20%s,\x20%s',_0x270eb2,'request\x20sent');_0x66282d(_0x58e728['result']['message']);}})[_0xd9ff('0x16')](function(_0x4f9d6d){logger[_0xd9ff('0x11')](_0xd9ff('0x14'),_0x270eb2,_0x4f9d6d);_0x13954e(_0x4f9d6d);});});} \ No newline at end of file diff --git a/server/api/intSugarcrmAccount/index.js b/server/api/intSugarcrmAccount/index.js new file mode 100644 index 0000000..f74beab --- /dev/null +++ b/server/api/intSugarcrmAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./intSugarcrmAccount.controller','get','index','/:id','getConfigurations','/:id/fields','isAuthenticated','getFields','post','addConfiguration','put','update','destroy','exports','multer','util','path'];(function(_0x31cd79,_0x1a667a){var _0x12d5dd=function(_0x4a60e0){while(--_0x4a60e0){_0x31cd79['push'](_0x31cd79['shift']());}};_0x12d5dd(++_0x1a667a);}(_0xa9e0,0x123));var _0x0a9e=function(_0x24237f,_0x4cf32c){_0x24237f=_0x24237f-0x0;var _0x48298e=_0xa9e0[_0x24237f];return _0x48298e;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['show']);router[_0x0a9e('0x8')]('/:id/configurations',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);router[_0x0a9e('0x8')](_0x0a9e('0xc'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0xf')]('/',auth['isAuthenticated'](),controller['create']);router['post']('/:id/configurations',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x10')]);router[_0x0a9e('0x11')](_0x0a9e('0xa'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x12')]);router['delete'](_0x0a9e('0xa'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x13')]);module[_0x0a9e('0x14')]=router; \ No newline at end of file diff --git a/server/api/intSugarcrmAccount/intSugarcrmAccount.attributes.js b/server/api/intSugarcrmAccount/intSugarcrmAccount.attributes.js new file mode 100644 index 0000000..e6c258e --- /dev/null +++ b/server/api/intSugarcrmAccount/intSugarcrmAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['remoteUri','sequelize','exports','STRING','username'];(function(_0x3b04fb,_0x36a420){var _0x159be6=function(_0x5194c7){while(--_0x5194c7){_0x3b04fb['push'](_0x3b04fb['shift']());}};_0x159be6(++_0x36a420);}(_0xa9e0,0x123));var _0x0a9e=function(_0x4709c0,_0x3396c7){_0x4709c0=_0x4709c0-0x0;var _0x13348b=_0xa9e0[_0x4709c0];return _0x13348b;};'use strict';var Sequelize=require(_0x0a9e('0x0'));module[_0x0a9e('0x1')]={'name':{'type':Sequelize[_0x0a9e('0x2')]},'description':{'type':Sequelize['STRING']},'username':{'type':Sequelize['STRING'],'unique':_0x0a9e('0x3')},'password':{'type':Sequelize['STRING']},'remoteUri':{'type':Sequelize[_0x0a9e('0x2')],'unique':_0x0a9e('0x4')},'serverUrl':{'type':Sequelize[_0x0a9e('0x2')],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/intSugarcrmAccount/intSugarcrmAccount.controller.js b/server/api/intSugarcrmAccount/intSugarcrmAccount.controller.js new file mode 100644 index 0000000..749aa1b --- /dev/null +++ b/server/api/intSugarcrmAccount/intSugarcrmAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8fe0=['index','map','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','VIRTUAL','name','merge','options','SugarcrmAccount','includeAll','include','rows','show','params','keys','find','catch','create','body','getConfigurations','findOne','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SugarcrmConfiguration','SugarcrmField','getFields','created_by','description','parent_id','parent_type','parent_name','direction','password','remoteUri','substring','lastIndexOf','POST','format','/service/v4_1/rest.php','JSON','stringify','PLAIN','Invalid\x20Login','%s%s','get_module_fields','values','module_fields','remove','includes','label','endsWith','value','test','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','to-csv','ejs','lodash','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','offset','undefined','limit','count','set','Content-Range','json','save','update','then','sendStatus','error','stack','send'];(function(_0x26eb00,_0x535593){var _0x1b23dc=function(_0x4e531a){while(--_0x4e531a){_0x26eb00['push'](_0x26eb00['shift']());}};_0x1b23dc(++_0x535593);}(_0x8fe0,0x1ab));var _0x08fe=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x8fe0[_0xa464c9];return _0x3d73c4;};'use strict';var emlformat=require(_0x08fe('0x0'));var rimraf=require(_0x08fe('0x1'));var zipdir=require(_0x08fe('0x2'));var jsonpatch=require(_0x08fe('0x3'));var rp=require(_0x08fe('0x4'));var moment=require(_0x08fe('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x08fe('0x6'));var util=require(_0x08fe('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x08fe('0x8'));var ejs=require(_0x08fe('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x08fe('0xa'));var squel=require(_0x08fe('0xb'));var crypto=require(_0x08fe('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x08fe('0xd'));var Redis=require(_0x08fe('0xe'));var authService=require(_0x08fe('0xf'));var qs=require(_0x08fe('0x10'));var as=require(_0x08fe('0x11'));var hardwareService=require(_0x08fe('0x12'));var logger=require('../../config/logger')(_0x08fe('0x13'));var utils=require(_0x08fe('0x14'));var config=require(_0x08fe('0x15'));var licenseUtil=require(_0x08fe('0x16'));var db=require(_0x08fe('0x17'))['db'];var integrations=require(_0x08fe('0x18'));function respondWithStatusCode(_0x44bde4,_0x5094fc){_0x5094fc=_0x5094fc||0xcc;return function(_0x38b8c6){if(_0x38b8c6){return _0x44bde4['sendStatus'](_0x5094fc);}return _0x44bde4[_0x08fe('0x19')](_0x5094fc)[_0x08fe('0x1a')]();};}function respondWithResult(_0x5c8bec,_0x8c2798){_0x8c2798=_0x8c2798||0xc8;return function(_0x32c713){if(_0x32c713){return _0x5c8bec[_0x08fe('0x19')](_0x8c2798)['json'](_0x32c713);}};}function respondWithFilteredResult(_0x361b5b,_0x24fc60){return function(_0x4ac8e8){if(_0x4ac8e8){var _0xb83ed7=typeof _0x24fc60[_0x08fe('0x1b')]===_0x08fe('0x1c')&&typeof _0x24fc60[_0x08fe('0x1d')]===_0x08fe('0x1c');var _0x3e24b8=_0x4ac8e8['count'];var _0x372b68=_0xb83ed7?0x0:_0x24fc60[_0x08fe('0x1b')];var _0x313f02=_0xb83ed7?_0x4ac8e8[_0x08fe('0x1e')]:_0x24fc60[_0x08fe('0x1b')]+_0x24fc60[_0x08fe('0x1d')];var _0x46f752;if(_0x313f02>=_0x3e24b8){_0x313f02=_0x3e24b8;_0x46f752=0xc8;}else{_0x46f752=0xce;}_0x361b5b[_0x08fe('0x19')](_0x46f752);return _0x361b5b[_0x08fe('0x1f')](_0x08fe('0x20'),_0x372b68+'-'+_0x313f02+'/'+_0x3e24b8)[_0x08fe('0x21')](_0x4ac8e8);}return null;};}function patchUpdates(_0x57fe96){return function(_0x31707d){try{jsonpatch['apply'](_0x31707d,_0x57fe96,!![]);}catch(_0x315e7c){return BPromise['reject'](_0x315e7c);}return _0x31707d[_0x08fe('0x22')]();};}function saveUpdates(_0x4f81da,_0x485c40){return function(_0x4e4be3){if(_0x4e4be3){return _0x4e4be3[_0x08fe('0x23')](_0x4f81da)['then'](function(_0x21f32b){return _0x21f32b;});}return null;};}function removeEntity(_0x2d66db,_0x2de9db){return function(_0x397352){if(_0x397352){return _0x397352['destroy']()[_0x08fe('0x24')](function(){_0x2d66db[_0x08fe('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4932f4,_0x392d4e){return function(_0x3b09c5){if(!_0x3b09c5){_0x4932f4[_0x08fe('0x25')](0x194);}return _0x3b09c5;};}function handleError(_0x2b2d68,_0x2a4fca){_0x2a4fca=_0x2a4fca||0x1f4;return function(_0x14b2fb){logger[_0x08fe('0x26')](_0x14b2fb[_0x08fe('0x27')]);if(_0x14b2fb['name']){delete _0x14b2fb['name'];}_0x2b2d68[_0x08fe('0x19')](_0x2a4fca)[_0x08fe('0x28')](_0x14b2fb);};}exports[_0x08fe('0x29')]=function(_0x106b51,_0x4082a1){var _0x2d3a27={},_0x57aca5={},_0x1fded9={'count':0x0,'rows':[]};var _0x1f8c09=_[_0x08fe('0x2a')](db['SugarcrmAccount'][_0x08fe('0x2b')],function(_0x1a34e3){return{'name':_0x1a34e3[_0x08fe('0x2c')],'type':_0x1a34e3['type'][_0x08fe('0x2d')]};});_0x57aca5[_0x08fe('0x2e')]=_[_0x08fe('0x2a')](_0x1f8c09,'name');_0x57aca5[_0x08fe('0x2f')]=_['keys'](_0x106b51['query']);_0x57aca5[_0x08fe('0x30')]=_[_0x08fe('0x31')](_0x57aca5[_0x08fe('0x2e')],_0x57aca5[_0x08fe('0x2f')]);_0x2d3a27[_0x08fe('0x32')]=_[_0x08fe('0x31')](_0x57aca5[_0x08fe('0x2e')],qs[_0x08fe('0x33')](_0x106b51[_0x08fe('0x2f')]['fields']));_0x2d3a27[_0x08fe('0x32')]=_0x2d3a27['attributes'][_0x08fe('0x34')]?_0x2d3a27[_0x08fe('0x32')]:_0x57aca5[_0x08fe('0x2e')];if(!_0x106b51[_0x08fe('0x2f')][_0x08fe('0x35')](_0x08fe('0x36'))){_0x2d3a27[_0x08fe('0x1d')]=qs[_0x08fe('0x1d')](_0x106b51['query'][_0x08fe('0x1d')]);_0x2d3a27[_0x08fe('0x1b')]=qs[_0x08fe('0x1b')](_0x106b51[_0x08fe('0x2f')]['offset']);}_0x2d3a27[_0x08fe('0x37')]=qs[_0x08fe('0x38')](_0x106b51[_0x08fe('0x2f')]['sort']);_0x2d3a27[_0x08fe('0x39')]=qs[_0x08fe('0x30')](_[_0x08fe('0x3a')](_0x106b51['query'],_0x57aca5[_0x08fe('0x30')]),_0x1f8c09);if(_0x106b51[_0x08fe('0x2f')][_0x08fe('0x3b')]){_0x2d3a27[_0x08fe('0x39')]=_['merge'](_0x2d3a27[_0x08fe('0x39')],{'$or':_[_0x08fe('0x2a')](_0x1f8c09,function(_0x35a732){if(_0x35a732[_0x08fe('0x3c')]!==_0x08fe('0x3d')){var _0x1183be={};_0x1183be[_0x35a732[_0x08fe('0x3e')]]={'$like':'%'+_0x106b51[_0x08fe('0x2f')][_0x08fe('0x3b')]+'%'};return _0x1183be;}})});}_0x2d3a27=_[_0x08fe('0x3f')]({},_0x2d3a27,_0x106b51[_0x08fe('0x40')]);var _0x3e0dca={'where':_0x2d3a27[_0x08fe('0x39')]};return db[_0x08fe('0x41')][_0x08fe('0x1e')](_0x3e0dca)[_0x08fe('0x24')](function(_0x151e67){_0x1fded9[_0x08fe('0x1e')]=_0x151e67;if(_0x106b51[_0x08fe('0x2f')][_0x08fe('0x42')]){_0x2d3a27[_0x08fe('0x43')]=[{'all':!![]}];}return db['SugarcrmAccount']['findAll'](_0x2d3a27);})[_0x08fe('0x24')](function(_0x2f064d){_0x1fded9[_0x08fe('0x44')]=_0x2f064d;return _0x1fded9;})[_0x08fe('0x24')](respondWithFilteredResult(_0x4082a1,_0x2d3a27))['catch'](handleError(_0x4082a1,null));};exports[_0x08fe('0x45')]=function(_0x247a5e,_0x322cc0){var _0x5af16e={'raw':![],'where':{'id':_0x247a5e[_0x08fe('0x46')]['id']}},_0x1364c8={};_0x1364c8[_0x08fe('0x2e')]=_[_0x08fe('0x47')](db[_0x08fe('0x41')]['rawAttributes']);_0x1364c8[_0x08fe('0x2f')]=_[_0x08fe('0x47')](_0x247a5e[_0x08fe('0x2f')]);_0x1364c8['filters']=_[_0x08fe('0x31')](_0x1364c8[_0x08fe('0x2e')],_0x1364c8[_0x08fe('0x2f')]);_0x5af16e['attributes']=_[_0x08fe('0x31')](_0x1364c8[_0x08fe('0x2e')],qs[_0x08fe('0x33')](_0x247a5e[_0x08fe('0x2f')]['fields']));_0x5af16e['attributes']=_0x5af16e[_0x08fe('0x32')][_0x08fe('0x34')]?_0x5af16e[_0x08fe('0x32')]:_0x1364c8[_0x08fe('0x2e')];if(_0x247a5e[_0x08fe('0x2f')][_0x08fe('0x42')]){_0x5af16e[_0x08fe('0x43')]=[{'all':!![]}];}_0x5af16e=_['merge']({},_0x5af16e,_0x247a5e[_0x08fe('0x40')]);return db[_0x08fe('0x41')][_0x08fe('0x48')](_0x5af16e)[_0x08fe('0x24')](handleEntityNotFound(_0x322cc0,null))['then'](respondWithResult(_0x322cc0,null))[_0x08fe('0x49')](handleError(_0x322cc0,null));};exports['create']=function(_0x4e92cd,_0x3abf19){return db['SugarcrmAccount'][_0x08fe('0x4a')](_0x4e92cd[_0x08fe('0x4b')],{})[_0x08fe('0x24')](respondWithResult(_0x3abf19,0xc9))[_0x08fe('0x49')](handleError(_0x3abf19,null));};exports[_0x08fe('0x23')]=function(_0x418cdb,_0x393967){if(_0x418cdb[_0x08fe('0x4b')]['id']){delete _0x418cdb[_0x08fe('0x4b')]['id'];}return db[_0x08fe('0x41')]['find']({'where':{'id':_0x418cdb['params']['id']}})[_0x08fe('0x24')](handleEntityNotFound(_0x393967,null))[_0x08fe('0x24')](saveUpdates(_0x418cdb[_0x08fe('0x4b')],null))[_0x08fe('0x24')](respondWithResult(_0x393967,null))[_0x08fe('0x49')](handleError(_0x393967,null));};exports['destroy']=function(_0x4ae4a6,_0x1f2802){return db[_0x08fe('0x41')][_0x08fe('0x48')]({'where':{'id':_0x4ae4a6[_0x08fe('0x46')]['id']}})[_0x08fe('0x24')](handleEntityNotFound(_0x1f2802,null))[_0x08fe('0x24')](removeEntity(_0x1f2802,null))[_0x08fe('0x49')](handleError(_0x1f2802,null));};exports[_0x08fe('0x4c')]=function(_0x3c91f8,_0x14df04,_0x297e8e){var _0xa71b89={};var _0x1c0155={};var _0x2942ef;var _0x207a03;return db[_0x08fe('0x41')][_0x08fe('0x4d')]({'where':{'id':_0x3c91f8[_0x08fe('0x46')]['id']}})[_0x08fe('0x24')](handleEntityNotFound(_0x14df04,null))['then'](function(_0x298470){if(_0x298470){_0x2942ef=_0x298470;_0x1c0155[_0x08fe('0x2e')]=_[_0x08fe('0x47')](db['SugarcrmConfiguration']['rawAttributes']);_0x1c0155[_0x08fe('0x2f')]=_[_0x08fe('0x47')](_0x3c91f8[_0x08fe('0x2f')]);_0x1c0155['filters']=_[_0x08fe('0x31')](_0x1c0155['model'],_0x1c0155[_0x08fe('0x2f')]);_0xa71b89[_0x08fe('0x32')]=_[_0x08fe('0x31')](_0x1c0155[_0x08fe('0x2e')],qs[_0x08fe('0x33')](_0x3c91f8[_0x08fe('0x2f')][_0x08fe('0x33')]));_0xa71b89[_0x08fe('0x32')]=_0xa71b89['attributes']['length']?_0xa71b89[_0x08fe('0x32')]:_0x1c0155[_0x08fe('0x2e')];_0xa71b89[_0x08fe('0x37')]=qs[_0x08fe('0x38')](_0x3c91f8[_0x08fe('0x2f')][_0x08fe('0x38')]);_0xa71b89['where']=qs[_0x08fe('0x30')](_[_0x08fe('0x3a')](_0x3c91f8[_0x08fe('0x2f')],_0x1c0155[_0x08fe('0x30')]));if(_0x3c91f8[_0x08fe('0x2f')][_0x08fe('0x3b')]){_0xa71b89[_0x08fe('0x39')]=_[_0x08fe('0x3f')](_0xa71b89[_0x08fe('0x39')],{'$or':_[_0x08fe('0x2a')](_0xa71b89[_0x08fe('0x32')],function(_0xcc20a9){var _0x131b39={};_0x131b39[_0xcc20a9]={'$like':'%'+_0x3c91f8[_0x08fe('0x2f')]['filter']+'%'};return _0x131b39;})});}_0xa71b89=_[_0x08fe('0x3f')]({},_0xa71b89,_0x3c91f8[_0x08fe('0x40')]);return _0x2942ef[_0x08fe('0x4c')](_0xa71b89);}})[_0x08fe('0x24')](function(_0x4a3764){if(_0x4a3764){_0x207a03=_0x4a3764[_0x08fe('0x34')];if(!_0x3c91f8[_0x08fe('0x2f')][_0x08fe('0x35')](_0x08fe('0x36'))){_0xa71b89['limit']=qs[_0x08fe('0x1d')](_0x3c91f8['query'][_0x08fe('0x1d')]);_0xa71b89[_0x08fe('0x1b')]=qs[_0x08fe('0x1b')](_0x3c91f8[_0x08fe('0x2f')]['offset']);}return _0x2942ef[_0x08fe('0x4c')](_0xa71b89);}})[_0x08fe('0x24')](function(_0x22bc96){if(_0x22bc96){return _0x22bc96?{'count':_0x207a03,'rows':_0x22bc96}:null;}})[_0x08fe('0x24')](respondWithResult(_0x14df04,null))['catch'](handleError(_0x14df04,null));};exports[_0x08fe('0x4e')]=function(_0x1a066b,_0x455e81,_0xb820d){if(_0x1a066b[_0x08fe('0x4b')]['id']){delete _0x1a066b[_0x08fe('0x4b')]['id'];}return db[_0x08fe('0x41')][_0x08fe('0x4d')]({'where':{'id':_0x1a066b[_0x08fe('0x46')]['id']}})[_0x08fe('0x24')](handleEntityNotFound(_0x455e81,null))[_0x08fe('0x24')](function(_0x427f1b){if(_0x427f1b){_0x1a066b[_0x08fe('0x4b')][_0x08fe('0x4f')]=_0x427f1b['id'];_0x1a066b[_0x08fe('0x4b')][_0x08fe('0x50')]=integrations[_0x08fe('0x51')](_0x1a066b['body'][_0x08fe('0x52')],_0x1a066b[_0x08fe('0x4b')]['type']);_0x1a066b['body'][_0x08fe('0x53')]=integrations[_0x08fe('0x54')](_0x1a066b[_0x08fe('0x4b')][_0x08fe('0x52')],_0x1a066b['body'][_0x08fe('0x3c')]);return db[_0x08fe('0x55')][_0x08fe('0x4a')](_0x1a066b[_0x08fe('0x4b')],{'include':[{'model':db[_0x08fe('0x56')],'as':'Subjects'},{'model':db['SugarcrmField'],'as':'Descriptions'}]});}return null;})[_0x08fe('0x24')](respondWithResult(_0x455e81,null))[_0x08fe('0x49')](handleError(_0x455e81,null));};exports[_0x08fe('0x57')]=function(_0x1454e7,_0x32772d,_0x4cc4c1){var _0x13deeb='';var _0x38a0ee=['id','name','assigned_user_id',_0x08fe('0x58'),_0x08fe('0x59'),'date_start','duration_hours','duration_minutes',_0x08fe('0x5a'),_0x08fe('0x5b'),_0x08fe('0x5c'),_0x08fe('0x5d')];return db[_0x08fe('0x41')]['findOne']({'where':{'id':_0x1454e7['params']['id']},'attributes':['id','username',_0x08fe('0x5e'),_0x08fe('0x5f')]})[_0x08fe('0x24')](handleEntityNotFound(_0x32772d,null))['then'](function(_0x49ecfb){if(_0x49ecfb){_0x13deeb=_0x49ecfb[_0x08fe('0x5f')];var _0x4f0c14=_0x13deeb['slice'](-0x1);if(_0x4f0c14==='/'){_0x13deeb=_0x13deeb[_0x08fe('0x60')](0x0,_0x13deeb[_0x08fe('0x61')](_0x4f0c14));}return rp({'method':_0x08fe('0x62'),'uri':util[_0x08fe('0x63')]('%s%s',_0x13deeb,_0x08fe('0x64')),'json':!![],'form':{'method':'login','input_type':_0x08fe('0x65'),'response_type':'JSON','rest_data':JSON[_0x08fe('0x66')]({'user_auth':{'user_name':_0x49ecfb['username'],'password':_0x49ecfb[_0x08fe('0x5e')],'encryption':_0x08fe('0x67')},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0x08fe('0x24')](function(_0x478849){if(_0x478849&&_0x478849[_0x08fe('0x3e')]!==_0x08fe('0x68')&&_0x478849[_0x08fe('0x3e')]!=='Password\x20Expired'){return rp({'method':'POST','uri':util[_0x08fe('0x63')](_0x08fe('0x69'),_0x13deeb,_0x08fe('0x64')),'json':!![],'form':{'method':_0x08fe('0x6a'),'input_type':'JSON','response_type':_0x08fe('0x65'),'rest_data':JSON[_0x08fe('0x66')]({'session':_0x478849['id'],'module_name':'Calls'})}})[_0x08fe('0x24')](function(_0x19677a){if(_0x19677a){var _0x43695e=_[_0x08fe('0x6b')](_0x19677a[_0x08fe('0x6c')]);_[_0x08fe('0x6d')](_0x43695e,function(_0xbd1d81){return _0x38a0ee[_0x08fe('0x6e')](_0xbd1d81[_0x08fe('0x3e')]);});return{'count':_0x43695e[_0x08fe('0x34')],'rows':_[_0x08fe('0x2a')](_0x43695e,function(_0x18edc0){return{'id':_0x18edc0[_0x08fe('0x3e')],'name':_0x18edc0[_0x08fe('0x6f')],'custom':_[_0x08fe('0x70')](_0x18edc0[_0x08fe('0x3e')],'_c')?!![]:![],'options':_0x18edc0[_0x08fe('0x40')]?_[_0x08fe('0x2a')](_[_0x08fe('0x6b')](_0x18edc0['options']),function(_0x2aeb62){return{'name':_0x2aeb62[_0x08fe('0x71')],'value':_0x2aeb62[_0x08fe('0x3e')]};}):[]};})};}})[_0x08fe('0x24')](respondWithResult(_0x32772d,null))[_0x08fe('0x49')](function(_0x12e474){var _0x37693c=_0x1454e7[_0x08fe('0x2f')]['test']?0x1f4:_0x12e474['statusCode']||0x1f4;logger[_0x08fe('0x26')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x37693c,JSON[_0x08fe('0x66')](_0x12e474));delete _0x12e474[_0x08fe('0x3e')];if(_0x37693c===0x191){_0x37693c=0x190;}_0x32772d['status'](_0x37693c)['send'](_0x1454e7['query'][_0x08fe('0x72')]?{'message':_0x08fe('0x73'),'statusCode':_0x12e474[_0x08fe('0x74')]}:_0x12e474);});}else{var _0x3a712f=0x1f4;_0x32772d[_0x08fe('0x19')](_0x3a712f)[_0x08fe('0x28')]({'message':_0x08fe('0x73'),'statusCode':0x190});}});}; \ No newline at end of file diff --git a/server/api/intSugarcrmAccount/intSugarcrmAccount.model.js b/server/api/intSugarcrmAccount/intSugarcrmAccount.model.js new file mode 100644 index 0000000..a687815 --- /dev/null +++ b/server/api/intSugarcrmAccount/intSugarcrmAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd3ab=['util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./intSugarcrmAccount.attributes','exports','define','SugarcrmAccount','int_sugarcrm_accounts','lodash'];(function(_0x4ebabe,_0x10d36d){var _0x37860b=function(_0xd40279){while(--_0xd40279){_0x4ebabe['push'](_0x4ebabe['shift']());}};_0x37860b(++_0x10d36d);}(_0xd3ab,0x149));var _0xbd3a=function(_0x38d6a8,_0x38aa8e){_0x38d6a8=_0x38d6a8-0x0;var _0x2bd252=_0xd3ab[_0x38d6a8];return _0x2bd252;};'use strict';var _=require(_0xbd3a('0x0'));var util=require(_0xbd3a('0x1'));var logger=require(_0xbd3a('0x2'))(_0xbd3a('0x3'));var moment=require(_0xbd3a('0x4'));var BPromise=require(_0xbd3a('0x5'));var rp=require(_0xbd3a('0x6'));var fs=require('fs');var path=require(_0xbd3a('0x7'));var rimraf=require(_0xbd3a('0x8'));var config=require(_0xbd3a('0x9'));var attributes=require(_0xbd3a('0xa'));var integrations=require('../../components/integrations/configuration');module[_0xbd3a('0xb')]=function(_0x49ac7c,_0x19835d){return _0x49ac7c[_0xbd3a('0xc')](_0xbd3a('0xd'),attributes,{'tableName':_0xbd3a('0xe'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSugarcrmAccount/intSugarcrmAccount.rpc.js b/server/api/intSugarcrmAccount/intSugarcrmAccount.rpc.js new file mode 100644 index 0000000..8bee446 --- /dev/null +++ b/server/api/intSugarcrmAccount/intSugarcrmAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x61a4=['jayson/promise','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','GetSugarcrmAccount','SugarcrmAccount','findAll','options','raw','where','attributes','include','map','model','stringify','ShowSugarcrmAccount','find','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x58ab41,_0x392cde){var _0x432789=function(_0x3b6982){while(--_0x3b6982){_0x58ab41['push'](_0x58ab41['shift']());}};_0x432789(++_0x392cde);}(_0x61a4,0x87));var _0x461a=function(_0x29c6e4,_0x59396c){_0x29c6e4=_0x29c6e4-0x0;var _0x1d250a=_0x61a4[_0x29c6e4];return _0x1d250a;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x461a('0x0'));var BPromise=require(_0x461a('0x1'));var rs=require(_0x461a('0x2'));var fs=require('fs');var Redis=require(_0x461a('0x3'));var db=require(_0x461a('0x4'))['db'];var utils=require(_0x461a('0x5'));var logger=require(_0x461a('0x6'))(_0x461a('0x7'));var config=require(_0x461a('0x8'));var jayson=require(_0x461a('0x9'));var client=jayson[_0x461a('0xa')][_0x461a('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3272e9,_0x19e6b7,_0x20b735){return new BPromise(function(_0x90513,_0x4169d1){return client[_0x461a('0xc')](_0x3272e9,_0x20b735)[_0x461a('0xd')](function(_0x55106f){logger[_0x461a('0xe')](_0x461a('0xf'),_0x19e6b7,_0x461a('0x10'));logger[_0x461a('0x11')]('SugarcrmAccount,\x20%s,\x20%s,\x20%s',_0x19e6b7,'request\x20sent',JSON['stringify'](_0x55106f));if(_0x55106f[_0x461a('0x12')]){if(_0x55106f[_0x461a('0x12')][_0x461a('0x13')]===0x1f4){logger[_0x461a('0x12')](_0x461a('0xf'),_0x19e6b7,_0x55106f['error'][_0x461a('0x14')]);return _0x4169d1(_0x55106f[_0x461a('0x12')][_0x461a('0x14')]);}logger[_0x461a('0x12')](_0x461a('0xf'),_0x19e6b7,_0x55106f[_0x461a('0x12')][_0x461a('0x14')]);return _0x90513(_0x55106f[_0x461a('0x12')][_0x461a('0x14')]);}else{logger[_0x461a('0xe')](_0x461a('0xf'),_0x19e6b7,'request\x20sent');_0x90513(_0x55106f[_0x461a('0x15')][_0x461a('0x14')]);}})[_0x461a('0x16')](function(_0x3ef470){logger[_0x461a('0x12')](_0x461a('0xf'),_0x19e6b7,_0x3ef470);_0x4169d1(_0x3ef470);});});}exports[_0x461a('0x17')]=function(_0x4f9e07){var _0x3372ca=this;return new Promise(function(_0x277aeb,_0x1f515e){return db[_0x461a('0x18')][_0x461a('0x19')]({'raw':_0x4f9e07[_0x461a('0x1a')]?_0x4f9e07[_0x461a('0x1a')][_0x461a('0x1b')]===undefined?!![]:![]:!![],'where':_0x4f9e07['options']?_0x4f9e07[_0x461a('0x1a')][_0x461a('0x1c')]||null:null,'attributes':_0x4f9e07[_0x461a('0x1a')]?_0x4f9e07[_0x461a('0x1a')][_0x461a('0x1d')]||null:null,'limit':_0x4f9e07[_0x461a('0x1a')]?_0x4f9e07['options']['limit']||null:null,'include':_0x4f9e07[_0x461a('0x1a')]?_0x4f9e07[_0x461a('0x1a')][_0x461a('0x1e')]?_[_0x461a('0x1f')](_0x4f9e07['options']['include'],function(_0x4fe465){return{'model':db[_0x4fe465[_0x461a('0x20')]],'as':_0x4fe465['as'],'attributes':_0x4fe465['attributes'],'include':_0x4fe465['include']?_[_0x461a('0x1f')](_0x4fe465[_0x461a('0x1e')],function(_0x481f03){return{'model':db[_0x481f03[_0x461a('0x20')]],'as':_0x481f03['as'],'attributes':_0x481f03[_0x461a('0x1d')],'include':_0x481f03[_0x461a('0x1e')]?_[_0x461a('0x1f')](_0x481f03[_0x461a('0x1e')],function(_0x470a8a){return{'model':db[_0x470a8a['model']],'as':_0x470a8a['as'],'attributes':_0x470a8a[_0x461a('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x461a('0xd')](function(_0x1b6e0c){logger['info'](_0x461a('0x17'),_0x4f9e07);logger[_0x461a('0x11')](_0x461a('0x17'),_0x4f9e07,JSON[_0x461a('0x21')](_0x1b6e0c));_0x277aeb(_0x1b6e0c);})['catch'](function(_0x4f94ea){logger[_0x461a('0x12')](_0x461a('0x17'),_0x4f94ea[_0x461a('0x14')],_0x4f9e07);_0x1f515e(_0x3372ca[_0x461a('0x12')](0x1f4,_0x4f94ea[_0x461a('0x14')]));});});};exports[_0x461a('0x22')]=function(_0x288e43){var _0x4f73b3=this;return new Promise(function(_0x479896,_0x414726){return db[_0x461a('0x18')][_0x461a('0x23')]({'raw':_0x288e43['options']?_0x288e43[_0x461a('0x1a')][_0x461a('0x1b')]===undefined?!![]:![]:!![],'where':_0x288e43[_0x461a('0x1a')]?_0x288e43[_0x461a('0x1a')][_0x461a('0x1c')]||null:null,'attributes':_0x288e43['options']?_0x288e43[_0x461a('0x1a')][_0x461a('0x1d')]||null:null,'include':_0x288e43[_0x461a('0x1a')]?_0x288e43['options'][_0x461a('0x1e')]?_[_0x461a('0x1f')](_0x288e43['options'][_0x461a('0x1e')],function(_0x6de0c3){return{'model':db[_0x6de0c3[_0x461a('0x20')]],'as':_0x6de0c3['as'],'attributes':_0x6de0c3[_0x461a('0x1d')],'include':_0x6de0c3[_0x461a('0x1e')]?_[_0x461a('0x1f')](_0x6de0c3[_0x461a('0x1e')],function(_0x233060){return{'model':db[_0x233060[_0x461a('0x20')]],'as':_0x233060['as'],'attributes':_0x233060['attributes'],'include':_0x233060[_0x461a('0x1e')]?_[_0x461a('0x1f')](_0x233060[_0x461a('0x1e')],function(_0x5dc668){return{'model':db[_0x5dc668[_0x461a('0x20')]],'as':_0x5dc668['as'],'attributes':_0x5dc668[_0x461a('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x183f31){logger[_0x461a('0xe')](_0x461a('0x22'),_0x288e43);logger[_0x461a('0x11')]('ShowSugarcrmAccount',_0x288e43,JSON[_0x461a('0x21')](_0x183f31));_0x479896(_0x183f31);})[_0x461a('0x16')](function(_0x34428f){logger[_0x461a('0x12')]('ShowSugarcrmAccount',_0x34428f[_0x461a('0x14')],_0x288e43);_0x414726(_0x4f73b3[_0x461a('0x12')](0x1f4,_0x34428f[_0x461a('0x14')]));});});}; \ No newline at end of file diff --git a/server/api/intSugarcrmConfiguration/index.js b/server/api/intSugarcrmConfiguration/index.js new file mode 100644 index 0000000..383e2ef --- /dev/null +++ b/server/api/intSugarcrmConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb873=['create','delete','destroy','exports','util','path','connect-timeout','express','Router','../../components/auth/service','../../config/environment','./intSugarcrmConfiguration.controller','get','isAuthenticated','index','/:id','show','/:id/fields','getFields','/:id/subjects','getSubjects','/:id/descriptions','getDescriptions','post'];(function(_0x33a65f,_0xa972fa){var _0x251674=function(_0x4ba5d6){while(--_0x4ba5d6){_0x33a65f['push'](_0x33a65f['shift']());}};_0x251674(++_0xa972fa);}(_0xb873,0x13c));var _0x3b87=function(_0xa6cc5c,_0x239c99){_0xa6cc5c=_0xa6cc5c-0x0;var _0x44803d=_0xb873[_0xa6cc5c];return _0x44803d;};'use strict';var multer=require('multer');var util=require(_0x3b87('0x0'));var path=require(_0x3b87('0x1'));var timeout=require(_0x3b87('0x2'));var express=require(_0x3b87('0x3'));var router=express[_0x3b87('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x3b87('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0x3b87('0x6'));var controller=require(_0x3b87('0x7'));router[_0x3b87('0x8')]('/',auth[_0x3b87('0x9')](),controller[_0x3b87('0xa')]);router[_0x3b87('0x8')](_0x3b87('0xb'),auth[_0x3b87('0x9')](),controller[_0x3b87('0xc')]);router[_0x3b87('0x8')](_0x3b87('0xd'),auth[_0x3b87('0x9')](),controller[_0x3b87('0xe')]);router[_0x3b87('0x8')](_0x3b87('0xf'),auth[_0x3b87('0x9')](),controller[_0x3b87('0x10')]);router[_0x3b87('0x8')](_0x3b87('0x11'),auth['isAuthenticated'](),controller[_0x3b87('0x12')]);router[_0x3b87('0x13')]('/',auth[_0x3b87('0x9')](),controller[_0x3b87('0x14')]);router['put'](_0x3b87('0xb'),auth[_0x3b87('0x9')](),controller['update']);router[_0x3b87('0x15')](_0x3b87('0xb'),auth[_0x3b87('0x9')](),controller[_0x3b87('0x16')]);module[_0x3b87('0x17')]=router; \ No newline at end of file diff --git a/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.attributes.js b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.attributes.js new file mode 100644 index 0000000..ed4443c --- /dev/null +++ b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc1c9=['exports','STRING'];(function(_0x1482b0,_0x312f02){var _0x4ad15f=function(_0x2621f9){while(--_0x2621f9){_0x1482b0['push'](_0x1482b0['shift']());}};_0x4ad15f(++_0x312f02);}(_0xc1c9,0x66));var _0x9c1c=function(_0x39096d,_0x51f8a0){_0x39096d=_0x39096d-0x0;var _0x13da4f=_0xc1c9[_0x39096d];return _0x13da4f;};'use strict';var Sequelize=require('sequelize');module[_0x9c1c('0x0')]={'name':{'type':Sequelize[_0x9c1c('0x1')]},'description':{'type':Sequelize[_0x9c1c('0x1')]}}; \ No newline at end of file diff --git a/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.controller.js b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.controller.js new file mode 100644 index 0000000..afb4cb8 --- /dev/null +++ b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb8f0=['map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','options','includeAll','include','SugarcrmConfiguration','findAll','rows','catch','show','length','find','create','body','params','destroy','findOne','SugarcrmField','getFields','hasOwnProperty','getSubjects','getDescriptions','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','to-csv','ejs','squel','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','Content-Range','apply','reject','save','update','then','error','stack','name','send','index'];(function(_0x17202e,_0x4c408d){var _0x4dbb09=function(_0x5a7ca8){while(--_0x5a7ca8){_0x17202e['push'](_0x17202e['shift']());}};_0x4dbb09(++_0x4c408d);}(_0xb8f0,0x78));var _0x0b8f=function(_0x231e1f,_0x2ea0d9){_0x231e1f=_0x231e1f-0x0;var _0x5832f3=_0xb8f0[_0x231e1f];return _0x5832f3;};'use strict';var emlformat=require(_0x0b8f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0b8f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0b8f('0x2'));var moment=require(_0x0b8f('0x3'));var BPromise=require(_0x0b8f('0x4'));var Mustache=require(_0x0b8f('0x5'));var util=require(_0x0b8f('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0x0b8f('0x7'));var ejs=require(_0x0b8f('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x0b8f('0x9'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0b8f('0xa'));var toCsv=require(_0x0b8f('0x7'));var querystring=require(_0x0b8f('0xb'));var Papa=require('papaparse');var Redis=require(_0x0b8f('0xc'));var authService=require('../../components/auth/service');var qs=require(_0x0b8f('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0b8f('0xe'));var logger=require(_0x0b8f('0xf'))(_0x0b8f('0x10'));var utils=require(_0x0b8f('0x11'));var config=require(_0x0b8f('0x12'));var licenseUtil=require(_0x0b8f('0x13'));var db=require(_0x0b8f('0x14'))['db'];function respondWithStatusCode(_0x4d63d9,_0x5c8e5b){_0x5c8e5b=_0x5c8e5b||0xcc;return function(_0x344e02){if(_0x344e02){return _0x4d63d9[_0x0b8f('0x15')](_0x5c8e5b);}return _0x4d63d9[_0x0b8f('0x16')](_0x5c8e5b)[_0x0b8f('0x17')]();};}function respondWithResult(_0x378d3d,_0x206103){_0x206103=_0x206103||0xc8;return function(_0x4cfdb2){if(_0x4cfdb2){return _0x378d3d[_0x0b8f('0x16')](_0x206103)[_0x0b8f('0x18')](_0x4cfdb2);}};}function respondWithFilteredResult(_0x6be765,_0x4ea060){return function(_0x57cc49){if(_0x57cc49){var _0x4ebceb=typeof _0x4ea060[_0x0b8f('0x19')]==='undefined'&&typeof _0x4ea060[_0x0b8f('0x1a')]===_0x0b8f('0x1b');var _0x5c0fd6=_0x57cc49[_0x0b8f('0x1c')];var _0x66268c=_0x4ebceb?0x0:_0x4ea060[_0x0b8f('0x19')];var _0x73ee1b=_0x4ebceb?_0x57cc49[_0x0b8f('0x1c')]:_0x4ea060[_0x0b8f('0x19')]+_0x4ea060[_0x0b8f('0x1a')];var _0x1a6080;if(_0x73ee1b>=_0x5c0fd6){_0x73ee1b=_0x5c0fd6;_0x1a6080=0xc8;}else{_0x1a6080=0xce;}_0x6be765['status'](_0x1a6080);return _0x6be765['set'](_0x0b8f('0x1d'),_0x66268c+'-'+_0x73ee1b+'/'+_0x5c0fd6)[_0x0b8f('0x18')](_0x57cc49);}return null;};}function patchUpdates(_0x3d76ad){return function(_0x2763db){try{jsonpatch[_0x0b8f('0x1e')](_0x2763db,_0x3d76ad,!![]);}catch(_0x2527ec){return BPromise[_0x0b8f('0x1f')](_0x2527ec);}return _0x2763db[_0x0b8f('0x20')]();};}function saveUpdates(_0x30cd3c,_0x34acdf){return function(_0x184486){if(_0x184486){return _0x184486[_0x0b8f('0x21')](_0x30cd3c)['then'](function(_0x2f4996){return _0x2f4996;});}return null;};}function removeEntity(_0x4a4535,_0xd1c04){return function(_0x37304b){if(_0x37304b){return _0x37304b['destroy']()[_0x0b8f('0x22')](function(){_0x4a4535[_0x0b8f('0x16')](0xcc)[_0x0b8f('0x17')]();});}};}function handleEntityNotFound(_0x7632fb,_0x2e7b0b){return function(_0x2b3993){if(!_0x2b3993){_0x7632fb[_0x0b8f('0x15')](0x194);}return _0x2b3993;};}function handleError(_0xdfb6b0,_0x146d00){_0x146d00=_0x146d00||0x1f4;return function(_0x19ec1f){logger[_0x0b8f('0x23')](_0x19ec1f[_0x0b8f('0x24')]);if(_0x19ec1f[_0x0b8f('0x25')]){delete _0x19ec1f['name'];}_0xdfb6b0['status'](_0x146d00)[_0x0b8f('0x26')](_0x19ec1f);};}exports[_0x0b8f('0x27')]=function(_0x57cce0,_0x2067cd){var _0x26a8ff={},_0x4b4369={},_0x599b77={'count':0x0,'rows':[]};var _0x562fb6=_[_0x0b8f('0x28')](db['SugarcrmConfiguration'][_0x0b8f('0x29')],function(_0x1f181e){return{'name':_0x1f181e[_0x0b8f('0x2a')],'type':_0x1f181e[_0x0b8f('0x2b')][_0x0b8f('0x2c')]};});_0x4b4369[_0x0b8f('0x2d')]=_['map'](_0x562fb6,_0x0b8f('0x25'));_0x4b4369[_0x0b8f('0x2e')]=_[_0x0b8f('0x2f')](_0x57cce0[_0x0b8f('0x2e')]);_0x4b4369[_0x0b8f('0x30')]=_[_0x0b8f('0x31')](_0x4b4369['model'],_0x4b4369[_0x0b8f('0x2e')]);_0x26a8ff['attributes']=_[_0x0b8f('0x31')](_0x4b4369[_0x0b8f('0x2d')],qs[_0x0b8f('0x32')](_0x57cce0[_0x0b8f('0x2e')]['fields']));_0x26a8ff[_0x0b8f('0x33')]=_0x26a8ff['attributes']['length']?_0x26a8ff[_0x0b8f('0x33')]:_0x4b4369[_0x0b8f('0x2d')];if(!_0x57cce0['query']['hasOwnProperty'](_0x0b8f('0x34'))){_0x26a8ff[_0x0b8f('0x1a')]=qs['limit'](_0x57cce0[_0x0b8f('0x2e')][_0x0b8f('0x1a')]);_0x26a8ff[_0x0b8f('0x19')]=qs[_0x0b8f('0x19')](_0x57cce0[_0x0b8f('0x2e')][_0x0b8f('0x19')]);}_0x26a8ff[_0x0b8f('0x35')]=qs[_0x0b8f('0x36')](_0x57cce0[_0x0b8f('0x2e')][_0x0b8f('0x36')]);_0x26a8ff[_0x0b8f('0x37')]=qs[_0x0b8f('0x30')](_[_0x0b8f('0x38')](_0x57cce0[_0x0b8f('0x2e')],_0x4b4369[_0x0b8f('0x30')]),_0x562fb6);if(_0x57cce0[_0x0b8f('0x2e')]['filter']){_0x26a8ff[_0x0b8f('0x37')]=_['merge'](_0x26a8ff[_0x0b8f('0x37')],{'$or':_['map'](_0x562fb6,function(_0x5f09f7){if(_0x5f09f7[_0x0b8f('0x2b')]!==_0x0b8f('0x39')){var _0x4da550={};_0x4da550[_0x5f09f7['name']]={'$like':'%'+_0x57cce0['query'][_0x0b8f('0x3a')]+'%'};return _0x4da550;}})});}_0x26a8ff=_[_0x0b8f('0x3b')]({},_0x26a8ff,_0x57cce0[_0x0b8f('0x3c')]);var _0x1e7f5e={'where':_0x26a8ff[_0x0b8f('0x37')]};return db['SugarcrmConfiguration'][_0x0b8f('0x1c')](_0x1e7f5e)['then'](function(_0xc1ebec){_0x599b77[_0x0b8f('0x1c')]=_0xc1ebec;if(_0x57cce0[_0x0b8f('0x2e')][_0x0b8f('0x3d')]){_0x26a8ff[_0x0b8f('0x3e')]=[{'all':!![]}];}return db[_0x0b8f('0x3f')][_0x0b8f('0x40')](_0x26a8ff);})['then'](function(_0x206afa){_0x599b77[_0x0b8f('0x41')]=_0x206afa;return _0x599b77;})['then'](respondWithFilteredResult(_0x2067cd,_0x26a8ff))[_0x0b8f('0x42')](handleError(_0x2067cd,null));};exports[_0x0b8f('0x43')]=function(_0x516647,_0x40ca03){var _0x39cb75={'raw':![],'where':{'id':_0x516647['params']['id']}},_0x3936a9={};_0x3936a9[_0x0b8f('0x2d')]=_['keys'](db[_0x0b8f('0x3f')]['rawAttributes']);_0x3936a9[_0x0b8f('0x2e')]=_['keys'](_0x516647[_0x0b8f('0x2e')]);_0x3936a9[_0x0b8f('0x30')]=_[_0x0b8f('0x31')](_0x3936a9['model'],_0x3936a9[_0x0b8f('0x2e')]);_0x39cb75[_0x0b8f('0x33')]=_[_0x0b8f('0x31')](_0x3936a9[_0x0b8f('0x2d')],qs[_0x0b8f('0x32')](_0x516647[_0x0b8f('0x2e')][_0x0b8f('0x32')]));_0x39cb75['attributes']=_0x39cb75[_0x0b8f('0x33')][_0x0b8f('0x44')]?_0x39cb75[_0x0b8f('0x33')]:_0x3936a9[_0x0b8f('0x2d')];if(_0x516647[_0x0b8f('0x2e')][_0x0b8f('0x3d')]){_0x39cb75[_0x0b8f('0x3e')]=[{'all':!![]}];}_0x39cb75=_[_0x0b8f('0x3b')]({},_0x39cb75,_0x516647[_0x0b8f('0x3c')]);return db[_0x0b8f('0x3f')][_0x0b8f('0x45')](_0x39cb75)[_0x0b8f('0x22')](handleEntityNotFound(_0x40ca03,null))[_0x0b8f('0x22')](respondWithResult(_0x40ca03,null))[_0x0b8f('0x42')](handleError(_0x40ca03,null));};exports[_0x0b8f('0x46')]=function(_0x391bc2,_0x3e8ae1){return db[_0x0b8f('0x3f')][_0x0b8f('0x46')](_0x391bc2[_0x0b8f('0x47')],{})[_0x0b8f('0x22')](respondWithResult(_0x3e8ae1,0xc9))[_0x0b8f('0x42')](handleError(_0x3e8ae1,null));};exports[_0x0b8f('0x21')]=function(_0x2c00c2,_0x3369e0){if(_0x2c00c2[_0x0b8f('0x47')]['id']){delete _0x2c00c2[_0x0b8f('0x47')]['id'];}return db[_0x0b8f('0x3f')][_0x0b8f('0x45')]({'where':{'id':_0x2c00c2[_0x0b8f('0x48')]['id']}})['then'](handleEntityNotFound(_0x3369e0,null))['then'](saveUpdates(_0x2c00c2[_0x0b8f('0x47')],null))['then'](respondWithResult(_0x3369e0,null))['catch'](handleError(_0x3369e0,null));};exports[_0x0b8f('0x49')]=function(_0x3dd65f,_0x5dd750){return db[_0x0b8f('0x3f')][_0x0b8f('0x45')]({'where':{'id':_0x3dd65f['params']['id']}})['then'](handleEntityNotFound(_0x5dd750,null))['then'](removeEntity(_0x5dd750,null))[_0x0b8f('0x42')](handleError(_0x5dd750,null));};exports['getFields']=function(_0x5399e3,_0x1c011b,_0x28ffa5){var _0x3ef011={};var _0x5b44d8={};var _0x52f997;var _0x2a2126;return db[_0x0b8f('0x3f')][_0x0b8f('0x4a')]({'where':{'id':_0x5399e3['params']['id']}})[_0x0b8f('0x22')](handleEntityNotFound(_0x1c011b,null))[_0x0b8f('0x22')](function(_0x49a0ef){if(_0x49a0ef){_0x52f997=_0x49a0ef;_0x5b44d8[_0x0b8f('0x2d')]=_[_0x0b8f('0x2f')](db[_0x0b8f('0x4b')][_0x0b8f('0x29')]);_0x5b44d8[_0x0b8f('0x2e')]=_['keys'](_0x5399e3['query']);_0x5b44d8[_0x0b8f('0x30')]=_['intersection'](_0x5b44d8['model'],_0x5b44d8[_0x0b8f('0x2e')]);_0x3ef011[_0x0b8f('0x33')]=_[_0x0b8f('0x31')](_0x5b44d8['model'],qs[_0x0b8f('0x32')](_0x5399e3['query'][_0x0b8f('0x32')]));_0x3ef011[_0x0b8f('0x33')]=_0x3ef011[_0x0b8f('0x33')][_0x0b8f('0x44')]?_0x3ef011[_0x0b8f('0x33')]:_0x5b44d8[_0x0b8f('0x2d')];_0x3ef011[_0x0b8f('0x35')]=qs[_0x0b8f('0x36')](_0x5399e3['query'][_0x0b8f('0x36')]);_0x3ef011[_0x0b8f('0x37')]=qs[_0x0b8f('0x30')](_[_0x0b8f('0x38')](_0x5399e3[_0x0b8f('0x2e')],_0x5b44d8[_0x0b8f('0x30')]));if(_0x5399e3[_0x0b8f('0x2e')][_0x0b8f('0x3a')]){_0x3ef011['where']=_[_0x0b8f('0x3b')](_0x3ef011[_0x0b8f('0x37')],{'$or':_['map'](_0x3ef011[_0x0b8f('0x33')],function(_0x1921d1){var _0x89f40d={};_0x89f40d[_0x1921d1]={'$like':'%'+_0x5399e3['query'][_0x0b8f('0x3a')]+'%'};return _0x89f40d;})});}_0x3ef011=_[_0x0b8f('0x3b')]({},_0x3ef011,_0x5399e3[_0x0b8f('0x3c')]);return _0x52f997[_0x0b8f('0x4c')](_0x3ef011);}})[_0x0b8f('0x22')](function(_0x169146){if(_0x169146){_0x2a2126=_0x169146[_0x0b8f('0x44')];if(!_0x5399e3['query'][_0x0b8f('0x4d')](_0x0b8f('0x34'))){_0x3ef011[_0x0b8f('0x1a')]=qs['limit'](_0x5399e3[_0x0b8f('0x2e')][_0x0b8f('0x1a')]);_0x3ef011[_0x0b8f('0x19')]=qs[_0x0b8f('0x19')](_0x5399e3[_0x0b8f('0x2e')]['offset']);}return _0x52f997[_0x0b8f('0x4c')](_0x3ef011);}})[_0x0b8f('0x22')](function(_0x1eb43d){if(_0x1eb43d){return _0x1eb43d?{'count':_0x2a2126,'rows':_0x1eb43d}:null;}})['then'](respondWithResult(_0x1c011b,null))[_0x0b8f('0x42')](handleError(_0x1c011b,null));};exports[_0x0b8f('0x4e')]=function(_0x25c01c,_0x5969e8,_0x5342d5){var _0x4a16d2={};var _0x41c45d={};var _0x5d852a;var _0x34379e;return db[_0x0b8f('0x3f')]['findOne']({'where':{'id':_0x25c01c[_0x0b8f('0x48')]['id']}})[_0x0b8f('0x22')](handleEntityNotFound(_0x5969e8,null))[_0x0b8f('0x22')](function(_0xdef875){if(_0xdef875){_0x5d852a=_0xdef875;_0x41c45d['model']=_[_0x0b8f('0x2f')](db[_0x0b8f('0x4b')][_0x0b8f('0x29')]);_0x41c45d[_0x0b8f('0x2e')]=_[_0x0b8f('0x2f')](_0x25c01c['query']);_0x41c45d[_0x0b8f('0x30')]=_[_0x0b8f('0x31')](_0x41c45d['model'],_0x41c45d[_0x0b8f('0x2e')]);_0x4a16d2[_0x0b8f('0x33')]=_[_0x0b8f('0x31')](_0x41c45d[_0x0b8f('0x2d')],qs[_0x0b8f('0x32')](_0x25c01c[_0x0b8f('0x2e')]['fields']));_0x4a16d2[_0x0b8f('0x33')]=_0x4a16d2['attributes']['length']?_0x4a16d2[_0x0b8f('0x33')]:_0x41c45d[_0x0b8f('0x2d')];_0x4a16d2[_0x0b8f('0x35')]=qs[_0x0b8f('0x36')](_0x25c01c[_0x0b8f('0x2e')][_0x0b8f('0x36')]);_0x4a16d2[_0x0b8f('0x37')]=qs[_0x0b8f('0x30')](_[_0x0b8f('0x38')](_0x25c01c['query'],_0x41c45d[_0x0b8f('0x30')]));if(_0x25c01c[_0x0b8f('0x2e')][_0x0b8f('0x3a')]){_0x4a16d2[_0x0b8f('0x37')]=_[_0x0b8f('0x3b')](_0x4a16d2[_0x0b8f('0x37')],{'$or':_[_0x0b8f('0x28')](_0x4a16d2[_0x0b8f('0x33')],function(_0x36ef97){var _0x2a9c52={};_0x2a9c52[_0x36ef97]={'$like':'%'+_0x25c01c[_0x0b8f('0x2e')][_0x0b8f('0x3a')]+'%'};return _0x2a9c52;})});}_0x4a16d2=_[_0x0b8f('0x3b')]({},_0x4a16d2,_0x25c01c['options']);return _0x5d852a[_0x0b8f('0x4e')](_0x4a16d2);}})['then'](function(_0x4e95e){if(_0x4e95e){_0x34379e=_0x4e95e[_0x0b8f('0x44')];if(!_0x25c01c['query']['hasOwnProperty'](_0x0b8f('0x34'))){_0x4a16d2[_0x0b8f('0x1a')]=qs[_0x0b8f('0x1a')](_0x25c01c[_0x0b8f('0x2e')]['limit']);_0x4a16d2[_0x0b8f('0x19')]=qs['offset'](_0x25c01c[_0x0b8f('0x2e')][_0x0b8f('0x19')]);}return _0x5d852a['getSubjects'](_0x4a16d2);}})[_0x0b8f('0x22')](function(_0x56a572){if(_0x56a572){return _0x56a572?{'count':_0x34379e,'rows':_0x56a572}:null;}})['then'](respondWithResult(_0x5969e8,null))['catch'](handleError(_0x5969e8,null));};exports[_0x0b8f('0x4f')]=function(_0x49ef29,_0x96c2a,_0x594080){var _0x32917a={};var _0x4a7135={};var _0x3e703c;var _0x3bcc64;return db['SugarcrmConfiguration'][_0x0b8f('0x4a')]({'where':{'id':_0x49ef29[_0x0b8f('0x48')]['id']}})[_0x0b8f('0x22')](handleEntityNotFound(_0x96c2a,null))[_0x0b8f('0x22')](function(_0x18bc04){if(_0x18bc04){_0x3e703c=_0x18bc04;_0x4a7135[_0x0b8f('0x2d')]=_[_0x0b8f('0x2f')](db['SugarcrmField'][_0x0b8f('0x29')]);_0x4a7135[_0x0b8f('0x2e')]=_['keys'](_0x49ef29['query']);_0x4a7135[_0x0b8f('0x30')]=_[_0x0b8f('0x31')](_0x4a7135['model'],_0x4a7135['query']);_0x32917a['attributes']=_[_0x0b8f('0x31')](_0x4a7135[_0x0b8f('0x2d')],qs[_0x0b8f('0x32')](_0x49ef29[_0x0b8f('0x2e')][_0x0b8f('0x32')]));_0x32917a['attributes']=_0x32917a['attributes'][_0x0b8f('0x44')]?_0x32917a[_0x0b8f('0x33')]:_0x4a7135[_0x0b8f('0x2d')];_0x32917a['order']=qs[_0x0b8f('0x36')](_0x49ef29[_0x0b8f('0x2e')][_0x0b8f('0x36')]);_0x32917a[_0x0b8f('0x37')]=qs[_0x0b8f('0x30')](_[_0x0b8f('0x38')](_0x49ef29['query'],_0x4a7135[_0x0b8f('0x30')]));if(_0x49ef29[_0x0b8f('0x2e')]['filter']){_0x32917a['where']=_[_0x0b8f('0x3b')](_0x32917a[_0x0b8f('0x37')],{'$or':_[_0x0b8f('0x28')](_0x32917a[_0x0b8f('0x33')],function(_0x59d1d5){var _0x2987ea={};_0x2987ea[_0x59d1d5]={'$like':'%'+_0x49ef29[_0x0b8f('0x2e')][_0x0b8f('0x3a')]+'%'};return _0x2987ea;})});}_0x32917a=_[_0x0b8f('0x3b')]({},_0x32917a,_0x49ef29[_0x0b8f('0x3c')]);return _0x3e703c[_0x0b8f('0x4f')](_0x32917a);}})['then'](function(_0xd7942b){if(_0xd7942b){_0x3bcc64=_0xd7942b['length'];if(!_0x49ef29[_0x0b8f('0x2e')][_0x0b8f('0x4d')](_0x0b8f('0x34'))){_0x32917a[_0x0b8f('0x1a')]=qs[_0x0b8f('0x1a')](_0x49ef29[_0x0b8f('0x2e')][_0x0b8f('0x1a')]);_0x32917a[_0x0b8f('0x19')]=qs[_0x0b8f('0x19')](_0x49ef29['query'][_0x0b8f('0x19')]);}return _0x3e703c['getDescriptions'](_0x32917a);}})['then'](function(_0xee0824){if(_0xee0824){return _0xee0824?{'count':_0x3bcc64,'rows':_0xee0824}:null;}})[_0x0b8f('0x22')](respondWithResult(_0x96c2a,null))[_0x0b8f('0x42')](handleError(_0x96c2a,null));}; \ No newline at end of file diff --git a/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.model.js b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.model.js new file mode 100644 index 0000000..29ab779 --- /dev/null +++ b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x88de=['../../config/logger','api','path','rimraf','../../config/environment','./intSugarcrmConfiguration.attributes','exports','define','SugarcrmConfiguration','util'];(function(_0x4bbdf6,_0x11a583){var _0x40b5b8=function(_0x3f6de4){while(--_0x3f6de4){_0x4bbdf6['push'](_0x4bbdf6['shift']());}};_0x40b5b8(++_0x11a583);}(_0x88de,0x6d));var _0xe88d=function(_0x221f38,_0x569fef){_0x221f38=_0x221f38-0x0;var _0x30c462=_0x88de[_0x221f38];return _0x30c462;};'use strict';var _=require('lodash');var util=require(_0xe88d('0x0'));var logger=require(_0xe88d('0x1'))(_0xe88d('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0xe88d('0x3'));var rimraf=require(_0xe88d('0x4'));var config=require(_0xe88d('0x5'));var attributes=require(_0xe88d('0x6'));module[_0xe88d('0x7')]=function(_0x16d77a,_0x309f22){return _0x16d77a[_0xe88d('0x8')](_0xe88d('0x9'),attributes,{'tableName':'int_sugarcrm_configurations','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.rpc.js b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.rpc.js new file mode 100644 index 0000000..0ba72cf --- /dev/null +++ b/server/api/intSugarcrmConfiguration/intSugarcrmConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdbbe=['message','result','catch','lodash','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','info','debug','request\x20sent','stringify','error','code','SugarcrmConfiguration,\x20%s,\x20%s'];(function(_0x5a33ff,_0x1304fe){var _0x1b0ded=function(_0x105037){while(--_0x105037){_0x5a33ff['push'](_0x5a33ff['shift']());}};_0x1b0ded(++_0x1304fe);}(_0xdbbe,0xc1));var _0xedbb=function(_0x13ff53,_0x5e1424){_0x13ff53=_0x13ff53-0x0;var _0x290228=_0xdbbe[_0x13ff53];return _0x290228;};'use strict';var _=require(_0xedbb('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xedbb('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xedbb('0x2'))['db'];var utils=require(_0xedbb('0x3'));var logger=require(_0xedbb('0x4'))('rpc');var config=require(_0xedbb('0x5'));var jayson=require(_0xedbb('0x6'));var client=jayson['client'][_0xedbb('0x7')]({'port':0x232a});function respondWithRpcPromise(_0xc630fb,_0x125a4a,_0x1eb9b5){return new BPromise(function(_0x4c2f4b,_0xbaff7a){return client[_0xedbb('0x8')](_0xc630fb,_0x1eb9b5)['then'](function(_0x1ab74b){logger[_0xedbb('0x9')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x125a4a,'request\x20sent');logger[_0xedbb('0xa')]('SugarcrmConfiguration,\x20%s,\x20%s,\x20%s',_0x125a4a,_0xedbb('0xb'),JSON[_0xedbb('0xc')](_0x1ab74b));if(_0x1ab74b[_0xedbb('0xd')]){if(_0x1ab74b['error'][_0xedbb('0xe')]===0x1f4){logger[_0xedbb('0xd')](_0xedbb('0xf'),_0x125a4a,_0x1ab74b[_0xedbb('0xd')][_0xedbb('0x10')]);return _0xbaff7a(_0x1ab74b[_0xedbb('0xd')]['message']);}logger['error'](_0xedbb('0xf'),_0x125a4a,_0x1ab74b['error']['message']);return _0x4c2f4b(_0x1ab74b['error']['message']);}else{logger[_0xedbb('0x9')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x125a4a,'request\x20sent');_0x4c2f4b(_0x1ab74b[_0xedbb('0x11')][_0xedbb('0x10')]);}})[_0xedbb('0x12')](function(_0x2bf047){logger[_0xedbb('0xd')](_0xedbb('0xf'),_0x125a4a,_0x2bf047);_0xbaff7a(_0x2bf047);});});} \ No newline at end of file diff --git a/server/api/intSugarcrmField/index.js b/server/api/intSugarcrmField/index.js new file mode 100644 index 0000000..64ba657 --- /dev/null +++ b/server/api/intSugarcrmField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c8b=['index','/:id','post','create','put','update','delete','destroy','multer','util','path','connect-timeout','express','../../components/auth/service','../../components/interaction/service','./intSugarcrmField.controller','get','isAuthenticated'];(function(_0x167b19,_0x56081a){var _0x1fcca2=function(_0x544ca4){while(--_0x544ca4){_0x167b19['push'](_0x167b19['shift']());}};_0x1fcca2(++_0x56081a);}(_0x9c8b,0xbc));var _0xb9c8=function(_0x56aca7,_0xba610b){_0x56aca7=_0x56aca7-0x0;var _0x320701=_0x9c8b[_0x56aca7];return _0x320701;};'use strict';var multer=require(_0xb9c8('0x0'));var util=require(_0xb9c8('0x1'));var path=require(_0xb9c8('0x2'));var timeout=require(_0xb9c8('0x3'));var express=require(_0xb9c8('0x4'));var router=express['Router']();var fs_extra=require('fs-extra');var auth=require(_0xb9c8('0x5'));var interaction=require(_0xb9c8('0x6'));var config=require('../../config/environment');var controller=require(_0xb9c8('0x7'));router[_0xb9c8('0x8')]('/',auth[_0xb9c8('0x9')](),controller[_0xb9c8('0xa')]);router[_0xb9c8('0x8')](_0xb9c8('0xb'),auth[_0xb9c8('0x9')](),controller['show']);router[_0xb9c8('0xc')]('/',auth[_0xb9c8('0x9')](),controller[_0xb9c8('0xd')]);router[_0xb9c8('0xe')](_0xb9c8('0xb'),auth['isAuthenticated'](),controller[_0xb9c8('0xf')]);router[_0xb9c8('0x10')](_0xb9c8('0xb'),auth[_0xb9c8('0x9')](),controller[_0xb9c8('0x11')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/intSugarcrmField/intSugarcrmField.attributes.js b/server/api/intSugarcrmField/intSugarcrmField.attributes.js new file mode 100644 index 0000000..b202c49 --- /dev/null +++ b/server/api/intSugarcrmField/intSugarcrmField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc622=['string','variable','customVariable','keyValue','picklist','STRING','ENUM','BOOLEAN','exports'];(function(_0x2fc379,_0xd4e15){var _0x91e89d=function(_0xa4c9d1){while(--_0xa4c9d1){_0x2fc379['push'](_0x2fc379['shift']());}};_0x91e89d(++_0xd4e15);}(_0xc622,0x13a));var _0x2c62=function(_0x5ce8b9,_0x5cded8){_0x5ce8b9=_0x5ce8b9-0x0;var _0xe34be0=_0xc622[_0x5ce8b9];return _0xe34be0;};'use strict';var Sequelize=require('sequelize');module[_0x2c62('0x0')]={'type':{'type':Sequelize['ENUM'](_0x2c62('0x1'),_0x2c62('0x2'),_0x2c62('0x3'),_0x2c62('0x4'),_0x2c62('0x5')),'defaultValue':'string'},'content':{'type':Sequelize[_0x2c62('0x6')]},'key':{'type':Sequelize[_0x2c62('0x6')]},'keyType':{'type':Sequelize[_0x2c62('0x7')](_0x2c62('0x1'),'variable','customVariable')},'keyContent':{'type':Sequelize[_0x2c62('0x6')]},'idField':{'type':Sequelize['STRING']},'nameField':{'type':Sequelize[_0x2c62('0x6')]},'customField':{'type':Sequelize[_0x2c62('0x8')],'defaultValue':!![]},'variableName':{'type':Sequelize[_0x2c62('0x6')]}}; \ No newline at end of file diff --git a/server/api/intSugarcrmField/intSugarcrmField.controller.js b/server/api/intSugarcrmField/intSugarcrmField.controller.js new file mode 100644 index 0000000..104a52c --- /dev/null +++ b/server/api/intSugarcrmField/intSugarcrmField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x86ba=['undefined','limit','count','set','apply','reject','update','then','destroy','error','stack','name','index','map','SugarcrmField','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','length','order','sort','where','pick','merge','type','VIRTUAL','filter','options','includeAll','findAll','rows','catch','show','params','fields','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path','sox','to-csv','ejs','fs-extra','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','end','status','offset'];(function(_0x1e2080,_0x53283b){var _0x260111=function(_0x15da5e){while(--_0x15da5e){_0x1e2080['push'](_0x1e2080['shift']());}};_0x260111(++_0x53283b);}(_0x86ba,0x72));var _0xa86b=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x86ba[_0x19e35c];return _0x3e1fe8;};'use strict';var emlformat=require(_0xa86b('0x0'));var rimraf=require(_0xa86b('0x1'));var zipdir=require(_0xa86b('0x2'));var jsonpatch=require(_0xa86b('0x3'));var rp=require('request-promise');var moment=require(_0xa86b('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xa86b('0x5'));var util=require('util');var path=require(_0xa86b('0x6'));var sox=require(_0xa86b('0x7'));var csv=require(_0xa86b('0x8'));var ejs=require(_0xa86b('0x9'));var fs=require('fs');var fs_extra=require(_0xa86b('0xa'));var _=require('lodash');var squel=require(_0xa86b('0xb'));var crypto=require('crypto');var jsforce=require(_0xa86b('0xc'));var deskjs=require(_0xa86b('0xd'));var toCsv=require('to-csv');var querystring=require(_0xa86b('0xe'));var Papa=require(_0xa86b('0xf'));var Redis=require('ioredis');var authService=require(_0xa86b('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xa86b('0x11'));var hardwareService=require(_0xa86b('0x12'));var logger=require(_0xa86b('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xa86b('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xa86b('0x15'))['db'];function respondWithStatusCode(_0x3fc13f,_0x5831b7){_0x5831b7=_0x5831b7||0xcc;return function(_0x464a8f){if(_0x464a8f){return _0x3fc13f[_0xa86b('0x16')](_0x5831b7);}return _0x3fc13f['status'](_0x5831b7)[_0xa86b('0x17')]();};}function respondWithResult(_0x58d714,_0x24262d){_0x24262d=_0x24262d||0xc8;return function(_0x271a9c){if(_0x271a9c){return _0x58d714[_0xa86b('0x18')](_0x24262d)['json'](_0x271a9c);}};}function respondWithFilteredResult(_0x1865f0,_0xe63961){return function(_0x5824bf){if(_0x5824bf){var _0x490b64=typeof _0xe63961[_0xa86b('0x19')]===_0xa86b('0x1a')&&typeof _0xe63961[_0xa86b('0x1b')]===_0xa86b('0x1a');var _0x49317f=_0x5824bf[_0xa86b('0x1c')];var _0x6ad653=_0x490b64?0x0:_0xe63961[_0xa86b('0x19')];var _0x374db1=_0x490b64?_0x5824bf['count']:_0xe63961[_0xa86b('0x19')]+_0xe63961['limit'];var _0x1a0842;if(_0x374db1>=_0x49317f){_0x374db1=_0x49317f;_0x1a0842=0xc8;}else{_0x1a0842=0xce;}_0x1865f0['status'](_0x1a0842);return _0x1865f0[_0xa86b('0x1d')]('Content-Range',_0x6ad653+'-'+_0x374db1+'/'+_0x49317f)['json'](_0x5824bf);}return null;};}function patchUpdates(_0x4f3188){return function(_0x1769aa){try{jsonpatch[_0xa86b('0x1e')](_0x1769aa,_0x4f3188,!![]);}catch(_0x54df0c){return BPromise[_0xa86b('0x1f')](_0x54df0c);}return _0x1769aa['save']();};}function saveUpdates(_0x2c4a98,_0x2eb8b7){return function(_0x511a96){if(_0x511a96){return _0x511a96[_0xa86b('0x20')](_0x2c4a98)[_0xa86b('0x21')](function(_0x41424f){return _0x41424f;});}return null;};}function removeEntity(_0x506386,_0x1032e9){return function(_0xcf53fb){if(_0xcf53fb){return _0xcf53fb[_0xa86b('0x22')]()[_0xa86b('0x21')](function(){_0x506386['status'](0xcc)[_0xa86b('0x17')]();});}};}function handleEntityNotFound(_0x2b5efe,_0x4f8b62){return function(_0x312900){if(!_0x312900){_0x2b5efe[_0xa86b('0x16')](0x194);}return _0x312900;};}function handleError(_0x1b45a2,_0x46dbf2){_0x46dbf2=_0x46dbf2||0x1f4;return function(_0x1f041d){logger[_0xa86b('0x23')](_0x1f041d[_0xa86b('0x24')]);if(_0x1f041d['name']){delete _0x1f041d[_0xa86b('0x25')];}_0x1b45a2[_0xa86b('0x18')](_0x46dbf2)['send'](_0x1f041d);};}exports[_0xa86b('0x26')]=function(_0xf38139,_0x387d10){var _0x2cc659={},_0x10bc8e={},_0x482dd4={'count':0x0,'rows':[]};var _0x2c4881=_[_0xa86b('0x27')](db[_0xa86b('0x28')][_0xa86b('0x29')],function(_0x3596a0){return{'name':_0x3596a0[_0xa86b('0x2a')],'type':_0x3596a0['type'][_0xa86b('0x2b')]};});_0x10bc8e[_0xa86b('0x2c')]=_[_0xa86b('0x27')](_0x2c4881,_0xa86b('0x25'));_0x10bc8e[_0xa86b('0x2d')]=_[_0xa86b('0x2e')](_0xf38139[_0xa86b('0x2d')]);_0x10bc8e[_0xa86b('0x2f')]=_['intersection'](_0x10bc8e[_0xa86b('0x2c')],_0x10bc8e['query']);_0x2cc659[_0xa86b('0x30')]=_[_0xa86b('0x31')](_0x10bc8e['model'],qs['fields'](_0xf38139[_0xa86b('0x2d')]['fields']));_0x2cc659[_0xa86b('0x30')]=_0x2cc659[_0xa86b('0x30')][_0xa86b('0x32')]?_0x2cc659[_0xa86b('0x30')]:_0x10bc8e[_0xa86b('0x2c')];if(!_0xf38139[_0xa86b('0x2d')]['hasOwnProperty']('nolimit')){_0x2cc659[_0xa86b('0x1b')]=qs['limit'](_0xf38139[_0xa86b('0x2d')][_0xa86b('0x1b')]);_0x2cc659['offset']=qs[_0xa86b('0x19')](_0xf38139[_0xa86b('0x2d')][_0xa86b('0x19')]);}_0x2cc659[_0xa86b('0x33')]=qs[_0xa86b('0x34')](_0xf38139[_0xa86b('0x2d')][_0xa86b('0x34')]);_0x2cc659[_0xa86b('0x35')]=qs['filters'](_[_0xa86b('0x36')](_0xf38139[_0xa86b('0x2d')],_0x10bc8e[_0xa86b('0x2f')]),_0x2c4881);if(_0xf38139[_0xa86b('0x2d')]['filter']){_0x2cc659['where']=_[_0xa86b('0x37')](_0x2cc659[_0xa86b('0x35')],{'$or':_[_0xa86b('0x27')](_0x2c4881,function(_0x91bcfb){if(_0x91bcfb[_0xa86b('0x38')]!==_0xa86b('0x39')){var _0x1236da={};_0x1236da[_0x91bcfb[_0xa86b('0x25')]]={'$like':'%'+_0xf38139[_0xa86b('0x2d')][_0xa86b('0x3a')]+'%'};return _0x1236da;}})});}_0x2cc659=_[_0xa86b('0x37')]({},_0x2cc659,_0xf38139[_0xa86b('0x3b')]);var _0x2b7a30={'where':_0x2cc659[_0xa86b('0x35')]};return db[_0xa86b('0x28')][_0xa86b('0x1c')](_0x2b7a30)[_0xa86b('0x21')](function(_0x42c3ff){_0x482dd4[_0xa86b('0x1c')]=_0x42c3ff;if(_0xf38139['query'][_0xa86b('0x3c')]){_0x2cc659['include']=[{'all':!![]}];}return db['SugarcrmField'][_0xa86b('0x3d')](_0x2cc659);})['then'](function(_0x2cf574){_0x482dd4[_0xa86b('0x3e')]=_0x2cf574;return _0x482dd4;})[_0xa86b('0x21')](respondWithFilteredResult(_0x387d10,_0x2cc659))[_0xa86b('0x3f')](handleError(_0x387d10,null));};exports[_0xa86b('0x40')]=function(_0x3acbe6,_0x2a4676){var _0x17fc4c={'raw':!![],'where':{'id':_0x3acbe6[_0xa86b('0x41')]['id']}},_0x5df4e2={};_0x5df4e2['model']=_[_0xa86b('0x2e')](db[_0xa86b('0x28')]['rawAttributes']);_0x5df4e2[_0xa86b('0x2d')]=_[_0xa86b('0x2e')](_0x3acbe6['query']);_0x5df4e2['filters']=_['intersection'](_0x5df4e2['model'],_0x5df4e2['query']);_0x17fc4c[_0xa86b('0x30')]=_[_0xa86b('0x31')](_0x5df4e2['model'],qs[_0xa86b('0x42')](_0x3acbe6['query']['fields']));_0x17fc4c['attributes']=_0x17fc4c[_0xa86b('0x30')][_0xa86b('0x32')]?_0x17fc4c['attributes']:_0x5df4e2[_0xa86b('0x2c')];if(_0x3acbe6[_0xa86b('0x2d')][_0xa86b('0x3c')]){_0x17fc4c['include']=[{'all':!![]}];}_0x17fc4c=_[_0xa86b('0x37')]({},_0x17fc4c,_0x3acbe6[_0xa86b('0x3b')]);return db[_0xa86b('0x28')][_0xa86b('0x43')](_0x17fc4c)[_0xa86b('0x21')](handleEntityNotFound(_0x2a4676,null))[_0xa86b('0x21')](respondWithResult(_0x2a4676,null))['catch'](handleError(_0x2a4676,null));};exports[_0xa86b('0x44')]=function(_0x42912a,_0x1b404f){return db['SugarcrmField'][_0xa86b('0x44')](_0x42912a[_0xa86b('0x45')],{})[_0xa86b('0x21')](respondWithResult(_0x1b404f,0xc9))[_0xa86b('0x3f')](handleError(_0x1b404f,null));};exports[_0xa86b('0x20')]=function(_0x8b672c,_0x834e34){if(_0x8b672c[_0xa86b('0x45')]['id']){delete _0x8b672c[_0xa86b('0x45')]['id'];}return db[_0xa86b('0x28')][_0xa86b('0x43')]({'where':{'id':_0x8b672c['params']['id']}})[_0xa86b('0x21')](handleEntityNotFound(_0x834e34,null))[_0xa86b('0x21')](saveUpdates(_0x8b672c[_0xa86b('0x45')],null))[_0xa86b('0x21')](respondWithResult(_0x834e34,null))[_0xa86b('0x3f')](handleError(_0x834e34,null));};exports[_0xa86b('0x22')]=function(_0x5d97d4,_0x8e835d){return db[_0xa86b('0x28')][_0xa86b('0x43')]({'where':{'id':_0x5d97d4['params']['id']}})[_0xa86b('0x21')](handleEntityNotFound(_0x8e835d,null))['then'](removeEntity(_0x8e835d,null))[_0xa86b('0x3f')](handleError(_0x8e835d,null));}; \ No newline at end of file diff --git a/server/api/intSugarcrmField/intSugarcrmField.model.js b/server/api/intSugarcrmField/intSugarcrmField.model.js new file mode 100644 index 0000000..649233a --- /dev/null +++ b/server/api/intSugarcrmField/intSugarcrmField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd99=['define','SugarcrmField','int_sugarcrm_fields','lodash','../../config/logger','moment','request-promise','path','rimraf','../../config/environment','./intSugarcrmField.attributes','exports'];(function(_0x22b800,_0x4e6eb3){var _0x2a1810=function(_0x2fa215){while(--_0x2fa215){_0x22b800['push'](_0x22b800['shift']());}};_0x2a1810(++_0x4e6eb3);}(_0xcd99,0x183));var _0x9cd9=function(_0x5d614a,_0x28776f){_0x5d614a=_0x5d614a-0x0;var _0x983985=_0xcd99[_0x5d614a];return _0x983985;};'use strict';var _=require(_0x9cd9('0x0'));var util=require('util');var logger=require(_0x9cd9('0x1'))('api');var moment=require(_0x9cd9('0x2'));var BPromise=require('bluebird');var rp=require(_0x9cd9('0x3'));var fs=require('fs');var path=require(_0x9cd9('0x4'));var rimraf=require(_0x9cd9('0x5'));var config=require(_0x9cd9('0x6'));var attributes=require(_0x9cd9('0x7'));module[_0x9cd9('0x8')]=function(_0x2da9e4,_0x18d903){return _0x2da9e4[_0x9cd9('0x9')](_0x9cd9('0xa'),attributes,{'tableName':_0x9cd9('0xb'),'paranoid':![],'indexes':[{'name':'sugarcrm_unique_index','fields':['idField','FieldId'],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intSugarcrmField/intSugarcrmField.rpc.js b/server/api/intSugarcrmField/intSugarcrmField.rpc.js new file mode 100644 index 0000000..31cb671 --- /dev/null +++ b/server/api/intSugarcrmField/intSugarcrmField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7b82=['stringify','error','code','SugarcrmField,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','request\x20sent','debug'];(function(_0x16fb0d,_0x2a08cd){var _0x3b041a=function(_0x3ab1d4){while(--_0x3ab1d4){_0x16fb0d['push'](_0x16fb0d['shift']());}};_0x3b041a(++_0x2a08cd);}(_0x7b82,0x13b));var _0x27b8=function(_0x1762b4,_0x33d836){_0x1762b4=_0x1762b4-0x0;var _0x29beda=_0x7b82[_0x1762b4];return _0x29beda;};'use strict';var _=require(_0x27b8('0x0'));var util=require(_0x27b8('0x1'));var moment=require(_0x27b8('0x2'));var BPromise=require(_0x27b8('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x27b8('0x4'));var db=require(_0x27b8('0x5'))['db'];var utils=require(_0x27b8('0x6'));var logger=require(_0x27b8('0x7'))('rpc');var config=require(_0x27b8('0x8'));var jayson=require(_0x27b8('0x9'));var client=jayson[_0x27b8('0xa')][_0x27b8('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x334191,_0x42be99,_0xde3cfc){return new BPromise(function(_0x1df637,_0x38b043){return client[_0x27b8('0xc')](_0x334191,_0xde3cfc)['then'](function(_0x371d04){logger['info']('SugarcrmField,\x20%s,\x20%s',_0x42be99,_0x27b8('0xd'));logger[_0x27b8('0xe')]('SugarcrmField,\x20%s,\x20%s,\x20%s',_0x42be99,_0x27b8('0xd'),JSON[_0x27b8('0xf')](_0x371d04));if(_0x371d04['error']){if(_0x371d04[_0x27b8('0x10')][_0x27b8('0x11')]===0x1f4){logger[_0x27b8('0x10')](_0x27b8('0x12'),_0x42be99,_0x371d04[_0x27b8('0x10')][_0x27b8('0x13')]);return _0x38b043(_0x371d04['error'][_0x27b8('0x13')]);}logger[_0x27b8('0x10')](_0x27b8('0x12'),_0x42be99,_0x371d04['error']['message']);return _0x1df637(_0x371d04[_0x27b8('0x10')]['message']);}else{logger['info'](_0x27b8('0x12'),_0x42be99,_0x27b8('0xd'));_0x1df637(_0x371d04[_0x27b8('0x14')]['message']);}})[_0x27b8('0x15')](function(_0x3ebb2a){logger['error'](_0x27b8('0x12'),_0x42be99,_0x3ebb2a);_0x38b043(_0x3ebb2a);});});} \ No newline at end of file diff --git a/server/api/intVtigerAccount/index.js b/server/api/intVtigerAccount/index.js new file mode 100644 index 0000000..9fff009 --- /dev/null +++ b/server/api/intVtigerAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7531=['../../config/environment','./intVtigerAccount.controller','isAuthenticated','index','get','/:id','show','getConfigurations','/:id/fields','getFields','create','post','/:id/configurations','addConfiguration','put','update','exports','multer','util','path','fs-extra','../../components/auth/service'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x7531,0x69));var _0x1753=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0x7531[_0x397e5f];return _0x5302b8;};'use strict';var multer=require(_0x1753('0x0'));var util=require(_0x1753('0x1'));var path=require(_0x1753('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express['Router']();var fs_extra=require(_0x1753('0x3'));var auth=require(_0x1753('0x4'));var interaction=require('../../components/interaction/service');var config=require(_0x1753('0x5'));var controller=require(_0x1753('0x6'));router['get']('/',auth[_0x1753('0x7')](),controller[_0x1753('0x8')]);router[_0x1753('0x9')](_0x1753('0xa'),auth[_0x1753('0x7')](),controller[_0x1753('0xb')]);router[_0x1753('0x9')]('/:id/configurations',auth[_0x1753('0x7')](),controller[_0x1753('0xc')]);router[_0x1753('0x9')](_0x1753('0xd'),auth[_0x1753('0x7')](),controller[_0x1753('0xe')]);router['post']('/',auth['isAuthenticated'](),controller[_0x1753('0xf')]);router[_0x1753('0x10')](_0x1753('0x11'),auth[_0x1753('0x7')](),controller[_0x1753('0x12')]);router[_0x1753('0x13')](_0x1753('0xa'),auth[_0x1753('0x7')](),controller[_0x1753('0x14')]);router['delete'](_0x1753('0xa'),auth['isAuthenticated'](),controller['destroy']);module[_0x1753('0x15')]=router; \ No newline at end of file diff --git a/server/api/intVtigerAccount/intVtigerAccount.attributes.js b/server/api/intVtigerAccount/intVtigerAccount.attributes.js new file mode 100644 index 0000000..565daf8 --- /dev/null +++ b/server/api/intVtigerAccount/intVtigerAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6801=['sequelize','exports','STRING','HelpDesk'];(function(_0x322522,_0x4db288){var _0x293bcf=function(_0xf108b8){while(--_0xf108b8){_0x322522['push'](_0x322522['shift']());}};_0x293bcf(++_0x4db288);}(_0x6801,0x17c));var _0x1680=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x6801[_0x3dd15e];return _0x231fd0;};'use strict';var Sequelize=require(_0x1680('0x0'));module[_0x1680('0x1')]={'name':{'type':Sequelize[_0x1680('0x2')],'allowNull':![]},'description':{'type':Sequelize[_0x1680('0x2')]},'username':{'type':Sequelize[_0x1680('0x2')],'allowNull':![]},'moduleName':{'type':Sequelize[_0x1680('0x2')],'allowNull':![],'defaultValue':_0x1680('0x3')},'remoteUri':{'type':Sequelize[_0x1680('0x2')],'allowNull':![]},'serverUrl':{'type':Sequelize[_0x1680('0x2')],'allowNull':![]},'accessKey':{'type':Sequelize['STRING'],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/intVtigerAccount/intVtigerAccount.controller.js b/server/api/intVtigerAccount/intVtigerAccount.controller.js new file mode 100644 index 0000000..2779ea3 --- /dev/null +++ b/server/api/intVtigerAccount/intVtigerAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x05d9=['format','%s/webservice.php','GET','username','success','POST','login','result','describe','sessionName','autogenerated','reference','remove','includes','false','label','startsWith','cf_','picklist','picklistValues','value','log','vTiger\x20error:\x20','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','rimraf','moment','bluebird','util','path','ejs','lodash','squel','crypto','to-csv','querystring','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','set','apply','reject','save','update','then','error','stack','name','send','map','VtigerAccount','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','merge','where','type','VIRTUAL','count','rows','catch','params','includeAll','include','options','find','create','body','destroy','getConfigurations','findOne','VtigerConfiguration','addConfiguration','Subjects','getSubjects','channel','getDescriptions','VtigerField','md5','getFields','moduleName','remoteUri','serverUrl','accessKey','slice','substring','lastIndexOf'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x05d9,0x104));var _0x905d=function(_0x473f38,_0x26d5e4){_0x473f38=_0x473f38-0x0;var _0xcfe52f=_0x05d9[_0x473f38];return _0xcfe52f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x905d('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x905d('0x1'));var BPromise=require(_0x905d('0x2'));var Mustache=require('mustache');var util=require(_0x905d('0x3'));var path=require(_0x905d('0x4'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x905d('0x5'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x905d('0x6'));var squel=require(_0x905d('0x7'));var crypto=require(_0x905d('0x8'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x905d('0x9'));var querystring=require(_0x905d('0xa'));var Papa=require('papaparse');var Redis=require(_0x905d('0xb'));var authService=require(_0x905d('0xc'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x905d('0xd'))(_0x905d('0xe'));var utils=require(_0x905d('0xf'));var config=require(_0x905d('0x10'));var licenseUtil=require(_0x905d('0x11'));var db=require('../../mysqldb')['db'];var integrations=require(_0x905d('0x12'));function respondWithStatusCode(_0x5796ff,_0x15d3c2){_0x15d3c2=_0x15d3c2||0xcc;return function(_0x2c7db7){if(_0x2c7db7){return _0x5796ff[_0x905d('0x13')](_0x15d3c2);}return _0x5796ff[_0x905d('0x14')](_0x15d3c2)[_0x905d('0x15')]();};}function respondWithResult(_0xd9da95,_0x35b3df){_0x35b3df=_0x35b3df||0xc8;return function(_0x3fefa1){if(_0x3fefa1){return _0xd9da95['status'](_0x35b3df)[_0x905d('0x16')](_0x3fefa1);}};}function respondWithFilteredResult(_0xc67661,_0xfefc4e){return function(_0x512a43){if(_0x512a43){var _0x25e4bf=typeof _0xfefc4e[_0x905d('0x17')]===_0x905d('0x18')&&typeof _0xfefc4e[_0x905d('0x19')]==='undefined';var _0x1e5f39=_0x512a43['count'];var _0x5609a2=_0x25e4bf?0x0:_0xfefc4e[_0x905d('0x17')];var _0xb7c9db=_0x25e4bf?_0x512a43['count']:_0xfefc4e['offset']+_0xfefc4e['limit'];var _0x379b2e;if(_0xb7c9db>=_0x1e5f39){_0xb7c9db=_0x1e5f39;_0x379b2e=0xc8;}else{_0x379b2e=0xce;}_0xc67661['status'](_0x379b2e);return _0xc67661[_0x905d('0x1a')]('Content-Range',_0x5609a2+'-'+_0xb7c9db+'/'+_0x1e5f39)[_0x905d('0x16')](_0x512a43);}return null;};}function patchUpdates(_0x3b0420){return function(_0x331416){try{jsonpatch[_0x905d('0x1b')](_0x331416,_0x3b0420,!![]);}catch(_0x3a4116){return BPromise[_0x905d('0x1c')](_0x3a4116);}return _0x331416[_0x905d('0x1d')]();};}function saveUpdates(_0x23c2ea,_0x1724df){return function(_0x4ca363){if(_0x4ca363){return _0x4ca363[_0x905d('0x1e')](_0x23c2ea)['then'](function(_0x25a43f){return _0x25a43f;});}return null;};}function removeEntity(_0x22a8a2,_0x180f3e){return function(_0x4539d6){if(_0x4539d6){return _0x4539d6['destroy']()[_0x905d('0x1f')](function(){_0x22a8a2[_0x905d('0x14')](0xcc)['end']();});}};}function handleEntityNotFound(_0x528604,_0xf52de5){return function(_0x11239f){if(!_0x11239f){_0x528604[_0x905d('0x13')](0x194);}return _0x11239f;};}function handleError(_0x4c563b,_0x458c9c){_0x458c9c=_0x458c9c||0x1f4;return function(_0x2db691){logger[_0x905d('0x20')](_0x2db691[_0x905d('0x21')]);if(_0x2db691[_0x905d('0x22')]){delete _0x2db691[_0x905d('0x22')];}_0x4c563b[_0x905d('0x14')](_0x458c9c)[_0x905d('0x23')](_0x2db691);};}exports['index']=function(_0x499106,_0x49f7f8){var _0x7c2e54={},_0x48d8dd={},_0x5372d0={'count':0x0,'rows':[]};var _0x4afa1e=_[_0x905d('0x24')](db[_0x905d('0x25')][_0x905d('0x26')],function(_0xe6d80f){return{'name':_0xe6d80f[_0x905d('0x27')],'type':_0xe6d80f['type'][_0x905d('0x28')]};});_0x48d8dd[_0x905d('0x29')]=_[_0x905d('0x24')](_0x4afa1e,_0x905d('0x22'));_0x48d8dd[_0x905d('0x2a')]=_[_0x905d('0x2b')](_0x499106[_0x905d('0x2a')]);_0x48d8dd[_0x905d('0x2c')]=_[_0x905d('0x2d')](_0x48d8dd[_0x905d('0x29')],_0x48d8dd['query']);_0x7c2e54[_0x905d('0x2e')]=_['intersection'](_0x48d8dd[_0x905d('0x29')],qs[_0x905d('0x2f')](_0x499106['query'][_0x905d('0x2f')]));_0x7c2e54[_0x905d('0x2e')]=_0x7c2e54[_0x905d('0x2e')][_0x905d('0x30')]?_0x7c2e54['attributes']:_0x48d8dd[_0x905d('0x29')];if(!_0x499106[_0x905d('0x2a')][_0x905d('0x31')](_0x905d('0x32'))){_0x7c2e54[_0x905d('0x19')]=qs['limit'](_0x499106['query'][_0x905d('0x19')]);_0x7c2e54['offset']=qs[_0x905d('0x17')](_0x499106[_0x905d('0x2a')][_0x905d('0x17')]);}_0x7c2e54[_0x905d('0x33')]=qs[_0x905d('0x34')](_0x499106['query'][_0x905d('0x34')]);_0x7c2e54['where']=qs['filters'](_[_0x905d('0x35')](_0x499106['query'],_0x48d8dd[_0x905d('0x2c')]),_0x4afa1e);if(_0x499106[_0x905d('0x2a')][_0x905d('0x36')]){_0x7c2e54['where']=_[_0x905d('0x37')](_0x7c2e54[_0x905d('0x38')],{'$or':_[_0x905d('0x24')](_0x4afa1e,function(_0x41f5f2){if(_0x41f5f2[_0x905d('0x39')]!==_0x905d('0x3a')){var _0x320a22={};_0x320a22[_0x41f5f2[_0x905d('0x22')]]={'$like':'%'+_0x499106[_0x905d('0x2a')][_0x905d('0x36')]+'%'};return _0x320a22;}})});}_0x7c2e54=_[_0x905d('0x37')]({},_0x7c2e54,_0x499106['options']);var _0x15dada={'where':_0x7c2e54[_0x905d('0x38')]};return db['VtigerAccount']['count'](_0x15dada)[_0x905d('0x1f')](function(_0x4b02d2){_0x5372d0[_0x905d('0x3b')]=_0x4b02d2;if(_0x499106[_0x905d('0x2a')]['includeAll']){_0x7c2e54['include']=[{'all':!![]}];}return db[_0x905d('0x25')]['findAll'](_0x7c2e54);})[_0x905d('0x1f')](function(_0x437829){_0x5372d0[_0x905d('0x3c')]=_0x437829;return _0x5372d0;})[_0x905d('0x1f')](respondWithFilteredResult(_0x49f7f8,_0x7c2e54))[_0x905d('0x3d')](handleError(_0x49f7f8,null));};exports['show']=function(_0x4f560d,_0x20c4be){var _0x1dae0b={'raw':![],'where':{'id':_0x4f560d[_0x905d('0x3e')]['id']}},_0x24d810={};_0x24d810['model']=_['keys'](db[_0x905d('0x25')]['rawAttributes']);_0x24d810[_0x905d('0x2a')]=_[_0x905d('0x2b')](_0x4f560d[_0x905d('0x2a')]);_0x24d810[_0x905d('0x2c')]=_[_0x905d('0x2d')](_0x24d810['model'],_0x24d810[_0x905d('0x2a')]);_0x1dae0b[_0x905d('0x2e')]=_[_0x905d('0x2d')](_0x24d810[_0x905d('0x29')],qs[_0x905d('0x2f')](_0x4f560d[_0x905d('0x2a')][_0x905d('0x2f')]));_0x1dae0b['attributes']=_0x1dae0b[_0x905d('0x2e')][_0x905d('0x30')]?_0x1dae0b[_0x905d('0x2e')]:_0x24d810['model'];if(_0x4f560d[_0x905d('0x2a')][_0x905d('0x3f')]){_0x1dae0b[_0x905d('0x40')]=[{'all':!![]}];}_0x1dae0b=_['merge']({},_0x1dae0b,_0x4f560d[_0x905d('0x41')]);return db['VtigerAccount'][_0x905d('0x42')](_0x1dae0b)['then'](handleEntityNotFound(_0x20c4be,null))[_0x905d('0x1f')](respondWithResult(_0x20c4be,null))[_0x905d('0x3d')](handleError(_0x20c4be,null));};exports['create']=function(_0x44bd79,_0x1f79f5){return db['VtigerAccount'][_0x905d('0x43')](_0x44bd79[_0x905d('0x44')],{})[_0x905d('0x1f')](respondWithResult(_0x1f79f5,0xc9))['catch'](handleError(_0x1f79f5,null));};exports['update']=function(_0x3e4454,_0x3b3b4f){if(_0x3e4454[_0x905d('0x44')]['id']){delete _0x3e4454['body']['id'];}return db['VtigerAccount'][_0x905d('0x42')]({'where':{'id':_0x3e4454[_0x905d('0x3e')]['id']}})[_0x905d('0x1f')](handleEntityNotFound(_0x3b3b4f,null))[_0x905d('0x1f')](saveUpdates(_0x3e4454['body'],null))[_0x905d('0x1f')](respondWithResult(_0x3b3b4f,null))[_0x905d('0x3d')](handleError(_0x3b3b4f,null));};exports[_0x905d('0x45')]=function(_0x3852d4,_0x36d909){return db['VtigerAccount'][_0x905d('0x42')]({'where':{'id':_0x3852d4[_0x905d('0x3e')]['id']}})[_0x905d('0x1f')](handleEntityNotFound(_0x36d909,null))[_0x905d('0x1f')](removeEntity(_0x36d909,null))[_0x905d('0x3d')](handleError(_0x36d909,null));};exports[_0x905d('0x46')]=function(_0xa58de3,_0x57567a,_0x29a396){var _0x4d4ee9={};var _0xf785de={};var _0x4d79a1;var _0x14ff92;return db['VtigerAccount'][_0x905d('0x47')]({'where':{'id':_0xa58de3[_0x905d('0x3e')]['id']}})[_0x905d('0x1f')](handleEntityNotFound(_0x57567a,null))[_0x905d('0x1f')](function(_0x4f0b04){if(_0x4f0b04){_0x4d79a1=_0x4f0b04;_0xf785de['model']=_[_0x905d('0x2b')](db[_0x905d('0x48')][_0x905d('0x26')]);_0xf785de[_0x905d('0x2a')]=_[_0x905d('0x2b')](_0xa58de3[_0x905d('0x2a')]);_0xf785de['filters']=_[_0x905d('0x2d')](_0xf785de['model'],_0xf785de[_0x905d('0x2a')]);_0x4d4ee9['attributes']=_['intersection'](_0xf785de[_0x905d('0x29')],qs[_0x905d('0x2f')](_0xa58de3['query']['fields']));_0x4d4ee9[_0x905d('0x2e')]=_0x4d4ee9['attributes']['length']?_0x4d4ee9[_0x905d('0x2e')]:_0xf785de[_0x905d('0x29')];_0x4d4ee9['order']=qs[_0x905d('0x34')](_0xa58de3[_0x905d('0x2a')]['sort']);_0x4d4ee9[_0x905d('0x38')]=qs['filters'](_[_0x905d('0x35')](_0xa58de3[_0x905d('0x2a')],_0xf785de[_0x905d('0x2c')]));if(_0xa58de3[_0x905d('0x2a')][_0x905d('0x36')]){_0x4d4ee9[_0x905d('0x38')]=_[_0x905d('0x37')](_0x4d4ee9[_0x905d('0x38')],{'$or':_[_0x905d('0x24')](_0x4d4ee9[_0x905d('0x2e')],function(_0x22815a){var _0x4afab8={};_0x4afab8[_0x22815a]={'$like':'%'+_0xa58de3[_0x905d('0x2a')][_0x905d('0x36')]+'%'};return _0x4afab8;})});}_0x4d4ee9=_[_0x905d('0x37')]({},_0x4d4ee9,_0xa58de3[_0x905d('0x41')]);return _0x4d79a1[_0x905d('0x46')](_0x4d4ee9);}})['then'](function(_0x3038bf){if(_0x3038bf){_0x14ff92=_0x3038bf[_0x905d('0x30')];if(!_0xa58de3[_0x905d('0x2a')][_0x905d('0x31')]('nolimit')){_0x4d4ee9[_0x905d('0x19')]=qs[_0x905d('0x19')](_0xa58de3[_0x905d('0x2a')]['limit']);_0x4d4ee9[_0x905d('0x17')]=qs[_0x905d('0x17')](_0xa58de3[_0x905d('0x2a')][_0x905d('0x17')]);}return _0x4d79a1[_0x905d('0x46')](_0x4d4ee9);}})[_0x905d('0x1f')](function(_0x3ca1c5){if(_0x3ca1c5){return _0x3ca1c5?{'count':_0x14ff92,'rows':_0x3ca1c5}:null;}})['then'](respondWithResult(_0x57567a,null))[_0x905d('0x3d')](handleError(_0x57567a,null));};exports[_0x905d('0x49')]=function(_0x592abb,_0x524836,_0x2b55de){if(_0x592abb['body']['id']){delete _0x592abb[_0x905d('0x44')]['id'];}return db[_0x905d('0x25')]['findOne']({'where':{'id':_0x592abb[_0x905d('0x3e')]['id']}})['then'](handleEntityNotFound(_0x524836,null))[_0x905d('0x1f')](function(_0x29d85d){if(_0x29d85d){_0x592abb[_0x905d('0x44')]['AccountId']=_0x29d85d['id'];_0x592abb[_0x905d('0x44')][_0x905d('0x4a')]=integrations[_0x905d('0x4b')](_0x592abb[_0x905d('0x44')][_0x905d('0x4c')],_0x592abb['body']['type']);_0x592abb[_0x905d('0x44')]['Descriptions']=integrations[_0x905d('0x4d')](_0x592abb['body'][_0x905d('0x4c')],_0x592abb['body'][_0x905d('0x39')]);return db[_0x905d('0x48')]['create'](_0x592abb[_0x905d('0x44')],{'include':[{'model':db[_0x905d('0x4e')],'as':_0x905d('0x4a')},{'model':db[_0x905d('0x4e')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x524836,null))[_0x905d('0x3d')](handleError(_0x524836,null));};var md5=require(_0x905d('0x4f'));exports[_0x905d('0x50')]=function(_0x264de0,_0x287442,_0x4524b3){var _0x12d612=null;var _0x5b275e=null;var _0x28930e=null;var _0x2aa525=null;var _0x2cd0ee='';return db['VtigerAccount'][_0x905d('0x47')]({'where':{'id':_0x264de0[_0x905d('0x3e')]['id']},'attributes':['id',_0x905d('0x22'),'username','description',_0x905d('0x51'),_0x905d('0x52'),_0x905d('0x53'),'accessKey']})['then'](handleEntityNotFound(_0x287442,null))[_0x905d('0x1f')](function(_0x1299ad){if(_0x1299ad){_0x12d612=_0x1299ad['username'];_0x5b275e=_0x1299ad[_0x905d('0x54')];_0x28930e=_0x1299ad[_0x905d('0x51')];_0x2cd0ee=_0x1299ad[_0x905d('0x52')];var _0x41593c=_0x2cd0ee[_0x905d('0x55')](-0x1);if(_0x41593c==='/'){_0x2cd0ee=_0x2cd0ee[_0x905d('0x56')](0x0,_0x2cd0ee[_0x905d('0x57')](_0x41593c));}_0x2aa525=util[_0x905d('0x58')](_0x905d('0x59'),_0x2cd0ee);var _0x2dc9c5={'method':_0x905d('0x5a'),'uri':_0x2aa525,'qs':{'operation':'getchallenge','username':_0x1299ad[_0x905d('0x5b')]},'json':!![]};return rp(_0x2dc9c5);}})[_0x905d('0x1f')](function(_0x14c28b){if(_0x14c28b[_0x905d('0x5c')]){var _0x490ff7={'method':_0x905d('0x5d'),'uri':_0x2aa525,'form':{'operation':_0x905d('0x5e'),'username':_0x12d612,'accessKey':md5(_0x14c28b[_0x905d('0x5f')]['token']+_0x5b275e)},'json':!![]};return rp(_0x490ff7);}})[_0x905d('0x1f')](function(_0xc464b8){if(_0xc464b8[_0x905d('0x5c')]){var _0x2a0857={'method':_0x905d('0x5a'),'uri':_0x2aa525,'qs':{'operation':_0x905d('0x60'),'username':_0x12d612,'sessionName':_0xc464b8[_0x905d('0x5f')][_0x905d('0x61')],'elementType':_0x28930e},'json':!![]};return rp(_0x2a0857);}})['then'](function(_0x398f68){if(_0x398f68[_0x905d('0x5c')]){var _0x303fde=[_0x905d('0x62'),_0x905d('0x63'),'owner'];_[_0x905d('0x64')](_0x398f68[_0x905d('0x5f')][_0x905d('0x2f')],function(_0x36ec88){return _0x303fde[_0x905d('0x65')](_0x36ec88[_0x905d('0x39')][_0x905d('0x22')]);});_['remove'](_0x398f68[_0x905d('0x5f')][_0x905d('0x2f')],function(_0x2cbdf9){return _0x2cbdf9['editable']===_0x905d('0x66');});return{'count':_0x398f68[_0x905d('0x5f')]['fields']['length'],'rows':_[_0x905d('0x24')](_0x398f68[_0x905d('0x5f')]['fields'],function(_0x429cab){return{'id':_0x429cab[_0x905d('0x22')],'name':_0x429cab[_0x905d('0x67')],'custom':_[_0x905d('0x68')](_0x429cab[_0x905d('0x22')],_0x905d('0x69'))?!![]:![],'options':_0x429cab[_0x905d('0x39')][_0x905d('0x22')]===_0x905d('0x6a')&&_0x429cab[_0x905d('0x39')]['picklistValues']['length']>0x0?_['map'](_0x429cab['type'][_0x905d('0x6b')],function(_0x295144){return{'name':_0x295144[_0x905d('0x67')],'value':_0x295144[_0x905d('0x6c')]};}):[]};})};}})['then'](respondWithResult(_0x287442,null))['catch'](function(_0x571527){console[_0x905d('0x6d')](_0x905d('0x6e')+_0x571527);var _0x52744e=_0x264de0[_0x905d('0x2a')][_0x905d('0x6f')]?0x1f4:_0x571527[_0x905d('0x70')]||0x1f4;logger[_0x905d('0x20')](_0x905d('0x71'),_0x905d('0x50'),_0x52744e,JSON[_0x905d('0x72')](_0x571527));delete _0x571527[_0x905d('0x22')];if(_0x52744e===0x191){_0x52744e=0x190;}_0x287442['status'](_0x52744e)[_0x905d('0x23')](_0x264de0['query'][_0x905d('0x6f')]?{'message':_0x905d('0x73'),'statusCode':_0x571527['statusCode']}:_0x571527);});}; \ No newline at end of file diff --git a/server/api/intVtigerAccount/intVtigerAccount.model.js b/server/api/intVtigerAccount/intVtigerAccount.model.js new file mode 100644 index 0000000..e7ddd6a --- /dev/null +++ b/server/api/intVtigerAccount/intVtigerAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8371=['moment','path','rimraf','../../components/integrations/configuration','exports','define','VtigerAccount','int_vtiger_accounts','lodash','util','api'];(function(_0xda3f86,_0x32c86c){var _0x1bcc40=function(_0x47a384){while(--_0x47a384){_0xda3f86['push'](_0xda3f86['shift']());}};_0x1bcc40(++_0x32c86c);}(_0x8371,0x1b5));var _0x1837=function(_0x572c85,_0x4bd93e){_0x572c85=_0x572c85-0x0;var _0x46a4ac=_0x8371[_0x572c85];return _0x46a4ac;};'use strict';var _=require(_0x1837('0x0'));var util=require(_0x1837('0x1'));var logger=require('../../config/logger')(_0x1837('0x2'));var moment=require(_0x1837('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0x1837('0x4'));var rimraf=require(_0x1837('0x5'));var config=require('../../config/environment');var attributes=require('./intVtigerAccount.attributes');var integrations=require(_0x1837('0x6'));module[_0x1837('0x7')]=function(_0x3d31a6,_0x20e28e){return _0x3d31a6[_0x1837('0x8')](_0x1837('0x9'),attributes,{'tableName':_0x1837('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intVtigerAccount/intVtigerAccount.rpc.js b/server/api/intVtigerAccount/intVtigerAccount.rpc.js new file mode 100644 index 0000000..4ed4177 --- /dev/null +++ b/server/api/intVtigerAccount/intVtigerAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa478=['info','request\x20sent','debug','error','code','message','VtigerAccount,\x20%s,\x20%s','result','catch','GetVtigerAccount','findAll','options','raw','where','attributes','include','map','model','VtigerAccount','find','ShowVtigerAccount','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then'];(function(_0x4cc0bc,_0x5679b5){var _0x2d45f4=function(_0x5398e7){while(--_0x5398e7){_0x4cc0bc['push'](_0x4cc0bc['shift']());}};_0x2d45f4(++_0x5679b5);}(_0xa478,0x136));var _0x8a47=function(_0x3e3221,_0x392851){_0x3e3221=_0x3e3221-0x0;var _0x190da4=_0xa478[_0x3e3221];return _0x190da4;};'use strict';var _=require(_0x8a47('0x0'));var util=require(_0x8a47('0x1'));var moment=require(_0x8a47('0x2'));var BPromise=require(_0x8a47('0x3'));var rs=require(_0x8a47('0x4'));var fs=require('fs');var Redis=require(_0x8a47('0x5'));var db=require(_0x8a47('0x6'))['db'];var utils=require(_0x8a47('0x7'));var logger=require(_0x8a47('0x8'))(_0x8a47('0x9'));var config=require(_0x8a47('0xa'));var jayson=require(_0x8a47('0xb'));var client=jayson['client'][_0x8a47('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2d62a6,_0x3de815,_0x3cb340){return new BPromise(function(_0x56884b,_0x384886){return client['request'](_0x2d62a6,_0x3cb340)[_0x8a47('0xd')](function(_0x369fc9){logger[_0x8a47('0xe')]('VtigerAccount,\x20%s,\x20%s',_0x3de815,_0x8a47('0xf'));logger[_0x8a47('0x10')]('VtigerAccount,\x20%s,\x20%s,\x20%s',_0x3de815,_0x8a47('0xf'),JSON['stringify'](_0x369fc9));if(_0x369fc9[_0x8a47('0x11')]){if(_0x369fc9[_0x8a47('0x11')][_0x8a47('0x12')]===0x1f4){logger['error']('VtigerAccount,\x20%s,\x20%s',_0x3de815,_0x369fc9['error'][_0x8a47('0x13')]);return _0x384886(_0x369fc9[_0x8a47('0x11')]['message']);}logger[_0x8a47('0x11')](_0x8a47('0x14'),_0x3de815,_0x369fc9[_0x8a47('0x11')][_0x8a47('0x13')]);return _0x56884b(_0x369fc9[_0x8a47('0x11')][_0x8a47('0x13')]);}else{logger[_0x8a47('0xe')](_0x8a47('0x14'),_0x3de815,_0x8a47('0xf'));_0x56884b(_0x369fc9[_0x8a47('0x15')][_0x8a47('0x13')]);}})[_0x8a47('0x16')](function(_0x2917d9){logger['error'](_0x8a47('0x14'),_0x3de815,_0x2917d9);_0x384886(_0x2917d9);});});}exports[_0x8a47('0x17')]=function(_0x3f9093){var _0x5f5884=this;return new Promise(function(_0x341089,_0x5c62eb){return db['VtigerAccount'][_0x8a47('0x18')]({'raw':_0x3f9093[_0x8a47('0x19')]?_0x3f9093[_0x8a47('0x19')][_0x8a47('0x1a')]===undefined?!![]:![]:!![],'where':_0x3f9093[_0x8a47('0x19')]?_0x3f9093[_0x8a47('0x19')][_0x8a47('0x1b')]||null:null,'attributes':_0x3f9093[_0x8a47('0x19')]?_0x3f9093[_0x8a47('0x19')][_0x8a47('0x1c')]||null:null,'limit':_0x3f9093['options']?_0x3f9093[_0x8a47('0x19')]['limit']||null:null,'include':_0x3f9093[_0x8a47('0x19')]?_0x3f9093[_0x8a47('0x19')][_0x8a47('0x1d')]?_[_0x8a47('0x1e')](_0x3f9093['options'][_0x8a47('0x1d')],function(_0x5ae186){return{'model':db[_0x5ae186['model']],'as':_0x5ae186['as'],'attributes':_0x5ae186['attributes'],'include':_0x5ae186['include']?_[_0x8a47('0x1e')](_0x5ae186[_0x8a47('0x1d')],function(_0x5bed3e){return{'model':db[_0x5bed3e[_0x8a47('0x1f')]],'as':_0x5bed3e['as'],'attributes':_0x5bed3e[_0x8a47('0x1c')],'include':_0x5bed3e[_0x8a47('0x1d')]?_[_0x8a47('0x1e')](_0x5bed3e[_0x8a47('0x1d')],function(_0xd06be6){return{'model':db[_0xd06be6[_0x8a47('0x1f')]],'as':_0xd06be6['as'],'attributes':_0xd06be6['attributes']};}):[]};}):[]};}):[]:[]})[_0x8a47('0xd')](function(_0x4a10c3){logger[_0x8a47('0xe')](_0x8a47('0x17'),_0x3f9093);logger['debug'](_0x8a47('0x17'),_0x3f9093,JSON['stringify'](_0x4a10c3));_0x341089(_0x4a10c3);})['catch'](function(_0x12470a){logger[_0x8a47('0x11')](_0x8a47('0x17'),_0x12470a[_0x8a47('0x13')],_0x3f9093);_0x5c62eb(_0x5f5884[_0x8a47('0x11')](0x1f4,_0x12470a[_0x8a47('0x13')]));});});};exports['ShowVtigerAccount']=function(_0x353576){var _0x4d78b5=this;return new Promise(function(_0x549913,_0x448459){return db[_0x8a47('0x20')][_0x8a47('0x21')]({'raw':_0x353576[_0x8a47('0x19')]?_0x353576[_0x8a47('0x19')][_0x8a47('0x1a')]===undefined?!![]:![]:!![],'where':_0x353576[_0x8a47('0x19')]?_0x353576[_0x8a47('0x19')][_0x8a47('0x1b')]||null:null,'attributes':_0x353576[_0x8a47('0x19')]?_0x353576['options'][_0x8a47('0x1c')]||null:null,'include':_0x353576[_0x8a47('0x19')]?_0x353576[_0x8a47('0x19')]['include']?_[_0x8a47('0x1e')](_0x353576[_0x8a47('0x19')]['include'],function(_0xa1a852){return{'model':db[_0xa1a852[_0x8a47('0x1f')]],'as':_0xa1a852['as'],'attributes':_0xa1a852[_0x8a47('0x1c')],'include':_0xa1a852[_0x8a47('0x1d')]?_['map'](_0xa1a852['include'],function(_0x145908){return{'model':db[_0x145908[_0x8a47('0x1f')]],'as':_0x145908['as'],'attributes':_0x145908[_0x8a47('0x1c')],'include':_0x145908[_0x8a47('0x1d')]?_[_0x8a47('0x1e')](_0x145908[_0x8a47('0x1d')],function(_0x1819ef){return{'model':db[_0x1819ef['model']],'as':_0x1819ef['as'],'attributes':_0x1819ef['attributes']};}):[]};}):[]};}):[]:[]})[_0x8a47('0xd')](function(_0x3636af){logger[_0x8a47('0xe')](_0x8a47('0x22'),_0x353576);logger[_0x8a47('0x10')](_0x8a47('0x22'),_0x353576,JSON[_0x8a47('0x23')](_0x3636af));_0x549913(_0x3636af);})[_0x8a47('0x16')](function(_0xe178f1){logger[_0x8a47('0x11')](_0x8a47('0x22'),_0xe178f1['message'],_0x353576);_0x448459(_0x4d78b5[_0x8a47('0x11')](0x1f4,_0xe178f1['message']));});});}; \ No newline at end of file diff --git a/server/api/intVtigerConfiguration/index.js b/server/api/intVtigerConfiguration/index.js new file mode 100644 index 0000000..a58ad6f --- /dev/null +++ b/server/api/intVtigerConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1bcd=['update','delete','exports','util','connect-timeout','express','Router','fs-extra','../../config/environment','get','isAuthenticated','/:id','show','/:id/fields','/:id/subjects','getSubjects','/:id/descriptions','getDescriptions','post','create','put'];(function(_0x5ee748,_0x552a2b){var _0x36da37=function(_0x22cc48){while(--_0x22cc48){_0x5ee748['push'](_0x5ee748['shift']());}};_0x36da37(++_0x552a2b);}(_0x1bcd,0x192));var _0xd1bc=function(_0x50d011,_0x6263b){_0x50d011=_0x50d011-0x0;var _0xd37c2e=_0x1bcd[_0x50d011];return _0xd37c2e;};'use strict';var multer=require('multer');var util=require(_0xd1bc('0x0'));var path=require('path');var timeout=require(_0xd1bc('0x1'));var express=require(_0xd1bc('0x2'));var router=express[_0xd1bc('0x3')]();var fs_extra=require(_0xd1bc('0x4'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require(_0xd1bc('0x5'));var controller=require('./intVtigerConfiguration.controller');router[_0xd1bc('0x6')]('/',auth[_0xd1bc('0x7')](),controller['index']);router[_0xd1bc('0x6')](_0xd1bc('0x8'),auth['isAuthenticated'](),controller[_0xd1bc('0x9')]);router[_0xd1bc('0x6')](_0xd1bc('0xa'),auth['isAuthenticated'](),controller['getFields']);router[_0xd1bc('0x6')](_0xd1bc('0xb'),auth[_0xd1bc('0x7')](),controller[_0xd1bc('0xc')]);router[_0xd1bc('0x6')](_0xd1bc('0xd'),auth['isAuthenticated'](),controller[_0xd1bc('0xe')]);router[_0xd1bc('0xf')]('/',auth[_0xd1bc('0x7')](),controller[_0xd1bc('0x10')]);router[_0xd1bc('0x11')](_0xd1bc('0x8'),auth[_0xd1bc('0x7')](),controller[_0xd1bc('0x12')]);router[_0xd1bc('0x13')](_0xd1bc('0x8'),auth[_0xd1bc('0x7')](),controller['destroy']);module[_0xd1bc('0x14')]=router; \ No newline at end of file diff --git a/server/api/intVtigerConfiguration/intVtigerConfiguration.attributes.js b/server/api/intVtigerConfiguration/intVtigerConfiguration.attributes.js new file mode 100644 index 0000000..6052673 --- /dev/null +++ b/server/api/intVtigerConfiguration/intVtigerConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd341=['STRING','sequelize','exports'];(function(_0x51fb42,_0x3020d5){var _0x5d767a=function(_0x5a7e20){while(--_0x5a7e20){_0x51fb42['push'](_0x51fb42['shift']());}};_0x5d767a(++_0x3020d5);}(_0xd341,0xbe));var _0x1d34=function(_0x46f2ca,_0xe2161b){_0x46f2ca=_0x46f2ca-0x0;var _0x508fd6=_0xd341[_0x46f2ca];return _0x508fd6;};'use strict';var Sequelize=require(_0x1d34('0x0'));module[_0x1d34('0x1')]={'name':{'type':Sequelize[_0x1d34('0x2')]},'description':{'type':Sequelize[_0x1d34('0x2')]}}; \ No newline at end of file diff --git a/server/api/intVtigerConfiguration/intVtigerConfiguration.controller.js b/server/api/intVtigerConfiguration/intVtigerConfiguration.controller.js new file mode 100644 index 0000000..bbb76d2 --- /dev/null +++ b/server/api/intVtigerConfiguration/intVtigerConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2c35=['lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','offset','undefined','count','limit','set','save','update','then','end','sendStatus','error','stack','name','send','map','VtigerConfiguration','fieldName','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','includeAll','findAll','rows','catch','show','params','rawAttributes','include','options','create','body','find','getFields','findOne','VtigerField','length','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','to-csv','ejs'];(function(_0x145b3c,_0x31ea4a){var _0x1b6e36=function(_0xfccee6){while(--_0xfccee6){_0x145b3c['push'](_0x145b3c['shift']());}};_0x1b6e36(++_0x31ea4a);}(_0x2c35,0xe5));var _0x52c3=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2c35[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0x52c3('0x0'));var rimraf=require(_0x52c3('0x1'));var zipdir=require(_0x52c3('0x2'));var jsonpatch=require(_0x52c3('0x3'));var rp=require('request-promise');var moment=require(_0x52c3('0x4'));var BPromise=require(_0x52c3('0x5'));var Mustache=require(_0x52c3('0x6'));var util=require(_0x52c3('0x7'));var path=require(_0x52c3('0x8'));var sox=require('sox');var csv=require(_0x52c3('0x9'));var ejs=require(_0x52c3('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x52c3('0xb'));var squel=require(_0x52c3('0xc'));var crypto=require(_0x52c3('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x52c3('0x9'));var querystring=require(_0x52c3('0xe'));var Papa=require(_0x52c3('0xf'));var Redis=require(_0x52c3('0x10'));var authService=require(_0x52c3('0x11'));var qs=require(_0x52c3('0x12'));var as=require(_0x52c3('0x13'));var hardwareService=require(_0x52c3('0x14'));var logger=require(_0x52c3('0x15'))(_0x52c3('0x16'));var utils=require(_0x52c3('0x17'));var config=require(_0x52c3('0x18'));var licenseUtil=require(_0x52c3('0x19'));var db=require(_0x52c3('0x1a'))['db'];function respondWithStatusCode(_0x3379e6,_0x5046e4){_0x5046e4=_0x5046e4||0xcc;return function(_0x3b5974){if(_0x3b5974){return _0x3379e6['sendStatus'](_0x5046e4);}return _0x3379e6[_0x52c3('0x1b')](_0x5046e4)['end']();};}function respondWithResult(_0x570e0f,_0x2fdf61){_0x2fdf61=_0x2fdf61||0xc8;return function(_0x4b3bfb){if(_0x4b3bfb){return _0x570e0f[_0x52c3('0x1b')](_0x2fdf61)[_0x52c3('0x1c')](_0x4b3bfb);}};}function respondWithFilteredResult(_0x170dad,_0x4e6b33){return function(_0x1ae1ba){if(_0x1ae1ba){var _0x24e382=typeof _0x4e6b33[_0x52c3('0x1d')]===_0x52c3('0x1e')&&typeof _0x4e6b33['limit']===_0x52c3('0x1e');var _0x232c24=_0x1ae1ba[_0x52c3('0x1f')];var _0x121ea1=_0x24e382?0x0:_0x4e6b33[_0x52c3('0x1d')];var _0x1f010a=_0x24e382?_0x1ae1ba[_0x52c3('0x1f')]:_0x4e6b33['offset']+_0x4e6b33[_0x52c3('0x20')];var _0x3d5c58;if(_0x1f010a>=_0x232c24){_0x1f010a=_0x232c24;_0x3d5c58=0xc8;}else{_0x3d5c58=0xce;}_0x170dad[_0x52c3('0x1b')](_0x3d5c58);return _0x170dad[_0x52c3('0x21')]('Content-Range',_0x121ea1+'-'+_0x1f010a+'/'+_0x232c24)[_0x52c3('0x1c')](_0x1ae1ba);}return null;};}function patchUpdates(_0x4f0c35){return function(_0x5d8fd1){try{jsonpatch['apply'](_0x5d8fd1,_0x4f0c35,!![]);}catch(_0x38be35){return BPromise['reject'](_0x38be35);}return _0x5d8fd1[_0x52c3('0x22')]();};}function saveUpdates(_0x4a3660,_0x20ae0f){return function(_0x24d20b){if(_0x24d20b){return _0x24d20b[_0x52c3('0x23')](_0x4a3660)[_0x52c3('0x24')](function(_0x41ace3){return _0x41ace3;});}return null;};}function removeEntity(_0x5c1aa8,_0x111bf7){return function(_0x4ef77b){if(_0x4ef77b){return _0x4ef77b['destroy']()[_0x52c3('0x24')](function(){_0x5c1aa8[_0x52c3('0x1b')](0xcc)[_0x52c3('0x25')]();});}};}function handleEntityNotFound(_0xdef651,_0x5db014){return function(_0x186a59){if(!_0x186a59){_0xdef651[_0x52c3('0x26')](0x194);}return _0x186a59;};}function handleError(_0x57afb0,_0xd97ce1){_0xd97ce1=_0xd97ce1||0x1f4;return function(_0x5a77a6){logger[_0x52c3('0x27')](_0x5a77a6[_0x52c3('0x28')]);if(_0x5a77a6[_0x52c3('0x29')]){delete _0x5a77a6[_0x52c3('0x29')];}_0x57afb0[_0x52c3('0x1b')](_0xd97ce1)[_0x52c3('0x2a')](_0x5a77a6);};}exports['index']=function(_0x44afe8,_0x8e3edb){var _0x4bea7a={},_0x3cab7c={},_0xa42faf={'count':0x0,'rows':[]};var _0x4c7d0c=_[_0x52c3('0x2b')](db[_0x52c3('0x2c')]['rawAttributes'],function(_0x54f075){return{'name':_0x54f075[_0x52c3('0x2d')],'type':_0x54f075['type']['key']};});_0x3cab7c[_0x52c3('0x2e')]=_['map'](_0x4c7d0c,_0x52c3('0x29'));_0x3cab7c[_0x52c3('0x2f')]=_[_0x52c3('0x30')](_0x44afe8[_0x52c3('0x2f')]);_0x3cab7c[_0x52c3('0x31')]=_['intersection'](_0x3cab7c[_0x52c3('0x2e')],_0x3cab7c[_0x52c3('0x2f')]);_0x4bea7a[_0x52c3('0x32')]=_[_0x52c3('0x33')](_0x3cab7c[_0x52c3('0x2e')],qs['fields'](_0x44afe8['query'][_0x52c3('0x34')]));_0x4bea7a['attributes']=_0x4bea7a[_0x52c3('0x32')]['length']?_0x4bea7a['attributes']:_0x3cab7c[_0x52c3('0x2e')];if(!_0x44afe8['query'][_0x52c3('0x35')](_0x52c3('0x36'))){_0x4bea7a[_0x52c3('0x20')]=qs['limit'](_0x44afe8['query']['limit']);_0x4bea7a[_0x52c3('0x1d')]=qs['offset'](_0x44afe8[_0x52c3('0x2f')]['offset']);}_0x4bea7a[_0x52c3('0x37')]=qs['sort'](_0x44afe8[_0x52c3('0x2f')][_0x52c3('0x38')]);_0x4bea7a[_0x52c3('0x39')]=qs[_0x52c3('0x31')](_[_0x52c3('0x3a')](_0x44afe8[_0x52c3('0x2f')],_0x3cab7c[_0x52c3('0x31')]),_0x4c7d0c);if(_0x44afe8['query']['filter']){_0x4bea7a[_0x52c3('0x39')]=_[_0x52c3('0x3b')](_0x4bea7a[_0x52c3('0x39')],{'$or':_['map'](_0x4c7d0c,function(_0x803a2d){if(_0x803a2d['type']!==_0x52c3('0x3c')){var _0x2102cf={};_0x2102cf[_0x803a2d[_0x52c3('0x29')]]={'$like':'%'+_0x44afe8[_0x52c3('0x2f')][_0x52c3('0x3d')]+'%'};return _0x2102cf;}})});}_0x4bea7a=_[_0x52c3('0x3b')]({},_0x4bea7a,_0x44afe8['options']);var _0x4d514f={'where':_0x4bea7a[_0x52c3('0x39')]};return db[_0x52c3('0x2c')][_0x52c3('0x1f')](_0x4d514f)[_0x52c3('0x24')](function(_0x5e14c2){_0xa42faf[_0x52c3('0x1f')]=_0x5e14c2;if(_0x44afe8[_0x52c3('0x2f')][_0x52c3('0x3e')]){_0x4bea7a['include']=[{'all':!![]}];}return db[_0x52c3('0x2c')][_0x52c3('0x3f')](_0x4bea7a);})['then'](function(_0x3e2258){_0xa42faf[_0x52c3('0x40')]=_0x3e2258;return _0xa42faf;})[_0x52c3('0x24')](respondWithFilteredResult(_0x8e3edb,_0x4bea7a))[_0x52c3('0x41')](handleError(_0x8e3edb,null));};exports[_0x52c3('0x42')]=function(_0xf0bc0d,_0x33440a){var _0x2dac14={'raw':![],'where':{'id':_0xf0bc0d[_0x52c3('0x43')]['id']}},_0x1c3444={};_0x1c3444[_0x52c3('0x2e')]=_['keys'](db[_0x52c3('0x2c')][_0x52c3('0x44')]);_0x1c3444[_0x52c3('0x2f')]=_['keys'](_0xf0bc0d[_0x52c3('0x2f')]);_0x1c3444[_0x52c3('0x31')]=_['intersection'](_0x1c3444[_0x52c3('0x2e')],_0x1c3444[_0x52c3('0x2f')]);_0x2dac14[_0x52c3('0x32')]=_[_0x52c3('0x33')](_0x1c3444[_0x52c3('0x2e')],qs['fields'](_0xf0bc0d[_0x52c3('0x2f')]['fields']));_0x2dac14['attributes']=_0x2dac14[_0x52c3('0x32')]['length']?_0x2dac14[_0x52c3('0x32')]:_0x1c3444[_0x52c3('0x2e')];if(_0xf0bc0d['query'][_0x52c3('0x3e')]){_0x2dac14[_0x52c3('0x45')]=[{'all':!![]}];}_0x2dac14=_[_0x52c3('0x3b')]({},_0x2dac14,_0xf0bc0d[_0x52c3('0x46')]);return db[_0x52c3('0x2c')]['find'](_0x2dac14)['then'](handleEntityNotFound(_0x33440a,null))['then'](respondWithResult(_0x33440a,null))[_0x52c3('0x41')](handleError(_0x33440a,null));};exports[_0x52c3('0x47')]=function(_0x543824,_0x21a183){return db[_0x52c3('0x2c')]['create'](_0x543824[_0x52c3('0x48')],{})[_0x52c3('0x24')](respondWithResult(_0x21a183,0xc9))[_0x52c3('0x41')](handleError(_0x21a183,null));};exports['update']=function(_0x56d387,_0x521c87){if(_0x56d387['body']['id']){delete _0x56d387['body']['id'];}return db['VtigerConfiguration'][_0x52c3('0x49')]({'where':{'id':_0x56d387[_0x52c3('0x43')]['id']}})[_0x52c3('0x24')](handleEntityNotFound(_0x521c87,null))[_0x52c3('0x24')](saveUpdates(_0x56d387['body'],null))[_0x52c3('0x24')](respondWithResult(_0x521c87,null))[_0x52c3('0x41')](handleError(_0x521c87,null));};exports['destroy']=function(_0x1eee51,_0x3a91c0){return db[_0x52c3('0x2c')][_0x52c3('0x49')]({'where':{'id':_0x1eee51[_0x52c3('0x43')]['id']}})[_0x52c3('0x24')](handleEntityNotFound(_0x3a91c0,null))[_0x52c3('0x24')](removeEntity(_0x3a91c0,null))['catch'](handleError(_0x3a91c0,null));};exports[_0x52c3('0x4a')]=function(_0x32a740,_0x54264f,_0x4185da){var _0x1c434f={};var _0x51f2e5={};var _0x8b16bb;var _0x5a654c;return db[_0x52c3('0x2c')][_0x52c3('0x4b')]({'where':{'id':_0x32a740[_0x52c3('0x43')]['id']}})[_0x52c3('0x24')](handleEntityNotFound(_0x54264f,null))[_0x52c3('0x24')](function(_0xdcd2b6){if(_0xdcd2b6){_0x8b16bb=_0xdcd2b6;_0x51f2e5[_0x52c3('0x2e')]=_[_0x52c3('0x30')](db[_0x52c3('0x4c')][_0x52c3('0x44')]);_0x51f2e5['query']=_[_0x52c3('0x30')](_0x32a740['query']);_0x51f2e5['filters']=_[_0x52c3('0x33')](_0x51f2e5['model'],_0x51f2e5[_0x52c3('0x2f')]);_0x1c434f['attributes']=_[_0x52c3('0x33')](_0x51f2e5[_0x52c3('0x2e')],qs[_0x52c3('0x34')](_0x32a740[_0x52c3('0x2f')][_0x52c3('0x34')]));_0x1c434f['attributes']=_0x1c434f[_0x52c3('0x32')][_0x52c3('0x4d')]?_0x1c434f[_0x52c3('0x32')]:_0x51f2e5[_0x52c3('0x2e')];_0x1c434f[_0x52c3('0x37')]=qs[_0x52c3('0x38')](_0x32a740[_0x52c3('0x2f')][_0x52c3('0x38')]);_0x1c434f[_0x52c3('0x39')]=qs[_0x52c3('0x31')](_['pick'](_0x32a740[_0x52c3('0x2f')],_0x51f2e5[_0x52c3('0x31')]));if(_0x32a740['query']['filter']){_0x1c434f[_0x52c3('0x39')]=_['merge'](_0x1c434f['where'],{'$or':_[_0x52c3('0x2b')](_0x1c434f[_0x52c3('0x32')],function(_0x1d3609){var _0x1adf34={};_0x1adf34[_0x1d3609]={'$like':'%'+_0x32a740['query'][_0x52c3('0x3d')]+'%'};return _0x1adf34;})});}_0x1c434f=_[_0x52c3('0x3b')]({},_0x1c434f,_0x32a740[_0x52c3('0x46')]);return _0x8b16bb[_0x52c3('0x4a')](_0x1c434f);}})[_0x52c3('0x24')](function(_0x4f7c21){if(_0x4f7c21){_0x5a654c=_0x4f7c21['length'];if(!_0x32a740[_0x52c3('0x2f')][_0x52c3('0x35')](_0x52c3('0x36'))){_0x1c434f[_0x52c3('0x20')]=qs[_0x52c3('0x20')](_0x32a740[_0x52c3('0x2f')][_0x52c3('0x20')]);_0x1c434f[_0x52c3('0x1d')]=qs[_0x52c3('0x1d')](_0x32a740[_0x52c3('0x2f')]['offset']);}return _0x8b16bb[_0x52c3('0x4a')](_0x1c434f);}})[_0x52c3('0x24')](function(_0x206b7a){if(_0x206b7a){return _0x206b7a?{'count':_0x5a654c,'rows':_0x206b7a}:null;}})[_0x52c3('0x24')](respondWithResult(_0x54264f,null))['catch'](handleError(_0x54264f,null));};exports['getSubjects']=function(_0x546e1f,_0x1c3b57,_0x5b199d){var _0x259886={};var _0x1cfec3={};var _0x14e153;var _0xc7a292;return db[_0x52c3('0x2c')]['findOne']({'where':{'id':_0x546e1f[_0x52c3('0x43')]['id']}})[_0x52c3('0x24')](handleEntityNotFound(_0x1c3b57,null))[_0x52c3('0x24')](function(_0x4e594a){if(_0x4e594a){_0x14e153=_0x4e594a;_0x1cfec3[_0x52c3('0x2e')]=_['keys'](db['VtigerField'][_0x52c3('0x44')]);_0x1cfec3['query']=_[_0x52c3('0x30')](_0x546e1f[_0x52c3('0x2f')]);_0x1cfec3[_0x52c3('0x31')]=_[_0x52c3('0x33')](_0x1cfec3[_0x52c3('0x2e')],_0x1cfec3['query']);_0x259886[_0x52c3('0x32')]=_[_0x52c3('0x33')](_0x1cfec3[_0x52c3('0x2e')],qs[_0x52c3('0x34')](_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x34')]));_0x259886['attributes']=_0x259886[_0x52c3('0x32')][_0x52c3('0x4d')]?_0x259886[_0x52c3('0x32')]:_0x1cfec3['model'];_0x259886[_0x52c3('0x37')]=qs[_0x52c3('0x38')](_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x38')]);_0x259886[_0x52c3('0x39')]=qs[_0x52c3('0x31')](_[_0x52c3('0x3a')](_0x546e1f[_0x52c3('0x2f')],_0x1cfec3[_0x52c3('0x31')]));if(_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x3d')]){_0x259886[_0x52c3('0x39')]=_[_0x52c3('0x3b')](_0x259886[_0x52c3('0x39')],{'$or':_[_0x52c3('0x2b')](_0x259886['attributes'],function(_0x47eb0f){var _0x1b74c1={};_0x1b74c1[_0x47eb0f]={'$like':'%'+_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x3d')]+'%'};return _0x1b74c1;})});}_0x259886=_[_0x52c3('0x3b')]({},_0x259886,_0x546e1f[_0x52c3('0x46')]);return _0x14e153[_0x52c3('0x4e')](_0x259886);}})['then'](function(_0x1b555d){if(_0x1b555d){_0xc7a292=_0x1b555d[_0x52c3('0x4d')];if(!_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x35')](_0x52c3('0x36'))){_0x259886[_0x52c3('0x20')]=qs[_0x52c3('0x20')](_0x546e1f[_0x52c3('0x2f')][_0x52c3('0x20')]);_0x259886['offset']=qs['offset'](_0x546e1f[_0x52c3('0x2f')]['offset']);}return _0x14e153[_0x52c3('0x4e')](_0x259886);}})[_0x52c3('0x24')](function(_0x1c5692){if(_0x1c5692){return _0x1c5692?{'count':_0xc7a292,'rows':_0x1c5692}:null;}})[_0x52c3('0x24')](respondWithResult(_0x1c3b57,null))[_0x52c3('0x41')](handleError(_0x1c3b57,null));};exports[_0x52c3('0x4f')]=function(_0x4d14de,_0x11dca1,_0x4d071e){var _0x415c27={};var _0x14252a={};var _0x153fd5;var _0x4f28a7;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x4d14de[_0x52c3('0x43')]['id']}})[_0x52c3('0x24')](handleEntityNotFound(_0x11dca1,null))[_0x52c3('0x24')](function(_0x597ae7){if(_0x597ae7){_0x153fd5=_0x597ae7;_0x14252a[_0x52c3('0x2e')]=_[_0x52c3('0x30')](db[_0x52c3('0x4c')][_0x52c3('0x44')]);_0x14252a['query']=_['keys'](_0x4d14de[_0x52c3('0x2f')]);_0x14252a['filters']=_[_0x52c3('0x33')](_0x14252a['model'],_0x14252a[_0x52c3('0x2f')]);_0x415c27[_0x52c3('0x32')]=_[_0x52c3('0x33')](_0x14252a[_0x52c3('0x2e')],qs[_0x52c3('0x34')](_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x34')]));_0x415c27[_0x52c3('0x32')]=_0x415c27[_0x52c3('0x32')][_0x52c3('0x4d')]?_0x415c27['attributes']:_0x14252a[_0x52c3('0x2e')];_0x415c27[_0x52c3('0x37')]=qs[_0x52c3('0x38')](_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x38')]);_0x415c27[_0x52c3('0x39')]=qs[_0x52c3('0x31')](_['pick'](_0x4d14de['query'],_0x14252a[_0x52c3('0x31')]));if(_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x3d')]){_0x415c27[_0x52c3('0x39')]=_['merge'](_0x415c27[_0x52c3('0x39')],{'$or':_['map'](_0x415c27[_0x52c3('0x32')],function(_0x12ba7d){var _0x4d0607={};_0x4d0607[_0x12ba7d]={'$like':'%'+_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x3d')]+'%'};return _0x4d0607;})});}_0x415c27=_[_0x52c3('0x3b')]({},_0x415c27,_0x4d14de['options']);return _0x153fd5[_0x52c3('0x4f')](_0x415c27);}})[_0x52c3('0x24')](function(_0x328312){if(_0x328312){_0x4f28a7=_0x328312[_0x52c3('0x4d')];if(!_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x35')]('nolimit')){_0x415c27[_0x52c3('0x20')]=qs[_0x52c3('0x20')](_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x20')]);_0x415c27[_0x52c3('0x1d')]=qs[_0x52c3('0x1d')](_0x4d14de[_0x52c3('0x2f')][_0x52c3('0x1d')]);}return _0x153fd5[_0x52c3('0x4f')](_0x415c27);}})[_0x52c3('0x24')](function(_0x49e59c){if(_0x49e59c){return _0x49e59c?{'count':_0x4f28a7,'rows':_0x49e59c}:null;}})[_0x52c3('0x24')](respondWithResult(_0x11dca1,null))[_0x52c3('0x41')](handleError(_0x11dca1,null));}; \ No newline at end of file diff --git a/server/api/intVtigerConfiguration/intVtigerConfiguration.model.js b/server/api/intVtigerConfiguration/intVtigerConfiguration.model.js new file mode 100644 index 0000000..aa103dd --- /dev/null +++ b/server/api/intVtigerConfiguration/intVtigerConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x251f=['exports','define','int_vtiger_configurations','lodash','util','api','request-promise','path','rimraf','../../config/environment','./intVtigerConfiguration.attributes'];(function(_0x130d82,_0x25f49b){var _0x112070=function(_0x5795ee){while(--_0x5795ee){_0x130d82['push'](_0x130d82['shift']());}};_0x112070(++_0x25f49b);}(_0x251f,0x7c));var _0xf251=function(_0x4a96d2,_0x689504){_0x4a96d2=_0x4a96d2-0x0;var _0x38af04=_0x251f[_0x4a96d2];return _0x38af04;};'use strict';var _=require(_0xf251('0x0'));var util=require(_0xf251('0x1'));var logger=require('../../config/logger')(_0xf251('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xf251('0x3'));var fs=require('fs');var path=require(_0xf251('0x4'));var rimraf=require(_0xf251('0x5'));var config=require(_0xf251('0x6'));var attributes=require(_0xf251('0x7'));module[_0xf251('0x8')]=function(_0x36f94d,_0xe93080){return _0x36f94d[_0xf251('0x9')]('VtigerConfiguration',attributes,{'tableName':_0xf251('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intVtigerConfiguration/intVtigerConfiguration.rpc.js b/server/api/intVtigerConfiguration/intVtigerConfiguration.rpc.js new file mode 100644 index 0000000..e5f4a8b --- /dev/null +++ b/server/api/intVtigerConfiguration/intVtigerConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbb2a=['bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','error','code','VtigerConfiguration,\x20%s,\x20%s','message','info','result','catch','lodash','moment'];(function(_0x177b6e,_0x2c35c5){var _0x58c7cc=function(_0xff798c){while(--_0xff798c){_0x177b6e['push'](_0x177b6e['shift']());}};_0x58c7cc(++_0x2c35c5);}(_0xbb2a,0x82));var _0xabb2=function(_0x1f54ce,_0x17b1ca){_0x1f54ce=_0x1f54ce-0x0;var _0x594827=_0xbb2a[_0x1f54ce];return _0x594827;};'use strict';var _=require(_0xabb2('0x0'));var util=require('util');var moment=require(_0xabb2('0x1'));var BPromise=require(_0xabb2('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xabb2('0x3'));var db=require(_0xabb2('0x4'))['db'];var utils=require(_0xabb2('0x5'));var logger=require(_0xabb2('0x6'))(_0xabb2('0x7'));var config=require(_0xabb2('0x8'));var jayson=require(_0xabb2('0x9'));var client=jayson['client'][_0xabb2('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3de9fc,_0x8659df,_0x2904b3){return new BPromise(function(_0x38fa76,_0x4fd3ae){return client['request'](_0x3de9fc,_0x2904b3)[_0xabb2('0xb')](function(_0x1970c3){logger['info']('VtigerConfiguration,\x20%s,\x20%s',_0x8659df,_0xabb2('0xc'));logger[_0xabb2('0xd')](_0xabb2('0xe'),_0x8659df,_0xabb2('0xc'),JSON['stringify'](_0x1970c3));if(_0x1970c3[_0xabb2('0xf')]){if(_0x1970c3[_0xabb2('0xf')][_0xabb2('0x10')]===0x1f4){logger[_0xabb2('0xf')](_0xabb2('0x11'),_0x8659df,_0x1970c3[_0xabb2('0xf')]['message']);return _0x4fd3ae(_0x1970c3[_0xabb2('0xf')][_0xabb2('0x12')]);}logger[_0xabb2('0xf')](_0xabb2('0x11'),_0x8659df,_0x1970c3[_0xabb2('0xf')][_0xabb2('0x12')]);return _0x38fa76(_0x1970c3['error'][_0xabb2('0x12')]);}else{logger[_0xabb2('0x13')](_0xabb2('0x11'),_0x8659df,'request\x20sent');_0x38fa76(_0x1970c3[_0xabb2('0x14')]['message']);}})[_0xabb2('0x15')](function(_0x300406){logger[_0xabb2('0xf')](_0xabb2('0x11'),_0x8659df,_0x300406);_0x4fd3ae(_0x300406);});});} \ No newline at end of file diff --git a/server/api/intVtigerField/index.js b/server/api/intVtigerField/index.js new file mode 100644 index 0000000..ef4ed9c --- /dev/null +++ b/server/api/intVtigerField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4d22=['exports','express','fs-extra','../../components/interaction/service','./intVtigerField.controller','get','isAuthenticated','index','/:id','show','post','put','update','delete','destroy'];(function(_0x33667c,_0xda7ae2){var _0x3dada6=function(_0x2f6b12){while(--_0x2f6b12){_0x33667c['push'](_0x33667c['shift']());}};_0x3dada6(++_0xda7ae2);}(_0x4d22,0x10f));var _0x24d2=function(_0xfa5032,_0x5be306){_0xfa5032=_0xfa5032-0x0;var _0x41f425=_0x4d22[_0xfa5032];return _0x41f425;};'use strict';var multer=require('multer');var util=require('util');var path=require('path');var timeout=require('connect-timeout');var express=require(_0x24d2('0x0'));var router=express['Router']();var fs_extra=require(_0x24d2('0x1'));var auth=require('../../components/auth/service');var interaction=require(_0x24d2('0x2'));var config=require('../../config/environment');var controller=require(_0x24d2('0x3'));router[_0x24d2('0x4')]('/',auth[_0x24d2('0x5')](),controller[_0x24d2('0x6')]);router['get'](_0x24d2('0x7'),auth['isAuthenticated'](),controller[_0x24d2('0x8')]);router[_0x24d2('0x9')]('/',auth['isAuthenticated'](),controller['create']);router[_0x24d2('0xa')](_0x24d2('0x7'),auth['isAuthenticated'](),controller[_0x24d2('0xb')]);router[_0x24d2('0xc')]('/:id',auth[_0x24d2('0x5')](),controller[_0x24d2('0xd')]);module[_0x24d2('0xe')]=router; \ No newline at end of file diff --git a/server/api/intVtigerField/intVtigerField.attributes.js b/server/api/intVtigerField/intVtigerField.attributes.js new file mode 100644 index 0000000..ab82fd0 --- /dev/null +++ b/server/api/intVtigerField/intVtigerField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd799=['customVariable','picklist','string','STRING','exports','ENUM','variable'];(function(_0x14a067,_0x3bc444){var _0x418dc3=function(_0x5736e0){while(--_0x5736e0){_0x14a067['push'](_0x14a067['shift']());}};_0x418dc3(++_0x3bc444);}(_0xd799,0x82));var _0x9d79=function(_0x487244,_0x1e6e88){_0x487244=_0x487244-0x0;var _0x86035c=_0xd799[_0x487244];return _0x86035c;};'use strict';var Sequelize=require('sequelize');module[_0x9d79('0x0')]={'type':{'type':Sequelize[_0x9d79('0x1')]('string',_0x9d79('0x2'),_0x9d79('0x3'),'keyValue',_0x9d79('0x4')),'defaultValue':_0x9d79('0x5')},'content':{'type':Sequelize[_0x9d79('0x6')]},'key':{'type':Sequelize[_0x9d79('0x6')]},'keyType':{'type':Sequelize[_0x9d79('0x1')](_0x9d79('0x5'),_0x9d79('0x2'),'customVariable')},'keyContent':{'type':Sequelize['STRING']},'idField':{'type':Sequelize[_0x9d79('0x6')]},'nameField':{'type':Sequelize[_0x9d79('0x6')]},'customField':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'variableName':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intVtigerField/intVtigerField.controller.js b/server/api/intVtigerField/intVtigerField.controller.js new file mode 100644 index 0000000..1302f38 --- /dev/null +++ b/server/api/intVtigerField/intVtigerField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x79f4=['desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','end','status','json','offset','undefined','limit','count','set','apply','reject','save','update','destroy','error','name','send','index','map','VtigerField','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','findAll','rows','catch','show','params','includeAll','find','body','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','jsforce'];(function(_0x2327be,_0x769e7){var _0x469e6c=function(_0x45eadc){while(--_0x45eadc){_0x2327be['push'](_0x2327be['shift']());}};_0x469e6c(++_0x769e7);}(_0x79f4,0x113));var _0x479f=function(_0x2babb3,_0x2640eb){_0x2babb3=_0x2babb3-0x0;var _0x333670=_0x79f4[_0x2babb3];return _0x333670;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x479f('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x479f('0x1'));var rp=require('request-promise');var moment=require(_0x479f('0x2'));var BPromise=require(_0x479f('0x3'));var Mustache=require(_0x479f('0x4'));var util=require(_0x479f('0x5'));var path=require(_0x479f('0x6'));var sox=require(_0x479f('0x7'));var csv=require(_0x479f('0x8'));var ejs=require(_0x479f('0x9'));var fs=require('fs');var fs_extra=require(_0x479f('0xa'));var _=require('lodash');var squel=require(_0x479f('0xb'));var crypto=require('crypto');var jsforce=require(_0x479f('0xc'));var deskjs=require(_0x479f('0xd'));var toCsv=require(_0x479f('0x8'));var querystring=require(_0x479f('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x479f('0xf'));var qs=require(_0x479f('0x10'));var as=require(_0x479f('0x11'));var hardwareService=require(_0x479f('0x12'));var logger=require(_0x479f('0x13'))(_0x479f('0x14'));var utils=require('../../config/utils');var config=require(_0x479f('0x15'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1e3ee7,_0x1b9d90){_0x1b9d90=_0x1b9d90||0xcc;return function(_0x2fc280){if(_0x2fc280){return _0x1e3ee7[_0x479f('0x16')](_0x1b9d90);}return _0x1e3ee7['status'](_0x1b9d90)[_0x479f('0x17')]();};}function respondWithResult(_0x34b764,_0x3fa0a0){_0x3fa0a0=_0x3fa0a0||0xc8;return function(_0x56906f){if(_0x56906f){return _0x34b764[_0x479f('0x18')](_0x3fa0a0)[_0x479f('0x19')](_0x56906f);}};}function respondWithFilteredResult(_0x10f51f,_0x40f4f0){return function(_0x2ffc39){if(_0x2ffc39){var _0xe7633f=typeof _0x40f4f0[_0x479f('0x1a')]===_0x479f('0x1b')&&typeof _0x40f4f0[_0x479f('0x1c')]==='undefined';var _0x2f1e8d=_0x2ffc39[_0x479f('0x1d')];var _0xce6e86=_0xe7633f?0x0:_0x40f4f0[_0x479f('0x1a')];var _0x3e6555=_0xe7633f?_0x2ffc39[_0x479f('0x1d')]:_0x40f4f0[_0x479f('0x1a')]+_0x40f4f0['limit'];var _0x1a52af;if(_0x3e6555>=_0x2f1e8d){_0x3e6555=_0x2f1e8d;_0x1a52af=0xc8;}else{_0x1a52af=0xce;}_0x10f51f[_0x479f('0x18')](_0x1a52af);return _0x10f51f[_0x479f('0x1e')]('Content-Range',_0xce6e86+'-'+_0x3e6555+'/'+_0x2f1e8d)[_0x479f('0x19')](_0x2ffc39);}return null;};}function patchUpdates(_0x3440f2){return function(_0x4646ff){try{jsonpatch[_0x479f('0x1f')](_0x4646ff,_0x3440f2,!![]);}catch(_0x500268){return BPromise[_0x479f('0x20')](_0x500268);}return _0x4646ff[_0x479f('0x21')]();};}function saveUpdates(_0x4219dc,_0x5e5dfe){return function(_0x5986b5){if(_0x5986b5){return _0x5986b5[_0x479f('0x22')](_0x4219dc)['then'](function(_0x27b71b){return _0x27b71b;});}return null;};}function removeEntity(_0x58267e,_0x5546b7){return function(_0x3bac9a){if(_0x3bac9a){return _0x3bac9a[_0x479f('0x23')]()['then'](function(){_0x58267e[_0x479f('0x18')](0xcc)[_0x479f('0x17')]();});}};}function handleEntityNotFound(_0x10ad9a,_0x5949f7){return function(_0x18edb7){if(!_0x18edb7){_0x10ad9a[_0x479f('0x16')](0x194);}return _0x18edb7;};}function handleError(_0x337212,_0x2d297b){_0x2d297b=_0x2d297b||0x1f4;return function(_0xdbe137){logger[_0x479f('0x24')](_0xdbe137['stack']);if(_0xdbe137[_0x479f('0x25')]){delete _0xdbe137[_0x479f('0x25')];}_0x337212[_0x479f('0x18')](_0x2d297b)[_0x479f('0x26')](_0xdbe137);};}exports[_0x479f('0x27')]=function(_0x5cc486,_0x17f806){var _0x5cad57={},_0x52b939={},_0x3cbc56={'count':0x0,'rows':[]};var _0x21704d=_[_0x479f('0x28')](db[_0x479f('0x29')][_0x479f('0x2a')],function(_0x9b21b3){return{'name':_0x9b21b3[_0x479f('0x2b')],'type':_0x9b21b3[_0x479f('0x2c')][_0x479f('0x2d')]};});_0x52b939[_0x479f('0x2e')]=_[_0x479f('0x28')](_0x21704d,_0x479f('0x25'));_0x52b939[_0x479f('0x2f')]=_[_0x479f('0x30')](_0x5cc486[_0x479f('0x2f')]);_0x52b939[_0x479f('0x31')]=_[_0x479f('0x32')](_0x52b939[_0x479f('0x2e')],_0x52b939[_0x479f('0x2f')]);_0x5cad57[_0x479f('0x33')]=_[_0x479f('0x32')](_0x52b939[_0x479f('0x2e')],qs[_0x479f('0x34')](_0x5cc486[_0x479f('0x2f')][_0x479f('0x34')]));_0x5cad57[_0x479f('0x33')]=_0x5cad57['attributes'][_0x479f('0x35')]?_0x5cad57[_0x479f('0x33')]:_0x52b939['model'];if(!_0x5cc486[_0x479f('0x2f')]['hasOwnProperty'](_0x479f('0x36'))){_0x5cad57[_0x479f('0x1c')]=qs[_0x479f('0x1c')](_0x5cc486[_0x479f('0x2f')][_0x479f('0x1c')]);_0x5cad57[_0x479f('0x1a')]=qs[_0x479f('0x1a')](_0x5cc486[_0x479f('0x2f')][_0x479f('0x1a')]);}_0x5cad57[_0x479f('0x37')]=qs['sort'](_0x5cc486[_0x479f('0x2f')][_0x479f('0x38')]);_0x5cad57[_0x479f('0x39')]=qs[_0x479f('0x31')](_[_0x479f('0x3a')](_0x5cc486[_0x479f('0x2f')],_0x52b939['filters']),_0x21704d);if(_0x5cc486[_0x479f('0x2f')][_0x479f('0x3b')]){_0x5cad57[_0x479f('0x39')]=_[_0x479f('0x3c')](_0x5cad57[_0x479f('0x39')],{'$or':_['map'](_0x21704d,function(_0x5eb44a){if(_0x5eb44a[_0x479f('0x2c')]!==_0x479f('0x3d')){var _0x27add6={};_0x27add6[_0x5eb44a['name']]={'$like':'%'+_0x5cc486['query'][_0x479f('0x3b')]+'%'};return _0x27add6;}})});}_0x5cad57=_['merge']({},_0x5cad57,_0x5cc486[_0x479f('0x3e')]);var _0x152097={'where':_0x5cad57[_0x479f('0x39')]};return db[_0x479f('0x29')]['count'](_0x152097)[_0x479f('0x3f')](function(_0x6bdbac){_0x3cbc56[_0x479f('0x1d')]=_0x6bdbac;if(_0x5cc486[_0x479f('0x2f')]['includeAll']){_0x5cad57['include']=[{'all':!![]}];}return db['VtigerField'][_0x479f('0x40')](_0x5cad57);})[_0x479f('0x3f')](function(_0x57f6a8){_0x3cbc56[_0x479f('0x41')]=_0x57f6a8;return _0x3cbc56;})[_0x479f('0x3f')](respondWithFilteredResult(_0x17f806,_0x5cad57))[_0x479f('0x42')](handleError(_0x17f806,null));};exports[_0x479f('0x43')]=function(_0xd62bb,_0x40bc55){var _0x33b7f6={'raw':!![],'where':{'id':_0xd62bb[_0x479f('0x44')]['id']}},_0x53b10d={};_0x53b10d[_0x479f('0x2e')]=_[_0x479f('0x30')](db[_0x479f('0x29')][_0x479f('0x2a')]);_0x53b10d[_0x479f('0x2f')]=_[_0x479f('0x30')](_0xd62bb[_0x479f('0x2f')]);_0x53b10d[_0x479f('0x31')]=_['intersection'](_0x53b10d['model'],_0x53b10d['query']);_0x33b7f6[_0x479f('0x33')]=_[_0x479f('0x32')](_0x53b10d[_0x479f('0x2e')],qs[_0x479f('0x34')](_0xd62bb['query'][_0x479f('0x34')]));_0x33b7f6[_0x479f('0x33')]=_0x33b7f6[_0x479f('0x33')]['length']?_0x33b7f6[_0x479f('0x33')]:_0x53b10d['model'];if(_0xd62bb[_0x479f('0x2f')][_0x479f('0x45')]){_0x33b7f6['include']=[{'all':!![]}];}_0x33b7f6=_[_0x479f('0x3c')]({},_0x33b7f6,_0xd62bb['options']);return db['VtigerField'][_0x479f('0x46')](_0x33b7f6)[_0x479f('0x3f')](handleEntityNotFound(_0x40bc55,null))[_0x479f('0x3f')](respondWithResult(_0x40bc55,null))[_0x479f('0x42')](handleError(_0x40bc55,null));};exports['create']=function(_0x5f5abe,_0x23c3ec){return db['VtigerField']['create'](_0x5f5abe['body'],{})[_0x479f('0x3f')](respondWithResult(_0x23c3ec,0xc9))[_0x479f('0x42')](handleError(_0x23c3ec,null));};exports['update']=function(_0x335894,_0x497d47){if(_0x335894[_0x479f('0x47')]['id']){delete _0x335894[_0x479f('0x47')]['id'];}return db[_0x479f('0x29')][_0x479f('0x46')]({'where':{'id':_0x335894['params']['id']}})[_0x479f('0x3f')](handleEntityNotFound(_0x497d47,null))[_0x479f('0x3f')](saveUpdates(_0x335894[_0x479f('0x47')],null))[_0x479f('0x3f')](respondWithResult(_0x497d47,null))[_0x479f('0x42')](handleError(_0x497d47,null));};exports[_0x479f('0x23')]=function(_0x78fcc7,_0x4c9a3b){return db[_0x479f('0x29')][_0x479f('0x46')]({'where':{'id':_0x78fcc7[_0x479f('0x44')]['id']}})[_0x479f('0x3f')](handleEntityNotFound(_0x4c9a3b,null))[_0x479f('0x3f')](removeEntity(_0x4c9a3b,null))[_0x479f('0x42')](handleError(_0x4c9a3b,null));}; \ No newline at end of file diff --git a/server/api/intVtigerField/intVtigerField.model.js b/server/api/intVtigerField/intVtigerField.model.js new file mode 100644 index 0000000..757e260 --- /dev/null +++ b/server/api/intVtigerField/intVtigerField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa439=['util','../../config/logger','moment','bluebird','request-promise','path','rimraf','../../config/environment','VtigerField','int_vtiger_fields','vtiger_unique_index','FieldId','lodash'];(function(_0x4a63fc,_0x167a02){var _0x30d4c3=function(_0x3eecb2){while(--_0x3eecb2){_0x4a63fc['push'](_0x4a63fc['shift']());}};_0x30d4c3(++_0x167a02);}(_0xa439,0x137));var _0x9a43=function(_0x5b6f19,_0x3dcb2d){_0x5b6f19=_0x5b6f19-0x0;var _0x5d02e5=_0xa439[_0x5b6f19];return _0x5d02e5;};'use strict';var _=require(_0x9a43('0x0'));var util=require(_0x9a43('0x1'));var logger=require(_0x9a43('0x2'))('api');var moment=require(_0x9a43('0x3'));var BPromise=require(_0x9a43('0x4'));var rp=require(_0x9a43('0x5'));var fs=require('fs');var path=require(_0x9a43('0x6'));var rimraf=require(_0x9a43('0x7'));var config=require(_0x9a43('0x8'));var attributes=require('./intVtigerField.attributes');module['exports']=function(_0x1d2359,_0x12590c){return _0x1d2359['define'](_0x9a43('0x9'),attributes,{'tableName':_0x9a43('0xa'),'paranoid':![],'indexes':[{'name':_0x9a43('0xb'),'fields':['idField',_0x9a43('0xc')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intVtigerField/intVtigerField.rpc.js b/server/api/intVtigerField/intVtigerField.rpc.js new file mode 100644 index 0000000..fc19aaa --- /dev/null +++ b/server/api/intVtigerField/intVtigerField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc0d=['catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','client','http','request','then','VtigerField,\x20%s,\x20%s','request\x20sent','debug','VtigerField,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result'];(function(_0x484e25,_0x3724f0){var _0x25806=function(_0x4d71c3){while(--_0x4d71c3){_0x484e25['push'](_0x484e25['shift']());}};_0x25806(++_0x3724f0);}(_0xfc0d,0x17b));var _0xdfc0=function(_0x4cdf2d,_0x228549){_0x4cdf2d=_0x4cdf2d-0x0;var _0xfb36d5=_0xfc0d[_0x4cdf2d];return _0xfb36d5;};'use strict';var _=require(_0xdfc0('0x0'));var util=require('util');var moment=require(_0xdfc0('0x1'));var BPromise=require(_0xdfc0('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xdfc0('0x3'));var db=require(_0xdfc0('0x4'))['db'];var utils=require(_0xdfc0('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xdfc0('0x6')][_0xdfc0('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1da9cb,_0x3a883b,_0x5b45c9){return new BPromise(function(_0x2f4a04,_0x534910){return client[_0xdfc0('0x8')](_0x1da9cb,_0x5b45c9)[_0xdfc0('0x9')](function(_0x434f80){logger['info'](_0xdfc0('0xa'),_0x3a883b,_0xdfc0('0xb'));logger[_0xdfc0('0xc')](_0xdfc0('0xd'),_0x3a883b,_0xdfc0('0xb'),JSON[_0xdfc0('0xe')](_0x434f80));if(_0x434f80[_0xdfc0('0xf')]){if(_0x434f80[_0xdfc0('0xf')][_0xdfc0('0x10')]===0x1f4){logger[_0xdfc0('0xf')](_0xdfc0('0xa'),_0x3a883b,_0x434f80[_0xdfc0('0xf')]['message']);return _0x534910(_0x434f80[_0xdfc0('0xf')][_0xdfc0('0x11')]);}logger['error']('VtigerField,\x20%s,\x20%s',_0x3a883b,_0x434f80[_0xdfc0('0xf')][_0xdfc0('0x11')]);return _0x2f4a04(_0x434f80[_0xdfc0('0xf')]['message']);}else{logger[_0xdfc0('0x12')](_0xdfc0('0xa'),_0x3a883b,_0xdfc0('0xb'));_0x2f4a04(_0x434f80[_0xdfc0('0x13')][_0xdfc0('0x11')]);}})[_0xdfc0('0x14')](function(_0x3dc645){logger[_0xdfc0('0xf')](_0xdfc0('0xa'),_0x3a883b,_0x3dc645);_0x534910(_0x3dc645);});});} \ No newline at end of file diff --git a/server/api/intZendeskAccount/index.js b/server/api/intZendeskAccount/index.js new file mode 100644 index 0000000..342dc3f --- /dev/null +++ b/server/api/intZendeskAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x21ff=['/:id','show','/:id/configurations','post','addConfiguration','put','update','destroy','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intZendeskAccount.controller','get','isAuthenticated','index'];(function(_0x44e8fb,_0x23e56a){var _0x1d5476=function(_0x26779b){while(--_0x26779b){_0x44e8fb['push'](_0x44e8fb['shift']());}};_0x1d5476(++_0x23e56a);}(_0x21ff,0x8c));var _0xf21f=function(_0x5bf2b3,_0xfcd364){_0x5bf2b3=_0x5bf2b3-0x0;var _0x5e8a9b=_0x21ff[_0x5bf2b3];return _0x5e8a9b;};'use strict';var multer=require(_0xf21f('0x0'));var util=require(_0xf21f('0x1'));var path=require(_0xf21f('0x2'));var timeout=require(_0xf21f('0x3'));var express=require(_0xf21f('0x4'));var router=express[_0xf21f('0x5')]();var fs_extra=require(_0xf21f('0x6'));var auth=require(_0xf21f('0x7'));var interaction=require(_0xf21f('0x8'));var config=require(_0xf21f('0x9'));var controller=require(_0xf21f('0xa'));router[_0xf21f('0xb')]('/',auth[_0xf21f('0xc')](),controller[_0xf21f('0xd')]);router['get'](_0xf21f('0xe'),auth[_0xf21f('0xc')](),controller[_0xf21f('0xf')]);router[_0xf21f('0xb')](_0xf21f('0x10'),auth['isAuthenticated'](),controller['getConfigurations']);router[_0xf21f('0xb')]('/:id/fields',auth[_0xf21f('0xc')](),controller['getFields']);router['post']('/',auth[_0xf21f('0xc')](),controller['create']);router[_0xf21f('0x11')](_0xf21f('0x10'),auth[_0xf21f('0xc')](),controller[_0xf21f('0x12')]);router[_0xf21f('0x13')](_0xf21f('0xe'),auth[_0xf21f('0xc')](),controller[_0xf21f('0x14')]);router['delete'](_0xf21f('0xe'),auth[_0xf21f('0xc')](),controller[_0xf21f('0x15')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/intZendeskAccount/intZendeskAccount.attributes.js b/server/api/intZendeskAccount/intZendeskAccount.attributes.js new file mode 100644 index 0000000..f31fcd3 --- /dev/null +++ b/server/api/intZendeskAccount/intZendeskAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa6ce=['STRING','username','remoteUri','ENUM','password','token','integrationTab','newTab','sequelize'];(function(_0x163a9f,_0xf9b87){var _0xe0fb8b=function(_0x218a08){while(--_0x218a08){_0x163a9f['push'](_0x163a9f['shift']());}};_0xe0fb8b(++_0xf9b87);}(_0xa6ce,0x15e));var _0xea6c=function(_0x5ac1e5,_0x4b5012){_0x5ac1e5=_0x5ac1e5-0x0;var _0x1bccc6=_0xa6ce[_0x5ac1e5];return _0x1bccc6;};'use strict';var Sequelize=require(_0xea6c('0x0'));module['exports']={'name':{'type':Sequelize[_0xea6c('0x1')]},'description':{'type':Sequelize[_0xea6c('0x1')]},'username':{'type':Sequelize['STRING'],'unique':_0xea6c('0x2')},'password':{'type':Sequelize[_0xea6c('0x1')]},'token':{'type':Sequelize['STRING']},'remoteUri':{'type':Sequelize['STRING'],'unique':_0xea6c('0x3')},'authType':{'type':Sequelize[_0xea6c('0x4')](_0xea6c('0x5'),_0xea6c('0x6')),'defaultValue':_0xea6c('0x5')},'serverUrl':{'type':Sequelize[_0xea6c('0x1')],'allowNull':![]},'type':{'type':Sequelize['ENUM'](_0xea6c('0x7'),_0xea6c('0x8')),'defaultValue':_0xea6c('0x7')}}; \ No newline at end of file diff --git a/server/api/intZendeskAccount/intZendeskAccount.controller.js b/server/api/intZendeskAccount/intZendeskAccount.controller.js new file mode 100644 index 0000000..990f1a9 --- /dev/null +++ b/server/api/intZendeskAccount/intZendeskAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9ffd=['catch','show','params','rawAttributes','find','create','body','destroy','getConfigurations','ZendeskConfiguration','pick','addConfiguration','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','channel','ZendeskField','findOne','username','password','token','authType','substring','lastIndexOf','format','%s/%s','ticket_fields','headers','Basic\x20%s','%s:%s','base64','%s/token:%s','toString','Sequelize','Unknown\x20authentication\x20type','subject','description','group','assignee','remove','includes','position','title','system_field_options','custom_field_options','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','getFields','send','Wrong\x20credentials','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','update','then','stack','name','index','map','ZendeskAccount','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','filter','merge','VIRTUAL','includeAll','include','findAll'];(function(_0x3e0767,_0x48c9c8){var _0x1a453b=function(_0x4c78d7){while(--_0x4c78d7){_0x3e0767['push'](_0x3e0767['shift']());}};_0x1a453b(++_0x48c9c8);}(_0x9ffd,0xaa));var _0xd9ff=function(_0x17d2f5,_0x2ce8b5){_0x17d2f5=_0x17d2f5-0x0;var _0x470d7d=_0x9ffd[_0x17d2f5];return _0x470d7d;};'use strict';var emlformat=require(_0xd9ff('0x0'));var rimraf=require(_0xd9ff('0x1'));var zipdir=require(_0xd9ff('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd9ff('0x3'));var moment=require(_0xd9ff('0x4'));var BPromise=require(_0xd9ff('0x5'));var Mustache=require(_0xd9ff('0x6'));var util=require('util');var path=require(_0xd9ff('0x7'));var sox=require(_0xd9ff('0x8'));var csv=require('to-csv');var ejs=require(_0xd9ff('0x9'));var fs=require('fs');var fs_extra=require(_0xd9ff('0xa'));var _=require(_0xd9ff('0xb'));var squel=require(_0xd9ff('0xc'));var crypto=require(_0xd9ff('0xd'));var jsforce=require(_0xd9ff('0xe'));var deskjs=require(_0xd9ff('0xf'));var toCsv=require(_0xd9ff('0x10'));var querystring=require(_0xd9ff('0x11'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xd9ff('0x12'));var hardwareService=require(_0xd9ff('0x13'));var logger=require(_0xd9ff('0x14'))(_0xd9ff('0x15'));var utils=require(_0xd9ff('0x16'));var config=require(_0xd9ff('0x17'));var licenseUtil=require(_0xd9ff('0x18'));var db=require(_0xd9ff('0x19'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x47b0d7,_0xaaf7af){_0xaaf7af=_0xaaf7af||0xcc;return function(_0x16a0d9){if(_0x16a0d9){return _0x47b0d7[_0xd9ff('0x1a')](_0xaaf7af);}return _0x47b0d7[_0xd9ff('0x1b')](_0xaaf7af)[_0xd9ff('0x1c')]();};}function respondWithResult(_0x556aa4,_0x2f78c1){_0x2f78c1=_0x2f78c1||0xc8;return function(_0x3c9ace){if(_0x3c9ace){return _0x556aa4['status'](_0x2f78c1)[_0xd9ff('0x1d')](_0x3c9ace);}};}function respondWithFilteredResult(_0x5db010,_0x4ffe54){return function(_0x547e28){if(_0x547e28){var _0x4c5718=typeof _0x4ffe54[_0xd9ff('0x1e')]==='undefined'&&typeof _0x4ffe54[_0xd9ff('0x1f')]===_0xd9ff('0x20');var _0x39c6ce=_0x547e28[_0xd9ff('0x21')];var _0x5f45c4=_0x4c5718?0x0:_0x4ffe54[_0xd9ff('0x1e')];var _0x3ccf15=_0x4c5718?_0x547e28[_0xd9ff('0x21')]:_0x4ffe54[_0xd9ff('0x1e')]+_0x4ffe54[_0xd9ff('0x1f')];var _0x3ea97d;if(_0x3ccf15>=_0x39c6ce){_0x3ccf15=_0x39c6ce;_0x3ea97d=0xc8;}else{_0x3ea97d=0xce;}_0x5db010[_0xd9ff('0x1b')](_0x3ea97d);return _0x5db010[_0xd9ff('0x22')]('Content-Range',_0x5f45c4+'-'+_0x3ccf15+'/'+_0x39c6ce)['json'](_0x547e28);}return null;};}function patchUpdates(_0x264a3d){return function(_0x3eed13){try{jsonpatch['apply'](_0x3eed13,_0x264a3d,!![]);}catch(_0x588151){return BPromise['reject'](_0x588151);}return _0x3eed13['save']();};}function saveUpdates(_0x1f4d9e,_0x58eb5f){return function(_0x4c486a){if(_0x4c486a){return _0x4c486a[_0xd9ff('0x23')](_0x1f4d9e)[_0xd9ff('0x24')](function(_0x9f074e){return _0x9f074e;});}return null;};}function removeEntity(_0x278b66,_0x42a828){return function(_0x4b058a){if(_0x4b058a){return _0x4b058a['destroy']()[_0xd9ff('0x24')](function(){_0x278b66['status'](0xcc)[_0xd9ff('0x1c')]();});}};}function handleEntityNotFound(_0x4d86fe,_0x285002){return function(_0x5d45b3){if(!_0x5d45b3){_0x4d86fe[_0xd9ff('0x1a')](0x194);}return _0x5d45b3;};}function handleError(_0x159e56,_0x2138b4){_0x2138b4=_0x2138b4||0x1f4;return function(_0x2970e8){logger['error'](_0x2970e8[_0xd9ff('0x25')]);if(_0x2970e8[_0xd9ff('0x26')]){delete _0x2970e8[_0xd9ff('0x26')];}_0x159e56[_0xd9ff('0x1b')](_0x2138b4)['send'](_0x2970e8);};}exports[_0xd9ff('0x27')]=function(_0x3792d9,_0x44b5a7){var _0x45fb63={},_0x263d3a={},_0xe516e2={'count':0x0,'rows':[]};var _0x420ffa=_[_0xd9ff('0x28')](db[_0xd9ff('0x29')]['rawAttributes'],function(_0xcea5db){return{'name':_0xcea5db['fieldName'],'type':_0xcea5db[_0xd9ff('0x2a')][_0xd9ff('0x2b')]};});_0x263d3a[_0xd9ff('0x2c')]=_['map'](_0x420ffa,_0xd9ff('0x26'));_0x263d3a[_0xd9ff('0x2d')]=_[_0xd9ff('0x2e')](_0x3792d9[_0xd9ff('0x2d')]);_0x263d3a['filters']=_[_0xd9ff('0x2f')](_0x263d3a['model'],_0x263d3a[_0xd9ff('0x2d')]);_0x45fb63[_0xd9ff('0x30')]=_[_0xd9ff('0x2f')](_0x263d3a[_0xd9ff('0x2c')],qs[_0xd9ff('0x31')](_0x3792d9[_0xd9ff('0x2d')][_0xd9ff('0x31')]));_0x45fb63[_0xd9ff('0x30')]=_0x45fb63[_0xd9ff('0x30')][_0xd9ff('0x32')]?_0x45fb63[_0xd9ff('0x30')]:_0x263d3a[_0xd9ff('0x2c')];if(!_0x3792d9[_0xd9ff('0x2d')][_0xd9ff('0x33')]('nolimit')){_0x45fb63[_0xd9ff('0x1f')]=qs[_0xd9ff('0x1f')](_0x3792d9[_0xd9ff('0x2d')]['limit']);_0x45fb63[_0xd9ff('0x1e')]=qs['offset'](_0x3792d9[_0xd9ff('0x2d')]['offset']);}_0x45fb63[_0xd9ff('0x34')]=qs['sort'](_0x3792d9[_0xd9ff('0x2d')][_0xd9ff('0x35')]);_0x45fb63[_0xd9ff('0x36')]=qs['filters'](_['pick'](_0x3792d9['query'],_0x263d3a[_0xd9ff('0x37')]),_0x420ffa);if(_0x3792d9[_0xd9ff('0x2d')][_0xd9ff('0x38')]){_0x45fb63[_0xd9ff('0x36')]=_[_0xd9ff('0x39')](_0x45fb63[_0xd9ff('0x36')],{'$or':_['map'](_0x420ffa,function(_0x4c00c2){if(_0x4c00c2['type']!==_0xd9ff('0x3a')){var _0x252edc={};_0x252edc[_0x4c00c2[_0xd9ff('0x26')]]={'$like':'%'+_0x3792d9[_0xd9ff('0x2d')]['filter']+'%'};return _0x252edc;}})});}_0x45fb63=_[_0xd9ff('0x39')]({},_0x45fb63,_0x3792d9['options']);var _0x3cff52={'where':_0x45fb63[_0xd9ff('0x36')]};return db[_0xd9ff('0x29')][_0xd9ff('0x21')](_0x3cff52)['then'](function(_0x1e34da){_0xe516e2[_0xd9ff('0x21')]=_0x1e34da;if(_0x3792d9['query'][_0xd9ff('0x3b')]){_0x45fb63[_0xd9ff('0x3c')]=[{'all':!![]}];}return db[_0xd9ff('0x29')][_0xd9ff('0x3d')](_0x45fb63);})[_0xd9ff('0x24')](function(_0x1cc848){_0xe516e2['rows']=_0x1cc848;return _0xe516e2;})[_0xd9ff('0x24')](respondWithFilteredResult(_0x44b5a7,_0x45fb63))[_0xd9ff('0x3e')](handleError(_0x44b5a7,null));};exports[_0xd9ff('0x3f')]=function(_0x39fbbb,_0x472724){var _0x52aab8={'raw':![],'where':{'id':_0x39fbbb[_0xd9ff('0x40')]['id']}},_0x3178cd={};_0x3178cd[_0xd9ff('0x2c')]=_['keys'](db['ZendeskAccount'][_0xd9ff('0x41')]);_0x3178cd[_0xd9ff('0x2d')]=_[_0xd9ff('0x2e')](_0x39fbbb[_0xd9ff('0x2d')]);_0x3178cd[_0xd9ff('0x37')]=_[_0xd9ff('0x2f')](_0x3178cd['model'],_0x3178cd[_0xd9ff('0x2d')]);_0x52aab8[_0xd9ff('0x30')]=_['intersection'](_0x3178cd[_0xd9ff('0x2c')],qs[_0xd9ff('0x31')](_0x39fbbb[_0xd9ff('0x2d')][_0xd9ff('0x31')]));_0x52aab8[_0xd9ff('0x30')]=_0x52aab8['attributes']['length']?_0x52aab8['attributes']:_0x3178cd[_0xd9ff('0x2c')];if(_0x39fbbb['query'][_0xd9ff('0x3b')]){_0x52aab8[_0xd9ff('0x3c')]=[{'all':!![]}];}_0x52aab8=_[_0xd9ff('0x39')]({},_0x52aab8,_0x39fbbb['options']);return db[_0xd9ff('0x29')][_0xd9ff('0x42')](_0x52aab8)['then'](handleEntityNotFound(_0x472724,null))[_0xd9ff('0x24')](respondWithResult(_0x472724,null))[_0xd9ff('0x3e')](handleError(_0x472724,null));};exports[_0xd9ff('0x43')]=function(_0x316854,_0x559101){return db[_0xd9ff('0x29')]['create'](_0x316854[_0xd9ff('0x44')],{})['then'](respondWithResult(_0x559101,0xc9))[_0xd9ff('0x3e')](handleError(_0x559101,null));};exports[_0xd9ff('0x23')]=function(_0x2bf37a,_0x1760c3){if(_0x2bf37a[_0xd9ff('0x44')]['id']){delete _0x2bf37a['body']['id'];}return db[_0xd9ff('0x29')][_0xd9ff('0x42')]({'where':{'id':_0x2bf37a[_0xd9ff('0x40')]['id']}})[_0xd9ff('0x24')](handleEntityNotFound(_0x1760c3,null))['then'](saveUpdates(_0x2bf37a['body'],null))['then'](respondWithResult(_0x1760c3,null))[_0xd9ff('0x3e')](handleError(_0x1760c3,null));};exports[_0xd9ff('0x45')]=function(_0x29c6bd,_0x572618){return db[_0xd9ff('0x29')][_0xd9ff('0x42')]({'where':{'id':_0x29c6bd[_0xd9ff('0x40')]['id']}})[_0xd9ff('0x24')](handleEntityNotFound(_0x572618,null))[_0xd9ff('0x24')](removeEntity(_0x572618,null))[_0xd9ff('0x3e')](handleError(_0x572618,null));};exports[_0xd9ff('0x46')]=function(_0x1e1364,_0x1ad160,_0x10d9d0){var _0x5dcb5={};var _0x3d6143={};var _0x2533d7;var _0x487b07;return db[_0xd9ff('0x29')]['findOne']({'where':{'id':_0x1e1364[_0xd9ff('0x40')]['id']}})['then'](handleEntityNotFound(_0x1ad160,null))[_0xd9ff('0x24')](function(_0x49623d){if(_0x49623d){_0x2533d7=_0x49623d;_0x3d6143[_0xd9ff('0x2c')]=_['keys'](db[_0xd9ff('0x47')]['rawAttributes']);_0x3d6143[_0xd9ff('0x2d')]=_['keys'](_0x1e1364[_0xd9ff('0x2d')]);_0x3d6143['filters']=_[_0xd9ff('0x2f')](_0x3d6143[_0xd9ff('0x2c')],_0x3d6143[_0xd9ff('0x2d')]);_0x5dcb5[_0xd9ff('0x30')]=_['intersection'](_0x3d6143[_0xd9ff('0x2c')],qs[_0xd9ff('0x31')](_0x1e1364[_0xd9ff('0x2d')]['fields']));_0x5dcb5[_0xd9ff('0x30')]=_0x5dcb5[_0xd9ff('0x30')][_0xd9ff('0x32')]?_0x5dcb5[_0xd9ff('0x30')]:_0x3d6143[_0xd9ff('0x2c')];_0x5dcb5['order']=qs[_0xd9ff('0x35')](_0x1e1364[_0xd9ff('0x2d')][_0xd9ff('0x35')]);_0x5dcb5[_0xd9ff('0x36')]=qs[_0xd9ff('0x37')](_[_0xd9ff('0x48')](_0x1e1364[_0xd9ff('0x2d')],_0x3d6143['filters']));if(_0x1e1364[_0xd9ff('0x2d')][_0xd9ff('0x38')]){_0x5dcb5['where']=_[_0xd9ff('0x39')](_0x5dcb5[_0xd9ff('0x36')],{'$or':_['map'](_0x5dcb5[_0xd9ff('0x30')],function(_0x36d5c2){var _0x25d8d1={};_0x25d8d1[_0x36d5c2]={'$like':'%'+_0x1e1364['query']['filter']+'%'};return _0x25d8d1;})});}_0x5dcb5=_[_0xd9ff('0x39')]({},_0x5dcb5,_0x1e1364['options']);return _0x2533d7[_0xd9ff('0x46')](_0x5dcb5);}})[_0xd9ff('0x24')](function(_0x31907e){if(_0x31907e){_0x487b07=_0x31907e[_0xd9ff('0x32')];if(!_0x1e1364['query']['hasOwnProperty']('nolimit')){_0x5dcb5[_0xd9ff('0x1f')]=qs[_0xd9ff('0x1f')](_0x1e1364[_0xd9ff('0x2d')][_0xd9ff('0x1f')]);_0x5dcb5[_0xd9ff('0x1e')]=qs['offset'](_0x1e1364[_0xd9ff('0x2d')]['offset']);}return _0x2533d7[_0xd9ff('0x46')](_0x5dcb5);}})[_0xd9ff('0x24')](function(_0x3f92c3){if(_0x3f92c3){return _0x3f92c3?{'count':_0x487b07,'rows':_0x3f92c3}:null;}})[_0xd9ff('0x24')](respondWithResult(_0x1ad160,null))[_0xd9ff('0x3e')](handleError(_0x1ad160,null));};exports[_0xd9ff('0x49')]=function(_0xed12df,_0xfcafbe,_0x5d633b){if(_0xed12df[_0xd9ff('0x44')]['id']){delete _0xed12df[_0xd9ff('0x44')]['id'];}return db['ZendeskAccount']['findOne']({'where':{'id':_0xed12df[_0xd9ff('0x40')]['id']}})['then'](handleEntityNotFound(_0xfcafbe,null))[_0xd9ff('0x24')](function(_0x34fca4){if(_0x34fca4){_0xed12df['body'][_0xd9ff('0x4a')]=_0x34fca4['id'];_0xed12df[_0xd9ff('0x44')][_0xd9ff('0x4b')]=integrations[_0xd9ff('0x4c')](_0xed12df[_0xd9ff('0x44')]['channel'],_0xed12df[_0xd9ff('0x44')]['type']);_0xed12df['body'][_0xd9ff('0x4d')]=integrations[_0xd9ff('0x4e')](_0xed12df[_0xd9ff('0x44')][_0xd9ff('0x4f')],_0xed12df['body'][_0xd9ff('0x2a')]);return db[_0xd9ff('0x47')][_0xd9ff('0x43')](_0xed12df[_0xd9ff('0x44')],{'include':[{'model':db[_0xd9ff('0x50')],'as':_0xd9ff('0x4b')},{'model':db[_0xd9ff('0x50')],'as':_0xd9ff('0x4d')}]});}return null;})['then'](respondWithResult(_0xfcafbe,null))['catch'](handleError(_0xfcafbe,null));};exports['getFields']=function(_0x275fb9,_0x31db27,_0x514d59){var _0x196670='';return db[_0xd9ff('0x29')][_0xd9ff('0x51')]({'where':{'id':_0x275fb9[_0xd9ff('0x40')]['id']},'attributes':['id',_0xd9ff('0x52'),_0xd9ff('0x53'),_0xd9ff('0x54'),_0xd9ff('0x55'),'remoteUri']})[_0xd9ff('0x24')](handleEntityNotFound(_0x31db27,null))[_0xd9ff('0x24')](function(_0x228413){if(_0x228413){_0x196670=_0x228413['remoteUri'];var _0x14e936=_0x196670['slice'](-0x1);if(_0x14e936==='/'){_0x196670=_0x196670[_0xd9ff('0x56')](0x0,_0x196670[_0xd9ff('0x57')](_0x14e936));}var _0x25ee82={'method':'GET','uri':util[_0xd9ff('0x58')](_0xd9ff('0x59'),_0x196670,_0xd9ff('0x5a')),'json':!![]};switch(_0x228413[_0xd9ff('0x55')]){case'password':_0x25ee82[_0xd9ff('0x5b')]={'Authorization':util[_0xd9ff('0x58')](_0xd9ff('0x5c'),new Buffer(util['format'](_0xd9ff('0x5d'),_0x228413[_0xd9ff('0x52')],_0x228413[_0xd9ff('0x53')]))['toString'](_0xd9ff('0x5e')))};break;case _0xd9ff('0x54'):_0x25ee82[_0xd9ff('0x5b')]={'Authorization':util[_0xd9ff('0x58')](_0xd9ff('0x5c'),new Buffer(util['format'](_0xd9ff('0x5f'),_0x228413[_0xd9ff('0x52')],_0x228413['token']))[_0xd9ff('0x60')](_0xd9ff('0x5e')))};break;default:throw new db[(_0xd9ff('0x61'))]['ValidationError'](_0xd9ff('0x62'));}return rp(_0x25ee82);}})['then'](function(_0x1e46fc){if(_0x1e46fc){var _0x478e0d=[_0xd9ff('0x63'),_0xd9ff('0x64'),_0xd9ff('0x65'),_0xd9ff('0x66')];_[_0xd9ff('0x67')](_0x1e46fc[_0xd9ff('0x5a')],function(_0xda0003){return _0x478e0d[_0xd9ff('0x68')](_0xda0003[_0xd9ff('0x2a')]);});return{'count':_0x1e46fc[_0xd9ff('0x5a')]['length'],'rows':_[_0xd9ff('0x28')](_0x1e46fc[_0xd9ff('0x5a')],function(_0x1f6cb9){return{'id':_0x1f6cb9['id'],'name':_0x1f6cb9[_0xd9ff('0x69')]>0x7?_0x1f6cb9[_0xd9ff('0x6a')]:_0x1f6cb9[_0xd9ff('0x2a')],'custom':_0x1f6cb9['position']>0x7?!![]:![],'options':_0x1f6cb9['system_field_options']?_0x1f6cb9[_0xd9ff('0x6b')]:_0x1f6cb9[_0xd9ff('0x6c')]?_0x1f6cb9[_0xd9ff('0x6c')]:[]};})};}})[_0xd9ff('0x24')](respondWithResult(_0x31db27,null))[_0xd9ff('0x3e')](function(_0x183199){var _0x5b234c=_0x275fb9[_0xd9ff('0x2d')][_0xd9ff('0x6d')]?0x1f4:_0x183199[_0xd9ff('0x6e')]||0x1f4;logger[_0xd9ff('0x6f')](_0xd9ff('0x70'),_0xd9ff('0x71'),_0x5b234c,JSON['stringify'](_0x183199));delete _0x183199[_0xd9ff('0x26')];if(_0x5b234c===0x191){_0x5b234c=0x190;}_0x31db27[_0xd9ff('0x1b')](_0x5b234c)[_0xd9ff('0x72')](_0x275fb9[_0xd9ff('0x2d')][_0xd9ff('0x6d')]?{'message':_0xd9ff('0x73'),'statusCode':_0x183199[_0xd9ff('0x6e')]}:_0x183199);});}; \ No newline at end of file diff --git a/server/api/intZendeskAccount/intZendeskAccount.model.js b/server/api/intZendeskAccount/intZendeskAccount.model.js new file mode 100644 index 0000000..68af3a4 --- /dev/null +++ b/server/api/intZendeskAccount/intZendeskAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xca68=['../../components/integrations/configuration','exports','define','ZendeskAccount','int_zendesk_accounts','util','api','moment','bluebird','request-promise','path','../../config/environment','./intZendeskAccount.attributes'];(function(_0x2181b1,_0x569637){var _0x530548=function(_0x4b31f1){while(--_0x4b31f1){_0x2181b1['push'](_0x2181b1['shift']());}};_0x530548(++_0x569637);}(_0xca68,0x18b));var _0x8ca6=function(_0x1fa4ca,_0x117360){_0x1fa4ca=_0x1fa4ca-0x0;var _0xb0338c=_0xca68[_0x1fa4ca];return _0xb0338c;};'use strict';var _=require('lodash');var util=require(_0x8ca6('0x0'));var logger=require('../../config/logger')(_0x8ca6('0x1'));var moment=require(_0x8ca6('0x2'));var BPromise=require(_0x8ca6('0x3'));var rp=require(_0x8ca6('0x4'));var fs=require('fs');var path=require(_0x8ca6('0x5'));var rimraf=require('rimraf');var config=require(_0x8ca6('0x6'));var attributes=require(_0x8ca6('0x7'));var integrations=require(_0x8ca6('0x8'));module[_0x8ca6('0x9')]=function(_0x21f5bb,_0x441914){return _0x21f5bb[_0x8ca6('0xa')](_0x8ca6('0xb'),attributes,{'tableName':_0x8ca6('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intZendeskAccount/intZendeskAccount.rpc.js b/server/api/intZendeskAccount/intZendeskAccount.rpc.js new file mode 100644 index 0000000..ac2041c --- /dev/null +++ b/server/api/intZendeskAccount/intZendeskAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x13c9=['model','attributes','ShowZendeskAccount','find','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','request','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetZendeskAccount','ZendeskAccount','findAll','options','raw','where','limit','include','map'];(function(_0x2b2396,_0x1efdc5){var _0x3a9147=function(_0x574808){while(--_0x574808){_0x2b2396['push'](_0x2b2396['shift']());}};_0x3a9147(++_0x1efdc5);}(_0x13c9,0x71));var _0x913c=function(_0x2f482b,_0x544217){_0x2f482b=_0x2f482b-0x0;var _0xb32299=_0x13c9[_0x2f482b];return _0xb32299;};'use strict';var _=require(_0x913c('0x0'));var util=require(_0x913c('0x1'));var moment=require(_0x913c('0x2'));var BPromise=require(_0x913c('0x3'));var rs=require(_0x913c('0x4'));var fs=require('fs');var Redis=require(_0x913c('0x5'));var db=require(_0x913c('0x6'))['db'];var utils=require(_0x913c('0x7'));var logger=require(_0x913c('0x8'))(_0x913c('0x9'));var config=require('../../config/environment');var jayson=require(_0x913c('0xa'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x38ae69,_0x312bf4,_0x53f08b){return new BPromise(function(_0x4bd33c,_0xd4c0b4){return client[_0x913c('0xb')](_0x38ae69,_0x53f08b)[_0x913c('0xc')](function(_0x1042a7){logger[_0x913c('0xd')](_0x913c('0xe'),_0x312bf4,_0x913c('0xf'));logger[_0x913c('0x10')](_0x913c('0x11'),_0x312bf4,_0x913c('0xf'),JSON['stringify'](_0x1042a7));if(_0x1042a7[_0x913c('0x12')]){if(_0x1042a7['error'][_0x913c('0x13')]===0x1f4){logger[_0x913c('0x12')](_0x913c('0xe'),_0x312bf4,_0x1042a7[_0x913c('0x12')][_0x913c('0x14')]);return _0xd4c0b4(_0x1042a7[_0x913c('0x12')][_0x913c('0x14')]);}logger['error'](_0x913c('0xe'),_0x312bf4,_0x1042a7[_0x913c('0x12')][_0x913c('0x14')]);return _0x4bd33c(_0x1042a7[_0x913c('0x12')][_0x913c('0x14')]);}else{logger[_0x913c('0xd')]('ZendeskAccount,\x20%s,\x20%s',_0x312bf4,'request\x20sent');_0x4bd33c(_0x1042a7['result']['message']);}})[_0x913c('0x15')](function(_0x94c424){logger[_0x913c('0x12')](_0x913c('0xe'),_0x312bf4,_0x94c424);_0xd4c0b4(_0x94c424);});});}exports[_0x913c('0x16')]=function(_0x4cb094){var _0x371772=this;return new Promise(function(_0xdf96fb,_0x33affd){return db[_0x913c('0x17')][_0x913c('0x18')]({'raw':_0x4cb094[_0x913c('0x19')]?_0x4cb094[_0x913c('0x19')][_0x913c('0x1a')]===undefined?!![]:![]:!![],'where':_0x4cb094['options']?_0x4cb094[_0x913c('0x19')][_0x913c('0x1b')]||null:null,'attributes':_0x4cb094[_0x913c('0x19')]?_0x4cb094[_0x913c('0x19')]['attributes']||null:null,'limit':_0x4cb094[_0x913c('0x19')]?_0x4cb094[_0x913c('0x19')][_0x913c('0x1c')]||null:null,'include':_0x4cb094['options']?_0x4cb094[_0x913c('0x19')][_0x913c('0x1d')]?_[_0x913c('0x1e')](_0x4cb094['options'][_0x913c('0x1d')],function(_0xa88930){return{'model':db[_0xa88930[_0x913c('0x1f')]],'as':_0xa88930['as'],'attributes':_0xa88930[_0x913c('0x20')],'include':_0xa88930[_0x913c('0x1d')]?_[_0x913c('0x1e')](_0xa88930[_0x913c('0x1d')],function(_0x4a0b04){return{'model':db[_0x4a0b04['model']],'as':_0x4a0b04['as'],'attributes':_0x4a0b04[_0x913c('0x20')],'include':_0x4a0b04[_0x913c('0x1d')]?_[_0x913c('0x1e')](_0x4a0b04['include'],function(_0x54c524){return{'model':db[_0x54c524[_0x913c('0x1f')]],'as':_0x54c524['as'],'attributes':_0x54c524[_0x913c('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5b8a75){logger[_0x913c('0xd')](_0x913c('0x16'),_0x4cb094);logger[_0x913c('0x10')]('GetZendeskAccount',_0x4cb094,JSON['stringify'](_0x5b8a75));_0xdf96fb(_0x5b8a75);})[_0x913c('0x15')](function(_0x48062d){logger[_0x913c('0x12')](_0x913c('0x16'),_0x48062d[_0x913c('0x14')],_0x4cb094);_0x33affd(_0x371772['error'](0x1f4,_0x48062d['message']));});});};exports[_0x913c('0x21')]=function(_0x57be59){var _0x387d71=this;return new Promise(function(_0x3b9542,_0x42d7cd){return db[_0x913c('0x17')][_0x913c('0x22')]({'raw':_0x57be59['options']?_0x57be59[_0x913c('0x19')][_0x913c('0x1a')]===undefined?!![]:![]:!![],'where':_0x57be59[_0x913c('0x19')]?_0x57be59[_0x913c('0x19')]['where']||null:null,'attributes':_0x57be59['options']?_0x57be59['options']['attributes']||null:null,'include':_0x57be59['options']?_0x57be59[_0x913c('0x19')][_0x913c('0x1d')]?_[_0x913c('0x1e')](_0x57be59[_0x913c('0x19')]['include'],function(_0x133c97){return{'model':db[_0x133c97[_0x913c('0x1f')]],'as':_0x133c97['as'],'attributes':_0x133c97[_0x913c('0x20')],'include':_0x133c97['include']?_['map'](_0x133c97['include'],function(_0x56fddc){return{'model':db[_0x56fddc[_0x913c('0x1f')]],'as':_0x56fddc['as'],'attributes':_0x56fddc[_0x913c('0x20')],'include':_0x56fddc[_0x913c('0x1d')]?_[_0x913c('0x1e')](_0x56fddc[_0x913c('0x1d')],function(_0x1f98ed){return{'model':db[_0x1f98ed[_0x913c('0x1f')]],'as':_0x1f98ed['as'],'attributes':_0x1f98ed[_0x913c('0x20')]};}):[]};}):[]};}):[]:[]})[_0x913c('0xc')](function(_0xb87d32){logger[_0x913c('0xd')](_0x913c('0x21'),_0x57be59);logger[_0x913c('0x10')]('ShowZendeskAccount',_0x57be59,JSON[_0x913c('0x23')](_0xb87d32));_0x3b9542(_0xb87d32);})[_0x913c('0x15')](function(_0x34ebf6){logger[_0x913c('0x12')](_0x913c('0x21'),_0x34ebf6[_0x913c('0x14')],_0x57be59);_0x42d7cd(_0x387d71[_0x913c('0x12')](0x1f4,_0x34ebf6[_0x913c('0x14')]));});});}; \ No newline at end of file diff --git a/server/api/intZendeskConfiguration/index.js b/server/api/intZendeskConfiguration/index.js new file mode 100644 index 0000000..3f0c0a8 --- /dev/null +++ b/server/api/intZendeskConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','isAuthenticated','index','get','show','/:id/fields','getFields','/:id/subjects','getSubjects','/:id/tags','getTags','post','create','setTags','put','/:id','delete','destroy','exports','multer','util'];(function(_0x4de1c3,_0xbe77b9){var _0x26acfe=function(_0x2c9df4){while(--_0x2c9df4){_0x4de1c3['push'](_0x4de1c3['shift']());}};_0x26acfe(++_0xbe77b9);}(_0xd8b0,0xad));var _0x0d8b=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xd8b0[_0xa464c9];return _0x3d73c4;};'use strict';var multer=require(_0x0d8b('0x0'));var util=require(_0x0d8b('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0d8b('0x2')]();var fs_extra=require(_0x0d8b('0x3'));var auth=require(_0x0d8b('0x4'));var interaction=require(_0x0d8b('0x5'));var config=require(_0x0d8b('0x6'));var controller=require('./intZendeskConfiguration.controller');router['get']('/',auth[_0x0d8b('0x7')](),controller[_0x0d8b('0x8')]);router[_0x0d8b('0x9')]('/:id',auth[_0x0d8b('0x7')](),controller[_0x0d8b('0xa')]);router['get'](_0x0d8b('0xb'),auth[_0x0d8b('0x7')](),controller[_0x0d8b('0xc')]);router[_0x0d8b('0x9')](_0x0d8b('0xd'),auth[_0x0d8b('0x7')](),controller[_0x0d8b('0xe')]);router[_0x0d8b('0x9')]('/:id/descriptions',auth[_0x0d8b('0x7')](),controller['getDescriptions']);router[_0x0d8b('0x9')](_0x0d8b('0xf'),auth[_0x0d8b('0x7')](),controller[_0x0d8b('0x10')]);router[_0x0d8b('0x11')]('/',auth[_0x0d8b('0x7')](),controller[_0x0d8b('0x12')]);router[_0x0d8b('0x11')](_0x0d8b('0xf'),auth[_0x0d8b('0x7')](),controller[_0x0d8b('0x13')]);router[_0x0d8b('0x14')](_0x0d8b('0x15'),auth[_0x0d8b('0x7')](),controller['update']);router[_0x0d8b('0x16')](_0x0d8b('0x15'),auth[_0x0d8b('0x7')](),controller[_0x0d8b('0x17')]);module[_0x0d8b('0x18')]=router; \ No newline at end of file diff --git a/server/api/intZendeskConfiguration/intZendeskConfiguration.attributes.js b/server/api/intZendeskConfiguration/intZendeskConfiguration.attributes.js new file mode 100644 index 0000000..9fc0fb0 --- /dev/null +++ b/server/api/intZendeskConfiguration/intZendeskConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e37=['exports','STRING','sequelize'];(function(_0x379809,_0x2a8f32){var _0xb64de7=function(_0x7fd2fe){while(--_0x7fd2fe){_0x379809['push'](_0x379809['shift']());}};_0xb64de7(++_0x2a8f32);}(_0x4e37,0x15e));var _0x74e3=function(_0x4b4844,_0x2f0dfb){_0x4b4844=_0x4b4844-0x0;var _0x575192=_0x4e37[_0x4b4844];return _0x575192;};'use strict';var Sequelize=require(_0x74e3('0x0'));module[_0x74e3('0x1')]={'name':{'type':Sequelize[_0x74e3('0x2')]},'description':{'type':Sequelize[_0x74e3('0x2')]}}; \ No newline at end of file diff --git a/server/api/intZendeskConfiguration/intZendeskConfiguration.controller.js b/server/api/intZendeskConfiguration/intZendeskConfiguration.controller.js new file mode 100644 index 0000000..ab076c9 --- /dev/null +++ b/server/api/intZendeskConfiguration/intZendeskConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc5e=['querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','save','update','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','ZendeskConfiguration','includeAll','findAll','catch','show','params','length','include','find','create','findOne','ZendeskField','getFields','getSubjects','getDescriptions','getTags','Tag','body','setTags','ids','eml-format','rimraf','fast-json-patch','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js'];(function(_0x30af30,_0xee8b76){var _0x1077c2=function(_0x2637d8){while(--_0x2637d8){_0x30af30['push'](_0x30af30['shift']());}};_0x1077c2(++_0xee8b76);}(_0xdc5e,0xec));var _0xedc5=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xdc5e[_0x321bb2];return _0x9c12ed;};'use strict';var emlformat=require(_0xedc5('0x0'));var rimraf=require(_0xedc5('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xedc5('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xedc5('0x3'));var util=require(_0xedc5('0x4'));var path=require('path');var sox=require(_0xedc5('0x5'));var csv=require(_0xedc5('0x6'));var ejs=require(_0xedc5('0x7'));var fs=require('fs');var fs_extra=require(_0xedc5('0x8'));var _=require(_0xedc5('0x9'));var squel=require(_0xedc5('0xa'));var crypto=require('crypto');var jsforce=require(_0xedc5('0xb'));var deskjs=require(_0xedc5('0xc'));var toCsv=require(_0xedc5('0x6'));var querystring=require(_0xedc5('0xd'));var Papa=require(_0xedc5('0xe'));var Redis=require('ioredis');var authService=require(_0xedc5('0xf'));var qs=require(_0xedc5('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xedc5('0x11'));var logger=require(_0xedc5('0x12'))(_0xedc5('0x13'));var utils=require(_0xedc5('0x14'));var config=require(_0xedc5('0x15'));var licenseUtil=require(_0xedc5('0x16'));var db=require(_0xedc5('0x17'))['db'];function respondWithStatusCode(_0x4eee7f,_0x135191){_0x135191=_0x135191||0xcc;return function(_0x5dc66c){if(_0x5dc66c){return _0x4eee7f[_0xedc5('0x18')](_0x135191);}return _0x4eee7f[_0xedc5('0x19')](_0x135191)[_0xedc5('0x1a')]();};}function respondWithResult(_0x1a87c3,_0x16eb50){_0x16eb50=_0x16eb50||0xc8;return function(_0x481b48){if(_0x481b48){return _0x1a87c3[_0xedc5('0x19')](_0x16eb50)[_0xedc5('0x1b')](_0x481b48);}};}function respondWithFilteredResult(_0x2e564c,_0xe3d602){return function(_0x34ab52){if(_0x34ab52){var _0x35b71d=typeof _0xe3d602[_0xedc5('0x1c')]==='undefined'&&typeof _0xe3d602[_0xedc5('0x1d')]===_0xedc5('0x1e');var _0x1205de=_0x34ab52[_0xedc5('0x1f')];var _0x44e9a8=_0x35b71d?0x0:_0xe3d602[_0xedc5('0x1c')];var _0x2f9b1f=_0x35b71d?_0x34ab52['count']:_0xe3d602['offset']+_0xe3d602['limit'];var _0x3556d7;if(_0x2f9b1f>=_0x1205de){_0x2f9b1f=_0x1205de;_0x3556d7=0xc8;}else{_0x3556d7=0xce;}_0x2e564c[_0xedc5('0x19')](_0x3556d7);return _0x2e564c[_0xedc5('0x20')]('Content-Range',_0x44e9a8+'-'+_0x2f9b1f+'/'+_0x1205de)[_0xedc5('0x1b')](_0x34ab52);}return null;};}function patchUpdates(_0x213265){return function(_0x33af62){try{jsonpatch['apply'](_0x33af62,_0x213265,!![]);}catch(_0x450895){return BPromise['reject'](_0x450895);}return _0x33af62[_0xedc5('0x21')]();};}function saveUpdates(_0x686772,_0x1cab30){return function(_0x1a2086){if(_0x1a2086){return _0x1a2086[_0xedc5('0x22')](_0x686772)[_0xedc5('0x23')](function(_0xf21074){return _0xf21074;});}return null;};}function removeEntity(_0x5ec021,_0x2af323){return function(_0x4e609e){if(_0x4e609e){return _0x4e609e[_0xedc5('0x24')]()[_0xedc5('0x23')](function(){_0x5ec021[_0xedc5('0x19')](0xcc)[_0xedc5('0x1a')]();});}};}function handleEntityNotFound(_0x530445,_0x3f793d){return function(_0x2a548f){if(!_0x2a548f){_0x530445[_0xedc5('0x18')](0x194);}return _0x2a548f;};}function handleError(_0x95a6c7,_0x49dec1){_0x49dec1=_0x49dec1||0x1f4;return function(_0x4b33a4){logger['error'](_0x4b33a4[_0xedc5('0x25')]);if(_0x4b33a4[_0xedc5('0x26')]){delete _0x4b33a4[_0xedc5('0x26')];}_0x95a6c7[_0xedc5('0x19')](_0x49dec1)[_0xedc5('0x27')](_0x4b33a4);};}exports[_0xedc5('0x28')]=function(_0x403064,_0x589605){var _0x5ea3cd={},_0x45e266={},_0x4c2a6a={'count':0x0,'rows':[]};var _0xb9434a=_[_0xedc5('0x29')](db['ZendeskConfiguration'][_0xedc5('0x2a')],function(_0x154197){return{'name':_0x154197[_0xedc5('0x2b')],'type':_0x154197[_0xedc5('0x2c')][_0xedc5('0x2d')]};});_0x45e266[_0xedc5('0x2e')]=_['map'](_0xb9434a,_0xedc5('0x26'));_0x45e266[_0xedc5('0x2f')]=_[_0xedc5('0x30')](_0x403064[_0xedc5('0x2f')]);_0x45e266[_0xedc5('0x31')]=_[_0xedc5('0x32')](_0x45e266[_0xedc5('0x2e')],_0x45e266[_0xedc5('0x2f')]);_0x5ea3cd[_0xedc5('0x33')]=_[_0xedc5('0x32')](_0x45e266['model'],qs['fields'](_0x403064[_0xedc5('0x2f')][_0xedc5('0x34')]));_0x5ea3cd[_0xedc5('0x33')]=_0x5ea3cd['attributes']['length']?_0x5ea3cd[_0xedc5('0x33')]:_0x45e266[_0xedc5('0x2e')];if(!_0x403064[_0xedc5('0x2f')][_0xedc5('0x35')](_0xedc5('0x36'))){_0x5ea3cd[_0xedc5('0x1d')]=qs['limit'](_0x403064[_0xedc5('0x2f')][_0xedc5('0x1d')]);_0x5ea3cd['offset']=qs['offset'](_0x403064['query'][_0xedc5('0x1c')]);}_0x5ea3cd[_0xedc5('0x37')]=qs['sort'](_0x403064[_0xedc5('0x2f')][_0xedc5('0x38')]);_0x5ea3cd['where']=qs[_0xedc5('0x31')](_[_0xedc5('0x39')](_0x403064[_0xedc5('0x2f')],_0x45e266[_0xedc5('0x31')]),_0xb9434a);if(_0x403064['query']['filter']){_0x5ea3cd[_0xedc5('0x3a')]=_[_0xedc5('0x3b')](_0x5ea3cd[_0xedc5('0x3a')],{'$or':_[_0xedc5('0x29')](_0xb9434a,function(_0x9028d9){if(_0x9028d9[_0xedc5('0x2c')]!==_0xedc5('0x3c')){var _0x33d2cc={};_0x33d2cc[_0x9028d9['name']]={'$like':'%'+_0x403064[_0xedc5('0x2f')][_0xedc5('0x3d')]+'%'};return _0x33d2cc;}})});}_0x5ea3cd=_[_0xedc5('0x3b')]({},_0x5ea3cd,_0x403064[_0xedc5('0x3e')]);var _0x73d1d2={'where':_0x5ea3cd['where']};return db[_0xedc5('0x3f')][_0xedc5('0x1f')](_0x73d1d2)['then'](function(_0x8eba9){_0x4c2a6a[_0xedc5('0x1f')]=_0x8eba9;if(_0x403064[_0xedc5('0x2f')][_0xedc5('0x40')]){_0x5ea3cd['include']=[{'all':!![]}];}return db[_0xedc5('0x3f')][_0xedc5('0x41')](_0x5ea3cd);})[_0xedc5('0x23')](function(_0x1246b9){_0x4c2a6a['rows']=_0x1246b9;return _0x4c2a6a;})[_0xedc5('0x23')](respondWithFilteredResult(_0x589605,_0x5ea3cd))[_0xedc5('0x42')](handleError(_0x589605,null));};exports[_0xedc5('0x43')]=function(_0x15a92e,_0x307af1){var _0x578c56={'raw':![],'where':{'id':_0x15a92e[_0xedc5('0x44')]['id']}},_0x5d19e5={};_0x5d19e5[_0xedc5('0x2e')]=_[_0xedc5('0x30')](db[_0xedc5('0x3f')][_0xedc5('0x2a')]);_0x5d19e5['query']=_[_0xedc5('0x30')](_0x15a92e[_0xedc5('0x2f')]);_0x5d19e5['filters']=_['intersection'](_0x5d19e5[_0xedc5('0x2e')],_0x5d19e5[_0xedc5('0x2f')]);_0x578c56[_0xedc5('0x33')]=_['intersection'](_0x5d19e5['model'],qs['fields'](_0x15a92e['query'][_0xedc5('0x34')]));_0x578c56['attributes']=_0x578c56[_0xedc5('0x33')][_0xedc5('0x45')]?_0x578c56[_0xedc5('0x33')]:_0x5d19e5[_0xedc5('0x2e')];if(_0x15a92e[_0xedc5('0x2f')][_0xedc5('0x40')]){_0x578c56[_0xedc5('0x46')]=[{'all':!![]}];}_0x578c56=_[_0xedc5('0x3b')]({},_0x578c56,_0x15a92e[_0xedc5('0x3e')]);return db[_0xedc5('0x3f')][_0xedc5('0x47')](_0x578c56)['then'](handleEntityNotFound(_0x307af1,null))[_0xedc5('0x23')](respondWithResult(_0x307af1,null))[_0xedc5('0x42')](handleError(_0x307af1,null));};exports['create']=function(_0x4b8743,_0x3256a5){return db[_0xedc5('0x3f')][_0xedc5('0x48')](_0x4b8743['body'],{})[_0xedc5('0x23')](respondWithResult(_0x3256a5,0xc9))[_0xedc5('0x42')](handleError(_0x3256a5,null));};exports['update']=function(_0x2269d3,_0x5ba94d){if(_0x2269d3['body']['id']){delete _0x2269d3['body']['id'];}return db[_0xedc5('0x3f')][_0xedc5('0x47')]({'where':{'id':_0x2269d3[_0xedc5('0x44')]['id']}})[_0xedc5('0x23')](handleEntityNotFound(_0x5ba94d,null))[_0xedc5('0x23')](saveUpdates(_0x2269d3['body'],null))['then'](respondWithResult(_0x5ba94d,null))['catch'](handleError(_0x5ba94d,null));};exports[_0xedc5('0x24')]=function(_0x711912,_0x1860ca){return db[_0xedc5('0x3f')][_0xedc5('0x47')]({'where':{'id':_0x711912[_0xedc5('0x44')]['id']}})[_0xedc5('0x23')](handleEntityNotFound(_0x1860ca,null))[_0xedc5('0x23')](removeEntity(_0x1860ca,null))[_0xedc5('0x42')](handleError(_0x1860ca,null));};exports['getFields']=function(_0x532e6f,_0x5a8d5b,_0x31468f){var _0xd0f069={};var _0x4be761={};var _0x452d1d;var _0x1819b4;return db[_0xedc5('0x3f')][_0xedc5('0x49')]({'where':{'id':_0x532e6f[_0xedc5('0x44')]['id']}})['then'](handleEntityNotFound(_0x5a8d5b,null))[_0xedc5('0x23')](function(_0x5dcc69){if(_0x5dcc69){_0x452d1d=_0x5dcc69;_0x4be761[_0xedc5('0x2e')]=_[_0xedc5('0x30')](db[_0xedc5('0x4a')][_0xedc5('0x2a')]);_0x4be761[_0xedc5('0x2f')]=_['keys'](_0x532e6f[_0xedc5('0x2f')]);_0x4be761[_0xedc5('0x31')]=_['intersection'](_0x4be761[_0xedc5('0x2e')],_0x4be761[_0xedc5('0x2f')]);_0xd0f069[_0xedc5('0x33')]=_[_0xedc5('0x32')](_0x4be761[_0xedc5('0x2e')],qs[_0xedc5('0x34')](_0x532e6f[_0xedc5('0x2f')][_0xedc5('0x34')]));_0xd0f069[_0xedc5('0x33')]=_0xd0f069[_0xedc5('0x33')]['length']?_0xd0f069[_0xedc5('0x33')]:_0x4be761[_0xedc5('0x2e')];_0xd0f069[_0xedc5('0x37')]=qs[_0xedc5('0x38')](_0x532e6f[_0xedc5('0x2f')]['sort']);_0xd0f069[_0xedc5('0x3a')]=qs['filters'](_[_0xedc5('0x39')](_0x532e6f[_0xedc5('0x2f')],_0x4be761[_0xedc5('0x31')]));if(_0x532e6f[_0xedc5('0x2f')][_0xedc5('0x3d')]){_0xd0f069[_0xedc5('0x3a')]=_['merge'](_0xd0f069[_0xedc5('0x3a')],{'$or':_[_0xedc5('0x29')](_0xd0f069[_0xedc5('0x33')],function(_0x3a149e){var _0x5cb71d={};_0x5cb71d[_0x3a149e]={'$like':'%'+_0x532e6f[_0xedc5('0x2f')]['filter']+'%'};return _0x5cb71d;})});}_0xd0f069=_['merge']({},_0xd0f069,_0x532e6f['options']);return _0x452d1d['getFields'](_0xd0f069);}})['then'](function(_0x483ea5){if(_0x483ea5){_0x1819b4=_0x483ea5['length'];if(!_0x532e6f[_0xedc5('0x2f')][_0xedc5('0x35')](_0xedc5('0x36'))){_0xd0f069[_0xedc5('0x1d')]=qs[_0xedc5('0x1d')](_0x532e6f['query'][_0xedc5('0x1d')]);_0xd0f069[_0xedc5('0x1c')]=qs[_0xedc5('0x1c')](_0x532e6f['query'][_0xedc5('0x1c')]);}return _0x452d1d[_0xedc5('0x4b')](_0xd0f069);}})[_0xedc5('0x23')](function(_0x533912){if(_0x533912){return _0x533912?{'count':_0x1819b4,'rows':_0x533912}:null;}})['then'](respondWithResult(_0x5a8d5b,null))[_0xedc5('0x42')](handleError(_0x5a8d5b,null));};exports[_0xedc5('0x4c')]=function(_0x3f6779,_0x412647,_0x3c9b7c){var _0x31f125={};var _0x1b7723={};var _0x5b3932;var _0x3fd8f8;return db['ZendeskConfiguration'][_0xedc5('0x49')]({'where':{'id':_0x3f6779[_0xedc5('0x44')]['id']}})[_0xedc5('0x23')](handleEntityNotFound(_0x412647,null))['then'](function(_0x588ed6){if(_0x588ed6){_0x5b3932=_0x588ed6;_0x1b7723['model']=_[_0xedc5('0x30')](db[_0xedc5('0x4a')][_0xedc5('0x2a')]);_0x1b7723[_0xedc5('0x2f')]=_[_0xedc5('0x30')](_0x3f6779[_0xedc5('0x2f')]);_0x1b7723[_0xedc5('0x31')]=_['intersection'](_0x1b7723['model'],_0x1b7723[_0xedc5('0x2f')]);_0x31f125[_0xedc5('0x33')]=_[_0xedc5('0x32')](_0x1b7723[_0xedc5('0x2e')],qs[_0xedc5('0x34')](_0x3f6779[_0xedc5('0x2f')]['fields']));_0x31f125[_0xedc5('0x33')]=_0x31f125[_0xedc5('0x33')][_0xedc5('0x45')]?_0x31f125[_0xedc5('0x33')]:_0x1b7723['model'];_0x31f125['order']=qs[_0xedc5('0x38')](_0x3f6779['query'][_0xedc5('0x38')]);_0x31f125[_0xedc5('0x3a')]=qs['filters'](_[_0xedc5('0x39')](_0x3f6779[_0xedc5('0x2f')],_0x1b7723[_0xedc5('0x31')]));if(_0x3f6779[_0xedc5('0x2f')][_0xedc5('0x3d')]){_0x31f125[_0xedc5('0x3a')]=_[_0xedc5('0x3b')](_0x31f125[_0xedc5('0x3a')],{'$or':_[_0xedc5('0x29')](_0x31f125['attributes'],function(_0x941f52){var _0x239966={};_0x239966[_0x941f52]={'$like':'%'+_0x3f6779[_0xedc5('0x2f')][_0xedc5('0x3d')]+'%'};return _0x239966;})});}_0x31f125=_[_0xedc5('0x3b')]({},_0x31f125,_0x3f6779[_0xedc5('0x3e')]);return _0x5b3932[_0xedc5('0x4c')](_0x31f125);}})[_0xedc5('0x23')](function(_0x55f7d5){if(_0x55f7d5){_0x3fd8f8=_0x55f7d5[_0xedc5('0x45')];if(!_0x3f6779['query'][_0xedc5('0x35')](_0xedc5('0x36'))){_0x31f125[_0xedc5('0x1d')]=qs[_0xedc5('0x1d')](_0x3f6779[_0xedc5('0x2f')][_0xedc5('0x1d')]);_0x31f125[_0xedc5('0x1c')]=qs['offset'](_0x3f6779[_0xedc5('0x2f')][_0xedc5('0x1c')]);}return _0x5b3932[_0xedc5('0x4c')](_0x31f125);}})[_0xedc5('0x23')](function(_0x4546e7){if(_0x4546e7){return _0x4546e7?{'count':_0x3fd8f8,'rows':_0x4546e7}:null;}})[_0xedc5('0x23')](respondWithResult(_0x412647,null))[_0xedc5('0x42')](handleError(_0x412647,null));};exports['getDescriptions']=function(_0x158037,_0x41820d,_0x71ba3b){var _0x249510={};var _0x12b805={};var _0x435ee4;var _0x56f586;return db[_0xedc5('0x3f')]['findOne']({'where':{'id':_0x158037[_0xedc5('0x44')]['id']}})['then'](handleEntityNotFound(_0x41820d,null))[_0xedc5('0x23')](function(_0x3dfcd9){if(_0x3dfcd9){_0x435ee4=_0x3dfcd9;_0x12b805[_0xedc5('0x2e')]=_[_0xedc5('0x30')](db[_0xedc5('0x4a')][_0xedc5('0x2a')]);_0x12b805[_0xedc5('0x2f')]=_[_0xedc5('0x30')](_0x158037['query']);_0x12b805['filters']=_[_0xedc5('0x32')](_0x12b805[_0xedc5('0x2e')],_0x12b805[_0xedc5('0x2f')]);_0x249510[_0xedc5('0x33')]=_[_0xedc5('0x32')](_0x12b805[_0xedc5('0x2e')],qs[_0xedc5('0x34')](_0x158037[_0xedc5('0x2f')][_0xedc5('0x34')]));_0x249510['attributes']=_0x249510[_0xedc5('0x33')][_0xedc5('0x45')]?_0x249510[_0xedc5('0x33')]:_0x12b805[_0xedc5('0x2e')];_0x249510[_0xedc5('0x37')]=qs['sort'](_0x158037['query'][_0xedc5('0x38')]);_0x249510['where']=qs[_0xedc5('0x31')](_['pick'](_0x158037[_0xedc5('0x2f')],_0x12b805['filters']));if(_0x158037['query']['filter']){_0x249510[_0xedc5('0x3a')]=_['merge'](_0x249510[_0xedc5('0x3a')],{'$or':_[_0xedc5('0x29')](_0x249510[_0xedc5('0x33')],function(_0x136f93){var _0x499596={};_0x499596[_0x136f93]={'$like':'%'+_0x158037[_0xedc5('0x2f')][_0xedc5('0x3d')]+'%'};return _0x499596;})});}_0x249510=_[_0xedc5('0x3b')]({},_0x249510,_0x158037[_0xedc5('0x3e')]);return _0x435ee4[_0xedc5('0x4d')](_0x249510);}})[_0xedc5('0x23')](function(_0x47c343){if(_0x47c343){_0x56f586=_0x47c343[_0xedc5('0x45')];if(!_0x158037[_0xedc5('0x2f')][_0xedc5('0x35')](_0xedc5('0x36'))){_0x249510['limit']=qs[_0xedc5('0x1d')](_0x158037[_0xedc5('0x2f')][_0xedc5('0x1d')]);_0x249510['offset']=qs[_0xedc5('0x1c')](_0x158037[_0xedc5('0x2f')][_0xedc5('0x1c')]);}return _0x435ee4['getDescriptions'](_0x249510);}})['then'](function(_0x11e97f){if(_0x11e97f){return _0x11e97f?{'count':_0x56f586,'rows':_0x11e97f}:null;}})[_0xedc5('0x23')](respondWithResult(_0x41820d,null))[_0xedc5('0x42')](handleError(_0x41820d,null));};exports[_0xedc5('0x4e')]=function(_0x2d1009,_0x497156,_0x47b591){var _0x52c898={};var _0x41a9a9={};var _0xafc75e;var _0x55fa8d;return db[_0xedc5('0x3f')][_0xedc5('0x49')]({'where':{'id':_0x2d1009['params']['id']}})[_0xedc5('0x23')](handleEntityNotFound(_0x497156,null))['then'](function(_0x343a3a){if(_0x343a3a){_0xafc75e=_0x343a3a;_0x41a9a9[_0xedc5('0x2e')]=_['keys'](db[_0xedc5('0x4f')]['rawAttributes']);_0x41a9a9['query']=_[_0xedc5('0x30')](_0x2d1009['query']);_0x41a9a9[_0xedc5('0x31')]=_[_0xedc5('0x32')](_0x41a9a9[_0xedc5('0x2e')],_0x41a9a9[_0xedc5('0x2f')]);_0x52c898[_0xedc5('0x33')]=_[_0xedc5('0x32')](_0x41a9a9[_0xedc5('0x2e')],qs[_0xedc5('0x34')](_0x2d1009[_0xedc5('0x2f')]['fields']));_0x52c898['attributes']=_0x52c898[_0xedc5('0x33')][_0xedc5('0x45')]?_0x52c898[_0xedc5('0x33')]:_0x41a9a9['model'];_0x52c898[_0xedc5('0x37')]=qs['sort'](_0x2d1009[_0xedc5('0x2f')][_0xedc5('0x38')]);_0x52c898[_0xedc5('0x3a')]=qs['filters'](_[_0xedc5('0x39')](_0x2d1009[_0xedc5('0x2f')],_0x41a9a9['filters']));if(_0x2d1009[_0xedc5('0x2f')]['filter']){_0x52c898[_0xedc5('0x3a')]=_[_0xedc5('0x3b')](_0x52c898[_0xedc5('0x3a')],{'$or':_['map'](_0x52c898[_0xedc5('0x33')],function(_0x3c0c74){var _0xcfe232={};_0xcfe232[_0x3c0c74]={'$like':'%'+_0x2d1009[_0xedc5('0x2f')][_0xedc5('0x3d')]+'%'};return _0xcfe232;})});}_0x52c898=_['merge']({},_0x52c898,_0x2d1009[_0xedc5('0x3e')]);return _0xafc75e[_0xedc5('0x4e')](_0x52c898);}})[_0xedc5('0x23')](function(_0x4ee244){if(_0x4ee244){_0x55fa8d=_0x4ee244[_0xedc5('0x45')];if(!_0x2d1009['query'][_0xedc5('0x35')](_0xedc5('0x36'))){_0x52c898[_0xedc5('0x1d')]=qs[_0xedc5('0x1d')](_0x2d1009['query']['limit']);_0x52c898[_0xedc5('0x1c')]=qs['offset'](_0x2d1009[_0xedc5('0x2f')][_0xedc5('0x1c')]);}return _0xafc75e['getTags'](_0x52c898);}})['then'](function(_0x3b2930){if(_0x3b2930){return _0x3b2930?{'count':_0x55fa8d,'rows':_0x3b2930}:null;}})['then'](respondWithResult(_0x497156,null))[_0xedc5('0x42')](handleError(_0x497156,null));};exports['setTags']=function(_0x5a01c6,_0xcbaa79,_0xd9b8ef){if(_0x5a01c6[_0xedc5('0x50')]['id']){delete _0x5a01c6[_0xedc5('0x50')]['id'];}return db[_0xedc5('0x3f')][_0xedc5('0x49')]({'where':{'id':_0x5a01c6[_0xedc5('0x44')]['id']}})[_0xedc5('0x23')](handleEntityNotFound(_0xcbaa79,null))[_0xedc5('0x23')](function(_0x59691a){if(_0x59691a){return _0x59691a[_0xedc5('0x51')](_0x5a01c6[_0xedc5('0x50')][_0xedc5('0x52')]||[]);}return null;})[_0xedc5('0x23')](respondWithResult(_0xcbaa79,null))[_0xedc5('0x42')](handleError(_0xcbaa79,null));}; \ No newline at end of file diff --git a/server/api/intZendeskConfiguration/intZendeskConfiguration.model.js b/server/api/intZendeskConfiguration/intZendeskConfiguration.model.js new file mode 100644 index 0000000..c17fad3 --- /dev/null +++ b/server/api/intZendeskConfiguration/intZendeskConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfcbb=['rimraf','../../config/environment','define','ZendeskConfiguration','int_zendesk_configurations','lodash','util','../../config/logger','bluebird','request-promise','path'];(function(_0x565a5f,_0x53eb6a){var _0x103eee=function(_0x260ee1){while(--_0x260ee1){_0x565a5f['push'](_0x565a5f['shift']());}};_0x103eee(++_0x53eb6a);}(_0xfcbb,0x10d));var _0xbfcb=function(_0x312f5a,_0x30bef1){_0x312f5a=_0x312f5a-0x0;var _0x9b06d8=_0xfcbb[_0x312f5a];return _0x9b06d8;};'use strict';var _=require(_0xbfcb('0x0'));var util=require(_0xbfcb('0x1'));var logger=require(_0xbfcb('0x2'))('api');var moment=require('moment');var BPromise=require(_0xbfcb('0x3'));var rp=require(_0xbfcb('0x4'));var fs=require('fs');var path=require(_0xbfcb('0x5'));var rimraf=require(_0xbfcb('0x6'));var config=require(_0xbfcb('0x7'));var attributes=require('./intZendeskConfiguration.attributes');module['exports']=function(_0x32c2aa,_0x4990c){return _0x32c2aa[_0xbfcb('0x8')](_0xbfcb('0x9'),attributes,{'tableName':_0xbfcb('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intZendeskConfiguration/intZendeskConfiguration.rpc.js b/server/api/intZendeskConfiguration/intZendeskConfiguration.rpc.js new file mode 100644 index 0000000..0fc94c6 --- /dev/null +++ b/server/api/intZendeskConfiguration/intZendeskConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4ed4=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','ZendeskConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','ZendeskConfiguration,\x20%s,\x20%s','message','result','catch','lodash','moment','bluebird','../../mysqldb'];(function(_0x1b976b,_0x1e8f55){var _0x1b0b87=function(_0x27612a){while(--_0x27612a){_0x1b976b['push'](_0x1b976b['shift']());}};_0x1b0b87(++_0x1e8f55);}(_0x4ed4,0x155));var _0x44ed=function(_0x907d59,_0x2a23fa){_0x907d59=_0x907d59-0x0;var _0x51355d=_0x4ed4[_0x907d59];return _0x51355d;};'use strict';var _=require(_0x44ed('0x0'));var util=require('util');var moment=require(_0x44ed('0x1'));var BPromise=require(_0x44ed('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x44ed('0x3'))['db'];var utils=require(_0x44ed('0x4'));var logger=require(_0x44ed('0x5'))(_0x44ed('0x6'));var config=require(_0x44ed('0x7'));var jayson=require(_0x44ed('0x8'));var client=jayson[_0x44ed('0x9')][_0x44ed('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x25b809,_0x33e208,_0x8deedd){return new BPromise(function(_0x54e89c,_0x3ad815){return client[_0x44ed('0xb')](_0x25b809,_0x8deedd)[_0x44ed('0xc')](function(_0x29a875){logger['info']('ZendeskConfiguration,\x20%s,\x20%s',_0x33e208,_0x44ed('0xd'));logger[_0x44ed('0xe')](_0x44ed('0xf'),_0x33e208,_0x44ed('0xd'),JSON[_0x44ed('0x10')](_0x29a875));if(_0x29a875[_0x44ed('0x11')]){if(_0x29a875[_0x44ed('0x11')][_0x44ed('0x12')]===0x1f4){logger['error'](_0x44ed('0x13'),_0x33e208,_0x29a875[_0x44ed('0x11')][_0x44ed('0x14')]);return _0x3ad815(_0x29a875[_0x44ed('0x11')]['message']);}logger[_0x44ed('0x11')](_0x44ed('0x13'),_0x33e208,_0x29a875[_0x44ed('0x11')][_0x44ed('0x14')]);return _0x54e89c(_0x29a875[_0x44ed('0x11')][_0x44ed('0x14')]);}else{logger['info'](_0x44ed('0x13'),_0x33e208,_0x44ed('0xd'));_0x54e89c(_0x29a875[_0x44ed('0x15')][_0x44ed('0x14')]);}})[_0x44ed('0x16')](function(_0x80683d){logger['error'](_0x44ed('0x13'),_0x33e208,_0x80683d);_0x3ad815(_0x80683d);});});} \ No newline at end of file diff --git a/server/api/intZendeskField/index.js b/server/api/intZendeskField/index.js new file mode 100644 index 0000000..2d000ee --- /dev/null +++ b/server/api/intZendeskField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb78e=['index','/:id','show','post','create','put','update','delete','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./intZendeskField.controller','get','isAuthenticated'];(function(_0x43eec,_0x5878eb){var _0x94b62b=function(_0x4c878f){while(--_0x4c878f){_0x43eec['push'](_0x43eec['shift']());}};_0x94b62b(++_0x5878eb);}(_0xb78e,0xd9));var _0xeb78=function(_0x4ddc33,_0x48a1ce){_0x4ddc33=_0x4ddc33-0x0;var _0x52a177=_0xb78e[_0x4ddc33];return _0x52a177;};'use strict';var multer=require(_0xeb78('0x0'));var util=require(_0xeb78('0x1'));var path=require(_0xeb78('0x2'));var timeout=require(_0xeb78('0x3'));var express=require(_0xeb78('0x4'));var router=express[_0xeb78('0x5')]();var fs_extra=require(_0xeb78('0x6'));var auth=require(_0xeb78('0x7'));var interaction=require(_0xeb78('0x8'));var config=require(_0xeb78('0x9'));var controller=require(_0xeb78('0xa'));router[_0xeb78('0xb')]('/',auth[_0xeb78('0xc')](),controller[_0xeb78('0xd')]);router[_0xeb78('0xb')](_0xeb78('0xe'),auth[_0xeb78('0xc')](),controller[_0xeb78('0xf')]);router[_0xeb78('0x10')]('/',auth['isAuthenticated'](),controller[_0xeb78('0x11')]);router[_0xeb78('0x12')](_0xeb78('0xe'),auth[_0xeb78('0xc')](),controller[_0xeb78('0x13')]);router[_0xeb78('0x14')](_0xeb78('0xe'),auth[_0xeb78('0xc')](),controller[_0xeb78('0x15')]);module[_0xeb78('0x16')]=router; \ No newline at end of file diff --git a/server/api/intZendeskField/intZendeskField.attributes.js b/server/api/intZendeskField/intZendeskField.attributes.js new file mode 100644 index 0000000..6893520 --- /dev/null +++ b/server/api/intZendeskField/intZendeskField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x23a5=['customVariable','keyValue','picklist','STRING','ENUM','variable','BOOLEAN','exports','string'];(function(_0x41ef02,_0x101e1a){var _0x5e6995=function(_0x124fdd){while(--_0x124fdd){_0x41ef02['push'](_0x41ef02['shift']());}};_0x5e6995(++_0x101e1a);}(_0x23a5,0x181));var _0x523a=function(_0x3e7f40,_0x49389b){_0x3e7f40=_0x3e7f40-0x0;var _0x9a9a1f=_0x23a5[_0x3e7f40];return _0x9a9a1f;};'use strict';var Sequelize=require('sequelize');module[_0x523a('0x0')]={'type':{'type':Sequelize['ENUM'](_0x523a('0x1'),'variable',_0x523a('0x2'),_0x523a('0x3'),_0x523a('0x4')),'defaultValue':_0x523a('0x1')},'content':{'type':Sequelize['STRING']},'key':{'type':Sequelize[_0x523a('0x5')]},'keyType':{'type':Sequelize[_0x523a('0x6')](_0x523a('0x1'),_0x523a('0x7'),_0x523a('0x2'))},'keyContent':{'type':Sequelize[_0x523a('0x5')]},'idField':{'type':Sequelize[_0x523a('0x5')]},'nameField':{'type':Sequelize[_0x523a('0x5')]},'customField':{'type':Sequelize[_0x523a('0x8')],'defaultValue':!![]},'variableName':{'type':Sequelize[_0x523a('0x5')]}}; \ No newline at end of file diff --git a/server/api/intZendeskField/intZendeskField.controller.js b/server/api/intZendeskField/intZendeskField.controller.js new file mode 100644 index 0000000..9b5f748 --- /dev/null +++ b/server/api/intZendeskField/intZendeskField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e4d=['../../config/utils','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','ZendeskField','findAll','params','keys','length','find','catch','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api'];(function(_0x4b38b7,_0x50afcd){var _0x115c6b=function(_0x52cfa5){while(--_0x52cfa5){_0x4b38b7['push'](_0x4b38b7['shift']());}};_0x115c6b(++_0x50afcd);}(_0x4e4d,0xd7));var _0xd4e4=function(_0x5416db,_0x55683a){_0x5416db=_0x5416db-0x0;var _0x243e35=_0x4e4d[_0x5416db];return _0x243e35;};'use strict';var emlformat=require(_0xd4e4('0x0'));var rimraf=require(_0xd4e4('0x1'));var zipdir=require(_0xd4e4('0x2'));var jsonpatch=require(_0xd4e4('0x3'));var rp=require(_0xd4e4('0x4'));var moment=require(_0xd4e4('0x5'));var BPromise=require(_0xd4e4('0x6'));var Mustache=require(_0xd4e4('0x7'));var util=require(_0xd4e4('0x8'));var path=require(_0xd4e4('0x9'));var sox=require(_0xd4e4('0xa'));var csv=require('to-csv');var ejs=require(_0xd4e4('0xb'));var fs=require('fs');var fs_extra=require(_0xd4e4('0xc'));var _=require('lodash');var squel=require(_0xd4e4('0xd'));var crypto=require(_0xd4e4('0xe'));var jsforce=require(_0xd4e4('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xd4e4('0x10'));var Papa=require(_0xd4e4('0x11'));var Redis=require(_0xd4e4('0x12'));var authService=require(_0xd4e4('0x13'));var qs=require(_0xd4e4('0x14'));var as=require(_0xd4e4('0x15'));var hardwareService=require(_0xd4e4('0x16'));var logger=require(_0xd4e4('0x17'))(_0xd4e4('0x18'));var utils=require(_0xd4e4('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0xd4e4('0x1a'));var db=require(_0xd4e4('0x1b'))['db'];function respondWithStatusCode(_0x1f6c99,_0x3961b7){_0x3961b7=_0x3961b7||0xcc;return function(_0x4de538){if(_0x4de538){return _0x1f6c99['sendStatus'](_0x3961b7);}return _0x1f6c99[_0xd4e4('0x1c')](_0x3961b7)[_0xd4e4('0x1d')]();};}function respondWithResult(_0x594124,_0x504038){_0x504038=_0x504038||0xc8;return function(_0x5761c2){if(_0x5761c2){return _0x594124[_0xd4e4('0x1c')](_0x504038)[_0xd4e4('0x1e')](_0x5761c2);}};}function respondWithFilteredResult(_0x5097d9,_0x1efac0){return function(_0x232b38){if(_0x232b38){var _0x2af259=typeof _0x1efac0[_0xd4e4('0x1f')]===_0xd4e4('0x20')&&typeof _0x1efac0['limit']===_0xd4e4('0x20');var _0x57a242=_0x232b38[_0xd4e4('0x21')];var _0x4ed0e4=_0x2af259?0x0:_0x1efac0[_0xd4e4('0x1f')];var _0x1413fc=_0x2af259?_0x232b38[_0xd4e4('0x21')]:_0x1efac0[_0xd4e4('0x1f')]+_0x1efac0[_0xd4e4('0x22')];var _0x4a52f9;if(_0x1413fc>=_0x57a242){_0x1413fc=_0x57a242;_0x4a52f9=0xc8;}else{_0x4a52f9=0xce;}_0x5097d9[_0xd4e4('0x1c')](_0x4a52f9);return _0x5097d9[_0xd4e4('0x23')](_0xd4e4('0x24'),_0x4ed0e4+'-'+_0x1413fc+'/'+_0x57a242)[_0xd4e4('0x1e')](_0x232b38);}return null;};}function patchUpdates(_0x55b327){return function(_0x591be6){try{jsonpatch[_0xd4e4('0x25')](_0x591be6,_0x55b327,!![]);}catch(_0x35bafb){return BPromise[_0xd4e4('0x26')](_0x35bafb);}return _0x591be6[_0xd4e4('0x27')]();};}function saveUpdates(_0x5edcf9,_0x4cc0ff){return function(_0xd3560d){if(_0xd3560d){return _0xd3560d[_0xd4e4('0x28')](_0x5edcf9)[_0xd4e4('0x29')](function(_0x4ebb0d){return _0x4ebb0d;});}return null;};}function removeEntity(_0x245879,_0x2ecaf9){return function(_0x51672d){if(_0x51672d){return _0x51672d[_0xd4e4('0x2a')]()[_0xd4e4('0x29')](function(){_0x245879[_0xd4e4('0x1c')](0xcc)[_0xd4e4('0x1d')]();});}};}function handleEntityNotFound(_0x436d20,_0x47914a){return function(_0x2a1ab0){if(!_0x2a1ab0){_0x436d20[_0xd4e4('0x2b')](0x194);}return _0x2a1ab0;};}function handleError(_0x34abbc,_0x155444){_0x155444=_0x155444||0x1f4;return function(_0x31cca7){logger['error'](_0x31cca7[_0xd4e4('0x2c')]);if(_0x31cca7['name']){delete _0x31cca7[_0xd4e4('0x2d')];}_0x34abbc[_0xd4e4('0x1c')](_0x155444)[_0xd4e4('0x2e')](_0x31cca7);};}exports[_0xd4e4('0x2f')]=function(_0x21acab,_0x1bf9e5){var _0xc59ca7={},_0x318f0b={},_0x147f9a={'count':0x0,'rows':[]};var _0x54e45d=_[_0xd4e4('0x30')](db['ZendeskField'][_0xd4e4('0x31')],function(_0x529886){return{'name':_0x529886[_0xd4e4('0x32')],'type':_0x529886[_0xd4e4('0x33')][_0xd4e4('0x34')]};});_0x318f0b[_0xd4e4('0x35')]=_[_0xd4e4('0x30')](_0x54e45d,_0xd4e4('0x2d'));_0x318f0b[_0xd4e4('0x36')]=_['keys'](_0x21acab['query']);_0x318f0b[_0xd4e4('0x37')]=_[_0xd4e4('0x38')](_0x318f0b['model'],_0x318f0b[_0xd4e4('0x36')]);_0xc59ca7[_0xd4e4('0x39')]=_[_0xd4e4('0x38')](_0x318f0b['model'],qs[_0xd4e4('0x3a')](_0x21acab[_0xd4e4('0x36')]['fields']));_0xc59ca7[_0xd4e4('0x39')]=_0xc59ca7[_0xd4e4('0x39')]['length']?_0xc59ca7[_0xd4e4('0x39')]:_0x318f0b[_0xd4e4('0x35')];if(!_0x21acab['query'][_0xd4e4('0x3b')](_0xd4e4('0x3c'))){_0xc59ca7[_0xd4e4('0x22')]=qs[_0xd4e4('0x22')](_0x21acab['query'][_0xd4e4('0x22')]);_0xc59ca7[_0xd4e4('0x1f')]=qs[_0xd4e4('0x1f')](_0x21acab[_0xd4e4('0x36')][_0xd4e4('0x1f')]);}_0xc59ca7[_0xd4e4('0x3d')]=qs[_0xd4e4('0x3e')](_0x21acab[_0xd4e4('0x36')][_0xd4e4('0x3e')]);_0xc59ca7[_0xd4e4('0x3f')]=qs['filters'](_[_0xd4e4('0x40')](_0x21acab[_0xd4e4('0x36')],_0x318f0b[_0xd4e4('0x37')]),_0x54e45d);if(_0x21acab[_0xd4e4('0x36')][_0xd4e4('0x41')]){_0xc59ca7[_0xd4e4('0x3f')]=_[_0xd4e4('0x42')](_0xc59ca7[_0xd4e4('0x3f')],{'$or':_[_0xd4e4('0x30')](_0x54e45d,function(_0x17243a){if(_0x17243a['type']!==_0xd4e4('0x43')){var _0x51bbc5={};_0x51bbc5[_0x17243a[_0xd4e4('0x2d')]]={'$like':'%'+_0x21acab[_0xd4e4('0x36')][_0xd4e4('0x41')]+'%'};return _0x51bbc5;}})});}_0xc59ca7=_[_0xd4e4('0x42')]({},_0xc59ca7,_0x21acab[_0xd4e4('0x44')]);var _0x111728={'where':_0xc59ca7[_0xd4e4('0x3f')]};return db['ZendeskField'][_0xd4e4('0x21')](_0x111728)[_0xd4e4('0x29')](function(_0x33df69){_0x147f9a['count']=_0x33df69;if(_0x21acab[_0xd4e4('0x36')][_0xd4e4('0x45')]){_0xc59ca7[_0xd4e4('0x46')]=[{'all':!![]}];}return db[_0xd4e4('0x47')][_0xd4e4('0x48')](_0xc59ca7);})[_0xd4e4('0x29')](function(_0x473fcf){_0x147f9a['rows']=_0x473fcf;return _0x147f9a;})[_0xd4e4('0x29')](respondWithFilteredResult(_0x1bf9e5,_0xc59ca7))['catch'](handleError(_0x1bf9e5,null));};exports['show']=function(_0x24276e,_0x430813){var _0x3ca37b={'raw':!![],'where':{'id':_0x24276e[_0xd4e4('0x49')]['id']}},_0x25dbf5={};_0x25dbf5[_0xd4e4('0x35')]=_[_0xd4e4('0x4a')](db[_0xd4e4('0x47')]['rawAttributes']);_0x25dbf5['query']=_[_0xd4e4('0x4a')](_0x24276e[_0xd4e4('0x36')]);_0x25dbf5[_0xd4e4('0x37')]=_['intersection'](_0x25dbf5['model'],_0x25dbf5[_0xd4e4('0x36')]);_0x3ca37b[_0xd4e4('0x39')]=_[_0xd4e4('0x38')](_0x25dbf5[_0xd4e4('0x35')],qs[_0xd4e4('0x3a')](_0x24276e[_0xd4e4('0x36')]['fields']));_0x3ca37b[_0xd4e4('0x39')]=_0x3ca37b[_0xd4e4('0x39')][_0xd4e4('0x4b')]?_0x3ca37b[_0xd4e4('0x39')]:_0x25dbf5[_0xd4e4('0x35')];if(_0x24276e[_0xd4e4('0x36')][_0xd4e4('0x45')]){_0x3ca37b[_0xd4e4('0x46')]=[{'all':!![]}];}_0x3ca37b=_['merge']({},_0x3ca37b,_0x24276e['options']);return db['ZendeskField'][_0xd4e4('0x4c')](_0x3ca37b)['then'](handleEntityNotFound(_0x430813,null))[_0xd4e4('0x29')](respondWithResult(_0x430813,null))[_0xd4e4('0x4d')](handleError(_0x430813,null));};exports[_0xd4e4('0x4e')]=function(_0xa0c7b3,_0x48abb0){return db['ZendeskField']['create'](_0xa0c7b3['body'],{})[_0xd4e4('0x29')](respondWithResult(_0x48abb0,0xc9))[_0xd4e4('0x4d')](handleError(_0x48abb0,null));};exports[_0xd4e4('0x28')]=function(_0x26fe76,_0x37440a){if(_0x26fe76[_0xd4e4('0x4f')]['id']){delete _0x26fe76['body']['id'];}return db[_0xd4e4('0x47')][_0xd4e4('0x4c')]({'where':{'id':_0x26fe76[_0xd4e4('0x49')]['id']}})['then'](handleEntityNotFound(_0x37440a,null))[_0xd4e4('0x29')](saveUpdates(_0x26fe76[_0xd4e4('0x4f')],null))[_0xd4e4('0x29')](respondWithResult(_0x37440a,null))[_0xd4e4('0x4d')](handleError(_0x37440a,null));};exports[_0xd4e4('0x2a')]=function(_0x30822e,_0x56eb5f){return db[_0xd4e4('0x47')]['find']({'where':{'id':_0x30822e[_0xd4e4('0x49')]['id']}})[_0xd4e4('0x29')](handleEntityNotFound(_0x56eb5f,null))[_0xd4e4('0x29')](removeEntity(_0x56eb5f,null))[_0xd4e4('0x4d')](handleError(_0x56eb5f,null));}; \ No newline at end of file diff --git a/server/api/intZendeskField/intZendeskField.model.js b/server/api/intZendeskField/intZendeskField.model.js new file mode 100644 index 0000000..123bcb0 --- /dev/null +++ b/server/api/intZendeskField/intZendeskField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf548=['define','int_zendesk_fields','zendesk_unique_index','idField','FieldId','lodash','util','api','moment','bluebird','request-promise','../../config/environment','./intZendeskField.attributes'];(function(_0xa2f3a7,_0x2ee243){var _0x10d91f=function(_0x405a00){while(--_0x405a00){_0xa2f3a7['push'](_0xa2f3a7['shift']());}};_0x10d91f(++_0x2ee243);}(_0xf548,0x116));var _0x8f54=function(_0x1fd675,_0x165dfe){_0x1fd675=_0x1fd675-0x0;var _0x16b554=_0xf548[_0x1fd675];return _0x16b554;};'use strict';var _=require(_0x8f54('0x0'));var util=require(_0x8f54('0x1'));var logger=require('../../config/logger')(_0x8f54('0x2'));var moment=require(_0x8f54('0x3'));var BPromise=require(_0x8f54('0x4'));var rp=require(_0x8f54('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x8f54('0x6'));var attributes=require(_0x8f54('0x7'));module['exports']=function(_0x195b8c,_0x51bfeb){return _0x195b8c[_0x8f54('0x8')]('ZendeskField',attributes,{'tableName':_0x8f54('0x9'),'paranoid':![],'indexes':[{'name':_0x8f54('0xa'),'fields':[_0x8f54('0xb'),_0x8f54('0xc')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intZendeskField/intZendeskField.rpc.js b/server/api/intZendeskField/intZendeskField.rpc.js new file mode 100644 index 0000000..220f813 --- /dev/null +++ b/server/api/intZendeskField/intZendeskField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8f65=['error','message','result','catch','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ZendeskField,\x20%s,\x20%s','request\x20sent','debug','stringify'];(function(_0x4b99f0,_0x419040){var _0x29d886=function(_0x398626){while(--_0x398626){_0x4b99f0['push'](_0x4b99f0['shift']());}};_0x29d886(++_0x419040);}(_0x8f65,0x77));var _0x58f6=function(_0x1cbce7,_0x3e67f5){_0x1cbce7=_0x1cbce7-0x0;var _0x18aaae=_0x8f65[_0x1cbce7];return _0x18aaae;};'use strict';var _=require(_0x58f6('0x0'));var util=require('util');var moment=require(_0x58f6('0x1'));var BPromise=require(_0x58f6('0x2'));var rs=require(_0x58f6('0x3'));var fs=require('fs');var Redis=require(_0x58f6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x58f6('0x5'));var logger=require(_0x58f6('0x6'))(_0x58f6('0x7'));var config=require(_0x58f6('0x8'));var jayson=require(_0x58f6('0x9'));var client=jayson[_0x58f6('0xa')][_0x58f6('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3c83c1,_0x56a836,_0x4590d7){return new BPromise(function(_0x257c2f,_0x351e4e){return client[_0x58f6('0xc')](_0x3c83c1,_0x4590d7)[_0x58f6('0xd')](function(_0x4fc129){logger[_0x58f6('0xe')](_0x58f6('0xf'),_0x56a836,_0x58f6('0x10'));logger[_0x58f6('0x11')]('ZendeskField,\x20%s,\x20%s,\x20%s',_0x56a836,_0x58f6('0x10'),JSON[_0x58f6('0x12')](_0x4fc129));if(_0x4fc129[_0x58f6('0x13')]){if(_0x4fc129[_0x58f6('0x13')]['code']===0x1f4){logger['error'](_0x58f6('0xf'),_0x56a836,_0x4fc129[_0x58f6('0x13')][_0x58f6('0x14')]);return _0x351e4e(_0x4fc129[_0x58f6('0x13')]['message']);}logger[_0x58f6('0x13')](_0x58f6('0xf'),_0x56a836,_0x4fc129[_0x58f6('0x13')]['message']);return _0x257c2f(_0x4fc129[_0x58f6('0x13')][_0x58f6('0x14')]);}else{logger[_0x58f6('0xe')](_0x58f6('0xf'),_0x56a836,_0x58f6('0x10'));_0x257c2f(_0x4fc129[_0x58f6('0x15')][_0x58f6('0x14')]);}})[_0x58f6('0x16')](function(_0x5c98bb){logger[_0x58f6('0x13')](_0x58f6('0xf'),_0x56a836,_0x5c98bb);_0x351e4e(_0x5c98bb);});});} \ No newline at end of file diff --git a/server/api/intZohoAccount/index.js b/server/api/intZohoAccount/index.js new file mode 100644 index 0000000..6de76f2 --- /dev/null +++ b/server/api/intZohoAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4550=['path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','index','/:id','isAuthenticated','show','getFields','post','create','/:id/configurations','addConfiguration','put','update','delete','util'];(function(_0x22ee0f,_0x22e6d2){var _0x204696=function(_0x4cab38){while(--_0x4cab38){_0x22ee0f['push'](_0x22ee0f['shift']());}};_0x204696(++_0x22e6d2);}(_0x4550,0x92));var _0x0455=function(_0x5a15b1,_0x202388){_0x5a15b1=_0x5a15b1-0x0;var _0x4c2df7=_0x4550[_0x5a15b1];return _0x4c2df7;};'use strict';var multer=require('multer');var util=require(_0x0455('0x0'));var path=require(_0x0455('0x1'));var timeout=require(_0x0455('0x2'));var express=require('express');var router=express[_0x0455('0x3')]();var fs_extra=require(_0x0455('0x4'));var auth=require(_0x0455('0x5'));var interaction=require(_0x0455('0x6'));var config=require(_0x0455('0x7'));var controller=require('./intZohoAccount.controller');router[_0x0455('0x8')]('/',auth['isAuthenticated'](),controller[_0x0455('0x9')]);router[_0x0455('0x8')](_0x0455('0xa'),auth[_0x0455('0xb')](),controller[_0x0455('0xc')]);router[_0x0455('0x8')]('/:id/configurations',auth[_0x0455('0xb')](),controller['getConfigurations']);router[_0x0455('0x8')]('/:id/fields',auth[_0x0455('0xb')](),controller[_0x0455('0xd')]);router[_0x0455('0xe')]('/',auth[_0x0455('0xb')](),controller[_0x0455('0xf')]);router[_0x0455('0xe')](_0x0455('0x10'),auth['isAuthenticated'](),controller[_0x0455('0x11')]);router[_0x0455('0x12')](_0x0455('0xa'),auth['isAuthenticated'](),controller[_0x0455('0x13')]);router[_0x0455('0x14')]('/:id',auth[_0x0455('0xb')](),controller['destroy']);module['exports']=router; \ No newline at end of file diff --git a/server/api/intZohoAccount/intZohoAccount.attributes.js b/server/api/intZohoAccount/intZohoAccount.attributes.js new file mode 100644 index 0000000..d9b3b5e --- /dev/null +++ b/server/api/intZohoAccount/intZohoAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd64b=['STRING','sequelize'];(function(_0x354fa4,_0x30e267){var _0x1aa414=function(_0xb38eaa){while(--_0xb38eaa){_0x354fa4['push'](_0x354fa4['shift']());}};_0x1aa414(++_0x30e267);}(_0xd64b,0xc1));var _0xbd64=function(_0x323021,_0x30f030){_0x323021=_0x323021-0x0;var _0x52cb3e=_0xd64b[_0x323021];return _0x52cb3e;};'use strict';var Sequelize=require(_0xbd64('0x0'));module['exports']={'name':{'type':Sequelize[_0xbd64('0x1')]},'description':{'type':Sequelize['STRING']},'host':{'type':Sequelize[_0xbd64('0x1')]},'zone':{'type':Sequelize[_0xbd64('0x1')]},'clientId':{'type':Sequelize[_0xbd64('0x1')]},'clientSecret':{'type':Sequelize[_0xbd64('0x1')]},'serverUrl':{'type':Sequelize[_0xbd64('0x1')],'allowNull':![]},'code':{'type':Sequelize['STRING']},'refreshToken':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/intZohoAccount/intZohoAccount.controller.js b/server/api/intZohoAccount/intZohoAccount.controller.js new file mode 100644 index 0000000..68d0c93 --- /dev/null +++ b/server/api/intZohoAccount/intZohoAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf2e4=['Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','destroy','then','error','send','map','ZohoAccount','rawAttributes','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','type','name','merge','rows','catch','show','keys','includeAll','options','find','create','body','params','findOne','ZohoConfiguration','getConfigurations','nolimit','addConfiguration','AccountId','Subjects','channel','getDescriptions','ZohoField','Descriptions','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.eu','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','/oauth/v2/token','clientId','clientSecret','refresh_token','access_token','Unable\x20to\x20retrieve\x20the\x20access\x20token','getFields','host','serverUrl','code','refreshToken','zoho.eu','com','substring','lastIndexOf','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','GET','format','Calls','Zoho-oauthtoken\x20','response','message','Owner','Subject','Description','WhoId','Call_Duration','Call_Result','Call_Type','remove','includes','api_name','system_mandatory','display_label','data_type','pick_list_values','stringify','test'];(function(_0x4ee2de,_0x4374d5){var _0x4148f5=function(_0x60b9ba){while(--_0x60b9ba){_0x4ee2de['push'](_0x4ee2de['shift']());}};_0x4148f5(++_0x4374d5);}(_0xf2e4,0x10c));var _0x4f2e=function(_0x4d2eb7,_0x45e672){_0x4d2eb7=_0x4d2eb7-0x0;var _0x56b032=_0xf2e4[_0x4d2eb7];return _0x56b032;};'use strict';var emlformat=require(_0x4f2e('0x0'));var rimraf=require(_0x4f2e('0x1'));var zipdir=require(_0x4f2e('0x2'));var jsonpatch=require(_0x4f2e('0x3'));var rp=require(_0x4f2e('0x4'));var moment=require(_0x4f2e('0x5'));var BPromise=require(_0x4f2e('0x6'));var Mustache=require(_0x4f2e('0x7'));var util=require(_0x4f2e('0x8'));var path=require(_0x4f2e('0x9'));var sox=require('sox');var csv=require(_0x4f2e('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4f2e('0xb'));var _=require('lodash');var squel=require(_0x4f2e('0xc'));var crypto=require('crypto');var jsforce=require(_0x4f2e('0xd'));var deskjs=require(_0x4f2e('0xe'));var toCsv=require(_0x4f2e('0xa'));var querystring=require(_0x4f2e('0xf'));var Papa=require(_0x4f2e('0x10'));var Redis=require('ioredis');var authService=require(_0x4f2e('0x11'));var qs=require(_0x4f2e('0x12'));var as=require(_0x4f2e('0x13'));var hardwareService=require(_0x4f2e('0x14'));var logger=require(_0x4f2e('0x15'))(_0x4f2e('0x16'));var utils=require(_0x4f2e('0x17'));var config=require(_0x4f2e('0x18'));var licenseUtil=require(_0x4f2e('0x19'));var db=require(_0x4f2e('0x1a'))['db'];var integrations=require(_0x4f2e('0x1b'));function respondWithStatusCode(_0x279b9d,_0x32388a){_0x32388a=_0x32388a||0xcc;return function(_0x64f1e1){if(_0x64f1e1){return _0x279b9d[_0x4f2e('0x1c')](_0x32388a);}return _0x279b9d[_0x4f2e('0x1d')](_0x32388a)[_0x4f2e('0x1e')]();};}function respondWithResult(_0x2ff6e1,_0x511452){_0x511452=_0x511452||0xc8;return function(_0x37b172){if(_0x37b172){return _0x2ff6e1[_0x4f2e('0x1d')](_0x511452)[_0x4f2e('0x1f')](_0x37b172);}};}function respondWithFilteredResult(_0x217c8a,_0x2c3e95){return function(_0x3d9976){if(_0x3d9976){var _0x424078=typeof _0x2c3e95[_0x4f2e('0x20')]===_0x4f2e('0x21')&&typeof _0x2c3e95[_0x4f2e('0x22')]===_0x4f2e('0x21');var _0x5d24ac=_0x3d9976[_0x4f2e('0x23')];var _0x15f1ba=_0x424078?0x0:_0x2c3e95[_0x4f2e('0x20')];var _0x39708f=_0x424078?_0x3d9976['count']:_0x2c3e95[_0x4f2e('0x20')]+_0x2c3e95[_0x4f2e('0x22')];var _0xd2bc0;if(_0x39708f>=_0x5d24ac){_0x39708f=_0x5d24ac;_0xd2bc0=0xc8;}else{_0xd2bc0=0xce;}_0x217c8a[_0x4f2e('0x1d')](_0xd2bc0);return _0x217c8a[_0x4f2e('0x24')](_0x4f2e('0x25'),_0x15f1ba+'-'+_0x39708f+'/'+_0x5d24ac)['json'](_0x3d9976);}return null;};}function patchUpdates(_0x5c1b77){return function(_0x5301c7){try{jsonpatch[_0x4f2e('0x26')](_0x5301c7,_0x5c1b77,!![]);}catch(_0x823b04){return BPromise['reject'](_0x823b04);}return _0x5301c7[_0x4f2e('0x27')]();};}function saveUpdates(_0x175afb,_0x55ade4){return function(_0x40b701){if(_0x40b701){return _0x40b701[_0x4f2e('0x28')](_0x175afb)['then'](function(_0x40d868){return _0x40d868;});}return null;};}function removeEntity(_0x21f6f2,_0x3107ca){return function(_0x48d5f7){if(_0x48d5f7){return _0x48d5f7[_0x4f2e('0x29')]()[_0x4f2e('0x2a')](function(){_0x21f6f2[_0x4f2e('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x9a726f,_0x50bd38){return function(_0x10e05e){if(!_0x10e05e){_0x9a726f[_0x4f2e('0x1c')](0x194);}return _0x10e05e;};}function handleError(_0x1bbc05,_0x28a41a){_0x28a41a=_0x28a41a||0x1f4;return function(_0x30de6f){logger[_0x4f2e('0x2b')](_0x30de6f['stack']);if(_0x30de6f['name']){delete _0x30de6f['name'];}_0x1bbc05[_0x4f2e('0x1d')](_0x28a41a)[_0x4f2e('0x2c')](_0x30de6f);};}exports['index']=function(_0x6a358b,_0x481621){var _0x53866d={},_0x38eb15={},_0x48cfb7={'count':0x0,'rows':[]};var _0x1593e6=_[_0x4f2e('0x2d')](db[_0x4f2e('0x2e')][_0x4f2e('0x2f')],function(_0x1902dd){return{'name':_0x1902dd['fieldName'],'type':_0x1902dd['type'][_0x4f2e('0x30')]};});_0x38eb15[_0x4f2e('0x31')]=_[_0x4f2e('0x2d')](_0x1593e6,'name');_0x38eb15['query']=_['keys'](_0x6a358b[_0x4f2e('0x32')]);_0x38eb15[_0x4f2e('0x33')]=_[_0x4f2e('0x34')](_0x38eb15[_0x4f2e('0x31')],_0x38eb15['query']);_0x53866d[_0x4f2e('0x35')]=_['intersection'](_0x38eb15[_0x4f2e('0x31')],qs[_0x4f2e('0x36')](_0x6a358b['query']['fields']));_0x53866d[_0x4f2e('0x35')]=_0x53866d[_0x4f2e('0x35')][_0x4f2e('0x37')]?_0x53866d['attributes']:_0x38eb15[_0x4f2e('0x31')];if(!_0x6a358b['query'][_0x4f2e('0x38')]('nolimit')){_0x53866d['limit']=qs[_0x4f2e('0x22')](_0x6a358b['query'][_0x4f2e('0x22')]);_0x53866d[_0x4f2e('0x20')]=qs[_0x4f2e('0x20')](_0x6a358b[_0x4f2e('0x32')][_0x4f2e('0x20')]);}_0x53866d[_0x4f2e('0x39')]=qs[_0x4f2e('0x3a')](_0x6a358b['query'][_0x4f2e('0x3a')]);_0x53866d[_0x4f2e('0x3b')]=qs[_0x4f2e('0x33')](_[_0x4f2e('0x3c')](_0x6a358b[_0x4f2e('0x32')],_0x38eb15['filters']),_0x1593e6);if(_0x6a358b[_0x4f2e('0x32')][_0x4f2e('0x3d')]){_0x53866d[_0x4f2e('0x3b')]=_['merge'](_0x53866d['where'],{'$or':_['map'](_0x1593e6,function(_0x159103){if(_0x159103[_0x4f2e('0x3e')]!=='VIRTUAL'){var _0x40aeff={};_0x40aeff[_0x159103[_0x4f2e('0x3f')]]={'$like':'%'+_0x6a358b[_0x4f2e('0x32')]['filter']+'%'};return _0x40aeff;}})});}_0x53866d=_[_0x4f2e('0x40')]({},_0x53866d,_0x6a358b['options']);var _0x1b88e9={'where':_0x53866d[_0x4f2e('0x3b')]};return db['ZohoAccount'][_0x4f2e('0x23')](_0x1b88e9)['then'](function(_0x362259){_0x48cfb7[_0x4f2e('0x23')]=_0x362259;if(_0x6a358b[_0x4f2e('0x32')]['includeAll']){_0x53866d['include']=[{'all':!![]}];}return db[_0x4f2e('0x2e')]['findAll'](_0x53866d);})[_0x4f2e('0x2a')](function(_0x2aa9c7){_0x48cfb7[_0x4f2e('0x41')]=_0x2aa9c7;return _0x48cfb7;})['then'](respondWithFilteredResult(_0x481621,_0x53866d))[_0x4f2e('0x42')](handleError(_0x481621,null));};exports[_0x4f2e('0x43')]=function(_0x515e43,_0x1a0dca){var _0x2ce446={'raw':![],'where':{'id':_0x515e43['params']['id']}},_0x1836a9={};_0x1836a9['model']=_[_0x4f2e('0x44')](db[_0x4f2e('0x2e')][_0x4f2e('0x2f')]);_0x1836a9[_0x4f2e('0x32')]=_[_0x4f2e('0x44')](_0x515e43[_0x4f2e('0x32')]);_0x1836a9[_0x4f2e('0x33')]=_[_0x4f2e('0x34')](_0x1836a9[_0x4f2e('0x31')],_0x1836a9[_0x4f2e('0x32')]);_0x2ce446[_0x4f2e('0x35')]=_[_0x4f2e('0x34')](_0x1836a9['model'],qs[_0x4f2e('0x36')](_0x515e43[_0x4f2e('0x32')][_0x4f2e('0x36')]));_0x2ce446['attributes']=_0x2ce446[_0x4f2e('0x35')]['length']?_0x2ce446[_0x4f2e('0x35')]:_0x1836a9[_0x4f2e('0x31')];if(_0x515e43['query'][_0x4f2e('0x45')]){_0x2ce446['include']=[{'all':!![]}];}_0x2ce446=_[_0x4f2e('0x40')]({},_0x2ce446,_0x515e43[_0x4f2e('0x46')]);return db['ZohoAccount'][_0x4f2e('0x47')](_0x2ce446)['then'](handleEntityNotFound(_0x1a0dca,null))['then'](respondWithResult(_0x1a0dca,null))[_0x4f2e('0x42')](handleError(_0x1a0dca,null));};exports['create']=function(_0x3656b3,_0x904f88){return db['ZohoAccount'][_0x4f2e('0x48')](_0x3656b3[_0x4f2e('0x49')],{})[_0x4f2e('0x2a')](respondWithResult(_0x904f88,0xc9))[_0x4f2e('0x42')](handleError(_0x904f88,null));};exports[_0x4f2e('0x28')]=function(_0x3c610d,_0x96caed){if(_0x3c610d[_0x4f2e('0x49')]['id']){delete _0x3c610d[_0x4f2e('0x49')]['id'];}return db[_0x4f2e('0x2e')]['find']({'where':{'id':_0x3c610d[_0x4f2e('0x4a')]['id']}})[_0x4f2e('0x2a')](handleEntityNotFound(_0x96caed,null))['then'](saveUpdates(_0x3c610d[_0x4f2e('0x49')],null))['then'](respondWithResult(_0x96caed,null))[_0x4f2e('0x42')](handleError(_0x96caed,null));};exports[_0x4f2e('0x29')]=function(_0x33b8c5,_0x2954ef){return db['ZohoAccount'][_0x4f2e('0x47')]({'where':{'id':_0x33b8c5[_0x4f2e('0x4a')]['id']}})[_0x4f2e('0x2a')](handleEntityNotFound(_0x2954ef,null))[_0x4f2e('0x2a')](removeEntity(_0x2954ef,null))['catch'](handleError(_0x2954ef,null));};exports['getConfigurations']=function(_0x43e84e,_0x31a269,_0x229151){var _0x15aece={};var _0x1281be={};var _0x2e1c0f;var _0x3b3b5e;return db[_0x4f2e('0x2e')][_0x4f2e('0x4b')]({'where':{'id':_0x43e84e['params']['id']}})[_0x4f2e('0x2a')](handleEntityNotFound(_0x31a269,null))['then'](function(_0x3b51f7){if(_0x3b51f7){_0x2e1c0f=_0x3b51f7;_0x1281be['model']=_['keys'](db[_0x4f2e('0x4c')][_0x4f2e('0x2f')]);_0x1281be[_0x4f2e('0x32')]=_[_0x4f2e('0x44')](_0x43e84e[_0x4f2e('0x32')]);_0x1281be['filters']=_['intersection'](_0x1281be['model'],_0x1281be[_0x4f2e('0x32')]);_0x15aece[_0x4f2e('0x35')]=_[_0x4f2e('0x34')](_0x1281be[_0x4f2e('0x31')],qs[_0x4f2e('0x36')](_0x43e84e[_0x4f2e('0x32')]['fields']));_0x15aece[_0x4f2e('0x35')]=_0x15aece[_0x4f2e('0x35')][_0x4f2e('0x37')]?_0x15aece[_0x4f2e('0x35')]:_0x1281be[_0x4f2e('0x31')];_0x15aece[_0x4f2e('0x39')]=qs[_0x4f2e('0x3a')](_0x43e84e[_0x4f2e('0x32')][_0x4f2e('0x3a')]);_0x15aece[_0x4f2e('0x3b')]=qs[_0x4f2e('0x33')](_[_0x4f2e('0x3c')](_0x43e84e[_0x4f2e('0x32')],_0x1281be[_0x4f2e('0x33')]));if(_0x43e84e['query'][_0x4f2e('0x3d')]){_0x15aece['where']=_['merge'](_0x15aece[_0x4f2e('0x3b')],{'$or':_[_0x4f2e('0x2d')](_0x15aece[_0x4f2e('0x35')],function(_0x165892){var _0x2fb643={};_0x2fb643[_0x165892]={'$like':'%'+_0x43e84e[_0x4f2e('0x32')]['filter']+'%'};return _0x2fb643;})});}_0x15aece=_[_0x4f2e('0x40')]({},_0x15aece,_0x43e84e['options']);return _0x2e1c0f[_0x4f2e('0x4d')](_0x15aece);}})[_0x4f2e('0x2a')](function(_0x423e2d){if(_0x423e2d){_0x3b3b5e=_0x423e2d['length'];if(!_0x43e84e[_0x4f2e('0x32')]['hasOwnProperty'](_0x4f2e('0x4e'))){_0x15aece[_0x4f2e('0x22')]=qs['limit'](_0x43e84e[_0x4f2e('0x32')][_0x4f2e('0x22')]);_0x15aece['offset']=qs['offset'](_0x43e84e[_0x4f2e('0x32')]['offset']);}return _0x2e1c0f[_0x4f2e('0x4d')](_0x15aece);}})[_0x4f2e('0x2a')](function(_0x280195){if(_0x280195){return _0x280195?{'count':_0x3b3b5e,'rows':_0x280195}:null;}})[_0x4f2e('0x2a')](respondWithResult(_0x31a269,null))['catch'](handleError(_0x31a269,null));};exports[_0x4f2e('0x4f')]=function(_0x4c7017,_0x3fac2b,_0x2c6bbb){if(_0x4c7017[_0x4f2e('0x49')]['id']){delete _0x4c7017[_0x4f2e('0x49')]['id'];}return db[_0x4f2e('0x2e')]['findOne']({'where':{'id':_0x4c7017['params']['id']}})[_0x4f2e('0x2a')](handleEntityNotFound(_0x3fac2b,null))[_0x4f2e('0x2a')](function(_0x18a82c){if(_0x18a82c){_0x4c7017['body'][_0x4f2e('0x50')]=_0x18a82c['id'];_0x4c7017[_0x4f2e('0x49')][_0x4f2e('0x51')]=integrations['getSubjects'](_0x4c7017[_0x4f2e('0x49')][_0x4f2e('0x52')],_0x4c7017['body'][_0x4f2e('0x3e')]);_0x4c7017['body']['Descriptions']=integrations[_0x4f2e('0x53')](_0x4c7017[_0x4f2e('0x49')][_0x4f2e('0x52')],_0x4c7017['body'][_0x4f2e('0x3e')]);return db[_0x4f2e('0x4c')][_0x4f2e('0x48')](_0x4c7017[_0x4f2e('0x49')],{'include':[{'model':db['ZohoField'],'as':_0x4f2e('0x51')},{'model':db[_0x4f2e('0x54')],'as':_0x4f2e('0x55')}]});}return null;})[_0x4f2e('0x2a')](respondWithResult(_0x3fac2b,null))['catch'](handleError(_0x3fac2b,null));};function getAccessToken(_0x3c510f){return new Promise(function(_0x37c043,_0x59adc7){var _0x29012c;switch(_0x3c510f[_0x4f2e('0x56')]){case'US':_0x29012c=_0x4f2e('0x57');break;case'AU':_0x29012c=_0x4f2e('0x58');break;case'EU':_0x29012c=_0x4f2e('0x59');break;case'IN':_0x29012c=_0x4f2e('0x5a');break;case'CN':_0x29012c=_0x4f2e('0x5b');break;default:_0x29012c=_0x4f2e('0x59');break;}var _0x1e079b={'method':_0x4f2e('0x5c'),'uri':_0x29012c+_0x4f2e('0x5d'),'qs':{'refresh_token':_0x3c510f['refreshToken'],'client_id':_0x3c510f[_0x4f2e('0x5e')],'client_secret':_0x3c510f[_0x4f2e('0x5f')],'grant_type':_0x4f2e('0x60')},'json':!![]};return rp(_0x1e079b)[_0x4f2e('0x2a')](function(_0x376140){if(_0x376140[_0x4f2e('0x61')]){_0x37c043(_0x376140[_0x4f2e('0x61')]);}else{_0x59adc7(_0x4f2e('0x62'));}})[_0x4f2e('0x42')](function(_0x4b32e6){_0x59adc7(_0x4b32e6);});});}exports[_0x4f2e('0x63')]=function(_0x578289,_0x38fd20,_0x57dd05){var _0x3acf53,_0x4fab21,_0x3a15a1,_0x5963b8,_0x3f3a81;return db[_0x4f2e('0x2e')][_0x4f2e('0x4b')]({'where':{'id':_0x578289[_0x4f2e('0x4a')]['id']},'attributes':['id',_0x4f2e('0x64'),'zone',_0x4f2e('0x5e'),_0x4f2e('0x5f'),_0x4f2e('0x65'),_0x4f2e('0x66'),_0x4f2e('0x67')]})[_0x4f2e('0x2a')](handleEntityNotFound(_0x38fd20,null))[_0x4f2e('0x2a')](function(_0x33b5ae){_0x3f3a81=_0x33b5ae;_0x3acf53=_0x3f3a81['host'];_0x4fab21=_0x3acf53===_0x4f2e('0x68')?'eu':_0x4f2e('0x69');_0x3a15a1=_0x3f3a81[_0x4f2e('0x65')];var _0x240889=_0x3a15a1['slice'](-0x1);if(_0x240889==='/'||_0x240889==='\x5c'||_0x240889===':'){_0x3a15a1=_0x3a15a1[_0x4f2e('0x6a')](0x0,_0x3a15a1[_0x4f2e('0x6b')](_0x240889));}if(!_0x3f3a81[_0x4f2e('0x67')]){throw new Error(_0x4f2e('0x6c'));}return getAccessToken(_0x3f3a81);})[_0x4f2e('0x2a')](function(_0x34d9f2){if(_0x34d9f2){return rp({'method':_0x4f2e('0x6d'),'uri':util[_0x4f2e('0x6e')]('https://www.zohoapis.%s/crm/v2/settings/fields',_0x4fab21),'qs':{'module':_0x4f2e('0x6f')},'headers':{'Authorization':_0x4f2e('0x70')+_0x34d9f2},'json':!![]});}})['then'](function(_0x505c4a){if(_0x505c4a){if(_0x505c4a[_0x4f2e('0x71')]&&_0x505c4a[_0x4f2e('0x71')][_0x4f2e('0x2b')]){throw new Error(_0x505c4a['response']['error'][_0x4f2e('0x72')]);}var _0x23efcc=[];var _0x3b5ff5=[];var _0x28895f=[_0x4f2e('0x73'),_0x4f2e('0x74'),_0x4f2e('0x75'),_0x4f2e('0x76'),_0x4f2e('0x77'),_0x4f2e('0x78'),'Call_Start_Time',_0x4f2e('0x79')];_0x3b5ff5=_[_0x4f2e('0x7a')](_0x505c4a[_0x4f2e('0x36')],function(_0x547954){return _0x28895f[_0x4f2e('0x7b')](_0x547954[_0x4f2e('0x7c')]);});for(var _0x51e61a=0x0;_0x51e61a<_0x3b5ff5[_0x4f2e('0x37')];_0x51e61a++){if(_0x3b5ff5[_0x51e61a][_0x4f2e('0x7d')]===![]){_0x23efcc['push']({'id':_0x3b5ff5[_0x51e61a]['id'],'name':_0x3b5ff5[_0x51e61a][_0x4f2e('0x7e')],'custom':_0x3b5ff5[_0x51e61a]['custom_field'],'options':_0x3b5ff5[_0x51e61a][_0x4f2e('0x7f')]==='picklist'&&_0x3b5ff5[_0x51e61a][_0x4f2e('0x80')][_0x4f2e('0x37')]>-0x1?_['map'](_0x3b5ff5[_0x51e61a]['pick_list_values'],function(_0x33cb83){return{'name':_0x33cb83,'value':_0x33cb83};}):[]});}}return{'count':_0x23efcc[_0x4f2e('0x37')],'rows':_0x23efcc};}else{return{'count':0x0,'rows':[]};}})[_0x4f2e('0x2a')](respondWithResult(_0x38fd20,null))['catch'](function(_0x3b4828){var _0x7b3ca7=_0x578289[_0x4f2e('0x32')]['test']?0x1f4:_0x3b4828['statusCode']||0x1f4;logger[_0x4f2e('0x2b')]('getFields,\x20%s,\x20%s,\x20%s',_0x4f2e('0x63'),_0x7b3ca7,JSON[_0x4f2e('0x81')](_0x3b4828));delete _0x3b4828[_0x4f2e('0x3f')];if(_0x7b3ca7===0x191){_0x7b3ca7=0x190;}_0x38fd20[_0x4f2e('0x1d')](_0x7b3ca7)[_0x4f2e('0x2c')](_0x578289[_0x4f2e('0x32')][_0x4f2e('0x82')]?{'message':_0x4f2e('0x83'),'statusCode':_0x3b4828[_0x4f2e('0x84')]}:_0x3b4828);});}; \ No newline at end of file diff --git a/server/api/intZohoAccount/intZohoAccount.model.js b/server/api/intZohoAccount/intZohoAccount.model.js new file mode 100644 index 0000000..6959f98 --- /dev/null +++ b/server/api/intZohoAccount/intZohoAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf278=['serverUrl','clientSecret','code','host','substring','https://accounts.zoho.com','https://accounts.zoho.in','https://accounts.zoho.eu','/oauth/v2/token','clientId','parse','refresh_token','refreshToken','format','name','ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d','inspect','catch','error','slice','lastIndexOf','https://accounts.zoho.com.au','https://accounts.zoho.com.cn','POST','authorization_code','application/x-www-form-urlencoded','info','ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d','../../config/logger','api','moment','request-promise','rimraf','../../config/environment','./intZohoAccount.attributes','../../components/integrations/configuration','exports','define','int_zoho_accounts','changed','zone'];(function(_0x54768b,_0x471822){var _0x587cbf=function(_0x413639){while(--_0x413639){_0x54768b['push'](_0x54768b['shift']());}};_0x587cbf(++_0x471822);}(_0xf278,0x13b));var _0x8f27=function(_0x2a83af,_0x4fa9ed){_0x2a83af=_0x2a83af-0x0;var _0x2e1648=_0xf278[_0x2a83af];return _0x2e1648;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x8f27('0x0'))(_0x8f27('0x1'));var moment=require(_0x8f27('0x2'));var BPromise=require('bluebird');var rp=require(_0x8f27('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0x8f27('0x4'));var config=require(_0x8f27('0x5'));var attributes=require(_0x8f27('0x6'));var integrations=require(_0x8f27('0x7'));module[_0x8f27('0x8')]=function(_0x4780df,_0x56e54a){return _0x4780df[_0x8f27('0x9')]('ZohoAccount',attributes,{'tableName':_0x8f27('0xa'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeCreate':function(_0x5e2d98,_0x1294f8,_0x4b9ebb){if(_0x5e2d98[_0x8f27('0xb')](_0x8f27('0xc'))||_0x5e2d98[_0x8f27('0xb')](_0x8f27('0xd'))||_0x5e2d98[_0x8f27('0xb')]('clientId')||_0x5e2d98[_0x8f27('0xb')](_0x8f27('0xe'))||_0x5e2d98[_0x8f27('0xb')](_0x8f27('0xf'))||_0x5e2d98['changed'](_0x8f27('0x10'))){var _0x34f7ba,_0x344775;_0x34f7ba=_0x5e2d98[_0x8f27('0xd')];var _0x598ee6=_0x34f7ba['slice'](-0x1);if(_0x598ee6==='/'||_0x598ee6==='\x5c'||_0x598ee6===':'){_0x34f7ba=_0x34f7ba[_0x8f27('0x11')](0x0,_0x34f7ba['lastIndexOf'](_0x598ee6));}switch(_0x5e2d98[_0x8f27('0xc')]){case'US':_0x344775=_0x8f27('0x12');break;case'AU':_0x344775='https://accounts.zoho.com.au';break;case'IN':_0x344775=_0x8f27('0x13');break;case'CN':_0x344775='https://accounts.zoho.com.cn';break;default:_0x344775=_0x8f27('0x14');break;}var _0x3ea2aa={'method':'POST','uri':_0x344775+_0x8f27('0x15'),'form':{'grant_type':'authorization_code','client_id':_0x5e2d98[_0x8f27('0x16')],'client_secret':_0x5e2d98['clientSecret'],'redirect_uri':_0x5e2d98[_0x8f27('0xd')],'code':_0x5e2d98[_0x8f27('0xf')]},'headers':{'Content-Type':'application/x-www-form-urlencoded'}};return rp(_0x3ea2aa)['then'](function(_0x27e365){var _0xa304d=JSON[_0x8f27('0x17')](_0x27e365);if(_0xa304d[_0x8f27('0x18')]){_0x5e2d98[_0x8f27('0x19')]=_0xa304d['refresh_token'];logger['info'](util[_0x8f27('0x1a')]('ZohoAccount,\x20Refresh\x20token\x20successfully\x20generated\x20for\x20account\x20\x22%s\x22\x20#%d',_0x5e2d98[_0x8f27('0x1b')],_0x5e2d98['id']));}else{logger['error'](util[_0x8f27('0x1a')](_0x8f27('0x1c'),_0x5e2d98['name'],_0x5e2d98['id']),util[_0x8f27('0x1d')](_0xa304d,{'showHidden':![],'depth':null}));}return _0x4b9ebb(null,_0x1294f8);})[_0x8f27('0x1e')](function(_0x7a32d7){logger[_0x8f27('0x1f')](util[_0x8f27('0x1a')](_0x8f27('0x1c'),_0x5e2d98[_0x8f27('0x1b')],_0x5e2d98['id']),util[_0x8f27('0x1d')](parsedResult,{'showHidden':![],'depth':null}));return _0x4b9ebb(_0x7a32d7);});}else{return _0x4b9ebb(null,_0x1294f8);}},'beforeUpdate':function(_0x945bcf,_0x464c23,_0x2588e7){if(_0x945bcf[_0x8f27('0xb')]('zone')||_0x945bcf['changed'](_0x8f27('0xd'))||_0x945bcf['changed'](_0x8f27('0x16'))||_0x945bcf['changed']('clientSecret')||_0x945bcf['changed'](_0x8f27('0xf'))||_0x945bcf[_0x8f27('0xb')]('host')){var _0x54e2a7,_0x17ab30;_0x54e2a7=_0x945bcf['serverUrl'];var _0x1b9609=_0x54e2a7[_0x8f27('0x20')](-0x1);if(_0x1b9609==='/'||_0x1b9609==='\x5c'||_0x1b9609===':'){_0x54e2a7=_0x54e2a7['substring'](0x0,_0x54e2a7[_0x8f27('0x21')](_0x1b9609));}switch(_0x945bcf[_0x8f27('0xc')]){case'US':_0x17ab30=_0x8f27('0x12');break;case'AU':_0x17ab30=_0x8f27('0x22');break;case'IN':_0x17ab30=_0x8f27('0x13');break;case'CN':_0x17ab30=_0x8f27('0x23');break;default:_0x17ab30='https://accounts.zoho.eu';break;}var _0x503a2a={'method':_0x8f27('0x24'),'uri':_0x17ab30+_0x8f27('0x15'),'form':{'grant_type':_0x8f27('0x25'),'client_id':_0x945bcf['clientId'],'client_secret':_0x945bcf['clientSecret'],'redirect_uri':_0x945bcf['serverUrl'],'code':_0x945bcf[_0x8f27('0xf')]},'headers':{'Content-Type':_0x8f27('0x26')}};return rp(_0x503a2a)['then'](function(_0x322b92){var _0x559cc2=JSON['parse'](_0x322b92);if(_0x559cc2[_0x8f27('0x18')]){_0x945bcf['refreshToken']=_0x559cc2[_0x8f27('0x18')];logger[_0x8f27('0x27')](util['format'](_0x8f27('0x28'),_0x945bcf[_0x8f27('0x1b')],_0x945bcf['id']));}else{logger[_0x8f27('0x1f')](util[_0x8f27('0x1a')](_0x8f27('0x1c'),_0x945bcf[_0x8f27('0x1b')],_0x945bcf['id']),util[_0x8f27('0x1d')](_0x559cc2,{'showHidden':![],'depth':null}));}return _0x2588e7(null,_0x464c23);})[_0x8f27('0x1e')](function(_0x337f9f){logger[_0x8f27('0x1f')](util[_0x8f27('0x1a')]('ZohoAccount,\x20Unable\x20to\x20generate\x20the\x20refresh\x20token\x20for\x20account\x20\x22%s\x22\x20#%d',_0x945bcf[_0x8f27('0x1b')],_0x945bcf['id']),util[_0x8f27('0x1d')](parsedResult,{'showHidden':![],'depth':null}));return _0x2588e7(_0x337f9f);});}else{return _0x2588e7(null,_0x464c23);}}}});}; \ No newline at end of file diff --git a/server/api/intZohoAccount/intZohoAccount.rpc.js b/server/api/intZohoAccount/intZohoAccount.rpc.js new file mode 100644 index 0000000..5cfcdbe --- /dev/null +++ b/server/api/intZohoAccount/intZohoAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe1c4=['result','catch','GetZohoAccount','ZohoAccount','findAll','options','raw','where','limit','include','map','model','attributes','debug','stringify','ShowZohoAccount','lodash','util','moment','ioredis','../../config/utils','../../config/logger','rpc','client','http','request','then','info','ZohoAccount,\x20%s,\x20%s','request\x20sent','ZohoAccount,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x445098,_0x2408f5){var _0xe7a955=function(_0x167e4e){while(--_0x167e4e){_0x445098['push'](_0x445098['shift']());}};_0xe7a955(++_0x2408f5);}(_0xe1c4,0x1ec));var _0x4e1c=function(_0x29b84a,_0x11c563){_0x29b84a=_0x29b84a-0x0;var _0x4ad70b=_0xe1c4[_0x29b84a];return _0x4ad70b;};'use strict';var _=require(_0x4e1c('0x0'));var util=require(_0x4e1c('0x1'));var moment=require(_0x4e1c('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4e1c('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x4e1c('0x4'));var logger=require(_0x4e1c('0x5'))(_0x4e1c('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x4e1c('0x7')][_0x4e1c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x44db21,_0x1c7e52,_0x460295){return new BPromise(function(_0x108830,_0x2622b4){return client[_0x4e1c('0x9')](_0x44db21,_0x460295)[_0x4e1c('0xa')](function(_0x60e98c){logger[_0x4e1c('0xb')](_0x4e1c('0xc'),_0x1c7e52,_0x4e1c('0xd'));logger['debug'](_0x4e1c('0xe'),_0x1c7e52,_0x4e1c('0xd'),JSON['stringify'](_0x60e98c));if(_0x60e98c[_0x4e1c('0xf')]){if(_0x60e98c[_0x4e1c('0xf')][_0x4e1c('0x10')]===0x1f4){logger[_0x4e1c('0xf')]('ZohoAccount,\x20%s,\x20%s',_0x1c7e52,_0x60e98c[_0x4e1c('0xf')][_0x4e1c('0x11')]);return _0x2622b4(_0x60e98c[_0x4e1c('0xf')][_0x4e1c('0x11')]);}logger['error']('ZohoAccount,\x20%s,\x20%s',_0x1c7e52,_0x60e98c['error'][_0x4e1c('0x11')]);return _0x108830(_0x60e98c[_0x4e1c('0xf')][_0x4e1c('0x11')]);}else{logger[_0x4e1c('0xb')]('ZohoAccount,\x20%s,\x20%s',_0x1c7e52,_0x4e1c('0xd'));_0x108830(_0x60e98c[_0x4e1c('0x12')][_0x4e1c('0x11')]);}})[_0x4e1c('0x13')](function(_0x44a842){logger[_0x4e1c('0xf')]('ZohoAccount,\x20%s,\x20%s',_0x1c7e52,_0x44a842);_0x2622b4(_0x44a842);});});}exports[_0x4e1c('0x14')]=function(_0x399bcc){var _0x2af3db=this;return new Promise(function(_0x46a887,_0x116a01){return db[_0x4e1c('0x15')][_0x4e1c('0x16')]({'raw':_0x399bcc['options']?_0x399bcc[_0x4e1c('0x17')][_0x4e1c('0x18')]===undefined?!![]:![]:!![],'where':_0x399bcc[_0x4e1c('0x17')]?_0x399bcc[_0x4e1c('0x17')][_0x4e1c('0x19')]||null:null,'attributes':_0x399bcc[_0x4e1c('0x17')]?_0x399bcc[_0x4e1c('0x17')]['attributes']||null:null,'limit':_0x399bcc[_0x4e1c('0x17')]?_0x399bcc[_0x4e1c('0x17')][_0x4e1c('0x1a')]||null:null,'include':_0x399bcc[_0x4e1c('0x17')]?_0x399bcc[_0x4e1c('0x17')][_0x4e1c('0x1b')]?_[_0x4e1c('0x1c')](_0x399bcc[_0x4e1c('0x17')][_0x4e1c('0x1b')],function(_0x5ada14){return{'model':db[_0x5ada14[_0x4e1c('0x1d')]],'as':_0x5ada14['as'],'attributes':_0x5ada14[_0x4e1c('0x1e')],'include':_0x5ada14[_0x4e1c('0x1b')]?_['map'](_0x5ada14['include'],function(_0x17f5a5){return{'model':db[_0x17f5a5['model']],'as':_0x17f5a5['as'],'attributes':_0x17f5a5[_0x4e1c('0x1e')],'include':_0x17f5a5[_0x4e1c('0x1b')]?_[_0x4e1c('0x1c')](_0x17f5a5[_0x4e1c('0x1b')],function(_0x12364d){return{'model':db[_0x12364d[_0x4e1c('0x1d')]],'as':_0x12364d['as'],'attributes':_0x12364d['attributes']};}):[]};}):[]};}):[]:[]})[_0x4e1c('0xa')](function(_0x2526a6){logger[_0x4e1c('0xb')](_0x4e1c('0x14'),_0x399bcc);logger[_0x4e1c('0x1f')]('GetZohoAccount',_0x399bcc,JSON[_0x4e1c('0x20')](_0x2526a6));_0x46a887(_0x2526a6);})[_0x4e1c('0x13')](function(_0x1b5ba8){logger[_0x4e1c('0xf')]('GetZohoAccount',_0x1b5ba8[_0x4e1c('0x11')],_0x399bcc);_0x116a01(_0x2af3db[_0x4e1c('0xf')](0x1f4,_0x1b5ba8['message']));});});};exports[_0x4e1c('0x21')]=function(_0x5ae521){var _0x88df92=this;return new Promise(function(_0x3c007f,_0x39f8fc){return db[_0x4e1c('0x15')]['find']({'raw':_0x5ae521[_0x4e1c('0x17')]?_0x5ae521['options'][_0x4e1c('0x18')]===undefined?!![]:![]:!![],'where':_0x5ae521['options']?_0x5ae521[_0x4e1c('0x17')][_0x4e1c('0x19')]||null:null,'attributes':_0x5ae521['options']?_0x5ae521[_0x4e1c('0x17')]['attributes']||null:null,'include':_0x5ae521[_0x4e1c('0x17')]?_0x5ae521[_0x4e1c('0x17')][_0x4e1c('0x1b')]?_[_0x4e1c('0x1c')](_0x5ae521[_0x4e1c('0x17')][_0x4e1c('0x1b')],function(_0x44477f){return{'model':db[_0x44477f[_0x4e1c('0x1d')]],'as':_0x44477f['as'],'attributes':_0x44477f[_0x4e1c('0x1e')],'include':_0x44477f[_0x4e1c('0x1b')]?_['map'](_0x44477f[_0x4e1c('0x1b')],function(_0x35763f){return{'model':db[_0x35763f[_0x4e1c('0x1d')]],'as':_0x35763f['as'],'attributes':_0x35763f[_0x4e1c('0x1e')],'include':_0x35763f[_0x4e1c('0x1b')]?_[_0x4e1c('0x1c')](_0x35763f['include'],function(_0x545d6b){return{'model':db[_0x545d6b[_0x4e1c('0x1d')]],'as':_0x545d6b['as'],'attributes':_0x545d6b[_0x4e1c('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4e1c('0xa')](function(_0x4365eb){logger['info'](_0x4e1c('0x21'),_0x5ae521);logger[_0x4e1c('0x1f')]('ShowZohoAccount',_0x5ae521,JSON[_0x4e1c('0x20')](_0x4365eb));_0x3c007f(_0x4365eb);})[_0x4e1c('0x13')](function(_0x729915){logger['error'](_0x4e1c('0x21'),_0x729915[_0x4e1c('0x11')],_0x5ae521);_0x39f8fc(_0x88df92['error'](0x1f4,_0x729915[_0x4e1c('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/intZohoConfiguration/index.js b/server/api/intZohoConfiguration/index.js new file mode 100644 index 0000000..88b8323 --- /dev/null +++ b/server/api/intZohoConfiguration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0d79=['/:id','show','/:id/fields','getFields','getSubjects','/:id/descriptions','getDescriptions','create','put','update','delete','destroy','exports','multer','util','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','./intZohoConfiguration.controller','get','isAuthenticated','index'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x0d79,0x1ed));var _0x90d7=function(_0x227bfa,_0x51bedc){_0x227bfa=_0x227bfa-0x0;var _0x331aba=_0x0d79[_0x227bfa];return _0x331aba;};'use strict';var multer=require(_0x90d7('0x0'));var util=require(_0x90d7('0x1'));var path=require('path');var timeout=require(_0x90d7('0x2'));var express=require(_0x90d7('0x3'));var router=express['Router']();var fs_extra=require(_0x90d7('0x4'));var auth=require(_0x90d7('0x5'));var interaction=require(_0x90d7('0x6'));var config=require('../../config/environment');var controller=require(_0x90d7('0x7'));router[_0x90d7('0x8')]('/',auth[_0x90d7('0x9')](),controller[_0x90d7('0xa')]);router[_0x90d7('0x8')](_0x90d7('0xb'),auth[_0x90d7('0x9')](),controller[_0x90d7('0xc')]);router[_0x90d7('0x8')](_0x90d7('0xd'),auth[_0x90d7('0x9')](),controller[_0x90d7('0xe')]);router['get']('/:id/subjects',auth[_0x90d7('0x9')](),controller[_0x90d7('0xf')]);router[_0x90d7('0x8')](_0x90d7('0x10'),auth[_0x90d7('0x9')](),controller[_0x90d7('0x11')]);router['post']('/',auth[_0x90d7('0x9')](),controller[_0x90d7('0x12')]);router[_0x90d7('0x13')](_0x90d7('0xb'),auth[_0x90d7('0x9')](),controller[_0x90d7('0x14')]);router[_0x90d7('0x15')]('/:id',auth[_0x90d7('0x9')](),controller[_0x90d7('0x16')]);module[_0x90d7('0x17')]=router; \ No newline at end of file diff --git a/server/api/intZohoConfiguration/intZohoConfiguration.attributes.js b/server/api/intZohoConfiguration/intZohoConfiguration.attributes.js new file mode 100644 index 0000000..07def24 --- /dev/null +++ b/server/api/intZohoConfiguration/intZohoConfiguration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa81a=['contact','STRING','sequelize','exports','ENUM','lead','contact_lead'];(function(_0x405c7e,_0x264502){var _0x3fa7d9=function(_0x514ee3){while(--_0x514ee3){_0x405c7e['push'](_0x405c7e['shift']());}};_0x3fa7d9(++_0x264502);}(_0xa81a,0xbf));var _0xaa81=function(_0x499140,_0x4c602c){_0x499140=_0x499140-0x0;var _0x4db9ec=_0xa81a[_0x499140];return _0x4db9ec;};'use strict';var Sequelize=require(_0xaa81('0x0'));module[_0xaa81('0x1')]={'name':{'type':Sequelize['STRING']},'moduleCreate':{'type':Sequelize[_0xaa81('0x2')](_0xaa81('0x3'),'contact','nothing'),'defaultValue':'lead'},'moduleSearch':{'type':Sequelize[_0xaa81('0x2')](_0xaa81('0x4'),_0xaa81('0x5'),_0xaa81('0x3')),'defaultValue':_0xaa81('0x4')},'description':{'type':Sequelize[_0xaa81('0x6')]}}; \ No newline at end of file diff --git a/server/api/intZohoConfiguration/intZohoConfiguration.controller.js b/server/api/intZohoConfiguration/intZohoConfiguration.controller.js new file mode 100644 index 0000000..547e95c --- /dev/null +++ b/server/api/intZohoConfiguration/intZohoConfiguration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x968f=['catch','show','params','keys','length','merge','find','create','body','findOne','ZohoField','order','pick','nolimit','getSubjects','getDescriptions','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','ZohoConfiguration','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','sort','where','filter','type','VIRTUAL','options','includeAll','include','findAll','rows'];(function(_0x3ff4c5,_0x588233){var _0x27904=function(_0x38f02c){while(--_0x38f02c){_0x3ff4c5['push'](_0x3ff4c5['shift']());}};_0x27904(++_0x588233);}(_0x968f,0x15c));var _0xf968=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x968f[_0x2641f9];return _0x585741;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf968('0x0'));var jsonpatch=require(_0xf968('0x1'));var rp=require(_0xf968('0x2'));var moment=require(_0xf968('0x3'));var BPromise=require(_0xf968('0x4'));var Mustache=require(_0xf968('0x5'));var util=require('util');var path=require('path');var sox=require(_0xf968('0x6'));var csv=require(_0xf968('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf968('0x8'));var _=require(_0xf968('0x9'));var squel=require(_0xf968('0xa'));var crypto=require(_0xf968('0xb'));var jsforce=require(_0xf968('0xc'));var deskjs=require(_0xf968('0xd'));var toCsv=require('to-csv');var querystring=require(_0xf968('0xe'));var Papa=require(_0xf968('0xf'));var Redis=require(_0xf968('0x10'));var authService=require(_0xf968('0x11'));var qs=require(_0xf968('0x12'));var as=require(_0xf968('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf968('0x14'))('api');var utils=require(_0xf968('0x15'));var config=require(_0xf968('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xf968('0x17'))['db'];function respondWithStatusCode(_0x42d86f,_0x574e8a){_0x574e8a=_0x574e8a||0xcc;return function(_0x1f7af0){if(_0x1f7af0){return _0x42d86f[_0xf968('0x18')](_0x574e8a);}return _0x42d86f['status'](_0x574e8a)[_0xf968('0x19')]();};}function respondWithResult(_0x515bb9,_0x3e2154){_0x3e2154=_0x3e2154||0xc8;return function(_0x24a50f){if(_0x24a50f){return _0x515bb9[_0xf968('0x1a')](_0x3e2154)[_0xf968('0x1b')](_0x24a50f);}};}function respondWithFilteredResult(_0xca960d,_0x1ea7b4){return function(_0xe5cc0c){if(_0xe5cc0c){var _0x331795=typeof _0x1ea7b4[_0xf968('0x1c')]===_0xf968('0x1d')&&typeof _0x1ea7b4[_0xf968('0x1e')]===_0xf968('0x1d');var _0x371d50=_0xe5cc0c[_0xf968('0x1f')];var _0x5ebe2e=_0x331795?0x0:_0x1ea7b4['offset'];var _0x5556fc=_0x331795?_0xe5cc0c[_0xf968('0x1f')]:_0x1ea7b4[_0xf968('0x1c')]+_0x1ea7b4[_0xf968('0x1e')];var _0x575d81;if(_0x5556fc>=_0x371d50){_0x5556fc=_0x371d50;_0x575d81=0xc8;}else{_0x575d81=0xce;}_0xca960d[_0xf968('0x1a')](_0x575d81);return _0xca960d[_0xf968('0x20')](_0xf968('0x21'),_0x5ebe2e+'-'+_0x5556fc+'/'+_0x371d50)[_0xf968('0x1b')](_0xe5cc0c);}return null;};}function patchUpdates(_0x4f0412){return function(_0x21fb00){try{jsonpatch[_0xf968('0x22')](_0x21fb00,_0x4f0412,!![]);}catch(_0x4792be){return BPromise[_0xf968('0x23')](_0x4792be);}return _0x21fb00[_0xf968('0x24')]();};}function saveUpdates(_0x2b232e,_0x40c524){return function(_0x600a40){if(_0x600a40){return _0x600a40[_0xf968('0x25')](_0x2b232e)[_0xf968('0x26')](function(_0x5efcd8){return _0x5efcd8;});}return null;};}function removeEntity(_0xfedddf,_0x28679b){return function(_0x39f5b3){if(_0x39f5b3){return _0x39f5b3[_0xf968('0x27')]()[_0xf968('0x26')](function(){_0xfedddf[_0xf968('0x1a')](0xcc)[_0xf968('0x19')]();});}};}function handleEntityNotFound(_0x3e3b37,_0x41a33b){return function(_0x1c21bc){if(!_0x1c21bc){_0x3e3b37['sendStatus'](0x194);}return _0x1c21bc;};}function handleError(_0x370fe0,_0x5887c2){_0x5887c2=_0x5887c2||0x1f4;return function(_0x1763db){logger[_0xf968('0x28')](_0x1763db[_0xf968('0x29')]);if(_0x1763db[_0xf968('0x2a')]){delete _0x1763db[_0xf968('0x2a')];}_0x370fe0[_0xf968('0x1a')](_0x5887c2)[_0xf968('0x2b')](_0x1763db);};}exports[_0xf968('0x2c')]=function(_0x373520,_0x331474){var _0x1af266={},_0x4b16f5={},_0x24a2f5={'count':0x0,'rows':[]};var _0x4e82a0=_[_0xf968('0x2d')](db[_0xf968('0x2e')][_0xf968('0x2f')],function(_0xeede48){return{'name':_0xeede48[_0xf968('0x30')],'type':_0xeede48['type'][_0xf968('0x31')]};});_0x4b16f5[_0xf968('0x32')]=_['map'](_0x4e82a0,_0xf968('0x2a'));_0x4b16f5[_0xf968('0x33')]=_['keys'](_0x373520[_0xf968('0x33')]);_0x4b16f5[_0xf968('0x34')]=_[_0xf968('0x35')](_0x4b16f5['model'],_0x4b16f5[_0xf968('0x33')]);_0x1af266[_0xf968('0x36')]=_['intersection'](_0x4b16f5[_0xf968('0x32')],qs[_0xf968('0x37')](_0x373520['query']['fields']));_0x1af266[_0xf968('0x36')]=_0x1af266[_0xf968('0x36')]['length']?_0x1af266[_0xf968('0x36')]:_0x4b16f5[_0xf968('0x32')];if(!_0x373520[_0xf968('0x33')][_0xf968('0x38')]('nolimit')){_0x1af266[_0xf968('0x1e')]=qs[_0xf968('0x1e')](_0x373520[_0xf968('0x33')][_0xf968('0x1e')]);_0x1af266[_0xf968('0x1c')]=qs[_0xf968('0x1c')](_0x373520[_0xf968('0x33')]['offset']);}_0x1af266['order']=qs['sort'](_0x373520['query'][_0xf968('0x39')]);_0x1af266[_0xf968('0x3a')]=qs[_0xf968('0x34')](_['pick'](_0x373520[_0xf968('0x33')],_0x4b16f5[_0xf968('0x34')]),_0x4e82a0);if(_0x373520[_0xf968('0x33')][_0xf968('0x3b')]){_0x1af266['where']=_['merge'](_0x1af266[_0xf968('0x3a')],{'$or':_['map'](_0x4e82a0,function(_0x4022ca){if(_0x4022ca[_0xf968('0x3c')]!==_0xf968('0x3d')){var _0x10c9de={};_0x10c9de[_0x4022ca[_0xf968('0x2a')]]={'$like':'%'+_0x373520[_0xf968('0x33')][_0xf968('0x3b')]+'%'};return _0x10c9de;}})});}_0x1af266=_['merge']({},_0x1af266,_0x373520[_0xf968('0x3e')]);var _0x1a1f59={'where':_0x1af266[_0xf968('0x3a')]};return db[_0xf968('0x2e')]['count'](_0x1a1f59)[_0xf968('0x26')](function(_0x53a379){_0x24a2f5[_0xf968('0x1f')]=_0x53a379;if(_0x373520[_0xf968('0x33')][_0xf968('0x3f')]){_0x1af266[_0xf968('0x40')]=[{'all':!![]}];}return db[_0xf968('0x2e')][_0xf968('0x41')](_0x1af266);})['then'](function(_0x5cad4c){_0x24a2f5[_0xf968('0x42')]=_0x5cad4c;return _0x24a2f5;})['then'](respondWithFilteredResult(_0x331474,_0x1af266))[_0xf968('0x43')](handleError(_0x331474,null));};exports[_0xf968('0x44')]=function(_0x34a4cc,_0x5b1e2b){var _0x278a48={'raw':![],'where':{'id':_0x34a4cc[_0xf968('0x45')]['id']}},_0x47c1dd={};_0x47c1dd[_0xf968('0x32')]=_[_0xf968('0x46')](db[_0xf968('0x2e')][_0xf968('0x2f')]);_0x47c1dd[_0xf968('0x33')]=_['keys'](_0x34a4cc[_0xf968('0x33')]);_0x47c1dd[_0xf968('0x34')]=_['intersection'](_0x47c1dd[_0xf968('0x32')],_0x47c1dd[_0xf968('0x33')]);_0x278a48[_0xf968('0x36')]=_[_0xf968('0x35')](_0x47c1dd[_0xf968('0x32')],qs[_0xf968('0x37')](_0x34a4cc[_0xf968('0x33')][_0xf968('0x37')]));_0x278a48[_0xf968('0x36')]=_0x278a48[_0xf968('0x36')][_0xf968('0x47')]?_0x278a48[_0xf968('0x36')]:_0x47c1dd[_0xf968('0x32')];if(_0x34a4cc[_0xf968('0x33')]['includeAll']){_0x278a48[_0xf968('0x40')]=[{'all':!![]}];}_0x278a48=_[_0xf968('0x48')]({},_0x278a48,_0x34a4cc[_0xf968('0x3e')]);return db[_0xf968('0x2e')][_0xf968('0x49')](_0x278a48)[_0xf968('0x26')](handleEntityNotFound(_0x5b1e2b,null))[_0xf968('0x26')](respondWithResult(_0x5b1e2b,null))['catch'](handleError(_0x5b1e2b,null));};exports['create']=function(_0x402034,_0x250cfc){return db['ZohoConfiguration'][_0xf968('0x4a')](_0x402034[_0xf968('0x4b')],{})[_0xf968('0x26')](respondWithResult(_0x250cfc,0xc9))['catch'](handleError(_0x250cfc,null));};exports['update']=function(_0x2bac49,_0x3ae505){if(_0x2bac49[_0xf968('0x4b')]['id']){delete _0x2bac49[_0xf968('0x4b')]['id'];}return db[_0xf968('0x2e')][_0xf968('0x49')]({'where':{'id':_0x2bac49[_0xf968('0x45')]['id']}})[_0xf968('0x26')](handleEntityNotFound(_0x3ae505,null))[_0xf968('0x26')](saveUpdates(_0x2bac49[_0xf968('0x4b')],null))['then'](respondWithResult(_0x3ae505,null))[_0xf968('0x43')](handleError(_0x3ae505,null));};exports[_0xf968('0x27')]=function(_0x247372,_0x24e93e){return db[_0xf968('0x2e')]['find']({'where':{'id':_0x247372[_0xf968('0x45')]['id']}})[_0xf968('0x26')](handleEntityNotFound(_0x24e93e,null))['then'](removeEntity(_0x24e93e,null))[_0xf968('0x43')](handleError(_0x24e93e,null));};exports['getFields']=function(_0x5a3650,_0x2d171c,_0x4382a0){var _0x4c9c84={};var _0x4eac98={};var _0x842d78;var _0x2cc0b0;return db[_0xf968('0x2e')][_0xf968('0x4c')]({'where':{'id':_0x5a3650[_0xf968('0x45')]['id']}})['then'](handleEntityNotFound(_0x2d171c,null))['then'](function(_0x53e31b){if(_0x53e31b){_0x842d78=_0x53e31b;_0x4eac98[_0xf968('0x32')]=_[_0xf968('0x46')](db[_0xf968('0x4d')][_0xf968('0x2f')]);_0x4eac98[_0xf968('0x33')]=_[_0xf968('0x46')](_0x5a3650['query']);_0x4eac98['filters']=_[_0xf968('0x35')](_0x4eac98['model'],_0x4eac98[_0xf968('0x33')]);_0x4c9c84['attributes']=_['intersection'](_0x4eac98[_0xf968('0x32')],qs[_0xf968('0x37')](_0x5a3650[_0xf968('0x33')][_0xf968('0x37')]));_0x4c9c84[_0xf968('0x36')]=_0x4c9c84[_0xf968('0x36')][_0xf968('0x47')]?_0x4c9c84['attributes']:_0x4eac98[_0xf968('0x32')];_0x4c9c84[_0xf968('0x4e')]=qs['sort'](_0x5a3650[_0xf968('0x33')][_0xf968('0x39')]);_0x4c9c84[_0xf968('0x3a')]=qs[_0xf968('0x34')](_[_0xf968('0x4f')](_0x5a3650[_0xf968('0x33')],_0x4eac98[_0xf968('0x34')]));if(_0x5a3650[_0xf968('0x33')][_0xf968('0x3b')]){_0x4c9c84[_0xf968('0x3a')]=_[_0xf968('0x48')](_0x4c9c84[_0xf968('0x3a')],{'$or':_[_0xf968('0x2d')](_0x4c9c84['attributes'],function(_0x37c283){var _0x2cbca2={};_0x2cbca2[_0x37c283]={'$like':'%'+_0x5a3650[_0xf968('0x33')][_0xf968('0x3b')]+'%'};return _0x2cbca2;})});}_0x4c9c84=_[_0xf968('0x48')]({},_0x4c9c84,_0x5a3650[_0xf968('0x3e')]);return _0x842d78['getFields'](_0x4c9c84);}})[_0xf968('0x26')](function(_0x2e5edc){if(_0x2e5edc){_0x2cc0b0=_0x2e5edc[_0xf968('0x47')];if(!_0x5a3650[_0xf968('0x33')][_0xf968('0x38')](_0xf968('0x50'))){_0x4c9c84['limit']=qs[_0xf968('0x1e')](_0x5a3650[_0xf968('0x33')]['limit']);_0x4c9c84[_0xf968('0x1c')]=qs[_0xf968('0x1c')](_0x5a3650['query']['offset']);}return _0x842d78['getFields'](_0x4c9c84);}})['then'](function(_0x572a51){if(_0x572a51){return _0x572a51?{'count':_0x2cc0b0,'rows':_0x572a51}:null;}})['then'](respondWithResult(_0x2d171c,null))['catch'](handleError(_0x2d171c,null));};exports[_0xf968('0x51')]=function(_0x1e9d8e,_0x3b21a5,_0x2c8d07){var _0x1c72c1={};var _0x7ce80d={};var _0x59b0ab;var _0x1ad45a;return db['ZohoConfiguration'][_0xf968('0x4c')]({'where':{'id':_0x1e9d8e[_0xf968('0x45')]['id']}})[_0xf968('0x26')](handleEntityNotFound(_0x3b21a5,null))['then'](function(_0x940840){if(_0x940840){_0x59b0ab=_0x940840;_0x7ce80d[_0xf968('0x32')]=_[_0xf968('0x46')](db[_0xf968('0x4d')]['rawAttributes']);_0x7ce80d[_0xf968('0x33')]=_[_0xf968('0x46')](_0x1e9d8e[_0xf968('0x33')]);_0x7ce80d[_0xf968('0x34')]=_[_0xf968('0x35')](_0x7ce80d['model'],_0x7ce80d[_0xf968('0x33')]);_0x1c72c1[_0xf968('0x36')]=_['intersection'](_0x7ce80d['model'],qs[_0xf968('0x37')](_0x1e9d8e['query'][_0xf968('0x37')]));_0x1c72c1[_0xf968('0x36')]=_0x1c72c1['attributes']['length']?_0x1c72c1[_0xf968('0x36')]:_0x7ce80d[_0xf968('0x32')];_0x1c72c1[_0xf968('0x4e')]=qs['sort'](_0x1e9d8e['query'][_0xf968('0x39')]);_0x1c72c1['where']=qs[_0xf968('0x34')](_[_0xf968('0x4f')](_0x1e9d8e['query'],_0x7ce80d[_0xf968('0x34')]));if(_0x1e9d8e['query'][_0xf968('0x3b')]){_0x1c72c1[_0xf968('0x3a')]=_['merge'](_0x1c72c1['where'],{'$or':_[_0xf968('0x2d')](_0x1c72c1['attributes'],function(_0x198be0){var _0x46e1f3={};_0x46e1f3[_0x198be0]={'$like':'%'+_0x1e9d8e[_0xf968('0x33')][_0xf968('0x3b')]+'%'};return _0x46e1f3;})});}_0x1c72c1=_['merge']({},_0x1c72c1,_0x1e9d8e[_0xf968('0x3e')]);return _0x59b0ab['getSubjects'](_0x1c72c1);}})['then'](function(_0x4020b7){if(_0x4020b7){_0x1ad45a=_0x4020b7[_0xf968('0x47')];if(!_0x1e9d8e[_0xf968('0x33')]['hasOwnProperty']('nolimit')){_0x1c72c1['limit']=qs['limit'](_0x1e9d8e[_0xf968('0x33')][_0xf968('0x1e')]);_0x1c72c1['offset']=qs['offset'](_0x1e9d8e[_0xf968('0x33')][_0xf968('0x1c')]);}return _0x59b0ab[_0xf968('0x51')](_0x1c72c1);}})[_0xf968('0x26')](function(_0x26ad71){if(_0x26ad71){return _0x26ad71?{'count':_0x1ad45a,'rows':_0x26ad71}:null;}})[_0xf968('0x26')](respondWithResult(_0x3b21a5,null))[_0xf968('0x43')](handleError(_0x3b21a5,null));};exports[_0xf968('0x52')]=function(_0x4d8eb1,_0x2135dd,_0x10652d){var _0x22be87={};var _0x4624ca={};var _0x4fef6b;var _0x3c9bcd;return db['ZohoConfiguration']['findOne']({'where':{'id':_0x4d8eb1[_0xf968('0x45')]['id']}})[_0xf968('0x26')](handleEntityNotFound(_0x2135dd,null))[_0xf968('0x26')](function(_0x5170db){if(_0x5170db){_0x4fef6b=_0x5170db;_0x4624ca['model']=_[_0xf968('0x46')](db[_0xf968('0x4d')][_0xf968('0x2f')]);_0x4624ca[_0xf968('0x33')]=_[_0xf968('0x46')](_0x4d8eb1[_0xf968('0x33')]);_0x4624ca[_0xf968('0x34')]=_[_0xf968('0x35')](_0x4624ca[_0xf968('0x32')],_0x4624ca['query']);_0x22be87[_0xf968('0x36')]=_['intersection'](_0x4624ca['model'],qs['fields'](_0x4d8eb1[_0xf968('0x33')][_0xf968('0x37')]));_0x22be87[_0xf968('0x36')]=_0x22be87[_0xf968('0x36')][_0xf968('0x47')]?_0x22be87[_0xf968('0x36')]:_0x4624ca['model'];_0x22be87['order']=qs['sort'](_0x4d8eb1[_0xf968('0x33')][_0xf968('0x39')]);_0x22be87[_0xf968('0x3a')]=qs[_0xf968('0x34')](_[_0xf968('0x4f')](_0x4d8eb1['query'],_0x4624ca[_0xf968('0x34')]));if(_0x4d8eb1[_0xf968('0x33')][_0xf968('0x3b')]){_0x22be87[_0xf968('0x3a')]=_['merge'](_0x22be87['where'],{'$or':_['map'](_0x22be87[_0xf968('0x36')],function(_0x40810d){var _0x16cd25={};_0x16cd25[_0x40810d]={'$like':'%'+_0x4d8eb1['query'][_0xf968('0x3b')]+'%'};return _0x16cd25;})});}_0x22be87=_[_0xf968('0x48')]({},_0x22be87,_0x4d8eb1['options']);return _0x4fef6b[_0xf968('0x52')](_0x22be87);}})[_0xf968('0x26')](function(_0x92807a){if(_0x92807a){_0x3c9bcd=_0x92807a['length'];if(!_0x4d8eb1[_0xf968('0x33')][_0xf968('0x38')]('nolimit')){_0x22be87['limit']=qs[_0xf968('0x1e')](_0x4d8eb1[_0xf968('0x33')][_0xf968('0x1e')]);_0x22be87['offset']=qs[_0xf968('0x1c')](_0x4d8eb1[_0xf968('0x33')]['offset']);}return _0x4fef6b[_0xf968('0x52')](_0x22be87);}})[_0xf968('0x26')](function(_0x276d78){if(_0x276d78){return _0x276d78?{'count':_0x3c9bcd,'rows':_0x276d78}:null;}})[_0xf968('0x26')](respondWithResult(_0x2135dd,null))['catch'](handleError(_0x2135dd,null));}; \ No newline at end of file diff --git a/server/api/intZohoConfiguration/intZohoConfiguration.model.js b/server/api/intZohoConfiguration/intZohoConfiguration.model.js new file mode 100644 index 0000000..6d7bc46 --- /dev/null +++ b/server/api/intZohoConfiguration/intZohoConfiguration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x74c0=['exports','ZohoConfiguration','int_zoho_configurations','lodash','../../config/logger','moment','request-promise','path','rimraf','./intZohoConfiguration.attributes'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x74c0,0x1ed));var _0x074c=function(_0x38e870,_0x3d2e6a){_0x38e870=_0x38e870-0x0;var _0x2dabbe=_0x74c0[_0x38e870];return _0x2dabbe;};'use strict';var _=require(_0x074c('0x0'));var util=require('util');var logger=require(_0x074c('0x1'))('api');var moment=require(_0x074c('0x2'));var BPromise=require('bluebird');var rp=require(_0x074c('0x3'));var fs=require('fs');var path=require(_0x074c('0x4'));var rimraf=require(_0x074c('0x5'));var config=require('../../config/environment');var attributes=require(_0x074c('0x6'));module[_0x074c('0x7')]=function(_0x186363,_0x2d3073){return _0x186363['define'](_0x074c('0x8'),attributes,{'tableName':_0x074c('0x9'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intZohoConfiguration/intZohoConfiguration.rpc.js b/server/api/intZohoConfiguration/intZohoConfiguration.rpc.js new file mode 100644 index 0000000..56bb626 --- /dev/null +++ b/server/api/intZohoConfiguration/intZohoConfiguration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf35d=['lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then','ZohoConfiguration,\x20%s,\x20%s','debug','ZohoConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','result','catch'];(function(_0xc71aad,_0x3b6646){var _0x183565=function(_0x3a56d0){while(--_0x3a56d0){_0xc71aad['push'](_0xc71aad['shift']());}};_0x183565(++_0x3b6646);}(_0xf35d,0xfd));var _0xdf35=function(_0x5df893,_0x224811){_0x5df893=_0x5df893-0x0;var _0x4f6a21=_0xf35d[_0x5df893];return _0x4f6a21;};'use strict';var _=require(_0xdf35('0x0'));var util=require('util');var moment=require(_0xdf35('0x1'));var BPromise=require(_0xdf35('0x2'));var rs=require(_0xdf35('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xdf35('0x4'))['db'];var utils=require(_0xdf35('0x5'));var logger=require(_0xdf35('0x6'))(_0xdf35('0x7'));var config=require('../../config/environment');var jayson=require(_0xdf35('0x8'));var client=jayson[_0xdf35('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1b797e,_0x101c3c,_0x2a07ab){return new BPromise(function(_0x41d9d3,_0x43a70e){return client[_0xdf35('0xa')](_0x1b797e,_0x2a07ab)[_0xdf35('0xb')](function(_0x3a37ed){logger['info'](_0xdf35('0xc'),_0x101c3c,'request\x20sent');logger[_0xdf35('0xd')](_0xdf35('0xe'),_0x101c3c,'request\x20sent',JSON[_0xdf35('0xf')](_0x3a37ed));if(_0x3a37ed['error']){if(_0x3a37ed[_0xdf35('0x10')][_0xdf35('0x11')]===0x1f4){logger[_0xdf35('0x10')]('ZohoConfiguration,\x20%s,\x20%s',_0x101c3c,_0x3a37ed[_0xdf35('0x10')]['message']);return _0x43a70e(_0x3a37ed[_0xdf35('0x10')][_0xdf35('0x12')]);}logger[_0xdf35('0x10')](_0xdf35('0xc'),_0x101c3c,_0x3a37ed[_0xdf35('0x10')][_0xdf35('0x12')]);return _0x41d9d3(_0x3a37ed['error']['message']);}else{logger[_0xdf35('0x13')](_0xdf35('0xc'),_0x101c3c,_0xdf35('0x14'));_0x41d9d3(_0x3a37ed[_0xdf35('0x15')][_0xdf35('0x12')]);}})[_0xdf35('0x16')](function(_0x4363a5){logger[_0xdf35('0x10')]('ZohoConfiguration,\x20%s,\x20%s',_0x101c3c,_0x4363a5);_0x43a70e(_0x4363a5);});});} \ No newline at end of file diff --git a/server/api/intZohoField/index.js b/server/api/intZohoField/index.js new file mode 100644 index 0000000..0d5b91e --- /dev/null +++ b/server/api/intZohoField/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf6f4=['./intZohoField.controller','isAuthenticated','index','get','/:id','update','delete','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service'];(function(_0x4f8e27,_0xc63503){var _0x34f479=function(_0x3ff982){while(--_0x3ff982){_0x4f8e27['push'](_0x4f8e27['shift']());}};_0x34f479(++_0xc63503);}(_0xf6f4,0x16e));var _0x4f6f=function(_0x5d5c9f,_0x816f20){_0x5d5c9f=_0x5d5c9f-0x0;var _0xc43d43=_0xf6f4[_0x5d5c9f];return _0xc43d43;};'use strict';var multer=require(_0x4f6f('0x0'));var util=require(_0x4f6f('0x1'));var path=require(_0x4f6f('0x2'));var timeout=require(_0x4f6f('0x3'));var express=require(_0x4f6f('0x4'));var router=express[_0x4f6f('0x5')]();var fs_extra=require(_0x4f6f('0x6'));var auth=require(_0x4f6f('0x7'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x4f6f('0x8'));router['get']('/',auth[_0x4f6f('0x9')](),controller[_0x4f6f('0xa')]);router[_0x4f6f('0xb')](_0x4f6f('0xc'),auth[_0x4f6f('0x9')](),controller['show']);router['post']('/',auth[_0x4f6f('0x9')](),controller['create']);router['put']('/:id',auth[_0x4f6f('0x9')](),controller[_0x4f6f('0xd')]);router[_0x4f6f('0xe')](_0x4f6f('0xc'),auth[_0x4f6f('0x9')](),controller[_0x4f6f('0xf')]);module[_0x4f6f('0x10')]=router; \ No newline at end of file diff --git a/server/api/intZohoField/intZohoField.attributes.js b/server/api/intZohoField/intZohoField.attributes.js new file mode 100644 index 0000000..4b86905 --- /dev/null +++ b/server/api/intZohoField/intZohoField.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3242=['string','variable','customVariable','keyValue','STRING','sequelize','ENUM'];(function(_0x40cfda,_0x22266e){var _0x2c840e=function(_0x25f8bf){while(--_0x25f8bf){_0x40cfda['push'](_0x40cfda['shift']());}};_0x2c840e(++_0x22266e);}(_0x3242,0x1b0));var _0x2324=function(_0x3a88a2,_0x4d1357){_0x3a88a2=_0x3a88a2-0x0;var _0x10fb3b=_0x3242[_0x3a88a2];return _0x10fb3b;};'use strict';var Sequelize=require(_0x2324('0x0'));module['exports']={'type':{'type':Sequelize[_0x2324('0x1')](_0x2324('0x2'),_0x2324('0x3'),_0x2324('0x4'),_0x2324('0x5'),'picklist'),'defaultValue':_0x2324('0x2')},'content':{'type':Sequelize['STRING']},'key':{'type':Sequelize['STRING']},'keyType':{'type':Sequelize[_0x2324('0x1')](_0x2324('0x2'),'variable',_0x2324('0x4'))},'keyContent':{'type':Sequelize[_0x2324('0x6')]},'idField':{'type':Sequelize[_0x2324('0x6')]},'nameField':{'type':Sequelize['STRING']},'customField':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'variableName':{'type':Sequelize[_0x2324('0x6')]}}; \ No newline at end of file diff --git a/server/api/intZohoField/intZohoField.controller.js b/server/api/intZohoField/intZohoField.controller.js new file mode 100644 index 0000000..f6b22ab --- /dev/null +++ b/server/api/intZohoField/intZohoField.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9ff8=['count','set','reject','update','destroy','error','stack','name','send','index','map','fieldName','type','key','model','query','keys','filters','fields','attributes','length','hasOwnProperty','order','pick','where','VIRTUAL','filter','merge','options','ZohoField','then','includeAll','include','findAll','rows','catch','show','params','rawAttributes','intersection','find','create','body','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','limit','undefined'];(function(_0x1a6da6,_0x5cc397){var _0x56ed97=function(_0x237167){while(--_0x237167){_0x1a6da6['push'](_0x1a6da6['shift']());}};_0x56ed97(++_0x5cc397);}(_0x9ff8,0x74));var _0x89ff=function(_0x345ddb,_0x4f3689){_0x345ddb=_0x345ddb-0x0;var _0x2d3bc8=_0x9ff8[_0x345ddb];return _0x2d3bc8;};'use strict';var emlformat=require(_0x89ff('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x89ff('0x1'));var jsonpatch=require(_0x89ff('0x2'));var rp=require(_0x89ff('0x3'));var moment=require(_0x89ff('0x4'));var BPromise=require(_0x89ff('0x5'));var Mustache=require('mustache');var util=require(_0x89ff('0x6'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x89ff('0x7'));var fs=require('fs');var fs_extra=require(_0x89ff('0x8'));var _=require('lodash');var squel=require(_0x89ff('0x9'));var crypto=require(_0x89ff('0xa'));var jsforce=require(_0x89ff('0xb'));var deskjs=require(_0x89ff('0xc'));var toCsv=require(_0x89ff('0xd'));var querystring=require(_0x89ff('0xe'));var Papa=require(_0x89ff('0xf'));var Redis=require(_0x89ff('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x89ff('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x89ff('0x12'));var logger=require('../../config/logger')(_0x89ff('0x13'));var utils=require(_0x89ff('0x14'));var config=require(_0x89ff('0x15'));var licenseUtil=require(_0x89ff('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1bff5e,_0x129685){_0x129685=_0x129685||0xcc;return function(_0x54a456){if(_0x54a456){return _0x1bff5e[_0x89ff('0x17')](_0x129685);}return _0x1bff5e[_0x89ff('0x18')](_0x129685)[_0x89ff('0x19')]();};}function respondWithResult(_0x1aa2ad,_0x3867f8){_0x3867f8=_0x3867f8||0xc8;return function(_0x52b1c6){if(_0x52b1c6){return _0x1aa2ad[_0x89ff('0x18')](_0x3867f8)[_0x89ff('0x1a')](_0x52b1c6);}};}function respondWithFilteredResult(_0x50a7ae,_0x58fe06){return function(_0x107424){if(_0x107424){var _0x23d0e8=typeof _0x58fe06[_0x89ff('0x1b')]==='undefined'&&typeof _0x58fe06[_0x89ff('0x1c')]===_0x89ff('0x1d');var _0x1e8602=_0x107424[_0x89ff('0x1e')];var _0x2a21cb=_0x23d0e8?0x0:_0x58fe06[_0x89ff('0x1b')];var _0x6c747c=_0x23d0e8?_0x107424[_0x89ff('0x1e')]:_0x58fe06[_0x89ff('0x1b')]+_0x58fe06['limit'];var _0x5de24f;if(_0x6c747c>=_0x1e8602){_0x6c747c=_0x1e8602;_0x5de24f=0xc8;}else{_0x5de24f=0xce;}_0x50a7ae[_0x89ff('0x18')](_0x5de24f);return _0x50a7ae[_0x89ff('0x1f')]('Content-Range',_0x2a21cb+'-'+_0x6c747c+'/'+_0x1e8602)[_0x89ff('0x1a')](_0x107424);}return null;};}function patchUpdates(_0x3f0767){return function(_0x48f4c9){try{jsonpatch['apply'](_0x48f4c9,_0x3f0767,!![]);}catch(_0x1513c7){return BPromise[_0x89ff('0x20')](_0x1513c7);}return _0x48f4c9['save']();};}function saveUpdates(_0x4caae0,_0x452ca2){return function(_0x151153){if(_0x151153){return _0x151153[_0x89ff('0x21')](_0x4caae0)['then'](function(_0x822ba2){return _0x822ba2;});}return null;};}function removeEntity(_0x25d343,_0x1925df){return function(_0x5160fe){if(_0x5160fe){return _0x5160fe[_0x89ff('0x22')]()['then'](function(){_0x25d343[_0x89ff('0x18')](0xcc)[_0x89ff('0x19')]();});}};}function handleEntityNotFound(_0x1c5474,_0x3e2a11){return function(_0x55e103){if(!_0x55e103){_0x1c5474[_0x89ff('0x17')](0x194);}return _0x55e103;};}function handleError(_0x382fcf,_0xf2b7ba){_0xf2b7ba=_0xf2b7ba||0x1f4;return function(_0x326746){logger[_0x89ff('0x23')](_0x326746[_0x89ff('0x24')]);if(_0x326746[_0x89ff('0x25')]){delete _0x326746[_0x89ff('0x25')];}_0x382fcf[_0x89ff('0x18')](_0xf2b7ba)[_0x89ff('0x26')](_0x326746);};}exports[_0x89ff('0x27')]=function(_0x4a8ca3,_0x2d8238){var _0x234a37={},_0x57c86f={},_0x10c4fa={'count':0x0,'rows':[]};var _0x38eeef=_[_0x89ff('0x28')](db['ZohoField']['rawAttributes'],function(_0x2131fd){return{'name':_0x2131fd[_0x89ff('0x29')],'type':_0x2131fd[_0x89ff('0x2a')][_0x89ff('0x2b')]};});_0x57c86f[_0x89ff('0x2c')]=_[_0x89ff('0x28')](_0x38eeef,'name');_0x57c86f[_0x89ff('0x2d')]=_[_0x89ff('0x2e')](_0x4a8ca3[_0x89ff('0x2d')]);_0x57c86f[_0x89ff('0x2f')]=_['intersection'](_0x57c86f[_0x89ff('0x2c')],_0x57c86f['query']);_0x234a37['attributes']=_['intersection'](_0x57c86f[_0x89ff('0x2c')],qs[_0x89ff('0x30')](_0x4a8ca3['query'][_0x89ff('0x30')]));_0x234a37[_0x89ff('0x31')]=_0x234a37[_0x89ff('0x31')][_0x89ff('0x32')]?_0x234a37['attributes']:_0x57c86f[_0x89ff('0x2c')];if(!_0x4a8ca3[_0x89ff('0x2d')][_0x89ff('0x33')]('nolimit')){_0x234a37['limit']=qs[_0x89ff('0x1c')](_0x4a8ca3[_0x89ff('0x2d')][_0x89ff('0x1c')]);_0x234a37[_0x89ff('0x1b')]=qs[_0x89ff('0x1b')](_0x4a8ca3[_0x89ff('0x2d')][_0x89ff('0x1b')]);}_0x234a37[_0x89ff('0x34')]=qs['sort'](_0x4a8ca3['query']['sort']);_0x234a37['where']=qs[_0x89ff('0x2f')](_[_0x89ff('0x35')](_0x4a8ca3[_0x89ff('0x2d')],_0x57c86f[_0x89ff('0x2f')]),_0x38eeef);if(_0x4a8ca3[_0x89ff('0x2d')]['filter']){_0x234a37[_0x89ff('0x36')]=_['merge'](_0x234a37[_0x89ff('0x36')],{'$or':_['map'](_0x38eeef,function(_0xff709e){if(_0xff709e[_0x89ff('0x2a')]!==_0x89ff('0x37')){var _0x1c5b20={};_0x1c5b20[_0xff709e['name']]={'$like':'%'+_0x4a8ca3[_0x89ff('0x2d')][_0x89ff('0x38')]+'%'};return _0x1c5b20;}})});}_0x234a37=_[_0x89ff('0x39')]({},_0x234a37,_0x4a8ca3[_0x89ff('0x3a')]);var _0x2ec472={'where':_0x234a37[_0x89ff('0x36')]};return db[_0x89ff('0x3b')]['count'](_0x2ec472)[_0x89ff('0x3c')](function(_0x203d71){_0x10c4fa[_0x89ff('0x1e')]=_0x203d71;if(_0x4a8ca3[_0x89ff('0x2d')][_0x89ff('0x3d')]){_0x234a37[_0x89ff('0x3e')]=[{'all':!![]}];}return db[_0x89ff('0x3b')][_0x89ff('0x3f')](_0x234a37);})['then'](function(_0x546c20){_0x10c4fa[_0x89ff('0x40')]=_0x546c20;return _0x10c4fa;})[_0x89ff('0x3c')](respondWithFilteredResult(_0x2d8238,_0x234a37))[_0x89ff('0x41')](handleError(_0x2d8238,null));};exports[_0x89ff('0x42')]=function(_0x20399d,_0x555cd7){var _0xc0f1e2={'raw':!![],'where':{'id':_0x20399d[_0x89ff('0x43')]['id']}},_0x2f403e={};_0x2f403e['model']=_[_0x89ff('0x2e')](db[_0x89ff('0x3b')][_0x89ff('0x44')]);_0x2f403e[_0x89ff('0x2d')]=_['keys'](_0x20399d[_0x89ff('0x2d')]);_0x2f403e[_0x89ff('0x2f')]=_[_0x89ff('0x45')](_0x2f403e['model'],_0x2f403e[_0x89ff('0x2d')]);_0xc0f1e2[_0x89ff('0x31')]=_[_0x89ff('0x45')](_0x2f403e[_0x89ff('0x2c')],qs[_0x89ff('0x30')](_0x20399d[_0x89ff('0x2d')][_0x89ff('0x30')]));_0xc0f1e2[_0x89ff('0x31')]=_0xc0f1e2[_0x89ff('0x31')][_0x89ff('0x32')]?_0xc0f1e2[_0x89ff('0x31')]:_0x2f403e[_0x89ff('0x2c')];if(_0x20399d[_0x89ff('0x2d')]['includeAll']){_0xc0f1e2[_0x89ff('0x3e')]=[{'all':!![]}];}_0xc0f1e2=_[_0x89ff('0x39')]({},_0xc0f1e2,_0x20399d[_0x89ff('0x3a')]);return db[_0x89ff('0x3b')][_0x89ff('0x46')](_0xc0f1e2)[_0x89ff('0x3c')](handleEntityNotFound(_0x555cd7,null))[_0x89ff('0x3c')](respondWithResult(_0x555cd7,null))[_0x89ff('0x41')](handleError(_0x555cd7,null));};exports[_0x89ff('0x47')]=function(_0x571e85,_0x46e258){return db[_0x89ff('0x3b')][_0x89ff('0x47')](_0x571e85[_0x89ff('0x48')],{})[_0x89ff('0x3c')](respondWithResult(_0x46e258,0xc9))[_0x89ff('0x41')](handleError(_0x46e258,null));};exports[_0x89ff('0x21')]=function(_0x27fb1a,_0x3848c9){if(_0x27fb1a['body']['id']){delete _0x27fb1a['body']['id'];}return db[_0x89ff('0x3b')][_0x89ff('0x46')]({'where':{'id':_0x27fb1a[_0x89ff('0x43')]['id']}})[_0x89ff('0x3c')](handleEntityNotFound(_0x3848c9,null))[_0x89ff('0x3c')](saveUpdates(_0x27fb1a[_0x89ff('0x48')],null))['then'](respondWithResult(_0x3848c9,null))[_0x89ff('0x41')](handleError(_0x3848c9,null));};exports[_0x89ff('0x22')]=function(_0x5ba55a,_0x155442){return db[_0x89ff('0x3b')][_0x89ff('0x46')]({'where':{'id':_0x5ba55a['params']['id']}})[_0x89ff('0x3c')](handleEntityNotFound(_0x155442,null))[_0x89ff('0x3c')](removeEntity(_0x155442,null))[_0x89ff('0x41')](handleError(_0x155442,null));}; \ No newline at end of file diff --git a/server/api/intZohoField/intZohoField.model.js b/server/api/intZohoField/intZohoField.model.js new file mode 100644 index 0000000..442bbad --- /dev/null +++ b/server/api/intZohoField/intZohoField.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4745=['../../config/environment','./intZohoField.attributes','exports','define','int_zoho_fields','idField','FieldId','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf'];(function(_0x513d65,_0x156ef6){var _0x307aa9=function(_0x3885d3){while(--_0x3885d3){_0x513d65['push'](_0x513d65['shift']());}};_0x307aa9(++_0x156ef6);}(_0x4745,0x1e7));var _0x5474=function(_0x36dfbd,_0x5bfe2d){_0x36dfbd=_0x36dfbd-0x0;var _0x4ecad9=_0x4745[_0x36dfbd];return _0x4ecad9;};'use strict';var _=require(_0x5474('0x0'));var util=require(_0x5474('0x1'));var logger=require(_0x5474('0x2'))(_0x5474('0x3'));var moment=require(_0x5474('0x4'));var BPromise=require(_0x5474('0x5'));var rp=require(_0x5474('0x6'));var fs=require('fs');var path=require(_0x5474('0x7'));var rimraf=require(_0x5474('0x8'));var config=require(_0x5474('0x9'));var attributes=require(_0x5474('0xa'));module[_0x5474('0xb')]=function(_0x4e7ce7,_0x3d1e1){return _0x4e7ce7[_0x5474('0xc')]('ZohoField',attributes,{'tableName':_0x5474('0xd'),'paranoid':![],'indexes':[{'name':'zoho_unique_index','fields':[_0x5474('0xe'),_0x5474('0xf')],'unique':!![]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/intZohoField/intZohoField.rpc.js b/server/api/intZohoField/intZohoField.rpc.js new file mode 100644 index 0000000..2fd3d05 --- /dev/null +++ b/server/api/intZohoField/intZohoField.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7349=['request','then','ZohoField,\x20%s,\x20%s','request\x20sent','debug','ZohoField,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','client','http'];(function(_0x349a8d,_0x2616e3){var _0x50f593=function(_0x3c4f1a){while(--_0x3c4f1a){_0x349a8d['push'](_0x349a8d['shift']());}};_0x50f593(++_0x2616e3);}(_0x7349,0x79));var _0x9734=function(_0x5ae9fd,_0x466d96){_0x5ae9fd=_0x5ae9fd-0x0;var _0x1009a2=_0x7349[_0x5ae9fd];return _0x1009a2;};'use strict';var _=require(_0x9734('0x0'));var util=require(_0x9734('0x1'));var moment=require(_0x9734('0x2'));var BPromise=require(_0x9734('0x3'));var rs=require(_0x9734('0x4'));var fs=require('fs');var Redis=require(_0x9734('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x9734('0x6'));var logger=require(_0x9734('0x7'))(_0x9734('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x9734('0x9')][_0x9734('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x16d4a9,_0xd9f4e4,_0x87923c){return new BPromise(function(_0x127813,_0x36a547){return client[_0x9734('0xb')](_0x16d4a9,_0x87923c)[_0x9734('0xc')](function(_0x350a1c){logger['info'](_0x9734('0xd'),_0xd9f4e4,_0x9734('0xe'));logger[_0x9734('0xf')](_0x9734('0x10'),_0xd9f4e4,_0x9734('0xe'),JSON[_0x9734('0x11')](_0x350a1c));if(_0x350a1c[_0x9734('0x12')]){if(_0x350a1c[_0x9734('0x12')][_0x9734('0x13')]===0x1f4){logger[_0x9734('0x12')](_0x9734('0xd'),_0xd9f4e4,_0x350a1c['error'][_0x9734('0x14')]);return _0x36a547(_0x350a1c[_0x9734('0x12')][_0x9734('0x14')]);}logger['error'](_0x9734('0xd'),_0xd9f4e4,_0x350a1c[_0x9734('0x12')][_0x9734('0x14')]);return _0x127813(_0x350a1c[_0x9734('0x12')][_0x9734('0x14')]);}else{logger['info']('ZohoField,\x20%s,\x20%s',_0xd9f4e4,_0x9734('0xe'));_0x127813(_0x350a1c['result'][_0x9734('0x14')]);}})[_0x9734('0x15')](function(_0x6d560c){logger['error'](_0x9734('0xd'),_0xd9f4e4,_0x6d560c);_0x36a547(_0x6d560c);});});} \ No newline at end of file diff --git a/server/api/integration/index.js b/server/api/integration/index.js new file mode 100644 index 0000000..dabec33 --- /dev/null +++ b/server/api/integration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe706=['../../components/interaction/service','../../config/environment','exports','multer','util','path','express','Router','fs-extra','../../components/auth/service'];(function(_0x2cc0c9,_0x1600f1){var _0x673533=function(_0x322f11){while(--_0x322f11){_0x2cc0c9['push'](_0x2cc0c9['shift']());}};_0x673533(++_0x1600f1);}(_0xe706,0xa3));var _0x6e70=function(_0x38136b,_0x35c34e){_0x38136b=_0x38136b-0x0;var _0x3b10b9=_0xe706[_0x38136b];return _0x3b10b9;};'use strict';var multer=require(_0x6e70('0x0'));var util=require(_0x6e70('0x1'));var path=require(_0x6e70('0x2'));var timeout=require('connect-timeout');var express=require(_0x6e70('0x3'));var router=express[_0x6e70('0x4')]();var fs_extra=require(_0x6e70('0x5'));var auth=require(_0x6e70('0x6'));var interaction=require(_0x6e70('0x7'));var config=require(_0x6e70('0x8'));module[_0x6e70('0x9')]=router; \ No newline at end of file diff --git a/server/api/integration/integration.attributes.js b/server/api/integration/integration.attributes.js new file mode 100644 index 0000000..8895713 --- /dev/null +++ b/server/api/integration/integration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2cb5=['BOOLEAN','state','STRING','unique_name_and_version','app.js','INTEGER'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0x2cb5,0x176));var _0x52cb=function(_0x5ce15c,_0x19c917){_0x5ce15c=_0x5ce15c-0x0;var _0x36e4f5=_0x2cb5[_0x5ce15c];return _0x36e4f5;};'use strict';var Sequelize=require('sequelize');module['exports']={'name':{'type':Sequelize[_0x52cb('0x0')],'allowNull':![],'unique':_0x52cb('0x1')},'version':{'type':Sequelize['STRING'],'allowNull':![],'unique':_0x52cb('0x1')},'main':{'type':Sequelize[_0x52cb('0x0')],'defaultValue':_0x52cb('0x2')},'filename':{'type':Sequelize['STRING']},'path':{'type':Sequelize[_0x52cb('0x0')]},'type':{'type':Sequelize[_0x52cb('0x0')]},'size':{'type':Sequelize[_0x52cb('0x3')]},'active':{'type':Sequelize[_0x52cb('0x4')],'defaultValue':![]},'author':{'type':Sequelize['STRING']},'logo':{'type':Sequelize[_0x52cb('0x0')]},'state':{'type':Sequelize[_0x52cb('0x0')],'unique':_0x52cb('0x5')},'description':{'type':Sequelize[_0x52cb('0x0')]},'title':{'type':Sequelize[_0x52cb('0x0')]},'remoteUri':{'type':Sequelize[_0x52cb('0x0')]},'link':{'type':Sequelize[_0x52cb('0x0')],'defaultValue':'#'}}; \ No newline at end of file diff --git a/server/api/integration/integration.controller.js b/server/api/integration/integration.controller.js new file mode 100644 index 0000000..0562e87 --- /dev/null +++ b/server/api/integration/integration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc2c7=['nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','keys','find','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','Content-Range','reject','save','update','destroy','then','error','name','send','index','map','Integration','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xc2c7,0x134));var _0x7c2c=function(_0x44638a,_0x4fc76b){_0x44638a=_0x44638a-0x0;var _0x4ab003=_0xc2c7[_0x44638a];return _0x4ab003;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7c2c('0x0'));var zipdir=require(_0x7c2c('0x1'));var jsonpatch=require(_0x7c2c('0x2'));var rp=require(_0x7c2c('0x3'));var moment=require(_0x7c2c('0x4'));var BPromise=require(_0x7c2c('0x5'));var Mustache=require(_0x7c2c('0x6'));var util=require(_0x7c2c('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x7c2c('0x8'));var ejs=require(_0x7c2c('0x9'));var fs=require('fs');var fs_extra=require(_0x7c2c('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7c2c('0xb'));var deskjs=require(_0x7c2c('0xc'));var toCsv=require(_0x7c2c('0x8'));var querystring=require(_0x7c2c('0xd'));var Papa=require(_0x7c2c('0xe'));var Redis=require('ioredis');var authService=require(_0x7c2c('0xf'));var qs=require(_0x7c2c('0x10'));var as=require(_0x7c2c('0x11'));var hardwareService=require(_0x7c2c('0x12'));var logger=require(_0x7c2c('0x13'))(_0x7c2c('0x14'));var utils=require(_0x7c2c('0x15'));var config=require(_0x7c2c('0x16'));var licenseUtil=require(_0x7c2c('0x17'));var db=require(_0x7c2c('0x18'))['db'];function respondWithStatusCode(_0xae8441,_0x45847d){_0x45847d=_0x45847d||0xcc;return function(_0x68398a){if(_0x68398a){return _0xae8441[_0x7c2c('0x19')](_0x45847d);}return _0xae8441[_0x7c2c('0x1a')](_0x45847d)[_0x7c2c('0x1b')]();};}function respondWithResult(_0x4c4aaf,_0x5b5729){_0x5b5729=_0x5b5729||0xc8;return function(_0x102778){if(_0x102778){return _0x4c4aaf[_0x7c2c('0x1a')](_0x5b5729)[_0x7c2c('0x1c')](_0x102778);}};}function respondWithFilteredResult(_0x5ae94f,_0x11424c){return function(_0x206ecd){if(_0x206ecd){var _0x5e55e0=typeof _0x11424c[_0x7c2c('0x1d')]==='undefined'&&typeof _0x11424c[_0x7c2c('0x1e')]==='undefined';var _0x342ea2=_0x206ecd[_0x7c2c('0x1f')];var _0x14453f=_0x5e55e0?0x0:_0x11424c[_0x7c2c('0x1d')];var _0x17df4a=_0x5e55e0?_0x206ecd[_0x7c2c('0x1f')]:_0x11424c[_0x7c2c('0x1d')]+_0x11424c[_0x7c2c('0x1e')];var _0x2d356e;if(_0x17df4a>=_0x342ea2){_0x17df4a=_0x342ea2;_0x2d356e=0xc8;}else{_0x2d356e=0xce;}_0x5ae94f[_0x7c2c('0x1a')](_0x2d356e);return _0x5ae94f[_0x7c2c('0x20')](_0x7c2c('0x21'),_0x14453f+'-'+_0x17df4a+'/'+_0x342ea2)['json'](_0x206ecd);}return null;};}function patchUpdates(_0x1c5491){return function(_0x4adb62){try{jsonpatch['apply'](_0x4adb62,_0x1c5491,!![]);}catch(_0x15ae33){return BPromise[_0x7c2c('0x22')](_0x15ae33);}return _0x4adb62[_0x7c2c('0x23')]();};}function saveUpdates(_0x38ae30,_0x41552f){return function(_0x1883b5){if(_0x1883b5){return _0x1883b5[_0x7c2c('0x24')](_0x38ae30)['then'](function(_0x10c356){return _0x10c356;});}return null;};}function removeEntity(_0x4dedd8,_0x302c93){return function(_0x57f510){if(_0x57f510){return _0x57f510[_0x7c2c('0x25')]()[_0x7c2c('0x26')](function(){_0x4dedd8[_0x7c2c('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4d6ec7,_0x31a50c){return function(_0x30c53e){if(!_0x30c53e){_0x4d6ec7[_0x7c2c('0x19')](0x194);}return _0x30c53e;};}function handleError(_0x150690,_0x31d8f3){_0x31d8f3=_0x31d8f3||0x1f4;return function(_0xa8e145){logger[_0x7c2c('0x27')](_0xa8e145['stack']);if(_0xa8e145[_0x7c2c('0x28')]){delete _0xa8e145[_0x7c2c('0x28')];}_0x150690[_0x7c2c('0x1a')](_0x31d8f3)[_0x7c2c('0x29')](_0xa8e145);};}exports[_0x7c2c('0x2a')]=function(_0x1f8846,_0xf2bfd1){var _0x26f472={},_0xa040ff={},_0x5769ec={'count':0x0,'rows':[]};var _0x465ad6=_[_0x7c2c('0x2b')](db[_0x7c2c('0x2c')][_0x7c2c('0x2d')],function(_0x53ad23){return{'name':_0x53ad23[_0x7c2c('0x2e')],'type':_0x53ad23[_0x7c2c('0x2f')][_0x7c2c('0x30')]};});_0xa040ff[_0x7c2c('0x31')]=_[_0x7c2c('0x2b')](_0x465ad6,_0x7c2c('0x28'));_0xa040ff[_0x7c2c('0x32')]=_['keys'](_0x1f8846[_0x7c2c('0x32')]);_0xa040ff[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0xa040ff[_0x7c2c('0x31')],_0xa040ff[_0x7c2c('0x32')]);_0x26f472['attributes']=_['intersection'](_0xa040ff[_0x7c2c('0x31')],qs['fields'](_0x1f8846['query'][_0x7c2c('0x35')]));_0x26f472[_0x7c2c('0x36')]=_0x26f472[_0x7c2c('0x36')][_0x7c2c('0x37')]?_0x26f472['attributes']:_0xa040ff[_0x7c2c('0x31')];if(!_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x38')](_0x7c2c('0x39'))){_0x26f472[_0x7c2c('0x1e')]=qs[_0x7c2c('0x1e')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1e')]);_0x26f472[_0x7c2c('0x1d')]=qs[_0x7c2c('0x1d')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1d')]);}_0x26f472[_0x7c2c('0x3a')]=qs['sort'](_0x1f8846['query'][_0x7c2c('0x3b')]);_0x26f472['where']=qs['filters'](_['pick'](_0x1f8846[_0x7c2c('0x32')],_0xa040ff[_0x7c2c('0x33')]),_0x465ad6);if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]){_0x26f472[_0x7c2c('0x3d')]=_[_0x7c2c('0x3e')](_0x26f472[_0x7c2c('0x3d')],{'$or':_[_0x7c2c('0x2b')](_0x465ad6,function(_0x2b6520){if(_0x2b6520[_0x7c2c('0x2f')]!==_0x7c2c('0x3f')){var _0x58696a={};_0x58696a[_0x2b6520['name']]={'$like':'%'+_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]+'%'};return _0x58696a;}})});}_0x26f472=_[_0x7c2c('0x3e')]({},_0x26f472,_0x1f8846[_0x7c2c('0x40')]);var _0x5e8c96={'where':_0x26f472[_0x7c2c('0x3d')]};return db[_0x7c2c('0x2c')][_0x7c2c('0x1f')](_0x5e8c96)[_0x7c2c('0x26')](function(_0x18e288){_0x5769ec[_0x7c2c('0x1f')]=_0x18e288;if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x26f472[_0x7c2c('0x42')]=[{'all':!![]}];}return db['Integration'][_0x7c2c('0x43')](_0x26f472);})['then'](function(_0x2c3f40){_0x5769ec[_0x7c2c('0x44')]=_0x2c3f40;return _0x5769ec;})['then'](respondWithFilteredResult(_0xf2bfd1,_0x26f472))[_0x7c2c('0x45')](handleError(_0xf2bfd1,null));};exports['show']=function(_0x3014fb,_0x33b2be){var _0x9b9813={'raw':![],'where':{'id':_0x3014fb['params']['id']}},_0x26351e={};_0x26351e[_0x7c2c('0x31')]=_['keys'](db['Integration'][_0x7c2c('0x2d')]);_0x26351e[_0x7c2c('0x32')]=_[_0x7c2c('0x46')](_0x3014fb['query']);_0x26351e[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0x26351e['model'],_0x26351e[_0x7c2c('0x32')]);_0x9b9813['attributes']=_[_0x7c2c('0x34')](_0x26351e[_0x7c2c('0x31')],qs['fields'](_0x3014fb['query'][_0x7c2c('0x35')]));_0x9b9813[_0x7c2c('0x36')]=_0x9b9813['attributes'][_0x7c2c('0x37')]?_0x9b9813['attributes']:_0x26351e['model'];if(_0x3014fb[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x9b9813[_0x7c2c('0x42')]=[{'all':!![]}];}_0x9b9813=_[_0x7c2c('0x3e')]({},_0x9b9813,_0x3014fb[_0x7c2c('0x40')]);return db[_0x7c2c('0x2c')][_0x7c2c('0x47')](_0x9b9813)[_0x7c2c('0x26')](handleEntityNotFound(_0x33b2be,null))[_0x7c2c('0x26')](respondWithResult(_0x33b2be,null))['catch'](handleError(_0x33b2be,null));};exports['create']=function(_0xeb067b,_0x3091bd){return db[_0x7c2c('0x2c')]['create'](_0xeb067b['body'],{})[_0x7c2c('0x26')](respondWithResult(_0x3091bd,0xc9))[_0x7c2c('0x45')](handleError(_0x3091bd,null));};exports[_0x7c2c('0x24')]=function(_0x2b79d5,_0x5f3de8){if(_0x2b79d5['body']['id']){delete _0x2b79d5['body']['id'];}return db[_0x7c2c('0x2c')][_0x7c2c('0x47')]({'where':{'id':_0x2b79d5[_0x7c2c('0x48')]['id']}})[_0x7c2c('0x26')](handleEntityNotFound(_0x5f3de8,null))[_0x7c2c('0x26')](saveUpdates(_0x2b79d5['body'],null))[_0x7c2c('0x26')](respondWithResult(_0x5f3de8,null))[_0x7c2c('0x45')](handleError(_0x5f3de8,null));};exports['destroy']=function(_0x19621a,_0x56e09d){return db[_0x7c2c('0x2c')][_0x7c2c('0x47')]({'where':{'id':_0x19621a[_0x7c2c('0x48')]['id']}})['then'](handleEntityNotFound(_0x56e09d,null))['then'](removeEntity(_0x56e09d,null))[_0x7c2c('0x45')](handleError(_0x56e09d,null));}; \ No newline at end of file diff --git a/server/api/integration/integration.model.js b/server/api/integration/integration.model.js new file mode 100644 index 0000000..67a0a15 --- /dev/null +++ b/server/api/integration/integration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x76c3=['../../config/environment','exports','Integration','lodash','util','../../config/logger','api','moment','request-promise'];(function(_0xc6be3a,_0x540e05){var _0x56a310=function(_0x50a144){while(--_0x50a144){_0xc6be3a['push'](_0xc6be3a['shift']());}};_0x56a310(++_0x540e05);}(_0x76c3,0xb7));var _0x376c=function(_0x5410f4,_0x560cb2){_0x5410f4=_0x5410f4-0x0;var _0x2fe39e=_0x76c3[_0x5410f4];return _0x2fe39e;};'use strict';var _=require(_0x376c('0x0'));var util=require(_0x376c('0x1'));var logger=require(_0x376c('0x2'))(_0x376c('0x3'));var moment=require(_0x376c('0x4'));var BPromise=require('bluebird');var rp=require(_0x376c('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x376c('0x6'));var attributes=require('./integration.attributes');module[_0x376c('0x7')]=function(_0x37f3ca,_0x451783){return _0x37f3ca['define'](_0x376c('0x8'),attributes,{'tableName':'integrations','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/integration/integration.rpc.js b/server/api/integration/integration.rpc.js new file mode 100644 index 0000000..786bef5 --- /dev/null +++ b/server/api/integration/integration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdb28=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then','Integration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','catch','lodash','util'];(function(_0xdb631a,_0x5a2173){var _0x1c85f0=function(_0x2a3c4d){while(--_0x2a3c4d){_0xdb631a['push'](_0xdb631a['shift']());}};_0x1c85f0(++_0x5a2173);}(_0xdb28,0x106));var _0x8db2=function(_0x117787,_0x4e871f){_0x117787=_0x117787-0x0;var _0xb5a78=_0xdb28[_0x117787];return _0xb5a78;};'use strict';var _=require(_0x8db2('0x0'));var util=require(_0x8db2('0x1'));var moment=require(_0x8db2('0x2'));var BPromise=require(_0x8db2('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8db2('0x4'));var db=require(_0x8db2('0x5'))['db'];var utils=require(_0x8db2('0x6'));var logger=require(_0x8db2('0x7'))(_0x8db2('0x8'));var config=require('../../config/environment');var jayson=require(_0x8db2('0x9'));var client=jayson[_0x8db2('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x494b40,_0x477f50,_0x46932f){return new BPromise(function(_0x131537,_0x29f698){return client[_0x8db2('0xb')](_0x494b40,_0x46932f)[_0x8db2('0xc')](function(_0x126c78){logger['info'](_0x8db2('0xd'),_0x477f50,_0x8db2('0xe'));logger[_0x8db2('0xf')]('Integration,\x20%s,\x20%s,\x20%s',_0x477f50,_0x8db2('0xe'),JSON[_0x8db2('0x10')](_0x126c78));if(_0x126c78['error']){if(_0x126c78[_0x8db2('0x11')][_0x8db2('0x12')]===0x1f4){logger[_0x8db2('0x11')](_0x8db2('0xd'),_0x477f50,_0x126c78[_0x8db2('0x11')]['message']);return _0x29f698(_0x126c78['error'][_0x8db2('0x13')]);}logger[_0x8db2('0x11')](_0x8db2('0xd'),_0x477f50,_0x126c78[_0x8db2('0x11')][_0x8db2('0x13')]);return _0x131537(_0x126c78[_0x8db2('0x11')][_0x8db2('0x13')]);}else{logger[_0x8db2('0x14')](_0x8db2('0xd'),_0x477f50,_0x8db2('0xe'));_0x131537(_0x126c78['result'][_0x8db2('0x13')]);}})[_0x8db2('0x15')](function(_0x48101e){logger[_0x8db2('0x11')](_0x8db2('0xd'),_0x477f50,_0x48101e);_0x29f698(_0x48101e);});});} \ No newline at end of file diff --git a/server/api/integrationReport/index.js b/server/api/integrationReport/index.js new file mode 100644 index 0000000..28c8ebf --- /dev/null +++ b/server/api/integrationReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0295=['isAuthenticated','index','post','create','put','/:id','update','delete','destroy','exports','multer','connect-timeout','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./integrationReport.controller','get'];(function(_0x9dfc10,_0x19c2d5){var _0x4f938a=function(_0x12b1e5){while(--_0x12b1e5){_0x9dfc10['push'](_0x9dfc10['shift']());}};_0x4f938a(++_0x19c2d5);}(_0x0295,0x1f0));var _0x5029=function(_0x2cf818,_0x1cd613){_0x2cf818=_0x2cf818-0x0;var _0x4c1fc7=_0x0295[_0x2cf818];return _0x4c1fc7;};'use strict';var multer=require(_0x5029('0x0'));var util=require('util');var path=require('path');var timeout=require(_0x5029('0x1'));var express=require('express');var router=express['Router']();var fs_extra=require(_0x5029('0x2'));var auth=require(_0x5029('0x3'));var interaction=require(_0x5029('0x4'));var config=require(_0x5029('0x5'));var controller=require(_0x5029('0x6'));router[_0x5029('0x7')]('/',auth[_0x5029('0x8')](),controller[_0x5029('0x9')]);router[_0x5029('0x7')]('/describe',auth['isAuthenticated'](),controller['describe']);router[_0x5029('0x7')]('/:id',auth[_0x5029('0x8')](),controller['show']);router[_0x5029('0xa')]('/',auth['isAuthenticated'](),controller[_0x5029('0xb')]);router[_0x5029('0xc')](_0x5029('0xd'),auth['isAuthenticated'](),controller[_0x5029('0xe')]);router[_0x5029('0xf')](_0x5029('0xd'),auth['isAuthenticated'](),controller[_0x5029('0x10')]);module[_0x5029('0x11')]=router; \ No newline at end of file diff --git a/server/api/integrationReport/integrationReport.attributes.js b/server/api/integrationReport/integrationReport.attributes.js new file mode 100644 index 0000000..a097220 --- /dev/null +++ b/server/api/integrationReport/integrationReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6752=['exports','STRING','INTEGER','DATE','BOOLEAN','TEXT','ENUM','SENT','SENDING','RECEIVED','FAILED','sequelize'];(function(_0xb30d1d,_0x138303){var _0x177c6b=function(_0x3527e3){while(--_0x3527e3){_0xb30d1d['push'](_0xb30d1d['shift']());}};_0x177c6b(++_0x138303);}(_0x6752,0x1af));var _0x2675=function(_0x54cd21,_0x2b5c7b){_0x54cd21=_0x54cd21-0x0;var _0x151a55=_0x6752[_0x54cd21];return _0x151a55;};'use strict';var Sequelize=require(_0x2675('0x0'));module[_0x2675('0x1')]={'integration':{'type':Sequelize[_0x2675('0x2')]},'eventChannel':{'type':Sequelize['STRING']},'exitStatus':{'type':Sequelize['STRING']},'ticketId':{'type':Sequelize['STRING']},'integrationId':{'type':Sequelize[_0x2675('0x3')]},'contacts':{'type':Sequelize['STRING']},'uniqueid':{'type':Sequelize['STRING']},'calleridnum':{'type':Sequelize[_0x2675('0x2')]},'calleridname':{'type':Sequelize[_0x2675('0x2')]},'queue':{'type':Sequelize[_0x2675('0x2')]},'interface':{'type':Sequelize['STRING']},'membername':{'type':Sequelize['STRING']},'agentcalledAt':{'type':Sequelize[_0x2675('0x4')]},'agentconnectAt':{'type':Sequelize['DATE']},'holdtime':{'type':Sequelize[_0x2675('0x3')]},'agentcomplete':{'type':Sequelize[_0x2675('0x5')],'defaultValue':![]},'agentcompleteAt':{'type':Sequelize[_0x2675('0x4')]},'talktime':{'type':Sequelize[_0x2675('0x3')]},'agentacw':{'type':Sequelize[_0x2675('0x5')],'defaultValue':![]},'acwtime':{'type':Sequelize[_0x2675('0x3')]},'reason':{'type':Sequelize[_0x2675('0x2')]},'agentringnoanswer':{'type':Sequelize[_0x2675('0x5')],'defaultValue':![]},'agentringnoanswerAt':{'type':Sequelize['DATE']},'agentdump':{'type':Sequelize[_0x2675('0x5')],'defaultValue':![]},'agentdumpAt':{'type':Sequelize[_0x2675('0x4')]},'lastevent':{'type':Sequelize['STRING']},'channel':{'type':Sequelize['STRING']},'channelstate':{'type':Sequelize[_0x2675('0x3')]},'channelstatedesc':{'type':Sequelize['STRING']},'connectedlinenum':{'type':Sequelize[_0x2675('0x2')]},'connectedlinename':{'type':Sequelize['STRING']},'language':{'type':Sequelize[_0x2675('0x2')]},'accountcode':{'type':Sequelize[_0x2675('0x2')]},'context':{'type':Sequelize[_0x2675('0x2')]},'exten':{'type':Sequelize[_0x2675('0x2')]},'priority':{'type':Sequelize[_0x2675('0x2')]},'destchannel':{'type':Sequelize[_0x2675('0x2')]},'destchannelstate':{'type':Sequelize[_0x2675('0x3')]},'destchannelstatedesc':{'type':Sequelize[_0x2675('0x2')]},'destcalleridnum':{'type':Sequelize[_0x2675('0x2')]},'destcalleridname':{'type':Sequelize['STRING']},'destconnectedlinenum':{'type':Sequelize[_0x2675('0x2')]},'destconnectedlinename':{'type':Sequelize[_0x2675('0x2')]},'destlanguage':{'type':Sequelize['STRING']},'destaccountcode':{'type':Sequelize[_0x2675('0x2')]},'destcontext':{'type':Sequelize[_0x2675('0x2')]},'destexten':{'type':Sequelize['STRING']},'destpriority':{'type':Sequelize[_0x2675('0x2')]},'destuniqueid':{'type':Sequelize[_0x2675('0x2')]},'messageId':{'type':Sequelize['STRING']},'inReplyTo':{'type':Sequelize[_0x2675('0x2')]},'subject':{'type':Sequelize[_0x2675('0x2')]},'from':{'type':Sequelize[_0x2675('0x2')]},'to':{'type':Sequelize[_0x2675('0x2')]},'cc':{'type':Sequelize['STRING']},'attachment':{'type':Sequelize[_0x2675('0x6')]},'html':{'type':Sequelize[_0x2675('0x6')]},'text':{'type':Sequelize[_0x2675('0x6')]},'status':{'type':Sequelize[_0x2675('0x7')](_0x2675('0x8'),_0x2675('0x9'),_0x2675('0xa'),_0x2675('0xb'))},'url':{'type':Sequelize['STRING']},'app':{'type':Sequelize[_0x2675('0x2')]},'appdata':{'type':Sequelize[_0x2675('0x2')]},'projectId':{'type':Sequelize[_0x2675('0x3')]}}; \ No newline at end of file diff --git a/server/api/integrationReport/integrationReport.controller.js b/server/api/integrationReport/integrationReport.controller.js new file mode 100644 index 0000000..1081ae7 --- /dev/null +++ b/server/api/integrationReport/integrationReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7b19=['save','then','destroy','sendStatus','name','send','map','IntegrationReport','rawAttributes','fieldName','type','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','params','find','body','update','describe','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','status','end','json','offset','undefined','limit','count','Content-Range','apply'];(function(_0x4fc421,_0x94e88){var _0x8c6d63=function(_0x5b8b42){while(--_0x5b8b42){_0x4fc421['push'](_0x4fc421['shift']());}};_0x8c6d63(++_0x94e88);}(_0x7b19,0x139));var _0x97b1=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7b19[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x97b1('0x0'));var zipdir=require(_0x97b1('0x1'));var jsonpatch=require(_0x97b1('0x2'));var rp=require('request-promise');var moment=require(_0x97b1('0x3'));var BPromise=require(_0x97b1('0x4'));var Mustache=require(_0x97b1('0x5'));var util=require('util');var path=require(_0x97b1('0x6'));var sox=require(_0x97b1('0x7'));var csv=require(_0x97b1('0x8'));var ejs=require(_0x97b1('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x97b1('0xa'));var crypto=require(_0x97b1('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x97b1('0xc'));var toCsv=require(_0x97b1('0x8'));var querystring=require(_0x97b1('0xd'));var Papa=require(_0x97b1('0xe'));var Redis=require(_0x97b1('0xf'));var authService=require(_0x97b1('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x97b1('0x11'));var hardwareService=require(_0x97b1('0x12'));var logger=require(_0x97b1('0x13'))(_0x97b1('0x14'));var utils=require(_0x97b1('0x15'));var config=require(_0x97b1('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4dd6a6,_0x38672e){_0x38672e=_0x38672e||0xcc;return function(_0x1af1ba){if(_0x1af1ba){return _0x4dd6a6['sendStatus'](_0x38672e);}return _0x4dd6a6[_0x97b1('0x17')](_0x38672e)[_0x97b1('0x18')]();};}function respondWithResult(_0x17539f,_0x1512a6){_0x1512a6=_0x1512a6||0xc8;return function(_0x16089b){if(_0x16089b){return _0x17539f[_0x97b1('0x17')](_0x1512a6)[_0x97b1('0x19')](_0x16089b);}};}function respondWithFilteredResult(_0x2d6344,_0x140210){return function(_0x12c32f){if(_0x12c32f){var _0x52c91a=typeof _0x140210[_0x97b1('0x1a')]===_0x97b1('0x1b')&&typeof _0x140210[_0x97b1('0x1c')]===_0x97b1('0x1b');var _0x5ac532=_0x12c32f[_0x97b1('0x1d')];var _0x5884fd=_0x52c91a?0x0:_0x140210['offset'];var _0x3480e1=_0x52c91a?_0x12c32f[_0x97b1('0x1d')]:_0x140210['offset']+_0x140210[_0x97b1('0x1c')];var _0x555ac8;if(_0x3480e1>=_0x5ac532){_0x3480e1=_0x5ac532;_0x555ac8=0xc8;}else{_0x555ac8=0xce;}_0x2d6344[_0x97b1('0x17')](_0x555ac8);return _0x2d6344['set'](_0x97b1('0x1e'),_0x5884fd+'-'+_0x3480e1+'/'+_0x5ac532)[_0x97b1('0x19')](_0x12c32f);}return null;};}function patchUpdates(_0x1a6385){return function(_0x50ea64){try{jsonpatch[_0x97b1('0x1f')](_0x50ea64,_0x1a6385,!![]);}catch(_0x1e636f){return BPromise['reject'](_0x1e636f);}return _0x50ea64[_0x97b1('0x20')]();};}function saveUpdates(_0x1b0544,_0x201da2){return function(_0x193807){if(_0x193807){return _0x193807['update'](_0x1b0544)[_0x97b1('0x21')](function(_0xd4f1c9){return _0xd4f1c9;});}return null;};}function removeEntity(_0x1a8a28,_0x4cdfd8){return function(_0x3d7192){if(_0x3d7192){return _0x3d7192[_0x97b1('0x22')]()[_0x97b1('0x21')](function(){_0x1a8a28[_0x97b1('0x17')](0xcc)[_0x97b1('0x18')]();});}};}function handleEntityNotFound(_0x1d9690,_0x9d9e24){return function(_0x16f096){if(!_0x16f096){_0x1d9690[_0x97b1('0x23')](0x194);}return _0x16f096;};}function handleError(_0xe340ab,_0x1dbd0c){_0x1dbd0c=_0x1dbd0c||0x1f4;return function(_0x394841){logger['error'](_0x394841['stack']);if(_0x394841[_0x97b1('0x24')]){delete _0x394841[_0x97b1('0x24')];}_0xe340ab[_0x97b1('0x17')](_0x1dbd0c)[_0x97b1('0x25')](_0x394841);};}exports['index']=function(_0x5e43df,_0x28edd2){var _0x4a055e={},_0x15185a={},_0x46e6de={'count':0x0,'rows':[]};var _0x2523d5=_[_0x97b1('0x26')](db[_0x97b1('0x27')][_0x97b1('0x28')],function(_0x782036){return{'name':_0x782036[_0x97b1('0x29')],'type':_0x782036[_0x97b1('0x2a')]['key']};});_0x15185a[_0x97b1('0x2b')]=_[_0x97b1('0x26')](_0x2523d5,_0x97b1('0x24'));_0x15185a[_0x97b1('0x2c')]=_[_0x97b1('0x2d')](_0x5e43df['query']);_0x15185a['filters']=_[_0x97b1('0x2e')](_0x15185a['model'],_0x15185a['query']);_0x4a055e[_0x97b1('0x2f')]=_[_0x97b1('0x2e')](_0x15185a[_0x97b1('0x2b')],qs[_0x97b1('0x30')](_0x5e43df[_0x97b1('0x2c')][_0x97b1('0x30')]));_0x4a055e['attributes']=_0x4a055e[_0x97b1('0x2f')]['length']?_0x4a055e['attributes']:_0x15185a[_0x97b1('0x2b')];if(!_0x5e43df[_0x97b1('0x2c')][_0x97b1('0x31')](_0x97b1('0x32'))){_0x4a055e[_0x97b1('0x1c')]=qs['limit'](_0x5e43df[_0x97b1('0x2c')]['limit']);_0x4a055e[_0x97b1('0x1a')]=qs[_0x97b1('0x1a')](_0x5e43df[_0x97b1('0x2c')][_0x97b1('0x1a')]);}_0x4a055e[_0x97b1('0x33')]=qs[_0x97b1('0x34')](_0x5e43df[_0x97b1('0x2c')][_0x97b1('0x34')]);_0x4a055e[_0x97b1('0x35')]=qs[_0x97b1('0x36')](_[_0x97b1('0x37')](_0x5e43df[_0x97b1('0x2c')],_0x15185a[_0x97b1('0x36')]),_0x2523d5);if(_0x5e43df['query'][_0x97b1('0x38')]){_0x4a055e['where']=_[_0x97b1('0x39')](_0x4a055e[_0x97b1('0x35')],{'$or':_['map'](_0x2523d5,function(_0xf17c01){if(_0xf17c01['type']!==_0x97b1('0x3a')){var _0x19dedb={};_0x19dedb[_0xf17c01['name']]={'$like':'%'+_0x5e43df['query'][_0x97b1('0x38')]+'%'};return _0x19dedb;}})});}_0x4a055e=_[_0x97b1('0x39')]({},_0x4a055e,_0x5e43df['options']);var _0x4684d0={'where':_0x4a055e[_0x97b1('0x35')]};return db[_0x97b1('0x27')][_0x97b1('0x1d')](_0x4684d0)['then'](function(_0x118bf7){_0x46e6de[_0x97b1('0x1d')]=_0x118bf7;if(_0x5e43df[_0x97b1('0x2c')][_0x97b1('0x3b')]){_0x4a055e[_0x97b1('0x3c')]=[{'all':!![]}];}return db[_0x97b1('0x27')][_0x97b1('0x3d')](_0x4a055e);})[_0x97b1('0x21')](function(_0x5c6a76){_0x46e6de[_0x97b1('0x3e')]=_0x5c6a76;return _0x46e6de;})['then'](respondWithFilteredResult(_0x28edd2,_0x4a055e))[_0x97b1('0x3f')](handleError(_0x28edd2,null));};exports['show']=function(_0x266f36,_0x1cda34){var _0x26048c={'raw':![],'where':{'id':_0x266f36[_0x97b1('0x40')]['id']}},_0x2b6ba3={};_0x2b6ba3[_0x97b1('0x2b')]=_[_0x97b1('0x2d')](db['IntegrationReport'][_0x97b1('0x28')]);_0x2b6ba3[_0x97b1('0x2c')]=_[_0x97b1('0x2d')](_0x266f36[_0x97b1('0x2c')]);_0x2b6ba3[_0x97b1('0x36')]=_[_0x97b1('0x2e')](_0x2b6ba3['model'],_0x2b6ba3[_0x97b1('0x2c')]);_0x26048c[_0x97b1('0x2f')]=_[_0x97b1('0x2e')](_0x2b6ba3[_0x97b1('0x2b')],qs[_0x97b1('0x30')](_0x266f36[_0x97b1('0x2c')][_0x97b1('0x30')]));_0x26048c[_0x97b1('0x2f')]=_0x26048c[_0x97b1('0x2f')]['length']?_0x26048c['attributes']:_0x2b6ba3[_0x97b1('0x2b')];if(_0x266f36[_0x97b1('0x2c')][_0x97b1('0x3b')]){_0x26048c[_0x97b1('0x3c')]=[{'all':!![]}];}_0x26048c=_[_0x97b1('0x39')]({},_0x26048c,_0x266f36['options']);return db['IntegrationReport'][_0x97b1('0x41')](_0x26048c)[_0x97b1('0x21')](handleEntityNotFound(_0x1cda34,null))[_0x97b1('0x21')](respondWithResult(_0x1cda34,null))[_0x97b1('0x3f')](handleError(_0x1cda34,null));};exports['create']=function(_0x459297,_0x3e2428){return db[_0x97b1('0x27')]['create'](_0x459297[_0x97b1('0x42')],{})[_0x97b1('0x21')](respondWithResult(_0x3e2428,0xc9))[_0x97b1('0x3f')](handleError(_0x3e2428,null));};exports[_0x97b1('0x43')]=function(_0x4e3405,_0x202183){if(_0x4e3405[_0x97b1('0x42')]['id']){delete _0x4e3405[_0x97b1('0x42')]['id'];}return db['IntegrationReport'][_0x97b1('0x41')]({'where':{'id':_0x4e3405[_0x97b1('0x40')]['id']}})[_0x97b1('0x21')](handleEntityNotFound(_0x202183,null))['then'](saveUpdates(_0x4e3405[_0x97b1('0x42')],null))[_0x97b1('0x21')](respondWithResult(_0x202183,null))[_0x97b1('0x3f')](handleError(_0x202183,null));};exports['destroy']=function(_0x2dc47c,_0x42b78f){return db[_0x97b1('0x27')][_0x97b1('0x41')]({'where':{'id':_0x2dc47c[_0x97b1('0x40')]['id']}})['then'](handleEntityNotFound(_0x42b78f,null))['then'](removeEntity(_0x42b78f,null))[_0x97b1('0x3f')](handleError(_0x42b78f,null));};exports['describe']=function(_0x5b24de,_0xa7a25b){return db[_0x97b1('0x27')][_0x97b1('0x44')]()['then'](respondWithResult(_0xa7a25b,null))['catch'](handleError(_0xa7a25b,null));}; \ No newline at end of file diff --git a/server/api/integrationReport/integrationReport.model.js b/server/api/integrationReport/integrationReport.model.js new file mode 100644 index 0000000..11a38da --- /dev/null +++ b/server/api/integrationReport/integrationReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1c78=['exports','lodash','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','./integrationReport.attributes'];(function(_0x515d16,_0x4dc95e){var _0x789eff=function(_0x5badd1){while(--_0x5badd1){_0x515d16['push'](_0x515d16['shift']());}};_0x789eff(++_0x4dc95e);}(_0x1c78,0x1eb));var _0x81c7=function(_0x16d10f,_0x2ba2d5){_0x16d10f=_0x16d10f-0x0;var _0x50c823=_0x1c78[_0x16d10f];return _0x50c823;};'use strict';var _=require(_0x81c7('0x0'));var util=require('util');var logger=require(_0x81c7('0x1'))(_0x81c7('0x2'));var moment=require(_0x81c7('0x3'));var BPromise=require(_0x81c7('0x4'));var rp=require(_0x81c7('0x5'));var fs=require('fs');var path=require(_0x81c7('0x6'));var rimraf=require(_0x81c7('0x7'));var config=require('../../config/environment');var attributes=require(_0x81c7('0x8'));module[_0x81c7('0x9')]=function(_0x4799c7,_0x53dcc4){return _0x4799c7['define']('IntegrationReport',attributes,{'tableName':'report_integration','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/integrationReport/integrationReport.rpc.js b/server/api/integrationReport/integrationReport.rpc.js new file mode 100644 index 0000000..ccfe95d --- /dev/null +++ b/server/api/integrationReport/integrationReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x53ec=['error','message','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','client','request','then','info','IntegrationReport,\x20%s,\x20%s','request\x20sent','debug','stringify','code'];(function(_0x307d86,_0x9264f2){var _0x361745=function(_0x1b64e1){while(--_0x1b64e1){_0x307d86['push'](_0x307d86['shift']());}};_0x361745(++_0x9264f2);}(_0x53ec,0x192));var _0xc53e=function(_0x2781b0,_0x4ec0d2){_0x2781b0=_0x2781b0-0x0;var _0xb532ba=_0x53ec[_0x2781b0];return _0xb532ba;};'use strict';var _=require(_0xc53e('0x0'));var util=require(_0xc53e('0x1'));var moment=require(_0xc53e('0x2'));var BPromise=require(_0xc53e('0x3'));var rs=require(_0xc53e('0x4'));var fs=require('fs');var Redis=require(_0xc53e('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xc53e('0x6'));var logger=require('../../config/logger')(_0xc53e('0x7'));var config=require(_0xc53e('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc53e('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x41a9e8,_0x2de88b,_0x5d3b28){return new BPromise(function(_0x1616ac,_0x1ac6c0){return client[_0xc53e('0xa')](_0x41a9e8,_0x5d3b28)[_0xc53e('0xb')](function(_0xd9612){logger[_0xc53e('0xc')](_0xc53e('0xd'),_0x2de88b,_0xc53e('0xe'));logger[_0xc53e('0xf')]('IntegrationReport,\x20%s,\x20%s,\x20%s',_0x2de88b,'request\x20sent',JSON[_0xc53e('0x10')](_0xd9612));if(_0xd9612['error']){if(_0xd9612['error'][_0xc53e('0x11')]===0x1f4){logger[_0xc53e('0x12')](_0xc53e('0xd'),_0x2de88b,_0xd9612[_0xc53e('0x12')]['message']);return _0x1ac6c0(_0xd9612['error'][_0xc53e('0x13')]);}logger[_0xc53e('0x12')](_0xc53e('0xd'),_0x2de88b,_0xd9612[_0xc53e('0x12')][_0xc53e('0x13')]);return _0x1616ac(_0xd9612[_0xc53e('0x12')][_0xc53e('0x13')]);}else{logger[_0xc53e('0xc')](_0xc53e('0xd'),_0x2de88b,_0xc53e('0xe'));_0x1616ac(_0xd9612['result'][_0xc53e('0x13')]);}})[_0xc53e('0x14')](function(_0x535cd4){logger[_0xc53e('0x12')](_0xc53e('0xd'),_0x2de88b,_0x535cd4);_0x1ac6c0(_0x535cd4);});});} \ No newline at end of file diff --git a/server/api/interval/index.js b/server/api/interval/index.js new file mode 100644 index 0000000..a389fdc --- /dev/null +++ b/server/api/interval/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcf8c=['path','connect-timeout','express','Router','../../components/interaction/service','../../config/environment','./interval.controller','get','isAuthenticated','index','/:id','/:id/sub_intervals','getIntervals','post','create','/:id/sub_intervals/create_many','addIntervals','update','delete','exports','multer','util'];(function(_0x416412,_0x23d936){var _0x43473f=function(_0x295f91){while(--_0x295f91){_0x416412['push'](_0x416412['shift']());}};_0x43473f(++_0x23d936);}(_0xcf8c,0xf0));var _0xccf8=function(_0x22fdfd,_0x5304da){_0x22fdfd=_0x22fdfd-0x0;var _0x1385b3=_0xcf8c[_0x22fdfd];return _0x1385b3;};'use strict';var multer=require(_0xccf8('0x0'));var util=require(_0xccf8('0x1'));var path=require(_0xccf8('0x2'));var timeout=require(_0xccf8('0x3'));var express=require(_0xccf8('0x4'));var router=express[_0xccf8('0x5')]();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require(_0xccf8('0x6'));var config=require(_0xccf8('0x7'));var controller=require(_0xccf8('0x8'));router[_0xccf8('0x9')]('/',auth[_0xccf8('0xa')](),controller[_0xccf8('0xb')]);router[_0xccf8('0x9')](_0xccf8('0xc'),auth[_0xccf8('0xa')](),controller['show']);router['get'](_0xccf8('0xd'),auth[_0xccf8('0xa')](),controller[_0xccf8('0xe')]);router[_0xccf8('0xf')]('/',auth[_0xccf8('0xa')](),controller[_0xccf8('0x10')]);router['post']('/:id/sub_intervals',auth[_0xccf8('0xa')](),controller['addInterval']);router[_0xccf8('0xf')](_0xccf8('0x11'),auth['isAuthenticated'](),controller[_0xccf8('0x12')]);router['put']('/:id',auth[_0xccf8('0xa')](),controller[_0xccf8('0x13')]);router[_0xccf8('0x14')](_0xccf8('0xc'),auth[_0xccf8('0xa')](),controller['destroy']);module[_0xccf8('0x15')]=router; \ No newline at end of file diff --git a/server/api/interval/interval.attributes.js b/server/api/interval/interval.attributes.js new file mode 100644 index 0000000..9968a79 --- /dev/null +++ b/server/api/interval/interval.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8258=['sequelize','exports','STRING'];(function(_0x1f66fe,_0x54993d){var _0x1a6e3a=function(_0x2ca73d){while(--_0x2ca73d){_0x1f66fe['push'](_0x1f66fe['shift']());}};_0x1a6e3a(++_0x54993d);}(_0x8258,0x14a));var _0x8825=function(_0xb1110,_0x3bec00){_0xb1110=_0xb1110-0x0;var _0xacd8ba=_0x8258[_0xb1110];return _0xacd8ba;};'use strict';var Sequelize=require(_0x8825('0x0'));module[_0x8825('0x1')]={'name':{'type':Sequelize['STRING']},'description':{'type':Sequelize['STRING']},'interval':{'type':Sequelize[_0x8825('0x2')],'allowNull':!![]}}; \ No newline at end of file diff --git a/server/api/interval/interval.controller.js b/server/api/interval/interval.controller.js new file mode 100644 index 0000000..f4e878d --- /dev/null +++ b/server/api/interval/interval.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc0b=['moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../components/extensions/rewrite','status','end','json','offset','limit','count','Content-Range','apply','reject','save','update','then','Intervals','UserProfileResource','destroy','sendStatus','stack','name','send','index','Interval','rawAttributes','fieldName','key','model','map','query','keys','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','intersection','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addInterval','IntervalId','getIntervals','findOne','sequelize','transaction','rimraf','zip-dir','request-promise'];(function(_0x4b793c,_0x4bc7f9){var _0x4c79c9=function(_0x121a5d){while(--_0x121a5d){_0x4b793c['push'](_0x4b793c['shift']());}};_0x4c79c9(++_0x4bc7f9);}(_0xfc0b,0x16d));var _0xbfc0=function(_0x3ac8a4,_0x10bc3d){_0x3ac8a4=_0x3ac8a4-0x0;var _0x49105f=_0xfc0b[_0x3ac8a4];return _0x49105f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbfc0('0x0'));var zipdir=require(_0xbfc0('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbfc0('0x2'));var moment=require(_0xbfc0('0x3'));var BPromise=require(_0xbfc0('0x4'));var Mustache=require(_0xbfc0('0x5'));var util=require(_0xbfc0('0x6'));var path=require('path');var sox=require(_0xbfc0('0x7'));var csv=require(_0xbfc0('0x8'));var ejs=require(_0xbfc0('0x9'));var fs=require('fs');var fs_extra=require(_0xbfc0('0xa'));var _=require(_0xbfc0('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbfc0('0xc'));var deskjs=require(_0xbfc0('0xd'));var toCsv=require(_0xbfc0('0x8'));var querystring=require(_0xbfc0('0xe'));var Papa=require(_0xbfc0('0xf'));var Redis=require(_0xbfc0('0x10'));var authService=require(_0xbfc0('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xbfc0('0x12'));var hardwareService=require(_0xbfc0('0x13'));var logger=require(_0xbfc0('0x14'))(_0xbfc0('0x15'));var utils=require(_0xbfc0('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var extensions=require(_0xbfc0('0x17'));function respondWithStatusCode(_0x2db607,_0x55d619){_0x55d619=_0x55d619||0xcc;return function(_0x174c95){if(_0x174c95){return _0x2db607['sendStatus'](_0x55d619);}return _0x2db607[_0xbfc0('0x18')](_0x55d619)[_0xbfc0('0x19')]();};}function respondWithResult(_0x2f1c19,_0x229695){_0x229695=_0x229695||0xc8;return function(_0x342509){if(_0x342509){return _0x2f1c19[_0xbfc0('0x18')](_0x229695)[_0xbfc0('0x1a')](_0x342509);}};}function respondWithFilteredResult(_0x4c2de5,_0x36069a){return function(_0x31df80){if(_0x31df80){var _0x1d049d=typeof _0x36069a[_0xbfc0('0x1b')]==='undefined'&&typeof _0x36069a[_0xbfc0('0x1c')]==='undefined';var _0x3ec402=_0x31df80[_0xbfc0('0x1d')];var _0x25a3bb=_0x1d049d?0x0:_0x36069a[_0xbfc0('0x1b')];var _0x1374e9=_0x1d049d?_0x31df80[_0xbfc0('0x1d')]:_0x36069a['offset']+_0x36069a[_0xbfc0('0x1c')];var _0x55ab57;if(_0x1374e9>=_0x3ec402){_0x1374e9=_0x3ec402;_0x55ab57=0xc8;}else{_0x55ab57=0xce;}_0x4c2de5[_0xbfc0('0x18')](_0x55ab57);return _0x4c2de5['set'](_0xbfc0('0x1e'),_0x25a3bb+'-'+_0x1374e9+'/'+_0x3ec402)['json'](_0x31df80);}return null;};}function patchUpdates(_0x4a94be){return function(_0x2019ea){try{jsonpatch[_0xbfc0('0x1f')](_0x2019ea,_0x4a94be,!![]);}catch(_0x3a58aa){return BPromise[_0xbfc0('0x20')](_0x3a58aa);}return _0x2019ea[_0xbfc0('0x21')]();};}function saveUpdates(_0xf6a9e8,_0x232165){return function(_0xba8842){if(_0xba8842){return _0xba8842[_0xbfc0('0x22')](_0xf6a9e8)[_0xbfc0('0x23')](function(_0x2d10a1){return _0x2d10a1;});}return null;};}function removeEntity(_0x11b171,_0x3084da){return function(_0xd1af1){if(_0xd1af1){return _0xd1af1['destroy']()[_0xbfc0('0x23')](function(){var _0xc5e464=_0xd1af1['get']({'plain':!![]});var _0x46b720=_0xbfc0('0x24');return db[_0xbfc0('0x25')][_0xbfc0('0x26')]({'where':{'type':_0x46b720,'resourceId':_0xc5e464['id']}})[_0xbfc0('0x23')](function(){return _0xd1af1;});})['then'](function(){_0x11b171[_0xbfc0('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x339f59,_0x2f53fd){return function(_0x471cfa){if(!_0x471cfa){_0x339f59[_0xbfc0('0x27')](0x194);}return _0x471cfa;};}function handleError(_0x12a002,_0x70f97d){_0x70f97d=_0x70f97d||0x1f4;return function(_0x58b3d2){logger['error'](_0x58b3d2[_0xbfc0('0x28')]);if(_0x58b3d2[_0xbfc0('0x29')]){delete _0x58b3d2[_0xbfc0('0x29')];}_0x12a002['status'](_0x70f97d)[_0xbfc0('0x2a')](_0x58b3d2);};}exports[_0xbfc0('0x2b')]=function(_0x3da836,_0x403b23){var _0xb8cb15={},_0x85d443={},_0x3638d4={'count':0x0,'rows':[]};var _0x42fed5=_['map'](db[_0xbfc0('0x2c')][_0xbfc0('0x2d')],function(_0x3aa58b){return{'name':_0x3aa58b[_0xbfc0('0x2e')],'type':_0x3aa58b['type'][_0xbfc0('0x2f')]};});_0x85d443[_0xbfc0('0x30')]=_[_0xbfc0('0x31')](_0x42fed5,_0xbfc0('0x29'));_0x85d443[_0xbfc0('0x32')]=_[_0xbfc0('0x33')](_0x3da836[_0xbfc0('0x32')]);_0x85d443['filters']=_['intersection'](_0x85d443[_0xbfc0('0x30')],_0x85d443[_0xbfc0('0x32')]);_0xb8cb15[_0xbfc0('0x34')]=_['intersection'](_0x85d443[_0xbfc0('0x30')],qs[_0xbfc0('0x35')](_0x3da836[_0xbfc0('0x32')][_0xbfc0('0x35')]));_0xb8cb15['attributes']=_0xb8cb15[_0xbfc0('0x34')][_0xbfc0('0x36')]?_0xb8cb15[_0xbfc0('0x34')]:_0x85d443['model'];if(!_0x3da836['query'][_0xbfc0('0x37')](_0xbfc0('0x38'))){_0xb8cb15[_0xbfc0('0x1c')]=qs[_0xbfc0('0x1c')](_0x3da836[_0xbfc0('0x32')][_0xbfc0('0x1c')]);_0xb8cb15[_0xbfc0('0x1b')]=qs[_0xbfc0('0x1b')](_0x3da836[_0xbfc0('0x32')][_0xbfc0('0x1b')]);}_0xb8cb15[_0xbfc0('0x39')]=qs[_0xbfc0('0x3a')](_0x3da836['query'][_0xbfc0('0x3a')]);_0xb8cb15[_0xbfc0('0x3b')]=qs[_0xbfc0('0x3c')](_[_0xbfc0('0x3d')](_0x3da836[_0xbfc0('0x32')],_0x85d443['filters']),_0x42fed5);if(_0x3da836['query'][_0xbfc0('0x3e')]){_0xb8cb15[_0xbfc0('0x3b')]=_[_0xbfc0('0x3f')](_0xb8cb15[_0xbfc0('0x3b')],{'$or':_[_0xbfc0('0x31')](_0x42fed5,function(_0x3b62c0){if(_0x3b62c0['type']!==_0xbfc0('0x40')){var _0x144690={};_0x144690[_0x3b62c0[_0xbfc0('0x29')]]={'$like':'%'+_0x3da836[_0xbfc0('0x32')]['filter']+'%'};return _0x144690;}})});}_0xb8cb15=_[_0xbfc0('0x3f')]({},_0xb8cb15,_0x3da836['options']);var _0x6f1194={'where':_0xb8cb15['where']};return db['Interval'][_0xbfc0('0x1d')](_0x6f1194)[_0xbfc0('0x23')](function(_0x3c6203){_0x3638d4[_0xbfc0('0x1d')]=_0x3c6203;if(_0x3da836[_0xbfc0('0x32')][_0xbfc0('0x41')]){_0xb8cb15[_0xbfc0('0x42')]=[{'all':!![]}];}return db[_0xbfc0('0x2c')][_0xbfc0('0x43')](_0xb8cb15);})[_0xbfc0('0x23')](function(_0xe6dbd5){_0x3638d4[_0xbfc0('0x44')]=_0xe6dbd5;return _0x3638d4;})[_0xbfc0('0x23')](respondWithFilteredResult(_0x403b23,_0xb8cb15))[_0xbfc0('0x45')](handleError(_0x403b23,null));};exports[_0xbfc0('0x46')]=function(_0x550ed8,_0xe1fcdd){var _0x3bb706={'raw':!![],'where':{'id':_0x550ed8[_0xbfc0('0x47')]['id']}},_0x21421d={};_0x21421d[_0xbfc0('0x30')]=_['keys'](db['Interval'][_0xbfc0('0x2d')]);_0x21421d['query']=_[_0xbfc0('0x33')](_0x550ed8[_0xbfc0('0x32')]);_0x21421d[_0xbfc0('0x3c')]=_[_0xbfc0('0x48')](_0x21421d[_0xbfc0('0x30')],_0x21421d[_0xbfc0('0x32')]);_0x3bb706[_0xbfc0('0x34')]=_[_0xbfc0('0x48')](_0x21421d[_0xbfc0('0x30')],qs[_0xbfc0('0x35')](_0x550ed8[_0xbfc0('0x32')]['fields']));_0x3bb706[_0xbfc0('0x34')]=_0x3bb706[_0xbfc0('0x34')][_0xbfc0('0x36')]?_0x3bb706[_0xbfc0('0x34')]:_0x21421d['model'];if(_0x550ed8[_0xbfc0('0x32')][_0xbfc0('0x41')]){_0x3bb706['include']=[{'all':!![]}];}_0x3bb706=_[_0xbfc0('0x3f')]({},_0x3bb706,_0x550ed8[_0xbfc0('0x49')]);return db['Interval'][_0xbfc0('0x4a')](_0x3bb706)['then'](handleEntityNotFound(_0xe1fcdd,null))[_0xbfc0('0x23')](respondWithResult(_0xe1fcdd,null))['catch'](handleError(_0xe1fcdd,null));};exports['create']=function(_0x5b52db,_0x22e6c8){return db[_0xbfc0('0x2c')][_0xbfc0('0x4b')](_0x5b52db[_0xbfc0('0x4c')],{})[_0xbfc0('0x23')](function(_0x485187){var _0x1f8d1f=_0x5b52db[_0xbfc0('0x4d')]['get']({'plain':!![]});if(!_0x1f8d1f)throw new Error(_0xbfc0('0x4e'));if(_0x1f8d1f[_0xbfc0('0x4f')]===_0xbfc0('0x4d')){var _0x2ef0cd=_0x485187[_0xbfc0('0x50')]({'plain':!![]});var _0x48118a=_0xbfc0('0x24');return db[_0xbfc0('0x51')]['find']({'where':{'name':_0x48118a,'userProfileId':_0x1f8d1f[_0xbfc0('0x52')]},'raw':!![]})['then'](function(_0x437b4e){if(_0x437b4e&&_0x437b4e[_0xbfc0('0x53')]===0x0){return db[_0xbfc0('0x25')][_0xbfc0('0x4b')]({'name':_0x2ef0cd[_0xbfc0('0x29')],'resourceId':_0x2ef0cd['id'],'type':_0x437b4e[_0xbfc0('0x29')],'sectionId':_0x437b4e['id']},{})['then'](function(){return _0x485187;});}else{return _0x485187;}})[_0xbfc0('0x45')](function(_0x13a3b5){logger[_0xbfc0('0x54')](_0xbfc0('0x55'),_0x13a3b5);throw _0x13a3b5;});}return _0x485187;})[_0xbfc0('0x23')](respondWithResult(_0x22e6c8,0xc9))['catch'](handleError(_0x22e6c8,null));};exports[_0xbfc0('0x22')]=function(_0x1c8c51,_0x343c95){if(_0x1c8c51[_0xbfc0('0x4c')]['id']){delete _0x1c8c51[_0xbfc0('0x4c')]['id'];}return db[_0xbfc0('0x2c')][_0xbfc0('0x4a')]({'where':{'id':_0x1c8c51[_0xbfc0('0x47')]['id']}})[_0xbfc0('0x23')](handleEntityNotFound(_0x343c95,null))[_0xbfc0('0x23')](saveUpdates(_0x1c8c51['body'],null))[_0xbfc0('0x23')](respondWithResult(_0x343c95,null))['catch'](handleError(_0x343c95,null));};exports[_0xbfc0('0x26')]=function(_0x16229d,_0xe54b93){return db['Interval']['find']({'where':{'id':_0x16229d[_0xbfc0('0x47')]['id']}})[_0xbfc0('0x23')](handleEntityNotFound(_0xe54b93,null))[_0xbfc0('0x23')](removeEntity(_0xe54b93,null))[_0xbfc0('0x45')](handleError(_0xe54b93,null));};exports[_0xbfc0('0x56')]=function(_0x2f4641,_0x12779c,_0x1589a6){if(_0x2f4641[_0xbfc0('0x4c')]['id']){delete _0x2f4641[_0xbfc0('0x4c')]['id'];}return db[_0xbfc0('0x2c')][_0xbfc0('0x4a')]({'where':{'id':_0x2f4641['params']['id']}})[_0xbfc0('0x23')](handleEntityNotFound(_0x12779c,null))[_0xbfc0('0x23')](function(_0x5d7c2f){if(_0x5d7c2f){_0x2f4641['body'][_0xbfc0('0x57')]=_0x5d7c2f['id'];return db['Interval'][_0xbfc0('0x4b')](_0x2f4641[_0xbfc0('0x4c')]);}})[_0xbfc0('0x23')](respondWithResult(_0x12779c,null))[_0xbfc0('0x45')](handleError(_0x12779c,null));};exports[_0xbfc0('0x58')]=function(_0x26b7a5,_0x388ed1,_0x51102d){var _0x71094d={};var _0x513f12={};var _0x3593e5;var _0xa5f64b;return db[_0xbfc0('0x2c')][_0xbfc0('0x59')]({'where':{'id':_0x26b7a5[_0xbfc0('0x47')]['id']}})[_0xbfc0('0x23')](handleEntityNotFound(_0x388ed1,null))[_0xbfc0('0x23')](function(_0xcbff49){if(_0xcbff49){_0x3593e5=_0xcbff49;_0x513f12[_0xbfc0('0x30')]=_[_0xbfc0('0x33')](db[_0xbfc0('0x2c')]['rawAttributes']);_0x513f12['query']=_['keys'](_0x26b7a5[_0xbfc0('0x32')]);_0x513f12[_0xbfc0('0x3c')]=_[_0xbfc0('0x48')](_0x513f12[_0xbfc0('0x30')],_0x513f12[_0xbfc0('0x32')]);_0x71094d['attributes']=_[_0xbfc0('0x48')](_0x513f12[_0xbfc0('0x30')],qs[_0xbfc0('0x35')](_0x26b7a5[_0xbfc0('0x32')][_0xbfc0('0x35')]));_0x71094d[_0xbfc0('0x34')]=_0x71094d[_0xbfc0('0x34')][_0xbfc0('0x36')]?_0x71094d['attributes']:_0x513f12[_0xbfc0('0x30')];_0x71094d['order']=qs['sort'](_0x26b7a5[_0xbfc0('0x32')][_0xbfc0('0x3a')]);_0x71094d[_0xbfc0('0x3b')]=qs['filters'](_[_0xbfc0('0x3d')](_0x26b7a5[_0xbfc0('0x32')],_0x513f12['filters']));if(_0x26b7a5[_0xbfc0('0x32')]['filter']){_0x71094d[_0xbfc0('0x3b')]=_['merge'](_0x71094d[_0xbfc0('0x3b')],{'$or':_[_0xbfc0('0x31')](_0x71094d[_0xbfc0('0x34')],function(_0xc75c65){var _0xa56e84={};_0xa56e84[_0xc75c65]={'$like':'%'+_0x26b7a5['query']['filter']+'%'};return _0xa56e84;})});}_0x71094d=_[_0xbfc0('0x3f')]({},_0x71094d,_0x26b7a5[_0xbfc0('0x49')]);return _0x3593e5[_0xbfc0('0x58')](_0x71094d);}})[_0xbfc0('0x23')](function(_0x446e8d){if(_0x446e8d){_0xa5f64b=_0x446e8d[_0xbfc0('0x36')];if(!_0x26b7a5[_0xbfc0('0x32')][_0xbfc0('0x37')](_0xbfc0('0x38'))){_0x71094d['limit']=qs['limit'](_0x26b7a5[_0xbfc0('0x32')]['limit']);_0x71094d[_0xbfc0('0x1b')]=qs[_0xbfc0('0x1b')](_0x26b7a5[_0xbfc0('0x32')][_0xbfc0('0x1b')]);}return _0x3593e5['getIntervals'](_0x71094d);}})[_0xbfc0('0x23')](function(_0x43ca3c){if(_0x43ca3c){return _0x43ca3c?{'count':_0xa5f64b,'rows':_0x43ca3c}:null;}})[_0xbfc0('0x23')](respondWithResult(_0x388ed1,null))[_0xbfc0('0x45')](handleError(_0x388ed1,null));};exports['addIntervals']=function(_0x13aceb,_0x518853,_0x665247){return db[_0xbfc0('0x2c')][_0xbfc0('0x59')]({'where':{'id':_0x13aceb['params']['id']}})[_0xbfc0('0x23')](handleEntityNotFound(_0x518853,null))['then'](function(_0x522cdc){if(_0x522cdc){return db[_0xbfc0('0x5a')][_0xbfc0('0x5b')](function(_0x511f98){return db[_0xbfc0('0x2c')][_0xbfc0('0x26')]({'where':{'IntervalId':_0x13aceb['params']['id']},'transaction':_0x511f98})[_0xbfc0('0x23')](function(_0x3ecaa4){var _0x419160=_[_0xbfc0('0x31')](_0x13aceb[_0xbfc0('0x4c')],function(_0x3b00c8){delete _0x3b00c8['id'];_0x3b00c8['IntervalId']=_0x13aceb[_0xbfc0('0x47')]['id'];return _0x3b00c8;});return db[_0xbfc0('0x2c')]['bulkCreate'](_0x419160,{'transaction':_0x511f98});});})[_0xbfc0('0x23')](function(){return db[_0xbfc0('0x2c')]['findAll']({'where':{'IntervalId':_0x13aceb[_0xbfc0('0x47')]['id']}});});}})[_0xbfc0('0x23')](respondWithResult(_0x518853,null))[_0xbfc0('0x45')](handleError(_0x518853,null));}; \ No newline at end of file diff --git a/server/api/interval/interval.model.js b/server/api/interval/interval.model.js new file mode 100644 index 0000000..6a1831d --- /dev/null +++ b/server/api/interval/interval.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x95ff=['define','Interval','tools_intervals','rewrite','string','interval','getIntervals','then','map','ifTime','reduce','./interval.attributes','../../utils/iftime','exports'];(function(_0x1fee7a,_0x100dfc){var _0x50d8f0=function(_0x129307){while(--_0x129307){_0x1fee7a['push'](_0x1fee7a['shift']());}};_0x50d8f0(++_0x100dfc);}(_0x95ff,0x1d9));var _0xf95f=function(_0x2c4a42,_0x41e2b9){_0x2c4a42=_0x2c4a42-0x0;var _0x2302a2=_0x95ff[_0x2c4a42];return _0x2302a2;};'use strict';var attributes=require(_0xf95f('0x0'));var extensions=require('../../components/extensions/rewrite');var iftime=require(_0xf95f('0x1'))['iftime'];module[_0xf95f('0x2')]=function(_0x5b900b){return _0x5b900b[_0xf95f('0x3')](_0xf95f('0x4'),attributes,{'tableName':_0xf95f('0x5'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x27710d){extensions[_0xf95f('0x6')](_0x5b900b,_0x27710d);},'afterBulkCreate':function(_0x43787c,_0x229c4d,_0x4c023e){_0x4c023e();extensions[_0xf95f('0x6')](_0x5b900b,_0x43787c[0x0]);},'afterUpdate':function(_0x8918fc){extensions[_0xf95f('0x6')](_0x5b900b,_0x8918fc);},'afterDestroy':function(_0x3cc821){extensions[_0xf95f('0x6')](_0x5b900b,_0x3cc821);}},'instanceMethods':{'ifTime':function(_0x598e76=undefined,_0x22f093=new Date()){if(typeof this['interval']===_0xf95f('0x7')){return iftime(this[_0xf95f('0x8')],_0x598e76,_0x22f093);}else{return this[_0xf95f('0x9')]()[_0xf95f('0xa')](function(_0x108525){return Promise['all'](_0x108525[_0xf95f('0xb')](function(_0x1aa960){return _0x1aa960[_0xf95f('0xc')](_0x598e76,_0x22f093);}));})[_0xf95f('0xa')](function(_0x35200c){return _0x35200c[_0xf95f('0xd')](function(_0x38e73b,_0x30b78c){return _0x38e73b||_0x30b78c;},![]);});}}}});}; \ No newline at end of file diff --git a/server/api/interval/interval.rpc.js b/server/api/interval/interval.rpc.js new file mode 100644 index 0000000..6f93bc2 --- /dev/null +++ b/server/api/interval/interval.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2664=['findAll','options','where','attributes','limit','include','model','map','then','info','debug','stringify','catch','error','message','ShowInterval','find','ifTime','reduce','format','name','join','findById','IntervalIftime','isArray','intervals','timezone','length','IntervalIftime:\x20interval\x20strings\x20=\x20%s','Iftime','silly','lodash','util','../../mysqldb','iftime','../../config/logger','GetInterval','Interval'];(function(_0x5e804b,_0x242732){var _0x116e07=function(_0x550e22){while(--_0x550e22){_0x5e804b['push'](_0x5e804b['shift']());}};_0x116e07(++_0x242732);}(_0x2664,0x103));var _0x4266=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x2664[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x4266('0x0'));var util=require(_0x4266('0x1'));var db=require(_0x4266('0x2'))['db'];var iftime=require('../../utils/iftime')[_0x4266('0x3')];var logger=require(_0x4266('0x4'))('rpc');exports[_0x4266('0x5')]=function(_0x35ead5){var _0xf8af53=this;return new Promise(function(_0x37691a,_0x2f6386){return db[_0x4266('0x6')][_0x4266('0x7')]({'raw':_0x35ead5['options']?_0x35ead5[_0x4266('0x8')]['raw']===undefined?!![]:![]:!![],'where':_0x35ead5['options']?_0x35ead5[_0x4266('0x8')][_0x4266('0x9')]||null:null,'attributes':_0x35ead5[_0x4266('0x8')]?_0x35ead5['options'][_0x4266('0xa')]||null:null,'limit':_0x35ead5[_0x4266('0x8')]?_0x35ead5['options'][_0x4266('0xb')]||null:null,'include':_0x35ead5[_0x4266('0x8')]?_0x35ead5[_0x4266('0x8')]['include']?_['map'](_0x35ead5[_0x4266('0x8')][_0x4266('0xc')],function(_0x2a3810){return{'model':db[_0x2a3810[_0x4266('0xd')]],'as':_0x2a3810['as'],'attributes':_0x2a3810[_0x4266('0xa')],'include':_0x2a3810[_0x4266('0xc')]?_['map'](_0x2a3810['include'],function(_0x51615c){return{'model':db[_0x51615c[_0x4266('0xd')]],'as':_0x51615c['as'],'attributes':_0x51615c[_0x4266('0xa')],'include':_0x51615c[_0x4266('0xc')]?_[_0x4266('0xe')](_0x51615c[_0x4266('0xc')],function(_0x2b7d50){return{'model':db[_0x2b7d50[_0x4266('0xd')]],'as':_0x2b7d50['as'],'attributes':_0x2b7d50[_0x4266('0xa')]};}):[]};}):[]};}):[]:[]})[_0x4266('0xf')](function(_0x456855){logger[_0x4266('0x10')](_0x4266('0x5'),_0x35ead5);logger[_0x4266('0x11')](_0x4266('0x5'),_0x35ead5,JSON[_0x4266('0x12')](_0x456855));_0x37691a(_0x456855);})[_0x4266('0x13')](function(_0x30d3bd){logger[_0x4266('0x14')](_0x4266('0x5'),_0x30d3bd[_0x4266('0x15')],_0x35ead5);_0x2f6386(_0xf8af53['error'](0x1f4,_0x30d3bd[_0x4266('0x15')]));});});};exports[_0x4266('0x16')]=function(_0x9c002d){var _0x1ee184=this;return new Promise(function(_0x94f5c7,_0x535671){return db['Interval'][_0x4266('0x17')]({'raw':_0x9c002d[_0x4266('0x8')]?_0x9c002d['options']['raw']===undefined?!![]:![]:!![],'where':_0x9c002d[_0x4266('0x8')]?_0x9c002d[_0x4266('0x8')][_0x4266('0x9')]||null:null,'attributes':_0x9c002d[_0x4266('0x8')]?_0x9c002d[_0x4266('0x8')][_0x4266('0xa')]||null:null,'include':_0x9c002d[_0x4266('0x8')]?_0x9c002d['options'][_0x4266('0xc')]?_[_0x4266('0xe')](_0x9c002d[_0x4266('0x8')][_0x4266('0xc')],function(_0x11e090){return{'model':db[_0x11e090['model']],'as':_0x11e090['as'],'attributes':_0x11e090[_0x4266('0xa')],'include':_0x11e090[_0x4266('0xc')]?_[_0x4266('0xe')](_0x11e090[_0x4266('0xc')],function(_0x584aad){return{'model':db[_0x584aad['model']],'as':_0x584aad['as'],'attributes':_0x584aad[_0x4266('0xa')],'include':_0x584aad[_0x4266('0xc')]?_['map'](_0x584aad[_0x4266('0xc')],function(_0x5a8dd5){return{'model':db[_0x5a8dd5[_0x4266('0xd')]],'as':_0x5a8dd5['as'],'attributes':_0x5a8dd5['attributes']};}):[]};}):[]};}):[]:[]})[_0x4266('0xf')](function(_0x56f9b7){logger['info'](_0x4266('0x16'),_0x9c002d);logger['debug'](_0x4266('0x16'),_0x9c002d,JSON[_0x4266('0x12')](_0x56f9b7));_0x94f5c7(_0x56f9b7);})[_0x4266('0x13')](function(_0x2ca2ca){logger['error'](_0x4266('0x16'),_0x2ca2ca[_0x4266('0x15')],_0x9c002d);_0x535671(_0x1ee184[_0x4266('0x14')](0x1f4,_0x2ca2ca[_0x4266('0x15')]));});});};function checkArrayOfIntervals(_0x452921,_0x3b4ef1){var _0x5b9039=[];return db[_0x4266('0x6')][_0x4266('0x7')]({'where':{'id':_0x452921}})['then'](function(_0x4282a9){_0x5b9039=_0x4282a9;return Promise['all'](_0x5b9039[_0x4266('0xe')](function(_0x4cfb22){return _0x4cfb22[_0x4266('0x18')](_0x3b4ef1);}));})['then'](function(_0x5e6046){var _0x3adb05=_0x5e6046[_0x4266('0x19')](function(_0x58a79a,_0x1a4eac){return _0x58a79a||_0x1a4eac;},![]);logger[_0x4266('0x10')](util[_0x4266('0x1a')]('IntervalIftime:\x20intervals\x20=\x20%s\x20(ids\x20=\x20%s)',_0x5b9039[_0x4266('0xe')](function(_0x5c5bf6){return _0x5c5bf6[_0x4266('0x1b')];})[_0x4266('0x1c')](',\x20'),_0x5b9039[_0x4266('0xe')](function(_0x55756c){return _0x55756c['id'];})[_0x4266('0x1c')](',\x20')));return _0x3adb05;});}function checkSingleInterval(_0x5937f6,_0x332212){return db[_0x4266('0x6')][_0x4266('0x1d')](_0x5937f6)[_0x4266('0xf')](function(_0x55d244){if(_0x55d244){logger[_0x4266('0x10')](util[_0x4266('0x1a')]('IntervalIftime:\x20interval\x20=\x20%s\x20(id\x20=\x20%s)',_0x55d244[_0x4266('0x1b')],_0x55d244['id']));return _0x55d244[_0x4266('0x18')](_0x332212);}});}exports[_0x4266('0x1e')]=function(_0x44defa){var _0x2b2b48=_0x44defa['intervalIds'];var _0x2519c6=Array[_0x4266('0x1f')](_0x44defa['intervals'])?_0x44defa[_0x4266('0x20')]:typeof _0x44defa['intervals']==='string'?[_0x44defa[_0x4266('0x20')]]:[];var _0x5d9fb1=_0x44defa[_0x4266('0x21')]||undefined;var _0x3266ea=![];if(_0x2519c6[_0x4266('0x22')]){logger[_0x4266('0x10')](util['format'](_0x4266('0x23'),_0x2519c6[_0x4266('0x1c')](';\x20')));}if(_0x5d9fb1){logger[_0x4266('0x10')](util[_0x4266('0x1a')]('IntervalIftime:\x20timezone\x20=\x20%s',_0x5d9fb1));}logger[_0x4266('0x11')](_0x4266('0x24'),_0x3266ea);logger[_0x4266('0x25')](_0x4266('0x1e'),_0x44defa);return Promise['resolve']()[_0x4266('0xf')](function(){if(Array['isArray'](_0x2b2b48)){return checkArrayOfIntervals(_0x2b2b48,_0x5d9fb1);}else if(_0x2b2b48){return checkSingleInterval(_0x2b2b48,_0x5d9fb1);}})[_0x4266('0xf')](function(_0x4f13fe){var _0x450f6d=_0x2519c6[_0x4266('0x19')](function(_0x59eae0,_0x243b5c){return _0x59eae0||iftime(_0x243b5c,_0x5d9fb1);},![]);_0x3266ea=_0x4f13fe||_0x450f6d;return _0x3266ea;})['catch'](function(_0x461473){logger[_0x4266('0x14')](_0x4266('0x1e'),_0x44defa,_0x461473);throw this[_0x4266('0x14')](0x1f4,_0x461473[_0x4266('0x15')]);});}; \ No newline at end of file diff --git a/server/api/jira/index.js b/server/api/jira/index.js new file mode 100644 index 0000000..79a600d --- /dev/null +++ b/server/api/jira/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5f66=['send','exports','Router','./jira.controller','post','isAuthenticated'];(function(_0x38987f,_0xc79720){var _0x4cb697=function(_0x1af5ae){while(--_0x1af5ae){_0x38987f['push'](_0x38987f['shift']());}};_0x4cb697(++_0xc79720);}(_0x5f66,0x1a0));var _0x65f6=function(_0x126558,_0x143c9a){_0x126558=_0x126558-0x0;var _0x1f6d14=_0x5f66[_0x126558];return _0x1f6d14;};'use strict';var express=require('express');var router=express[_0x65f6('0x0')]();var auth=require('../../components/auth/service');var controller=require(_0x65f6('0x1'));router[_0x65f6('0x2')]('/',auth[_0x65f6('0x3')](),controller[_0x65f6('0x4')]);module[_0x65f6('0x5')]=router; \ No newline at end of file diff --git a/server/api/jira/jira.controller.js b/server/api/jira/jira.controller.js new file mode 100644 index 0000000..0829613 --- /dev/null +++ b/server/api/jira/jira.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaf75=['Error\x20during\x20license\x20request.\x20Please\x20contact\x20our\x20license\x20team\x20at\x20license@xcally.com\x20with\x20your\x20request','api.jira','send','body','headers','connection','remoteAddress','socket','bluebird','../../config/logger','support','3eAmWpBVP0','key','MOTGUI','summary','Report','\x20from\x20','description','stringify','issuetype','Bug','fields','customfield_11500','email','customfield_11501','oldToken','customfield_11502','newToken','name','customfield_11504','track.xcallymotion.com','/rest/api/2/issue','POST','application/json','Basic\x20','request','utf8','data','end','status','json','error'];(function(_0x280f8b,_0x56922a){var _0x4d1f79=function(_0x17a33c){while(--_0x17a33c){_0x280f8b['push'](_0x280f8b['shift']());}};_0x4d1f79(++_0x56922a);}(_0xaf75,0x1d6));var _0x5af7=function(_0x25b508,_0x366b39){_0x25b508=_0x25b508-0x0;var _0x264927=_0xaf75[_0x25b508];return _0x264927;};'use strict';var BPromise=require(_0x5af7('0x0'));var https=require('https');var logger=require(_0x5af7('0x1'))('api');var USERNAME=_0x5af7('0x2');var PASSWORD=_0x5af7('0x3');function openIssue(_0x1c187d,_0x72719d){var _0x18fbaf={'fields':{'project':{'key':_0x1c187d[_0x5af7('0x4')]||_0x5af7('0x5')},'summary':(_0x1c187d[_0x5af7('0x6')]||_0x5af7('0x7'))+_0x5af7('0x8')+_0x1c187d['ip'],'description':_0x1c187d[_0x5af7('0x9')]||JSON[_0x5af7('0xa')](_0x1c187d),'issuetype':{'name':_0x1c187d[_0x5af7('0xb')]||_0x5af7('0xc')}}};_0x18fbaf[_0x5af7('0xd')][_0x5af7('0xe')]=_0x1c187d[_0x5af7('0xf')];_0x18fbaf['fields'][_0x5af7('0x10')]=_0x1c187d[_0x5af7('0x11')];_0x18fbaf[_0x5af7('0xd')][_0x5af7('0x12')]=_0x1c187d[_0x5af7('0x13')];_0x18fbaf['fields']['customfield_11503']=_0x1c187d[_0x5af7('0x14')];_0x18fbaf[_0x5af7('0xd')][_0x5af7('0x15')]=_0x1c187d['reason'];_0x18fbaf[_0x5af7('0xd')]['customfield_10102']=_0x1c187d['ip'];var _0xeabf01={'host':_0x5af7('0x16'),'port':0x1bb,'path':_0x5af7('0x17'),'method':_0x5af7('0x18'),'timeout':0x4e20,'headers':{'Content-Type':_0x5af7('0x19'),'Authorization':_0x5af7('0x1a')+new Buffer(USERNAME+':'+PASSWORD)['toString']('base64')}};var _0x2acb9e=JSON[_0x5af7('0xa')](_0x18fbaf);var _0x582040=https[_0x5af7('0x1b')](_0xeabf01,function(_0x274870){_0x274870['setEncoding'](_0x5af7('0x1c'));var _0x138b31='';_0x274870['on'](_0x5af7('0x1d'),function(_0x12f8f1){_0x138b31+=_0x12f8f1;});_0x274870['on'](_0x5af7('0x1e'),function(){if(_0x72719d){return _0x72719d[_0x5af7('0x1f')](_0x274870['statusCode'])[_0x5af7('0x20')](JSON['parse'](_0x138b31));}});});_0x582040['on'](_0x5af7('0x21'),function(_0x1f295b){if(_0x72719d){return _0x72719d[_0x5af7('0x1f')](0x1f4)[_0x5af7('0x20')]({'errors':[{'message':_0x5af7('0x22'),'type':_0x5af7('0x23')}]});}});_0x582040['write'](_0x2acb9e);_0x582040[_0x5af7('0x1e')]();}exports['openIssue']=openIssue;exports[_0x5af7('0x24')]=function(_0x314d2b,_0x4f4235){_0x314d2b[_0x5af7('0x25')]['ip']=_0x314d2b[_0x5af7('0x26')]['x-forwarded-for']||_0x314d2b[_0x5af7('0x27')][_0x5af7('0x28')]||_0x314d2b[_0x5af7('0x29')][_0x5af7('0x28')]||_0x314d2b[_0x5af7('0x27')][_0x5af7('0x29')][_0x5af7('0x28')];return openIssue(_0x314d2b[_0x5af7('0x25')],_0x4f4235);}; \ No newline at end of file diff --git a/server/api/jscriptyAnswerReport/index.js b/server/api/jscriptyAnswerReport/index.js new file mode 100644 index 0000000..12d69cc --- /dev/null +++ b/server/api/jscriptyAnswerReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x17ba=['/describe','describe','/:id','show','create','put','update','delete','destroy','exports','multer','util','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./jscriptyAnswerReport.controller','get','isAuthenticated','index'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0x17ba,0xab));var _0xa17b=function(_0x4fadd4,_0x3c1cb9){_0x4fadd4=_0x4fadd4-0x0;var _0x4b8120=_0x17ba[_0x4fadd4];return _0x4b8120;};'use strict';var multer=require(_0xa17b('0x0'));var util=require(_0xa17b('0x1'));var path=require('path');var timeout=require(_0xa17b('0x2'));var express=require(_0xa17b('0x3'));var router=express[_0xa17b('0x4')]();var fs_extra=require(_0xa17b('0x5'));var auth=require(_0xa17b('0x6'));var interaction=require(_0xa17b('0x7'));var config=require(_0xa17b('0x8'));var controller=require(_0xa17b('0x9'));router[_0xa17b('0xa')]('/',auth[_0xa17b('0xb')](),controller[_0xa17b('0xc')]);router[_0xa17b('0xa')](_0xa17b('0xd'),auth[_0xa17b('0xb')](),controller[_0xa17b('0xe')]);router[_0xa17b('0xa')](_0xa17b('0xf'),auth[_0xa17b('0xb')](),controller[_0xa17b('0x10')]);router['post']('/',auth[_0xa17b('0xb')](),controller[_0xa17b('0x11')]);router[_0xa17b('0x12')](_0xa17b('0xf'),auth[_0xa17b('0xb')](),controller[_0xa17b('0x13')]);router[_0xa17b('0x14')]('/:id',auth[_0xa17b('0xb')](),controller[_0xa17b('0x15')]);module[_0xa17b('0x16')]=router; \ No newline at end of file diff --git a/server/api/jscriptyAnswerReport/jscriptyAnswerReport.attributes.js b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.attributes.js new file mode 100644 index 0000000..aec2717 --- /dev/null +++ b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['long','STRING','sequelize','exports','TEXT'];(function(_0x5a776b,_0x46f785){var _0xbbef59=function(_0x38313e){while(--_0x38313e){_0x5a776b['push'](_0x5a776b['shift']());}};_0xbbef59(++_0x46f785);}(_0x7a54,0x106));var _0x47a5=function(_0x3cccf7,_0x22235b){_0x3cccf7=_0x3cccf7-0x0;var _0x11a3c8=_0x7a54[_0x3cccf7];return _0x11a3c8;};'use strict';var Sequelize=require(_0x47a5('0x0'));module[_0x47a5('0x1')]={'question':{'type':Sequelize[_0x47a5('0x2')]},'answer':{'type':Sequelize['TEXT'](_0x47a5('0x3'))},'membername':{'type':Sequelize[_0x47a5('0x4')]},'projectname':{'type':Sequelize['STRING']},'queue':{'type':Sequelize[_0x47a5('0x4')]},'uniqueid':{'type':Sequelize[_0x47a5('0x4')]},'calleridname':{'type':Sequelize[_0x47a5('0x4')]},'calleridnum':{'type':Sequelize[_0x47a5('0x4')]},'questionId':{'type':Sequelize[_0x47a5('0x4')]}}; \ No newline at end of file diff --git a/server/api/jscriptyAnswerReport/jscriptyAnswerReport.controller.js b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.controller.js new file mode 100644 index 0000000..1f6a0fe --- /dev/null +++ b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x236d=['undefined','limit','count','set','apply','save','update','then','error','stack','name','send','index','map','JscriptyAnswerReport','rawAttributes','fieldName','type','key','model','keys','filters','intersection','attributes','fields','query','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','find','create','body','catch','destroy','params','describe','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset'];(function(_0x5c2e3e,_0x26ecd3){var _0x53f64a=function(_0x2b5df8){while(--_0x2b5df8){_0x5c2e3e['push'](_0x5c2e3e['shift']());}};_0x53f64a(++_0x26ecd3);}(_0x236d,0x7e));var _0xd236=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x236d[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xd236('0x0'));var rimraf=require(_0xd236('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd236('0x2'));var rp=require('request-promise');var moment=require(_0xd236('0x3'));var BPromise=require(_0xd236('0x4'));var Mustache=require(_0xd236('0x5'));var util=require(_0xd236('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0xd236('0x7'));var ejs=require(_0xd236('0x8'));var fs=require('fs');var fs_extra=require(_0xd236('0x9'));var _=require(_0xd236('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xd236('0xb'));var deskjs=require(_0xd236('0xc'));var toCsv=require('to-csv');var querystring=require(_0xd236('0xd'));var Papa=require(_0xd236('0xe'));var Redis=require('ioredis');var authService=require(_0xd236('0xf'));var qs=require(_0xd236('0x10'));var as=require(_0xd236('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xd236('0x12'))(_0xd236('0x13'));var utils=require(_0xd236('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xd236('0x15'));var db=require(_0xd236('0x16'))['db'];function respondWithStatusCode(_0x3d1076,_0x160cb1){_0x160cb1=_0x160cb1||0xcc;return function(_0x21f27b){if(_0x21f27b){return _0x3d1076[_0xd236('0x17')](_0x160cb1);}return _0x3d1076[_0xd236('0x18')](_0x160cb1)[_0xd236('0x19')]();};}function respondWithResult(_0x22435c,_0x3d7465){_0x3d7465=_0x3d7465||0xc8;return function(_0x348734){if(_0x348734){return _0x22435c[_0xd236('0x18')](_0x3d7465)[_0xd236('0x1a')](_0x348734);}};}function respondWithFilteredResult(_0x3b60a7,_0xd851b5){return function(_0x3b2535){if(_0x3b2535){var _0x2a076d=typeof _0xd851b5[_0xd236('0x1b')]===_0xd236('0x1c')&&typeof _0xd851b5[_0xd236('0x1d')]==='undefined';var _0x4f06c6=_0x3b2535[_0xd236('0x1e')];var _0x1b02a5=_0x2a076d?0x0:_0xd851b5['offset'];var _0x11c6ec=_0x2a076d?_0x3b2535[_0xd236('0x1e')]:_0xd851b5[_0xd236('0x1b')]+_0xd851b5['limit'];var _0x355b65;if(_0x11c6ec>=_0x4f06c6){_0x11c6ec=_0x4f06c6;_0x355b65=0xc8;}else{_0x355b65=0xce;}_0x3b60a7[_0xd236('0x18')](_0x355b65);return _0x3b60a7[_0xd236('0x1f')]('Content-Range',_0x1b02a5+'-'+_0x11c6ec+'/'+_0x4f06c6)[_0xd236('0x1a')](_0x3b2535);}return null;};}function patchUpdates(_0x3b0a27){return function(_0x26c758){try{jsonpatch[_0xd236('0x20')](_0x26c758,_0x3b0a27,!![]);}catch(_0x2f512d){return BPromise['reject'](_0x2f512d);}return _0x26c758[_0xd236('0x21')]();};}function saveUpdates(_0x30e7aa,_0x1e4ddb){return function(_0x3d1e4e){if(_0x3d1e4e){return _0x3d1e4e[_0xd236('0x22')](_0x30e7aa)['then'](function(_0x4a35d0){return _0x4a35d0;});}return null;};}function removeEntity(_0x257f27,_0x4be5ac){return function(_0x22924d){if(_0x22924d){return _0x22924d['destroy']()[_0xd236('0x23')](function(){_0x257f27[_0xd236('0x18')](0xcc)[_0xd236('0x19')]();});}};}function handleEntityNotFound(_0x49d822,_0x41049a){return function(_0x339b08){if(!_0x339b08){_0x49d822[_0xd236('0x17')](0x194);}return _0x339b08;};}function handleError(_0x13ba7a,_0x3a30d8){_0x3a30d8=_0x3a30d8||0x1f4;return function(_0x17f927){logger[_0xd236('0x24')](_0x17f927[_0xd236('0x25')]);if(_0x17f927[_0xd236('0x26')]){delete _0x17f927[_0xd236('0x26')];}_0x13ba7a[_0xd236('0x18')](_0x3a30d8)[_0xd236('0x27')](_0x17f927);};}exports[_0xd236('0x28')]=function(_0x23714d,_0x3108f4){var _0x28175d={},_0x436a19={},_0x471ed6={'count':0x0,'rows':[]};var _0x463fc8=_[_0xd236('0x29')](db[_0xd236('0x2a')][_0xd236('0x2b')],function(_0x3c1617){return{'name':_0x3c1617[_0xd236('0x2c')],'type':_0x3c1617[_0xd236('0x2d')][_0xd236('0x2e')]};});_0x436a19[_0xd236('0x2f')]=_[_0xd236('0x29')](_0x463fc8,_0xd236('0x26'));_0x436a19['query']=_[_0xd236('0x30')](_0x23714d['query']);_0x436a19[_0xd236('0x31')]=_[_0xd236('0x32')](_0x436a19[_0xd236('0x2f')],_0x436a19['query']);_0x28175d[_0xd236('0x33')]=_[_0xd236('0x32')](_0x436a19[_0xd236('0x2f')],qs[_0xd236('0x34')](_0x23714d[_0xd236('0x35')][_0xd236('0x34')]));_0x28175d[_0xd236('0x33')]=_0x28175d['attributes'][_0xd236('0x36')]?_0x28175d['attributes']:_0x436a19[_0xd236('0x2f')];if(!_0x23714d['query'][_0xd236('0x37')](_0xd236('0x38'))){_0x28175d[_0xd236('0x1d')]=qs[_0xd236('0x1d')](_0x23714d[_0xd236('0x35')][_0xd236('0x1d')]);_0x28175d[_0xd236('0x1b')]=qs[_0xd236('0x1b')](_0x23714d[_0xd236('0x35')][_0xd236('0x1b')]);}_0x28175d[_0xd236('0x39')]=qs[_0xd236('0x3a')](_0x23714d[_0xd236('0x35')]['sort']);_0x28175d[_0xd236('0x3b')]=qs[_0xd236('0x31')](_[_0xd236('0x3c')](_0x23714d['query'],_0x436a19[_0xd236('0x31')]),_0x463fc8);if(_0x23714d[_0xd236('0x35')][_0xd236('0x3d')]){_0x28175d[_0xd236('0x3b')]=_[_0xd236('0x3e')](_0x28175d[_0xd236('0x3b')],{'$or':_['map'](_0x463fc8,function(_0x696bed){if(_0x696bed[_0xd236('0x2d')]!==_0xd236('0x3f')){var _0x3c798f={};_0x3c798f[_0x696bed[_0xd236('0x26')]]={'$like':'%'+_0x23714d[_0xd236('0x35')]['filter']+'%'};return _0x3c798f;}})});}_0x28175d=_[_0xd236('0x3e')]({},_0x28175d,_0x23714d[_0xd236('0x40')]);var _0x2ba3ae={'where':_0x28175d['where']};return db[_0xd236('0x2a')]['count'](_0x2ba3ae)[_0xd236('0x23')](function(_0x5793bf){_0x471ed6['count']=_0x5793bf;if(_0x23714d[_0xd236('0x35')][_0xd236('0x41')]){_0x28175d[_0xd236('0x42')]=[{'all':!![]}];}return db[_0xd236('0x2a')][_0xd236('0x43')](_0x28175d);})['then'](function(_0x4d0d65){_0x471ed6[_0xd236('0x44')]=_0x4d0d65;return _0x471ed6;})[_0xd236('0x23')](respondWithFilteredResult(_0x3108f4,_0x28175d))['catch'](handleError(_0x3108f4,null));};exports[_0xd236('0x45')]=function(_0x342fd5,_0x2d815b){var _0x55007d={'raw':!![],'where':{'id':_0x342fd5['params']['id']}},_0x58a93a={};_0x58a93a[_0xd236('0x2f')]=_['keys'](db['JscriptyAnswerReport'][_0xd236('0x2b')]);_0x58a93a[_0xd236('0x35')]=_[_0xd236('0x30')](_0x342fd5[_0xd236('0x35')]);_0x58a93a[_0xd236('0x31')]=_['intersection'](_0x58a93a['model'],_0x58a93a[_0xd236('0x35')]);_0x55007d[_0xd236('0x33')]=_[_0xd236('0x32')](_0x58a93a[_0xd236('0x2f')],qs[_0xd236('0x34')](_0x342fd5[_0xd236('0x35')]['fields']));_0x55007d[_0xd236('0x33')]=_0x55007d['attributes'][_0xd236('0x36')]?_0x55007d[_0xd236('0x33')]:_0x58a93a['model'];if(_0x342fd5['query']['includeAll']){_0x55007d['include']=[{'all':!![]}];}_0x55007d=_[_0xd236('0x3e')]({},_0x55007d,_0x342fd5[_0xd236('0x40')]);return db[_0xd236('0x2a')][_0xd236('0x46')](_0x55007d)[_0xd236('0x23')](handleEntityNotFound(_0x2d815b,null))['then'](respondWithResult(_0x2d815b,null))['catch'](handleError(_0x2d815b,null));};exports[_0xd236('0x47')]=function(_0x7c0650,_0xbf4ba9){return db[_0xd236('0x2a')][_0xd236('0x47')](_0x7c0650[_0xd236('0x48')],{})['then'](respondWithResult(_0xbf4ba9,0xc9))[_0xd236('0x49')](handleError(_0xbf4ba9,null));};exports['update']=function(_0x223a14,_0x2c8861){if(_0x223a14['body']['id']){delete _0x223a14[_0xd236('0x48')]['id'];}return db[_0xd236('0x2a')]['find']({'where':{'id':_0x223a14['params']['id']}})[_0xd236('0x23')](handleEntityNotFound(_0x2c8861,null))[_0xd236('0x23')](saveUpdates(_0x223a14[_0xd236('0x48')],null))[_0xd236('0x23')](respondWithResult(_0x2c8861,null))['catch'](handleError(_0x2c8861,null));};exports[_0xd236('0x4a')]=function(_0x43c12b,_0x3d8ca6){return db[_0xd236('0x2a')][_0xd236('0x46')]({'where':{'id':_0x43c12b[_0xd236('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3d8ca6,null))['then'](removeEntity(_0x3d8ca6,null))[_0xd236('0x49')](handleError(_0x3d8ca6,null));};exports['describe']=function(_0xa39da6,_0x30c336){return db['JscriptyAnswerReport'][_0xd236('0x4c')]()[_0xd236('0x23')](respondWithResult(_0x30c336,null))['catch'](handleError(_0x30c336,null));}; \ No newline at end of file diff --git a/server/api/jscriptyAnswerReport/jscriptyAnswerReport.model.js b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.model.js new file mode 100644 index 0000000..246a742 --- /dev/null +++ b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdfc0=['report_jscripty_answers','lodash','../../config/logger','api','bluebird','../../config/environment','./jscriptyAnswerReport.attributes','exports','JscriptyAnswerReport'];(function(_0x479f93,_0x5d9ba0){var _0x33afbc=function(_0x4ff7c2){while(--_0x4ff7c2){_0x479f93['push'](_0x479f93['shift']());}};_0x33afbc(++_0x5d9ba0);}(_0xdfc0,0x1d5));var _0x0dfc=function(_0x1abcb6,_0x1ef8b0){_0x1abcb6=_0x1abcb6-0x0;var _0x40a2e9=_0xdfc0[_0x1abcb6];return _0x40a2e9;};'use strict';var _=require(_0x0dfc('0x0'));var util=require('util');var logger=require(_0x0dfc('0x1'))(_0x0dfc('0x2'));var moment=require('moment');var BPromise=require(_0x0dfc('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x0dfc('0x4'));var attributes=require(_0x0dfc('0x5'));module[_0x0dfc('0x6')]=function(_0xfd345c,_0x5e3295){return _0xfd345c['define'](_0x0dfc('0x7'),attributes,{'tableName':_0x0dfc('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/jscriptyAnswerReport/jscriptyAnswerReport.rpc.js b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.rpc.js new file mode 100644 index 0000000..b085d56 --- /dev/null +++ b/server/api/jscriptyAnswerReport/jscriptyAnswerReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe0ff=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','info','JscriptyAnswerReport,\x20%s,\x20%s','request\x20sent','debug','JscriptyAnswerReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','lodash','util'];(function(_0x1bd2a6,_0x45f0fc){var _0x525206=function(_0x3ae097){while(--_0x3ae097){_0x1bd2a6['push'](_0x1bd2a6['shift']());}};_0x525206(++_0x45f0fc);}(_0xe0ff,0x1d9));var _0xfe0f=function(_0x53dc68,_0x2602ad){_0x53dc68=_0x53dc68-0x0;var _0x286063=_0xe0ff[_0x53dc68];return _0x286063;};'use strict';var _=require(_0xfe0f('0x0'));var util=require(_0xfe0f('0x1'));var moment=require(_0xfe0f('0x2'));var BPromise=require(_0xfe0f('0x3'));var rs=require(_0xfe0f('0x4'));var fs=require('fs');var Redis=require(_0xfe0f('0x5'));var db=require(_0xfe0f('0x6'))['db'];var utils=require(_0xfe0f('0x7'));var logger=require(_0xfe0f('0x8'))('rpc');var config=require('../../config/environment');var jayson=require(_0xfe0f('0x9'));var client=jayson[_0xfe0f('0xa')][_0xfe0f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2671fa,_0x49ad0e,_0x45cdb6){return new BPromise(function(_0xda08fc,_0x172159){return client[_0xfe0f('0xc')](_0x2671fa,_0x45cdb6)[_0xfe0f('0xd')](function(_0x1187e8){logger[_0xfe0f('0xe')](_0xfe0f('0xf'),_0x49ad0e,_0xfe0f('0x10'));logger[_0xfe0f('0x11')](_0xfe0f('0x12'),_0x49ad0e,'request\x20sent',JSON[_0xfe0f('0x13')](_0x1187e8));if(_0x1187e8[_0xfe0f('0x14')]){if(_0x1187e8[_0xfe0f('0x14')][_0xfe0f('0x15')]===0x1f4){logger['error']('JscriptyAnswerReport,\x20%s,\x20%s',_0x49ad0e,_0x1187e8[_0xfe0f('0x14')][_0xfe0f('0x16')]);return _0x172159(_0x1187e8[_0xfe0f('0x14')][_0xfe0f('0x16')]);}logger[_0xfe0f('0x14')](_0xfe0f('0xf'),_0x49ad0e,_0x1187e8[_0xfe0f('0x14')][_0xfe0f('0x16')]);return _0xda08fc(_0x1187e8[_0xfe0f('0x14')][_0xfe0f('0x16')]);}else{logger[_0xfe0f('0xe')](_0xfe0f('0xf'),_0x49ad0e,_0xfe0f('0x10'));_0xda08fc(_0x1187e8[_0xfe0f('0x17')][_0xfe0f('0x16')]);}})[_0xfe0f('0x18')](function(_0x1d2616){logger['error'](_0xfe0f('0xf'),_0x49ad0e,_0x1d2616);_0x172159(_0x1d2616);});});} \ No newline at end of file diff --git a/server/api/jscriptyProject/index.js b/server/api/jscriptyProject/index.js new file mode 100644 index 0000000..24bd237 --- /dev/null +++ b/server/api/jscriptyProject/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x377a=['30s','getSummary','create','post','/:id/clone','clone','put','/:id','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./jscriptyProject.controller','isAuthenticated','index','show','get','getSessions','/:id/answers','getAnswers','/:id/summary'];(function(_0x445f11,_0x275ef5){var _0x44f25f=function(_0xaeaedb){while(--_0xaeaedb){_0x445f11['push'](_0x445f11['shift']());}};_0x44f25f(++_0x275ef5);}(_0x377a,0xe1));var _0xa377=function(_0x331615,_0x13aebd){_0x331615=_0x331615-0x0;var _0x4ba773=_0x377a[_0x331615];return _0x4ba773;};'use strict';var multer=require('multer');var util=require(_0xa377('0x0'));var path=require(_0xa377('0x1'));var timeout=require(_0xa377('0x2'));var express=require(_0xa377('0x3'));var router=express[_0xa377('0x4')]();var fs_extra=require(_0xa377('0x5'));var auth=require(_0xa377('0x6'));var interaction=require(_0xa377('0x7'));var config=require(_0xa377('0x8'));var controller=require(_0xa377('0x9'));router['get']('/',auth[_0xa377('0xa')](),controller[_0xa377('0xb')]);router['get']('/:id',auth['isAuthenticated'](),controller[_0xa377('0xc')]);router[_0xa377('0xd')]('/:id/sessions',auth[_0xa377('0xa')](),controller[_0xa377('0xe')]);router[_0xa377('0xd')](_0xa377('0xf'),auth[_0xa377('0xa')](),controller[_0xa377('0x10')]);router[_0xa377('0xd')](_0xa377('0x11'),auth[_0xa377('0xa')](),timeout(_0xa377('0x12')),controller[_0xa377('0x13')]);router['post']('/',auth[_0xa377('0xa')](),controller[_0xa377('0x14')]);router[_0xa377('0x15')](_0xa377('0x16'),auth['isAuthenticated'](),controller[_0xa377('0x17')]);router[_0xa377('0x18')](_0xa377('0x19'),auth[_0xa377('0xa')](),controller['update']);router['delete']('/:id',auth['isAuthenticated'](),controller['destroy']);module[_0xa377('0x1a')]=router; \ No newline at end of file diff --git a/server/api/jscriptyProject/jscriptyProject.attributes.js b/server/api/jscriptyProject/jscriptyProject.attributes.js new file mode 100644 index 0000000..cf00d79 --- /dev/null +++ b/server/api/jscriptyProject/jscriptyProject.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9b1a=['description','BOOLEAN','lodash','util','exports','name','STRING','isObjectLike','formData','setDataValue','format','{\x22name\x22:\x22%s\x22,\x22description\x22:\x22%s\x22,\x22pages\x22:[]}','getDataValue'];(function(_0x5b6064,_0x376df5){var _0x1f5b14=function(_0x361967){while(--_0x361967){_0x5b6064['push'](_0x5b6064['shift']());}};_0x1f5b14(++_0x376df5);}(_0x9b1a,0x13a));var _0xa9b1=function(_0x211632,_0x378e2e){_0x211632=_0x211632-0x0;var _0x5a1da1=_0x9b1a[_0x211632];return _0x5a1da1;};'use strict';var Sequelize=require('sequelize');var _=require(_0xa9b1('0x0'));var util=require(_0xa9b1('0x1'));module[_0xa9b1('0x2')]={'name':{'type':Sequelize['STRING'],'unique':_0xa9b1('0x3')},'description':{'type':Sequelize[_0xa9b1('0x4')]},'formData':{'type':Sequelize['TEXT']('long'),'set':function(_0x592bac){if(_[_0xa9b1('0x5')](_0x592bac)){this['setDataValue'](_0xa9b1('0x6'),JSON['stringify'](_0x592bac));}else if(_['isString'](_0x592bac)){this[_0xa9b1('0x7')](_0xa9b1('0x6'),_0x592bac);}else{this['setDataValue'](_0xa9b1('0x6'),util[_0xa9b1('0x8')](_0xa9b1('0x9'),this['getDataValue']('name')||'',this[_0xa9b1('0xa')](_0xa9b1('0xb'))||''));}}},'enableUncompleteSave':{'type':Sequelize[_0xa9b1('0xc')],'defaultValue':!![]},'sendUnpauseOnSubmit':{'type':Sequelize[_0xa9b1('0xc')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/jscriptyProject/jscriptyProject.controller.js b/server/api/jscriptyProject/jscriptyProject.controller.js new file mode 100644 index 0000000..4352d48 --- /dev/null +++ b/server/api/jscriptyProject/jscriptyProject.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6215=['query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','get','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','rawAttributes','omit','updatedAt','body','getSessions','findOne','JscriptySessionReport','hasOwnProperty','ProjectId','findAll','getAnswers','JscriptyAnswerReport','fromCharCode','toString','indexOf','getSummary','startTime','parse','-createdAt','questionId','question','format','YYYY-MM-DD\x20HH:mm:ss','SessionId','push','isEmpty','now','setHeader','Content-disposition','attachment;\x20filename=','Jscripty_Project_%d_Summary_%s.csv','Content-type','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','update','then','destroy','Projects','UserProfileResource','name','send','index','map','JscriptyProject','fieldName','type','key','model','keys'];(function(_0x40ca65,_0x42956d){var _0x59da60=function(_0x17fb85){while(--_0x17fb85){_0x40ca65['push'](_0x40ca65['shift']());}};_0x59da60(++_0x42956d);}(_0x6215,0x198));var _0x5621=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x6215[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0x5621('0x0'));var rimraf=require(_0x5621('0x1'));var zipdir=require(_0x5621('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5621('0x3'));var moment=require(_0x5621('0x4'));var BPromise=require(_0x5621('0x5'));var Mustache=require(_0x5621('0x6'));var util=require(_0x5621('0x7'));var path=require(_0x5621('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5621('0x9'));var squel=require(_0x5621('0xa'));var crypto=require(_0x5621('0xb'));var jsforce=require(_0x5621('0xc'));var deskjs=require(_0x5621('0xd'));var toCsv=require('to-csv');var querystring=require(_0x5621('0xe'));var Papa=require(_0x5621('0xf'));var Redis=require(_0x5621('0x10'));var authService=require(_0x5621('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x5621('0x12'));var hardwareService=require(_0x5621('0x13'));var logger=require(_0x5621('0x14'))('api');var utils=require(_0x5621('0x15'));var config=require(_0x5621('0x16'));var licenseUtil=require(_0x5621('0x17'));var db=require(_0x5621('0x18'))['db'];function respondWithStatusCode(_0x38d23d,_0x30e179){_0x30e179=_0x30e179||0xcc;return function(_0xac5caf){if(_0xac5caf){return _0x38d23d[_0x5621('0x19')](_0x30e179);}return _0x38d23d[_0x5621('0x1a')](_0x30e179)[_0x5621('0x1b')]();};}function respondWithResult(_0x532564,_0x32f3fc){_0x32f3fc=_0x32f3fc||0xc8;return function(_0x1067c0){if(_0x1067c0){return _0x532564[_0x5621('0x1a')](_0x32f3fc)['json'](_0x1067c0);}};}function respondWithFilteredResult(_0x35f0df,_0x2a4cbc){return function(_0x555e21){if(_0x555e21){var _0x55ca9c=typeof _0x2a4cbc[_0x5621('0x1c')]===_0x5621('0x1d')&&typeof _0x2a4cbc[_0x5621('0x1e')]===_0x5621('0x1d');var _0x2f3289=_0x555e21[_0x5621('0x1f')];var _0x374f44=_0x55ca9c?0x0:_0x2a4cbc[_0x5621('0x1c')];var _0x2baba3=_0x55ca9c?_0x555e21['count']:_0x2a4cbc[_0x5621('0x1c')]+_0x2a4cbc[_0x5621('0x1e')];var _0x5a9667;if(_0x2baba3>=_0x2f3289){_0x2baba3=_0x2f3289;_0x5a9667=0xc8;}else{_0x5a9667=0xce;}_0x35f0df[_0x5621('0x1a')](_0x5a9667);return _0x35f0df['set'](_0x5621('0x20'),_0x374f44+'-'+_0x2baba3+'/'+_0x2f3289)[_0x5621('0x21')](_0x555e21);}return null;};}function patchUpdates(_0x179830){return function(_0x3f6791){try{jsonpatch[_0x5621('0x22')](_0x3f6791,_0x179830,!![]);}catch(_0x5bbabe){return BPromise[_0x5621('0x23')](_0x5bbabe);}return _0x3f6791[_0x5621('0x24')]();};}function saveUpdates(_0x16cb32,_0x3eaa1a){return function(_0x52a148){if(_0x52a148){return _0x52a148[_0x5621('0x25')](_0x16cb32)[_0x5621('0x26')](function(_0x3527e0){return _0x3527e0;});}return null;};}function removeEntity(_0x168e5a,_0x1a3ee6){return function(_0x2af50a){if(_0x2af50a){return _0x2af50a[_0x5621('0x27')]()['then'](function(){var _0x23ba00=_0x2af50a['get']({'plain':!![]});var _0xb6800=_0x5621('0x28');return db[_0x5621('0x29')][_0x5621('0x27')]({'where':{'type':_0xb6800,'resourceId':_0x23ba00['id']}})[_0x5621('0x26')](function(){return _0x2af50a;});})[_0x5621('0x26')](function(){_0x168e5a[_0x5621('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x226d73,_0x250f65){return function(_0x1c8e5a){if(!_0x1c8e5a){_0x226d73[_0x5621('0x19')](0x194);}return _0x1c8e5a;};}function handleError(_0x5b17dd,_0x161c93){_0x161c93=_0x161c93||0x1f4;return function(_0x2f0600){logger['error'](_0x2f0600['stack']);if(_0x2f0600[_0x5621('0x2a')]){delete _0x2f0600[_0x5621('0x2a')];}_0x5b17dd[_0x5621('0x1a')](_0x161c93)[_0x5621('0x2b')](_0x2f0600);};}exports[_0x5621('0x2c')]=function(_0xc1af98,_0x280974){var _0x5b138f={},_0x1cc873={},_0x45a33d={'count':0x0,'rows':[]};var _0x45313e=_[_0x5621('0x2d')](db[_0x5621('0x2e')]['rawAttributes'],function(_0x311060){return{'name':_0x311060[_0x5621('0x2f')],'type':_0x311060[_0x5621('0x30')][_0x5621('0x31')]};});_0x1cc873[_0x5621('0x32')]=_['map'](_0x45313e,_0x5621('0x2a'));_0x1cc873['query']=_[_0x5621('0x33')](_0xc1af98[_0x5621('0x34')]);_0x1cc873[_0x5621('0x35')]=_[_0x5621('0x36')](_0x1cc873[_0x5621('0x32')],_0x1cc873['query']);_0x5b138f[_0x5621('0x37')]=_[_0x5621('0x36')](_0x1cc873[_0x5621('0x32')],qs[_0x5621('0x38')](_0xc1af98[_0x5621('0x34')]['fields']));_0x5b138f[_0x5621('0x37')]=_0x5b138f[_0x5621('0x37')][_0x5621('0x39')]?_0x5b138f['attributes']:_0x1cc873[_0x5621('0x32')];if(!_0xc1af98[_0x5621('0x34')]['hasOwnProperty'](_0x5621('0x3a'))){_0x5b138f[_0x5621('0x1e')]=qs[_0x5621('0x1e')](_0xc1af98[_0x5621('0x34')][_0x5621('0x1e')]);_0x5b138f[_0x5621('0x1c')]=qs[_0x5621('0x1c')](_0xc1af98['query'][_0x5621('0x1c')]);}_0x5b138f[_0x5621('0x3b')]=qs[_0x5621('0x3c')](_0xc1af98[_0x5621('0x34')][_0x5621('0x3c')]);_0x5b138f[_0x5621('0x3d')]=qs['filters'](_[_0x5621('0x3e')](_0xc1af98[_0x5621('0x34')],_0x1cc873[_0x5621('0x35')]),_0x45313e);if(_0xc1af98['query']['filter']){_0x5b138f[_0x5621('0x3d')]=_['merge'](_0x5b138f['where'],{'$or':_[_0x5621('0x2d')](_0x45313e,function(_0x65f703){if(_0x65f703[_0x5621('0x30')]!=='VIRTUAL'){var _0x460262={};_0x460262[_0x65f703[_0x5621('0x2a')]]={'$like':'%'+_0xc1af98['query'][_0x5621('0x3f')]+'%'};return _0x460262;}})});}_0x5b138f=_[_0x5621('0x40')]({},_0x5b138f,_0xc1af98[_0x5621('0x41')]);var _0x3574c2={'where':_0x5b138f[_0x5621('0x3d')]};return db[_0x5621('0x2e')][_0x5621('0x1f')](_0x3574c2)[_0x5621('0x26')](function(_0x5e3c29){_0x45a33d[_0x5621('0x1f')]=_0x5e3c29;if(_0xc1af98['query'][_0x5621('0x42')]){_0x5b138f[_0x5621('0x43')]=[{'all':!![]}];}return db[_0x5621('0x2e')]['findAll'](_0x5b138f);})[_0x5621('0x26')](function(_0x21a006){_0x45a33d[_0x5621('0x44')]=_0x21a006;return _0x45a33d;})[_0x5621('0x26')](respondWithFilteredResult(_0x280974,_0x5b138f))[_0x5621('0x45')](handleError(_0x280974,null));};exports[_0x5621('0x46')]=function(_0x3bb41f,_0x483c1f){var _0xf36e3={'raw':![],'where':{'id':_0x3bb41f[_0x5621('0x47')]['id']}},_0x2154c8={};_0x2154c8[_0x5621('0x32')]=_[_0x5621('0x33')](db[_0x5621('0x2e')]['rawAttributes']);_0x2154c8[_0x5621('0x34')]=_['keys'](_0x3bb41f[_0x5621('0x34')]);_0x2154c8['filters']=_[_0x5621('0x36')](_0x2154c8[_0x5621('0x32')],_0x2154c8[_0x5621('0x34')]);_0xf36e3[_0x5621('0x37')]=_[_0x5621('0x36')](_0x2154c8[_0x5621('0x32')],qs[_0x5621('0x38')](_0x3bb41f['query'][_0x5621('0x38')]));_0xf36e3[_0x5621('0x37')]=_0xf36e3[_0x5621('0x37')]['length']?_0xf36e3[_0x5621('0x37')]:_0x2154c8[_0x5621('0x32')];if(_0x3bb41f[_0x5621('0x34')][_0x5621('0x42')]){_0xf36e3[_0x5621('0x43')]=[{'all':!![]}];}_0xf36e3=_[_0x5621('0x40')]({},_0xf36e3,_0x3bb41f[_0x5621('0x41')]);return db[_0x5621('0x2e')][_0x5621('0x48')](_0xf36e3)[_0x5621('0x26')](handleEntityNotFound(_0x483c1f,null))[_0x5621('0x26')](respondWithResult(_0x483c1f,null))['catch'](handleError(_0x483c1f,null));};exports[_0x5621('0x49')]=function(_0x3cb2d9,_0x5b2607){return db[_0x5621('0x2e')][_0x5621('0x49')](_0x3cb2d9['body'],{})['then'](function(_0x248cff){var _0x3f25e2=_0x3cb2d9['user']['get']({'plain':!![]});if(!_0x3f25e2)throw new Error(_0x5621('0x4a'));if(_0x3f25e2[_0x5621('0x4b')]===_0x5621('0x4c')){var _0x35205c=_0x248cff[_0x5621('0x4d')]({'plain':!![]});var _0xccab9b='Projects';return db[_0x5621('0x4e')]['find']({'where':{'name':_0xccab9b,'userProfileId':_0x3f25e2[_0x5621('0x4f')]},'raw':!![]})['then'](function(_0x51e65d){if(_0x51e65d&&_0x51e65d[_0x5621('0x50')]===0x0){return db[_0x5621('0x29')][_0x5621('0x49')]({'name':_0x35205c['name'],'resourceId':_0x35205c['id'],'type':_0x51e65d[_0x5621('0x2a')],'sectionId':_0x51e65d['id']},{})['then'](function(){return _0x248cff;});}else{return _0x248cff;}})[_0x5621('0x45')](function(_0x45e0c1){logger[_0x5621('0x51')](_0x5621('0x52'),_0x45e0c1);throw _0x45e0c1;});}return _0x248cff;})[_0x5621('0x26')](respondWithResult(_0x5b2607,0xc9))[_0x5621('0x45')](handleError(_0x5b2607,null));};exports['clone']=function(_0xfc075f,_0x205829){var _0xaaac2d={'where':{'id':_0xfc075f[_0x5621('0x47')]['id']}},_0x2d4375={};_0x2d4375[_0x5621('0x32')]=_[_0x5621('0x33')](db[_0x5621('0x2e')][_0x5621('0x53')]);_0xaaac2d['attributes']=_[_0x5621('0x36')](_0x2d4375[_0x5621('0x32')],qs[_0x5621('0x38')](_0xfc075f[_0x5621('0x34')][_0x5621('0x38')]));_0xaaac2d['attributes']=_0xaaac2d['attributes'][_0x5621('0x39')]?_0xaaac2d[_0x5621('0x37')]:_0x2d4375['model'];if(_0xfc075f[_0x5621('0x34')][_0x5621('0x42')]){_0xaaac2d[_0x5621('0x43')]=[{'all':!![]}];}_0xaaac2d=_['merge']({},_0xaaac2d,_0xfc075f[_0x5621('0x41')]);return db[_0x5621('0x2e')][_0x5621('0x48')](_0xaaac2d)[_0x5621('0x26')](handleEntityNotFound(_0x205829,null))[_0x5621('0x26')](function(_0x4f9e73){if(_0x4f9e73){var _0x1fd36d=_0x4f9e73[_0x5621('0x4d')]({'plain':!![]});_0x1fd36d=qs[_0x5621('0x54')](_0x1fd36d,['id','createdAt',_0x5621('0x55')]);_0xfc075f[_0x5621('0x56')]=_[_0x5621('0x54')](_0xfc075f[_0x5621('0x56')],['id','createdAt',_0x5621('0x55')]);return db[_0x5621('0x2e')][_0x5621('0x49')](_[_0x5621('0x40')](_0x1fd36d,_0xfc075f[_0x5621('0x56')]),{'include':_0xfc075f['query']['includeAll']?[{'all':!![]}]:undefined})[_0x5621('0x26')](function(_0x2305ae){var _0x17728b=_0xfc075f['user']['get']({'plain':!![]});if(!_0x17728b)throw new Error(_0x5621('0x4a'));if(_0x17728b['role']===_0x5621('0x4c')){var _0x2231ae=_0x2305ae[_0x5621('0x4d')]({'plain':!![]});var _0x3409c4=_0x5621('0x28');return db[_0x5621('0x4e')][_0x5621('0x48')]({'where':{'name':_0x3409c4,'userProfileId':_0x17728b['userProfileId']},'raw':!![]})[_0x5621('0x26')](function(_0x874baa){if(_0x874baa&&_0x874baa[_0x5621('0x50')]===0x0){return db['UserProfileResource']['create']({'name':_0x2231ae[_0x5621('0x2a')],'resourceId':_0x2231ae['id'],'type':_0x874baa[_0x5621('0x2a')],'sectionId':_0x874baa['id']},{})['then'](function(){return _0x2305ae;});}else{return _0x2305ae;}})[_0x5621('0x45')](function(_0x9c9fc7){logger[_0x5621('0x51')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x9c9fc7);throw _0x9c9fc7;});}return _0x2305ae;});}})['then'](respondWithResult(_0x205829,0xc9))[_0x5621('0x45')](handleError(_0x205829,null));};exports[_0x5621('0x25')]=function(_0x488e40,_0x3a9769){if(_0x488e40[_0x5621('0x56')]['id']){delete _0x488e40['body']['id'];}return db[_0x5621('0x2e')][_0x5621('0x48')]({'where':{'id':_0x488e40['params']['id']}})[_0x5621('0x26')](handleEntityNotFound(_0x3a9769,null))[_0x5621('0x26')](saveUpdates(_0x488e40[_0x5621('0x56')],null))[_0x5621('0x26')](respondWithResult(_0x3a9769,null))[_0x5621('0x45')](handleError(_0x3a9769,null));};exports[_0x5621('0x27')]=function(_0x10b630,_0x583644){return db[_0x5621('0x2e')][_0x5621('0x48')]({'where':{'id':_0x10b630[_0x5621('0x47')]['id']}})['then'](handleEntityNotFound(_0x583644,null))['then'](removeEntity(_0x583644,null))[_0x5621('0x45')](handleError(_0x583644,null));};exports[_0x5621('0x57')]=function(_0x32839c,_0x54a6a5,_0x540616){var _0x2cc10d={'raw':!![],'where':{}};var _0x3a578b={};var _0x23136e={'count':0x0,'rows':[]};return db[_0x5621('0x2e')][_0x5621('0x58')]({'where':{'id':_0x32839c[_0x5621('0x47')]['id']}})['then'](handleEntityNotFound(_0x54a6a5,null))[_0x5621('0x26')](function(_0x3852e0){if(_0x3852e0){_0x3a578b[_0x5621('0x32')]=_[_0x5621('0x33')](db[_0x5621('0x59')][_0x5621('0x53')]);_0x3a578b[_0x5621('0x34')]=_[_0x5621('0x33')](_0x32839c[_0x5621('0x34')]);_0x3a578b[_0x5621('0x35')]=_[_0x5621('0x36')](_0x3a578b[_0x5621('0x32')],_0x3a578b[_0x5621('0x34')]);_0x2cc10d[_0x5621('0x37')]=_[_0x5621('0x36')](_0x3a578b[_0x5621('0x32')],qs[_0x5621('0x38')](_0x32839c['query']['fields']));_0x2cc10d[_0x5621('0x37')]=_0x2cc10d[_0x5621('0x37')][_0x5621('0x39')]?_0x2cc10d[_0x5621('0x37')]:_0x3a578b['model'];if(!_0x32839c[_0x5621('0x34')][_0x5621('0x5a')](_0x5621('0x3a'))){_0x2cc10d[_0x5621('0x1e')]=qs['limit'](_0x32839c[_0x5621('0x34')][_0x5621('0x1e')]);_0x2cc10d[_0x5621('0x1c')]=qs['offset'](_0x32839c[_0x5621('0x34')]['offset']);}_0x2cc10d[_0x5621('0x3b')]=qs[_0x5621('0x3c')](_0x32839c['query'][_0x5621('0x3c')]);_0x2cc10d['where']=qs['filters'](_[_0x5621('0x3e')](_0x32839c[_0x5621('0x34')],_0x3a578b[_0x5621('0x35')]));_0x2cc10d[_0x5621('0x3d')][_0x5621('0x5b')]=_0x3852e0['id'];if(_0x32839c[_0x5621('0x34')][_0x5621('0x3f')]){_0x2cc10d['where']=_[_0x5621('0x40')](_0x2cc10d[_0x5621('0x3d')],{'$or':_[_0x5621('0x2d')](_0x2cc10d[_0x5621('0x37')],function(_0x327945){var _0x3f7b89={};_0x3f7b89[_0x327945]={'$like':'%'+_0x32839c['query'][_0x5621('0x3f')]+'%'};return _0x3f7b89;})});}_0x2cc10d=_['merge']({},_0x2cc10d,_0x32839c[_0x5621('0x41')]);return db[_0x5621('0x59')][_0x5621('0x1f')]({'where':_0x2cc10d[_0x5621('0x3d')]})['then'](function(_0x187d2d){_0x23136e['count']=_0x187d2d;if(_0x32839c[_0x5621('0x34')]['includeAll']){_0x2cc10d[_0x5621('0x43')]=[{'all':!![]}];}return db[_0x5621('0x59')][_0x5621('0x5c')](_0x2cc10d);})[_0x5621('0x26')](function(_0x15d56){_0x23136e[_0x5621('0x44')]=_0x15d56;return _0x23136e;});}})[_0x5621('0x26')](respondWithFilteredResult(_0x54a6a5,_0x2cc10d))[_0x5621('0x45')](handleError(_0x54a6a5,null));};exports[_0x5621('0x5d')]=function(_0x30fba0,_0x3b8188,_0x3ffc31){var _0x105ddb={'raw':!![],'where':{}};var _0x434ba2={};var _0xfbcdaf={'count':0x0,'rows':[]};return db[_0x5621('0x2e')][_0x5621('0x58')]({'where':{'id':_0x30fba0[_0x5621('0x47')]['id']}})['then'](handleEntityNotFound(_0x3b8188,null))[_0x5621('0x26')](function(_0x53a40c){if(_0x53a40c){_0x434ba2[_0x5621('0x32')]=_[_0x5621('0x33')](db[_0x5621('0x5e')]['rawAttributes']);_0x434ba2[_0x5621('0x34')]=_[_0x5621('0x33')](_0x30fba0[_0x5621('0x34')]);_0x434ba2[_0x5621('0x35')]=_[_0x5621('0x36')](_0x434ba2[_0x5621('0x32')],_0x434ba2[_0x5621('0x34')]);_0x105ddb['attributes']=_[_0x5621('0x36')](_0x434ba2[_0x5621('0x32')],qs[_0x5621('0x38')](_0x30fba0[_0x5621('0x34')]['fields']));_0x105ddb[_0x5621('0x37')]=_0x105ddb[_0x5621('0x37')][_0x5621('0x39')]?_0x105ddb[_0x5621('0x37')]:_0x434ba2[_0x5621('0x32')];if(!_0x30fba0[_0x5621('0x34')][_0x5621('0x5a')](_0x5621('0x3a'))){_0x105ddb[_0x5621('0x1e')]=qs[_0x5621('0x1e')](_0x30fba0['query'][_0x5621('0x1e')]);_0x105ddb[_0x5621('0x1c')]=qs[_0x5621('0x1c')](_0x30fba0[_0x5621('0x34')]['offset']);}_0x105ddb[_0x5621('0x3b')]=qs[_0x5621('0x3c')](_0x30fba0['query'][_0x5621('0x3c')]);_0x105ddb[_0x5621('0x3d')]=qs[_0x5621('0x35')](_[_0x5621('0x3e')](_0x30fba0[_0x5621('0x34')],_0x434ba2[_0x5621('0x35')]));_0x105ddb[_0x5621('0x3d')][_0x5621('0x5b')]=_0x53a40c['id'];if(_0x30fba0[_0x5621('0x34')]['filter']){_0x105ddb[_0x5621('0x3d')]=_[_0x5621('0x40')](_0x105ddb[_0x5621('0x3d')],{'$or':_[_0x5621('0x2d')](_0x105ddb[_0x5621('0x37')],function(_0x205c89){var _0x2270f4={};_0x2270f4[_0x205c89]={'$like':'%'+_0x30fba0['query'][_0x5621('0x3f')]+'%'};return _0x2270f4;})});}_0x105ddb=_[_0x5621('0x40')]({},_0x105ddb,_0x30fba0[_0x5621('0x41')]);return db[_0x5621('0x5e')][_0x5621('0x1f')]({'where':_0x105ddb[_0x5621('0x3d')]})[_0x5621('0x26')](function(_0x8b5d09){_0xfbcdaf[_0x5621('0x1f')]=_0x8b5d09;if(_0x30fba0[_0x5621('0x34')][_0x5621('0x42')]){_0x105ddb[_0x5621('0x43')]=[{'all':!![]}];}return db[_0x5621('0x5e')][_0x5621('0x5c')](_0x105ddb);})['then'](function(_0x29cd8f){_0xfbcdaf[_0x5621('0x44')]=_0x29cd8f;return _0xfbcdaf;});}})[_0x5621('0x26')](respondWithFilteredResult(_0x3b8188,_0x105ddb))[_0x5621('0x45')](handleError(_0x3b8188,null));};function char(_0x472686){return'number'===typeof _0x472686?String[_0x5621('0x5f')][_0x5621('0x22')](null,arguments):_0x472686;}function needsEncapsulation(_0x564052){return!!_0x564052&&(_0x564052[_0x5621('0x60')]()['indexOf'](char(0xd))>=0x0||_0x564052['toString']()[_0x5621('0x61')](char(0xa))>=0x0||_0x564052['toString']()['indexOf'](char(0x2c))>=0x0||_0x564052[_0x5621('0x60')]()[_0x5621('0x61')](char(0x22))>=0x0);}function encapsulate(_0xb8c3a2){var _0x2d100d=char(0x22),_0x5d3c91='\x5c'+char(0x22),_0x27bfa6=_0xb8c3a2['toString']()['replace'](new RegExp(_0x2d100d,'g'),_0x5d3c91);return _0x2d100d+_0x27bfa6+_0x2d100d;}exports[_0x5621('0x62')]=function(_0x6c313e,_0x5799f6,_0x28cbd7){var _0x295e02,_0x23eeeb;var _0x24d6c4={'where':{'ProjectId':_0x6c313e['params']['id']}};if(_0x6c313e['query'][_0x5621('0x63')]){_0x24d6c4[_0x5621('0x3d')]['starttime']=JSON[_0x5621('0x64')](_0x6c313e[_0x5621('0x34')][_0x5621('0x63')]);}return db[_0x5621('0x59')]['findAll'](_0x24d6c4)[_0x5621('0x26')](handleEntityNotFound(_0x5799f6,null))[_0x5621('0x26')](function(_0x49f57e){if(_0x49f57e){_0x295e02=_0x49f57e;return db['JscriptyQuestionReport'][_0x5621('0x5c')]({'where':{'SessionId':{'$in':_[_0x5621('0x2d')](_0x295e02,'id')},'ProjectId':_0x6c313e['params']['id']},'order':_0x5621('0x65')});}})[_0x5621('0x26')](handleEntityNotFound(_0x5799f6,null))[_0x5621('0x26')](function(_0x4fab76){if(_0x4fab76){_0x23eeeb=_0x4fab76;var _0x315675={};for(var _0x278da0=0x0,_0x4e5f8b=_0x23eeeb[_0x5621('0x39')];_0x278da0<_0x4e5f8b;_0x278da0++){if(!_0x315675[_0x5621('0x5a')](_0x23eeeb[_0x278da0][_0x5621('0x66')])){_0x315675[_0x23eeeb[_0x278da0][_0x5621('0x66')]]=needsEncapsulation(_0x23eeeb[_0x278da0][_0x5621('0x67')])?encapsulate(_0x23eeeb[_0x278da0][_0x5621('0x67')]):_0x23eeeb[_0x278da0][_0x5621('0x67')];}}var _0x34f64b=[],_0x5d8d4f={};for(var _0x1b1f9d=0x0,_0x5da953=_0x295e02['length'];_0x1b1f9d<_0x5da953;_0x1b1f9d++){_0x5d8d4f={'ProjectId':_0x6c313e['params']['id'],'SessionId':_0x295e02[_0x1b1f9d]['id'],'StartTime':moment(_0x295e02[_0x1b1f9d]['starttime'])[_0x5621('0x68')](_0x5621('0x69'))};for(var _0x492e8c=0x0,_0x167105=_0x23eeeb[_0x5621('0x39')];_0x492e8c<_0x167105;_0x492e8c++){if(_0x23eeeb[_0x492e8c][_0x5621('0x6a')]==_0x295e02[_0x1b1f9d]['id']&&_0x315675[_0x5621('0x5a')](_0x23eeeb[_0x492e8c]['questionId'])){_0x5d8d4f[_0x315675[_0x23eeeb[_0x492e8c]['questionId']]]=_0x23eeeb[_0x492e8c]['answer'];}}for(var _0xd0afbd in _0x315675){if(!_0x5d8d4f[_0x5621('0x5a')](_0x315675[_0xd0afbd])){_0x5d8d4f[_0x315675[_0xd0afbd]]=null;}}_0x34f64b[_0x5621('0x6b')](_0x5d8d4f);}return _0x34f64b;}})[_0x5621('0x26')](function(_0x111a4a){if(!_[_0x5621('0x6c')](_0x111a4a)){var _0x20631b=toCsv(_0x111a4a);var _0x420abc=Date[_0x5621('0x6d')]();fs['writeFileSync'](util[_0x5621('0x68')]('/tmp/Jscripty_Project_%d_Summary_%s.csv',_0x6c313e[_0x5621('0x47')]['id'],_0x420abc),_0x20631b);_0x5799f6[_0x5621('0x6e')](_0x5621('0x6f'),_0x5621('0x70')+util[_0x5621('0x68')](_0x5621('0x71'),_0x6c313e[_0x5621('0x47')]['id'],_0x420abc));_0x5799f6[_0x5621('0x6e')](_0x5621('0x72'),'text/csv');return _0x5799f6['download'](util['format']('/tmp/Jscripty_Project_%d_Summary_%s.csv',_0x6c313e[_0x5621('0x47')]['id'],_0x420abc));}else{return _0x5799f6[_0x5621('0x19')](0xcc);}})[_0x5621('0x45')](handleError(_0x5799f6,null));}; \ No newline at end of file diff --git a/server/api/jscriptyProject/jscriptyProject.model.js b/server/api/jscriptyProject/jscriptyProject.model.js new file mode 100644 index 0000000..2ff744b --- /dev/null +++ b/server/api/jscriptyProject/jscriptyProject.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6334=['rimraf','../../config/environment','./jscriptyProject.attributes','exports','JscriptyProject','lodash','util','../../config/logger','api','moment','bluebird','path'];(function(_0x393730,_0x2bfe34){var _0x3323f3=function(_0x1b8faf){while(--_0x1b8faf){_0x393730['push'](_0x393730['shift']());}};_0x3323f3(++_0x2bfe34);}(_0x6334,0x119));var _0x4633=function(_0x252805,_0x1d1e8e){_0x252805=_0x252805-0x0;var _0x3e74b9=_0x6334[_0x252805];return _0x3e74b9;};'use strict';var _=require(_0x4633('0x0'));var util=require(_0x4633('0x1'));var logger=require(_0x4633('0x2'))(_0x4633('0x3'));var moment=require(_0x4633('0x4'));var BPromise=require(_0x4633('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x4633('0x6'));var rimraf=require(_0x4633('0x7'));var config=require(_0x4633('0x8'));var attributes=require(_0x4633('0x9'));module[_0x4633('0xa')]=function(_0x6493dc,_0x175e14){return _0x6493dc['define'](_0x4633('0xb'),attributes,{'tableName':'jscripty_projects','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/jscriptyProject/jscriptyProject.rpc.js b/server/api/jscriptyProject/jscriptyProject.rpc.js new file mode 100644 index 0000000..badf828 --- /dev/null +++ b/server/api/jscriptyProject/jscriptyProject.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda3f=['rpc','jayson/promise','client','request','then','info','JscriptyProject,\x20%s,\x20%s','request\x20sent','debug','JscriptyProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','util','moment','../../mysqldb','../../config/logger'];(function(_0x47408e,_0x481428){var _0x1636bc=function(_0x2fe7a6){while(--_0x2fe7a6){_0x47408e['push'](_0x47408e['shift']());}};_0x1636bc(++_0x481428);}(_0xda3f,0xec));var _0xfda3=function(_0x32f3f7,_0x1d8aa2){_0x32f3f7=_0x32f3f7-0x0;var _0x50e6c7=_0xda3f[_0x32f3f7];return _0x50e6c7;};'use strict';var _=require('lodash');var util=require(_0xfda3('0x0'));var moment=require(_0xfda3('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfda3('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0xfda3('0x3'))(_0xfda3('0x4'));var config=require('../../config/environment');var jayson=require(_0xfda3('0x5'));var client=jayson[_0xfda3('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4e72d1,_0x316792,_0x42476a){return new BPromise(function(_0x125e2a,_0x4018c0){return client[_0xfda3('0x7')](_0x4e72d1,_0x42476a)[_0xfda3('0x8')](function(_0x46655c){logger[_0xfda3('0x9')](_0xfda3('0xa'),_0x316792,_0xfda3('0xb'));logger[_0xfda3('0xc')](_0xfda3('0xd'),_0x316792,'request\x20sent',JSON[_0xfda3('0xe')](_0x46655c));if(_0x46655c[_0xfda3('0xf')]){if(_0x46655c[_0xfda3('0xf')][_0xfda3('0x10')]===0x1f4){logger[_0xfda3('0xf')]('JscriptyProject,\x20%s,\x20%s',_0x316792,_0x46655c[_0xfda3('0xf')]['message']);return _0x4018c0(_0x46655c[_0xfda3('0xf')][_0xfda3('0x11')]);}logger['error']('JscriptyProject,\x20%s,\x20%s',_0x316792,_0x46655c['error'][_0xfda3('0x11')]);return _0x125e2a(_0x46655c[_0xfda3('0xf')]['message']);}else{logger['info']('JscriptyProject,\x20%s,\x20%s',_0x316792,_0xfda3('0xb'));_0x125e2a(_0x46655c[_0xfda3('0x12')][_0xfda3('0x11')]);}})[_0xfda3('0x13')](function(_0x34900d){logger[_0xfda3('0xf')](_0xfda3('0xa'),_0x316792,_0x34900d);_0x4018c0(_0x34900d);});});} \ No newline at end of file diff --git a/server/api/jscriptyQuestionReport/index.js b/server/api/jscriptyQuestionReport/index.js new file mode 100644 index 0000000..cebf513 --- /dev/null +++ b/server/api/jscriptyQuestionReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdb47=['show','post','create','put','update','destroy','exports','connect-timeout','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./jscriptyQuestionReport.controller','get','isAuthenticated','index','/describe','describe','/:id'];(function(_0xb6acc,_0x324909){var _0x37c846=function(_0x3295f3){while(--_0x3295f3){_0xb6acc['push'](_0xb6acc['shift']());}};_0x37c846(++_0x324909);}(_0xdb47,0x9f));var _0x7db4=function(_0x56d487,_0x34012d){_0x56d487=_0x56d487-0x0;var _0x43c2f6=_0xdb47[_0x56d487];return _0x43c2f6;};'use strict';var multer=require('multer');var util=require('util');var path=require('path');var timeout=require(_0x7db4('0x0'));var express=require('express');var router=express[_0x7db4('0x1')]();var fs_extra=require('fs-extra');var auth=require(_0x7db4('0x2'));var interaction=require(_0x7db4('0x3'));var config=require(_0x7db4('0x4'));var controller=require(_0x7db4('0x5'));router[_0x7db4('0x6')]('/',auth[_0x7db4('0x7')](),controller[_0x7db4('0x8')]);router[_0x7db4('0x6')](_0x7db4('0x9'),auth['isAuthenticated'](),controller[_0x7db4('0xa')]);router['get'](_0x7db4('0xb'),auth[_0x7db4('0x7')](),controller[_0x7db4('0xc')]);router[_0x7db4('0xd')]('/',auth[_0x7db4('0x7')](),controller[_0x7db4('0xe')]);router[_0x7db4('0xf')](_0x7db4('0xb'),auth[_0x7db4('0x7')](),controller[_0x7db4('0x10')]);router['delete'](_0x7db4('0xb'),auth[_0x7db4('0x7')](),controller[_0x7db4('0x11')]);module[_0x7db4('0x12')]=router; \ No newline at end of file diff --git a/server/api/jscriptyQuestionReport/jscriptyQuestionReport.attributes.js b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.attributes.js new file mode 100644 index 0000000..ec1e575 --- /dev/null +++ b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['long','STRING','sequelize','exports','TEXT'];(function(_0x1e4360,_0x930b9b){var _0x31e6b4=function(_0x49dd8e){while(--_0x49dd8e){_0x1e4360['push'](_0x1e4360['shift']());}};_0x31e6b4(++_0x930b9b);}(_0x7a54,0x106));var _0x47a5=function(_0x4d4e7b,_0xa9d9e5){_0x4d4e7b=_0x4d4e7b-0x0;var _0x360b66=_0x7a54[_0x4d4e7b];return _0x360b66;};'use strict';var Sequelize=require(_0x47a5('0x0'));module[_0x47a5('0x1')]={'question':{'type':Sequelize[_0x47a5('0x2')]},'answer':{'type':Sequelize['TEXT'](_0x47a5('0x3'))},'membername':{'type':Sequelize[_0x47a5('0x4')]},'projectname':{'type':Sequelize['STRING']},'queue':{'type':Sequelize[_0x47a5('0x4')]},'uniqueid':{'type':Sequelize[_0x47a5('0x4')]},'calleridname':{'type':Sequelize[_0x47a5('0x4')]},'calleridnum':{'type':Sequelize[_0x47a5('0x4')]},'questionId':{'type':Sequelize[_0x47a5('0x4')]}}; \ No newline at end of file diff --git a/server/api/jscriptyQuestionReport/jscriptyQuestionReport.controller.js b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.controller.js new file mode 100644 index 0000000..68cc1b2 --- /dev/null +++ b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4dec=['../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','destroy','then','error','send','index','map','JscriptyQuestionReport','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','name','options','includeAll','include','findAll','rows','catch','show','find','create','update','body','params','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','ejs','fs-extra','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch'];(function(_0x16be88,_0x4f1df2){var _0xa22080=function(_0x3de901){while(--_0x3de901){_0x16be88['push'](_0x16be88['shift']());}};_0xa22080(++_0x4f1df2);}(_0x4dec,0xd9));var _0xc4de=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x4dec[_0x3b380d];return _0x54502b;};'use strict';var emlformat=require(_0xc4de('0x0'));var rimraf=require(_0xc4de('0x1'));var zipdir=require(_0xc4de('0x2'));var jsonpatch=require(_0xc4de('0x3'));var rp=require(_0xc4de('0x4'));var moment=require(_0xc4de('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xc4de('0x6'));var util=require(_0xc4de('0x7'));var path=require(_0xc4de('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xc4de('0x9'));var fs=require('fs');var fs_extra=require(_0xc4de('0xa'));var _=require(_0xc4de('0xb'));var squel=require(_0xc4de('0xc'));var crypto=require(_0xc4de('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xc4de('0xe'));var toCsv=require(_0xc4de('0xf'));var querystring=require(_0xc4de('0x10'));var Papa=require(_0xc4de('0x11'));var Redis=require(_0xc4de('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xc4de('0x13'));var hardwareService=require(_0xc4de('0x14'));var logger=require(_0xc4de('0x15'))(_0xc4de('0x16'));var utils=require('../../config/utils');var config=require(_0xc4de('0x17'));var licenseUtil=require(_0xc4de('0x18'));var db=require(_0xc4de('0x19'))['db'];function respondWithStatusCode(_0x43dd7b,_0x41f3a1){_0x41f3a1=_0x41f3a1||0xcc;return function(_0x4cc05d){if(_0x4cc05d){return _0x43dd7b[_0xc4de('0x1a')](_0x41f3a1);}return _0x43dd7b['status'](_0x41f3a1)[_0xc4de('0x1b')]();};}function respondWithResult(_0x191ff1,_0x294e50){_0x294e50=_0x294e50||0xc8;return function(_0x1328bc){if(_0x1328bc){return _0x191ff1[_0xc4de('0x1c')](_0x294e50)[_0xc4de('0x1d')](_0x1328bc);}};}function respondWithFilteredResult(_0x5a60f9,_0x227b95){return function(_0x3dd4db){if(_0x3dd4db){var _0x4fe54b=typeof _0x227b95[_0xc4de('0x1e')]===_0xc4de('0x1f')&&typeof _0x227b95[_0xc4de('0x20')]===_0xc4de('0x1f');var _0x5bbf22=_0x3dd4db['count'];var _0x1ee08e=_0x4fe54b?0x0:_0x227b95[_0xc4de('0x1e')];var _0x37ab51=_0x4fe54b?_0x3dd4db[_0xc4de('0x21')]:_0x227b95[_0xc4de('0x1e')]+_0x227b95[_0xc4de('0x20')];var _0x4c3b69;if(_0x37ab51>=_0x5bbf22){_0x37ab51=_0x5bbf22;_0x4c3b69=0xc8;}else{_0x4c3b69=0xce;}_0x5a60f9[_0xc4de('0x1c')](_0x4c3b69);return _0x5a60f9[_0xc4de('0x22')](_0xc4de('0x23'),_0x1ee08e+'-'+_0x37ab51+'/'+_0x5bbf22)[_0xc4de('0x1d')](_0x3dd4db);}return null;};}function patchUpdates(_0x590fd9){return function(_0x49f879){try{jsonpatch[_0xc4de('0x24')](_0x49f879,_0x590fd9,!![]);}catch(_0x5084c9){return BPromise[_0xc4de('0x25')](_0x5084c9);}return _0x49f879[_0xc4de('0x26')]();};}function saveUpdates(_0x160580,_0x490a0c){return function(_0x4f65d0){if(_0x4f65d0){return _0x4f65d0['update'](_0x160580)['then'](function(_0x435b2b){return _0x435b2b;});}return null;};}function removeEntity(_0xcadfe2,_0x419588){return function(_0x51e046){if(_0x51e046){return _0x51e046[_0xc4de('0x27')]()[_0xc4de('0x28')](function(){_0xcadfe2['status'](0xcc)[_0xc4de('0x1b')]();});}};}function handleEntityNotFound(_0x3b2adc,_0x2869f1){return function(_0x3725b7){if(!_0x3725b7){_0x3b2adc[_0xc4de('0x1a')](0x194);}return _0x3725b7;};}function handleError(_0x2a25cd,_0x2d75cd){_0x2d75cd=_0x2d75cd||0x1f4;return function(_0x4cb1f1){logger[_0xc4de('0x29')](_0x4cb1f1['stack']);if(_0x4cb1f1['name']){delete _0x4cb1f1['name'];}_0x2a25cd[_0xc4de('0x1c')](_0x2d75cd)[_0xc4de('0x2a')](_0x4cb1f1);};}exports[_0xc4de('0x2b')]=function(_0x15ec5b,_0x305c6a){var _0x145d23={},_0x406322={},_0x3a4467={'count':0x0,'rows':[]};var _0x1a149e=_[_0xc4de('0x2c')](db[_0xc4de('0x2d')][_0xc4de('0x2e')],function(_0x1f9192){return{'name':_0x1f9192[_0xc4de('0x2f')],'type':_0x1f9192[_0xc4de('0x30')]['key']};});_0x406322[_0xc4de('0x31')]=_['map'](_0x1a149e,'name');_0x406322[_0xc4de('0x32')]=_[_0xc4de('0x33')](_0x15ec5b['query']);_0x406322[_0xc4de('0x34')]=_[_0xc4de('0x35')](_0x406322['model'],_0x406322['query']);_0x145d23['attributes']=_['intersection'](_0x406322[_0xc4de('0x31')],qs[_0xc4de('0x36')](_0x15ec5b['query'][_0xc4de('0x36')]));_0x145d23[_0xc4de('0x37')]=_0x145d23[_0xc4de('0x37')][_0xc4de('0x38')]?_0x145d23[_0xc4de('0x37')]:_0x406322['model'];if(!_0x15ec5b[_0xc4de('0x32')][_0xc4de('0x39')](_0xc4de('0x3a'))){_0x145d23['limit']=qs[_0xc4de('0x20')](_0x15ec5b[_0xc4de('0x32')][_0xc4de('0x20')]);_0x145d23[_0xc4de('0x1e')]=qs[_0xc4de('0x1e')](_0x15ec5b[_0xc4de('0x32')][_0xc4de('0x1e')]);}_0x145d23[_0xc4de('0x3b')]=qs['sort'](_0x15ec5b[_0xc4de('0x32')][_0xc4de('0x3c')]);_0x145d23[_0xc4de('0x3d')]=qs['filters'](_[_0xc4de('0x3e')](_0x15ec5b['query'],_0x406322[_0xc4de('0x34')]),_0x1a149e);if(_0x15ec5b['query']['filter']){_0x145d23[_0xc4de('0x3d')]=_[_0xc4de('0x3f')](_0x145d23['where'],{'$or':_[_0xc4de('0x2c')](_0x1a149e,function(_0x38a273){if(_0x38a273[_0xc4de('0x30')]!==_0xc4de('0x40')){var _0x4f0c5c={};_0x4f0c5c[_0x38a273[_0xc4de('0x41')]]={'$like':'%'+_0x15ec5b[_0xc4de('0x32')]['filter']+'%'};return _0x4f0c5c;}})});}_0x145d23=_[_0xc4de('0x3f')]({},_0x145d23,_0x15ec5b[_0xc4de('0x42')]);var _0x220f46={'where':_0x145d23[_0xc4de('0x3d')]};return db[_0xc4de('0x2d')][_0xc4de('0x21')](_0x220f46)[_0xc4de('0x28')](function(_0x4b2d00){_0x3a4467[_0xc4de('0x21')]=_0x4b2d00;if(_0x15ec5b[_0xc4de('0x32')][_0xc4de('0x43')]){_0x145d23[_0xc4de('0x44')]=[{'all':!![]}];}return db[_0xc4de('0x2d')][_0xc4de('0x45')](_0x145d23);})[_0xc4de('0x28')](function(_0x4e30d2){_0x3a4467[_0xc4de('0x46')]=_0x4e30d2;return _0x3a4467;})[_0xc4de('0x28')](respondWithFilteredResult(_0x305c6a,_0x145d23))[_0xc4de('0x47')](handleError(_0x305c6a,null));};exports[_0xc4de('0x48')]=function(_0x8bf7a,_0x398eb7){var _0x45259b={'raw':!![],'where':{'id':_0x8bf7a['params']['id']}},_0x42f8b5={};_0x42f8b5[_0xc4de('0x31')]=_[_0xc4de('0x33')](db['JscriptyQuestionReport'][_0xc4de('0x2e')]);_0x42f8b5['query']=_[_0xc4de('0x33')](_0x8bf7a['query']);_0x42f8b5[_0xc4de('0x34')]=_[_0xc4de('0x35')](_0x42f8b5[_0xc4de('0x31')],_0x42f8b5[_0xc4de('0x32')]);_0x45259b[_0xc4de('0x37')]=_[_0xc4de('0x35')](_0x42f8b5[_0xc4de('0x31')],qs[_0xc4de('0x36')](_0x8bf7a[_0xc4de('0x32')]['fields']));_0x45259b['attributes']=_0x45259b[_0xc4de('0x37')][_0xc4de('0x38')]?_0x45259b['attributes']:_0x42f8b5['model'];if(_0x8bf7a[_0xc4de('0x32')][_0xc4de('0x43')]){_0x45259b['include']=[{'all':!![]}];}_0x45259b=_[_0xc4de('0x3f')]({},_0x45259b,_0x8bf7a[_0xc4de('0x42')]);return db['JscriptyQuestionReport'][_0xc4de('0x49')](_0x45259b)[_0xc4de('0x28')](handleEntityNotFound(_0x398eb7,null))['then'](respondWithResult(_0x398eb7,null))['catch'](handleError(_0x398eb7,null));};exports['create']=function(_0x3a2ae0,_0x49f257){return db[_0xc4de('0x2d')][_0xc4de('0x4a')](_0x3a2ae0['body'],{})[_0xc4de('0x28')](respondWithResult(_0x49f257,0xc9))[_0xc4de('0x47')](handleError(_0x49f257,null));};exports[_0xc4de('0x4b')]=function(_0x5c736e,_0x260d47){if(_0x5c736e[_0xc4de('0x4c')]['id']){delete _0x5c736e['body']['id'];}return db[_0xc4de('0x2d')]['find']({'where':{'id':_0x5c736e[_0xc4de('0x4d')]['id']}})[_0xc4de('0x28')](handleEntityNotFound(_0x260d47,null))[_0xc4de('0x28')](saveUpdates(_0x5c736e[_0xc4de('0x4c')],null))[_0xc4de('0x28')](respondWithResult(_0x260d47,null))[_0xc4de('0x47')](handleError(_0x260d47,null));};exports[_0xc4de('0x27')]=function(_0x4af726,_0x25fc25){return db['JscriptyQuestionReport']['find']({'where':{'id':_0x4af726[_0xc4de('0x4d')]['id']}})[_0xc4de('0x28')](handleEntityNotFound(_0x25fc25,null))[_0xc4de('0x28')](removeEntity(_0x25fc25,null))['catch'](handleError(_0x25fc25,null));};exports[_0xc4de('0x4e')]=function(_0x155957,_0x2ed677){return db['JscriptyQuestionReport']['describe']()[_0xc4de('0x28')](respondWithResult(_0x2ed677,null))['catch'](handleError(_0x2ed677,null));}; \ No newline at end of file diff --git a/server/api/jscriptyQuestionReport/jscriptyQuestionReport.model.js b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.model.js new file mode 100644 index 0000000..5fdb9bc --- /dev/null +++ b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9a67=['api','moment','bluebird','request-promise','path','rimraf','../../config/environment','define','JscriptyQuestionReport','report_jscripty_questions','util','../../config/logger'];(function(_0x131065,_0x3f030d){var _0x2a79e7=function(_0xff87d9){while(--_0xff87d9){_0x131065['push'](_0x131065['shift']());}};_0x2a79e7(++_0x3f030d);}(_0x9a67,0x18a));var _0x79a6=function(_0x33532f,_0x16d0ec){_0x33532f=_0x33532f-0x0;var _0x2b93aa=_0x9a67[_0x33532f];return _0x2b93aa;};'use strict';var _=require('lodash');var util=require(_0x79a6('0x0'));var logger=require(_0x79a6('0x1'))(_0x79a6('0x2'));var moment=require(_0x79a6('0x3'));var BPromise=require(_0x79a6('0x4'));var rp=require(_0x79a6('0x5'));var fs=require('fs');var path=require(_0x79a6('0x6'));var rimraf=require(_0x79a6('0x7'));var config=require(_0x79a6('0x8'));var attributes=require('./jscriptyQuestionReport.attributes');module['exports']=function(_0x51a680,_0x20a7d9){return _0x51a680[_0x79a6('0x9')](_0x79a6('0xa'),attributes,{'tableName':_0x79a6('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/jscriptyQuestionReport/jscriptyQuestionReport.rpc.js b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.rpc.js new file mode 100644 index 0000000..3418887 --- /dev/null +++ b/server/api/jscriptyQuestionReport/jscriptyQuestionReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x94ee=['message','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','then','info','JscriptyQuestionReport,\x20%s,\x20%s','request\x20sent','JscriptyQuestionReport,\x20%s,\x20%s,\x20%s','error','code'];(function(_0x4179cf,_0x3885da){var _0x33d325=function(_0x55d35f){while(--_0x55d35f){_0x4179cf['push'](_0x4179cf['shift']());}};_0x33d325(++_0x3885da);}(_0x94ee,0x1e5));var _0xe94e=function(_0x32f962,_0x1d2037){_0x32f962=_0x32f962-0x0;var _0x3aee1e=_0x94ee[_0x32f962];return _0x3aee1e;};'use strict';var _=require(_0xe94e('0x0'));var util=require(_0xe94e('0x1'));var moment=require(_0xe94e('0x2'));var BPromise=require(_0xe94e('0x3'));var rs=require(_0xe94e('0x4'));var fs=require('fs');var Redis=require(_0xe94e('0x5'));var db=require(_0xe94e('0x6'))['db'];var utils=require(_0xe94e('0x7'));var logger=require('../../config/logger')('rpc');var config=require(_0xe94e('0x8'));var jayson=require(_0xe94e('0x9'));var client=jayson[_0xe94e('0xa')][_0xe94e('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x48dddc,_0x189db2,_0x48d4e5){return new BPromise(function(_0x1b0bd5,_0x2f9b98){return client['request'](_0x48dddc,_0x48d4e5)[_0xe94e('0xc')](function(_0x3e1936){logger[_0xe94e('0xd')](_0xe94e('0xe'),_0x189db2,_0xe94e('0xf'));logger['debug'](_0xe94e('0x10'),_0x189db2,'request\x20sent',JSON['stringify'](_0x3e1936));if(_0x3e1936[_0xe94e('0x11')]){if(_0x3e1936[_0xe94e('0x11')][_0xe94e('0x12')]===0x1f4){logger['error']('JscriptyQuestionReport,\x20%s,\x20%s',_0x189db2,_0x3e1936['error']['message']);return _0x2f9b98(_0x3e1936[_0xe94e('0x11')][_0xe94e('0x13')]);}logger[_0xe94e('0x11')]('JscriptyQuestionReport,\x20%s,\x20%s',_0x189db2,_0x3e1936[_0xe94e('0x11')][_0xe94e('0x13')]);return _0x1b0bd5(_0x3e1936[_0xe94e('0x11')]['message']);}else{logger[_0xe94e('0xd')](_0xe94e('0xe'),_0x189db2,_0xe94e('0xf'));_0x1b0bd5(_0x3e1936['result'][_0xe94e('0x13')]);}})[_0xe94e('0x14')](function(_0x167418){logger['error'](_0xe94e('0xe'),_0x189db2,_0x167418);_0x2f9b98(_0x167418);});});} \ No newline at end of file diff --git a/server/api/jscriptySessionReport/index.js b/server/api/jscriptySessionReport/index.js new file mode 100644 index 0000000..c9351e6 --- /dev/null +++ b/server/api/jscriptySessionReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfca0=['exports','multer','util','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','describe','isAuthenticated','show','getQuestions','put','/:id','update','delete'];(function(_0x7f2df0,_0x2aa6df){var _0x1bb042=function(_0x38b02f){while(--_0x38b02f){_0x7f2df0['push'](_0x7f2df0['shift']());}};_0x1bb042(++_0x2aa6df);}(_0xfca0,0x190));var _0x0fca=function(_0x24259f,_0x102a0d){_0x24259f=_0x24259f-0x0;var _0x4e98e=_0xfca0[_0x24259f];return _0x4e98e;};'use strict';var multer=require(_0x0fca('0x0'));var util=require(_0x0fca('0x1'));var path=require('path');var timeout=require(_0x0fca('0x2'));var express=require(_0x0fca('0x3'));var router=express[_0x0fca('0x4')]();var fs_extra=require(_0x0fca('0x5'));var auth=require(_0x0fca('0x6'));var interaction=require(_0x0fca('0x7'));var config=require(_0x0fca('0x8'));var controller=require('./jscriptySessionReport.controller');router['get']('/',auth['isAuthenticated'](),controller['index']);router[_0x0fca('0x9')]('/describe',auth['isAuthenticated'](),controller[_0x0fca('0xa')]);router['get']('/:id',auth[_0x0fca('0xb')](),controller[_0x0fca('0xc')]);router[_0x0fca('0x9')]('/:id/questions',auth[_0x0fca('0xb')](),controller[_0x0fca('0xd')]);router['post']('/',auth[_0x0fca('0xb')](),controller['create']);router[_0x0fca('0xe')](_0x0fca('0xf'),auth[_0x0fca('0xb')](),controller[_0x0fca('0x10')]);router[_0x0fca('0x11')](_0x0fca('0xf'),auth[_0x0fca('0xb')](),controller['destroy']);module[_0x0fca('0x12')]=router; \ No newline at end of file diff --git a/server/api/jscriptySessionReport/jscriptySessionReport.attributes.js b/server/api/jscriptySessionReport/jscriptySessionReport.attributes.js new file mode 100644 index 0000000..38427e3 --- /dev/null +++ b/server/api/jscriptySessionReport/jscriptySessionReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa64d=['BOOLEAN','moment','exports','setDataValue','starttime','endtime','format','YYYY-MM-DD\x20HH:mm:ss','STRING'];(function(_0x2112d4,_0x3c863c){var _0x434972=function(_0x477020){while(--_0x477020){_0x2112d4['push'](_0x2112d4['shift']());}};_0x434972(++_0x3c863c);}(_0xa64d,0x13c));var _0xda64=function(_0x172bac,_0xe60dbf){_0x172bac=_0x172bac-0x0;var _0x3a11ed=_0xa64d[_0x172bac];return _0x3a11ed;};'use strict';var moment=require(_0xda64('0x0'));var Sequelize=require('sequelize');module[_0xda64('0x1')]={'starttime':{'type':Sequelize['DATE'],'set':function(_0x1b4e0d){this[_0xda64('0x2')](_0xda64('0x3'),_0x1b4e0d);this[_0xda64('0x2')](_0xda64('0x4'),moment()[_0xda64('0x5')](_0xda64('0x6')));}},'endtime':{'type':Sequelize['DATE']},'membername':{'type':Sequelize[_0xda64('0x7')]},'projectname':{'type':Sequelize[_0xda64('0x7')]},'queue':{'type':Sequelize[_0xda64('0x7')]},'uniqueid':{'type':Sequelize[_0xda64('0x7')]},'calleridname':{'type':Sequelize[_0xda64('0x7')]},'calleridnum':{'type':Sequelize['STRING']},'completed':{'type':Sequelize[_0xda64('0x8')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/jscriptySessionReport/jscriptySessionReport.controller.js b/server/api/jscriptySessionReport/jscriptySessionReport.controller.js new file mode 100644 index 0000000..06622bd --- /dev/null +++ b/server/api/jscriptySessionReport/jscriptySessionReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1cef=['rows','catch','params','length','options','create','body','find','findOne','JscriptyQuestionReport','hasOwnProperty','SessionId','findAll','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','reject','save','update','then','destroy','error','stack','name','send','map','rawAttributes','type','query','keys','filters','intersection','attributes','model','fields','nolimit','order','sort','where','pick','filter','merge','JscriptySessionReport','includeAll','include'];(function(_0x263ca7,_0x20b967){var _0x2d19fb=function(_0x3b6080){while(--_0x3b6080){_0x263ca7['push'](_0x263ca7['shift']());}};_0x2d19fb(++_0x20b967);}(_0x1cef,0x1e7));var _0xf1ce=function(_0x3df223,_0x1740fc){_0x3df223=_0x3df223-0x0;var _0x562d11=_0x1cef[_0x3df223];return _0x562d11;};'use strict';var emlformat=require(_0xf1ce('0x0'));var rimraf=require(_0xf1ce('0x1'));var zipdir=require(_0xf1ce('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf1ce('0x3'));var moment=require(_0xf1ce('0x4'));var BPromise=require(_0xf1ce('0x5'));var Mustache=require('mustache');var util=require(_0xf1ce('0x6'));var path=require(_0xf1ce('0x7'));var sox=require(_0xf1ce('0x8'));var csv=require('to-csv');var ejs=require(_0xf1ce('0x9'));var fs=require('fs');var fs_extra=require(_0xf1ce('0xa'));var _=require(_0xf1ce('0xb'));var squel=require(_0xf1ce('0xc'));var crypto=require(_0xf1ce('0xd'));var jsforce=require(_0xf1ce('0xe'));var deskjs=require(_0xf1ce('0xf'));var toCsv=require('to-csv');var querystring=require(_0xf1ce('0x10'));var Papa=require(_0xf1ce('0x11'));var Redis=require(_0xf1ce('0x12'));var authService=require(_0xf1ce('0x13'));var qs=require(_0xf1ce('0x14'));var as=require(_0xf1ce('0x15'));var hardwareService=require(_0xf1ce('0x16'));var logger=require(_0xf1ce('0x17'))('api');var utils=require(_0xf1ce('0x18'));var config=require(_0xf1ce('0x19'));var licenseUtil=require(_0xf1ce('0x1a'));var db=require(_0xf1ce('0x1b'))['db'];function respondWithStatusCode(_0x348cbe,_0x2e6070){_0x2e6070=_0x2e6070||0xcc;return function(_0x28b27c){if(_0x28b27c){return _0x348cbe[_0xf1ce('0x1c')](_0x2e6070);}return _0x348cbe['status'](_0x2e6070)[_0xf1ce('0x1d')]();};}function respondWithResult(_0x361551,_0xd47f88){_0xd47f88=_0xd47f88||0xc8;return function(_0x4471ac){if(_0x4471ac){return _0x361551[_0xf1ce('0x1e')](_0xd47f88)[_0xf1ce('0x1f')](_0x4471ac);}};}function respondWithFilteredResult(_0x267442,_0x5bded6){return function(_0x10cc06){if(_0x10cc06){var _0x446a4c=typeof _0x5bded6[_0xf1ce('0x20')]===_0xf1ce('0x21')&&typeof _0x5bded6['limit']==='undefined';var _0x52cd6d=_0x10cc06[_0xf1ce('0x22')];var _0x2b55a0=_0x446a4c?0x0:_0x5bded6[_0xf1ce('0x20')];var _0xccba31=_0x446a4c?_0x10cc06['count']:_0x5bded6[_0xf1ce('0x20')]+_0x5bded6[_0xf1ce('0x23')];var _0x482a37;if(_0xccba31>=_0x52cd6d){_0xccba31=_0x52cd6d;_0x482a37=0xc8;}else{_0x482a37=0xce;}_0x267442[_0xf1ce('0x1e')](_0x482a37);return _0x267442[_0xf1ce('0x24')]('Content-Range',_0x2b55a0+'-'+_0xccba31+'/'+_0x52cd6d)['json'](_0x10cc06);}return null;};}function patchUpdates(_0x548f53){return function(_0x41f059){try{jsonpatch['apply'](_0x41f059,_0x548f53,!![]);}catch(_0x42fec4){return BPromise[_0xf1ce('0x25')](_0x42fec4);}return _0x41f059[_0xf1ce('0x26')]();};}function saveUpdates(_0x58f11f,_0x31e162){return function(_0x58bf33){if(_0x58bf33){return _0x58bf33[_0xf1ce('0x27')](_0x58f11f)[_0xf1ce('0x28')](function(_0x348736){return _0x348736;});}return null;};}function removeEntity(_0x2598db,_0x39f72e){return function(_0x379ec2){if(_0x379ec2){return _0x379ec2[_0xf1ce('0x29')]()[_0xf1ce('0x28')](function(){_0x2598db[_0xf1ce('0x1e')](0xcc)[_0xf1ce('0x1d')]();});}};}function handleEntityNotFound(_0x197199,_0x4e79e0){return function(_0x433683){if(!_0x433683){_0x197199[_0xf1ce('0x1c')](0x194);}return _0x433683;};}function handleError(_0x1a8556,_0x4e2a74){_0x4e2a74=_0x4e2a74||0x1f4;return function(_0x19e5b4){logger[_0xf1ce('0x2a')](_0x19e5b4[_0xf1ce('0x2b')]);if(_0x19e5b4[_0xf1ce('0x2c')]){delete _0x19e5b4[_0xf1ce('0x2c')];}_0x1a8556[_0xf1ce('0x1e')](_0x4e2a74)[_0xf1ce('0x2d')](_0x19e5b4);};}exports['index']=function(_0x3e2dd0,_0x34e465){var _0x18a6d9={},_0x1f849f={},_0x55d3dc={'count':0x0,'rows':[]};var _0x172633=_[_0xf1ce('0x2e')](db['JscriptySessionReport'][_0xf1ce('0x2f')],function(_0x58f6ec){return{'name':_0x58f6ec['fieldName'],'type':_0x58f6ec[_0xf1ce('0x30')]['key']};});_0x1f849f['model']=_[_0xf1ce('0x2e')](_0x172633,_0xf1ce('0x2c'));_0x1f849f[_0xf1ce('0x31')]=_[_0xf1ce('0x32')](_0x3e2dd0[_0xf1ce('0x31')]);_0x1f849f[_0xf1ce('0x33')]=_[_0xf1ce('0x34')](_0x1f849f['model'],_0x1f849f[_0xf1ce('0x31')]);_0x18a6d9[_0xf1ce('0x35')]=_['intersection'](_0x1f849f[_0xf1ce('0x36')],qs['fields'](_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x37')]));_0x18a6d9[_0xf1ce('0x35')]=_0x18a6d9[_0xf1ce('0x35')]['length']?_0x18a6d9[_0xf1ce('0x35')]:_0x1f849f[_0xf1ce('0x36')];if(!_0x3e2dd0[_0xf1ce('0x31')]['hasOwnProperty'](_0xf1ce('0x38'))){_0x18a6d9['limit']=qs[_0xf1ce('0x23')](_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x23')]);_0x18a6d9['offset']=qs['offset'](_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x20')]);}_0x18a6d9[_0xf1ce('0x39')]=qs[_0xf1ce('0x3a')](_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x3a')]);_0x18a6d9[_0xf1ce('0x3b')]=qs[_0xf1ce('0x33')](_[_0xf1ce('0x3c')](_0x3e2dd0[_0xf1ce('0x31')],_0x1f849f[_0xf1ce('0x33')]),_0x172633);if(_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x3d')]){_0x18a6d9['where']=_[_0xf1ce('0x3e')](_0x18a6d9[_0xf1ce('0x3b')],{'$or':_[_0xf1ce('0x2e')](_0x172633,function(_0x2613b8){if(_0x2613b8[_0xf1ce('0x30')]!=='VIRTUAL'){var _0x196907={};_0x196907[_0x2613b8[_0xf1ce('0x2c')]]={'$like':'%'+_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x3d')]+'%'};return _0x196907;}})});}_0x18a6d9=_[_0xf1ce('0x3e')]({},_0x18a6d9,_0x3e2dd0['options']);var _0x5ae3cd={'where':_0x18a6d9[_0xf1ce('0x3b')]};return db[_0xf1ce('0x3f')][_0xf1ce('0x22')](_0x5ae3cd)[_0xf1ce('0x28')](function(_0x13a598){_0x55d3dc[_0xf1ce('0x22')]=_0x13a598;if(_0x3e2dd0[_0xf1ce('0x31')][_0xf1ce('0x40')]){_0x18a6d9[_0xf1ce('0x41')]=[{'all':!![]}];}return db['JscriptySessionReport']['findAll'](_0x18a6d9);})[_0xf1ce('0x28')](function(_0x166ff9){_0x55d3dc[_0xf1ce('0x42')]=_0x166ff9;return _0x55d3dc;})['then'](respondWithFilteredResult(_0x34e465,_0x18a6d9))[_0xf1ce('0x43')](handleError(_0x34e465,null));};exports['show']=function(_0x380a4a,_0x5c058f){var _0x31b432={'raw':!![],'where':{'id':_0x380a4a[_0xf1ce('0x44')]['id']}},_0x52bc82={};_0x52bc82[_0xf1ce('0x36')]=_[_0xf1ce('0x32')](db[_0xf1ce('0x3f')]['rawAttributes']);_0x52bc82[_0xf1ce('0x31')]=_['keys'](_0x380a4a['query']);_0x52bc82[_0xf1ce('0x33')]=_[_0xf1ce('0x34')](_0x52bc82[_0xf1ce('0x36')],_0x52bc82[_0xf1ce('0x31')]);_0x31b432[_0xf1ce('0x35')]=_['intersection'](_0x52bc82[_0xf1ce('0x36')],qs[_0xf1ce('0x37')](_0x380a4a['query'][_0xf1ce('0x37')]));_0x31b432[_0xf1ce('0x35')]=_0x31b432[_0xf1ce('0x35')][_0xf1ce('0x45')]?_0x31b432[_0xf1ce('0x35')]:_0x52bc82['model'];if(_0x380a4a['query'][_0xf1ce('0x40')]){_0x31b432['include']=[{'all':!![]}];}_0x31b432=_['merge']({},_0x31b432,_0x380a4a[_0xf1ce('0x46')]);return db[_0xf1ce('0x3f')]['find'](_0x31b432)['then'](handleEntityNotFound(_0x5c058f,null))[_0xf1ce('0x28')](respondWithResult(_0x5c058f,null))[_0xf1ce('0x43')](handleError(_0x5c058f,null));};exports[_0xf1ce('0x47')]=function(_0x5d3fea,_0x465692){return db['JscriptySessionReport'][_0xf1ce('0x47')](_0x5d3fea['body'],{})['then'](respondWithResult(_0x465692,0xc9))[_0xf1ce('0x43')](handleError(_0x465692,null));};exports[_0xf1ce('0x27')]=function(_0x1e0189,_0x2a0a7c){if(_0x1e0189[_0xf1ce('0x48')]['id']){delete _0x1e0189['body']['id'];}return db['JscriptySessionReport'][_0xf1ce('0x49')]({'where':{'id':_0x1e0189[_0xf1ce('0x44')]['id']}})['then'](handleEntityNotFound(_0x2a0a7c,null))['then'](saveUpdates(_0x1e0189['body'],null))[_0xf1ce('0x28')](respondWithResult(_0x2a0a7c,null))['catch'](handleError(_0x2a0a7c,null));};exports[_0xf1ce('0x29')]=function(_0x2f3efa,_0x478a06){return db[_0xf1ce('0x3f')][_0xf1ce('0x49')]({'where':{'id':_0x2f3efa[_0xf1ce('0x44')]['id']}})['then'](handleEntityNotFound(_0x478a06,null))['then'](removeEntity(_0x478a06,null))[_0xf1ce('0x43')](handleError(_0x478a06,null));};exports['describe']=function(_0x460286,_0x135a9b){return db[_0xf1ce('0x3f')]['describe']()[_0xf1ce('0x28')](respondWithResult(_0x135a9b,null))['catch'](handleError(_0x135a9b,null));};exports['getQuestions']=function(_0x53462f,_0x28421a,_0x9d40f0){var _0x308745={'raw':!![],'where':{}};var _0x3cfc1c={};var _0x128114={'count':0x0,'rows':[]};return db[_0xf1ce('0x3f')][_0xf1ce('0x4a')]({'where':{'id':_0x53462f['params']['id']}})[_0xf1ce('0x28')](handleEntityNotFound(_0x28421a,null))[_0xf1ce('0x28')](function(_0x5d8a43){if(_0x5d8a43){_0x3cfc1c[_0xf1ce('0x36')]=_[_0xf1ce('0x32')](db[_0xf1ce('0x4b')][_0xf1ce('0x2f')]);_0x3cfc1c[_0xf1ce('0x31')]=_['keys'](_0x53462f[_0xf1ce('0x31')]);_0x3cfc1c[_0xf1ce('0x33')]=_['intersection'](_0x3cfc1c[_0xf1ce('0x36')],_0x3cfc1c['query']);_0x308745[_0xf1ce('0x35')]=_['intersection'](_0x3cfc1c[_0xf1ce('0x36')],qs[_0xf1ce('0x37')](_0x53462f[_0xf1ce('0x31')]['fields']));_0x308745[_0xf1ce('0x35')]=_0x308745[_0xf1ce('0x35')][_0xf1ce('0x45')]?_0x308745['attributes']:_0x3cfc1c[_0xf1ce('0x36')];if(!_0x53462f[_0xf1ce('0x31')][_0xf1ce('0x4c')](_0xf1ce('0x38'))){_0x308745[_0xf1ce('0x23')]=qs[_0xf1ce('0x23')](_0x53462f['query'][_0xf1ce('0x23')]);_0x308745[_0xf1ce('0x20')]=qs[_0xf1ce('0x20')](_0x53462f[_0xf1ce('0x31')]['offset']);}_0x308745[_0xf1ce('0x39')]=qs[_0xf1ce('0x3a')](_0x53462f[_0xf1ce('0x31')]['sort']);_0x308745[_0xf1ce('0x3b')]=qs['filters'](_[_0xf1ce('0x3c')](_0x53462f[_0xf1ce('0x31')],_0x3cfc1c[_0xf1ce('0x33')]));_0x308745[_0xf1ce('0x3b')][_0xf1ce('0x4d')]=_0x5d8a43['id'];if(_0x53462f['query'][_0xf1ce('0x3d')]){_0x308745[_0xf1ce('0x3b')]=_[_0xf1ce('0x3e')](_0x308745[_0xf1ce('0x3b')],{'$or':_['map'](_0x308745['attributes'],function(_0x25ae2b){var _0x38ae33={};_0x38ae33[_0x25ae2b]={'$like':'%'+_0x53462f[_0xf1ce('0x31')][_0xf1ce('0x3d')]+'%'};return _0x38ae33;})});}_0x308745=_[_0xf1ce('0x3e')]({},_0x308745,_0x53462f[_0xf1ce('0x46')]);return db[_0xf1ce('0x4b')][_0xf1ce('0x22')]({'where':_0x308745[_0xf1ce('0x3b')]})[_0xf1ce('0x28')](function(_0x5791d2){_0x128114[_0xf1ce('0x22')]=_0x5791d2;if(_0x53462f['query'][_0xf1ce('0x40')]){_0x308745[_0xf1ce('0x41')]=[{'all':!![]}];}return db['JscriptyQuestionReport'][_0xf1ce('0x4e')](_0x308745);})[_0xf1ce('0x28')](function(_0x5ed132){_0x128114['rows']=_0x5ed132;return _0x128114;});}})['then'](respondWithFilteredResult(_0x28421a,_0x308745))[_0xf1ce('0x43')](handleError(_0x28421a,null));}; \ No newline at end of file diff --git a/server/api/jscriptySessionReport/jscriptySessionReport.model.js b/server/api/jscriptySessionReport/jscriptySessionReport.model.js new file mode 100644 index 0000000..02333cf --- /dev/null +++ b/server/api/jscriptySessionReport/jscriptySessionReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5d17=['lodash','util','moment','bluebird','request-promise','rimraf','../../config/environment','./jscriptySessionReport.attributes','exports','define','JscriptySessionReport','report_jscripty_sessions'];(function(_0x16f37d,_0x52b81b){var _0x36d50d=function(_0x144cac){while(--_0x144cac){_0x16f37d['push'](_0x16f37d['shift']());}};_0x36d50d(++_0x52b81b);}(_0x5d17,0x114));var _0x75d1=function(_0x23ca4d,_0x5c2a32){_0x23ca4d=_0x23ca4d-0x0;var _0x435432=_0x5d17[_0x23ca4d];return _0x435432;};'use strict';var _=require(_0x75d1('0x0'));var util=require(_0x75d1('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0x75d1('0x2'));var BPromise=require(_0x75d1('0x3'));var rp=require(_0x75d1('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0x75d1('0x5'));var config=require(_0x75d1('0x6'));var attributes=require(_0x75d1('0x7'));module[_0x75d1('0x8')]=function(_0x56ac0a,_0x458681){return _0x56ac0a[_0x75d1('0x9')](_0x75d1('0xa'),attributes,{'tableName':_0x75d1('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/jscriptySessionReport/jscriptySessionReport.rpc.js b/server/api/jscriptySessionReport/jscriptySessionReport.rpc.js new file mode 100644 index 0000000..1a87dc8 --- /dev/null +++ b/server/api/jscriptySessionReport/jscriptySessionReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7ee1=['request\x20sent','JscriptySessionReport,\x20%s,\x20%s,\x20%s','stringify','error','code','JscriptySessionReport,\x20%s,\x20%s','message','catch','lodash','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then'];(function(_0x505439,_0x5a4a50){var _0x54267a=function(_0x5e635f){while(--_0x5e635f){_0x505439['push'](_0x505439['shift']());}};_0x54267a(++_0x5a4a50);}(_0x7ee1,0x8d));var _0x17ee=function(_0x12db7b,_0x3f710e){_0x12db7b=_0x12db7b-0x0;var _0x1df082=_0x7ee1[_0x12db7b];return _0x1df082;};'use strict';var _=require(_0x17ee('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x17ee('0x1'));var fs=require('fs');var Redis=require(_0x17ee('0x2'));var db=require(_0x17ee('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x17ee('0x4'))(_0x17ee('0x5'));var config=require(_0x17ee('0x6'));var jayson=require(_0x17ee('0x7'));var client=jayson['client'][_0x17ee('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x29b9eb,_0x54b4f6,_0x3f61af){return new BPromise(function(_0x57e1d1,_0x3d767b){return client[_0x17ee('0x9')](_0x29b9eb,_0x3f61af)[_0x17ee('0xa')](function(_0x4af369){logger['info']('JscriptySessionReport,\x20%s,\x20%s',_0x54b4f6,_0x17ee('0xb'));logger['debug'](_0x17ee('0xc'),_0x54b4f6,_0x17ee('0xb'),JSON[_0x17ee('0xd')](_0x4af369));if(_0x4af369[_0x17ee('0xe')]){if(_0x4af369['error'][_0x17ee('0xf')]===0x1f4){logger['error'](_0x17ee('0x10'),_0x54b4f6,_0x4af369[_0x17ee('0xe')][_0x17ee('0x11')]);return _0x3d767b(_0x4af369[_0x17ee('0xe')][_0x17ee('0x11')]);}logger[_0x17ee('0xe')](_0x17ee('0x10'),_0x54b4f6,_0x4af369[_0x17ee('0xe')][_0x17ee('0x11')]);return _0x57e1d1(_0x4af369[_0x17ee('0xe')][_0x17ee('0x11')]);}else{logger['info']('JscriptySessionReport,\x20%s,\x20%s',_0x54b4f6,'request\x20sent');_0x57e1d1(_0x4af369['result'][_0x17ee('0x11')]);}})[_0x17ee('0x12')](function(_0x1b87c3){logger[_0x17ee('0xe')](_0x17ee('0x10'),_0x54b4f6,_0x1b87c3);_0x3d767b(_0x1b87c3);});});} \ No newline at end of file diff --git a/server/api/license/index.js b/server/api/license/index.js new file mode 100644 index 0000000..f8f3a33 --- /dev/null +++ b/server/api/license/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0951=['exports','multer','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','./license.controller','get','put','/:id','update','/download_log_file','isAuthenticated','downloadLogFile'];(function(_0x232190,_0x5cdabd){var _0x31d160=function(_0x34d20d){while(--_0x34d20d){_0x232190['push'](_0x232190['shift']());}};_0x31d160(++_0x5cdabd);}(_0x0951,0x1bb));var _0x1095=function(_0x205085,_0x1492cf){_0x205085=_0x205085-0x0;var _0x131b01=_0x0951[_0x205085];return _0x131b01;};'use strict';var multer=require(_0x1095('0x0'));var util=require('util');var path=require(_0x1095('0x1'));var timeout=require(_0x1095('0x2'));var express=require(_0x1095('0x3'));var router=express[_0x1095('0x4')]();var fs_extra=require(_0x1095('0x5'));var auth=require(_0x1095('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0x1095('0x7'));var controller=require(_0x1095('0x8'));router[_0x1095('0x9')]('/',controller['index']);router[_0x1095('0xa')](_0x1095('0xb'),auth['isAuthenticated'](),controller[_0x1095('0xc')]);router[_0x1095('0x9')](_0x1095('0xd'),auth[_0x1095('0xe')](),controller[_0x1095('0xf')]);module[_0x1095('0x10')]=router; \ No newline at end of file diff --git a/server/api/license/license.attributes.js b/server/api/license/license.attributes.js new file mode 100644 index 0000000..b1ca3ae --- /dev/null +++ b/server/api/license/license.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1c3f=['exports','TEXT','STRING','INTEGER','sequelize'];(function(_0x4fd9be,_0x3df4e8){var _0xe57499=function(_0x3b0a23){while(--_0x3b0a23){_0x4fd9be['push'](_0x4fd9be['shift']());}};_0xe57499(++_0x3df4e8);}(_0x1c3f,0x13a));var _0xf1c3=function(_0x2426c8,_0x9668d3){_0x2426c8=_0x2426c8-0x0;var _0x56f51e=_0x1c3f[_0x2426c8];return _0x56f51e;};'use strict';var Sequelize=require(_0xf1c3('0x0'));module[_0xf1c3('0x1')]={'license':{'type':Sequelize[_0xf1c3('0x2')]},'data1':{'type':Sequelize[_0xf1c3('0x3')]},'data2':{'type':Sequelize[_0xf1c3('0x3')]},'chatLicenseExceeded':{'type':Sequelize[_0xf1c3('0x4')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/license/license.controller.js b/server/api/license/license.controller.js new file mode 100644 index 0000000..c6c3074 --- /dev/null +++ b/server/api/license/license.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x57b6=['set','save','update','destroy','then','stack','name','send','index','keys','License','rawAttributes','query','filters','intersection','model','attributes','merge','body','find','params','get','key','catch','license-info.log','join','/var','log','xcally','setHeader','Content-disposition','attachment;\x20filename=','Content-Type','text/plain','download','rimraf','zip-dir','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','sendStatus','end','json','offset','undefined','limit','count','status'];(function(_0xaf7ed1,_0xd5813c){var _0x39ee1f=function(_0x505ef0){while(--_0x505ef0){_0xaf7ed1['push'](_0xaf7ed1['shift']());}};_0x39ee1f(++_0xd5813c);}(_0x57b6,0xdd));var _0x657b=function(_0x488bae,_0x30caf7){_0x488bae=_0x488bae-0x0;var _0x5ce921=_0x57b6[_0x488bae];return _0x5ce921;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x657b('0x0'));var zipdir=require(_0x657b('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x657b('0x2'));var moment=require('moment');var BPromise=require(_0x657b('0x3'));var Mustache=require(_0x657b('0x4'));var util=require('util');var path=require(_0x657b('0x5'));var sox=require(_0x657b('0x6'));var csv=require(_0x657b('0x7'));var ejs=require(_0x657b('0x8'));var fs=require('fs');var fs_extra=require(_0x657b('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x657b('0xa'));var deskjs=require(_0x657b('0xb'));var toCsv=require(_0x657b('0x7'));var querystring=require(_0x657b('0xc'));var Papa=require(_0x657b('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x657b('0xe'));var as=require(_0x657b('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x657b('0x10'));var utils=require(_0x657b('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0x657b('0x12'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3eed05,_0x19edaf){_0x19edaf=_0x19edaf||0xcc;return function(_0x2b6035){if(_0x2b6035){return _0x3eed05[_0x657b('0x13')](_0x19edaf);}return _0x3eed05['status'](_0x19edaf)[_0x657b('0x14')]();};}function respondWithResult(_0x299ef1,_0xf9dd39){_0xf9dd39=_0xf9dd39||0xc8;return function(_0x944206){if(_0x944206){return _0x299ef1['status'](_0xf9dd39)[_0x657b('0x15')](_0x944206);}};}function respondWithFilteredResult(_0x435f1c,_0x550128){return function(_0x3ad556){if(_0x3ad556){var _0x2390ae=typeof _0x550128[_0x657b('0x16')]===_0x657b('0x17')&&typeof _0x550128[_0x657b('0x18')]===_0x657b('0x17');var _0xea9c92=_0x3ad556[_0x657b('0x19')];var _0x168647=_0x2390ae?0x0:_0x550128['offset'];var _0x4d1e60=_0x2390ae?_0x3ad556[_0x657b('0x19')]:_0x550128[_0x657b('0x16')]+_0x550128[_0x657b('0x18')];var _0x30502b;if(_0x4d1e60>=_0xea9c92){_0x4d1e60=_0xea9c92;_0x30502b=0xc8;}else{_0x30502b=0xce;}_0x435f1c[_0x657b('0x1a')](_0x30502b);return _0x435f1c[_0x657b('0x1b')]('Content-Range',_0x168647+'-'+_0x4d1e60+'/'+_0xea9c92)[_0x657b('0x15')](_0x3ad556);}return null;};}function patchUpdates(_0x40853b){return function(_0x3f0420){try{jsonpatch['apply'](_0x3f0420,_0x40853b,!![]);}catch(_0x3039b5){return BPromise['reject'](_0x3039b5);}return _0x3f0420[_0x657b('0x1c')]();};}function saveUpdates(_0x50ea86,_0x51f018){return function(_0x5f051f){if(_0x5f051f){return _0x5f051f[_0x657b('0x1d')](_0x50ea86)['then'](function(_0x3e3e6){return _0x3e3e6;});}return null;};}function removeEntity(_0x28215b,_0x328b07){return function(_0x563c74){if(_0x563c74){return _0x563c74[_0x657b('0x1e')]()[_0x657b('0x1f')](function(){_0x28215b[_0x657b('0x1a')](0xcc)[_0x657b('0x14')]();});}};}function handleEntityNotFound(_0x158ba6,_0xc2ddae){return function(_0x221eed){if(!_0x221eed){_0x158ba6[_0x657b('0x13')](0x194);}return _0x221eed;};}function handleError(_0x4e9ae9,_0xe4fd23){_0xe4fd23=_0xe4fd23||0x1f4;return function(_0x1d71fa){logger['error'](_0x1d71fa[_0x657b('0x20')]);if(_0x1d71fa[_0x657b('0x21')]){delete _0x1d71fa[_0x657b('0x21')];}_0x4e9ae9['status'](_0xe4fd23)[_0x657b('0x22')](_0x1d71fa);};}var utilLicense=require(_0x657b('0x12'));exports[_0x657b('0x23')]=function(_0x41cbb1,_0x4fb069){var _0x4d6b69={'raw':!![],'where':{'id':0x1}},_0x5a605d={};_0x5a605d['model']=_[_0x657b('0x24')](db[_0x657b('0x25')][_0x657b('0x26')]);_0x5a605d[_0x657b('0x27')]=_[_0x657b('0x24')](_0x41cbb1[_0x657b('0x27')]);_0x5a605d[_0x657b('0x28')]=_[_0x657b('0x29')](_0x5a605d[_0x657b('0x2a')],_0x5a605d[_0x657b('0x27')]);_0x4d6b69[_0x657b('0x2b')]=_[_0x657b('0x29')](_0x5a605d[_0x657b('0x2a')],qs['fields'](_0x41cbb1[_0x657b('0x27')]['fields']));_0x4d6b69['attributes']=_0x4d6b69[_0x657b('0x2b')]['length']?_0x4d6b69[_0x657b('0x2b')]:_0x5a605d[_0x657b('0x2a')];_0x4d6b69=_[_0x657b('0x2c')]({},_0x4d6b69,_0x41cbb1['options']);return utilLicense['getLicense'](_0x4d6b69)[_0x657b('0x1f')](respondWithResult(_0x4fb069,null))['catch'](handleError(_0x4fb069,null));};exports[_0x657b('0x1d')]=function(_0x33d93b,_0x403f34){if(_0x33d93b[_0x657b('0x2d')]['id']){delete _0x33d93b[_0x657b('0x2d')]['id'];}return db['License'][_0x657b('0x2e')]({'where':{'id':_0x33d93b[_0x657b('0x2f')]['id']}})[_0x657b('0x1f')](handleEntityNotFound(_0x403f34,null))['then'](function(_0x585e1a){var _0x25003e=_0x585e1a[_0x657b('0x30')]({'plain':!![]});return utilLicense['checkLicense'](_0x25003e,_0x33d93b[_0x657b('0x2d')][_0x657b('0x31')]);})[_0x657b('0x1f')](function(_0x5afcda){if(!_0x5afcda['demo']){return saveUpdates(_0x33d93b[_0x657b('0x2d')],null);}return _0x5afcda;})[_0x657b('0x1f')](respondWithResult(_0x403f34,null))[_0x657b('0x32')](handleError(_0x403f34,null));};exports['downloadLogFile']=function(_0x29c003,_0x27bc50){var _0x325ac5=_0x657b('0x33');var _0x17e852=path[_0x657b('0x34')](_0x657b('0x35'),_0x657b('0x36'),_0x657b('0x37'),_0x325ac5);_0x27bc50[_0x657b('0x38')](_0x657b('0x39'),_0x657b('0x3a')+_0x325ac5);_0x27bc50[_0x657b('0x1b')](_0x657b('0x3b'),_0x657b('0x3c'));_0x27bc50[_0x657b('0x3d')](_0x17e852);}; \ No newline at end of file diff --git a/server/api/license/license.model.js b/server/api/license/license.model.js new file mode 100644 index 0000000..61c1180 --- /dev/null +++ b/server/api/license/license.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe93e=['exports','define','license','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment'];(function(_0x451f88,_0x5c061a){var _0x2cc2b7=function(_0x5bb6ce){while(--_0x5bb6ce){_0x451f88['push'](_0x451f88['shift']());}};_0x2cc2b7(++_0x5c061a);}(_0xe93e,0x148));var _0xee93=function(_0xa41df9,_0x20fed0){_0xa41df9=_0xa41df9-0x0;var _0x342a45=_0xe93e[_0xa41df9];return _0x342a45;};'use strict';var _=require(_0xee93('0x0'));var util=require(_0xee93('0x1'));var logger=require(_0xee93('0x2'))(_0xee93('0x3'));var moment=require(_0xee93('0x4'));var BPromise=require(_0xee93('0x5'));var rp=require(_0xee93('0x6'));var fs=require('fs');var path=require(_0xee93('0x7'));var rimraf=require(_0xee93('0x8'));var config=require(_0xee93('0x9'));var attributes=require('./license.attributes');module[_0xee93('0xa')]=function(_0x5ac859,_0x5c1ae9){return _0x5ac859[_0xee93('0xb')]('License',attributes,{'tableName':_0xee93('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/license/license.rpc.js b/server/api/license/license.rpc.js new file mode 100644 index 0000000..c0da594 --- /dev/null +++ b/server/api/license/license.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7342=['jayson/promise','client','http','request','then','info','License,\x20%s,\x20%s','request\x20sent','debug','License,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','lodash','util','moment','randomstring','ioredis','../../config/utils','rpc','../../config/environment'];(function(_0x9727d6,_0x28d540){var _0x53834a=function(_0x3bc024){while(--_0x3bc024){_0x9727d6['push'](_0x9727d6['shift']());}};_0x53834a(++_0x28d540);}(_0x7342,0x1dc));var _0x2734=function(_0x902fc7,_0x42d685){_0x902fc7=_0x902fc7-0x0;var _0x5a5a98=_0x7342[_0x902fc7];return _0x5a5a98;};'use strict';var _=require(_0x2734('0x0'));var util=require(_0x2734('0x1'));var moment=require(_0x2734('0x2'));var BPromise=require('bluebird');var rs=require(_0x2734('0x3'));var fs=require('fs');var Redis=require(_0x2734('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x2734('0x5'));var logger=require('../../config/logger')(_0x2734('0x6'));var config=require(_0x2734('0x7'));var jayson=require(_0x2734('0x8'));var client=jayson[_0x2734('0x9')][_0x2734('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1582ab,_0x1db7fb,_0x5a884a){return new BPromise(function(_0x233ec5,_0x432e9c){return client[_0x2734('0xb')](_0x1582ab,_0x5a884a)[_0x2734('0xc')](function(_0x5f3026){logger[_0x2734('0xd')](_0x2734('0xe'),_0x1db7fb,_0x2734('0xf'));logger[_0x2734('0x10')](_0x2734('0x11'),_0x1db7fb,_0x2734('0xf'),JSON[_0x2734('0x12')](_0x5f3026));if(_0x5f3026['error']){if(_0x5f3026[_0x2734('0x13')]['code']===0x1f4){logger['error']('License,\x20%s,\x20%s',_0x1db7fb,_0x5f3026['error']['message']);return _0x432e9c(_0x5f3026['error']['message']);}logger[_0x2734('0x13')](_0x2734('0xe'),_0x1db7fb,_0x5f3026['error'][_0x2734('0x14')]);return _0x233ec5(_0x5f3026['error'][_0x2734('0x14')]);}else{logger[_0x2734('0xd')]('License,\x20%s,\x20%s',_0x1db7fb,_0x2734('0xf'));_0x233ec5(_0x5f3026['result'][_0x2734('0x14')]);}})[_0x2734('0x15')](function(_0x4d6def){logger[_0x2734('0x13')](_0x2734('0xe'),_0x1db7fb,_0x4d6def);_0x432e9c(_0x4d6def);});});} \ No newline at end of file diff --git a/server/api/mailAccount/index.js b/server/api/mailAccount/index.js new file mode 100644 index 0000000..cf6d926 --- /dev/null +++ b/server/api/mailAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c07=['addImap','addSmtp','/:id/send','send','put','delete','removeAnswers','removeImap','/:id','destroy','removeAgents','exports','multer','util','path','fs-extra','../../components/auth/service','../../components/interaction/service','./mailAccount.controller','isAuthenticated','index','get','describe','show','/:id/dispositions','getDispositions','/:id/canned_answers','getAnswers','/:id/in_servers','/:id/out_servers','getSmtp','/:id/interactions','/:id/applications','getApplications','/:id/messages','getMessages','/:id/verify','verifySmtp','/:id/users','getAgents','addDisposition','post','addAnswer','create'];(function(_0x323430,_0x3d2b6d){var _0x9eecd1=function(_0xab855a){while(--_0xab855a){_0x323430['push'](_0x323430['shift']());}};_0x9eecd1(++_0x3d2b6d);}(_0x9c07,0xe8));var _0x79c0=function(_0x46bf6c,_0x365b09){_0x46bf6c=_0x46bf6c-0x0;var _0xf024ce=_0x9c07[_0x46bf6c];return _0xf024ce;};'use strict';var multer=require(_0x79c0('0x0'));var util=require(_0x79c0('0x1'));var path=require(_0x79c0('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express['Router']();var fs_extra=require(_0x79c0('0x3'));var auth=require(_0x79c0('0x4'));var interaction=require(_0x79c0('0x5'));var config=require('../../config/environment');var controller=require(_0x79c0('0x6'));router['get']('/',auth[_0x79c0('0x7')](),controller[_0x79c0('0x8')]);router[_0x79c0('0x9')]('/describe',auth[_0x79c0('0x7')](),controller[_0x79c0('0xa')]);router[_0x79c0('0x9')]('/:id',auth[_0x79c0('0x7')](),controller[_0x79c0('0xb')]);router[_0x79c0('0x9')](_0x79c0('0xc'),auth[_0x79c0('0x7')](),controller[_0x79c0('0xd')]);router[_0x79c0('0x9')](_0x79c0('0xe'),auth[_0x79c0('0x7')](),controller[_0x79c0('0xf')]);router[_0x79c0('0x9')](_0x79c0('0x10'),auth['isAuthenticated'](),controller['getImap']);router[_0x79c0('0x9')](_0x79c0('0x11'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x12')]);router['get'](_0x79c0('0x13'),auth[_0x79c0('0x7')](),controller['getInteractions']);router[_0x79c0('0x9')](_0x79c0('0x14'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x15')]);router[_0x79c0('0x9')](_0x79c0('0x16'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x17')]);router['get'](_0x79c0('0x18'),auth['isAuthenticated'](),controller[_0x79c0('0x19')]);router[_0x79c0('0x9')](_0x79c0('0x1a'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x1b')]);router['post']('/:id/dispositions',auth[_0x79c0('0x7')](),controller[_0x79c0('0x1c')]);router[_0x79c0('0x1d')](_0x79c0('0xe'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x1e')]);router[_0x79c0('0x1d')]('/',auth[_0x79c0('0x7')](),controller[_0x79c0('0x1f')]);router[_0x79c0('0x1d')](_0x79c0('0x10'),auth['isAuthenticated'](),controller[_0x79c0('0x20')]);router['post'](_0x79c0('0x11'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x21')]);router[_0x79c0('0x1d')](_0x79c0('0x13'),auth[_0x79c0('0x7')](),controller['addInteraction']);router['post'](_0x79c0('0x14'),auth['isAuthenticated'](),controller['addApplications']);router[_0x79c0('0x1d')](_0x79c0('0x22'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x23')]);router[_0x79c0('0x1d')](_0x79c0('0x1a'),auth[_0x79c0('0x7')](),controller['addAgents']);router[_0x79c0('0x24')]('/:id',auth[_0x79c0('0x7')](),controller['update']);router['delete'](_0x79c0('0xc'),auth['isAuthenticated'](),controller['removeDispositions']);router[_0x79c0('0x25')]('/:id/canned_answers',auth[_0x79c0('0x7')](),controller[_0x79c0('0x26')]);router['delete']('/:id/in_servers',auth[_0x79c0('0x7')](),controller[_0x79c0('0x27')]);router[_0x79c0('0x25')]('/:id/out_servers',auth[_0x79c0('0x7')](),controller['removeSmtp']);router[_0x79c0('0x25')](_0x79c0('0x28'),auth[_0x79c0('0x7')](),controller[_0x79c0('0x29')]);router[_0x79c0('0x25')](_0x79c0('0x1a'),auth['isAuthenticated'](),controller[_0x79c0('0x2a')]);module[_0x79c0('0x2b')]=router; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.attributes.js b/server/api/mailAccount/mailAccount.attributes.js new file mode 100644 index 0000000..7f147c0 --- /dev/null +++ b/server/api/mailAccount/mailAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5ed9=['Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}
Subject\x20:\x20{{message.subject}}','Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled','setDataValue','mandatoryDisposition','ENUM','gmail','hotmail','outlook365','getDataValue','provider','custom','sequelize','STRING','BOOLEAN','Arial,Helvetica,sans-serif','INTEGER'];(function(_0x580576,_0x2f107d){var _0x3f55a0=function(_0x2e180b){while(--_0x2e180b){_0x580576['push'](_0x580576['shift']());}};_0x3f55a0(++_0x2f107d);}(_0x5ed9,0x14b));var _0x95ed=function(_0x5f0089,_0x227e2c){_0x5f0089=_0x5f0089-0x0;var _0x193892=_0x5ed9[_0x5f0089];return _0x193892;};'use strict';var Sequelize=require(_0x95ed('0x0'));module['exports']={'description':{'type':Sequelize[_0x95ed('0x1')]},'name':{'type':Sequelize[_0x95ed('0x1')],'allowNull':![]},'service':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'email':{'type':Sequelize['STRING'],'validate':{'isEmail':!![]}},'active':{'type':Sequelize[_0x95ed('0x2')],'defaultValue':!![]},'key':{'type':Sequelize['STRING'],'allowNull':![]},'template':{'type':Sequelize['TEXT']},'markAsUnread':{'type':Sequelize[_0x95ed('0x2')],'defaultValue':![]},'fontFamily':{'type':Sequelize[_0x95ed('0x1')],'allowNull':![],'defaultValue':_0x95ed('0x3')},'fontSize':{'type':Sequelize[_0x95ed('0x4')](0x2)['UNSIGNED'],'defaultValue':0xd,'validate':{'min':0x8,'max':0x48}},'notificationTemplate':{'type':Sequelize['TEXT'],'defaultValue':function(){return _0x95ed('0x5');}},'notificationSound':{'type':Sequelize[_0x95ed('0x2')],'defaultValue':!![]},'notificationShake':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'waitForTheAssignedAgent':{'type':Sequelize[_0x95ed('0x4')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'queueTransfer':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize[_0x95ed('0x4')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize[_0x95ed('0x2')],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0x95ed('0x4')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'mandatoryDispositionPauseId':{'type':Sequelize[_0x95ed('0x4')],'allowNull':!![],'defaultValue':null,'comment':_0x95ed('0x6')},'mandatoryDisposition':{'type':Sequelize[_0x95ed('0x2')],'defaultValue':![],'comment':'Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','set':function(_0x3f97c4){if(!_0x3f97c4)this['setDataValue']('mandatoryDispositionPauseId',null);this[_0x95ed('0x7')](_0x95ed('0x8'),_0x3f97c4);}},'provider':{'type':Sequelize[_0x95ed('0x9')](_0x95ed('0xa'),_0x95ed('0xb'),'yahoo',_0x95ed('0xc')),'defaultValue':null,'get':function(){if(!this[_0x95ed('0xd')](_0x95ed('0xe')))return _0x95ed('0xf');return this[_0x95ed('0xd')](_0x95ed('0xe'));},'set':function(_0x46e111){if(_0x46e111===_0x95ed('0xf'))_0x46e111=null;return this[_0x95ed('0x7')](_0x95ed('0xe'),_0x46e111);}}}; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.controller.js b/server/api/mailAccount/mailAccount.controller.js new file mode 100644 index 0000000..e2e6315 --- /dev/null +++ b/server/api/mailAccount/mailAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x63c9=['key','provider','email','ListId','isNil','active','description','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','getImap','addImap','removeImap','getSmtp','addSmtp','removeSmtp','addInteraction','MailInteraction','CmContact','Contact','Owner','internal','Tag','Tags','tag','rows','addApplications','transaction','sequelize','ISOLATION_LEVELS','MailApplication','findAndCountAll','finally','getApplications','getMessages','MailMessage','$gte','split','YYYY-MM-DD\x20HH:mm:ss','true','CmList','List','updatedAt','CloudProvider','Smtp\x20configuration\x20not\x20found','from','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','SendMail','Contacts','messageId','subject','attach','out','format','Interaction','Messages','getSmtpOptions','verifySmtp','Sequelize','ValidationError','omit','spread','emit','removeAgents','isArray','userMailAccount:remove','getAgents','User','moment','bluebird','util','lodash','juice','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','http','request','then','info','MailAccount,\x20%s,\x20%s','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','request\x20sent','result','catch','sendStatus','end','json','offset','undefined','count','status','update','get','MailAccounts','UserProfileResource','destroy','stack','name','send','gmail','imap.gmail.com','imap.mail.yahoo.com','imap-mail.outlook.com','outlook365','outlook.office365.com','Unknown\x20email\x20service\x20provider','yahoo','smtp.mail.yahoo.com','hotmail','smtp-mail.outlook.com','smtp.office365.com','user','pass','password','modernAuthentication','CloudProviderId','host','port','service','authentication','username','Imap','Smtp','index','MailServerIn','mandatoryDispositionPause','map','MailAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','options','includeAll','include','findAll','show','params','MailServerOut','Pause','body','custom','secure','describe','addDisposition','MailAccountId','Disposition','create','getDispositions','pick','removeDispositions','find','ids','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers'];(function(_0x2b27ac,_0x36af86){var _0x14d6c6=function(_0x11f85a){while(--_0x11f85a){_0x2b27ac['push'](_0x2b27ac['shift']());}};_0x14d6c6(++_0x36af86);}(_0x63c9,0x10d));var _0x963c=function(_0x2c7618,_0x26be9c){_0x2c7618=_0x2c7618-0x0;var _0x5ce3f0=_0x63c9[_0x2c7618];return _0x5ce3f0;};'use strict';var moment=require(_0x963c('0x0'));var BPromise=require(_0x963c('0x1'));var util=require(_0x963c('0x2'));var path=require('path');var _=require(_0x963c('0x3'));var juice=require(_0x963c('0x4'));var Redis=require(_0x963c('0x5'));var qs=require(_0x963c('0x6'));var logger=require(_0x963c('0x7'))(_0x963c('0x8'));var config=require(_0x963c('0x9'));var db=require('../../mysqldb')['db'];config[_0x963c('0xa')]=_[_0x963c('0xb')](config[_0x963c('0xa')],{'host':_0x963c('0xc'),'port':0x18eb});var socket=require(_0x963c('0xd'))(new Redis(config[_0x963c('0xa')]));require(_0x963c('0xe'))[_0x963c('0xf')](socket);var jayson=require(_0x963c('0x10'));var client=jayson[_0x963c('0x11')][_0x963c('0x12')]({'port':0x232b});function respondWithRpcPromise(_0x39dd22,_0x4d3e91,_0x52fc0c,_0x4131ff){return new BPromise(function(_0x6a9b3c,_0x134045){var _0x1b89cf=_0x4131ff||client;return _0x1b89cf[_0x963c('0x13')](_0x39dd22,_0x52fc0c)[_0x963c('0x14')](function(_0x868054){logger[_0x963c('0x15')](_0x963c('0x16'),_0x4d3e91,'request\x20sent');logger[_0x963c('0x17')](_0x963c('0x18'),_0x4d3e91,'request\x20sent',JSON[_0x963c('0x19')](_0x868054));if(_0x868054['error']){if(_0x868054['error'][_0x963c('0x1a')]===0x1f4){logger['error'](_0x963c('0x16'),_0x4d3e91,_0x868054[_0x963c('0x1b')]['message']);return _0x134045(_0x868054[_0x963c('0x1b')][_0x963c('0x1c')]);}logger[_0x963c('0x1b')](_0x963c('0x16'),_0x4d3e91,_0x868054[_0x963c('0x1b')][_0x963c('0x1c')]);return _0x6a9b3c(_0x868054['error'][_0x963c('0x1c')]);}else{logger[_0x963c('0x15')](_0x963c('0x16'),_0x4d3e91,_0x963c('0x1d'));_0x6a9b3c(_0x868054[_0x963c('0x1e')][_0x963c('0x1c')]);}})[_0x963c('0x1f')](function(_0x11d411){logger[_0x963c('0x1b')](_0x963c('0x16'),_0x4d3e91,_0x11d411);_0x134045(_0x11d411);});});}function respondWithStatusCode(_0x595ea2,_0x5bd720){_0x5bd720=_0x5bd720||0xcc;return function(_0xc56881){if(_0xc56881){return _0x595ea2[_0x963c('0x20')](_0x5bd720);}return _0x595ea2['status'](_0x5bd720)[_0x963c('0x21')]();};}function respondWithResult(_0x2341e2,_0x36c76f){_0x36c76f=_0x36c76f||0xc8;return function(_0x12f103){if(_0x12f103){return _0x2341e2['status'](_0x36c76f)[_0x963c('0x22')](_0x12f103);}};}function respondWithFilteredResult(_0x137de3,_0x5f4ba8){return function(_0x715a5d){if(_0x715a5d){var _0x42a3a7=typeof _0x5f4ba8[_0x963c('0x23')]===_0x963c('0x24')&&typeof _0x5f4ba8['limit']===_0x963c('0x24');var _0x3a4e2d=_0x715a5d[_0x963c('0x25')];var _0x2d64f7=_0x42a3a7?0x0:_0x5f4ba8[_0x963c('0x23')];var _0x464d2f=_0x42a3a7?_0x715a5d['count']:_0x5f4ba8[_0x963c('0x23')]+_0x5f4ba8['limit'];var _0x1f0cde;if(_0x464d2f>=_0x3a4e2d){_0x464d2f=_0x3a4e2d;_0x1f0cde=0xc8;}else{_0x1f0cde=0xce;}_0x137de3[_0x963c('0x26')](_0x1f0cde);return _0x137de3['set']('Content-Range',_0x2d64f7+'-'+_0x464d2f+'/'+_0x3a4e2d)[_0x963c('0x22')](_0x715a5d);}return null;};}function saveUpdates(_0x10db2e){return function(_0x175543){if(_0x175543){return _0x175543[_0x963c('0x27')](_0x10db2e)[_0x963c('0x14')](function(_0x494615){return _0x494615;});}return null;};}function removeEntity(_0x431d17){return function(_0x36bad1){if(_0x36bad1){return _0x36bad1['destroy']()[_0x963c('0x14')](function(){var _0xb3cb02=_0x36bad1[_0x963c('0x28')]({'plain':!![]});var _0x1ad80c=_0x963c('0x29');return db[_0x963c('0x2a')][_0x963c('0x2b')]({'where':{'type':_0x1ad80c,'resourceId':_0xb3cb02['id']}})['then'](function(){return _0x36bad1;});})[_0x963c('0x14')](function(){_0x431d17[_0x963c('0x26')](0xcc)[_0x963c('0x21')]();});}};}function handleEntityNotFound(_0x560740){return function(_0x16a243){if(!_0x16a243){_0x560740['sendStatus'](0x194);}return _0x16a243;};}function handleError(_0x1d4b1c,_0x5e08b3){_0x5e08b3=_0x5e08b3||0x1f4;return function(_0x1ad09e){logger[_0x963c('0x1b')](_0x1ad09e[_0x963c('0x2c')]);if(_0x1ad09e['name']){delete _0x1ad09e[_0x963c('0x2d')];}_0x1d4b1c[_0x963c('0x26')](_0x5e08b3)[_0x963c('0x2e')](_0x1ad09e);};}function getImapHost(_0x57b0f1){switch(_0x57b0f1){case _0x963c('0x2f'):return _0x963c('0x30');case'yahoo':return _0x963c('0x31');case'hotmail':return _0x963c('0x32');case _0x963c('0x33'):return _0x963c('0x34');}throw new Error(_0x963c('0x35'),_0x57b0f1);}function getSmtpHost(_0x3cc400){switch(_0x3cc400){case _0x963c('0x2f'):return'smtp.gmail.com';case _0x963c('0x36'):return _0x963c('0x37');case _0x963c('0x38'):return _0x963c('0x39');case _0x963c('0x33'):return _0x963c('0x3a');}throw new Error('Unknown\x20email\x20service\x20provider',_0x3cc400);}function getAuthenticationOptions(_0x3a2d9e,_0x51643d){var _0xc2c799={};var _0x2dce41={};if(_0x3a2d9e){_0xc2c799[_0x963c('0x3b')]=_0x2dce41['user']=_0x51643d['username'];_0xc2c799['password']=_0x2dce41[_0x963c('0x3c')]=_0x51643d[_0x963c('0x3d')];if(_0x51643d[_0x963c('0x3e')]){_0xc2c799[_0x963c('0x3e')]=_0x2dce41['modernAuthentication']=!![];_0xc2c799['CloudProviderId']=_0x2dce41[_0x963c('0x3f')]=_0x51643d[_0x963c('0x3f')];_0xc2c799[_0x963c('0x3d')]=_0x2dce41['pass']=null;}else{_0xc2c799['CloudProviderId']=_0x2dce41[_0x963c('0x3f')]=null;}_0xc2c799[_0x963c('0x40')]=getImapHost(_0x3a2d9e);_0xc2c799[_0x963c('0x41')]=0x3e1;_0x2dce41[_0x963c('0x40')]=getSmtpHost(_0x3a2d9e);_0x2dce41[_0x963c('0x41')]=0x24b;_0x2dce41['secure']=![];_0xc2c799[_0x963c('0x42')]=_0x2dce41[_0x963c('0x42')]=null;}else{if(_0x51643d[_0x963c('0x43')]){_0xc2c799[_0x963c('0x3b')]=_0x2dce41['user']=_0x51643d[_0x963c('0x44')];_0xc2c799[_0x963c('0x3d')]=_0x2dce41['pass']=_0x51643d[_0x963c('0x3d')];}else{_0xc2c799[_0x963c('0x43')]=_0x2dce41[_0x963c('0x43')]=![];_0xc2c799[_0x963c('0x3b')]=_0x2dce41['user']=null;_0xc2c799[_0x963c('0x3d')]=_0x2dce41['pass']=null;}_0xc2c799[_0x963c('0x40')]=_0x51643d[_0x963c('0x45')][_0x963c('0x40')];_0xc2c799[_0x963c('0x41')]=_0x51643d[_0x963c('0x45')][_0x963c('0x41')];_0x2dce41[_0x963c('0x40')]=_0x51643d[_0x963c('0x46')]['host'];_0x2dce41['port']=_0x51643d['Smtp'][_0x963c('0x41')];}return{'Imap':_0xc2c799,'Smtp':_0x2dce41};}exports[_0x963c('0x47')]=function(_0x546ef7,_0x43d6c7){var _0x4679a2={'include':[{'model':db[_0x963c('0x48')],'as':_0x963c('0x45')},{'model':db['MailServerOut'],'as':_0x963c('0x46')},{'model':db['Pause'],'as':_0x963c('0x49')}]},_0x40bdf3={},_0x287ed6={'count':0x0,'rows':[]};var _0x2e7041=_[_0x963c('0x4a')](db[_0x963c('0x4b')][_0x963c('0x4c')],function(_0x388822){return{'name':_0x388822[_0x963c('0x4d')],'type':_0x388822[_0x963c('0x4e')]['key']};});_0x40bdf3[_0x963c('0x4f')]=_[_0x963c('0x4a')](_0x2e7041,'name');_0x40bdf3[_0x963c('0x50')]=_[_0x963c('0x51')](_0x546ef7[_0x963c('0x50')]);_0x40bdf3[_0x963c('0x52')]=_[_0x963c('0x53')](_0x40bdf3[_0x963c('0x4f')],_0x40bdf3[_0x963c('0x50')]);_0x4679a2[_0x963c('0x54')]=_[_0x963c('0x53')](_0x40bdf3[_0x963c('0x4f')],qs[_0x963c('0x55')](_0x546ef7[_0x963c('0x50')]['fields']));_0x4679a2[_0x963c('0x54')]=_0x4679a2[_0x963c('0x54')][_0x963c('0x56')]?_0x4679a2[_0x963c('0x54')]:_0x40bdf3['model'];if(!_0x546ef7['query'][_0x963c('0x57')](_0x963c('0x58'))){_0x4679a2['limit']=qs[_0x963c('0x59')](_0x546ef7[_0x963c('0x50')][_0x963c('0x59')]);_0x4679a2[_0x963c('0x23')]=qs[_0x963c('0x23')](_0x546ef7[_0x963c('0x50')][_0x963c('0x23')]);}_0x4679a2[_0x963c('0x5a')]=qs[_0x963c('0x5b')](_0x546ef7[_0x963c('0x50')][_0x963c('0x5b')]);_0x4679a2[_0x963c('0x5c')]=qs[_0x963c('0x52')](_['pick'](_0x546ef7[_0x963c('0x50')],_0x40bdf3[_0x963c('0x52')]),_0x2e7041);if(_0x546ef7[_0x963c('0x50')][_0x963c('0x5d')]){_0x4679a2[_0x963c('0x5c')]=_[_0x963c('0x5e')](_0x4679a2['where'],{'$or':_['map'](_0x2e7041,function(_0x2776c7){if(_0x2776c7['type']!=='VIRTUAL'){var _0x4d9970={};_0x4d9970[_0x2776c7[_0x963c('0x2d')]]={'$like':'%'+_0x546ef7[_0x963c('0x50')][_0x963c('0x5d')]+'%'};return _0x4d9970;}})});}_0x4679a2=_[_0x963c('0x5e')]({},_0x4679a2,_0x546ef7[_0x963c('0x5f')]);var _0xab0de7={'where':_0x4679a2['where']};return db[_0x963c('0x4b')][_0x963c('0x25')](_0xab0de7)['then'](function(_0x56367c){_0x287ed6[_0x963c('0x25')]=_0x56367c;if(_0x546ef7[_0x963c('0x50')][_0x963c('0x60')]){_0x4679a2[_0x963c('0x61')]=[{'all':!![]}];}return db[_0x963c('0x4b')][_0x963c('0x62')](_0x4679a2);})['then'](function(_0x1cfdc5){_0x287ed6['rows']=_0x1cfdc5;return _0x287ed6;})['then'](respondWithFilteredResult(_0x43d6c7,_0x4679a2))[_0x963c('0x1f')](handleError(_0x43d6c7,null));};exports[_0x963c('0x63')]=function(_0x273445,_0x233345){var _0x55de0c={'raw':![],'where':{'id':_0x273445[_0x963c('0x64')]['id']},'include':[{'model':db[_0x963c('0x48')],'as':_0x963c('0x45')},{'model':db[_0x963c('0x65')],'as':_0x963c('0x46')},{'model':db[_0x963c('0x66')],'as':_0x963c('0x49')}]},_0x208027={};_0x208027[_0x963c('0x4f')]=_[_0x963c('0x51')](db[_0x963c('0x4b')][_0x963c('0x4c')]);_0x208027[_0x963c('0x50')]=_['keys'](_0x273445['query']);_0x208027[_0x963c('0x52')]=_[_0x963c('0x53')](_0x208027[_0x963c('0x4f')],_0x208027[_0x963c('0x50')]);_0x55de0c[_0x963c('0x54')]=_['intersection'](_0x208027[_0x963c('0x4f')],qs[_0x963c('0x55')](_0x273445[_0x963c('0x50')][_0x963c('0x55')]));_0x55de0c['attributes']=_0x55de0c[_0x963c('0x54')]['length']?_0x55de0c['attributes']:_0x208027[_0x963c('0x4f')];if(_0x273445[_0x963c('0x50')][_0x963c('0x60')]){_0x55de0c[_0x963c('0x61')]=[{'all':!![]}];}_0x55de0c=_[_0x963c('0x5e')]({},_0x55de0c,_0x273445[_0x963c('0x5f')]);return db['MailAccount']['find'](_0x55de0c)['then'](handleEntityNotFound(_0x233345,null))['then'](respondWithResult(_0x233345,null))['catch'](handleError(_0x233345,null));};exports[_0x963c('0x27')]=function(_0x257021,_0x1eb38d){if(_0x257021[_0x963c('0x67')]['id']){delete _0x257021['body']['id'];}var _0x4cc562=_0x257021[_0x963c('0x67')]['provider']===_0x963c('0x68')?null:_0x257021['body']['provider'];var _0x22a189=_0x257021[_0x963c('0x67')][_0x963c('0x45')]||{};var _0x5ec086=_0x257021['body'][_0x963c('0x46')]||{};if(_0x4cc562){_0x22a189['host']=getImapHost(_0x4cc562);_0x22a189['port']=0x3e1;_0x5ec086[_0x963c('0x40')]=getSmtpHost(_0x4cc562);_0x5ec086['port']=0x24b;_0x5ec086[_0x963c('0x69')]=![];}if(_0x5ec086[_0x963c('0x3e')]){_0x5ec086[_0x963c('0x69')]=![];}else{_0x5ec086[_0x963c('0x3f')]=null;}if(!_0x22a189[_0x963c('0x3e')])_0x22a189[_0x963c('0x3f')]=null;_0x257021[_0x963c('0x67')][_0x963c('0x45')]=_0x22a189;_0x257021[_0x963c('0x67')]['Smtp']=_0x5ec086;return db['MailAccount']['find']({'where':{'id':_0x257021[_0x963c('0x64')]['id']},'include':[{'model':db[_0x963c('0x48')],'as':'Imap'},{'model':db['MailServerOut'],'as':'Smtp'},{'model':db['Pause'],'as':_0x963c('0x49')}]})[_0x963c('0x14')](handleEntityNotFound(_0x1eb38d,null))[_0x963c('0x14')](function(_0x511a91){if(!_0x511a91)throw new Error('Mail\x20Account\x20not\x20found');if(_0x511a91[_0x963c('0x42')])delete _0x257021['body']['Imap'];return _0x511a91;})[_0x963c('0x14')](saveUpdates(_0x257021[_0x963c('0x67')],null))[_0x963c('0x14')](function(_0x2dd65a){if(!_0x257021[_0x963c('0x67')][_0x963c('0x45')])return _0x2dd65a;return db[_0x963c('0x48')][_0x963c('0x27')](_0x257021[_0x963c('0x67')][_0x963c('0x45')],{'where':{'MailAccountId':_0x2dd65a['id']}})[_0x963c('0x14')](function(){return _0x2dd65a;});})['then'](function(_0x18d53f){if(!_0x257021[_0x963c('0x67')][_0x963c('0x46')])return _0x18d53f;return db[_0x963c('0x65')][_0x963c('0x27')](_0x257021[_0x963c('0x67')][_0x963c('0x46')],{'where':{'MailAccountId':_0x18d53f['id']}})[_0x963c('0x14')](function(){return _0x18d53f;});})[_0x963c('0x14')](respondWithResult(_0x1eb38d,null))[_0x963c('0x1f')](handleError(_0x1eb38d,null));};exports[_0x963c('0x6a')]=function(_0x6002f9,_0x412541){return db['MailAccount'][_0x963c('0x6a')]()[_0x963c('0x14')](respondWithResult(_0x412541,null))[_0x963c('0x1f')](handleError(_0x412541,null));};exports[_0x963c('0x6b')]=function(_0x4cfe03,_0x5c51b8){if(_0x4cfe03[_0x963c('0x67')]['id']){delete _0x4cfe03[_0x963c('0x67')]['id'];}return db[_0x963c('0x4b')]['find']({'where':{'id':_0x4cfe03['params']['id']}})['then'](handleEntityNotFound(_0x5c51b8,null))[_0x963c('0x14')](function(_0x3a0131){if(_0x3a0131){_0x4cfe03[_0x963c('0x67')][_0x963c('0x6c')]=_0x3a0131['id'];return db[_0x963c('0x6d')][_0x963c('0x6e')](_0x4cfe03[_0x963c('0x67')]);}})[_0x963c('0x14')](respondWithResult(_0x5c51b8,null))[_0x963c('0x1f')](handleError(_0x5c51b8,null));};exports[_0x963c('0x6f')]=function(_0x31b7fb,_0x1b5dd9){var _0x54813c={'raw':![],'where':{}};var _0x9cf4b0={};var _0xa87ed8={'count':0x0,'rows':[]};return db[_0x963c('0x4b')]['findOne']({'where':{'id':_0x31b7fb['params']['id']}})['then'](handleEntityNotFound(_0x1b5dd9,null))['then'](function(_0x296658){if(_0x296658){_0x9cf4b0[_0x963c('0x4f')]=_[_0x963c('0x51')](db[_0x963c('0x6d')]['rawAttributes']);_0x9cf4b0['query']=_[_0x963c('0x51')](_0x31b7fb['query']);_0x9cf4b0[_0x963c('0x52')]=_[_0x963c('0x53')](_0x9cf4b0[_0x963c('0x4f')],_0x9cf4b0[_0x963c('0x50')]);_0x54813c[_0x963c('0x54')]=_['intersection'](_0x9cf4b0[_0x963c('0x4f')],qs[_0x963c('0x55')](_0x31b7fb[_0x963c('0x50')][_0x963c('0x55')]));_0x54813c['attributes']=_0x54813c[_0x963c('0x54')]['length']?_0x54813c[_0x963c('0x54')]:_0x9cf4b0[_0x963c('0x4f')];if(!_0x31b7fb['query'][_0x963c('0x57')](_0x963c('0x58'))){_0x54813c[_0x963c('0x59')]=qs[_0x963c('0x59')](_0x31b7fb[_0x963c('0x50')][_0x963c('0x59')]);_0x54813c[_0x963c('0x23')]=qs[_0x963c('0x23')](_0x31b7fb[_0x963c('0x50')]['offset']);}_0x54813c['order']=qs[_0x963c('0x5b')](_0x31b7fb[_0x963c('0x50')]['sort']);_0x54813c['where']=qs[_0x963c('0x52')](_[_0x963c('0x70')](_0x31b7fb[_0x963c('0x50')],_0x9cf4b0['filters']));_0x54813c['where'][_0x963c('0x6c')]=_0x296658['id'];if(_0x31b7fb[_0x963c('0x50')][_0x963c('0x5d')]){_0x54813c[_0x963c('0x5c')]=_[_0x963c('0x5e')](_0x54813c[_0x963c('0x5c')],{'$or':_['map'](_0x54813c[_0x963c('0x54')],function(_0x37916e){var _0x510637={};_0x510637[_0x37916e]={'$like':'%'+_0x31b7fb['query'][_0x963c('0x5d')]+'%'};return _0x510637;})});}_0x54813c=_[_0x963c('0x5e')]({},_0x54813c,_0x31b7fb[_0x963c('0x5f')]);return db[_0x963c('0x6d')]['count']({'where':_0x54813c['where']})[_0x963c('0x14')](function(_0x34547b){_0xa87ed8[_0x963c('0x25')]=_0x34547b;if(_0x31b7fb['query'][_0x963c('0x60')]){_0x54813c[_0x963c('0x61')]=[{'all':!![]}];}return db[_0x963c('0x6d')][_0x963c('0x62')](_0x54813c);})[_0x963c('0x14')](function(_0x511ddb){_0xa87ed8['rows']=_0x511ddb;return _0xa87ed8;});}})[_0x963c('0x14')](respondWithFilteredResult(_0x1b5dd9,_0x54813c))[_0x963c('0x1f')](handleError(_0x1b5dd9,null));};exports[_0x963c('0x71')]=function(_0x1bf6f8,_0x12ae32){return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x1bf6f8[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x12ae32,null))[_0x963c('0x14')](function(_0x5b7c37){if(_0x5b7c37){return _0x5b7c37[_0x963c('0x71')](_0x1bf6f8[_0x963c('0x50')][_0x963c('0x73')]);}})[_0x963c('0x14')](respondWithStatusCode(_0x12ae32,null))[_0x963c('0x1f')](handleError(_0x12ae32,null));};exports[_0x963c('0x74')]=function(_0x39a35a,_0x210504){if(_0x39a35a[_0x963c('0x67')]['id']){delete _0x39a35a[_0x963c('0x67')]['id'];}return db[_0x963c('0x4b')]['find']({'where':{'id':_0x39a35a[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x210504,null))['then'](function(_0x3e1e80){if(_0x3e1e80){_0x39a35a[_0x963c('0x67')]['MailAccountId']=_0x3e1e80['id'];return db[_0x963c('0x75')][_0x963c('0x6e')](_0x39a35a[_0x963c('0x67')]);}})[_0x963c('0x14')](respondWithResult(_0x210504,null))[_0x963c('0x1f')](handleError(_0x210504,null));};exports[_0x963c('0x76')]=function(_0x3427e0,_0x3d1bc6){var _0x285ac6={'raw':![],'where':{}};var _0x5cf8cd={};var _0x32ef50={'count':0x0,'rows':[]};return db['MailAccount'][_0x963c('0x77')]({'where':{'id':_0x3427e0['params']['id']}})['then'](handleEntityNotFound(_0x3d1bc6,null))[_0x963c('0x14')](function(_0x3b7f46){if(_0x3b7f46){_0x5cf8cd['model']=_[_0x963c('0x51')](db['CannedAnswer'][_0x963c('0x4c')]);_0x5cf8cd[_0x963c('0x50')]=_[_0x963c('0x51')](_0x3427e0[_0x963c('0x50')]);_0x5cf8cd[_0x963c('0x52')]=_['intersection'](_0x5cf8cd[_0x963c('0x4f')],_0x5cf8cd[_0x963c('0x50')]);_0x285ac6[_0x963c('0x54')]=_[_0x963c('0x53')](_0x5cf8cd[_0x963c('0x4f')],qs['fields'](_0x3427e0['query'][_0x963c('0x55')]));_0x285ac6[_0x963c('0x54')]=_0x285ac6['attributes'][_0x963c('0x56')]?_0x285ac6[_0x963c('0x54')]:_0x5cf8cd[_0x963c('0x4f')];if(!_0x3427e0[_0x963c('0x50')][_0x963c('0x57')](_0x963c('0x58'))){_0x285ac6[_0x963c('0x59')]=qs['limit'](_0x3427e0[_0x963c('0x50')]['limit']);_0x285ac6['offset']=qs[_0x963c('0x23')](_0x3427e0[_0x963c('0x50')]['offset']);}_0x285ac6[_0x963c('0x5a')]=qs[_0x963c('0x5b')](_0x3427e0['query'][_0x963c('0x5b')]);_0x285ac6[_0x963c('0x5c')]=qs[_0x963c('0x52')](_['pick'](_0x3427e0['query'],_0x5cf8cd[_0x963c('0x52')]));_0x285ac6['where'][_0x963c('0x6c')]=_0x3b7f46['id'];if(_0x3427e0[_0x963c('0x50')][_0x963c('0x5d')]){_0x285ac6[_0x963c('0x5c')]=_[_0x963c('0x5e')](_0x285ac6[_0x963c('0x5c')],{'$or':_[_0x963c('0x4a')](_0x285ac6[_0x963c('0x54')],function(_0x1709ee){var _0x92dfdc={};_0x92dfdc[_0x1709ee]={'$like':'%'+_0x3427e0['query'][_0x963c('0x5d')]+'%'};return _0x92dfdc;})});}_0x285ac6=_[_0x963c('0x5e')]({},_0x285ac6,_0x3427e0[_0x963c('0x5f')]);return db[_0x963c('0x75')]['count']({'where':_0x285ac6['where']})[_0x963c('0x14')](function(_0x4da1a0){_0x32ef50[_0x963c('0x25')]=_0x4da1a0;if(_0x3427e0['query'][_0x963c('0x60')]){_0x285ac6[_0x963c('0x61')]=[{'all':!![]}];}return db['CannedAnswer'][_0x963c('0x62')](_0x285ac6);})[_0x963c('0x14')](function(_0x3b49d8){_0x32ef50['rows']=_0x3b49d8;return _0x32ef50;});}})[_0x963c('0x14')](respondWithFilteredResult(_0x3d1bc6,_0x285ac6))['catch'](handleError(_0x3d1bc6,null));};exports[_0x963c('0x78')]=function(_0x380347,_0x42a110){return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x380347[_0x963c('0x64')]['id']}})['then'](handleEntityNotFound(_0x42a110,null))[_0x963c('0x14')](function(_0x3c2427){if(_0x3c2427){return _0x3c2427[_0x963c('0x78')](_0x380347[_0x963c('0x50')][_0x963c('0x73')]);}})[_0x963c('0x14')](respondWithStatusCode(_0x42a110,null))[_0x963c('0x1f')](handleError(_0x42a110,null));};exports[_0x963c('0x6e')]=function(_0x2b3bf3,_0x2105ca){var _0x2ac40f={'name':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x2d')],'key':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x79')],'provider':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7a')]===_0x963c('0x68')?null:_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7a')],'email':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7b')],'ListId':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7c')],'active':!_[_0x963c('0x7d')](_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7e')])?_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7e')]:!![],'description':_0x2b3bf3[_0x963c('0x67')][_0x963c('0x7f')]||null};var _0x3ce0c9=getAuthenticationOptions(_0x2ac40f[_0x963c('0x7a')],_0x2b3bf3[_0x963c('0x67')]);_0x2ac40f[_0x963c('0x45')]=_0x3ce0c9['Imap'];_0x2ac40f[_0x963c('0x46')]=_0x3ce0c9['Smtp'];return db['MailAccount'][_0x963c('0x6e')](_0x2ac40f,{'include':[{'model':db[_0x963c('0x65')],'as':_0x963c('0x46')},{'model':db[_0x963c('0x48')],'as':_0x963c('0x45')}]})[_0x963c('0x14')](function(_0x3849d5){var _0x24b3f9=_0x2b3bf3['user']['get']({'plain':!![]});if(!_0x24b3f9)throw new Error(_0x963c('0x80'));if(_0x24b3f9[_0x963c('0x81')]===_0x963c('0x3b')){var _0x46e3f1=_0x3849d5[_0x963c('0x28')]({'plain':!![]});return db['UserProfileSection'][_0x963c('0x72')]({'where':{'name':_0x963c('0x29'),'userProfileId':_0x24b3f9[_0x963c('0x82')]},'raw':!![]})['then'](function(_0x2765e6){if(_0x2765e6&&_0x2765e6[_0x963c('0x83')]===0x0){return db[_0x963c('0x2a')][_0x963c('0x6e')]({'name':_0x46e3f1[_0x963c('0x2d')],'resourceId':_0x46e3f1['id'],'type':_0x2765e6[_0x963c('0x2d')],'sectionId':_0x2765e6['id']},{})[_0x963c('0x14')](function(){return _0x3849d5;});}else{return _0x3849d5;}})[_0x963c('0x1f')](function(_0x42f94a){logger[_0x963c('0x1b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x42f94a);throw _0x42f94a;});}return _0x3849d5;})[_0x963c('0x14')](respondWithResult(_0x2105ca,0xc9))[_0x963c('0x1f')](handleError(_0x2105ca,null));};exports[_0x963c('0x84')]=function(_0x9a3d69,_0x5e88bc){return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0x9a3d69[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x5e88bc,null))[_0x963c('0x14')](function(_0x3c2871){if(_0x3c2871){return _0x3c2871[_0x963c('0x84')]();}return null;})[_0x963c('0x14')](respondWithResult(_0x5e88bc,null))[_0x963c('0x1f')](handleError(_0x5e88bc,null));};exports[_0x963c('0x85')]=function(_0x37c2bf,_0x5440f0){if(_0x37c2bf[_0x963c('0x67')]['id']){delete _0x37c2bf['body']['id'];}return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x37c2bf['params']['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x5440f0,null))[_0x963c('0x14')](function(_0x12fe27){if(_0x12fe27){_0x37c2bf[_0x963c('0x67')][_0x963c('0x6c')]=_0x12fe27['id'];return db[_0x963c('0x48')]['create'](_0x37c2bf[_0x963c('0x67')]);}})[_0x963c('0x14')](respondWithResult(_0x5440f0,null))[_0x963c('0x1f')](handleError(_0x5440f0,null));};exports[_0x963c('0x86')]=function(_0x34a2fd,_0x244b82){return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0x34a2fd[_0x963c('0x64')]['id']}})['then'](handleEntityNotFound(_0x244b82,null))[_0x963c('0x14')](function(_0xfd661c){if(_0xfd661c){return _0xfd661c['setImap'](null);}return null;})[_0x963c('0x14')](respondWithStatusCode(_0x244b82,null))['catch'](handleError(_0x244b82,null));};exports[_0x963c('0x87')]=function(_0x48e05f,_0x2af19c){return db[_0x963c('0x4b')]['findOne']({'where':{'id':_0x48e05f[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x2af19c,null))['then'](function(_0x3ccc1b){if(_0x3ccc1b){return _0x3ccc1b[_0x963c('0x87')]();}return null;})['then'](respondWithResult(_0x2af19c,null))[_0x963c('0x1f')](handleError(_0x2af19c,null));};exports[_0x963c('0x88')]=function(_0x48badf,_0xfd9716){if(_0x48badf[_0x963c('0x67')]['id']){delete _0x48badf[_0x963c('0x67')]['id'];}return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x48badf[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0xfd9716,null))[_0x963c('0x14')](function(_0x3fd9c4){if(_0x3fd9c4){_0x48badf[_0x963c('0x67')][_0x963c('0x6c')]=_0x3fd9c4['id'];return db[_0x963c('0x65')]['create'](_0x48badf[_0x963c('0x67')]);}})[_0x963c('0x14')](respondWithResult(_0xfd9716,null))[_0x963c('0x1f')](handleError(_0xfd9716,null));};exports[_0x963c('0x89')]=function(_0x4d3a7c,_0x25ea26){return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0x4d3a7c['params']['id']}})['then'](handleEntityNotFound(_0x25ea26,null))[_0x963c('0x14')](function(_0x360762){if(_0x360762){return _0x360762['setSmtp'](null);}return null;})[_0x963c('0x14')](respondWithStatusCode(_0x25ea26,null))[_0x963c('0x1f')](handleError(_0x25ea26,null));};exports[_0x963c('0x8a')]=function(_0x301ded,_0x525be8){return db[_0x963c('0x8b')][_0x963c('0x72')]({'where':{'id':_0x301ded[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x525be8,null))[_0x963c('0x14')](function(_0x273d78){if(_0x273d78){return _0x273d78['addInteraction'](_0x301ded['body'][_0x963c('0x73')],_['omit'](_0x301ded[_0x963c('0x67')],[_0x963c('0x73'),'id'])||{});}})[_0x963c('0x14')](respondWithResult(_0x525be8,null))[_0x963c('0x1f')](handleError(_0x525be8,null));};exports['getInteractions']=function(_0xa1ec74,_0x1395ff){var _0x444947={'raw':![],'where':{}};var _0x125a86={};var _0x3ae1b6={'count':0x0,'rows':[]};return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0xa1ec74[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x1395ff,null))['then'](function(_0x4b06d5){if(_0x4b06d5){_0x125a86[_0x963c('0x4f')]=_[_0x963c('0x51')](db[_0x963c('0x8b')][_0x963c('0x4c')]);_0x125a86[_0x963c('0x50')]=_['keys'](_0xa1ec74[_0x963c('0x50')]);_0x125a86[_0x963c('0x52')]=_[_0x963c('0x53')](_0x125a86[_0x963c('0x4f')],_0x125a86[_0x963c('0x50')]);_0x444947['attributes']=_[_0x963c('0x53')](_0x125a86[_0x963c('0x4f')],qs[_0x963c('0x55')](_0xa1ec74[_0x963c('0x50')][_0x963c('0x55')]));_0x444947['attributes']=_0x444947['attributes'][_0x963c('0x56')]?_0x444947[_0x963c('0x54')]:_0x125a86[_0x963c('0x4f')];if(!_0xa1ec74[_0x963c('0x50')][_0x963c('0x57')](_0x963c('0x58'))){_0x444947[_0x963c('0x59')]=qs[_0x963c('0x59')](_0xa1ec74['query']['limit']);_0x444947[_0x963c('0x23')]=qs[_0x963c('0x23')](_0xa1ec74[_0x963c('0x50')][_0x963c('0x23')]);}_0x444947[_0x963c('0x5a')]=qs['sort'](_0xa1ec74[_0x963c('0x50')]['sort']);_0x444947[_0x963c('0x5c')]=qs['filters'](_[_0x963c('0x70')](_0xa1ec74[_0x963c('0x50')],_0x125a86['filters']));_0x444947[_0x963c('0x5c')][_0x963c('0x6c')]=_0x4b06d5['id'];if(_0xa1ec74[_0x963c('0x50')]['filter']){_0x444947[_0x963c('0x5c')]=_['merge'](_0x444947[_0x963c('0x5c')],{'$or':_['map'](_0x444947['attributes'],function(_0xa6cf91){var _0x545592={};_0x545592[_0xa6cf91]={'$like':'%'+_0xa1ec74['query'][_0x963c('0x5d')]+'%'};return _0x545592;})});}_0x444947=_[_0x963c('0x5e')]({},_0x444947,_0xa1ec74[_0x963c('0x5f')]);return db[_0x963c('0x8b')][_0x963c('0x25')]({'where':_0x444947[_0x963c('0x5c')]})[_0x963c('0x14')](function(_0x1bf8d9){_0x3ae1b6[_0x963c('0x25')]=_0x1bf8d9;if(_0xa1ec74[_0x963c('0x50')]['includeAll']){_0x444947['include']=[{'model':db[_0x963c('0x8c')],'as':_0x963c('0x8d'),'required':![]},{'model':db['User'],'as':_0x963c('0x8e'),'attributes':[_0x963c('0x2d'),'fullname',_0x963c('0x8f')],'required':![]},{'model':db[_0x963c('0x90')],'as':_0x963c('0x91'),'attributes':['id',_0x963c('0x2d'),'color'],'where':_0xa1ec74['query'][_0x963c('0x92')]?{'id':_0xa1ec74[_0x963c('0x50')]['tag']}:undefined,'required':_0xa1ec74[_0x963c('0x50')][_0x963c('0x92')]?!![]:![]}];}return db[_0x963c('0x8b')][_0x963c('0x62')](_0x444947);})['then'](function(_0x37881f){_0x3ae1b6[_0x963c('0x93')]=_0x37881f;return _0x3ae1b6;});}})[_0x963c('0x14')](respondWithFilteredResult(_0x1395ff,_0x444947))['catch'](handleError(_0x1395ff,null));};exports[_0x963c('0x94')]=function addApplications(_0xe04de6,_0x43acd0){var _0x396803=_0xe04de6[_0x963c('0x64')]['id'];var _0x96f964=_0xe04de6['body'];var _0x4c5024=0xc8;var _0x389ed4=null;return db['sequelize'][_0x963c('0x95')]({'isolationLevel':db[_0x963c('0x96')]['Transaction'][_0x963c('0x97')]['READ_COMMITTED']},function(_0x21c5ec){return db['MailAccount'][_0x963c('0x77')]({'where':{'id':_0x396803},'transaction':_0x21c5ec})['then'](function(_0x33a32c){if(_0x33a32c){return db['MailApplication'][_0x963c('0x2b')]({'where':{'MailAccountId':_0x396803},'transaction':_0x21c5ec})[_0x963c('0x14')](function(){var _0x3bf09b=_[_0x963c('0x4a')](_0x96f964,function(_0x47d78d){_0x47d78d[_0x963c('0x6c')]=_0x396803;return _0x47d78d;});return db[_0x963c('0x98')]['bulkCreate'](_0x3bf09b,{'transaction':_0x21c5ec});});}else{_0x4c5024=0x194;_0x389ed4=[];}});})[_0x963c('0x14')](function(){if(_0x4c5024!==0x194){return db['MailApplication'][_0x963c('0x99')]({'where':{'MailAccountId':_0x396803},'order':'priority'})['then'](function(_0x45e731){_0x389ed4=_0x45e731;});}})['catch'](function(_0x422886){_0x4c5024=0x1f4;logger[_0x963c('0x1b')](_0x422886[_0x963c('0x2c')]);if(_0x422886[_0x963c('0x2d')]){delete _0x422886[_0x963c('0x2d')];}_0x389ed4=_0x422886;})[_0x963c('0x9a')](function(){if(_0x389ed4===null){_0x43acd0[_0x963c('0x20')](_0x4c5024);}else{if(_0x4c5024===0x1f4){_0x43acd0[_0x963c('0x26')](_0x4c5024)[_0x963c('0x2e')](_0x389ed4);}else{_0x43acd0[_0x963c('0x26')](_0x4c5024)['json'](_0x389ed4);}}});};exports[_0x963c('0x9b')]=function(_0x12df54,_0x1b5a25){var _0x3482d2={};var _0xc50a46={};var _0x2d35a4;var _0xe97370;return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0x12df54[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x1b5a25,null))['then'](function(_0x3e3279){if(_0x3e3279){_0x2d35a4=_0x3e3279;_0xc50a46[_0x963c('0x4f')]=_[_0x963c('0x51')](db[_0x963c('0x98')][_0x963c('0x4c')]);_0xc50a46[_0x963c('0x50')]=_[_0x963c('0x51')](_0x12df54[_0x963c('0x50')]);_0xc50a46[_0x963c('0x52')]=_['intersection'](_0xc50a46['model'],_0xc50a46[_0x963c('0x50')]);_0x3482d2['attributes']=_['intersection'](_0xc50a46[_0x963c('0x4f')],qs[_0x963c('0x55')](_0x12df54[_0x963c('0x50')]['fields']));_0x3482d2[_0x963c('0x54')]=_0x3482d2[_0x963c('0x54')][_0x963c('0x56')]?_0x3482d2['attributes']:_0xc50a46['model'];_0x3482d2['order']=qs[_0x963c('0x5b')](_0x12df54[_0x963c('0x50')][_0x963c('0x5b')]);_0x3482d2[_0x963c('0x5c')]=qs['filters'](_[_0x963c('0x70')](_0x12df54[_0x963c('0x50')],_0xc50a46[_0x963c('0x52')]));if(_0x12df54['query']['filter']){_0x3482d2[_0x963c('0x5c')]=_[_0x963c('0x5e')](_0x3482d2[_0x963c('0x5c')],{'$or':_['map'](_0x3482d2[_0x963c('0x54')],function(_0x2b949b){var _0x7a5da8={};_0x7a5da8[_0x2b949b]={'$like':'%'+_0x12df54['query'][_0x963c('0x5d')]+'%'};return _0x7a5da8;})});}_0x3482d2=_[_0x963c('0x5e')]({},_0x3482d2,_0x12df54['options']);return _0x2d35a4[_0x963c('0x9b')](_0x3482d2);}})[_0x963c('0x14')](function(_0x151da5){if(_0x151da5){_0xe97370=_0x151da5[_0x963c('0x56')];if(!_0x12df54[_0x963c('0x50')][_0x963c('0x57')](_0x963c('0x58'))){_0x3482d2[_0x963c('0x59')]=qs[_0x963c('0x59')](_0x12df54[_0x963c('0x50')][_0x963c('0x59')]);_0x3482d2['offset']=qs[_0x963c('0x23')](_0x12df54[_0x963c('0x50')][_0x963c('0x23')]);}return _0x2d35a4[_0x963c('0x9b')](_0x3482d2);}})['then'](function(_0xb6bd36){if(_0xb6bd36){return _0xb6bd36?{'count':_0xe97370,'rows':_0xb6bd36}:null;}})[_0x963c('0x14')](respondWithResult(_0x1b5a25,null))[_0x963c('0x1f')](handleError(_0x1b5a25,null));};exports[_0x963c('0x9c')]=function(_0x4cd6c2,_0x5a568b){var _0x4ae76f={'raw':!![],'where':{}};var _0x1cb90e={};var _0x8b6176={'count':0x0,'rows':[]};return db[_0x963c('0x4b')][_0x963c('0x77')]({'where':{'id':_0x4cd6c2[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x5a568b,null))['then'](function(_0x168e7b){if(_0x168e7b){_0x1cb90e[_0x963c('0x4f')]=_[_0x963c('0x51')](db[_0x963c('0x9d')][_0x963c('0x4c')]);_0x1cb90e[_0x963c('0x50')]=_[_0x963c('0x51')](_0x4cd6c2[_0x963c('0x50')]);_0x1cb90e['filters']=_[_0x963c('0x53')](_0x1cb90e[_0x963c('0x4f')],_0x1cb90e[_0x963c('0x50')]);_0x4ae76f[_0x963c('0x54')]=_[_0x963c('0x53')](_0x1cb90e['model'],qs[_0x963c('0x55')](_0x4cd6c2['query'][_0x963c('0x55')]));_0x4ae76f[_0x963c('0x54')]=_0x4ae76f['attributes'][_0x963c('0x56')]?_0x4ae76f[_0x963c('0x54')]:_0x1cb90e['model'];if(!_0x4cd6c2['query'][_0x963c('0x57')]('nolimit')){_0x4ae76f[_0x963c('0x59')]=qs[_0x963c('0x59')](_0x4cd6c2[_0x963c('0x50')][_0x963c('0x59')]);_0x4ae76f[_0x963c('0x23')]=qs[_0x963c('0x23')](_0x4cd6c2[_0x963c('0x50')][_0x963c('0x23')]);}_0x4ae76f['order']=qs['sort'](_0x4cd6c2[_0x963c('0x50')][_0x963c('0x5b')]);_0x4ae76f['where']=qs['filters'](_[_0x963c('0x70')](_0x4cd6c2[_0x963c('0x50')],_0x1cb90e[_0x963c('0x52')]));_0x4ae76f['where'][_0x963c('0x6c')]=_0x168e7b['id'];if(_0x4cd6c2[_0x963c('0x50')][_0x963c('0x5d')]){_0x4ae76f[_0x963c('0x5c')]=_['merge'](_0x4ae76f[_0x963c('0x5c')],{'$or':_[_0x963c('0x4a')](_0x4ae76f[_0x963c('0x54')],function(_0x5c9ad3){var _0x14e786={};_0x14e786[_0x5c9ad3]={'$like':'%'+_0x4cd6c2[_0x963c('0x50')]['filter']+'%'};return _0x14e786;})});}if(_0x4cd6c2[_0x963c('0x50')][_0x963c('0x9e')]){var _0x290615=_0x4cd6c2[_0x963c('0x50')][_0x963c('0x9e')][_0x963c('0x9f')](',');var _0x2a200d={};_0x2a200d[_0x290615[0x0]]={'$gte':moment(_0x290615[0x1])['format'](_0x963c('0xa0'))};_0x4ae76f[_0x963c('0x5c')]=_['merge'](_0x4ae76f[_0x963c('0x5c')],_0x2a200d);}_0x4ae76f=_[_0x963c('0x5e')]({},_0x4ae76f,_0x4cd6c2[_0x963c('0x5f')]);return db[_0x963c('0x9d')][_0x963c('0x25')]({'where':_0x4ae76f[_0x963c('0x5c')]})['then'](function(_0x2c5609){_0x8b6176[_0x963c('0x25')]=_0x2c5609;if(_0x4cd6c2['query'][_0x963c('0x60')]){_0x4ae76f[_0x963c('0x61')]=[{'all':!![]}];}return db['MailMessage'][_0x963c('0x62')](_0x4ae76f);})['then'](function(_0x4b2656){if(_0x4cd6c2['query']['inlineCss']===_0x963c('0xa1')){for(var _0x173d92=0x0;_0x173d92<_0x4b2656[_0x963c('0x56')];_0x173d92++){_0x4b2656[_0x173d92][_0x963c('0x67')]=juice(_0x4b2656[_0x173d92]['body']);}}_0x8b6176[_0x963c('0x93')]=_0x4b2656;return _0x8b6176;});}})[_0x963c('0x14')](respondWithFilteredResult(_0x5a568b,_0x4ae76f))['catch'](handleError(_0x5a568b,null));};exports[_0x963c('0x2e')]=function(_0x135f9e,_0x1517c3){var _0x3d28b3,_0x435c7={},_0x51072e;if(_0x135f9e['body']['to']){_0x51072e=_0x135f9e['body']['to'][_0x963c('0x9f')](',')[0x0];}return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x135f9e[_0x963c('0x64')]['id']},'include':[{'model':db[_0x963c('0xa2')],'as':_0x963c('0xa3'),'include':[{'model':db['CmContact'],'as':'Contacts','where':{'email':_0x51072e},'limit':0x1,'order':[[_0x963c('0xa4'),'DESC']]}]},{'model':db['MailServerOut'],'as':_0x963c('0x46'),'raw':!![],'include':[{'model':db[_0x963c('0xa5')],'as':'CloudProvider','raw':!![]}]}]})[_0x963c('0x14')](handleEntityNotFound(_0x1517c3,null))['then'](function(_0x5454c0){if(!_0x5454c0)return;_0x3d28b3=_0x5454c0;if(!_0x5454c0[_0x963c('0x46')])throw new Error(_0x963c('0xa6'));if(_[_0x963c('0x7d')](_0x135f9e[_0x963c('0x67')][_0x963c('0xa7')])){_0x135f9e['body'][_0x963c('0xa7')]=util['format'](_0x963c('0xa8'),_0x5454c0[_0x963c('0x2d')],_0x5454c0[_0x963c('0x7b')]||_0x5454c0['Smtp'][_0x963c('0x3b')]);}if(_0x135f9e[_0x963c('0x67')][_0x963c('0xa9')]&&_0x135f9e['body']['attachments'][_0x963c('0x56')]){for(var _0x349675=0x0;_0x349675<_0x135f9e[_0x963c('0x67')][_0x963c('0xa9')][_0x963c('0x56')];_0x349675+=0x1){_0x135f9e[_0x963c('0x67')]['attachments'][_0x349675]={'filename':_0x135f9e[_0x963c('0x67')]['attachments'][_0x349675][_0x963c('0x2d')],'path':path[_0x963c('0xaa')](config[_0x963c('0xab')],_0x963c('0xac'),_0x135f9e[_0x963c('0x67')][_0x963c('0xa9')][_0x349675][_0x963c('0xad')])};}}var _0x555ee2=_0x5454c0['getSmtpOptions']();return respondWithRpcPromise(_0x963c('0xae'),'sendMail',{'account':_0x555ee2,'message':_0x135f9e[_0x963c('0x67')]});})[_0x963c('0x14')](function(_0x5aac44){if(!_0x5aac44)return;_0x435c7=_0x5aac44;if(!_0x3d28b3['List'])throw new Error('List\x20not\x20found');if(_0x3d28b3[_0x963c('0xa3')][_0x963c('0xaf')]['length'])return _0x3d28b3[_0x963c('0xa3')][_0x963c('0xaf')][0x0];return db[_0x963c('0x8c')][_0x963c('0x6e')](_[_0x963c('0xb')](_0x135f9e['body'],{'firstName':_0x135f9e['body']['to'],'email':_0x135f9e[_0x963c('0x67')]['to'],'phone':_0x135f9e[_0x963c('0x67')]['to'],'ListId':_0x3d28b3[_0x963c('0x7c')]}));})[_0x963c('0x14')](function(_0x574116){if(!_0x574116)return;var _0x5138e0={'UserId':_0x135f9e[_0x963c('0x3b')]['id'],'ContactId':_0x574116['id'],'MailAccountId':_0x3d28b3['id'],'inReplyTo':_0x435c7[_0x963c('0xb0')],'to':_0x135f9e[_0x963c('0x67')][_0x963c('0xa7')],'cc':_0x135f9e['body']['cc'],'subject':_0x135f9e[_0x963c('0x67')][_0x963c('0xb1')],'attach':_0x135f9e[_0x963c('0x67')][_0x963c('0xb2')],'firstMsgDirection':_0x963c('0xb3'),'lastMsgAt':moment()[_0x963c('0xb4')](_0x963c('0xa0')),'lastMsgDirection':_0x963c('0xb3'),'Messages':[_['merge'](_0x135f9e[_0x963c('0x67')],{'messageId':_0x435c7[_0x963c('0xb0')],'sentAt':moment()[_0x963c('0xb4')]('YYYY-MM-DD\x20HH:mm:ss'),'read':!![],'MailAccountId':_0x3d28b3['id'],'UserId':_0x135f9e[_0x963c('0x3b')]['id'],'ContactId':_0x574116['id']})]};if(_0x135f9e[_0x963c('0x67')][_0x963c('0xb5')]){_0x5138e0=_[_0x963c('0x5e')](_0x5138e0,_0x135f9e['body'][_0x963c('0xb5')]);}return db['MailInteraction'][_0x963c('0x6e')](_0x5138e0,{'include':[{'model':db[_0x963c('0x9d')],'as':_0x963c('0xb6')}]});})[_0x963c('0x14')](respondWithResult(_0x1517c3,null))[_0x963c('0x1f')](handleError(_0x1517c3,null));};exports['verifySmtp']=function(_0x521e9b,_0x36070f){return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x521e9b['params']['id']},'include':[{'model':db[_0x963c('0x65')],'as':'Smtp','raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x963c('0xa5'),'raw':!![]}]}]})[_0x963c('0x14')](handleEntityNotFound(_0x36070f,null))[_0x963c('0x14')](function(_0x48d0e4){if(!_0x48d0e4[_0x963c('0x46')])return;var _0x229e6c=_0x48d0e4[_0x963c('0xb7')]();return respondWithRpcPromise('VerifySmtp',_0x963c('0xb8'),{'account':_0x229e6c});})[_0x963c('0x14')](respondWithResult(_0x36070f,null))[_0x963c('0x1f')](handleError(_0x36070f,null));};exports['destroy']=function(_0x547d20,_0x24ec3f){return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x547d20[_0x963c('0x64')]['id']}})[_0x963c('0x14')](handleEntityNotFound(_0x24ec3f,null))[_0x963c('0x14')](function(_0x59e178){if(_0x59e178&&_0x59e178['service']){throw new db[(_0x963c('0xb9'))][(_0x963c('0xba'))]('You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account');}return _0x59e178;})[_0x963c('0x14')](removeEntity(_0x24ec3f,null))[_0x963c('0x1f')](handleError(_0x24ec3f,null));};exports['addAgents']=function(_0x1f953a,_0x3df71e){return db[_0x963c('0x4b')][_0x963c('0x72')]({'where':{'id':_0x1f953a[_0x963c('0x64')]['id']}})['then'](handleEntityNotFound(_0x3df71e,null))['then'](function(_0x19ec16){if(_0x19ec16){return _0x19ec16['addAgents'](_0x1f953a[_0x963c('0x67')]['ids'],_[_0x963c('0xbb')](_0x1f953a[_0x963c('0x67')],[_0x963c('0x73'),'id'])||{})[_0x963c('0xbc')](function(_0x20cbfa){for(var _0x3a23fe=0x0;_0x3a23fe<_0x1f953a[_0x963c('0x67')][_0x963c('0x73')][_0x963c('0x56')];_0x3a23fe+=0x1){socket[_0x963c('0xbd')]('userMailAccount:save',{'UserId':Number(_0x1f953a[_0x963c('0x67')][_0x963c('0x73')][_0x3a23fe]),'MailAccountId':Number(_0x1f953a[_0x963c('0x64')]['id'])});}return _0x20cbfa;});}})[_0x963c('0x14')](respondWithResult(_0x3df71e,null))[_0x963c('0x1f')](handleError(_0x3df71e,null));};exports['removeAgents']=function(_0x4c4764,_0x1b89e3){return db['MailAccount']['find']({'where':{'id':_0x4c4764[_0x963c('0x64')]['id']}})['then'](handleEntityNotFound(_0x1b89e3,null))['then'](function(_0x19949f){if(_0x19949f){return _0x19949f[_0x963c('0xbe')](_0x4c4764[_0x963c('0x50')][_0x963c('0x73')])[_0x963c('0x14')](function(){if(_[_0x963c('0xbf')](_0x4c4764[_0x963c('0x50')][_0x963c('0x73')])){for(var _0x4f40c6=0x0;_0x4f40c6<_0x4c4764['query'][_0x963c('0x73')]['length'];_0x4f40c6+=0x1){socket[_0x963c('0xbd')](_0x963c('0xc0'),{'UserId':Number(_0x4c4764['query']['ids'][_0x4f40c6]),'MailAccountId':Number(_0x4c4764[_0x963c('0x64')]['id'])});}}else{socket['emit'](_0x963c('0xc0'),{'UserId':Number(_0x4c4764[_0x963c('0x50')][_0x963c('0x73')]),'MailAccountId':Number(_0x4c4764['params']['id'])});}});}})['then'](respondWithStatusCode(_0x1b89e3,null))[_0x963c('0x1f')](handleError(_0x1b89e3,null));};exports[_0x963c('0xc1')]=function(_0x20ed5c,_0x325346){var _0x520de2={};var _0xfec01a={};var _0x416af0;var _0x363218;return db['MailAccount'][_0x963c('0x77')]({'where':{'id':_0x20ed5c[_0x963c('0x64')]['id']}})['then'](handleEntityNotFound(_0x325346,null))[_0x963c('0x14')](function(_0x437bcc){if(_0x437bcc){_0x416af0=_0x437bcc;_0xfec01a[_0x963c('0x4f')]=_['keys'](db[_0x963c('0xc2')][_0x963c('0x4c')]);_0xfec01a[_0x963c('0x50')]=_[_0x963c('0x51')](_0x20ed5c[_0x963c('0x50')]);_0xfec01a['filters']=_[_0x963c('0x53')](_0xfec01a[_0x963c('0x4f')],_0xfec01a[_0x963c('0x50')]);_0x520de2[_0x963c('0x54')]=_['intersection'](_0xfec01a[_0x963c('0x4f')],qs[_0x963c('0x55')](_0x20ed5c[_0x963c('0x50')]['fields']));_0x520de2[_0x963c('0x54')]=_0x520de2[_0x963c('0x54')][_0x963c('0x56')]?_0x520de2[_0x963c('0x54')]:_0xfec01a['model'];_0x520de2[_0x963c('0x5a')]=qs[_0x963c('0x5b')](_0x20ed5c[_0x963c('0x50')]['sort']);_0x520de2['where']=qs[_0x963c('0x52')](_[_0x963c('0x70')](_0x20ed5c[_0x963c('0x50')],_0xfec01a[_0x963c('0x52')]));if(_0x20ed5c[_0x963c('0x50')][_0x963c('0x5d')]){_0x520de2[_0x963c('0x5c')]=_[_0x963c('0x5e')](_0x520de2[_0x963c('0x5c')],{'$or':_['map'](_0x520de2[_0x963c('0x54')],function(_0x41ab03){var _0x107128={};_0x107128[_0x41ab03]={'$like':'%'+_0x20ed5c[_0x963c('0x50')][_0x963c('0x5d')]+'%'};return _0x107128;})});}_0x520de2=_['merge']({},_0x520de2,_0x20ed5c[_0x963c('0x5f')]);return _0x416af0[_0x963c('0xc1')](_0x520de2);}})[_0x963c('0x14')](function(_0x1aaf18){if(_0x1aaf18){_0x363218=_0x1aaf18[_0x963c('0x56')];if(!_0x20ed5c[_0x963c('0x50')][_0x963c('0x57')](_0x963c('0x58'))){_0x520de2['limit']=qs[_0x963c('0x59')](_0x20ed5c[_0x963c('0x50')][_0x963c('0x59')]);_0x520de2[_0x963c('0x23')]=qs[_0x963c('0x23')](_0x20ed5c[_0x963c('0x50')][_0x963c('0x23')]);}return _0x416af0[_0x963c('0xc1')](_0x520de2);}})[_0x963c('0x14')](function(_0xdde057){if(_0xdde057){return _0xdde057?{'count':_0x363218,'rows':_0xdde057}:null;}})[_0x963c('0x14')](respondWithResult(_0x325346,null))['catch'](handleError(_0x325346,null));}; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.events.js b/server/api/mailAccount/mailAccount.events.js new file mode 100644 index 0000000..6d35f95 --- /dev/null +++ b/server/api/mailAccount/mailAccount.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd9b4=['setMaxListeners','save','update','remove','emit','hasOwnProperty','hook','exports','events','../../mysqldb','MailAccount'];(function(_0x4ec520,_0x15fee2){var _0xed49d7=function(_0x3031f2){while(--_0x3031f2){_0x4ec520['push'](_0x4ec520['shift']());}};_0xed49d7(++_0x15fee2);}(_0xd9b4,0x1c0));var _0x4d9b=function(_0x105e5c,_0x2a1c3a){_0x105e5c=_0x105e5c-0x0;var _0x4426f8=_0xd9b4[_0x105e5c];return _0x4426f8;};'use strict';var EventEmitter=require(_0x4d9b('0x0'));var MailAccount=require(_0x4d9b('0x1'))['db'][_0x4d9b('0x2')];var MailAccountEvents=new EventEmitter();MailAccountEvents[_0x4d9b('0x3')](0x0);var events={'afterCreate':_0x4d9b('0x4'),'afterUpdate':_0x4d9b('0x5'),'afterDestroy':_0x4d9b('0x6')};function emitEvent(_0x19b4cb){return function(_0x493238,_0x598beb,_0xa5ee50){MailAccountEvents['emit'](_0x19b4cb+':'+_0x493238['id'],_0x493238);MailAccountEvents[_0x4d9b('0x7')](_0x19b4cb,_0x493238);_0xa5ee50(null);};}for(var e in events){if(events[_0x4d9b('0x8')](e)){var event=events[e];MailAccount[_0x4d9b('0x9')](e,emitEvent(event));}}module[_0x4d9b('0xa')]=MailAccountEvents; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.model.js b/server/api/mailAccount/mailAccount.model.js new file mode 100644 index 0000000..e1c6fe7 --- /dev/null +++ b/server/api/mailAccount/mailAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7812=['pass','./mailAccount.attributes','exports','define','MailAccount','mail_accounts','provider','custom','host','port','Smtp','secure','authentication','modernAuthentication','Cloud\x20Provider\x20configuration\x20not\x20found','auth','OAuth2','user','data5'];(function(_0x298152,_0x2bab07){var _0x58117d=function(_0x12ff68){while(--_0x12ff68){_0x298152['push'](_0x298152['shift']());}};_0x58117d(++_0x2bab07);}(_0x7812,0x17d));var _0x2781=function(_0x377d7d,_0x5d8eb2){_0x377d7d=_0x377d7d-0x0;var _0x59d647=_0x7812[_0x377d7d];return _0x59d647;};'use strict';var attributes=require(_0x2781('0x0'));module[_0x2781('0x1')]=function(_0x18e5be){return _0x18e5be[_0x2781('0x2')](_0x2781('0x3'),attributes,{'tableName':_0x2781('0x4'),'paranoid':![],'indexes':[],'timestamps':!![],'instanceMethods':{'getSmtpOptions':function(){var _0x1f4ec8=this;var _0x3b4076={'id':_0x1f4ec8['id'],'tls':{'rejectUnauthorized':![]}};if(_0x1f4ec8[_0x2781('0x5')]!==_0x2781('0x6')){_0x3b4076['service']=_0x1f4ec8['provider'];}else{_0x3b4076[_0x2781('0x7')]=_0x1f4ec8['Smtp'][_0x2781('0x7')];_0x3b4076[_0x2781('0x8')]=_0x1f4ec8[_0x2781('0x9')][_0x2781('0x8')];_0x3b4076[_0x2781('0xa')]=_0x1f4ec8['Smtp'][_0x2781('0xa')];}if(_0x1f4ec8['Smtp'][_0x2781('0xb')]){if(_0x1f4ec8[_0x2781('0x9')][_0x2781('0xc')]){if(!_0x1f4ec8['Smtp']['CloudProvider'])throw new Error(_0x2781('0xd'));_0x3b4076[_0x2781('0xe')]={'type':_0x2781('0xf'),'user':_0x1f4ec8['Smtp'][_0x2781('0x10')],'accessToken':_0x1f4ec8[_0x2781('0x9')]['CloudProvider'][_0x2781('0x11')]};}else{_0x3b4076['auth']={'user':_0x1f4ec8[_0x2781('0x9')][_0x2781('0x10')],'pass':_0x1f4ec8[_0x2781('0x9')][_0x2781('0x12')]};}}return _0x3b4076;}}});}; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.rpc.js b/server/api/mailAccount/mailAccount.rpc.js new file mode 100644 index 0000000..a61ea1d --- /dev/null +++ b/server/api/mailAccount/mailAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd943=['MailServerOut','Smtp','CloudProvider','get','account','omit','smtpOptions','applications','list','asc','autoclose','close','Contacts','length','defaults','ListId','List\x20not\x20found','contact','messageId','generate','subject','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','Messages','create','spread','attach','interaction','created','attachments','originTo','originCc','ChatWebsiteId','originChannel','Email','ChatOfflineMessageId','Attachment','Attachments','UserId','User','name','agent','waitForTheAssignedAgent','Start','startRouting','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','redis','socket.io-emitter','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','MailAccount','findAll','options','where','attributes','limit','include','map','model','stringify','GetMailAccount','ShowMailAccount','smtp','setDataValue','getSmtpOptions','NotifyMailAccount','body','mail','difference','keys','CmContact','updatedAt','CompanyId','isNil','from','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','List','DESC','MailApplication','Applications'];(function(_0x4b07eb,_0x4284fb){var _0x3ed187=function(_0x4728aa){while(--_0x4728aa){_0x4b07eb['push'](_0x4b07eb['shift']());}};_0x3ed187(++_0x4284fb);}(_0xd943,0x15d));var _0x3d94=function(_0x43750b,_0x5b6b4f){_0x43750b=_0x43750b-0x0;var _0x6ca08=_0xd943[_0x43750b];return _0x6ca08;};'use strict';var _=require(_0x3d94('0x0'));var moment=require(_0x3d94('0x1'));var BPromise=require(_0x3d94('0x2'));var rs=require(_0x3d94('0x3'));var Redis=require('ioredis');var db=require(_0x3d94('0x4'))['db'];var logger=require(_0x3d94('0x5'))(_0x3d94('0x6'));var config=require(_0x3d94('0x7'));var jayson=require(_0x3d94('0x8'));var client=jayson['client']['http']({'port':0x232c});config[_0x3d94('0x9')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x3d94('0xa'))(new Redis(config[_0x3d94('0x9')]));require('./mailAccount.socket')['register'](socket);function respondWithRpcPromise(_0x3984a3,_0x27e381,_0x1cc58c){return new BPromise(function(_0x5908a7,_0x182066){return client['request'](_0x3984a3,_0x1cc58c)[_0x3d94('0xb')](function(_0x301536){logger['info'](_0x3d94('0xc'),_0x27e381,_0x3d94('0xd'));logger[_0x3d94('0xe')](_0x3d94('0xf'),_0x27e381,_0x3d94('0xd'),JSON['stringify'](_0x301536));if(_0x301536[_0x3d94('0x10')]){if(_0x301536[_0x3d94('0x10')][_0x3d94('0x11')]===0x1f4){logger['error'](_0x3d94('0xc'),_0x27e381,_0x301536[_0x3d94('0x10')][_0x3d94('0x12')]);return _0x182066(_0x301536['error'][_0x3d94('0x12')]);}logger[_0x3d94('0x10')](_0x3d94('0xc'),_0x27e381,_0x301536[_0x3d94('0x10')][_0x3d94('0x12')]);return _0x5908a7(_0x301536[_0x3d94('0x10')][_0x3d94('0x12')]);}else{logger[_0x3d94('0x13')]('MailAccount,\x20%s,\x20%s',_0x27e381,_0x3d94('0xd'));_0x5908a7(_0x301536[_0x3d94('0x14')][_0x3d94('0x12')]);}})[_0x3d94('0x15')](function(_0x4afc92){logger[_0x3d94('0x10')](_0x3d94('0xc'),_0x27e381,_0x4afc92);_0x182066(_0x4afc92);});});}exports['GetMailAccount']=function(_0x9bca24){var _0x59b741=this;return new Promise(function(_0x28bead,_0x193934){return db[_0x3d94('0x16')][_0x3d94('0x17')]({'raw':_0x9bca24[_0x3d94('0x18')]?_0x9bca24['options']['raw']===undefined?!![]:![]:!![],'where':_0x9bca24[_0x3d94('0x18')]?_0x9bca24[_0x3d94('0x18')][_0x3d94('0x19')]||null:null,'attributes':_0x9bca24['options']?_0x9bca24[_0x3d94('0x18')][_0x3d94('0x1a')]||null:null,'limit':_0x9bca24[_0x3d94('0x18')]?_0x9bca24[_0x3d94('0x18')][_0x3d94('0x1b')]||null:null,'include':_0x9bca24[_0x3d94('0x18')]?_0x9bca24[_0x3d94('0x18')][_0x3d94('0x1c')]?_[_0x3d94('0x1d')](_0x9bca24[_0x3d94('0x18')][_0x3d94('0x1c')],function(_0x192839){return{'model':db[_0x192839[_0x3d94('0x1e')]],'as':_0x192839['as'],'attributes':_0x192839[_0x3d94('0x1a')],'include':_0x192839[_0x3d94('0x1c')]?_['map'](_0x192839[_0x3d94('0x1c')],function(_0x558fd2){return{'model':db[_0x558fd2[_0x3d94('0x1e')]],'as':_0x558fd2['as'],'attributes':_0x558fd2[_0x3d94('0x1a')],'include':_0x558fd2[_0x3d94('0x1c')]?_[_0x3d94('0x1d')](_0x558fd2[_0x3d94('0x1c')],function(_0x82b568){return{'model':db[_0x82b568[_0x3d94('0x1e')]],'as':_0x82b568['as'],'attributes':_0x82b568['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x362642){logger['info']('GetMailAccount',_0x9bca24);logger[_0x3d94('0xe')]('GetMailAccount',_0x9bca24,JSON[_0x3d94('0x1f')](_0x362642));_0x28bead(_0x362642);})[_0x3d94('0x15')](function(_0x32403a){logger['error'](_0x3d94('0x20'),_0x32403a['message'],_0x9bca24);_0x193934(_0x59b741[_0x3d94('0x10')](0x1f4,_0x32403a['message']));});});};exports[_0x3d94('0x21')]=function(_0x215ad7){var _0x29b1ff=this;return new Promise(function(_0x246f88,_0x50560c){return db[_0x3d94('0x16')]['find']({'raw':_0x215ad7[_0x3d94('0x18')]?_0x215ad7[_0x3d94('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x215ad7['options']?_0x215ad7[_0x3d94('0x18')][_0x3d94('0x19')]||null:null,'attributes':_0x215ad7[_0x3d94('0x18')]?_0x215ad7['options'][_0x3d94('0x1a')]||null:null,'include':_0x215ad7[_0x3d94('0x18')]?_0x215ad7['options'][_0x3d94('0x1c')]?_[_0x3d94('0x1d')](_0x215ad7[_0x3d94('0x18')][_0x3d94('0x1c')],function(_0x782c1){return{'model':db[_0x782c1['model']],'as':_0x782c1['as'],'attributes':_0x782c1[_0x3d94('0x1a')],'include':_0x782c1[_0x3d94('0x1c')]?_[_0x3d94('0x1d')](_0x782c1[_0x3d94('0x1c')],function(_0xb493f1){return{'model':db[_0xb493f1[_0x3d94('0x1e')]],'as':_0xb493f1['as'],'attributes':_0xb493f1['attributes'],'include':_0xb493f1['include']?_[_0x3d94('0x1d')](_0xb493f1[_0x3d94('0x1c')],function(_0x1c1b25){return{'model':db[_0x1c1b25[_0x3d94('0x1e')]],'as':_0x1c1b25['as'],'attributes':_0x1c1b25[_0x3d94('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x3d94('0xb')](function(_0x2ef743){if(_0x215ad7[_0x3d94('0x18')][_0x3d94('0x22')]===!![])_0x2ef743[_0x3d94('0x23')]('smtpOptions',_0x2ef743[_0x3d94('0x24')]());logger[_0x3d94('0x13')](_0x3d94('0x21'),_0x215ad7);logger[_0x3d94('0xe')]('ShowMailAccount',_0x215ad7,JSON[_0x3d94('0x1f')](_0x2ef743));_0x246f88(_0x2ef743);})[_0x3d94('0x15')](function(_0x35e0e6){logger[_0x3d94('0x10')](_0x3d94('0x21'),_0x35e0e6['message'],_0x215ad7);_0x50560c(_0x29b1ff[_0x3d94('0x10')](0x1f4,_0x35e0e6[_0x3d94('0x12')]));});});};exports[_0x3d94('0x25')]=function(_0x485066){var _0x4eee4d=this;return new Promise(function(_0x4d8a8f,_0x47905e){var _0x3b3550={'body':_0x485066[_0x3d94('0x26')],'channel':_0x3d94('0x27')};var _0x146ccb=_[_0x3d94('0x28')](_[_0x3d94('0x29')](db[_0x3d94('0x2a')]['rawAttributes']),['createdAt',_0x3d94('0x2b'),_0x3d94('0x2c'),'ListId']);var _0x2d0aa2=![];if(_0x485066['body']['id']){delete _0x485066[_0x3d94('0x26')]['id'];}if(_[_0x3d94('0x2d')](_0x485066[_0x3d94('0x26')][_0x3d94('0x2e')])){return _0x47905e(_0x4eee4d[_0x3d94('0x10')](0x1f4,'from\x20is\x20mandatory'));}if(_[_0x3d94('0x2d')](_0x485066[_0x3d94('0x26')][_0x3d94('0x26')])||_0x485066['body'][_0x3d94('0x26')]===''){return _0x47905e(_0x4eee4d['error'](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x3d94('0x2d')](_0x485066[_0x3d94('0x26')][_0x3d94('0x2f')])){return _0x47905e(_0x4eee4d[_0x3d94('0x10')](0x1f4,'mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x146ccb));}if(!_[_0x3d94('0x30')](_0x146ccb,_0x485066['body'][_0x3d94('0x2f')])){return _0x47905e(_0x4eee4d[_0x3d94('0x10')](0x1f4,_0x3d94('0x31')+_0x146ccb));}var _0x15c8e7={};_0x15c8e7[_0x485066[_0x3d94('0x26')][_0x3d94('0x2f')]]=_0x485066[_0x3d94('0x26')]['from'];return db[_0x3d94('0x16')][_0x3d94('0x32')]({'where':{'id':_0x485066['account']['id']},'include':[{'model':db['CmList'],'as':_0x3d94('0x33'),'include':[{'model':db[_0x3d94('0x2a')],'as':'Contacts','where':_0x15c8e7,'limit':0x1,'order':[[_0x3d94('0x2b'),_0x3d94('0x34')]]}]},{'model':db[_0x3d94('0x35')],'as':_0x3d94('0x36')},{'model':db[_0x3d94('0x37')],'as':_0x3d94('0x38'),'include':[{'model':db[_0x3d94('0x39')],'as':_0x3d94('0x39')}]}]})[_0x3d94('0xb')](function(_0x2429bc){if(_0x2429bc&&_0x2429bc[_0x3d94('0x33')]){var _0x29682b=_0x2429bc[_0x3d94('0x3a')]({'plain':!![]});_0x3b3550[_0x3d94('0x3b')]=_[_0x3d94('0x3c')](_0x29682b,['Applications',_0x3d94('0x33')]);_0x3b3550[_0x3d94('0x3b')][_0x3d94('0x3d')]=_0x2429bc[_0x3d94('0x24')]();_0x3b3550[_0x3d94('0x3e')]=_0x29682b[_0x3d94('0x36')];_0x3b3550[_0x3d94('0x3f')]=_0x29682b[_0x3d94('0x33')];_0x3b3550[_0x3d94('0x3e')]=_['orderBy'](_0x3b3550[_0x3d94('0x3e')],['priority'],[_0x3d94('0x40')]);if(_0x3b3550[_0x3d94('0x3b')]&&_0x3b3550['account'][_0x3d94('0x41')]){_0x3b3550['applications']['push']({'id':0x0,'priority':_0x3b3550[_0x3d94('0x3e')]['length']+0x1,'app':_0x3d94('0x42'),'appdata':_0x3d94('0x41'),'interval':'*,*,*,*'});}if(_0x3b3550[_0x3d94('0x3b')]['Applications']){delete _0x3b3550['account'][_0x3d94('0x36')];}if(_0x3b3550[_0x3d94('0x3b')][_0x3d94('0x33')]){delete _0x3b3550[_0x3d94('0x3b')][_0x3d94('0x33')];}if(_0x29682b[_0x3d94('0x33')][_0x3d94('0x43')][_0x3d94('0x44')]){return _0x29682b[_0x3d94('0x33')]['Contacts'][0x0];}var _0x28cfbb=_[_0x3d94('0x45')](_0x485066[_0x3d94('0x26')],{'firstName':_0x485066[_0x3d94('0x26')][_0x3d94('0x2e')],'ListId':_0x29682b[_0x3d94('0x46')]});_0x28cfbb[_0x485066[_0x3d94('0x26')][_0x3d94('0x2f')]]=_0x485066[_0x3d94('0x26')][_0x3d94('0x2e')];return db[_0x3d94('0x2a')]['create'](_0x28cfbb);}else{throw new Error(_0x3d94('0x47'));}})['then'](function(_0x709841){_0x3b3550[_0x3d94('0x48')]=_0x709841;if(_0x709841){if(!_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x49')]){_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x49')]=rs[_0x3d94('0x4a')]()+'\x20'+_0x485066['body']['message'][_0x3d94('0x2e')];}var _0x4bd97c={'ContactId':_0x709841['id'],'MailAccountId':_0x485066[_0x3d94('0x3b')]['id'],'inReplyTo':_0x485066[_0x3d94('0x26')]['message'][_0x3d94('0x49')],'to':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x2e')],'cc':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['cc'],'subject':_0x485066[_0x3d94('0x26')]['message'][_0x3d94('0x4b')],'attach':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['attach'],'lastMsgAt':moment()[_0x3d94('0x4c')](_0x3d94('0x4d')),'lastMsgDirection':'in'};return db[_0x3d94('0x4e')][_0x3d94('0x32')]({'where':{'closed':![],'MailAccountId':_0x485066['account']['id']},'include':[{'model':db['MailMessage'],'as':_0x3d94('0x4f'),'attributes':[_0x3d94('0x49')],'where':{'messageId':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['inReplyTo']}}]})[_0x3d94('0xb')](function(_0x1c99d1){if(_0x1c99d1){return[_0x1c99d1,![]];}return db['MailInteraction'][_0x3d94('0x50')](_0x4bd97c)[_0x3d94('0xb')](function(_0x336e36){return[_0x336e36,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0x3d94('0x51')](function(_0x227372,_0x585531){if(_0x227372){_0x2d0aa2=_0x585531;if(!_0x585531){return _0x227372['update']({'inReplyTo':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['messageId'],'to':_0x485066['body']['message'][_0x3d94('0x2e')],'cc':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['cc'],'subject':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['subject'],'attach':_0x227372[_0x3d94('0x52')]?_0x227372[_0x3d94('0x52')]:_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x52')],'substatus':null,'substatusAt':moment()[_0x3d94('0x4c')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgAt':moment()[_0x3d94('0x4c')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'});}else{return _0x227372;}}})[_0x3d94('0xb')](function(_0x41d561){_0x3b3550[_0x3d94('0x53')]=_0x41d561[_0x3d94('0x3a')]({'plain':!![]});_0x3b3550[_0x3d94('0x53')][_0x3d94('0x54')]=_0x2d0aa2;return db['MailMessage']['create']({'body':_0x485066[_0x3d94('0x26')]['body'],'MailAccountId':_0x485066['account']['id'],'MailInteractionId':_0x41d561['id'],'direction':'in','ContactId':_0x3b3550['contact']['id'],'messageId':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x49')],'from':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x2e')],'to':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['to'],'cc':_0x485066['body'][_0x3d94('0x12')]['cc'],'subject':_0x485066['body'][_0x3d94('0x12')][_0x3d94('0x4b')],'attach':_0x485066[_0x3d94('0x26')]['message']['attach'],'Attachments':_0x485066['body'][_0x3d94('0x12')][_0x3d94('0x55')],'originTo':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x56')],'originCc':_0x485066['body']['message'][_0x3d94('0x57')],'bcc':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')]['bcc'],'ChatWebsiteId':_0x485066[_0x3d94('0x26')]['message'][_0x3d94('0x58')]||null,'originChannel':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x59')]||_0x3d94('0x5a'),'ChatOfflineMessageId':_0x485066[_0x3d94('0x26')][_0x3d94('0x12')][_0x3d94('0x5b')]||null},{'include':[{'model':db[_0x3d94('0x5c')],'as':_0x3d94('0x5d')}]});})[_0x3d94('0xb')](function(_0xe6cfd1){_0x3b3550[_0x3d94('0x12')]=_0xe6cfd1;if(_0x3b3550['interaction'][_0x3d94('0x5e')]){return db[_0x3d94('0x5f')][_0x3d94('0x32')]({'attributes':['id',_0x3d94('0x60')],'where':{'id':_0x3b3550['interaction'][_0x3d94('0x5e')]}})['then'](function(_0x4f217f){if(_0x4f217f){_0x3b3550[_0x3d94('0x3e')]['unshift']({'id':0x0,'priority':0x0,'app':_0x3d94('0x61'),'appdata':_0x4f217f[_0x3d94('0x60')]+','+(_0x3b3550['account'][_0x3d94('0x62')]||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x3d94('0x63'),_0x3d94('0x64'),_0x3b3550);});}return respondWithRpcPromise('Start','startRouting',_0x3b3550);})['then'](function(_0x833d96){_0x4d8a8f(_0x833d96);})['catch'](function(_0x5a8114){_0x47905e(_0x4eee4d[_0x3d94('0x10')](0x1f4,_0x5a8114[_0x3d94('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/mailAccount/mailAccount.socket.js b/server/api/mailAccount/mailAccount.socket.js new file mode 100644 index 0000000..394bc1e --- /dev/null +++ b/server/api/mailAccount/mailAccount.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbb72=['register','length','mailAccount:','remove','update','emit','removeListener'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xbb72,0xce));var _0x2bb7=function(_0x489fe7,_0xe66878){_0x489fe7=_0x489fe7-0x0;var _0x35c203=_0xbb72[_0x489fe7];return _0x35c203;};'use strict';var MailAccountEvents=require('./mailAccount.events');var events=['save',_0x2bb7('0x0'),_0x2bb7('0x1')];function createListener(_0x4d77a9,_0x3cc783){return function(_0x5dffa9){_0x3cc783[_0x2bb7('0x2')](_0x4d77a9,_0x5dffa9);};}function removeListener(_0x5c9ebd,_0x4975da){return function(){MailAccountEvents[_0x2bb7('0x3')](_0x5c9ebd,_0x4975da);};}exports[_0x2bb7('0x4')]=function(_0x186762){for(var _0x28445a=0x0,_0x4e512d=events[_0x2bb7('0x5')];_0x28445a<_0x4e512d;_0x28445a++){var _0x41669b=events[_0x28445a];var _0x2c57d2=createListener(_0x2bb7('0x6')+_0x41669b,_0x186762);MailAccountEvents['on'](_0x41669b,_0x2c57d2);}}; \ No newline at end of file diff --git a/server/api/mailApplication/index.js b/server/api/mailApplication/index.js new file mode 100644 index 0000000..97512b9 --- /dev/null +++ b/server/api/mailApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x02fc=['update','delete','destroy','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./mailApplication.controller','get','/:id','isAuthenticated','show','put'];(function(_0x36594d,_0x5aaa06){var _0x1b8802=function(_0x578cc9){while(--_0x578cc9){_0x36594d['push'](_0x36594d['shift']());}};_0x1b8802(++_0x5aaa06);}(_0x02fc,0x89));var _0xc02f=function(_0x5a5fa4,_0x111420){_0x5a5fa4=_0x5a5fa4-0x0;var _0x4606dd=_0x02fc[_0x5a5fa4];return _0x4606dd;};'use strict';var multer=require(_0xc02f('0x0'));var util=require(_0xc02f('0x1'));var path=require(_0xc02f('0x2'));var timeout=require(_0xc02f('0x3'));var express=require('express');var router=express[_0xc02f('0x4')]();var fs_extra=require(_0xc02f('0x5'));var auth=require(_0xc02f('0x6'));var interaction=require(_0xc02f('0x7'));var config=require(_0xc02f('0x8'));var controller=require(_0xc02f('0x9'));router[_0xc02f('0xa')](_0xc02f('0xb'),auth[_0xc02f('0xc')](),controller[_0xc02f('0xd')]);router[_0xc02f('0xe')](_0xc02f('0xb'),auth[_0xc02f('0xc')](),controller[_0xc02f('0xf')]);router[_0xc02f('0x10')](_0xc02f('0xb'),auth['isAuthenticated'](),controller[_0xc02f('0x11')]);module[_0xc02f('0x12')]=router; \ No newline at end of file diff --git a/server/api/mailApplication/mailApplication.attributes.js b/server/api/mailApplication/mailApplication.attributes.js new file mode 100644 index 0000000..3270f08 --- /dev/null +++ b/server/api/mailApplication/mailApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x816c=['INTEGER','noop','STRING','*,*,*,*','sequelize'];(function(_0x25e7ee,_0x4d8966){var _0x1251f2=function(_0x165472){while(--_0x165472){_0x25e7ee['push'](_0x25e7ee['shift']());}};_0x1251f2(++_0x4d8966);}(_0x816c,0xc7));var _0xc816=function(_0x2e1051,_0x58b01d){_0x2e1051=_0x2e1051-0x0;var _0x5aa734=_0x816c[_0x2e1051];return _0x5aa734;};'use strict';var Sequelize=require(_0xc816('0x0'));module['exports']={'priority':{'type':Sequelize[_0xc816('0x1')],'allowNull':![]},'app':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0xc816('0x2')},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize[_0xc816('0x3')]},'interval':{'type':Sequelize[_0xc816('0x3')],'defaultValue':_0xc816('0x4')}}; \ No newline at end of file diff --git a/server/api/mailApplication/mailApplication.controller.js b/server/api/mailApplication/mailApplication.controller.js new file mode 100644 index 0000000..a66fb0b --- /dev/null +++ b/server/api/mailApplication/mailApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbdb7=['update','error','stack','name','send','show','params','model','keys','MailApplication','query','filters','intersection','attributes','length','includeAll','merge','find','then','body','catch','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','fs-extra','lodash','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','end','json','offset','undefined','limit','count','status','set','Content-Range','apply','save'];(function(_0x30f030,_0xd03b7a){var _0xf7614f=function(_0x261cac){while(--_0x261cac){_0x30f030['push'](_0x30f030['shift']());}};_0xf7614f(++_0xd03b7a);}(_0xbdb7,0x12e));var _0x7bdb=function(_0x871ef5,_0x58880b){_0x871ef5=_0x871ef5-0x0;var _0x1f62ea=_0xbdb7[_0x871ef5];return _0x1f62ea;};'use strict';var emlformat=require(_0x7bdb('0x0'));var rimraf=require(_0x7bdb('0x1'));var zipdir=require(_0x7bdb('0x2'));var jsonpatch=require(_0x7bdb('0x3'));var rp=require(_0x7bdb('0x4'));var moment=require(_0x7bdb('0x5'));var BPromise=require(_0x7bdb('0x6'));var Mustache=require(_0x7bdb('0x7'));var util=require(_0x7bdb('0x8'));var path=require('path');var sox=require(_0x7bdb('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x7bdb('0xa'));var _=require(_0x7bdb('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7bdb('0xc'));var deskjs=require(_0x7bdb('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x7bdb('0xe'));var Redis=require(_0x7bdb('0xf'));var authService=require(_0x7bdb('0x10'));var qs=require(_0x7bdb('0x11'));var as=require(_0x7bdb('0x12'));var hardwareService=require(_0x7bdb('0x13'));var logger=require(_0x7bdb('0x14'))(_0x7bdb('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x7bdb('0x16'))['db'];function respondWithStatusCode(_0x25e3cb,_0x496613){_0x496613=_0x496613||0xcc;return function(_0x8d74ff){if(_0x8d74ff){return _0x25e3cb['sendStatus'](_0x496613);}return _0x25e3cb['status'](_0x496613)[_0x7bdb('0x17')]();};}function respondWithResult(_0x46dd4a,_0x4fd91a){_0x4fd91a=_0x4fd91a||0xc8;return function(_0x50eeca){if(_0x50eeca){return _0x46dd4a['status'](_0x4fd91a)[_0x7bdb('0x18')](_0x50eeca);}};}function respondWithFilteredResult(_0x195b2e,_0xe9919f){return function(_0x25d417){if(_0x25d417){var _0x31c909=typeof _0xe9919f[_0x7bdb('0x19')]===_0x7bdb('0x1a')&&typeof _0xe9919f[_0x7bdb('0x1b')]==='undefined';var _0x1c5750=_0x25d417[_0x7bdb('0x1c')];var _0x5723f4=_0x31c909?0x0:_0xe9919f[_0x7bdb('0x19')];var _0x4ffd4b=_0x31c909?_0x25d417[_0x7bdb('0x1c')]:_0xe9919f[_0x7bdb('0x19')]+_0xe9919f['limit'];var _0x3e5f8e;if(_0x4ffd4b>=_0x1c5750){_0x4ffd4b=_0x1c5750;_0x3e5f8e=0xc8;}else{_0x3e5f8e=0xce;}_0x195b2e[_0x7bdb('0x1d')](_0x3e5f8e);return _0x195b2e[_0x7bdb('0x1e')](_0x7bdb('0x1f'),_0x5723f4+'-'+_0x4ffd4b+'/'+_0x1c5750)[_0x7bdb('0x18')](_0x25d417);}return null;};}function patchUpdates(_0x5bfc35){return function(_0x49f353){try{jsonpatch[_0x7bdb('0x20')](_0x49f353,_0x5bfc35,!![]);}catch(_0xcb25f2){return BPromise['reject'](_0xcb25f2);}return _0x49f353[_0x7bdb('0x21')]();};}function saveUpdates(_0x118ea1,_0x346c72){return function(_0x3f53e7){if(_0x3f53e7){return _0x3f53e7[_0x7bdb('0x22')](_0x118ea1)['then'](function(_0x1d37ac){return _0x1d37ac;});}return null;};}function removeEntity(_0xdad53d,_0x40c447){return function(_0x3a456f){if(_0x3a456f){return _0x3a456f['destroy']()['then'](function(){_0xdad53d[_0x7bdb('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x47abaf,_0x4a9e02){return function(_0x2abef6){if(!_0x2abef6){_0x47abaf['sendStatus'](0x194);}return _0x2abef6;};}function handleError(_0x2b14bc,_0x72ba69){_0x72ba69=_0x72ba69||0x1f4;return function(_0x3ec129){logger[_0x7bdb('0x23')](_0x3ec129[_0x7bdb('0x24')]);if(_0x3ec129['name']){delete _0x3ec129[_0x7bdb('0x25')];}_0x2b14bc[_0x7bdb('0x1d')](_0x72ba69)[_0x7bdb('0x26')](_0x3ec129);};}exports[_0x7bdb('0x27')]=function(_0x371e8a,_0x2e8e65){var _0x1e9996={'raw':!![],'where':{'id':_0x371e8a[_0x7bdb('0x28')]['id']}},_0xd2d7be={};_0xd2d7be[_0x7bdb('0x29')]=_[_0x7bdb('0x2a')](db[_0x7bdb('0x2b')]['rawAttributes']);_0xd2d7be[_0x7bdb('0x2c')]=_[_0x7bdb('0x2a')](_0x371e8a[_0x7bdb('0x2c')]);_0xd2d7be[_0x7bdb('0x2d')]=_[_0x7bdb('0x2e')](_0xd2d7be['model'],_0xd2d7be[_0x7bdb('0x2c')]);_0x1e9996[_0x7bdb('0x2f')]=_[_0x7bdb('0x2e')](_0xd2d7be[_0x7bdb('0x29')],qs['fields'](_0x371e8a['query']['fields']));_0x1e9996[_0x7bdb('0x2f')]=_0x1e9996['attributes'][_0x7bdb('0x30')]?_0x1e9996['attributes']:_0xd2d7be[_0x7bdb('0x29')];if(_0x371e8a[_0x7bdb('0x2c')][_0x7bdb('0x31')]){_0x1e9996['include']=[{'all':!![]}];}_0x1e9996=_[_0x7bdb('0x32')]({},_0x1e9996,_0x371e8a['options']);return db['MailApplication'][_0x7bdb('0x33')](_0x1e9996)['then'](handleEntityNotFound(_0x2e8e65,null))[_0x7bdb('0x34')](respondWithResult(_0x2e8e65,null))['catch'](handleError(_0x2e8e65,null));};exports['update']=function(_0x206c26,_0x353b26){if(_0x206c26[_0x7bdb('0x35')]['id']){delete _0x206c26[_0x7bdb('0x35')]['id'];}return db[_0x7bdb('0x2b')][_0x7bdb('0x33')]({'where':{'id':_0x206c26['params']['id']}})[_0x7bdb('0x34')](handleEntityNotFound(_0x353b26,null))[_0x7bdb('0x34')](saveUpdates(_0x206c26[_0x7bdb('0x35')],null))[_0x7bdb('0x34')](respondWithResult(_0x353b26,null))[_0x7bdb('0x36')](handleError(_0x353b26,null));};exports[_0x7bdb('0x37')]=function(_0x228340,_0x2587af){return db[_0x7bdb('0x2b')]['find']({'where':{'id':_0x228340['params']['id']}})[_0x7bdb('0x34')](handleEntityNotFound(_0x2587af,null))[_0x7bdb('0x34')](removeEntity(_0x2587af,null))[_0x7bdb('0x36')](handleError(_0x2587af,null));}; \ No newline at end of file diff --git a/server/api/mailApplication/mailApplication.model.js b/server/api/mailApplication/mailApplication.model.js new file mode 100644 index 0000000..2c607cc --- /dev/null +++ b/server/api/mailApplication/mailApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb16c=['bluebird','request-promise','path','rimraf','../../config/environment','./mailApplication.attributes','exports','define','MailApplication','mail_applications','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger'];(function(_0x28652b,_0x1456c0){var _0x909610=function(_0x36064a){while(--_0x36064a){_0x28652b['push'](_0x28652b['shift']());}};_0x909610(++_0x1456c0);}(_0xb16c,0xc0));var _0xcb16=function(_0x58f904,_0x4d2646){_0x58f904=_0x58f904-0x0;var _0x3e35ef=_0xb16c[_0x58f904];return _0x3e35ef;};'use strict';var _=require(_0xcb16('0x0'));var util=require(_0xcb16('0x1'));var logger=require(_0xcb16('0x2'))('api');var moment=require('moment');var BPromise=require(_0xcb16('0x3'));var rp=require(_0xcb16('0x4'));var fs=require('fs');var path=require(_0xcb16('0x5'));var rimraf=require(_0xcb16('0x6'));var config=require(_0xcb16('0x7'));var attributes=require(_0xcb16('0x8'));module[_0xcb16('0x9')]=function(_0x3b2036,_0x1a4db5){return _0x3b2036[_0xcb16('0xa')](_0xcb16('0xb'),attributes,{'tableName':_0xcb16('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':_0xcb16('0xd'),'collate':_0xcb16('0xe')});}; \ No newline at end of file diff --git a/server/api/mailApplication/mailApplication.rpc.js b/server/api/mailApplication/mailApplication.rpc.js new file mode 100644 index 0000000..d48e3a6 --- /dev/null +++ b/server/api/mailApplication/mailApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3ba7=['jayson/promise','client','http','request','then','info','MailApplication,\x20%s,\x20%s','debug','MailApplication,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','UpdateMailApplication','MailApplication','update','body','options','where','attributes','limit','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment'];(function(_0x1ee15d,_0x51813e){var _0xef4846=function(_0x3abc0f){while(--_0x3abc0f){_0x1ee15d['push'](_0x1ee15d['shift']());}};_0xef4846(++_0x51813e);}(_0x3ba7,0x16c));var _0x73ba=function(_0x276ca2,_0x95cdee){_0x276ca2=_0x276ca2-0x0;var _0x1ca2c9=_0x3ba7[_0x276ca2];return _0x1ca2c9;};'use strict';var _=require(_0x73ba('0x0'));var util=require(_0x73ba('0x1'));var moment=require(_0x73ba('0x2'));var BPromise=require(_0x73ba('0x3'));var rs=require(_0x73ba('0x4'));var fs=require('fs');var Redis=require(_0x73ba('0x5'));var db=require(_0x73ba('0x6'))['db'];var utils=require(_0x73ba('0x7'));var logger=require(_0x73ba('0x8'))('rpc');var config=require(_0x73ba('0x9'));var jayson=require(_0x73ba('0xa'));var client=jayson[_0x73ba('0xb')][_0x73ba('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x376f8a,_0x3437b3,_0x28ac82){return new BPromise(function(_0x543d2a,_0x169e36){return client[_0x73ba('0xd')](_0x376f8a,_0x28ac82)[_0x73ba('0xe')](function(_0x29033f){logger[_0x73ba('0xf')](_0x73ba('0x10'),_0x3437b3,'request\x20sent');logger[_0x73ba('0x11')](_0x73ba('0x12'),_0x3437b3,_0x73ba('0x13'),JSON[_0x73ba('0x14')](_0x29033f));if(_0x29033f[_0x73ba('0x15')]){if(_0x29033f[_0x73ba('0x15')][_0x73ba('0x16')]===0x1f4){logger[_0x73ba('0x15')]('MailApplication,\x20%s,\x20%s',_0x3437b3,_0x29033f['error'][_0x73ba('0x17')]);return _0x169e36(_0x29033f['error'][_0x73ba('0x17')]);}logger[_0x73ba('0x15')](_0x73ba('0x10'),_0x3437b3,_0x29033f[_0x73ba('0x15')][_0x73ba('0x17')]);return _0x543d2a(_0x29033f[_0x73ba('0x15')][_0x73ba('0x17')]);}else{logger[_0x73ba('0xf')](_0x73ba('0x10'),_0x3437b3,'request\x20sent');_0x543d2a(_0x29033f[_0x73ba('0x18')][_0x73ba('0x17')]);}})[_0x73ba('0x19')](function(_0xf6cfaf){logger['error'](_0x73ba('0x10'),_0x3437b3,_0xf6cfaf);_0x169e36(_0xf6cfaf);});});}exports[_0x73ba('0x1a')]=function(_0xefeb93){var _0x411c0e=this;return new Promise(function(_0x4cebc6,_0x4aef21){return db[_0x73ba('0x1b')][_0x73ba('0x1c')](_0xefeb93[_0x73ba('0x1d')],{'raw':_0xefeb93['options']?_0xefeb93['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xefeb93[_0x73ba('0x1e')]?_0xefeb93[_0x73ba('0x1e')][_0x73ba('0x1f')]||null:null,'attributes':_0xefeb93['options']?_0xefeb93[_0x73ba('0x1e')][_0x73ba('0x20')]||null:null,'limit':_0xefeb93[_0x73ba('0x1e')]?_0xefeb93[_0x73ba('0x1e')][_0x73ba('0x21')]||null:null})[_0x73ba('0xe')](function(_0x3023aa){logger['info']('UpdateMailApplication',_0xefeb93);logger['debug']('UpdateMailApplication',_0xefeb93,JSON[_0x73ba('0x14')](_0x3023aa));_0x4cebc6(_0x3023aa);})[_0x73ba('0x19')](function(_0x79d923){logger[_0x73ba('0x15')](_0x73ba('0x1a'),_0x79d923[_0x73ba('0x17')],_0xefeb93);_0x4aef21(_0x411c0e[_0x73ba('0x15')](0x1f4,_0x79d923['message']));});});}; \ No newline at end of file diff --git a/server/api/mailInteraction/index.js b/server/api/mailInteraction/index.js new file mode 100644 index 0000000..fc5b4d4 --- /dev/null +++ b/server/api/mailInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2432=['get','isAuthenticated','index','show','getMessages','/:id/download','download','post','create','/:id/messages','addMessage','/:id/tags','mail','mailinteraction:addtags','addTags','put','tracked','mailinteraction:update','update','delete','/:id','mailinteraction:destroy','destroy','exports','express','Router','../../components/auth/service','../../components/interaction/service','./mailInteraction.controller'];(function(_0x7ac046,_0x3a1e11){var _0x4b6cc6=function(_0x1eb088){while(--_0x1eb088){_0x7ac046['push'](_0x7ac046['shift']());}};_0x4b6cc6(++_0x3a1e11);}(_0x2432,0x100));var _0x2243=function(_0x4debf3,_0x3abfaf){_0x4debf3=_0x4debf3-0x0;var _0x5a4b30=_0x2432[_0x4debf3];return _0x5a4b30;};'use strict';var express=require(_0x2243('0x0'));var router=express[_0x2243('0x1')]();var auth=require(_0x2243('0x2'));var interaction=require(_0x2243('0x3'));var controller=require(_0x2243('0x4'));router[_0x2243('0x5')]('/',auth[_0x2243('0x6')](),controller[_0x2243('0x7')]);router[_0x2243('0x5')]('/describe',auth[_0x2243('0x6')](),controller['describe']);router[_0x2243('0x5')]('/:id',auth[_0x2243('0x6')](),controller[_0x2243('0x8')]);router[_0x2243('0x5')]('/:id/messages',auth['isAuthenticated'](),controller[_0x2243('0x9')]);router[_0x2243('0x5')](_0x2243('0xa'),auth[_0x2243('0x6')](),controller[_0x2243('0xb')]);router[_0x2243('0xc')]('/',auth[_0x2243('0x6')](),controller[_0x2243('0xd')]);router[_0x2243('0xc')](_0x2243('0xe'),auth[_0x2243('0x6')](),controller[_0x2243('0xf')]);router[_0x2243('0xc')](_0x2243('0x10'),auth[_0x2243('0x6')](),interaction['tracked'](_0x2243('0x11'),_0x2243('0x12')),controller[_0x2243('0x13')]);router[_0x2243('0x14')]('/:id',auth['isAuthenticated'](),interaction[_0x2243('0x15')](_0x2243('0x11'),_0x2243('0x16')),controller[_0x2243('0x17')]);router[_0x2243('0x18')](_0x2243('0x19'),auth[_0x2243('0x6')](),interaction[_0x2243('0x15')](_0x2243('0x11'),_0x2243('0x1a')),controller[_0x2243('0x1b')]);router[_0x2243('0x18')](_0x2243('0x10'),auth['isAuthenticated'](),controller['removeTags']);module[_0x2243('0x1c')]=router; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.attributes.js b/server/api/mailInteraction/mailInteraction.attributes.js new file mode 100644 index 0000000..152f199 --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c61=['TEXT','long','ENUM','out','sequelize','iconv','BOOLEAN','DATE','STRING'];(function(_0x3108d8,_0x5162a8){var _0xdecb89=function(_0x359900){while(--_0x359900){_0x3108d8['push'](_0x3108d8['shift']());}};_0xdecb89(++_0x5162a8);}(_0x4c61,0xca));var _0x14c6=function(_0x2d5643,_0x2d13f2){_0x2d5643=_0x2d5643-0x0;var _0x2e42cf=_0x4c61[_0x2d5643];return _0x2e42cf;};'use strict';var Sequelize=require(_0x14c6('0x0'));var iconv=require(_0x14c6('0x1'));module['exports']={'closed':{'type':Sequelize[_0x14c6('0x2')],'defaultValue':![]},'closedAt':{'type':Sequelize[_0x14c6('0x3')]},'disposition':{'type':Sequelize['STRING']},'secondDisposition':{'type':Sequelize['STRING']},'thirdDisposition':{'type':Sequelize['STRING']},'note':{'type':Sequelize['STRING']},'inReplyTo':{'type':Sequelize[_0x14c6('0x4')](0x1fe)},'to':{'type':Sequelize['STRING']},'cc':{'type':Sequelize[_0x14c6('0x5')](_0x14c6('0x6'))},'subject':{'type':Sequelize[_0x14c6('0x5')]()},'attach':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'read1stAt':{'type':Sequelize[_0x14c6('0x3')]},'substatus':{'type':Sequelize[_0x14c6('0x4')](0x3c)},'substatusAt':{'type':Sequelize['DATE']},'firstMsgDirection':{'type':Sequelize[_0x14c6('0x7')]('in',_0x14c6('0x8')),'defaultValue':'in','allowNull':![]},'lastMsgAt':{'type':Sequelize[_0x14c6('0x3')]},'lastMsgDirection':{'type':Sequelize[_0x14c6('0x7')]('in',_0x14c6('0x8')),'defaultValue':'in','allowNull':![]},'autoreplyExecuted':{'type':Sequelize[_0x14c6('0x2')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.controller.js b/server/api/mailInteraction/mailInteraction.controller.js new file mode 100644 index 0000000..8aa2882 --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xecc5=['join','root','server','files','attachments','transcript-%d-%s.zip','Attachment','Attachments','Messages','bcc','subject','createdAt','get','mkdirSync','each','missing.recipient@your.company.com','decode','headers','Bcc','basename','existsSync','readFileSync','writeFileSync','unlinkSync','rimraf','zip-dir','moment','bluebird','util','path','juice','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','html-entities','redis','register','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','json','then','destroy','stack','name','send','map','rawAttributes','type','key','findAll','mail','query','user','catch','params','model','MailInteraction','keys','filters','intersection','attributes','fields','length','includeAll','include','merge','options','create','body','update','find','describe','addMessage','MailMessage','ids','omit','findOne','hasOwnProperty','nolimit','order','sort','pick','MailInteractionId','where','filter','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','inlineCss','true','rows','setTags','spread','Tag','color','emit','removeTags','download','unix'];(function(_0x2822f6,_0x484293){var _0x3ff9d2=function(_0x5893ab){while(--_0x5893ab){_0x2822f6['push'](_0x2822f6['shift']());}};_0x3ff9d2(++_0x484293);}(_0xecc5,0xf4));var _0x5ecc=function(_0x18fb96,_0x37ca7e){_0x18fb96=_0x18fb96-0x0;var _0x59f3b2=_0xecc5[_0x18fb96];return _0x59f3b2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5ecc('0x0'));var zipdir=require(_0x5ecc('0x1'));var moment=require(_0x5ecc('0x2'));var BPromise=require(_0x5ecc('0x3'));var util=require(_0x5ecc('0x4'));var path=require(_0x5ecc('0x5'));var fs=require('fs');var _=require('lodash');var juice=require(_0x5ecc('0x6'));var Redis=require(_0x5ecc('0x7'));var interaction=require(_0x5ecc('0x8'));var qs=require(_0x5ecc('0x9'));var logger=require(_0x5ecc('0xa'))(_0x5ecc('0xb'));var config=require(_0x5ecc('0xc'));var db=require('../../mysqldb')['db'];var htmlEntities=require(_0x5ecc('0xd'));config[_0x5ecc('0xe')]=_['defaults'](config[_0x5ecc('0xe')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5ecc('0xe')]));require('./mailInteraction.socket')[_0x5ecc('0xf')](socket);function respondWithStatusCode(_0x47375f,_0x29fcd7){_0x29fcd7=_0x29fcd7||0xcc;return function(_0x1f3185){if(_0x1f3185){return _0x47375f[_0x5ecc('0x10')](_0x29fcd7);}return _0x47375f[_0x5ecc('0x11')](_0x29fcd7)[_0x5ecc('0x12')]();};}function respondWithResult(_0x30e498,_0x86c25d){_0x86c25d=_0x86c25d||0xc8;return function(_0x355cbe){if(_0x355cbe){return _0x30e498[_0x5ecc('0x11')](_0x86c25d)['json'](_0x355cbe);}};}function respondWithFilteredResult(_0x4ee809,_0x48bee8){return function(_0x3b783e){if(_0x3b783e){var _0x261210=typeof _0x48bee8[_0x5ecc('0x13')]===_0x5ecc('0x14')&&typeof _0x48bee8['limit']===_0x5ecc('0x14');var _0x482504=_0x3b783e[_0x5ecc('0x15')];var _0x5630c4=_0x261210?0x0:_0x48bee8[_0x5ecc('0x13')];var _0x1f5e31=_0x261210?_0x3b783e[_0x5ecc('0x15')]:_0x48bee8[_0x5ecc('0x13')]+_0x48bee8[_0x5ecc('0x16')];var _0x4a1d17;if(_0x1f5e31>=_0x482504){_0x1f5e31=_0x482504;_0x4a1d17=0xc8;}else{_0x4a1d17=0xce;}_0x4ee809[_0x5ecc('0x11')](_0x4a1d17);return _0x4ee809[_0x5ecc('0x17')](_0x5ecc('0x18'),_0x5630c4+'-'+_0x1f5e31+'/'+_0x482504)[_0x5ecc('0x19')](_0x3b783e);}return null;};}function saveUpdates(_0x39f850){return function(_0x26a77b){if(_0x26a77b){return _0x26a77b['update'](_0x39f850)[_0x5ecc('0x1a')](function(_0x1462ec){return _0x1462ec;});}return null;};}function removeEntity(_0x483b45){return function(_0x81fe18){if(_0x81fe18){return _0x81fe18[_0x5ecc('0x1b')]()['then'](function(){_0x483b45[_0x5ecc('0x11')](0xcc)[_0x5ecc('0x12')]();});}};}function handleEntityNotFound(_0x21520e){return function(_0x11a4ca){if(!_0x11a4ca){_0x21520e['sendStatus'](0x194);}return _0x11a4ca;};}function handleError(_0x35b042,_0xb85e65){_0xb85e65=_0xb85e65||0x1f4;return function(_0x4d1fe5){logger['error'](_0x4d1fe5[_0x5ecc('0x1c')]);if(_0x4d1fe5[_0x5ecc('0x1d')]){delete _0x4d1fe5[_0x5ecc('0x1d')];}_0x35b042['status'](_0xb85e65)[_0x5ecc('0x1e')](_0x4d1fe5);};}exports['index']=function(_0x1cf45d,_0x136329){var _0x5f0013={};var _0x4f2655=_[_0x5ecc('0x1f')](db['MailInteraction'][_0x5ecc('0x20')],function(_0x2db954){return{'name':_0x2db954['fieldName'],'type':_0x2db954[_0x5ecc('0x21')][_0x5ecc('0x22')]};});_0x5f0013=qs['getOptions'](_0x4f2655,_0x1cf45d);return interaction[_0x5ecc('0x23')](_0x5ecc('0x24'),_0x1cf45d[_0x5ecc('0x25')],_0x1cf45d[_0x5ecc('0x26')],_0x5f0013,_0x4f2655)['then'](respondWithFilteredResult(_0x136329,_0x5f0013))[_0x5ecc('0x27')](handleError(_0x136329,null));};exports['show']=function(_0x44665d,_0x1e301c){var _0xb740df={'raw':![],'where':{'id':_0x44665d[_0x5ecc('0x28')]['id']}},_0x2bfd24={};_0x2bfd24[_0x5ecc('0x29')]=_['keys'](db[_0x5ecc('0x2a')][_0x5ecc('0x20')]);_0x2bfd24[_0x5ecc('0x25')]=_[_0x5ecc('0x2b')](_0x44665d[_0x5ecc('0x25')]);_0x2bfd24[_0x5ecc('0x2c')]=_[_0x5ecc('0x2d')](_0x2bfd24[_0x5ecc('0x29')],_0x2bfd24[_0x5ecc('0x25')]);_0xb740df[_0x5ecc('0x2e')]=_[_0x5ecc('0x2d')](_0x2bfd24[_0x5ecc('0x29')],qs[_0x5ecc('0x2f')](_0x44665d['query'][_0x5ecc('0x2f')]));_0xb740df[_0x5ecc('0x2e')]=_0xb740df[_0x5ecc('0x2e')][_0x5ecc('0x30')]?_0xb740df['attributes']:_0x2bfd24['model'];if(_0x44665d['query'][_0x5ecc('0x31')]){_0xb740df[_0x5ecc('0x32')]=[{'all':!![]}];}_0xb740df=_[_0x5ecc('0x33')]({},_0xb740df,_0x44665d[_0x5ecc('0x34')]);return db['MailInteraction']['find'](_0xb740df)[_0x5ecc('0x1a')](handleEntityNotFound(_0x1e301c,null))[_0x5ecc('0x1a')](respondWithResult(_0x1e301c,null))[_0x5ecc('0x27')](handleError(_0x1e301c,null));};exports[_0x5ecc('0x35')]=function(_0x1224ff,_0x2221f6){return db[_0x5ecc('0x2a')][_0x5ecc('0x35')](_0x1224ff[_0x5ecc('0x36')],{})['then'](respondWithResult(_0x2221f6,0xc9))['catch'](handleError(_0x2221f6,null));};exports[_0x5ecc('0x37')]=function(_0x4de4f1,_0x2f139b){if(_0x4de4f1['body']['id']){delete _0x4de4f1[_0x5ecc('0x36')]['id'];}return db[_0x5ecc('0x2a')][_0x5ecc('0x38')]({'where':{'id':_0x4de4f1[_0x5ecc('0x28')]['id']}})[_0x5ecc('0x1a')](handleEntityNotFound(_0x2f139b,null))[_0x5ecc('0x1a')](saveUpdates(_0x4de4f1[_0x5ecc('0x36')],null))[_0x5ecc('0x1a')](respondWithResult(_0x2f139b,null))[_0x5ecc('0x27')](handleError(_0x2f139b,null));};exports[_0x5ecc('0x1b')]=function(_0x12d760,_0x4907bd){return db[_0x5ecc('0x2a')]['find']({'where':{'id':_0x12d760[_0x5ecc('0x28')]['id']}})[_0x5ecc('0x1a')](handleEntityNotFound(_0x4907bd,null))[_0x5ecc('0x1a')](removeEntity(_0x4907bd,null))['catch'](handleError(_0x4907bd,null));};exports['describe']=function(_0x3579f7,_0x5f47c9){return db[_0x5ecc('0x2a')][_0x5ecc('0x39')]()[_0x5ecc('0x1a')](respondWithResult(_0x5f47c9,null))['catch'](handleError(_0x5f47c9,null));};exports[_0x5ecc('0x3a')]=function(_0x1fa73a,_0x3a4afd){return db[_0x5ecc('0x3b')][_0x5ecc('0x38')]({'where':{'id':_0x1fa73a[_0x5ecc('0x28')]['id']}})[_0x5ecc('0x1a')](handleEntityNotFound(_0x3a4afd,null))[_0x5ecc('0x1a')](function(_0x424fcb){if(_0x424fcb){return _0x424fcb[_0x5ecc('0x3a')](_0x1fa73a[_0x5ecc('0x36')][_0x5ecc('0x3c')],_[_0x5ecc('0x3d')](_0x1fa73a[_0x5ecc('0x36')],[_0x5ecc('0x3c'),'id'])||{});}})[_0x5ecc('0x1a')](respondWithResult(_0x3a4afd,null))[_0x5ecc('0x27')](handleError(_0x3a4afd,null));};exports['getMessages']=function(_0x2c933b,_0x42a6f5){var _0x16d903={'raw':![],'where':{}};var _0x57dc08={};var _0x550b3f={'count':0x0,'rows':[]};return db['MailInteraction'][_0x5ecc('0x3e')]({'where':{'id':_0x2c933b[_0x5ecc('0x28')]['id']}})['then'](handleEntityNotFound(_0x42a6f5,null))[_0x5ecc('0x1a')](function(_0x4f3059){if(_0x4f3059){_0x57dc08[_0x5ecc('0x29')]=_[_0x5ecc('0x2b')](db[_0x5ecc('0x3b')][_0x5ecc('0x20')]);_0x57dc08[_0x5ecc('0x25')]=_[_0x5ecc('0x2b')](_0x2c933b[_0x5ecc('0x25')]);_0x57dc08[_0x5ecc('0x2c')]=_['intersection'](_0x57dc08['model'],_0x57dc08[_0x5ecc('0x25')]);_0x16d903['attributes']=_[_0x5ecc('0x2d')](_0x57dc08[_0x5ecc('0x29')],qs[_0x5ecc('0x2f')](_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x2f')]));_0x16d903[_0x5ecc('0x2e')]=_0x16d903['attributes'][_0x5ecc('0x30')]?_0x16d903[_0x5ecc('0x2e')]:_0x57dc08['model'];if(!_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x3f')](_0x5ecc('0x40'))){_0x16d903[_0x5ecc('0x16')]=qs[_0x5ecc('0x16')](_0x2c933b[_0x5ecc('0x25')]['limit']);_0x16d903[_0x5ecc('0x13')]=qs[_0x5ecc('0x13')](_0x2c933b[_0x5ecc('0x25')]['offset']);}_0x16d903[_0x5ecc('0x41')]=qs[_0x5ecc('0x42')](_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x42')]);_0x16d903['where']=qs[_0x5ecc('0x2c')](_[_0x5ecc('0x43')](_0x2c933b[_0x5ecc('0x25')],_0x57dc08[_0x5ecc('0x2c')]));_0x16d903['where'][_0x5ecc('0x44')]=_0x4f3059['id'];if(_0x2c933b[_0x5ecc('0x25')]['filter']){_0x16d903[_0x5ecc('0x45')]=_[_0x5ecc('0x33')](_0x16d903[_0x5ecc('0x45')],{'$or':_[_0x5ecc('0x1f')](_0x16d903[_0x5ecc('0x2e')],function(_0x53e160){var _0x10f3f7={};_0x10f3f7[_0x53e160]={'$like':'%'+_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x46')]+'%'};return _0x10f3f7;})});}if(_0x2c933b['query'][_0x5ecc('0x47')]){var _0x16d7e0=_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x47')][_0x5ecc('0x48')](',');var _0x5e12be={};_0x5e12be[_0x16d7e0[0x0]]={'$gte':moment(_0x16d7e0[0x1])[_0x5ecc('0x49')](_0x5ecc('0x4a'))};_0x16d903[_0x5ecc('0x45')]=_['merge'](_0x16d903['where'],_0x5e12be);}_0x16d903=_[_0x5ecc('0x33')]({},_0x16d903,_0x2c933b['options']);return db['MailMessage'][_0x5ecc('0x15')]({'where':_0x16d903['where']})[_0x5ecc('0x1a')](function(_0x257681){_0x550b3f['count']=_0x257681;if(_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x31')]){_0x16d903[_0x5ecc('0x32')]=[{'all':!![]}];}return db[_0x5ecc('0x3b')][_0x5ecc('0x23')](_0x16d903);})[_0x5ecc('0x1a')](function(_0xb268b1){if(_0x2c933b[_0x5ecc('0x25')][_0x5ecc('0x4b')]===_0x5ecc('0x4c')){for(var _0x3fe276=0x0;_0x3fe276<_0xb268b1[_0x5ecc('0x30')];_0x3fe276++){_0xb268b1[_0x3fe276][_0x5ecc('0x36')]=juice(_0xb268b1[_0x3fe276][_0x5ecc('0x36')]);}}_0x550b3f[_0x5ecc('0x4d')]=_0xb268b1;return _0x550b3f;});}})[_0x5ecc('0x1a')](respondWithFilteredResult(_0x42a6f5,_0x16d903))['catch'](handleError(_0x42a6f5,null));};exports['addTags']=function(_0x47dce2,_0x1c0338){return db[_0x5ecc('0x2a')][_0x5ecc('0x38')]({'where':{'id':_0x47dce2[_0x5ecc('0x28')]['id']}})[_0x5ecc('0x1a')](handleEntityNotFound(_0x1c0338,null))[_0x5ecc('0x1a')](function(_0x15f383){if(_0x15f383){return _0x15f383[_0x5ecc('0x4e')](_0x47dce2[_0x5ecc('0x36')][_0x5ecc('0x3c')],_['omit'](_0x47dce2[_0x5ecc('0x36')],[_0x5ecc('0x3c'),'id'])||{})[_0x5ecc('0x4f')](function(){return db[_0x5ecc('0x50')][_0x5ecc('0x23')]({'attributes':['id',_0x5ecc('0x1d'),_0x5ecc('0x51')],'where':{'id':_0x47dce2[_0x5ecc('0x36')][_0x5ecc('0x3c')]}});})[_0x5ecc('0x1a')](function(_0x270049){socket[_0x5ecc('0x52')]('mailInteractionTags:save',{'id':Number(_0x47dce2['params']['id']),'tags':_0x270049||[]});return{'id':Number(_0x47dce2[_0x5ecc('0x28')]['id']),'tags':_0x270049||[]};});}})['then'](respondWithResult(_0x1c0338,null))[_0x5ecc('0x27')](handleError(_0x1c0338,null));};exports[_0x5ecc('0x53')]=function(_0x2c6f8f,_0x1396cc){return db[_0x5ecc('0x2a')][_0x5ecc('0x38')]({'where':{'id':_0x2c6f8f[_0x5ecc('0x28')]['id']}})[_0x5ecc('0x1a')](handleEntityNotFound(_0x1396cc,null))[_0x5ecc('0x1a')](function(_0x3baa64){if(_0x3baa64){return _0x3baa64[_0x5ecc('0x53')](_0x2c6f8f[_0x5ecc('0x25')][_0x5ecc('0x3c')]);}})[_0x5ecc('0x1a')](respondWithStatusCode(_0x1396cc,null))[_0x5ecc('0x27')](handleError(_0x1396cc,null));};exports[_0x5ecc('0x54')]=function(_0x81741d,_0x31022c){var _0x52e5b5=moment()[_0x5ecc('0x55')]()['toString']();var _0x519396=path[_0x5ecc('0x56')](config[_0x5ecc('0x57')],_0x5ecc('0x58'),_0x5ecc('0x59'),'tmp');var _0x435020=path['join'](config['root'],_0x5ecc('0x58'),_0x5ecc('0x59'),_0x5ecc('0x5a'));var _0x2f623b=path[_0x5ecc('0x56')](_0x519396,_0x52e5b5);var _0x2fa2ad=util['format'](_0x5ecc('0x5b'),_0x81741d['params']['id'],_0x52e5b5);var _0x55038b=path[_0x5ecc('0x56')](_0x519396,_0x2fa2ad);var _0x67f422=[];if(_0x81741d['query']['attachments']){_0x67f422['push']({'model':db[_0x5ecc('0x5c')],'as':_0x5ecc('0x5d'),'raw':!![]});}var _0x31d251=[{'model':db[_0x5ecc('0x3b')],'as':_0x5ecc('0x5e'),'attributes':['id','body','from','to','cc',_0x5ecc('0x5f'),_0x5ecc('0x60'),_0x5ecc('0x61')],'where':{'secret':![]},'order':qs[_0x5ecc('0x42')]('id'),'include':_0x67f422}];return db[_0x5ecc('0x2a')][_0x5ecc('0x38')]({'where':{'id':_0x81741d[_0x5ecc('0x28')]['id']},'include':_0x31d251})['then'](handleEntityNotFound(_0x31022c,null))[_0x5ecc('0x1a')](function(_0x380919){if(_0x380919&&_0x380919[_0x5ecc('0x5e')]){var _0x363eea=_0x380919[_0x5ecc('0x62')]({'plain':!![]});fs[_0x5ecc('0x63')](_0x2f623b);return BPromise[_0x5ecc('0x64')](_0x363eea[_0x5ecc('0x5e')],function(_0x3eadef,_0x21cfa8){var _0xf47aea={'from':_0x3eadef['from'],'to':_0x3eadef['to']||_0x5ecc('0x65'),'subject':_0x3eadef[_0x5ecc('0x60')],'html':htmlEntities[_0x5ecc('0x66')](_0x3eadef['body']),'headers':{'Date':moment(_0x3eadef['createdAt'])[_0x5ecc('0x49')]('ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ')},'attachments':[]};if(_0x3eadef['cc']){_0xf47aea[_0x5ecc('0x67')]['Cc']=_0x3eadef['cc'];}if(_0x3eadef['bcc']){_0xf47aea[_0x5ecc('0x67')][_0x5ecc('0x68')]=_0x3eadef[_0x5ecc('0x5f')];}return new BPromise(function(_0x3f94f5,_0x203edd){if(_0x3eadef[_0x5ecc('0x5d')]){for(var _0xe1e8fb=0x0;_0xe1e8fb<_0x3eadef[_0x5ecc('0x5d')][_0x5ecc('0x30')];_0xe1e8fb++){var _0x408935=_0x3eadef['Attachments'][_0xe1e8fb];var _0x82e1fc=path['join'](_0x435020,_0x408935[_0x5ecc('0x69')]);if(fs[_0x5ecc('0x6a')](_0x82e1fc)){_0xf47aea[_0x5ecc('0x5a')]['push']({'name':_0x408935['name'],'contentType':_0x408935[_0x5ecc('0x21')],'data':fs[_0x5ecc('0x6b')](_0x82e1fc)});}}}emlformat['build'](_0xf47aea,function(_0x12c428,_0x43bcd5){if(_0x12c428)return _0x203edd(_0x12c428);fs[_0x5ecc('0x6c')](path[_0x5ecc('0x56')](_0x2f623b,util['format']('message%d.eml',_0x21cfa8)),_0x43bcd5);return _0x3f94f5(_0x43bcd5);});});})['then'](function(){return new BPromise(function(_0x15c562,_0x4c33f2){zipdir(_0x2f623b,{'saveTo':_0x55038b},function(_0x4ac132,_0x2a076e){if(_0x4ac132)return _0x4c33f2(_0x4ac132);return _0x15c562(_0x2a076e);});})[_0x5ecc('0x1a')](function(){return new BPromise(function(_0x16ef07,_0x28da1e){rimraf(_0x2f623b,function(_0x10e816){if(_0x10e816)_0x28da1e(_0x10e816);return _0x16ef07();});});})[_0x5ecc('0x1a')](function(){return _0x31022c[_0x5ecc('0x54')](_0x55038b,_0x2fa2ad,function(_0x4296da){if(!_0x4296da)fs[_0x5ecc('0x6d')](_0x55038b);});});});}else{return _0x31022c[_0x5ecc('0x10')](0xc8);}})[_0x5ecc('0x27')](handleError(_0x31022c,null));}; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.events.js b/server/api/mailInteraction/mailInteraction.events.js new file mode 100644 index 0000000..62ea5de --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3ce4=['MailInteraction','MailMessage','save','update','setDataValue','Users','map','findAll','then','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb'];(function(_0x1b0011,_0x403cc8){var _0x29b74c=function(_0x1edb84){while(--_0x1edb84){_0x1b0011['push'](_0x1b0011['shift']());}};_0x29b74c(++_0x403cc8);}(_0x3ce4,0x1a7));var _0x43ce=function(_0x20ef64,_0x4a8fe9){_0x20ef64=_0x20ef64-0x0;var _0x3707d8=_0x3ce4[_0x20ef64];return _0x3707d8;};'use strict';var EventEmitter=require(_0x43ce('0x0'));var MailInteraction=require(_0x43ce('0x1'))['db'][_0x43ce('0x2')];var MailMessage=require(_0x43ce('0x1'))['db'][_0x43ce('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x43ce('0x4'),'afterUpdate':_0x43ce('0x5'),'afterDestroy':'remove'};function emitEvent(_0x2882f6){return function(_0x180047,_0x48c397,_0x55e487){_0x180047['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x53615f){_0x180047[_0x43ce('0x6')](_0x43ce('0x7'),_0x53615f[_0x43ce('0x8')](function(_0x4d10fb){return{'id':_0x4d10fb['id']};}));return MailMessage[_0x43ce('0x9')]({'where':{'MailInteractionId':_0x180047['id'],'direction':'in','read':![]},'raw':!![]});})[_0x43ce('0xa')](function(_0x5d2f60){_0x180047['setDataValue']('unreadMessages',_0x5d2f60[_0x43ce('0xb')]);MailInteractionEvents[_0x43ce('0xc')](_0x2882f6+':'+_0x180047['id'],_0x180047);MailInteractionEvents['emit'](_0x2882f6,_0x180047);_0x55e487(null);})[_0x43ce('0xd')](_0x55e487(null));};}for(var e in events){if(events[_0x43ce('0xe')](e)){var event=events[e];MailInteraction[_0x43ce('0xf')](e,emitEvent(event));}}module[_0x43ce('0x10')]=MailInteractionEvents; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.model.js b/server/api/mailInteraction/mailInteraction.model.js new file mode 100644 index 0000000..ae5ff55 --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9b30=['then','catch','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','./mailInteraction.attributes','exports','define','mail_interactions','fti_mail_interactions','subject','FULLTEXT','substatus','substatusAt','format','YYYY-MM-DD\x20HH:mm:ss','closed','closedAt','changed','models','get','update'];(function(_0x565de0,_0x48c769){var _0xfe99c8=function(_0x8a8e){while(--_0x8a8e){_0x565de0['push'](_0x565de0['shift']());}};_0xfe99c8(++_0x48c769);}(_0x9b30,0x19a));var _0x09b3=function(_0x27af45,_0x1b57aa){_0x27af45=_0x27af45-0x0;var _0x18df21=_0x9b30[_0x27af45];return _0x18df21;};'use strict';var _=require('lodash');var util=require(_0x09b3('0x0'));var logger=require(_0x09b3('0x1'))(_0x09b3('0x2'));var moment=require(_0x09b3('0x3'));var BPromise=require(_0x09b3('0x4'));var rp=require(_0x09b3('0x5'));var fs=require('fs');var path=require(_0x09b3('0x6'));var rimraf=require(_0x09b3('0x7'));var config=require('../../config/environment');var attributes=require(_0x09b3('0x8'));module[_0x09b3('0x9')]=function(_0x5bec09,_0x2f2e1a){return _0x5bec09[_0x09b3('0xa')]('MailInteraction',attributes,{'tableName':_0x09b3('0xb'),'paranoid':![],'indexes':[{'name':_0x09b3('0xc'),'fields':[_0x09b3('0xd'),'to'],'type':_0x09b3('0xe')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x8828ea,_0x4fd28d,_0x2b7f00){if(_0x8828ea[_0x09b3('0xf')]){_0x8828ea[_0x09b3('0x10')]=moment()[_0x09b3('0x11')](_0x09b3('0x12'));}if(_0x8828ea[_0x09b3('0x13')]){_0x8828ea[_0x09b3('0x14')]=moment()['format'](_0x09b3('0x12'));}_0x2b7f00(null,_0x4fd28d);},'beforeUpdate':function(_0x390821,_0xa9f179,_0x3d0cf8){if(_0x390821[_0x09b3('0x15')](_0x09b3('0xf'))){_0x390821[_0x09b3('0x10')]=_0x390821[_0x09b3('0xf')]?moment()[_0x09b3('0x11')](_0x09b3('0x12')):null;}if(_0x390821[_0x09b3('0x15')](_0x09b3('0x13'))){_0x390821['closedAt']=moment()[_0x09b3('0x11')](_0x09b3('0x12'));_0x390821['substatus']=null;_0x390821[_0x09b3('0x10')]=null;}_0x3d0cf8(null,_0x390821);},'afterUpdate':function(_0x22411e,_0x626b07,_0x4ad2b2){var _0x8432e2=_0x5bec09[_0x09b3('0x16')];var _0x1f4802=_0x22411e[_0x09b3('0x17')]({'plain':!![]});if(_0x1f4802['closed']){return _0x8432e2['MailMessage'][_0x09b3('0x18')]({'read':!![]},{'where':{'MailInteractionId':_0x1f4802['id']}})[_0x09b3('0x19')](function(){_0x4ad2b2();})[_0x09b3('0x1a')](function(_0x499d78){_0x4ad2b2(_0x499d78);});}else{_0x4ad2b2();}}},'charset':_0x09b3('0x1b'),'collate':_0x09b3('0x1c')});}; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.rpc.js b/server/api/mailInteraction/mailInteraction.rpc.js new file mode 100644 index 0000000..af938dc --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2f70=['limit','AddTagsToMailInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./mailInteraction.socket','request','then','info','MailInteraction,\x20%s,\x20%s','debug','MailInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','UpdateMailInteraction','MailInteraction','body','options','raw','where'];(function(_0x2566d2,_0x86e7d4){var _0x10d583=function(_0x4bee7b){while(--_0x4bee7b){_0x2566d2['push'](_0x2566d2['shift']());}};_0x10d583(++_0x86e7d4);}(_0x2f70,0xb8));var _0x02f7=function(_0x59a638,_0x2639ec){_0x59a638=_0x59a638-0x0;var _0x554ff4=_0x2f70[_0x59a638];return _0x554ff4;};'use strict';var _=require(_0x02f7('0x0'));var util=require(_0x02f7('0x1'));var moment=require(_0x02f7('0x2'));var BPromise=require(_0x02f7('0x3'));var rs=require(_0x02f7('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x02f7('0x5'))['db'];var utils=require(_0x02f7('0x6'));var logger=require(_0x02f7('0x7'))(_0x02f7('0x8'));var config=require(_0x02f7('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x02f7('0xa')][_0x02f7('0xb')]({'port':0x232a});config[_0x02f7('0xc')]=_[_0x02f7('0xd')](config[_0x02f7('0xc')],{'host':_0x02f7('0xe'),'port':0x18eb});var socket=require(_0x02f7('0xf'))(new Redis(config[_0x02f7('0xc')]));require(_0x02f7('0x10'))['register'](socket);function respondWithRpcPromise(_0x22916a,_0x1469ae,_0x52f505){return new BPromise(function(_0x112155,_0x131a6f){return client[_0x02f7('0x11')](_0x22916a,_0x52f505)[_0x02f7('0x12')](function(_0x241e1f){logger[_0x02f7('0x13')](_0x02f7('0x14'),_0x1469ae,'request\x20sent');logger[_0x02f7('0x15')](_0x02f7('0x16'),_0x1469ae,_0x02f7('0x17'),JSON[_0x02f7('0x18')](_0x241e1f));if(_0x241e1f[_0x02f7('0x19')]){if(_0x241e1f[_0x02f7('0x19')][_0x02f7('0x1a')]===0x1f4){logger[_0x02f7('0x19')]('MailInteraction,\x20%s,\x20%s',_0x1469ae,_0x241e1f[_0x02f7('0x19')][_0x02f7('0x1b')]);return _0x131a6f(_0x241e1f[_0x02f7('0x19')][_0x02f7('0x1b')]);}logger[_0x02f7('0x19')](_0x02f7('0x14'),_0x1469ae,_0x241e1f[_0x02f7('0x19')][_0x02f7('0x1b')]);return _0x112155(_0x241e1f[_0x02f7('0x19')][_0x02f7('0x1b')]);}else{logger[_0x02f7('0x13')]('MailInteraction,\x20%s,\x20%s',_0x1469ae,'request\x20sent');_0x112155(_0x241e1f[_0x02f7('0x1c')][_0x02f7('0x1b')]);}})[_0x02f7('0x1d')](function(_0x1034a8){logger[_0x02f7('0x19')](_0x02f7('0x14'),_0x1469ae,_0x1034a8);_0x131a6f(_0x1034a8);});});}exports[_0x02f7('0x1e')]=function(_0x53e26d){var _0xd2505f=this;return new Promise(function(_0x3dd659,_0x28d92e){return db[_0x02f7('0x1f')]['update'](_0x53e26d[_0x02f7('0x20')],{'raw':_0x53e26d[_0x02f7('0x21')]?_0x53e26d[_0x02f7('0x21')][_0x02f7('0x22')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x53e26d[_0x02f7('0x21')]?_0x53e26d[_0x02f7('0x21')][_0x02f7('0x23')]||null:null,'attributes':_0x53e26d[_0x02f7('0x21')]?_0x53e26d['options']['attributes']||null:null,'limit':_0x53e26d['options']?_0x53e26d[_0x02f7('0x21')][_0x02f7('0x24')]||null:null})[_0x02f7('0x12')](function(_0x511ad9){logger[_0x02f7('0x13')](_0x02f7('0x1e'),_0x53e26d);logger[_0x02f7('0x15')]('UpdateMailInteraction',_0x53e26d,JSON['stringify'](_0x511ad9));_0x3dd659(_0x511ad9);})['catch'](function(_0x514680){logger[_0x02f7('0x19')]('UpdateMailInteraction',_0x514680[_0x02f7('0x1b')],_0x53e26d);_0x28d92e(_0xd2505f[_0x02f7('0x19')](0x1f4,_0x514680[_0x02f7('0x1b')]));});});};exports[_0x02f7('0x25')]=function(_0x18517f){return new Promise(function(_0x12dc30,_0x2da29e){return db[_0x02f7('0x1f')][_0x02f7('0x26')]({'where':_0x18517f[_0x02f7('0x21')]?_0x18517f[_0x02f7('0x21')]['where']||null:null})[_0x02f7('0x12')](function(_0x375bb5){if(_0x375bb5){return _0x375bb5[_0x02f7('0x27')](_0x18517f[_0x02f7('0x20')][_0x02f7('0x28')],_[_0x02f7('0x29')](_0x18517f['body'],[_0x02f7('0x28'),'id'])||{});}})[_0x02f7('0x2a')](function(_0x1c6409){logger[_0x02f7('0x13')](_0x02f7('0x2b'),_0x18517f);logger[_0x02f7('0x15')](_0x02f7('0x2b'),_0x18517f,JSON[_0x02f7('0x18')](_0x1c6409));_0x12dc30(_0x1c6409);})[_0x02f7('0x1d')](function(_0x2d9192){logger[_0x02f7('0x19')]('AddTags',_0x2d9192[_0x02f7('0x1b')],_0x18517f);_0x2da29e(_this['error'](0x1f4,_0x2d9192[_0x02f7('0x1b')]));});});}; \ No newline at end of file diff --git a/server/api/mailInteraction/mailInteraction.socket.js b/server/api/mailInteraction/mailInteraction.socket.js new file mode 100644 index 0000000..5c4fbe5 --- /dev/null +++ b/server/api/mailInteraction/mailInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa080=['removeListener','mailInteraction:','remove','update','emit'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0xa080,0x1c9));var _0x0a08=function(_0x5642a4,_0x3b3752){_0x5642a4=_0x5642a4-0x0;var _0x20b040=_0xa080[_0x5642a4];return _0x20b040;};'use strict';var MailInteractionEvents=require('./mailInteraction.events');var events=['save',_0x0a08('0x0'),_0x0a08('0x1')];function createListener(_0x4c0432,_0x5a6dc2){return function(_0x15609b){_0x5a6dc2[_0x0a08('0x2')](_0x4c0432,_0x15609b);};}function removeListener(_0xa5feb6,_0x100cae){return function(){MailInteractionEvents[_0x0a08('0x3')](_0xa5feb6,_0x100cae);};}exports['register']=function(_0x49c6be){for(var _0x4ff097=0x0,_0x2a59a7=events['length'];_0x4ff097<_0x2a59a7;_0x4ff097++){var _0xc81820=events[_0x4ff097];var _0x514155=createListener(_0x0a08('0x4')+_0xc81820,_0x49c6be);MailInteractionEvents['on'](_0xc81820,_0x514155);}}; \ No newline at end of file diff --git a/server/api/mailMessage/index.js b/server/api/mailMessage/index.js new file mode 100644 index 0000000..b3c2750 --- /dev/null +++ b/server/api/mailMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd909=['path','connect-timeout','express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./mailMessage.controller','get','isAuthenticated','/describe','describe','/:id','show','/:id/download','post','mail','put','update','accept','/:id/reject','reject','destroy','exports','util'];(function(_0x4bba85,_0x4c3e39){var _0x17e4d2=function(_0x57ce98){while(--_0x57ce98){_0x4bba85['push'](_0x4bba85['shift']());}};_0x17e4d2(++_0x4c3e39);}(_0xd909,0x1c1));var _0x9d90=function(_0x11f8f8,_0x3b1d76){_0x11f8f8=_0x11f8f8-0x0;var _0x13914a=_0xd909[_0x11f8f8];return _0x13914a;};'use strict';var multer=require('multer');var util=require(_0x9d90('0x0'));var path=require(_0x9d90('0x1'));var timeout=require(_0x9d90('0x2'));var express=require(_0x9d90('0x3'));var router=express['Router']();var fs_extra=require(_0x9d90('0x4'));var auth=require(_0x9d90('0x5'));var interaction=require(_0x9d90('0x6'));var config=require(_0x9d90('0x7'));var controller=require(_0x9d90('0x8'));router[_0x9d90('0x9')]('/',auth[_0x9d90('0xa')](),controller['index']);router[_0x9d90('0x9')](_0x9d90('0xb'),auth[_0x9d90('0xa')](),controller[_0x9d90('0xc')]);router[_0x9d90('0x9')](_0x9d90('0xd'),auth[_0x9d90('0xa')](),controller[_0x9d90('0xe')]);router[_0x9d90('0x9')](_0x9d90('0xf'),auth[_0x9d90('0xa')](),controller['download']);router[_0x9d90('0x10')]('/',auth[_0x9d90('0xa')](),interaction['tracked'](_0x9d90('0x11'),'mailmessage:create'),controller['create']);router[_0x9d90('0x12')](_0x9d90('0xd'),auth[_0x9d90('0xa')](),controller[_0x9d90('0x13')]);router[_0x9d90('0x12')]('/:id/accept',auth['isAuthenticated'](),controller[_0x9d90('0x14')]);router[_0x9d90('0x12')](_0x9d90('0x15'),auth[_0x9d90('0xa')](),controller[_0x9d90('0x16')]);router['delete'](_0x9d90('0xd'),auth[_0x9d90('0xa')](),controller[_0x9d90('0x17')]);module[_0x9d90('0x18')]=router; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.attributes.js b/server/api/mailMessage/mailMessage.attributes.js new file mode 100644 index 0000000..7e524cb --- /dev/null +++ b/server/api/mailMessage/mailMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeeaf=['TEXT','long','medium','BOOLEAN','ENUM','out','STRING','DATE','INTEGER','Email','Chat','sequelize','exports'];(function(_0x7dd4b,_0x4ce376){var _0x30bad3=function(_0x17eaef){while(--_0x17eaef){_0x7dd4b['push'](_0x7dd4b['shift']());}};_0x30bad3(++_0x4ce376);}(_0xeeaf,0x150));var _0xfeea=function(_0x5150f5,_0x3b4d7b){_0x5150f5=_0x5150f5-0x0;var _0x4f7c53=_0xeeaf[_0x5150f5];return _0x4f7c53;};'use strict';var Sequelize=require(_0xfeea('0x0'));var _=require('lodash');module[_0xfeea('0x1')]={'body':{'type':Sequelize[_0xfeea('0x2')](_0xfeea('0x3')),'allowNull':![]},'plainBody':{'type':Sequelize[_0xfeea('0x2')](_0xfeea('0x4'))},'read':{'type':Sequelize[_0xfeea('0x5')],'defaultValue':![]},'direction':{'type':Sequelize[_0xfeea('0x6')]('in',_0xfeea('0x7')),'defaultValue':_0xfeea('0x7'),'allowNull':![]},'messageId':{'type':Sequelize[_0xfeea('0x8')](0x1fe)},'from':{'type':Sequelize['STRING']},'to':{'type':Sequelize['TEXT'](_0xfeea('0x3'))},'cc':{'type':Sequelize[_0xfeea('0x2')](_0xfeea('0x3'))},'bcc':{'type':Sequelize[_0xfeea('0x2')](_0xfeea('0x3'))},'subject':{'type':Sequelize[_0xfeea('0x2')]},'sentAt':{'type':Sequelize[_0xfeea('0x9')]},'attach':{'type':Sequelize[_0xfeea('0xa')],'defaultValue':0x0},'secret':{'type':Sequelize[_0xfeea('0x5')],'defaultValue':![]},'readAt':{'type':Sequelize[_0xfeea('0x9')]},'originTo':{'type':Sequelize[_0xfeea('0x2')]('long')},'originCc':{'type':Sequelize[_0xfeea('0x2')]('long')},'originChannel':{'type':Sequelize[_0xfeea('0x6')](_0xfeea('0xb'),_0xfeea('0xc')),'defaultValue':_0xfeea('0xb'),'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.controller.js b/server/api/mailMessage/mailMessage.controller.js new file mode 100644 index 0000000..84ed085 --- /dev/null +++ b/server/api/mailMessage/mailMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x242a=['split','MailAccount','MailAccountId','List','CmContact','Contacts','updatedAt','DESC','CloudProvider','Smtp','getSmtpOptions','attachments','join','root','basename','ListId','messageId','YYYY-MM-DD\x20HH:mm:ss','mail','read','format','UserId','user','agent','get','MailInteraction','MailInteractionId','isNil','read1stAt','[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','SELECT','contact','User','fullname','email','internal','interface','channel','motionChannel','event','fromString','EventManager','acceptmessage','reject','interaction','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','QueryTypes','download','unix','toString','server','files','tmp','from','Attachment','decode','createdAt','bcc','Bcc','Attachments','existsSync','push','readFileSync','build','writeFileSync','unlinkSync','eml-format','moment','bluebird','path','lodash','ioredis','html-to-text','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./mailMessage.socket','jayson/promise','http','client','then','MailMessage,\x20%s,\x20%s','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','status','json','offset','limit','undefined','count','set','Content-Range','update','stack','name','map','MailMessage','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','includeAll','include','rows','params','body','find','destroy','describe','create','out','secret'];(function(_0x2543d6,_0x3a5e78){var _0x55213c=function(_0x292768){while(--_0x292768){_0x2543d6['push'](_0x2543d6['shift']());}};_0x55213c(++_0x3a5e78);}(_0x242a,0xe1));var _0xa242=function(_0xa148b7,_0x2f3eb2){_0xa148b7=_0xa148b7-0x0;var _0x51efd3=_0x242a[_0xa148b7];return _0x51efd3;};'use strict';var emlformat=require(_0xa242('0x0'));var moment=require(_0xa242('0x1'));var BPromise=require(_0xa242('0x2'));var util=require('util');var path=require(_0xa242('0x3'));var fs=require('fs');var _=require(_0xa242('0x4'));var Redis=require(_0xa242('0x5'));var htmlToText=require(_0xa242('0x6'));var qs=require(_0xa242('0x7'));var logger=require(_0xa242('0x8'))('api');var interaction_log=require(_0xa242('0x8'))('mail-interactions');var config=require(_0xa242('0x9'));var db=require(_0xa242('0xa'))['db'];config[_0xa242('0xb')]=_[_0xa242('0xc')](config['redis'],{'host':_0xa242('0xd'),'port':0x18eb});var socket=require(_0xa242('0xe'))(new Redis(config['redis']));var htmlEntities=require('html-entities');require(_0xa242('0xf'))['register'](socket);var jayson=require(_0xa242('0x10'));var client=jayson['client'][_0xa242('0x11')]({'port':0x232c});var client9003=jayson[_0xa242('0x12')][_0xa242('0x11')]({'port':0x232b});var client9002=jayson['client'][_0xa242('0x11')]({'port':0x232a});function respondWithRpcPromise(_0x3c0e44,_0x2a1b27,_0x4d117e,_0x286121){return new BPromise(function(_0x4d5cf6,_0x227c05){var _0x108d14=_0x286121||client;return _0x108d14['request'](_0x3c0e44,_0x4d117e)[_0xa242('0x13')](function(_0x258b84){logger['info'](_0xa242('0x14'),_0x2a1b27,_0xa242('0x15'));logger[_0xa242('0x16')](_0xa242('0x17'),_0x2a1b27,_0xa242('0x15'),JSON[_0xa242('0x18')](_0x258b84));if(_0x258b84[_0xa242('0x19')]){if(_0x258b84[_0xa242('0x19')][_0xa242('0x1a')]===0x1f4){logger[_0xa242('0x19')](_0xa242('0x14'),_0x2a1b27,_0x258b84['error'][_0xa242('0x1b')]);return _0x227c05(_0x258b84[_0xa242('0x19')][_0xa242('0x1b')]);}logger[_0xa242('0x19')](_0xa242('0x14'),_0x2a1b27,_0x258b84[_0xa242('0x19')][_0xa242('0x1b')]);return _0x4d5cf6(_0x258b84['error'][_0xa242('0x1b')]);}else{logger[_0xa242('0x1c')](_0xa242('0x14'),_0x2a1b27,_0xa242('0x15'));_0x4d5cf6(_0x258b84[_0xa242('0x1d')]['message']);}})[_0xa242('0x1e')](function(_0x1da694){logger[_0xa242('0x19')](_0xa242('0x14'),_0x2a1b27,_0x1da694);_0x227c05(_0x1da694);});});}function respondWithResult(_0x44674f,_0x56f13f){_0x56f13f=_0x56f13f||0xc8;return function(_0x1de4d3){if(_0x1de4d3){return _0x44674f[_0xa242('0x1f')](_0x56f13f)[_0xa242('0x20')](_0x1de4d3);}};}function respondWithFilteredResult(_0x4ef5db,_0x22b6ed){return function(_0x1df8bd){if(_0x1df8bd){var _0x5f05a7=typeof _0x22b6ed[_0xa242('0x21')]==='undefined'&&typeof _0x22b6ed[_0xa242('0x22')]===_0xa242('0x23');var _0x13955d=_0x1df8bd[_0xa242('0x24')];var _0x49000f=_0x5f05a7?0x0:_0x22b6ed[_0xa242('0x21')];var _0x2649a9=_0x5f05a7?_0x1df8bd[_0xa242('0x24')]:_0x22b6ed['offset']+_0x22b6ed['limit'];var _0x448d91;if(_0x2649a9>=_0x13955d){_0x2649a9=_0x13955d;_0x448d91=0xc8;}else{_0x448d91=0xce;}_0x4ef5db[_0xa242('0x1f')](_0x448d91);return _0x4ef5db[_0xa242('0x25')](_0xa242('0x26'),_0x49000f+'-'+_0x2649a9+'/'+_0x13955d)[_0xa242('0x20')](_0x1df8bd);}return null;};}function saveUpdates(_0x4a1b82){return function(_0xb94688){if(_0xb94688){return _0xb94688[_0xa242('0x27')](_0x4a1b82)[_0xa242('0x13')](function(_0x41d3bf){return _0x41d3bf;});}return null;};}function removeEntity(_0x2391de){return function(_0x29df2f){if(_0x29df2f){return _0x29df2f['destroy']()['then'](function(){_0x2391de[_0xa242('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x244b85){return function(_0x4cfb61){if(!_0x4cfb61){_0x244b85['sendStatus'](0x194);}return _0x4cfb61;};}function handleError(_0x5b117e,_0x4e5a69){_0x4e5a69=_0x4e5a69||0x1f4;return function(_0x27f38b){logger['error'](_0x27f38b[_0xa242('0x28')]);if(_0x27f38b['name']){delete _0x27f38b[_0xa242('0x29')];}_0x5b117e['status'](_0x4e5a69)['send'](_0x27f38b);};}exports['index']=function(_0x36ab38,_0x285615){var _0x52f020={},_0xe8b0ba={},_0x54de2d={'count':0x0,'rows':[]};var _0x4f134d=_[_0xa242('0x2a')](db[_0xa242('0x2b')][_0xa242('0x2c')],function(_0x491c82){return{'name':_0x491c82[_0xa242('0x2d')],'type':_0x491c82[_0xa242('0x2e')][_0xa242('0x2f')]};});_0xe8b0ba['model']=_[_0xa242('0x2a')](_0x4f134d,_0xa242('0x29'));_0xe8b0ba[_0xa242('0x30')]=_[_0xa242('0x31')](_0x36ab38['query']);_0xe8b0ba[_0xa242('0x32')]=_[_0xa242('0x33')](_0xe8b0ba[_0xa242('0x34')],_0xe8b0ba[_0xa242('0x30')]);_0x52f020[_0xa242('0x35')]=_[_0xa242('0x33')](_0xe8b0ba[_0xa242('0x34')],qs[_0xa242('0x36')](_0x36ab38[_0xa242('0x30')][_0xa242('0x36')]));_0x52f020[_0xa242('0x35')]=_0x52f020[_0xa242('0x35')][_0xa242('0x37')]?_0x52f020[_0xa242('0x35')]:_0xe8b0ba[_0xa242('0x34')];if(!_0x36ab38[_0xa242('0x30')]['hasOwnProperty'](_0xa242('0x38'))){_0x52f020[_0xa242('0x22')]=qs[_0xa242('0x22')](_0x36ab38[_0xa242('0x30')]['limit']);_0x52f020[_0xa242('0x21')]=qs[_0xa242('0x21')](_0x36ab38['query'][_0xa242('0x21')]);}_0x52f020[_0xa242('0x39')]=qs[_0xa242('0x3a')](_0x36ab38['query'][_0xa242('0x3a')]);_0x52f020[_0xa242('0x3b')]=qs[_0xa242('0x32')](_[_0xa242('0x3c')](_0x36ab38['query'],_0xe8b0ba[_0xa242('0x32')]),_0x4f134d);if(_0x36ab38[_0xa242('0x30')]['filter']){_0x52f020[_0xa242('0x3b')]=_['merge'](_0x52f020[_0xa242('0x3b')],{'$or':_[_0xa242('0x2a')](_0x4f134d,function(_0x27cc29){if(_0x27cc29[_0xa242('0x2e')]!==_0xa242('0x3d')){var _0x13768a={};_0x13768a[_0x27cc29[_0xa242('0x29')]]={'$like':'%'+_0x36ab38[_0xa242('0x30')][_0xa242('0x3e')]+'%'};return _0x13768a;}})});}_0x52f020=_[_0xa242('0x3f')]({},_0x52f020,_0x36ab38['options']);var _0x23c6d2={'where':_0x52f020[_0xa242('0x3b')]};return db[_0xa242('0x2b')]['count'](_0x23c6d2)[_0xa242('0x13')](function(_0x33df0e){_0x54de2d['count']=_0x33df0e;if(_0x36ab38[_0xa242('0x30')][_0xa242('0x40')]){_0x52f020[_0xa242('0x41')]=[{'all':!![]}];}return db[_0xa242('0x2b')]['findAll'](_0x52f020);})['then'](function(_0x2ccb8c){_0x54de2d[_0xa242('0x42')]=_0x2ccb8c;return _0x54de2d;})[_0xa242('0x13')](respondWithFilteredResult(_0x285615,_0x52f020))[_0xa242('0x1e')](handleError(_0x285615,null));};exports['show']=function(_0x37961,_0x4cdd58){var _0x5a0cef={'raw':!![],'where':{'id':_0x37961[_0xa242('0x43')]['id']}},_0xee085d={};_0xee085d[_0xa242('0x34')]=_[_0xa242('0x31')](db[_0xa242('0x2b')][_0xa242('0x2c')]);_0xee085d[_0xa242('0x30')]=_[_0xa242('0x31')](_0x37961[_0xa242('0x30')]);_0xee085d['filters']=_[_0xa242('0x33')](_0xee085d[_0xa242('0x34')],_0xee085d['query']);_0x5a0cef[_0xa242('0x35')]=_['intersection'](_0xee085d['model'],qs[_0xa242('0x36')](_0x37961[_0xa242('0x30')][_0xa242('0x36')]));_0x5a0cef[_0xa242('0x35')]=_0x5a0cef['attributes']['length']?_0x5a0cef[_0xa242('0x35')]:_0xee085d[_0xa242('0x34')];if(_0x37961[_0xa242('0x30')]['includeAll']){_0x5a0cef[_0xa242('0x41')]=[{'all':!![]}];}_0x5a0cef=_[_0xa242('0x3f')]({},_0x5a0cef,_0x37961['options']);return db[_0xa242('0x2b')]['find'](_0x5a0cef)['then'](handleEntityNotFound(_0x4cdd58,null))[_0xa242('0x13')](respondWithResult(_0x4cdd58,null))[_0xa242('0x1e')](handleError(_0x4cdd58,null));};exports[_0xa242('0x27')]=function(_0x1054ca,_0x1b8356){if(_0x1054ca[_0xa242('0x44')]['id']){delete _0x1054ca['body']['id'];}return db[_0xa242('0x2b')][_0xa242('0x45')]({'where':{'id':_0x1054ca[_0xa242('0x43')]['id']}})[_0xa242('0x13')](handleEntityNotFound(_0x1b8356,null))[_0xa242('0x13')](saveUpdates(_0x1054ca[_0xa242('0x44')],null))['then'](respondWithResult(_0x1b8356,null))[_0xa242('0x1e')](handleError(_0x1b8356,null));};exports[_0xa242('0x46')]=function(_0x2caa9e,_0x1ee8d6){return db[_0xa242('0x2b')][_0xa242('0x45')]({'where':{'id':_0x2caa9e[_0xa242('0x43')]['id']}})[_0xa242('0x13')](handleEntityNotFound(_0x1ee8d6,null))[_0xa242('0x13')](removeEntity(_0x1ee8d6,null))[_0xa242('0x1e')](handleError(_0x1ee8d6,null));};exports[_0xa242('0x47')]=function(_0xf33572,_0x4c3133){return db[_0xa242('0x2b')][_0xa242('0x47')]()[_0xa242('0x13')](respondWithResult(_0x4c3133,null))[_0xa242('0x1e')](handleError(_0x4c3133,null));};exports[_0xa242('0x48')]=function(_0x546d25,_0x397fca){return db[_0xa242('0x2b')][_0xa242('0x48')](_0x546d25[_0xa242('0x44')])[_0xa242('0x13')](function(_0x4d23af){if(_0x4d23af){if(_0x4d23af['direction']===_0xa242('0x49')&&!_0x4d23af[_0xa242('0x4a')]){var _0x1f96cd,_0x29f47e,_0x17ef0e;if(_0x546d25['body']['to']){_0x29f47e=_0x546d25[_0xa242('0x44')]['to'][_0xa242('0x4b')](',')[0x0];}return db[_0xa242('0x4c')]['findOne']({'where':{'id':_0x4d23af[_0xa242('0x4d')]},'include':[{'model':db['CmList'],'as':_0xa242('0x4e'),'include':[{'model':db[_0xa242('0x4f')],'as':_0xa242('0x50'),'where':{'email':_0x29f47e},'limit':0x1,'order':[[_0xa242('0x51'),_0xa242('0x52')]]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![],'include':[{'model':db[_0xa242('0x53')],'as':_0xa242('0x53'),'raw':!![]}]}]})[_0xa242('0x13')](function(_0x5db8e8){_0x1f96cd=_0x5db8e8;if(!_0x1f96cd||!_0x1f96cd[_0xa242('0x54')])return;var _0x355a91=_0x1f96cd[_0xa242('0x55')]();if(_0x546d25[_0xa242('0x44')][_0xa242('0x56')]&&_0x546d25[_0xa242('0x44')][_0xa242('0x56')][_0xa242('0x37')]){for(var _0x432f73=0x0;_0x432f73<_0x546d25[_0xa242('0x44')][_0xa242('0x56')][_0xa242('0x37')];_0x432f73+=0x1){_0x546d25['body'][_0xa242('0x56')][_0x432f73]={'filename':_0x546d25[_0xa242('0x44')][_0xa242('0x56')][_0x432f73][_0xa242('0x29')],'path':path[_0xa242('0x57')](config[_0xa242('0x58')],'server/files/attachments',_0x546d25[_0xa242('0x44')][_0xa242('0x56')][_0x432f73][_0xa242('0x59')])};}}_0x17ef0e={'account':_0x355a91,'message':_0x546d25[_0xa242('0x44')]};return;})[_0xa242('0x13')](function(){if(_0x1f96cd[_0xa242('0x4e')]){if(_0x1f96cd[_0xa242('0x4e')][_0xa242('0x50')]['length']){return _0x1f96cd[_0xa242('0x4e')][_0xa242('0x50')][0x0];}else{return db[_0xa242('0x4f')][_0xa242('0x48')](_['defaults'](_0x546d25['body'],{'firstName':_0x546d25[_0xa242('0x44')]['to'],'email':_0x546d25[_0xa242('0x44')]['to'],'phone':_0x546d25[_0xa242('0x44')]['to'],'ListId':_0x1f96cd[_0xa242('0x5a')]}));}}else{throw new Error('List\x20not\x20found');}})[_0xa242('0x13')](function(){if(_0x17ef0e){return respondWithRpcPromise('SendMail','sendMail',_0x17ef0e,client9003)['then'](function(_0x1a21d7){return _0x4d23af[_0xa242('0x27')]({'read':!![],'messageId':_0x1a21d7[_0xa242('0x5b')],'sentAt':moment()['format'](_0xa242('0x5c'))});})['catch'](function(_0x107203){logger[_0xa242('0x19')]('%s',JSON[_0xa242('0x18')](_0x107203));return _0x4d23af;});}return _0x4d23af;});}return _0x4d23af;}})[_0xa242('0x13')](respondWithResult(_0x397fca,0xc9))['catch'](handleError(_0x397fca,null));};exports['accept']=function(_0x261174,_0x12399d){var _0x1bea1c={'agent':{},'channel':_0xa242('0x5d')};if(_0x261174[_0xa242('0x44')]['id']){delete _0x261174[_0xa242('0x44')]['id'];}_0x261174['body'][_0xa242('0x5e')]=!![];_0x261174[_0xa242('0x44')]['readAt']=moment()[_0xa242('0x5f')]('YYYY-MM-DD\x20HH:mm:ss');_0x261174[_0xa242('0x44')]['UserId']=_0x261174[_0xa242('0x44')][_0xa242('0x60')]||_0x261174[_0xa242('0x61')]['id'];_0x1bea1c[_0xa242('0x62')]['id']=_0x261174[_0xa242('0x44')][_0xa242('0x60')];return db[_0xa242('0x2b')][_0xa242('0x45')]({'where':{'id':_0x261174[_0xa242('0x43')]['id'],'UserId':null}})[_0xa242('0x13')](handleEntityNotFound(_0x12399d,null))['then'](saveUpdates(_0x261174[_0xa242('0x44')],null))[_0xa242('0x13')](function(_0x2e6e61){if(_0x2e6e61){_0x1bea1c[_0xa242('0x1b')]=_0x2e6e61[_0xa242('0x63')]({'plain':!![]});return db[_0xa242('0x64')][_0xa242('0x45')]({'where':{'id':_0x2e6e61[_0xa242('0x65')]}});}return null;})[_0xa242('0x13')](handleEntityNotFound(_0x12399d,null))[_0xa242('0x13')](function(_0x367aaf){if(_0x367aaf){return _0x367aaf['update']({'UserId':_0x261174[_0xa242('0x44')][_0xa242('0x60')],'read1stAt':_[_0xa242('0x66')](_0x367aaf[_0xa242('0x67')])?moment()[_0xa242('0x5f')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xa242('0x13')](function(_0x79a564){if(_0x79a564){_0x1bea1c['interaction']=_0x79a564['get']({'plain':!![]});interaction_log[_0xa242('0x1c')](_0xa242('0x68'),_0x261174[_0xa242('0x61')]['id'],_0x261174[_0xa242('0x61')][_0xa242('0x29')],_0x261174[_0xa242('0x61')][_0xa242('0x69')],_0x1bea1c['interaction']['id'],_0x261174[_0xa242('0x44')]?JSON[_0xa242('0x18')](_0x261174[_0xa242('0x44')]):_0xa242('0x6a'));return respondWithRpcPromise(_0xa242('0x6b'),_0xa242('0x6c'),_0x1bea1c);}return null;})[_0xa242('0x13')](function(_0x43c381){var _0x11baa0=_0xa242('0x6d')+_0x43c381[_0xa242('0x1b')][_0xa242('0x6e')];return db['sequelize']['query'](_0x11baa0,{'type':db[_0xa242('0x6f')]['QueryTypes'][_0xa242('0x70')],'raw':!![]})[_0xa242('0x13')](function(_0x2f360d){return _0x2f360d;});})[_0xa242('0x13')](function(_0x423587){if(_0x423587){_0x1bea1c[_0xa242('0x1b')][_0xa242('0x71')]=_0x423587[0x0];if(!_0x261174[_0xa242('0x44')]['UserId'])return;return db[_0xa242('0x72')][_0xa242('0x45')]({'where':{'id':_0x261174['body'][_0xa242('0x60')],'role':_0xa242('0x62')},'attributes':['id',_0xa242('0x29'),_0xa242('0x73'),_0xa242('0x74'),_0xa242('0x75')],'raw':!![]});}return null;})['then'](function(_0x5bc597){if(!_0x5bc597)return null;_0x1bea1c['message']['agent']=_0x5bc597;return _0x1bea1c;})[_0xa242('0x13')](function(_0x5d6799){if(_0x5d6799){if(_0x261174[_0xa242('0x44')]['manual']){_0x1bea1c['message'][_0xa242('0x76')]=util[_0xa242('0x5f')]('SIP/%s',_0x261174[_0xa242('0x61')][_0xa242('0x29')]);_0x1bea1c[_0xa242('0x1b')][_0xa242('0x77')]=_0x1bea1c['channel'];_0x1bea1c['message'][_0xa242('0x78')]=_0x1bea1c['channel'];_0x1bea1c[_0xa242('0x1b')][_0xa242('0x79')]='accept';_0x1bea1c['message']['body']=htmlToText[_0xa242('0x7a')](_0x1bea1c[_0xa242('0x1b')][_0xa242('0x44')]);return respondWithRpcPromise('EventManager',_0xa242('0x7b'),{'event':_0xa242('0x7c'),'message':_0x1bea1c[_0xa242('0x1b')]},client9002)[_0xa242('0x13')](function(){return _0x1bea1c;});}return _0x1bea1c;}return null;})[_0xa242('0x13')](respondWithResult(_0x12399d,null))[_0xa242('0x1e')](handleError(_0x12399d,null));};exports[_0xa242('0x7d')]=function(_0x2d3e23,_0x358491){var _0x55c6fb={'agent':{},'channel':'mail'};if(_0x2d3e23[_0xa242('0x44')]['id']){delete _0x2d3e23['body']['id'];}_0x2d3e23['body'][_0xa242('0x60')]=_0x2d3e23[_0xa242('0x44')][_0xa242('0x60')]||_0x2d3e23['user']['id'];_0x55c6fb[_0xa242('0x62')]['id']=_0x2d3e23[_0xa242('0x44')][_0xa242('0x60')];return db[_0xa242('0x2b')][_0xa242('0x45')]({'where':{'id':_0x2d3e23[_0xa242('0x43')]['id'],'UserId':null}})[_0xa242('0x13')](handleEntityNotFound(_0x358491,null))[_0xa242('0x13')](function(_0x8b2fbb){if(_0x8b2fbb){_0x55c6fb[_0xa242('0x1b')]=_0x8b2fbb['get']({'plain':!![]});return db[_0xa242('0x64')][_0xa242('0x45')]({'where':{'id':_0x8b2fbb[_0xa242('0x65')]}});}return null;})[_0xa242('0x13')](handleEntityNotFound(_0x358491,null))[_0xa242('0x13')](function(_0x1c3d3b){if(_0x1c3d3b){_0x55c6fb[_0xa242('0x7e')]=_0x1c3d3b['get']({'plain':!![]});interaction_log[_0xa242('0x1c')](_0xa242('0x7f'),_0x2d3e23[_0xa242('0x61')]['id'],_0x2d3e23[_0xa242('0x61')][_0xa242('0x29')],_0x2d3e23['user'][_0xa242('0x69')],_0x55c6fb[_0xa242('0x7e')]['id'],_0x2d3e23[_0xa242('0x44')]?JSON['stringify'](_0x2d3e23[_0xa242('0x44')]):_0xa242('0x6a'));return respondWithRpcPromise(_0xa242('0x80'),_0xa242('0x81'),_0x55c6fb);}return null;})[_0xa242('0x13')](function(_0x4e6607){var _0x445276=_0xa242('0x6d')+_0x4e6607[_0xa242('0x1b')][_0xa242('0x6e')];return db['sequelize'][_0xa242('0x30')](_0x445276,{'type':db['Sequelize'][_0xa242('0x82')][_0xa242('0x70')],'raw':!![]})[_0xa242('0x13')](function(_0x5c89e7){return _0x5c89e7;});})['then'](function(_0x1e6596){if(_0x1e6596){_0x55c6fb[_0xa242('0x1b')][_0xa242('0x71')]=_0x1e6596[0x0];if(!_0x2d3e23[_0xa242('0x44')][_0xa242('0x60')])return;return db[_0xa242('0x72')][_0xa242('0x45')]({'where':{'id':_0x2d3e23[_0xa242('0x44')][_0xa242('0x60')],'role':'agent'},'attributes':['id',_0xa242('0x29'),'fullname',_0xa242('0x74'),'internal'],'raw':!![]});}return null;})['then'](function(_0x27647c){if(!_0x27647c)return null;_0x55c6fb['message'][_0xa242('0x62')]=_0x27647c;return _0x55c6fb;})['then'](function(_0x56a79a){if(_0x56a79a){_0x56a79a['message'][_0xa242('0x76')]=util[_0xa242('0x5f')]('SIP/%s',_0x2d3e23[_0xa242('0x61')][_0xa242('0x29')]);_0x56a79a['message'][_0xa242('0x77')]=_0x55c6fb['channel'];_0x56a79a[_0xa242('0x1b')][_0xa242('0x78')]=_0x55c6fb[_0xa242('0x77')];_0x56a79a[_0xa242('0x1b')]['event']=_0xa242('0x7d');_0x56a79a[_0xa242('0x1b')][_0xa242('0x44')]=htmlToText['fromString'](_0x55c6fb[_0xa242('0x1b')]['body']);respondWithRpcPromise(_0xa242('0x7b'),_0xa242('0x7b'),{'event':'rejectmessage','message':_0x56a79a[_0xa242('0x1b')]},client9002);return _0x55c6fb;}return null;})[_0xa242('0x13')](respondWithResult(_0x358491,null))['catch'](handleError(_0x358491,null));};exports[_0xa242('0x83')]=function(_0x4ad3b5,_0x62eea0){var _0x588379=moment()[_0xa242('0x84')]()[_0xa242('0x85')]();var _0x40adcd=path[_0xa242('0x57')](config[_0xa242('0x58')],_0xa242('0x86'),_0xa242('0x87'),_0xa242('0x88'));var _0x36ab43=path[_0xa242('0x57')](config['root'],_0xa242('0x86'),'files',_0xa242('0x56'));var _0x7f1d10=util[_0xa242('0x5f')]('message-%s.eml',_0x588379);return db[_0xa242('0x2b')]['find']({'where':{'id':_0x4ad3b5[_0xa242('0x43')]['id']},'attributes':['id',_0xa242('0x44'),_0xa242('0x89'),'to','cc','bcc','subject','createdAt'],'include':_0x4ad3b5[_0xa242('0x30')][_0xa242('0x56')]?[{'model':db[_0xa242('0x8a')],'as':'Attachments'}]:undefined})[_0xa242('0x13')](handleEntityNotFound(_0x62eea0,null))[_0xa242('0x13')](function(_0x1d51e6){if(_0x1d51e6){var _0x45fd0a=_0x1d51e6;var _0x1c550d={'from':_0x45fd0a['from'],'to':_0x45fd0a['to'],'subject':_0x45fd0a['subject'],'html':htmlEntities[_0xa242('0x8b')](_0x45fd0a[_0xa242('0x44')]),'headers':{'Date':moment(_0x45fd0a[_0xa242('0x8c')])[_0xa242('0x5f')]('ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ')},'attachments':[]};if(_0x1d51e6['cc']){_0x1c550d['headers']['Cc']=_0x1d51e6['cc'];}if(_0x1d51e6[_0xa242('0x8d')]){_0x1c550d['headers'][_0xa242('0x8e')]=_0x1d51e6[_0xa242('0x8d')];}return new BPromise(function(_0x1ef0fe,_0x5addc8){if(_0x1d51e6['Attachments']){for(var _0x1b1bea=0x0;_0x1b1bea<_0x1d51e6[_0xa242('0x8f')]['length'];_0x1b1bea++){var _0x1d7239=_0x1d51e6[_0xa242('0x8f')][_0x1b1bea];var _0x113eff=path[_0xa242('0x57')](_0x36ab43,_0x1d7239[_0xa242('0x59')]);if(fs[_0xa242('0x90')](_0x113eff)){_0x1c550d[_0xa242('0x56')][_0xa242('0x91')]({'name':_0x1d7239[_0xa242('0x29')],'contentType':_0x1d7239[_0xa242('0x2e')],'data':fs[_0xa242('0x92')](_0x113eff)});}}}emlformat[_0xa242('0x93')](_0x1c550d,function(_0x32c14c,_0xbf7b5){if(_0x32c14c)return _0x5addc8(_0x32c14c);fs[_0xa242('0x94')](path[_0xa242('0x57')](_0x40adcd,_0x7f1d10),_0xbf7b5);return _0x1ef0fe(_0xbf7b5);});});}})[_0xa242('0x13')](function(_0x3a86d8){if(_0x3a86d8){return _0x62eea0[_0xa242('0x83')](path[_0xa242('0x57')](_0x40adcd,_0x7f1d10),_0x7f1d10,function(_0x412abe){if(!_0x412abe)fs[_0xa242('0x95')](path[_0xa242('0x57')](_0x40adcd,_0x7f1d10));});}})['catch'](handleError(_0x62eea0,null));}; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.events.js b/server/api/mailMessage/mailMessage.events.js new file mode 100644 index 0000000..e5363a3 --- /dev/null +++ b/server/api/mailMessage/mailMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4f48=['emit','hasOwnProperty','hook','exports','events','../../mysqldb','MailMessage'];(function(_0x1177d5,_0x22b649){var _0xc3ddc2=function(_0x43ff95){while(--_0x43ff95){_0x1177d5['push'](_0x1177d5['shift']());}};_0xc3ddc2(++_0x22b649);}(_0x4f48,0x9e));var _0x84f4=function(_0x4eacc6,_0x2e8373){_0x4eacc6=_0x4eacc6-0x0;var _0x41deb6=_0x4f48[_0x4eacc6];return _0x41deb6;};'use strict';var EventEmitter=require(_0x84f4('0x0'));var MailMessage=require(_0x84f4('0x1'))['db'][_0x84f4('0x2')];var MailMessageEvents=new EventEmitter();MailMessageEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':'remove'};function emitEvent(_0x464075){return function(_0x2ec552,_0x42f64f,_0x5d711f){MailMessageEvents[_0x84f4('0x3')](_0x464075+':'+_0x2ec552['id'],_0x2ec552);MailMessageEvents[_0x84f4('0x3')](_0x464075,_0x2ec552);_0x5d711f(null);};}for(var e in events){if(events[_0x84f4('0x4')](e)){var event=events[e];MailMessage[_0x84f4('0x5')](e,emitEvent(event));}}module[_0x84f4('0x6')]=MailMessageEvents; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.model.js b/server/api/mailMessage/mailMessage.model.js new file mode 100644 index 0000000..664e08c --- /dev/null +++ b/server/api/mailMessage/mailMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37e8=['path','rimraf','../../config/environment','./mailMessage.attributes','exports','MailMessage','mail_messages','messageId','fti_mail_messages','subject','FULLTEXT','body','plainBody','fromString','models','get','direction','secret','UserId','MailInteraction','findOne','MailInteractionId','then','update','toLowerCase','error','utf8mb4','utf8mb4_unicode_ci','../../config/logger','api','moment','bluebird','request-promise','html-to-text'];(function(_0x2e1af3,_0x2a077b){var _0x4150cd=function(_0x1e08f3){while(--_0x1e08f3){_0x2e1af3['push'](_0x2e1af3['shift']());}};_0x4150cd(++_0x2a077b);}(_0x37e8,0x10a));var _0x837e=function(_0x4141ac,_0x3ba6b5){_0x4141ac=_0x4141ac-0x0;var _0x2bd174=_0x37e8[_0x4141ac];return _0x2bd174;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x837e('0x0'))(_0x837e('0x1'));var moment=require(_0x837e('0x2'));var BPromise=require(_0x837e('0x3'));var rp=require(_0x837e('0x4'));var htmlToText=require(_0x837e('0x5'));var fs=require('fs');var path=require(_0x837e('0x6'));var rimraf=require(_0x837e('0x7'));var config=require(_0x837e('0x8'));var attributes=require(_0x837e('0x9'));module[_0x837e('0xa')]=function(_0x454c8d,_0x2e09d4){return _0x454c8d['define'](_0x837e('0xb'),attributes,{'tableName':_0x837e('0xc'),'paranoid':![],'indexes':[{'name':_0x837e('0xd'),'fields':['messageId']},{'name':_0x837e('0xe'),'fields':['plainBody',_0x837e('0xf')],'type':_0x837e('0x10')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0xf2aa43,_0x181eea,_0x3e7ba1){if(_0xf2aa43[_0x837e('0x11')]){_0xf2aa43[_0x837e('0x12')]=htmlToText[_0x837e('0x13')](_0xf2aa43[_0x837e('0x11')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x3e7ba1(null,_0x181eea);},'afterCreate':function(_0x5ee2c6,_0x2e779b,_0x5eadeb){var _0x29a176=_0x454c8d[_0x837e('0x14')];var _0x59244b=_0x5ee2c6[_0x837e('0x15')]({'plain':!![]});if(_0x59244b[_0x837e('0x16')]['toLowerCase']()==='in'||_0x59244b[_0x837e('0x16')]['toLowerCase']()==='out'&&!_0x59244b[_0x837e('0x17')]&&!_['isNil'](_0x59244b[_0x837e('0x18')])){_0x29a176[_0x837e('0x19')][_0x837e('0x1a')]({'where':{'id':_0x59244b[_0x837e('0x1b')]}})[_0x837e('0x1c')](function(_0x1c713f){if(_0x1c713f){_0x1c713f[_0x837e('0x1d')]({'lastMsgAt':_0x59244b['createdAt'],'lastMsgDirection':_0x59244b[_0x837e('0x16')][_0x837e('0x1e')]()});}})['catch'](function(_0xb56c04){console[_0x837e('0x1f')](_0xb56c04);});}_0x5eadeb();}},'charset':_0x837e('0x20'),'collate':_0x837e('0x21')});}; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.rpc.js b/server/api/mailMessage/mailMessage.rpc.js new file mode 100644 index 0000000..5e37d6d --- /dev/null +++ b/server/api/mailMessage/mailMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xea28=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./mailMessage.socket','register','request','then','MailMessage,\x20%s,\x20%s','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','CreateMailMessage','MailMessage','body','options','raw','stringify','lodash'];(function(_0x4715d2,_0x3371b2){var _0x141811=function(_0x520bc6){while(--_0x520bc6){_0x4715d2['push'](_0x4715d2['shift']());}};_0x141811(++_0x3371b2);}(_0xea28,0x13a));var _0x8ea2=function(_0x3c2a50,_0xc728e7){_0x3c2a50=_0x3c2a50-0x0;var _0x4a0e7f=_0xea28[_0x3c2a50];return _0x4a0e7f;};'use strict';var _=require(_0x8ea2('0x0'));var util=require(_0x8ea2('0x1'));var moment=require(_0x8ea2('0x2'));var BPromise=require(_0x8ea2('0x3'));var rs=require(_0x8ea2('0x4'));var fs=require('fs');var Redis=require(_0x8ea2('0x5'));var db=require(_0x8ea2('0x6'))['db'];var utils=require(_0x8ea2('0x7'));var logger=require('../../config/logger')(_0x8ea2('0x8'));var config=require(_0x8ea2('0x9'));var jayson=require(_0x8ea2('0xa'));var client=jayson['client'][_0x8ea2('0xb')]({'port':0x232a});config[_0x8ea2('0xc')]=_[_0x8ea2('0xd')](config[_0x8ea2('0xc')],{'host':_0x8ea2('0xe'),'port':0x18eb});var socket=require(_0x8ea2('0xf'))(new Redis(config[_0x8ea2('0xc')]));require(_0x8ea2('0x10'))[_0x8ea2('0x11')](socket);function respondWithRpcPromise(_0x3000f9,_0x3d0b35,_0x21ae3d){return new BPromise(function(_0x500b82,_0x4da3b1){return client[_0x8ea2('0x12')](_0x3000f9,_0x21ae3d)[_0x8ea2('0x13')](function(_0x374973){logger['info'](_0x8ea2('0x14'),_0x3d0b35,_0x8ea2('0x15'));logger[_0x8ea2('0x16')](_0x8ea2('0x17'),_0x3d0b35,_0x8ea2('0x15'),JSON['stringify'](_0x374973));if(_0x374973[_0x8ea2('0x18')]){if(_0x374973['error']['code']===0x1f4){logger[_0x8ea2('0x18')](_0x8ea2('0x14'),_0x3d0b35,_0x374973[_0x8ea2('0x18')][_0x8ea2('0x19')]);return _0x4da3b1(_0x374973[_0x8ea2('0x18')][_0x8ea2('0x19')]);}logger[_0x8ea2('0x18')](_0x8ea2('0x14'),_0x3d0b35,_0x374973[_0x8ea2('0x18')][_0x8ea2('0x19')]);return _0x500b82(_0x374973[_0x8ea2('0x18')][_0x8ea2('0x19')]);}else{logger[_0x8ea2('0x1a')](_0x8ea2('0x14'),_0x3d0b35,_0x8ea2('0x15'));_0x500b82(_0x374973[_0x8ea2('0x1b')][_0x8ea2('0x19')]);}})[_0x8ea2('0x1c')](function(_0x1068b6){logger[_0x8ea2('0x18')](_0x8ea2('0x14'),_0x3d0b35,_0x1068b6);_0x4da3b1(_0x1068b6);});});}exports[_0x8ea2('0x1d')]=function(_0x52b58c){var _0x4be7c9=this;return new Promise(function(_0x3790e9,_0x248c18){return db[_0x8ea2('0x1e')]['create'](_0x52b58c[_0x8ea2('0x1f')],{'raw':_0x52b58c[_0x8ea2('0x20')]?_0x52b58c['options'][_0x8ea2('0x21')]===undefined?!![]:![]:!![]})[_0x8ea2('0x13')](function(_0x37229a){logger[_0x8ea2('0x1a')](_0x8ea2('0x1d'),_0x52b58c);logger[_0x8ea2('0x16')](_0x8ea2('0x1d'),_0x52b58c,JSON[_0x8ea2('0x22')](_0x37229a));_0x3790e9(_0x37229a);})[_0x8ea2('0x1c')](function(_0x4d5030){logger[_0x8ea2('0x18')]('CreateMailMessage',_0x4d5030[_0x8ea2('0x19')],_0x52b58c);_0x248c18(_0x4be7c9[_0x8ea2('0x18')](0x1f4,_0x4d5030[_0x8ea2('0x19')]));});});}; \ No newline at end of file diff --git a/server/api/mailMessage/mailMessage.socket.js b/server/api/mailMessage/mailMessage.socket.js new file mode 100644 index 0000000..a9fe0bf --- /dev/null +++ b/server/api/mailMessage/mailMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9f3a=['save','remove','update','removeListener','register','length'];(function(_0x39eba2,_0x5a5ad8){var _0x20b9ed=function(_0x5b86e1){while(--_0x5b86e1){_0x39eba2['push'](_0x39eba2['shift']());}};_0x20b9ed(++_0x5a5ad8);}(_0x9f3a,0xcc));var _0xa9f3=function(_0x2cfb48,_0x24b83b){_0x2cfb48=_0x2cfb48-0x0;var _0xc4594f=_0x9f3a[_0x2cfb48];return _0xc4594f;};'use strict';var MailMessageEvents=require('./mailMessage.events');var events=[_0xa9f3('0x0'),_0xa9f3('0x1'),_0xa9f3('0x2')];function createListener(_0xced7a2,_0x507760){return function(_0x4858e9){_0x507760['emit'](_0xced7a2,_0x4858e9);};}function removeListener(_0x53c3cf,_0x4f8ca0){return function(){MailMessageEvents[_0xa9f3('0x3')](_0x53c3cf,_0x4f8ca0);};}exports[_0xa9f3('0x4')]=function(_0xf60fba){for(var _0x369e43=0x0,_0x36f757=events[_0xa9f3('0x5')];_0x369e43<_0x36f757;_0x369e43++){var _0x5c772b=events[_0x369e43];var _0x51e8a6=createListener('mailMessage:'+_0x5c772b,_0xf60fba);MailMessageEvents['on'](_0x5c772b,_0x51e8a6);}}; \ No newline at end of file diff --git a/server/api/mailQueue/index.js b/server/api/mailQueue/index.js new file mode 100644 index 0000000..44543e3 --- /dev/null +++ b/server/api/mailQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x80ee=['index','/describe','isAuthenticated','/:id','getMembers','/:id/teams','/:id/users','post','create','addTeams','addAgents','update','delete','destroy','removeTeams','removeAgents','exports','multer','util','express','Router','../../components/auth/service','../../components/interaction/service','./mailQueue.controller','get'];(function(_0xd7f732,_0x1ba856){var _0x26fd49=function(_0x18fc7d){while(--_0x18fc7d){_0xd7f732['push'](_0xd7f732['shift']());}};_0x26fd49(++_0x1ba856);}(_0x80ee,0x13d));var _0xe80e=function(_0x2aaeac,_0x30bda5){_0x2aaeac=_0x2aaeac-0x0;var _0x757741=_0x80ee[_0x2aaeac];return _0x757741;};'use strict';var multer=require(_0xe80e('0x0'));var util=require(_0xe80e('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require(_0xe80e('0x2'));var router=express[_0xe80e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0xe80e('0x4'));var interaction=require(_0xe80e('0x5'));var config=require('../../config/environment');var controller=require(_0xe80e('0x6'));router[_0xe80e('0x7')]('/',auth['isAuthenticated'](),controller[_0xe80e('0x8')]);router[_0xe80e('0x7')](_0xe80e('0x9'),auth[_0xe80e('0xa')](),controller['describe']);router[_0xe80e('0x7')](_0xe80e('0xb'),auth[_0xe80e('0xa')](),controller['show']);router[_0xe80e('0x7')]('/:id/members',auth[_0xe80e('0xa')](),controller[_0xe80e('0xc')]);router[_0xe80e('0x7')](_0xe80e('0xd'),auth[_0xe80e('0xa')](),controller['getTeams']);router[_0xe80e('0x7')](_0xe80e('0xe'),auth[_0xe80e('0xa')](),controller['getAgents']);router[_0xe80e('0xf')]('/',auth['isAuthenticated'](),controller[_0xe80e('0x10')]);router[_0xe80e('0xf')](_0xe80e('0xd'),auth[_0xe80e('0xa')](),controller[_0xe80e('0x11')]);router[_0xe80e('0xf')](_0xe80e('0xe'),auth[_0xe80e('0xa')](),controller[_0xe80e('0x12')]);router['put'](_0xe80e('0xb'),auth['isAuthenticated'](),controller[_0xe80e('0x13')]);router[_0xe80e('0x14')]('/:id',auth[_0xe80e('0xa')](),controller[_0xe80e('0x15')]);router['delete'](_0xe80e('0xd'),auth[_0xe80e('0xa')](),controller[_0xe80e('0x16')]);router['delete'](_0xe80e('0xe'),auth[_0xe80e('0xa')](),controller[_0xe80e('0x17')]);module[_0xe80e('0x18')]=router; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.attributes.js b/server/api/mailQueue/mailQueue.attributes.js new file mode 100644 index 0000000..454d74d --- /dev/null +++ b/server/api/mailQueue/mailQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3024=['exports','name','STRING','rrmemory','beepall','roundrobin'];(function(_0x445c98,_0x132bf7){var _0x2fe913=function(_0x32e864){while(--_0x32e864){_0x445c98['push'](_0x445c98['shift']());}};_0x2fe913(++_0x132bf7);}(_0x3024,0x198));var _0x4302=function(_0x1464c2,_0x5551d2){_0x1464c2=_0x1464c2-0x0;var _0x3bfb77=_0x3024[_0x1464c2];return _0x3bfb77;};'use strict';var Sequelize=require('sequelize');module[_0x4302('0x0')]={'name':{'type':Sequelize['STRING'],'unique':_0x4302('0x1'),'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'description':{'type':Sequelize[_0x4302('0x2')]},'timeout':{'type':Sequelize['INTEGER'],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize['ENUM'](_0x4302('0x3'),_0x4302('0x4'),_0x4302('0x5'))}}; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.controller.js b/server/api/mailQueue/mailQueue.controller.js new file mode 100644 index 0000000..f372958 --- /dev/null +++ b/server/api/mailQueue/mailQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7cc4=['userMailQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','ejs','lodash','squel','crypto','jsforce','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','register','sendStatus','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','get','error','stack','name','send','index','map','MailQueue','key','query','keys','filters','model','fields','attributes','hasOwnProperty','nolimit','order','sort','pick','filter','where','type','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','intersection','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','MailQueues','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserMailQueue','length','MailQueueId','User','UserId','mailPause','updatedAt','createdAt','format','%s/%s','getTeams','Team','ids','voicePause','interface','flatMap','Agents','sequelize','transaction','addTeams','findOrCreate','forEach','userMailQueue:save','removeTeams','select','field','from','team_has_mail_queues','join','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','TeamId','includes','union','compact','value','isEmpty','emit'];(function(_0x3070dc,_0x40cf11){var _0x431489=function(_0x49bc2a){while(--_0x49bc2a){_0x3070dc['push'](_0x3070dc['shift']());}};_0x431489(++_0x40cf11);}(_0x7cc4,0x1a8));var _0x47cc=function(_0x4d67b8,_0x565134){_0x4d67b8=_0x4d67b8-0x0;var _0x55af3b=_0x7cc4[_0x4d67b8];return _0x55af3b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x47cc('0x0'));var zipdir=require(_0x47cc('0x1'));var jsonpatch=require(_0x47cc('0x2'));var rp=require(_0x47cc('0x3'));var moment=require(_0x47cc('0x4'));var BPromise=require(_0x47cc('0x5'));var Mustache=require(_0x47cc('0x6'));var util=require('util');var path=require(_0x47cc('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x47cc('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x47cc('0x9'));var squel=require(_0x47cc('0xa'));var crypto=require(_0x47cc('0xb'));var jsforce=require(_0x47cc('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x47cc('0xd'));var querystring=require(_0x47cc('0xe'));var Papa=require('papaparse');var Redis=require(_0x47cc('0xf'));var authService=require(_0x47cc('0x10'));var qs=require(_0x47cc('0x11'));var as=require(_0x47cc('0x12'));var hardwareService=require(_0x47cc('0x13'));var logger=require(_0x47cc('0x14'))(_0x47cc('0x15'));var utils=require(_0x47cc('0x16'));var config=require(_0x47cc('0x17'));var licenseUtil=require(_0x47cc('0x18'));var db=require('../../mysqldb')['db'];config[_0x47cc('0x19')]=_[_0x47cc('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x47cc('0x19')]));require('./mailQueue.socket')[_0x47cc('0x1b')](socket);function respondWithStatusCode(_0x4d2229,_0x2a4e8e){_0x2a4e8e=_0x2a4e8e||0xcc;return function(_0x10f843){if(_0x10f843){return _0x4d2229[_0x47cc('0x1c')](_0x2a4e8e);}return _0x4d2229['status'](_0x2a4e8e)[_0x47cc('0x1d')]();};}function respondWithResult(_0x58320b,_0x282a70){_0x282a70=_0x282a70||0xc8;return function(_0x26ff5b){if(_0x26ff5b){return _0x58320b[_0x47cc('0x1e')](_0x282a70)[_0x47cc('0x1f')](_0x26ff5b);}};}function respondWithFilteredResult(_0x5042ec,_0x34af0c){return function(_0x5eab65){if(_0x5eab65){var _0xc839d0=typeof _0x34af0c['offset']===_0x47cc('0x20')&&typeof _0x34af0c[_0x47cc('0x21')]===_0x47cc('0x20');var _0x1d81da=_0x5eab65[_0x47cc('0x22')];var _0x5aee09=_0xc839d0?0x0:_0x34af0c[_0x47cc('0x23')];var _0x10f4d1=_0xc839d0?_0x5eab65[_0x47cc('0x22')]:_0x34af0c[_0x47cc('0x23')]+_0x34af0c['limit'];var _0x5819bf;if(_0x10f4d1>=_0x1d81da){_0x10f4d1=_0x1d81da;_0x5819bf=0xc8;}else{_0x5819bf=0xce;}_0x5042ec[_0x47cc('0x1e')](_0x5819bf);return _0x5042ec[_0x47cc('0x24')](_0x47cc('0x25'),_0x5aee09+'-'+_0x10f4d1+'/'+_0x1d81da)[_0x47cc('0x1f')](_0x5eab65);}return null;};}function patchUpdates(_0x2753fe){return function(_0x56bb41){try{jsonpatch[_0x47cc('0x26')](_0x56bb41,_0x2753fe,!![]);}catch(_0x3355c1){return BPromise[_0x47cc('0x27')](_0x3355c1);}return _0x56bb41[_0x47cc('0x28')]();};}function saveUpdates(_0x25f4d9,_0x4eb4d6){return function(_0x3e8fc9){if(_0x3e8fc9){return _0x3e8fc9[_0x47cc('0x29')](_0x25f4d9)[_0x47cc('0x2a')](function(_0x2670de){return _0x2670de;});}return null;};}function removeEntity(_0x4bf3f1,_0x577e70){return function(_0x181985){if(_0x181985){return _0x181985[_0x47cc('0x2b')]()['then'](function(){var _0x80bf23=_0x181985[_0x47cc('0x2c')]({'plain':!![]});var _0x46288b='MailQueues';return db['UserProfileResource']['destroy']({'where':{'type':_0x46288b,'resourceId':_0x80bf23['id']}})[_0x47cc('0x2a')](function(){return _0x181985;});})[_0x47cc('0x2a')](function(){_0x4bf3f1['status'](0xcc)[_0x47cc('0x1d')]();});}};}function handleEntityNotFound(_0xaa5846,_0x3b0168){return function(_0x1c287b){if(!_0x1c287b){_0xaa5846['sendStatus'](0x194);}return _0x1c287b;};}function handleError(_0x282368,_0x145f83){_0x145f83=_0x145f83||0x1f4;return function(_0x2f91db){logger[_0x47cc('0x2d')](_0x2f91db[_0x47cc('0x2e')]);if(_0x2f91db[_0x47cc('0x2f')]){delete _0x2f91db[_0x47cc('0x2f')];}_0x282368['status'](_0x145f83)[_0x47cc('0x30')](_0x2f91db);};}exports[_0x47cc('0x31')]=function(_0x914811,_0x27f16c){var _0x476103={},_0x5ae153={},_0x3adbda={'count':0x0,'rows':[]};var _0x141fad=_[_0x47cc('0x32')](db[_0x47cc('0x33')]['rawAttributes'],function(_0x439e05){return{'name':_0x439e05['fieldName'],'type':_0x439e05['type'][_0x47cc('0x34')]};});_0x5ae153['model']=_[_0x47cc('0x32')](_0x141fad,_0x47cc('0x2f'));_0x5ae153[_0x47cc('0x35')]=_[_0x47cc('0x36')](_0x914811[_0x47cc('0x35')]);_0x5ae153[_0x47cc('0x37')]=_['intersection'](_0x5ae153[_0x47cc('0x38')],_0x5ae153[_0x47cc('0x35')]);_0x476103['attributes']=_['intersection'](_0x5ae153[_0x47cc('0x38')],qs[_0x47cc('0x39')](_0x914811[_0x47cc('0x35')][_0x47cc('0x39')]));_0x476103[_0x47cc('0x3a')]=_0x476103[_0x47cc('0x3a')]['length']?_0x476103[_0x47cc('0x3a')]:_0x5ae153[_0x47cc('0x38')];if(!_0x914811[_0x47cc('0x35')][_0x47cc('0x3b')](_0x47cc('0x3c'))){_0x476103[_0x47cc('0x21')]=qs['limit'](_0x914811[_0x47cc('0x35')][_0x47cc('0x21')]);_0x476103['offset']=qs[_0x47cc('0x23')](_0x914811[_0x47cc('0x35')][_0x47cc('0x23')]);}_0x476103[_0x47cc('0x3d')]=qs['sort'](_0x914811['query'][_0x47cc('0x3e')]);_0x476103['where']=qs[_0x47cc('0x37')](_[_0x47cc('0x3f')](_0x914811[_0x47cc('0x35')],_0x5ae153[_0x47cc('0x37')]),_0x141fad);if(_0x914811[_0x47cc('0x35')][_0x47cc('0x40')]){_0x476103[_0x47cc('0x41')]=_['merge'](_0x476103[_0x47cc('0x41')],{'$or':_[_0x47cc('0x32')](_0x141fad,function(_0x21fb9a){if(_0x21fb9a[_0x47cc('0x42')]!=='VIRTUAL'){var _0x777081={};_0x777081[_0x21fb9a[_0x47cc('0x2f')]]={'$like':'%'+_0x914811[_0x47cc('0x35')][_0x47cc('0x40')]+'%'};return _0x777081;}})});}_0x476103=_['merge']({},_0x476103,_0x914811[_0x47cc('0x43')]);var _0x32a28b={'where':_0x476103[_0x47cc('0x41')]};return db[_0x47cc('0x33')][_0x47cc('0x22')](_0x32a28b)[_0x47cc('0x2a')](function(_0x2bed9a){_0x3adbda['count']=_0x2bed9a;if(_0x914811[_0x47cc('0x35')][_0x47cc('0x44')]){_0x476103[_0x47cc('0x45')]=[{'all':!![]}];}return db['MailQueue'][_0x47cc('0x46')](_0x476103);})[_0x47cc('0x2a')](function(_0x563a7f){_0x3adbda[_0x47cc('0x47')]=_0x563a7f;return _0x3adbda;})[_0x47cc('0x2a')](respondWithFilteredResult(_0x27f16c,_0x476103))[_0x47cc('0x48')](handleError(_0x27f16c,null));};exports[_0x47cc('0x49')]=function(_0x424d78,_0x11c242){var _0x5a343b={'raw':!![],'where':{'id':_0x424d78[_0x47cc('0x4a')]['id']}},_0x532e7c={};_0x532e7c['model']=_['keys'](db[_0x47cc('0x33')][_0x47cc('0x4b')]);_0x532e7c[_0x47cc('0x35')]=_[_0x47cc('0x36')](_0x424d78[_0x47cc('0x35')]);_0x532e7c[_0x47cc('0x37')]=_['intersection'](_0x532e7c[_0x47cc('0x38')],_0x532e7c[_0x47cc('0x35')]);_0x5a343b[_0x47cc('0x3a')]=_[_0x47cc('0x4c')](_0x532e7c['model'],qs['fields'](_0x424d78[_0x47cc('0x35')][_0x47cc('0x39')]));_0x5a343b[_0x47cc('0x3a')]=_0x5a343b[_0x47cc('0x3a')]['length']?_0x5a343b[_0x47cc('0x3a')]:_0x532e7c[_0x47cc('0x38')];if(_0x424d78[_0x47cc('0x35')][_0x47cc('0x44')]){_0x5a343b[_0x47cc('0x45')]=[{'all':!![]}];}_0x5a343b=_[_0x47cc('0x4d')]({},_0x5a343b,_0x424d78['options']);return db['MailQueue'][_0x47cc('0x4e')](_0x5a343b)[_0x47cc('0x2a')](handleEntityNotFound(_0x11c242,null))['then'](respondWithResult(_0x11c242,null))['catch'](handleError(_0x11c242,null));};exports[_0x47cc('0x4f')]=function(_0x35ab10,_0x4fa2ef){return db[_0x47cc('0x33')][_0x47cc('0x4f')](_0x35ab10[_0x47cc('0x50')],{})['then'](function(_0x13188f){var _0x158889=_0x35ab10[_0x47cc('0x51')][_0x47cc('0x2c')]({'plain':!![]});if(!_0x158889)throw new Error(_0x47cc('0x52'));if(_0x158889[_0x47cc('0x53')]===_0x47cc('0x51')){var _0x3f6e22=_0x13188f['get']({'plain':!![]});var _0x3bcccd=_0x47cc('0x54');return db['UserProfileSection'][_0x47cc('0x4e')]({'where':{'name':_0x3bcccd,'userProfileId':_0x158889['userProfileId']},'raw':!![]})[_0x47cc('0x2a')](function(_0x536a2a){if(_0x536a2a&&_0x536a2a[_0x47cc('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x3f6e22[_0x47cc('0x2f')],'resourceId':_0x3f6e22['id'],'type':_0x536a2a[_0x47cc('0x2f')],'sectionId':_0x536a2a['id']},{})[_0x47cc('0x2a')](function(){return _0x13188f;});}else{return _0x13188f;}})[_0x47cc('0x48')](function(_0x127a77){logger[_0x47cc('0x2d')](_0x47cc('0x56'),_0x127a77);throw _0x127a77;});}return _0x13188f;})[_0x47cc('0x2a')](respondWithResult(_0x4fa2ef,0xc9))[_0x47cc('0x48')](handleError(_0x4fa2ef,null));};exports[_0x47cc('0x29')]=function(_0x350526,_0x3ff615){if(_0x350526[_0x47cc('0x50')]['id']){delete _0x350526['body']['id'];}return db[_0x47cc('0x33')]['find']({'where':{'id':_0x350526[_0x47cc('0x4a')]['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x3ff615,null))[_0x47cc('0x2a')](saveUpdates(_0x350526['body'],null))[_0x47cc('0x2a')](respondWithResult(_0x3ff615,null))[_0x47cc('0x48')](handleError(_0x3ff615,null));};exports['destroy']=function(_0x5a7bd2,_0x931641){return db[_0x47cc('0x33')][_0x47cc('0x4e')]({'where':{'id':_0x5a7bd2['params']['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x931641,null))[_0x47cc('0x2a')](removeEntity(_0x931641,null))[_0x47cc('0x48')](handleError(_0x931641,null));};exports[_0x47cc('0x57')]=function(_0x16edb7,_0x5a4b82){return db['MailQueue'][_0x47cc('0x57')]()[_0x47cc('0x2a')](respondWithResult(_0x5a4b82,null))['catch'](handleError(_0x5a4b82,null));};exports[_0x47cc('0x58')]=function(_0x26f753,_0x5042f1,_0x134423){var _0x3b9205={'raw':!![],'where':{}},_0x204f8c={},_0x13fcda;return db[_0x47cc('0x33')][_0x47cc('0x59')]({'where':{'id':_0x26f753[_0x47cc('0x4a')]['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x5042f1,null))['then'](function(_0x4a8d42){if(_0x4a8d42){_0x13fcda=_0x4a8d42[_0x47cc('0x2c')]({'plain':!![]});_0x204f8c[_0x47cc('0x38')]=_[_0x47cc('0x36')](db[_0x47cc('0x5a')]['rawAttributes']);_0x204f8c[_0x47cc('0x35')]=_[_0x47cc('0x36')](_0x26f753[_0x47cc('0x35')]);_0x204f8c[_0x47cc('0x37')]=_['intersection'](_0x204f8c[_0x47cc('0x38')],_0x204f8c[_0x47cc('0x35')]);_0x3b9205[_0x47cc('0x3a')]=_[_0x47cc('0x4c')](_0x204f8c[_0x47cc('0x38')],qs[_0x47cc('0x39')](_0x26f753[_0x47cc('0x35')][_0x47cc('0x39')]));_0x3b9205[_0x47cc('0x3a')]=_0x3b9205[_0x47cc('0x3a')][_0x47cc('0x5b')]?_0x3b9205['attributes']:_0x204f8c[_0x47cc('0x38')];if(!_0x26f753[_0x47cc('0x35')][_0x47cc('0x3b')](_0x47cc('0x3c'))){_0x3b9205[_0x47cc('0x21')]=qs[_0x47cc('0x21')](_0x26f753['query'][_0x47cc('0x21')]);_0x3b9205[_0x47cc('0x23')]=qs[_0x47cc('0x23')](_0x26f753[_0x47cc('0x35')][_0x47cc('0x23')]);}_0x3b9205['order']=qs[_0x47cc('0x3e')](_0x26f753[_0x47cc('0x35')][_0x47cc('0x3e')]);_0x3b9205['where']=qs[_0x47cc('0x37')](_[_0x47cc('0x3f')](_0x26f753[_0x47cc('0x35')],_0x204f8c[_0x47cc('0x37')]));_0x3b9205[_0x47cc('0x41')][_0x47cc('0x5c')]=_0x4a8d42['id'];if(_0x26f753['query'][_0x47cc('0x40')]){_0x3b9205['where']=_[_0x47cc('0x4d')](_0x3b9205['where'],{'$or':_[_0x47cc('0x32')](_0x3b9205[_0x47cc('0x3a')],function(_0x2e2d7c){var _0x3b445f={};_0x3b445f[_0x2e2d7c]={'$like':'%'+_0x26f753[_0x47cc('0x35')][_0x47cc('0x40')]+'%'};return _0x3b445f;})});}_0x3b9205=_[_0x47cc('0x4d')]({},_0x3b9205,_0x26f753[_0x47cc('0x43')]);return db[_0x47cc('0x5a')][_0x47cc('0x46')](_0x3b9205);}})['then'](function(_0x5be946){if(_0x5be946){return db[_0x47cc('0x5d')]['findAndCountAll']({'where':{'id':_[_0x47cc('0x32')](_0x5be946,_0x47cc('0x5e')),'role':'agent'},'attributes':['id',_0x47cc('0x2f'),_0x47cc('0x5f'),_0x47cc('0x60'),_0x47cc('0x61')]});}})[_0x47cc('0x2a')](function(_0x3e6d2c){if(_0x3e6d2c){return{'count':_0x3e6d2c[_0x47cc('0x22')],'rows':_[_0x47cc('0x32')](_0x3e6d2c[_0x47cc('0x47')],function(_0x3a4cce){return{'membername':_0x3a4cce[_0x47cc('0x2f')],'UserId':_0x3a4cce['id'],'queue_name':_0x13fcda[_0x47cc('0x2f')],'MailQueueId':_0x13fcda['id'],'interface':util[_0x47cc('0x62')](_0x47cc('0x63'),'SIP',_0x3a4cce[_0x47cc('0x2f')]),'penalty':0x0,'paused':_0x3a4cce[_0x47cc('0x5f')],'createdAt':_0x3a4cce['createdAt'],'updatedAt':_0x3a4cce['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5042f1,_0x3b9205))['catch'](handleError(_0x5042f1,null));};exports[_0x47cc('0x64')]=function(_0x3033e1,_0x5eb3a2,_0x2d23c7){var _0x3ccfb8={};var _0x1c7352={};var _0xaf09cc;var _0x11d787;return db[_0x47cc('0x33')][_0x47cc('0x59')]({'where':{'id':_0x3033e1[_0x47cc('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5eb3a2,null))[_0x47cc('0x2a')](function(_0x521df8){if(_0x521df8){_0xaf09cc=_0x521df8;_0x1c7352[_0x47cc('0x38')]=_[_0x47cc('0x36')](db[_0x47cc('0x65')][_0x47cc('0x4b')]);_0x1c7352[_0x47cc('0x35')]=_[_0x47cc('0x36')](_0x3033e1[_0x47cc('0x35')]);_0x1c7352[_0x47cc('0x37')]=_[_0x47cc('0x4c')](_0x1c7352['model'],_0x1c7352[_0x47cc('0x35')]);_0x3ccfb8[_0x47cc('0x3a')]=_[_0x47cc('0x4c')](_0x1c7352[_0x47cc('0x38')],qs[_0x47cc('0x39')](_0x3033e1['query'][_0x47cc('0x39')]));_0x3ccfb8['attributes']=_0x3ccfb8[_0x47cc('0x3a')][_0x47cc('0x5b')]?_0x3ccfb8[_0x47cc('0x3a')]:_0x1c7352[_0x47cc('0x38')];_0x3ccfb8['order']=qs[_0x47cc('0x3e')](_0x3033e1[_0x47cc('0x35')][_0x47cc('0x3e')]);_0x3ccfb8[_0x47cc('0x41')]=qs[_0x47cc('0x37')](_['pick'](_0x3033e1['query'],_0x1c7352[_0x47cc('0x37')]));if(_0x3033e1[_0x47cc('0x35')][_0x47cc('0x40')]){_0x3ccfb8[_0x47cc('0x41')]=_[_0x47cc('0x4d')](_0x3ccfb8[_0x47cc('0x41')],{'$or':_[_0x47cc('0x32')](_0x3ccfb8[_0x47cc('0x3a')],function(_0xaa0701){var _0x549b99={};_0x549b99[_0xaa0701]={'$like':'%'+_0x3033e1[_0x47cc('0x35')][_0x47cc('0x40')]+'%'};return _0x549b99;})});}_0x3ccfb8=_[_0x47cc('0x4d')]({},_0x3ccfb8,_0x3033e1[_0x47cc('0x43')]);return _0xaf09cc[_0x47cc('0x64')](_0x3ccfb8);}})[_0x47cc('0x2a')](function(_0x1dbdb4){if(_0x1dbdb4){_0x11d787=_0x1dbdb4['length'];if(!_0x3033e1[_0x47cc('0x35')][_0x47cc('0x3b')](_0x47cc('0x3c'))){_0x3ccfb8[_0x47cc('0x21')]=qs['limit'](_0x3033e1['query'][_0x47cc('0x21')]);_0x3ccfb8[_0x47cc('0x23')]=qs[_0x47cc('0x23')](_0x3033e1[_0x47cc('0x35')]['offset']);}return _0xaf09cc[_0x47cc('0x64')](_0x3ccfb8);}})['then'](function(_0x2a443d){if(_0x2a443d){return _0x2a443d?{'count':_0x11d787,'rows':_0x2a443d}:null;}})[_0x47cc('0x2a')](respondWithResult(_0x5eb3a2,null))[_0x47cc('0x48')](handleError(_0x5eb3a2,null));};exports['addTeams']=function(_0x948c5b,_0x366498,_0x45b8af){var _0x116aac=_0x948c5b[_0x47cc('0x50')][_0x47cc('0x66')];return db[_0x47cc('0x65')][_0x47cc('0x46')]({'where':{'id':_0x116aac},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name','online',_0x47cc('0x67'),_0x47cc('0x68')],'raw':!![]}]})['then'](function(_0x4524a1){if(_0x4524a1){var _0x369f00=_[_0x47cc('0x69')](_0x4524a1,function(_0x3ed36a){var _0x191fc1=_0x3ed36a[_0x47cc('0x2c')]({'plain':!![]});return _0x191fc1[_0x47cc('0x6a')];});return db['MailQueue'][_0x47cc('0x4e')]({'where':{'id':_0x948c5b[_0x47cc('0x4a')]['id']}})[_0x47cc('0x2a')](function(_0x4626a3){return db[_0x47cc('0x6b')][_0x47cc('0x6c')](function(_0x593a93){return _0x4626a3[_0x47cc('0x6d')](_0x116aac,{'transaction':_0x593a93})[_0x47cc('0x2a')](function(){return BPromise['each'](_0x369f00,function(_0xb3b53e){return db[_0x47cc('0x5a')][_0x47cc('0x6e')]({'where':{'UserId':_0xb3b53e['id'],'MailQueueId':_0x948c5b[_0x47cc('0x4a')]['id']},'transaction':_0x593a93});});})[_0x47cc('0x2a')](function(){_0x369f00[_0x47cc('0x6f')](function(_0x14d6ac){socket['emit'](_0x47cc('0x70'),{'UserId':_0x14d6ac['id'],'MailQueueId':_0x4626a3['id']});});});});});}})['then'](respondWithStatusCode(_0x366498,null))[_0x47cc('0x48')](handleError(_0x366498,null));};exports[_0x47cc('0x71')]=function(_0x20bbb6,_0x20332c,_0x18cbaa){return db[_0x47cc('0x65')][_0x47cc('0x46')]({'where':{'id':_0x20bbb6[_0x47cc('0x35')][_0x47cc('0x66')]},'attributes':['id'],'include':[{'model':db[_0x47cc('0x5d')],'as':_0x47cc('0x6a'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x20332c,null))[_0x47cc('0x2a')](function(_0x46b3d1){var _0x21f341=_[_0x47cc('0x32')](_0x46b3d1,'id');var _0x4a1850=[];var _0x590e28=[];var _0x5a283c=squel[_0x47cc('0x72')]();_0x5a283c[_0x47cc('0x73')]('tq.TeamId')[_0x47cc('0x74')](_0x47cc('0x75'),'tq')[_0x47cc('0x76')]('user_has_teams','ut',_0x47cc('0x77'))[_0x47cc('0x41')]('MailQueueId\x20=\x20?',_0x20bbb6[_0x47cc('0x4a')]['id']);for(var _0x5a91f8=0x0;_0x5a91f8<_0x46b3d1[_0x47cc('0x5b')];_0x5a91f8+=0x1){let _0x4eee17=_0x46b3d1[_0x5a91f8];for(var _0x14fba1=0x0;_0x14fba1<_0x4eee17[_0x47cc('0x6a')]['length'];_0x14fba1+=0x1){let _0x498fcb=_0x4eee17['Agents'][_0x14fba1];var _0x50554d=_0x5a283c['clone']();_0x50554d['where'](_0x47cc('0x78'),_0x498fcb['id']);_0x590e28[_0x47cc('0x79')](db[_0x47cc('0x6b')][_0x47cc('0x35')](_0x50554d[_0x47cc('0x7a')](),{'type':db['sequelize'][_0x47cc('0x7b')][_0x47cc('0x7c')]})[_0x47cc('0x2a')](function(_0x40dcc9){if(_0x40dcc9[_0x47cc('0x5b')]===0x1){return _0x498fcb['id'];}else{var _0x10f76a=_['every'](_[_0x47cc('0x32')](_0x40dcc9,_0x47cc('0x7d')),function(_0x4af1d8){return _[_0x47cc('0x7e')](_0x21f341,_0x4af1d8);});if(_0x10f76a){return _0x498fcb['id'];}}}));}}return BPromise['all'](_0x590e28)[_0x47cc('0x2a')](function(_0x120ae1){_0x4a1850=_(_0x4a1850)[_0x47cc('0x7f')](_0x120ae1)[_0x47cc('0x80')]()[_0x47cc('0x81')]();return db[_0x47cc('0x33')][_0x47cc('0x4e')]({'where':{'id':_0x20bbb6['params']['id']}})[_0x47cc('0x2a')](function(_0x5034cd){return db[_0x47cc('0x6b')][_0x47cc('0x6c')](function(_0xbce338){return _0x5034cd['removeTeams'](_0x20bbb6[_0x47cc('0x35')][_0x47cc('0x66')],{'transaction':_0xbce338})['then'](function(){if(!_[_0x47cc('0x82')](_0x4a1850)){return _0x5034cd['removeAgents'](_0x4a1850,{'transaction':_0xbce338});}})[_0x47cc('0x2a')](function(){_0x4a1850[_0x47cc('0x6f')](function(_0x5a7b9b){socket[_0x47cc('0x83')](_0x47cc('0x84'),{'UserId':_0x5a7b9b,'MailQueueId':_0x5034cd['id']});});});});});});})[_0x47cc('0x2a')](respondWithStatusCode(_0x20332c,null))['catch'](handleError(_0x20332c,null));};exports['addAgents']=function(_0x40706c,_0x5e0cf2,_0x30c92c){return db['MailQueue'][_0x47cc('0x4e')]({'where':{'id':_0x40706c['params']['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x5e0cf2,null))[_0x47cc('0x2a')](function(_0x9f05e1){if(_0x9f05e1){return _0x9f05e1[_0x47cc('0x85')](_0x40706c[_0x47cc('0x50')][_0x47cc('0x66')],_[_0x47cc('0x86')](_0x40706c[_0x47cc('0x50')],[_0x47cc('0x66'),'id'])||{})[_0x47cc('0x87')](function(_0x1ec552){for(var _0x48d360=0x0;_0x48d360<_0x40706c['body']['ids'][_0x47cc('0x5b')];_0x48d360+=0x1){socket['emit'](_0x47cc('0x70'),{'UserId':Number(_0x40706c['body']['ids'][_0x48d360]),'MailQueueId':Number(_0x40706c[_0x47cc('0x4a')]['id'])});}return _0x1ec552;});}})[_0x47cc('0x2a')](respondWithResult(_0x5e0cf2,null))['catch'](handleError(_0x5e0cf2,null));};exports[_0x47cc('0x88')]=function(_0x53026e,_0x599f6c,_0x2979ce){return db[_0x47cc('0x33')][_0x47cc('0x4e')]({'where':{'id':_0x53026e[_0x47cc('0x4a')]['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x599f6c,null))[_0x47cc('0x2a')](function(_0x2178f7){if(_0x2178f7){return _0x2178f7[_0x47cc('0x88')](_0x53026e[_0x47cc('0x35')][_0x47cc('0x66')])[_0x47cc('0x2a')](function(){if(_[_0x47cc('0x89')](_0x53026e['query'][_0x47cc('0x66')])){for(var _0x3455ef=0x0;_0x3455ef<_0x53026e[_0x47cc('0x35')][_0x47cc('0x66')][_0x47cc('0x5b')];_0x3455ef+=0x1){socket[_0x47cc('0x83')](_0x47cc('0x84'),{'UserId':Number(_0x53026e[_0x47cc('0x35')][_0x47cc('0x66')][_0x3455ef]),'MailQueueId':Number(_0x53026e[_0x47cc('0x4a')]['id'])});}}else{socket[_0x47cc('0x83')](_0x47cc('0x84'),{'UserId':Number(_0x53026e['query'][_0x47cc('0x66')]),'MailQueueId':Number(_0x53026e['params']['id'])});}});}})[_0x47cc('0x2a')](respondWithStatusCode(_0x599f6c,null))[_0x47cc('0x48')](handleError(_0x599f6c,null));};exports[_0x47cc('0x8a')]=function(_0x2c6247,_0x5e145e,_0x58ee40){var _0x1dddb2={};var _0x964827={};var _0x180ba6;var _0x45fe30;return db[_0x47cc('0x33')][_0x47cc('0x59')]({'where':{'id':_0x2c6247['params']['id']}})[_0x47cc('0x2a')](handleEntityNotFound(_0x5e145e,null))[_0x47cc('0x2a')](function(_0x5d94d9){if(_0x5d94d9){_0x180ba6=_0x5d94d9;_0x964827['model']=_['keys'](db['User']['rawAttributes']);_0x964827['query']=_[_0x47cc('0x36')](_0x2c6247[_0x47cc('0x35')]);_0x964827[_0x47cc('0x37')]=_[_0x47cc('0x4c')](_0x964827[_0x47cc('0x38')],_0x964827[_0x47cc('0x35')]);_0x1dddb2[_0x47cc('0x3a')]=_[_0x47cc('0x4c')](_0x964827['model'],qs[_0x47cc('0x39')](_0x2c6247[_0x47cc('0x35')][_0x47cc('0x39')]));_0x1dddb2[_0x47cc('0x3a')]=_0x1dddb2['attributes'][_0x47cc('0x5b')]?_0x1dddb2[_0x47cc('0x3a')]:_0x964827[_0x47cc('0x38')];_0x1dddb2['order']=qs[_0x47cc('0x3e')](_0x2c6247[_0x47cc('0x35')]['sort']);_0x1dddb2[_0x47cc('0x41')]=qs[_0x47cc('0x37')](_[_0x47cc('0x3f')](_0x2c6247[_0x47cc('0x35')],_0x964827[_0x47cc('0x37')]));if(_0x2c6247[_0x47cc('0x35')][_0x47cc('0x40')]){_0x1dddb2[_0x47cc('0x41')]=_[_0x47cc('0x4d')](_0x1dddb2[_0x47cc('0x41')],{'$or':_['map'](_0x1dddb2['attributes'],function(_0x1680a7){var _0x649941={};_0x649941[_0x1680a7]={'$like':'%'+_0x2c6247['query']['filter']+'%'};return _0x649941;})});}_0x1dddb2=_['merge']({},_0x1dddb2,_0x2c6247[_0x47cc('0x43')]);return _0x180ba6[_0x47cc('0x8a')](_0x1dddb2);}})[_0x47cc('0x2a')](function(_0x340018){if(_0x340018){_0x45fe30=_0x340018[_0x47cc('0x5b')];if(!_0x2c6247[_0x47cc('0x35')][_0x47cc('0x3b')](_0x47cc('0x3c'))){_0x1dddb2[_0x47cc('0x21')]=qs[_0x47cc('0x21')](_0x2c6247[_0x47cc('0x35')][_0x47cc('0x21')]);_0x1dddb2[_0x47cc('0x23')]=qs['offset'](_0x2c6247['query'][_0x47cc('0x23')]);}return _0x180ba6['getAgents'](_0x1dddb2);}})[_0x47cc('0x2a')](function(_0x4c7def){if(_0x4c7def){return _0x4c7def?{'count':_0x45fe30,'rows':_0x4c7def}:null;}})[_0x47cc('0x2a')](respondWithResult(_0x5e145e,null))[_0x47cc('0x48')](handleError(_0x5e145e,null));}; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.events.js b/server/api/mailQueue/mailQueue.events.js new file mode 100644 index 0000000..0da4b80 --- /dev/null +++ b/server/api/mailQueue/mailQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x666a=['save','update','remove','emit','hook','setMaxListeners'];(function(_0x6767c6,_0xbae02){var _0x30cc74=function(_0x3cc837){while(--_0x3cc837){_0x6767c6['push'](_0x6767c6['shift']());}};_0x30cc74(++_0xbae02);}(_0x666a,0xbf));var _0xa666=function(_0x1ceca7,_0x3f3754){_0x1ceca7=_0x1ceca7-0x0;var _0x1654d9=_0x666a[_0x1ceca7];return _0x1654d9;};'use strict';var EventEmitter=require('events');var MailQueue=require('../../mysqldb')['db']['MailQueue'];var MailQueueEvents=new EventEmitter();MailQueueEvents[_0xa666('0x0')](0x0);var events={'afterCreate':_0xa666('0x1'),'afterUpdate':_0xa666('0x2'),'afterDestroy':_0xa666('0x3')};function emitEvent(_0x3141c3){return function(_0x236c57,_0x7d142d,_0x17d7d1){MailQueueEvents['emit'](_0x3141c3+':'+_0x236c57['id'],_0x236c57);MailQueueEvents[_0xa666('0x4')](_0x3141c3,_0x236c57);_0x17d7d1(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailQueue[_0xa666('0x5')](e,emitEvent(event));}}module['exports']=MailQueueEvents; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.model.js b/server/api/mailQueue/mailQueue.model.js new file mode 100644 index 0000000..4e08208 --- /dev/null +++ b/server/api/mailQueue/mailQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x940f=['request-promise','path','rimraf','./mailQueue.attributes','exports','MailQueue','lodash','../../config/logger','moment','bluebird'];(function(_0x4df06f,_0x468fb0){var _0x2fa5cb=function(_0x222a4f){while(--_0x222a4f){_0x4df06f['push'](_0x4df06f['shift']());}};_0x2fa5cb(++_0x468fb0);}(_0x940f,0x1c8));var _0xf940=function(_0x590feb,_0x3055d9){_0x590feb=_0x590feb-0x0;var _0x3901bb=_0x940f[_0x590feb];return _0x3901bb;};'use strict';var _=require(_0xf940('0x0'));var util=require('util');var logger=require(_0xf940('0x1'))('api');var moment=require(_0xf940('0x2'));var BPromise=require(_0xf940('0x3'));var rp=require(_0xf940('0x4'));var fs=require('fs');var path=require(_0xf940('0x5'));var rimraf=require(_0xf940('0x6'));var config=require('../../config/environment');var attributes=require(_0xf940('0x7'));module[_0xf940('0x8')]=function(_0x2fb0fe,_0x41c12a){return _0x2fb0fe['define'](_0xf940('0x9'),attributes,{'tableName':'mail_queues','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.rpc.js b/server/api/mailQueue/mailQueue.rpc.js new file mode 100644 index 0000000..d7f2f0b --- /dev/null +++ b/server/api/mailQueue/mailQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5e4b=['where','attributes','include','map','model','ShowMailQueue','MailQueue','find','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','redis','localhost','socket.io-emitter','./mailQueue.socket','register','request','then','MailQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','info','catch','GetMailQueue','findAll','options','raw'];(function(_0x3b93ef,_0x5b9eac){var _0x3cef85=function(_0x8bb24f){while(--_0x8bb24f){_0x3b93ef['push'](_0x3b93ef['shift']());}};_0x3cef85(++_0x5b9eac);}(_0x5e4b,0x7a));var _0xb5e4=function(_0xd1d19a,_0x1933f0){_0xd1d19a=_0xd1d19a-0x0;var _0x52a79d=_0x5e4b[_0xd1d19a];return _0x52a79d;};'use strict';var _=require('lodash');var util=require(_0xb5e4('0x0'));var moment=require(_0xb5e4('0x1'));var BPromise=require('bluebird');var rs=require(_0xb5e4('0x2'));var fs=require('fs');var Redis=require(_0xb5e4('0x3'));var db=require(_0xb5e4('0x4'))['db'];var utils=require(_0xb5e4('0x5'));var logger=require(_0xb5e4('0x6'))(_0xb5e4('0x7'));var config=require(_0xb5e4('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb5e4('0x9')]['http']({'port':0x232a});config[_0xb5e4('0xa')]=_['defaults'](config['redis'],{'host':_0xb5e4('0xb'),'port':0x18eb});var socket=require(_0xb5e4('0xc'))(new Redis(config[_0xb5e4('0xa')]));require(_0xb5e4('0xd'))[_0xb5e4('0xe')](socket);function respondWithRpcPromise(_0x5c8bc3,_0x35e23e,_0x504118){return new BPromise(function(_0x1ca950,_0xa0902f){return client[_0xb5e4('0xf')](_0x5c8bc3,_0x504118)[_0xb5e4('0x10')](function(_0x47bf1d){logger['info'](_0xb5e4('0x11'),_0x35e23e,_0xb5e4('0x12'));logger[_0xb5e4('0x13')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x35e23e,_0xb5e4('0x12'),JSON[_0xb5e4('0x14')](_0x47bf1d));if(_0x47bf1d['error']){if(_0x47bf1d['error'][_0xb5e4('0x15')]===0x1f4){logger[_0xb5e4('0x16')]('MailQueue,\x20%s,\x20%s',_0x35e23e,_0x47bf1d[_0xb5e4('0x16')][_0xb5e4('0x17')]);return _0xa0902f(_0x47bf1d[_0xb5e4('0x16')][_0xb5e4('0x17')]);}logger[_0xb5e4('0x16')](_0xb5e4('0x11'),_0x35e23e,_0x47bf1d[_0xb5e4('0x16')][_0xb5e4('0x17')]);return _0x1ca950(_0x47bf1d[_0xb5e4('0x16')][_0xb5e4('0x17')]);}else{logger[_0xb5e4('0x18')](_0xb5e4('0x11'),_0x35e23e,_0xb5e4('0x12'));_0x1ca950(_0x47bf1d['result']['message']);}})[_0xb5e4('0x19')](function(_0x2d119a){logger[_0xb5e4('0x16')](_0xb5e4('0x11'),_0x35e23e,_0x2d119a);_0xa0902f(_0x2d119a);});});}exports[_0xb5e4('0x1a')]=function(_0x1bcd21){var _0x147cd3=this;return new Promise(function(_0x2597f9,_0x206be5){return db['MailQueue'][_0xb5e4('0x1b')]({'raw':_0x1bcd21['options']?_0x1bcd21[_0xb5e4('0x1c')][_0xb5e4('0x1d')]===undefined?!![]:![]:!![],'where':_0x1bcd21[_0xb5e4('0x1c')]?_0x1bcd21[_0xb5e4('0x1c')][_0xb5e4('0x1e')]||null:null,'attributes':_0x1bcd21[_0xb5e4('0x1c')]?_0x1bcd21[_0xb5e4('0x1c')][_0xb5e4('0x1f')]||null:null,'limit':_0x1bcd21[_0xb5e4('0x1c')]?_0x1bcd21['options']['limit']||null:null,'include':_0x1bcd21['options']?_0x1bcd21[_0xb5e4('0x1c')][_0xb5e4('0x20')]?_[_0xb5e4('0x21')](_0x1bcd21['options'][_0xb5e4('0x20')],function(_0x2414b4){return{'model':db[_0x2414b4[_0xb5e4('0x22')]],'as':_0x2414b4['as'],'attributes':_0x2414b4[_0xb5e4('0x1f')],'include':_0x2414b4[_0xb5e4('0x20')]?_['map'](_0x2414b4[_0xb5e4('0x20')],function(_0x2311c7){return{'model':db[_0x2311c7['model']],'as':_0x2311c7['as'],'attributes':_0x2311c7[_0xb5e4('0x1f')],'include':_0x2311c7[_0xb5e4('0x20')]?_[_0xb5e4('0x21')](_0x2311c7[_0xb5e4('0x20')],function(_0xffcb75){return{'model':db[_0xffcb75[_0xb5e4('0x22')]],'as':_0xffcb75['as'],'attributes':_0xffcb75[_0xb5e4('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb5e4('0x10')](function(_0x2691b3){logger[_0xb5e4('0x18')](_0xb5e4('0x1a'),_0x1bcd21);logger[_0xb5e4('0x13')](_0xb5e4('0x1a'),_0x1bcd21,JSON['stringify'](_0x2691b3));_0x2597f9(_0x2691b3);})[_0xb5e4('0x19')](function(_0x26f6f7){logger[_0xb5e4('0x16')](_0xb5e4('0x1a'),_0x26f6f7['message'],_0x1bcd21);_0x206be5(_0x147cd3[_0xb5e4('0x16')](0x1f4,_0x26f6f7['message']));});});};exports[_0xb5e4('0x23')]=function(_0xdf6a19){var _0x205d02=this;return new Promise(function(_0x8c8835,_0x47106d){return db[_0xb5e4('0x24')][_0xb5e4('0x25')]({'raw':_0xdf6a19['options']?_0xdf6a19[_0xb5e4('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0xdf6a19[_0xb5e4('0x1c')]?_0xdf6a19[_0xb5e4('0x1c')][_0xb5e4('0x1e')]||null:null,'attributes':_0xdf6a19[_0xb5e4('0x1c')]?_0xdf6a19[_0xb5e4('0x1c')][_0xb5e4('0x1f')]||null:null,'include':_0xdf6a19[_0xb5e4('0x1c')]?_0xdf6a19['options']['include']?_[_0xb5e4('0x21')](_0xdf6a19['options']['include'],function(_0x594fd3){return{'model':db[_0x594fd3[_0xb5e4('0x22')]],'as':_0x594fd3['as'],'attributes':_0x594fd3[_0xb5e4('0x1f')],'include':_0x594fd3[_0xb5e4('0x20')]?_['map'](_0x594fd3[_0xb5e4('0x20')],function(_0x5920fb){return{'model':db[_0x5920fb[_0xb5e4('0x22')]],'as':_0x5920fb['as'],'attributes':_0x5920fb[_0xb5e4('0x1f')],'include':_0x5920fb[_0xb5e4('0x20')]?_['map'](_0x5920fb['include'],function(_0x1b7866){return{'model':db[_0x1b7866['model']],'as':_0x1b7866['as'],'attributes':_0x1b7866['attributes']};}):[]};}):[]};}):[]:[]})[_0xb5e4('0x10')](function(_0x1435b3){logger[_0xb5e4('0x18')](_0xb5e4('0x23'),_0xdf6a19);logger['debug'](_0xb5e4('0x23'),_0xdf6a19,JSON['stringify'](_0x1435b3));_0x8c8835(_0x1435b3);})[_0xb5e4('0x19')](function(_0x3e405a){logger['error'](_0xb5e4('0x23'),_0x3e405a[_0xb5e4('0x17')],_0xdf6a19);_0x47106d(_0x205d02[_0xb5e4('0x16')](0x1f4,_0x3e405a['message']));});});}; \ No newline at end of file diff --git a/server/api/mailQueue/mailQueue.socket.js b/server/api/mailQueue/mailQueue.socket.js new file mode 100644 index 0000000..58c836c --- /dev/null +++ b/server/api/mailQueue/mailQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf929=['removeListener','register','length','mailQueue:','./mailQueue.events','remove','update','emit'];(function(_0x5e9e30,_0x55b114){var _0x493af5=function(_0x2eb96b){while(--_0x2eb96b){_0x5e9e30['push'](_0x5e9e30['shift']());}};_0x493af5(++_0x55b114);}(_0xf929,0x164));var _0x9f92=function(_0x23b110,_0x1173ba){_0x23b110=_0x23b110-0x0;var _0x39d441=_0xf929[_0x23b110];return _0x39d441;};'use strict';var MailQueueEvents=require(_0x9f92('0x0'));var events=['save',_0x9f92('0x1'),_0x9f92('0x2')];function createListener(_0x55d60d,_0x451ded){return function(_0x366b0d){_0x451ded[_0x9f92('0x3')](_0x55d60d,_0x366b0d);};}function removeListener(_0x5840d9,_0x3aca39){return function(){MailQueueEvents[_0x9f92('0x4')](_0x5840d9,_0x3aca39);};}exports[_0x9f92('0x5')]=function(_0x2fbe4d){for(var _0x396372=0x0,_0x29a770=events[_0x9f92('0x6')];_0x396372<_0x29a770;_0x396372++){var _0x5f343f=events[_0x396372];var _0x98a2f5=createListener(_0x9f92('0x7')+_0x5f343f,_0x2fbe4d);MailQueueEvents['on'](_0x5f343f,_0x98a2f5);}}; \ No newline at end of file diff --git a/server/api/mailQueueReport/index.js b/server/api/mailQueueReport/index.js new file mode 100644 index 0000000..7afcb21 --- /dev/null +++ b/server/api/mailQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xddeb=['put','/:id','update','delete','exports','util','path','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','get','isAuthenticated','index','/describe','describe','show','post','create'];(function(_0x459a97,_0x3d2ece){var _0x56bb18=function(_0x2375d9){while(--_0x2375d9){_0x459a97['push'](_0x459a97['shift']());}};_0x56bb18(++_0x3d2ece);}(_0xddeb,0x10f));var _0xbdde=function(_0x38854e,_0x23cbc9){_0x38854e=_0x38854e-0x0;var _0x3f8415=_0xddeb[_0x38854e];return _0x3f8415;};'use strict';var multer=require('multer');var util=require(_0xbdde('0x0'));var path=require(_0xbdde('0x1'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0xbdde('0x2')]();var fs_extra=require('fs-extra');var auth=require(_0xbdde('0x3'));var interaction=require(_0xbdde('0x4'));var config=require(_0xbdde('0x5'));var controller=require('./mailQueueReport.controller');router[_0xbdde('0x6')]('/',auth[_0xbdde('0x7')](),controller[_0xbdde('0x8')]);router[_0xbdde('0x6')](_0xbdde('0x9'),auth[_0xbdde('0x7')](),controller[_0xbdde('0xa')]);router[_0xbdde('0x6')]('/:id',auth[_0xbdde('0x7')](),controller[_0xbdde('0xb')]);router[_0xbdde('0xc')]('/',auth[_0xbdde('0x7')](),controller[_0xbdde('0xd')]);router[_0xbdde('0xe')](_0xbdde('0xf'),auth[_0xbdde('0x7')](),controller[_0xbdde('0x10')]);router[_0xbdde('0x11')]('/:id',auth[_0xbdde('0x7')](),controller['destroy']);module[_0xbdde('0x12')]=router; \ No newline at end of file diff --git a/server/api/mailQueueReport/mailQueueReport.attributes.js b/server/api/mailQueueReport/mailQueueReport.attributes.js new file mode 100644 index 0000000..ea317ed --- /dev/null +++ b/server/api/mailQueueReport/mailQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7f90=['sequelize','STRING','DATE'];(function(_0x434b31,_0x1cc3f3){var _0x49dee7=function(_0x857d0e){while(--_0x857d0e){_0x434b31['push'](_0x434b31['shift']());}};_0x49dee7(++_0x1cc3f3);}(_0x7f90,0x1c5));var _0x07f9=function(_0x53f5bb,_0x5d45ce){_0x53f5bb=_0x53f5bb-0x0;var _0x4de461=_0x7f90[_0x53f5bb];return _0x4de461;};'use strict';var moment=require('moment');var Sequelize=require(_0x07f9('0x0'));module['exports']={'uniqueid':{'type':Sequelize['STRING'],'allowNull':![]},'from':{'type':Sequelize[_0x07f9('0x1')]},'joinAt':{'type':Sequelize['DATE']},'leaveAt':{'type':Sequelize[_0x07f9('0x2')]},'acceptAt':{'type':Sequelize['DATE']},'exitAt':{'type':Sequelize[_0x07f9('0x2')]},'reason':{'type':Sequelize[_0x07f9('0x1')]}}; \ No newline at end of file diff --git a/server/api/mailQueueReport/mailQueueReport.controller.js b/server/api/mailQueueReport/mailQueueReport.controller.js new file mode 100644 index 0000000..7077f12 --- /dev/null +++ b/server/api/mailQueueReport/mailQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1a37=['index','map','MailQueueReport','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filter','VIRTUAL','merge','includeAll','include','findAll','catch','show','options','find','create','body','params','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','error','stack','name','send'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x1a37,0xb4));var _0x71a3=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x1a37[_0x53ccf2];return _0x5a2964;};'use strict';var emlformat=require(_0x71a3('0x0'));var rimraf=require(_0x71a3('0x1'));var zipdir=require(_0x71a3('0x2'));var jsonpatch=require(_0x71a3('0x3'));var rp=require(_0x71a3('0x4'));var moment=require(_0x71a3('0x5'));var BPromise=require(_0x71a3('0x6'));var Mustache=require(_0x71a3('0x7'));var util=require(_0x71a3('0x8'));var path=require(_0x71a3('0x9'));var sox=require('sox');var csv=require(_0x71a3('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x71a3('0xb'));var _=require(_0x71a3('0xc'));var squel=require(_0x71a3('0xd'));var crypto=require(_0x71a3('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x71a3('0xf'));var Redis=require(_0x71a3('0x10'));var authService=require(_0x71a3('0x11'));var qs=require(_0x71a3('0x12'));var as=require(_0x71a3('0x13'));var hardwareService=require(_0x71a3('0x14'));var logger=require(_0x71a3('0x15'))(_0x71a3('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x71a3('0x17'))['db'];function respondWithStatusCode(_0x3830cb,_0x27e46d){_0x27e46d=_0x27e46d||0xcc;return function(_0x229134){if(_0x229134){return _0x3830cb[_0x71a3('0x18')](_0x27e46d);}return _0x3830cb[_0x71a3('0x19')](_0x27e46d)[_0x71a3('0x1a')]();};}function respondWithResult(_0x3b256c,_0x4dc4ed){_0x4dc4ed=_0x4dc4ed||0xc8;return function(_0x203ee1){if(_0x203ee1){return _0x3b256c[_0x71a3('0x19')](_0x4dc4ed)['json'](_0x203ee1);}};}function respondWithFilteredResult(_0x1743d7,_0x32591a){return function(_0x59021f){if(_0x59021f){var _0x4aa918=typeof _0x32591a[_0x71a3('0x1b')]===_0x71a3('0x1c')&&typeof _0x32591a[_0x71a3('0x1d')]===_0x71a3('0x1c');var _0x1af1bc=_0x59021f[_0x71a3('0x1e')];var _0x5d4dee=_0x4aa918?0x0:_0x32591a[_0x71a3('0x1b')];var _0x27bfb4=_0x4aa918?_0x59021f['count']:_0x32591a['offset']+_0x32591a[_0x71a3('0x1d')];var _0x250db3;if(_0x27bfb4>=_0x1af1bc){_0x27bfb4=_0x1af1bc;_0x250db3=0xc8;}else{_0x250db3=0xce;}_0x1743d7[_0x71a3('0x19')](_0x250db3);return _0x1743d7[_0x71a3('0x1f')](_0x71a3('0x20'),_0x5d4dee+'-'+_0x27bfb4+'/'+_0x1af1bc)['json'](_0x59021f);}return null;};}function patchUpdates(_0x1ab947){return function(_0x4156e1){try{jsonpatch[_0x71a3('0x21')](_0x4156e1,_0x1ab947,!![]);}catch(_0x3ea036){return BPromise[_0x71a3('0x22')](_0x3ea036);}return _0x4156e1['save']();};}function saveUpdates(_0x1af24b,_0x5bbaee){return function(_0x3bf78e){if(_0x3bf78e){return _0x3bf78e[_0x71a3('0x23')](_0x1af24b)[_0x71a3('0x24')](function(_0x21899d){return _0x21899d;});}return null;};}function removeEntity(_0x452bc4,_0x2847b4){return function(_0x5f33c5){if(_0x5f33c5){return _0x5f33c5[_0x71a3('0x25')]()[_0x71a3('0x24')](function(){_0x452bc4[_0x71a3('0x19')](0xcc)[_0x71a3('0x1a')]();});}};}function handleEntityNotFound(_0xb0f3aa,_0x4fd214){return function(_0x107fbd){if(!_0x107fbd){_0xb0f3aa[_0x71a3('0x18')](0x194);}return _0x107fbd;};}function handleError(_0x4c1a3d,_0x412746){_0x412746=_0x412746||0x1f4;return function(_0x515519){logger[_0x71a3('0x26')](_0x515519[_0x71a3('0x27')]);if(_0x515519[_0x71a3('0x28')]){delete _0x515519[_0x71a3('0x28')];}_0x4c1a3d[_0x71a3('0x19')](_0x412746)[_0x71a3('0x29')](_0x515519);};}exports[_0x71a3('0x2a')]=function(_0x242b85,_0x305eb1){var _0x3fc578={},_0x3ea7aa={},_0x228afa={'count':0x0,'rows':[]};var _0x51cde3=_[_0x71a3('0x2b')](db[_0x71a3('0x2c')][_0x71a3('0x2d')],function(_0x23ae85){return{'name':_0x23ae85['fieldName'],'type':_0x23ae85[_0x71a3('0x2e')][_0x71a3('0x2f')]};});_0x3ea7aa[_0x71a3('0x30')]=_[_0x71a3('0x2b')](_0x51cde3,_0x71a3('0x28'));_0x3ea7aa[_0x71a3('0x31')]=_[_0x71a3('0x32')](_0x242b85['query']);_0x3ea7aa[_0x71a3('0x33')]=_[_0x71a3('0x34')](_0x3ea7aa[_0x71a3('0x30')],_0x3ea7aa[_0x71a3('0x31')]);_0x3fc578[_0x71a3('0x35')]=_[_0x71a3('0x34')](_0x3ea7aa[_0x71a3('0x30')],qs[_0x71a3('0x36')](_0x242b85[_0x71a3('0x31')][_0x71a3('0x36')]));_0x3fc578[_0x71a3('0x35')]=_0x3fc578[_0x71a3('0x35')][_0x71a3('0x37')]?_0x3fc578['attributes']:_0x3ea7aa['model'];if(!_0x242b85[_0x71a3('0x31')][_0x71a3('0x38')]('nolimit')){_0x3fc578[_0x71a3('0x1d')]=qs[_0x71a3('0x1d')](_0x242b85['query'][_0x71a3('0x1d')]);_0x3fc578[_0x71a3('0x1b')]=qs[_0x71a3('0x1b')](_0x242b85[_0x71a3('0x31')][_0x71a3('0x1b')]);}_0x3fc578[_0x71a3('0x39')]=qs[_0x71a3('0x3a')](_0x242b85['query'][_0x71a3('0x3a')]);_0x3fc578[_0x71a3('0x3b')]=qs[_0x71a3('0x33')](_['pick'](_0x242b85[_0x71a3('0x31')],_0x3ea7aa[_0x71a3('0x33')]),_0x51cde3);if(_0x242b85[_0x71a3('0x31')][_0x71a3('0x3c')]){_0x3fc578[_0x71a3('0x3b')]=_['merge'](_0x3fc578['where'],{'$or':_[_0x71a3('0x2b')](_0x51cde3,function(_0x2b3197){if(_0x2b3197[_0x71a3('0x2e')]!==_0x71a3('0x3d')){var _0x36ed2e={};_0x36ed2e[_0x2b3197['name']]={'$like':'%'+_0x242b85[_0x71a3('0x31')][_0x71a3('0x3c')]+'%'};return _0x36ed2e;}})});}_0x3fc578=_[_0x71a3('0x3e')]({},_0x3fc578,_0x242b85['options']);var _0x17c467={'where':_0x3fc578['where']};return db[_0x71a3('0x2c')][_0x71a3('0x1e')](_0x17c467)[_0x71a3('0x24')](function(_0x43c6d1){_0x228afa[_0x71a3('0x1e')]=_0x43c6d1;if(_0x242b85[_0x71a3('0x31')][_0x71a3('0x3f')]){_0x3fc578[_0x71a3('0x40')]=[{'all':!![]}];}return db[_0x71a3('0x2c')][_0x71a3('0x41')](_0x3fc578);})['then'](function(_0xa49846){_0x228afa['rows']=_0xa49846;return _0x228afa;})[_0x71a3('0x24')](respondWithFilteredResult(_0x305eb1,_0x3fc578))[_0x71a3('0x42')](handleError(_0x305eb1,null));};exports[_0x71a3('0x43')]=function(_0x18974c,_0x59c7c9){var _0x412bce={'raw':!![],'where':{'id':_0x18974c['params']['id']}},_0x4b4fde={};_0x4b4fde[_0x71a3('0x30')]=_[_0x71a3('0x32')](db[_0x71a3('0x2c')][_0x71a3('0x2d')]);_0x4b4fde['query']=_[_0x71a3('0x32')](_0x18974c[_0x71a3('0x31')]);_0x4b4fde[_0x71a3('0x33')]=_[_0x71a3('0x34')](_0x4b4fde[_0x71a3('0x30')],_0x4b4fde[_0x71a3('0x31')]);_0x412bce[_0x71a3('0x35')]=_[_0x71a3('0x34')](_0x4b4fde[_0x71a3('0x30')],qs[_0x71a3('0x36')](_0x18974c[_0x71a3('0x31')][_0x71a3('0x36')]));_0x412bce[_0x71a3('0x35')]=_0x412bce[_0x71a3('0x35')][_0x71a3('0x37')]?_0x412bce[_0x71a3('0x35')]:_0x4b4fde['model'];if(_0x18974c[_0x71a3('0x31')][_0x71a3('0x3f')]){_0x412bce['include']=[{'all':!![]}];}_0x412bce=_[_0x71a3('0x3e')]({},_0x412bce,_0x18974c[_0x71a3('0x44')]);return db[_0x71a3('0x2c')][_0x71a3('0x45')](_0x412bce)[_0x71a3('0x24')](handleEntityNotFound(_0x59c7c9,null))['then'](respondWithResult(_0x59c7c9,null))['catch'](handleError(_0x59c7c9,null));};exports[_0x71a3('0x46')]=function(_0x4305ee,_0x51d20d){return db[_0x71a3('0x2c')][_0x71a3('0x46')](_0x4305ee[_0x71a3('0x47')],{})[_0x71a3('0x24')](respondWithResult(_0x51d20d,0xc9))[_0x71a3('0x42')](handleError(_0x51d20d,null));};exports[_0x71a3('0x23')]=function(_0x501a62,_0x1c9ba6){if(_0x501a62['body']['id']){delete _0x501a62[_0x71a3('0x47')]['id'];}return db[_0x71a3('0x2c')][_0x71a3('0x45')]({'where':{'id':_0x501a62[_0x71a3('0x48')]['id']}})[_0x71a3('0x24')](handleEntityNotFound(_0x1c9ba6,null))['then'](saveUpdates(_0x501a62[_0x71a3('0x47')],null))[_0x71a3('0x24')](respondWithResult(_0x1c9ba6,null))[_0x71a3('0x42')](handleError(_0x1c9ba6,null));};exports['destroy']=function(_0x6c34,_0x4e6423){return db[_0x71a3('0x2c')][_0x71a3('0x45')]({'where':{'id':_0x6c34['params']['id']}})[_0x71a3('0x24')](handleEntityNotFound(_0x4e6423,null))[_0x71a3('0x24')](removeEntity(_0x4e6423,null))[_0x71a3('0x42')](handleError(_0x4e6423,null));};exports[_0x71a3('0x49')]=function(_0x11391d,_0x3952c0){return db[_0x71a3('0x2c')]['describe']()[_0x71a3('0x24')](respondWithResult(_0x3952c0,null))['catch'](handleError(_0x3952c0,null));}; \ No newline at end of file diff --git a/server/api/mailQueueReport/mailQueueReport.model.js b/server/api/mailQueueReport/mailQueueReport.model.js new file mode 100644 index 0000000..3b6dc20 --- /dev/null +++ b/server/api/mailQueueReport/mailQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x74b0=['path','../../config/environment','exports','define','report_mail_queue','uniqueid','lodash','../../config/logger','api','moment','bluebird'];(function(_0x592e20,_0x51cc4e){var _0x3db268=function(_0x5867d8){while(--_0x5867d8){_0x592e20['push'](_0x592e20['shift']());}};_0x3db268(++_0x51cc4e);}(_0x74b0,0x171));var _0x074b=function(_0x4f7e4b,_0x5bbdb2){_0x4f7e4b=_0x4f7e4b-0x0;var _0x55a507=_0x74b0[_0x4f7e4b];return _0x55a507;};'use strict';var _=require(_0x074b('0x0'));var util=require('util');var logger=require(_0x074b('0x1'))(_0x074b('0x2'));var moment=require(_0x074b('0x3'));var BPromise=require(_0x074b('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x074b('0x5'));var rimraf=require('rimraf');var config=require(_0x074b('0x6'));var attributes=require('./mailQueueReport.attributes');module[_0x074b('0x7')]=function(_0x5e0782,_0x3b9b7a){return _0x5e0782[_0x074b('0x8')]('MailQueueReport',attributes,{'tableName':_0x074b('0x9'),'paranoid':![],'indexes':[{'name':_0x074b('0xa'),'fields':[_0x074b('0xa')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/mailQueueReport/mailQueueReport.rpc.js b/server/api/mailQueueReport/mailQueueReport.rpc.js new file mode 100644 index 0000000..2b77bde --- /dev/null +++ b/server/api/mailQueueReport/mailQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadb5=['MailQueueReport,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateMailQueueReport','create','options','raw','debug','MailQueueReport','body','attributes','limit','UpdateMailQueueReport','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info'];(function(_0x28f474,_0x5535e4){var _0x45fddc=function(_0x9b0cc6){while(--_0x9b0cc6){_0x28f474['push'](_0x28f474['shift']());}};_0x45fddc(++_0x5535e4);}(_0xadb5,0xad));var _0x5adb=function(_0x40dda4,_0x2de28b){_0x40dda4=_0x40dda4-0x0;var _0x58c1cb=_0xadb5[_0x40dda4];return _0x58c1cb;};'use strict';var _=require('lodash');var util=require(_0x5adb('0x0'));var moment=require('moment');var BPromise=require(_0x5adb('0x1'));var rs=require(_0x5adb('0x2'));var fs=require('fs');var Redis=require(_0x5adb('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x5adb('0x4'));var logger=require(_0x5adb('0x5'))(_0x5adb('0x6'));var config=require('../../config/environment');var jayson=require(_0x5adb('0x7'));var client=jayson[_0x5adb('0x8')][_0x5adb('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3213e8,_0xdf3776,_0x353885){return new BPromise(function(_0x47228a,_0x6d1b45){return client[_0x5adb('0xa')](_0x3213e8,_0x353885)[_0x5adb('0xb')](function(_0x34f59d){logger[_0x5adb('0xc')](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));logger['debug']('MailQueueReport,\x20%s,\x20%s,\x20%s',_0xdf3776,_0x5adb('0xe'),JSON[_0x5adb('0xf')](_0x34f59d));if(_0x34f59d[_0x5adb('0x10')]){if(_0x34f59d['error'][_0x5adb('0x11')]===0x1f4){logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d['error'][_0x5adb('0x12')]);return _0x6d1b45(_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);}logger['error'](_0x5adb('0xd'),_0xdf3776,_0x34f59d[_0x5adb('0x10')][_0x5adb('0x12')]);return _0x47228a(_0x34f59d['error'][_0x5adb('0x12')]);}else{logger['info'](_0x5adb('0xd'),_0xdf3776,_0x5adb('0xe'));_0x47228a(_0x34f59d[_0x5adb('0x13')][_0x5adb('0x12')]);}})[_0x5adb('0x14')](function(_0x39d24d){logger[_0x5adb('0x10')](_0x5adb('0xd'),_0xdf3776,_0x39d24d);_0x6d1b45(_0x39d24d);});});}exports[_0x5adb('0x15')]=function(_0x529b65){var _0x3fff62=this;return new Promise(function(_0x5de028,_0x1d9e86){return db['MailQueueReport'][_0x5adb('0x16')](_0x529b65['body'],{'raw':_0x529b65['options']?_0x529b65[_0x5adb('0x17')][_0x5adb('0x18')]===undefined?!![]:![]:!![]})[_0x5adb('0xb')](function(_0x1fd4a7){logger[_0x5adb('0xc')]('CreateMailQueueReport',_0x529b65);logger[_0x5adb('0x19')]('CreateMailQueueReport',_0x529b65,JSON['stringify'](_0x1fd4a7));_0x5de028(_0x1fd4a7);})[_0x5adb('0x14')](function(_0x379b33){logger[_0x5adb('0x10')](_0x5adb('0x15'),_0x379b33[_0x5adb('0x12')],_0x529b65);_0x1d9e86(_0x3fff62[_0x5adb('0x10')](0x1f4,_0x379b33[_0x5adb('0x12')]));});});};exports['UpdateMailQueueReport']=function(_0x4b1957){var _0x373cc3=this;return new Promise(function(_0x3220cd,_0x3839fb){return db[_0x5adb('0x1a')]['update'](_0x4b1957[_0x5adb('0x1b')],{'raw':_0x4b1957[_0x5adb('0x17')]?_0x4b1957['options'][_0x5adb('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4b1957[_0x5adb('0x17')]?_0x4b1957[_0x5adb('0x17')]['where']||null:null,'attributes':_0x4b1957[_0x5adb('0x17')]?_0x4b1957[_0x5adb('0x17')][_0x5adb('0x1c')]||null:null,'limit':_0x4b1957[_0x5adb('0x17')]?_0x4b1957[_0x5adb('0x17')][_0x5adb('0x1d')]||null:null})['then'](function(_0x49992e){logger['info'](_0x5adb('0x1e'),_0x4b1957);logger[_0x5adb('0x19')](_0x5adb('0x1e'),_0x4b1957,JSON[_0x5adb('0xf')](_0x49992e));_0x3220cd(_0x49992e);})[_0x5adb('0x14')](function(_0x4de310){logger[_0x5adb('0x10')](_0x5adb('0x1e'),_0x4de310[_0x5adb('0x12')],_0x4b1957);_0x3839fb(_0x373cc3[_0x5adb('0x10')](0x1f4,_0x4de310[_0x5adb('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/mailServerIn/index.js b/server/api/mailServerIn/index.js new file mode 100644 index 0000000..ede39ed --- /dev/null +++ b/server/api/mailServerIn/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcb91=['express','Router','../../components/auth/service','../../components/interaction/service','exports','path','connect-timeout'];(function(_0x18aa27,_0x21720f){var _0x87bd76=function(_0x4cbc74){while(--_0x4cbc74){_0x18aa27['push'](_0x18aa27['shift']());}};_0x87bd76(++_0x21720f);}(_0xcb91,0x1a9));var _0x1cb9=function(_0x5d2803,_0xf375bd){_0x5d2803=_0x5d2803-0x0;var _0xdcad2c=_0xcb91[_0x5d2803];return _0xdcad2c;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x1cb9('0x0'));var timeout=require(_0x1cb9('0x1'));var express=require(_0x1cb9('0x2'));var router=express[_0x1cb9('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x1cb9('0x4'));var interaction=require(_0x1cb9('0x5'));var config=require('../../config/environment');module[_0x1cb9('0x6')]=router; \ No newline at end of file diff --git a/server/api/mailServerIn/mailServerIn.attributes.js b/server/api/mailServerIn/mailServerIn.attributes.js new file mode 100644 index 0000000..c5bb563 --- /dev/null +++ b/server/api/mailServerIn/mailServerIn.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcc90=['BOOLEAN','INTEGER','INBOX','sequelize','STRING'];(function(_0x5e5882,_0x699de4){var _0x3ea2dc=function(_0x185fb4){while(--_0x185fb4){_0x5e5882['push'](_0x5e5882['shift']());}};_0x3ea2dc(++_0x699de4);}(_0xcc90,0x148));var _0x0cc9=function(_0xcfc19c,_0x1d4e22){_0xcfc19c=_0xcfc19c-0x0;var _0x37cf4a=_0xcc90[_0xcfc19c];return _0x37cf4a;};'use strict';var Sequelize=require(_0x0cc9('0x0'));module['exports']={'description':{'type':Sequelize[_0x0cc9('0x1')]},'host':{'type':Sequelize['STRING']},'authentication':{'type':Sequelize[_0x0cc9('0x2')],'defaultValue':!![]},'user':{'type':Sequelize['STRING']},'password':{'type':Sequelize['STRING']},'port':{'type':Sequelize[_0x0cc9('0x3')]},'tls':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'mailbox':{'type':Sequelize[_0x0cc9('0x1')],'defaultValue':_0x0cc9('0x4')},'connTimeout':{'type':Sequelize[_0x0cc9('0x3')],'defaultValue':0xa},'authTimeout':{'type':Sequelize[_0x0cc9('0x3')],'defaultValue':0x5},'service':{'type':Sequelize[_0x0cc9('0x1')]},'modernAuthentication':{'type':Sequelize[_0x0cc9('0x2')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/mailServerIn/mailServerIn.model.js b/server/api/mailServerIn/mailServerIn.model.js new file mode 100644 index 0000000..7bf3d8a --- /dev/null +++ b/server/api/mailServerIn/mailServerIn.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeb9e=['exports','define','MailServerIn','mail_servers_in','lodash','util','../../config/logger','moment','request-promise','path','rimraf','../../config/environment','./mailServerIn.attributes'];(function(_0x41579c,_0x471380){var _0x1c744c=function(_0xf5eb29){while(--_0xf5eb29){_0x41579c['push'](_0x41579c['shift']());}};_0x1c744c(++_0x471380);}(_0xeb9e,0x122));var _0xeeb9=function(_0x45175c,_0x27f36c){_0x45175c=_0x45175c-0x0;var _0x203bd5=_0xeb9e[_0x45175c];return _0x203bd5;};'use strict';var _=require(_0xeeb9('0x0'));var util=require(_0xeeb9('0x1'));var logger=require(_0xeeb9('0x2'))('api');var moment=require(_0xeeb9('0x3'));var BPromise=require('bluebird');var rp=require(_0xeeb9('0x4'));var fs=require('fs');var path=require(_0xeeb9('0x5'));var rimraf=require(_0xeeb9('0x6'));var config=require(_0xeeb9('0x7'));var attributes=require(_0xeeb9('0x8'));module[_0xeeb9('0x9')]=function(_0x4094fd,_0xdda1ba){return _0x4094fd[_0xeeb9('0xa')](_0xeeb9('0xb'),attributes,{'tableName':_0xeeb9('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/mailServerIn/mailServerIn.rpc.js b/server/api/mailServerIn/mailServerIn.rpc.js new file mode 100644 index 0000000..732c34d --- /dev/null +++ b/server/api/mailServerIn/mailServerIn.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1bdd=['error','code','message','result','catch','GetMailServerIn','findAll','options','raw','attributes','include','model','map','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','debug','stringify'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x1bdd,0x143));var _0xd1bd=function(_0x15193d,_0x13ba1f){_0x15193d=_0x15193d-0x0;var _0xfa2c0=_0x1bdd[_0x15193d];return _0xfa2c0;};'use strict';var _=require(_0xd1bd('0x0'));var util=require(_0xd1bd('0x1'));var moment=require(_0xd1bd('0x2'));var BPromise=require(_0xd1bd('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xd1bd('0x4'))['db'];var utils=require(_0xd1bd('0x5'));var logger=require(_0xd1bd('0x6'))(_0xd1bd('0x7'));var config=require(_0xd1bd('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xd1bd('0x9')][_0xd1bd('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x35231d,_0x128479,_0x15b6de){return new BPromise(function(_0x45cccc,_0x225277){return client[_0xd1bd('0xb')](_0x35231d,_0x15b6de)[_0xd1bd('0xc')](function(_0x523146){logger[_0xd1bd('0xd')](_0xd1bd('0xe'),_0x128479,_0xd1bd('0xf'));logger[_0xd1bd('0x10')]('MailServerIn,\x20%s,\x20%s,\x20%s',_0x128479,_0xd1bd('0xf'),JSON[_0xd1bd('0x11')](_0x523146));if(_0x523146[_0xd1bd('0x12')]){if(_0x523146['error'][_0xd1bd('0x13')]===0x1f4){logger[_0xd1bd('0x12')](_0xd1bd('0xe'),_0x128479,_0x523146['error'][_0xd1bd('0x14')]);return _0x225277(_0x523146[_0xd1bd('0x12')][_0xd1bd('0x14')]);}logger[_0xd1bd('0x12')](_0xd1bd('0xe'),_0x128479,_0x523146[_0xd1bd('0x12')][_0xd1bd('0x14')]);return _0x45cccc(_0x523146[_0xd1bd('0x12')][_0xd1bd('0x14')]);}else{logger[_0xd1bd('0xd')](_0xd1bd('0xe'),_0x128479,'request\x20sent');_0x45cccc(_0x523146[_0xd1bd('0x15')]['message']);}})[_0xd1bd('0x16')](function(_0x321a30){logger[_0xd1bd('0x12')]('MailServerIn,\x20%s,\x20%s',_0x128479,_0x321a30);_0x225277(_0x321a30);});});}exports[_0xd1bd('0x17')]=function(_0x169554){var _0x3cb2d6=this;return new Promise(function(_0x1d54ab,_0x556e46){return db['MailServerIn'][_0xd1bd('0x18')]({'raw':_0x169554[_0xd1bd('0x19')]?_0x169554[_0xd1bd('0x19')][_0xd1bd('0x1a')]===undefined?!![]:![]:!![],'where':_0x169554[_0xd1bd('0x19')]?_0x169554[_0xd1bd('0x19')]['where']||null:null,'attributes':_0x169554[_0xd1bd('0x19')]?_0x169554[_0xd1bd('0x19')][_0xd1bd('0x1b')]||null:null,'limit':_0x169554[_0xd1bd('0x19')]?_0x169554[_0xd1bd('0x19')]['limit']||null:null,'include':_0x169554[_0xd1bd('0x19')]?_0x169554['options'][_0xd1bd('0x1c')]?_['map'](_0x169554[_0xd1bd('0x19')][_0xd1bd('0x1c')],function(_0x491289){return{'model':db[_0x491289[_0xd1bd('0x1d')]],'as':_0x491289['as'],'attributes':_0x491289[_0xd1bd('0x1b')],'include':_0x491289[_0xd1bd('0x1c')]?_[_0xd1bd('0x1e')](_0x491289[_0xd1bd('0x1c')],function(_0x21cc93){return{'model':db[_0x21cc93[_0xd1bd('0x1d')]],'as':_0x21cc93['as'],'attributes':_0x21cc93[_0xd1bd('0x1b')],'include':_0x21cc93[_0xd1bd('0x1c')]?_[_0xd1bd('0x1e')](_0x21cc93['include'],function(_0x551ba4){return{'model':db[_0x551ba4[_0xd1bd('0x1d')]],'as':_0x551ba4['as'],'attributes':_0x551ba4[_0xd1bd('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xd1bd('0xc')](function(_0x5c7c7b){logger[_0xd1bd('0xd')](_0xd1bd('0x17'),_0x169554);logger[_0xd1bd('0x10')](_0xd1bd('0x17'),_0x169554,JSON[_0xd1bd('0x11')](_0x5c7c7b));_0x1d54ab(_0x5c7c7b);})[_0xd1bd('0x16')](function(_0x230990){logger['error'](_0xd1bd('0x17'),_0x230990[_0xd1bd('0x14')],_0x169554);_0x556e46(_0x3cb2d6['error'](0x1f4,_0x230990['message']));});});}; \ No newline at end of file diff --git a/server/api/mailServerOut/index.js b/server/api/mailServerOut/index.js new file mode 100644 index 0000000..4365eb4 --- /dev/null +++ b/server/api/mailServerOut/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9957=['multer','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./mailServerOut.controller','get','isAuthenticated','index','/:id','show','post','create','put','update','delete','destroy','exports'];(function(_0x3a6efd,_0x2a5102){var _0x487b9a=function(_0x104f89){while(--_0x104f89){_0x3a6efd['push'](_0x3a6efd['shift']());}};_0x487b9a(++_0x2a5102);}(_0x9957,0x93));var _0x7995=function(_0x5ddb1c,_0x5ea4df){_0x5ddb1c=_0x5ddb1c-0x0;var _0x354adc=_0x9957[_0x5ddb1c];return _0x354adc;};'use strict';var multer=require(_0x7995('0x0'));var util=require(_0x7995('0x1'));var path=require(_0x7995('0x2'));var timeout=require(_0x7995('0x3'));var express=require('express');var router=express[_0x7995('0x4')]();var fs_extra=require(_0x7995('0x5'));var auth=require(_0x7995('0x6'));var interaction=require(_0x7995('0x7'));var config=require('../../config/environment');var controller=require(_0x7995('0x8'));router[_0x7995('0x9')]('/',auth[_0x7995('0xa')](),controller[_0x7995('0xb')]);router[_0x7995('0x9')](_0x7995('0xc'),auth['isAuthenticated'](),controller[_0x7995('0xd')]);router[_0x7995('0xe')]('/',auth['isAuthenticated'](),controller[_0x7995('0xf')]);router[_0x7995('0x10')](_0x7995('0xc'),auth[_0x7995('0xa')](),controller[_0x7995('0x11')]);router[_0x7995('0x12')](_0x7995('0xc'),auth['isAuthenticated'](),controller[_0x7995('0x13')]);module[_0x7995('0x14')]=router; \ No newline at end of file diff --git a/server/api/mailServerOut/mailServerOut.attributes.js b/server/api/mailServerOut/mailServerOut.attributes.js new file mode 100644 index 0000000..29a4217 --- /dev/null +++ b/server/api/mailServerOut/mailServerOut.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7334=['sequelize','exports','STRING','BOOLEAN'];(function(_0x166742,_0x55520c){var _0xb7814a=function(_0x18feaf){while(--_0x18feaf){_0x166742['push'](_0x166742['shift']());}};_0xb7814a(++_0x55520c);}(_0x7334,0x184));var _0x4733=function(_0x244538,_0x33bd34){_0x244538=_0x244538-0x0;var _0xde1f7=_0x7334[_0x244538];return _0xde1f7;};'use strict';var Sequelize=require(_0x4733('0x0'));module[_0x4733('0x1')]={'description':{'type':Sequelize[_0x4733('0x2')]},'host':{'type':Sequelize['STRING']},'user':{'type':Sequelize['STRING']},'pass':{'type':Sequelize[_0x4733('0x2')]},'port':{'type':Sequelize['INTEGER']},'secure':{'type':Sequelize[_0x4733('0x3')],'defaultValue':![]},'service':{'type':Sequelize[_0x4733('0x2')]},'authentication':{'type':Sequelize[_0x4733('0x3')],'defaultValue':!![]},'modernAuthentication':{'type':Sequelize[_0x4733('0x3')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/mailServerOut/mailServerOut.controller.js b/server/api/mailServerOut/mailServerOut.controller.js new file mode 100644 index 0000000..bdf5179 --- /dev/null +++ b/server/api/mailServerOut/mailServerOut.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x51d1=['undefined','limit','offset','count','set','Content-Range','reject','save','then','destroy','error','name','send','index','MailServerOut','rawAttributes','fieldName','type','key','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','where','pick','merge','map','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','keys','create','body','update','find','params','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json'];(function(_0x29a3cf,_0x2d787a){var _0x3dca8f=function(_0x4942d7){while(--_0x4942d7){_0x29a3cf['push'](_0x29a3cf['shift']());}};_0x3dca8f(++_0x2d787a);}(_0x51d1,0x7a));var _0x151d=function(_0xc81f5f,_0x181205){_0xc81f5f=_0xc81f5f-0x0;var _0x4410dc=_0x51d1[_0xc81f5f];return _0x4410dc;};'use strict';var emlformat=require(_0x151d('0x0'));var rimraf=require(_0x151d('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x151d('0x2'));var rp=require(_0x151d('0x3'));var moment=require(_0x151d('0x4'));var BPromise=require(_0x151d('0x5'));var Mustache=require('mustache');var util=require(_0x151d('0x6'));var path=require(_0x151d('0x7'));var sox=require('sox');var csv=require(_0x151d('0x8'));var ejs=require(_0x151d('0x9'));var fs=require('fs');var fs_extra=require(_0x151d('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x151d('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x151d('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x151d('0xd'));var Redis=require(_0x151d('0xe'));var authService=require(_0x151d('0xf'));var qs=require(_0x151d('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x151d('0x11'));var logger=require(_0x151d('0x12'))(_0x151d('0x13'));var utils=require(_0x151d('0x14'));var config=require(_0x151d('0x15'));var licenseUtil=require(_0x151d('0x16'));var db=require(_0x151d('0x17'))['db'];function respondWithStatusCode(_0x580f64,_0x197449){_0x197449=_0x197449||0xcc;return function(_0x3cdbe0){if(_0x3cdbe0){return _0x580f64[_0x151d('0x18')](_0x197449);}return _0x580f64[_0x151d('0x19')](_0x197449)[_0x151d('0x1a')]();};}function respondWithResult(_0x54f283,_0x32aea1){_0x32aea1=_0x32aea1||0xc8;return function(_0x59264b){if(_0x59264b){return _0x54f283[_0x151d('0x19')](_0x32aea1)[_0x151d('0x1b')](_0x59264b);}};}function respondWithFilteredResult(_0x152b74,_0x2bfffc){return function(_0x185c1a){if(_0x185c1a){var _0x14bceb=typeof _0x2bfffc['offset']===_0x151d('0x1c')&&typeof _0x2bfffc[_0x151d('0x1d')]===_0x151d('0x1c');var _0x1494c9=_0x185c1a['count'];var _0x49a660=_0x14bceb?0x0:_0x2bfffc[_0x151d('0x1e')];var _0x5d83d1=_0x14bceb?_0x185c1a[_0x151d('0x1f')]:_0x2bfffc['offset']+_0x2bfffc['limit'];var _0x48fd0c;if(_0x5d83d1>=_0x1494c9){_0x5d83d1=_0x1494c9;_0x48fd0c=0xc8;}else{_0x48fd0c=0xce;}_0x152b74[_0x151d('0x19')](_0x48fd0c);return _0x152b74[_0x151d('0x20')](_0x151d('0x21'),_0x49a660+'-'+_0x5d83d1+'/'+_0x1494c9)[_0x151d('0x1b')](_0x185c1a);}return null;};}function patchUpdates(_0xcd6a7c){return function(_0x4e7640){try{jsonpatch['apply'](_0x4e7640,_0xcd6a7c,!![]);}catch(_0x55fed8){return BPromise[_0x151d('0x22')](_0x55fed8);}return _0x4e7640[_0x151d('0x23')]();};}function saveUpdates(_0x5ccf65,_0x2c27d9){return function(_0x327530){if(_0x327530){return _0x327530['update'](_0x5ccf65)[_0x151d('0x24')](function(_0x4ee3e8){return _0x4ee3e8;});}return null;};}function removeEntity(_0x81cd7c,_0x3bb3b1){return function(_0x52d1c1){if(_0x52d1c1){return _0x52d1c1[_0x151d('0x25')]()[_0x151d('0x24')](function(){_0x81cd7c[_0x151d('0x19')](0xcc)[_0x151d('0x1a')]();});}};}function handleEntityNotFound(_0x471e4a,_0x2a6210){return function(_0x117a59){if(!_0x117a59){_0x471e4a['sendStatus'](0x194);}return _0x117a59;};}function handleError(_0x3202da,_0x63e95a){_0x63e95a=_0x63e95a||0x1f4;return function(_0x58f7d6){logger[_0x151d('0x26')](_0x58f7d6['stack']);if(_0x58f7d6[_0x151d('0x27')]){delete _0x58f7d6['name'];}_0x3202da['status'](_0x63e95a)[_0x151d('0x28')](_0x58f7d6);};}exports[_0x151d('0x29')]=function(_0x2d008b,_0x26393c){var _0x792945={},_0xac42a0={},_0x12625d={'count':0x0,'rows':[]};var _0x37d574=_['map'](db[_0x151d('0x2a')][_0x151d('0x2b')],function(_0x3271c4){return{'name':_0x3271c4[_0x151d('0x2c')],'type':_0x3271c4[_0x151d('0x2d')][_0x151d('0x2e')]};});_0xac42a0['model']=_['map'](_0x37d574,_0x151d('0x27'));_0xac42a0[_0x151d('0x2f')]=_['keys'](_0x2d008b[_0x151d('0x2f')]);_0xac42a0[_0x151d('0x30')]=_[_0x151d('0x31')](_0xac42a0[_0x151d('0x32')],_0xac42a0['query']);_0x792945['attributes']=_[_0x151d('0x31')](_0xac42a0[_0x151d('0x32')],qs[_0x151d('0x33')](_0x2d008b[_0x151d('0x2f')][_0x151d('0x33')]));_0x792945[_0x151d('0x34')]=_0x792945[_0x151d('0x34')][_0x151d('0x35')]?_0x792945[_0x151d('0x34')]:_0xac42a0['model'];if(!_0x2d008b[_0x151d('0x2f')][_0x151d('0x36')](_0x151d('0x37'))){_0x792945[_0x151d('0x1d')]=qs['limit'](_0x2d008b['query'][_0x151d('0x1d')]);_0x792945[_0x151d('0x1e')]=qs[_0x151d('0x1e')](_0x2d008b[_0x151d('0x2f')][_0x151d('0x1e')]);}_0x792945[_0x151d('0x38')]=qs['sort'](_0x2d008b[_0x151d('0x2f')]['sort']);_0x792945[_0x151d('0x39')]=qs[_0x151d('0x30')](_[_0x151d('0x3a')](_0x2d008b[_0x151d('0x2f')],_0xac42a0[_0x151d('0x30')]),_0x37d574);if(_0x2d008b[_0x151d('0x2f')]['filter']){_0x792945[_0x151d('0x39')]=_[_0x151d('0x3b')](_0x792945['where'],{'$or':_[_0x151d('0x3c')](_0x37d574,function(_0x204566){if(_0x204566['type']!==_0x151d('0x3d')){var _0x393f9a={};_0x393f9a[_0x204566[_0x151d('0x27')]]={'$like':'%'+_0x2d008b[_0x151d('0x2f')][_0x151d('0x3e')]+'%'};return _0x393f9a;}})});}_0x792945=_[_0x151d('0x3b')]({},_0x792945,_0x2d008b[_0x151d('0x3f')]);var _0x324c87={'where':_0x792945[_0x151d('0x39')]};return db['MailServerOut'][_0x151d('0x1f')](_0x324c87)[_0x151d('0x24')](function(_0x15840a){_0x12625d[_0x151d('0x1f')]=_0x15840a;if(_0x2d008b[_0x151d('0x2f')][_0x151d('0x40')]){_0x792945[_0x151d('0x41')]=[{'all':!![]}];}return db['MailServerOut'][_0x151d('0x42')](_0x792945);})[_0x151d('0x24')](function(_0x2c63c2){_0x12625d[_0x151d('0x43')]=_0x2c63c2;return _0x12625d;})[_0x151d('0x24')](respondWithFilteredResult(_0x26393c,_0x792945))[_0x151d('0x44')](handleError(_0x26393c,null));};exports['show']=function(_0x53f672,_0x50bdcc){var _0x2968ce={'raw':!![],'where':{'id':_0x53f672['params']['id']}},_0x1f9158={};_0x1f9158['model']=_[_0x151d('0x45')](db[_0x151d('0x2a')][_0x151d('0x2b')]);_0x1f9158[_0x151d('0x2f')]=_[_0x151d('0x45')](_0x53f672[_0x151d('0x2f')]);_0x1f9158['filters']=_['intersection'](_0x1f9158[_0x151d('0x32')],_0x1f9158[_0x151d('0x2f')]);_0x2968ce[_0x151d('0x34')]=_[_0x151d('0x31')](_0x1f9158['model'],qs[_0x151d('0x33')](_0x53f672[_0x151d('0x2f')][_0x151d('0x33')]));_0x2968ce[_0x151d('0x34')]=_0x2968ce[_0x151d('0x34')][_0x151d('0x35')]?_0x2968ce[_0x151d('0x34')]:_0x1f9158[_0x151d('0x32')];if(_0x53f672[_0x151d('0x2f')][_0x151d('0x40')]){_0x2968ce[_0x151d('0x41')]=[{'all':!![]}];}_0x2968ce=_['merge']({},_0x2968ce,_0x53f672[_0x151d('0x3f')]);return db['MailServerOut']['find'](_0x2968ce)[_0x151d('0x24')](handleEntityNotFound(_0x50bdcc,null))[_0x151d('0x24')](respondWithResult(_0x50bdcc,null))['catch'](handleError(_0x50bdcc,null));};exports['create']=function(_0x548ec0,_0x25cb88){return db[_0x151d('0x2a')][_0x151d('0x46')](_0x548ec0[_0x151d('0x47')],{})[_0x151d('0x24')](respondWithResult(_0x25cb88,0xc9))['catch'](handleError(_0x25cb88,null));};exports[_0x151d('0x48')]=function(_0x2fb6f8,_0x11c670){if(_0x2fb6f8['body']['id']){delete _0x2fb6f8[_0x151d('0x47')]['id'];}return db[_0x151d('0x2a')][_0x151d('0x49')]({'where':{'id':_0x2fb6f8[_0x151d('0x4a')]['id']}})[_0x151d('0x24')](handleEntityNotFound(_0x11c670,null))['then'](saveUpdates(_0x2fb6f8[_0x151d('0x47')],null))['then'](respondWithResult(_0x11c670,null))[_0x151d('0x44')](handleError(_0x11c670,null));};exports[_0x151d('0x25')]=function(_0x5d2e0f,_0x329787){return db[_0x151d('0x2a')][_0x151d('0x49')]({'where':{'id':_0x5d2e0f[_0x151d('0x4a')]['id']}})[_0x151d('0x24')](handleEntityNotFound(_0x329787,null))[_0x151d('0x24')](removeEntity(_0x329787,null))[_0x151d('0x44')](handleError(_0x329787,null));}; \ No newline at end of file diff --git a/server/api/mailServerOut/mailServerOut.model.js b/server/api/mailServerOut/mailServerOut.model.js new file mode 100644 index 0000000..a817d52 --- /dev/null +++ b/server/api/mailServerOut/mailServerOut.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6fcc=['lodash','../../config/logger','moment','bluebird','request-promise','path','rimraf','exports','define','MailServerOut','mail_servers_out'];(function(_0x513231,_0x1359e6){var _0x2e563e=function(_0x33572a){while(--_0x33572a){_0x513231['push'](_0x513231['shift']());}};_0x2e563e(++_0x1359e6);}(_0x6fcc,0x176));var _0xc6fc=function(_0x48360f,_0x4fefcf){_0x48360f=_0x48360f-0x0;var _0x6bd90d=_0x6fcc[_0x48360f];return _0x6bd90d;};'use strict';var _=require(_0xc6fc('0x0'));var util=require('util');var logger=require(_0xc6fc('0x1'))('api');var moment=require(_0xc6fc('0x2'));var BPromise=require(_0xc6fc('0x3'));var rp=require(_0xc6fc('0x4'));var fs=require('fs');var path=require(_0xc6fc('0x5'));var rimraf=require(_0xc6fc('0x6'));var config=require('../../config/environment');var attributes=require('./mailServerOut.attributes');module[_0xc6fc('0x7')]=function(_0x10c08e,_0x4d631f){return _0x10c08e[_0xc6fc('0x8')](_0xc6fc('0x9'),attributes,{'tableName':_0xc6fc('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/mailServerOut/mailServerOut.rpc.js b/server/api/mailServerOut/mailServerOut.rpc.js new file mode 100644 index 0000000..1ad449d --- /dev/null +++ b/server/api/mailServerOut/mailServerOut.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['then','info','MailServerOut,\x20%s,\x20%s','request\x20sent','MailServerOut,\x20%s,\x20%s,\x20%s','error','code','message','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','http','request'];(function(_0x4d9255,_0x374413){var _0x19442c=function(_0x10ed9b){while(--_0x10ed9b){_0x4d9255['push'](_0x4d9255['shift']());}};_0x19442c(++_0x374413);}(_0x1261,0x144));var _0x1126=function(_0x310eb9,_0x1aed15){_0x310eb9=_0x310eb9-0x0;var _0x28915c=_0x1261[_0x310eb9];return _0x28915c;};'use strict';var _=require('lodash');var util=require(_0x1126('0x0'));var moment=require(_0x1126('0x1'));var BPromise=require(_0x1126('0x2'));var rs=require(_0x1126('0x3'));var fs=require('fs');var Redis=require(_0x1126('0x4'));var db=require(_0x1126('0x5'))['db'];var utils=require(_0x1126('0x6'));var logger=require(_0x1126('0x7'))(_0x1126('0x8'));var config=require(_0x1126('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x1126('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x907180,_0x4f239c,_0x17e5f0){return new BPromise(function(_0x28772d,_0x245be9){return client[_0x1126('0xb')](_0x907180,_0x17e5f0)[_0x1126('0xc')](function(_0x59cfa1){logger[_0x1126('0xd')](_0x1126('0xe'),_0x4f239c,_0x1126('0xf'));logger['debug'](_0x1126('0x10'),_0x4f239c,'request\x20sent',JSON['stringify'](_0x59cfa1));if(_0x59cfa1[_0x1126('0x11')]){if(_0x59cfa1['error'][_0x1126('0x12')]===0x1f4){logger[_0x1126('0x11')](_0x1126('0xe'),_0x4f239c,_0x59cfa1[_0x1126('0x11')][_0x1126('0x13')]);return _0x245be9(_0x59cfa1[_0x1126('0x11')][_0x1126('0x13')]);}logger[_0x1126('0x11')](_0x1126('0xe'),_0x4f239c,_0x59cfa1['error']['message']);return _0x28772d(_0x59cfa1[_0x1126('0x11')][_0x1126('0x13')]);}else{logger[_0x1126('0xd')]('MailServerOut,\x20%s,\x20%s',_0x4f239c,_0x1126('0xf'));_0x28772d(_0x59cfa1['result'][_0x1126('0x13')]);}})[_0x1126('0x14')](function(_0x257b5f){logger['error'](_0x1126('0xe'),_0x4f239c,_0x257b5f);_0x245be9(_0x257b5f);});});} \ No newline at end of file diff --git a/server/api/mailSubstatus/index.js b/server/api/mailSubstatus/index.js new file mode 100644 index 0000000..a3be599 --- /dev/null +++ b/server/api/mailSubstatus/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf413=['../../config/environment','./mailSubstatus.controller','isAuthenticated','index','get','/describe','describe','/:id','show','create','update','delete','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service'];(function(_0x311be9,_0x12b742){var _0x27f742=function(_0x42282e){while(--_0x42282e){_0x311be9['push'](_0x311be9['shift']());}};_0x27f742(++_0x12b742);}(_0xf413,0x66));var _0x3f41=function(_0x584233,_0x5cf2cf){_0x584233=_0x584233-0x0;var _0x465b30=_0xf413[_0x584233];return _0x465b30;};'use strict';var multer=require(_0x3f41('0x0'));var util=require(_0x3f41('0x1'));var path=require(_0x3f41('0x2'));var timeout=require(_0x3f41('0x3'));var express=require(_0x3f41('0x4'));var router=express[_0x3f41('0x5')]();var fs_extra=require(_0x3f41('0x6'));var auth=require(_0x3f41('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0x3f41('0x8'));var controller=require(_0x3f41('0x9'));router['get']('/',auth[_0x3f41('0xa')](),controller[_0x3f41('0xb')]);router[_0x3f41('0xc')](_0x3f41('0xd'),auth['isAuthenticated'](),controller[_0x3f41('0xe')]);router[_0x3f41('0xc')](_0x3f41('0xf'),auth[_0x3f41('0xa')](),controller[_0x3f41('0x10')]);router['post']('/',auth[_0x3f41('0xa')](),controller[_0x3f41('0x11')]);router['put'](_0x3f41('0xf'),auth[_0x3f41('0xa')](),controller[_0x3f41('0x12')]);router[_0x3f41('0x13')](_0x3f41('0xf'),auth[_0x3f41('0xa')](),controller[_0x3f41('0x14')]);module[_0x3f41('0x15')]=router; \ No newline at end of file diff --git a/server/api/mailSubstatus/mailSubstatus.attributes.js b/server/api/mailSubstatus/mailSubstatus.attributes.js new file mode 100644 index 0000000..92721f9 --- /dev/null +++ b/server/api/mailSubstatus/mailSubstatus.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdfa0=['sequelize','STRING','name'];(function(_0x4b3e49,_0x9e566c){var _0x57e339=function(_0x1430e9){while(--_0x1430e9){_0x4b3e49['push'](_0x4b3e49['shift']());}};_0x57e339(++_0x9e566c);}(_0xdfa0,0x69));var _0x0dfa=function(_0x14c868,_0x15b75a){_0x14c868=_0x14c868-0x0;var _0x18e7cd=_0xdfa0[_0x14c868];return _0x18e7cd;};'use strict';var Sequelize=require(_0x0dfa('0x0'));module['exports']={'name':{'type':Sequelize[_0x0dfa('0x1')],'unique':_0x0dfa('0x2'),'allowNull':![],'validate':{'notEmpty':!![]}},'description':{'type':Sequelize['STRING']}}; \ No newline at end of file diff --git a/server/api/mailSubstatus/mailSubstatus.controller.js b/server/api/mailSubstatus/mailSubstatus.controller.js new file mode 100644 index 0000000..d1e4c30 --- /dev/null +++ b/server/api/mailSubstatus/mailSubstatus.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0105=['update','then','destroy','error','stack','name','send','index','map','MailSubstatus','rawAttributes','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','order','sort','where','pick','filter','merge','type','options','includeAll','include','findAll','rows','catch','params','length','find','create','body','describe','eml-format','rimraf','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','status','end','offset','undefined','limit','count','Content-Range','json','save'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0x0105,0x1dc));var _0x5010=function(_0x5ee973,_0x5bc5c0){_0x5ee973=_0x5ee973-0x0;var _0x311971=_0x0105[_0x5ee973];return _0x311971;};'use strict';var emlformat=require(_0x5010('0x0'));var rimraf=require(_0x5010('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5010('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x5010('0x3'));var Mustache=require(_0x5010('0x4'));var util=require(_0x5010('0x5'));var path=require(_0x5010('0x6'));var sox=require(_0x5010('0x7'));var csv=require(_0x5010('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5010('0x9'));var _=require(_0x5010('0xa'));var squel=require(_0x5010('0xb'));var crypto=require(_0x5010('0xc'));var jsforce=require(_0x5010('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x5010('0x8'));var querystring=require(_0x5010('0xe'));var Papa=require(_0x5010('0xf'));var Redis=require(_0x5010('0x10'));var authService=require(_0x5010('0x11'));var qs=require(_0x5010('0x12'));var as=require(_0x5010('0x13'));var hardwareService=require(_0x5010('0x14'));var logger=require(_0x5010('0x15'))(_0x5010('0x16'));var utils=require('../../config/utils');var config=require(_0x5010('0x17'));var licenseUtil=require(_0x5010('0x18'));var db=require(_0x5010('0x19'))['db'];function respondWithStatusCode(_0x2d392c,_0x2be8ad){_0x2be8ad=_0x2be8ad||0xcc;return function(_0x1438b7){if(_0x1438b7){return _0x2d392c['sendStatus'](_0x2be8ad);}return _0x2d392c[_0x5010('0x1a')](_0x2be8ad)[_0x5010('0x1b')]();};}function respondWithResult(_0x2f1d22,_0x59ae74){_0x59ae74=_0x59ae74||0xc8;return function(_0x59a5e5){if(_0x59a5e5){return _0x2f1d22[_0x5010('0x1a')](_0x59ae74)['json'](_0x59a5e5);}};}function respondWithFilteredResult(_0x26b1a0,_0x3216a1){return function(_0x71b4b6){if(_0x71b4b6){var _0x21254=typeof _0x3216a1[_0x5010('0x1c')]===_0x5010('0x1d')&&typeof _0x3216a1[_0x5010('0x1e')]===_0x5010('0x1d');var _0x333f3b=_0x71b4b6[_0x5010('0x1f')];var _0x32bc28=_0x21254?0x0:_0x3216a1[_0x5010('0x1c')];var _0x22c494=_0x21254?_0x71b4b6[_0x5010('0x1f')]:_0x3216a1[_0x5010('0x1c')]+_0x3216a1[_0x5010('0x1e')];var _0x24f16a;if(_0x22c494>=_0x333f3b){_0x22c494=_0x333f3b;_0x24f16a=0xc8;}else{_0x24f16a=0xce;}_0x26b1a0[_0x5010('0x1a')](_0x24f16a);return _0x26b1a0['set'](_0x5010('0x20'),_0x32bc28+'-'+_0x22c494+'/'+_0x333f3b)[_0x5010('0x21')](_0x71b4b6);}return null;};}function patchUpdates(_0x520583){return function(_0x4e4fed){try{jsonpatch['apply'](_0x4e4fed,_0x520583,!![]);}catch(_0x4e5957){return BPromise['reject'](_0x4e5957);}return _0x4e4fed[_0x5010('0x22')]();};}function saveUpdates(_0x4968fe,_0x18fa23){return function(_0x2fe8dc){if(_0x2fe8dc){return _0x2fe8dc[_0x5010('0x23')](_0x4968fe)[_0x5010('0x24')](function(_0x4522d1){return _0x4522d1;});}return null;};}function removeEntity(_0x2cc4cb,_0x2fb790){return function(_0x34cc36){if(_0x34cc36){return _0x34cc36[_0x5010('0x25')]()[_0x5010('0x24')](function(){_0x2cc4cb[_0x5010('0x1a')](0xcc)[_0x5010('0x1b')]();});}};}function handleEntityNotFound(_0x375d26,_0x57a93d){return function(_0x7151a){if(!_0x7151a){_0x375d26['sendStatus'](0x194);}return _0x7151a;};}function handleError(_0x4bbcb0,_0x2ca1c7){_0x2ca1c7=_0x2ca1c7||0x1f4;return function(_0x12e620){logger[_0x5010('0x26')](_0x12e620[_0x5010('0x27')]);if(_0x12e620[_0x5010('0x28')]){delete _0x12e620['name'];}_0x4bbcb0[_0x5010('0x1a')](_0x2ca1c7)[_0x5010('0x29')](_0x12e620);};}exports[_0x5010('0x2a')]=function(_0x14e185,_0x1d6432){var _0x11bc56={},_0x2e73d4={},_0x37f426={'count':0x0,'rows':[]};var _0x2219be=_[_0x5010('0x2b')](db[_0x5010('0x2c')][_0x5010('0x2d')],function(_0x33305e){return{'name':_0x33305e['fieldName'],'type':_0x33305e['type']['key']};});_0x2e73d4[_0x5010('0x2e')]=_[_0x5010('0x2b')](_0x2219be,_0x5010('0x28'));_0x2e73d4[_0x5010('0x2f')]=_[_0x5010('0x30')](_0x14e185[_0x5010('0x2f')]);_0x2e73d4[_0x5010('0x31')]=_['intersection'](_0x2e73d4[_0x5010('0x2e')],_0x2e73d4[_0x5010('0x2f')]);_0x11bc56[_0x5010('0x32')]=_[_0x5010('0x33')](_0x2e73d4[_0x5010('0x2e')],qs[_0x5010('0x34')](_0x14e185[_0x5010('0x2f')]['fields']));_0x11bc56[_0x5010('0x32')]=_0x11bc56[_0x5010('0x32')]['length']?_0x11bc56[_0x5010('0x32')]:_0x2e73d4[_0x5010('0x2e')];if(!_0x14e185[_0x5010('0x2f')][_0x5010('0x35')]('nolimit')){_0x11bc56[_0x5010('0x1e')]=qs['limit'](_0x14e185[_0x5010('0x2f')][_0x5010('0x1e')]);_0x11bc56['offset']=qs[_0x5010('0x1c')](_0x14e185['query'][_0x5010('0x1c')]);}_0x11bc56[_0x5010('0x36')]=qs[_0x5010('0x37')](_0x14e185['query']['sort']);_0x11bc56[_0x5010('0x38')]=qs['filters'](_[_0x5010('0x39')](_0x14e185[_0x5010('0x2f')],_0x2e73d4[_0x5010('0x31')]),_0x2219be);if(_0x14e185[_0x5010('0x2f')][_0x5010('0x3a')]){_0x11bc56[_0x5010('0x38')]=_[_0x5010('0x3b')](_0x11bc56['where'],{'$or':_[_0x5010('0x2b')](_0x2219be,function(_0x25523e){if(_0x25523e[_0x5010('0x3c')]!=='VIRTUAL'){var _0x9c5d80={};_0x9c5d80[_0x25523e[_0x5010('0x28')]]={'$like':'%'+_0x14e185[_0x5010('0x2f')][_0x5010('0x3a')]+'%'};return _0x9c5d80;}})});}_0x11bc56=_[_0x5010('0x3b')]({},_0x11bc56,_0x14e185[_0x5010('0x3d')]);var _0x38639b={'where':_0x11bc56[_0x5010('0x38')]};return db['MailSubstatus'][_0x5010('0x1f')](_0x38639b)[_0x5010('0x24')](function(_0x55785d){_0x37f426[_0x5010('0x1f')]=_0x55785d;if(_0x14e185['query'][_0x5010('0x3e')]){_0x11bc56[_0x5010('0x3f')]=[{'all':!![]}];}return db[_0x5010('0x2c')][_0x5010('0x40')](_0x11bc56);})[_0x5010('0x24')](function(_0x27ef48){_0x37f426[_0x5010('0x41')]=_0x27ef48;return _0x37f426;})[_0x5010('0x24')](respondWithFilteredResult(_0x1d6432,_0x11bc56))[_0x5010('0x42')](handleError(_0x1d6432,null));};exports['show']=function(_0x2b0fe4,_0x27e4ca){var _0x239564={'raw':!![],'where':{'id':_0x2b0fe4[_0x5010('0x43')]['id']}},_0x18a468={};_0x18a468[_0x5010('0x2e')]=_['keys'](db['MailSubstatus']['rawAttributes']);_0x18a468[_0x5010('0x2f')]=_['keys'](_0x2b0fe4[_0x5010('0x2f')]);_0x18a468['filters']=_[_0x5010('0x33')](_0x18a468['model'],_0x18a468[_0x5010('0x2f')]);_0x239564[_0x5010('0x32')]=_[_0x5010('0x33')](_0x18a468[_0x5010('0x2e')],qs[_0x5010('0x34')](_0x2b0fe4[_0x5010('0x2f')][_0x5010('0x34')]));_0x239564[_0x5010('0x32')]=_0x239564['attributes'][_0x5010('0x44')]?_0x239564['attributes']:_0x18a468['model'];if(_0x2b0fe4['query'][_0x5010('0x3e')]){_0x239564[_0x5010('0x3f')]=[{'all':!![]}];}_0x239564=_[_0x5010('0x3b')]({},_0x239564,_0x2b0fe4[_0x5010('0x3d')]);return db[_0x5010('0x2c')][_0x5010('0x45')](_0x239564)[_0x5010('0x24')](handleEntityNotFound(_0x27e4ca,null))[_0x5010('0x24')](respondWithResult(_0x27e4ca,null))[_0x5010('0x42')](handleError(_0x27e4ca,null));};exports[_0x5010('0x46')]=function(_0x66bbbb,_0xbcdb10){return db[_0x5010('0x2c')][_0x5010('0x46')](_0x66bbbb['body'],{})[_0x5010('0x24')](respondWithResult(_0xbcdb10,0xc9))[_0x5010('0x42')](handleError(_0xbcdb10,null));};exports[_0x5010('0x23')]=function(_0x4af82e,_0x2fbed5){if(_0x4af82e[_0x5010('0x47')]['id']){delete _0x4af82e[_0x5010('0x47')]['id'];}return db[_0x5010('0x2c')][_0x5010('0x45')]({'where':{'id':_0x4af82e['params']['id']}})['then'](handleEntityNotFound(_0x2fbed5,null))['then'](saveUpdates(_0x4af82e[_0x5010('0x47')],null))['then'](respondWithResult(_0x2fbed5,null))['catch'](handleError(_0x2fbed5,null));};exports[_0x5010('0x25')]=function(_0x48ce68,_0x4e7c15){return db['MailSubstatus'][_0x5010('0x45')]({'where':{'id':_0x48ce68[_0x5010('0x43')]['id']}})[_0x5010('0x24')](handleEntityNotFound(_0x4e7c15,null))[_0x5010('0x24')](removeEntity(_0x4e7c15,null))[_0x5010('0x42')](handleError(_0x4e7c15,null));};exports['describe']=function(_0x4e17a8,_0x382cbb){return db[_0x5010('0x2c')][_0x5010('0x48')]()[_0x5010('0x24')](respondWithResult(_0x382cbb,null))[_0x5010('0x42')](handleError(_0x382cbb,null));}; \ No newline at end of file diff --git a/server/api/mailSubstatus/mailSubstatus.events.js b/server/api/mailSubstatus/mailSubstatus.events.js new file mode 100644 index 0000000..a380c43 --- /dev/null +++ b/server/api/mailSubstatus/mailSubstatus.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa930=['exports','events','MailSubstatus','setMaxListeners','update','emit','hasOwnProperty','hook'];(function(_0x418fa3,_0x464468){var _0x845083=function(_0x12b8ae){while(--_0x12b8ae){_0x418fa3['push'](_0x418fa3['shift']());}};_0x845083(++_0x464468);}(_0xa930,0xb1));var _0x0a93=function(_0x4f8d05,_0x3c7053){_0x4f8d05=_0x4f8d05-0x0;var _0x2087d9=_0xa930[_0x4f8d05];return _0x2087d9;};'use strict';var EventEmitter=require(_0x0a93('0x0'));var MailSubstatus=require('../../mysqldb')['db'][_0x0a93('0x1')];var MailSubstatusEvents=new EventEmitter();MailSubstatusEvents[_0x0a93('0x2')](0x0);var events={'afterUpdate':_0x0a93('0x3')};function emitEvent(_0x4235a4){return function(_0x170f0a,_0x3c003e,_0x3a1e24){MailSubstatusEvents[_0x0a93('0x4')](_0x4235a4+':'+_0x170f0a['id'],_0x170f0a);MailSubstatusEvents[_0x0a93('0x4')](_0x4235a4,_0x170f0a);_0x3a1e24(null);};}for(var e in events){if(events[_0x0a93('0x5')](e)){var event=events[e];MailSubstatus[_0x0a93('0x6')](e,emitEvent(event));}}module[_0x0a93('0x7')]=MailSubstatusEvents; \ No newline at end of file diff --git a/server/api/mailSubstatus/mailSubstatus.model.js b/server/api/mailSubstatus/mailSubstatus.model.js new file mode 100644 index 0000000..1f8c88f --- /dev/null +++ b/server/api/mailSubstatus/mailSubstatus.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf0ae=['mailSubstatus','_previousDataValues','then','catch','exports','models','define','MailSubstatus','update','name'];(function(_0x3aa0c7,_0x4c6217){var _0x1b9df3=function(_0xc9fcf9){while(--_0xc9fcf9){_0x3aa0c7['push'](_0x3aa0c7['shift']());}};_0x1b9df3(++_0x4c6217);}(_0xf0ae,0x14e));var _0xef0a=function(_0x1d24eb,_0x12295b){_0x1d24eb=_0x1d24eb-0x0;var _0x1dc576=_0xf0ae[_0x1d24eb];return _0x1dc576;};'use strict';var attributes=require('./mailSubstatus.attributes');module[_0xef0a('0x0')]=function(_0xf4c9d2){var _0x4b540d=_0xf4c9d2[_0xef0a('0x1')];return _0xf4c9d2[_0xef0a('0x2')](_0xef0a('0x3'),attributes,{'tableName':'mail_substatuses','paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterUpdate':function(_0x204a3b,_0x1e8fdd,_0xc8ed19){return _0x4b540d['Condition'][_0xef0a('0x4')]({'value':_0x204a3b[_0xef0a('0x5')]},{'where':{'field':_0xef0a('0x6'),'value':_0x204a3b[_0xef0a('0x7')]['name']}})[_0xef0a('0x8')](function(){_0xc8ed19();})[_0xef0a('0x9')](function(_0x33abe4){_0xc8ed19(_0x33abe4);});}}});}; \ No newline at end of file diff --git a/server/api/mailSubstatus/mailSubstatus.rpc.js b/server/api/mailSubstatus/mailSubstatus.rpc.js new file mode 100644 index 0000000..22c6bdd --- /dev/null +++ b/server/api/mailSubstatus/mailSubstatus.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0eab=['http','request','info','MailSubstatus,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client'];(function(_0x16db8b,_0xca7d28){var _0x5ba017=function(_0x35b933){while(--_0x35b933){_0x16db8b['push'](_0x16db8b['shift']());}};_0x5ba017(++_0xca7d28);}(_0x0eab,0x1d4));var _0xb0ea=function(_0x597873,_0x48c75a){_0x597873=_0x597873-0x0;var _0x45582c=_0x0eab[_0x597873];return _0x45582c;};'use strict';var _=require(_0xb0ea('0x0'));var util=require(_0xb0ea('0x1'));var moment=require(_0xb0ea('0x2'));var BPromise=require(_0xb0ea('0x3'));var rs=require(_0xb0ea('0x4'));var fs=require('fs');var Redis=require(_0xb0ea('0x5'));var db=require(_0xb0ea('0x6'))['db'];var utils=require(_0xb0ea('0x7'));var logger=require(_0xb0ea('0x8'))(_0xb0ea('0x9'));var config=require('../../config/environment');var jayson=require(_0xb0ea('0xa'));var client=jayson[_0xb0ea('0xb')][_0xb0ea('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x136b87,_0x1cecac,_0x5d3174){return new BPromise(function(_0x1d045f,_0x4cf153){return client[_0xb0ea('0xd')](_0x136b87,_0x5d3174)['then'](function(_0x5965db){logger[_0xb0ea('0xe')](_0xb0ea('0xf'),_0x1cecac,_0xb0ea('0x10'));logger[_0xb0ea('0x11')]('MailSubstatus,\x20%s,\x20%s,\x20%s',_0x1cecac,_0xb0ea('0x10'),JSON[_0xb0ea('0x12')](_0x5965db));if(_0x5965db[_0xb0ea('0x13')]){if(_0x5965db[_0xb0ea('0x13')][_0xb0ea('0x14')]===0x1f4){logger[_0xb0ea('0x13')](_0xb0ea('0xf'),_0x1cecac,_0x5965db[_0xb0ea('0x13')][_0xb0ea('0x15')]);return _0x4cf153(_0x5965db[_0xb0ea('0x13')][_0xb0ea('0x15')]);}logger[_0xb0ea('0x13')]('MailSubstatus,\x20%s,\x20%s',_0x1cecac,_0x5965db[_0xb0ea('0x13')][_0xb0ea('0x15')]);return _0x1d045f(_0x5965db[_0xb0ea('0x13')][_0xb0ea('0x15')]);}else{logger[_0xb0ea('0xe')](_0xb0ea('0xf'),_0x1cecac,_0xb0ea('0x10'));_0x1d045f(_0x5965db[_0xb0ea('0x16')]['message']);}})[_0xb0ea('0x17')](function(_0x1deef6){logger[_0xb0ea('0x13')]('MailSubstatus,\x20%s,\x20%s',_0x1cecac,_0x1deef6);_0x4cf153(_0x1deef6);});});} \ No newline at end of file diff --git a/server/api/mailTransferReport/index.js b/server/api/mailTransferReport/index.js new file mode 100644 index 0000000..2154b49 --- /dev/null +++ b/server/api/mailTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xae38=['express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./mailTransferReport.controller','get','isAuthenticated','index','/:id','show','post','create','put','update','delete','destroy','exports','multer','util','path','connect-timeout'];(function(_0x138889,_0x447c34){var _0x713093=function(_0x443784){while(--_0x443784){_0x138889['push'](_0x138889['shift']());}};_0x713093(++_0x447c34);}(_0xae38,0x127));var _0x8ae3=function(_0xe49f,_0x588638){_0xe49f=_0xe49f-0x0;var _0x4f549e=_0xae38[_0xe49f];return _0x4f549e;};'use strict';var multer=require(_0x8ae3('0x0'));var util=require(_0x8ae3('0x1'));var path=require(_0x8ae3('0x2'));var timeout=require(_0x8ae3('0x3'));var express=require(_0x8ae3('0x4'));var router=express[_0x8ae3('0x5')]();var fs_extra=require(_0x8ae3('0x6'));var auth=require(_0x8ae3('0x7'));var interaction=require(_0x8ae3('0x8'));var config=require(_0x8ae3('0x9'));var controller=require(_0x8ae3('0xa'));router[_0x8ae3('0xb')]('/',auth[_0x8ae3('0xc')](),controller[_0x8ae3('0xd')]);router['get']('/describe',auth[_0x8ae3('0xc')](),controller['describe']);router[_0x8ae3('0xb')](_0x8ae3('0xe'),auth[_0x8ae3('0xc')](),controller[_0x8ae3('0xf')]);router[_0x8ae3('0x10')]('/',auth[_0x8ae3('0xc')](),controller[_0x8ae3('0x11')]);router[_0x8ae3('0x12')](_0x8ae3('0xe'),auth[_0x8ae3('0xc')](),controller[_0x8ae3('0x13')]);router[_0x8ae3('0x14')](_0x8ae3('0xe'),auth['isAuthenticated'](),controller[_0x8ae3('0x15')]);module[_0x8ae3('0x16')]=router; \ No newline at end of file diff --git a/server/api/mailTransferReport/mailTransferReport.attributes.js b/server/api/mailTransferReport/mailTransferReport.attributes.js new file mode 100644 index 0000000..390ea73 --- /dev/null +++ b/server/api/mailTransferReport/mailTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c44=['ENUM','account','agent','queue','NOW','exports','STRING'];(function(_0x5caabb,_0x2b0cc1){var _0x2929d8=function(_0x389698){while(--_0x389698){_0x5caabb['push'](_0x5caabb['shift']());}};_0x2929d8(++_0x2b0cc1);}(_0x9c44,0x178));var _0x49c4=function(_0x1d9aa0,_0x272488){_0x1d9aa0=_0x1d9aa0-0x0;var _0x226868=_0x9c44[_0x1d9aa0];return _0x226868;};'use strict';var moment=require('moment');var Sequelize=require('sequelize');module[_0x49c4('0x0')]={'uniqueid':{'type':Sequelize[_0x49c4('0x1')],'allowNull':![]},'type':{'type':Sequelize[_0x49c4('0x2')](_0x49c4('0x3'),_0x49c4('0x4'),_0x49c4('0x5')),'allowNull':![],'defaultValue':'queue'},'transferredAt':{'type':Sequelize['DATE'],'allowNull':![],'defaultValue':Sequelize[_0x49c4('0x6')]}}; \ No newline at end of file diff --git a/server/api/mailTransferReport/mailTransferReport.controller.js b/server/api/mailTransferReport/mailTransferReport.controller.js new file mode 100644 index 0000000..f09105a --- /dev/null +++ b/server/api/mailTransferReport/mailTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x238b=['body','params','describe','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','reject','save','then','destroy','error','stack','name','send','index','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL','options','MailTransferReport','include','findAll','catch','rawAttributes','includeAll','find','create'];(function(_0x1a9ed0,_0x1085fc){var _0x47bbd6=function(_0x27bd1c){while(--_0x27bd1c){_0x1a9ed0['push'](_0x1a9ed0['shift']());}};_0x47bbd6(++_0x1085fc);}(_0x238b,0x170));var _0xb238=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x238b[_0x14add3];return _0x4a174f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb238('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb238('0x1'));var rp=require(_0xb238('0x2'));var moment=require(_0xb238('0x3'));var BPromise=require(_0xb238('0x4'));var Mustache=require('mustache');var util=require(_0xb238('0x5'));var path=require(_0xb238('0x6'));var sox=require(_0xb238('0x7'));var csv=require(_0xb238('0x8'));var ejs=require(_0xb238('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb238('0xa'));var squel=require(_0xb238('0xb'));var crypto=require(_0xb238('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xb238('0xd'));var toCsv=require(_0xb238('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xb238('0xe'));var authService=require(_0xb238('0xf'));var qs=require(_0xb238('0x10'));var as=require(_0xb238('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb238('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xb238('0x13'));var licenseUtil=require(_0xb238('0x14'));var db=require(_0xb238('0x15'))['db'];function respondWithStatusCode(_0x2a8849,_0x5d0b70){_0x5d0b70=_0x5d0b70||0xcc;return function(_0x345fd0){if(_0x345fd0){return _0x2a8849[_0xb238('0x16')](_0x5d0b70);}return _0x2a8849[_0xb238('0x17')](_0x5d0b70)[_0xb238('0x18')]();};}function respondWithResult(_0x56300e,_0x523944){_0x523944=_0x523944||0xc8;return function(_0x5064e9){if(_0x5064e9){return _0x56300e[_0xb238('0x17')](_0x523944)['json'](_0x5064e9);}};}function respondWithFilteredResult(_0x1b6f55,_0x17482c){return function(_0x12bd5f){if(_0x12bd5f){var _0x2d62d2=typeof _0x17482c[_0xb238('0x19')]===_0xb238('0x1a')&&typeof _0x17482c[_0xb238('0x1b')]===_0xb238('0x1a');var _0x2ccbf4=_0x12bd5f[_0xb238('0x1c')];var _0x17ad30=_0x2d62d2?0x0:_0x17482c[_0xb238('0x19')];var _0x4ed841=_0x2d62d2?_0x12bd5f[_0xb238('0x1c')]:_0x17482c[_0xb238('0x19')]+_0x17482c[_0xb238('0x1b')];var _0x19df43;if(_0x4ed841>=_0x2ccbf4){_0x4ed841=_0x2ccbf4;_0x19df43=0xc8;}else{_0x19df43=0xce;}_0x1b6f55[_0xb238('0x17')](_0x19df43);return _0x1b6f55[_0xb238('0x1d')](_0xb238('0x1e'),_0x17ad30+'-'+_0x4ed841+'/'+_0x2ccbf4)[_0xb238('0x1f')](_0x12bd5f);}return null;};}function patchUpdates(_0x3b8d){return function(_0x192d34){try{jsonpatch['apply'](_0x192d34,_0x3b8d,!![]);}catch(_0x3a1a4a){return BPromise[_0xb238('0x20')](_0x3a1a4a);}return _0x192d34[_0xb238('0x21')]();};}function saveUpdates(_0x3e244a,_0x2219f4){return function(_0x45402c){if(_0x45402c){return _0x45402c['update'](_0x3e244a)[_0xb238('0x22')](function(_0x184458){return _0x184458;});}return null;};}function removeEntity(_0x286bd4,_0x4c404e){return function(_0x7113c1){if(_0x7113c1){return _0x7113c1[_0xb238('0x23')]()[_0xb238('0x22')](function(){_0x286bd4[_0xb238('0x17')](0xcc)[_0xb238('0x18')]();});}};}function handleEntityNotFound(_0x56d561,_0x357ac4){return function(_0x3b8c9c){if(!_0x3b8c9c){_0x56d561[_0xb238('0x16')](0x194);}return _0x3b8c9c;};}function handleError(_0x45b4a7,_0x3aa7e0){_0x3aa7e0=_0x3aa7e0||0x1f4;return function(_0x36de3d){logger[_0xb238('0x24')](_0x36de3d[_0xb238('0x25')]);if(_0x36de3d[_0xb238('0x26')]){delete _0x36de3d[_0xb238('0x26')];}_0x45b4a7[_0xb238('0x17')](_0x3aa7e0)[_0xb238('0x27')](_0x36de3d);};}exports[_0xb238('0x28')]=function(_0x5045e7,_0x294660){var _0x548392={},_0x5f40bc={},_0x105fc0={'count':0x0,'rows':[]};var _0x225853=_['map'](db['MailTransferReport']['rawAttributes'],function(_0x930c0a){return{'name':_0x930c0a['fieldName'],'type':_0x930c0a[_0xb238('0x29')][_0xb238('0x2a')]};});_0x5f40bc[_0xb238('0x2b')]=_['map'](_0x225853,_0xb238('0x26'));_0x5f40bc[_0xb238('0x2c')]=_[_0xb238('0x2d')](_0x5045e7[_0xb238('0x2c')]);_0x5f40bc[_0xb238('0x2e')]=_[_0xb238('0x2f')](_0x5f40bc['model'],_0x5f40bc['query']);_0x548392[_0xb238('0x30')]=_['intersection'](_0x5f40bc[_0xb238('0x2b')],qs[_0xb238('0x31')](_0x5045e7[_0xb238('0x2c')][_0xb238('0x31')]));_0x548392[_0xb238('0x30')]=_0x548392[_0xb238('0x30')][_0xb238('0x32')]?_0x548392[_0xb238('0x30')]:_0x5f40bc['model'];if(!_0x5045e7['query'][_0xb238('0x33')](_0xb238('0x34'))){_0x548392[_0xb238('0x1b')]=qs[_0xb238('0x1b')](_0x5045e7[_0xb238('0x2c')]['limit']);_0x548392[_0xb238('0x19')]=qs[_0xb238('0x19')](_0x5045e7[_0xb238('0x2c')][_0xb238('0x19')]);}_0x548392[_0xb238('0x35')]=qs[_0xb238('0x36')](_0x5045e7[_0xb238('0x2c')][_0xb238('0x36')]);_0x548392[_0xb238('0x37')]=qs[_0xb238('0x2e')](_[_0xb238('0x38')](_0x5045e7[_0xb238('0x2c')],_0x5f40bc['filters']),_0x225853);if(_0x5045e7['query'][_0xb238('0x39')]){_0x548392[_0xb238('0x37')]=_[_0xb238('0x3a')](_0x548392[_0xb238('0x37')],{'$or':_[_0xb238('0x3b')](_0x225853,function(_0x30ce4a){if(_0x30ce4a[_0xb238('0x29')]!==_0xb238('0x3c')){var _0x3e1c05={};_0x3e1c05[_0x30ce4a['name']]={'$like':'%'+_0x5045e7[_0xb238('0x2c')]['filter']+'%'};return _0x3e1c05;}})});}_0x548392=_[_0xb238('0x3a')]({},_0x548392,_0x5045e7[_0xb238('0x3d')]);var _0x2e3a78={'where':_0x548392[_0xb238('0x37')]};return db[_0xb238('0x3e')][_0xb238('0x1c')](_0x2e3a78)[_0xb238('0x22')](function(_0x5aab24){_0x105fc0['count']=_0x5aab24;if(_0x5045e7[_0xb238('0x2c')]['includeAll']){_0x548392[_0xb238('0x3f')]=[{'all':!![]}];}return db[_0xb238('0x3e')][_0xb238('0x40')](_0x548392);})[_0xb238('0x22')](function(_0xc3ac7f){_0x105fc0['rows']=_0xc3ac7f;return _0x105fc0;})[_0xb238('0x22')](respondWithFilteredResult(_0x294660,_0x548392))[_0xb238('0x41')](handleError(_0x294660,null));};exports['show']=function(_0x3f5291,_0x2fecde){var _0x577dd4={'raw':!![],'where':{'id':_0x3f5291['params']['id']}},_0x51d50c={};_0x51d50c[_0xb238('0x2b')]=_[_0xb238('0x2d')](db['MailTransferReport'][_0xb238('0x42')]);_0x51d50c[_0xb238('0x2c')]=_['keys'](_0x3f5291[_0xb238('0x2c')]);_0x51d50c['filters']=_['intersection'](_0x51d50c[_0xb238('0x2b')],_0x51d50c[_0xb238('0x2c')]);_0x577dd4['attributes']=_[_0xb238('0x2f')](_0x51d50c[_0xb238('0x2b')],qs[_0xb238('0x31')](_0x3f5291['query'][_0xb238('0x31')]));_0x577dd4[_0xb238('0x30')]=_0x577dd4[_0xb238('0x30')][_0xb238('0x32')]?_0x577dd4['attributes']:_0x51d50c[_0xb238('0x2b')];if(_0x3f5291[_0xb238('0x2c')][_0xb238('0x43')]){_0x577dd4[_0xb238('0x3f')]=[{'all':!![]}];}_0x577dd4=_['merge']({},_0x577dd4,_0x3f5291[_0xb238('0x3d')]);return db[_0xb238('0x3e')][_0xb238('0x44')](_0x577dd4)[_0xb238('0x22')](handleEntityNotFound(_0x2fecde,null))[_0xb238('0x22')](respondWithResult(_0x2fecde,null))[_0xb238('0x41')](handleError(_0x2fecde,null));};exports[_0xb238('0x45')]=function(_0x2e32b5,_0x366332){return db[_0xb238('0x3e')][_0xb238('0x45')](_0x2e32b5[_0xb238('0x46')],{})[_0xb238('0x22')](respondWithResult(_0x366332,0xc9))[_0xb238('0x41')](handleError(_0x366332,null));};exports['update']=function(_0x240967,_0x515c18){if(_0x240967['body']['id']){delete _0x240967['body']['id'];}return db[_0xb238('0x3e')][_0xb238('0x44')]({'where':{'id':_0x240967[_0xb238('0x47')]['id']}})[_0xb238('0x22')](handleEntityNotFound(_0x515c18,null))['then'](saveUpdates(_0x240967[_0xb238('0x46')],null))[_0xb238('0x22')](respondWithResult(_0x515c18,null))[_0xb238('0x41')](handleError(_0x515c18,null));};exports[_0xb238('0x23')]=function(_0x3b0e61,_0xf06cdd){return db[_0xb238('0x3e')][_0xb238('0x44')]({'where':{'id':_0x3b0e61[_0xb238('0x47')]['id']}})['then'](handleEntityNotFound(_0xf06cdd,null))[_0xb238('0x22')](removeEntity(_0xf06cdd,null))[_0xb238('0x41')](handleError(_0xf06cdd,null));};exports[_0xb238('0x48')]=function(_0x3eb9ed,_0x2beade){return db['MailTransferReport'][_0xb238('0x48')]()[_0xb238('0x22')](respondWithResult(_0x2beade,null))['catch'](handleError(_0x2beade,null));}; \ No newline at end of file diff --git a/server/api/mailTransferReport/mailTransferReport.model.js b/server/api/mailTransferReport/mailTransferReport.model.js new file mode 100644 index 0000000..e6ae281 --- /dev/null +++ b/server/api/mailTransferReport/mailTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x35f9=['rimraf','../../config/environment','define','MailTransferReport','report_mail_transfer','uniqueid','lodash','util','../../config/logger','api','bluebird'];(function(_0x51beba,_0x202d19){var _0x167ee0=function(_0x2d5b21){while(--_0x2d5b21){_0x51beba['push'](_0x51beba['shift']());}};_0x167ee0(++_0x202d19);}(_0x35f9,0x1df));var _0x935f=function(_0x3a8158,_0x58ed48){_0x3a8158=_0x3a8158-0x0;var _0x4021f8=_0x35f9[_0x3a8158];return _0x4021f8;};'use strict';var _=require(_0x935f('0x0'));var util=require(_0x935f('0x1'));var logger=require(_0x935f('0x2'))(_0x935f('0x3'));var moment=require('moment');var BPromise=require(_0x935f('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x935f('0x5'));var config=require(_0x935f('0x6'));var attributes=require('./mailTransferReport.attributes');module['exports']=function(_0x287043,_0x4403e1){return _0x287043[_0x935f('0x7')](_0x935f('0x8'),attributes,{'tableName':_0x935f('0x9'),'paranoid':![],'indexes':[{'name':_0x935f('0xa'),'fields':[_0x935f('0xa')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/mailTransferReport/mailTransferReport.rpc.js b/server/api/mailTransferReport/mailTransferReport.rpc.js new file mode 100644 index 0000000..b6913d3 --- /dev/null +++ b/server/api/mailTransferReport/mailTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5e6e=['info','MailTransferReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','then'];(function(_0x1a72b8,_0x1e4f4b){var _0x39f72d=function(_0x35aef1){while(--_0x35aef1){_0x1a72b8['push'](_0x1a72b8['shift']());}};_0x39f72d(++_0x1e4f4b);}(_0x5e6e,0x169));var _0xe5e6=function(_0x1903e3,_0xec6383){_0x1903e3=_0x1903e3-0x0;var _0x57cea4=_0x5e6e[_0x1903e3];return _0x57cea4;};'use strict';var _=require(_0xe5e6('0x0'));var util=require(_0xe5e6('0x1'));var moment=require(_0xe5e6('0x2'));var BPromise=require(_0xe5e6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe5e6('0x4'));var db=require(_0xe5e6('0x5'))['db'];var utils=require(_0xe5e6('0x6'));var logger=require('../../config/logger')(_0xe5e6('0x7'));var config=require(_0xe5e6('0x8'));var jayson=require(_0xe5e6('0x9'));var client=jayson[_0xe5e6('0xa')][_0xe5e6('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1b79be,_0x26dc6c,_0x4754c7){return new BPromise(function(_0xc5eba6,_0x149cb4){return client['request'](_0x1b79be,_0x4754c7)[_0xe5e6('0xc')](function(_0x517699){logger[_0xe5e6('0xd')](_0xe5e6('0xe'),_0x26dc6c,_0xe5e6('0xf'));logger[_0xe5e6('0x10')]('MailTransferReport,\x20%s,\x20%s,\x20%s',_0x26dc6c,_0xe5e6('0xf'),JSON[_0xe5e6('0x11')](_0x517699));if(_0x517699[_0xe5e6('0x12')]){if(_0x517699[_0xe5e6('0x12')][_0xe5e6('0x13')]===0x1f4){logger[_0xe5e6('0x12')](_0xe5e6('0xe'),_0x26dc6c,_0x517699[_0xe5e6('0x12')][_0xe5e6('0x14')]);return _0x149cb4(_0x517699[_0xe5e6('0x12')][_0xe5e6('0x14')]);}logger[_0xe5e6('0x12')](_0xe5e6('0xe'),_0x26dc6c,_0x517699[_0xe5e6('0x12')]['message']);return _0xc5eba6(_0x517699[_0xe5e6('0x12')][_0xe5e6('0x14')]);}else{logger[_0xe5e6('0xd')](_0xe5e6('0xe'),_0x26dc6c,'request\x20sent');_0xc5eba6(_0x517699[_0xe5e6('0x15')][_0xe5e6('0x14')]);}})['catch'](function(_0x56cca6){logger['error'](_0xe5e6('0xe'),_0x26dc6c,_0x56cca6);_0x149cb4(_0x56cca6);});});} \ No newline at end of file diff --git a/server/api/memberReport/index.js b/server/api/memberReport/index.js new file mode 100644 index 0000000..b0b1e9a --- /dev/null +++ b/server/api/memberReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7c3b=['/describe','describe','/:id','show','create','put','update','delete','destroy','exports','multer','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','./memberReport.controller','get','isAuthenticated'];(function(_0x2ee974,_0x1cceb5){var _0x20c5fb=function(_0xc54e84){while(--_0xc54e84){_0x2ee974['push'](_0x2ee974['shift']());}};_0x20c5fb(++_0x1cceb5);}(_0x7c3b,0x9d));var _0xb7c3=function(_0x4d7d77,_0x2c4113){_0x4d7d77=_0x4d7d77-0x0;var _0x13e3b9=_0x7c3b[_0x4d7d77];return _0x13e3b9;};'use strict';var multer=require(_0xb7c3('0x0'));var util=require('util');var path=require(_0xb7c3('0x1'));var timeout=require(_0xb7c3('0x2'));var express=require(_0xb7c3('0x3'));var router=express[_0xb7c3('0x4')]();var fs_extra=require(_0xb7c3('0x5'));var auth=require(_0xb7c3('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0xb7c3('0x7'));var controller=require(_0xb7c3('0x8'));router[_0xb7c3('0x9')]('/',auth[_0xb7c3('0xa')](),controller['index']);router[_0xb7c3('0x9')](_0xb7c3('0xb'),auth[_0xb7c3('0xa')](),controller[_0xb7c3('0xc')]);router[_0xb7c3('0x9')](_0xb7c3('0xd'),auth['isAuthenticated'](),controller[_0xb7c3('0xe')]);router['post']('/',auth[_0xb7c3('0xa')](),controller[_0xb7c3('0xf')]);router[_0xb7c3('0x10')]('/:id',auth[_0xb7c3('0xa')](),controller[_0xb7c3('0x11')]);router[_0xb7c3('0x12')](_0xb7c3('0xd'),auth[_0xb7c3('0xa')](),controller[_0xb7c3('0x13')]);module[_0xb7c3('0x14')]=router; \ No newline at end of file diff --git a/server/api/memberReport/memberReport.attributes.js b/server/api/memberReport/memberReport.attributes.js new file mode 100644 index 0000000..1474f26 --- /dev/null +++ b/server/api/memberReport/memberReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x350f=['exports','STRING','DEFAULT\x20PAUSE','LOGIN,\x20PAUSE,\x20TALKING','DATE','getDataValue','enterAt','diff','setDataValue','exitAt','duration','talk:[inbound,\x20outbound],\x20pause:[reason]','talk:[start]','talk:[dial\x20string]','talk:[queue]','INTEGER','sequelize','moment'];(function(_0x34e553,_0x3935e1){var _0x4485b5=function(_0x5ebd36){while(--_0x5ebd36){_0x34e553['push'](_0x34e553['shift']());}};_0x4485b5(++_0x3935e1);}(_0x350f,0xa0));var _0xf350=function(_0x34bc94,_0x74f0fd){_0x34bc94=_0x34bc94-0x0;var _0xee41e7=_0x350f[_0x34bc94];return _0xee41e7;};'use strict';var Sequelize=require(_0xf350('0x0'));var moment=require(_0xf350('0x1'));module[_0xf350('0x2')]={'channel':{'type':Sequelize[_0xf350('0x3')]},'membername':{'type':Sequelize['STRING']},'interface':{'type':Sequelize[_0xf350('0x3')]},'type':{'type':Sequelize[_0xf350('0x3')],'defaultValue':_0xf350('0x4'),'comment':_0xf350('0x5')},'duration':{'type':Sequelize['INTEGER']},'enterAt':{'type':Sequelize[_0xf350('0x6')]},'exitAt':{'type':Sequelize['DATE'],'set':function(_0x17db12){var _0x1d2a30=moment(_0x17db12);var _0x4a74fa=moment(this[_0xf350('0x7')](_0xf350('0x8')));var _0xd675ec=_0x1d2a30[_0xf350('0x9')](_0x4a74fa,'seconds');this[_0xf350('0xa')](_0xf350('0xb'),_0x17db12);this[_0xf350('0xa')](_0xf350('0xc'),_0xd675ec>=0x0?_0xd675ec:null);}},'data1':{'type':Sequelize['STRING'],'comment':_0xf350('0xd')},'data2':{'type':Sequelize[_0xf350('0x3')],'comment':_0xf350('0xe')},'data3':{'type':Sequelize[_0xf350('0x3')],'comment':'talk:[destination]'},'data4':{'type':Sequelize[_0xf350('0x3')],'comment':_0xf350('0xf')},'data5':{'type':Sequelize[_0xf350('0x3')],'comment':_0xf350('0x10')},'role':{'type':Sequelize[_0xf350('0x3')]},'internal':{'type':Sequelize[_0xf350('0x11')]},'uniqueid':{'type':Sequelize[_0xf350('0x3')]}}; \ No newline at end of file diff --git a/server/api/memberReport/memberReport.controller.js b/server/api/memberReport/memberReport.controller.js new file mode 100644 index 0000000..1e768f8 --- /dev/null +++ b/server/api/memberReport/memberReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xedd9=['keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','params','find','create','body','update','destroy','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','apply','then','end','error','stack','send','index','map','MemberReport','rawAttributes','fieldName','type','key','model','name','query'];(function(_0x376b45,_0x5964fb){var _0x2341b3=function(_0x5a7f01){while(--_0x5a7f01){_0x376b45['push'](_0x376b45['shift']());}};_0x2341b3(++_0x5964fb);}(_0xedd9,0xfc));var _0x9edd=function(_0x47afa7,_0x5ef197){_0x47afa7=_0x47afa7-0x0;var _0x23d021=_0xedd9[_0x47afa7];return _0x23d021;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9edd('0x0'));var zipdir=require(_0x9edd('0x1'));var jsonpatch=require(_0x9edd('0x2'));var rp=require(_0x9edd('0x3'));var moment=require(_0x9edd('0x4'));var BPromise=require(_0x9edd('0x5'));var Mustache=require(_0x9edd('0x6'));var util=require(_0x9edd('0x7'));var path=require('path');var sox=require(_0x9edd('0x8'));var csv=require(_0x9edd('0x9'));var ejs=require(_0x9edd('0xa'));var fs=require('fs');var fs_extra=require(_0x9edd('0xb'));var _=require('lodash');var squel=require(_0x9edd('0xc'));var crypto=require('crypto');var jsforce=require(_0x9edd('0xd'));var deskjs=require(_0x9edd('0xe'));var toCsv=require(_0x9edd('0x9'));var querystring=require(_0x9edd('0xf'));var Papa=require('papaparse');var Redis=require(_0x9edd('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x9edd('0x11'));var as=require(_0x9edd('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9edd('0x13'))(_0x9edd('0x14'));var utils=require('../../config/utils');var config=require(_0x9edd('0x15'));var licenseUtil=require(_0x9edd('0x16'));var db=require(_0x9edd('0x17'))['db'];function respondWithStatusCode(_0xfd544a,_0x287ddd){_0x287ddd=_0x287ddd||0xcc;return function(_0x3a7b84){if(_0x3a7b84){return _0xfd544a[_0x9edd('0x18')](_0x287ddd);}return _0xfd544a[_0x9edd('0x19')](_0x287ddd)['end']();};}function respondWithResult(_0x176bfa,_0x44fc7c){_0x44fc7c=_0x44fc7c||0xc8;return function(_0x891832){if(_0x891832){return _0x176bfa[_0x9edd('0x19')](_0x44fc7c)[_0x9edd('0x1a')](_0x891832);}};}function respondWithFilteredResult(_0x338f3c,_0x1042aa){return function(_0x75a4ab){if(_0x75a4ab){var _0x4ea60f=typeof _0x1042aa[_0x9edd('0x1b')]===_0x9edd('0x1c')&&typeof _0x1042aa[_0x9edd('0x1d')]==='undefined';var _0x1b54c0=_0x75a4ab[_0x9edd('0x1e')];var _0x40ba32=_0x4ea60f?0x0:_0x1042aa['offset'];var _0x43dc70=_0x4ea60f?_0x75a4ab['count']:_0x1042aa[_0x9edd('0x1b')]+_0x1042aa[_0x9edd('0x1d')];var _0x4bdb88;if(_0x43dc70>=_0x1b54c0){_0x43dc70=_0x1b54c0;_0x4bdb88=0xc8;}else{_0x4bdb88=0xce;}_0x338f3c['status'](_0x4bdb88);return _0x338f3c[_0x9edd('0x1f')]('Content-Range',_0x40ba32+'-'+_0x43dc70+'/'+_0x1b54c0)[_0x9edd('0x1a')](_0x75a4ab);}return null;};}function patchUpdates(_0x54a03f){return function(_0x535f37){try{jsonpatch[_0x9edd('0x20')](_0x535f37,_0x54a03f,!![]);}catch(_0x1c46a8){return BPromise['reject'](_0x1c46a8);}return _0x535f37['save']();};}function saveUpdates(_0x341d67,_0x186186){return function(_0x477878){if(_0x477878){return _0x477878['update'](_0x341d67)[_0x9edd('0x21')](function(_0x1dca43){return _0x1dca43;});}return null;};}function removeEntity(_0x44a6c1,_0x2ca65f){return function(_0x339a0d){if(_0x339a0d){return _0x339a0d['destroy']()[_0x9edd('0x21')](function(){_0x44a6c1[_0x9edd('0x19')](0xcc)[_0x9edd('0x22')]();});}};}function handleEntityNotFound(_0x2f9f86,_0x310a4d){return function(_0x4d507f){if(!_0x4d507f){_0x2f9f86['sendStatus'](0x194);}return _0x4d507f;};}function handleError(_0x3276ee,_0xfeca7b){_0xfeca7b=_0xfeca7b||0x1f4;return function(_0x8d67aa){logger[_0x9edd('0x23')](_0x8d67aa[_0x9edd('0x24')]);if(_0x8d67aa['name']){delete _0x8d67aa['name'];}_0x3276ee[_0x9edd('0x19')](_0xfeca7b)[_0x9edd('0x25')](_0x8d67aa);};}exports[_0x9edd('0x26')]=function(_0x52746a,_0x238b22){var _0x28cfae={},_0x2ae8dd={},_0x41af53={'count':0x0,'rows':[]};var _0x5eccfb=_[_0x9edd('0x27')](db[_0x9edd('0x28')][_0x9edd('0x29')],function(_0x12c1bc){return{'name':_0x12c1bc[_0x9edd('0x2a')],'type':_0x12c1bc[_0x9edd('0x2b')][_0x9edd('0x2c')]};});_0x2ae8dd[_0x9edd('0x2d')]=_[_0x9edd('0x27')](_0x5eccfb,_0x9edd('0x2e'));_0x2ae8dd[_0x9edd('0x2f')]=_[_0x9edd('0x30')](_0x52746a[_0x9edd('0x2f')]);_0x2ae8dd[_0x9edd('0x31')]=_[_0x9edd('0x32')](_0x2ae8dd['model'],_0x2ae8dd[_0x9edd('0x2f')]);_0x28cfae[_0x9edd('0x33')]=_[_0x9edd('0x32')](_0x2ae8dd['model'],qs[_0x9edd('0x34')](_0x52746a[_0x9edd('0x2f')][_0x9edd('0x34')]));_0x28cfae[_0x9edd('0x33')]=_0x28cfae[_0x9edd('0x33')][_0x9edd('0x35')]?_0x28cfae[_0x9edd('0x33')]:_0x2ae8dd[_0x9edd('0x2d')];if(!_0x52746a[_0x9edd('0x2f')][_0x9edd('0x36')](_0x9edd('0x37'))){_0x28cfae[_0x9edd('0x1d')]=qs[_0x9edd('0x1d')](_0x52746a[_0x9edd('0x2f')]['limit']);_0x28cfae[_0x9edd('0x1b')]=qs['offset'](_0x52746a[_0x9edd('0x2f')][_0x9edd('0x1b')]);}_0x28cfae[_0x9edd('0x38')]=qs[_0x9edd('0x39')](_0x52746a[_0x9edd('0x2f')]['sort']);_0x28cfae[_0x9edd('0x3a')]=qs[_0x9edd('0x31')](_[_0x9edd('0x3b')](_0x52746a[_0x9edd('0x2f')],_0x2ae8dd[_0x9edd('0x31')]),_0x5eccfb);if(_0x52746a[_0x9edd('0x2f')][_0x9edd('0x3c')]){_0x28cfae[_0x9edd('0x3a')]=_[_0x9edd('0x3d')](_0x28cfae[_0x9edd('0x3a')],{'$or':_['map'](_0x5eccfb,function(_0x231604){if(_0x231604['type']!==_0x9edd('0x3e')){var _0x5658d6={};_0x5658d6[_0x231604[_0x9edd('0x2e')]]={'$like':'%'+_0x52746a[_0x9edd('0x2f')][_0x9edd('0x3c')]+'%'};return _0x5658d6;}})});}_0x28cfae=_['merge']({},_0x28cfae,_0x52746a[_0x9edd('0x3f')]);var _0xcbd0ef={'where':_0x28cfae[_0x9edd('0x3a')]};return db['MemberReport'][_0x9edd('0x1e')](_0xcbd0ef)['then'](function(_0x1fc4fb){_0x41af53[_0x9edd('0x1e')]=_0x1fc4fb;if(_0x52746a['query'][_0x9edd('0x40')]){_0x28cfae[_0x9edd('0x41')]=[{'all':!![]}];}return db[_0x9edd('0x28')][_0x9edd('0x42')](_0x28cfae);})['then'](function(_0x449f01){_0x41af53['rows']=_0x449f01;return _0x41af53;})[_0x9edd('0x21')](respondWithFilteredResult(_0x238b22,_0x28cfae))[_0x9edd('0x43')](handleError(_0x238b22,null));};exports['show']=function(_0x318757,_0x49a128){var _0x548299={'raw':!![],'where':{'id':_0x318757[_0x9edd('0x44')]['id']}},_0x369b69={};_0x369b69[_0x9edd('0x2d')]=_[_0x9edd('0x30')](db[_0x9edd('0x28')][_0x9edd('0x29')]);_0x369b69[_0x9edd('0x2f')]=_[_0x9edd('0x30')](_0x318757[_0x9edd('0x2f')]);_0x369b69[_0x9edd('0x31')]=_[_0x9edd('0x32')](_0x369b69[_0x9edd('0x2d')],_0x369b69[_0x9edd('0x2f')]);_0x548299[_0x9edd('0x33')]=_[_0x9edd('0x32')](_0x369b69['model'],qs[_0x9edd('0x34')](_0x318757[_0x9edd('0x2f')][_0x9edd('0x34')]));_0x548299[_0x9edd('0x33')]=_0x548299[_0x9edd('0x33')][_0x9edd('0x35')]?_0x548299[_0x9edd('0x33')]:_0x369b69['model'];if(_0x318757['query']['includeAll']){_0x548299[_0x9edd('0x41')]=[{'all':!![]}];}_0x548299=_['merge']({},_0x548299,_0x318757[_0x9edd('0x3f')]);return db[_0x9edd('0x28')][_0x9edd('0x45')](_0x548299)[_0x9edd('0x21')](handleEntityNotFound(_0x49a128,null))[_0x9edd('0x21')](respondWithResult(_0x49a128,null))['catch'](handleError(_0x49a128,null));};exports[_0x9edd('0x46')]=function(_0x35e63c,_0x40e33d){return db['MemberReport'][_0x9edd('0x46')](_0x35e63c[_0x9edd('0x47')],{})[_0x9edd('0x21')](respondWithResult(_0x40e33d,0xc9))[_0x9edd('0x43')](handleError(_0x40e33d,null));};exports[_0x9edd('0x48')]=function(_0x35bdec,_0x4d4f33){if(_0x35bdec[_0x9edd('0x47')]['id']){delete _0x35bdec[_0x9edd('0x47')]['id'];}return db['MemberReport'][_0x9edd('0x45')]({'where':{'id':_0x35bdec[_0x9edd('0x44')]['id']}})['then'](handleEntityNotFound(_0x4d4f33,null))[_0x9edd('0x21')](saveUpdates(_0x35bdec[_0x9edd('0x47')],null))[_0x9edd('0x21')](respondWithResult(_0x4d4f33,null))['catch'](handleError(_0x4d4f33,null));};exports[_0x9edd('0x49')]=function(_0x151157,_0x317a60){return db[_0x9edd('0x28')]['find']({'where':{'id':_0x151157[_0x9edd('0x44')]['id']}})[_0x9edd('0x21')](handleEntityNotFound(_0x317a60,null))[_0x9edd('0x21')](removeEntity(_0x317a60,null))['catch'](handleError(_0x317a60,null));};exports[_0x9edd('0x4a')]=function(_0x21f6ce,_0x57db43){return db[_0x9edd('0x28')]['describe']()[_0x9edd('0x21')](respondWithResult(_0x57db43,null))[_0x9edd('0x43')](handleError(_0x57db43,null));}; \ No newline at end of file diff --git a/server/api/memberReport/memberReport.model.js b/server/api/memberReport/memberReport.model.js new file mode 100644 index 0000000..e3ce4df --- /dev/null +++ b/server/api/memberReport/memberReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd011=['report_member','membername','interface','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./memberReport.attributes','define','MemberReport'];(function(_0x3a2ef5,_0x47e4c1){var _0x48d535=function(_0x5e5503){while(--_0x5e5503){_0x3a2ef5['push'](_0x3a2ef5['shift']());}};_0x48d535(++_0x47e4c1);}(_0xd011,0xc6));var _0x1d01=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xd011[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x1d01('0x0'));var util=require(_0x1d01('0x1'));var logger=require('../../config/logger')(_0x1d01('0x2'));var moment=require(_0x1d01('0x3'));var BPromise=require(_0x1d01('0x4'));var rp=require(_0x1d01('0x5'));var fs=require('fs');var path=require(_0x1d01('0x6'));var rimraf=require(_0x1d01('0x7'));var config=require(_0x1d01('0x8'));var attributes=require(_0x1d01('0x9'));module['exports']=function(_0x4afecd,_0x114552){return _0x4afecd[_0x1d01('0xa')](_0x1d01('0xb'),attributes,{'tableName':_0x1d01('0xc'),'paranoid':![],'indexes':[{'name':'membername_interface','fields':[_0x1d01('0xd'),_0x1d01('0xe')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/memberReport/memberReport.rpc.js b/server/api/memberReport/memberReport.rpc.js new file mode 100644 index 0000000..5b68d02 --- /dev/null +++ b/server/api/memberReport/memberReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x720b=['client','http','request','then','info','MemberReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','GetMemberReport','MemberReport','findAll','options','raw','where','attributes','limit','map','include','model','CreateMemberReport','create','body','update','UpdateMemberReport','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x25e7cb,_0x3579b7){var _0x375d92=function(_0xe8cf3b){while(--_0xe8cf3b){_0x25e7cb['push'](_0x25e7cb['shift']());}};_0x375d92(++_0x3579b7);}(_0x720b,0x1d8));var _0xb720=function(_0xa39151,_0x2da41d){_0xa39151=_0xa39151-0x0;var _0x294a0c=_0x720b[_0xa39151];return _0x294a0c;};'use strict';var _=require(_0xb720('0x0'));var util=require(_0xb720('0x1'));var moment=require(_0xb720('0x2'));var BPromise=require('bluebird');var rs=require(_0xb720('0x3'));var fs=require('fs');var Redis=require(_0xb720('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb720('0x5'));var logger=require(_0xb720('0x6'))(_0xb720('0x7'));var config=require('../../config/environment');var jayson=require(_0xb720('0x8'));var client=jayson[_0xb720('0x9')][_0xb720('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x19d0ba,_0x2b319a,_0x4c327c){return new BPromise(function(_0x5a97b8,_0x259266){return client[_0xb720('0xb')](_0x19d0ba,_0x4c327c)[_0xb720('0xc')](function(_0x16fbb0){logger[_0xb720('0xd')](_0xb720('0xe'),_0x2b319a,_0xb720('0xf'));logger[_0xb720('0x10')]('MemberReport,\x20%s,\x20%s,\x20%s',_0x2b319a,_0xb720('0xf'),JSON[_0xb720('0x11')](_0x16fbb0));if(_0x16fbb0['error']){if(_0x16fbb0[_0xb720('0x12')]['code']===0x1f4){logger[_0xb720('0x12')]('MemberReport,\x20%s,\x20%s',_0x2b319a,_0x16fbb0[_0xb720('0x12')][_0xb720('0x13')]);return _0x259266(_0x16fbb0[_0xb720('0x12')][_0xb720('0x13')]);}logger[_0xb720('0x12')](_0xb720('0xe'),_0x2b319a,_0x16fbb0[_0xb720('0x12')][_0xb720('0x13')]);return _0x5a97b8(_0x16fbb0['error'][_0xb720('0x13')]);}else{logger[_0xb720('0xd')](_0xb720('0xe'),_0x2b319a,'request\x20sent');_0x5a97b8(_0x16fbb0['result'][_0xb720('0x13')]);}})[_0xb720('0x14')](function(_0x373303){logger['error'](_0xb720('0xe'),_0x2b319a,_0x373303);_0x259266(_0x373303);});});}exports[_0xb720('0x15')]=function(_0x453c43){var _0x2cf456=this;return new Promise(function(_0x395d6a,_0x730e0f){return db[_0xb720('0x16')][_0xb720('0x17')]({'raw':_0x453c43[_0xb720('0x18')]?_0x453c43[_0xb720('0x18')][_0xb720('0x19')]===undefined?!![]:![]:!![],'where':_0x453c43[_0xb720('0x18')]?_0x453c43[_0xb720('0x18')][_0xb720('0x1a')]||null:null,'attributes':_0x453c43[_0xb720('0x18')]?_0x453c43[_0xb720('0x18')][_0xb720('0x1b')]||null:null,'limit':_0x453c43[_0xb720('0x18')]?_0x453c43[_0xb720('0x18')][_0xb720('0x1c')]||null:null,'include':_0x453c43['options']?_0x453c43['options']['include']?_[_0xb720('0x1d')](_0x453c43['options'][_0xb720('0x1e')],function(_0x20bec1){return{'model':db[_0x20bec1[_0xb720('0x1f')]],'as':_0x20bec1['as'],'attributes':_0x20bec1[_0xb720('0x1b')],'include':_0x20bec1[_0xb720('0x1e')]?_[_0xb720('0x1d')](_0x20bec1['include'],function(_0x498860){return{'model':db[_0x498860['model']],'as':_0x498860['as'],'attributes':_0x498860[_0xb720('0x1b')],'include':_0x498860[_0xb720('0x1e')]?_['map'](_0x498860['include'],function(_0x1c3805){return{'model':db[_0x1c3805['model']],'as':_0x1c3805['as'],'attributes':_0x1c3805[_0xb720('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4e436f){logger[_0xb720('0xd')](_0xb720('0x15'),_0x453c43);logger[_0xb720('0x10')](_0xb720('0x15'),_0x453c43,JSON[_0xb720('0x11')](_0x4e436f));_0x395d6a(_0x4e436f);})[_0xb720('0x14')](function(_0x732423){logger[_0xb720('0x12')]('GetMemberReport',_0x732423['message'],_0x453c43);_0x730e0f(_0x2cf456['error'](0x1f4,_0x732423[_0xb720('0x13')]));});});};exports[_0xb720('0x20')]=function(_0x49b6ae){var _0x1f7979=this;return new Promise(function(_0x558bbe,_0x2b6445){return db[_0xb720('0x16')][_0xb720('0x21')](_0x49b6ae[_0xb720('0x22')],{'raw':_0x49b6ae[_0xb720('0x18')]?_0x49b6ae[_0xb720('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xb720('0xc')](function(_0x40752a){logger[_0xb720('0xd')]('CreateMemberReport',_0x49b6ae);logger[_0xb720('0x10')](_0xb720('0x20'),_0x49b6ae,JSON['stringify'](_0x40752a));_0x558bbe(_0x40752a);})['catch'](function(_0x29e540){logger['error'](_0xb720('0x20'),_0x29e540[_0xb720('0x13')],_0x49b6ae);_0x2b6445(_0x1f7979[_0xb720('0x12')](0x1f4,_0x29e540[_0xb720('0x13')]));});});};exports['UpdateMemberReport']=function(_0x591b0e){var _0x259a71=this;return new Promise(function(_0x9d5954,_0x21e561){return db[_0xb720('0x16')][_0xb720('0x23')](_0x591b0e['body'],{'raw':_0x591b0e['options']?_0x591b0e[_0xb720('0x18')][_0xb720('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x591b0e[_0xb720('0x18')]?_0x591b0e[_0xb720('0x18')][_0xb720('0x1a')]||null:null,'attributes':_0x591b0e[_0xb720('0x18')]?_0x591b0e[_0xb720('0x18')][_0xb720('0x1b')]||null:null,'limit':_0x591b0e[_0xb720('0x18')]?_0x591b0e['options']['limit']||null:null})[_0xb720('0xc')](function(_0x221d39){logger[_0xb720('0xd')](_0xb720('0x24'),_0x591b0e);logger[_0xb720('0x10')](_0xb720('0x24'),_0x591b0e,JSON[_0xb720('0x11')](_0x221d39));_0x9d5954(_0x221d39);})[_0xb720('0x14')](function(_0xad5038){logger[_0xb720('0x12')](_0xb720('0x24'),_0xad5038[_0xb720('0x13')],_0x591b0e);_0x21e561(_0x259a71[_0xb720('0x12')](0x1f4,_0xad5038[_0xb720('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/migration/index.js b/server/api/migration/index.js new file mode 100644 index 0000000..7c7bd99 --- /dev/null +++ b/server/api/migration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x170d=['express','Router','../../components/interaction/service','./migration.controller','get','index','exports','multer','util','path','connect-timeout'];(function(_0x5c9c54,_0x5a5d39){var _0x51da8b=function(_0x153241){while(--_0x153241){_0x5c9c54['push'](_0x5c9c54['shift']());}};_0x51da8b(++_0x5a5d39);}(_0x170d,0x13b));var _0xd170=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0x170d[_0x59ee6f];return _0x4c0979;};'use strict';var multer=require(_0xd170('0x0'));var util=require(_0xd170('0x1'));var path=require(_0xd170('0x2'));var timeout=require(_0xd170('0x3'));var express=require(_0xd170('0x4'));var router=express[_0xd170('0x5')]();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require(_0xd170('0x6'));var config=require('../../config/environment');var controller=require(_0xd170('0x7'));router[_0xd170('0x8')]('/',controller[_0xd170('0x9')]);module[_0xd170('0xa')]=router; \ No newline at end of file diff --git a/server/api/migration/migration.attributes.js b/server/api/migration/migration.attributes.js new file mode 100644 index 0000000..f18f551 --- /dev/null +++ b/server/api/migration/migration.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc760=['version','exports','STRING'];(function(_0x1026d2,_0x42fe66){var _0x4a6773=function(_0x1a295f){while(--_0x1a295f){_0x1026d2['push'](_0x1026d2['shift']());}};_0x4a6773(++_0x42fe66);}(_0xc760,0x7f));var _0x0c76=function(_0x4e4bf8,_0x65dcf3){_0x4e4bf8=_0x4e4bf8-0x0;var _0x39171c=_0xc760[_0x4e4bf8];return _0x39171c;};'use strict';var Sequelize=require('sequelize');module[_0x0c76('0x0')]={'version':{'type':Sequelize[_0x0c76('0x1')],'unique':_0x0c76('0x2')}}; \ No newline at end of file diff --git a/server/api/migration/migration.controller.js b/server/api/migration/migration.controller.js new file mode 100644 index 0000000..3938488 --- /dev/null +++ b/server/api/migration/migration.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x088d=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','set','Content-Range','json','apply','reject','save','then','destroy','error','name','send','index','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','order','sort','filters','pick','filter','merge','where','VIRTUAL','Migration','includeAll','findAll','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse'];(function(_0x25566d,_0x478964){var _0x27f3a8=function(_0x172aa3){while(--_0x172aa3){_0x25566d['push'](_0x25566d['shift']());}};_0x27f3a8(++_0x478964);}(_0x088d,0x7b));var _0xd088=function(_0x3ed888,_0x1e4779){_0x3ed888=_0x3ed888-0x0;var _0x4b1254=_0x088d[_0x3ed888];return _0x4b1254;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xd088('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd088('0x1'));var rp=require(_0xd088('0x2'));var moment=require(_0xd088('0x3'));var BPromise=require(_0xd088('0x4'));var Mustache=require(_0xd088('0x5'));var util=require(_0xd088('0x6'));var path=require('path');var sox=require(_0xd088('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xd088('0x8'));var _=require(_0xd088('0x9'));var squel=require(_0xd088('0xa'));var crypto=require(_0xd088('0xb'));var jsforce=require(_0xd088('0xc'));var deskjs=require(_0xd088('0xd'));var toCsv=require(_0xd088('0xe'));var querystring=require(_0xd088('0xf'));var Papa=require(_0xd088('0x10'));var Redis=require(_0xd088('0x11'));var authService=require(_0xd088('0x12'));var qs=require(_0xd088('0x13'));var as=require(_0xd088('0x14'));var hardwareService=require(_0xd088('0x15'));var logger=require(_0xd088('0x16'))(_0xd088('0x17'));var utils=require(_0xd088('0x18'));var config=require(_0xd088('0x19'));var licenseUtil=require(_0xd088('0x1a'));var db=require(_0xd088('0x1b'))['db'];function respondWithStatusCode(_0x431e3d,_0x25c84c){_0x25c84c=_0x25c84c||0xcc;return function(_0x4f1b6e){if(_0x4f1b6e){return _0x431e3d[_0xd088('0x1c')](_0x25c84c);}return _0x431e3d[_0xd088('0x1d')](_0x25c84c)[_0xd088('0x1e')]();};}function respondWithResult(_0x5e6b03,_0x52ec3f){_0x52ec3f=_0x52ec3f||0xc8;return function(_0x3a8f09){if(_0x3a8f09){return _0x5e6b03['status'](_0x52ec3f)['json'](_0x3a8f09);}};}function respondWithFilteredResult(_0x2ec961,_0x41c94d){return function(_0x5eaf3e){if(_0x5eaf3e){var _0x456382=typeof _0x41c94d[_0xd088('0x1f')]==='undefined'&&typeof _0x41c94d[_0xd088('0x20')]===_0xd088('0x21');var _0x5cf192=_0x5eaf3e[_0xd088('0x22')];var _0xdfa1ef=_0x456382?0x0:_0x41c94d[_0xd088('0x1f')];var _0x2fcebb=_0x456382?_0x5eaf3e[_0xd088('0x22')]:_0x41c94d[_0xd088('0x1f')]+_0x41c94d[_0xd088('0x20')];var _0xe334cf;if(_0x2fcebb>=_0x5cf192){_0x2fcebb=_0x5cf192;_0xe334cf=0xc8;}else{_0xe334cf=0xce;}_0x2ec961['status'](_0xe334cf);return _0x2ec961[_0xd088('0x23')](_0xd088('0x24'),_0xdfa1ef+'-'+_0x2fcebb+'/'+_0x5cf192)[_0xd088('0x25')](_0x5eaf3e);}return null;};}function patchUpdates(_0x36528d){return function(_0x9a17c4){try{jsonpatch[_0xd088('0x26')](_0x9a17c4,_0x36528d,!![]);}catch(_0x398e12){return BPromise[_0xd088('0x27')](_0x398e12);}return _0x9a17c4[_0xd088('0x28')]();};}function saveUpdates(_0x345581,_0x33edcf){return function(_0x4da08e){if(_0x4da08e){return _0x4da08e['update'](_0x345581)[_0xd088('0x29')](function(_0x45276d){return _0x45276d;});}return null;};}function removeEntity(_0x55aa2c,_0x4be45a){return function(_0x328a17){if(_0x328a17){return _0x328a17[_0xd088('0x2a')]()['then'](function(){_0x55aa2c['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x578a6e,_0x3030c0){return function(_0x34b1e4){if(!_0x34b1e4){_0x578a6e['sendStatus'](0x194);}return _0x34b1e4;};}function handleError(_0x10f3cc,_0x163665){_0x163665=_0x163665||0x1f4;return function(_0x67d004){logger[_0xd088('0x2b')](_0x67d004['stack']);if(_0x67d004[_0xd088('0x2c')]){delete _0x67d004['name'];}_0x10f3cc[_0xd088('0x1d')](_0x163665)[_0xd088('0x2d')](_0x67d004);};}exports[_0xd088('0x2e')]=function(_0x591857,_0x910efe){var _0x5b9529={},_0x1afdce={},_0x7e9e44={'count':0x0,'rows':[]};var _0x3feb3e=_['map'](db['Migration'][_0xd088('0x2f')],function(_0xd1b147){return{'name':_0xd1b147[_0xd088('0x30')],'type':_0xd1b147[_0xd088('0x31')][_0xd088('0x32')]};});_0x1afdce[_0xd088('0x33')]=_[_0xd088('0x34')](_0x3feb3e,_0xd088('0x2c'));_0x1afdce[_0xd088('0x35')]=_[_0xd088('0x36')](_0x591857['query']);_0x1afdce['filters']=_[_0xd088('0x37')](_0x1afdce[_0xd088('0x33')],_0x1afdce[_0xd088('0x35')]);_0x5b9529[_0xd088('0x38')]=_[_0xd088('0x37')](_0x1afdce[_0xd088('0x33')],qs[_0xd088('0x39')](_0x591857[_0xd088('0x35')]['fields']));_0x5b9529[_0xd088('0x38')]=_0x5b9529[_0xd088('0x38')][_0xd088('0x3a')]?_0x5b9529['attributes']:_0x1afdce[_0xd088('0x33')];if(!_0x591857[_0xd088('0x35')]['hasOwnProperty']('nolimit')){_0x5b9529[_0xd088('0x20')]=qs[_0xd088('0x20')](_0x591857['query'][_0xd088('0x20')]);_0x5b9529['offset']=qs[_0xd088('0x1f')](_0x591857[_0xd088('0x35')][_0xd088('0x1f')]);}_0x5b9529[_0xd088('0x3b')]=qs[_0xd088('0x3c')](_0x591857[_0xd088('0x35')]['sort']);_0x5b9529['where']=qs[_0xd088('0x3d')](_[_0xd088('0x3e')](_0x591857[_0xd088('0x35')],_0x1afdce[_0xd088('0x3d')]),_0x3feb3e);if(_0x591857[_0xd088('0x35')][_0xd088('0x3f')]){_0x5b9529['where']=_[_0xd088('0x40')](_0x5b9529[_0xd088('0x41')],{'$or':_[_0xd088('0x34')](_0x3feb3e,function(_0x289476){if(_0x289476['type']!==_0xd088('0x42')){var _0x51491f={};_0x51491f[_0x289476['name']]={'$like':'%'+_0x591857[_0xd088('0x35')][_0xd088('0x3f')]+'%'};return _0x51491f;}})});}_0x5b9529=_[_0xd088('0x40')]({},_0x5b9529,_0x591857['options']);var _0x3bcfdb={'where':_0x5b9529[_0xd088('0x41')]};return db[_0xd088('0x43')]['count'](_0x3bcfdb)[_0xd088('0x29')](function(_0x1057fb){_0x7e9e44[_0xd088('0x22')]=_0x1057fb;if(_0x591857[_0xd088('0x35')][_0xd088('0x44')]){_0x5b9529['include']=[{'all':!![]}];}return db[_0xd088('0x43')][_0xd088('0x45')](_0x5b9529);})[_0xd088('0x29')](function(_0x304905){_0x7e9e44['rows']=_0x304905;return _0x7e9e44;})['then'](respondWithFilteredResult(_0x910efe,_0x5b9529))['catch'](handleError(_0x910efe,null));}; \ No newline at end of file diff --git a/server/api/migration/migration.model.js b/server/api/migration/migration.model.js new file mode 100644 index 0000000..a479907 --- /dev/null +++ b/server/api/migration/migration.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaa21=['migrations','util','bluebird','request-promise','rimraf','../../config/environment','./migration.attributes','exports','define','Migration'];(function(_0x5d816a,_0x48b3f7){var _0x445415=function(_0x394276){while(--_0x394276){_0x5d816a['push'](_0x5d816a['shift']());}};_0x445415(++_0x48b3f7);}(_0xaa21,0x119));var _0x1aa2=function(_0x487524,_0x292ba6){_0x487524=_0x487524-0x0;var _0x3f3543=_0xaa21[_0x487524];return _0x3f3543;};'use strict';var _=require('lodash');var util=require(_0x1aa2('0x0'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x1aa2('0x1'));var rp=require(_0x1aa2('0x2'));var fs=require('fs');var path=require('path');var rimraf=require(_0x1aa2('0x3'));var config=require(_0x1aa2('0x4'));var attributes=require(_0x1aa2('0x5'));module[_0x1aa2('0x6')]=function(_0x4d1937,_0xdbc990){return _0x4d1937[_0x1aa2('0x7')](_0x1aa2('0x8'),attributes,{'tableName':_0x1aa2('0x9'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/migration/migration.rpc.js b/server/api/migration/migration.rpc.js new file mode 100644 index 0000000..d451f04 --- /dev/null +++ b/server/api/migration/migration.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd139=['../../config/logger','rpc','../../config/environment','client','http','info','Migration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x2f437b,_0x2499b5){var _0x3b53fc=function(_0x5ddf8f){while(--_0x5ddf8f){_0x2f437b['push'](_0x2f437b['shift']());}};_0x3b53fc(++_0x2499b5);}(_0xd139,0x14e));var _0x9d13=function(_0x7b024e,_0x30fc22){_0x7b024e=_0x7b024e-0x0;var _0xd73520=_0xd139[_0x7b024e];return _0xd73520;};'use strict';var _=require(_0x9d13('0x0'));var util=require(_0x9d13('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x9d13('0x2'));var fs=require('fs');var Redis=require(_0x9d13('0x3'));var db=require(_0x9d13('0x4'))['db'];var utils=require(_0x9d13('0x5'));var logger=require(_0x9d13('0x6'))(_0x9d13('0x7'));var config=require(_0x9d13('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x9d13('0x9')][_0x9d13('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x50294b,_0x198d7d,_0x4b3db0){return new BPromise(function(_0x434ef6,_0x524947){return client['request'](_0x50294b,_0x4b3db0)['then'](function(_0x3ccdf9){logger[_0x9d13('0xb')](_0x9d13('0xc'),_0x198d7d,_0x9d13('0xd'));logger[_0x9d13('0xe')]('Migration,\x20%s,\x20%s,\x20%s',_0x198d7d,_0x9d13('0xd'),JSON[_0x9d13('0xf')](_0x3ccdf9));if(_0x3ccdf9[_0x9d13('0x10')]){if(_0x3ccdf9['error']['code']===0x1f4){logger[_0x9d13('0x10')](_0x9d13('0xc'),_0x198d7d,_0x3ccdf9[_0x9d13('0x10')][_0x9d13('0x11')]);return _0x524947(_0x3ccdf9[_0x9d13('0x10')]['message']);}logger['error'](_0x9d13('0xc'),_0x198d7d,_0x3ccdf9[_0x9d13('0x10')][_0x9d13('0x11')]);return _0x434ef6(_0x3ccdf9[_0x9d13('0x10')][_0x9d13('0x11')]);}else{logger[_0x9d13('0xb')](_0x9d13('0xc'),_0x198d7d,'request\x20sent');_0x434ef6(_0x3ccdf9[_0x9d13('0x12')][_0x9d13('0x11')]);}})[_0x9d13('0x13')](function(_0x250234){logger[_0x9d13('0x10')](_0x9d13('0xc'),_0x198d7d,_0x250234);_0x524947(_0x250234);});});} \ No newline at end of file diff --git a/server/api/network/index.js b/server/api/network/index.js new file mode 100644 index 0000000..c6bb18b --- /dev/null +++ b/server/api/network/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6f7c=['/:id','update','delete','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','./network.controller','get','isAuthenticated','put'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x6f7c,0x137));var _0xc6f7=function(_0x46698a,_0x431d21){_0x46698a=_0x46698a-0x0;var _0x420318=_0x6f7c[_0x46698a];return _0x420318;};'use strict';var multer=require(_0xc6f7('0x0'));var util=require(_0xc6f7('0x1'));var path=require(_0xc6f7('0x2'));var timeout=require(_0xc6f7('0x3'));var express=require(_0xc6f7('0x4'));var router=express[_0xc6f7('0x5')]();var fs_extra=require(_0xc6f7('0x6'));var auth=require(_0xc6f7('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0xc6f7('0x8'));var controller=require(_0xc6f7('0x9'));router[_0xc6f7('0xa')]('/',auth['isAuthenticated'](),controller['index']);router[_0xc6f7('0xa')]('/:id',auth[_0xc6f7('0xb')](),controller['show']);router['post']('/',auth[_0xc6f7('0xb')](),controller['create']);router[_0xc6f7('0xc')](_0xc6f7('0xd'),auth[_0xc6f7('0xb')](),controller[_0xc6f7('0xe')]);router[_0xc6f7('0xf')](_0xc6f7('0xd'),auth[_0xc6f7('0xb')](),controller[_0xc6f7('0x10')]);module[_0xc6f7('0x11')]=router; \ No newline at end of file diff --git a/server/api/network/network.attributes.js b/server/api/network/network.attributes.js new file mode 100644 index 0000000..0579edf --- /dev/null +++ b/server/api/network/network.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc597=['stun','turn','STRING','sequelize','exports','ENUM','externip'];(function(_0x57f7ea,_0x54da6b){var _0x54a7e4=function(_0x2c9d4f){while(--_0x2c9d4f){_0x57f7ea['push'](_0x57f7ea['shift']());}};_0x54a7e4(++_0x54da6b);}(_0xc597,0x1a0));var _0x7c59=function(_0xc4376d,_0x2e6841){_0xc4376d=_0xc4376d-0x0;var _0x291524=_0xc597[_0xc4376d];return _0x291524;};'use strict';var Sequelize=require(_0x7c59('0x0'));module[_0x7c59('0x1')]={'type':{'type':Sequelize[_0x7c59('0x2')]('localnet',_0x7c59('0x3'),_0x7c59('0x4'),_0x7c59('0x5'))},'value':{'type':Sequelize['STRING']},'username':{'type':Sequelize[_0x7c59('0x6')]},'password':{'type':Sequelize[_0x7c59('0x6')]}}; \ No newline at end of file diff --git a/server/api/network/network.controller.js b/server/api/network/network.controller.js new file mode 100644 index 0000000..0ed13fd --- /dev/null +++ b/server/api/network/network.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x95b0=['update','sendStatus','name','send','map','Network','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','params','rawAttributes','find','create','body','type','toUpperCase','STUN','readFileSync','join','root','server/files/templates/stun_multiple.ejs','utf8','render','writeFileSync','Reload','res_stun_monitor.so','server/files/templates/turn_multiple.ejs','/etc/asterisk/turn_xcally.conf','format','toLowerCase','chan_sip.so','TURN','/etc/asterisk/sip_xcally_%s.conf','destroy','util','ejs','lodash','../../config/logger','api','../../mysqldb','jayson/promise','client','then','request\x20sent','debug','Network,\x20%s,\x20%s,\x20%s','stringify','error','Network,\x20%s,\x20%s','message','info','result','catch','status','offset','undefined','count','limit','set','Content-Range'];(function(_0x49b339,_0x4055e6){var _0x1ca51f=function(_0xe6353e){while(--_0xe6353e){_0x49b339['push'](_0x49b339['shift']());}};_0x1ca51f(++_0x4055e6);}(_0x95b0,0x171));var _0x095b=function(_0x318504,_0x258421){_0x318504=_0x318504-0x0;var _0x3459ab=_0x95b0[_0x318504];return _0x3459ab;};'use strict';var util=require(_0x095b('0x0'));var path=require('path');var ejs=require(_0x095b('0x1'));var fs=require('fs');var _=require(_0x095b('0x2'));var qs=require('../../components/parsers/qs');var logger=require(_0x095b('0x3'))(_0x095b('0x4'));var config=require('../../config/environment');var db=require(_0x095b('0x5'))['db'];var jayson=require(_0x095b('0x6'));var client=jayson[_0x095b('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x27df9b,_0x27c671,_0x4566e1,_0x5b9a8f){return new Promise(function(_0x42a275,_0xbf12a2){var _0x12765a=_0x5b9a8f||client;return _0x12765a['request'](_0x27df9b,_0x4566e1)[_0x095b('0x8')](function(_0x3f253d){logger['info']('Network,\x20%s,\x20%s',_0x27c671,_0x095b('0x9'));logger[_0x095b('0xa')](_0x095b('0xb'),_0x27c671,'request\x20sent',JSON[_0x095b('0xc')](_0x3f253d));if(_0x3f253d[_0x095b('0xd')]){if(_0x3f253d[_0x095b('0xd')]['code']===0x1f4){logger[_0x095b('0xd')](_0x095b('0xe'),_0x27c671,_0x3f253d[_0x095b('0xd')][_0x095b('0xf')]);return _0xbf12a2(_0x3f253d['error'][_0x095b('0xf')]);}logger[_0x095b('0xd')](_0x095b('0xe'),_0x27c671,_0x3f253d['error'][_0x095b('0xf')]);return _0x42a275(_0x3f253d[_0x095b('0xd')][_0x095b('0xf')]);}else{logger[_0x095b('0x10')](_0x095b('0xe'),_0x27c671,_0x095b('0x9'));_0x42a275(_0x3f253d[_0x095b('0x11')][_0x095b('0xf')]);}})[_0x095b('0x12')](function(_0x59ea6a){logger[_0x095b('0xd')](_0x095b('0xe'),_0x27c671,_0x59ea6a);_0xbf12a2(_0x59ea6a);});});}function respondWithResult(_0x11a36a,_0x404bb8){_0x404bb8=_0x404bb8||0xc8;return function(_0x1aacbd){if(_0x1aacbd){return _0x11a36a[_0x095b('0x13')](_0x404bb8)['json'](_0x1aacbd);}};}function respondWithFilteredResult(_0x36fa83,_0x4636d3){return function(_0x17a366){if(_0x17a366){var _0x284bcd=typeof _0x4636d3[_0x095b('0x14')]===_0x095b('0x15')&&typeof _0x4636d3['limit']==='undefined';var _0x63919a=_0x17a366['count'];var _0x9461d5=_0x284bcd?0x0:_0x4636d3['offset'];var _0x49ea17=_0x284bcd?_0x17a366[_0x095b('0x16')]:_0x4636d3['offset']+_0x4636d3[_0x095b('0x17')];var _0x3dab4e;if(_0x49ea17>=_0x63919a){_0x49ea17=_0x63919a;_0x3dab4e=0xc8;}else{_0x3dab4e=0xce;}_0x36fa83[_0x095b('0x13')](_0x3dab4e);return _0x36fa83[_0x095b('0x18')](_0x095b('0x19'),_0x9461d5+'-'+_0x49ea17+'/'+_0x63919a)['json'](_0x17a366);}return null;};}function saveUpdates(_0x7e204c){return function(_0x26c9bc){if(_0x26c9bc){return _0x26c9bc[_0x095b('0x1a')](_0x7e204c)['then'](function(_0x3f3950){return _0x3f3950;});}return null;};}function removeEntity(_0x207cd1){return function(_0x36f51c){if(_0x36f51c){return _0x36f51c['destroy']()[_0x095b('0x8')](function(){_0x207cd1['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x180eb3){return function(_0x2f4429){if(!_0x2f4429){_0x180eb3[_0x095b('0x1b')](0x194);}return _0x2f4429;};}function handleError(_0x152104,_0x485d2d){_0x485d2d=_0x485d2d||0x1f4;return function(_0x409de8){logger[_0x095b('0xd')](_0x409de8['stack']);if(_0x409de8['name']){delete _0x409de8[_0x095b('0x1c')];}_0x152104[_0x095b('0x13')](_0x485d2d)[_0x095b('0x1d')](_0x409de8);};}exports['index']=function(_0x5018b7,_0x2ca5aa){var _0x4745f={},_0x1283c2={},_0xc416f4={'count':0x0,'rows':[]};var _0x55dce1=_[_0x095b('0x1e')](db[_0x095b('0x1f')]['rawAttributes'],function(_0x444a66){return{'name':_0x444a66['fieldName'],'type':_0x444a66['type'][_0x095b('0x20')]};});_0x1283c2[_0x095b('0x21')]=_[_0x095b('0x1e')](_0x55dce1,'name');_0x1283c2[_0x095b('0x22')]=_[_0x095b('0x23')](_0x5018b7[_0x095b('0x22')]);_0x1283c2[_0x095b('0x24')]=_[_0x095b('0x25')](_0x1283c2[_0x095b('0x21')],_0x1283c2[_0x095b('0x22')]);_0x4745f[_0x095b('0x26')]=_[_0x095b('0x25')](_0x1283c2[_0x095b('0x21')],qs[_0x095b('0x27')](_0x5018b7[_0x095b('0x22')][_0x095b('0x27')]));_0x4745f[_0x095b('0x26')]=_0x4745f[_0x095b('0x26')][_0x095b('0x28')]?_0x4745f[_0x095b('0x26')]:_0x1283c2['model'];if(!_0x5018b7[_0x095b('0x22')][_0x095b('0x29')](_0x095b('0x2a'))){_0x4745f['limit']=qs[_0x095b('0x17')](_0x5018b7[_0x095b('0x22')][_0x095b('0x17')]);_0x4745f[_0x095b('0x14')]=qs[_0x095b('0x14')](_0x5018b7[_0x095b('0x22')][_0x095b('0x14')]);}_0x4745f[_0x095b('0x2b')]=qs[_0x095b('0x2c')](_0x5018b7[_0x095b('0x22')][_0x095b('0x2c')]);_0x4745f[_0x095b('0x2d')]=qs[_0x095b('0x24')](_[_0x095b('0x2e')](_0x5018b7[_0x095b('0x22')],_0x1283c2['filters']),_0x55dce1);if(_0x5018b7[_0x095b('0x22')][_0x095b('0x2f')]){_0x4745f[_0x095b('0x2d')]=_['merge'](_0x4745f['where'],{'$or':_[_0x095b('0x1e')](_0x55dce1,function(_0x438530){if(_0x438530['type']!=='VIRTUAL'){var _0x1723a8={};_0x1723a8[_0x438530['name']]={'$like':'%'+_0x5018b7[_0x095b('0x22')][_0x095b('0x2f')]+'%'};return _0x1723a8;}})});}_0x4745f=_[_0x095b('0x30')]({},_0x4745f,_0x5018b7[_0x095b('0x31')]);var _0x31f329={'where':_0x4745f[_0x095b('0x2d')]};return db[_0x095b('0x1f')]['count'](_0x31f329)[_0x095b('0x8')](function(_0x494e83){_0xc416f4[_0x095b('0x16')]=_0x494e83;if(_0x5018b7[_0x095b('0x22')][_0x095b('0x32')]){_0x4745f[_0x095b('0x33')]=[{'all':!![]}];}return db['Network'][_0x095b('0x34')](_0x4745f);})['then'](function(_0x3945c7){_0xc416f4[_0x095b('0x35')]=_0x3945c7;return _0xc416f4;})[_0x095b('0x8')](respondWithFilteredResult(_0x2ca5aa,_0x4745f))[_0x095b('0x12')](handleError(_0x2ca5aa,null));};exports['show']=function(_0x392ad4,_0x477238){var _0x45d363={'raw':!![],'where':{'id':_0x392ad4[_0x095b('0x36')]['id']}},_0x400bb6={};_0x400bb6[_0x095b('0x21')]=_[_0x095b('0x23')](db[_0x095b('0x1f')][_0x095b('0x37')]);_0x400bb6[_0x095b('0x22')]=_[_0x095b('0x23')](_0x392ad4[_0x095b('0x22')]);_0x400bb6[_0x095b('0x24')]=_[_0x095b('0x25')](_0x400bb6[_0x095b('0x21')],_0x400bb6[_0x095b('0x22')]);_0x45d363['attributes']=_['intersection'](_0x400bb6['model'],qs[_0x095b('0x27')](_0x392ad4[_0x095b('0x22')][_0x095b('0x27')]));_0x45d363['attributes']=_0x45d363[_0x095b('0x26')][_0x095b('0x28')]?_0x45d363[_0x095b('0x26')]:_0x400bb6[_0x095b('0x21')];if(_0x392ad4[_0x095b('0x22')][_0x095b('0x32')]){_0x45d363[_0x095b('0x33')]=[{'all':!![]}];}_0x45d363=_['merge']({},_0x45d363,_0x392ad4['options']);return db[_0x095b('0x1f')][_0x095b('0x38')](_0x45d363)[_0x095b('0x8')](handleEntityNotFound(_0x477238,null))[_0x095b('0x8')](respondWithResult(_0x477238,null))['catch'](handleError(_0x477238,null));};exports[_0x095b('0x39')]=function(_0x43b345,_0x15ee34){var _0xa9c7b2;return db[_0x095b('0x1f')]['create'](_0x43b345['body'],{'raw':!![]})['then'](function(_0x51110c){_0xa9c7b2=_0x51110c;return db['Network'][_0x095b('0x34')]({'where':{'type':_0x43b345[_0x095b('0x3a')][_0x095b('0x3b')]},'raw':!![]});})['then'](function(_0x557e7e){if(_0xa9c7b2[_0x095b('0x3b')][_0x095b('0x3c')]()==_0x095b('0x3d')){var _0x285bbb=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],_0x095b('0x41')),_0x095b('0x42'));var _0x117a25=ejs[_0x095b('0x43')](_0x285bbb,{'networks':_0x557e7e||[]});fs[_0x095b('0x44')]('/etc/asterisk/stun_xcally.conf',_0x117a25);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x39'),{'module':_0x095b('0x46')});}else if(_0xa9c7b2[_0x095b('0x3b')][_0x095b('0x3c')]()=='TURN'){var _0x1cebca=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],_0x095b('0x47')),_0x095b('0x42'));var _0x2762c7=ejs[_0x095b('0x43')](_0x1cebca,{'networks':_0x557e7e||[]});fs[_0x095b('0x44')](_0x095b('0x48'),_0x2762c7);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x39'),{'module':_0x095b('0x46')});}else{var _0x478130=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],'server/files/templates/network.ejs'),_0x095b('0x42'));var _0x3621f3=ejs[_0x095b('0x43')](_0x478130,{'networks':_0x557e7e||[]});fs['writeFileSync'](util[_0x095b('0x49')]('/etc/asterisk/sip_xcally_%s.conf',_0x43b345[_0x095b('0x3a')]['type'][_0x095b('0x4a')]()),_0x3621f3);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x39'),{'module':_0x095b('0x4b')});}})[_0x095b('0x8')](function(){return _0xa9c7b2;})['then'](respondWithResult(_0x15ee34,0xc9))[_0x095b('0x12')](handleError(_0x15ee34,null));};exports[_0x095b('0x1a')]=function(_0x29994f,_0x5004a1){var _0x44c4f9;return db[_0x095b('0x1f')][_0x095b('0x38')]({'where':{'id':_0x29994f[_0x095b('0x36')]['id']}})['then'](handleEntityNotFound(_0x5004a1,null))['then'](saveUpdates(_0x29994f[_0x095b('0x3a')],null))[_0x095b('0x8')](function(_0x2c66ef){if(_0x2c66ef){_0x44c4f9=_0x2c66ef;return db[_0x095b('0x1f')][_0x095b('0x34')]({'where':{'type':_0x44c4f9['type']},'raw':!![]});}return null;})[_0x095b('0x8')](function(_0x396880){if(_0x44c4f9[_0x095b('0x3b')][_0x095b('0x3c')]()==_0x095b('0x3d')){var _0x2a825f=fs[_0x095b('0x3e')](path['join'](config[_0x095b('0x40')],_0x095b('0x41')),_0x095b('0x42'));var _0x1e2a57=ejs[_0x095b('0x43')](_0x2a825f,{'networks':_0x396880||[]});fs[_0x095b('0x44')]('/etc/asterisk/stun_xcally.conf',_0x1e2a57);return respondWithRpcPromise('Reload',_0x095b('0x1a'),{'module':_0x095b('0x46')});}else if(_0x44c4f9['type'][_0x095b('0x3c')]()==_0x095b('0x4c')){var _0x4c1aba=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],'server/files/templates/turn_multiple.ejs'),_0x095b('0x42'));var _0x55a956=ejs['render'](_0x4c1aba,{'networks':_0x396880||[]});fs[_0x095b('0x44')]('/etc/asterisk/turn_xcally.conf',_0x55a956);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x1a'),{'module':_0x095b('0x46')});}else{var _0x1edad1=fs['readFileSync'](path[_0x095b('0x3f')](config[_0x095b('0x40')],'server/files/templates/network.ejs'),_0x095b('0x42'));var _0x16fb1d=ejs[_0x095b('0x43')](_0x1edad1,{'networks':_0x396880||[]});fs['writeFileSync'](util[_0x095b('0x49')](_0x095b('0x4d'),_0x29994f['body'][_0x095b('0x3b')][_0x095b('0x4a')]()),_0x16fb1d);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x1a'),{'module':'chan_sip.so'});}})[_0x095b('0x8')](function(_0x5d94ec){if(_0x5d94ec){return _0x44c4f9;}return null;})[_0x095b('0x8')](respondWithResult(_0x5004a1,null))['catch'](handleError(_0x5004a1,null));};exports[_0x095b('0x4e')]=function(_0x4810fc,_0x276e1c){var _0x272ff3;return db[_0x095b('0x1f')][_0x095b('0x38')]({'where':{'id':_0x4810fc['params']['id']}})['then'](function(_0xaf0beb){_0x272ff3=_0xaf0beb;return _0xaf0beb;})[_0x095b('0x8')](handleEntityNotFound(_0x276e1c,null))[_0x095b('0x8')](removeEntity(_0x276e1c,null))[_0x095b('0x8')](function(){if(_0x272ff3){return db[_0x095b('0x1f')][_0x095b('0x34')]({'where':{'type':_0x272ff3[_0x095b('0x3b')]},'raw':!![]});}})['then'](function(_0x5d6116){if(_0x272ff3[_0x095b('0x3b')]['toUpperCase']()==_0x095b('0x3d')){var _0x5edf86=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],_0x095b('0x41')),'utf8');var _0x31af04=ejs[_0x095b('0x43')](_0x5edf86,{'networks':_0x5d6116||[]});fs['writeFileSync']('/etc/asterisk/stun_xcally.conf',_0x31af04);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x4e'),{'module':_0x095b('0x46')});}else if(_0x272ff3[_0x095b('0x3b')]['toUpperCase']()=='TURN'){var _0x20a932=fs['readFileSync'](path[_0x095b('0x3f')](config[_0x095b('0x40')],_0x095b('0x47')),_0x095b('0x42'));var _0x1ae6b3=ejs[_0x095b('0x43')](_0x20a932,{'networks':_0x5d6116||[]});fs['writeFileSync'](_0x095b('0x48'),_0x1ae6b3);return respondWithRpcPromise(_0x095b('0x45'),'destroy',{'module':'res_stun_monitor.so'});}else{var _0x150848=fs[_0x095b('0x3e')](path[_0x095b('0x3f')](config[_0x095b('0x40')],'server/files/templates/network.ejs'),_0x095b('0x42'));var _0x5ba7ce=ejs['render'](_0x150848,{'networks':_0x5d6116||[]});fs[_0x095b('0x44')](util[_0x095b('0x49')](_0x095b('0x4d'),_0x272ff3['type'][_0x095b('0x4a')]()),_0x5ba7ce);return respondWithRpcPromise(_0x095b('0x45'),_0x095b('0x4e'),{'module':'chan_sip.so'});}})['catch'](handleError(_0x276e1c,null));}; \ No newline at end of file diff --git a/server/api/network/network.model.js b/server/api/network/network.model.js new file mode 100644 index 0000000..9bae747 --- /dev/null +++ b/server/api/network/network.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc6d8=['../../config/logger','moment','request-promise','../../config/environment','./network.attributes','exports','define','Network','lodash'];(function(_0x1a020c,_0x3246f3){var _0x17c650=function(_0xa6cbc8){while(--_0xa6cbc8){_0x1a020c['push'](_0x1a020c['shift']());}};_0x17c650(++_0x3246f3);}(_0xc6d8,0xd7));var _0x8c6d=function(_0x172660,_0x260d9b){_0x172660=_0x172660-0x0;var _0x83204f=_0xc6d8[_0x172660];return _0x83204f;};'use strict';var _=require(_0x8c6d('0x0'));var util=require('util');var logger=require(_0x8c6d('0x1'))('api');var moment=require(_0x8c6d('0x2'));var BPromise=require('bluebird');var rp=require(_0x8c6d('0x3'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x8c6d('0x4'));var attributes=require(_0x8c6d('0x5'));module[_0x8c6d('0x6')]=function(_0x4f5e8f,_0x3c265c){return _0x4f5e8f[_0x8c6d('0x7')](_0x8c6d('0x8'),attributes,{'tableName':'network','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/network/network.rpc.js b/server/api/network/network.rpc.js new file mode 100644 index 0000000..364e0ae --- /dev/null +++ b/server/api/network/network.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['info','Network,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result','catch','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0x7a54,0x106));var _0x47a5=function(_0x1fe37d,_0x2fe53b){_0x1fe37d=_0x1fe37d-0x0;var _0x1baa4b=_0x7a54[_0x1fe37d];return _0x1baa4b;};'use strict';var _=require(_0x47a5('0x0'));var util=require(_0x47a5('0x1'));var moment=require(_0x47a5('0x2'));var BPromise=require('bluebird');var rs=require(_0x47a5('0x3'));var fs=require('fs');var Redis=require(_0x47a5('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x47a5('0x5'));var logger=require(_0x47a5('0x6'))(_0x47a5('0x7'));var config=require(_0x47a5('0x8'));var jayson=require(_0x47a5('0x9'));var client=jayson['client'][_0x47a5('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x59199c,_0x343372,_0x30e405){return new BPromise(function(_0x506eda,_0x194fb0){return client['request'](_0x59199c,_0x30e405)['then'](function(_0x582352){logger[_0x47a5('0xb')](_0x47a5('0xc'),_0x343372,'request\x20sent');logger[_0x47a5('0xd')]('Network,\x20%s,\x20%s,\x20%s',_0x343372,'request\x20sent',JSON[_0x47a5('0xe')](_0x582352));if(_0x582352[_0x47a5('0xf')]){if(_0x582352[_0x47a5('0xf')][_0x47a5('0x10')]===0x1f4){logger[_0x47a5('0xf')](_0x47a5('0xc'),_0x343372,_0x582352[_0x47a5('0xf')]['message']);return _0x194fb0(_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);}logger[_0x47a5('0xf')](_0x47a5('0xc'),_0x343372,_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);return _0x506eda(_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);}else{logger['info'](_0x47a5('0xc'),_0x343372,_0x47a5('0x12'));_0x506eda(_0x582352[_0x47a5('0x13')][_0x47a5('0x11')]);}})[_0x47a5('0x14')](function(_0x574af6){logger['error'](_0x47a5('0xc'),_0x343372,_0x574af6);_0x194fb0(_0x574af6);});});} \ No newline at end of file diff --git a/server/api/openchannelAccount/index.js b/server/api/openchannelAccount/index.js new file mode 100644 index 0000000..761d1c4 --- /dev/null +++ b/server/api/openchannelAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd93=['isAuthenticated','index','/describe','describe','/:id','show','getDispositions','/:id/canned_answers','getAnswers','/:id/applications','/:id/interactions','getInteractions','/:id/users','post','/:id/dispositions','addDisposition','addAnswer','/:id/notify','notify','send','put','update','destroy','delete','removeDispositions','removeAnswers','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get'];(function(_0x4f0ac0,_0x25e418){var _0x2971bb=function(_0x50a31e){while(--_0x50a31e){_0x4f0ac0['push'](_0x4f0ac0['shift']());}};_0x2971bb(++_0x25e418);}(_0xcd93,0x168));var _0x3cd9=function(_0x124714,_0x2a9bed){_0x124714=_0x124714-0x0;var _0x551bd7=_0xcd93[_0x124714];return _0x551bd7;};'use strict';var multer=require('multer');var util=require(_0x3cd9('0x0'));var path=require(_0x3cd9('0x1'));var timeout=require(_0x3cd9('0x2'));var express=require(_0x3cd9('0x3'));var router=express[_0x3cd9('0x4')]();var fs_extra=require(_0x3cd9('0x5'));var auth=require(_0x3cd9('0x6'));var interaction=require(_0x3cd9('0x7'));var config=require(_0x3cd9('0x8'));var controller=require('./openchannelAccount.controller');router[_0x3cd9('0x9')]('/',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0xb')]);router[_0x3cd9('0x9')](_0x3cd9('0xc'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0xd')]);router[_0x3cd9('0x9')](_0x3cd9('0xe'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0xf')]);router[_0x3cd9('0x9')]('/:id/dispositions',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x10')]);router[_0x3cd9('0x9')](_0x3cd9('0x11'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x12')]);router[_0x3cd9('0x9')](_0x3cd9('0x13'),auth[_0x3cd9('0xa')](),controller['getApplications']);router[_0x3cd9('0x9')](_0x3cd9('0x14'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x15')]);router[_0x3cd9('0x9')](_0x3cd9('0x16'),auth[_0x3cd9('0xa')](),controller['getAgents']);router[_0x3cd9('0x17')]('/',auth[_0x3cd9('0xa')](),controller['create']);router[_0x3cd9('0x17')](_0x3cd9('0x18'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x19')]);router[_0x3cd9('0x17')]('/:id/canned_answers',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x1a')]);router[_0x3cd9('0x17')](_0x3cd9('0x1b'),controller[_0x3cd9('0x1c')]);router['post'](_0x3cd9('0x13'),auth[_0x3cd9('0xa')](),controller['addApplications']);router[_0x3cd9('0x17')](_0x3cd9('0x16'),auth['isAuthenticated'](),controller['addAgents']);router[_0x3cd9('0x17')]('/:id/send',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x1d')]);router[_0x3cd9('0x1e')](_0x3cd9('0xe'),auth['isAuthenticated'](),controller[_0x3cd9('0x1f')]);router['delete']('/:id',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x20')]);router[_0x3cd9('0x21')]('/:id/dispositions',auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x22')]);router[_0x3cd9('0x21')](_0x3cd9('0x11'),auth[_0x3cd9('0xa')](),controller[_0x3cd9('0x23')]);router[_0x3cd9('0x21')](_0x3cd9('0x16'),auth[_0x3cd9('0xa')](),controller['removeAgents']);module[_0x3cd9('0x24')]=router; \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.attributes.js b/server/api/openchannelAccount/openchannelAccount.attributes.js new file mode 100644 index 0000000..aaade9d --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7299=['mandatoryDisposition','randomstring','exports','STRING','name','generate','TEXT','Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}','BOOLEAN','INTEGER','Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled','setDataValue','mandatoryDispositionPauseId'];(function(_0x51b538,_0x3ec1a6){var _0x3b92b7=function(_0x44dadb){while(--_0x44dadb){_0x51b538['push'](_0x51b538['shift']());}};_0x3b92b7(++_0x3ec1a6);}(_0x7299,0x139));var _0x9729=function(_0x433df9,_0x5808c7){_0x433df9=_0x433df9-0x0;var _0x2574cf=_0x7299[_0x433df9];return _0x2574cf;};'use strict';var Sequelize=require('sequelize');var rs=require(_0x9729('0x0'));module[_0x9729('0x1')]={'name':{'type':Sequelize[_0x9729('0x2')],'unique':_0x9729('0x3'),'allowNull':![]},'description':{'type':Sequelize[_0x9729('0x2')]},'token':{'type':Sequelize[_0x9729('0x2')],'defaultValue':function(){return rs[_0x9729('0x4')]();}},'replyUri':{'type':Sequelize['STRING'],'validate':{'isUrl':!![]}},'key':{'type':Sequelize['STRING'],'allowNull':![]},'notificationTemplate':{'type':Sequelize[_0x9729('0x5')],'defaultValue':function(){return _0x9729('0x6');}},'notificationSound':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'notificationShake':{'type':Sequelize[_0x9729('0x7')],'defaultValue':![]},'waitForTheAssignedAgent':{'type':Sequelize[_0x9729('0x8')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'mapKey':{'type':Sequelize['STRING']},'queueTransfer':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize[_0x9729('0x8')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize[_0x9729('0x7')],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0x9729('0x8')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'mandatoryDispositionPauseId':{'type':Sequelize[_0x9729('0x8')],'allowNull':!![],'defaultValue':null,'comment':_0x9729('0x9')},'mandatoryDisposition':{'type':Sequelize[_0x9729('0x7')],'defaultValue':![],'comment':'Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','set':function(_0x34aab9){if(!_0x34aab9)this[_0x9729('0xa')](_0x9729('0xb'),null);this[_0x9729('0xa')](_0x9729('0xc'),_0x34aab9);}}}; \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.controller.js b/server/api/openchannelAccount/openchannelAccount.controller.js new file mode 100644 index 0000000..608a568 --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5826=['user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','Pause','describe','Disposition','getDispositions','findOne','OpenchannelAccountId','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','order','removeAnswers','notify','CmContact','Sequelize','no\x20available\x20attributes','difference','createdAt','CompanyId','ListId','isNil','from','ValidationError','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','updatedAt','OpenchannelApplication','Applications','account','list','applications','orderBy','priority','asc','defaults','firstName','lastName','threadId','OpenchannelInteraction','externalUrl','ContactId','spread','messageId','interaction','created','push','close','*,*,*,*','OpenchannelMessage','contact','User','UserId','unshift','forcedOwnership','Start','startRouting','EventManager','addApplications','sequelize','transaction','READ_COMMITTED','bulkCreate','findAndCountAll','stack','finally','getApplications','getInteractions','Owner','fullname','internal','Tag','color','tag','addAgents','omit','emit','userOpenchannelAccount:save','removeAgents','isArray','userOpenchannelAccount:remove','getAgents','CmList','DESC','out','Messages','dataValues','zip-dir','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./openchannelAccount.socket','jayson/promise','client','request','then','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','OpenchannelAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','save','get','OpenchannelAccounts','destroy','name','send','mandatoryDispositionPause','OpenchannelAccount','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','filter','includeAll','findAll','rows','show','params','include','options','find','create','body'];(function(_0x149c7c,_0x6f4ba2){var _0x2814cc=function(_0x5e2333){while(--_0x5e2333){_0x149c7c['push'](_0x149c7c['shift']());}};_0x2814cc(++_0x6f4ba2);}(_0x5826,0x1ea));var _0x6582=function(_0x4bdfbf,_0x32c35b){_0x4bdfbf=_0x4bdfbf-0x0;var _0x4ff968=_0x5826[_0x4bdfbf];return _0x4ff968;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x6582('0x0'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x6582('0x1'));var BPromise=require(_0x6582('0x2'));var Mustache=require(_0x6582('0x3'));var util=require(_0x6582('0x4'));var path=require(_0x6582('0x5'));var sox=require(_0x6582('0x6'));var csv=require(_0x6582('0x7'));var ejs=require(_0x6582('0x8'));var fs=require('fs');var fs_extra=require(_0x6582('0x9'));var _=require(_0x6582('0xa'));var squel=require(_0x6582('0xb'));var crypto=require(_0x6582('0xc'));var jsforce=require(_0x6582('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x6582('0x7'));var querystring=require(_0x6582('0xe'));var Papa=require(_0x6582('0xf'));var Redis=require(_0x6582('0x10'));var authService=require(_0x6582('0x11'));var qs=require(_0x6582('0x12'));var as=require(_0x6582('0x13'));var hardwareService=require(_0x6582('0x14'));var logger=require(_0x6582('0x15'))(_0x6582('0x16'));var utils=require(_0x6582('0x17'));var config=require(_0x6582('0x18'));var licenseUtil=require(_0x6582('0x19'));var db=require(_0x6582('0x1a'))['db'];config[_0x6582('0x1b')]=_['defaults'](config['redis'],{'host':_0x6582('0x1c'),'port':0x18eb});var socket=require(_0x6582('0x1d'))(new Redis(config[_0x6582('0x1b')]));require(_0x6582('0x1e'))['register'](socket);var jayson=require(_0x6582('0x1f'));var client=jayson[_0x6582('0x20')]['http']({'port':0x232c});var client9002=jayson[_0x6582('0x20')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4d030b,_0x2507db,_0x463128,_0x4c4514){return new BPromise(function(_0x27349e,_0x287bc3){var _0xc3983=_0x4c4514||client;return _0xc3983[_0x6582('0x21')](_0x4d030b,_0x463128)[_0x6582('0x22')](function(_0x48c3d6){logger['info'](_0x6582('0x23'),_0x2507db,_0x6582('0x24'));logger['debug'](_0x6582('0x25'),_0x2507db,_0x6582('0x24'),JSON[_0x6582('0x26')](_0x48c3d6));if(_0x48c3d6[_0x6582('0x27')]){if(_0x48c3d6[_0x6582('0x27')][_0x6582('0x28')]===0x1f4){logger[_0x6582('0x27')](_0x6582('0x23'),_0x2507db,_0x48c3d6['error'][_0x6582('0x29')]);return _0x287bc3(_0x48c3d6[_0x6582('0x27')][_0x6582('0x29')]);}logger[_0x6582('0x27')]('OpenchannelAccount,\x20%s,\x20%s',_0x2507db,_0x48c3d6[_0x6582('0x27')][_0x6582('0x29')]);return _0x27349e(_0x48c3d6[_0x6582('0x27')][_0x6582('0x29')]);}else{logger[_0x6582('0x2a')](_0x6582('0x23'),_0x2507db,'request\x20sent');_0x27349e(_0x48c3d6[_0x6582('0x2b')]['message']);}})[_0x6582('0x2c')](function(_0x335522){logger[_0x6582('0x27')](_0x6582('0x23'),_0x2507db,_0x335522);_0x287bc3(_0x335522);});});}function respondWithStatusCode(_0x18c8fe,_0x10bf92){_0x10bf92=_0x10bf92||0xcc;return function(_0x4c543){if(_0x4c543){return _0x18c8fe[_0x6582('0x2d')](_0x10bf92);}return _0x18c8fe[_0x6582('0x2e')](_0x10bf92)[_0x6582('0x2f')]();};}function respondWithResult(_0x545316,_0x511381){_0x511381=_0x511381||0xc8;return function(_0x15b2b0){if(_0x15b2b0){return _0x545316[_0x6582('0x2e')](_0x511381)['json'](_0x15b2b0);}};}function respondWithFilteredResult(_0x2add50,_0x4fcab1){return function(_0x4f1f1c){if(_0x4f1f1c){var _0x37e996=typeof _0x4fcab1[_0x6582('0x30')]===_0x6582('0x31')&&typeof _0x4fcab1[_0x6582('0x32')]===_0x6582('0x31');var _0xa899b2=_0x4f1f1c['count'];var _0x4dd143=_0x37e996?0x0:_0x4fcab1[_0x6582('0x30')];var _0x54170e=_0x37e996?_0x4f1f1c[_0x6582('0x33')]:_0x4fcab1['offset']+_0x4fcab1[_0x6582('0x32')];var _0x18e84e;if(_0x54170e>=_0xa899b2){_0x54170e=_0xa899b2;_0x18e84e=0xc8;}else{_0x18e84e=0xce;}_0x2add50['status'](_0x18e84e);return _0x2add50[_0x6582('0x34')](_0x6582('0x35'),_0x4dd143+'-'+_0x54170e+'/'+_0xa899b2)[_0x6582('0x36')](_0x4f1f1c);}return null;};}function patchUpdates(_0x1fa3a8){return function(_0x5ce119){try{jsonpatch[_0x6582('0x37')](_0x5ce119,_0x1fa3a8,!![]);}catch(_0x1dbf65){return BPromise['reject'](_0x1dbf65);}return _0x5ce119[_0x6582('0x38')]();};}function saveUpdates(_0x2ed3a3,_0x37aaca){return function(_0x435cf8){if(_0x435cf8){return _0x435cf8['update'](_0x2ed3a3)['then'](function(_0x51d291){return _0x51d291;});}return null;};}function removeEntity(_0x1363bf,_0x559c73){return function(_0x12d566){if(_0x12d566){return _0x12d566['destroy']()[_0x6582('0x22')](function(){var _0xfee013=_0x12d566[_0x6582('0x39')]({'plain':!![]});var _0xc28341=_0x6582('0x3a');return db['UserProfileResource'][_0x6582('0x3b')]({'where':{'type':_0xc28341,'resourceId':_0xfee013['id']}})[_0x6582('0x22')](function(){return _0x12d566;});})[_0x6582('0x22')](function(){_0x1363bf[_0x6582('0x2e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x41334b,_0x55009c){return function(_0xec6e3f){if(!_0xec6e3f){_0x41334b['sendStatus'](0x194);}return _0xec6e3f;};}function handleError(_0x450760,_0x4f7671){_0x4f7671=_0x4f7671||0x1f4;return function(_0x3d5b00){logger[_0x6582('0x27')](_0x3d5b00['stack']);if(_0x3d5b00[_0x6582('0x3c')]){delete _0x3d5b00['name'];}_0x450760[_0x6582('0x2e')](_0x4f7671)[_0x6582('0x3d')](_0x3d5b00);};}exports['index']=function(_0x53931b,_0x13cb42){var _0x6faeb1={'include':[{'model':db['Pause'],'as':_0x6582('0x3e')}]},_0x26ec8a={},_0x1216ef={'count':0x0,'rows':[]};var _0x1ab40f=_['map'](db[_0x6582('0x3f')][_0x6582('0x40')],function(_0x414ab1){return{'name':_0x414ab1[_0x6582('0x41')],'type':_0x414ab1[_0x6582('0x42')][_0x6582('0x43')]};});_0x26ec8a[_0x6582('0x44')]=_[_0x6582('0x45')](_0x1ab40f,_0x6582('0x3c'));_0x26ec8a[_0x6582('0x46')]=_[_0x6582('0x47')](_0x53931b['query']);_0x26ec8a[_0x6582('0x48')]=_[_0x6582('0x49')](_0x26ec8a['model'],_0x26ec8a[_0x6582('0x46')]);_0x6faeb1[_0x6582('0x4a')]=_[_0x6582('0x49')](_0x26ec8a['model'],qs[_0x6582('0x4b')](_0x53931b[_0x6582('0x46')][_0x6582('0x4b')]));_0x6faeb1[_0x6582('0x4a')]=_0x6faeb1[_0x6582('0x4a')][_0x6582('0x4c')]?_0x6faeb1[_0x6582('0x4a')]:_0x26ec8a[_0x6582('0x44')];if(!_0x53931b['query'][_0x6582('0x4d')](_0x6582('0x4e'))){_0x6faeb1[_0x6582('0x32')]=qs[_0x6582('0x32')](_0x53931b['query']['limit']);_0x6faeb1['offset']=qs[_0x6582('0x30')](_0x53931b['query'][_0x6582('0x30')]);}_0x6faeb1['order']=qs[_0x6582('0x4f')](_0x53931b[_0x6582('0x46')][_0x6582('0x4f')]);_0x6faeb1[_0x6582('0x50')]=qs[_0x6582('0x48')](_[_0x6582('0x51')](_0x53931b[_0x6582('0x46')],_0x26ec8a[_0x6582('0x48')]),_0x1ab40f);if(_0x53931b[_0x6582('0x46')]['filter']){_0x6faeb1[_0x6582('0x50')]=_[_0x6582('0x52')](_0x6faeb1['where'],{'$or':_['map'](_0x1ab40f,function(_0x1dd719){if(_0x1dd719[_0x6582('0x42')]!==_0x6582('0x53')){var _0x34c238={};_0x34c238[_0x1dd719[_0x6582('0x3c')]]={'$like':'%'+_0x53931b[_0x6582('0x46')][_0x6582('0x54')]+'%'};return _0x34c238;}})});}_0x6faeb1=_[_0x6582('0x52')]({},_0x6faeb1,_0x53931b['options']);var _0xd0586={'where':_0x6faeb1[_0x6582('0x50')]};return db[_0x6582('0x3f')]['count'](_0xd0586)['then'](function(_0x197d44){_0x1216ef[_0x6582('0x33')]=_0x197d44;if(_0x53931b[_0x6582('0x46')][_0x6582('0x55')]){_0x6faeb1['include']=[{'all':!![]}];}return db[_0x6582('0x3f')][_0x6582('0x56')](_0x6faeb1);})[_0x6582('0x22')](function(_0x5244da){_0x1216ef[_0x6582('0x57')]=_0x5244da;return _0x1216ef;})[_0x6582('0x22')](respondWithFilteredResult(_0x13cb42,_0x6faeb1))['catch'](handleError(_0x13cb42,null));};exports[_0x6582('0x58')]=function(_0x189639,_0x22d913){var _0xdc6d8e={'raw':![],'where':{'id':_0x189639[_0x6582('0x59')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x4d3804={};_0x4d3804[_0x6582('0x44')]=_[_0x6582('0x47')](db[_0x6582('0x3f')][_0x6582('0x40')]);_0x4d3804['query']=_[_0x6582('0x47')](_0x189639[_0x6582('0x46')]);_0x4d3804[_0x6582('0x48')]=_[_0x6582('0x49')](_0x4d3804[_0x6582('0x44')],_0x4d3804[_0x6582('0x46')]);_0xdc6d8e[_0x6582('0x4a')]=_['intersection'](_0x4d3804[_0x6582('0x44')],qs[_0x6582('0x4b')](_0x189639[_0x6582('0x46')][_0x6582('0x4b')]));_0xdc6d8e[_0x6582('0x4a')]=_0xdc6d8e[_0x6582('0x4a')][_0x6582('0x4c')]?_0xdc6d8e[_0x6582('0x4a')]:_0x4d3804['model'];if(_0x189639[_0x6582('0x46')][_0x6582('0x55')]){_0xdc6d8e[_0x6582('0x5a')]=[{'all':!![]}];}_0xdc6d8e=_[_0x6582('0x52')]({},_0xdc6d8e,_0x189639[_0x6582('0x5b')]);return db['OpenchannelAccount'][_0x6582('0x5c')](_0xdc6d8e)[_0x6582('0x22')](handleEntityNotFound(_0x22d913,null))[_0x6582('0x22')](respondWithResult(_0x22d913,null))[_0x6582('0x2c')](handleError(_0x22d913,null));};exports[_0x6582('0x5d')]=function(_0x43d8ce,_0x402121){return db[_0x6582('0x3f')]['create'](_0x43d8ce[_0x6582('0x5e')],{})[_0x6582('0x22')](function(_0xd0be89){var _0x451e8f=_0x43d8ce[_0x6582('0x5f')][_0x6582('0x39')]({'plain':!![]});if(!_0x451e8f)throw new Error(_0x6582('0x60'));if(_0x451e8f[_0x6582('0x61')]===_0x6582('0x5f')){var _0x326a2a=_0xd0be89[_0x6582('0x39')]({'plain':!![]});var _0x25370c=_0x6582('0x3a');return db['UserProfileSection'][_0x6582('0x5c')]({'where':{'name':_0x25370c,'userProfileId':_0x451e8f['userProfileId']},'raw':!![]})[_0x6582('0x22')](function(_0x4c6e55){if(_0x4c6e55&&_0x4c6e55[_0x6582('0x62')]===0x0){return db[_0x6582('0x63')][_0x6582('0x5d')]({'name':_0x326a2a[_0x6582('0x3c')],'resourceId':_0x326a2a['id'],'type':_0x4c6e55[_0x6582('0x3c')],'sectionId':_0x4c6e55['id']},{})[_0x6582('0x22')](function(){return _0xd0be89;});}else{return _0xd0be89;}})[_0x6582('0x2c')](function(_0x45c1ea){logger['error'](_0x6582('0x64'),_0x45c1ea);throw _0x45c1ea;});}return _0xd0be89;})[_0x6582('0x22')](respondWithResult(_0x402121,0xc9))[_0x6582('0x2c')](handleError(_0x402121,null));};exports[_0x6582('0x65')]=function(_0x58c796,_0x556989){if(_0x58c796['body']['id']){delete _0x58c796[_0x6582('0x5e')]['id'];}return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x58c796[_0x6582('0x59')]['id']},'include':[{'model':db[_0x6582('0x66')],'as':_0x6582('0x3e')}]})[_0x6582('0x22')](handleEntityNotFound(_0x556989,null))[_0x6582('0x22')](saveUpdates(_0x58c796[_0x6582('0x5e')],null))[_0x6582('0x22')](respondWithResult(_0x556989,null))[_0x6582('0x2c')](handleError(_0x556989,null));};exports[_0x6582('0x3b')]=function(_0x2cb018,_0x4325a3){return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x2cb018[_0x6582('0x59')]['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x4325a3,null))[_0x6582('0x22')](removeEntity(_0x4325a3,null))['catch'](handleError(_0x4325a3,null));};exports[_0x6582('0x67')]=function(_0x1f624f,_0x46b526){return db[_0x6582('0x3f')]['describe']()[_0x6582('0x22')](respondWithResult(_0x46b526,null))[_0x6582('0x2c')](handleError(_0x46b526,null));};exports['addDisposition']=function(_0x4ecf73,_0x3af1ce,_0x1123db){if(_0x4ecf73['body']['id']){delete _0x4ecf73[_0x6582('0x5e')]['id'];}return db['OpenchannelAccount'][_0x6582('0x5c')]({'where':{'id':_0x4ecf73[_0x6582('0x59')]['id']}})['then'](handleEntityNotFound(_0x3af1ce,null))[_0x6582('0x22')](function(_0x3814b2){if(_0x3814b2){_0x4ecf73[_0x6582('0x5e')]['OpenchannelAccountId']=_0x3814b2['id'];return db[_0x6582('0x68')][_0x6582('0x5d')](_0x4ecf73[_0x6582('0x5e')]);}})[_0x6582('0x22')](respondWithResult(_0x3af1ce,null))[_0x6582('0x2c')](handleError(_0x3af1ce,null));};exports[_0x6582('0x69')]=function(_0x1a9d24,_0x35ad1f,_0x4742ea){var _0x553234={'raw':![],'where':{}};var _0x20467e={};var _0x4b5e27={'count':0x0,'rows':[]};return db[_0x6582('0x3f')][_0x6582('0x6a')]({'where':{'id':_0x1a9d24[_0x6582('0x59')]['id']}})['then'](handleEntityNotFound(_0x35ad1f,null))[_0x6582('0x22')](function(_0x296fdc){if(_0x296fdc){_0x20467e[_0x6582('0x44')]=_[_0x6582('0x47')](db[_0x6582('0x68')][_0x6582('0x40')]);_0x20467e[_0x6582('0x46')]=_['keys'](_0x1a9d24['query']);_0x20467e['filters']=_[_0x6582('0x49')](_0x20467e['model'],_0x20467e[_0x6582('0x46')]);_0x553234['attributes']=_['intersection'](_0x20467e[_0x6582('0x44')],qs[_0x6582('0x4b')](_0x1a9d24[_0x6582('0x46')][_0x6582('0x4b')]));_0x553234[_0x6582('0x4a')]=_0x553234[_0x6582('0x4a')][_0x6582('0x4c')]?_0x553234[_0x6582('0x4a')]:_0x20467e[_0x6582('0x44')];if(!_0x1a9d24[_0x6582('0x46')]['hasOwnProperty']('nolimit')){_0x553234[_0x6582('0x32')]=qs[_0x6582('0x32')](_0x1a9d24['query']['limit']);_0x553234['offset']=qs['offset'](_0x1a9d24[_0x6582('0x46')][_0x6582('0x30')]);}_0x553234['order']=qs[_0x6582('0x4f')](_0x1a9d24[_0x6582('0x46')][_0x6582('0x4f')]);_0x553234['where']=qs['filters'](_[_0x6582('0x51')](_0x1a9d24[_0x6582('0x46')],_0x20467e[_0x6582('0x48')]));_0x553234[_0x6582('0x50')][_0x6582('0x6b')]=_0x296fdc['id'];if(_0x1a9d24[_0x6582('0x46')][_0x6582('0x54')]){_0x553234[_0x6582('0x50')]=_[_0x6582('0x52')](_0x553234[_0x6582('0x50')],{'$or':_[_0x6582('0x45')](_0x553234[_0x6582('0x4a')],function(_0x4a1c52){var _0x37ddb7={};_0x37ddb7[_0x4a1c52]={'$like':'%'+_0x1a9d24[_0x6582('0x46')]['filter']+'%'};return _0x37ddb7;})});}_0x553234=_[_0x6582('0x52')]({},_0x553234,_0x1a9d24[_0x6582('0x5b')]);return db['Disposition'][_0x6582('0x33')]({'where':_0x553234['where']})[_0x6582('0x22')](function(_0xed20b2){_0x4b5e27[_0x6582('0x33')]=_0xed20b2;if(_0x1a9d24[_0x6582('0x46')][_0x6582('0x55')]){_0x553234[_0x6582('0x5a')]=[{'all':!![]}];}return db[_0x6582('0x68')][_0x6582('0x56')](_0x553234);})[_0x6582('0x22')](function(_0x1e484d){_0x4b5e27[_0x6582('0x57')]=_0x1e484d;return _0x4b5e27;});}})[_0x6582('0x22')](respondWithFilteredResult(_0x35ad1f,_0x553234))['catch'](handleError(_0x35ad1f,null));};exports[_0x6582('0x6c')]=function(_0x4eb1c8,_0x5661ea,_0x155e7c){return db['OpenchannelAccount'][_0x6582('0x5c')]({'where':{'id':_0x4eb1c8['params']['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x5661ea,null))['then'](function(_0x509b05){if(_0x509b05){return _0x509b05[_0x6582('0x6c')](_0x4eb1c8[_0x6582('0x46')][_0x6582('0x6d')]);}})[_0x6582('0x22')](respondWithStatusCode(_0x5661ea,null))[_0x6582('0x2c')](handleError(_0x5661ea,null));};exports[_0x6582('0x6e')]=function(_0x18797e,_0x35e523,_0x550008){if(_0x18797e[_0x6582('0x5e')]['id']){delete _0x18797e[_0x6582('0x5e')]['id'];}return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x18797e[_0x6582('0x59')]['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x35e523,null))[_0x6582('0x22')](function(_0xc47ab6){if(_0xc47ab6){_0x18797e['body'][_0x6582('0x6b')]=_0xc47ab6['id'];return db[_0x6582('0x6f')][_0x6582('0x5d')](_0x18797e[_0x6582('0x5e')]);}})['then'](respondWithResult(_0x35e523,null))[_0x6582('0x2c')](handleError(_0x35e523,null));};exports[_0x6582('0x70')]=function(_0x137dec,_0x3caa71,_0x419ab7){var _0x1fde18={'raw':![],'where':{}};var _0x37e2c7={};var _0x527c33={'count':0x0,'rows':[]};return db[_0x6582('0x3f')]['findOne']({'where':{'id':_0x137dec[_0x6582('0x59')]['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x3caa71,null))[_0x6582('0x22')](function(_0x58f90a){if(_0x58f90a){_0x37e2c7['model']=_['keys'](db[_0x6582('0x6f')][_0x6582('0x40')]);_0x37e2c7[_0x6582('0x46')]=_[_0x6582('0x47')](_0x137dec[_0x6582('0x46')]);_0x37e2c7['filters']=_[_0x6582('0x49')](_0x37e2c7['model'],_0x37e2c7[_0x6582('0x46')]);_0x1fde18[_0x6582('0x4a')]=_[_0x6582('0x49')](_0x37e2c7['model'],qs['fields'](_0x137dec[_0x6582('0x46')][_0x6582('0x4b')]));_0x1fde18[_0x6582('0x4a')]=_0x1fde18[_0x6582('0x4a')][_0x6582('0x4c')]?_0x1fde18[_0x6582('0x4a')]:_0x37e2c7[_0x6582('0x44')];if(!_0x137dec[_0x6582('0x46')]['hasOwnProperty'](_0x6582('0x4e'))){_0x1fde18[_0x6582('0x32')]=qs[_0x6582('0x32')](_0x137dec[_0x6582('0x46')]['limit']);_0x1fde18[_0x6582('0x30')]=qs[_0x6582('0x30')](_0x137dec[_0x6582('0x46')][_0x6582('0x30')]);}_0x1fde18[_0x6582('0x71')]=qs[_0x6582('0x4f')](_0x137dec[_0x6582('0x46')]['sort']);_0x1fde18[_0x6582('0x50')]=qs[_0x6582('0x48')](_['pick'](_0x137dec[_0x6582('0x46')],_0x37e2c7[_0x6582('0x48')]));_0x1fde18[_0x6582('0x50')][_0x6582('0x6b')]=_0x58f90a['id'];if(_0x137dec['query'][_0x6582('0x54')]){_0x1fde18[_0x6582('0x50')]=_['merge'](_0x1fde18[_0x6582('0x50')],{'$or':_['map'](_0x1fde18[_0x6582('0x4a')],function(_0x299939){var _0x150742={};_0x150742[_0x299939]={'$like':'%'+_0x137dec[_0x6582('0x46')][_0x6582('0x54')]+'%'};return _0x150742;})});}_0x1fde18=_[_0x6582('0x52')]({},_0x1fde18,_0x137dec['options']);return db['CannedAnswer'][_0x6582('0x33')]({'where':_0x1fde18[_0x6582('0x50')]})[_0x6582('0x22')](function(_0x17b5b8){_0x527c33[_0x6582('0x33')]=_0x17b5b8;if(_0x137dec[_0x6582('0x46')][_0x6582('0x55')]){_0x1fde18[_0x6582('0x5a')]=[{'all':!![]}];}return db[_0x6582('0x6f')][_0x6582('0x56')](_0x1fde18);})[_0x6582('0x22')](function(_0x402c9a){_0x527c33[_0x6582('0x57')]=_0x402c9a;return _0x527c33;});}})['then'](respondWithFilteredResult(_0x3caa71,_0x1fde18))[_0x6582('0x2c')](handleError(_0x3caa71,null));};exports['removeAnswers']=function(_0x57fabe,_0x222fa8,_0x1c282d){return db['OpenchannelAccount'][_0x6582('0x5c')]({'where':{'id':_0x57fabe['params']['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x222fa8,null))[_0x6582('0x22')](function(_0x2f3df4){if(_0x2f3df4){return _0x2f3df4[_0x6582('0x72')](_0x57fabe['query'][_0x6582('0x6d')]);}})[_0x6582('0x22')](respondWithStatusCode(_0x222fa8,null))[_0x6582('0x2c')](handleError(_0x222fa8,null));};exports[_0x6582('0x73')]=function(_0x2d3d3f,_0x21f4d8,_0x17af3a){var _0x10634d={'body':_0x2d3d3f[_0x6582('0x5e')],'channel':'openchannel'};var _0x22071f=[];var _0x261045=[];var _0x218375={};var _0x148218=![];return db[_0x6582('0x74')]['describe']()[_0x6582('0x22')](function(_0x36630f){if(!_0x36630f){throw new db[(_0x6582('0x75'))]['ValidationError'](_0x6582('0x76'));}_0x22071f=_[_0x6582('0x77')](_[_0x6582('0x47')](_0x36630f),[_0x6582('0x78'),'updatedAt']);_0x261045=_[_0x6582('0x77')](_['keys'](_0x36630f),['createdAt','updatedAt',_0x6582('0x79'),_0x6582('0x7a')]);if(_0x2d3d3f[_0x6582('0x5e')]['id']){delete _0x2d3d3f[_0x6582('0x5e')]['id'];}if(_[_0x6582('0x7b')](_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x7c')])){throw new db['Sequelize'][(_0x6582('0x7d'))](_0x6582('0x7e'));}if(_[_0x6582('0x7b')](_0x2d3d3f['body'][_0x6582('0x5e')])||_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x5e')]===''){throw new db[(_0x6582('0x75'))][(_0x6582('0x7d'))](_0x6582('0x7f'));}if(_[_0x6582('0x7b')](_0x2d3d3f['body'][_0x6582('0x80')])){throw new db['Sequelize']['ValidationError'](_0x6582('0x81')+_0x261045);}if(!_[_0x6582('0x82')](_0x261045,_0x2d3d3f[_0x6582('0x5e')]['mapKey'])){throw new db[(_0x6582('0x75'))][(_0x6582('0x7d'))](_0x6582('0x83')+_0x261045);}_0x218375[_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x80')]]=_0x2d3d3f[_0x6582('0x5e')]['from'];})['then'](function(){return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x2d3d3f['params']['id']},'include':[{'model':db['CmList'],'as':_0x6582('0x84'),'include':[{'model':db[_0x6582('0x74')],'as':_0x6582('0x85'),'where':_0x218375,'limit':0x1,'order':[[_0x6582('0x86'),'DESC']]}]},{'model':db[_0x6582('0x87')],'as':_0x6582('0x88')}]});})['then'](handleEntityNotFound(_0x21f4d8,null))[_0x6582('0x22')](function(_0x1d7584){if(_0x1d7584&&_0x1d7584[_0x6582('0x84')]){_0x10634d[_0x6582('0x89')]=_0x1d7584;_0x10634d['applications']=_0x1d7584['Applications'];_0x10634d[_0x6582('0x8a')]=_0x1d7584['List'];_0x10634d[_0x6582('0x8b')]=_[_0x6582('0x8c')](_0x10634d[_0x6582('0x8b')],[_0x6582('0x8d')],[_0x6582('0x8e')]);if(_0x10634d[_0x6582('0x89')][_0x6582('0x88')]){delete _0x10634d[_0x6582('0x89')][_0x6582('0x88')];}if(_0x10634d['account'][_0x6582('0x84')]&&_0x10634d['account']['List'][_0x6582('0x85')][_0x6582('0x4c')]){return _0x10634d[_0x6582('0x89')][_0x6582('0x84')]['Contacts'][0x0];}var _0x36ae3c=_[_0x6582('0x8f')](_0x2d3d3f[_0x6582('0x5e')],{'firstName':_0x2d3d3f['body'][_0x6582('0x7c')],'ListId':_0x1d7584['ListId']});_0x36ae3c[_0x2d3d3f['body'][_0x6582('0x80')]]=_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x7c')];return db[_0x6582('0x74')][_0x6582('0x5d')](_0x36ae3c,{'fields':_0x22071f,'raw':!![]});}})['then'](handleEntityNotFound(_0x21f4d8,null))[_0x6582('0x22')](function(_0x437c3a){_0x10634d['contact']=_0x437c3a;if(_0x437c3a){var _0x574558={'ContactId':_0x437c3a['id'],'OpenchannelAccountId':_0x2d3d3f[_0x6582('0x59')]['id'],'from':(_0x437c3a[_0x6582('0x90')]||'')+'\x20'+(_0x437c3a[_0x6582('0x91')]||'')};var _0x45fcbc={'OpenchannelAccountId':_0x2d3d3f['params']['id'],'closed':![]};if(_0x2d3d3f['body']['threadId']){_0x45fcbc['threadId']=_0x2d3d3f['body'][_0x6582('0x92')];return db[_0x6582('0x93')][_0x6582('0x5c')]({'where':_0x45fcbc})[_0x6582('0x22')](function(_0x55a384){if(_0x55a384){return[_0x55a384,![]];}_0x574558[_0x6582('0x92')]=_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x92')];_0x574558[_0x6582('0x94')]=_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x94')];return db['OpenchannelInteraction'][_0x6582('0x5d')](_0x574558)[_0x6582('0x22')](function(_0x18ed40){return[_0x18ed40,!![]];});});}else{_0x45fcbc['threadId']=null;}_0x45fcbc[_0x6582('0x95')]=_0x437c3a['id'];return db[_0x6582('0x93')][_0x6582('0x5c')]({'where':_0x45fcbc})['then'](function(_0x237f79){if(_0x237f79){return[_0x237f79,![]];}return db[_0x6582('0x93')][_0x6582('0x5d')](_0x574558)['then'](function(_0xcf0873){return[_0xcf0873,!![]];});});}})[_0x6582('0x96')](function(_0x13d260,_0x4ded2f){if(_0x13d260){_0x148218=_0x4ded2f;if(!_0x4ded2f){var _0xdb83a={'from':(_0x10634d['contact'][_0x6582('0x90')]||'')+'\x20'+(_0x10634d['contact']['lastName']||'')};if(_0x2d3d3f['body'][_0x6582('0x92')]&&_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x97')]&&_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x92')]!=_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x97')]){_0xdb83a[_0x6582('0x92')]=_0x2d3d3f[_0x6582('0x5e')][_0x6582('0x97')];}return _0x13d260[_0x6582('0x65')](_0xdb83a);}else{return _0x13d260;}}})[_0x6582('0x22')](function(_0xdb9c3a){_0x10634d['interaction']=_0xdb9c3a[_0x6582('0x39')]({'plain':!![]});_0x10634d[_0x6582('0x98')][_0x6582('0x99')]=_0x148218;if(_0x10634d['interaction'][_0x6582('0x99')]){if(_0x10634d[_0x6582('0x89')]['autoclose']){_0x10634d[_0x6582('0x8b')][_0x6582('0x9a')]({'id':0x0,'priority':_0x10634d['applications'][_0x6582('0x4c')]+0x1,'app':_0x6582('0x9b'),'appdata':'unmanaged','interval':_0x6582('0x9c')});}}return db[_0x6582('0x9d')]['create']({'body':_0x2d3d3f['body'][_0x6582('0x5e')],'OpenchannelAccountId':_0x2d3d3f['params']['id'],'OpenchannelInteractionId':_0xdb9c3a['id'],'direction':'in','ContactId':_0x10634d[_0x6582('0x9e')]['id'],'AttachmentId':_0x2d3d3f[_0x6582('0x5e')]['AttachmentId']});})[_0x6582('0x22')](function(_0x456e4e){_0x10634d[_0x6582('0x29')]=_0x456e4e;if(_0x10634d[_0x6582('0x98')]['UserId']){return db[_0x6582('0x9f')][_0x6582('0x5c')]({'attributes':['id',_0x6582('0x3c')],'where':{'id':_0x10634d[_0x6582('0x98')][_0x6582('0xa0')]}})[_0x6582('0x22')](function(_0x3e28b8){if(_0x3e28b8){_0x10634d[_0x6582('0x8b')][_0x6582('0xa1')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x3e28b8[_0x6582('0x3c')]+','+(_0x10634d['account']['waitForTheAssignedAgent']||0xa),'interval':_0x6582('0x9c')});_0x10634d[_0x6582('0xa2')]=![];}return respondWithRpcPromise(_0x6582('0xa3'),_0x6582('0xa4'),_0x10634d);});}return respondWithRpcPromise(_0x6582('0xa3'),_0x6582('0xa4'),_0x10634d);})[_0x6582('0x22')](function(_0x49235e){respondWithRpcPromise('EventManager',_0x6582('0xa5'),{'event':_0x6582('0x73'),'message':_0x49235e},client9002);return _0x49235e;})['then'](respondWithResult(_0x21f4d8,null))[_0x6582('0x2c')](handleError(_0x21f4d8,null));};exports[_0x6582('0xa6')]=function(_0x292ede,_0x86ce07){var _0x158019=_0x292ede['params']['id'];var _0x4d5960=_0x292ede[_0x6582('0x5e')];var _0x5dd303=0xc8;var _0x196bb9=null;return db[_0x6582('0xa7')][_0x6582('0xa8')]({'isolationLevel':db[_0x6582('0xa7')]['Transaction']['ISOLATION_LEVELS'][_0x6582('0xa9')]},function(_0x21c26f){return db[_0x6582('0x3f')]['findOne']({'where':{'id':_0x158019},'transaction':_0x21c26f})[_0x6582('0x22')](function(_0x387cc0){if(_0x387cc0){return db['OpenchannelApplication']['destroy']({'where':{'OpenchannelAccountId':_0x158019},'transaction':_0x21c26f})['then'](function(){var _0x35f63a=_[_0x6582('0x45')](_0x4d5960,function(_0x4925f3){_0x4925f3[_0x6582('0x6b')]=_0x158019;return _0x4925f3;});return db['OpenchannelApplication'][_0x6582('0xaa')](_0x35f63a,{'transaction':_0x21c26f});});}else{_0x5dd303=0x194;_0x196bb9=[];}});})[_0x6582('0x22')](function(){if(_0x5dd303!==0x194){return db[_0x6582('0x87')][_0x6582('0xab')]({'where':{'OpenchannelAccountId':_0x158019},'order':_0x6582('0x8d')})[_0x6582('0x22')](function(_0x53d855){_0x196bb9=_0x53d855;});}})['catch'](function(_0x3e13f8){_0x5dd303=0x1f4;logger[_0x6582('0x27')](_0x3e13f8[_0x6582('0xac')]);if(_0x3e13f8[_0x6582('0x3c')]){delete _0x3e13f8[_0x6582('0x3c')];}_0x196bb9=_0x3e13f8;})[_0x6582('0xad')](function(){if(_0x196bb9===null){_0x86ce07['sendStatus'](_0x5dd303);}else{if(_0x5dd303===0x1f4){_0x86ce07[_0x6582('0x2e')](_0x5dd303)[_0x6582('0x3d')](_0x196bb9);}else{_0x86ce07[_0x6582('0x2e')](_0x5dd303)[_0x6582('0x36')](_0x196bb9);}}});};exports[_0x6582('0xae')]=function(_0x4bb330,_0x94cd6c,_0x45d586){var _0x2597e6={};var _0x361983={};var _0x482d01;var _0x15e4a1;return db[_0x6582('0x3f')]['findOne']({'where':{'id':_0x4bb330['params']['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x94cd6c,null))[_0x6582('0x22')](function(_0xe12585){if(_0xe12585){_0x482d01=_0xe12585;_0x361983[_0x6582('0x44')]=_[_0x6582('0x47')](db[_0x6582('0x87')][_0x6582('0x40')]);_0x361983[_0x6582('0x46')]=_[_0x6582('0x47')](_0x4bb330['query']);_0x361983[_0x6582('0x48')]=_['intersection'](_0x361983[_0x6582('0x44')],_0x361983['query']);_0x2597e6['attributes']=_[_0x6582('0x49')](_0x361983[_0x6582('0x44')],qs[_0x6582('0x4b')](_0x4bb330[_0x6582('0x46')][_0x6582('0x4b')]));_0x2597e6[_0x6582('0x4a')]=_0x2597e6[_0x6582('0x4a')]['length']?_0x2597e6[_0x6582('0x4a')]:_0x361983['model'];_0x2597e6['order']=qs[_0x6582('0x4f')](_0x4bb330[_0x6582('0x46')]['sort']);_0x2597e6[_0x6582('0x50')]=qs['filters'](_[_0x6582('0x51')](_0x4bb330[_0x6582('0x46')],_0x361983['filters']));if(_0x4bb330[_0x6582('0x46')][_0x6582('0x54')]){_0x2597e6['where']=_[_0x6582('0x52')](_0x2597e6[_0x6582('0x50')],{'$or':_['map'](_0x2597e6['attributes'],function(_0x248e8c){var _0x1ccd4c={};_0x1ccd4c[_0x248e8c]={'$like':'%'+_0x4bb330['query'][_0x6582('0x54')]+'%'};return _0x1ccd4c;})});}_0x2597e6=_['merge']({},_0x2597e6,_0x4bb330[_0x6582('0x5b')]);return _0x482d01[_0x6582('0xae')](_0x2597e6);}})[_0x6582('0x22')](function(_0x33e32f){if(_0x33e32f){_0x15e4a1=_0x33e32f[_0x6582('0x4c')];if(!_0x4bb330[_0x6582('0x46')]['hasOwnProperty'](_0x6582('0x4e'))){_0x2597e6['limit']=qs[_0x6582('0x32')](_0x4bb330[_0x6582('0x46')][_0x6582('0x32')]);_0x2597e6['offset']=qs[_0x6582('0x30')](_0x4bb330[_0x6582('0x46')][_0x6582('0x30')]);}return _0x482d01[_0x6582('0xae')](_0x2597e6);}})[_0x6582('0x22')](function(_0x481334){if(_0x481334){return _0x481334?{'count':_0x15e4a1,'rows':_0x481334}:null;}})['then'](respondWithResult(_0x94cd6c,null))[_0x6582('0x2c')](handleError(_0x94cd6c,null));};exports[_0x6582('0xaf')]=function(_0x368567,_0x9b08bb,_0x3ee750){var _0x32293c={'raw':![],'where':{}};var _0xe1c75e={};var _0x42ee00={'count':0x0,'rows':[]};return db[_0x6582('0x3f')][_0x6582('0x6a')]({'where':{'id':_0x368567[_0x6582('0x59')]['id']}})['then'](handleEntityNotFound(_0x9b08bb,null))[_0x6582('0x22')](function(_0x3d6c19){if(_0x3d6c19){_0xe1c75e[_0x6582('0x44')]=_[_0x6582('0x47')](db[_0x6582('0x93')][_0x6582('0x40')]);_0xe1c75e[_0x6582('0x46')]=_[_0x6582('0x47')](_0x368567[_0x6582('0x46')]);_0xe1c75e[_0x6582('0x48')]=_[_0x6582('0x49')](_0xe1c75e['model'],_0xe1c75e[_0x6582('0x46')]);_0x32293c['attributes']=_['intersection'](_0xe1c75e[_0x6582('0x44')],qs[_0x6582('0x4b')](_0x368567[_0x6582('0x46')][_0x6582('0x4b')]));_0x32293c[_0x6582('0x4a')]=_0x32293c[_0x6582('0x4a')][_0x6582('0x4c')]?_0x32293c[_0x6582('0x4a')]:_0xe1c75e[_0x6582('0x44')];if(!_0x368567[_0x6582('0x46')][_0x6582('0x4d')](_0x6582('0x4e'))){_0x32293c[_0x6582('0x32')]=qs[_0x6582('0x32')](_0x368567[_0x6582('0x46')][_0x6582('0x32')]);_0x32293c['offset']=qs[_0x6582('0x30')](_0x368567[_0x6582('0x46')][_0x6582('0x30')]);}_0x32293c[_0x6582('0x71')]=qs[_0x6582('0x4f')](_0x368567[_0x6582('0x46')]['sort']);_0x32293c[_0x6582('0x50')]=qs['filters'](_[_0x6582('0x51')](_0x368567[_0x6582('0x46')],_0xe1c75e[_0x6582('0x48')]));_0x32293c[_0x6582('0x50')][_0x6582('0x6b')]=_0x3d6c19['id'];if(_0x368567['query'][_0x6582('0x54')]){_0x32293c[_0x6582('0x50')]=_['merge'](_0x32293c[_0x6582('0x50')],{'$or':_[_0x6582('0x45')](_0x32293c['attributes'],function(_0x55ff5b){var _0x4644b1={};_0x4644b1[_0x55ff5b]={'$like':'%'+_0x368567[_0x6582('0x46')][_0x6582('0x54')]+'%'};return _0x4644b1;})});}_0x32293c=_[_0x6582('0x52')]({},_0x32293c,_0x368567[_0x6582('0x5b')]);return db[_0x6582('0x93')]['count']({'where':_0x32293c[_0x6582('0x50')]})['then'](function(_0x228187){_0x42ee00['count']=_0x228187;if(_0x368567[_0x6582('0x46')]['includeAll']){_0x32293c[_0x6582('0x5a')]=[{'model':db[_0x6582('0x74')],'as':'Contact','required':![]},{'model':db[_0x6582('0x9f')],'as':_0x6582('0xb0'),'attributes':[_0x6582('0x3c'),_0x6582('0xb1'),_0x6582('0xb2')],'required':![]},{'model':db[_0x6582('0xb3')],'as':'Tags','attributes':['id',_0x6582('0x3c'),_0x6582('0xb4')],'where':_0x368567[_0x6582('0x46')][_0x6582('0xb5')]?{'id':_0x368567[_0x6582('0x46')][_0x6582('0xb5')]}:undefined,'required':_0x368567[_0x6582('0x46')]['tag']?!![]:![]}];}return db[_0x6582('0x93')][_0x6582('0x56')](_0x32293c);})['then'](function(_0x45a494){_0x42ee00[_0x6582('0x57')]=_0x45a494;return _0x42ee00;});}})['then'](respondWithFilteredResult(_0x9b08bb,_0x32293c))['catch'](handleError(_0x9b08bb,null));};exports[_0x6582('0xb6')]=function(_0x421f5c,_0x3b57c8,_0x3c739b){return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x421f5c[_0x6582('0x59')]['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x3b57c8,null))[_0x6582('0x22')](function(_0x44d955){if(_0x44d955){return _0x44d955[_0x6582('0xb6')](_0x421f5c[_0x6582('0x5e')][_0x6582('0x6d')],_[_0x6582('0xb7')](_0x421f5c[_0x6582('0x5e')],[_0x6582('0x6d'),'id'])||{})[_0x6582('0x96')](function(_0x37f628){for(var _0x5f290b=0x0;_0x5f290b<_0x421f5c[_0x6582('0x5e')][_0x6582('0x6d')][_0x6582('0x4c')];_0x5f290b+=0x1){socket[_0x6582('0xb8')](_0x6582('0xb9'),{'UserId':Number(_0x421f5c[_0x6582('0x5e')][_0x6582('0x6d')][_0x5f290b]),'OpenchannelAccountId':Number(_0x421f5c[_0x6582('0x59')]['id'])});}return _0x37f628;});}})[_0x6582('0x22')](respondWithResult(_0x3b57c8,null))['catch'](handleError(_0x3b57c8,null));};exports['removeAgents']=function(_0x3c0aca,_0x1c69e1,_0x5de3ae){return db[_0x6582('0x3f')][_0x6582('0x5c')]({'where':{'id':_0x3c0aca[_0x6582('0x59')]['id']}})['then'](handleEntityNotFound(_0x1c69e1,null))['then'](function(_0x2405d9){if(_0x2405d9){return _0x2405d9[_0x6582('0xba')](_0x3c0aca[_0x6582('0x46')]['ids'])[_0x6582('0x22')](function(){if(_[_0x6582('0xbb')](_0x3c0aca['query'][_0x6582('0x6d')])){for(var _0x21d560=0x0;_0x21d560<_0x3c0aca[_0x6582('0x46')][_0x6582('0x6d')][_0x6582('0x4c')];_0x21d560+=0x1){socket[_0x6582('0xb8')](_0x6582('0xbc'),{'UserId':Number(_0x3c0aca[_0x6582('0x46')]['ids'][_0x21d560]),'OpenchannelAccountId':Number(_0x3c0aca[_0x6582('0x59')]['id'])});}}else{socket['emit']('userOpenchannelAccount:remove',{'UserId':Number(_0x3c0aca[_0x6582('0x46')][_0x6582('0x6d')]),'OpenchannelAccountId':Number(_0x3c0aca['params']['id'])});}});}})[_0x6582('0x22')](respondWithStatusCode(_0x1c69e1,null))[_0x6582('0x2c')](handleError(_0x1c69e1,null));};exports[_0x6582('0xbd')]=function(_0xdf97ef,_0xa80b9a,_0x4ab969){var _0x1403ac={};var _0x306dbe={};var _0x459fcb;var _0x4c304a;return db[_0x6582('0x3f')]['findOne']({'where':{'id':_0xdf97ef[_0x6582('0x59')]['id']}})['then'](handleEntityNotFound(_0xa80b9a,null))[_0x6582('0x22')](function(_0x40bcae){if(_0x40bcae){_0x459fcb=_0x40bcae;_0x306dbe['model']=_[_0x6582('0x47')](db[_0x6582('0x9f')][_0x6582('0x40')]);_0x306dbe[_0x6582('0x46')]=_['keys'](_0xdf97ef[_0x6582('0x46')]);_0x306dbe[_0x6582('0x48')]=_[_0x6582('0x49')](_0x306dbe[_0x6582('0x44')],_0x306dbe[_0x6582('0x46')]);_0x1403ac['attributes']=_['intersection'](_0x306dbe['model'],qs[_0x6582('0x4b')](_0xdf97ef[_0x6582('0x46')][_0x6582('0x4b')]));_0x1403ac['attributes']=_0x1403ac['attributes']['length']?_0x1403ac[_0x6582('0x4a')]:_0x306dbe[_0x6582('0x44')];_0x1403ac['order']=qs[_0x6582('0x4f')](_0xdf97ef['query'][_0x6582('0x4f')]);_0x1403ac[_0x6582('0x50')]=qs[_0x6582('0x48')](_[_0x6582('0x51')](_0xdf97ef[_0x6582('0x46')],_0x306dbe[_0x6582('0x48')]));if(_0xdf97ef[_0x6582('0x46')][_0x6582('0x54')]){_0x1403ac[_0x6582('0x50')]=_['merge'](_0x1403ac['where'],{'$or':_[_0x6582('0x45')](_0x1403ac[_0x6582('0x4a')],function(_0x2b7189){var _0x33c44b={};_0x33c44b[_0x2b7189]={'$like':'%'+_0xdf97ef[_0x6582('0x46')][_0x6582('0x54')]+'%'};return _0x33c44b;})});}_0x1403ac=_['merge']({},_0x1403ac,_0xdf97ef['options']);return _0x459fcb[_0x6582('0xbd')](_0x1403ac);}})[_0x6582('0x22')](function(_0x450e84){if(_0x450e84){_0x4c304a=_0x450e84[_0x6582('0x4c')];if(!_0xdf97ef[_0x6582('0x46')][_0x6582('0x4d')]('nolimit')){_0x1403ac[_0x6582('0x32')]=qs[_0x6582('0x32')](_0xdf97ef[_0x6582('0x46')]['limit']);_0x1403ac[_0x6582('0x30')]=qs[_0x6582('0x30')](_0xdf97ef['query']['offset']);}return _0x459fcb['getAgents'](_0x1403ac);}})['then'](function(_0x61dcfc){if(_0x61dcfc){return _0x61dcfc?{'count':_0x4c304a,'rows':_0x61dcfc}:null;}})[_0x6582('0x22')](respondWithResult(_0xa80b9a,null))['catch'](handleError(_0xa80b9a,null));};exports['send']=function(_0x3cbb65,_0x16a431,_0x503741){var _0x5a5be3,_0x712caa,_0x28110f;if(_[_0x6582('0x7b')](_0x3cbb65['body'][_0x6582('0x5e')])||_0x3cbb65[_0x6582('0x5e')][_0x6582('0x5e')]===''){throw new db['Sequelize'][(_0x6582('0x7d'))](_0x6582('0x7f'));}if(_['isNil'](_0x3cbb65['body']['to'])){}_0x5a5be3=_0x3cbb65[_0x6582('0x5e')]['to'];return db['OpenchannelAccount'][_0x6582('0x6a')]({'where':{'id':_0x3cbb65[_0x6582('0x59')]['id']}})[_0x6582('0x22')](handleEntityNotFound(_0x16a431,null))[_0x6582('0x22')](function(_0x3ac2b0){if(_0x3ac2b0){return db['OpenchannelAccount']['find']({'where':{'id':_0x3ac2b0['id']},'include':[{'model':db[_0x6582('0xbe')],'as':_0x6582('0x84'),'include':[{'model':db[_0x6582('0x74')],'as':_0x6582('0x85'),'where':{[_0x3ac2b0[_0x6582('0x80')]]:_0x5a5be3},'limit':0x1,'order':[['updatedAt',_0x6582('0xbf')]]}]}]})[_0x6582('0x22')](handleEntityNotFound(_0x16a431,null))[_0x6582('0x22')](function(_0x30c987){if(_0x30c987&&_0x30c987['List']){_0x712caa=_0x30c987[_0x6582('0x39')]({'plain':!![]});if(_0x712caa['List']&&_0x712caa[_0x6582('0x84')][_0x6582('0x85')][_0x6582('0x4c')]){return _0x712caa[_0x6582('0x84')][_0x6582('0x85')][0x0];}return db[_0x6582('0x74')]['create'](_[_0x6582('0x8f')](_0x3cbb65[_0x6582('0x5e')],{'firstName':_0x5a5be3,[_0x30c987['mapKey']]:_0x5a5be3,'phone':_0x5a5be3,'ListId':_0x712caa[_0x6582('0x7a')]}));}})[_0x6582('0x22')](handleEntityNotFound(_0x16a431,null))[_0x6582('0x22')](function(_0x55eead){if(_0x55eead){_0x28110f=_0x55eead;return db[_0x6582('0x93')][_0x6582('0x5c')]({'where':{'ContactId':_0x28110f['id'],'closed':![],'OpenchannelAccountId':_0x712caa['id']}})[_0x6582('0x22')](function(_0x234653){if(_0x234653){return[_0x234653,![]];}return db['OpenchannelInteraction']['create']({'UserId':_0x3cbb65[_0x6582('0x5f')]['id'],'ContactId':_0x28110f['id'],'OpenchannelAccountId':_0x712caa['id'],'lastMsgDirection':'out','firstMsgDirection':_0x6582('0xc0'),'Messages':[_['merge'](_0x3cbb65[_0x6582('0x5e')],{'read':![],'body':_0x3cbb65[_0x6582('0x5e')]['body'],'OpenchannelAccountId':_0x712caa['id'],'UserId':_0x3cbb65[_0x6582('0x5f')]['id'],'ContactId':_0x28110f['id']})]},{'include':[{'model':db[_0x6582('0x9d')],'as':_0x6582('0xc1')}]})[_0x6582('0x22')](function(_0x27478a){return[_0x27478a,!![]];});});}})[_0x6582('0x96')](function(_0x47a179,_0xaa5085){if(_0xaa5085){return _0x47a179;}return db[_0x6582('0x9d')][_0x6582('0x5d')](_[_0x6582('0x52')](_0x3cbb65[_0x6582('0x5e')],{'read':![],'body':_0x3cbb65[_0x6582('0x5e')][_0x6582('0x5e')],'OpenchannelAccountId':_0x712caa['id'],'OpenchannelInteractionId':_0x47a179['id'],'UserId':_0x3cbb65[_0x6582('0x5f')]['id'],'ContactId':_0x28110f['id']}))[_0x6582('0x22')](function(_0x168c75){_0x47a179[_0x6582('0xc2')][_0x6582('0xc1')]=[];_0x47a179[_0x6582('0xc2')][_0x6582('0xc1')][_0x6582('0x9a')](_0x168c75[_0x6582('0xc2')]);return _0x47a179;});});}})[_0x6582('0x22')](respondWithResult(_0x16a431,null))[_0x6582('0x2c')](handleError(_0x16a431,null));}; \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.events.js b/server/api/openchannelAccount/openchannelAccount.events.js new file mode 100644 index 0000000..674f67c --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa74f=['remove','hasOwnProperty','hook','exports','OpenchannelAccount','update'];(function(_0xba274,_0x20a193){var _0x2e7efc=function(_0x570e59){while(--_0x570e59){_0xba274['push'](_0xba274['shift']());}};_0x2e7efc(++_0x20a193);}(_0xa74f,0x9a));var _0xfa74=function(_0x52e0ee,_0x52f7c1){_0x52e0ee=_0x52e0ee-0x0;var _0x32534c=_0xa74f[_0x52e0ee];return _0x32534c;};'use strict';var EventEmitter=require('events');var OpenchannelAccount=require('../../mysqldb')['db'][_0xfa74('0x0')];var OpenchannelAccountEvents=new EventEmitter();OpenchannelAccountEvents['setMaxListeners'](0x0);var events={'afterCreate':'save','afterUpdate':_0xfa74('0x1'),'afterDestroy':_0xfa74('0x2')};function emitEvent(_0x394a1e){return function(_0x25a9b7,_0x5b367b,_0x141625){OpenchannelAccountEvents['emit'](_0x394a1e+':'+_0x25a9b7['id'],_0x25a9b7);OpenchannelAccountEvents['emit'](_0x394a1e,_0x25a9b7);_0x141625(null);};}for(var e in events){if(events[_0xfa74('0x3')](e)){var event=events[e];OpenchannelAccount[_0xfa74('0x4')](e,emitEvent(event));}}module[_0xfa74('0x5')]=OpenchannelAccountEvents; \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.model.js b/server/api/openchannelAccount/openchannelAccount.model.js new file mode 100644 index 0000000..901b836 --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../config/environment','./openchannelAccount.attributes','exports','define','OpenchannelAccount','lodash','util','../../config/logger','bluebird','path','rimraf'];(function(_0x40c0d3,_0x183fca){var _0x434974=function(_0x462a59){while(--_0x462a59){_0x40c0d3['push'](_0x40c0d3['shift']());}};_0x434974(++_0x183fca);}(_0xa9e0,0x123));var _0x0a9e=function(_0x4dbaad,_0x730318){_0x4dbaad=_0x4dbaad-0x0;var _0x226c72=_0xa9e0[_0x4dbaad];return _0x226c72;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var logger=require(_0x0a9e('0x2'))('api');var moment=require('moment');var BPromise=require(_0x0a9e('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x0a9e('0x4'));var rimraf=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var attributes=require(_0x0a9e('0x7'));module[_0x0a9e('0x8')]=function(_0x57b080,_0x219af0){return _0x57b080[_0x0a9e('0x9')](_0x0a9e('0xa'),attributes,{'tableName':'openchannel_accounts','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.rpc.js b/server/api/openchannelAccount/openchannelAccount.rpc.js new file mode 100644 index 0000000..f2707cb --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0427=['./openchannelAccount.socket','register','then','info','OpenchannelAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x357001,_0x2d5f60){var _0x3c835a=function(_0x544c9a){while(--_0x544c9a){_0x357001['push'](_0x357001['shift']());}};_0x3c835a(++_0x2d5f60);}(_0x0427,0x137));var _0x7042=function(_0x31eaae,_0x296f51){_0x31eaae=_0x31eaae-0x0;var _0x42f5e1=_0x0427[_0x31eaae];return _0x42f5e1;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x7042('0x0'));var BPromise=require(_0x7042('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7042('0x2'));var db=require(_0x7042('0x3'))['db'];var utils=require(_0x7042('0x4'));var logger=require(_0x7042('0x5'))(_0x7042('0x6'));var config=require(_0x7042('0x7'));var jayson=require(_0x7042('0x8'));var client=jayson['client'][_0x7042('0x9')]({'port':0x232a});config[_0x7042('0xa')]=_[_0x7042('0xb')](config[_0x7042('0xa')],{'host':_0x7042('0xc'),'port':0x18eb});var socket=require(_0x7042('0xd'))(new Redis(config[_0x7042('0xa')]));require(_0x7042('0xe'))[_0x7042('0xf')](socket);function respondWithRpcPromise(_0x5a29aa,_0x326210,_0x5c3f0f){return new BPromise(function(_0x5cf853,_0x50eefb){return client['request'](_0x5a29aa,_0x5c3f0f)[_0x7042('0x10')](function(_0x5636e8){logger[_0x7042('0x11')](_0x7042('0x12'),_0x326210,_0x7042('0x13'));logger['debug']('OpenchannelAccount,\x20%s,\x20%s,\x20%s',_0x326210,_0x7042('0x13'),JSON[_0x7042('0x14')](_0x5636e8));if(_0x5636e8[_0x7042('0x15')]){if(_0x5636e8[_0x7042('0x15')][_0x7042('0x16')]===0x1f4){logger[_0x7042('0x15')]('OpenchannelAccount,\x20%s,\x20%s',_0x326210,_0x5636e8[_0x7042('0x15')][_0x7042('0x17')]);return _0x50eefb(_0x5636e8[_0x7042('0x15')]['message']);}logger[_0x7042('0x15')](_0x7042('0x12'),_0x326210,_0x5636e8['error'][_0x7042('0x17')]);return _0x5cf853(_0x5636e8['error']['message']);}else{logger[_0x7042('0x11')](_0x7042('0x12'),_0x326210,_0x7042('0x13'));_0x5cf853(_0x5636e8[_0x7042('0x18')][_0x7042('0x17')]);}})['catch'](function(_0x438084){logger[_0x7042('0x15')](_0x7042('0x12'),_0x326210,_0x438084);_0x50eefb(_0x438084);});});} \ No newline at end of file diff --git a/server/api/openchannelAccount/openchannelAccount.socket.js b/server/api/openchannelAccount/openchannelAccount.socket.js new file mode 100644 index 0000000..a4fffaa --- /dev/null +++ b/server/api/openchannelAccount/openchannelAccount.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1bb2=['register','length','save','remove','update','emit','removeListener'];(function(_0x25cf20,_0x4d6c77){var _0x58e96e=function(_0x3c995c){while(--_0x3c995c){_0x25cf20['push'](_0x25cf20['shift']());}};_0x58e96e(++_0x4d6c77);}(_0x1bb2,0x152));var _0x21bb=function(_0x53424c,_0x20fabf){_0x53424c=_0x53424c-0x0;var _0xfa8f93=_0x1bb2[_0x53424c];return _0xfa8f93;};'use strict';var OpenchannelAccountEvents=require('./openchannelAccount.events');var events=[_0x21bb('0x0'),_0x21bb('0x1'),_0x21bb('0x2')];function createListener(_0x480fcb,_0x4e514f){return function(_0x170632){_0x4e514f[_0x21bb('0x3')](_0x480fcb,_0x170632);};}function removeListener(_0x1c21c6,_0x469984){return function(){OpenchannelAccountEvents[_0x21bb('0x4')](_0x1c21c6,_0x469984);};}exports[_0x21bb('0x5')]=function(_0x198344){for(var _0x267bb0=0x0,_0x36217b=events[_0x21bb('0x6')];_0x267bb0<_0x36217b;_0x267bb0++){var _0x642998=events[_0x267bb0];var _0x316b77=createListener('openchannelAccount:'+_0x642998,_0x198344);OpenchannelAccountEvents['on'](_0x642998,_0x316b77);}}; \ No newline at end of file diff --git a/server/api/openchannelApplication/index.js b/server/api/openchannelApplication/index.js new file mode 100644 index 0000000..5cd8567 --- /dev/null +++ b/server/api/openchannelApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2668=['create','update','delete','destroy','exports','multer','path','connect-timeout','Router','../../components/auth/service','../../config/environment','isAuthenticated','index','get','/:id','post'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x2668,0x1b5));var _0x8266=function(_0x2b4411,_0x2625ed){_0x2b4411=_0x2b4411-0x0;var _0x8e41ef=_0x2668[_0x2b4411];return _0x8e41ef;};'use strict';var multer=require(_0x8266('0x0'));var util=require('util');var path=require(_0x8266('0x1'));var timeout=require(_0x8266('0x2'));var express=require('express');var router=express[_0x8266('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x8266('0x4'));var interaction=require('../../components/interaction/service');var config=require(_0x8266('0x5'));var controller=require('./openchannelApplication.controller');router['get']('/',auth[_0x8266('0x6')](),controller[_0x8266('0x7')]);router[_0x8266('0x8')](_0x8266('0x9'),auth[_0x8266('0x6')](),controller['show']);router[_0x8266('0xa')]('/',auth[_0x8266('0x6')](),controller[_0x8266('0xb')]);router['put'](_0x8266('0x9'),auth['isAuthenticated'](),controller[_0x8266('0xc')]);router[_0x8266('0xd')](_0x8266('0x9'),auth[_0x8266('0x6')](),controller[_0x8266('0xe')]);module[_0x8266('0xf')]=router; \ No newline at end of file diff --git a/server/api/openchannelApplication/openchannelApplication.attributes.js b/server/api/openchannelApplication/openchannelApplication.attributes.js new file mode 100644 index 0000000..a0ce650 --- /dev/null +++ b/server/api/openchannelApplication/openchannelApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe7be=['noop','STRING','*,*,*,*','sequelize','exports','INTEGER'];(function(_0x108a1c,_0x6c5bda){var _0x3e4e11=function(_0x4982e2){while(--_0x4982e2){_0x108a1c['push'](_0x108a1c['shift']());}};_0x3e4e11(++_0x6c5bda);}(_0xe7be,0x1ef));var _0xee7b=function(_0x1b3e32,_0x49ad74){_0x1b3e32=_0x1b3e32-0x0;var _0x4796e3=_0xe7be[_0x1b3e32];return _0x4796e3;};'use strict';var Sequelize=require(_0xee7b('0x0'));module[_0xee7b('0x1')]={'priority':{'type':Sequelize[_0xee7b('0x2')],'allowNull':![]},'app':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0xee7b('0x3')},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize[_0xee7b('0x4')]},'interval':{'type':Sequelize[_0xee7b('0x4')],'defaultValue':_0xee7b('0x5')}}; \ No newline at end of file diff --git a/server/api/openchannelApplication/openchannelApplication.controller.js b/server/api/openchannelApplication/openchannelApplication.controller.js new file mode 100644 index 0000000..239b191 --- /dev/null +++ b/server/api/openchannelApplication/openchannelApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x93bb=['limit','count','Content-Range','reject','save','update','then','destroy','end','error','stack','name','send','index','OpenchannelApplication','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','pick','filter','where','merge','options','includeAll','rows','catch','show','params','include','find','create','body','eml-format','zip-dir','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined'];(function(_0x305542,_0x4b921a){var _0x413821=function(_0x4c1204){while(--_0x4c1204){_0x305542['push'](_0x305542['shift']());}};_0x413821(++_0x4b921a);}(_0x93bb,0x1a9));var _0xb93b=function(_0x528362,_0x2248b1){_0x528362=_0x528362-0x0;var _0x5e8bf8=_0x93bb[_0x528362];return _0x5e8bf8;};'use strict';var emlformat=require(_0xb93b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xb93b('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xb93b('0x2'));var BPromise=require(_0xb93b('0x3'));var Mustache=require(_0xb93b('0x4'));var util=require('util');var path=require(_0xb93b('0x5'));var sox=require(_0xb93b('0x6'));var csv=require('to-csv');var ejs=require(_0xb93b('0x7'));var fs=require('fs');var fs_extra=require(_0xb93b('0x8'));var _=require(_0xb93b('0x9'));var squel=require(_0xb93b('0xa'));var crypto=require(_0xb93b('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xb93b('0xc'));var toCsv=require(_0xb93b('0xd'));var querystring=require(_0xb93b('0xe'));var Papa=require(_0xb93b('0xf'));var Redis=require(_0xb93b('0x10'));var authService=require(_0xb93b('0x11'));var qs=require(_0xb93b('0x12'));var as=require(_0xb93b('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb93b('0x14'))(_0xb93b('0x15'));var utils=require(_0xb93b('0x16'));var config=require(_0xb93b('0x17'));var licenseUtil=require(_0xb93b('0x18'));var db=require(_0xb93b('0x19'))['db'];function respondWithStatusCode(_0x33c524,_0xeaed2b){_0xeaed2b=_0xeaed2b||0xcc;return function(_0x4f72db){if(_0x4f72db){return _0x33c524[_0xb93b('0x1a')](_0xeaed2b);}return _0x33c524[_0xb93b('0x1b')](_0xeaed2b)['end']();};}function respondWithResult(_0x5d4170,_0x1ad9f5){_0x1ad9f5=_0x1ad9f5||0xc8;return function(_0x48a6ed){if(_0x48a6ed){return _0x5d4170[_0xb93b('0x1b')](_0x1ad9f5)[_0xb93b('0x1c')](_0x48a6ed);}};}function respondWithFilteredResult(_0xd7956a,_0x3ac756){return function(_0xf7bf36){if(_0xf7bf36){var _0x4a9137=typeof _0x3ac756[_0xb93b('0x1d')]===_0xb93b('0x1e')&&typeof _0x3ac756[_0xb93b('0x1f')]===_0xb93b('0x1e');var _0x267141=_0xf7bf36[_0xb93b('0x20')];var _0x3b936c=_0x4a9137?0x0:_0x3ac756[_0xb93b('0x1d')];var _0x272575=_0x4a9137?_0xf7bf36[_0xb93b('0x20')]:_0x3ac756['offset']+_0x3ac756['limit'];var _0x226647;if(_0x272575>=_0x267141){_0x272575=_0x267141;_0x226647=0xc8;}else{_0x226647=0xce;}_0xd7956a['status'](_0x226647);return _0xd7956a['set'](_0xb93b('0x21'),_0x3b936c+'-'+_0x272575+'/'+_0x267141)[_0xb93b('0x1c')](_0xf7bf36);}return null;};}function patchUpdates(_0x10a85e){return function(_0x2dec90){try{jsonpatch['apply'](_0x2dec90,_0x10a85e,!![]);}catch(_0x360045){return BPromise[_0xb93b('0x22')](_0x360045);}return _0x2dec90[_0xb93b('0x23')]();};}function saveUpdates(_0x1b8f34,_0x5c6367){return function(_0x2ce6e2){if(_0x2ce6e2){return _0x2ce6e2[_0xb93b('0x24')](_0x1b8f34)[_0xb93b('0x25')](function(_0xecb481){return _0xecb481;});}return null;};}function removeEntity(_0x330650,_0x4b62ea){return function(_0x25a603){if(_0x25a603){return _0x25a603[_0xb93b('0x26')]()[_0xb93b('0x25')](function(){_0x330650[_0xb93b('0x1b')](0xcc)[_0xb93b('0x27')]();});}};}function handleEntityNotFound(_0x3bc347,_0x48a1f1){return function(_0x36a617){if(!_0x36a617){_0x3bc347[_0xb93b('0x1a')](0x194);}return _0x36a617;};}function handleError(_0xa5b33a,_0x344bbd){_0x344bbd=_0x344bbd||0x1f4;return function(_0x1ec7c2){logger[_0xb93b('0x28')](_0x1ec7c2[_0xb93b('0x29')]);if(_0x1ec7c2[_0xb93b('0x2a')]){delete _0x1ec7c2[_0xb93b('0x2a')];}_0xa5b33a[_0xb93b('0x1b')](_0x344bbd)[_0xb93b('0x2b')](_0x1ec7c2);};}exports[_0xb93b('0x2c')]=function(_0x19976c,_0x3cb45b){var _0x4c2bad={},_0x5991be={},_0x116523={'count':0x0,'rows':[]};var _0x2462ac=_['map'](db[_0xb93b('0x2d')][_0xb93b('0x2e')],function(_0x3fe952){return{'name':_0x3fe952[_0xb93b('0x2f')],'type':_0x3fe952[_0xb93b('0x30')][_0xb93b('0x31')]};});_0x5991be[_0xb93b('0x32')]=_[_0xb93b('0x33')](_0x2462ac,_0xb93b('0x2a'));_0x5991be[_0xb93b('0x34')]=_[_0xb93b('0x35')](_0x19976c[_0xb93b('0x34')]);_0x5991be[_0xb93b('0x36')]=_[_0xb93b('0x37')](_0x5991be['model'],_0x5991be['query']);_0x4c2bad['attributes']=_['intersection'](_0x5991be[_0xb93b('0x32')],qs['fields'](_0x19976c[_0xb93b('0x34')][_0xb93b('0x38')]));_0x4c2bad[_0xb93b('0x39')]=_0x4c2bad[_0xb93b('0x39')][_0xb93b('0x3a')]?_0x4c2bad[_0xb93b('0x39')]:_0x5991be[_0xb93b('0x32')];if(!_0x19976c[_0xb93b('0x34')][_0xb93b('0x3b')]('nolimit')){_0x4c2bad[_0xb93b('0x1f')]=qs[_0xb93b('0x1f')](_0x19976c[_0xb93b('0x34')][_0xb93b('0x1f')]);_0x4c2bad['offset']=qs['offset'](_0x19976c[_0xb93b('0x34')][_0xb93b('0x1d')]);}_0x4c2bad[_0xb93b('0x3c')]=qs[_0xb93b('0x3d')](_0x19976c[_0xb93b('0x34')][_0xb93b('0x3d')]);_0x4c2bad['where']=qs[_0xb93b('0x36')](_[_0xb93b('0x3e')](_0x19976c[_0xb93b('0x34')],_0x5991be[_0xb93b('0x36')]),_0x2462ac);if(_0x19976c[_0xb93b('0x34')][_0xb93b('0x3f')]){_0x4c2bad[_0xb93b('0x40')]=_[_0xb93b('0x41')](_0x4c2bad[_0xb93b('0x40')],{'$or':_['map'](_0x2462ac,function(_0x55c4d8){if(_0x55c4d8[_0xb93b('0x30')]!=='VIRTUAL'){var _0x28fd8c={};_0x28fd8c[_0x55c4d8[_0xb93b('0x2a')]]={'$like':'%'+_0x19976c[_0xb93b('0x34')][_0xb93b('0x3f')]+'%'};return _0x28fd8c;}})});}_0x4c2bad=_[_0xb93b('0x41')]({},_0x4c2bad,_0x19976c[_0xb93b('0x42')]);var _0x37e4c6={'where':_0x4c2bad[_0xb93b('0x40')]};return db[_0xb93b('0x2d')][_0xb93b('0x20')](_0x37e4c6)['then'](function(_0x1d78cb){_0x116523[_0xb93b('0x20')]=_0x1d78cb;if(_0x19976c[_0xb93b('0x34')][_0xb93b('0x43')]){_0x4c2bad['include']=[{'all':!![]}];}return db[_0xb93b('0x2d')]['findAll'](_0x4c2bad);})[_0xb93b('0x25')](function(_0x136531){_0x116523[_0xb93b('0x44')]=_0x136531;return _0x116523;})[_0xb93b('0x25')](respondWithFilteredResult(_0x3cb45b,_0x4c2bad))[_0xb93b('0x45')](handleError(_0x3cb45b,null));};exports[_0xb93b('0x46')]=function(_0x27e161,_0x4ac8cb){var _0x3fb151={'raw':!![],'where':{'id':_0x27e161[_0xb93b('0x47')]['id']}},_0x4f1ffe={};_0x4f1ffe[_0xb93b('0x32')]=_[_0xb93b('0x35')](db[_0xb93b('0x2d')]['rawAttributes']);_0x4f1ffe[_0xb93b('0x34')]=_[_0xb93b('0x35')](_0x27e161[_0xb93b('0x34')]);_0x4f1ffe[_0xb93b('0x36')]=_['intersection'](_0x4f1ffe['model'],_0x4f1ffe[_0xb93b('0x34')]);_0x3fb151[_0xb93b('0x39')]=_[_0xb93b('0x37')](_0x4f1ffe[_0xb93b('0x32')],qs['fields'](_0x27e161['query'][_0xb93b('0x38')]));_0x3fb151['attributes']=_0x3fb151[_0xb93b('0x39')]['length']?_0x3fb151[_0xb93b('0x39')]:_0x4f1ffe[_0xb93b('0x32')];if(_0x27e161[_0xb93b('0x34')][_0xb93b('0x43')]){_0x3fb151[_0xb93b('0x48')]=[{'all':!![]}];}_0x3fb151=_[_0xb93b('0x41')]({},_0x3fb151,_0x27e161[_0xb93b('0x42')]);return db[_0xb93b('0x2d')][_0xb93b('0x49')](_0x3fb151)['then'](handleEntityNotFound(_0x4ac8cb,null))[_0xb93b('0x25')](respondWithResult(_0x4ac8cb,null))['catch'](handleError(_0x4ac8cb,null));};exports['create']=function(_0xe6f43d,_0x17ce01){return db[_0xb93b('0x2d')][_0xb93b('0x4a')](_0xe6f43d[_0xb93b('0x4b')],{})[_0xb93b('0x25')](respondWithResult(_0x17ce01,0xc9))[_0xb93b('0x45')](handleError(_0x17ce01,null));};exports[_0xb93b('0x24')]=function(_0x1a2885,_0x925004){if(_0x1a2885[_0xb93b('0x4b')]['id']){delete _0x1a2885[_0xb93b('0x4b')]['id'];}return db[_0xb93b('0x2d')][_0xb93b('0x49')]({'where':{'id':_0x1a2885[_0xb93b('0x47')]['id']}})['then'](handleEntityNotFound(_0x925004,null))[_0xb93b('0x25')](saveUpdates(_0x1a2885[_0xb93b('0x4b')],null))[_0xb93b('0x25')](respondWithResult(_0x925004,null))[_0xb93b('0x45')](handleError(_0x925004,null));};exports[_0xb93b('0x26')]=function(_0x34f001,_0x4862a0){return db[_0xb93b('0x2d')][_0xb93b('0x49')]({'where':{'id':_0x34f001[_0xb93b('0x47')]['id']}})[_0xb93b('0x25')](handleEntityNotFound(_0x4862a0,null))[_0xb93b('0x25')](removeEntity(_0x4862a0,null))[_0xb93b('0x45')](handleError(_0x4862a0,null));}; \ No newline at end of file diff --git a/server/api/openchannelApplication/openchannelApplication.model.js b/server/api/openchannelApplication/openchannelApplication.model.js new file mode 100644 index 0000000..46a7994 --- /dev/null +++ b/server/api/openchannelApplication/openchannelApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9df8=['rimraf','../../config/environment','exports','define','OpenchannelApplication','openchannel_applications','lodash','util','../../config/logger','api','moment','bluebird','path'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0x9df8,0x95));var _0x89df=function(_0x39dae4,_0x58a305){_0x39dae4=_0x39dae4-0x0;var _0x39ab08=_0x9df8[_0x39dae4];return _0x39ab08;};'use strict';var _=require(_0x89df('0x0'));var util=require(_0x89df('0x1'));var logger=require(_0x89df('0x2'))(_0x89df('0x3'));var moment=require(_0x89df('0x4'));var BPromise=require(_0x89df('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x89df('0x6'));var rimraf=require(_0x89df('0x7'));var config=require(_0x89df('0x8'));var attributes=require('./openchannelApplication.attributes');module[_0x89df('0x9')]=function(_0x95bcce,_0x3de5f7){return _0x95bcce[_0x89df('0xa')](_0x89df('0xb'),attributes,{'tableName':_0x89df('0xc'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});}; \ No newline at end of file diff --git a/server/api/openchannelApplication/openchannelApplication.rpc.js b/server/api/openchannelApplication/openchannelApplication.rpc.js new file mode 100644 index 0000000..ada04e9 --- /dev/null +++ b/server/api/openchannelApplication/openchannelApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb88b=['where','attributes','then','stringify','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','request','info','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','error','message','result','catch','UpdateOpenchannelApplication','OpenchannelApplication','update','body','options','raw'];(function(_0x53b1c0,_0xe63aeb){var _0x5a2417=function(_0x4b0fc7){while(--_0x4b0fc7){_0x53b1c0['push'](_0x53b1c0['shift']());}};_0x5a2417(++_0xe63aeb);}(_0xb88b,0x1a8));var _0xbb88=function(_0xbbfa7e,_0x19cb37){_0xbbfa7e=_0xbbfa7e-0x0;var _0x311aa6=_0xb88b[_0xbbfa7e];return _0x311aa6;};'use strict';var _=require(_0xbb88('0x0'));var util=require(_0xbb88('0x1'));var moment=require(_0xbb88('0x2'));var BPromise=require(_0xbb88('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbb88('0x4'));var db=require(_0xbb88('0x5'))['db'];var utils=require(_0xbb88('0x6'));var logger=require(_0xbb88('0x7'))(_0xbb88('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xbb88('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x24502f,_0x4a41fc,_0x5b326e){return new BPromise(function(_0x21c3c9,_0x25f747){return client[_0xbb88('0xa')](_0x24502f,_0x5b326e)['then'](function(_0x1dfc18){logger[_0xbb88('0xb')](_0xbb88('0xc'),_0x4a41fc,_0xbb88('0xd'));logger[_0xbb88('0xe')](_0xbb88('0xf'),_0x4a41fc,_0xbb88('0xd'),JSON['stringify'](_0x1dfc18));if(_0x1dfc18[_0xbb88('0x10')]){if(_0x1dfc18[_0xbb88('0x10')]['code']===0x1f4){logger[_0xbb88('0x10')](_0xbb88('0xc'),_0x4a41fc,_0x1dfc18[_0xbb88('0x10')][_0xbb88('0x11')]);return _0x25f747(_0x1dfc18[_0xbb88('0x10')][_0xbb88('0x11')]);}logger[_0xbb88('0x10')](_0xbb88('0xc'),_0x4a41fc,_0x1dfc18[_0xbb88('0x10')][_0xbb88('0x11')]);return _0x21c3c9(_0x1dfc18['error'][_0xbb88('0x11')]);}else{logger[_0xbb88('0xb')]('OpenchannelApplication,\x20%s,\x20%s',_0x4a41fc,_0xbb88('0xd'));_0x21c3c9(_0x1dfc18[_0xbb88('0x12')][_0xbb88('0x11')]);}})[_0xbb88('0x13')](function(_0x2b5720){logger['error']('OpenchannelApplication,\x20%s,\x20%s',_0x4a41fc,_0x2b5720);_0x25f747(_0x2b5720);});});}exports[_0xbb88('0x14')]=function(_0x53a17b){var _0x346705=this;return new Promise(function(_0x3aba28,_0xd3fc0c){return db[_0xbb88('0x15')][_0xbb88('0x16')](_0x53a17b[_0xbb88('0x17')],{'raw':_0x53a17b[_0xbb88('0x18')]?_0x53a17b['options'][_0xbb88('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x53a17b[_0xbb88('0x18')]?_0x53a17b[_0xbb88('0x18')][_0xbb88('0x1a')]||null:null,'attributes':_0x53a17b['options']?_0x53a17b['options'][_0xbb88('0x1b')]||null:null,'limit':_0x53a17b[_0xbb88('0x18')]?_0x53a17b[_0xbb88('0x18')]['limit']||null:null})[_0xbb88('0x1c')](function(_0x63e661){logger[_0xbb88('0xb')](_0xbb88('0x14'),_0x53a17b);logger[_0xbb88('0xe')]('UpdateOpenchannelApplication',_0x53a17b,JSON[_0xbb88('0x1d')](_0x63e661));_0x3aba28(_0x63e661);})[_0xbb88('0x13')](function(_0x14b80b){logger[_0xbb88('0x10')](_0xbb88('0x14'),_0x14b80b['message'],_0x53a17b);_0xd3fc0c(_0x346705[_0xbb88('0x10')](0x1f4,_0x14b80b[_0xbb88('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/openchannelInteraction/index.js b/server/api/openchannelInteraction/index.js new file mode 100644 index 0000000..7a9a47b --- /dev/null +++ b/server/api/openchannelInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd030=['update','delete','openchannelinteraction:destroy','destroy','removeTags','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','./openchannelInteraction.controller','get','isAuthenticated','/describe','describe','/:id','show','/:id/messages','/:id/download','download','post','create','addMessage','/:id/tags','tracked','openchannel','openchannelinteraction:addtags','addTags','put'];(function(_0x3890f9,_0x64277e){var _0x39354a=function(_0x1ae1a4){while(--_0x1ae1a4){_0x3890f9['push'](_0x3890f9['shift']());}};_0x39354a(++_0x64277e);}(_0xd030,0x68));var _0x0d03=function(_0x13656b,_0x31e562){_0x13656b=_0x13656b-0x0;var _0x3e64db=_0xd030[_0x13656b];return _0x3e64db;};'use strict';var multer=require(_0x0d03('0x0'));var util=require(_0x0d03('0x1'));var path=require(_0x0d03('0x2'));var timeout=require(_0x0d03('0x3'));var express=require(_0x0d03('0x4'));var router=express[_0x0d03('0x5')]();var fs_extra=require(_0x0d03('0x6'));var auth=require(_0x0d03('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0x0d03('0x8'));var controller=require(_0x0d03('0x9'));router[_0x0d03('0xa')]('/',auth[_0x0d03('0xb')](),controller['index']);router[_0x0d03('0xa')](_0x0d03('0xc'),auth[_0x0d03('0xb')](),controller[_0x0d03('0xd')]);router[_0x0d03('0xa')](_0x0d03('0xe'),auth[_0x0d03('0xb')](),controller[_0x0d03('0xf')]);router[_0x0d03('0xa')](_0x0d03('0x10'),auth[_0x0d03('0xb')](),controller['getMessages']);router[_0x0d03('0xa')](_0x0d03('0x11'),auth[_0x0d03('0xb')](),controller[_0x0d03('0x12')]);router[_0x0d03('0x13')]('/',auth[_0x0d03('0xb')](),controller[_0x0d03('0x14')]);router[_0x0d03('0x13')]('/:id/messages',auth[_0x0d03('0xb')](),controller[_0x0d03('0x15')]);router[_0x0d03('0x13')](_0x0d03('0x16'),auth[_0x0d03('0xb')](),interaction[_0x0d03('0x17')](_0x0d03('0x18'),_0x0d03('0x19')),controller[_0x0d03('0x1a')]);router[_0x0d03('0x1b')](_0x0d03('0xe'),auth[_0x0d03('0xb')](),interaction[_0x0d03('0x17')](_0x0d03('0x18'),'openchannelinteraction:update'),controller[_0x0d03('0x1c')]);router[_0x0d03('0x1d')](_0x0d03('0xe'),auth[_0x0d03('0xb')](),interaction[_0x0d03('0x17')]('openchannel',_0x0d03('0x1e')),controller[_0x0d03('0x1f')]);router[_0x0d03('0x1d')]('/:id/tags',auth[_0x0d03('0xb')](),controller[_0x0d03('0x20')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.attributes.js b/server/api/openchannelInteraction/openchannelInteraction.attributes.js new file mode 100644 index 0000000..8d4e4ec --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x340c=['BOOLEAN','DATE','STRING','ENUM','out','sequelize','exports'];(function(_0x2b5eae,_0x55010d){var _0x5f3ac9=function(_0x397bfc){while(--_0x397bfc){_0x2b5eae['push'](_0x2b5eae['shift']());}};_0x5f3ac9(++_0x55010d);}(_0x340c,0xe5));var _0xc340=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x340c[_0x3dd15e];return _0x231fd0;};'use strict';var Sequelize=require(_0xc340('0x0'));module[_0xc340('0x1')]={'closed':{'type':Sequelize[_0xc340('0x2')],'defaultValue':![]},'closedAt':{'type':Sequelize[_0xc340('0x3')]},'disposition':{'type':Sequelize['STRING']},'secondDisposition':{'type':Sequelize[_0xc340('0x4')]},'thirdDisposition':{'type':Sequelize[_0xc340('0x4')]},'note':{'type':Sequelize[_0xc340('0x4')]},'read1stAt':{'type':Sequelize[_0xc340('0x3')]},'threadId':{'type':Sequelize['STRING']},'externalUrl':{'type':Sequelize[_0xc340('0x4')]},'lastMsgAt':{'type':Sequelize[_0xc340('0x3')]},'firstMsgDirection':{'type':Sequelize[_0xc340('0x5')]('in',_0xc340('0x6')),'defaultValue':'in','allowNull':![]},'lastMsgDirection':{'type':Sequelize[_0xc340('0x5')]('in','out'),'defaultValue':'in','allowNull':![]},'from':{'type':Sequelize['STRING']},'autoreplyExecuted':{'type':Sequelize['BOOLEAN'],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.controller.js b/server/api/openchannelInteraction/openchannelInteraction.controller.js new file mode 100644 index 0000000..1c08412 --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9d23=['addMessage','ids','omit','getMessages','findOne','hasOwnProperty','order','sort','where','pick','OpenchannelInteractionId','filter','$gte','format','YYYY-MM-DD\x20HH:mm:ss','includeAll','rows','addTags','spread','Tag','color','emit','removeTags','download','unix','toString','join','root','files','push','User','fullname','CmContact','firstName','lastName','attachments','Attachment','Messages','createdAt','direction','secret','read','OpenchannelAccount','Account','Owner','get','mkdirSync','Openchannel','N.A.','closed','closedAt','threadId','Public','existsSync','createWriteStream','basename','System','Contact','renderFile','server','views','downloadInteraction.ejs','.pdf','createPdfFromHTML','Unable\x20to\x20delete\x20zip\x20file','unlinkSync','zip-dir','moment','util','path','ejs','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../components/export/pdf','../../config/logger','api','../../config/environment','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','status','end','json','offset','undefined','limit','count','set','Content-Range','update','then','sendStatus','error','stack','name','send','index','map','OpenchannelInteraction','rawAttributes','fieldName','type','key','getOptions','findAll','openchannel','query','catch','show','from','params','model','keys','filters','intersection','attributes','fields','length','merge','options','find','create','body','destroy','describe','OpenchannelMessage'];(function(_0x6de23e,_0x2d5128){var _0x35d730=function(_0x41a59f){while(--_0x41a59f){_0x6de23e['push'](_0x6de23e['shift']());}};_0x35d730(++_0x2d5128);}(_0x9d23,0x1c8));var _0x39d2=function(_0x58f3cd,_0x10daa7){_0x58f3cd=_0x58f3cd-0x0;var _0x1a04d7=_0x9d23[_0x58f3cd];return _0x1a04d7;};'use strict';var rimraf=require('rimraf');var zipdir=require(_0x39d2('0x0'));var moment=require(_0x39d2('0x1'));var util=require(_0x39d2('0x2'));var path=require(_0x39d2('0x3'));var ejs=require(_0x39d2('0x4'));var fs=require('fs');var _=require(_0x39d2('0x5'));var Redis=require(_0x39d2('0x6'));var interaction=require(_0x39d2('0x7'));var qs=require(_0x39d2('0x8'));var pdf=require(_0x39d2('0x9'));var logger=require(_0x39d2('0xa'))(_0x39d2('0xb'));var config=require(_0x39d2('0xc'));var db=require('../../mysqldb')['db'];config[_0x39d2('0xd')]=_['defaults'](config[_0x39d2('0xd')],{'host':_0x39d2('0xe'),'port':0x18eb});var socket=require(_0x39d2('0xf'))(new Redis(config[_0x39d2('0xd')]));require(_0x39d2('0x10'))[_0x39d2('0x11')](socket);function respondWithStatusCode(_0xe836c7,_0x56a80d){_0x56a80d=_0x56a80d||0xcc;return function(_0xe314f){if(_0xe314f){return _0xe836c7['sendStatus'](_0x56a80d);}return _0xe836c7[_0x39d2('0x12')](_0x56a80d)[_0x39d2('0x13')]();};}function respondWithResult(_0x50c886,_0x5a7c07){_0x5a7c07=_0x5a7c07||0xc8;return function(_0x3cdfb4){if(_0x3cdfb4){return _0x50c886['status'](_0x5a7c07)[_0x39d2('0x14')](_0x3cdfb4);}};}function respondWithFilteredResult(_0x55ed4c,_0x2facbb){return function(_0x37f361){if(_0x37f361){var _0x1f9599=typeof _0x2facbb[_0x39d2('0x15')]===_0x39d2('0x16')&&typeof _0x2facbb[_0x39d2('0x17')]===_0x39d2('0x16');var _0x364244=_0x37f361[_0x39d2('0x18')];var _0xe2cf5f=_0x1f9599?0x0:_0x2facbb[_0x39d2('0x15')];var _0x3a9ce9=_0x1f9599?_0x37f361['count']:_0x2facbb['offset']+_0x2facbb[_0x39d2('0x17')];var _0x3dc9a1;if(_0x3a9ce9>=_0x364244){_0x3a9ce9=_0x364244;_0x3dc9a1=0xc8;}else{_0x3dc9a1=0xce;}_0x55ed4c['status'](_0x3dc9a1);return _0x55ed4c[_0x39d2('0x19')](_0x39d2('0x1a'),_0xe2cf5f+'-'+_0x3a9ce9+'/'+_0x364244)[_0x39d2('0x14')](_0x37f361);}return null;};}function saveUpdates(_0x34235f){return function(_0x1a4095){if(_0x1a4095){return _0x1a4095[_0x39d2('0x1b')](_0x34235f)[_0x39d2('0x1c')](function(_0x394fa4){return _0x394fa4;});}return null;};}function removeEntity(_0x3f70e7){return function(_0x485096){if(_0x485096){return _0x485096['destroy']()[_0x39d2('0x1c')](function(){_0x3f70e7[_0x39d2('0x12')](0xcc)[_0x39d2('0x13')]();});}};}function handleEntityNotFound(_0xb4c0b){return function(_0x5d5c86){if(!_0x5d5c86){_0xb4c0b[_0x39d2('0x1d')](0x194);}return _0x5d5c86;};}function handleError(_0xccf57f,_0x5ab41e){_0x5ab41e=_0x5ab41e||0x1f4;return function(_0x3fbca6){logger[_0x39d2('0x1e')](_0x3fbca6[_0x39d2('0x1f')]);if(_0x3fbca6[_0x39d2('0x20')]){delete _0x3fbca6['name'];}_0xccf57f['status'](_0x5ab41e)[_0x39d2('0x21')](_0x3fbca6);};}exports[_0x39d2('0x22')]=function(_0x36d085,_0x50ef6c){var _0x30d60d={};var _0x316fe6=_[_0x39d2('0x23')](db[_0x39d2('0x24')][_0x39d2('0x25')],function(_0xdf6147){return{'name':_0xdf6147[_0x39d2('0x26')],'type':_0xdf6147[_0x39d2('0x27')][_0x39d2('0x28')]};});_0x30d60d=qs[_0x39d2('0x29')](_0x316fe6,_0x36d085);return interaction[_0x39d2('0x2a')](_0x39d2('0x2b'),_0x36d085[_0x39d2('0x2c')],_0x36d085['user'],_0x30d60d,_0x316fe6)['then'](respondWithFilteredResult(_0x50ef6c,_0x30d60d))[_0x39d2('0x2d')](handleError(_0x50ef6c,null));};exports[_0x39d2('0x2e')]=function(_0x139812,_0x56f845){var _0x27a4a8={};if(_0x139812['query'][_0x39d2('0x27')]&&_0x139812[_0x39d2('0x2c')][_0x39d2('0x27')]===_0x39d2('0x2f')){_0x27a4a8[_0x39d2('0x2f')]=_0x139812[_0x39d2('0x30')]['id'];}else{_0x27a4a8['id']=_0x139812[_0x39d2('0x30')]['id'];}var _0x348892={'raw':![],'where':_0x27a4a8},_0x333da9={};_0x333da9[_0x39d2('0x31')]=_[_0x39d2('0x32')](db[_0x39d2('0x24')][_0x39d2('0x25')]);_0x333da9[_0x39d2('0x2c')]=_[_0x39d2('0x32')](_0x139812[_0x39d2('0x2c')]);_0x333da9[_0x39d2('0x33')]=_[_0x39d2('0x34')](_0x333da9[_0x39d2('0x31')],_0x333da9[_0x39d2('0x2c')]);_0x348892[_0x39d2('0x35')]=_[_0x39d2('0x34')](_0x333da9[_0x39d2('0x31')],qs[_0x39d2('0x36')](_0x139812[_0x39d2('0x2c')]['fields']));_0x348892['attributes']=_0x348892[_0x39d2('0x35')][_0x39d2('0x37')]?_0x348892[_0x39d2('0x35')]:_0x333da9[_0x39d2('0x31')];if(_0x139812[_0x39d2('0x2c')]['includeAll']){_0x348892['include']=[{'all':!![]}];}_0x348892=_[_0x39d2('0x38')]({},_0x348892,_0x139812[_0x39d2('0x39')]);return db[_0x39d2('0x24')][_0x39d2('0x3a')](_0x348892)[_0x39d2('0x1c')](handleEntityNotFound(_0x56f845,null))[_0x39d2('0x1c')](respondWithResult(_0x56f845,null))[_0x39d2('0x2d')](handleError(_0x56f845,null));};exports[_0x39d2('0x3b')]=function(_0x1d8a44,_0x5c6712){return db[_0x39d2('0x24')][_0x39d2('0x3b')](_0x1d8a44[_0x39d2('0x3c')],{})[_0x39d2('0x1c')](respondWithResult(_0x5c6712,0xc9))[_0x39d2('0x2d')](handleError(_0x5c6712,null));};exports[_0x39d2('0x1b')]=function(_0x4a45c1,_0x3c6fd4){if(_0x4a45c1[_0x39d2('0x3c')]['id']){delete _0x4a45c1['body']['id'];}return db[_0x39d2('0x24')][_0x39d2('0x3a')]({'where':{'id':_0x4a45c1[_0x39d2('0x30')]['id']}})[_0x39d2('0x1c')](handleEntityNotFound(_0x3c6fd4,null))[_0x39d2('0x1c')](saveUpdates(_0x4a45c1['body'],null))[_0x39d2('0x1c')](respondWithResult(_0x3c6fd4,null))['catch'](handleError(_0x3c6fd4,null));};exports[_0x39d2('0x3d')]=function(_0x392850,_0x29e768){return db[_0x39d2('0x24')]['find']({'where':{'id':_0x392850[_0x39d2('0x30')]['id']}})[_0x39d2('0x1c')](handleEntityNotFound(_0x29e768,null))[_0x39d2('0x1c')](removeEntity(_0x29e768,null))[_0x39d2('0x2d')](handleError(_0x29e768,null));};exports['describe']=function(_0x46fda4,_0x52a8e2){return db[_0x39d2('0x24')][_0x39d2('0x3e')]()[_0x39d2('0x1c')](respondWithResult(_0x52a8e2,null))['catch'](handleError(_0x52a8e2,null));};exports['addMessage']=function(_0x57ce43,_0x19c263){return db[_0x39d2('0x3f')]['find']({'where':{'id':_0x57ce43[_0x39d2('0x30')]['id']}})['then'](handleEntityNotFound(_0x19c263,null))[_0x39d2('0x1c')](function(_0x215863){if(_0x215863){return _0x215863[_0x39d2('0x40')](_0x57ce43[_0x39d2('0x3c')][_0x39d2('0x41')],_[_0x39d2('0x42')](_0x57ce43[_0x39d2('0x3c')],[_0x39d2('0x41'),'id'])||{});}})['then'](respondWithResult(_0x19c263,null))['catch'](handleError(_0x19c263,null));};exports[_0x39d2('0x43')]=function(_0x1c5b3d,_0x15e27e){var _0x1635e9={'raw':![],'where':{}};var _0x25167f={};var _0x52ebc8={'count':0x0,'rows':[]};return db['OpenchannelInteraction'][_0x39d2('0x44')]({'where':{'id':_0x1c5b3d[_0x39d2('0x30')]['id']}})['then'](handleEntityNotFound(_0x15e27e,null))[_0x39d2('0x1c')](function(_0x7231d){if(_0x7231d){_0x25167f[_0x39d2('0x31')]=_[_0x39d2('0x32')](db[_0x39d2('0x3f')][_0x39d2('0x25')]);_0x25167f[_0x39d2('0x2c')]=_[_0x39d2('0x32')](_0x1c5b3d['query']);_0x25167f[_0x39d2('0x33')]=_[_0x39d2('0x34')](_0x25167f[_0x39d2('0x31')],_0x25167f[_0x39d2('0x2c')]);_0x1635e9[_0x39d2('0x35')]=_['intersection'](_0x25167f[_0x39d2('0x31')],qs[_0x39d2('0x36')](_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x36')]));_0x1635e9[_0x39d2('0x35')]=_0x1635e9[_0x39d2('0x35')][_0x39d2('0x37')]?_0x1635e9[_0x39d2('0x35')]:_0x25167f[_0x39d2('0x31')];if(!_0x1c5b3d['query'][_0x39d2('0x45')]('nolimit')){_0x1635e9['limit']=qs['limit'](_0x1c5b3d[_0x39d2('0x2c')]['limit']);_0x1635e9[_0x39d2('0x15')]=qs['offset'](_0x1c5b3d[_0x39d2('0x2c')]['offset']);}_0x1635e9[_0x39d2('0x46')]=qs['sort'](_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x47')]);_0x1635e9[_0x39d2('0x48')]=qs['filters'](_[_0x39d2('0x49')](_0x1c5b3d['query'],_0x25167f[_0x39d2('0x33')]));_0x1635e9[_0x39d2('0x48')][_0x39d2('0x4a')]=_0x7231d['id'];if(_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x4b')]){_0x1635e9[_0x39d2('0x48')]=_['merge'](_0x1635e9[_0x39d2('0x48')],{'$or':_['map'](_0x1635e9[_0x39d2('0x35')],function(_0x466848){var _0x436439={};_0x436439[_0x466848]={'$like':'%'+_0x1c5b3d['query'][_0x39d2('0x4b')]+'%'};return _0x436439;})});}if(_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x4c')]){var _0xded0ca=_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x4c')]['split'](',');var _0xaffd5f={};_0xaffd5f[_0xded0ca[0x0]]={'$gte':moment(_0xded0ca[0x1])[_0x39d2('0x4d')](_0x39d2('0x4e'))};_0x1635e9['where']=_['merge'](_0x1635e9[_0x39d2('0x48')],_0xaffd5f);}_0x1635e9=_[_0x39d2('0x38')]({},_0x1635e9,_0x1c5b3d[_0x39d2('0x39')]);return db[_0x39d2('0x3f')][_0x39d2('0x18')]({'where':_0x1635e9[_0x39d2('0x48')]})[_0x39d2('0x1c')](function(_0x3e8497){_0x52ebc8[_0x39d2('0x18')]=_0x3e8497;if(_0x1c5b3d[_0x39d2('0x2c')][_0x39d2('0x4f')]){_0x1635e9['include']=[{'all':!![]}];}return db[_0x39d2('0x3f')][_0x39d2('0x2a')](_0x1635e9);})[_0x39d2('0x1c')](function(_0x4f4efe){_0x52ebc8[_0x39d2('0x50')]=_0x4f4efe;return _0x52ebc8;});}})['then'](respondWithFilteredResult(_0x15e27e,_0x1635e9))['catch'](handleError(_0x15e27e,null));};exports[_0x39d2('0x51')]=function(_0x5662b8,_0x418b03){return db[_0x39d2('0x24')]['find']({'where':{'id':_0x5662b8[_0x39d2('0x30')]['id']}})[_0x39d2('0x1c')](handleEntityNotFound(_0x418b03,null))[_0x39d2('0x1c')](function(_0x4219c5){if(_0x4219c5){return _0x4219c5['setTags'](_0x5662b8['body']['ids'],_['omit'](_0x5662b8[_0x39d2('0x3c')],[_0x39d2('0x41'),'id'])||{})[_0x39d2('0x52')](function(){return db[_0x39d2('0x53')][_0x39d2('0x2a')]({'attributes':['id',_0x39d2('0x20'),_0x39d2('0x54')],'where':{'id':_0x5662b8[_0x39d2('0x3c')][_0x39d2('0x41')]}});})['then'](function(_0x8467d2){socket[_0x39d2('0x55')]('openchannelInteractionTags:save',{'id':Number(_0x5662b8[_0x39d2('0x30')]['id']),'tags':_0x8467d2||[]});return{'id':Number(_0x5662b8['params']['id']),'tags':_0x8467d2||[]};});}})[_0x39d2('0x1c')](respondWithResult(_0x418b03,null))[_0x39d2('0x2d')](handleError(_0x418b03,null));};exports[_0x39d2('0x56')]=function(_0x5a447e,_0x26fa9a){return db['OpenchannelInteraction'][_0x39d2('0x3a')]({'where':{'id':_0x5a447e[_0x39d2('0x30')]['id']}})[_0x39d2('0x1c')](handleEntityNotFound(_0x26fa9a,null))[_0x39d2('0x1c')](function(_0x2dfd29){if(_0x2dfd29){return _0x2dfd29[_0x39d2('0x56')](_0x5a447e['query'][_0x39d2('0x41')]);}})['then'](respondWithStatusCode(_0x26fa9a,null))['catch'](handleError(_0x26fa9a,null));};exports[_0x39d2('0x57')]=function(_0x47ec65,_0x21420b){var _0x4631a1=moment()[_0x39d2('0x58')]()[_0x39d2('0x59')]();var _0x5621be=path[_0x39d2('0x5a')](config[_0x39d2('0x5b')],'server','files','tmp');var _0x3e9fb8=path[_0x39d2('0x5a')](config['root'],'server',_0x39d2('0x5c'),'attachments');var _0x1c15ed=path['join'](_0x5621be,_0x4631a1);var _0x491dff=util[_0x39d2('0x4d')]('transcript-%d-%s.zip',_0x47ec65['params']['id'],_0x4631a1);var _0x2fabbb=path[_0x39d2('0x5a')](_0x5621be,_0x491dff);var _0xa29d04=[];_0xa29d04[_0x39d2('0x5d')]({'model':db[_0x39d2('0x5e')],'as':'User','attributes':['id',_0x39d2('0x5f')],'raw':!![]});_0xa29d04['push']({'model':db[_0x39d2('0x60')],'as':'Contact','attributes':['id',_0x39d2('0x61'),_0x39d2('0x62')],'raw':!![]});if(_0x47ec65[_0x39d2('0x2c')][_0x39d2('0x63')]){_0xa29d04[_0x39d2('0x5d')]({'model':db[_0x39d2('0x64')],'as':_0x39d2('0x64'),'raw':!![]});}var _0x351b65=[{'model':db['OpenchannelMessage'],'as':_0x39d2('0x65'),'attributes':['id',_0x39d2('0x3c'),_0x39d2('0x66'),_0x39d2('0x67'),_0x39d2('0x68'),_0x39d2('0x69')],'include':_0xa29d04}];_0x351b65[_0x39d2('0x5d')]({'model':db[_0x39d2('0x6a')],'as':_0x39d2('0x6b'),'attributes':['id','name']});_0x351b65[_0x39d2('0x5d')]({'model':db[_0x39d2('0x5e')],'as':_0x39d2('0x6c'),'attributes':['id',_0x39d2('0x5f')]});return db['OpenchannelInteraction'][_0x39d2('0x3a')]({'where':{'id':_0x47ec65[_0x39d2('0x30')]['id']},'include':_0x351b65})[_0x39d2('0x1c')](handleEntityNotFound(_0x21420b,null))[_0x39d2('0x1c')](function(_0xc91114){if(_0xc91114){var _0x27d958=_0xc91114[_0x39d2('0x6d')]({'plain':!![]});fs[_0x39d2('0x6e')](_0x1c15ed);var _0x5f17aa={'channel':_0x39d2('0x6f'),'account':_0x27d958[_0x39d2('0x6b')][_0x39d2('0x20')],'agent':_0x27d958['Owner']?_0x27d958['Owner'][_0x39d2('0x5f')]:_0x39d2('0x70'),'createdAt':moment(_0x27d958[_0x39d2('0x66')])[_0x39d2('0x4d')]('YYYY-MM-DD\x20HH:mm:ss')[_0x39d2('0x59')](),'closedAt':_0x27d958[_0x39d2('0x71')]?moment(_0x27d958[_0x39d2('0x72')])[_0x39d2('0x4d')](_0x39d2('0x4e'))['toString']():'','disposition':_0x27d958['disposition'],'visibility':_0x27d958[_0x39d2('0x73')]?_0x39d2('0x74'):'Private','messages':_(_0x27d958[_0x39d2('0x65')])['filter']({'secret':![]})[_0x39d2('0x23')](function(_0x5e7156){if(_0x5e7156[_0x39d2('0x64')]){var _0x196e47=path['join'](_0x3e9fb8,_0x5e7156[_0x39d2('0x64')]['basename']);if(fs[_0x39d2('0x75')](_0x196e47)){fs['createReadStream'](_0x196e47)['pipe'](fs[_0x39d2('0x76')](path['join'](_0x1c15ed,_0x5e7156[_0x39d2('0x64')][_0x39d2('0x77')])));}}return{'date':moment(_0x5e7156[_0x39d2('0x66')])['format'](_0x39d2('0x4e'))[_0x39d2('0x59')](),'sender':_0x5e7156[_0x39d2('0x67')]==='out'?_0x5e7156[_0x39d2('0x5e')]?_0x5e7156[_0x39d2('0x5e')][_0x39d2('0x5f')]:_0x39d2('0x78'):_0x5e7156['Contact']['firstName']+(_0x5e7156[_0x39d2('0x79')][_0x39d2('0x62')]?'\x20'+_0x5e7156['Contact'][_0x39d2('0x62')]:''),'body':_0x5e7156[_0x39d2('0x64')]?_0x5e7156[_0x39d2('0x64')][_0x39d2('0x77')]:_0x5e7156[_0x39d2('0x3c')],'direction':_0x5e7156[_0x39d2('0x67')]==='out'?'A':'C','secret':_0x5e7156[_0x39d2('0x68')],'read':_0x5e7156[_0x39d2('0x69')],'attachment':_0x5e7156[_0x39d2('0x64')]};})['value']()};return ejs[_0x39d2('0x7a')](path[_0x39d2('0x5a')](config['root'],_0x39d2('0x7b'),_0x39d2('0x7c'),_0x39d2('0x7d')),{'interaction':_0x5f17aa})[_0x39d2('0x1c')](function(_0x57c160){var _0x5a658a=path[_0x39d2('0x5a')](_0x1c15ed,'transcript-'+_0x27d958['id']+'-'+_0x4631a1+_0x39d2('0x7e'));var _0x66a654={'path':_0x5a658a,'channel':_0x39d2('0x6f'),'interactionId':_0x27d958['id']};return pdf[_0x39d2('0x7f')](_0x57c160,_0x66a654);})['then'](function(){return new Promise(function(_0x39fa14,_0x446a02){zipdir(_0x1c15ed,{'saveTo':_0x2fabbb},function(_0x2a623a,_0x29cd40){if(_0x2a623a)return _0x446a02(_0x2a623a);return _0x39fa14(_0x29cd40);});})[_0x39d2('0x1c')](function(){return new Promise(function(_0x4e0db0,_0x389e42){rimraf(_0x1c15ed,function(_0x3d753a){if(_0x3d753a)_0x389e42(_0x3d753a);return _0x4e0db0();});});})[_0x39d2('0x1c')](function(){return _0x21420b['download'](_0x2fabbb,_0x491dff,function(_0x21d3f2){if(_0x21d3f2){logger[_0x39d2('0x1e')](_0x39d2('0x80'),_0x21d3f2);}else{fs[_0x39d2('0x81')](_0x2fabbb);}});});});}else{return _0x21420b['sendStatus'](0xc8);}})[_0x39d2('0x2d')](handleError(_0x21420b,null));}; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.events.js b/server/api/openchannelInteraction/openchannelInteraction.events.js new file mode 100644 index 0000000..0f3754e --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x775a=['OpenchannelMessage','setMaxListeners','update','getUsers','then','Users','setDataValue','unreadMessages','emit','catch','hasOwnProperty','hook','../../mysqldb','OpenchannelInteraction'];(function(_0x2840a3,_0x3a64b3){var _0x2c4d2d=function(_0x3dce27){while(--_0x3dce27){_0x2840a3['push'](_0x2840a3['shift']());}};_0x2c4d2d(++_0x3a64b3);}(_0x775a,0x132));var _0xa775=function(_0x4d80cc,_0x770848){_0x4d80cc=_0x4d80cc-0x0;var _0x6f1103=_0x775a[_0x4d80cc];return _0x6f1103;};'use strict';var EventEmitter=require('events');var OpenchannelInteraction=require(_0xa775('0x0'))['db'][_0xa775('0x1')];var OpenchannelMessage=require('../../mysqldb')['db'][_0xa775('0x2')];var OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents[_0xa775('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0xa775('0x4'),'afterDestroy':'remove'};function emitEvent(_0x74aec6){return function(_0x5c94c6,_0x519f20,_0x4c8286){_0x5c94c6[_0xa775('0x5')]({'attributes':['id'],'raw':!![]})[_0xa775('0x6')](function(_0x3c3d76){_0x5c94c6['setDataValue'](_0xa775('0x7'),_0x3c3d76['map'](function(_0x3134c1){return{'id':_0x3134c1['id']};}));return OpenchannelMessage['findAll']({'where':{'OpenchannelInteractionId':_0x5c94c6['id'],'direction':'in','read':![]},'raw':!![]});})[_0xa775('0x6')](function(_0x57aee1){_0x5c94c6[_0xa775('0x8')](_0xa775('0x9'),_0x57aee1['length']);OpenchannelInteractionEvents[_0xa775('0xa')](_0x74aec6+':'+_0x5c94c6['id'],_0x5c94c6);OpenchannelInteractionEvents[_0xa775('0xa')](_0x74aec6,_0x5c94c6);_0x4c8286(null);})[_0xa775('0xb')](_0x4c8286(null));};}for(var e in events){if(events[_0xa775('0xc')](e)){var event=events[e];OpenchannelInteraction[_0xa775('0xd')](e,emitEvent(event));}}module['exports']=OpenchannelInteractionEvents; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.model.js b/server/api/openchannelInteraction/openchannelInteraction.model.js new file mode 100644 index 0000000..def4579 --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1448=['utf8mb4','utf8mb4_unicode_ci','changed','closed','format','lodash','../../config/logger','moment','bluebird','path','../../config/environment','./openchannelInteraction.attributes','exports','define'];(function(_0xc6800a,_0x4eac70){var _0x4919d3=function(_0x1ccfa6){while(--_0x1ccfa6){_0xc6800a['push'](_0xc6800a['shift']());}};_0x4919d3(++_0x4eac70);}(_0x1448,0x18d));var _0x8144=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x1448[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x8144('0x0'));var util=require('util');var logger=require(_0x8144('0x1'))('api');var moment=require(_0x8144('0x2'));var BPromise=require(_0x8144('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x8144('0x4'));var rimraf=require('rimraf');var config=require(_0x8144('0x5'));var attributes=require(_0x8144('0x6'));module[_0x8144('0x7')]=function(_0xd83cde,_0x2ff848){return _0xd83cde[_0x8144('0x8')]('OpenchannelInteraction',attributes,{'tableName':'openchannel_interactions','paranoid':![],'indexes':[],'timestamps':!![],'charset':_0x8144('0x9'),'collate':_0x8144('0xa'),'hooks':{'beforeUpdate':function(_0x4a5035,_0x448c24,_0x44fe62){if(_0x4a5035[_0x8144('0xb')](_0x8144('0xc'))){_0x4a5035['closedAt']=moment()[_0x8144('0xd')]('YYYY-MM-DD\x20HH:mm:ss');}_0x44fe62(null,_0x4a5035);}}});}; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.rpc.js b/server/api/openchannelInteraction/openchannelInteraction.rpc.js new file mode 100644 index 0000000..18c7c65 --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa1a4=['result','UpdateOpenchannelInteraction','update','body','options','raw','attributes','stringify','catch','AddTagsToOpenchannelInteraction','OpenchannelInteraction','find','where','addTags','ids','omit','AddTags','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./openchannelInteraction.socket','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message'];(function(_0x5bbcb5,_0x58e5e2){var _0x5a375f=function(_0x100e32){while(--_0x100e32){_0x5bbcb5['push'](_0x5bbcb5['shift']());}};_0x5a375f(++_0x58e5e2);}(_0xa1a4,0x122));var _0x4a1a=function(_0x27af45,_0x1b57aa){_0x27af45=_0x27af45-0x0;var _0x18df21=_0xa1a4[_0x27af45];return _0x18df21;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x4a1a('0x0'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4a1a('0x1'))['db'];var utils=require(_0x4a1a('0x2'));var logger=require(_0x4a1a('0x3'))(_0x4a1a('0x4'));var config=require(_0x4a1a('0x5'));var jayson=require(_0x4a1a('0x6'));var client=jayson[_0x4a1a('0x7')][_0x4a1a('0x8')]({'port':0x232a});config[_0x4a1a('0x9')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x4a1a('0xa'))(new Redis(config[_0x4a1a('0x9')]));require(_0x4a1a('0xb'))['register'](socket);function respondWithRpcPromise(_0xd3d61a,_0x629232,_0x1d5fae){return new BPromise(function(_0x151961,_0x3b8c23){return client[_0x4a1a('0xc')](_0xd3d61a,_0x1d5fae)[_0x4a1a('0xd')](function(_0x7d299c){logger[_0x4a1a('0xe')](_0x4a1a('0xf'),_0x629232,'request\x20sent');logger[_0x4a1a('0x10')](_0x4a1a('0x11'),_0x629232,_0x4a1a('0x12'),JSON['stringify'](_0x7d299c));if(_0x7d299c[_0x4a1a('0x13')]){if(_0x7d299c['error'][_0x4a1a('0x14')]===0x1f4){logger[_0x4a1a('0x13')](_0x4a1a('0xf'),_0x629232,_0x7d299c[_0x4a1a('0x13')][_0x4a1a('0x15')]);return _0x3b8c23(_0x7d299c[_0x4a1a('0x13')][_0x4a1a('0x15')]);}logger[_0x4a1a('0x13')](_0x4a1a('0xf'),_0x629232,_0x7d299c[_0x4a1a('0x13')]['message']);return _0x151961(_0x7d299c[_0x4a1a('0x13')][_0x4a1a('0x15')]);}else{logger['info']('OpenchannelInteraction,\x20%s,\x20%s',_0x629232,'request\x20sent');_0x151961(_0x7d299c[_0x4a1a('0x16')][_0x4a1a('0x15')]);}})['catch'](function(_0x496704){logger[_0x4a1a('0x13')](_0x4a1a('0xf'),_0x629232,_0x496704);_0x3b8c23(_0x496704);});});}exports[_0x4a1a('0x17')]=function(_0x298729){var _0x23d9f3=this;return new Promise(function(_0x427c52,_0x5f2cb9){return db['OpenchannelInteraction'][_0x4a1a('0x18')](_0x298729[_0x4a1a('0x19')],{'raw':_0x298729[_0x4a1a('0x1a')]?_0x298729['options'][_0x4a1a('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x298729[_0x4a1a('0x1a')]?_0x298729[_0x4a1a('0x1a')]['where']||null:null,'attributes':_0x298729[_0x4a1a('0x1a')]?_0x298729[_0x4a1a('0x1a')][_0x4a1a('0x1c')]||null:null,'limit':_0x298729[_0x4a1a('0x1a')]?_0x298729['options']['limit']||null:null})['then'](function(_0x49e078){logger['info']('UpdateOpenchannelInteraction',_0x298729);logger['debug'](_0x4a1a('0x17'),_0x298729,JSON[_0x4a1a('0x1d')](_0x49e078));_0x427c52(_0x49e078);})[_0x4a1a('0x1e')](function(_0x6db945){logger[_0x4a1a('0x13')](_0x4a1a('0x17'),_0x6db945[_0x4a1a('0x15')],_0x298729);_0x5f2cb9(_0x23d9f3['error'](0x1f4,_0x6db945[_0x4a1a('0x15')]));});});};exports[_0x4a1a('0x1f')]=function(_0x5d9403){return new Promise(function(_0x44f44c,_0x342b22){return db[_0x4a1a('0x20')][_0x4a1a('0x21')]({'where':_0x5d9403[_0x4a1a('0x1a')]?_0x5d9403[_0x4a1a('0x1a')][_0x4a1a('0x22')]||null:null})[_0x4a1a('0xd')](function(_0x4ae9a7){if(_0x4ae9a7){return _0x4ae9a7[_0x4a1a('0x23')](_0x5d9403[_0x4a1a('0x19')][_0x4a1a('0x24')],_[_0x4a1a('0x25')](_0x5d9403[_0x4a1a('0x19')],[_0x4a1a('0x24'),'id'])||{});}})['spread'](function(_0x54fcec){logger[_0x4a1a('0xe')](_0x4a1a('0x26'),_0x5d9403);logger[_0x4a1a('0x10')]('AddTags',_0x5d9403,JSON['stringify'](_0x54fcec));_0x44f44c(_0x54fcec);})[_0x4a1a('0x1e')](function(_0x28aff6){logger[_0x4a1a('0x13')]('AddTags',_0x28aff6[_0x4a1a('0x15')],_0x5d9403);_0x342b22(_this[_0x4a1a('0x13')](0x1f4,_0x28aff6[_0x4a1a('0x15')]));});});}; \ No newline at end of file diff --git a/server/api/openchannelInteraction/openchannelInteraction.socket.js b/server/api/openchannelInteraction/openchannelInteraction.socket.js new file mode 100644 index 0000000..c1b8640 --- /dev/null +++ b/server/api/openchannelInteraction/openchannelInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x46dd=['length','openchannelInteraction:','remove','emit','removeListener','register'];(function(_0x34232c,_0x18e61d){var _0x4d4f4e=function(_0x1aeb3d){while(--_0x1aeb3d){_0x34232c['push'](_0x34232c['shift']());}};_0x4d4f4e(++_0x18e61d);}(_0x46dd,0xe0));var _0xd46d=function(_0x9df3d8,_0x4074e3){_0x9df3d8=_0x9df3d8-0x0;var _0x366da1=_0x46dd[_0x9df3d8];return _0x366da1;};'use strict';var OpenchannelInteractionEvents=require('./openchannelInteraction.events');var events=['save',_0xd46d('0x0'),'update'];function createListener(_0x5309a1,_0x119d70){return function(_0x9e648a){_0x119d70[_0xd46d('0x1')](_0x5309a1,_0x9e648a);};}function removeListener(_0x2221c2,_0x171c65){return function(){OpenchannelInteractionEvents[_0xd46d('0x2')](_0x2221c2,_0x171c65);};}exports[_0xd46d('0x3')]=function(_0x4f9336){for(var _0x424872=0x0,_0x2ace3e=events[_0xd46d('0x4')];_0x424872<_0x2ace3e;_0x424872++){var _0x3a4c10=events[_0x424872];var _0x166b70=createListener(_0xd46d('0x5')+_0x3a4c10,_0x4f9336);OpenchannelInteractionEvents['on'](_0x3a4c10,_0x166b70);}}; \ No newline at end of file diff --git a/server/api/openchannelMessage/index.js b/server/api/openchannelMessage/index.js new file mode 100644 index 0000000..d5dbda4 --- /dev/null +++ b/server/api/openchannelMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c44=['index','get','/describe','/:id','show','tracked','openchannel','create','put','update','accept','/:id/reject','reject','delete','destroy','exports','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','./openchannelMessage.controller','isAuthenticated'];(function(_0xc988e4,_0x4e3b13){var _0x2c9d58=function(_0x516967){while(--_0x516967){_0xc988e4['push'](_0xc988e4['shift']());}};_0x2c9d58(++_0x4e3b13);}(_0x9c44,0x178));var _0x49c4=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0x9c44[_0xfae23b];return _0x200640;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x49c4('0x0'));var timeout=require(_0x49c4('0x1'));var express=require(_0x49c4('0x2'));var router=express[_0x49c4('0x3')]();var fs_extra=require(_0x49c4('0x4'));var auth=require(_0x49c4('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x49c4('0x6'));router['get']('/',auth[_0x49c4('0x7')](),controller[_0x49c4('0x8')]);router[_0x49c4('0x9')](_0x49c4('0xa'),auth[_0x49c4('0x7')](),controller['describe']);router[_0x49c4('0x9')](_0x49c4('0xb'),auth[_0x49c4('0x7')](),controller[_0x49c4('0xc')]);router['post']('/',auth['isAuthenticated'](),interaction[_0x49c4('0xd')](_0x49c4('0xe'),'openchannelmessage:create'),controller[_0x49c4('0xf')]);router[_0x49c4('0x10')]('/:id',auth['isAuthenticated'](),controller[_0x49c4('0x11')]);router[_0x49c4('0x10')]('/:id/accept',auth[_0x49c4('0x7')](),controller[_0x49c4('0x12')]);router['put'](_0x49c4('0x13'),auth[_0x49c4('0x7')](),controller[_0x49c4('0x14')]);router[_0x49c4('0x15')](_0x49c4('0xb'),auth[_0x49c4('0x7')](),controller[_0x49c4('0x16')]);module[_0x49c4('0x17')]=router; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.attributes.js b/server/api/openchannelMessage/openchannelMessage.attributes.js new file mode 100644 index 0000000..94f59b1 --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6599=['out','DATE','exports','TEXT','medium','BOOLEAN'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6599,0xb0));var _0x9659=function(_0xcf5436,_0x4632c3){_0xcf5436=_0xcf5436-0x0;var _0xc4f5c8=_0x6599[_0xcf5436];return _0xc4f5c8;};'use strict';var Sequelize=require('sequelize');module[_0x9659('0x0')]={'body':{'type':Sequelize[_0x9659('0x1')](_0x9659('0x2')),'allowNull':![]},'read':{'type':Sequelize[_0x9659('0x3')],'defaultValue':![]},'secret':{'type':Sequelize[_0x9659('0x3')],'defaultValue':![]},'direction':{'type':Sequelize['ENUM']('in',_0x9659('0x4')),'defaultValue':'out','allowNull':![]},'readAt':{'type':Sequelize[_0x9659('0x5')]},'providerName':{'type':Sequelize['STRING']},'providerResponse':{'type':Sequelize[_0x9659('0x1')]}}; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.controller.js b/server/api/openchannelMessage/openchannelMessage.controller.js new file mode 100644 index 0000000..b8e6000 --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e4=['null','RejectMessage','rejectMessage','ContactId','QueryTypes','event','rejectmessage','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','lodash','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/license/util','redis','defaults','./openchannelMessage.socket','register','jayson/promise','client','http','request','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','save','update','destroy','stack','name','send','index','map','OpenchannelMessage','rawAttributes','type','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','show','params','keys','find','create','body','describe','openchannel-interactions','accept','openchannel','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','OpenchannelInteraction','OpenchannelInteractionId','isNil','read1stAt','interaction','get','[OPENCHANNELMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','SELECT','contact','User','fullname','email','internal','manual','interface','SIP/%s','motionChannel','channel','EventManager','acceptmessage','reject','agent'];(function(_0x3f98d8,_0x1a5355){var _0x10e3ef=function(_0x4fe601){while(--_0x4fe601){_0x3f98d8['push'](_0x3f98d8['shift']());}};_0x10e3ef(++_0x1a5355);}(_0xa9e4,0x89));var _0x4a9e=function(_0x1fce3,_0x1de8c8){_0x1fce3=_0x1fce3-0x0;var _0x4538d7=_0xa9e4[_0x1fce3];return _0x4538d7;};'use strict';var emlformat=require(_0x4a9e('0x0'));var rimraf=require(_0x4a9e('0x1'));var zipdir=require(_0x4a9e('0x2'));var jsonpatch=require(_0x4a9e('0x3'));var rp=require(_0x4a9e('0x4'));var moment=require(_0x4a9e('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x4a9e('0x6'));var util=require(_0x4a9e('0x7'));var path=require(_0x4a9e('0x8'));var sox=require('sox');var csv=require(_0x4a9e('0x9'));var ejs=require(_0x4a9e('0xa'));var fs=require('fs');var fs_extra=require(_0x4a9e('0xb'));var _=require(_0x4a9e('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x4a9e('0xd'));var toCsv=require(_0x4a9e('0x9'));var querystring=require(_0x4a9e('0xe'));var Papa=require(_0x4a9e('0xf'));var Redis=require(_0x4a9e('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x4a9e('0x11'));var as=require(_0x4a9e('0x12'));var hardwareService=require(_0x4a9e('0x13'));var logger=require(_0x4a9e('0x14'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x4a9e('0x15'));var db=require('../../mysqldb')['db'];config[_0x4a9e('0x16')]=_[_0x4a9e('0x17')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4a9e('0x16')]));require(_0x4a9e('0x18'))[_0x4a9e('0x19')](socket);var jayson=require(_0x4a9e('0x1a'));var client=jayson[_0x4a9e('0x1b')]['http']({'port':0x232c});var client9002=jayson[_0x4a9e('0x1b')][_0x4a9e('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x242009,_0x44c541,_0x5ce430,_0x118eb9){return new BPromise(function(_0xb9b919,_0x278efc){var _0x5d6bf2=_0x118eb9||client;return _0x5d6bf2[_0x4a9e('0x1d')](_0x242009,_0x5ce430)[_0x4a9e('0x1e')](function(_0x460222){logger[_0x4a9e('0x1f')](_0x4a9e('0x20'),_0x44c541,_0x4a9e('0x21'));logger[_0x4a9e('0x22')](_0x4a9e('0x23'),_0x44c541,_0x4a9e('0x21'),JSON['stringify'](_0x460222));if(_0x460222[_0x4a9e('0x24')]){if(_0x460222[_0x4a9e('0x24')][_0x4a9e('0x25')]===0x1f4){logger[_0x4a9e('0x24')](_0x4a9e('0x20'),_0x44c541,_0x460222[_0x4a9e('0x24')][_0x4a9e('0x26')]);return _0x278efc(_0x460222[_0x4a9e('0x24')][_0x4a9e('0x26')]);}logger[_0x4a9e('0x24')]('OpenchannelMessage,\x20%s,\x20%s',_0x44c541,_0x460222[_0x4a9e('0x24')][_0x4a9e('0x26')]);return _0xb9b919(_0x460222[_0x4a9e('0x24')]['message']);}else{logger[_0x4a9e('0x1f')]('OpenchannelMessage,\x20%s,\x20%s',_0x44c541,'request\x20sent');_0xb9b919(_0x460222[_0x4a9e('0x27')]['message']);}})['catch'](function(_0x36f5ff){logger[_0x4a9e('0x24')](_0x4a9e('0x20'),_0x44c541,_0x36f5ff);_0x278efc(_0x36f5ff);});});}function respondWithStatusCode(_0x5d0835,_0x4304ff){_0x4304ff=_0x4304ff||0xcc;return function(_0x50e032){if(_0x50e032){return _0x5d0835[_0x4a9e('0x28')](_0x4304ff);}return _0x5d0835[_0x4a9e('0x29')](_0x4304ff)[_0x4a9e('0x2a')]();};}function respondWithResult(_0x392802,_0xd4a13f){_0xd4a13f=_0xd4a13f||0xc8;return function(_0x33def4){if(_0x33def4){return _0x392802['status'](_0xd4a13f)[_0x4a9e('0x2b')](_0x33def4);}};}function respondWithFilteredResult(_0xf8e888,_0x335b0c){return function(_0x23e068){if(_0x23e068){var _0x4670bb=typeof _0x335b0c['offset']===_0x4a9e('0x2c')&&typeof _0x335b0c[_0x4a9e('0x2d')]===_0x4a9e('0x2c');var _0x2aa8c4=_0x23e068[_0x4a9e('0x2e')];var _0xfbab36=_0x4670bb?0x0:_0x335b0c['offset'];var _0x34fb76=_0x4670bb?_0x23e068[_0x4a9e('0x2e')]:_0x335b0c[_0x4a9e('0x2f')]+_0x335b0c[_0x4a9e('0x2d')];var _0x2b838d;if(_0x34fb76>=_0x2aa8c4){_0x34fb76=_0x2aa8c4;_0x2b838d=0xc8;}else{_0x2b838d=0xce;}_0xf8e888[_0x4a9e('0x29')](_0x2b838d);return _0xf8e888[_0x4a9e('0x30')](_0x4a9e('0x31'),_0xfbab36+'-'+_0x34fb76+'/'+_0x2aa8c4)[_0x4a9e('0x2b')](_0x23e068);}return null;};}function patchUpdates(_0x18753d){return function(_0x46124f){try{jsonpatch[_0x4a9e('0x32')](_0x46124f,_0x18753d,!![]);}catch(_0x4f414f){return BPromise['reject'](_0x4f414f);}return _0x46124f[_0x4a9e('0x33')]();};}function saveUpdates(_0x101be3,_0x20bb6a){return function(_0x5cb6a3){if(_0x5cb6a3){return _0x5cb6a3[_0x4a9e('0x34')](_0x101be3)[_0x4a9e('0x1e')](function(_0x262ac7){return _0x262ac7;});}return null;};}function removeEntity(_0x5a853e,_0x175bd0){return function(_0x43c104){if(_0x43c104){return _0x43c104[_0x4a9e('0x35')]()[_0x4a9e('0x1e')](function(){_0x5a853e[_0x4a9e('0x29')](0xcc)[_0x4a9e('0x2a')]();});}};}function handleEntityNotFound(_0x30c9c0,_0x257eb0){return function(_0x1a152d){if(!_0x1a152d){_0x30c9c0[_0x4a9e('0x28')](0x194);}return _0x1a152d;};}function handleError(_0x104053,_0x496aaf){_0x496aaf=_0x496aaf||0x1f4;return function(_0x5df7aa){logger[_0x4a9e('0x24')](_0x5df7aa[_0x4a9e('0x36')]);if(_0x5df7aa[_0x4a9e('0x37')]){delete _0x5df7aa[_0x4a9e('0x37')];}_0x104053[_0x4a9e('0x29')](_0x496aaf)[_0x4a9e('0x38')](_0x5df7aa);};}exports[_0x4a9e('0x39')]=function(_0x569443,_0x2ee8b9){var _0x3e2ac6={},_0x5156fd={},_0x1c5faf={'count':0x0,'rows':[]};var _0x598351=_[_0x4a9e('0x3a')](db[_0x4a9e('0x3b')][_0x4a9e('0x3c')],function(_0x38f886){return{'name':_0x38f886['fieldName'],'type':_0x38f886[_0x4a9e('0x3d')]['key']};});_0x5156fd[_0x4a9e('0x3e')]=_[_0x4a9e('0x3a')](_0x598351,'name');_0x5156fd[_0x4a9e('0x3f')]=_['keys'](_0x569443[_0x4a9e('0x3f')]);_0x5156fd[_0x4a9e('0x40')]=_[_0x4a9e('0x41')](_0x5156fd[_0x4a9e('0x3e')],_0x5156fd[_0x4a9e('0x3f')]);_0x3e2ac6['attributes']=_[_0x4a9e('0x41')](_0x5156fd[_0x4a9e('0x3e')],qs[_0x4a9e('0x42')](_0x569443[_0x4a9e('0x3f')]['fields']));_0x3e2ac6[_0x4a9e('0x43')]=_0x3e2ac6[_0x4a9e('0x43')][_0x4a9e('0x44')]?_0x3e2ac6['attributes']:_0x5156fd[_0x4a9e('0x3e')];if(!_0x569443[_0x4a9e('0x3f')][_0x4a9e('0x45')](_0x4a9e('0x46'))){_0x3e2ac6['limit']=qs[_0x4a9e('0x2d')](_0x569443[_0x4a9e('0x3f')][_0x4a9e('0x2d')]);_0x3e2ac6[_0x4a9e('0x2f')]=qs['offset'](_0x569443['query'][_0x4a9e('0x2f')]);}_0x3e2ac6[_0x4a9e('0x47')]=qs[_0x4a9e('0x48')](_0x569443[_0x4a9e('0x3f')][_0x4a9e('0x48')]);_0x3e2ac6[_0x4a9e('0x49')]=qs[_0x4a9e('0x40')](_[_0x4a9e('0x4a')](_0x569443[_0x4a9e('0x3f')],_0x5156fd['filters']),_0x598351);if(_0x569443[_0x4a9e('0x3f')][_0x4a9e('0x4b')]){_0x3e2ac6['where']=_[_0x4a9e('0x4c')](_0x3e2ac6[_0x4a9e('0x49')],{'$or':_['map'](_0x598351,function(_0x4aaa4d){if(_0x4aaa4d['type']!==_0x4a9e('0x4d')){var _0x43c0af={};_0x43c0af[_0x4aaa4d['name']]={'$like':'%'+_0x569443[_0x4a9e('0x3f')][_0x4a9e('0x4b')]+'%'};return _0x43c0af;}})});}_0x3e2ac6=_[_0x4a9e('0x4c')]({},_0x3e2ac6,_0x569443[_0x4a9e('0x4e')]);var _0x5d27eb={'where':_0x3e2ac6[_0x4a9e('0x49')]};return db[_0x4a9e('0x3b')][_0x4a9e('0x2e')](_0x5d27eb)['then'](function(_0x4baea5){_0x1c5faf['count']=_0x4baea5;if(_0x569443['query']['includeAll']){_0x3e2ac6[_0x4a9e('0x4f')]=[{'all':!![]}];}return db['OpenchannelMessage']['findAll'](_0x3e2ac6);})[_0x4a9e('0x1e')](function(_0x5763d7){_0x1c5faf[_0x4a9e('0x50')]=_0x5763d7;return _0x1c5faf;})[_0x4a9e('0x1e')](respondWithFilteredResult(_0x2ee8b9,_0x3e2ac6))[_0x4a9e('0x51')](handleError(_0x2ee8b9,null));};exports[_0x4a9e('0x52')]=function(_0x1e3bbe,_0x556146){var _0x298e36={'raw':!![],'where':{'id':_0x1e3bbe[_0x4a9e('0x53')]['id']}},_0x4261a6={};_0x4261a6[_0x4a9e('0x3e')]=_[_0x4a9e('0x54')](db[_0x4a9e('0x3b')][_0x4a9e('0x3c')]);_0x4261a6[_0x4a9e('0x3f')]=_[_0x4a9e('0x54')](_0x1e3bbe[_0x4a9e('0x3f')]);_0x4261a6['filters']=_[_0x4a9e('0x41')](_0x4261a6[_0x4a9e('0x3e')],_0x4261a6[_0x4a9e('0x3f')]);_0x298e36[_0x4a9e('0x43')]=_['intersection'](_0x4261a6[_0x4a9e('0x3e')],qs[_0x4a9e('0x42')](_0x1e3bbe[_0x4a9e('0x3f')][_0x4a9e('0x42')]));_0x298e36[_0x4a9e('0x43')]=_0x298e36[_0x4a9e('0x43')][_0x4a9e('0x44')]?_0x298e36[_0x4a9e('0x43')]:_0x4261a6[_0x4a9e('0x3e')];if(_0x1e3bbe[_0x4a9e('0x3f')]['includeAll']){_0x298e36['include']=[{'all':!![]}];}_0x298e36=_['merge']({},_0x298e36,_0x1e3bbe[_0x4a9e('0x4e')]);return db[_0x4a9e('0x3b')][_0x4a9e('0x55')](_0x298e36)['then'](handleEntityNotFound(_0x556146,null))[_0x4a9e('0x1e')](respondWithResult(_0x556146,null))['catch'](handleError(_0x556146,null));};exports[_0x4a9e('0x56')]=function(_0x4fa9b0,_0x539774){return db['OpenchannelMessage'][_0x4a9e('0x56')](_0x4fa9b0['body'],{})[_0x4a9e('0x1e')](respondWithResult(_0x539774,0xc9))[_0x4a9e('0x51')](handleError(_0x539774,null));};exports['update']=function(_0x458623,_0x4b4c0e){if(_0x458623[_0x4a9e('0x57')]['id']){delete _0x458623['body']['id'];}return db[_0x4a9e('0x3b')][_0x4a9e('0x55')]({'where':{'id':_0x458623[_0x4a9e('0x53')]['id']}})[_0x4a9e('0x1e')](handleEntityNotFound(_0x4b4c0e,null))['then'](saveUpdates(_0x458623[_0x4a9e('0x57')],null))[_0x4a9e('0x1e')](respondWithResult(_0x4b4c0e,null))[_0x4a9e('0x51')](handleError(_0x4b4c0e,null));};exports[_0x4a9e('0x35')]=function(_0x3e73b7,_0x1b97b5){return db['OpenchannelMessage'][_0x4a9e('0x55')]({'where':{'id':_0x3e73b7['params']['id']}})[_0x4a9e('0x1e')](handleEntityNotFound(_0x1b97b5,null))[_0x4a9e('0x1e')](removeEntity(_0x1b97b5,null))[_0x4a9e('0x51')](handleError(_0x1b97b5,null));};exports[_0x4a9e('0x58')]=function(_0x3ab665,_0x402ae2){return db[_0x4a9e('0x3b')][_0x4a9e('0x58')]()['then'](respondWithResult(_0x402ae2,null))[_0x4a9e('0x51')](handleError(_0x402ae2,null));};var interaction_log=require(_0x4a9e('0x14'))(_0x4a9e('0x59'));exports[_0x4a9e('0x5a')]=function(_0x378c49,_0x32c8ad,_0x4950da){var _0x1d0c62={'agent':{},'channel':_0x4a9e('0x5b')};if(_0x378c49['body']['id']){delete _0x378c49[_0x4a9e('0x57')]['id'];}_0x378c49['body']['read']=!![];_0x378c49[_0x4a9e('0x57')]['readAt']=moment()[_0x4a9e('0x5c')](_0x4a9e('0x5d'));_0x378c49[_0x4a9e('0x57')][_0x4a9e('0x5e')]=_0x378c49[_0x4a9e('0x57')]['UserId']||_0x378c49[_0x4a9e('0x5f')]['id'];_0x1d0c62['agent']['id']=_0x378c49[_0x4a9e('0x57')]['UserId'];return db[_0x4a9e('0x3b')]['find']({'where':{'id':_0x378c49[_0x4a9e('0x53')]['id'],'UserId':null}})[_0x4a9e('0x1e')](handleEntityNotFound(_0x32c8ad,null))[_0x4a9e('0x1e')](saveUpdates(_0x378c49[_0x4a9e('0x57')],null))[_0x4a9e('0x1e')](function(_0x262cf6){if(_0x262cf6){_0x1d0c62[_0x4a9e('0x26')]=_0x262cf6['get']({'plain':!![]});return db[_0x4a9e('0x60')]['find']({'where':{'id':_0x262cf6[_0x4a9e('0x61')]}});}return null;})['then'](handleEntityNotFound(_0x32c8ad,null))['then'](function(_0x3bcce1){if(_0x3bcce1){return _0x3bcce1[_0x4a9e('0x34')]({'UserId':_0x378c49[_0x4a9e('0x57')][_0x4a9e('0x5e')],'read1stAt':_[_0x4a9e('0x62')](_0x3bcce1[_0x4a9e('0x63')])?moment()[_0x4a9e('0x5c')](_0x4a9e('0x5d')):undefined});}return null;})['then'](function(_0x1853a5){if(_0x1853a5){_0x1d0c62[_0x4a9e('0x64')]=_0x1853a5[_0x4a9e('0x65')]({'plain':!![]});interaction_log[_0x4a9e('0x1f')](_0x4a9e('0x66'),_0x378c49[_0x4a9e('0x5f')]['id'],_0x378c49[_0x4a9e('0x5f')]['name'],_0x378c49['user'][_0x4a9e('0x67')],_0x1d0c62[_0x4a9e('0x64')]['id'],_0x378c49[_0x4a9e('0x57')]?JSON['stringify'](_0x378c49[_0x4a9e('0x57')]):'null');return respondWithRpcPromise(_0x4a9e('0x68'),_0x4a9e('0x69'),_0x1d0c62);}return null;})['then'](function(_0x21d657){var _0x385db4=_0x4a9e('0x6a')+_0x21d657[_0x4a9e('0x26')]['ContactId'];return db[_0x4a9e('0x6b')]['query'](_0x385db4,{'type':db['Sequelize']['QueryTypes'][_0x4a9e('0x6c')],'raw':!![]})[_0x4a9e('0x1e')](function(_0x57731e){return _0x57731e;});})[_0x4a9e('0x1e')](function(_0x4fb346){if(_0x4fb346){_0x1d0c62[_0x4a9e('0x26')][_0x4a9e('0x6d')]=_0x4fb346[0x0];if(!_0x378c49[_0x4a9e('0x57')][_0x4a9e('0x5e')])return;return db[_0x4a9e('0x6e')][_0x4a9e('0x55')]({'where':{'id':_0x378c49[_0x4a9e('0x57')][_0x4a9e('0x5e')],'role':'agent'},'attributes':['id','name',_0x4a9e('0x6f'),_0x4a9e('0x70'),_0x4a9e('0x71')],'raw':!![]});}return null;})[_0x4a9e('0x1e')](function(_0x345565){if(!_0x345565)return null;_0x1d0c62['message']['agent']=_0x345565;return _0x1d0c62;})[_0x4a9e('0x1e')](function(_0x115907){if(_0x115907){if(_0x378c49['body'][_0x4a9e('0x72')]){_0x1d0c62[_0x4a9e('0x26')][_0x4a9e('0x73')]=util[_0x4a9e('0x5c')](_0x4a9e('0x74'),_0x378c49[_0x4a9e('0x5f')]['name']);_0x1d0c62['message']['channel']=_0x1d0c62['channel'];_0x1d0c62['message'][_0x4a9e('0x75')]=_0x1d0c62[_0x4a9e('0x76')];_0x1d0c62[_0x4a9e('0x26')]['event']=_0x4a9e('0x5a');return respondWithRpcPromise(_0x4a9e('0x77'),_0x4a9e('0x77'),{'event':_0x4a9e('0x78'),'message':_0x1d0c62[_0x4a9e('0x26')]},client9002)[_0x4a9e('0x1e')](function(){return _0x1d0c62;});}return _0x1d0c62;}return null;})['then'](respondWithResult(_0x32c8ad,null))['catch'](handleError(_0x32c8ad,null));};var interaction_log=require('../../config/logger')('openchannel-interactions');exports[_0x4a9e('0x79')]=function(_0x259526,_0x4a4ea5,_0x481013){var _0x1f6d6d={'agent':{},'channel':'openchannel'};if(_0x259526[_0x4a9e('0x57')]['id']){delete _0x259526[_0x4a9e('0x57')]['id'];}_0x259526['body'][_0x4a9e('0x5e')]=_0x259526[_0x4a9e('0x57')]['UserId']||_0x259526[_0x4a9e('0x5f')]['id'];_0x1f6d6d[_0x4a9e('0x7a')]['id']=_0x259526['body'][_0x4a9e('0x5e')];return db[_0x4a9e('0x3b')]['find']({'where':{'id':_0x259526[_0x4a9e('0x53')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x4a4ea5,null))[_0x4a9e('0x1e')](function(_0x532c19){if(_0x532c19){_0x1f6d6d[_0x4a9e('0x26')]=_0x532c19[_0x4a9e('0x65')]({'plain':!![]});return db['OpenchannelInteraction'][_0x4a9e('0x55')]({'where':{'id':_0x532c19[_0x4a9e('0x61')]}});}return null;})[_0x4a9e('0x1e')](handleEntityNotFound(_0x4a4ea5,null))['then'](function(_0x3278c3){if(_0x3278c3){_0x1f6d6d[_0x4a9e('0x64')]=_0x3278c3[_0x4a9e('0x65')]({'plain':!![]});interaction_log[_0x4a9e('0x1f')]('[OPENCHANNELMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x259526[_0x4a9e('0x5f')]['id'],_0x259526['user']['name'],_0x259526[_0x4a9e('0x5f')][_0x4a9e('0x67')],_0x1f6d6d[_0x4a9e('0x64')]['id'],_0x259526[_0x4a9e('0x57')]?JSON['stringify'](_0x259526[_0x4a9e('0x57')]):_0x4a9e('0x7b'));return respondWithRpcPromise(_0x4a9e('0x7c'),_0x4a9e('0x7d'),_0x1f6d6d);}return null;})[_0x4a9e('0x1e')](function(_0x2a2531){var _0xb9d170='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x2a2531['message'][_0x4a9e('0x7e')];return db[_0x4a9e('0x6b')][_0x4a9e('0x3f')](_0xb9d170,{'type':db['Sequelize'][_0x4a9e('0x7f')][_0x4a9e('0x6c')],'raw':!![]})[_0x4a9e('0x1e')](function(_0x3d6488){return _0x3d6488;});})[_0x4a9e('0x1e')](function(_0x5946a6){if(_0x5946a6){_0x1f6d6d[_0x4a9e('0x26')][_0x4a9e('0x6d')]=_0x5946a6[0x0];if(!_0x259526[_0x4a9e('0x57')]['UserId'])return;return db['User'][_0x4a9e('0x55')]({'where':{'id':_0x259526[_0x4a9e('0x57')][_0x4a9e('0x5e')],'role':'agent'},'attributes':['id','name',_0x4a9e('0x6f'),'email',_0x4a9e('0x71')],'raw':!![]});}return null;})[_0x4a9e('0x1e')](function(_0x5b94ce){if(!_0x5b94ce)return null;_0x1f6d6d['message'][_0x4a9e('0x7a')]=_0x5b94ce;return _0x1f6d6d;})['then'](function(_0xf0c854){if(_0xf0c854){_0xf0c854['message'][_0x4a9e('0x73')]=util[_0x4a9e('0x5c')](_0x4a9e('0x74'),_0x259526[_0x4a9e('0x5f')][_0x4a9e('0x37')]);_0xf0c854[_0x4a9e('0x26')][_0x4a9e('0x76')]=_0x1f6d6d['channel'];_0xf0c854[_0x4a9e('0x26')][_0x4a9e('0x75')]=_0x1f6d6d[_0x4a9e('0x76')];_0xf0c854[_0x4a9e('0x26')][_0x4a9e('0x80')]='reject';respondWithRpcPromise(_0x4a9e('0x77'),_0x4a9e('0x77'),{'event':_0x4a9e('0x81'),'message':_0xf0c854[_0x4a9e('0x26')]},client9002);return _0x1f6d6d;}return null;})[_0x4a9e('0x1e')](respondWithResult(_0x4a4ea5,null))[_0x4a9e('0x51')](handleError(_0x4a4ea5,null));}; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.events.js b/server/api/openchannelMessage/openchannelMessage.events.js new file mode 100644 index 0000000..920fd65 --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe926=['save','update','remove','emit','hook','exports','events','OpenchannelMessage'];(function(_0xa8e041,_0x1348af){var _0x330b32=function(_0x31f4ef){while(--_0x31f4ef){_0xa8e041['push'](_0xa8e041['shift']());}};_0x330b32(++_0x1348af);}(_0xe926,0x15e));var _0x6e92=function(_0x1d0499,_0x23e22f){_0x1d0499=_0x1d0499-0x0;var _0x153fb3=_0xe926[_0x1d0499];return _0x153fb3;};'use strict';var EventEmitter=require(_0x6e92('0x0'));var OpenchannelMessage=require('../../mysqldb')['db'][_0x6e92('0x1')];var OpenchannelMessageEvents=new EventEmitter();OpenchannelMessageEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x6e92('0x2'),'afterUpdate':_0x6e92('0x3'),'afterDestroy':_0x6e92('0x4')};function emitEvent(_0x3ae01e){return function(_0x1f3638,_0x438867,_0x6478c8){OpenchannelMessageEvents[_0x6e92('0x5')](_0x3ae01e+':'+_0x1f3638['id'],_0x1f3638);OpenchannelMessageEvents[_0x6e92('0x5')](_0x3ae01e,_0x1f3638);_0x6478c8(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];OpenchannelMessage[_0x6e92('0x6')](e,emitEvent(event));}}module[_0x6e92('0x7')]=OpenchannelMessageEvents; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.model.js b/server/api/openchannelMessage/openchannelMessage.model.js new file mode 100644 index 0000000..e45fe80 --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfff3=['format','Forwarding\x20message\x20%d\x20to\x20%s','length','POST','method','GET','body','Message\x20%d\x20forwarded\x20to\x20%s','threadId','Interaction','inspect','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','rimraf','./openchannelMessage.attributes','exports','define','openchannel_messages','FULLTEXT','direction','toLowerCase','out','secret','isNil','UserId','findOne','OpenchannelInteractionId','then','update','createdAt','catch','error','CmContact','describe','find','OpenchannelAccountId','OpenchannelInteraction','Interactions','Contact','keys','get','replyUri','OpenchannelMessage,\x20%s,\x20%s','afterCreate'];(function(_0x2c3255,_0x4e00ae){var _0x282aba=function(_0x5721d5){while(--_0x5721d5){_0x2c3255['push'](_0x2c3255['shift']());}};_0x282aba(++_0x4e00ae);}(_0xfff3,0x1d9));var _0x3fff=function(_0x5b8fa5,_0x35f163){_0x5b8fa5=_0x5b8fa5-0x0;var _0x504056=_0xfff3[_0x5b8fa5];return _0x504056;};'use strict';var _=require(_0x3fff('0x0'));var util=require(_0x3fff('0x1'));var logger=require(_0x3fff('0x2'))(_0x3fff('0x3'));var moment=require(_0x3fff('0x4'));var BPromise=require(_0x3fff('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x3fff('0x6'));var config=require('../../config/environment');var attributes=require(_0x3fff('0x7'));module[_0x3fff('0x8')]=function(_0x46e26f,_0x118904){return _0x46e26f[_0x3fff('0x9')]('OpenchannelMessage',attributes,{'tableName':_0x3fff('0xa'),'paranoid':![],'indexes':[{'name':'fti_openchannel_messages','fields':['body'],'type':_0x3fff('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x35d8bd,_0x4872b0,_0x589401){var _0x49b269=_0x46e26f['models'];var _0x36dc47=_0x35d8bd['get']({'plain':!![]});if(_0x36dc47[_0x3fff('0xc')][_0x3fff('0xd')]()==='in'||_0x36dc47[_0x3fff('0xc')][_0x3fff('0xd')]()===_0x3fff('0xe')&&!_0x36dc47[_0x3fff('0xf')]&&!_[_0x3fff('0x10')](_0x36dc47[_0x3fff('0x11')])){_0x49b269['OpenchannelInteraction'][_0x3fff('0x12')]({'where':{'id':_0x36dc47[_0x3fff('0x13')]}})[_0x3fff('0x14')](function(_0x4be5cb){if(_0x4be5cb){_0x4be5cb[_0x3fff('0x15')]({'lastMsgAt':_0x36dc47[_0x3fff('0x16')],'lastMsgDirection':_0x36dc47[_0x3fff('0xc')]['toLowerCase']()});}})[_0x3fff('0x17')](function(_0x53cf9c){console[_0x3fff('0x18')](_0x53cf9c);});}if(_0x36dc47['direction']===_0x3fff('0xe')&&!_0x36dc47[_0x3fff('0xf')]){var _0x33bf18;_0x49b269[_0x3fff('0x19')][_0x3fff('0x1a')]()[_0x3fff('0x14')](function(_0xb303e1){return _0x49b269['OpenchannelAccount'][_0x3fff('0x1b')]({'where':{'id':_0x36dc47[_0x3fff('0x1c')]},'include':[{'model':_0x49b269[_0x3fff('0x1d')],'as':_0x3fff('0x1e'),'where':{'id':_0x36dc47[_0x3fff('0x13')]},'limit':0x1,'include':[{'model':_0x49b269[_0x3fff('0x19')],'as':_0x3fff('0x1f'),'attributes':_[_0x3fff('0x20')](_0xb303e1)}]}]});})[_0x3fff('0x14')](function(_0x246a34){_0x33bf18=_0x246a34[_0x3fff('0x21')]({'plain':!![]});if(_0x33bf18&&_0x33bf18[_0x3fff('0x22')]){logger['info'](_0x3fff('0x23'),_0x3fff('0x24'),util[_0x3fff('0x25')](_0x3fff('0x26'),_0x36dc47['id'],_0x33bf18['replyUri']));if(_0x33bf18[_0x3fff('0x1e')]&&_0x33bf18['Interactions'][_0x3fff('0x27')]){_0x36dc47['Interaction']=_['omit'](_0x33bf18[_0x3fff('0x1e')][0x0],_0x3fff('0x1f'));_0x36dc47[_0x3fff('0x1f')]=_0x33bf18[_0x3fff('0x1e')][0x0][_0x3fff('0x1f')];}var _0x4872b0={'method':_0x3fff('0x28'),'uri':encodeURI(_0x33bf18[_0x3fff('0x22')]),'json':!![],'resolveWithFullResponse':!![]};switch(_0x4872b0[_0x3fff('0x29')]){case _0x3fff('0x2a'):_0x4872b0['qs']=_0x36dc47;break;case _0x3fff('0x28'):_0x4872b0[_0x3fff('0x2b')]=_0x36dc47;break;}return rp(_0x4872b0)[_0x3fff('0x14')](function(_0x28852e){logger['info'](_0x3fff('0x23'),_0x3fff('0x24'),util[_0x3fff('0x25')](_0x3fff('0x2c'),_0x36dc47['id'],_0x33bf18[_0x3fff('0x22')]));if(_0x28852e[_0x3fff('0x2b')][_0x3fff('0x2d')]&&_0x28852e[_0x3fff('0x2b')][_0x3fff('0x2d')]!=_0x36dc47['Interaction'][_0x3fff('0x2d')]){return _0x49b269['OpenchannelInteraction'][_0x3fff('0x15')]({'threadId':_0x28852e[_0x3fff('0x2b')][_0x3fff('0x2d')]},{'where':{'id':_0x36dc47[_0x3fff('0x2e')]['id']}});}else{return;}})['then'](function(){return _0x35d8bd[_0x3fff('0x15')]({'read':!![]});})[_0x3fff('0x17')](function(_0x46b4f8){logger[_0x3fff('0x18')]('OpenchannelMessage,\x20%s,\x20%s',_0x3fff('0x24'),util[_0x3fff('0x2f')](_0x46b4f8,{'showHidden':![],'depth':null}));_0x589401();});}else{_0x589401();}})[_0x3fff('0x30')](function(){_0x589401();});}else{_0x589401();}}},'charset':_0x3fff('0x31'),'collate':_0x3fff('0x32')});}; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.rpc.js b/server/api/openchannelMessage/openchannelMessage.rpc.js new file mode 100644 index 0000000..56d688c --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['../../config/utils','../../config/logger','rpc','../../config/environment','http','redis','localhost','socket.io-emitter','./openchannelMessage.socket','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','OpenchannelMessage','options','raw','then','CreateOpenchannelMessage','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x3fc807,_0x16ee12){var _0x2a4b4d=function(_0x2101f4){while(--_0x2101f4){_0x3fc807['push'](_0x3fc807['shift']());}};_0x2a4b4d(++_0x16ee12);}(_0x1261,0x144));var _0x1126=function(_0x411b14,_0x3f9e36){_0x411b14=_0x411b14-0x0;var _0x402736=_0x1261[_0x411b14];return _0x402736;};'use strict';var _=require('lodash');var util=require(_0x1126('0x0'));var moment=require(_0x1126('0x1'));var BPromise=require(_0x1126('0x2'));var rs=require(_0x1126('0x3'));var fs=require('fs');var Redis=require(_0x1126('0x4'));var db=require(_0x1126('0x5'))['db'];var utils=require(_0x1126('0x6'));var logger=require(_0x1126('0x7'))(_0x1126('0x8'));var config=require(_0x1126('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x1126('0xa')]({'port':0x232a});config[_0x1126('0xb')]=_['defaults'](config[_0x1126('0xb')],{'host':_0x1126('0xc'),'port':0x18eb});var socket=require(_0x1126('0xd'))(new Redis(config[_0x1126('0xb')]));require(_0x1126('0xe'))['register'](socket);function respondWithRpcPromise(_0x3f09ac,_0x18dbe6,_0x167ef1){return new BPromise(function(_0x5e72e2,_0x34571c){return client['request'](_0x3f09ac,_0x167ef1)['then'](function(_0x15c071){logger['info'](_0x1126('0xf'),_0x18dbe6,_0x1126('0x10'));logger[_0x1126('0x11')](_0x1126('0x12'),_0x18dbe6,_0x1126('0x10'),JSON[_0x1126('0x13')](_0x15c071));if(_0x15c071[_0x1126('0x14')]){if(_0x15c071[_0x1126('0x14')][_0x1126('0x15')]===0x1f4){logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0x18dbe6,_0x15c071[_0x1126('0x14')][_0x1126('0x16')]);return _0x34571c(_0x15c071[_0x1126('0x14')]['message']);}logger[_0x1126('0x14')]('OpenchannelMessage,\x20%s,\x20%s',_0x18dbe6,_0x15c071[_0x1126('0x14')][_0x1126('0x16')]);return _0x5e72e2(_0x15c071[_0x1126('0x14')]['message']);}else{logger[_0x1126('0x17')](_0x1126('0xf'),_0x18dbe6,'request\x20sent');_0x5e72e2(_0x15c071['result'][_0x1126('0x16')]);}})[_0x1126('0x18')](function(_0x58d11a){logger['error'](_0x1126('0xf'),_0x18dbe6,_0x58d11a);_0x34571c(_0x58d11a);});});}exports['CreateOpenchannelMessage']=function(_0x22ed37){var _0x1d6d19=this;return new Promise(function(_0x2f70ac,_0x54400a){return db[_0x1126('0x19')]['create'](_0x22ed37['body'],{'raw':_0x22ed37[_0x1126('0x1a')]?_0x22ed37[_0x1126('0x1a')][_0x1126('0x1b')]===undefined?!![]:![]:!![]})[_0x1126('0x1c')](function(_0x526ca1){logger[_0x1126('0x17')](_0x1126('0x1d'),_0x22ed37);logger['debug'](_0x1126('0x1d'),_0x22ed37,JSON['stringify'](_0x526ca1));_0x2f70ac(_0x526ca1);})['catch'](function(_0x4b57ab){logger[_0x1126('0x14')](_0x1126('0x1d'),_0x4b57ab[_0x1126('0x16')],_0x22ed37);_0x54400a(_0x1d6d19[_0x1126('0x14')](0x1f4,_0x4b57ab[_0x1126('0x16')]));});});}; \ No newline at end of file diff --git a/server/api/openchannelMessage/openchannelMessage.socket.js b/server/api/openchannelMessage/openchannelMessage.socket.js new file mode 100644 index 0000000..350fd0b --- /dev/null +++ b/server/api/openchannelMessage/openchannelMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x757a=['update','emit','removeListener','length','openchannelMessage:','save'];(function(_0x8dbc64,_0x17362d){var _0x2645ca=function(_0x24f6fc){while(--_0x24f6fc){_0x8dbc64['push'](_0x8dbc64['shift']());}};_0x2645ca(++_0x17362d);}(_0x757a,0x1af));var _0xa757=function(_0x2d2237,_0x5bd828){_0x2d2237=_0x2d2237-0x0;var _0x115f10=_0x757a[_0x2d2237];return _0x115f10;};'use strict';var OpenchannelMessageEvents=require('./openchannelMessage.events');var events=[_0xa757('0x0'),'remove',_0xa757('0x1')];function createListener(_0x53364d,_0x53eaeb){return function(_0x919482){_0x53eaeb[_0xa757('0x2')](_0x53364d,_0x919482);};}function removeListener(_0x468559,_0x339299){return function(){OpenchannelMessageEvents[_0xa757('0x3')](_0x468559,_0x339299);};}exports['register']=function(_0x410ed1){for(var _0x2e804c=0x0,_0x155b42=events[_0xa757('0x4')];_0x2e804c<_0x155b42;_0x2e804c++){var _0x186a9b=events[_0x2e804c];var _0x3fd774=createListener(_0xa757('0x5')+_0x186a9b,_0x410ed1);OpenchannelMessageEvents['on'](_0x186a9b,_0x3fd774);}}; \ No newline at end of file diff --git a/server/api/openchannelQueue/index.js b/server/api/openchannelQueue/index.js new file mode 100644 index 0000000..ab2f422 --- /dev/null +++ b/server/api/openchannelQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xec82=['show','/:id/members','/:id/teams','/:id/users','create','post','addTeams','addAgents','put','update','delete','destroy','removeTeams','removeAgents','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./openchannelQueue.controller','get','isAuthenticated','index','/describe','describe','/:id'];(function(_0x50ce16,_0x59e64b){var _0x30f4d7=function(_0x1cd2ee){while(--_0x1cd2ee){_0x50ce16['push'](_0x50ce16['shift']());}};_0x30f4d7(++_0x59e64b);}(_0xec82,0xcf));var _0x2ec8=function(_0xa92b87,_0x260182){_0xa92b87=_0xa92b87-0x0;var _0x261faf=_0xec82[_0xa92b87];return _0x261faf;};'use strict';var multer=require(_0x2ec8('0x0'));var util=require(_0x2ec8('0x1'));var path=require(_0x2ec8('0x2'));var timeout=require(_0x2ec8('0x3'));var express=require(_0x2ec8('0x4'));var router=express[_0x2ec8('0x5')]();var fs_extra=require(_0x2ec8('0x6'));var auth=require(_0x2ec8('0x7'));var interaction=require(_0x2ec8('0x8'));var config=require(_0x2ec8('0x9'));var controller=require(_0x2ec8('0xa'));router[_0x2ec8('0xb')]('/',auth[_0x2ec8('0xc')](),controller[_0x2ec8('0xd')]);router[_0x2ec8('0xb')](_0x2ec8('0xe'),auth[_0x2ec8('0xc')](),controller[_0x2ec8('0xf')]);router[_0x2ec8('0xb')](_0x2ec8('0x10'),auth[_0x2ec8('0xc')](),controller[_0x2ec8('0x11')]);router['get'](_0x2ec8('0x12'),auth['isAuthenticated'](),controller['getMembers']);router[_0x2ec8('0xb')](_0x2ec8('0x13'),auth['isAuthenticated'](),controller['getTeams']);router[_0x2ec8('0xb')](_0x2ec8('0x14'),auth[_0x2ec8('0xc')](),controller['getAgents']);router['post']('/',auth[_0x2ec8('0xc')](),controller[_0x2ec8('0x15')]);router[_0x2ec8('0x16')]('/:id/teams',auth['isAuthenticated'](),controller[_0x2ec8('0x17')]);router[_0x2ec8('0x16')]('/:id/users',auth['isAuthenticated'](),controller[_0x2ec8('0x18')]);router[_0x2ec8('0x19')]('/:id',auth['isAuthenticated'](),controller[_0x2ec8('0x1a')]);router[_0x2ec8('0x1b')](_0x2ec8('0x10'),auth[_0x2ec8('0xc')](),controller[_0x2ec8('0x1c')]);router[_0x2ec8('0x1b')](_0x2ec8('0x13'),auth[_0x2ec8('0xc')](),controller[_0x2ec8('0x1d')]);router[_0x2ec8('0x1b')](_0x2ec8('0x14'),auth['isAuthenticated'](),controller[_0x2ec8('0x1e')]);module[_0x2ec8('0x1f')]=router; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.attributes.js b/server/api/openchannelQueue/openchannelQueue.attributes.js new file mode 100644 index 0000000..4f3761a --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3f30=['STRING','INTEGER','ENUM','rrmemory','beepall','sequelize','exports','name'];(function(_0x47e69e,_0x398963){var _0x302e7f=function(_0x3ca5b1){while(--_0x3ca5b1){_0x47e69e['push'](_0x47e69e['shift']());}};_0x302e7f(++_0x398963);}(_0x3f30,0xfd));var _0x03f3=function(_0x12c705,_0x56b9b3){_0x12c705=_0x12c705-0x0;var _0x4c826f=_0x3f30[_0x12c705];return _0x4c826f;};'use strict';var Sequelize=require(_0x03f3('0x0'));module[_0x03f3('0x1')]={'name':{'type':Sequelize['STRING'],'unique':_0x03f3('0x2'),'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'description':{'type':Sequelize[_0x03f3('0x3')]},'timeout':{'type':Sequelize[_0x03f3('0x4')],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize[_0x03f3('0x5')](_0x03f3('0x6'),_0x03f3('0x7'),'roundrobin')}}; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.controller.js b/server/api/openchannelQueue/openchannelQueue.controller.js new file mode 100644 index 0000000..2b24048 --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x911d=['find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserOpenchannelQueue','OpenchannelQueueId','User','findAndCountAll','UserId','openchannelPause','createdAt','format','%s/%s','SIP','getTeams','addTeams','Team','Agents','online','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','emit','userOpenchannelQueue:save','removeTeams','ids','select','field','from','team_has_openchannel_queues','join','ut.TeamId\x20=\x20tq.TeamId','OpenchannelQueueId\x20=\x20?','ut.UserId\x20=\x20?','sequelize','toString','QueryTypes','SELECT','all','union','value','isEmpty','removeAgents','userOpenchannelQueue:remove','addAgents','omit','spread','isArray','getAgents','sort','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','offset','limit','undefined','count','set','json','apply','reject','update','then','destroy','get','OpenchannelQueues','UserProfileResource','error','stack','name','send','OpenchannelQueue','rawAttributes','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','map','type','options','includeAll','findAll','rows','catch','show','params','keys','include','create','body','user','UserProfileSection'];(function(_0x2f2ed0,_0x1c6435){var _0x250b0d=function(_0x1909c1){while(--_0x1909c1){_0x2f2ed0['push'](_0x2f2ed0['shift']());}};_0x250b0d(++_0x1c6435);}(_0x911d,0xc5));var _0xd911=function(_0x25948f,_0x4ac7e4){_0x25948f=_0x25948f-0x0;var _0x2b1976=_0x911d[_0x25948f];return _0x2b1976;};'use strict';var emlformat=require(_0xd911('0x0'));var rimraf=require(_0xd911('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd911('0x2'));var rp=require(_0xd911('0x3'));var moment=require(_0xd911('0x4'));var BPromise=require(_0xd911('0x5'));var Mustache=require('mustache');var util=require(_0xd911('0x6'));var path=require(_0xd911('0x7'));var sox=require(_0xd911('0x8'));var csv=require(_0xd911('0x9'));var ejs=require(_0xd911('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xd911('0xb'));var crypto=require(_0xd911('0xc'));var jsforce=require(_0xd911('0xd'));var deskjs=require(_0xd911('0xe'));var toCsv=require('to-csv');var querystring=require(_0xd911('0xf'));var Papa=require(_0xd911('0x10'));var Redis=require(_0xd911('0x11'));var authService=require(_0xd911('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xd911('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xd911('0x14'))(_0xd911('0x15'));var utils=require(_0xd911('0x16'));var config=require(_0xd911('0x17'));var licenseUtil=require(_0xd911('0x18'));var db=require(_0xd911('0x19'))['db'];config[_0xd911('0x1a')]=_[_0xd911('0x1b')](config['redis'],{'host':_0xd911('0x1c'),'port':0x18eb});var socket=require(_0xd911('0x1d'))(new Redis(config[_0xd911('0x1a')]));require('./openchannelQueue.socket')[_0xd911('0x1e')](socket);function respondWithStatusCode(_0x3be208,_0x51e439){_0x51e439=_0x51e439||0xcc;return function(_0x440300){if(_0x440300){return _0x3be208[_0xd911('0x1f')](_0x51e439);}return _0x3be208[_0xd911('0x20')](_0x51e439)[_0xd911('0x21')]();};}function respondWithResult(_0x436477,_0x58cd61){_0x58cd61=_0x58cd61||0xc8;return function(_0x41355f){if(_0x41355f){return _0x436477[_0xd911('0x20')](_0x58cd61)['json'](_0x41355f);}};}function respondWithFilteredResult(_0x6e944c,_0xc3ba60){return function(_0x4d6e88){if(_0x4d6e88){var _0x984d57=typeof _0xc3ba60[_0xd911('0x22')]==='undefined'&&typeof _0xc3ba60[_0xd911('0x23')]===_0xd911('0x24');var _0x14d175=_0x4d6e88[_0xd911('0x25')];var _0x3b642c=_0x984d57?0x0:_0xc3ba60[_0xd911('0x22')];var _0x21cde8=_0x984d57?_0x4d6e88[_0xd911('0x25')]:_0xc3ba60[_0xd911('0x22')]+_0xc3ba60[_0xd911('0x23')];var _0x43a20b;if(_0x21cde8>=_0x14d175){_0x21cde8=_0x14d175;_0x43a20b=0xc8;}else{_0x43a20b=0xce;}_0x6e944c['status'](_0x43a20b);return _0x6e944c[_0xd911('0x26')]('Content-Range',_0x3b642c+'-'+_0x21cde8+'/'+_0x14d175)[_0xd911('0x27')](_0x4d6e88);}return null;};}function patchUpdates(_0x20e29b){return function(_0x3dab20){try{jsonpatch[_0xd911('0x28')](_0x3dab20,_0x20e29b,!![]);}catch(_0x1f1e91){return BPromise[_0xd911('0x29')](_0x1f1e91);}return _0x3dab20['save']();};}function saveUpdates(_0x5e69ca,_0x58ba95){return function(_0x410fc9){if(_0x410fc9){return _0x410fc9[_0xd911('0x2a')](_0x5e69ca)[_0xd911('0x2b')](function(_0x30b5e6){return _0x30b5e6;});}return null;};}function removeEntity(_0x21a816,_0x34554b){return function(_0x20cab6){if(_0x20cab6){return _0x20cab6[_0xd911('0x2c')]()[_0xd911('0x2b')](function(){var _0x43e5ed=_0x20cab6[_0xd911('0x2d')]({'plain':!![]});var _0x14daed=_0xd911('0x2e');return db[_0xd911('0x2f')]['destroy']({'where':{'type':_0x14daed,'resourceId':_0x43e5ed['id']}})[_0xd911('0x2b')](function(){return _0x20cab6;});})[_0xd911('0x2b')](function(){_0x21a816[_0xd911('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x112d4f,_0x3b3e31){return function(_0x362c13){if(!_0x362c13){_0x112d4f[_0xd911('0x1f')](0x194);}return _0x362c13;};}function handleError(_0x56a75c,_0xd61db9){_0xd61db9=_0xd61db9||0x1f4;return function(_0x3517eb){logger[_0xd911('0x30')](_0x3517eb[_0xd911('0x31')]);if(_0x3517eb['name']){delete _0x3517eb[_0xd911('0x32')];}_0x56a75c[_0xd911('0x20')](_0xd61db9)[_0xd911('0x33')](_0x3517eb);};}exports['index']=function(_0x50e380,_0x3aeae7){var _0x4fccbd={},_0x5bef65={},_0x375099={'count':0x0,'rows':[]};var _0x3a7acf=_['map'](db[_0xd911('0x34')][_0xd911('0x35')],function(_0x594848){return{'name':_0x594848['fieldName'],'type':_0x594848['type']['key']};});_0x5bef65[_0xd911('0x36')]=_['map'](_0x3a7acf,'name');_0x5bef65[_0xd911('0x37')]=_['keys'](_0x50e380[_0xd911('0x37')]);_0x5bef65[_0xd911('0x38')]=_[_0xd911('0x39')](_0x5bef65[_0xd911('0x36')],_0x5bef65[_0xd911('0x37')]);_0x4fccbd[_0xd911('0x3a')]=_[_0xd911('0x39')](_0x5bef65[_0xd911('0x36')],qs[_0xd911('0x3b')](_0x50e380['query']['fields']));_0x4fccbd['attributes']=_0x4fccbd['attributes'][_0xd911('0x3c')]?_0x4fccbd['attributes']:_0x5bef65[_0xd911('0x36')];if(!_0x50e380['query'][_0xd911('0x3d')](_0xd911('0x3e'))){_0x4fccbd[_0xd911('0x23')]=qs[_0xd911('0x23')](_0x50e380['query'][_0xd911('0x23')]);_0x4fccbd[_0xd911('0x22')]=qs[_0xd911('0x22')](_0x50e380[_0xd911('0x37')]['offset']);}_0x4fccbd[_0xd911('0x3f')]=qs['sort'](_0x50e380['query']['sort']);_0x4fccbd[_0xd911('0x40')]=qs[_0xd911('0x38')](_[_0xd911('0x41')](_0x50e380[_0xd911('0x37')],_0x5bef65[_0xd911('0x38')]),_0x3a7acf);if(_0x50e380['query'][_0xd911('0x42')]){_0x4fccbd[_0xd911('0x40')]=_[_0xd911('0x43')](_0x4fccbd[_0xd911('0x40')],{'$or':_[_0xd911('0x44')](_0x3a7acf,function(_0x2db627){if(_0x2db627[_0xd911('0x45')]!=='VIRTUAL'){var _0x6c2f5d={};_0x6c2f5d[_0x2db627[_0xd911('0x32')]]={'$like':'%'+_0x50e380[_0xd911('0x37')][_0xd911('0x42')]+'%'};return _0x6c2f5d;}})});}_0x4fccbd=_['merge']({},_0x4fccbd,_0x50e380[_0xd911('0x46')]);var _0x4f5f62={'where':_0x4fccbd[_0xd911('0x40')]};return db[_0xd911('0x34')][_0xd911('0x25')](_0x4f5f62)[_0xd911('0x2b')](function(_0x59f687){_0x375099[_0xd911('0x25')]=_0x59f687;if(_0x50e380['query'][_0xd911('0x47')]){_0x4fccbd['include']=[{'all':!![]}];}return db[_0xd911('0x34')][_0xd911('0x48')](_0x4fccbd);})['then'](function(_0x5a1df3){_0x375099[_0xd911('0x49')]=_0x5a1df3;return _0x375099;})[_0xd911('0x2b')](respondWithFilteredResult(_0x3aeae7,_0x4fccbd))[_0xd911('0x4a')](handleError(_0x3aeae7,null));};exports[_0xd911('0x4b')]=function(_0x5ecb2b,_0x157e39){var _0x4d1dad={'raw':!![],'where':{'id':_0x5ecb2b[_0xd911('0x4c')]['id']}},_0xc7f12a={};_0xc7f12a['model']=_[_0xd911('0x4d')](db['OpenchannelQueue'][_0xd911('0x35')]);_0xc7f12a[_0xd911('0x37')]=_['keys'](_0x5ecb2b['query']);_0xc7f12a['filters']=_['intersection'](_0xc7f12a[_0xd911('0x36')],_0xc7f12a[_0xd911('0x37')]);_0x4d1dad[_0xd911('0x3a')]=_[_0xd911('0x39')](_0xc7f12a[_0xd911('0x36')],qs[_0xd911('0x3b')](_0x5ecb2b['query'][_0xd911('0x3b')]));_0x4d1dad['attributes']=_0x4d1dad[_0xd911('0x3a')]['length']?_0x4d1dad[_0xd911('0x3a')]:_0xc7f12a[_0xd911('0x36')];if(_0x5ecb2b[_0xd911('0x37')][_0xd911('0x47')]){_0x4d1dad[_0xd911('0x4e')]=[{'all':!![]}];}_0x4d1dad=_[_0xd911('0x43')]({},_0x4d1dad,_0x5ecb2b[_0xd911('0x46')]);return db[_0xd911('0x34')]['find'](_0x4d1dad)[_0xd911('0x2b')](handleEntityNotFound(_0x157e39,null))[_0xd911('0x2b')](respondWithResult(_0x157e39,null))[_0xd911('0x4a')](handleError(_0x157e39,null));};exports['create']=function(_0x47df60,_0x15f2e8){return db[_0xd911('0x34')][_0xd911('0x4f')](_0x47df60[_0xd911('0x50')],{})[_0xd911('0x2b')](function(_0x662949){var _0x5def76=_0x47df60['user'][_0xd911('0x2d')]({'plain':!![]});if(!_0x5def76)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5def76['role']===_0xd911('0x51')){var _0x474500=_0x662949[_0xd911('0x2d')]({'plain':!![]});var _0x2ea18d='OpenchannelQueues';return db[_0xd911('0x52')][_0xd911('0x53')]({'where':{'name':_0x2ea18d,'userProfileId':_0x5def76[_0xd911('0x54')]},'raw':!![]})['then'](function(_0x32f5a4){if(_0x32f5a4&&_0x32f5a4[_0xd911('0x55')]===0x0){return db['UserProfileResource'][_0xd911('0x4f')]({'name':_0x474500[_0xd911('0x32')],'resourceId':_0x474500['id'],'type':_0x32f5a4[_0xd911('0x32')],'sectionId':_0x32f5a4['id']},{})[_0xd911('0x2b')](function(){return _0x662949;});}else{return _0x662949;}})[_0xd911('0x4a')](function(_0x332429){logger['error'](_0xd911('0x56'),_0x332429);throw _0x332429;});}return _0x662949;})[_0xd911('0x2b')](respondWithResult(_0x15f2e8,0xc9))[_0xd911('0x4a')](handleError(_0x15f2e8,null));};exports[_0xd911('0x2a')]=function(_0x1b4ea7,_0x3f67e1){if(_0x1b4ea7['body']['id']){delete _0x1b4ea7[_0xd911('0x50')]['id'];}return db[_0xd911('0x34')][_0xd911('0x53')]({'where':{'id':_0x1b4ea7[_0xd911('0x4c')]['id']}})[_0xd911('0x2b')](handleEntityNotFound(_0x3f67e1,null))[_0xd911('0x2b')](saveUpdates(_0x1b4ea7[_0xd911('0x50')],null))['then'](respondWithResult(_0x3f67e1,null))[_0xd911('0x4a')](handleError(_0x3f67e1,null));};exports[_0xd911('0x2c')]=function(_0x4dddf7,_0x3158b2){return db['OpenchannelQueue'][_0xd911('0x53')]({'where':{'id':_0x4dddf7[_0xd911('0x4c')]['id']}})['then'](handleEntityNotFound(_0x3158b2,null))[_0xd911('0x2b')](removeEntity(_0x3158b2,null))[_0xd911('0x4a')](handleError(_0x3158b2,null));};exports[_0xd911('0x57')]=function(_0x48d149,_0x572f15){return db['OpenchannelQueue'][_0xd911('0x57')]()['then'](respondWithResult(_0x572f15,null))[_0xd911('0x4a')](handleError(_0x572f15,null));};exports[_0xd911('0x58')]=function(_0x26f5c2,_0x48b275,_0x30d803){var _0x5809d2={'raw':!![],'where':{}},_0x5bad14={},_0x51627d;return db[_0xd911('0x34')][_0xd911('0x59')]({'where':{'id':_0x26f5c2[_0xd911('0x4c')]['id']}})['then'](handleEntityNotFound(_0x48b275,null))['then'](function(_0x5b7adb){if(_0x5b7adb){_0x51627d=_0x5b7adb[_0xd911('0x2d')]({'plain':!![]});_0x5bad14[_0xd911('0x36')]=_['keys'](db[_0xd911('0x5a')][_0xd911('0x35')]);_0x5bad14['query']=_[_0xd911('0x4d')](_0x26f5c2[_0xd911('0x37')]);_0x5bad14[_0xd911('0x38')]=_['intersection'](_0x5bad14[_0xd911('0x36')],_0x5bad14['query']);_0x5809d2[_0xd911('0x3a')]=_[_0xd911('0x39')](_0x5bad14[_0xd911('0x36')],qs[_0xd911('0x3b')](_0x26f5c2[_0xd911('0x37')]['fields']));_0x5809d2[_0xd911('0x3a')]=_0x5809d2[_0xd911('0x3a')][_0xd911('0x3c')]?_0x5809d2['attributes']:_0x5bad14['model'];if(!_0x26f5c2[_0xd911('0x37')][_0xd911('0x3d')](_0xd911('0x3e'))){_0x5809d2[_0xd911('0x23')]=qs['limit'](_0x26f5c2[_0xd911('0x37')][_0xd911('0x23')]);_0x5809d2[_0xd911('0x22')]=qs[_0xd911('0x22')](_0x26f5c2['query'][_0xd911('0x22')]);}_0x5809d2[_0xd911('0x3f')]=qs['sort'](_0x26f5c2[_0xd911('0x37')]['sort']);_0x5809d2[_0xd911('0x40')]=qs['filters'](_['pick'](_0x26f5c2[_0xd911('0x37')],_0x5bad14[_0xd911('0x38')]));_0x5809d2[_0xd911('0x40')][_0xd911('0x5b')]=_0x5b7adb['id'];if(_0x26f5c2[_0xd911('0x37')][_0xd911('0x42')]){_0x5809d2[_0xd911('0x40')]=_['merge'](_0x5809d2['where'],{'$or':_[_0xd911('0x44')](_0x5809d2[_0xd911('0x3a')],function(_0x4cf967){var _0x2d8735={};_0x2d8735[_0x4cf967]={'$like':'%'+_0x26f5c2[_0xd911('0x37')][_0xd911('0x42')]+'%'};return _0x2d8735;})});}_0x5809d2=_['merge']({},_0x5809d2,_0x26f5c2[_0xd911('0x46')]);return db['UserOpenchannelQueue']['findAll'](_0x5809d2);}})['then'](function(_0x3e9918){if(_0x3e9918){return db[_0xd911('0x5c')][_0xd911('0x5d')]({'where':{'id':_[_0xd911('0x44')](_0x3e9918,_0xd911('0x5e')),'role':'agent'},'attributes':['id',_0xd911('0x32'),_0xd911('0x5f'),'updatedAt',_0xd911('0x60')]});}})[_0xd911('0x2b')](function(_0x161d9a){if(_0x161d9a){return{'count':_0x161d9a[_0xd911('0x25')],'rows':_[_0xd911('0x44')](_0x161d9a[_0xd911('0x49')],function(_0xfd5618){return{'membername':_0xfd5618[_0xd911('0x32')],'UserId':_0xfd5618['id'],'queue_name':_0x51627d[_0xd911('0x32')],'OpenchannelQueueId':_0x51627d['id'],'interface':util[_0xd911('0x61')](_0xd911('0x62'),_0xd911('0x63'),_0xfd5618[_0xd911('0x32')]),'penalty':0x0,'paused':_0xfd5618['openchannelPause'],'createdAt':_0xfd5618[_0xd911('0x60')],'updatedAt':_0xfd5618['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xd911('0x2b')](respondWithFilteredResult(_0x48b275,_0x5809d2))[_0xd911('0x4a')](handleError(_0x48b275,null));};exports[_0xd911('0x64')]=function(_0x981bab,_0x3e8404,_0x8f9a3c){var _0x111269={};var _0x345230={};var _0x1a1b58;var _0x9ca659;return db['OpenchannelQueue']['findOne']({'where':{'id':_0x981bab[_0xd911('0x4c')]['id']}})['then'](handleEntityNotFound(_0x3e8404,null))[_0xd911('0x2b')](function(_0x3ccfe6){if(_0x3ccfe6){_0x1a1b58=_0x3ccfe6;_0x345230[_0xd911('0x36')]=_[_0xd911('0x4d')](db['Team'][_0xd911('0x35')]);_0x345230[_0xd911('0x37')]=_[_0xd911('0x4d')](_0x981bab[_0xd911('0x37')]);_0x345230[_0xd911('0x38')]=_[_0xd911('0x39')](_0x345230['model'],_0x345230[_0xd911('0x37')]);_0x111269['attributes']=_[_0xd911('0x39')](_0x345230[_0xd911('0x36')],qs[_0xd911('0x3b')](_0x981bab[_0xd911('0x37')][_0xd911('0x3b')]));_0x111269[_0xd911('0x3a')]=_0x111269['attributes'][_0xd911('0x3c')]?_0x111269[_0xd911('0x3a')]:_0x345230[_0xd911('0x36')];_0x111269[_0xd911('0x3f')]=qs['sort'](_0x981bab[_0xd911('0x37')]['sort']);_0x111269[_0xd911('0x40')]=qs['filters'](_[_0xd911('0x41')](_0x981bab[_0xd911('0x37')],_0x345230['filters']));if(_0x981bab[_0xd911('0x37')][_0xd911('0x42')]){_0x111269[_0xd911('0x40')]=_[_0xd911('0x43')](_0x111269[_0xd911('0x40')],{'$or':_['map'](_0x111269[_0xd911('0x3a')],function(_0x4533f9){var _0x464523={};_0x464523[_0x4533f9]={'$like':'%'+_0x981bab[_0xd911('0x37')][_0xd911('0x42')]+'%'};return _0x464523;})});}_0x111269=_['merge']({},_0x111269,_0x981bab[_0xd911('0x46')]);return _0x1a1b58['getTeams'](_0x111269);}})[_0xd911('0x2b')](function(_0x382ed4){if(_0x382ed4){_0x9ca659=_0x382ed4[_0xd911('0x3c')];if(!_0x981bab[_0xd911('0x37')][_0xd911('0x3d')](_0xd911('0x3e'))){_0x111269[_0xd911('0x23')]=qs['limit'](_0x981bab[_0xd911('0x37')][_0xd911('0x23')]);_0x111269[_0xd911('0x22')]=qs[_0xd911('0x22')](_0x981bab[_0xd911('0x37')]['offset']);}return _0x1a1b58[_0xd911('0x64')](_0x111269);}})[_0xd911('0x2b')](function(_0x1ea0e4){if(_0x1ea0e4){return _0x1ea0e4?{'count':_0x9ca659,'rows':_0x1ea0e4}:null;}})[_0xd911('0x2b')](respondWithResult(_0x3e8404,null))['catch'](handleError(_0x3e8404,null));};exports[_0xd911('0x65')]=function(_0x10676f,_0x5dc153,_0x524ef5){var _0xd2a741=_0x10676f['body']['ids'];return db[_0xd911('0x66')][_0xd911('0x48')]({'where':{'id':_0xd2a741},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd911('0x67'),'attributes':['id',_0xd911('0x32'),_0xd911('0x68'),_0xd911('0x69'),_0xd911('0x6a')],'raw':!![]}]})[_0xd911('0x2b')](function(_0xe41482){if(_0xe41482){var _0x217e44=_[_0xd911('0x6b')](_0xe41482,function(_0x300a8){var _0xa2eb51=_0x300a8[_0xd911('0x2d')]({'plain':!![]});return _0xa2eb51[_0xd911('0x67')];});return db[_0xd911('0x34')][_0xd911('0x53')]({'where':{'id':_0x10676f['params']['id']}})[_0xd911('0x2b')](function(_0x27dfcf){return db['sequelize'][_0xd911('0x6c')](function(_0x34b92b){return _0x27dfcf['addTeams'](_0xd2a741,{'transaction':_0x34b92b})[_0xd911('0x2b')](function(){return BPromise[_0xd911('0x6d')](_0x217e44,function(_0x3ed3f0){return db[_0xd911('0x5a')][_0xd911('0x6e')]({'where':{'UserId':_0x3ed3f0['id'],'OpenchannelQueueId':_0x10676f[_0xd911('0x4c')]['id']},'transaction':_0x34b92b});});})[_0xd911('0x2b')](function(){_0x217e44[_0xd911('0x6f')](function(_0x44115a){socket[_0xd911('0x70')](_0xd911('0x71'),{'UserId':_0x44115a['id'],'OpenchannelQueueId':_0x27dfcf['id']});});});});});}})[_0xd911('0x2b')](respondWithStatusCode(_0x5dc153,null))['catch'](handleError(_0x5dc153,null));};exports[_0xd911('0x72')]=function(_0x38ab5d,_0x3bd235,_0x47721c){return db[_0xd911('0x66')][_0xd911('0x48')]({'where':{'id':_0x38ab5d['query'][_0xd911('0x73')]},'attributes':['id'],'include':[{'model':db[_0xd911('0x5c')],'as':_0xd911('0x67'),'attributes':['id'],'raw':!![]}]})[_0xd911('0x2b')](handleEntityNotFound(_0x3bd235,null))[_0xd911('0x2b')](function(_0x5ee8d0){var _0x17931a=_[_0xd911('0x44')](_0x5ee8d0,'id');var _0x3d47e8=[];var _0xf6baad=[];var _0x301425=squel[_0xd911('0x74')]();_0x301425[_0xd911('0x75')]('tq.TeamId')[_0xd911('0x76')](_0xd911('0x77'),'tq')[_0xd911('0x78')]('user_has_teams','ut',_0xd911('0x79'))[_0xd911('0x40')](_0xd911('0x7a'),_0x38ab5d['params']['id']);for(var _0x2ee7b4=0x0;_0x2ee7b4<_0x5ee8d0['length'];_0x2ee7b4+=0x1){let _0x50b475=_0x5ee8d0[_0x2ee7b4];for(var _0x232d15=0x0;_0x232d15<_0x50b475[_0xd911('0x67')]['length'];_0x232d15+=0x1){let _0xb5c023=_0x50b475[_0xd911('0x67')][_0x232d15];var _0x474383=_0x301425['clone']();_0x474383[_0xd911('0x40')](_0xd911('0x7b'),_0xb5c023['id']);_0xf6baad['push'](db[_0xd911('0x7c')][_0xd911('0x37')](_0x474383[_0xd911('0x7d')](),{'type':db[_0xd911('0x7c')][_0xd911('0x7e')][_0xd911('0x7f')]})['then'](function(_0x4786ad){if(_0x4786ad[_0xd911('0x3c')]===0x1){return _0xb5c023['id'];}else{var _0xdff188=_['every'](_[_0xd911('0x44')](_0x4786ad,'TeamId'),function(_0x59f801){return _['includes'](_0x17931a,_0x59f801);});if(_0xdff188){return _0xb5c023['id'];}}}));}}return BPromise[_0xd911('0x80')](_0xf6baad)[_0xd911('0x2b')](function(_0x1f3550){_0x3d47e8=_(_0x3d47e8)[_0xd911('0x81')](_0x1f3550)['compact']()[_0xd911('0x82')]();return db['OpenchannelQueue'][_0xd911('0x53')]({'where':{'id':_0x38ab5d['params']['id']}})[_0xd911('0x2b')](function(_0x8cdb9){return db[_0xd911('0x7c')][_0xd911('0x6c')](function(_0x31cb0e){return _0x8cdb9['removeTeams'](_0x38ab5d[_0xd911('0x37')]['ids'],{'transaction':_0x31cb0e})[_0xd911('0x2b')](function(){if(!_[_0xd911('0x83')](_0x3d47e8)){return _0x8cdb9[_0xd911('0x84')](_0x3d47e8,{'transaction':_0x31cb0e});}})['then'](function(){_0x3d47e8['forEach'](function(_0x340a00){socket[_0xd911('0x70')](_0xd911('0x85'),{'UserId':_0x340a00,'OpenchannelQueueId':_0x8cdb9['id']});});});});});});})[_0xd911('0x2b')](respondWithStatusCode(_0x3bd235,null))[_0xd911('0x4a')](handleError(_0x3bd235,null));};exports[_0xd911('0x86')]=function(_0x5b7892,_0x1877bb,_0x43081b){return db[_0xd911('0x34')][_0xd911('0x53')]({'where':{'id':_0x5b7892['params']['id']}})[_0xd911('0x2b')](handleEntityNotFound(_0x1877bb,null))[_0xd911('0x2b')](function(_0x23de81){if(_0x23de81){return _0x23de81[_0xd911('0x86')](_0x5b7892[_0xd911('0x50')][_0xd911('0x73')],_[_0xd911('0x87')](_0x5b7892[_0xd911('0x50')],[_0xd911('0x73'),'id'])||{})[_0xd911('0x88')](function(_0x7fbd68){for(var _0x3aa1e3=0x0;_0x3aa1e3<_0x5b7892[_0xd911('0x50')][_0xd911('0x73')]['length'];_0x3aa1e3+=0x1){socket[_0xd911('0x70')]('userOpenchannelQueue:save',{'UserId':Number(_0x5b7892['body'][_0xd911('0x73')][_0x3aa1e3]),'OpenchannelQueueId':Number(_0x5b7892['params']['id'])});}return _0x7fbd68;});}})[_0xd911('0x2b')](respondWithResult(_0x1877bb,null))[_0xd911('0x4a')](handleError(_0x1877bb,null));};exports['removeAgents']=function(_0x28b333,_0x4dbf1a,_0x3084c2){return db[_0xd911('0x34')]['find']({'where':{'id':_0x28b333[_0xd911('0x4c')]['id']}})['then'](handleEntityNotFound(_0x4dbf1a,null))[_0xd911('0x2b')](function(_0x12356e){if(_0x12356e){return _0x12356e['removeAgents'](_0x28b333[_0xd911('0x37')][_0xd911('0x73')])[_0xd911('0x2b')](function(){if(_[_0xd911('0x89')](_0x28b333['query'][_0xd911('0x73')])){for(var _0x52aff3=0x0;_0x52aff3<_0x28b333['query']['ids'][_0xd911('0x3c')];_0x52aff3+=0x1){socket[_0xd911('0x70')](_0xd911('0x85'),{'UserId':Number(_0x28b333[_0xd911('0x37')]['ids'][_0x52aff3]),'OpenchannelQueueId':Number(_0x28b333[_0xd911('0x4c')]['id'])});}}else{socket['emit'](_0xd911('0x85'),{'UserId':Number(_0x28b333[_0xd911('0x37')]['ids']),'OpenchannelQueueId':Number(_0x28b333[_0xd911('0x4c')]['id'])});}});}})[_0xd911('0x2b')](respondWithStatusCode(_0x4dbf1a,null))['catch'](handleError(_0x4dbf1a,null));};exports[_0xd911('0x8a')]=function(_0x29784d,_0x1c463c,_0x259d07){var _0x6cff1e={};var _0x34cb6c={};var _0x567ff7;var _0x3939fb;return db['OpenchannelQueue'][_0xd911('0x59')]({'where':{'id':_0x29784d[_0xd911('0x4c')]['id']}})[_0xd911('0x2b')](handleEntityNotFound(_0x1c463c,null))[_0xd911('0x2b')](function(_0x2ec660){if(_0x2ec660){_0x567ff7=_0x2ec660;_0x34cb6c[_0xd911('0x36')]=_[_0xd911('0x4d')](db[_0xd911('0x5c')]['rawAttributes']);_0x34cb6c[_0xd911('0x37')]=_[_0xd911('0x4d')](_0x29784d[_0xd911('0x37')]);_0x34cb6c[_0xd911('0x38')]=_[_0xd911('0x39')](_0x34cb6c[_0xd911('0x36')],_0x34cb6c[_0xd911('0x37')]);_0x6cff1e['attributes']=_[_0xd911('0x39')](_0x34cb6c[_0xd911('0x36')],qs[_0xd911('0x3b')](_0x29784d[_0xd911('0x37')][_0xd911('0x3b')]));_0x6cff1e['attributes']=_0x6cff1e['attributes'][_0xd911('0x3c')]?_0x6cff1e['attributes']:_0x34cb6c['model'];_0x6cff1e[_0xd911('0x3f')]=qs['sort'](_0x29784d[_0xd911('0x37')][_0xd911('0x8b')]);_0x6cff1e[_0xd911('0x40')]=qs[_0xd911('0x38')](_['pick'](_0x29784d[_0xd911('0x37')],_0x34cb6c['filters']));if(_0x29784d['query'][_0xd911('0x42')]){_0x6cff1e['where']=_['merge'](_0x6cff1e[_0xd911('0x40')],{'$or':_[_0xd911('0x44')](_0x6cff1e[_0xd911('0x3a')],function(_0x47ec07){var _0x5315fe={};_0x5315fe[_0x47ec07]={'$like':'%'+_0x29784d[_0xd911('0x37')][_0xd911('0x42')]+'%'};return _0x5315fe;})});}_0x6cff1e=_[_0xd911('0x43')]({},_0x6cff1e,_0x29784d[_0xd911('0x46')]);return _0x567ff7[_0xd911('0x8a')](_0x6cff1e);}})['then'](function(_0x242d35){if(_0x242d35){_0x3939fb=_0x242d35['length'];if(!_0x29784d[_0xd911('0x37')]['hasOwnProperty'](_0xd911('0x3e'))){_0x6cff1e[_0xd911('0x23')]=qs[_0xd911('0x23')](_0x29784d[_0xd911('0x37')][_0xd911('0x23')]);_0x6cff1e['offset']=qs[_0xd911('0x22')](_0x29784d[_0xd911('0x37')][_0xd911('0x22')]);}return _0x567ff7[_0xd911('0x8a')](_0x6cff1e);}})['then'](function(_0x49fb91){if(_0x49fb91){return _0x49fb91?{'count':_0x3939fb,'rows':_0x49fb91}:null;}})['then'](respondWithResult(_0x1c463c,null))[_0xd911('0x4a')](handleError(_0x1c463c,null));}; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.events.js b/server/api/openchannelQueue/openchannelQueue.events.js new file mode 100644 index 0000000..8228f86 --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9321=['exports','events','../../mysqldb','OpenchannelQueue','save','update','remove','emit','hasOwnProperty'];(function(_0x1c6b2c,_0x33636d){var _0x49b175=function(_0x434b23){while(--_0x434b23){_0x1c6b2c['push'](_0x1c6b2c['shift']());}};_0x49b175(++_0x33636d);}(_0x9321,0x17b));var _0x1932=function(_0x590651,_0x29dcf5){_0x590651=_0x590651-0x0;var _0xa4cee=_0x9321[_0x590651];return _0xa4cee;};'use strict';var EventEmitter=require(_0x1932('0x0'));var OpenchannelQueue=require(_0x1932('0x1'))['db'][_0x1932('0x2')];var OpenchannelQueueEvents=new EventEmitter();OpenchannelQueueEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x1932('0x3'),'afterUpdate':_0x1932('0x4'),'afterDestroy':_0x1932('0x5')};function emitEvent(_0x3cc138){return function(_0x4a3da8,_0xb299ea,_0x19d095){OpenchannelQueueEvents[_0x1932('0x6')](_0x3cc138+':'+_0x4a3da8['id'],_0x4a3da8);OpenchannelQueueEvents[_0x1932('0x6')](_0x3cc138,_0x4a3da8);_0x19d095(null);};}for(var e in events){if(events[_0x1932('0x7')](e)){var event=events[e];OpenchannelQueue['hook'](e,emitEvent(event));}}module[_0x1932('0x8')]=OpenchannelQueueEvents; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.model.js b/server/api/openchannelQueue/openchannelQueue.model.js new file mode 100644 index 0000000..d3adcf3 --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x488c=['openchannel_queues','util','../../config/logger','moment','bluebird','request-promise','exports'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x488c,0x17b));var _0xc488=function(_0x2cc437,_0x1b4c3f){_0x2cc437=_0x2cc437-0x0;var _0x2e163a=_0x488c[_0x2cc437];return _0x2e163a;};'use strict';var _=require('lodash');var util=require(_0xc488('0x0'));var logger=require(_0xc488('0x1'))('api');var moment=require(_0xc488('0x2'));var BPromise=require(_0xc488('0x3'));var rp=require(_0xc488('0x4'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require('./openchannelQueue.attributes');module[_0xc488('0x5')]=function(_0xd216fa,_0x3db0fe){return _0xd216fa['define']('OpenchannelQueue',attributes,{'tableName':_0xc488('0x6'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.rpc.js b/server/api/openchannelQueue/openchannelQueue.rpc.js new file mode 100644 index 0000000..b89e73e --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbd6e=['rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','then','info','OpenchannelQueue,\x20%s,\x20%s','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','attributes','limit','include','map','model','ShowOpenchannelQueue','find','raw','where','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger'];(function(_0x29a535,_0x227a89){var _0x1b3d33=function(_0x56e502){while(--_0x56e502){_0x29a535['push'](_0x29a535['shift']());}};_0x1b3d33(++_0x227a89);}(_0xbd6e,0x71));var _0xebd6=function(_0x4228d0,_0x1ab712){_0x4228d0=_0x4228d0-0x0;var _0x38435c=_0xbd6e[_0x4228d0];return _0x38435c;};'use strict';var _=require('lodash');var util=require(_0xebd6('0x0'));var moment=require(_0xebd6('0x1'));var BPromise=require(_0xebd6('0x2'));var rs=require(_0xebd6('0x3'));var fs=require('fs');var Redis=require(_0xebd6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xebd6('0x5'));var logger=require(_0xebd6('0x6'))(_0xebd6('0x7'));var config=require('../../config/environment');var jayson=require(_0xebd6('0x8'));var client=jayson[_0xebd6('0x9')][_0xebd6('0xa')]({'port':0x232a});config['redis']=_[_0xebd6('0xb')](config[_0xebd6('0xc')],{'host':_0xebd6('0xd'),'port':0x18eb});var socket=require(_0xebd6('0xe'))(new Redis(config[_0xebd6('0xc')]));require('./openchannelQueue.socket')[_0xebd6('0xf')](socket);function respondWithRpcPromise(_0x12abc4,_0x5a6ffd,_0x2f241b){return new BPromise(function(_0x4f554b,_0x61e494){return client['request'](_0x12abc4,_0x2f241b)[_0xebd6('0x10')](function(_0x36c631){logger[_0xebd6('0x11')](_0xebd6('0x12'),_0x5a6ffd,'request\x20sent');logger[_0xebd6('0x13')](_0xebd6('0x14'),_0x5a6ffd,'request\x20sent',JSON[_0xebd6('0x15')](_0x36c631));if(_0x36c631[_0xebd6('0x16')]){if(_0x36c631['error'][_0xebd6('0x17')]===0x1f4){logger[_0xebd6('0x16')](_0xebd6('0x12'),_0x5a6ffd,_0x36c631[_0xebd6('0x16')]['message']);return _0x61e494(_0x36c631['error'][_0xebd6('0x18')]);}logger[_0xebd6('0x16')](_0xebd6('0x12'),_0x5a6ffd,_0x36c631[_0xebd6('0x16')][_0xebd6('0x18')]);return _0x4f554b(_0x36c631[_0xebd6('0x16')][_0xebd6('0x18')]);}else{logger[_0xebd6('0x11')](_0xebd6('0x12'),_0x5a6ffd,'request\x20sent');_0x4f554b(_0x36c631[_0xebd6('0x19')][_0xebd6('0x18')]);}})[_0xebd6('0x1a')](function(_0xd29d8c){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x5a6ffd,_0xd29d8c);_0x61e494(_0xd29d8c);});});}exports[_0xebd6('0x1b')]=function(_0x1b5de2){var _0x348824=this;return new Promise(function(_0x1f12da,_0x5a11b7){return db[_0xebd6('0x1c')][_0xebd6('0x1d')]({'raw':_0x1b5de2['options']?_0x1b5de2['options']['raw']===undefined?!![]:![]:!![],'where':_0x1b5de2[_0xebd6('0x1e')]?_0x1b5de2[_0xebd6('0x1e')]['where']||null:null,'attributes':_0x1b5de2[_0xebd6('0x1e')]?_0x1b5de2[_0xebd6('0x1e')][_0xebd6('0x1f')]||null:null,'limit':_0x1b5de2[_0xebd6('0x1e')]?_0x1b5de2['options'][_0xebd6('0x20')]||null:null,'include':_0x1b5de2[_0xebd6('0x1e')]?_0x1b5de2[_0xebd6('0x1e')][_0xebd6('0x21')]?_[_0xebd6('0x22')](_0x1b5de2[_0xebd6('0x1e')][_0xebd6('0x21')],function(_0x13c6b2){return{'model':db[_0x13c6b2['model']],'as':_0x13c6b2['as'],'attributes':_0x13c6b2[_0xebd6('0x1f')],'include':_0x13c6b2[_0xebd6('0x21')]?_[_0xebd6('0x22')](_0x13c6b2[_0xebd6('0x21')],function(_0x295bba){return{'model':db[_0x295bba[_0xebd6('0x23')]],'as':_0x295bba['as'],'attributes':_0x295bba[_0xebd6('0x1f')],'include':_0x295bba[_0xebd6('0x21')]?_[_0xebd6('0x22')](_0x295bba[_0xebd6('0x21')],function(_0x32f459){return{'model':db[_0x32f459[_0xebd6('0x23')]],'as':_0x32f459['as'],'attributes':_0x32f459[_0xebd6('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x325aab){logger[_0xebd6('0x11')](_0xebd6('0x1b'),_0x1b5de2);logger[_0xebd6('0x13')](_0xebd6('0x1b'),_0x1b5de2,JSON[_0xebd6('0x15')](_0x325aab));_0x1f12da(_0x325aab);})[_0xebd6('0x1a')](function(_0x49917d){logger[_0xebd6('0x16')](_0xebd6('0x1b'),_0x49917d[_0xebd6('0x18')],_0x1b5de2);_0x5a11b7(_0x348824[_0xebd6('0x16')](0x1f4,_0x49917d['message']));});});};exports[_0xebd6('0x24')]=function(_0x1ca99f){var _0x447499=this;return new Promise(function(_0x236042,_0x57b61e){return db[_0xebd6('0x1c')][_0xebd6('0x25')]({'raw':_0x1ca99f[_0xebd6('0x1e')]?_0x1ca99f['options'][_0xebd6('0x26')]===undefined?!![]:![]:!![],'where':_0x1ca99f[_0xebd6('0x1e')]?_0x1ca99f['options'][_0xebd6('0x27')]||null:null,'attributes':_0x1ca99f[_0xebd6('0x1e')]?_0x1ca99f[_0xebd6('0x1e')][_0xebd6('0x1f')]||null:null,'include':_0x1ca99f[_0xebd6('0x1e')]?_0x1ca99f[_0xebd6('0x1e')][_0xebd6('0x21')]?_['map'](_0x1ca99f['options']['include'],function(_0x48f77f){return{'model':db[_0x48f77f[_0xebd6('0x23')]],'as':_0x48f77f['as'],'attributes':_0x48f77f[_0xebd6('0x1f')],'include':_0x48f77f[_0xebd6('0x21')]?_['map'](_0x48f77f[_0xebd6('0x21')],function(_0x2c75c0){return{'model':db[_0x2c75c0[_0xebd6('0x23')]],'as':_0x2c75c0['as'],'attributes':_0x2c75c0[_0xebd6('0x1f')],'include':_0x2c75c0['include']?_[_0xebd6('0x22')](_0x2c75c0[_0xebd6('0x21')],function(_0x287ae7){return{'model':db[_0x287ae7[_0xebd6('0x23')]],'as':_0x287ae7['as'],'attributes':_0x287ae7[_0xebd6('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1bc45e){logger[_0xebd6('0x11')]('ShowOpenchannelQueue',_0x1ca99f);logger[_0xebd6('0x13')]('ShowOpenchannelQueue',_0x1ca99f,JSON[_0xebd6('0x15')](_0x1bc45e));_0x236042(_0x1bc45e);})['catch'](function(_0x137864){logger[_0xebd6('0x16')](_0xebd6('0x24'),_0x137864[_0xebd6('0x18')],_0x1ca99f);_0x57b61e(_0x447499['error'](0x1f4,_0x137864[_0xebd6('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/openchannelQueue/openchannelQueue.socket.js b/server/api/openchannelQueue/openchannelQueue.socket.js new file mode 100644 index 0000000..ad9f9a0 --- /dev/null +++ b/server/api/openchannelQueue/openchannelQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7b0a=['openchannelQueue:','./openchannelQueue.events','save','update','emit','removeListener','length'];(function(_0x6b8e6,_0x5b5b8d){var _0x11e8d9=function(_0x27609b){while(--_0x27609b){_0x6b8e6['push'](_0x6b8e6['shift']());}};_0x11e8d9(++_0x5b5b8d);}(_0x7b0a,0x143));var _0xa7b0=function(_0x561074,_0x4c03f4){_0x561074=_0x561074-0x0;var _0x5103d7=_0x7b0a[_0x561074];return _0x5103d7;};'use strict';var OpenchannelQueueEvents=require(_0xa7b0('0x0'));var events=[_0xa7b0('0x1'),'remove',_0xa7b0('0x2')];function createListener(_0x49074e,_0x370475){return function(_0x520f99){_0x370475[_0xa7b0('0x3')](_0x49074e,_0x520f99);};}function removeListener(_0x155de3,_0x6ea282){return function(){OpenchannelQueueEvents[_0xa7b0('0x4')](_0x155de3,_0x6ea282);};}exports['register']=function(_0x411f23){for(var _0xce91a1=0x0,_0x455631=events[_0xa7b0('0x5')];_0xce91a1<_0x455631;_0xce91a1++){var _0x2b6f25=events[_0xce91a1];var _0x59a921=createListener(_0xa7b0('0x6')+_0x2b6f25,_0x411f23);OpenchannelQueueEvents['on'](_0x2b6f25,_0x59a921);}}; \ No newline at end of file diff --git a/server/api/openchannelQueueReport/index.js b/server/api/openchannelQueueReport/index.js new file mode 100644 index 0000000..422d40d --- /dev/null +++ b/server/api/openchannelQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x02b3=['connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./openchannelQueueReport.controller','get','index','isAuthenticated','describe','/:id','show','post','create','update','destroy','exports','multer','util','path'];(function(_0x3cc16d,_0x2a569c){var _0x13c29c=function(_0x32e098){while(--_0x32e098){_0x3cc16d['push'](_0x3cc16d['shift']());}};_0x13c29c(++_0x2a569c);}(_0x02b3,0x115));var _0x302b=function(_0x5d2803,_0xf375bd){_0x5d2803=_0x5d2803-0x0;var _0xdcad2c=_0x02b3[_0x5d2803];return _0xdcad2c;};'use strict';var multer=require(_0x302b('0x0'));var util=require(_0x302b('0x1'));var path=require(_0x302b('0x2'));var timeout=require(_0x302b('0x3'));var express=require('express');var router=express[_0x302b('0x4')]();var fs_extra=require(_0x302b('0x5'));var auth=require(_0x302b('0x6'));var interaction=require(_0x302b('0x7'));var config=require('../../config/environment');var controller=require(_0x302b('0x8'));router[_0x302b('0x9')]('/',auth['isAuthenticated'](),controller[_0x302b('0xa')]);router[_0x302b('0x9')]('/describe',auth[_0x302b('0xb')](),controller[_0x302b('0xc')]);router[_0x302b('0x9')](_0x302b('0xd'),auth['isAuthenticated'](),controller[_0x302b('0xe')]);router[_0x302b('0xf')]('/',auth['isAuthenticated'](),controller[_0x302b('0x10')]);router['put'](_0x302b('0xd'),auth[_0x302b('0xb')](),controller[_0x302b('0x11')]);router['delete']('/:id',auth[_0x302b('0xb')](),controller[_0x302b('0x12')]);module[_0x302b('0x13')]=router; \ No newline at end of file diff --git a/server/api/openchannelQueueReport/openchannelQueueReport.attributes.js b/server/api/openchannelQueueReport/openchannelQueueReport.attributes.js new file mode 100644 index 0000000..3c1af20 --- /dev/null +++ b/server/api/openchannelQueueReport/openchannelQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7579=['STRING','DATE','moment','sequelize','exports'];(function(_0x2b7764,_0x2606f1){var _0x848dcb=function(_0x1ae85b){while(--_0x1ae85b){_0x2b7764['push'](_0x2b7764['shift']());}};_0x848dcb(++_0x2606f1);}(_0x7579,0x1e2));var _0x9757=function(_0x5d3ba7,_0x451333){_0x5d3ba7=_0x5d3ba7-0x0;var _0xe9fb2=_0x7579[_0x5d3ba7];return _0xe9fb2;};'use strict';var moment=require(_0x9757('0x0'));var Sequelize=require(_0x9757('0x1'));module[_0x9757('0x2')]={'uniqueid':{'type':Sequelize[_0x9757('0x3')],'allowNull':![]},'from':{'type':Sequelize[_0x9757('0x3')]},'joinAt':{'type':Sequelize[_0x9757('0x4')]},'leaveAt':{'type':Sequelize['DATE']},'acceptAt':{'type':Sequelize[_0x9757('0x4')]},'exitAt':{'type':Sequelize[_0x9757('0x4')]},'reason':{'type':Sequelize[_0x9757('0x3')]}}; \ No newline at end of file diff --git a/server/api/openchannelQueueReport/openchannelQueueReport.controller.js b/server/api/openchannelQueueReport/openchannelQueueReport.controller.js new file mode 100644 index 0000000..83508b5 --- /dev/null +++ b/server/api/openchannelQueueReport/openchannelQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x58f3=['attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','OpenchannelQueueReport','include','rows','show','params','rawAttributes','length','includeAll','options','find','catch','create','body','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','apply','reject','save','update','then','destroy','error','stack','name','send','map','fieldName','type','key','query','keys','filters','model'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x58f3,0x103));var _0x358f=function(_0x47a14e,_0x4701d1){_0x47a14e=_0x47a14e-0x0;var _0x3499e1=_0x58f3[_0x47a14e];return _0x3499e1;};'use strict';var emlformat=require(_0x358f('0x0'));var rimraf=require(_0x358f('0x1'));var zipdir=require(_0x358f('0x2'));var jsonpatch=require(_0x358f('0x3'));var rp=require(_0x358f('0x4'));var moment=require(_0x358f('0x5'));var BPromise=require(_0x358f('0x6'));var Mustache=require(_0x358f('0x7'));var util=require(_0x358f('0x8'));var path=require(_0x358f('0x9'));var sox=require(_0x358f('0xa'));var csv=require(_0x358f('0xb'));var ejs=require(_0x358f('0xc'));var fs=require('fs');var fs_extra=require(_0x358f('0xd'));var _=require(_0x358f('0xe'));var squel=require(_0x358f('0xf'));var crypto=require(_0x358f('0x10'));var jsforce=require(_0x358f('0x11'));var deskjs=require('desk.js');var toCsv=require(_0x358f('0xb'));var querystring=require(_0x358f('0x12'));var Papa=require(_0x358f('0x13'));var Redis=require(_0x358f('0x14'));var authService=require(_0x358f('0x15'));var qs=require(_0x358f('0x16'));var as=require(_0x358f('0x17'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x358f('0x18'))('api');var utils=require('../../config/utils');var config=require(_0x358f('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x358f('0x1a'))['db'];function respondWithStatusCode(_0x13605d,_0x14bceb){_0x14bceb=_0x14bceb||0xcc;return function(_0x29bf5a){if(_0x29bf5a){return _0x13605d[_0x358f('0x1b')](_0x14bceb);}return _0x13605d[_0x358f('0x1c')](_0x14bceb)[_0x358f('0x1d')]();};}function respondWithResult(_0x368ab5,_0x57c005){_0x57c005=_0x57c005||0xc8;return function(_0x4632ae){if(_0x4632ae){return _0x368ab5['status'](_0x57c005)[_0x358f('0x1e')](_0x4632ae);}};}function respondWithFilteredResult(_0x404567,_0x1f554d){return function(_0x549a6d){if(_0x549a6d){var _0x14d4f9=typeof _0x1f554d[_0x358f('0x1f')]==='undefined'&&typeof _0x1f554d[_0x358f('0x20')]==='undefined';var _0x7978ba=_0x549a6d[_0x358f('0x21')];var _0x893b4d=_0x14d4f9?0x0:_0x1f554d[_0x358f('0x1f')];var _0x36dd0a=_0x14d4f9?_0x549a6d[_0x358f('0x21')]:_0x1f554d[_0x358f('0x1f')]+_0x1f554d[_0x358f('0x20')];var _0x250867;if(_0x36dd0a>=_0x7978ba){_0x36dd0a=_0x7978ba;_0x250867=0xc8;}else{_0x250867=0xce;}_0x404567[_0x358f('0x1c')](_0x250867);return _0x404567[_0x358f('0x22')]('Content-Range',_0x893b4d+'-'+_0x36dd0a+'/'+_0x7978ba)[_0x358f('0x1e')](_0x549a6d);}return null;};}function patchUpdates(_0x455033){return function(_0x104bf6){try{jsonpatch[_0x358f('0x23')](_0x104bf6,_0x455033,!![]);}catch(_0x2b5d04){return BPromise[_0x358f('0x24')](_0x2b5d04);}return _0x104bf6[_0x358f('0x25')]();};}function saveUpdates(_0x40a717,_0x2e4868){return function(_0x2e346a){if(_0x2e346a){return _0x2e346a[_0x358f('0x26')](_0x40a717)[_0x358f('0x27')](function(_0x57f043){return _0x57f043;});}return null;};}function removeEntity(_0x1fc19e,_0x4f2282){return function(_0x4a9035){if(_0x4a9035){return _0x4a9035[_0x358f('0x28')]()[_0x358f('0x27')](function(){_0x1fc19e[_0x358f('0x1c')](0xcc)[_0x358f('0x1d')]();});}};}function handleEntityNotFound(_0x1ee5ab,_0x3698a2){return function(_0x33798e){if(!_0x33798e){_0x1ee5ab['sendStatus'](0x194);}return _0x33798e;};}function handleError(_0x212cfd,_0x195a8d){_0x195a8d=_0x195a8d||0x1f4;return function(_0x56ad41){logger[_0x358f('0x29')](_0x56ad41[_0x358f('0x2a')]);if(_0x56ad41[_0x358f('0x2b')]){delete _0x56ad41[_0x358f('0x2b')];}_0x212cfd['status'](_0x195a8d)[_0x358f('0x2c')](_0x56ad41);};}exports['index']=function(_0x378367,_0x299500){var _0x22c40b={},_0x3a123a={},_0x4dcdf5={'count':0x0,'rows':[]};var _0x225d1c=_[_0x358f('0x2d')](db['OpenchannelQueueReport']['rawAttributes'],function(_0x8d9766){return{'name':_0x8d9766[_0x358f('0x2e')],'type':_0x8d9766[_0x358f('0x2f')][_0x358f('0x30')]};});_0x3a123a['model']=_[_0x358f('0x2d')](_0x225d1c,'name');_0x3a123a[_0x358f('0x31')]=_[_0x358f('0x32')](_0x378367[_0x358f('0x31')]);_0x3a123a[_0x358f('0x33')]=_['intersection'](_0x3a123a[_0x358f('0x34')],_0x3a123a[_0x358f('0x31')]);_0x22c40b[_0x358f('0x35')]=_[_0x358f('0x36')](_0x3a123a['model'],qs[_0x358f('0x37')](_0x378367[_0x358f('0x31')][_0x358f('0x37')]));_0x22c40b[_0x358f('0x35')]=_0x22c40b[_0x358f('0x35')]['length']?_0x22c40b[_0x358f('0x35')]:_0x3a123a[_0x358f('0x34')];if(!_0x378367[_0x358f('0x31')][_0x358f('0x38')](_0x358f('0x39'))){_0x22c40b['limit']=qs[_0x358f('0x20')](_0x378367[_0x358f('0x31')][_0x358f('0x20')]);_0x22c40b[_0x358f('0x1f')]=qs[_0x358f('0x1f')](_0x378367[_0x358f('0x31')]['offset']);}_0x22c40b[_0x358f('0x3a')]=qs[_0x358f('0x3b')](_0x378367['query']['sort']);_0x22c40b[_0x358f('0x3c')]=qs[_0x358f('0x33')](_[_0x358f('0x3d')](_0x378367[_0x358f('0x31')],_0x3a123a['filters']),_0x225d1c);if(_0x378367['query'][_0x358f('0x3e')]){_0x22c40b[_0x358f('0x3c')]=_[_0x358f('0x3f')](_0x22c40b[_0x358f('0x3c')],{'$or':_[_0x358f('0x2d')](_0x225d1c,function(_0x4d9291){if(_0x4d9291[_0x358f('0x2f')]!=='VIRTUAL'){var _0x45d975={};_0x45d975[_0x4d9291[_0x358f('0x2b')]]={'$like':'%'+_0x378367[_0x358f('0x31')][_0x358f('0x3e')]+'%'};return _0x45d975;}})});}_0x22c40b=_[_0x358f('0x3f')]({},_0x22c40b,_0x378367['options']);var _0x34bf93={'where':_0x22c40b[_0x358f('0x3c')]};return db[_0x358f('0x40')][_0x358f('0x21')](_0x34bf93)['then'](function(_0x3c282a){_0x4dcdf5[_0x358f('0x21')]=_0x3c282a;if(_0x378367[_0x358f('0x31')]['includeAll']){_0x22c40b[_0x358f('0x41')]=[{'all':!![]}];}return db[_0x358f('0x40')]['findAll'](_0x22c40b);})[_0x358f('0x27')](function(_0x2525c7){_0x4dcdf5[_0x358f('0x42')]=_0x2525c7;return _0x4dcdf5;})[_0x358f('0x27')](respondWithFilteredResult(_0x299500,_0x22c40b))['catch'](handleError(_0x299500,null));};exports[_0x358f('0x43')]=function(_0x18b2a3,_0x1bebd5){var _0x2deeed={'raw':!![],'where':{'id':_0x18b2a3[_0x358f('0x44')]['id']}},_0x40fb18={};_0x40fb18[_0x358f('0x34')]=_['keys'](db[_0x358f('0x40')][_0x358f('0x45')]);_0x40fb18[_0x358f('0x31')]=_[_0x358f('0x32')](_0x18b2a3[_0x358f('0x31')]);_0x40fb18[_0x358f('0x33')]=_[_0x358f('0x36')](_0x40fb18[_0x358f('0x34')],_0x40fb18['query']);_0x2deeed[_0x358f('0x35')]=_['intersection'](_0x40fb18[_0x358f('0x34')],qs['fields'](_0x18b2a3[_0x358f('0x31')][_0x358f('0x37')]));_0x2deeed['attributes']=_0x2deeed[_0x358f('0x35')][_0x358f('0x46')]?_0x2deeed[_0x358f('0x35')]:_0x40fb18[_0x358f('0x34')];if(_0x18b2a3[_0x358f('0x31')][_0x358f('0x47')]){_0x2deeed[_0x358f('0x41')]=[{'all':!![]}];}_0x2deeed=_[_0x358f('0x3f')]({},_0x2deeed,_0x18b2a3[_0x358f('0x48')]);return db['OpenchannelQueueReport'][_0x358f('0x49')](_0x2deeed)['then'](handleEntityNotFound(_0x1bebd5,null))[_0x358f('0x27')](respondWithResult(_0x1bebd5,null))[_0x358f('0x4a')](handleError(_0x1bebd5,null));};exports[_0x358f('0x4b')]=function(_0x41761e,_0x4a2b5e){return db[_0x358f('0x40')][_0x358f('0x4b')](_0x41761e[_0x358f('0x4c')],{})[_0x358f('0x27')](respondWithResult(_0x4a2b5e,0xc9))[_0x358f('0x4a')](handleError(_0x4a2b5e,null));};exports['update']=function(_0x54010c,_0x2d4656){if(_0x54010c[_0x358f('0x4c')]['id']){delete _0x54010c['body']['id'];}return db[_0x358f('0x40')][_0x358f('0x49')]({'where':{'id':_0x54010c['params']['id']}})[_0x358f('0x27')](handleEntityNotFound(_0x2d4656,null))[_0x358f('0x27')](saveUpdates(_0x54010c[_0x358f('0x4c')],null))['then'](respondWithResult(_0x2d4656,null))['catch'](handleError(_0x2d4656,null));};exports[_0x358f('0x28')]=function(_0x50fa8e,_0x30b54e){return db[_0x358f('0x40')]['find']({'where':{'id':_0x50fa8e[_0x358f('0x44')]['id']}})[_0x358f('0x27')](handleEntityNotFound(_0x30b54e,null))[_0x358f('0x27')](removeEntity(_0x30b54e,null))[_0x358f('0x4a')](handleError(_0x30b54e,null));};exports[_0x358f('0x4d')]=function(_0x42eba8,_0x3f218b){return db[_0x358f('0x40')][_0x358f('0x4d')]()['then'](respondWithResult(_0x3f218b,null))[_0x358f('0x4a')](handleError(_0x3f218b,null));}; \ No newline at end of file diff --git a/server/api/openchannelQueueReport/openchannelQueueReport.model.js b/server/api/openchannelQueueReport/openchannelQueueReport.model.js new file mode 100644 index 0000000..479338f --- /dev/null +++ b/server/api/openchannelQueueReport/openchannelQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./openchannelQueueReport.attributes','define','report_openchannel_queue','uniqueid','util'];(function(_0x121ca9,_0x32bc76){var _0xbf761b=function(_0x292204){while(--_0x292204){_0x121ca9['push'](_0x121ca9['shift']());}};_0xbf761b(++_0x32bc76);}(_0x1261,0x144));var _0x1126=function(_0x51df00,_0x4ac573){_0x51df00=_0x51df00-0x0;var _0x198328=_0x1261[_0x51df00];return _0x198328;};'use strict';var _=require('lodash');var util=require(_0x1126('0x0'));var logger=require(_0x1126('0x1'))(_0x1126('0x2'));var moment=require(_0x1126('0x3'));var BPromise=require(_0x1126('0x4'));var rp=require(_0x1126('0x5'));var fs=require('fs');var path=require(_0x1126('0x6'));var rimraf=require(_0x1126('0x7'));var config=require(_0x1126('0x8'));var attributes=require(_0x1126('0x9'));module['exports']=function(_0x5c68c8,_0x40ba58){return _0x5c68c8[_0x1126('0xa')]('OpenchannelQueueReport',attributes,{'tableName':_0x1126('0xb'),'paranoid':![],'indexes':[{'name':_0x1126('0xc'),'fields':[_0x1126('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/openchannelQueueReport/openchannelQueueReport.rpc.js b/server/api/openchannelQueueReport/openchannelQueueReport.rpc.js new file mode 100644 index 0000000..5e40d8c --- /dev/null +++ b/server/api/openchannelQueueReport/openchannelQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x84a0=['OpenchannelQueueReport','create','body','options','raw','CreateOpenchannelQueueReport','UpdateOpenchannelQueueReport','update','attributes','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','client','http','request','then','info','debug','OpenchannelQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','OpenchannelQueueReport,\x20%s,\x20%s','message','result','catch'];(function(_0x34e4a0,_0x1fd446){var _0x3ead3e=function(_0x47adec){while(--_0x47adec){_0x34e4a0['push'](_0x34e4a0['shift']());}};_0x3ead3e(++_0x1fd446);}(_0x84a0,0x66));var _0x084a=function(_0x5b67be,_0x59f4c5){_0x5b67be=_0x5b67be-0x0;var _0x383225=_0x84a0[_0x5b67be];return _0x383225;};'use strict';var _=require(_0x084a('0x0'));var util=require(_0x084a('0x1'));var moment=require(_0x084a('0x2'));var BPromise=require(_0x084a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x084a('0x4'));var db=require(_0x084a('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x084a('0x6'));var config=require(_0x084a('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x084a('0x8')][_0x084a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2e6810,_0x373d2,_0x2b30bc){return new BPromise(function(_0x58d419,_0x1051a9){return client[_0x084a('0xa')](_0x2e6810,_0x2b30bc)[_0x084a('0xb')](function(_0x2888e3){logger[_0x084a('0xc')]('OpenchannelQueueReport,\x20%s,\x20%s',_0x373d2,'request\x20sent');logger[_0x084a('0xd')](_0x084a('0xe'),_0x373d2,_0x084a('0xf'),JSON[_0x084a('0x10')](_0x2888e3));if(_0x2888e3[_0x084a('0x11')]){if(_0x2888e3['error']['code']===0x1f4){logger[_0x084a('0x11')](_0x084a('0x12'),_0x373d2,_0x2888e3[_0x084a('0x11')][_0x084a('0x13')]);return _0x1051a9(_0x2888e3[_0x084a('0x11')][_0x084a('0x13')]);}logger[_0x084a('0x11')](_0x084a('0x12'),_0x373d2,_0x2888e3['error'][_0x084a('0x13')]);return _0x58d419(_0x2888e3['error'][_0x084a('0x13')]);}else{logger[_0x084a('0xc')](_0x084a('0x12'),_0x373d2,_0x084a('0xf'));_0x58d419(_0x2888e3[_0x084a('0x14')]['message']);}})[_0x084a('0x15')](function(_0x4abd81){logger[_0x084a('0x11')](_0x084a('0x12'),_0x373d2,_0x4abd81);_0x1051a9(_0x4abd81);});});}exports['CreateOpenchannelQueueReport']=function(_0xf2c333){var _0x32c729=this;return new Promise(function(_0x4134b9,_0x14bb19){return db[_0x084a('0x16')][_0x084a('0x17')](_0xf2c333[_0x084a('0x18')],{'raw':_0xf2c333[_0x084a('0x19')]?_0xf2c333[_0x084a('0x19')][_0x084a('0x1a')]===undefined?!![]:![]:!![]})[_0x084a('0xb')](function(_0x279e25){logger[_0x084a('0xc')](_0x084a('0x1b'),_0xf2c333);logger[_0x084a('0xd')]('CreateOpenchannelQueueReport',_0xf2c333,JSON[_0x084a('0x10')](_0x279e25));_0x4134b9(_0x279e25);})[_0x084a('0x15')](function(_0x41a90f){logger[_0x084a('0x11')](_0x084a('0x1b'),_0x41a90f['message'],_0xf2c333);_0x14bb19(_0x32c729[_0x084a('0x11')](0x1f4,_0x41a90f[_0x084a('0x13')]));});});};exports[_0x084a('0x1c')]=function(_0x1f2c9f){var _0x18b43d=this;return new Promise(function(_0x3cdc1e,_0x5be167){return db[_0x084a('0x16')][_0x084a('0x1d')](_0x1f2c9f[_0x084a('0x18')],{'raw':_0x1f2c9f['options']?_0x1f2c9f[_0x084a('0x19')][_0x084a('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1f2c9f[_0x084a('0x19')]?_0x1f2c9f['options']['where']||null:null,'attributes':_0x1f2c9f['options']?_0x1f2c9f['options'][_0x084a('0x1e')]||null:null,'limit':_0x1f2c9f['options']?_0x1f2c9f['options']['limit']||null:null})[_0x084a('0xb')](function(_0x4651e6){logger[_0x084a('0xc')](_0x084a('0x1c'),_0x1f2c9f);logger[_0x084a('0xd')](_0x084a('0x1c'),_0x1f2c9f,JSON[_0x084a('0x10')](_0x4651e6));_0x3cdc1e(_0x4651e6);})[_0x084a('0x15')](function(_0x5e6ea8){logger[_0x084a('0x11')](_0x084a('0x1c'),_0x5e6ea8['message'],_0x1f2c9f);_0x5be167(_0x18b43d[_0x084a('0x11')](0x1f4,_0x5e6ea8[_0x084a('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/openchannelTransferReport/index.js b/server/api/openchannelTransferReport/index.js new file mode 100644 index 0000000..5f3557a --- /dev/null +++ b/server/api/openchannelTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9dcc=['delete','exports','multer','util','path','express','Router','fs-extra','../../components/interaction/service','../../config/environment','./openchannelTransferReport.controller','index','/describe','isAuthenticated','describe','get','/:id','show','post','put','update'];(function(_0x436ddb,_0x25443d){var _0x40a778=function(_0x18a2aa){while(--_0x18a2aa){_0x436ddb['push'](_0x436ddb['shift']());}};_0x40a778(++_0x25443d);}(_0x9dcc,0x1d0));var _0xc9dc=function(_0x58a18a,_0x1d948a){_0x58a18a=_0x58a18a-0x0;var _0x504330=_0x9dcc[_0x58a18a];return _0x504330;};'use strict';var multer=require(_0xc9dc('0x0'));var util=require(_0xc9dc('0x1'));var path=require(_0xc9dc('0x2'));var timeout=require('connect-timeout');var express=require(_0xc9dc('0x3'));var router=express[_0xc9dc('0x4')]();var fs_extra=require(_0xc9dc('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0xc9dc('0x6'));var config=require(_0xc9dc('0x7'));var controller=require(_0xc9dc('0x8'));router['get']('/',auth['isAuthenticated'](),controller[_0xc9dc('0x9')]);router['get'](_0xc9dc('0xa'),auth[_0xc9dc('0xb')](),controller[_0xc9dc('0xc')]);router[_0xc9dc('0xd')](_0xc9dc('0xe'),auth[_0xc9dc('0xb')](),controller[_0xc9dc('0xf')]);router[_0xc9dc('0x10')]('/',auth['isAuthenticated'](),controller['create']);router[_0xc9dc('0x11')]('/:id',auth[_0xc9dc('0xb')](),controller[_0xc9dc('0x12')]);router[_0xc9dc('0x13')](_0xc9dc('0xe'),auth[_0xc9dc('0xb')](),controller['destroy']);module[_0xc9dc('0x14')]=router; \ No newline at end of file diff --git a/server/api/openchannelTransferReport/openchannelTransferReport.attributes.js b/server/api/openchannelTransferReport/openchannelTransferReport.attributes.js new file mode 100644 index 0000000..151250d --- /dev/null +++ b/server/api/openchannelTransferReport/openchannelTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf4eb=['NOW','moment','account','queue','DATE'];(function(_0x1da515,_0x56f169){var _0x1feff4=function(_0x580abe){while(--_0x580abe){_0x1da515['push'](_0x1da515['shift']());}};_0x1feff4(++_0x56f169);}(_0xf4eb,0xec));var _0xbf4e=function(_0x592cdd,_0x421fd2){_0x592cdd=_0x592cdd-0x0;var _0x36db80=_0xf4eb[_0x592cdd];return _0x36db80;};'use strict';var moment=require(_0xbf4e('0x0'));var Sequelize=require('sequelize');module['exports']={'uniqueid':{'type':Sequelize['STRING'],'allowNull':![]},'type':{'type':Sequelize['ENUM'](_0xbf4e('0x1'),'agent','queue'),'allowNull':![],'defaultValue':_0xbf4e('0x2')},'transferredAt':{'type':Sequelize[_0xbf4e('0x3')],'allowNull':![],'defaultValue':Sequelize[_0xbf4e('0x4')]}}; \ No newline at end of file diff --git a/server/api/openchannelTransferReport/openchannelTransferReport.controller.js b/server/api/openchannelTransferReport/openchannelTransferReport.controller.js new file mode 100644 index 0000000..4dfd4ee --- /dev/null +++ b/server/api/openchannelTransferReport/openchannelTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x81dc=['bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','apply','reject','save','update','stack','name','send','index','map','OpenchannelTransferReport','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','merge','options','includeAll','include','findAll','then','catch','show','params','find','create','body','destroy','describe','eml-format','zip-dir','fast-json-patch','request-promise','moment'];(function(_0x541260,_0x4c7f2e){var _0x1dd2b5=function(_0x4140de){while(--_0x4140de){_0x541260['push'](_0x541260['shift']());}};_0x1dd2b5(++_0x4c7f2e);}(_0x81dc,0xdc));var _0xc81d=function(_0x5ce15c,_0x19c917){_0x5ce15c=_0x5ce15c-0x0;var _0x36e4f5=_0x81dc[_0x5ce15c];return _0x36e4f5;};'use strict';var emlformat=require(_0xc81d('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc81d('0x1'));var jsonpatch=require(_0xc81d('0x2'));var rp=require(_0xc81d('0x3'));var moment=require(_0xc81d('0x4'));var BPromise=require(_0xc81d('0x5'));var Mustache=require(_0xc81d('0x6'));var util=require(_0xc81d('0x7'));var path=require(_0xc81d('0x8'));var sox=require(_0xc81d('0x9'));var csv=require(_0xc81d('0xa'));var ejs=require(_0xc81d('0xb'));var fs=require('fs');var fs_extra=require(_0xc81d('0xc'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xc81d('0xd'));var jsforce=require(_0xc81d('0xe'));var deskjs=require(_0xc81d('0xf'));var toCsv=require(_0xc81d('0xa'));var querystring=require('querystring');var Papa=require(_0xc81d('0x10'));var Redis=require(_0xc81d('0x11'));var authService=require(_0xc81d('0x12'));var qs=require(_0xc81d('0x13'));var as=require(_0xc81d('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc81d('0x15'))(_0xc81d('0x16'));var utils=require('../../config/utils');var config=require(_0xc81d('0x17'));var licenseUtil=require(_0xc81d('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4b90a3,_0x165d6d){_0x165d6d=_0x165d6d||0xcc;return function(_0x548fab){if(_0x548fab){return _0x4b90a3[_0xc81d('0x19')](_0x165d6d);}return _0x4b90a3[_0xc81d('0x1a')](_0x165d6d)[_0xc81d('0x1b')]();};}function respondWithResult(_0x446e16,_0x16dcb5){_0x16dcb5=_0x16dcb5||0xc8;return function(_0x30a14a){if(_0x30a14a){return _0x446e16[_0xc81d('0x1a')](_0x16dcb5)[_0xc81d('0x1c')](_0x30a14a);}};}function respondWithFilteredResult(_0x1b8e60,_0x41fc2a){return function(_0x3db0c9){if(_0x3db0c9){var _0xdcd131=typeof _0x41fc2a[_0xc81d('0x1d')]==='undefined'&&typeof _0x41fc2a['limit']===_0xc81d('0x1e');var _0x552aef=_0x3db0c9[_0xc81d('0x1f')];var _0x305e04=_0xdcd131?0x0:_0x41fc2a[_0xc81d('0x1d')];var _0x48da17=_0xdcd131?_0x3db0c9[_0xc81d('0x1f')]:_0x41fc2a[_0xc81d('0x1d')]+_0x41fc2a[_0xc81d('0x20')];var _0x328590;if(_0x48da17>=_0x552aef){_0x48da17=_0x552aef;_0x328590=0xc8;}else{_0x328590=0xce;}_0x1b8e60[_0xc81d('0x1a')](_0x328590);return _0x1b8e60['set']('Content-Range',_0x305e04+'-'+_0x48da17+'/'+_0x552aef)[_0xc81d('0x1c')](_0x3db0c9);}return null;};}function patchUpdates(_0x339b9c){return function(_0x5e53f1){try{jsonpatch[_0xc81d('0x21')](_0x5e53f1,_0x339b9c,!![]);}catch(_0x4f0d1b){return BPromise[_0xc81d('0x22')](_0x4f0d1b);}return _0x5e53f1[_0xc81d('0x23')]();};}function saveUpdates(_0x300ff1,_0x490dc8){return function(_0x16aabe){if(_0x16aabe){return _0x16aabe[_0xc81d('0x24')](_0x300ff1)['then'](function(_0x3b0a19){return _0x3b0a19;});}return null;};}function removeEntity(_0x1944a3,_0xda326c){return function(_0x3392a8){if(_0x3392a8){return _0x3392a8['destroy']()['then'](function(){_0x1944a3[_0xc81d('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2c347d,_0x1572e4){return function(_0x68ded3){if(!_0x68ded3){_0x2c347d[_0xc81d('0x19')](0x194);}return _0x68ded3;};}function handleError(_0x19861c,_0xbba2d4){_0xbba2d4=_0xbba2d4||0x1f4;return function(_0x363e20){logger['error'](_0x363e20[_0xc81d('0x25')]);if(_0x363e20[_0xc81d('0x26')]){delete _0x363e20[_0xc81d('0x26')];}_0x19861c[_0xc81d('0x1a')](_0xbba2d4)[_0xc81d('0x27')](_0x363e20);};}exports[_0xc81d('0x28')]=function(_0x458665,_0x57bce7){var _0x566918={},_0x2b0f70={},_0x5a2408={'count':0x0,'rows':[]};var _0x57703a=_[_0xc81d('0x29')](db[_0xc81d('0x2a')]['rawAttributes'],function(_0x31dcf6){return{'name':_0x31dcf6[_0xc81d('0x2b')],'type':_0x31dcf6[_0xc81d('0x2c')][_0xc81d('0x2d')]};});_0x2b0f70[_0xc81d('0x2e')]=_[_0xc81d('0x29')](_0x57703a,_0xc81d('0x26'));_0x2b0f70[_0xc81d('0x2f')]=_[_0xc81d('0x30')](_0x458665[_0xc81d('0x2f')]);_0x2b0f70[_0xc81d('0x31')]=_[_0xc81d('0x32')](_0x2b0f70[_0xc81d('0x2e')],_0x2b0f70[_0xc81d('0x2f')]);_0x566918['attributes']=_['intersection'](_0x2b0f70[_0xc81d('0x2e')],qs[_0xc81d('0x33')](_0x458665[_0xc81d('0x2f')][_0xc81d('0x33')]));_0x566918[_0xc81d('0x34')]=_0x566918['attributes'][_0xc81d('0x35')]?_0x566918[_0xc81d('0x34')]:_0x2b0f70[_0xc81d('0x2e')];if(!_0x458665[_0xc81d('0x2f')][_0xc81d('0x36')](_0xc81d('0x37'))){_0x566918[_0xc81d('0x20')]=qs[_0xc81d('0x20')](_0x458665[_0xc81d('0x2f')][_0xc81d('0x20')]);_0x566918[_0xc81d('0x1d')]=qs[_0xc81d('0x1d')](_0x458665[_0xc81d('0x2f')]['offset']);}_0x566918[_0xc81d('0x38')]=qs[_0xc81d('0x39')](_0x458665[_0xc81d('0x2f')]['sort']);_0x566918[_0xc81d('0x3a')]=qs[_0xc81d('0x31')](_[_0xc81d('0x3b')](_0x458665[_0xc81d('0x2f')],_0x2b0f70[_0xc81d('0x31')]),_0x57703a);if(_0x458665['query']['filter']){_0x566918['where']=_['merge'](_0x566918[_0xc81d('0x3a')],{'$or':_[_0xc81d('0x29')](_0x57703a,function(_0x58468b){if(_0x58468b[_0xc81d('0x2c')]!==_0xc81d('0x3c')){var _0x16133b={};_0x16133b[_0x58468b[_0xc81d('0x26')]]={'$like':'%'+_0x458665[_0xc81d('0x2f')]['filter']+'%'};return _0x16133b;}})});}_0x566918=_[_0xc81d('0x3d')]({},_0x566918,_0x458665[_0xc81d('0x3e')]);var _0x25f964={'where':_0x566918[_0xc81d('0x3a')]};return db[_0xc81d('0x2a')]['count'](_0x25f964)['then'](function(_0x3ce888){_0x5a2408[_0xc81d('0x1f')]=_0x3ce888;if(_0x458665[_0xc81d('0x2f')][_0xc81d('0x3f')]){_0x566918[_0xc81d('0x40')]=[{'all':!![]}];}return db[_0xc81d('0x2a')][_0xc81d('0x41')](_0x566918);})[_0xc81d('0x42')](function(_0x49b3fa){_0x5a2408['rows']=_0x49b3fa;return _0x5a2408;})[_0xc81d('0x42')](respondWithFilteredResult(_0x57bce7,_0x566918))[_0xc81d('0x43')](handleError(_0x57bce7,null));};exports[_0xc81d('0x44')]=function(_0x45ff3f,_0x90f7e7){var _0x43b2ea={'raw':!![],'where':{'id':_0x45ff3f[_0xc81d('0x45')]['id']}},_0x33b603={};_0x33b603['model']=_[_0xc81d('0x30')](db['OpenchannelTransferReport']['rawAttributes']);_0x33b603[_0xc81d('0x2f')]=_[_0xc81d('0x30')](_0x45ff3f[_0xc81d('0x2f')]);_0x33b603[_0xc81d('0x31')]=_[_0xc81d('0x32')](_0x33b603[_0xc81d('0x2e')],_0x33b603[_0xc81d('0x2f')]);_0x43b2ea[_0xc81d('0x34')]=_['intersection'](_0x33b603[_0xc81d('0x2e')],qs[_0xc81d('0x33')](_0x45ff3f['query'][_0xc81d('0x33')]));_0x43b2ea[_0xc81d('0x34')]=_0x43b2ea[_0xc81d('0x34')]['length']?_0x43b2ea[_0xc81d('0x34')]:_0x33b603[_0xc81d('0x2e')];if(_0x45ff3f['query']['includeAll']){_0x43b2ea[_0xc81d('0x40')]=[{'all':!![]}];}_0x43b2ea=_['merge']({},_0x43b2ea,_0x45ff3f[_0xc81d('0x3e')]);return db[_0xc81d('0x2a')][_0xc81d('0x46')](_0x43b2ea)[_0xc81d('0x42')](handleEntityNotFound(_0x90f7e7,null))['then'](respondWithResult(_0x90f7e7,null))['catch'](handleError(_0x90f7e7,null));};exports[_0xc81d('0x47')]=function(_0x5c0260,_0x1bd23c){return db[_0xc81d('0x2a')]['create'](_0x5c0260['body'],{})['then'](respondWithResult(_0x1bd23c,0xc9))[_0xc81d('0x43')](handleError(_0x1bd23c,null));};exports[_0xc81d('0x24')]=function(_0x2f4c0d,_0x396ff6){if(_0x2f4c0d[_0xc81d('0x48')]['id']){delete _0x2f4c0d['body']['id'];}return db[_0xc81d('0x2a')]['find']({'where':{'id':_0x2f4c0d['params']['id']}})[_0xc81d('0x42')](handleEntityNotFound(_0x396ff6,null))[_0xc81d('0x42')](saveUpdates(_0x2f4c0d['body'],null))['then'](respondWithResult(_0x396ff6,null))['catch'](handleError(_0x396ff6,null));};exports[_0xc81d('0x49')]=function(_0x204d78,_0x34668e){return db[_0xc81d('0x2a')][_0xc81d('0x46')]({'where':{'id':_0x204d78['params']['id']}})[_0xc81d('0x42')](handleEntityNotFound(_0x34668e,null))['then'](removeEntity(_0x34668e,null))[_0xc81d('0x43')](handleError(_0x34668e,null));};exports['describe']=function(_0x3066da,_0xefd06a){return db[_0xc81d('0x2a')][_0xc81d('0x4a')]()[_0xc81d('0x42')](respondWithResult(_0xefd06a,null))[_0xc81d('0x43')](handleError(_0xefd06a,null));}; \ No newline at end of file diff --git a/server/api/openchannelTransferReport/openchannelTransferReport.model.js b/server/api/openchannelTransferReport/openchannelTransferReport.model.js new file mode 100644 index 0000000..a44fab9 --- /dev/null +++ b/server/api/openchannelTransferReport/openchannelTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb5fd=['request-promise','rimraf','../../config/environment','./openchannelTransferReport.attributes','define','report_openchannel_transfer','uniqueid','../../config/logger','api','bluebird'];(function(_0x3e6c7a,_0x36746a){var _0xa990bb=function(_0x50c3e5){while(--_0x50c3e5){_0x3e6c7a['push'](_0x3e6c7a['shift']());}};_0xa990bb(++_0x36746a);}(_0xb5fd,0x1c9));var _0xdb5f=function(_0x4f139f,_0x150de5){_0x4f139f=_0x4f139f-0x0;var _0x24a88b=_0xb5fd[_0x4f139f];return _0x24a88b;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0xdb5f('0x0'))(_0xdb5f('0x1'));var moment=require('moment');var BPromise=require(_0xdb5f('0x2'));var rp=require(_0xdb5f('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0xdb5f('0x4'));var config=require(_0xdb5f('0x5'));var attributes=require(_0xdb5f('0x6'));module['exports']=function(_0x6d762,_0x5731a2){return _0x6d762[_0xdb5f('0x7')]('OpenchannelTransferReport',attributes,{'tableName':_0xdb5f('0x8'),'paranoid':![],'indexes':[{'name':'uniqueid','fields':[_0xdb5f('0x9')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/openchannelTransferReport/openchannelTransferReport.rpc.js b/server/api/openchannelTransferReport/openchannelTransferReport.rpc.js new file mode 100644 index 0000000..9b79cad --- /dev/null +++ b/server/api/openchannelTransferReport/openchannelTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5fc3=['../../config/environment','jayson/promise','request','then','info','request\x20sent','debug','stringify','error','code','message','OpenchannelTransferReport,\x20%s,\x20%s','result','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc'];(function(_0x4085b1,_0x515b5e){var _0x218dc5=function(_0x70bd3b){while(--_0x70bd3b){_0x4085b1['push'](_0x4085b1['shift']());}};_0x218dc5(++_0x515b5e);}(_0x5fc3,0xa8));var _0x35fc=function(_0x2a0183,_0x3fc93c){_0x2a0183=_0x2a0183-0x0;var _0x158c3a=_0x5fc3[_0x2a0183];return _0x158c3a;};'use strict';var _=require(_0x35fc('0x0'));var util=require(_0x35fc('0x1'));var moment=require('moment');var BPromise=require(_0x35fc('0x2'));var rs=require(_0x35fc('0x3'));var fs=require('fs');var Redis=require(_0x35fc('0x4'));var db=require(_0x35fc('0x5'))['db'];var utils=require(_0x35fc('0x6'));var logger=require('../../config/logger')(_0x35fc('0x7'));var config=require(_0x35fc('0x8'));var jayson=require(_0x35fc('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x19a0d1,_0x508b32,_0x16e153){return new BPromise(function(_0x27524f,_0xc72d93){return client[_0x35fc('0xa')](_0x19a0d1,_0x16e153)[_0x35fc('0xb')](function(_0xf9d3a6){logger[_0x35fc('0xc')]('OpenchannelTransferReport,\x20%s,\x20%s',_0x508b32,_0x35fc('0xd'));logger[_0x35fc('0xe')]('OpenchannelTransferReport,\x20%s,\x20%s,\x20%s',_0x508b32,_0x35fc('0xd'),JSON[_0x35fc('0xf')](_0xf9d3a6));if(_0xf9d3a6['error']){if(_0xf9d3a6[_0x35fc('0x10')][_0x35fc('0x11')]===0x1f4){logger['error']('OpenchannelTransferReport,\x20%s,\x20%s',_0x508b32,_0xf9d3a6[_0x35fc('0x10')]['message']);return _0xc72d93(_0xf9d3a6[_0x35fc('0x10')][_0x35fc('0x12')]);}logger[_0x35fc('0x10')](_0x35fc('0x13'),_0x508b32,_0xf9d3a6[_0x35fc('0x10')]['message']);return _0x27524f(_0xf9d3a6['error']['message']);}else{logger['info'](_0x35fc('0x13'),_0x508b32,_0x35fc('0xd'));_0x27524f(_0xf9d3a6[_0x35fc('0x14')][_0x35fc('0x12')]);}})[_0x35fc('0x15')](function(_0x1121fa){logger['error'](_0x35fc('0x13'),_0x508b32,_0x1121fa);_0xc72d93(_0x1121fa);});});} \ No newline at end of file diff --git a/server/api/pause/index.js b/server/api/pause/index.js new file mode 100644 index 0000000..199ce4d --- /dev/null +++ b/server/api/pause/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdeab=['../../components/interaction/service','../../config/environment','get','isAuthenticated','index','/:id','show','post','create','put','update','destroy','util','path','express','Router','fs-extra','../../components/auth/service'];(function(_0x40f142,_0x57d68a){var _0x1b2292=function(_0x228c74){while(--_0x228c74){_0x40f142['push'](_0x40f142['shift']());}};_0x1b2292(++_0x57d68a);}(_0xdeab,0xc0));var _0xbdea=function(_0xc62435,_0x3584e0){_0xc62435=_0xc62435-0x0;var _0x56b63c=_0xdeab[_0xc62435];return _0x56b63c;};'use strict';var multer=require('multer');var util=require(_0xbdea('0x0'));var path=require(_0xbdea('0x1'));var timeout=require('connect-timeout');var express=require(_0xbdea('0x2'));var router=express[_0xbdea('0x3')]();var fs_extra=require(_0xbdea('0x4'));var auth=require(_0xbdea('0x5'));var interaction=require(_0xbdea('0x6'));var config=require(_0xbdea('0x7'));var controller=require('./pause.controller');router[_0xbdea('0x8')]('/',auth[_0xbdea('0x9')](),controller[_0xbdea('0xa')]);router[_0xbdea('0x8')](_0xbdea('0xb'),auth[_0xbdea('0x9')](),controller[_0xbdea('0xc')]);router[_0xbdea('0xd')]('/',auth[_0xbdea('0x9')](),controller[_0xbdea('0xe')]);router[_0xbdea('0xf')]('/:id',auth[_0xbdea('0x9')](),controller[_0xbdea('0x10')]);router['delete'](_0xbdea('0xb'),auth[_0xbdea('0x9')](),controller[_0xbdea('0x11')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/pause/pause.attributes.js b/server/api/pause/pause.attributes.js new file mode 100644 index 0000000..5862ebf --- /dev/null +++ b/server/api/pause/pause.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3be9=['exports','name','STRING','sequelize'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x3be9,0xc3));var _0x93be=function(_0x2f6541,_0x363cba){_0x2f6541=_0x2f6541-0x0;var _0x4d76d8=_0x3be9[_0x2f6541];return _0x4d76d8;};'use strict';var Sequelize=require(_0x93be('0x0'));module[_0x93be('0x1')]={'name':{'type':Sequelize['STRING'],'unique':_0x93be('0x2'),'allowNull':![]},'description':{'type':Sequelize[_0x93be('0x3')]}}; \ No newline at end of file diff --git a/server/api/pause/pause.controller.js b/server/api/pause/pause.controller.js new file mode 100644 index 0000000..5d69a51 --- /dev/null +++ b/server/api/pause/pause.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd7ca=['reject','save','update','then','destroy','Pauses','UserProfileResource','end','error','name','send','index','map','rawAttributes','fieldName','type','keys','filters','model','query','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','Pause','findAll','rows','catch','params','length','include','find','create','user','get','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xd7ca,0x171));var _0xad7c=function(_0x3db375,_0x5099d3){_0x3db375=_0x3db375-0x0;var _0x490cb9=_0xd7ca[_0x3db375];return _0x490cb9;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xad7c('0x0'));var moment=require(_0xad7c('0x1'));var BPromise=require(_0xad7c('0x2'));var Mustache=require(_0xad7c('0x3'));var util=require(_0xad7c('0x4'));var path=require(_0xad7c('0x5'));var sox=require('sox');var csv=require(_0xad7c('0x6'));var ejs=require(_0xad7c('0x7'));var fs=require('fs');var fs_extra=require(_0xad7c('0x8'));var _=require(_0xad7c('0x9'));var squel=require(_0xad7c('0xa'));var crypto=require(_0xad7c('0xb'));var jsforce=require(_0xad7c('0xc'));var deskjs=require(_0xad7c('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xad7c('0xe'));var Redis=require(_0xad7c('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xad7c('0x10'));var logger=require(_0xad7c('0x11'))(_0xad7c('0x12'));var utils=require(_0xad7c('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xad7c('0x14'))['db'];function respondWithStatusCode(_0x9f6693,_0x39df21){_0x39df21=_0x39df21||0xcc;return function(_0x2684c8){if(_0x2684c8){return _0x9f6693[_0xad7c('0x15')](_0x39df21);}return _0x9f6693[_0xad7c('0x16')](_0x39df21)['end']();};}function respondWithResult(_0x35ba8d,_0xd81547){_0xd81547=_0xd81547||0xc8;return function(_0x23247f){if(_0x23247f){return _0x35ba8d[_0xad7c('0x16')](_0xd81547)[_0xad7c('0x17')](_0x23247f);}};}function respondWithFilteredResult(_0x5cc05d,_0x518bab){return function(_0x4ce323){if(_0x4ce323){var _0x48ec67=typeof _0x518bab[_0xad7c('0x18')]===_0xad7c('0x19')&&typeof _0x518bab[_0xad7c('0x1a')]===_0xad7c('0x19');var _0x29080e=_0x4ce323[_0xad7c('0x1b')];var _0x2fdf62=_0x48ec67?0x0:_0x518bab[_0xad7c('0x18')];var _0xaada7b=_0x48ec67?_0x4ce323[_0xad7c('0x1b')]:_0x518bab[_0xad7c('0x18')]+_0x518bab[_0xad7c('0x1a')];var _0x55b12c;if(_0xaada7b>=_0x29080e){_0xaada7b=_0x29080e;_0x55b12c=0xc8;}else{_0x55b12c=0xce;}_0x5cc05d[_0xad7c('0x16')](_0x55b12c);return _0x5cc05d[_0xad7c('0x1c')](_0xad7c('0x1d'),_0x2fdf62+'-'+_0xaada7b+'/'+_0x29080e)['json'](_0x4ce323);}return null;};}function patchUpdates(_0x1ae1ee){return function(_0x2c4289){try{jsonpatch[_0xad7c('0x1e')](_0x2c4289,_0x1ae1ee,!![]);}catch(_0x3a4d80){return BPromise[_0xad7c('0x1f')](_0x3a4d80);}return _0x2c4289[_0xad7c('0x20')]();};}function saveUpdates(_0xac064e,_0x1b4ef0){return function(_0x3f3620){if(_0x3f3620){return _0x3f3620[_0xad7c('0x21')](_0xac064e)[_0xad7c('0x22')](function(_0x40e6e2){return _0x40e6e2;});}return null;};}function removeEntity(_0x394507,_0x2e8598){return function(_0x365ac0){if(_0x365ac0){return _0x365ac0[_0xad7c('0x23')]()[_0xad7c('0x22')](function(){var _0x110d59=_0x365ac0['get']({'plain':!![]});var _0x201591=_0xad7c('0x24');return db[_0xad7c('0x25')]['destroy']({'where':{'type':_0x201591,'resourceId':_0x110d59['id']}})[_0xad7c('0x22')](function(){return _0x365ac0;});})[_0xad7c('0x22')](function(){_0x394507['status'](0xcc)[_0xad7c('0x26')]();});}};}function handleEntityNotFound(_0x7cfcfd,_0x5105d8){return function(_0x452398){if(!_0x452398){_0x7cfcfd[_0xad7c('0x15')](0x194);}return _0x452398;};}function handleError(_0x4e12a5,_0x25acc3){_0x25acc3=_0x25acc3||0x1f4;return function(_0x503594){logger[_0xad7c('0x27')](_0x503594['stack']);if(_0x503594[_0xad7c('0x28')]){delete _0x503594[_0xad7c('0x28')];}_0x4e12a5[_0xad7c('0x16')](_0x25acc3)[_0xad7c('0x29')](_0x503594);};}exports[_0xad7c('0x2a')]=function(_0x267c54,_0xb0c771){var _0x4aa24c={},_0x3e3ead={},_0x35354d={'count':0x0,'rows':[]};var _0x32761e=_[_0xad7c('0x2b')](db['Pause'][_0xad7c('0x2c')],function(_0x5673a0){return{'name':_0x5673a0[_0xad7c('0x2d')],'type':_0x5673a0[_0xad7c('0x2e')]['key']};});_0x3e3ead['model']=_[_0xad7c('0x2b')](_0x32761e,_0xad7c('0x28'));_0x3e3ead['query']=_[_0xad7c('0x2f')](_0x267c54['query']);_0x3e3ead[_0xad7c('0x30')]=_['intersection'](_0x3e3ead[_0xad7c('0x31')],_0x3e3ead[_0xad7c('0x32')]);_0x4aa24c[_0xad7c('0x33')]=_[_0xad7c('0x34')](_0x3e3ead[_0xad7c('0x31')],qs[_0xad7c('0x35')](_0x267c54[_0xad7c('0x32')][_0xad7c('0x35')]));_0x4aa24c['attributes']=_0x4aa24c[_0xad7c('0x33')]['length']?_0x4aa24c[_0xad7c('0x33')]:_0x3e3ead[_0xad7c('0x31')];if(!_0x267c54['query'][_0xad7c('0x36')](_0xad7c('0x37'))){_0x4aa24c[_0xad7c('0x1a')]=qs[_0xad7c('0x1a')](_0x267c54[_0xad7c('0x32')][_0xad7c('0x1a')]);_0x4aa24c[_0xad7c('0x18')]=qs['offset'](_0x267c54[_0xad7c('0x32')][_0xad7c('0x18')]);}_0x4aa24c[_0xad7c('0x38')]=qs[_0xad7c('0x39')](_0x267c54[_0xad7c('0x32')][_0xad7c('0x39')]);_0x4aa24c[_0xad7c('0x3a')]=qs[_0xad7c('0x30')](_[_0xad7c('0x3b')](_0x267c54[_0xad7c('0x32')],_0x3e3ead[_0xad7c('0x30')]),_0x32761e);if(_0x267c54[_0xad7c('0x32')][_0xad7c('0x3c')]){_0x4aa24c[_0xad7c('0x3a')]=_['merge'](_0x4aa24c[_0xad7c('0x3a')],{'$or':_['map'](_0x32761e,function(_0xdb2d3e){if(_0xdb2d3e[_0xad7c('0x2e')]!==_0xad7c('0x3d')){var _0x47426d={};_0x47426d[_0xdb2d3e[_0xad7c('0x28')]]={'$like':'%'+_0x267c54[_0xad7c('0x32')][_0xad7c('0x3c')]+'%'};return _0x47426d;}})});}_0x4aa24c=_[_0xad7c('0x3e')]({},_0x4aa24c,_0x267c54[_0xad7c('0x3f')]);var _0x1e37f9={'where':_0x4aa24c[_0xad7c('0x3a')]};return db['Pause'][_0xad7c('0x1b')](_0x1e37f9)[_0xad7c('0x22')](function(_0x2ad8d4){_0x35354d[_0xad7c('0x1b')]=_0x2ad8d4;if(_0x267c54[_0xad7c('0x32')][_0xad7c('0x40')]){_0x4aa24c['include']=[{'all':!![]}];}return db[_0xad7c('0x41')][_0xad7c('0x42')](_0x4aa24c);})[_0xad7c('0x22')](function(_0x2b86d1){_0x35354d[_0xad7c('0x43')]=_0x2b86d1;return _0x35354d;})[_0xad7c('0x22')](respondWithFilteredResult(_0xb0c771,_0x4aa24c))[_0xad7c('0x44')](handleError(_0xb0c771,null));};exports['show']=function(_0xd7af88,_0x141249){var _0x3984b7={'raw':!![],'where':{'id':_0xd7af88[_0xad7c('0x45')]['id']}},_0x5bc83b={};_0x5bc83b[_0xad7c('0x31')]=_[_0xad7c('0x2f')](db[_0xad7c('0x41')][_0xad7c('0x2c')]);_0x5bc83b[_0xad7c('0x32')]=_[_0xad7c('0x2f')](_0xd7af88[_0xad7c('0x32')]);_0x5bc83b[_0xad7c('0x30')]=_[_0xad7c('0x34')](_0x5bc83b[_0xad7c('0x31')],_0x5bc83b[_0xad7c('0x32')]);_0x3984b7[_0xad7c('0x33')]=_[_0xad7c('0x34')](_0x5bc83b[_0xad7c('0x31')],qs[_0xad7c('0x35')](_0xd7af88[_0xad7c('0x32')][_0xad7c('0x35')]));_0x3984b7['attributes']=_0x3984b7[_0xad7c('0x33')][_0xad7c('0x46')]?_0x3984b7['attributes']:_0x5bc83b['model'];if(_0xd7af88[_0xad7c('0x32')]['includeAll']){_0x3984b7[_0xad7c('0x47')]=[{'all':!![]}];}_0x3984b7=_[_0xad7c('0x3e')]({},_0x3984b7,_0xd7af88[_0xad7c('0x3f')]);return db[_0xad7c('0x41')][_0xad7c('0x48')](_0x3984b7)[_0xad7c('0x22')](handleEntityNotFound(_0x141249,null))['then'](respondWithResult(_0x141249,null))['catch'](handleError(_0x141249,null));};exports[_0xad7c('0x49')]=function(_0x1dd875,_0xd3a6e3){return db[_0xad7c('0x41')][_0xad7c('0x49')](_0x1dd875['body'],{})[_0xad7c('0x22')](function(_0x421a11){var _0x6ed308=_0x1dd875[_0xad7c('0x4a')][_0xad7c('0x4b')]({'plain':!![]});if(!_0x6ed308)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x6ed308['role']===_0xad7c('0x4a')){var _0x4bcdc5=_0x421a11[_0xad7c('0x4b')]({'plain':!![]});var _0x5a5219=_0xad7c('0x24');return db['UserProfileSection'][_0xad7c('0x48')]({'where':{'name':_0x5a5219,'userProfileId':_0x6ed308[_0xad7c('0x4c')]},'raw':!![]})[_0xad7c('0x22')](function(_0x4b6082){if(_0x4b6082&&_0x4b6082[_0xad7c('0x4d')]===0x0){return db['UserProfileResource'][_0xad7c('0x49')]({'name':_0x4bcdc5[_0xad7c('0x28')],'resourceId':_0x4bcdc5['id'],'type':_0x4b6082[_0xad7c('0x28')],'sectionId':_0x4b6082['id']},{})[_0xad7c('0x22')](function(){return _0x421a11;});}else{return _0x421a11;}})['catch'](function(_0x526828){logger[_0xad7c('0x27')](_0xad7c('0x4e'),_0x526828);throw _0x526828;});}return _0x421a11;})[_0xad7c('0x22')](respondWithResult(_0xd3a6e3,0xc9))[_0xad7c('0x44')](handleError(_0xd3a6e3,null));};exports['update']=function(_0x497955,_0x308140){if(_0x497955[_0xad7c('0x4f')]['id']){delete _0x497955[_0xad7c('0x4f')]['id'];}return db[_0xad7c('0x41')]['find']({'where':{'id':_0x497955[_0xad7c('0x45')]['id']}})[_0xad7c('0x22')](handleEntityNotFound(_0x308140,null))[_0xad7c('0x22')](saveUpdates(_0x497955[_0xad7c('0x4f')],null))['then'](respondWithResult(_0x308140,null))[_0xad7c('0x44')](handleError(_0x308140,null));};exports[_0xad7c('0x23')]=function(_0x267ffd,_0x4bd15a){return db['Pause'][_0xad7c('0x48')]({'where':{'id':_0x267ffd['params']['id']}})[_0xad7c('0x22')](handleEntityNotFound(_0x4bd15a,null))[_0xad7c('0x22')](removeEntity(_0x4bd15a,null))[_0xad7c('0x44')](handleError(_0x4bd15a,null));}; \ No newline at end of file diff --git a/server/api/pause/pause.model.js b/server/api/pause/pause.model.js new file mode 100644 index 0000000..4ff0f32 --- /dev/null +++ b/server/api/pause/pause.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7217=['../../config/environment','./pause.attributes','exports','define','Pause','tools_pauses','lodash','../../config/logger','api','moment','bluebird','request-promise'];(function(_0x28394f,_0x5ebdd2){var _0x2618d2=function(_0x2ffed6){while(--_0x2ffed6){_0x28394f['push'](_0x28394f['shift']());}};_0x2618d2(++_0x5ebdd2);}(_0x7217,0x19e));var _0x7721=function(_0x32d457,_0x1a39c9){_0x32d457=_0x32d457-0x0;var _0x338386=_0x7217[_0x32d457];return _0x338386;};'use strict';var _=require(_0x7721('0x0'));var util=require('util');var logger=require(_0x7721('0x1'))(_0x7721('0x2'));var moment=require(_0x7721('0x3'));var BPromise=require(_0x7721('0x4'));var rp=require(_0x7721('0x5'));var fs=require('fs');var path=require('path');var rimraf=require('rimraf');var config=require(_0x7721('0x6'));var attributes=require(_0x7721('0x7'));module[_0x7721('0x8')]=function(_0x3fe47c,_0xb239e0){return _0x3fe47c[_0x7721('0x9')](_0x7721('0xa'),attributes,{'tableName':_0x7721('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/pause/pause.rpc.js b/server/api/pause/pause.rpc.js new file mode 100644 index 0000000..27b8014 --- /dev/null +++ b/server/api/pause/pause.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['message','request\x20sent','result','catch','Pause','find','options','raw','where','attributes','map','include','model','ShowPause','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','info','Pause,\x20%s,\x20%s','debug','stringify','error','code'];(function(_0x4d5aa3,_0x13433b){var _0x3440fe=function(_0x2cc05){while(--_0x2cc05){_0x4d5aa3['push'](_0x4d5aa3['shift']());}};_0x3440fe(++_0x13433b);}(_0x7a54,0x106));var _0x47a5=function(_0x16c76e,_0x554243){_0x16c76e=_0x16c76e-0x0;var _0x3942eb=_0x7a54[_0x16c76e];return _0x3942eb;};'use strict';var _=require(_0x47a5('0x0'));var util=require(_0x47a5('0x1'));var moment=require(_0x47a5('0x2'));var BPromise=require('bluebird');var rs=require(_0x47a5('0x3'));var fs=require('fs');var Redis=require(_0x47a5('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x47a5('0x5'));var logger=require(_0x47a5('0x6'))(_0x47a5('0x7'));var config=require(_0x47a5('0x8'));var jayson=require(_0x47a5('0x9'));var client=jayson['client'][_0x47a5('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x59199c,_0x343372,_0x30e405){return new BPromise(function(_0x506eda,_0x194fb0){return client['request'](_0x59199c,_0x30e405)['then'](function(_0x582352){logger[_0x47a5('0xb')](_0x47a5('0xc'),_0x343372,'request\x20sent');logger[_0x47a5('0xd')]('Pause,\x20%s,\x20%s,\x20%s',_0x343372,'request\x20sent',JSON[_0x47a5('0xe')](_0x582352));if(_0x582352[_0x47a5('0xf')]){if(_0x582352[_0x47a5('0xf')][_0x47a5('0x10')]===0x1f4){logger[_0x47a5('0xf')](_0x47a5('0xc'),_0x343372,_0x582352[_0x47a5('0xf')]['message']);return _0x194fb0(_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);}logger[_0x47a5('0xf')](_0x47a5('0xc'),_0x343372,_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);return _0x506eda(_0x582352[_0x47a5('0xf')][_0x47a5('0x11')]);}else{logger['info'](_0x47a5('0xc'),_0x343372,_0x47a5('0x12'));_0x506eda(_0x582352[_0x47a5('0x13')][_0x47a5('0x11')]);}})[_0x47a5('0x14')](function(_0x574af6){logger['error'](_0x47a5('0xc'),_0x343372,_0x574af6);_0x194fb0(_0x574af6);});});}exports['ShowPause']=function(_0x5247fd){var _0x423a81=this;return new Promise(function(_0xaf70a6,_0x2ce454){return db[_0x47a5('0x15')][_0x47a5('0x16')]({'raw':_0x5247fd[_0x47a5('0x17')]?_0x5247fd[_0x47a5('0x17')][_0x47a5('0x18')]===undefined?!![]:![]:!![],'where':_0x5247fd[_0x47a5('0x17')]?_0x5247fd['options'][_0x47a5('0x19')]||null:null,'attributes':_0x5247fd[_0x47a5('0x17')]?_0x5247fd['options'][_0x47a5('0x1a')]||null:null,'include':_0x5247fd[_0x47a5('0x17')]?_0x5247fd[_0x47a5('0x17')]['include']?_[_0x47a5('0x1b')](_0x5247fd[_0x47a5('0x17')][_0x47a5('0x1c')],function(_0x7a9f9e){return{'model':db[_0x7a9f9e['model']],'as':_0x7a9f9e['as'],'attributes':_0x7a9f9e[_0x47a5('0x1a')],'include':_0x7a9f9e[_0x47a5('0x1c')]?_['map'](_0x7a9f9e[_0x47a5('0x1c')],function(_0xc4cd63){return{'model':db[_0xc4cd63[_0x47a5('0x1d')]],'as':_0xc4cd63['as'],'attributes':_0xc4cd63[_0x47a5('0x1a')],'include':_0xc4cd63[_0x47a5('0x1c')]?_['map'](_0xc4cd63['include'],function(_0x136745){return{'model':db[_0x136745['model']],'as':_0x136745['as'],'attributes':_0x136745[_0x47a5('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x23cb77){logger[_0x47a5('0xb')](_0x47a5('0x1e'),_0x5247fd);logger[_0x47a5('0xd')](_0x47a5('0x1e'),_0x5247fd,JSON[_0x47a5('0xe')](_0x23cb77));_0xaf70a6(_0x23cb77);})[_0x47a5('0x14')](function(_0x136b14){logger[_0x47a5('0xf')](_0x47a5('0x1e'),_0x136b14[_0x47a5('0x11')],_0x5247fd);_0x2ce454(_0x423a81[_0x47a5('0xf')](0x1f4,_0x136b14[_0x47a5('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/plugin/index.js b/server/api/plugin/index.js new file mode 100644 index 0000000..803a2d0 --- /dev/null +++ b/server/api/plugin/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda55=['diskStorage','join','server/files/plugins','originalname','replace','format','%s-%s%s','now','extname','post','single','file','webhookPost','put','delete','exports','multer','util','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./plugin.controller','isAuthenticated','get','/webhook','webhookGet','/:id','show','download'];(function(_0x414b48,_0x27550e){var _0x4c2226=function(_0x21afc3){while(--_0x21afc3){_0x414b48['push'](_0x414b48['shift']());}};_0x4c2226(++_0x27550e);}(_0xda55,0x6d));var _0x5da5=function(_0x28e74e,_0x53fdf1){_0x28e74e=_0x28e74e-0x0;var _0xb45ac1=_0xda55[_0x28e74e];return _0xb45ac1;};'use strict';var multer=require(_0x5da5('0x0'));var util=require(_0x5da5('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require(_0x5da5('0x2'));var router=express[_0x5da5('0x3')]();var fs_extra=require(_0x5da5('0x4'));var auth=require(_0x5da5('0x5'));var interaction=require(_0x5da5('0x6'));var config=require('../../config/environment');var controller=require(_0x5da5('0x7'));router['get']('/',auth[_0x5da5('0x8')](),controller['index']);router[_0x5da5('0x9')](_0x5da5('0xa'),controller[_0x5da5('0xb')]);router[_0x5da5('0x9')](_0x5da5('0xc'),auth[_0x5da5('0x8')](),controller[_0x5da5('0xd')]);router[_0x5da5('0x9')]('/:id/download',auth[_0x5da5('0x8')](),controller[_0x5da5('0xe')]);var upload=multer({'storage':multer[_0x5da5('0xf')]({'destination':function(_0x26fbe3,_0x1a047e,_0x2a361c){_0x2a361c(null,path[_0x5da5('0x10')](config['root'],_0x5da5('0x11')));},'filename':function(_0x3b5ff9,_0x4f813b,_0x37aeb0){_0x4f813b[_0x5da5('0x12')]=_0x4f813b[_0x5da5('0x12')][_0x5da5('0x13')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');_0x37aeb0(null,util[_0x5da5('0x14')](_0x5da5('0x15'),path['basename'](_0x4f813b['originalname'],path['extname'](_0x4f813b[_0x5da5('0x12')])),Date[_0x5da5('0x16')](),path[_0x5da5('0x17')](_0x4f813b[_0x5da5('0x12')])));}})});router[_0x5da5('0x18')]('/',upload[_0x5da5('0x19')](_0x5da5('0x1a')),controller['upload']);router[_0x5da5('0x18')](_0x5da5('0xa'),controller[_0x5da5('0x1b')]);router[_0x5da5('0x1c')](_0x5da5('0xc'),auth[_0x5da5('0x8')](),controller['update']);router[_0x5da5('0x1d')](_0x5da5('0xc'),auth[_0x5da5('0x8')](),controller[_0x5da5('0x1d')]);module[_0x5da5('0x1e')]=router; \ No newline at end of file diff --git a/server/api/plugin/plugin.attributes.js b/server/api/plugin/plugin.attributes.js new file mode 100644 index 0000000..fe1f4fb --- /dev/null +++ b/server/api/plugin/plugin.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x48bf=['never','always','Indicates\x20whether\x20to\x20display\x20the\x20plugin\x20in\x20the\x20sidebar.','sequelize','exports','STRING','ENUM','html','script','TEXT','The\x20physical\x20path\x20where\x20the\x20plugin\x20is\x20stored.','BOOLEAN','agentOnly'];(function(_0x5d3f22,_0x1064bf){var _0x3d3a25=function(_0x3e4b63){while(--_0x3e4b63){_0x5d3f22['push'](_0x5d3f22['shift']());}};_0x3d3a25(++_0x1064bf);}(_0x48bf,0x92));var _0xf48b=function(_0x3a7fe5,_0x371426){_0x3a7fe5=_0x3a7fe5-0x0;var _0x18ed66=_0x48bf[_0x3a7fe5];return _0x18ed66;};'use strict';var Sequelize=require(_0xf48b('0x0'));module[_0xf48b('0x1')]={'name':{'type':Sequelize[_0xf48b('0x2')]},'type':{'type':Sequelize[_0xf48b('0x3')](_0xf48b('0x4'),_0xf48b('0x5'))},'description':{'type':Sequelize[_0xf48b('0x6')]},'version':{'type':Sequelize[_0xf48b('0x6')]},'path':{'type':Sequelize[_0xf48b('0x2')],'comment':_0xf48b('0x7')},'active':{'type':Sequelize[_0xf48b('0x8')],'defaultValue':0x0,'comment':'Indicates\x20whether\x20the\x20plugin\x20is\x20installed.\x20Updated\x20when\x20the\x20plugin\x20is\x20installed/uninstalled.'},'sidebar':{'type':Sequelize[_0xf48b('0x3')]('adminOnly',_0xf48b('0x9'),'always',_0xf48b('0xa')),'defaultValue':_0xf48b('0xb'),'comment':_0xf48b('0xc')},'icon':{'type':Sequelize[_0xf48b('0x2')]},'adminUrl':{'type':Sequelize[_0xf48b('0x2')]},'agentUrl':{'type':Sequelize[_0xf48b('0x2')]},'scriptName':{'type':Sequelize[_0xf48b('0x2')]},'scriptPath':{'type':Sequelize[_0xf48b('0x2')]}}; \ No newline at end of file diff --git a/server/api/plugin/plugin.controller.js b/server/api/plugin/plugin.controller.js new file mode 100644 index 0000000..ce541a0 --- /dev/null +++ b/server/api/plugin/plugin.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0d07=['scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','sidebar','always','icon','html','plugins','test','Warning:\x20agent\x20view\x20not\x20specified','scriptName','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','send','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','update','delete','webhookGet','\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','encoding','method','%s%s','headers','content-length','endsWith','statusCode','webhookPost','http://localhost:','content-type','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','papaparse','extract-zip','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','./plugin.socket','register','sendStatus','json','offset','undefined','count','limit','status','set','Content-Range','reject','destroy','get','Plugins','UserProfileResource','then','end','error','stack','name','index','map','Plugin','rawAttributes','fieldName','type','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort','filters','pick','filter','where','merge','options','includeAll','include','show','find','catch','download','params','join','root','server/files/plugins','%s.zip','basename','createWriteStream','zip','warning','ENOENT','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','dirname','attachments/**/*','Sequelize','Plugin\x20not\x20found','format','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','Download\x20completed','info','file','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync','lstatSync','isFile','Invalid\x20plugin\x20structure','isDirectory','some','Plugin\x20manifest\x20missing','readFileSync','manifest.json','parse','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','Invalid\x20manifest:\x20version\x20not\x20specified','Invalid\x20manifest:\x20parameters\x20missing','parameters','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','Invalid\x20manifest:\x20script\x20name\x20missing'];(function(_0x2791aa,_0x26a4c0){var _0x43b95a=function(_0x18b43b){while(--_0x18b43b){_0x2791aa['push'](_0x2791aa['shift']());}};_0x43b95a(++_0x26a4c0);}(_0x0d07,0x16f));var _0x70d0=function(_0x41aed2,_0x5320c3){_0x41aed2=_0x41aed2-0x0;var _0x114230=_0x0d07[_0x41aed2];return _0x114230;};'use strict';var emlformat=require(_0x70d0('0x0'));var rimraf=require(_0x70d0('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x70d0('0x2'));var rp=require(_0x70d0('0x3'));var moment=require(_0x70d0('0x4'));var BPromise=require(_0x70d0('0x5'));var Mustache=require(_0x70d0('0x6'));var util=require(_0x70d0('0x7'));var path=require(_0x70d0('0x8'));var sox=require(_0x70d0('0x9'));var csv=require(_0x70d0('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x70d0('0xb'));var squel=require(_0x70d0('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x70d0('0xa'));var querystring=require('querystring');var Papa=require(_0x70d0('0xd'));var extract=require(_0x70d0('0xe'));var rimraf=require(_0x70d0('0x1'));var archiver=require('archiver');var Redis=require(_0x70d0('0xf'));var authService=require(_0x70d0('0x10'));var qs=require(_0x70d0('0x11'));var as=require(_0x70d0('0x12'));var hardwareService=require(_0x70d0('0x13'));var logger=require(_0x70d0('0x14'))('api');var utils=require(_0x70d0('0x15'));var config=require(_0x70d0('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x70d0('0x17'))['db'];config['redis']=_[_0x70d0('0x18')](config[_0x70d0('0x19')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x70d0('0x19')]));require(_0x70d0('0x1a'))[_0x70d0('0x1b')](socket);function respondWithStatusCode(_0x56f276,_0x15f1c4){_0x15f1c4=_0x15f1c4||0xcc;return function(_0x2a4365){if(_0x2a4365){return _0x56f276[_0x70d0('0x1c')](_0x15f1c4);}return _0x56f276['status'](_0x15f1c4)['end']();};}function respondWithResult(_0x10412a,_0x2ed680){_0x2ed680=_0x2ed680||0xc8;return function(_0x47bf8d){if(_0x47bf8d){return _0x10412a['status'](_0x2ed680)[_0x70d0('0x1d')](_0x47bf8d);}};}function respondWithFilteredResult(_0x2336ee,_0x581077){return function(_0x1cb94b){if(_0x1cb94b){var _0x1e2897=typeof _0x581077[_0x70d0('0x1e')]==='undefined'&&typeof _0x581077['limit']===_0x70d0('0x1f');var _0x53eb9e=_0x1cb94b['count'];var _0x25d4f8=_0x1e2897?0x0:_0x581077['offset'];var _0x53f4c1=_0x1e2897?_0x1cb94b[_0x70d0('0x20')]:_0x581077[_0x70d0('0x1e')]+_0x581077[_0x70d0('0x21')];var _0x598637;if(_0x53f4c1>=_0x53eb9e){_0x53f4c1=_0x53eb9e;_0x598637=0xc8;}else{_0x598637=0xce;}_0x2336ee[_0x70d0('0x22')](_0x598637);return _0x2336ee[_0x70d0('0x23')](_0x70d0('0x24'),_0x25d4f8+'-'+_0x53f4c1+'/'+_0x53eb9e)['json'](_0x1cb94b);}return null;};}function patchUpdates(_0x47c5cb){return function(_0x23bd80){try{jsonpatch['apply'](_0x23bd80,_0x47c5cb,!![]);}catch(_0x3e9302){return BPromise[_0x70d0('0x25')](_0x3e9302);}return _0x23bd80['save']();};}function saveUpdates(_0x325cbf,_0x1add75){return function(_0x462ddd){if(_0x462ddd){return _0x462ddd['update'](_0x325cbf)['then'](function(_0x3d7ab6){return _0x3d7ab6;});}return null;};}function removeEntity(_0x5842ee,_0x206e70){return function(_0x3fe136){if(_0x3fe136){return _0x3fe136[_0x70d0('0x26')]()['then'](function(){var _0x124918=_0x3fe136[_0x70d0('0x27')]({'plain':!![]});var _0x513a7e=_0x70d0('0x28');return db[_0x70d0('0x29')][_0x70d0('0x26')]({'where':{'type':_0x513a7e,'resourceId':_0x124918['id']}})['then'](function(){return _0x3fe136;});})[_0x70d0('0x2a')](function(){_0x5842ee[_0x70d0('0x22')](0xcc)[_0x70d0('0x2b')]();});}};}function handleEntityNotFound(_0x44b16d,_0x3e3747){return function(_0x19a83f){if(!_0x19a83f){_0x44b16d[_0x70d0('0x1c')](0x194);}return _0x19a83f;};}function handleError(_0x16d0d9,_0x5e6ccc){_0x5e6ccc=_0x5e6ccc||0x1f4;return function(_0xb39b36){logger[_0x70d0('0x2c')](_0xb39b36[_0x70d0('0x2d')]);if(_0xb39b36[_0x70d0('0x2e')]){delete _0xb39b36['name'];}_0x16d0d9['status'](_0x5e6ccc)['send'](_0xb39b36);};}exports[_0x70d0('0x2f')]=function(_0x27f64d,_0x58bd0d){var _0x321422={},_0x3b86ec={},_0xbd6736={'count':0x0,'rows':[]};var _0x5d0ab1=_[_0x70d0('0x30')](db[_0x70d0('0x31')][_0x70d0('0x32')],function(_0x23bd00){return{'name':_0x23bd00[_0x70d0('0x33')],'type':_0x23bd00[_0x70d0('0x34')]['key']};});_0x3b86ec[_0x70d0('0x35')]=_[_0x70d0('0x30')](_0x5d0ab1,_0x70d0('0x2e'));_0x3b86ec[_0x70d0('0x36')]=_[_0x70d0('0x37')](_0x27f64d[_0x70d0('0x36')]);_0x3b86ec['filters']=_[_0x70d0('0x38')](_0x3b86ec[_0x70d0('0x35')],_0x3b86ec[_0x70d0('0x36')]);_0x321422[_0x70d0('0x39')]=_[_0x70d0('0x38')](_0x3b86ec[_0x70d0('0x35')],qs[_0x70d0('0x3a')](_0x27f64d[_0x70d0('0x36')][_0x70d0('0x3a')]));_0x321422[_0x70d0('0x39')]=_0x321422[_0x70d0('0x39')][_0x70d0('0x3b')]?_0x321422[_0x70d0('0x39')]:_0x3b86ec[_0x70d0('0x35')];if(!_0x27f64d['query']['hasOwnProperty'](_0x70d0('0x3c'))){_0x321422['limit']=qs[_0x70d0('0x21')](_0x27f64d['query'][_0x70d0('0x21')]);_0x321422[_0x70d0('0x1e')]=qs[_0x70d0('0x1e')](_0x27f64d[_0x70d0('0x36')][_0x70d0('0x1e')]);}_0x321422[_0x70d0('0x3d')]=qs[_0x70d0('0x3e')](_0x27f64d['query'][_0x70d0('0x3e')]);_0x321422['where']=qs[_0x70d0('0x3f')](_[_0x70d0('0x40')](_0x27f64d[_0x70d0('0x36')],_0x3b86ec[_0x70d0('0x3f')]),_0x5d0ab1);if(_0x27f64d[_0x70d0('0x36')][_0x70d0('0x41')]){_0x321422[_0x70d0('0x42')]=_[_0x70d0('0x43')](_0x321422[_0x70d0('0x42')],{'$or':_[_0x70d0('0x30')](_0x5d0ab1,function(_0x59c511){if(_0x59c511[_0x70d0('0x34')]!=='VIRTUAL'){var _0x1daa07={};_0x1daa07[_0x59c511[_0x70d0('0x2e')]]={'$like':'%'+_0x27f64d[_0x70d0('0x36')][_0x70d0('0x41')]+'%'};return _0x1daa07;}})});}_0x321422=_[_0x70d0('0x43')]({},_0x321422,_0x27f64d[_0x70d0('0x44')]);var _0x5825bd={'where':_0x321422[_0x70d0('0x42')]};return db['Plugin'][_0x70d0('0x20')](_0x5825bd)[_0x70d0('0x2a')](function(_0x19f6d7){_0xbd6736[_0x70d0('0x20')]=_0x19f6d7;if(_0x27f64d[_0x70d0('0x36')][_0x70d0('0x45')]){_0x321422[_0x70d0('0x46')]=[{'all':!![]}];}return db[_0x70d0('0x31')]['findAll'](_0x321422);})[_0x70d0('0x2a')](function(_0x9d6ab0){_0xbd6736['rows']=_0x9d6ab0;return _0xbd6736;})[_0x70d0('0x2a')](respondWithFilteredResult(_0x58bd0d,_0x321422))['catch'](handleError(_0x58bd0d,null));};exports[_0x70d0('0x47')]=function(_0x15a9a0,_0x1ffdd5){var _0x4f79a5={'raw':!![],'where':{'id':_0x15a9a0['params']['id']}},_0x3ee973={};_0x3ee973['model']=_['keys'](db[_0x70d0('0x31')][_0x70d0('0x32')]);_0x3ee973[_0x70d0('0x36')]=_[_0x70d0('0x37')](_0x15a9a0[_0x70d0('0x36')]);_0x3ee973[_0x70d0('0x3f')]=_[_0x70d0('0x38')](_0x3ee973[_0x70d0('0x35')],_0x3ee973[_0x70d0('0x36')]);_0x4f79a5[_0x70d0('0x39')]=_[_0x70d0('0x38')](_0x3ee973[_0x70d0('0x35')],qs[_0x70d0('0x3a')](_0x15a9a0[_0x70d0('0x36')][_0x70d0('0x3a')]));_0x4f79a5[_0x70d0('0x39')]=_0x4f79a5[_0x70d0('0x39')]['length']?_0x4f79a5[_0x70d0('0x39')]:_0x3ee973[_0x70d0('0x35')];if(_0x15a9a0[_0x70d0('0x36')][_0x70d0('0x45')]){_0x4f79a5[_0x70d0('0x46')]=[{'all':!![]}];}_0x4f79a5=_[_0x70d0('0x43')]({},_0x4f79a5,_0x15a9a0['options']);return db['Plugin'][_0x70d0('0x48')](_0x4f79a5)['then'](handleEntityNotFound(_0x1ffdd5,null))[_0x70d0('0x2a')](respondWithResult(_0x1ffdd5,null))[_0x70d0('0x49')](handleError(_0x1ffdd5,null));};exports[_0x70d0('0x4a')]=function(_0x2cc95b,_0x440bfb,_0x1f9688){return db[_0x70d0('0x31')][_0x70d0('0x48')]({'where':{'id':_0x2cc95b[_0x70d0('0x4b')]['id']},'attributes':[_0x70d0('0x2e'),_0x70d0('0x8')],'raw':!![]})[_0x70d0('0x2a')](handleEntityNotFound(_0x440bfb,null))['then'](function(_0x558bb1){if(_0x558bb1){var _0x3a83f6=path[_0x70d0('0x4c')](config[_0x70d0('0x4d')],_0x70d0('0x4e'),util['format'](_0x70d0('0x4f'),path[_0x70d0('0x50')](_0x558bb1[_0x70d0('0x8')])));var _0x348626=fs[_0x70d0('0x51')](_0x3a83f6);var _0x430947=archiver(_0x70d0('0x52'),{'zlib':{'level':0x9}});_0x430947['on'](_0x70d0('0x53'),function(_0x554c18){if(_0x554c18['code']===_0x70d0('0x54')){logger[_0x70d0('0x2c')](_0x554c18);}else{throw new db['Sequelize'][(_0x70d0('0x55'))](_0x70d0('0x56'));}});_0x430947['on'](_0x70d0('0x2c'),function(_0x789993){throw new db['Sequelize'][(_0x70d0('0x55'))](_0x70d0('0x56'));});_0x430947['pipe'](_0x348626);_0x430947[_0x70d0('0x57')]('**/*',{'cwd':path[_0x70d0('0x4c')](config[_0x70d0('0x4d')],_0x70d0('0x4e'),path[_0x70d0('0x58')](_0x558bb1[_0x70d0('0x8')])),'ignore':[path['join'](path['basename'](_0x558bb1['path']),'node_modules/**/*'),path[_0x70d0('0x4c')](path['basename'](_0x558bb1[_0x70d0('0x8')]),_0x70d0('0x59'))],'nodir':!![]})['finalize']();_0x348626['on']('close',function(){if(!fs['existsSync'](_0x3a83f6)){throw new db[(_0x70d0('0x5a'))]['Error'](_0x70d0('0x5b'));}return _0x440bfb[_0x70d0('0x4a')](_0x3a83f6,util[_0x70d0('0x5c')](_0x70d0('0x4f'),path[_0x70d0('0x50')](_0x558bb1[_0x70d0('0x8')])),function(_0x3ecbb4){if(_0x3ecbb4){throw new db[(_0x70d0('0x5a'))][(_0x70d0('0x55'))](_0x70d0('0x5d'));}fs[_0x70d0('0x5e')](_0x3a83f6);logger['info'](_0x70d0('0x5f'));logger[_0x70d0('0x60')]('Temporary\x20file\x20removed');});});}return null;})['catch'](handleError(_0x440bfb,null));};exports['upload']=function(_0x1913d5,_0x1e130f,_0x1de3c7){var _0x222708=path[_0x70d0('0x50')](_0x1913d5[_0x70d0('0x61')][_0x70d0('0x62')],path['extname'](_0x1913d5[_0x70d0('0x61')][_0x70d0('0x62')]));var _0x416c59=path[_0x70d0('0x4c')](config[_0x70d0('0x4d')],_0x70d0('0x4e'),_0x1913d5[_0x70d0('0x61')][_0x70d0('0x62')]);var _0x27f9f9=path[_0x70d0('0x4c')](config[_0x70d0('0x4d')],_0x70d0('0x4e'),_0x222708);logger[_0x70d0('0x60')](_0x70d0('0x63'),_0x416c59);logger[_0x70d0('0x60')](_0x70d0('0x64'),_0x27f9f9);try{fs[_0x70d0('0x65')](_0x416c59,parseInt(_0x70d0('0x66'),0x8));extract(_0x416c59,{'dir':_0x27f9f9},function(_0x42b0cb){if(_0x42b0cb){logger['error'](_0x42b0cb);handleError(_0x42b0cb,!![]);};var _0x1e771b=fs[_0x70d0('0x67')](_0x27f9f9);if(_0x1e771b[_0x70d0('0x3b')]>0x1){removeReferences(_0x416c59,_0x27f9f9);logger[_0x70d0('0x2c')]('Invalid\x20plugin\x20structure');return _0x1de3c7(new Error('Invalid\x20plugin\x20structure'));}var _0x1d1b75=fs[_0x70d0('0x68')](path['join'](_0x27f9f9,_0x1e771b[0x0]));if(_0x1d1b75[_0x70d0('0x69')]()){removeReferences(_0x416c59,_0x27f9f9);logger[_0x70d0('0x2c')](_0x70d0('0x6a'));return _0x1de3c7(new Error(_0x70d0('0x6a')));}if(_0x1d1b75[_0x70d0('0x6b')]()){var _0x4c9d00=fs['readdirSync'](path[_0x70d0('0x4c')](_0x27f9f9,_0x1e771b[0x0]));if(_0x4c9d00[_0x70d0('0x3b')]===0x0){removeReferences(_0x416c59,_0x27f9f9);logger[_0x70d0('0x2c')]('Invalid\x20plugin\x20structure');return _0x1de3c7(new Error(_0x70d0('0x6a')));}var _0x3c296a=_0x4c9d00[_0x70d0('0x6c')](function(_0x23302e){return _0x23302e==='manifest.json';});if(!_0x3c296a){return _0x1de3c7(new Error(_0x70d0('0x6d')));}var _0x4e4758=fs[_0x70d0('0x6e')](path['join'](_0x27f9f9,_0x1e771b[0x0],_0x70d0('0x6f')));var _0x5ec13b=JSON[_0x70d0('0x70')](_0x4e4758);if(_0x70d0('0x1f')==typeof _0x5ec13b['name']){return _0x1de3c7(new Error(_0x70d0('0x71')));}if(_0x70d0('0x1f')==typeof _0x5ec13b['type']){return _0x1de3c7(new Error(_0x70d0('0x72')));}if(_0x70d0('0x1f')==typeof _0x5ec13b['version']){return _0x1de3c7(new Error(_0x70d0('0x73')));}if(_0x70d0('0x1f')==typeof _0x5ec13b['parameters']){return _0x1de3c7(new Error(_0x70d0('0x74')));}if(_0x5ec13b[_0x70d0('0x34')]==='html'){if(_0x70d0('0x1f')==typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')]){return _0x1de3c7(new Error(_0x70d0('0x77')));}if(_0x70d0('0x1f')==typeof _0x5ec13b[_0x70d0('0x75')]['views'][_0x70d0('0x78')]&&_0x70d0('0x1f')==typeof _0x5ec13b[_0x70d0('0x75')]['views'][_0x70d0('0x79')]){return _0x1de3c7(new Error(_0x70d0('0x7a')));}}else if(_0x5ec13b[_0x70d0('0x34')]===_0x70d0('0x7b')){if(_0x70d0('0x1f')==typeof _0x5ec13b[_0x70d0('0x75')]['scriptName']){return _0x1de3c7(new Error(_0x70d0('0x7c')));}if(_0x70d0('0x1f')==typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x7d')]){return _0x1de3c7(new Error(_0x70d0('0x7e')));}}else{return _0x1de3c7(new Error(_0x70d0('0x7f')));}var _0x4bbb8f=_0x5ec13b[_0x70d0('0x2e')];var _0x219eaf=_0x5ec13b['description'];var _0x747b9f=_0x5ec13b['type'];var _0x492dc1=_0x5ec13b[_0x70d0('0x80')]?_0x5ec13b[_0x70d0('0x80')]:_0x70d0('0x81');var _0x35cd86=_0x5ec13b[_0x70d0('0x82')]?_0x5ec13b['icon']:'icon-apps';var _0x45fe68='';var _0x445ebc='';var _0x31af1c='';var _0x4a41cb='';var _0x5b9273=_0x5ec13b['version'];if(_0x747b9f===_0x70d0('0x83')){if(_0x70d0('0x1f')!=typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')][_0x70d0('0x78')]){var _0x43ced8=_0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')][_0x70d0('0x78')];if(!/^(f|ht)tps?:\/\//i['test'](_0x43ced8)){_0x45fe68=path[_0x70d0('0x4c')](_0x70d0('0x84'),_0x222708,_0x1e771b[0x0],_0x43ced8);}else{_0x45fe68=_0x43ced8;}}else{logger['info']('Warning:\x20admin\x20view\x20not\x20specified');}if(_0x70d0('0x1f')!=typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')][_0x70d0('0x79')]){var _0x26eb97=_0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')]['agent'];if(!/^(f|ht)tps?:\/\//i[_0x70d0('0x85')](_0x26eb97)){_0x445ebc=path[_0x70d0('0x4c')](_0x70d0('0x84'),_0x222708,_0x1e771b[0x0],_0x26eb97);}else{_0x445ebc=_0x26eb97;}}else{logger[_0x70d0('0x60')](_0x70d0('0x86'));}}else if(_0x747b9f===_0x70d0('0x7b')){_0x31af1c=_0x5ec13b[_0x70d0('0x75')][_0x70d0('0x87')];_0x4a41cb=_0x5ec13b[_0x70d0('0x75')][_0x70d0('0x7d')];if(_0x70d0('0x1f')!=typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')]){if(_0x70d0('0x1f')!=typeof _0x5ec13b['parameters'][_0x70d0('0x76')][_0x70d0('0x78')]){var _0x43ced8=_0x5ec13b['parameters']['views']['admin'];if(!/^(f|ht)tps?:\/\//i[_0x70d0('0x85')](_0x43ced8)){_0x45fe68=path[_0x70d0('0x4c')](_0x70d0('0x84'),_0x222708,_0x1e771b[0x0],_0x43ced8);}else{_0x45fe68=_0x43ced8;}}if(_0x70d0('0x1f')!=typeof _0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')][_0x70d0('0x79')]){var _0x26eb97=_0x5ec13b[_0x70d0('0x75')][_0x70d0('0x76')][_0x70d0('0x79')];if(!/^(f|ht)tps?:\/\//i['test'](_0x26eb97)){_0x445ebc=path[_0x70d0('0x4c')](_0x70d0('0x84'),_0x222708,_0x1e771b[0x0],_0x26eb97);}else{_0x445ebc=_0x26eb97;}}}}var _0x13cbe8={'name':_0x4bbb8f,'description':_0x219eaf,'path':path[_0x70d0('0x4c')](_0x222708,_0x1e771b[0x0]),'type':_0x747b9f,'sidebar':_0x492dc1,'icon':_0x35cd86,'adminUrl':_0x45fe68,'agentUrl':_0x445ebc,'scriptName':_0x31af1c,'scriptPath':_0x4a41cb,'version':_0x5b9273};removeReferences(_0x416c59,null);return db[_0x70d0('0x31')][_0x70d0('0x88')](_0x13cbe8)['then'](function(_0x4edab6){var _0x50bc9d={'role':_0x1913d5[_0x70d0('0x89')][_0x70d0('0x8a')],'userProfileId':_0x1913d5[_0x70d0('0x89')][_0x70d0('0x8b')]};if(!_0x50bc9d)throw new Error(_0x70d0('0x8c'));if(_0x50bc9d['role']===_0x70d0('0x8d')){var _0x390810=_0x4edab6[_0x70d0('0x27')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':_0x70d0('0x28'),'userProfileId':_0x50bc9d[_0x70d0('0x8b')]},'raw':!![]})[_0x70d0('0x2a')](function(_0x33798e){if(_0x33798e&&_0x33798e[_0x70d0('0x8e')]===0x0){return db['UserProfileResource'][_0x70d0('0x88')]({'name':_0x390810[_0x70d0('0x2e')],'resourceId':_0x390810['id'],'type':_0x33798e[_0x70d0('0x2e')],'sectionId':_0x33798e['id']},{})['then'](function(){return _0x4edab6;});}else{return _0x4edab6;}})[_0x70d0('0x49')](function(_0x1851df){logger[_0x70d0('0x2c')](_0x70d0('0x8f'),_0x1851df);throw _0x1851df;});}return _0x4edab6;})['then'](respondWithResult(_0x1e130f,null))[_0x70d0('0x49')](handleError(_0x1e130f,null));}});}catch(_0x4a07f5){_0x1e130f[_0x70d0('0x22')](0x1f4)[_0x70d0('0x90')](_0x4a07f5);}};function removeReferences(_0x47a6e9,_0x278c27){try{if(_0x47a6e9){fs['unlinkSync'](_0x47a6e9);logger[_0x70d0('0x60')](_0x70d0('0x91'));}if(_0x278c27){rimraf(_0x278c27,function(){});logger[_0x70d0('0x60')](_0x70d0('0x92'));}}catch(_0x3e963f){logger['error'](_0x3e963f);}}exports[_0x70d0('0x93')]=function(_0x1a1352,_0x4ccf9d,_0x51f8f8){return db['Plugin'][_0x70d0('0x48')]({'where':{'id':_0x1a1352['params']['id']}})[_0x70d0('0x2a')](handleEntityNotFound(_0x4ccf9d,null))['then'](saveUpdates(_0x1a1352[_0x70d0('0x89')],null))['then'](respondWithResult(_0x4ccf9d,null))[_0x70d0('0x49')](handleError(_0x4ccf9d,null));};exports[_0x70d0('0x94')]=function(_0x453e34,_0x4ac25d,_0x2c5906){return db[_0x70d0('0x31')][_0x70d0('0x48')]({'where':{'id':_0x453e34[_0x70d0('0x4b')]['id']}})[_0x70d0('0x2a')](function(_0xe4acf1){if(_0xe4acf1){return _0xe4acf1['destroy']();}})[_0x70d0('0x2a')](function(_0x20e528){rimraf(path[_0x70d0('0x4c')](config[_0x70d0('0x4d')],_0x70d0('0x4e'),path[_0x70d0('0x58')](_0x20e528['path'])),function(){});return _0x20e528;})[_0x70d0('0x2a')](handleEntityNotFound(_0x4ac25d,null))['then'](respondWithStatusCode(_0x4ac25d,null))['catch'](handleError(_0x4ac25d,null));};exports[_0x70d0('0x95')]=function(_0x2e19df,_0x1c1de2,_0x2c359a){return BPromise['resolve']()[_0x70d0('0x2a')](function(){if(!_0x2e19df[_0x70d0('0x36')]['path']){throw new Error(_0x70d0('0x96'));}if(!_0x2e19df[_0x70d0('0x36')][_0x70d0('0x97')]){throw new Error(_0x70d0('0x98'));}var _0x53ba88=_0x2e19df['query'][_0x70d0('0x99')]?_0x2e19df['query'][_0x70d0('0x99')]+':'+_0x2e19df[_0x70d0('0x36')][_0x70d0('0x97')]:'http://localhost:'+_0x2e19df[_0x70d0('0x36')]['port'];var _0x3fccbd=_0x2e19df[_0x70d0('0x36')][_0x70d0('0x1d')]?_0x2e19df[_0x70d0('0x36')][_0x70d0('0x1d')]:!![];var _0x198bf7=_0x2e19df['query'][_0x70d0('0x9a')]?_0x2e19df[_0x70d0('0x36')][_0x70d0('0x9a')]:null;var _0x33fad3={'method':_0x2e19df[_0x70d0('0x9b')],'uri':util['format'](_0x70d0('0x9c'),_0x53ba88,_0x2e19df[_0x70d0('0x36')]['path']),'json':_0x3fccbd,'resolveWithFullResponse':!![],'encoding':_0x198bf7,'qs':_0x2e19df[_0x70d0('0x36')]};if(_0x2e19df[_0x70d0('0x9d')]){_0x33fad3[_0x70d0('0x9d')]=_0x2e19df[_0x70d0('0x9d')];if(_0x33fad3['headers']['content-length']){delete _0x33fad3[_0x70d0('0x9d')][_0x70d0('0x9e')];}}if(_0x33fad3[_0x70d0('0x9d')]['content-type']){delete _0x33fad3[_0x70d0('0x9d')]['content-type'];}return rp(_0x33fad3);})['then'](function(_0x5bd283){if(_0x5bd283){_0x1c1de2[_0x70d0('0x23')](_0x5bd283['headers']);logger[_0x70d0('0x60')](_0x5bd283[_0x70d0('0x89')]);if(_[_0x70d0('0x9f')](_0x2e19df[_0x70d0('0x36')][_0x70d0('0x8')],_0x70d0('0x4a'))&&_0x5bd283[_0x70d0('0xa0')]==0x1f4){return _0x1c1de2[_0x70d0('0x1c')](_0x5bd283[_0x70d0('0xa0')]);}else{return _0x1c1de2[_0x70d0('0x22')](_0x5bd283['statusCode'])[_0x70d0('0x90')](_0x5bd283[_0x70d0('0x89')]);}}else{return _0x1c1de2[_0x70d0('0x1c')](0xc8);}})[_0x70d0('0x49')](handleError(_0x1c1de2,null));};exports[_0x70d0('0xa1')]=function(_0x467b7b,_0x5dd22e,_0x2948f3){return BPromise['resolve']()[_0x70d0('0x2a')](function(){if(!_0x467b7b[_0x70d0('0x36')]['path']){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x467b7b[_0x70d0('0x36')][_0x70d0('0x97')]){throw new Error(_0x70d0('0x98'));}var _0x386733=_0x467b7b[_0x70d0('0x36')][_0x70d0('0x99')]?_0x467b7b[_0x70d0('0x36')][_0x70d0('0x99')]+':'+_0x467b7b[_0x70d0('0x36')][_0x70d0('0x97')]:_0x70d0('0xa2')+_0x467b7b[_0x70d0('0x36')][_0x70d0('0x97')];var _0x4b0ed3=_0x467b7b[_0x70d0('0x36')][_0x70d0('0x1d')]?_0x467b7b[_0x70d0('0x36')][_0x70d0('0x1d')]:!![];var _0x2d6220=_0x467b7b[_0x70d0('0x36')][_0x70d0('0x9a')]?_0x467b7b[_0x70d0('0x36')][_0x70d0('0x9a')]:null;var _0x317220={'method':_0x467b7b[_0x70d0('0x9b')],'uri':util[_0x70d0('0x5c')](_0x70d0('0x9c'),_0x386733,_0x467b7b[_0x70d0('0x36')][_0x70d0('0x8')]),'json':_0x4b0ed3,'resolveWithFullResponse':!![],'encoding':_0x2d6220,'body':_0x467b7b[_0x70d0('0x89')]};if(_0x467b7b[_0x70d0('0x9d')]){_0x317220['headers']=_0x467b7b[_0x70d0('0x9d')];if(_0x317220[_0x70d0('0x9d')]['content-length']){delete _0x317220[_0x70d0('0x9d')][_0x70d0('0x9e')];}}if(_0x317220[_0x70d0('0x9d')][_0x70d0('0xa3')]){delete _0x317220[_0x70d0('0x9d')][_0x70d0('0xa3')];}return rp(_0x317220);})['then'](function(_0x413908){if(_0x413908){_0x5dd22e[_0x70d0('0x23')](_0x413908[_0x70d0('0x9d')]);logger[_0x70d0('0x60')](_0x413908['body']);return _0x5dd22e[_0x70d0('0x22')](_0x413908[_0x70d0('0xa0')])[_0x70d0('0x90')](_0x413908[_0x70d0('0x89')]);}else{return _0x5dd22e[_0x70d0('0x1c')](0xc8);}})[_0x70d0('0x49')](handleError(_0x5dd22e,null));}; \ No newline at end of file diff --git a/server/api/plugin/plugin.events.js b/server/api/plugin/plugin.events.js new file mode 100644 index 0000000..871fb3e --- /dev/null +++ b/server/api/plugin/plugin.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9f02=['save','update','remove','emit','hasOwnProperty','hook','events'];(function(_0x43c920,_0x187315){var _0x16e4c0=function(_0xa1ae11){while(--_0xa1ae11){_0x43c920['push'](_0x43c920['shift']());}};_0x16e4c0(++_0x187315);}(_0x9f02,0x68));var _0x29f0=function(_0x2c77d1,_0x172e20){_0x2c77d1=_0x2c77d1-0x0;var _0x1cac3f=_0x9f02[_0x2c77d1];return _0x1cac3f;};'use strict';var EventEmitter=require(_0x29f0('0x0'));var Plugin=require('../../mysqldb')['db']['Plugin'];var PluginEvents=new EventEmitter();PluginEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x29f0('0x1'),'afterUpdate':_0x29f0('0x2'),'afterDestroy':_0x29f0('0x3')};function emitEvent(_0x24792b){return function(_0x1a49c1,_0x47e569,_0x204fc4){PluginEvents['emit'](_0x24792b+':'+_0x1a49c1['id'],_0x1a49c1);PluginEvents[_0x29f0('0x4')](_0x24792b,_0x1a49c1);_0x204fc4(null);};}for(var e in events){if(events[_0x29f0('0x5')](e)){var event=events[e];Plugin[_0x29f0('0x6')](e,emitEvent(event));}}module['exports']=PluginEvents; \ No newline at end of file diff --git a/server/api/plugin/plugin.model.js b/server/api/plugin/plugin.model.js new file mode 100644 index 0000000..1dd0741 --- /dev/null +++ b/server/api/plugin/plugin.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc0bc=['Plugin','plugins','util','../../config/logger','api','moment','request-promise','path','rimraf','./plugin.attributes','exports','define'];(function(_0x57d13b,_0x52d8cb){var _0x467696=function(_0x153000){while(--_0x153000){_0x57d13b['push'](_0x57d13b['shift']());}};_0x467696(++_0x52d8cb);}(_0xc0bc,0x176));var _0xcc0b=function(_0xfe34bc,_0x191504){_0xfe34bc=_0xfe34bc-0x0;var _0x3a085c=_0xc0bc[_0xfe34bc];return _0x3a085c;};'use strict';var _=require('lodash');var util=require(_0xcc0b('0x0'));var logger=require(_0xcc0b('0x1'))(_0xcc0b('0x2'));var moment=require(_0xcc0b('0x3'));var BPromise=require('bluebird');var rp=require(_0xcc0b('0x4'));var fs=require('fs');var path=require(_0xcc0b('0x5'));var rimraf=require(_0xcc0b('0x6'));var config=require('../../config/environment');var attributes=require(_0xcc0b('0x7'));module[_0xcc0b('0x8')]=function(_0x526a0d,_0x5b427c){return _0x526a0d[_0xcc0b('0x9')](_0xcc0b('0xa'),attributes,{'tableName':_0xcc0b('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/plugin/plugin.rpc.js b/server/api/plugin/plugin.rpc.js new file mode 100644 index 0000000..60522a2 --- /dev/null +++ b/server/api/plugin/plugin.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5000=['create','body','stringify','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','message','result','CreatePlugin','Plugin'];(function(_0x1d3ece,_0x3fb359){var _0x1ba5d2=function(_0xaa2729){while(--_0xaa2729){_0x1d3ece['push'](_0x1d3ece['shift']());}};_0x1ba5d2(++_0x3fb359);}(_0x5000,0x1c5));var _0x0500=function(_0x522736,_0x30aadc){_0x522736=_0x522736-0x0;var _0x4b4aae=_0x5000[_0x522736];return _0x4b4aae;};'use strict';var _=require(_0x0500('0x0'));var util=require(_0x0500('0x1'));var moment=require('moment');var BPromise=require(_0x0500('0x2'));var rs=require(_0x0500('0x3'));var fs=require('fs');var Redis=require(_0x0500('0x4'));var db=require(_0x0500('0x5'))['db'];var utils=require(_0x0500('0x6'));var logger=require(_0x0500('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x0500('0x8'));var client=jayson['client'][_0x0500('0x9')]({'port':0x232a});config[_0x0500('0xa')]=_[_0x0500('0xb')](config[_0x0500('0xa')],{'host':_0x0500('0xc'),'port':0x18eb});var socket=require(_0x0500('0xd'))(new Redis(config[_0x0500('0xa')]));require(_0x0500('0xe'))[_0x0500('0xf')](socket);function respondWithRpcPromise(_0x3757de,_0xfe456e,_0x344135){return new BPromise(function(_0x31970b,_0x3c76aa){return client['request'](_0x3757de,_0x344135)[_0x0500('0x10')](function(_0x2510c5){logger[_0x0500('0x11')](_0x0500('0x12'),_0xfe456e,_0x0500('0x13'));logger[_0x0500('0x14')](_0x0500('0x15'),_0xfe456e,_0x0500('0x13'),JSON['stringify'](_0x2510c5));if(_0x2510c5[_0x0500('0x16')]){if(_0x2510c5[_0x0500('0x16')]['code']===0x1f4){logger['error']('Plugin,\x20%s,\x20%s',_0xfe456e,_0x2510c5[_0x0500('0x16')][_0x0500('0x17')]);return _0x3c76aa(_0x2510c5[_0x0500('0x16')][_0x0500('0x17')]);}logger['error'](_0x0500('0x12'),_0xfe456e,_0x2510c5['error']['message']);return _0x31970b(_0x2510c5['error'][_0x0500('0x17')]);}else{logger[_0x0500('0x11')]('Plugin,\x20%s,\x20%s',_0xfe456e,_0x0500('0x13'));_0x31970b(_0x2510c5[_0x0500('0x18')][_0x0500('0x17')]);}})['catch'](function(_0x557a93){logger['error']('Plugin,\x20%s,\x20%s',_0xfe456e,_0x557a93);_0x3c76aa(_0x557a93);});});}exports[_0x0500('0x19')]=function(_0x2da331){var _0x404583=this;return new Promise(function(_0x431b6e,_0x2ccb2d){return db[_0x0500('0x1a')][_0x0500('0x1b')](_0x2da331[_0x0500('0x1c')],{'raw':_0x2da331['options']?_0x2da331['options']['raw']===undefined?!![]:![]:!![]})[_0x0500('0x10')](function(_0x5c4c9b){logger[_0x0500('0x11')](_0x0500('0x19'),_0x2da331);logger['debug'](_0x0500('0x19'),_0x2da331,JSON[_0x0500('0x1d')](_0x5c4c9b));_0x431b6e(_0x5c4c9b);})['catch'](function(_0x56f033){logger['error'](_0x0500('0x19'),_0x56f033[_0x0500('0x17')],_0x2da331);_0x2ccb2d(_0x404583[_0x0500('0x16')](0x1f4,_0x56f033['message']));});});}; \ No newline at end of file diff --git a/server/api/plugin/plugin.socket.js b/server/api/plugin/plugin.socket.js new file mode 100644 index 0000000..3b18591 --- /dev/null +++ b/server/api/plugin/plugin.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8c93=['save','remove','update','removeListener','register','length','plugin:'];(function(_0x2a4885,_0x528f86){var _0x41a605=function(_0x2f756e){while(--_0x2f756e){_0x2a4885['push'](_0x2a4885['shift']());}};_0x41a605(++_0x528f86);}(_0x8c93,0xcb));var _0x38c9=function(_0x2d4d7e,_0x191aac){_0x2d4d7e=_0x2d4d7e-0x0;var _0x39c54c=_0x8c93[_0x2d4d7e];return _0x39c54c;};'use strict';var PluginEvents=require('./plugin.events');var events=[_0x38c9('0x0'),_0x38c9('0x1'),_0x38c9('0x2')];function createListener(_0x2f80f5,_0x18b2d2){return function(_0x20327f){_0x18b2d2['emit'](_0x2f80f5,_0x20327f);};}function removeListener(_0x3dad93,_0x370c11){return function(){PluginEvents[_0x38c9('0x3')](_0x3dad93,_0x370c11);};}exports[_0x38c9('0x4')]=function(_0x1e9fab){for(var _0x1f1094=0x0,_0x100272=events[_0x38c9('0x5')];_0x1f1094<_0x100272;_0x1f1094++){var _0x5829f0=events[_0x1f1094];var _0x2ef2bc=createListener(_0x38c9('0x6')+_0x5829f0,_0x1e9fab);PluginEvents['on'](_0x5829f0,_0x2ef2bc);}}; \ No newline at end of file diff --git a/server/api/pm2/index.js b/server/api/pm2/index.js new file mode 100644 index 0000000..7c1ab62 --- /dev/null +++ b/server/api/pm2/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['create','put','delete','destroy','exports','express','Router','../../components/auth/service','isAuthenticated','get','/:id','show','post'];(function(_0x4186e4,_0x4db806){var _0x544e7a=function(_0x4a7e84){while(--_0x4a7e84){_0x4186e4['push'](_0x4186e4['shift']());}};_0x544e7a(++_0x4db806);}(_0xa9e0,0x123));var _0x0a9e=function(_0xae7c2f,_0xf31e04){_0xae7c2f=_0xae7c2f-0x0;var _0x5d7001=_0xa9e0[_0xae7c2f];return _0x5d7001;};'use strict';var express=require(_0x0a9e('0x0'));var router=express[_0x0a9e('0x1')]();var auth=require(_0x0a9e('0x2'));var controller=require('./pm2.controller');router['get']('/',auth[_0x0a9e('0x3')](),controller['index']);router[_0x0a9e('0x4')](_0x0a9e('0x5'),auth[_0x0a9e('0x3')](),controller[_0x0a9e('0x6')]);router[_0x0a9e('0x7')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x8')]);router[_0x0a9e('0x9')](_0x0a9e('0x5'),auth['isAuthenticated'](),controller['update']);router[_0x0a9e('0xa')]('/:id',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);module[_0x0a9e('0xc')]=router; \ No newline at end of file diff --git a/server/api/pm2/pm2.controller.js b/server/api/pm2/pm2.controller.js new file mode 100644 index 0000000..5662d67 --- /dev/null +++ b/server/api/pm2/pm2.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb469=['motion2','show','create','body','join','../../files/plugins','chdir','dirname','start','dump','catch','status','update','restart','hasOwnProperty','params','Unknown\x20status','delete','Unknown\x20id','lodash','../../config/pm2','../../config/logger','api','path','child_process','exec','sendStatus','error','stack','name','send','info','index','list','then','reject','express'];(function(_0x48aaac,_0x34c645){var _0xd9947a=function(_0x1a039a){while(--_0x1a039a){_0x48aaac['push'](_0x48aaac['shift']());}};_0xd9947a(++_0x34c645);}(_0xb469,0x13b));var _0x9b46=function(_0x32c10f,_0x10a371){_0x32c10f=_0x32c10f-0x0;var _0x46c409=_0xb469[_0x32c10f];return _0x46c409;};'use strict';var _=require(_0x9b46('0x0'));var pm2=require(_0x9b46('0x1'));var logger=require(_0x9b46('0x2'))(_0x9b46('0x3'));var path=require(_0x9b46('0x4'));var exec=require(_0x9b46('0x5'))[_0x9b46('0x6')];var BPromise=require('bluebird');function handleEntityNotFound(_0x31f853,_0x45322f){return function(_0x538fc4){if(!_0x538fc4){_0x31f853[_0x9b46('0x7')](0x194);;}return _0x538fc4;};}function respondWithResult(_0x405d1c,_0x50b49e){_0x50b49e=_0x50b49e||0xc8;return function(_0x1b2dd3){if(_0x1b2dd3){return _0x405d1c['status'](_0x50b49e)['json'](_0x1b2dd3);}return null;};}function handleError(_0x34c0de,_0x545b6c){_0x545b6c=_0x545b6c||0x1f4;return function(_0x402595){logger[_0x9b46('0x8')](_0x402595[_0x9b46('0x9')]);if(_0x402595['name']){delete _0x402595[_0x9b46('0xa')];}_0x34c0de['status'](_0x545b6c)[_0x9b46('0xb')](_0x402595);};}function execChildProcess(){return new BPromise(function(_0x568d9a,_0x2c29a7){exec('npm\x20install',function(_0x672157,_0x233b6b,_0x563de4){logger[_0x9b46('0xc')](_0x233b6b);logger[_0x9b46('0xc')](_0x563de4);if(_0x672157){logger['error'](_0x672157);return _0x2c29a7(_0x672157);}return _0x568d9a(_0x233b6b);});});}exports[_0x9b46('0xd')]=function(_0x2cfb35,_0x3d9618){return pm2[_0x9b46('0xe')]()[_0x9b46('0xf')](function(_0x35c5c1){if(_0x35c5c1){var _0x2136bc=_[_0x9b46('0x10')](_0x35c5c1,function(_0x3f2b28){return _0x3f2b28[_0x9b46('0xa')]===_0x9b46('0x11')||_0x3f2b28[_0x9b46('0xa')]===_0x9b46('0x12');});return{'rows':_0x2136bc,'count':_0x2136bc['length']};}return null;})['then'](respondWithResult(_0x3d9618,null))['catch'](handleError(_0x3d9618,null));};exports[_0x9b46('0x13')]=function(_0x5a380c,_0x29fec9){return pm2['describe'](_0x5a380c['params']['id'])[_0x9b46('0xf')](respondWithResult(_0x29fec9,null))['then'](handleEntityNotFound(_0x29fec9,null))['catch'](handleError(_0x29fec9,null));};exports[_0x9b46('0x14')]=function(_0x3a15cc,_0x5a0d25){if(_0x3a15cc[_0x9b46('0x15')][_0x9b46('0xa')]&&_0x3a15cc['body']['script']){var _0xbec2ea=path[_0x9b46('0x16')](__dirname,_0x9b46('0x17'),_0x3a15cc['body']['script']);var _0x2b3440=process['cwd']();process[_0x9b46('0x18')](path[_0x9b46('0x19')](_0xbec2ea));return execChildProcess()['then'](function(_0xadff19){process['chdir'](_0x2b3440);return pm2[_0x9b46('0x1a')]({'name':_0x3a15cc[_0x9b46('0x15')]['name'],'script':_0xbec2ea});})[_0x9b46('0xf')](function(_0x31ca63){pm2[_0x9b46('0x1b')]();return _0x31ca63[0x0];})[_0x9b46('0xf')](respondWithResult(_0x5a0d25,0xc9))[_0x9b46('0x1c')](handleError(_0x5a0d25,null));}else{return _0x5a0d25[_0x9b46('0x1d')](0x1f4)[_0x9b46('0xb')]({'message':'Missing\x20name\x20and/or\x20path'});}};exports[_0x9b46('0x1e')]=function(_0x3ac37e,_0x478105){if(_0x3ac37e[_0x9b46('0x15')]['id']){delete _0x3ac37e[_0x9b46('0x15')]['id'];}var _0x2a79a5={'online':_0x9b46('0x1f'),'stopped':'stop'};if(_0x2a79a5[_0x9b46('0x20')](_0x3ac37e[_0x9b46('0x15')][_0x9b46('0x1d')])){return pm2[_0x2a79a5[_0x3ac37e[_0x9b46('0x15')][_0x9b46('0x1d')]]](_0x3ac37e[_0x9b46('0x21')]['id'])[_0x9b46('0xf')](respondWithResult(_0x478105,0xc8))[_0x9b46('0x1c')](handleError(_0x478105,null));}else{return _0x478105[_0x9b46('0x1d')](0x1f4)[_0x9b46('0xb')]({'message':_0x9b46('0x22')});}};exports['destroy']=function(_0x1f722d,_0x27f326){if(_0x1f722d[_0x9b46('0x15')]['id']){delete _0x1f722d[_0x9b46('0x15')]['id'];}if(_0x1f722d[_0x9b46('0x21')]['id']){return pm2[_0x9b46('0x23')](_0x1f722d[_0x9b46('0x21')]['id'])[_0x9b46('0xf')](function(_0x3ab49a){pm2[_0x9b46('0x1b')]();return _0x3ab49a[0x0];})[_0x9b46('0xf')](respondWithResult(_0x27f326,null))['catch'](handleError(_0x27f326,null));}else{return _0x27f326[_0x9b46('0x1d')](0x1f4)['send']({'message':_0x9b46('0x24')});}}; \ No newline at end of file diff --git a/server/api/realtime/index.js b/server/api/realtime/index.js new file mode 100644 index 0000000..05ad090 --- /dev/null +++ b/server/api/realtime/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3dd2=['getAgents','/queues','exports','../../components/auth/service','./realtime.controller','/agents','isAuthenticated'];(function(_0xfbe361,_0x5573e2){var _0x4fcb56=function(_0x65dcd5){while(--_0x65dcd5){_0xfbe361['push'](_0xfbe361['shift']());}};_0x4fcb56(++_0x5573e2);}(_0x3dd2,0xab));var _0x23dd=function(_0x27cf2e,_0x2e99ee){_0x27cf2e=_0x27cf2e-0x0;var _0x4e8da7=_0x3dd2[_0x27cf2e];return _0x4e8da7;};'use strict';var express=require('express');var router=express['Router']();var auth=require(_0x23dd('0x0'));var controller=require(_0x23dd('0x1'));router['get'](_0x23dd('0x2'),auth[_0x23dd('0x3')](),controller[_0x23dd('0x4')]);router['get'](_0x23dd('0x5'),auth[_0x23dd('0x3')](),controller['getQueues']);module[_0x23dd('0x6')]=router; \ No newline at end of file diff --git a/server/api/realtime/realtime.controller.js b/server/api/realtime/realtime.controller.js new file mode 100644 index 0000000..ed6668b --- /dev/null +++ b/server/api/realtime/realtime.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0024=['then','channel','format','Channel\x20parameter\x20%s\x20is\x20invalid','toLowerCase','sort','includes','validateSortParameter','getUpdatedSortOptions','fields','getAgentIdsByQueues','getRealtimeAgents','getSortedAgentsIdsByStatus','getAgentIdsByStatus','map','User','rawAttributes','type','agent','online','raw','length','sequelize','literal','FIELD(id,','order','push','Pause','forEach','where','user','role','userProfileId','Agents','extraQueryConditions','assign','UserProfile','findAndCountAll','rows','find','filterAgentAttributes','merge','globalStatus','getAgentStatus','pause','Status','sortAgentsByStatus','split','catch','getQueues','startCase','Queue','fieldName','name','voice','outbound','join','getOptions','QueueCampaigns','Queues','filter','initializeQueues','lodash','util','../../components/realtime/agents','../../components/realtime/queues','../../components/parsers/qs','../../config/utils','../../errors/api','APIBadRequestError','undefined','limit','offset','count','status','set','Content-Range','getChannels','query','globalQueueFilter','globalStatusFilter','pauseTypeFilter','*pause','resolve'];(function(_0x2cfb58,_0x3d9412){var _0xd99951=function(_0x329afa){while(--_0x329afa){_0x2cfb58['push'](_0x2cfb58['shift']());}};_0xd99951(++_0x3d9412);}(_0x0024,0x13a));var _0x4002=function(_0x178619,_0x8acdca){_0x178619=_0x178619-0x0;var _0x5d16a0=_0x0024[_0x178619];return _0x5d16a0;};'use strict';var _=require(_0x4002('0x0'));var util=require(_0x4002('0x1'));var rta=require(_0x4002('0x2'));var rtq=require(_0x4002('0x3'));var qs=require(_0x4002('0x4'));var utils=require(_0x4002('0x5'));var db=require('../../mysqldb')['db'];var APIBadRequestError=require(_0x4002('0x6'))[_0x4002('0x7')];var APIHandleError=require(_0x4002('0x6'))['handleError'];function respondWithFilteredResult(_0x17ef4c,_0x4c8855){return function(_0xfc8817){if(_0xfc8817){var _0x46fe98=typeof _0x4c8855['offset']===_0x4002('0x8')&&typeof _0x4c8855[_0x4002('0x9')]===_0x4002('0x8');var _0xe1c2b1=_0xfc8817['count'];var _0x3b6165=_0x46fe98?0x0:_0x4c8855[_0x4002('0xa')];var _0x966e72=_0x46fe98?_0xfc8817[_0x4002('0xb')]:_0x4c8855[_0x4002('0xa')]+_0x4c8855[_0x4002('0x9')];var _0x7e65f5;if(_0x966e72>=_0xe1c2b1){_0x966e72=_0xe1c2b1;_0x7e65f5=0xc8;}else{_0x7e65f5=0xce;}_0x17ef4c[_0x4002('0xc')](_0x7e65f5);return _0x17ef4c[_0x4002('0xd')](_0x4002('0xe'),_0x3b6165+'-'+_0x966e72+'/'+_0xe1c2b1)['json'](_0xfc8817);}return null;};}exports['getAgents']=function(_0x1429ae,_0xe2c82){var _0x391dff={'count':0x0,'rows':[]};var _0x3f4426={};var _0x3dafa7;var _0x592d33=utils[_0x4002('0xf')]();var _0xeb3e16;var _0x147a68;var _0x4c2a4f=_0x1429ae[_0x4002('0x10')][_0x4002('0x11')];var _0x3dd5e0=_0x1429ae['query'][_0x4002('0x12')];var _0x431d53=_0x1429ae[_0x4002('0x10')][_0x4002('0x13')];var _0x560357=_0x3dd5e0==='pause'||_0x3dd5e0===_0x4002('0x14')?!![]:![];var _0x39f259=[];var _0xccfbcc;var _0x41501f;Promise[_0x4002('0x15')]()[_0x4002('0x16')](function(){if(_0x1429ae[_0x4002('0x10')]['channel']){if(!utils['isValidChannel'](_0x1429ae[_0x4002('0x10')][_0x4002('0x17')])){throw new APIBadRequestError(util[_0x4002('0x18')](_0x4002('0x19'),_0x1429ae[_0x4002('0x10')][_0x4002('0x17')]));}_0x3dafa7=_0x1429ae['query'][_0x4002('0x17')][_0x4002('0x1a')]();}if(!_0x1429ae[_0x4002('0x10')][_0x4002('0x1b')]||!_0x1429ae[_0x4002('0x10')][_0x4002('0x1b')][_0x4002('0x1c')]('globalStatus')){_0x1429ae[_0x4002('0x10')][_0x4002('0x1b')]=rta[_0x4002('0x1d')](_0x1429ae[_0x4002('0x10')][_0x4002('0x1b')]);return;}var _0x2b3ea1=rta[_0x4002('0x1e')](_0x1429ae[_0x4002('0x10')]['sort']);_0x1429ae[_0x4002('0x10')]['sort']=_0x2b3ea1[_0x4002('0x1f')]['join'](',');_0xccfbcc=_0x2b3ea1['order'];})['then'](function(){if(!_0x4c2a4f){return[];}return rta[_0x4002('0x20')](_0x4c2a4f,_0x3dafa7);})[_0x4002('0x16')](function(_0x4aa848){_0x39f259=_0x4aa848;return rta[_0x4002('0x21')]();})['then'](function(_0x3ff082){_0x147a68=_0x3ff082['rows'];if((!_0x3dd5e0||_0x560357)&&!_0xccfbcc){return _0x39f259;}if(_0xccfbcc&&!_0x3dd5e0){return rta[_0x4002('0x22')](_0x147a68,_0x39f259,_0xccfbcc);}else{return rta[_0x4002('0x23')](_0x147a68,_0x39f259,_0x3dd5e0);}})[_0x4002('0x16')](function(_0x236b97){_0x39f259=_0x236b97;var _0x319637=![];if(_0x39f259['length']===0x0){if(_0x4c2a4f||_0x3dd5e0){_0x319637=!![];}if(_0x560357){_0x319637=![];}}if(_0x319637){return _0x391dff;}var _0x43d76c=_[_0x4002('0x24')](db[_0x4002('0x25')][_0x4002('0x26')],function(_0x3adfef){return{'name':_0x3adfef['fieldName'],'type':_0x3adfef[_0x4002('0x27')]['key']};});_0x1429ae['query']['role']=_0x4002('0x28');_0x1429ae[_0x4002('0x10')][_0x4002('0x29')]=!![];_0x3f4426=qs['getOptions'](_0x43d76c,_0x1429ae);_0x3f4426[_0x4002('0x2a')]=!![];var _0x2e3249=[];if(_0x39f259[_0x4002('0x2b')]>0x0){_0x2e3249['push']({'id':{'$in':_0x39f259}});if(_0xccfbcc&&!_0x3dd5e0){_0x41501f=[db[_0x4002('0x2c')][_0x4002('0x2d')](_0x4002('0x2e')+_0x39f259+')')];_0x3f4426[_0x4002('0x2f')]=_0x41501f;}}if(_0x560357){_0x592d33['forEach'](function(_0x5710ae){var _0xc0ade5=!![];if(_0x3dd5e0===_0x4002('0x14')&&_0x3dafa7!==_0x5710ae){_0xc0ade5=![];}_0x2e3249[_0x4002('0x30')]({[_0x5710ae+_0x4002('0x31')]:_0xc0ade5});});if(_0x431d53){_0x2e3249[_0x4002('0x30')]({'pauseType':_0x431d53});}}else if(_0x3dd5e0){_0x592d33[_0x4002('0x32')](function(_0x24a1ea){_0x2e3249[_0x4002('0x30')]({[_0x24a1ea+_0x4002('0x31')]:![]});});}_0x3f4426[_0x4002('0x33')]=_['merge'](_0x3f4426[_0x4002('0x33')],{'$and':_0x2e3249});if(_0x1429ae[_0x4002('0x34')][_0x4002('0x35')]===_0x4002('0x34')){var _0x5d4e2f={'params':{'id':_0x1429ae['user'][_0x4002('0x36')]},'query':{'section':_0x4002('0x37'),'role':'agent','online':!![],'raw':!![],'ids':_0x39f259,'customSorting':_0x41501f}};if(_0x560357){_0x5d4e2f[_0x4002('0x10')][_0x4002('0x38')]=_0x2e3249;}_0x5d4e2f['query']=Object[_0x4002('0x39')](_0x5d4e2f[_0x4002('0x10')],_0x1429ae[_0x4002('0x10')]);delete _0x5d4e2f[_0x4002('0x10')]['id'];return db[_0x4002('0x3a')]['getResources'](_0x5d4e2f);}return db[_0x4002('0x25')][_0x4002('0x3b')](_0x3f4426);})[_0x4002('0x16')](function(_0x50a6d9){_0x391dff[_0x4002('0xb')]=_0x50a6d9[_0x4002('0xb')];_0xeb3e16=_0x50a6d9[_0x4002('0x3c')];return _0xeb3e16[_0x4002('0x24')](function(_0x1266c7){var _0x59b58c=_[_0x4002('0x3d')](_0x147a68,['id',_0x1266c7['id']]);if(_0x59b58c){var _0x2f69b0=rta[_0x4002('0x3e')](_0x59b58c);_[_0x4002('0x3f')](_0x1266c7,_0x2f69b0);}_0x1266c7[_0x4002('0x40')]=rta[_0x4002('0x41')](_0x1266c7);if(_0x1266c7[_0x4002('0x40')][_0x4002('0x1c')](_0x4002('0x42'))){_0x592d33[_0x4002('0x32')](function(_0x7cdfe9){if(_0x1266c7[_0x7cdfe9+'Pause']){_0x1266c7[_0x7cdfe9+_0x4002('0x43')]=_0x4002('0x42');}});}return _0x1266c7;});})[_0x4002('0x16')](function(_0x1224bf){if(!_0xccfbcc||_0x41501f){return _0x1224bf;}return rta[_0x4002('0x44')](_0x1224bf,_0xccfbcc);})[_0x4002('0x16')](function(_0x51cab6){var _0x57e374=null;if(_0x1429ae[_0x4002('0x10')][_0x4002('0x1f')]){var _0x39b623=_0x1429ae[_0x4002('0x10')][_0x4002('0x1f')][_0x4002('0x45')](',');_0x57e374=_0x51cab6['map'](function(_0x1276a2){return _['pick'](_0x1276a2,_0x39b623);});}_0x391dff[_0x4002('0x3c')]=_0x57e374||_0x51cab6;return _0x391dff;})[_0x4002('0x16')](respondWithFilteredResult(_0xe2c82,_0x3f4426))[_0x4002('0x46')](APIHandleError(_0xe2c82));};exports[_0x4002('0x47')]=function(_0x37cf03,_0x597d87){var _0x1da662={'count':0x0,'rows':[]};var _0x21b8e4={};var _0xfa38ae;var _0x19ce66;var _0x471877;Promise['resolve']()[_0x4002('0x16')](function(){if(_0x37cf03[_0x4002('0x10')]['channel']){if(!utils['isValidChannel'](_0x37cf03[_0x4002('0x10')][_0x4002('0x17')])){throw new APIBadRequestError(util[_0x4002('0x18')](_0x4002('0x19'),_0x37cf03['query']['channel']));}_0xfa38ae=_0x37cf03['query'][_0x4002('0x17')][_0x4002('0x1a')]();}var _0xd37436=_[_0x4002('0x48')](_0xfa38ae)+_0x4002('0x49');var _0x3bc0f5=_[_0x4002('0x24')](db[_0xd37436][_0x4002('0x26')],function(_0x43f681){return{'name':_0x43f681[_0x4002('0x4a')],'type':_0x43f681['type']['key']};});if(!_0x37cf03[_0x4002('0x10')]['fields']){var _0x30b14b=['id',_0x4002('0x4b')];if(_0xfa38ae===_0x4002('0x4c')){_0x30b14b[_0x4002('0x30')]('type');if(_0x37cf03[_0x4002('0x10')]['type']===_0x4002('0x4d')){_0x30b14b[_0x4002('0x30')](['dialActive','dialMethod']);}}_0x37cf03[_0x4002('0x10')][_0x4002('0x1f')]=_0x30b14b[_0x4002('0x4e')](',');}_0x21b8e4=qs[_0x4002('0x4f')](_0x3bc0f5,_0x37cf03);if(_0x37cf03[_0x4002('0x34')][_0x4002('0x35')]==='user'){var _0x45613b={'params':{'id':_0x37cf03[_0x4002('0x34')][_0x4002('0x36')]},'query':{'section':_0xfa38ae===_0x4002('0x4c')&&_0x37cf03['query'][_0x4002('0x27')]==='outbound'?_0x4002('0x50'):_[_0x4002('0x48')](_0xfa38ae)+_0x4002('0x51'),'type':_0x37cf03[_0x4002('0x10')]['type'],'nolimit':!![],'sort':_0x4002('0x4b'),'filter':_0x37cf03[_0x4002('0x10')][_0x4002('0x52')]}};return db['UserProfile']['getResources'](_0x45613b);}return db[_0xd37436]['findAndCountAll'](_0x21b8e4);})[_0x4002('0x16')](function(_0x3e546b){_0x1da662['count']=_0x3e546b[_0x4002('0xb')];_0x19ce66=_0x3e546b[_0x4002('0x3c')];return rtq['getRealtimeQueues'](_0x37cf03,_0xfa38ae);})[_0x4002('0x16')](function(_0x52dba1){_0x471877=_0x52dba1['rows'];return rtq[_0x4002('0x53')](_0x19ce66,_0x471877,_0xfa38ae,_0x37cf03[_0x4002('0x10')][_0x4002('0x27')]);})[_0x4002('0x16')](function(_0x35d26b){_0x1da662[_0x4002('0x3c')]=_0x35d26b;return _0x1da662;})[_0x4002('0x16')](respondWithFilteredResult(_0x597d87,_0x21b8e4))['catch'](APIHandleError(_0x597d87));}; \ No newline at end of file diff --git a/server/api/reportAgentPreview/index.js b/server/api/reportAgentPreview/index.js new file mode 100644 index 0000000..723e800 --- /dev/null +++ b/server/api/reportAgentPreview/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../components/interaction/service','../../config/environment','exports','multer','util','path','Router','../../components/auth/service'];(function(_0x43469e,_0x4e69d6){var _0xcefd2a=function(_0x8ded6f){while(--_0x8ded6f){_0x43469e['push'](_0x43469e['shift']());}};_0xcefd2a(++_0x4e69d6);}(_0xa9e0,0x123));var _0x0a9e=function(_0x37bd26,_0x5ad346){_0x37bd26=_0x37bd26-0x0;var _0xe83dc4=_0xa9e0[_0x37bd26];return _0xe83dc4;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));module[_0x0a9e('0x7')]=router; \ No newline at end of file diff --git a/server/api/reportAgentPreview/reportAgentPreview.attributes.js b/server/api/reportAgentPreview/reportAgentPreview.attributes.js new file mode 100644 index 0000000..b0c0a30 --- /dev/null +++ b/server/api/reportAgentPreview/reportAgentPreview.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5e0c=['INTEGER','STRING','DATE','exports'];(function(_0xc64699,_0x1b3076){var _0x40732e=function(_0x23d369){while(--_0x23d369){_0xc64699['push'](_0xc64699['shift']());}};_0x40732e(++_0x1b3076);}(_0x5e0c,0x19f));var _0xc5e0=function(_0x37d8ef,_0x53fdea){_0x37d8ef=_0x37d8ef-0x0;var _0x520900=_0x5e0c[_0x37d8ef];return _0x520900;};'use strict';var Sequelize=require('sequelize');module[_0xc5e0('0x0')]={'state':{'type':Sequelize[_0xc5e0('0x1')](0x2)},'statedesc':{'type':Sequelize[_0xc5e0('0x2')]},'scheduledat':{'type':Sequelize[_0xc5e0('0x3')]},'uniqueid':{'type':Sequelize[_0xc5e0('0x2')]},'starttime':{'type':Sequelize[_0xc5e0('0x3')]},'responsetime':{'type':Sequelize['DATE']},'ringtime':{'type':Sequelize[_0xc5e0('0x1')],'defaultValue':0x0},'campaign':{'type':Sequelize[_0xc5e0('0x2')]},'campaigntype':{'type':Sequelize[_0xc5e0('0x2')]},'membername':{'type':Sequelize[_0xc5e0('0x2')]}}; \ No newline at end of file diff --git a/server/api/reportAgentPreview/reportAgentPreview.model.js b/server/api/reportAgentPreview/reportAgentPreview.model.js new file mode 100644 index 0000000..f4af63b --- /dev/null +++ b/server/api/reportAgentPreview/reportAgentPreview.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8db8=['path','rimraf','../../config/environment','./reportAgentPreview.attributes','exports','define','lodash','../../config/logger','moment','bluebird','request-promise'];(function(_0x528eb7,_0x1f0c9a){var _0x3a0370=function(_0x5dea57){while(--_0x5dea57){_0x528eb7['push'](_0x528eb7['shift']());}};_0x3a0370(++_0x1f0c9a);}(_0x8db8,0x145));var _0x88db=function(_0x5c6c50,_0x24be01){_0x5c6c50=_0x5c6c50-0x0;var _0x1a8d2a=_0x8db8[_0x5c6c50];return _0x1a8d2a;};'use strict';var _=require(_0x88db('0x0'));var util=require('util');var logger=require(_0x88db('0x1'))('api');var moment=require(_0x88db('0x2'));var BPromise=require(_0x88db('0x3'));var rp=require(_0x88db('0x4'));var fs=require('fs');var path=require(_0x88db('0x5'));var rimraf=require(_0x88db('0x6'));var config=require(_0x88db('0x7'));var attributes=require(_0x88db('0x8'));module[_0x88db('0x9')]=function(_0x2095b0,_0x56cc64){return _0x2095b0[_0x88db('0xa')]('ReportAgentPreview',attributes,{'tableName':'report_agent_preview','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/reportAgentPreview/reportAgentPreview.rpc.js b/server/api/reportAgentPreview/reportAgentPreview.rpc.js new file mode 100644 index 0000000..c1b7b8d --- /dev/null +++ b/server/api/reportAgentPreview/reportAgentPreview.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa713=['lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc','http','request','then','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','ReportAgentPreview,\x20%s,\x20%s','result','catch','CreateReportAgentPreview','body','options','info'];(function(_0x473767,_0x1f69f9){var _0x193a36=function(_0x1851b4){while(--_0x1851b4){_0x473767['push'](_0x473767['shift']());}};_0x193a36(++_0x1f69f9);}(_0xa713,0xe6));var _0x3a71=function(_0x457e81,_0x44c530){_0x457e81=_0x457e81-0x0;var _0x2558e4=_0xa713[_0x457e81];return _0x2558e4;};'use strict';var _=require(_0x3a71('0x0'));var util=require(_0x3a71('0x1'));var moment=require(_0x3a71('0x2'));var BPromise=require('bluebird');var rs=require(_0x3a71('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3a71('0x4'));var logger=require(_0x3a71('0x5'))(_0x3a71('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x3a71('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x49ff93,_0x2029e6,_0x19d306){return new BPromise(function(_0x2d1a94,_0x4733fa){return client[_0x3a71('0x8')](_0x49ff93,_0x19d306)[_0x3a71('0x9')](function(_0x2828d1){logger['info']('ReportAgentPreview,\x20%s,\x20%s',_0x2029e6,'request\x20sent');logger[_0x3a71('0xa')](_0x3a71('0xb'),_0x2029e6,_0x3a71('0xc'),JSON[_0x3a71('0xd')](_0x2828d1));if(_0x2828d1['error']){if(_0x2828d1['error']['code']===0x1f4){logger[_0x3a71('0xe')]('ReportAgentPreview,\x20%s,\x20%s',_0x2029e6,_0x2828d1['error'][_0x3a71('0xf')]);return _0x4733fa(_0x2828d1[_0x3a71('0xe')][_0x3a71('0xf')]);}logger[_0x3a71('0xe')](_0x3a71('0x10'),_0x2029e6,_0x2828d1[_0x3a71('0xe')][_0x3a71('0xf')]);return _0x2d1a94(_0x2828d1[_0x3a71('0xe')][_0x3a71('0xf')]);}else{logger['info']('ReportAgentPreview,\x20%s,\x20%s',_0x2029e6,_0x3a71('0xc'));_0x2d1a94(_0x2828d1[_0x3a71('0x11')]['message']);}})[_0x3a71('0x12')](function(_0x4bf7b8){logger['error']('ReportAgentPreview,\x20%s,\x20%s',_0x2029e6,_0x4bf7b8);_0x4733fa(_0x4bf7b8);});});}exports[_0x3a71('0x13')]=function(_0x4b60b8){var _0x2f7f9a=this;return new Promise(function(_0x4d6d10,_0x41b1e2){return db['ReportAgentPreview']['create'](_0x4b60b8[_0x3a71('0x14')],{'raw':_0x4b60b8[_0x3a71('0x15')]?_0x4b60b8[_0x3a71('0x15')]['raw']===undefined?!![]:![]:!![]})[_0x3a71('0x9')](function(_0x141e4a){logger[_0x3a71('0x16')](_0x3a71('0x13'),_0x4b60b8);logger[_0x3a71('0xa')](_0x3a71('0x13'),_0x4b60b8,JSON[_0x3a71('0xd')](_0x141e4a));_0x4d6d10(_0x141e4a);})['catch'](function(_0x1dd509){logger[_0x3a71('0xe')](_0x3a71('0x13'),_0x1dd509[_0x3a71('0xf')],_0x4b60b8);_0x41b1e2(_0x2f7f9a[_0x3a71('0xe')](0x1f4,_0x1dd509[_0x3a71('0xf')]));});});}; \ No newline at end of file diff --git a/server/api/rpc/index.js b/server/api/rpc/index.js new file mode 100644 index 0000000..c2dbafc --- /dev/null +++ b/server/api/rpc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x33d4=['post','/mail/queues/:id/notify','mail','/mail/queues/:id','showMailQueues','/chat/queues/:id/notify','chat','/chat/queues/:id','showChatQueues','queueNotify','fax','/fax/queues/:id','/openchannel/queues/:id/notify','openchannel','showOpenchannelQueues','sms','/whatsapp/queues/:id/notify','whatsapp','/sms/queues/:id','showSmsQueues','/whatsapp/queues/:id','/agents/:id/notify','agentNotify','exports','multer','path','express','Router','../../components/auth/service','./rpc.controller','isAuthenticated','voiceChannels','get','/voice/channels/:uniqueid/mixmonitor','voiceChannelMixMonitor','/voice/queues','voiceQueues','/chat/queues','chatQueues','/mail/queues','/mail/accounts','mailAccounts','/openchannel/queues','smsQueues','/whatsapp/queues','whatsappQueues','/fax/queues','faxQueues','/voice/queues/preview/:id','voiceQueuesPreview','voiceQueuesChannels','/voice/queues/channels/:uniqueid','voiceQueuesChannel','/voice/queues/channels/:uniqueid/hangup','voiceQueuesChannelHangup','voiceQueuesChannelRedirect','/voice/queues/:id','showVoiceQueues','updateVoiceQueue','/outbound/channels','outboundChannels','/agents','agents','/agents/:id/capacity','agentCapacity','/telephones','telephones','/trunks','trunks','/campaigns','/fax/accounts','faxAccounts','/chat/queues/waitinginteractions','chatQueuesWaitingInteractions','/mail/queues/waitinginteractions','mailQueuesWaitingInteractions','/openchannel/queues/waitinginteractions','openchannelQueuesWaitingInteractions','/openchannel/queues/:id/waitinginteractions','/sms/queues/waitinginteractions','smsQueuesWaitingInteractions','/fax/queues/waitinginteractions','faxQueuesWaitingInteractions'];(function(_0x2d929c,_0x1e231d){var _0x20dac1=function(_0x3ac2c2){while(--_0x3ac2c2){_0x2d929c['push'](_0x2d929c['shift']());}};_0x20dac1(++_0x1e231d);}(_0x33d4,0x111));var _0x433d=function(_0x1111ba,_0x506977){_0x1111ba=_0x1111ba-0x0;var _0x5cf412=_0x33d4[_0x1111ba];return _0x5cf412;};'use strict';var multer=require(_0x433d('0x0'));var util=require('util');var path=require(_0x433d('0x1'));var express=require(_0x433d('0x2'));var router=express[_0x433d('0x3')]();var auth=require(_0x433d('0x4'));var controller=require(_0x433d('0x5'));router['get']('/voice/channels',auth[_0x433d('0x6')](),controller[_0x433d('0x7')]);router[_0x433d('0x8')](_0x433d('0x9'),auth['isAuthenticated'](),controller[_0x433d('0xa')]);router[_0x433d('0x8')]('/voice/channels/:uniqueid/stopmixmonitor',auth[_0x433d('0x6')](),controller['voiceChannelStopMixMonitor']);router[_0x433d('0x8')](_0x433d('0xb'),auth[_0x433d('0x6')](),controller[_0x433d('0xc')]);router['get'](_0x433d('0xd'),auth[_0x433d('0x6')](),controller[_0x433d('0xe')]);router[_0x433d('0x8')](_0x433d('0xf'),auth[_0x433d('0x6')](),controller['mailQueues']);router['get'](_0x433d('0x10'),auth['isAuthenticated'](),controller[_0x433d('0x11')]);router[_0x433d('0x8')](_0x433d('0x12'),auth[_0x433d('0x6')](),controller['openchannelQueues']);router[_0x433d('0x8')]('/sms/queues',auth[_0x433d('0x6')](),controller[_0x433d('0x13')]);router[_0x433d('0x8')](_0x433d('0x14'),auth[_0x433d('0x6')](),controller[_0x433d('0x15')]);router[_0x433d('0x8')](_0x433d('0x16'),auth[_0x433d('0x6')](),controller[_0x433d('0x17')]);router['get'](_0x433d('0x18'),auth[_0x433d('0x6')](),controller[_0x433d('0x19')]);router['get']('/voice/queues/channels',auth[_0x433d('0x6')](),controller[_0x433d('0x1a')]);router[_0x433d('0x8')](_0x433d('0x1b'),auth[_0x433d('0x6')](),controller[_0x433d('0x1c')]);router[_0x433d('0x8')](_0x433d('0x1d'),auth[_0x433d('0x6')](),controller[_0x433d('0x1e')]);router[_0x433d('0x8')]('/voice/queues/channels/:uniqueid/redirect/:exten',auth[_0x433d('0x6')](),controller[_0x433d('0x1f')]);router[_0x433d('0x8')](_0x433d('0x20'),auth[_0x433d('0x6')](),controller[_0x433d('0x21')]);router['put']('/voice/queues/:id',auth[_0x433d('0x6')](),controller[_0x433d('0x22')]);router['get']('/outbound',auth[_0x433d('0x6')](),controller['outbound']);router[_0x433d('0x8')](_0x433d('0x23'),auth[_0x433d('0x6')](),controller[_0x433d('0x24')]);router[_0x433d('0x8')](_0x433d('0x25'),auth['isAuthenticated'](),controller[_0x433d('0x26')]);router['put'](_0x433d('0x27'),auth[_0x433d('0x6')](),controller[_0x433d('0x28')]);router[_0x433d('0x8')](_0x433d('0x29'),auth['isAuthenticated'](),controller[_0x433d('0x2a')]);router[_0x433d('0x8')](_0x433d('0x2b'),auth[_0x433d('0x6')](),controller[_0x433d('0x2c')]);router[_0x433d('0x8')](_0x433d('0x2d'),auth[_0x433d('0x6')](),controller['campaigns']);router['get'](_0x433d('0x2e'),auth['isAuthenticated'](),controller[_0x433d('0x2f')]);router[_0x433d('0x8')](_0x433d('0x30'),auth[_0x433d('0x6')](),controller[_0x433d('0x31')]);router[_0x433d('0x8')](_0x433d('0x32'),auth[_0x433d('0x6')](),controller[_0x433d('0x33')]);router['get'](_0x433d('0x34'),auth[_0x433d('0x6')](),controller[_0x433d('0x35')]);router[_0x433d('0x8')](_0x433d('0x36'),auth[_0x433d('0x6')](),controller['openchannelQueuesIdWaitingInteractions']);router[_0x433d('0x8')](_0x433d('0x37'),auth[_0x433d('0x6')](),controller[_0x433d('0x38')]);router['get']('/whatsapp/queues/waitinginteractions',auth['isAuthenticated'](),controller['whatsappQueuesWaitingInteractions']);router['get'](_0x433d('0x39'),auth[_0x433d('0x6')](),controller[_0x433d('0x3a')]);router[_0x433d('0x3b')](_0x433d('0x3c'),auth[_0x433d('0x6')](),controller['queueNotify'](_0x433d('0x3d')));router[_0x433d('0x8')](_0x433d('0x3e'),auth[_0x433d('0x6')](),controller[_0x433d('0x3f')]);router['post'](_0x433d('0x40'),auth['isAuthenticated'](),controller['queueNotify'](_0x433d('0x41')));router[_0x433d('0x8')](_0x433d('0x42'),auth[_0x433d('0x6')](),controller[_0x433d('0x43')]);router[_0x433d('0x3b')]('/fax/queues/:id/notify',auth[_0x433d('0x6')](),controller[_0x433d('0x44')](_0x433d('0x45')));router['get'](_0x433d('0x46'),auth[_0x433d('0x6')](),controller['showFaxQueues']);router[_0x433d('0x3b')](_0x433d('0x47'),auth['isAuthenticated'](),controller[_0x433d('0x44')](_0x433d('0x48')));router[_0x433d('0x8')]('/openchannel/queues/:id',auth[_0x433d('0x6')](),controller[_0x433d('0x49')]);router[_0x433d('0x3b')]('/sms/queues/:id/notify',auth['isAuthenticated'](),controller[_0x433d('0x44')](_0x433d('0x4a')));router['post'](_0x433d('0x4b'),auth[_0x433d('0x6')](),controller['queueNotify'](_0x433d('0x4c')));router[_0x433d('0x8')](_0x433d('0x4d'),auth['isAuthenticated'](),controller[_0x433d('0x4e')]);router[_0x433d('0x8')](_0x433d('0x4f'),auth['isAuthenticated'](),controller['showWhatsappQueues']);router[_0x433d('0x3b')](_0x433d('0x50'),auth[_0x433d('0x6')](),controller[_0x433d('0x51')]);module[_0x433d('0x52')]=router; \ No newline at end of file diff --git a/server/api/rpc/rpc.controller.js b/server/api/rpc/rpc.controller.js new file mode 100644 index 0000000..1babb91 --- /dev/null +++ b/server/api/rpc/rpc.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe14b=['MessageId','InteractionId','QueueId','TransferReport','create','Start','queue','queueTransferTimeout','*,*,*,*','agentNotify','Channel\x20field\x20is\x20mandatory','channel','chat','Website','User','agent','Agent\x20not\x20found','Message','update','From','bluebird','moment','../../mysqldb','../../config/logger','jayson/promise','client','http','request','then','error','message','result','catch','status','json','sendStatus','name','send','isNil','rows','find','voiceChannels','VoiceChannels','query','voiceChannelMixMonitor','VoiceChannelMixMonitor','merge','params','VoiceChannelStopMixMonitor','VoiceQueues','updateVoiceQueue','UpdateVoiceQueue','body','voiceQueuesPreview','VoiceQueuesPreview','voiceQueuesChannels','VoiceQueuesChannels','voiceQueuesChannelHangup','VoiceQueuesChannelHangup','VoiceQueuesChannelRedirect','outbound','Outbound','outboundChannels','agents','Agents','agentCapacity','interaction','user','hasOwnProperty','MemberReport','INTERACTION','length','format','YYYY-MM-DD\x20HH:mm:ss','findOrCreate','interface','internal','AgentCapacity','capacity','telephones','Trunks','Campaigns','chatQueues','ChatQueues','showChatQueues','MailQueues','showMailQueues','mailAccounts','MailAccounts','openchannelQueues','OpenchannelQueues','showOpenchannelQueues','smsQueues','SmsQueues','whatsappQueues','showWhatsappQueues','WhatsappQueues','faxQueues','FaxQueues','showFaxQueues','faxAccounts','chatQueuesWaitingInteractions','ChatQueuesWaitingInteractions','mailQueuesWaitingInteractions','MailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','OpenchannelQueuesWaitingInteractions','type','filter','map','queue_id','uniq','value','smsQueuesWaitingInteractions','SmsQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','WhatsappQueuesWaitingInteractions','FaxQueuesWaitingInteractions','queueNotify','capitalize','Account','Queue','findOne','\x20Queue\x20not\x20found','messageId','Interaction','\x20Message\x20not\x20found'];(function(_0x2d9443,_0x558bca){var _0x5cbf52=function(_0xa246f9){while(--_0xa246f9){_0x2d9443['push'](_0x2d9443['shift']());}};_0x5cbf52(++_0x558bca);}(_0xe14b,0x93));var _0xbe14=function(_0x3006cb,_0x570eda){_0x3006cb=_0x3006cb-0x0;var _0x3eb32f=_0xe14b[_0x3006cb];return _0x3eb32f;};'use strict';var BPromise=require(_0xbe14('0x0'));var moment=require(_0xbe14('0x1'));var _=require('lodash');var util=require('util');var db=require(_0xbe14('0x2'))['db'];var logger=require(_0xbe14('0x3'))('api');var jayson=require(_0xbe14('0x4'));var amiClient=jayson['client']['http']({'port':0x232a});var mailClient=jayson[_0xbe14('0x5')][_0xbe14('0x6')]({'port':0x232b});var routingClient=jayson[_0xbe14('0x5')][_0xbe14('0x6')]({'port':0x232c});function respondWithRpcPromise(_0x1d9ade,_0x39387e,_0x196fca){return new BPromise(function(_0x566ae7,_0x50f909){var _0x496063=_0x196fca?_0x196fca:amiClient;return _0x496063[_0xbe14('0x7')](_0x1d9ade,_0x39387e)[_0xbe14('0x8')](function(_0xd68cd7){if(_0xd68cd7[_0xbe14('0x9')]){if(_0xd68cd7['error']['code']===0x1f4){return _0x50f909(_0xd68cd7[_0xbe14('0x9')][_0xbe14('0xa')]);}return _0x566ae7(_0xd68cd7['error'][_0xbe14('0xa')]);}else{_0x566ae7(_0xd68cd7[_0xbe14('0xb')]);}})[_0xbe14('0xc')](function(_0x3d38c2){_0x50f909(_0x3d38c2);});});}function respondWithResult(_0x27792f,_0x3b898d){_0x3b898d=_0x3b898d||0xc8;return function(_0x23a730){if(_0x23a730){return _0x27792f[_0xbe14('0xd')](_0x3b898d)[_0xbe14('0xe')](_0x23a730);}return _0x27792f[_0xbe14('0xf')](0x194);};}function handleError(_0x1e4826,_0x33fd54){_0x33fd54=_0x33fd54||0x1f4;return function(_0x813399){logger['error'](_0x813399['stack']);if(_0x813399[_0xbe14('0x10')]){delete _0x813399[_0xbe14('0x10')];}_0x1e4826[_0xbe14('0xd')](_0x33fd54)[_0xbe14('0x11')](_0x813399);};}function findById(_0x4e8f34){return function(_0x21c789){if(!_[_0xbe14('0x12')](_0x4e8f34)&&!_[_0xbe14('0x12')](_0x21c789)&&!_[_0xbe14('0x12')](_0x21c789[_0xbe14('0x13')])){return _[_0xbe14('0x14')](_0x21c789[_0xbe14('0x13')],function(_0x5ea1f8){return _0x5ea1f8['id']==_0x4e8f34;});}return null;};}exports[_0xbe14('0x15')]=function(_0x456ca8,_0x329588){return respondWithRpcPromise(_0xbe14('0x16'),_0x456ca8[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x329588,null))['catch'](handleError(_0x329588,null));};exports[_0xbe14('0x18')]=function(_0x4a1bbd,_0x417c8d){return respondWithRpcPromise(_0xbe14('0x19'),_[_0xbe14('0x1a')](_0x4a1bbd['query'],_0x4a1bbd[_0xbe14('0x1b')]))['then'](respondWithResult(_0x417c8d,null))[_0xbe14('0xc')](handleError(_0x417c8d,null));};exports['voiceChannelStopMixMonitor']=function(_0x32e8eb,_0x4a25fa){return respondWithRpcPromise(_0xbe14('0x1c'),_[_0xbe14('0x1a')](_0x32e8eb['query'],_0x32e8eb[_0xbe14('0x1b')]))['then'](respondWithResult(_0x4a25fa,null))[_0xbe14('0xc')](handleError(_0x4a25fa,null));};exports['voiceQueues']=function(_0x36a21e,_0x5fa043){return respondWithRpcPromise(_0xbe14('0x1d'),_0x36a21e[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x5fa043,null))[_0xbe14('0xc')](handleError(_0x5fa043,null));};exports['showVoiceQueues']=function(_0x1822e0,_0x1ba46a){return respondWithRpcPromise(_0xbe14('0x1d'),_0x1822e0[_0xbe14('0x17')])['then'](findById(_0x1822e0[_0xbe14('0x1b')]['id']))[_0xbe14('0x8')](respondWithResult(_0x1ba46a,null))['catch'](handleError(_0x1ba46a,null));};exports[_0xbe14('0x1e')]=function(_0x3b3e84,_0x1c7cc7){return respondWithRpcPromise(_0xbe14('0x1f'),_[_0xbe14('0x1a')](_0x3b3e84[_0xbe14('0x20')],_0x3b3e84[_0xbe14('0x1b')]))[_0xbe14('0x8')](respondWithResult(_0x1c7cc7,null))[_0xbe14('0xc')](handleError(_0x1c7cc7,null));};exports[_0xbe14('0x21')]=function(_0x40538f,_0x3bf43c){return respondWithRpcPromise(_0xbe14('0x22'),_[_0xbe14('0x1a')](_0x40538f[_0xbe14('0x17')],_0x40538f[_0xbe14('0x1b')]))[_0xbe14('0x8')](respondWithResult(_0x3bf43c,null))[_0xbe14('0xc')](handleError(_0x3bf43c,null));};exports[_0xbe14('0x23')]=function(_0x14e7c4,_0x581e86){return respondWithRpcPromise(_0xbe14('0x24'),_0x14e7c4['query'])['then'](respondWithResult(_0x581e86,null))[_0xbe14('0xc')](handleError(_0x581e86,null));};exports['voiceQueuesChannel']=function(_0x243524,_0x345b0){return respondWithRpcPromise('VoiceQueuesChannel',_['merge'](_0x243524['query'],_0x243524[_0xbe14('0x1b')]))[_0xbe14('0x8')](respondWithResult(_0x345b0,null))['catch'](handleError(_0x345b0,null));};exports[_0xbe14('0x25')]=function(_0x1faf3e,_0x452635){return respondWithRpcPromise(_0xbe14('0x26'),_[_0xbe14('0x1a')](_0x1faf3e['query'],_0x1faf3e['params']))[_0xbe14('0x8')](respondWithResult(_0x452635,null))['catch'](handleError(_0x452635,null));};exports['voiceQueuesChannelRedirect']=function(_0x5c5e9f,_0x163ef7){return respondWithRpcPromise(_0xbe14('0x27'),_[_0xbe14('0x1a')](_0x5c5e9f[_0xbe14('0x17')],_0x5c5e9f[_0xbe14('0x1b')]))[_0xbe14('0x8')](respondWithResult(_0x163ef7,null))[_0xbe14('0xc')](handleError(_0x163ef7,null));};exports[_0xbe14('0x28')]=function(_0x2d9c12,_0x2dfd5a){return respondWithRpcPromise(_0xbe14('0x29'),_0x2d9c12[_0xbe14('0x17')])['then'](respondWithResult(_0x2dfd5a,null))['catch'](handleError(_0x2dfd5a,null));};exports[_0xbe14('0x2a')]=function(_0x2951e1,_0x13bfcf){return respondWithRpcPromise('OutboundChannels',_0x2951e1[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x13bfcf,null))[_0xbe14('0xc')](handleError(_0x13bfcf,null));};exports[_0xbe14('0x2b')]=function(_0x3bd454,_0x25ee1f){var _0x19fa30;return respondWithRpcPromise(_0xbe14('0x2c'),_0x3bd454[_0xbe14('0x17')])['then'](function(_0xe51424){_0x19fa30=_0xe51424;return respondWithRpcPromise(_0xbe14('0x2c'),_0x3bd454[_0xbe14('0x17')],routingClient);})[_0xbe14('0x8')](function(_0x3287b9){return _[_0xbe14('0x1a')]({},_0x3287b9,_0x19fa30);})['then'](respondWithResult(_0x25ee1f,null))[_0xbe14('0xc')](handleError(_0x25ee1f,null));};exports[_0xbe14('0x2d')]=function(_0x1220c9,_0x36263c){if(_0x1220c9['body']&&_0x1220c9['body'][_0xbe14('0x2e')]&&_0x1220c9[_0xbe14('0x2f')]&&_0x1220c9[_0xbe14('0x2f')]['name']){for(var _0x5d5318 in _0x1220c9[_0xbe14('0x20')]['interaction']){if(_0x1220c9['body'][_0xbe14('0x2e')][_0xbe14('0x30')](_0x5d5318)){db[_0xbe14('0x31')]['findAll']({'where':{'channel':_0x5d5318,'membername':_0x1220c9['user']['name'],'type':_0xbe14('0x32'),'exitAt':null,'uniqueid':_0x1220c9[_0xbe14('0x20')][_0xbe14('0x2e')][_0x5d5318]&&_0x1220c9['body'][_0xbe14('0x2e')][_0x5d5318][_0xbe14('0x33')]?{'$notIn':_0x1220c9[_0xbe14('0x20')][_0xbe14('0x2e')][_0x5d5318]}:{'$ne':null}}})['then'](function(_0x4a1a4b){var _0x3e2fd3=moment()[_0xbe14('0x34')](_0xbe14('0x35'));for(var _0xb2b285=0x0,_0x2550dc=_0x4a1a4b['length'];_0xb2b285<_0x2550dc;_0xb2b285+=0x1){_0x4a1a4b[_0xb2b285]['updateAttributes']({'exitAt':_0x3e2fd3});}});for(var _0x46af81=0x0;_0x46af81<_0x1220c9[_0xbe14('0x20')][_0xbe14('0x2e')][_0x5d5318][_0xbe14('0x33')];_0x46af81+=0x1){db['MemberReport'][_0xbe14('0x36')]({'where':{'channel':_0x5d5318,'membername':_0x1220c9[_0xbe14('0x2f')]['name'],'type':_0xbe14('0x32'),'uniqueid':_0x1220c9[_0xbe14('0x20')][_0xbe14('0x2e')][_0x5d5318][_0x46af81],'exitAt':null},'defaults':{'channel':_0x5d5318,'membername':_0x1220c9[_0xbe14('0x2f')]['name'],'interface':_['isNil'](_0x1220c9[_0xbe14('0x2f')][_0xbe14('0x37')])?util['format']('SIP/%s',_0x1220c9[_0xbe14('0x2f')][_0xbe14('0x10')]):_0x1220c9[_0xbe14('0x2f')][_0xbe14('0x37')],'type':_0xbe14('0x32'),'enterAt':moment()[_0xbe14('0x34')](_0xbe14('0x35')),'role':'agent','internal':_0x1220c9[_0xbe14('0x2f')][_0xbe14('0x38')],'uniqueid':_0x1220c9[_0xbe14('0x20')][_0xbe14('0x2e')][_0x5d5318][_0x46af81]}});}}}}return respondWithRpcPromise(_0xbe14('0x39'),{'id':_0x1220c9['params']['id'],'capacity':_0x1220c9[_0xbe14('0x20')][_0xbe14('0x3a')]},routingClient)[_0xbe14('0x8')](respondWithResult(_0x36263c,null))[_0xbe14('0xc')](handleError(_0x36263c,null));};exports[_0xbe14('0x3b')]=function(_0x2dbeb1,_0x505829){return respondWithRpcPromise('Telephones',_0x2dbeb1[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x505829,null))[_0xbe14('0xc')](handleError(_0x505829,null));};exports['trunks']=function(_0x497b00,_0x44fe0d){return respondWithRpcPromise(_0xbe14('0x3c'),_0x497b00['query'])[_0xbe14('0x8')](respondWithResult(_0x44fe0d,null))[_0xbe14('0xc')](handleError(_0x44fe0d,null));};exports['campaigns']=function(_0x28f995,_0x4a40d2){return respondWithRpcPromise(_0xbe14('0x3d'),_0x28f995[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x4a40d2,null))['catch'](handleError(_0x4a40d2,null));};exports[_0xbe14('0x3e')]=function(_0x404212,_0x5dc78a){return respondWithRpcPromise(_0xbe14('0x3f'),_0x404212[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x5dc78a,null))[_0xbe14('0xc')](handleError(_0x5dc78a,null));};exports[_0xbe14('0x40')]=function(_0x4f06a3,_0x42a346){return respondWithRpcPromise(_0xbe14('0x3f'),_0x4f06a3[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](findById(_0x4f06a3[_0xbe14('0x1b')]['id']))[_0xbe14('0x8')](respondWithResult(_0x42a346,null))[_0xbe14('0xc')](handleError(_0x42a346,null));};exports['mailQueues']=function(_0x72c875,_0x1b47a4){return respondWithRpcPromise(_0xbe14('0x41'),_0x72c875[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x1b47a4,null))[_0xbe14('0xc')](handleError(_0x1b47a4,null));};exports[_0xbe14('0x42')]=function(_0x32df3c,_0x285b6e){return respondWithRpcPromise(_0xbe14('0x41'),_0x32df3c[_0xbe14('0x17')],routingClient)['then'](findById(_0x32df3c['params']['id']))['then'](respondWithResult(_0x285b6e,null))[_0xbe14('0xc')](handleError(_0x285b6e,null));};exports[_0xbe14('0x43')]=function(_0x2f4e52,_0xf79b21){return respondWithRpcPromise(_0xbe14('0x44'),_0x2f4e52[_0xbe14('0x17')],mailClient)[_0xbe14('0x8')](respondWithResult(_0xf79b21,null))[_0xbe14('0xc')](handleError(_0xf79b21,null));};exports[_0xbe14('0x45')]=function(_0x451b0b,_0x603816){return respondWithRpcPromise(_0xbe14('0x46'),_0x451b0b[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x603816,null))[_0xbe14('0xc')](handleError(_0x603816,null));};exports[_0xbe14('0x47')]=function(_0x179077,_0x2225d9){return respondWithRpcPromise(_0xbe14('0x46'),_0x179077[_0xbe14('0x17')],routingClient)['then'](findById(_0x179077[_0xbe14('0x1b')]['id']))[_0xbe14('0x8')](respondWithResult(_0x2225d9,null))[_0xbe14('0xc')](handleError(_0x2225d9,null));};exports[_0xbe14('0x48')]=function(_0x3ee6b7,_0x222944){return respondWithRpcPromise(_0xbe14('0x49'),_0x3ee6b7[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x222944,null))[_0xbe14('0xc')](handleError(_0x222944,null));};exports['showSmsQueues']=function(_0x18be56,_0x442ec4){return respondWithRpcPromise(_0xbe14('0x49'),_0x18be56[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](findById(_0x18be56['params']['id']))[_0xbe14('0x8')](respondWithResult(_0x442ec4,null))[_0xbe14('0xc')](handleError(_0x442ec4,null));};exports[_0xbe14('0x4a')]=function(_0xd4e1c7,_0x46ac9c){return respondWithRpcPromise('WhatsappQueues',_0xd4e1c7[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x46ac9c,null))[_0xbe14('0xc')](handleError(_0x46ac9c,null));};exports[_0xbe14('0x4b')]=function(_0xaebce8,_0x289c4d){return respondWithRpcPromise(_0xbe14('0x4c'),_0xaebce8[_0xbe14('0x17')],routingClient)['then'](findById(_0xaebce8[_0xbe14('0x1b')]['id']))[_0xbe14('0x8')](respondWithResult(_0x289c4d,null))[_0xbe14('0xc')](handleError(_0x289c4d,null));};exports[_0xbe14('0x4d')]=function(_0x5982b7,_0xa4b2a3){return respondWithRpcPromise(_0xbe14('0x4e'),_0x5982b7['query'],routingClient)['then'](respondWithResult(_0xa4b2a3,null))[_0xbe14('0xc')](handleError(_0xa4b2a3,null));};exports[_0xbe14('0x4f')]=function(_0x2d2643,_0x2510a0){return respondWithRpcPromise(_0xbe14('0x4e'),_0x2d2643[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](findById(_0x2d2643[_0xbe14('0x1b')]['id']))['then'](respondWithResult(_0x2510a0,null))['catch'](handleError(_0x2510a0,null));};exports[_0xbe14('0x50')]=function(_0x1c18b6,_0x29aa52){return respondWithRpcPromise('FaxAccounts',_0x1c18b6[_0xbe14('0x17')])[_0xbe14('0x8')](respondWithResult(_0x29aa52,null))[_0xbe14('0xc')](handleError(_0x29aa52,null));};exports[_0xbe14('0x51')]=function(_0x468e9f,_0x1ef09b){return respondWithRpcPromise(_0xbe14('0x52'),_0x468e9f['query'],routingClient)[_0xbe14('0x8')](respondWithResult(_0x1ef09b,null))[_0xbe14('0xc')](handleError(_0x1ef09b,null));};exports[_0xbe14('0x53')]=function(_0x3afc5a,_0x469555){return respondWithRpcPromise(_0xbe14('0x54'),_0x3afc5a[_0xbe14('0x17')],routingClient)['then'](respondWithResult(_0x469555,null))[_0xbe14('0xc')](handleError(_0x469555,null));};exports[_0xbe14('0x55')]=function(_0x3cd17e,_0x1c0932){return respondWithRpcPromise(_0xbe14('0x56'),_0x3cd17e[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x1c0932,null))[_0xbe14('0xc')](handleError(_0x1c0932,null));};exports['openchannelQueuesIdWaitingInteractions']=function(_0x1e5ce1,_0x401968){return respondWithRpcPromise(_0xbe14('0x56'),_0x1e5ce1[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](function(_0x17576b){if(_0x1e5ce1['query'][_0xbe14('0x57')]!==undefined){var _0x175213=_(_0x17576b[_0xbe14('0x13')])[_0xbe14('0x58')]([_0x1e5ce1['query'][_0xbe14('0x57')],_0x1e5ce1[_0xbe14('0x1b')]['id']])[_0xbe14('0x59')](_0xbe14('0x5a'))[_0xbe14('0x5b')]()[_0xbe14('0x5c')]();return _0x17576b[_0xbe14('0x13')]['filter'](function(_0x70ed08){return _0x175213['indexOf'](_0x70ed08[_0xbe14('0x5a')])>-0x1;});}else{return _0x17576b['rows'][_0xbe14('0x58')](function(_0x21837c){return _0x21837c[_0xbe14('0x5a')]===parseInt(_0x1e5ce1['params']['id']);});}})[_0xbe14('0x8')](respondWithResult(_0x401968,null))[_0xbe14('0xc')](handleError(_0x401968,null));};exports[_0xbe14('0x5d')]=function(_0x546f22,_0x41a896){return respondWithRpcPromise(_0xbe14('0x5e'),_0x546f22[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x41a896,null))['catch'](handleError(_0x41a896,null));};exports[_0xbe14('0x5f')]=function(_0x39bc54,_0x34f90b){return respondWithRpcPromise(_0xbe14('0x60'),_0x39bc54[_0xbe14('0x17')],routingClient)[_0xbe14('0x8')](respondWithResult(_0x34f90b,null))[_0xbe14('0xc')](handleError(_0x34f90b,null));};exports['faxQueuesWaitingInteractions']=function(_0x2ff94c,_0x123f4f){return respondWithRpcPromise(_0xbe14('0x61'),_0x2ff94c['query'],routingClient)[_0xbe14('0x8')](respondWithResult(_0x123f4f,null))[_0xbe14('0xc')](handleError(_0x123f4f,null));};exports[_0xbe14('0x62')]=function(_0x5bc52b){return function(_0xa53262,_0x1205d1){var _0x47d7bb,_0x2be969;var _0x49990b=_[_0xbe14('0x63')](_0x5bc52b);var _0x337073=_0x5bc52b==='chat'?'Website':_0xbe14('0x64');return db[_0x49990b+_0xbe14('0x65')][_0xbe14('0x66')]({'raw':!![],'where':{'id':_0xa53262['params']['id']}})[_0xbe14('0x8')](function(_0x30c03b){if(_[_0xbe14('0x12')](_0x30c03b)){throw new Error(_0x49990b+_0xbe14('0x67'));}_0x47d7bb=_0x30c03b;return db[_0x49990b+'Message']['findOne']({'where':{'id':_0xa53262[_0xbe14('0x20')][_0xbe14('0x68')]},'include':[{'model':db[_0x49990b+_0xbe14('0x69')],'as':_0xbe14('0x69')},{'model':db[_0x49990b+_0x337073],'as':_0xbe14('0x64')}]});})[_0xbe14('0x8')](function(_0x139aab){if(_['isNil'](_0x139aab)){throw new Error(_0x49990b+_0xbe14('0x6a'));}_0x2be969=_0x139aab;return _0x139aab['update']({'read':0x0,'readAt':null,'UserId':null});})[_0xbe14('0x8')](function(){var _0x3a01bb={'uniqueid':_0x5bc52b+'.'+_0x2be969['id']+'.'+_0x2be969[_0xbe14('0x69')]['id'],'FromUserId':_0xa53262[_0xbe14('0x2f')]['id'],'type':'queue'};_0x3a01bb[_0x49990b+_0xbe14('0x6b')]=_0x2be969['id'];_0x3a01bb[_0x49990b+_0xbe14('0x6c')]=_0x2be969[_0xbe14('0x69')]['id'];_0x3a01bb['From'+_0x49990b+_0x337073+'Id']=_0x2be969[_0xbe14('0x64')]['id'];_0x3a01bb['To'+_0x49990b+_0xbe14('0x6d')]=_0x47d7bb['id'];return db[_0x49990b+_0xbe14('0x6e')][_0xbe14('0x6f')](_0x3a01bb);})[_0xbe14('0x8')](function(){return respondWithRpcPromise(_0xbe14('0x70'),{'channel':_0x5bc52b,'interaction':_0x2be969[_0xbe14('0x69')],'message':_0x2be969,'account':_0x2be969[_0xbe14('0x64')],'applications':[{'id':0x0,'priority':0x1,'app':_0xbe14('0x71'),'appdata':_0x47d7bb[_0xbe14('0x10')]+','+(_0x2be969[_0xbe14('0x64')][_0xbe14('0x72')]||0x12c),'interval':_0xbe14('0x73')}]},routingClient);})[_0xbe14('0x8')](respondWithResult(_0x1205d1,null))[_0xbe14('0xc')](handleError(_0x1205d1,null));};};exports[_0xbe14('0x74')]=function(_0x1de70d,_0x30be9e){var _0x1679bd,_0x2ca6e6;if(_['isNil'](_0x1de70d[_0xbe14('0x20')]['channel'])){throw new Error(_0xbe14('0x75'));}var _0x1b8733=_0x1de70d[_0xbe14('0x20')][_0xbe14('0x76')];var _0x1d7b08=_['capitalize'](_0x1b8733);var _0x5868d7=_0x1b8733===_0xbe14('0x77')?_0xbe14('0x78'):_0xbe14('0x64');return db[_0xbe14('0x79')]['findOne']({'raw':!![],'where':{'id':_0x1de70d[_0xbe14('0x1b')]['id'],'role':_0xbe14('0x7a')}})['then'](function(_0x186225){if(_[_0xbe14('0x12')](_0x186225)){throw new Error(_0xbe14('0x7b'));}_0x1679bd=_0x186225;return db[_0x1d7b08+_0xbe14('0x7c')]['findOne']({'where':{'id':_0x1de70d[_0xbe14('0x20')]['messageId']},'include':[{'model':db[_0x1d7b08+'Interaction'],'as':_0xbe14('0x69')},{'model':db[_0x1d7b08+_0x5868d7],'as':_0xbe14('0x64')}]});})[_0xbe14('0x8')](function(_0x3d890b){if(_[_0xbe14('0x12')](_0x3d890b)){throw new Error(_0x1d7b08+'\x20Message\x20not\x20found');}_0x2ca6e6=_0x3d890b;return _0x3d890b[_0xbe14('0x7d')]({'read':0x0,'readAt':null,'UserId':null});})[_0xbe14('0x8')](function(){var _0x5dc793={'uniqueid':_0x1b8733+'.'+_0x2ca6e6['id']+'.'+_0x2ca6e6['Interaction']['id'],'FromUserId':_0x1de70d[_0xbe14('0x2f')]['id'],'type':_0xbe14('0x71'),'ToUserId':_0x1679bd['id']};_0x5dc793[_0x1d7b08+'MessageId']=_0x2ca6e6['id'];_0x5dc793[_0x1d7b08+_0xbe14('0x6c')]=_0x2ca6e6['Interaction']['id'];_0x5dc793[_0xbe14('0x7e')+_0x1d7b08+_0x5868d7+'Id']=_0x2ca6e6['Account']['id'];return db[_0x1d7b08+_0xbe14('0x6e')]['create'](_0x5dc793);})[_0xbe14('0x8')](function(){return respondWithRpcPromise('Start',{'channel':_0x1b8733,'interaction':_0x2ca6e6[_0xbe14('0x69')],'message':_0x2ca6e6,'account':_0x2ca6e6[_0xbe14('0x64')],'applications':[{'id':0x0,'priority':0x1,'app':'agent','appdata':_0x1679bd['name']+','+(_0x2ca6e6[_0xbe14('0x64')]['agentTransferTimeout']||0x12c),'interval':'*,*,*,*'}]},routingClient);})[_0xbe14('0x8')](respondWithResult(_0x30be9e,null))[_0xbe14('0xc')](handleError(_0x30be9e,null));}; \ No newline at end of file diff --git a/server/api/schedule/index.js b/server/api/schedule/index.js new file mode 100644 index 0000000..3ccde6b --- /dev/null +++ b/server/api/schedule/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4b3e=['express','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./schedule.controller','get','isAuthenticated','index','show','/:id/run','post','create','put','/:id','delete','destroy','exports','multer','util','connect-timeout'];(function(_0x4d1b69,_0x26283b){var _0x594ccd=function(_0xdc39d5){while(--_0xdc39d5){_0x4d1b69['push'](_0x4d1b69['shift']());}};_0x594ccd(++_0x26283b);}(_0x4b3e,0x1a1));var _0xe4b3=function(_0xbd08b4,_0x4790ed){_0xbd08b4=_0xbd08b4-0x0;var _0x314f1e=_0x4b3e[_0xbd08b4];return _0x314f1e;};'use strict';var multer=require(_0xe4b3('0x0'));var util=require(_0xe4b3('0x1'));var path=require('path');var timeout=require(_0xe4b3('0x2'));var express=require(_0xe4b3('0x3'));var router=express[_0xe4b3('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0xe4b3('0x5'));var interaction=require(_0xe4b3('0x6'));var config=require(_0xe4b3('0x7'));var controller=require(_0xe4b3('0x8'));router[_0xe4b3('0x9')]('/',auth[_0xe4b3('0xa')](),controller[_0xe4b3('0xb')]);router[_0xe4b3('0x9')]('/:id',auth[_0xe4b3('0xa')](),controller[_0xe4b3('0xc')]);router[_0xe4b3('0x9')](_0xe4b3('0xd'),auth[_0xe4b3('0xa')](),controller['run']);router[_0xe4b3('0xe')]('/',auth['isAuthenticated'](),controller[_0xe4b3('0xf')]);router[_0xe4b3('0x10')](_0xe4b3('0x11'),auth[_0xe4b3('0xa')](),controller['update']);router[_0xe4b3('0x12')](_0xe4b3('0x11'),auth[_0xe4b3('0xa')](),controller[_0xe4b3('0x13')]);module[_0xe4b3('0x14')]=router; \ No newline at end of file diff --git a/server/api/schedule/schedule.attributes.js b/server/api/schedule/schedule.attributes.js new file mode 100644 index 0000000..a8fc7cd --- /dev/null +++ b/server/api/schedule/schedule.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5bd0=['days','minutes','csv','pdf','xlsx','custom','default','BOOLEAN','TEXT','sequelize','exports','STRING','DATE','INTEGER','ENUM','months','weeks'];(function(_0x441847,_0x21da34){var _0x5b109c=function(_0x1ec126){while(--_0x1ec126){_0x441847['push'](_0x441847['shift']());}};_0x5b109c(++_0x21da34);}(_0x5bd0,0xc4));var _0x05bd=function(_0x1a27f3,_0x1c082d){_0x1a27f3=_0x1a27f3-0x0;var _0x3ce222=_0x5bd0[_0x1a27f3];return _0x3ce222;};'use strict';var Sequelize=require(_0x05bd('0x0'));module[_0x05bd('0x1')]={'name':{'type':Sequelize[_0x05bd('0x2')],'allowNull':![]},'description':{'type':Sequelize[_0x05bd('0x2')]},'active':{'type':Sequelize['BOOLEAN'],'allowNull':![],'defaultValue':![]},'cron':{'type':Sequelize[_0x05bd('0x2')],'allowNull':![],'defaultValue':'0\x200\x20*\x20*\x20*'},'startAt':{'type':Sequelize[_0x05bd('0x3')],'allowNull':![]},'endAt':{'type':Sequelize['DATE'],'allowNull':![]},'subtractNumber':{'type':Sequelize[_0x05bd('0x4')],'allowNull':![],'defaultValue':0x1,'validate':{'min':0x1}},'subtractUnit':{'type':Sequelize[_0x05bd('0x5')]('years','quarters',_0x05bd('0x6'),_0x05bd('0x7'),_0x05bd('0x8'),'hours',_0x05bd('0x9')),'allowNull':![],'defaultValue':_0x05bd('0x8')},'output':{'type':Sequelize[_0x05bd('0x5')](_0x05bd('0xa'),_0x05bd('0xb'),_0x05bd('0xc')),'allowNull':![],'defaultValue':_0x05bd('0xa')},'type':{'type':Sequelize[_0x05bd('0x5')](_0x05bd('0xd'),_0x05bd('0xe')),'allowNull':![],'defaultValue':'custom'},'sendMail':{'type':Sequelize[_0x05bd('0xf')],'defaultValue':![]},'email':{'type':Sequelize['STRING']},'cc':{'type':Sequelize[_0x05bd('0x10')]},'bcc':{'type':Sequelize[_0x05bd('0x10')]},'sendIfEmpty':{'type':Sequelize[_0x05bd('0xf')],'defaultValue':!![]}}; \ No newline at end of file diff --git a/server/api/schedule/schedule.controller.js b/server/api/schedule/schedule.controller.js new file mode 100644 index 0000000..e694aa8 --- /dev/null +++ b/server/api/schedule/schedule.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2cc3=['intersection','model','attributes','fields','length','nolimit','sort','where','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','rawAttributes','include','find','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','run','../../config/schedule','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','Scheduler','UserProfileResource','destroy','end','error','stack','name','index','map','Schedule','fieldName','type','key','query','keys','filters'];(function(_0x559e13,_0x4b5c3f){var _0x1c5183=function(_0x12e8d7){while(--_0x12e8d7){_0x559e13['push'](_0x559e13['shift']());}};_0x1c5183(++_0x4b5c3f);}(_0x2cc3,0x180));var _0x32cc=function(_0x5e3632,_0x4a531d){_0x5e3632=_0x5e3632-0x0;var _0x5082f3=_0x2cc3[_0x5e3632];return _0x5082f3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x32cc('0x0'));var zipdir=require(_0x32cc('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x32cc('0x2'));var moment=require(_0x32cc('0x3'));var BPromise=require(_0x32cc('0x4'));var Mustache=require(_0x32cc('0x5'));var util=require('util');var path=require(_0x32cc('0x6'));var sox=require(_0x32cc('0x7'));var csv=require(_0x32cc('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x32cc('0x9'));var _=require(_0x32cc('0xa'));var squel=require(_0x32cc('0xb'));var crypto=require('crypto');var jsforce=require(_0x32cc('0xc'));var deskjs=require(_0x32cc('0xd'));var toCsv=require(_0x32cc('0x8'));var querystring=require(_0x32cc('0xe'));var Papa=require(_0x32cc('0xf'));var Redis=require(_0x32cc('0x10'));var authService=require(_0x32cc('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x32cc('0x12'));var hardwareService=require(_0x32cc('0x13'));var logger=require(_0x32cc('0x14'))(_0x32cc('0x15'));var utils=require(_0x32cc('0x16'));var config=require(_0x32cc('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x32cc('0x18'))['db'];function respondWithStatusCode(_0x186022,_0x55b1ac){_0x55b1ac=_0x55b1ac||0xcc;return function(_0x288cb2){if(_0x288cb2){return _0x186022[_0x32cc('0x19')](_0x55b1ac);}return _0x186022[_0x32cc('0x1a')](_0x55b1ac)['end']();};}function respondWithResult(_0x122c51,_0xba87e1){_0xba87e1=_0xba87e1||0xc8;return function(_0x33c094){if(_0x33c094){return _0x122c51['status'](_0xba87e1)[_0x32cc('0x1b')](_0x33c094);}};}function respondWithFilteredResult(_0x2a6348,_0x470f65){return function(_0x4e00e2){if(_0x4e00e2){var _0xf5ef74=typeof _0x470f65[_0x32cc('0x1c')]===_0x32cc('0x1d')&&typeof _0x470f65[_0x32cc('0x1e')]===_0x32cc('0x1d');var _0x1b07de=_0x4e00e2[_0x32cc('0x1f')];var _0x3cf07a=_0xf5ef74?0x0:_0x470f65[_0x32cc('0x1c')];var _0x52382b=_0xf5ef74?_0x4e00e2[_0x32cc('0x1f')]:_0x470f65[_0x32cc('0x1c')]+_0x470f65['limit'];var _0x341a85;if(_0x52382b>=_0x1b07de){_0x52382b=_0x1b07de;_0x341a85=0xc8;}else{_0x341a85=0xce;}_0x2a6348[_0x32cc('0x1a')](_0x341a85);return _0x2a6348[_0x32cc('0x20')](_0x32cc('0x21'),_0x3cf07a+'-'+_0x52382b+'/'+_0x1b07de)['json'](_0x4e00e2);}return null;};}function patchUpdates(_0x5e83ba){return function(_0x4da987){try{jsonpatch[_0x32cc('0x22')](_0x4da987,_0x5e83ba,!![]);}catch(_0x28e755){return BPromise[_0x32cc('0x23')](_0x28e755);}return _0x4da987[_0x32cc('0x24')]();};}function saveUpdates(_0x525d86,_0x538f4f){return function(_0xae743f){if(_0xae743f){return _0xae743f[_0x32cc('0x25')](_0x525d86)[_0x32cc('0x26')](function(_0x19ecd1){return _0x19ecd1;});}return null;};}function removeEntity(_0x37ca62,_0x3e3668){return function(_0x40d9bb){if(_0x40d9bb){return _0x40d9bb['destroy']()[_0x32cc('0x26')](function(){var _0x11ede9=_0x40d9bb[_0x32cc('0x27')]({'plain':!![]});var _0x833963=_0x32cc('0x28');return db[_0x32cc('0x29')][_0x32cc('0x2a')]({'where':{'type':_0x833963,'resourceId':_0x11ede9['id']}})[_0x32cc('0x26')](function(){return _0x40d9bb;});})[_0x32cc('0x26')](function(){_0x37ca62[_0x32cc('0x1a')](0xcc)[_0x32cc('0x2b')]();});}};}function handleEntityNotFound(_0x41c6d8,_0xd4743e){return function(_0x35dd1f){if(!_0x35dd1f){_0x41c6d8[_0x32cc('0x19')](0x194);}return _0x35dd1f;};}function handleError(_0x21b655,_0x3aced1){_0x3aced1=_0x3aced1||0x1f4;return function(_0xca3ba){logger[_0x32cc('0x2c')](_0xca3ba[_0x32cc('0x2d')]);if(_0xca3ba[_0x32cc('0x2e')]){delete _0xca3ba[_0x32cc('0x2e')];}_0x21b655[_0x32cc('0x1a')](_0x3aced1)['send'](_0xca3ba);};}exports[_0x32cc('0x2f')]=function(_0x2596c2,_0x5a69e6){var _0x488ae1={},_0x5bbbf4={},_0x2efcb7={'count':0x0,'rows':[]};var _0x44e1d8=_[_0x32cc('0x30')](db[_0x32cc('0x31')]['rawAttributes'],function(_0x1b5585){return{'name':_0x1b5585[_0x32cc('0x32')],'type':_0x1b5585[_0x32cc('0x33')][_0x32cc('0x34')]};});_0x5bbbf4['model']=_[_0x32cc('0x30')](_0x44e1d8,_0x32cc('0x2e'));_0x5bbbf4[_0x32cc('0x35')]=_[_0x32cc('0x36')](_0x2596c2[_0x32cc('0x35')]);_0x5bbbf4[_0x32cc('0x37')]=_[_0x32cc('0x38')](_0x5bbbf4[_0x32cc('0x39')],_0x5bbbf4[_0x32cc('0x35')]);_0x488ae1[_0x32cc('0x3a')]=_['intersection'](_0x5bbbf4[_0x32cc('0x39')],qs['fields'](_0x2596c2[_0x32cc('0x35')][_0x32cc('0x3b')]));_0x488ae1['attributes']=_0x488ae1['attributes'][_0x32cc('0x3c')]?_0x488ae1[_0x32cc('0x3a')]:_0x5bbbf4[_0x32cc('0x39')];if(!_0x2596c2[_0x32cc('0x35')]['hasOwnProperty'](_0x32cc('0x3d'))){_0x488ae1[_0x32cc('0x1e')]=qs[_0x32cc('0x1e')](_0x2596c2[_0x32cc('0x35')]['limit']);_0x488ae1['offset']=qs[_0x32cc('0x1c')](_0x2596c2[_0x32cc('0x35')][_0x32cc('0x1c')]);}_0x488ae1['order']=qs[_0x32cc('0x3e')](_0x2596c2[_0x32cc('0x35')][_0x32cc('0x3e')]);_0x488ae1[_0x32cc('0x3f')]=qs[_0x32cc('0x37')](_['pick'](_0x2596c2['query'],_0x5bbbf4[_0x32cc('0x37')]),_0x44e1d8);if(_0x2596c2[_0x32cc('0x35')][_0x32cc('0x40')]){_0x488ae1[_0x32cc('0x3f')]=_[_0x32cc('0x41')](_0x488ae1[_0x32cc('0x3f')],{'$or':_[_0x32cc('0x30')](_0x44e1d8,function(_0x4ea0f2){if(_0x4ea0f2[_0x32cc('0x33')]!==_0x32cc('0x42')){var _0x397175={};_0x397175[_0x4ea0f2[_0x32cc('0x2e')]]={'$like':'%'+_0x2596c2[_0x32cc('0x35')][_0x32cc('0x40')]+'%'};return _0x397175;}})});}_0x488ae1=_[_0x32cc('0x41')]({},_0x488ae1,_0x2596c2[_0x32cc('0x43')]);var _0x4f8026={'where':_0x488ae1[_0x32cc('0x3f')]};return db[_0x32cc('0x31')][_0x32cc('0x1f')](_0x4f8026)['then'](function(_0x4c2a6c){_0x2efcb7[_0x32cc('0x1f')]=_0x4c2a6c;if(_0x2596c2[_0x32cc('0x35')][_0x32cc('0x44')]){_0x488ae1['include']=[{'all':!![]}];}return db[_0x32cc('0x31')][_0x32cc('0x45')](_0x488ae1);})[_0x32cc('0x26')](function(_0xaa2919){_0x2efcb7[_0x32cc('0x46')]=_0xaa2919;return _0x2efcb7;})[_0x32cc('0x26')](respondWithFilteredResult(_0x5a69e6,_0x488ae1))['catch'](handleError(_0x5a69e6,null));};exports[_0x32cc('0x47')]=function(_0x114008,_0x4916f4){var _0x2e2ab3={'raw':![],'where':{'id':_0x114008[_0x32cc('0x48')]['id']}},_0x3e741f={};_0x3e741f[_0x32cc('0x39')]=_[_0x32cc('0x36')](db[_0x32cc('0x31')][_0x32cc('0x49')]);_0x3e741f[_0x32cc('0x35')]=_[_0x32cc('0x36')](_0x114008[_0x32cc('0x35')]);_0x3e741f[_0x32cc('0x37')]=_[_0x32cc('0x38')](_0x3e741f[_0x32cc('0x39')],_0x3e741f[_0x32cc('0x35')]);_0x2e2ab3[_0x32cc('0x3a')]=_[_0x32cc('0x38')](_0x3e741f['model'],qs[_0x32cc('0x3b')](_0x114008[_0x32cc('0x35')][_0x32cc('0x3b')]));_0x2e2ab3[_0x32cc('0x3a')]=_0x2e2ab3[_0x32cc('0x3a')][_0x32cc('0x3c')]?_0x2e2ab3['attributes']:_0x3e741f[_0x32cc('0x39')];if(_0x114008[_0x32cc('0x35')][_0x32cc('0x44')]){_0x2e2ab3[_0x32cc('0x4a')]=[{'all':!![]}];}_0x2e2ab3=_[_0x32cc('0x41')]({},_0x2e2ab3,_0x114008[_0x32cc('0x43')]);return db['Schedule'][_0x32cc('0x4b')](_0x2e2ab3)[_0x32cc('0x26')](handleEntityNotFound(_0x4916f4,null))['then'](respondWithResult(_0x4916f4,null))[_0x32cc('0x4c')](handleError(_0x4916f4,null));};exports[_0x32cc('0x4d')]=function(_0x2b74a2,_0x365311){return db[_0x32cc('0x31')]['create'](_0x2b74a2['body'],{})[_0x32cc('0x26')](function(_0x188548){var _0x55e1d6=_0x2b74a2[_0x32cc('0x4e')][_0x32cc('0x27')]({'plain':!![]});if(!_0x55e1d6)throw new Error(_0x32cc('0x4f'));if(_0x55e1d6[_0x32cc('0x50')]===_0x32cc('0x4e')){var _0x90f9b0=_0x188548[_0x32cc('0x27')]({'plain':!![]});var _0x491812=_0x32cc('0x28');return db[_0x32cc('0x51')][_0x32cc('0x4b')]({'where':{'name':_0x491812,'userProfileId':_0x55e1d6[_0x32cc('0x52')]},'raw':!![]})['then'](function(_0x48b2f9){if(_0x48b2f9&&_0x48b2f9[_0x32cc('0x53')]===0x0){return db['UserProfileResource'][_0x32cc('0x4d')]({'name':_0x90f9b0['name'],'resourceId':_0x90f9b0['id'],'type':_0x48b2f9['name'],'sectionId':_0x48b2f9['id']},{})['then'](function(){return _0x188548;});}else{return _0x188548;}})[_0x32cc('0x4c')](function(_0x101e18){logger[_0x32cc('0x2c')](_0x32cc('0x54'),_0x101e18);throw _0x101e18;});}return _0x188548;})['then'](respondWithResult(_0x365311,0xc9))[_0x32cc('0x4c')](handleError(_0x365311,null));};exports[_0x32cc('0x25')]=function(_0x49cf56,_0x4f7fa8){if(_0x49cf56[_0x32cc('0x55')]['id']){delete _0x49cf56[_0x32cc('0x55')]['id'];}return db[_0x32cc('0x31')]['find']({'where':{'id':_0x49cf56['params']['id']}})[_0x32cc('0x26')](handleEntityNotFound(_0x4f7fa8,null))[_0x32cc('0x26')](saveUpdates(_0x49cf56[_0x32cc('0x55')],null))[_0x32cc('0x26')](respondWithResult(_0x4f7fa8,null))['catch'](handleError(_0x4f7fa8,null));};exports['destroy']=function(_0x3d8741,_0x342dee){return db['Schedule'][_0x32cc('0x4b')]({'where':{'id':_0x3d8741[_0x32cc('0x48')]['id']}})['then'](handleEntityNotFound(_0x342dee,null))[_0x32cc('0x26')](removeEntity(_0x342dee,null))[_0x32cc('0x4c')](handleError(_0x342dee,null));};exports[_0x32cc('0x56')]=function(_0x2ab8a8,_0x19a84c,_0x3f49dc){var _0x1ddab2=require(_0x32cc('0x57'));return db['Schedule'][_0x32cc('0x4b')]({'where':{'id':_0x2ab8a8[_0x32cc('0x48')]['id']},'raw':!![]})['then'](handleEntityNotFound(_0x19a84c,null))[_0x32cc('0x26')](function(){_0x1ddab2[_0x32cc('0x56')](_0x2ab8a8['params']['id']);})[_0x32cc('0x26')](respondWithStatusCode(_0x19a84c,null))[_0x32cc('0x4c')](handleError(_0x19a84c,null));}; \ No newline at end of file diff --git a/server/api/schedule/schedule.model.js b/server/api/schedule/schedule.model.js new file mode 100644 index 0000000..df4e043 --- /dev/null +++ b/server/api/schedule/schedule.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1462=['bluebird','path','rimraf','../../config/environment','./schedule.attributes','exports','Schedule','tools_schedules','lodash','api','moment'];(function(_0xd02bb,_0x26e2d0){var _0x1cdf23=function(_0x18fd05){while(--_0x18fd05){_0xd02bb['push'](_0xd02bb['shift']());}};_0x1cdf23(++_0x26e2d0);}(_0x1462,0x15d));var _0x2146=function(_0x3e4ee2,_0x3bf500){_0x3e4ee2=_0x3e4ee2-0x0;var _0x89b47=_0x1462[_0x3e4ee2];return _0x89b47;};'use strict';var _=require(_0x2146('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x2146('0x1'));var moment=require(_0x2146('0x2'));var BPromise=require(_0x2146('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x2146('0x4'));var rimraf=require(_0x2146('0x5'));var config=require(_0x2146('0x6'));var attributes=require(_0x2146('0x7'));module[_0x2146('0x8')]=function(_0x1d0cf2,_0x1f2c51){return _0x1d0cf2['define'](_0x2146('0x9'),attributes,{'tableName':_0x2146('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/schedule/schedule.rpc.js b/server/api/schedule/schedule.rpc.js new file mode 100644 index 0000000..22e757f --- /dev/null +++ b/server/api/schedule/schedule.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e51=['request\x20sent','Schedule,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','info','Schedule,\x20%s,\x20%s'];(function(_0x4db816,_0x530857){var _0x760883=function(_0x19c25b){while(--_0x19c25b){_0x4db816['push'](_0x4db816['shift']());}};_0x760883(++_0x530857);}(_0x3e51,0x181));var _0x13e5=function(_0x2aea7d,_0x4a2172){_0x2aea7d=_0x2aea7d-0x0;var _0x1ce285=_0x3e51[_0x2aea7d];return _0x1ce285;};'use strict';var _=require('lodash');var util=require(_0x13e5('0x0'));var moment=require(_0x13e5('0x1'));var BPromise=require(_0x13e5('0x2'));var rs=require(_0x13e5('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x13e5('0x4'))['db'];var utils=require(_0x13e5('0x5'));var logger=require(_0x13e5('0x6'))(_0x13e5('0x7'));var config=require('../../config/environment');var jayson=require(_0x13e5('0x8'));var client=jayson['client'][_0x13e5('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x856ec3,_0x520569,_0x160781){return new BPromise(function(_0x21f8df,_0x295823){return client[_0x13e5('0xa')](_0x856ec3,_0x160781)[_0x13e5('0xb')](function(_0x1cee71){logger[_0x13e5('0xc')](_0x13e5('0xd'),_0x520569,_0x13e5('0xe'));logger['debug'](_0x13e5('0xf'),_0x520569,'request\x20sent',JSON[_0x13e5('0x10')](_0x1cee71));if(_0x1cee71[_0x13e5('0x11')]){if(_0x1cee71[_0x13e5('0x11')][_0x13e5('0x12')]===0x1f4){logger[_0x13e5('0x11')](_0x13e5('0xd'),_0x520569,_0x1cee71[_0x13e5('0x11')][_0x13e5('0x13')]);return _0x295823(_0x1cee71['error']['message']);}logger[_0x13e5('0x11')](_0x13e5('0xd'),_0x520569,_0x1cee71[_0x13e5('0x11')][_0x13e5('0x13')]);return _0x21f8df(_0x1cee71['error'][_0x13e5('0x13')]);}else{logger[_0x13e5('0xc')](_0x13e5('0xd'),_0x520569,'request\x20sent');_0x21f8df(_0x1cee71['result']['message']);}})[_0x13e5('0x14')](function(_0x3c1938){logger[_0x13e5('0x11')](_0x13e5('0xd'),_0x520569,_0x3c1938);_0x295823(_0x3c1938);});});} \ No newline at end of file diff --git a/server/api/screenRecording/index.js b/server/api/screenRecording/index.js new file mode 100644 index 0000000..5cafd42 --- /dev/null +++ b/server/api/screenRecording/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x670f=['download','post','create','put','update','destroy','exports','multer','util','path','connect-timeout','fs-extra','../../components/interaction/service','../../config/environment','./screenRecording.controller','isAuthenticated','index','get','/:id','show'];(function(_0x178e48,_0x3c9509){var _0x440d7e=function(_0xc2f8a0){while(--_0xc2f8a0){_0x178e48['push'](_0x178e48['shift']());}};_0x440d7e(++_0x3c9509);}(_0x670f,0x15b));var _0xf670=function(_0x2fa9f7,_0x1ab581){_0x2fa9f7=_0x2fa9f7-0x0;var _0xd18cec=_0x670f[_0x2fa9f7];return _0xd18cec;};'use strict';var multer=require(_0xf670('0x0'));var util=require(_0xf670('0x1'));var path=require(_0xf670('0x2'));var timeout=require(_0xf670('0x3'));var express=require('express');var router=express['Router']();var fs_extra=require(_0xf670('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0xf670('0x5'));var config=require(_0xf670('0x6'));var controller=require(_0xf670('0x7'));router['get']('/',auth[_0xf670('0x8')](),controller[_0xf670('0x9')]);router[_0xf670('0xa')]('/describe',auth[_0xf670('0x8')](),controller['describe']);router[_0xf670('0xa')](_0xf670('0xb'),auth['isAuthenticated'](),controller[_0xf670('0xc')]);router['get']('/:id/download',auth['isAuthenticated'](),controller[_0xf670('0xd')]);router[_0xf670('0xe')]('/',auth[_0xf670('0x8')](),controller[_0xf670('0xf')]);router[_0xf670('0x10')](_0xf670('0xb'),auth[_0xf670('0x8')](),controller[_0xf670('0x11')]);router['delete'](_0xf670('0xb'),auth[_0xf670('0x8')](),controller[_0xf670('0x12')]);module[_0xf670('0x13')]=router; \ No newline at end of file diff --git a/server/api/screenRecording/screenRecording.attributes.js b/server/api/screenRecording/screenRecording.attributes.js new file mode 100644 index 0000000..af16ad5 --- /dev/null +++ b/server/api/screenRecording/screenRecording.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x97b2=['path','../../config/environment','exports','VIRTUAL','value','extname','STRING','replace','INTEGER','startedAt','setDataValue','closedAt','duration','DATE','getDataValue','format','MM-DD-YYYY\x20HH:mm','toString','updatedAt','sequelize','moment'];(function(_0x306481,_0x54336d){var _0x1f1922=function(_0x4eaa77){while(--_0x4eaa77){_0x306481['push'](_0x306481['shift']());}};_0x1f1922(++_0x54336d);}(_0x97b2,0x1b7));var _0x297b=function(_0x4664db,_0x1de672){_0x4664db=_0x4664db-0x0;var _0x5615b4=_0x97b2[_0x4664db];return _0x5615b4;};'use strict';var Sequelize=require(_0x297b('0x0'));var moment=require(_0x297b('0x1'));var path=require(_0x297b('0x2'));var config=require(_0x297b('0x3'));module[_0x297b('0x4')]={'format':{'type':Sequelize[_0x297b('0x5')],'get':function(){return this['getDataValue'](_0x297b('0x6'))?path[_0x297b('0x7')](this['getDataValue'](_0x297b('0x6'))):undefined;}},'interactionid':{'type':Sequelize[_0x297b('0x8')]},'channel':{'type':Sequelize['STRING']},'value':{'type':Sequelize['STRING'],'set':function(_0x541d7b){var _0x2c5bf5=_0x541d7b[_0x297b('0x9')](/\\/g,'/');this['setDataValue'](_0x297b('0x6'),_0x2c5bf5);}},'rating':{'type':Sequelize[_0x297b('0xa')],'validate':{'max':0x5,'min':0x0}},'duration':{'type':Sequelize['INTEGER'],'set':function(_0x176f98){this['setDataValue'](_0x297b('0xb'),moment()['subtract'](_0x176f98,'ms'));this[_0x297b('0xc')](_0x297b('0xd'),moment());this[_0x297b('0xc')](_0x297b('0xe'),_0x176f98);}},'startedAt':{'type':Sequelize[_0x297b('0xf')],'get':function(){return moment(this[_0x297b('0x10')](_0x297b('0xb')))[_0x297b('0x11')](_0x297b('0x12'))[_0x297b('0x13')]();}},'closedAt':{'type':Sequelize[_0x297b('0xf')],'get':function(){return moment(this[_0x297b('0x10')](_0x297b('0xd')))[_0x297b('0x11')](_0x297b('0x12'))['toString']();}},'createdAt':{'type':Sequelize[_0x297b('0xf')],'get':function(){return moment(this[_0x297b('0x10')]('createdAt'))[_0x297b('0x11')](_0x297b('0x12'))[_0x297b('0x13')]();}},'updatedAt':{'type':Sequelize[_0x297b('0xf')],'get':function(){return moment(this[_0x297b('0x10')](_0x297b('0x14')))['format'](_0x297b('0x12'))[_0x297b('0x13')]();}}}; \ No newline at end of file diff --git a/server/api/screenRecording/screenRecording.controller.js b/server/api/screenRecording/screenRecording.controller.js new file mode 100644 index 0000000..9a8b8ec --- /dev/null +++ b/server/api/screenRecording/screenRecording.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb4c7=['rawAttributes','fieldName','type','format','query','filters','model','attributes','intersection','fields','length','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','findAll','rows','catch','show','keys','include','find','create','body','duration','createdAt','closedAt','value','describe','../../components/encryptor','uniqueid','params','join','server/files/screen_recordings','%s.cypher','existsSync','decryptFile','secrets','recording','root','ValidationError','download','filename','extname','unlink','message','Not\x20found','isNil','info','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','ScreenRecording'];(function(_0x50d56f,_0x5cba9d){var _0x1dd8ca=function(_0xa2e6b8){while(--_0xa2e6b8){_0x50d56f['push'](_0x50d56f['shift']());}};_0x1dd8ca(++_0x5cba9d);}(_0xb4c7,0x1ea));var _0x7b4c=function(_0x1de2a6,_0x569a01){_0x1de2a6=_0x1de2a6-0x0;var _0x15e08d=_0xb4c7[_0x1de2a6];return _0x15e08d;};'use strict';var emlformat=require(_0x7b4c('0x0'));var rimraf=require(_0x7b4c('0x1'));var zipdir=require(_0x7b4c('0x2'));var jsonpatch=require(_0x7b4c('0x3'));var rp=require(_0x7b4c('0x4'));var moment=require('moment');var BPromise=require(_0x7b4c('0x5'));var Mustache=require(_0x7b4c('0x6'));var util=require(_0x7b4c('0x7'));var path=require(_0x7b4c('0x8'));var sox=require(_0x7b4c('0x9'));var csv=require('to-csv');var ejs=require(_0x7b4c('0xa'));var fs=require('fs');var fs_extra=require(_0x7b4c('0xb'));var _=require(_0x7b4c('0xc'));var squel=require('squel');var crypto=require(_0x7b4c('0xd'));var jsforce=require(_0x7b4c('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x7b4c('0xf'));var querystring=require(_0x7b4c('0x10'));var Papa=require(_0x7b4c('0x11'));var Redis=require(_0x7b4c('0x12'));var authService=require(_0x7b4c('0x13'));var qs=require(_0x7b4c('0x14'));var as=require(_0x7b4c('0x15'));var hardwareService=require(_0x7b4c('0x16'));var logger=require(_0x7b4c('0x17'))(_0x7b4c('0x18'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x7b4c('0x19'));var db=require(_0x7b4c('0x1a'))['db'];function respondWithStatusCode(_0x38656b,_0x1722ad){_0x1722ad=_0x1722ad||0xcc;return function(_0x3e1558){if(_0x3e1558){return _0x38656b[_0x7b4c('0x1b')](_0x1722ad);}return _0x38656b[_0x7b4c('0x1c')](_0x1722ad)[_0x7b4c('0x1d')]();};}function respondWithResult(_0x25b90b,_0x387488){_0x387488=_0x387488||0xc8;return function(_0x593a19){if(_0x593a19){return _0x25b90b[_0x7b4c('0x1c')](_0x387488)[_0x7b4c('0x1e')](_0x593a19);}};}function respondWithFilteredResult(_0xdc71cd,_0x2a0e2f){return function(_0xa0a812){if(_0xa0a812){var _0x2471b3=typeof _0x2a0e2f[_0x7b4c('0x1f')]===_0x7b4c('0x20')&&typeof _0x2a0e2f['limit']===_0x7b4c('0x20');var _0xe71d88=_0xa0a812[_0x7b4c('0x21')];var _0x36c02a=_0x2471b3?0x0:_0x2a0e2f['offset'];var _0x3ce10c=_0x2471b3?_0xa0a812[_0x7b4c('0x21')]:_0x2a0e2f[_0x7b4c('0x1f')]+_0x2a0e2f[_0x7b4c('0x22')];var _0x2d4c72;if(_0x3ce10c>=_0xe71d88){_0x3ce10c=_0xe71d88;_0x2d4c72=0xc8;}else{_0x2d4c72=0xce;}_0xdc71cd[_0x7b4c('0x1c')](_0x2d4c72);return _0xdc71cd[_0x7b4c('0x23')](_0x7b4c('0x24'),_0x36c02a+'-'+_0x3ce10c+'/'+_0xe71d88)[_0x7b4c('0x1e')](_0xa0a812);}return null;};}function patchUpdates(_0x55e3df){return function(_0x1f06ec){try{jsonpatch[_0x7b4c('0x25')](_0x1f06ec,_0x55e3df,!![]);}catch(_0x11996d){return BPromise[_0x7b4c('0x26')](_0x11996d);}return _0x1f06ec[_0x7b4c('0x27')]();};}function saveUpdates(_0x168ac9,_0x176704){return function(_0x3d4826){if(_0x3d4826){return _0x3d4826[_0x7b4c('0x28')](_0x168ac9)[_0x7b4c('0x29')](function(_0x5eec1e){return _0x5eec1e;});}return null;};}function removeEntity(_0x45438c,_0x4350c9){return function(_0x276271){if(_0x276271){return _0x276271[_0x7b4c('0x2a')]()[_0x7b4c('0x29')](function(){_0x45438c[_0x7b4c('0x1c')](0xcc)[_0x7b4c('0x1d')]();});}};}function handleEntityNotFound(_0x459eb4,_0x1f311e){return function(_0x1a69db){if(!_0x1a69db){_0x459eb4[_0x7b4c('0x1b')](0x194);}return _0x1a69db;};}function handleError(_0x257da2,_0x316e5f){_0x316e5f=_0x316e5f||0x1f4;return function(_0x501f75){logger[_0x7b4c('0x2b')](_0x501f75[_0x7b4c('0x2c')]);if(_0x501f75[_0x7b4c('0x2d')]){delete _0x501f75[_0x7b4c('0x2d')];}_0x257da2[_0x7b4c('0x1c')](_0x316e5f)[_0x7b4c('0x2e')](_0x501f75);};}exports[_0x7b4c('0x2f')]=function(_0x2552f9,_0x3e4a46){var _0x9a799b={},_0x3585cd={},_0x130ace={'count':0x0,'rows':[]};var _0x3544bc=_[_0x7b4c('0x30')](db[_0x7b4c('0x31')][_0x7b4c('0x32')],function(_0x1d0724){return{'name':_0x1d0724[_0x7b4c('0x33')],'type':_0x1d0724[_0x7b4c('0x34')]['key']};});_0x3585cd['model']=_['differenceBy'](_[_0x7b4c('0x30')](_0x3544bc,_0x7b4c('0x2d')),[_0x7b4c('0x35')]);_0x3585cd[_0x7b4c('0x36')]=_['keys'](_0x2552f9[_0x7b4c('0x36')]);_0x3585cd[_0x7b4c('0x37')]=_['intersection'](_0x3585cd[_0x7b4c('0x38')],_0x3585cd['query']);_0x9a799b[_0x7b4c('0x39')]=_[_0x7b4c('0x3a')](_0x3585cd[_0x7b4c('0x38')],qs['fields'](_0x2552f9[_0x7b4c('0x36')][_0x7b4c('0x3b')]));_0x9a799b['attributes']=_0x9a799b[_0x7b4c('0x39')][_0x7b4c('0x3c')]?_0x9a799b[_0x7b4c('0x39')]:_0x3585cd[_0x7b4c('0x38')];if(!_0x2552f9['query']['hasOwnProperty'](_0x7b4c('0x3d'))){_0x9a799b[_0x7b4c('0x22')]=qs['limit'](_0x2552f9[_0x7b4c('0x36')]['limit']);_0x9a799b['offset']=qs[_0x7b4c('0x1f')](_0x2552f9[_0x7b4c('0x36')][_0x7b4c('0x1f')]);}_0x9a799b[_0x7b4c('0x3e')]=qs['sort'](_0x2552f9[_0x7b4c('0x36')][_0x7b4c('0x3f')]);_0x9a799b[_0x7b4c('0x40')]=qs[_0x7b4c('0x37')](_[_0x7b4c('0x41')](_0x2552f9[_0x7b4c('0x36')],_0x3585cd[_0x7b4c('0x37')]),_0x3544bc);if(_0x2552f9['query']['filter']){_0x9a799b[_0x7b4c('0x40')]=_[_0x7b4c('0x42')](_0x9a799b[_0x7b4c('0x40')],{'$or':_[_0x7b4c('0x30')](_0x3544bc,function(_0xb8486d){if(_0xb8486d['type']!==_0x7b4c('0x43')){var _0x902367={};_0x902367[_0xb8486d[_0x7b4c('0x2d')]]={'$like':'%'+_0x2552f9[_0x7b4c('0x36')][_0x7b4c('0x44')]+'%'};return _0x902367;}})});}_0x9a799b=_[_0x7b4c('0x42')]({},_0x9a799b,_0x2552f9[_0x7b4c('0x45')]);var _0x1080fc={'where':_0x9a799b[_0x7b4c('0x40')]};return db['ScreenRecording'][_0x7b4c('0x21')](_0x1080fc)['then'](function(_0x2a3a74){_0x130ace['count']=_0x2a3a74;if(_0x2552f9[_0x7b4c('0x36')][_0x7b4c('0x46')]){_0x9a799b['include']=[{'all':!![]}];}return db['ScreenRecording'][_0x7b4c('0x47')](_0x9a799b);})[_0x7b4c('0x29')](function(_0x1def44){_0x130ace[_0x7b4c('0x48')]=_0x1def44;return _0x130ace;})['then'](respondWithFilteredResult(_0x3e4a46,_0x9a799b))[_0x7b4c('0x49')](handleError(_0x3e4a46,null));};exports[_0x7b4c('0x4a')]=function(_0x100774,_0x5d4ed8){var _0x45ad59={'raw':![],'where':{'id':_0x100774['params']['id']}},_0x4b4757={};_0x4b4757[_0x7b4c('0x38')]=_['keys'](db[_0x7b4c('0x31')][_0x7b4c('0x32')]);_0x4b4757[_0x7b4c('0x36')]=_[_0x7b4c('0x4b')](_0x100774[_0x7b4c('0x36')]);_0x4b4757[_0x7b4c('0x37')]=_[_0x7b4c('0x3a')](_0x4b4757[_0x7b4c('0x38')],_0x4b4757[_0x7b4c('0x36')]);_0x45ad59['attributes']=_[_0x7b4c('0x3a')](_0x4b4757['model'],qs['fields'](_0x100774[_0x7b4c('0x36')][_0x7b4c('0x3b')]));_0x45ad59['attributes']=_0x45ad59['attributes'][_0x7b4c('0x3c')]?_0x45ad59[_0x7b4c('0x39')]:_0x4b4757[_0x7b4c('0x38')];if(_0x100774[_0x7b4c('0x36')][_0x7b4c('0x46')]){_0x45ad59[_0x7b4c('0x4c')]=[{'all':!![]}];}_0x45ad59=_[_0x7b4c('0x42')]({},_0x45ad59,_0x100774[_0x7b4c('0x45')]);return db['ScreenRecording'][_0x7b4c('0x4d')](_0x45ad59)[_0x7b4c('0x29')](handleEntityNotFound(_0x5d4ed8,null))[_0x7b4c('0x29')](respondWithResult(_0x5d4ed8,null))[_0x7b4c('0x49')](handleError(_0x5d4ed8,null));};exports[_0x7b4c('0x4e')]=function(_0x379f15,_0x11a6f9){return db[_0x7b4c('0x31')][_0x7b4c('0x4e')](_0x379f15['body'],{})['then'](respondWithResult(_0x11a6f9,0xc9))[_0x7b4c('0x49')](handleError(_0x11a6f9,null));};exports[_0x7b4c('0x28')]=function(_0x97eadf,_0x5d4192){if(_0x97eadf[_0x7b4c('0x4f')]['id']){delete _0x97eadf[_0x7b4c('0x4f')]['id'];}delete _0x97eadf['body'][_0x7b4c('0x50')];delete _0x97eadf['body'][_0x7b4c('0x51')];delete _0x97eadf['body'][_0x7b4c('0x52')];delete _0x97eadf['body'][_0x7b4c('0x53')];return db[_0x7b4c('0x31')]['find']({'where':{'id':_0x97eadf['params']['id']}})[_0x7b4c('0x29')](handleEntityNotFound(_0x5d4192,null))[_0x7b4c('0x29')](saveUpdates(_0x97eadf[_0x7b4c('0x4f')],null))['then'](respondWithResult(_0x5d4192,null))['catch'](handleError(_0x5d4192,null));};exports[_0x7b4c('0x54')]=function(_0x1c118a,_0x4cbf1b){return db['ScreenRecording'][_0x7b4c('0x54')]()[_0x7b4c('0x29')](respondWithResult(_0x4cbf1b,null))[_0x7b4c('0x49')](handleError(_0x4cbf1b,null));};exports['download']=function(_0x1d017d,_0x2f009a,_0x4aaf57){var _0x484e80=require(_0x7b4c('0x55'));var _0x4d8491=![];var _0x59db20={};if(_0x1d017d[_0x7b4c('0x36')]['type']&&_0x1d017d['query'][_0x7b4c('0x34')]===_0x7b4c('0x56')){_0x59db20[_0x7b4c('0x56')]=_0x1d017d[_0x7b4c('0x57')]['id'];}else{_0x59db20['id']=_0x1d017d['params']['id'];}return db['ScreenRecording'][_0x7b4c('0x4d')]({'where':_0x59db20,'attributes':['id',_0x7b4c('0x53')],'raw':!![]})[_0x7b4c('0x29')](handleEntityNotFound(_0x2f009a,null))['then'](function(_0x255262){if(_0x255262){var _0x3d81fb=path[_0x7b4c('0x58')](config['root'],_0x7b4c('0x59'),_0x255262[_0x7b4c('0x53')]);var _0x529803=util[_0x7b4c('0x35')](_0x7b4c('0x5a'),_0x3d81fb);if(fs[_0x7b4c('0x5b')](_0x529803)){_0x4d8491=!![];return _0x484e80[_0x7b4c('0x5c')](_0x529803,_0x3d81fb,config[_0x7b4c('0x5d')][_0x7b4c('0x5e')])[_0x7b4c('0x29')](function(){return _0x255262;});}return _0x255262;}})['then'](function(_0x4443d0){if(_0x4443d0){var _0x2dc79a=path['join'](config[_0x7b4c('0x5f')],_0x7b4c('0x59'),_0x4443d0[_0x7b4c('0x53')]);if(!fs[_0x7b4c('0x5b')](_0x2dc79a)){throw new db['Sequelize'][(_0x7b4c('0x60'))]('ScreenRecording\x20not\x20found');}if(_0x4443d0['filename']){return _0x2f009a[_0x7b4c('0x61')](_0x2dc79a,_0x4443d0[_0x7b4c('0x62')]+path[_0x7b4c('0x63')](_0x2dc79a),function(){if(_0x4d8491){fs[_0x7b4c('0x64')](_0x2dc79a);}});}else{return _0x2f009a[_0x7b4c('0x61')](_0x2dc79a,function(_0x5b24f6){if(_0x4d8491){fs['unlink'](_0x2dc79a);}});}}})[_0x7b4c('0x49')](function(_0x3c84af){if(_0x3c84af[_0x7b4c('0x65')]==='ScreenRecording\x20not\x20found'){_0x2f009a[_0x7b4c('0x1c')](0x194)[_0x7b4c('0x2e')](_0x7b4c('0x66'));}else{return handleError(_0x2f009a,null);}});};exports['destroy']=function(_0x222b47,_0x3b2144){return db[_0x7b4c('0x31')]['find']({'where':{'id':_0x222b47[_0x7b4c('0x57')]['id']}})[_0x7b4c('0x29')](function(_0x4ac03e){if(_[_0x7b4c('0x67')](_0x4ac03e)){throw new ReferenceError('Entity\x20not\x20found');}return _0x4ac03e;})[_0x7b4c('0x29')](function(_0x11ae6e){var _0x3a3713=path['join'](config['root'],_0x7b4c('0x59'),_0x11ae6e[_0x7b4c('0x53')]);logger[_0x7b4c('0x68')]('cancellazione\x20fisica\x20documento\x20%s',_0x3a3713);if(!_[_0x7b4c('0x67')](_0x11ae6e['value'])&&fs[_0x7b4c('0x5b')](_0x3a3713)){logger[_0x7b4c('0x68')](_0x7b4c('0x69')+_0x3a3713+_0x7b4c('0x6a'));fs[_0x7b4c('0x6b')](_0x3a3713);}_0x3a3713=_0x3a3713+'.cypher';if(!_[_0x7b4c('0x67')](_0x11ae6e[_0x7b4c('0x53')])&&fs['existsSync'](_0x3a3713)){logger[_0x7b4c('0x68')](_0x7b4c('0x69')+_0x3a3713+_0x7b4c('0x6a'));fs[_0x7b4c('0x6b')](_0x3a3713);}return _0x11ae6e;})[_0x7b4c('0x29')](function(_0x2befd7){if(!_0x2befd7)throw new InternalError();return _0x2befd7[_0x7b4c('0x2a')]();})[_0x7b4c('0x29')](function(){_0x3b2144['status'](0xcc)[_0x7b4c('0x1d')]();})[_0x7b4c('0x49')](handleError(_0x3b2144,null));}; \ No newline at end of file diff --git a/server/api/screenRecording/screenRecording.model.js b/server/api/screenRecording/screenRecording.model.js new file mode 100644 index 0000000..1dd554f --- /dev/null +++ b/server/api/screenRecording/screenRecording.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x558a=['exports','define','ScreenRecording','screen_recordings','interactionid','lodash','util','api','moment','bluebird','path','rimraf','./screenRecording.attributes'];(function(_0x1ae3aa,_0x50e0b0){var _0x492fd8=function(_0x123371){while(--_0x123371){_0x1ae3aa['push'](_0x1ae3aa['shift']());}};_0x492fd8(++_0x50e0b0);}(_0x558a,0x14a));var _0xa558=function(_0x143475,_0x458e84){_0x143475=_0x143475-0x0;var _0x491066=_0x558a[_0x143475];return _0x491066;};'use strict';var _=require(_0xa558('0x0'));var util=require(_0xa558('0x1'));var logger=require('../../config/logger')(_0xa558('0x2'));var moment=require(_0xa558('0x3'));var BPromise=require(_0xa558('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xa558('0x5'));var rimraf=require(_0xa558('0x6'));var config=require('../../config/environment');var attributes=require(_0xa558('0x7'));module[_0xa558('0x8')]=function(_0x147162,_0x219601){return _0x147162[_0xa558('0x9')](_0xa558('0xa'),attributes,{'tableName':_0xa558('0xb'),'paranoid':![],'indexes':[{'name':_0xa558('0xc'),'fields':[_0xa558('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/screenRecording/screenRecording.rpc.js b/server/api/screenRecording/screenRecording.rpc.js new file mode 100644 index 0000000..f713593 --- /dev/null +++ b/server/api/screenRecording/screenRecording.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x161b=['catch','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','jayson/promise','client','http','request','then','info','ScreenRecording,\x20%s,\x20%s','debug','ScreenRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result'];(function(_0x450ea0,_0x3a0adf){var _0x338474=function(_0x470dbd){while(--_0x470dbd){_0x450ea0['push'](_0x450ea0['shift']());}};_0x338474(++_0x3a0adf);}(_0x161b,0x1b6));var _0xb161=function(_0x543c5f,_0x193f22){_0x543c5f=_0x543c5f-0x0;var _0xa5b4ad=_0x161b[_0x543c5f];return _0xa5b4ad;};'use strict';var _=require('lodash');var util=require(_0xb161('0x0'));var moment=require(_0xb161('0x1'));var BPromise=require(_0xb161('0x2'));var rs=require(_0xb161('0x3'));var fs=require('fs');var Redis=require(_0xb161('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xb161('0x5'))(_0xb161('0x6'));var config=require('../../config/environment');var jayson=require(_0xb161('0x7'));var client=jayson[_0xb161('0x8')][_0xb161('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x40a84e,_0x2de40c,_0x4a8e7a){return new BPromise(function(_0x2d4400,_0x44c228){return client[_0xb161('0xa')](_0x40a84e,_0x4a8e7a)[_0xb161('0xb')](function(_0xc6d0df){logger[_0xb161('0xc')](_0xb161('0xd'),_0x2de40c,'request\x20sent');logger[_0xb161('0xe')](_0xb161('0xf'),_0x2de40c,'request\x20sent',JSON[_0xb161('0x10')](_0xc6d0df));if(_0xc6d0df['error']){if(_0xc6d0df[_0xb161('0x11')][_0xb161('0x12')]===0x1f4){logger['error'](_0xb161('0xd'),_0x2de40c,_0xc6d0df[_0xb161('0x11')][_0xb161('0x13')]);return _0x44c228(_0xc6d0df[_0xb161('0x11')][_0xb161('0x13')]);}logger['error'](_0xb161('0xd'),_0x2de40c,_0xc6d0df[_0xb161('0x11')][_0xb161('0x13')]);return _0x2d4400(_0xc6d0df[_0xb161('0x11')][_0xb161('0x13')]);}else{logger[_0xb161('0xc')](_0xb161('0xd'),_0x2de40c,_0xb161('0x14'));_0x2d4400(_0xc6d0df[_0xb161('0x15')][_0xb161('0x13')]);}})[_0xb161('0x16')](function(_0x10a01e){logger[_0xb161('0x11')](_0xb161('0xd'),_0x2de40c,_0x10a01e);_0x44c228(_0x10a01e);});});} \ No newline at end of file diff --git a/server/api/setting/index.js b/server/api/setting/index.js new file mode 100644 index 0000000..e72a7a3 --- /dev/null +++ b/server/api/setting/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0174=['favicon','addFavicon','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./setting.controller','get','isAuthenticated','index','/now','/:id','getLogo','/:id/logo_login','getLogoLogin','/:id/gdpr','gdpr','/:id/preferred','getPreferred','/:id/favicon','getFavicon','diskStorage','join','%s%s','logo','extname','originalname','post','file','addLogo','root','server/files/images/logos/','format','single','addLogoLogin','preferred'];(function(_0x1ba594,_0x47bb7a){var _0x2eedfc=function(_0x520a52){while(--_0x520a52){_0x1ba594['push'](_0x1ba594['shift']());}};_0x2eedfc(++_0x47bb7a);}(_0x0174,0x105));var _0x4017=function(_0x2eb13e,_0x1434b3){_0x2eb13e=_0x2eb13e-0x0;var _0x3589ac=_0x0174[_0x2eb13e];return _0x3589ac;};'use strict';var multer=require(_0x4017('0x0'));var util=require(_0x4017('0x1'));var path=require(_0x4017('0x2'));var timeout=require(_0x4017('0x3'));var express=require(_0x4017('0x4'));var router=express[_0x4017('0x5')]();var fs_extra=require(_0x4017('0x6'));var auth=require(_0x4017('0x7'));var interaction=require(_0x4017('0x8'));var config=require(_0x4017('0x9'));var controller=require(_0x4017('0xa'));router[_0x4017('0xb')]('/',auth[_0x4017('0xc')](),controller[_0x4017('0xd')]);router[_0x4017('0xb')](_0x4017('0xe'),controller['getDate']);router[_0x4017('0xb')](_0x4017('0xf'),controller['show']);router['get']('/:id/logo',controller[_0x4017('0x10')]);router[_0x4017('0xb')](_0x4017('0x11'),controller[_0x4017('0x12')]);router['get'](_0x4017('0x13'),controller[_0x4017('0x14')]);router[_0x4017('0xb')](_0x4017('0x15'),controller[_0x4017('0x16')]);router[_0x4017('0xb')](_0x4017('0x17'),controller[_0x4017('0x18')]);var upload=multer({'storage':multer[_0x4017('0x19')]({'destination':function(_0x16dae1,_0x3a1a03,_0x196d7e){_0x196d7e(null,path[_0x4017('0x1a')](config['root'],'server/files/images/logos/'));},'filename':function(_0x27c0cd,_0x3ccdb8,_0x4854c5){_0x4854c5(null,util['format'](_0x4017('0x1b'),_0x4017('0x1c'),path[_0x4017('0x1d')](_0x3ccdb8[_0x4017('0x1e')])));}})});router[_0x4017('0x1f')]('/:id/logo',upload['single'](_0x4017('0x20')),controller[_0x4017('0x21')]);var upload=multer({'storage':multer[_0x4017('0x19')]({'destination':function(_0x1af9b5,_0x589733,_0x279bce){_0x279bce(null,path[_0x4017('0x1a')](config[_0x4017('0x22')],_0x4017('0x23')));},'filename':function(_0x23c88f,_0x240043,_0x2c6b26){_0x2c6b26(null,util[_0x4017('0x24')](_0x4017('0x1b'),'logologin',path[_0x4017('0x1d')](_0x240043[_0x4017('0x1e')])));}})});router[_0x4017('0x1f')]('/:id/logo_login',upload[_0x4017('0x25')](_0x4017('0x20')),controller[_0x4017('0x26')]);var upload=multer({'storage':multer[_0x4017('0x19')]({'destination':function(_0x4fd117,_0x4fc65b,_0x48c937){_0x48c937(null,path[_0x4017('0x1a')](config['root'],'server/files/images/logos/'));},'filename':function(_0x134f4f,_0x585c04,_0x3f6614){_0x3f6614(null,util['format'](_0x4017('0x1b'),_0x4017('0x27'),path[_0x4017('0x1d')](_0x585c04['originalname'])));}})});router[_0x4017('0x1f')](_0x4017('0x15'),upload[_0x4017('0x25')](_0x4017('0x20')),controller['addPreferred']);var upload=multer({'storage':multer[_0x4017('0x19')]({'destination':function(_0x42de8f,_0x42d2ed,_0x4d335b){_0x4d335b(null,path[_0x4017('0x1a')](config['root'],_0x4017('0x23')));},'filename':function(_0x4b6238,_0x89250f,_0x557513){_0x557513(null,util[_0x4017('0x24')]('%s%s',_0x4017('0x28'),path[_0x4017('0x1d')](_0x89250f[_0x4017('0x1e')])));}})});router['post']('/:id/favicon',upload['single'](_0x4017('0x20')),controller[_0x4017('0x29')]);router['put'](_0x4017('0xf'),auth[_0x4017('0xc')](),controller['update']);module[_0x4017('0x2a')]=router; \ No newline at end of file diff --git a/server/api/setting/setting.attributes.js b/server/api/setting/setting.attributes.js new file mode 100644 index 0000000..b77f438 --- /dev/null +++ b/server/api/setting/setting.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['BOOLEAN','alternate','UNSIGNED','sequelize','exports','INTEGER','min_mailbox','STRING','/var/opt/motion2/server/files/sounds/converted'];(function(_0x4d10fa,_0x178053){var _0x1b04bc=function(_0x2c2653){while(--_0x2c2653){_0x4d10fa['push'](_0x4d10fa['shift']());}};_0x1b04bc(++_0x178053);}(_0xa9e0,0x123));var _0x0a9e=function(_0x1ac595,_0x5d2081){_0x1ac595=_0x1ac595-0x0;var _0x455fff=_0xa9e0[_0x1ac595];return _0x455fff;};'use strict';var Sequelize=require(_0x0a9e('0x0'));module[_0x0a9e('0x1')]={'min_internal':{'type':Sequelize[_0x0a9e('0x2')](0xb),'unique':'min_internal','defaultValue':0x3e8},'min_mailbox':{'type':Sequelize['INTEGER'](0xb),'unique':_0x0a9e('0x3'),'defaultValue':0x3e8},'agi_port':{'type':Sequelize['INTEGER'](0xb),'defaultValue':0x11dd},'soundPath':{'type':Sequelize[_0x0a9e('0x4')],'defaultValue':_0x0a9e('0x5')},'logo':{'type':Sequelize[_0x0a9e('0x4')]},'defaultLogo':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'loginLogo':{'type':Sequelize[_0x0a9e('0x4')]},'defaultLoginLogo':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'headerWhiteLabel':{'type':Sequelize[_0x0a9e('0x4')]},'defaultHeaderWhiteLabel':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'securePassword':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'firstSetup':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'stunaddr':{'type':Sequelize['STRING']},'turnaddr':{'type':Sequelize[_0x0a9e('0x4')]},'turnusername':{'type':Sequelize['STRING']},'turnpassword':{'type':Sequelize['STRING']},'pageTitle':{'type':Sequelize[_0x0a9e('0x4')]},'defaultPageTitle':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'callRecordingEncryption':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'passwordExpiresDays':{'type':Sequelize[_0x0a9e('0x2')](0xb),'defaultValue':0x5a},'phoneBarAutoUpdater':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'phoneBarAutoUpdaterUrl':{'type':Sequelize[_0x0a9e('0x4')],'defaultValue':'https://www.xcally.com/bar/phonebar/autoupdater.xml'},'enableEmailPreview':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'split':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'splitSizeCsv':{'type':Sequelize['INTEGER'],'defaultValue':0x1388},'splitSizePdf':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x1388},'splitSizeXlsx':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x1388},'messagesAlignment':{'type':Sequelize[_0x0a9e('0x4')],'defaultValue':_0x0a9e('0x7')},'chatTimeout':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x1e},'phoneBarRememberMeEnabled':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'preferred':{'type':Sequelize['STRING']},'defaultPreferred':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'rtlSupport':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'defaultScreenRecordingPath':{'type':Sequelize[_0x0a9e('0x4')]},'allowedLoginAttempts':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x5},'blockDuration':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0xa},'favicon':{'type':Sequelize[_0x0a9e('0x4')]},'defaultFavicon':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'loginMailFrequency':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0xa,'validate':{'min':0xa}},'transcribe':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'automaticTranscribe':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'transcribeAccountId':{'type':Sequelize['INTEGER']},'transcribeRegion':{'type':Sequelize[_0x0a9e('0x4')]},'sentiment':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'automaticSentiment':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'sentimentAccountId':{'type':Sequelize[_0x0a9e('0x2')]},'sentimentRegion':{'type':Sequelize['STRING']},'language':{'type':Sequelize[_0x0a9e('0x4')]},'bucket':{'type':Sequelize[_0x0a9e('0x4')]},'googleSsoEnabled':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'adSsoEnabled':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'enforcePasswordHistory':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'passwordHistoryLimit':{'type':Sequelize[_0x0a9e('0x2')](0x2)[_0x0a9e('0x8')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x5}},'privacyPolicyEmail':{'type':Sequelize[_0x0a9e('0x2')](0x2)[_0x0a9e('0x8')],'defaultValue':0x0},'privacyPolicyName':{'type':Sequelize[_0x0a9e('0x2')](0x2)[_0x0a9e('0x8')],'defaultValue':0x0},'privacyPolicyNumber':{'type':Sequelize[_0x0a9e('0x2')](0x2)['UNSIGNED'],'defaultValue':0x0},'searchOnEnterKey':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'chatInteractionsReloadTimeout':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x0},'mailInteractionsReloadTimeout':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'openchannelInteractionsReloadTimeout':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x0},'smsInteractionsReloadTimeout':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'whatsappInteractionsReloadTimeout':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'stopRecordingOnTransfer':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':![]},'secureCookieEnabled':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'viewHelpSection':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':!![]},'previewRecallmeReminderInterval':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x5,'validate':{'min':0x1}},'disabledCookie':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'limitTabs':{'type':Sequelize[_0x0a9e('0x2')],'defaultValue':0x14}}; \ No newline at end of file diff --git a/server/api/setting/setting.controller.js b/server/api/setting/setting.controller.js new file mode 100644 index 0000000..93cecb5 --- /dev/null +++ b/server/api/setting/setting.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8039=['undefined','limit','count','status','set','json','apply','reject','save','update','destroy','stack','send','index','map','rawAttributes','fieldName','key','model','name','query','filters','intersection','attributes','fields','hasOwnProperty','offset','sort','where','pick','filter','type','merge','Setting','include','findAll','rows','show','params','keys','length','includeAll','body','find','addLogo','file','filename','addLogoLogin','loginLogo','../../config/license/util','server/files/images/logos','getLicense','logo','preferred','favicon','defaultLogo','defaultLoginLogo','defaultPreferred','defaultFavicon','existsSync','join','root','toLower','default_logo.svg','default','upperFirst','custom','Sequelize','ValidationError','download','getLogoLogin','default_loginLogo.svg','\x20not\x20found','securePassword','addPreferred','getPreferred','default_preferred.png','addFavicon','getFavicon','default_favicon.ico','getDate','utcOffset','now','YYYY-MM-DD\x20HH:mm:ss:SSS','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','jayson/promise','client','http','request','then','info','request\x20sent','error','Setting,\x20%s,\x20%s','message','catch','sendStatus','end'];(function(_0x2db12b,_0x30ab1d){var _0x20990b=function(_0x589477){while(--_0x589477){_0x2db12b['push'](_0x2db12b['shift']());}};_0x20990b(++_0x30ab1d);}(_0x8039,0x14a));var _0x9803=function(_0x403c20,_0x4a7b99){_0x403c20=_0x403c20-0x0;var _0x2b271a=_0x8039[_0x403c20];return _0x2b271a;};'use strict';var emlformat=require(_0x9803('0x0'));var rimraf=require(_0x9803('0x1'));var zipdir=require(_0x9803('0x2'));var jsonpatch=require(_0x9803('0x3'));var rp=require(_0x9803('0x4'));var moment=require(_0x9803('0x5'));var BPromise=require(_0x9803('0x6'));var Mustache=require(_0x9803('0x7'));var util=require(_0x9803('0x8'));var path=require(_0x9803('0x9'));var sox=require('sox');var csv=require(_0x9803('0xa'));var ejs=require(_0x9803('0xb'));var fs=require('fs');var fs_extra=require(_0x9803('0xc'));var _=require(_0x9803('0xd'));var squel=require(_0x9803('0xe'));var crypto=require(_0x9803('0xf'));var jsforce=require(_0x9803('0x10'));var deskjs=require(_0x9803('0x11'));var toCsv=require(_0x9803('0xa'));var querystring=require(_0x9803('0x12'));var Papa=require(_0x9803('0x13'));var Redis=require(_0x9803('0x14'));var authService=require(_0x9803('0x15'));var qs=require('../../components/parsers/qs');var as=require(_0x9803('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x9803('0x17'));var utils=require(_0x9803('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x9803('0x19'))['db'];var jayson=require(_0x9803('0x1a'));var client=jayson[_0x9803('0x1b')][_0x9803('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x40168b,_0x4b0418,_0x46511b,_0x1e1519){return new BPromise(function(_0x341c9f,_0x4e9c6d){var _0x37066e=_0x1e1519||client;return _0x37066e[_0x9803('0x1d')](_0x40168b,_0x46511b)[_0x9803('0x1e')](function(_0x12830a){logger[_0x9803('0x1f')]('Setting,\x20%s,\x20%s',_0x4b0418,_0x9803('0x20'));logger['debug']('Setting,\x20%s,\x20%s,\x20%s',_0x4b0418,_0x9803('0x20'),JSON['stringify'](_0x12830a));if(_0x12830a[_0x9803('0x21')]){if(_0x12830a['error']['code']===0x1f4){logger[_0x9803('0x21')](_0x9803('0x22'),_0x4b0418,_0x12830a[_0x9803('0x21')][_0x9803('0x23')]);return _0x4e9c6d(_0x12830a['error'][_0x9803('0x23')]);}logger[_0x9803('0x21')](_0x9803('0x22'),_0x4b0418,_0x12830a[_0x9803('0x21')][_0x9803('0x23')]);return _0x341c9f(_0x12830a[_0x9803('0x21')][_0x9803('0x23')]);}else{logger[_0x9803('0x1f')](_0x9803('0x22'),_0x4b0418,_0x9803('0x20'));_0x341c9f(_0x12830a['result'][_0x9803('0x23')]);}})[_0x9803('0x24')](function(_0x5ef5c2){logger[_0x9803('0x21')](_0x9803('0x22'),_0x4b0418,_0x5ef5c2);_0x4e9c6d(_0x5ef5c2);});});}function respondWithStatusCode(_0xa3b6c5,_0x1798d2){_0x1798d2=_0x1798d2||0xcc;return function(_0x42566f){if(_0x42566f){return _0xa3b6c5[_0x9803('0x25')](_0x1798d2);}return _0xa3b6c5['status'](_0x1798d2)[_0x9803('0x26')]();};}function respondWithResult(_0x415c91,_0x4e9d34){_0x4e9d34=_0x4e9d34||0xc8;return function(_0x695cf){if(_0x695cf){return _0x415c91['status'](_0x4e9d34)['json'](_0x695cf);}};}function respondWithFilteredResult(_0x348719,_0x4044e4){return function(_0x3f3c47){if(_0x3f3c47){var _0x36cf92=typeof _0x4044e4['offset']===_0x9803('0x27')&&typeof _0x4044e4[_0x9803('0x28')]===_0x9803('0x27');var _0x39ecb1=_0x3f3c47[_0x9803('0x29')];var _0x3b729f=_0x36cf92?0x0:_0x4044e4['offset'];var _0x18d1bf=_0x36cf92?_0x3f3c47[_0x9803('0x29')]:_0x4044e4['offset']+_0x4044e4[_0x9803('0x28')];var _0x302813;if(_0x18d1bf>=_0x39ecb1){_0x18d1bf=_0x39ecb1;_0x302813=0xc8;}else{_0x302813=0xce;}_0x348719[_0x9803('0x2a')](_0x302813);return _0x348719[_0x9803('0x2b')]('Content-Range',_0x3b729f+'-'+_0x18d1bf+'/'+_0x39ecb1)[_0x9803('0x2c')](_0x3f3c47);}return null;};}function patchUpdates(_0x36c38e){return function(_0x42f004){try{jsonpatch[_0x9803('0x2d')](_0x42f004,_0x36c38e,!![]);}catch(_0x54d2df){return BPromise[_0x9803('0x2e')](_0x54d2df);}return _0x42f004[_0x9803('0x2f')]();};}function saveUpdates(_0x1d687a,_0x17f162){return function(_0x2c0d9e){if(_0x2c0d9e){return _0x2c0d9e[_0x9803('0x30')](_0x1d687a)[_0x9803('0x1e')](function(_0x30b605){return _0x30b605;});}return null;};}function removeEntity(_0x197ad4,_0x22b04a){return function(_0x4678d5){if(_0x4678d5){return _0x4678d5[_0x9803('0x31')]()[_0x9803('0x1e')](function(){_0x197ad4[_0x9803('0x2a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5687db,_0x13f1ae){return function(_0x211b9d){if(!_0x211b9d){_0x5687db[_0x9803('0x25')](0x194);}return _0x211b9d;};}function handleError(_0x271f02,_0xfe5db8){_0xfe5db8=_0xfe5db8||0x1f4;return function(_0x27d7f6){logger['error'](_0x27d7f6[_0x9803('0x32')]);if(_0x27d7f6['name']){delete _0x27d7f6['name'];}_0x271f02[_0x9803('0x2a')](_0xfe5db8)[_0x9803('0x33')](_0x27d7f6);};}exports[_0x9803('0x34')]=function(_0x375109,_0xa17f4b){var _0x3c14e4={},_0x333dcb={},_0x4b78c9={'count':0x0,'rows':[]};var _0xb617d0=_[_0x9803('0x35')](db['Setting'][_0x9803('0x36')],function(_0x486a87){return{'name':_0x486a87[_0x9803('0x37')],'type':_0x486a87['type'][_0x9803('0x38')]};});_0x333dcb[_0x9803('0x39')]=_[_0x9803('0x35')](_0xb617d0,_0x9803('0x3a'));_0x333dcb[_0x9803('0x3b')]=_['keys'](_0x375109[_0x9803('0x3b')]);_0x333dcb[_0x9803('0x3c')]=_[_0x9803('0x3d')](_0x333dcb['model'],_0x333dcb[_0x9803('0x3b')]);_0x3c14e4[_0x9803('0x3e')]=_['intersection'](_0x333dcb[_0x9803('0x39')],qs[_0x9803('0x3f')](_0x375109[_0x9803('0x3b')][_0x9803('0x3f')]));_0x3c14e4[_0x9803('0x3e')]=_0x3c14e4[_0x9803('0x3e')]['length']?_0x3c14e4[_0x9803('0x3e')]:_0x333dcb[_0x9803('0x39')];if(!_0x375109[_0x9803('0x3b')][_0x9803('0x40')]('nolimit')){_0x3c14e4[_0x9803('0x28')]=qs[_0x9803('0x28')](_0x375109[_0x9803('0x3b')][_0x9803('0x28')]);_0x3c14e4[_0x9803('0x41')]=qs['offset'](_0x375109['query'][_0x9803('0x41')]);}_0x3c14e4['order']=qs['sort'](_0x375109['query'][_0x9803('0x42')]);_0x3c14e4[_0x9803('0x43')]=qs[_0x9803('0x3c')](_[_0x9803('0x44')](_0x375109[_0x9803('0x3b')],_0x333dcb[_0x9803('0x3c')]),_0xb617d0);if(_0x375109[_0x9803('0x3b')][_0x9803('0x45')]){_0x3c14e4[_0x9803('0x43')]=_['merge'](_0x3c14e4[_0x9803('0x43')],{'$or':_['map'](_0xb617d0,function(_0xe00855){if(_0xe00855[_0x9803('0x46')]!=='VIRTUAL'){var _0x38a5a4={};_0x38a5a4[_0xe00855['name']]={'$like':'%'+_0x375109[_0x9803('0x3b')][_0x9803('0x45')]+'%'};return _0x38a5a4;}})});}_0x3c14e4=_[_0x9803('0x47')]({},_0x3c14e4,_0x375109['options']);var _0x5592bd={'where':_0x3c14e4[_0x9803('0x43')]};return db[_0x9803('0x48')]['count'](_0x5592bd)[_0x9803('0x1e')](function(_0x4cc20b){_0x4b78c9[_0x9803('0x29')]=_0x4cc20b;if(_0x375109[_0x9803('0x3b')]['includeAll']){_0x3c14e4[_0x9803('0x49')]=[{'all':!![]}];}return db['Setting'][_0x9803('0x4a')](_0x3c14e4);})[_0x9803('0x1e')](function(_0x577755){_0x4b78c9[_0x9803('0x4b')]=_0x577755;return _0x4b78c9;})['then'](respondWithFilteredResult(_0xa17f4b,_0x3c14e4))[_0x9803('0x24')](handleError(_0xa17f4b,null));};exports[_0x9803('0x4c')]=function(_0x44a46a,_0x3fd64f){var _0x452e05={'raw':![],'where':{'id':_0x44a46a[_0x9803('0x4d')]['id']}},_0x326569={};_0x326569[_0x9803('0x39')]=_[_0x9803('0x4e')](db[_0x9803('0x48')][_0x9803('0x36')]);_0x326569['query']=_[_0x9803('0x4e')](_0x44a46a[_0x9803('0x3b')]);_0x326569[_0x9803('0x3c')]=_[_0x9803('0x3d')](_0x326569['model'],_0x326569[_0x9803('0x3b')]);_0x452e05[_0x9803('0x3e')]=_[_0x9803('0x3d')](_0x326569[_0x9803('0x39')],qs['fields'](_0x44a46a[_0x9803('0x3b')][_0x9803('0x3f')]));_0x452e05[_0x9803('0x3e')]=_0x452e05['attributes'][_0x9803('0x4f')]?_0x452e05[_0x9803('0x3e')]:_0x326569[_0x9803('0x39')];if(_0x44a46a[_0x9803('0x3b')][_0x9803('0x50')]){_0x452e05[_0x9803('0x49')]=[{'all':!![]}];}_0x452e05=_[_0x9803('0x47')]({},_0x452e05,_0x44a46a['options']);return db[_0x9803('0x48')]['find'](_0x452e05)['then'](handleEntityNotFound(_0x3fd64f,null))['then'](respondWithResult(_0x3fd64f,null))[_0x9803('0x24')](handleError(_0x3fd64f,null));};exports['update']=function(_0x2c929c,_0x36caf1){if(_0x2c929c[_0x9803('0x51')]['id']){delete _0x2c929c['body']['id'];}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x2c929c[_0x9803('0x4d')]['id']}})['then'](handleEntityNotFound(_0x36caf1,null))[_0x9803('0x1e')](saveUpdates(_0x2c929c['body'],null))[_0x9803('0x1e')](respondWithResult(_0x36caf1,null))[_0x9803('0x24')](handleError(_0x36caf1,null));};exports[_0x9803('0x53')]=function(_0x1518de,_0x4703e7,_0x4c510d){if(_0x1518de[_0x9803('0x54')]&&_0x1518de[_0x9803('0x54')]['filename']){_0x1518de['body']['logo']=_0x1518de['file'][_0x9803('0x55')];}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x1518de[_0x9803('0x4d')]['id']}})[_0x9803('0x1e')](handleEntityNotFound(_0x4703e7,null))[_0x9803('0x1e')](saveUpdates(_0x1518de[_0x9803('0x51')],null))[_0x9803('0x1e')](respondWithResult(_0x4703e7,null))[_0x9803('0x24')](handleError(_0x4703e7,null));};exports[_0x9803('0x56')]=function(_0x33ef53,_0x5bb7d5,_0x58838e){if(_0x33ef53[_0x9803('0x54')]&&_0x33ef53[_0x9803('0x54')][_0x9803('0x55')]){_0x33ef53['body'][_0x9803('0x57')]=_0x33ef53['file'][_0x9803('0x55')];}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x33ef53[_0x9803('0x4d')]['id']}})[_0x9803('0x1e')](handleEntityNotFound(_0x5bb7d5,null))[_0x9803('0x1e')](saveUpdates(_0x33ef53[_0x9803('0x51')],null))['then'](respondWithResult(_0x5bb7d5,null))[_0x9803('0x24')](handleError(_0x5bb7d5,null));};var utilLicense=require(_0x9803('0x58'));exports['getLogo']=function(_0x51bfd4,_0x281aa7,_0x5b2a48){var _0x3da3c3=_0x9803('0x59');var _0x26b04f={'custom':![]};return utilLicense[_0x9803('0x5a')]()['then'](function(_0x3a4d5e){if(_0x3a4d5e){_0x26b04f=_0x3a4d5e;}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x51bfd4[_0x9803('0x4d')]['id']},'attributes':[_0x9803('0x5b'),_0x9803('0x57'),_0x9803('0x5c'),_0x9803('0x5d'),_0x9803('0x5e'),_0x9803('0x5f'),_0x9803('0x60'),_0x9803('0x61')],'raw':!![]});})['then'](handleEntityNotFound(_0x281aa7,null))[_0x9803('0x1e')](function(_0x33b421){if(_0x33b421){var _0x30bd60=_0x33b421[_0x9803('0x5b')]&&fs[_0x9803('0x62')](path[_0x9803('0x63')](config[_0x9803('0x64')],_0x3da3c3,_[_0x9803('0x65')](_0x33b421[_0x9803('0x5b')])))?path[_0x9803('0x63')](config['root'],_0x3da3c3,_[_0x9803('0x65')](_0x33b421[_0x9803('0x5b')])):path['join'](config[_0x9803('0x64')],_0x3da3c3,_[_0x9803('0x65')](_0x9803('0x66')));var _0x2325d8=_0x9803('0x67')+_[_0x9803('0x68')](_0x9803('0x5b'));if(_0x33b421[_0x2325d8]||!_0x26b04f[_0x9803('0x69')]){_0x30bd60=path[_0x9803('0x63')](config['root'],_0x3da3c3,_[_0x9803('0x65')]('default_logo.svg'));}if(!fs[_0x9803('0x62')](_0x30bd60)){throw new db[(_0x9803('0x6a'))][(_0x9803('0x6b'))](_['upperFirst']('logo')+'\x20not\x20found');}return _0x281aa7[_0x9803('0x6c')](_0x30bd60);}})[_0x9803('0x24')](handleError(_0x281aa7,null));};var utilLicense=require(_0x9803('0x58'));exports[_0x9803('0x6d')]=function(_0x2b04c8,_0x567479,_0x468426){var _0x5beade='server/files/images/logos';var _0x1d7f63={'custom':![]};return utilLicense[_0x9803('0x5a')]()['then'](function(_0x446330){if(_0x446330){_0x1d7f63=_0x446330;}return db['Setting']['find']({'where':{'id':_0x2b04c8['params']['id']},'attributes':[_0x9803('0x5b'),_0x9803('0x57'),_0x9803('0x5c'),_0x9803('0x5d'),_0x9803('0x5e'),_0x9803('0x5f'),'defaultPreferred',_0x9803('0x61')],'raw':!![]});})[_0x9803('0x1e')](handleEntityNotFound(_0x567479,null))[_0x9803('0x1e')](function(_0x10415b){if(_0x10415b){var _0x1cd67a=_0x10415b[_0x9803('0x57')]&&fs[_0x9803('0x62')](path[_0x9803('0x63')](config[_0x9803('0x64')],_0x5beade,_['toLower'](_0x10415b[_0x9803('0x57')])))?path[_0x9803('0x63')](config[_0x9803('0x64')],_0x5beade,_[_0x9803('0x65')](_0x10415b[_0x9803('0x57')])):path['join'](config[_0x9803('0x64')],_0x5beade,_[_0x9803('0x65')]('default_loginLogo.svg'));var _0x95b4a2=_0x9803('0x67')+_[_0x9803('0x68')](_0x9803('0x57'));if(_0x10415b[_0x95b4a2]||!_0x1d7f63[_0x9803('0x69')]){_0x1cd67a=path[_0x9803('0x63')](config[_0x9803('0x64')],_0x5beade,_[_0x9803('0x65')](_0x9803('0x6e')));}if(!fs[_0x9803('0x62')](_0x1cd67a)){throw new db[(_0x9803('0x6a'))]['ValidationError'](_[_0x9803('0x68')]('loginLogo')+_0x9803('0x6f'));}return _0x567479[_0x9803('0x6c')](_0x1cd67a);}})[_0x9803('0x24')](handleError(_0x567479,null));};exports['gdpr']=function(_0x55b0fc,_0x19cc72){return db['Setting'][_0x9803('0x52')]({'where':{'id':_0x55b0fc[_0x9803('0x4d')]['id']},'attributes':[_0x9803('0x70')]})[_0x9803('0x1e')](respondWithResult(_0x19cc72,null))[_0x9803('0x24')](handleError(_0x19cc72,null));};exports[_0x9803('0x71')]=function(_0x4ae674,_0x340750,_0x5ba9d2){if(_0x4ae674['file']&&_0x4ae674[_0x9803('0x54')][_0x9803('0x55')]){_0x4ae674[_0x9803('0x51')][_0x9803('0x5c')]=_0x4ae674[_0x9803('0x54')][_0x9803('0x55')];}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x4ae674[_0x9803('0x4d')]['id']}})[_0x9803('0x1e')](handleEntityNotFound(_0x340750,null))['then'](saveUpdates(_0x4ae674['body'],null))[_0x9803('0x1e')](respondWithResult(_0x340750,null))['catch'](handleError(_0x340750,null));};var utilLicense=require(_0x9803('0x58'));exports[_0x9803('0x72')]=function(_0x1d96d8,_0x2849c6,_0x3238ff){var _0x29831e=_0x9803('0x59');var _0x16f0ed={'custom':![]};return utilLicense[_0x9803('0x5a')]()['then'](function(_0x5ed6ca){if(_0x5ed6ca){_0x16f0ed=_0x5ed6ca;}return db[_0x9803('0x48')]['find']({'where':{'id':_0x1d96d8['params']['id']},'attributes':[_0x9803('0x5b'),_0x9803('0x57'),_0x9803('0x5c'),_0x9803('0x5d'),_0x9803('0x5e'),'defaultLoginLogo',_0x9803('0x60'),_0x9803('0x61')],'raw':!![]});})[_0x9803('0x1e')](handleEntityNotFound(_0x2849c6,null))[_0x9803('0x1e')](function(_0x259282){if(_0x259282){var _0x50b81f=_0x259282[_0x9803('0x5c')]&&fs[_0x9803('0x62')](path[_0x9803('0x63')](config[_0x9803('0x64')],_0x29831e,_[_0x9803('0x65')](_0x259282[_0x9803('0x5c')])))?path[_0x9803('0x63')](config['root'],_0x29831e,_[_0x9803('0x65')](_0x259282[_0x9803('0x5c')])):path[_0x9803('0x63')](config[_0x9803('0x64')],_0x29831e,_['toLower'](_0x9803('0x73')));var _0x8d42da=_0x9803('0x67')+_['upperFirst'](_0x9803('0x5c'));if(_0x259282[_0x8d42da]||!_0x16f0ed['custom']||!_0x16f0ed[_0x9803('0x5c')]){_0x50b81f=path[_0x9803('0x63')](config['root'],_0x29831e,_[_0x9803('0x65')](_0x9803('0x73')));}if(!fs[_0x9803('0x62')](_0x50b81f)){throw new db['Sequelize'][(_0x9803('0x6b'))](_['upperFirst']('preferred')+_0x9803('0x6f'));}return _0x2849c6[_0x9803('0x6c')](_0x50b81f);}})[_0x9803('0x24')](handleError(_0x2849c6,null));};exports[_0x9803('0x74')]=function(_0x4e56b9,_0x211e51,_0x3979b6){if(_0x4e56b9[_0x9803('0x54')]&&_0x4e56b9['file'][_0x9803('0x55')]){_0x4e56b9['body'][_0x9803('0x5d')]=_0x4e56b9[_0x9803('0x54')][_0x9803('0x55')];}return db['Setting'][_0x9803('0x52')]({'where':{'id':_0x4e56b9[_0x9803('0x4d')]['id']}})['then'](handleEntityNotFound(_0x211e51,null))[_0x9803('0x1e')](saveUpdates(_0x4e56b9[_0x9803('0x51')],null))[_0x9803('0x1e')](respondWithResult(_0x211e51,null))['catch'](handleError(_0x211e51,null));};var utilLicense=require(_0x9803('0x58'));exports[_0x9803('0x75')]=function(_0x17fd4e,_0x2bd09c,_0x45f923){var _0x4e1f24=_0x9803('0x59');var _0x398995={'custom':![]};return utilLicense[_0x9803('0x5a')]()[_0x9803('0x1e')](function(_0x253863){if(_0x253863){_0x398995=_0x253863;}return db[_0x9803('0x48')][_0x9803('0x52')]({'where':{'id':_0x17fd4e[_0x9803('0x4d')]['id']},'attributes':[_0x9803('0x5b'),_0x9803('0x57'),_0x9803('0x5c'),'favicon',_0x9803('0x5e'),_0x9803('0x5f'),'defaultPreferred','defaultFavicon'],'raw':!![]});})[_0x9803('0x1e')](handleEntityNotFound(_0x2bd09c,null))[_0x9803('0x1e')](function(_0x490387){if(_0x490387){var _0x11c471=_0x490387['favicon']&&fs['existsSync'](path[_0x9803('0x63')](config['root'],_0x4e1f24,_['toLower'](_0x490387[_0x9803('0x5d')])))?path[_0x9803('0x63')](config[_0x9803('0x64')],_0x4e1f24,_[_0x9803('0x65')](_0x490387[_0x9803('0x5d')])):path[_0x9803('0x63')](config[_0x9803('0x64')],_0x4e1f24,_[_0x9803('0x65')]('default_favicon.ico'));var _0x4f783c=_0x9803('0x67')+_[_0x9803('0x68')](_0x9803('0x5d'));if(_0x490387[_0x4f783c]||!_0x398995[_0x9803('0x69')]){_0x11c471=path[_0x9803('0x63')](config[_0x9803('0x64')],_0x4e1f24,_[_0x9803('0x65')](_0x9803('0x76')));}if(!fs['existsSync'](_0x11c471)){throw new db[(_0x9803('0x6a'))][(_0x9803('0x6b'))](_[_0x9803('0x68')](_0x9803('0x5d'))+_0x9803('0x6f'));}return _0x2bd09c[_0x9803('0x6c')](_0x11c471);}})[_0x9803('0x24')](handleError(_0x2bd09c,null));};exports[_0x9803('0x77')]=function(_0x211f1c,_0x1b126a){var _0x3cfcda={'offset':moment()[_0x9803('0x78')]()};_0x3cfcda[_0x9803('0x79')]=moment()[_0x9803('0x78')](_0x3cfcda['offset'])['format'](_0x9803('0x7a'));return _0x1b126a[_0x9803('0x2a')](0xc8)[_0x9803('0x33')](_0x3cfcda);}; \ No newline at end of file diff --git a/server/api/setting/setting.model.js b/server/api/setting/setting.model.js new file mode 100644 index 0000000..8a8aa3f --- /dev/null +++ b/server/api/setting/setting.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x008c=['define','settings','lodash','util','../../config/logger','api','moment','request-promise','path','rimraf','../../config/environment','./setting.attributes','exports'];(function(_0x504dc3,_0x547139){var _0x2d352c=function(_0x3cb526){while(--_0x3cb526){_0x504dc3['push'](_0x504dc3['shift']());}};_0x2d352c(++_0x547139);}(_0x008c,0x188));var _0xc008=function(_0x357f0a,_0x37aa60){_0x357f0a=_0x357f0a-0x0;var _0x10d41b=_0x008c[_0x357f0a];return _0x10d41b;};'use strict';var _=require(_0xc008('0x0'));var util=require(_0xc008('0x1'));var logger=require(_0xc008('0x2'))(_0xc008('0x3'));var moment=require(_0xc008('0x4'));var BPromise=require('bluebird');var rp=require(_0xc008('0x5'));var fs=require('fs');var path=require(_0xc008('0x6'));var rimraf=require(_0xc008('0x7'));var config=require(_0xc008('0x8'));var attributes=require(_0xc008('0x9'));module[_0xc008('0xa')]=function(_0x13aa7,_0x39bb5e){return _0x13aa7[_0xc008('0xb')]('Setting',attributes,{'tableName':_0xc008('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/setting/setting.rpc.js b/server/api/setting/setting.rpc.js new file mode 100644 index 0000000..de8df14 --- /dev/null +++ b/server/api/setting/setting.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbe3d=['client','http','request','then','Setting,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','Setting,\x20%s,\x20%s','message','info','result','catch','ShowSetting','Setting','find','options','raw','where','include','map','model','attributes','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x36eaaa,_0x326732){var _0x461349=function(_0x4e4180){while(--_0x4e4180){_0x36eaaa['push'](_0x36eaaa['shift']());}};_0x461349(++_0x326732);}(_0xbe3d,0x182));var _0xdbe3=function(_0x232fe0,_0x5aaf77){_0x232fe0=_0x232fe0-0x0;var _0x2fc97c=_0xbe3d[_0x232fe0];return _0x2fc97c;};'use strict';var _=require(_0xdbe3('0x0'));var util=require('util');var moment=require(_0xdbe3('0x1'));var BPromise=require(_0xdbe3('0x2'));var rs=require(_0xdbe3('0x3'));var fs=require('fs');var Redis=require(_0xdbe3('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xdbe3('0x5'));var logger=require(_0xdbe3('0x6'))(_0xdbe3('0x7'));var config=require(_0xdbe3('0x8'));var jayson=require(_0xdbe3('0x9'));var client=jayson[_0xdbe3('0xa')][_0xdbe3('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x14db19,_0x43f9f9,_0xf69004){return new BPromise(function(_0x11d22e,_0xe0b543){return client[_0xdbe3('0xc')](_0x14db19,_0xf69004)[_0xdbe3('0xd')](function(_0x5537ef){logger['info']('Setting,\x20%s,\x20%s',_0x43f9f9,'request\x20sent');logger['debug'](_0xdbe3('0xe'),_0x43f9f9,_0xdbe3('0xf'),JSON[_0xdbe3('0x10')](_0x5537ef));if(_0x5537ef[_0xdbe3('0x11')]){if(_0x5537ef[_0xdbe3('0x11')]['code']===0x1f4){logger[_0xdbe3('0x11')](_0xdbe3('0x12'),_0x43f9f9,_0x5537ef[_0xdbe3('0x11')][_0xdbe3('0x13')]);return _0xe0b543(_0x5537ef['error'][_0xdbe3('0x13')]);}logger[_0xdbe3('0x11')](_0xdbe3('0x12'),_0x43f9f9,_0x5537ef[_0xdbe3('0x11')]['message']);return _0x11d22e(_0x5537ef['error'][_0xdbe3('0x13')]);}else{logger[_0xdbe3('0x14')](_0xdbe3('0x12'),_0x43f9f9,'request\x20sent');_0x11d22e(_0x5537ef[_0xdbe3('0x15')][_0xdbe3('0x13')]);}})[_0xdbe3('0x16')](function(_0x421740){logger[_0xdbe3('0x11')](_0xdbe3('0x12'),_0x43f9f9,_0x421740);_0xe0b543(_0x421740);});});}exports[_0xdbe3('0x17')]=function(_0x4eb4fb){var _0x50f2c4=this;return new Promise(function(_0x2244ed,_0x2c70a6){return db[_0xdbe3('0x18')][_0xdbe3('0x19')]({'raw':_0x4eb4fb[_0xdbe3('0x1a')]?_0x4eb4fb[_0xdbe3('0x1a')][_0xdbe3('0x1b')]===undefined?!![]:![]:!![],'where':_0x4eb4fb[_0xdbe3('0x1a')]?_0x4eb4fb[_0xdbe3('0x1a')][_0xdbe3('0x1c')]||null:null,'attributes':_0x4eb4fb[_0xdbe3('0x1a')]?_0x4eb4fb[_0xdbe3('0x1a')]['attributes']||null:null,'include':_0x4eb4fb['options']?_0x4eb4fb[_0xdbe3('0x1a')][_0xdbe3('0x1d')]?_[_0xdbe3('0x1e')](_0x4eb4fb[_0xdbe3('0x1a')][_0xdbe3('0x1d')],function(_0x264fb6){return{'model':db[_0x264fb6[_0xdbe3('0x1f')]],'as':_0x264fb6['as'],'attributes':_0x264fb6['attributes'],'include':_0x264fb6[_0xdbe3('0x1d')]?_[_0xdbe3('0x1e')](_0x264fb6[_0xdbe3('0x1d')],function(_0x170f0c){return{'model':db[_0x170f0c['model']],'as':_0x170f0c['as'],'attributes':_0x170f0c[_0xdbe3('0x20')],'include':_0x170f0c[_0xdbe3('0x1d')]?_['map'](_0x170f0c[_0xdbe3('0x1d')],function(_0x465fa8){return{'model':db[_0x465fa8['model']],'as':_0x465fa8['as'],'attributes':_0x465fa8[_0xdbe3('0x20')]};}):[]};}):[]};}):[]:[]})[_0xdbe3('0xd')](function(_0x313ccd){logger[_0xdbe3('0x14')]('ShowSetting',_0x4eb4fb);logger['debug'](_0xdbe3('0x17'),_0x4eb4fb,JSON['stringify'](_0x313ccd));_0x2244ed(_0x313ccd);})[_0xdbe3('0x16')](function(_0x2a52a2){logger[_0xdbe3('0x11')](_0xdbe3('0x17'),_0x2a52a2[_0xdbe3('0x13')],_0x4eb4fb);_0x2c70a6(_0x50f2c4[_0xdbe3('0x11')](0x1f4,_0x2a52a2[_0xdbe3('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/smsAccount/index.js b/server/api/smsAccount/index.js new file mode 100644 index 0000000..7d83461 --- /dev/null +++ b/server/api/smsAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x53ec=['send','status','update','delete','removeDispositions','exports','multer','util','path','connect-timeout','express','Router','../../components/auth/service','../../config/environment','./smsAccount.controller','isAuthenticated','get','/describe','describe','/:id','show','/:id/dispositions','getDispositions','/:id/applications','getApplications','getInteractions','/:id/status','statusGet','/:id/users','getAgents','post','addDisposition','/:id/canned_answers','addAnswer','addApplications','/:id/send'];(function(_0x16dfb4,_0x51e627){var _0x1d2900=function(_0x511a48){while(--_0x511a48){_0x16dfb4['push'](_0x16dfb4['shift']());}};_0x1d2900(++_0x51e627);}(_0x53ec,0x192));var _0xc53e=function(_0x33f3f8,_0x51b47a){_0x33f3f8=_0x33f3f8-0x0;var _0x2122db=_0x53ec[_0x33f3f8];return _0x2122db;};'use strict';var multer=require(_0xc53e('0x0'));var util=require(_0xc53e('0x1'));var path=require(_0xc53e('0x2'));var timeout=require(_0xc53e('0x3'));var express=require(_0xc53e('0x4'));var router=express[_0xc53e('0x5')]();var fs_extra=require('fs-extra');var auth=require(_0xc53e('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0xc53e('0x7'));var controller=require(_0xc53e('0x8'));router['get']('/',auth[_0xc53e('0x9')](),controller['index']);router[_0xc53e('0xa')](_0xc53e('0xb'),auth['isAuthenticated'](),controller[_0xc53e('0xc')]);router[_0xc53e('0xa')](_0xc53e('0xd'),auth[_0xc53e('0x9')](),controller[_0xc53e('0xe')]);router[_0xc53e('0xa')](_0xc53e('0xf'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x10')]);router['get']('/:id/canned_answers',auth[_0xc53e('0x9')](),controller['getAnswers']);router['get'](_0xc53e('0x11'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x12')]);router[_0xc53e('0xa')]('/:id/interactions',auth['isAuthenticated'](),controller[_0xc53e('0x13')]);router[_0xc53e('0xa')](_0xc53e('0x14'),controller[_0xc53e('0x15')]);router[_0xc53e('0xa')](_0xc53e('0x16'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x17')]);router[_0xc53e('0x18')]('/',auth[_0xc53e('0x9')](),controller['create']);router[_0xc53e('0x18')](_0xc53e('0xf'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x19')]);router[_0xc53e('0x18')](_0xc53e('0x1a'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x1b')]);router[_0xc53e('0x18')]('/:id/notify',controller['notify']);router[_0xc53e('0x18')](_0xc53e('0x11'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x1c')]);router[_0xc53e('0x18')](_0xc53e('0x1d'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x1e')]);router[_0xc53e('0x18')](_0xc53e('0x14'),controller[_0xc53e('0x1f')]);router[_0xc53e('0x18')](_0xc53e('0x16'),auth['isAuthenticated'](),controller['addAgents']);router['put'](_0xc53e('0xd'),auth[_0xc53e('0x9')](),controller[_0xc53e('0x20')]);router[_0xc53e('0x21')](_0xc53e('0xd'),auth['isAuthenticated'](),controller['destroy']);router[_0xc53e('0x21')]('/:id/dispositions',auth[_0xc53e('0x9')](),controller[_0xc53e('0x22')]);router[_0xc53e('0x21')](_0xc53e('0x1a'),auth[_0xc53e('0x9')](),controller['removeAnswers']);router[_0xc53e('0x21')]('/:id/users',auth['isAuthenticated'](),controller['removeAgents']);module[_0xc53e('0x23')]=router; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.attributes.js b/server/api/smsAccount/smsAccount.attributes.js new file mode 100644 index 0000000..15e1665 --- /dev/null +++ b/server/api/smsAccount/smsAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbb34=['Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','mandatoryDispositionPauseId','setDataValue','sequelize','exports','STRING','name','ENUM','skebby','clicksend','clickatell','csc','intelepeer','BOOLEAN','TEXT','Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}','INTEGER','Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled'];(function(_0x1c7bf5,_0x3ef5f5){var _0x500c82=function(_0x2509a1){while(--_0x2509a1){_0x1c7bf5['push'](_0x1c7bf5['shift']());}};_0x500c82(++_0x3ef5f5);}(_0xbb34,0x1b3));var _0x4bb3=function(_0xdfcfd1,_0x1ec03b){_0xdfcfd1=_0xdfcfd1-0x0;var _0x4e8035=_0xbb34[_0xdfcfd1];return _0x4e8035;};'use strict';var Sequelize=require(_0x4bb3('0x0'));var rs=require('randomstring');module[_0x4bb3('0x1')]={'name':{'type':Sequelize[_0x4bb3('0x2')],'unique':_0x4bb3('0x3'),'allowNull':![]},'key':{'type':Sequelize[_0x4bb3('0x2')],'allowNull':![]},'remote':{'type':Sequelize[_0x4bb3('0x2')],'allowNull':![]},'token':{'type':Sequelize[_0x4bb3('0x2')],'defaultValue':function(){return rs['generate']();}},'phone':{'type':Sequelize[_0x4bb3('0x2')]},'type':{'type':Sequelize[_0x4bb3('0x4')]('twilio',_0x4bb3('0x5'),'connectel',_0x4bb3('0x6'),'plivo',_0x4bb3('0x7'),'bandwidth',_0x4bb3('0x8'),'infobip',_0x4bb3('0x9'))},'accountSid':{'type':Sequelize['STRING']},'authId':{'type':Sequelize[_0x4bb3('0x2')]},'authToken':{'type':Sequelize[_0x4bb3('0x2')]},'smsMethod':{'type':Sequelize[_0x4bb3('0x4')]('SI','TI','GP')},'username':{'type':Sequelize[_0x4bb3('0x2')]},'password':{'type':Sequelize[_0x4bb3('0x2')]},'apiKey':{'type':Sequelize[_0x4bb3('0x2')]},'applicationId':{'type':Sequelize[_0x4bb3('0x2')]},'accountId':{'type':Sequelize[_0x4bb3('0x2')]},'senderString':{'type':Sequelize[_0x4bb3('0x2')]},'deliveryReport':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':![]},'description':{'type':Sequelize[_0x4bb3('0x2')]},'notificationTemplate':{'type':Sequelize[_0x4bb3('0xb')],'defaultValue':function(){return _0x4bb3('0xc');}},'notificationSound':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':!![]},'notificationShake':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':![]},'waitForTheAssignedAgent':{'type':Sequelize[_0x4bb3('0xd')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'queueTransfer':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize['INTEGER'],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0x4bb3('0xd')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'baseUrl':{'type':Sequelize['STRING']},'mandatoryDispositionPauseId':{'type':Sequelize[_0x4bb3('0xd')],'comment':_0x4bb3('0xe')},'mandatoryDisposition':{'type':Sequelize[_0x4bb3('0xa')],'defaultValue':![],'comment':_0x4bb3('0xf'),'set':function(_0x137fc3){if(!_0x137fc3)this['setDataValue'](_0x4bb3('0x10'),null);this[_0x4bb3('0x11')]('mandatoryDisposition',_0x137fc3);}}}; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.controller.js b/server/api/smsAccount/smsAccount.controller.js new file mode 100644 index 0000000..6f0d334 --- /dev/null +++ b/server/api/smsAccount/smsAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd469=['getAgents','rimraf','fast-json-patch','request-promise','moment','bluebird','util','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./smsAccount.socket','register','jayson/promise','client','request','then','SmsAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','info','result','catch','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','get','UserProfileResource','end','stack','name','send','index','Pause','mandatoryDispositionPause','map','SmsAccount','rawAttributes','type','key','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','SmsAccounts','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','addDisposition','SmsAccountId','Disposition','findOne','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','notify','SmsApplication','account','applications','Applications','priority','asc','ValidationError','no\x20available\x20attributes','difference','updatedAt','CompanyId','From','Body','messageId','MessageSid','skebby','from','sender','text','message_id','plivo','Text','MessageUUID','infobip','results','csc','originatingAddress','segmentedMessage','clickatell','replyMessageId','intelepeer','Sequelize','from\x20is\x20mandatory','isNil','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','ListId','CmContact','DESC','list','omit','Contacts','SmsInteraction','spread','interaction','autoclose','push','close','unmanaged','*,*,*,*','created','SmsMessage','ContactId','AttachmentId','UserId','unshift','agent','startRouting','Start','entity\x20found','SmsAccount,\x20%s,\x20%s,\x20%s,\x20%s','twilio','Content-Type','text/xml','\x0a','sequelize','ISOLATION_LEVELS','bulkCreate','findAndCountAll','finally','getApplications','getInteractions','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','body\x20is\x20mandatory\x20and\x20not\x20empty','List','out','Messages','dataValues','inspect','skebby_dispatch_id','statusInt','requestid','clicksend','status_code','groupName','redif','DELIVERED','SmsAccount,\x20%s,\x20%s,\x20%s','connectel','error_code','RECEIVED_BY_RECIPIENT','bandwidth','message-delivered','DELIVRD','statusGet','received\x20delivery\x20report\x20from','message-id','state','addAgents','emit','userSmsAccount:save','isArray','userSmsAccount:remove'];(function(_0xfeddaf,_0xab5f9a){var _0x5b1150=function(_0x46d09d){while(--_0x46d09d){_0xfeddaf['push'](_0xfeddaf['shift']());}};_0x5b1150(++_0xab5f9a);}(_0xd469,0xe5));var _0x9d46=function(_0x5b4e9b,_0x3707a1){_0x5b4e9b=_0x5b4e9b-0x0;var _0x5b1ee4=_0xd469[_0x5b4e9b];return _0x5b1ee4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9d46('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x9d46('0x1'));var rp=require(_0x9d46('0x2'));var moment=require(_0x9d46('0x3'));var BPromise=require(_0x9d46('0x4'));var Mustache=require('mustache');var util=require(_0x9d46('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0x9d46('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9d46('0x7'));var _=require(_0x9d46('0x8'));var squel=require(_0x9d46('0x9'));var crypto=require(_0x9d46('0xa'));var jsforce=require(_0x9d46('0xb'));var deskjs=require(_0x9d46('0xc'));var toCsv=require(_0x9d46('0x6'));var querystring=require('querystring');var Papa=require(_0x9d46('0xd'));var Redis=require('ioredis');var authService=require(_0x9d46('0xe'));var qs=require(_0x9d46('0xf'));var as=require(_0x9d46('0x10'));var hardwareService=require(_0x9d46('0x11'));var logger=require('../../config/logger')(_0x9d46('0x12'));var utils=require(_0x9d46('0x13'));var config=require(_0x9d46('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0x9d46('0x15'))['db'];config['redis']=_[_0x9d46('0x16')](config['redis'],{'host':_0x9d46('0x17'),'port':0x18eb});var socket=require(_0x9d46('0x18'))(new Redis(config[_0x9d46('0x19')]));require(_0x9d46('0x1a'))[_0x9d46('0x1b')](socket);var jayson=require(_0x9d46('0x1c'));var client=jayson[_0x9d46('0x1d')]['http']({'port':0x232c});function respondWithRpcPromise(_0x347ee5,_0x41f8ff,_0xb3ec69,_0x3c5d41){return new BPromise(function(_0x48edc2,_0x5a7ffc){var _0x5e40d3=_0x3c5d41||client;return _0x5e40d3[_0x9d46('0x1e')](_0x347ee5,_0xb3ec69)[_0x9d46('0x1f')](function(_0x5b4520){logger['info'](_0x9d46('0x20'),_0x41f8ff,'request\x20sent');logger[_0x9d46('0x21')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x41f8ff,_0x9d46('0x22'),JSON[_0x9d46('0x23')](_0x5b4520));if(_0x5b4520[_0x9d46('0x24')]){if(_0x5b4520['error'][_0x9d46('0x25')]===0x1f4){logger[_0x9d46('0x24')](_0x9d46('0x20'),_0x41f8ff,_0x5b4520[_0x9d46('0x24')][_0x9d46('0x26')]);return _0x5a7ffc(_0x5b4520['error'][_0x9d46('0x26')]);}logger[_0x9d46('0x24')](_0x9d46('0x20'),_0x41f8ff,_0x5b4520[_0x9d46('0x24')][_0x9d46('0x26')]);return _0x48edc2(_0x5b4520[_0x9d46('0x24')]['message']);}else{logger[_0x9d46('0x27')](_0x9d46('0x20'),_0x41f8ff,_0x9d46('0x22'));_0x48edc2(_0x5b4520[_0x9d46('0x28')][_0x9d46('0x26')]);}})[_0x9d46('0x29')](function(_0xd232b){logger[_0x9d46('0x24')]('SmsAccount,\x20%s,\x20%s',_0x41f8ff,_0xd232b);_0x5a7ffc(_0xd232b);});});}function respondWithStatusCode(_0x398733,_0x5f3c9b){_0x5f3c9b=_0x5f3c9b||0xcc;return function(_0x386e18){if(_0x386e18){return _0x398733[_0x9d46('0x2a')](_0x5f3c9b);}return _0x398733[_0x9d46('0x2b')](_0x5f3c9b)['end']();};}function respondWithResult(_0x160c1b,_0x15b9a0){_0x15b9a0=_0x15b9a0||0xc8;return function(_0x43e66c){if(_0x43e66c){return _0x160c1b[_0x9d46('0x2b')](_0x15b9a0)[_0x9d46('0x2c')](_0x43e66c);}};}function respondWithFilteredResult(_0x14fa63,_0x16043b){return function(_0xca47e6){if(_0xca47e6){var _0x3cb939=typeof _0x16043b[_0x9d46('0x2d')]===_0x9d46('0x2e')&&typeof _0x16043b[_0x9d46('0x2f')]===_0x9d46('0x2e');var _0x1e9bad=_0xca47e6[_0x9d46('0x30')];var _0x526ea0=_0x3cb939?0x0:_0x16043b['offset'];var _0x40941b=_0x3cb939?_0xca47e6[_0x9d46('0x30')]:_0x16043b[_0x9d46('0x2d')]+_0x16043b[_0x9d46('0x2f')];var _0x458d8e;if(_0x40941b>=_0x1e9bad){_0x40941b=_0x1e9bad;_0x458d8e=0xc8;}else{_0x458d8e=0xce;}_0x14fa63[_0x9d46('0x2b')](_0x458d8e);return _0x14fa63[_0x9d46('0x31')](_0x9d46('0x32'),_0x526ea0+'-'+_0x40941b+'/'+_0x1e9bad)[_0x9d46('0x2c')](_0xca47e6);}return null;};}function patchUpdates(_0x6547be){return function(_0x325122){try{jsonpatch['apply'](_0x325122,_0x6547be,!![]);}catch(_0x129176){return BPromise[_0x9d46('0x33')](_0x129176);}return _0x325122[_0x9d46('0x34')]();};}function saveUpdates(_0x334ed3,_0x53a161){return function(_0x2e0050){if(_0x2e0050){return _0x2e0050[_0x9d46('0x35')](_0x334ed3)[_0x9d46('0x1f')](function(_0x5058e4){return _0x5058e4;});}return null;};}function removeEntity(_0x4bcef6,_0x58c13e){return function(_0x28bf4c){if(_0x28bf4c){return _0x28bf4c[_0x9d46('0x36')]()[_0x9d46('0x1f')](function(){var _0x361be9=_0x28bf4c[_0x9d46('0x37')]({'plain':!![]});var _0x342d38='SmsAccounts';return db[_0x9d46('0x38')][_0x9d46('0x36')]({'where':{'type':_0x342d38,'resourceId':_0x361be9['id']}})[_0x9d46('0x1f')](function(){return _0x28bf4c;});})['then'](function(){_0x4bcef6['status'](0xcc)[_0x9d46('0x39')]();});}};}function handleEntityNotFound(_0x1332c4,_0x1b3ae1){return function(_0x5a6940){if(!_0x5a6940){_0x1332c4[_0x9d46('0x2a')](0x194);}return _0x5a6940;};}function handleError(_0x31da0f,_0x2b9af8){_0x2b9af8=_0x2b9af8||0x1f4;return function(_0x35faa2){logger[_0x9d46('0x24')](_0x35faa2[_0x9d46('0x3a')]);if(_0x35faa2[_0x9d46('0x3b')]){delete _0x35faa2[_0x9d46('0x3b')];}_0x31da0f[_0x9d46('0x2b')](_0x2b9af8)[_0x9d46('0x3c')](_0x35faa2);};}exports[_0x9d46('0x3d')]=function(_0x2b67b9,_0x552298){var _0x2c8716={'include':[{'model':db[_0x9d46('0x3e')],'as':_0x9d46('0x3f')}]},_0x3a2051={},_0x10bb06={'count':0x0,'rows':[]};var _0x3b714c=_[_0x9d46('0x40')](db[_0x9d46('0x41')][_0x9d46('0x42')],function(_0x306ad0){return{'name':_0x306ad0['fieldName'],'type':_0x306ad0[_0x9d46('0x43')][_0x9d46('0x44')]};});_0x3a2051['model']=_[_0x9d46('0x40')](_0x3b714c,_0x9d46('0x3b'));_0x3a2051[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x2b67b9[_0x9d46('0x45')]);_0x3a2051['filters']=_[_0x9d46('0x47')](_0x3a2051[_0x9d46('0x48')],_0x3a2051['query']);_0x2c8716[_0x9d46('0x49')]=_['intersection'](_0x3a2051[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x4a')]));_0x2c8716[_0x9d46('0x49')]=_0x2c8716[_0x9d46('0x49')][_0x9d46('0x4b')]?_0x2c8716[_0x9d46('0x49')]:_0x3a2051[_0x9d46('0x48')];if(!_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x4c')](_0x9d46('0x4d'))){_0x2c8716['limit']=qs[_0x9d46('0x2f')](_0x2b67b9[_0x9d46('0x45')]['limit']);_0x2c8716[_0x9d46('0x2d')]=qs[_0x9d46('0x2d')](_0x2b67b9[_0x9d46('0x45')]['offset']);}_0x2c8716[_0x9d46('0x4e')]=qs['sort'](_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x4f')]);_0x2c8716[_0x9d46('0x50')]=qs['filters'](_[_0x9d46('0x51')](_0x2b67b9[_0x9d46('0x45')],_0x3a2051[_0x9d46('0x52')]),_0x3b714c);if(_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x53')]){_0x2c8716['where']=_[_0x9d46('0x54')](_0x2c8716[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x3b714c,function(_0x1f540a){if(_0x1f540a['type']!==_0x9d46('0x55')){var _0xa085df={};_0xa085df[_0x1f540a[_0x9d46('0x3b')]]={'$like':'%'+_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0xa085df;}})});}_0x2c8716=_['merge']({},_0x2c8716,_0x2b67b9[_0x9d46('0x56')]);var _0x2958b2={'where':_0x2c8716[_0x9d46('0x50')]};return db[_0x9d46('0x41')]['count'](_0x2958b2)[_0x9d46('0x1f')](function(_0x78bbb5){_0x10bb06[_0x9d46('0x30')]=_0x78bbb5;if(_0x2b67b9[_0x9d46('0x45')][_0x9d46('0x57')]){_0x2c8716[_0x9d46('0x58')]=[{'all':!![]}];}return db[_0x9d46('0x41')][_0x9d46('0x59')](_0x2c8716);})['then'](function(_0x95b4d3){_0x10bb06[_0x9d46('0x5a')]=_0x95b4d3;return _0x10bb06;})['then'](respondWithFilteredResult(_0x552298,_0x2c8716))[_0x9d46('0x29')](handleError(_0x552298,null));};exports['show']=function(_0x364eb6,_0x519718){var _0x10ec1a={'raw':![],'where':{'id':_0x364eb6[_0x9d46('0x5b')]['id']},'include':[{'model':db[_0x9d46('0x3e')],'as':_0x9d46('0x3f')}]},_0x5b620c={};_0x5b620c[_0x9d46('0x48')]=_[_0x9d46('0x46')](db[_0x9d46('0x41')]['rawAttributes']);_0x5b620c[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x364eb6['query']);_0x5b620c['filters']=_[_0x9d46('0x47')](_0x5b620c['model'],_0x5b620c[_0x9d46('0x45')]);_0x10ec1a[_0x9d46('0x49')]=_[_0x9d46('0x47')](_0x5b620c[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x364eb6[_0x9d46('0x45')][_0x9d46('0x4a')]));_0x10ec1a[_0x9d46('0x49')]=_0x10ec1a['attributes'][_0x9d46('0x4b')]?_0x10ec1a[_0x9d46('0x49')]:_0x5b620c[_0x9d46('0x48')];if(_0x364eb6[_0x9d46('0x45')]['includeAll']){_0x10ec1a[_0x9d46('0x58')]=[{'all':!![]}];}_0x10ec1a=_[_0x9d46('0x54')]({},_0x10ec1a,_0x364eb6['options']);return db['SmsAccount']['find'](_0x10ec1a)[_0x9d46('0x1f')](handleEntityNotFound(_0x519718,null))['then'](respondWithResult(_0x519718,null))[_0x9d46('0x29')](handleError(_0x519718,null));};exports[_0x9d46('0x5c')]=function(_0x2d9d46,_0x45ad77){return db[_0x9d46('0x41')][_0x9d46('0x5c')](_0x2d9d46[_0x9d46('0x5d')],{})['then'](function(_0x357628){var _0x273908=_0x2d9d46[_0x9d46('0x5e')]['get']({'plain':!![]});if(!_0x273908)throw new Error(_0x9d46('0x5f'));if(_0x273908['role']==='user'){var _0x4dec4a=_0x357628['get']({'plain':!![]});var _0x3e0268=_0x9d46('0x60');return db[_0x9d46('0x61')]['find']({'where':{'name':_0x3e0268,'userProfileId':_0x273908[_0x9d46('0x62')]},'raw':!![]})[_0x9d46('0x1f')](function(_0x1faee9){if(_0x1faee9&&_0x1faee9['autoAssociation']===0x0){return db[_0x9d46('0x38')][_0x9d46('0x5c')]({'name':_0x4dec4a[_0x9d46('0x3b')],'resourceId':_0x4dec4a['id'],'type':_0x1faee9[_0x9d46('0x3b')],'sectionId':_0x1faee9['id']},{})[_0x9d46('0x1f')](function(){return _0x357628;});}else{return _0x357628;}})[_0x9d46('0x29')](function(_0x3a11ce){logger[_0x9d46('0x24')](_0x9d46('0x63'),_0x3a11ce);throw _0x3a11ce;});}return _0x357628;})[_0x9d46('0x1f')](respondWithResult(_0x45ad77,0xc9))['catch'](handleError(_0x45ad77,null));};exports[_0x9d46('0x35')]=function(_0x554096,_0x2e6876){if(_0x554096[_0x9d46('0x5d')]['id']){delete _0x554096[_0x9d46('0x5d')]['id'];}return db['SmsAccount'][_0x9d46('0x64')]({'where':{'id':_0x554096['params']['id']},'include':[{'model':db[_0x9d46('0x3e')],'as':_0x9d46('0x3f')}]})[_0x9d46('0x1f')](handleEntityNotFound(_0x2e6876,null))[_0x9d46('0x1f')](saveUpdates(_0x554096[_0x9d46('0x5d')],null))[_0x9d46('0x1f')](respondWithResult(_0x2e6876,null))['catch'](handleError(_0x2e6876,null));};exports[_0x9d46('0x36')]=function(_0xd9a94,_0x550074){return db['SmsAccount'][_0x9d46('0x64')]({'where':{'id':_0xd9a94[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x550074,null))[_0x9d46('0x1f')](removeEntity(_0x550074,null))['catch'](handleError(_0x550074,null));};exports['describe']=function(_0x43c49a,_0x1f4ba4){return db[_0x9d46('0x41')][_0x9d46('0x65')]()['then'](respondWithResult(_0x1f4ba4,null))[_0x9d46('0x29')](handleError(_0x1f4ba4,null));};exports[_0x9d46('0x66')]=function(_0x5b01fa,_0x1fe090,_0x4e878e){if(_0x5b01fa[_0x9d46('0x5d')]['id']){delete _0x5b01fa['body']['id'];}return db['SmsAccount']['find']({'where':{'id':_0x5b01fa['params']['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1fe090,null))['then'](function(_0x5150dd){if(_0x5150dd){_0x5b01fa[_0x9d46('0x5d')][_0x9d46('0x67')]=_0x5150dd['id'];return db[_0x9d46('0x68')]['create'](_0x5b01fa[_0x9d46('0x5d')]);}})['then'](respondWithResult(_0x1fe090,null))[_0x9d46('0x29')](handleError(_0x1fe090,null));};exports['getDispositions']=function(_0x287d7f,_0x55a72c,_0xf4da0){var _0x2133a2={'raw':![],'where':{}};var _0x2e2c1a={};var _0x1cabb6={'count':0x0,'rows':[]};return db['SmsAccount'][_0x9d46('0x69')]({'where':{'id':_0x287d7f['params']['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x55a72c,null))[_0x9d46('0x1f')](function(_0x274afa){if(_0x274afa){_0x2e2c1a['model']=_['keys'](db[_0x9d46('0x68')][_0x9d46('0x42')]);_0x2e2c1a[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x287d7f['query']);_0x2e2c1a['filters']=_[_0x9d46('0x47')](_0x2e2c1a[_0x9d46('0x48')],_0x2e2c1a[_0x9d46('0x45')]);_0x2133a2[_0x9d46('0x49')]=_['intersection'](_0x2e2c1a[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x287d7f[_0x9d46('0x45')][_0x9d46('0x4a')]));_0x2133a2[_0x9d46('0x49')]=_0x2133a2[_0x9d46('0x49')][_0x9d46('0x4b')]?_0x2133a2['attributes']:_0x2e2c1a[_0x9d46('0x48')];if(!_0x287d7f[_0x9d46('0x45')][_0x9d46('0x4c')](_0x9d46('0x4d'))){_0x2133a2['limit']=qs['limit'](_0x287d7f[_0x9d46('0x45')][_0x9d46('0x2f')]);_0x2133a2[_0x9d46('0x2d')]=qs[_0x9d46('0x2d')](_0x287d7f[_0x9d46('0x45')][_0x9d46('0x2d')]);}_0x2133a2['order']=qs['sort'](_0x287d7f[_0x9d46('0x45')][_0x9d46('0x4f')]);_0x2133a2[_0x9d46('0x50')]=qs[_0x9d46('0x52')](_['pick'](_0x287d7f[_0x9d46('0x45')],_0x2e2c1a[_0x9d46('0x52')]));_0x2133a2[_0x9d46('0x50')][_0x9d46('0x67')]=_0x274afa['id'];if(_0x287d7f['query'][_0x9d46('0x53')]){_0x2133a2[_0x9d46('0x50')]=_[_0x9d46('0x54')](_0x2133a2[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x2133a2[_0x9d46('0x49')],function(_0x4a100f){var _0x4086c1={};_0x4086c1[_0x4a100f]={'$like':'%'+_0x287d7f[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0x4086c1;})});}_0x2133a2=_['merge']({},_0x2133a2,_0x287d7f[_0x9d46('0x56')]);return db[_0x9d46('0x68')][_0x9d46('0x30')]({'where':_0x2133a2[_0x9d46('0x50')]})['then'](function(_0x4754c2){_0x1cabb6[_0x9d46('0x30')]=_0x4754c2;if(_0x287d7f['query'][_0x9d46('0x57')]){_0x2133a2['include']=[{'all':!![]}];}return db['Disposition'][_0x9d46('0x59')](_0x2133a2);})[_0x9d46('0x1f')](function(_0x2ff3ed){_0x1cabb6[_0x9d46('0x5a')]=_0x2ff3ed;return _0x1cabb6;});}})['then'](respondWithFilteredResult(_0x55a72c,_0x2133a2))[_0x9d46('0x29')](handleError(_0x55a72c,null));};exports[_0x9d46('0x6a')]=function(_0x5ba9a4,_0x20ea3b,_0x55cc64){return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x5ba9a4[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x20ea3b,null))[_0x9d46('0x1f')](function(_0x32bf75){if(_0x32bf75){return _0x32bf75[_0x9d46('0x6a')](_0x5ba9a4[_0x9d46('0x45')][_0x9d46('0x6b')]);}})[_0x9d46('0x1f')](respondWithStatusCode(_0x20ea3b,null))[_0x9d46('0x29')](handleError(_0x20ea3b,null));};exports[_0x9d46('0x6c')]=function(_0xdd1d0b,_0x2f222d,_0x5491f9){if(_0xdd1d0b[_0x9d46('0x5d')]['id']){delete _0xdd1d0b[_0x9d46('0x5d')]['id'];}return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0xdd1d0b[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x2f222d,null))[_0x9d46('0x1f')](function(_0x43713d){if(_0x43713d){_0xdd1d0b[_0x9d46('0x5d')][_0x9d46('0x67')]=_0x43713d['id'];return db[_0x9d46('0x6d')][_0x9d46('0x5c')](_0xdd1d0b[_0x9d46('0x5d')]);}})[_0x9d46('0x1f')](respondWithResult(_0x2f222d,null))['catch'](handleError(_0x2f222d,null));};exports[_0x9d46('0x6e')]=function(_0xc48405,_0x40c5e2,_0x4e00bd){var _0x1fa9be={'raw':![],'where':{}};var _0x3c7d95={};var _0x5873f0={'count':0x0,'rows':[]};return db[_0x9d46('0x41')][_0x9d46('0x69')]({'where':{'id':_0xc48405[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x40c5e2,null))[_0x9d46('0x1f')](function(_0x236d91){if(_0x236d91){_0x3c7d95[_0x9d46('0x48')]=_[_0x9d46('0x46')](db[_0x9d46('0x6d')][_0x9d46('0x42')]);_0x3c7d95['query']=_['keys'](_0xc48405[_0x9d46('0x45')]);_0x3c7d95[_0x9d46('0x52')]=_[_0x9d46('0x47')](_0x3c7d95[_0x9d46('0x48')],_0x3c7d95[_0x9d46('0x45')]);_0x1fa9be[_0x9d46('0x49')]=_[_0x9d46('0x47')](_0x3c7d95['model'],qs[_0x9d46('0x4a')](_0xc48405[_0x9d46('0x45')][_0x9d46('0x4a')]));_0x1fa9be[_0x9d46('0x49')]=_0x1fa9be[_0x9d46('0x49')]['length']?_0x1fa9be[_0x9d46('0x49')]:_0x3c7d95[_0x9d46('0x48')];if(!_0xc48405[_0x9d46('0x45')][_0x9d46('0x4c')](_0x9d46('0x4d'))){_0x1fa9be[_0x9d46('0x2f')]=qs[_0x9d46('0x2f')](_0xc48405[_0x9d46('0x45')]['limit']);_0x1fa9be[_0x9d46('0x2d')]=qs['offset'](_0xc48405['query'][_0x9d46('0x2d')]);}_0x1fa9be[_0x9d46('0x4e')]=qs['sort'](_0xc48405[_0x9d46('0x45')][_0x9d46('0x4f')]);_0x1fa9be[_0x9d46('0x50')]=qs[_0x9d46('0x52')](_[_0x9d46('0x51')](_0xc48405[_0x9d46('0x45')],_0x3c7d95[_0x9d46('0x52')]));_0x1fa9be['where'][_0x9d46('0x67')]=_0x236d91['id'];if(_0xc48405['query']['filter']){_0x1fa9be[_0x9d46('0x50')]=_[_0x9d46('0x54')](_0x1fa9be[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x1fa9be[_0x9d46('0x49')],function(_0x131d0a){var _0x4b3b37={};_0x4b3b37[_0x131d0a]={'$like':'%'+_0xc48405[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0x4b3b37;})});}_0x1fa9be=_[_0x9d46('0x54')]({},_0x1fa9be,_0xc48405[_0x9d46('0x56')]);return db[_0x9d46('0x6d')][_0x9d46('0x30')]({'where':_0x1fa9be['where']})[_0x9d46('0x1f')](function(_0x5ebd5f){_0x5873f0['count']=_0x5ebd5f;if(_0xc48405['query']['includeAll']){_0x1fa9be[_0x9d46('0x58')]=[{'all':!![]}];}return db[_0x9d46('0x6d')][_0x9d46('0x59')](_0x1fa9be);})[_0x9d46('0x1f')](function(_0x8e6531){_0x5873f0[_0x9d46('0x5a')]=_0x8e6531;return _0x5873f0;});}})[_0x9d46('0x1f')](respondWithFilteredResult(_0x40c5e2,_0x1fa9be))[_0x9d46('0x29')](handleError(_0x40c5e2,null));};exports[_0x9d46('0x6f')]=function(_0x4c0e4a,_0x48c6ce,_0x34be2b){return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x4c0e4a[_0x9d46('0x5b')]['id']}})['then'](handleEntityNotFound(_0x48c6ce,null))[_0x9d46('0x1f')](function(_0x183088){if(_0x183088){return _0x183088['removeAnswers'](_0x4c0e4a[_0x9d46('0x45')][_0x9d46('0x6b')]);}})[_0x9d46('0x1f')](respondWithStatusCode(_0x48c6ce,null))[_0x9d46('0x29')](handleError(_0x48c6ce,null));};exports[_0x9d46('0x70')]=function(_0x32d59a,_0x1cce9b,_0x37b425){var _0x54ddfb={'channel':'sms'};var _0x2bde1d=[];var _0x5f3d08=[];var _0x455be9={};return db['SmsAccount'][_0x9d46('0x64')]({'where':{'id':_0x32d59a[_0x9d46('0x5b')]['id']},'include':[{'model':db[_0x9d46('0x71')],'as':'Applications'}]})[_0x9d46('0x1f')](handleEntityNotFound(_0x1cce9b,null))['then'](function(_0x56ca75){_0x54ddfb[_0x9d46('0x72')]=_0x56ca75;_0x54ddfb[_0x9d46('0x73')]=_['orderBy'](_0x56ca75[_0x9d46('0x74')],[_0x9d46('0x75')],[_0x9d46('0x76')]);if(_0x54ddfb[_0x9d46('0x72')]['Applications']){delete _0x54ddfb['account'][_0x9d46('0x74')];}return db['CmContact'][_0x9d46('0x65')]();})[_0x9d46('0x1f')](function(_0x5e1e25){if(!_0x5e1e25){throw new db['Sequelize'][(_0x9d46('0x77'))](_0x9d46('0x78'));}_0x2bde1d=_[_0x9d46('0x79')](_[_0x9d46('0x46')](_0x5e1e25),['createdAt',_0x9d46('0x7a')]);_0x5f3d08=_['difference'](_[_0x9d46('0x46')](_0x5e1e25),['createdAt',_0x9d46('0x7a'),_0x9d46('0x7b'),'ListId']);_0x54ddfb[_0x9d46('0x5d')]={'mapKey':'mobile'};if(_0x54ddfb[_0x9d46('0x72')]['type']){switch(_0x54ddfb[_0x9d46('0x72')][_0x9d46('0x43')]){case'twilio':_0x54ddfb[_0x9d46('0x5d')]['from']=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x7c')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x7d')];_0x54ddfb['body'][_0x9d46('0x7e')]=_0x32d59a['body'][_0x9d46('0x7f')];break;case _0x9d46('0x80'):_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]='+'+_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x82')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x83')];break;case'connectel':_0x54ddfb[_0x9d46('0x5d')]['from']=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x81')];_0x54ddfb['body']['body']=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x26')];break;case'clicksend':_0x54ddfb['body'][_0x9d46('0x81')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x81')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x5d')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x7e')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x84')];break;case _0x9d46('0x85'):_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]=_0x32d59a[_0x9d46('0x5d')]['From'];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x86')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x7e')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x87')];break;case _0x9d46('0x88'):_0x54ddfb['body'][_0x9d46('0x81')]='+'+_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x89')][0x0][_0x9d46('0x81')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')]['results'][0x0][_0x9d46('0x83')];_0x54ddfb[_0x9d46('0x5d')]['messageId']=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x89')][0x0][_0x9d46('0x7e')];break;case _0x9d46('0x8a'):_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x8b')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x8c')]['message'];break;case _0x9d46('0x8d'):_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]=_0x32d59a[_0x9d46('0x5d')]['fromNumber'];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')]['text'];_0x54ddfb['body'][_0x9d46('0x7e')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x8e')];break;case'bandwidth':_0x54ddfb['body']['messageId']=_0x32d59a[_0x9d46('0x5d')][0x0][_0x9d46('0x26')]['id'];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]=_0x32d59a[_0x9d46('0x5d')][0x0][_0x9d46('0x26')][_0x9d46('0x81')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][0x0]['message'][_0x9d46('0x83')];break;case _0x9d46('0x8f'):_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')]=_0x32d59a['body'][_0x9d46('0x81')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')]=_0x32d59a[_0x9d46('0x5d')][_0x9d46('0x26')];_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x7e')]=_0x32d59a[_0x9d46('0x5d')]['refid'];break;}}if(_0x54ddfb[_0x9d46('0x5d')]['id']){delete _0x54ddfb['body']['id'];}if(_['isNil'](_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x81')])){throw new db[(_0x9d46('0x90'))][(_0x9d46('0x77'))](_0x9d46('0x91'));}if(_[_0x9d46('0x92')](_0x54ddfb[_0x9d46('0x5d')]['body'])||_0x54ddfb['body'][_0x9d46('0x5d')]===''){throw new db['Sequelize'][(_0x9d46('0x77'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x54ddfb['body'][_0x9d46('0x93')])){throw new db[(_0x9d46('0x90'))][(_0x9d46('0x77'))](_0x9d46('0x94')+_0x5f3d08);}if(!_[_0x9d46('0x95')](_0x5f3d08,_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x93')])){throw new db[(_0x9d46('0x90'))][(_0x9d46('0x77'))](_0x9d46('0x96')+_0x5f3d08);}_0x455be9[_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x93')]]=_0x54ddfb[_0x9d46('0x5d')]['from'];return db[_0x9d46('0x97')][_0x9d46('0x64')]({'where':{'id':_0x54ddfb['account'][_0x9d46('0x98')]},'include':[{'model':db[_0x9d46('0x99')],'as':'Contacts','where':_0x455be9,'limit':0x1,'order':[[_0x9d46('0x7a'),_0x9d46('0x9a')]]}]});})[_0x9d46('0x1f')](handleEntityNotFound(_0x1cce9b,null))['then'](function(_0x11014e){if(_0x11014e){_0x54ddfb[_0x9d46('0x9b')]=_[_0x9d46('0x9c')](_0x11014e,['Contacts']);if(_0x11014e['Contacts'][_0x9d46('0x4b')]){return _0x11014e[_0x9d46('0x9d')][0x0];}var _0x5f30a7=_[_0x9d46('0x16')](_0x54ddfb['body'],{'firstName':_0x54ddfb['body'][_0x9d46('0x81')],'ListId':_0x11014e['id']});_0x5f30a7[_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x93')]]=_0x54ddfb['body'][_0x9d46('0x81')];return db[_0x9d46('0x99')][_0x9d46('0x5c')](_0x5f30a7,{'fields':_0x2bde1d,'raw':!![]});}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1cce9b,null))[_0x9d46('0x1f')](function(_0x4503e3){if(_0x4503e3){_0x54ddfb['contact']=_0x4503e3;var _0x18523b={'ContactId':_0x4503e3['id'],'phone':_0x54ddfb[_0x9d46('0x5d')]['from'],'SmsAccountId':_0x32d59a['params']['id']};var _0x57b90d={'ContactId':_0x4503e3['id'],'SmsAccountId':_0x32d59a['params']['id'],'closed':![]};return db['SmsInteraction'][_0x9d46('0x64')]({'where':_0x57b90d})[_0x9d46('0x1f')](function(_0x356eb9){if(_0x356eb9){return[_0x356eb9,![]];}return db[_0x9d46('0x9e')][_0x9d46('0x5c')](_0x18523b)[_0x9d46('0x1f')](function(_0x285416){return[_0x285416,!![]];});});}})[_0x9d46('0x9f')](function(_0xb25d2,_0x50138e){_0x54ddfb[_0x9d46('0xa0')]=_0xb25d2[_0x9d46('0x37')]({'plain':!![]});_0x54ddfb['interaction']['created']=![];if(_0x50138e){if(_0x54ddfb[_0x9d46('0x72')][_0x9d46('0xa1')]){_0x54ddfb[_0x9d46('0x73')][_0x9d46('0xa2')]({'id':0x0,'priority':_0x54ddfb[_0x9d46('0x73')]['length']+0x1,'app':_0x9d46('0xa3'),'appdata':_0x9d46('0xa4'),'interval':_0x9d46('0xa5')});}_0x54ddfb[_0x9d46('0xa0')][_0x9d46('0xa6')]=!![];}return db[_0x9d46('0xa7')][_0x9d46('0x5c')]({'phone':_0x54ddfb['body'][_0x9d46('0x81')],'messageId':_0x54ddfb[_0x9d46('0x5d')]['messageId'],'body':_0x54ddfb[_0x9d46('0x5d')][_0x9d46('0x5d')],'SmsAccountId':_0x32d59a[_0x9d46('0x5b')]['id'],'SmsInteractionId':_0xb25d2['id'],'direction':'in','ContactId':_0xb25d2[_0x9d46('0xa8')],'AttachmentId':_0x54ddfb['body'][_0x9d46('0xa9')]});})[_0x9d46('0x1f')](function(_0x410e78){_0x54ddfb['message']=_0x410e78;if(_0x54ddfb[_0x9d46('0xa0')][_0x9d46('0xaa')]){return db['User'][_0x9d46('0x64')]({'attributes':['id',_0x9d46('0x3b')],'where':{'id':_0x54ddfb[_0x9d46('0xa0')][_0x9d46('0xaa')]}})['then'](function(_0x106420){if(_0x106420){_0x54ddfb[_0x9d46('0x73')][_0x9d46('0xab')]({'id':0x0,'priority':0x0,'app':_0x9d46('0xac'),'appdata':_0x106420[_0x9d46('0x3b')]+','+(_0x54ddfb[_0x9d46('0x72')]['waitForTheAssignedAgent']||0xa),'interval':_0x9d46('0xa5')});}return respondWithRpcPromise('Start',_0x9d46('0xad'),_0x54ddfb);});}return respondWithRpcPromise(_0x9d46('0xae'),'startRouting',_0x54ddfb);})[_0x9d46('0x1f')](function(_0x25e933){if(_0x25e933){var _0x4e1e6f=0xc8;var _0x5c9ffe='receiveMessage';logger[_0x9d46('0x27')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x5c9ffe,_0x4e1e6f,_0x9d46('0xaf'));logger[_0x9d46('0x21')](_0x9d46('0xb0'),_0x5c9ffe,_0x4e1e6f,'entity\x20found',JSON[_0x9d46('0x23')](_0x25e933));if(_0x54ddfb[_0x9d46('0x72')][_0x9d46('0x43')]===_0x9d46('0xb1')){return _0x1cce9b[_0x9d46('0x2b')](_0x4e1e6f)[_0x9d46('0x31')](_0x9d46('0xb2'),_0x9d46('0xb3'))[_0x9d46('0x3c')](_0x9d46('0xb4'));}else{return _0x1cce9b['status'](_0x4e1e6f)['json'](_0x25e933);}}})[_0x9d46('0x29')](handleError(_0x1cce9b,null));};exports['addApplications']=function(_0x5654c1,_0x3623f8){var _0x1965fe=_0x5654c1[_0x9d46('0x5b')]['id'];var _0x1f30ea=_0x5654c1[_0x9d46('0x5d')];var _0x2ccfc4=0xc8;var _0x596d2a=null;return db['sequelize']['transaction']({'isolationLevel':db[_0x9d46('0xb5')]['Transaction'][_0x9d46('0xb6')]['READ_COMMITTED']},function(_0x52d2c4){return db[_0x9d46('0x41')]['findOne']({'where':{'id':_0x1965fe},'transaction':_0x52d2c4})[_0x9d46('0x1f')](function(_0x2e7748){if(_0x2e7748){return db[_0x9d46('0x71')][_0x9d46('0x36')]({'where':{'SmsAccountId':_0x1965fe},'transaction':_0x52d2c4})[_0x9d46('0x1f')](function(){var _0x534f77=_['map'](_0x1f30ea,function(_0x57c0e6){_0x57c0e6[_0x9d46('0x67')]=_0x1965fe;return _0x57c0e6;});return db[_0x9d46('0x71')][_0x9d46('0xb7')](_0x534f77,{'transaction':_0x52d2c4});});}else{_0x2ccfc4=0x194;_0x596d2a=[];}});})[_0x9d46('0x1f')](function(){if(_0x2ccfc4!==0x194){return db[_0x9d46('0x71')][_0x9d46('0xb8')]({'where':{'SmsAccountId':_0x1965fe},'order':_0x9d46('0x75')})[_0x9d46('0x1f')](function(_0xf9610b){_0x596d2a=_0xf9610b;});}})[_0x9d46('0x29')](function(_0x38794b){_0x2ccfc4=0x1f4;logger[_0x9d46('0x24')](_0x38794b[_0x9d46('0x3a')]);if(_0x38794b['name']){delete _0x38794b[_0x9d46('0x3b')];}_0x596d2a=_0x38794b;})[_0x9d46('0xb9')](function(){if(_0x596d2a===null){_0x3623f8[_0x9d46('0x2a')](_0x2ccfc4);}else{if(_0x2ccfc4===0x1f4){_0x3623f8[_0x9d46('0x2b')](_0x2ccfc4)[_0x9d46('0x3c')](_0x596d2a);}else{_0x3623f8[_0x9d46('0x2b')](_0x2ccfc4)['json'](_0x596d2a);}}});};exports[_0x9d46('0xba')]=function(_0x38dd1a,_0x33b253,_0x24cce3){var _0x2d3e26={};var _0x52cce6={};var _0x1f42aa;var _0x33da10;return db['SmsAccount'][_0x9d46('0x69')]({'where':{'id':_0x38dd1a[_0x9d46('0x5b')]['id']}})['then'](handleEntityNotFound(_0x33b253,null))[_0x9d46('0x1f')](function(_0x2aeead){if(_0x2aeead){_0x1f42aa=_0x2aeead;_0x52cce6['model']=_[_0x9d46('0x46')](db[_0x9d46('0x71')][_0x9d46('0x42')]);_0x52cce6[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x38dd1a[_0x9d46('0x45')]);_0x52cce6[_0x9d46('0x52')]=_[_0x9d46('0x47')](_0x52cce6[_0x9d46('0x48')],_0x52cce6['query']);_0x2d3e26[_0x9d46('0x49')]=_[_0x9d46('0x47')](_0x52cce6[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x38dd1a[_0x9d46('0x45')][_0x9d46('0x4a')]));_0x2d3e26[_0x9d46('0x49')]=_0x2d3e26[_0x9d46('0x49')][_0x9d46('0x4b')]?_0x2d3e26[_0x9d46('0x49')]:_0x52cce6[_0x9d46('0x48')];_0x2d3e26[_0x9d46('0x4e')]=qs['sort'](_0x38dd1a[_0x9d46('0x45')][_0x9d46('0x4f')]);_0x2d3e26[_0x9d46('0x50')]=qs['filters'](_['pick'](_0x38dd1a['query'],_0x52cce6[_0x9d46('0x52')]));if(_0x38dd1a[_0x9d46('0x45')]['filter']){_0x2d3e26[_0x9d46('0x50')]=_[_0x9d46('0x54')](_0x2d3e26[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x2d3e26[_0x9d46('0x49')],function(_0x251ded){var _0x528169={};_0x528169[_0x251ded]={'$like':'%'+_0x38dd1a[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0x528169;})});}_0x2d3e26=_[_0x9d46('0x54')]({},_0x2d3e26,_0x38dd1a['options']);return _0x1f42aa[_0x9d46('0xba')](_0x2d3e26);}})[_0x9d46('0x1f')](function(_0x34e418){if(_0x34e418){_0x33da10=_0x34e418['length'];if(!_0x38dd1a['query']['hasOwnProperty'](_0x9d46('0x4d'))){_0x2d3e26[_0x9d46('0x2f')]=qs[_0x9d46('0x2f')](_0x38dd1a[_0x9d46('0x45')]['limit']);_0x2d3e26[_0x9d46('0x2d')]=qs[_0x9d46('0x2d')](_0x38dd1a[_0x9d46('0x45')][_0x9d46('0x2d')]);}return _0x1f42aa['getApplications'](_0x2d3e26);}})[_0x9d46('0x1f')](function(_0x10ec0a){if(_0x10ec0a){return _0x10ec0a?{'count':_0x33da10,'rows':_0x10ec0a}:null;}})[_0x9d46('0x1f')](respondWithResult(_0x33b253,null))[_0x9d46('0x29')](handleError(_0x33b253,null));};exports[_0x9d46('0xbb')]=function(_0x12a6f4,_0x4d54f8,_0x265b53){var _0x41ca76={'raw':![],'where':{}};var _0x58659f={};var _0x272e80={'count':0x0,'rows':[]};return db[_0x9d46('0x41')][_0x9d46('0x69')]({'where':{'id':_0x12a6f4[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x4d54f8,null))['then'](function(_0x7f0092){if(_0x7f0092){_0x58659f[_0x9d46('0x48')]=_['keys'](db['SmsInteraction'][_0x9d46('0x42')]);_0x58659f[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x12a6f4[_0x9d46('0x45')]);_0x58659f[_0x9d46('0x52')]=_['intersection'](_0x58659f[_0x9d46('0x48')],_0x58659f[_0x9d46('0x45')]);_0x41ca76['attributes']=_[_0x9d46('0x47')](_0x58659f[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x12a6f4['query'][_0x9d46('0x4a')]));_0x41ca76[_0x9d46('0x49')]=_0x41ca76[_0x9d46('0x49')][_0x9d46('0x4b')]?_0x41ca76[_0x9d46('0x49')]:_0x58659f[_0x9d46('0x48')];if(!_0x12a6f4[_0x9d46('0x45')][_0x9d46('0x4c')]('nolimit')){_0x41ca76['limit']=qs['limit'](_0x12a6f4[_0x9d46('0x45')][_0x9d46('0x2f')]);_0x41ca76[_0x9d46('0x2d')]=qs[_0x9d46('0x2d')](_0x12a6f4[_0x9d46('0x45')][_0x9d46('0x2d')]);}_0x41ca76['order']=qs[_0x9d46('0x4f')](_0x12a6f4[_0x9d46('0x45')]['sort']);_0x41ca76[_0x9d46('0x50')]=qs['filters'](_[_0x9d46('0x51')](_0x12a6f4[_0x9d46('0x45')],_0x58659f[_0x9d46('0x52')]));_0x41ca76[_0x9d46('0x50')][_0x9d46('0x67')]=_0x7f0092['id'];if(_0x12a6f4['query'][_0x9d46('0x53')]){_0x41ca76['where']=_[_0x9d46('0x54')](_0x41ca76[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x41ca76[_0x9d46('0x49')],function(_0xe25519){var _0x4d0a81={};_0x4d0a81[_0xe25519]={'$like':'%'+_0x12a6f4[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0x4d0a81;})});}_0x41ca76=_[_0x9d46('0x54')]({},_0x41ca76,_0x12a6f4[_0x9d46('0x56')]);return db[_0x9d46('0x9e')][_0x9d46('0x30')]({'where':_0x41ca76[_0x9d46('0x50')]})[_0x9d46('0x1f')](function(_0x54aaee){_0x272e80[_0x9d46('0x30')]=_0x54aaee;if(_0x12a6f4['query'][_0x9d46('0x57')]){_0x41ca76[_0x9d46('0x58')]=[{'model':db[_0x9d46('0x99')],'as':_0x9d46('0xbc'),'required':![]},{'model':db[_0x9d46('0xbd')],'as':_0x9d46('0xbe'),'attributes':[_0x9d46('0x3b'),_0x9d46('0xbf'),_0x9d46('0xc0')],'required':![]},{'model':db[_0x9d46('0xc1')],'as':_0x9d46('0xc2'),'attributes':['id','name',_0x9d46('0xc3')],'where':_0x12a6f4['query'][_0x9d46('0xc4')]?{'id':_0x12a6f4[_0x9d46('0x45')][_0x9d46('0xc4')]}:undefined,'required':_0x12a6f4[_0x9d46('0x45')][_0x9d46('0xc4')]?!![]:![]}];}return db[_0x9d46('0x9e')][_0x9d46('0x59')](_0x41ca76);})[_0x9d46('0x1f')](function(_0x50be0d){_0x272e80[_0x9d46('0x5a')]=_0x50be0d;return _0x272e80;});}})[_0x9d46('0x1f')](respondWithFilteredResult(_0x4d54f8,_0x41ca76))[_0x9d46('0x29')](handleError(_0x4d54f8,null));};exports['send']=function(_0x40e800,_0x1bf2ed,_0x208c37){var _0x13733c,_0x4d1059,_0x458b14;if(_['isNil'](_0x40e800[_0x9d46('0x5d')]['body'])||_0x40e800[_0x9d46('0x5d')][_0x9d46('0x5d')]===''){throw new db[(_0x9d46('0x90'))][(_0x9d46('0x77'))](_0x9d46('0xc5'));}if(_[_0x9d46('0x92')](_0x40e800[_0x9d46('0x5d')]['to'])){throw new db[(_0x9d46('0x90'))][(_0x9d46('0x77'))]('to\x20is\x20mandatory');}_0x13733c=_0x40e800[_0x9d46('0x5d')]['to'];return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x40e800[_0x9d46('0x5b')]['id']},'include':[{'model':db['CmList'],'as':_0x9d46('0xc6'),'include':[{'model':db['CmContact'],'as':_0x9d46('0x9d'),'where':{'mobile':_0x13733c},'limit':0x1,'order':[['updatedAt','DESC']]}]}]})[_0x9d46('0x1f')](handleEntityNotFound(_0x1bf2ed,null))['then'](function(_0x145f86){if(_0x145f86&&_0x145f86[_0x9d46('0xc6')]){_0x4d1059=_0x145f86[_0x9d46('0x37')]({'plain':!![]});if(_0x4d1059[_0x9d46('0xc6')]&&_0x4d1059[_0x9d46('0xc6')][_0x9d46('0x9d')][_0x9d46('0x4b')]){return _0x4d1059[_0x9d46('0xc6')][_0x9d46('0x9d')][0x0];}return db[_0x9d46('0x99')][_0x9d46('0x5c')](_[_0x9d46('0x16')](_0x40e800[_0x9d46('0x5d')],{'firstName':_0x13733c,'mobile':_0x13733c,'phone':_0x13733c,'ListId':_0x4d1059[_0x9d46('0x98')]}));}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1bf2ed,null))[_0x9d46('0x1f')](function(_0x205651){if(_0x205651){_0x458b14=_0x205651;return db['SmsInteraction'][_0x9d46('0x64')]({'where':{'ContactId':_0x458b14['id'],'closed':![],'SmsAccountId':_0x4d1059['id']}})[_0x9d46('0x1f')](function(_0x4a3d25){if(_0x4a3d25){return[_0x4a3d25,![]];}return db[_0x9d46('0x9e')][_0x9d46('0x5c')]({'UserId':_0x40e800['user']['id'],'ContactId':_0x458b14['id'],'SmsAccountId':_0x4d1059['id'],'phone':_0x13733c,'firstMsgDirection':_0x9d46('0xc7'),'Messages':[_['merge'](_0x40e800[_0x9d46('0x5d')],{'read':![],'body':_0x40e800[_0x9d46('0x5d')][_0x9d46('0x5d')],'phone':_0x13733c,'SmsAccountId':_0x4d1059['id'],'UserId':_0x40e800['user']['id'],'ContactId':_0x458b14['id']})]},{'include':[{'model':db[_0x9d46('0xa7')],'as':_0x9d46('0xc8')}]})[_0x9d46('0x1f')](function(_0x17a8cc){return[_0x17a8cc,!![]];});});}})[_0x9d46('0x9f')](function(_0x311c61,_0xb0e70f){if(_0xb0e70f){return _0x311c61;}return db[_0x9d46('0xa7')]['create'](_[_0x9d46('0x54')](_0x40e800[_0x9d46('0x5d')],{'read':![],'body':_0x40e800[_0x9d46('0x5d')][_0x9d46('0x5d')],'phone':_0x13733c,'SmsAccountId':_0x4d1059['id'],'SmsInteractionId':_0x311c61['id'],'UserId':_0x40e800[_0x9d46('0x5e')]['id'],'ContactId':_0x458b14['id']}))[_0x9d46('0x1f')](function(_0x3fe4e9){_0x311c61[_0x9d46('0xc9')][_0x9d46('0xc8')]=[];_0x311c61['dataValues'][_0x9d46('0xc8')][_0x9d46('0xa2')](_0x3fe4e9[_0x9d46('0xc9')]);return _0x311c61;});})[_0x9d46('0x1f')](respondWithResult(_0x1bf2ed,null))[_0x9d46('0x29')](handleError(_0x1bf2ed,null));};exports['status']=function(_0x2daff7,_0x1b6f1e,_0xc71b28){if(_0x2daff7[_0x9d46('0x5d')]['id']){delete _0x2daff7['body']['id'];}var _0x411c7b,_0x3c9c7e,_0xfd4d39;return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x2daff7[_0x9d46('0x5b')]['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1b6f1e,null))[_0x9d46('0x1f')](function(_0x2870fd){if(_0x2870fd){_0xfd4d39=_0x2870fd;logger[_0x9d46('0x21')]('SmsAccount,\x20%s,\x20%s,\x20%s','status','received\x20delivery\x20report\x20from',_0x2870fd[_0x9d46('0x43')],util[_0x9d46('0xca')](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));switch(_0x2870fd[_0x9d46('0x43')]){case _0x9d46('0x80'):if(_0x2daff7[_0x9d46('0x5d')][_0x9d46('0xcb')]&&_0x2daff7[_0x9d46('0x5d')]['status']){_0x3c9c7e=_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x2b')];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7[_0x9d46('0x5d')]['skebby_dispatch_id']}});}break;case'connectel':if(_0x2daff7['body']['requestid']&&_0x2daff7['body'][_0x9d46('0xcc')]){_0x3c9c7e=_0x2daff7['body'][_0x9d46('0xcc')];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7['body'][_0x9d46('0xcd')]}});}break;case _0x9d46('0xce'):if(_0x2daff7['body'][_0x9d46('0x84')]&&_0x2daff7[_0x9d46('0x5d')][_0x9d46('0xcf')]){_0x3c9c7e=_0x2daff7[_0x9d46('0x5d')]['status_code'];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7[_0x9d46('0x5d')]['message_id']}});}break;case _0x9d46('0x88'):var _0x402024=_0x2daff7[_0x9d46('0x5d')]['results'][0x0];if(_0x402024['messageId']&&_0x402024[_0x9d46('0x2b')]['groupName']==='DELIVERED'){_0x3c9c7e=_0x402024['status'][_0x9d46('0xd0')];return db[_0x9d46('0xa7')]['find']({'where':{'messageId':_0x402024[_0x9d46('0x7e')]}});}break;case _0x9d46('0x8d'):if(_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x7e')]&&_0x2daff7[_0x9d46('0x5d')]['status']){_0x3c9c7e=_0x2daff7[_0x9d46('0x5d')]['status'];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x7e')]}});}break;case'bandwidth':if(_0x2daff7[_0x9d46('0x5d')][0x0][_0x9d46('0x26')]['id']){_0x3c9c7e=_0x2daff7[_0x9d46('0x5d')][0x0][_0x9d46('0x43')];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7['body'][0x0][_0x9d46('0x26')]['id']}});}break;case _0x9d46('0x8f'):if(_0x2daff7[_0x9d46('0x5d')]['redif']&&_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x2b')]){_0x3c9c7e=_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x2b')];return db[_0x9d46('0xa7')][_0x9d46('0x64')]({'where':{'messageId':_0x2daff7[_0x9d46('0x5d')][_0x9d46('0xd1')]}});}break;}}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1b6f1e,null))[_0x9d46('0x1f')](function(_0x25d960){if(_0x25d960){_0x411c7b=_0x25d960;switch(_0xfd4d39[_0x9d46('0x43')]){case _0x9d46('0x80'):if(_0x3c9c7e===_0x9d46('0xd2')){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),'skebby',util[_0x9d46('0xca')](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));}break;case _0x9d46('0xd4'):if(_0x3c9c7e==='1'){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),_0x9d46('0x80'),util[_0x9d46('0xca')](_0x2daff7['body'],{'showHidden':![],'depth':null}));}break;case _0x9d46('0xce'):if(!_0x2daff7[_0x9d46('0x5d')][_0x9d46('0xd5')]&&_0x3c9c7e>=0xc8&&_0x3c9c7e<=0xce){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),_0x9d46('0xce'),util[_0x9d46('0xca')](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));}break;case _0x9d46('0x88'):var _0x15e28f=_0x2daff7[_0x9d46('0x5d')][_0x9d46('0x89')][0x0];if(_0x15e28f['status'][_0x9d46('0xd0')]==='DELIVERED'){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),_0x9d46('0x88'),util[_0x9d46('0xca')](_0x2daff7['body'],{'showHidden':![],'depth':null}));}break;case _0x9d46('0x8d'):if(_0x3c9c7e=='DELIVERED_TO_GATEWAY'||_0x3c9c7e==_0x9d46('0xd6')){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),_0x9d46('0x8d'),util[_0x9d46('0xca')](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));}break;case _0x9d46('0xd7'):if(_0x3c9c7e==_0x9d46('0xd8')){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),'bandwidth',util[_0x9d46('0xca')](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));}break;case'intelepeer':if(_0x3c9c7e===_0x9d46('0xd9')||_0x3c9c7e==='ACCEPTD'){return _0x411c7b[_0x9d46('0x35')]({'read':!![]});}else{logger['error'](_0x9d46('0xd3'),_0x9d46('0x2b'),'intelepeer',util['inspect'](_0x2daff7[_0x9d46('0x5d')],{'showHidden':![],'depth':null}));}break;}return _0x411c7b;}})[_0x9d46('0x1f')](respondWithResult(_0x1b6f1e,null))['catch'](handleError(_0x1b6f1e,null));};exports[_0x9d46('0xda')]=function(_0x39f398,_0x1ac65c,_0x58ce92){var _0x3996fa,_0x8f0b4,_0x3391b7;return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x39f398[_0x9d46('0x5b')]['id']}})['then'](handleEntityNotFound(_0x1ac65c,null))[_0x9d46('0x1f')](function(_0x32c6eb){if(_0x32c6eb){_0x3391b7=_0x32c6eb;logger[_0x9d46('0x21')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x9d46('0x2b'),_0x9d46('0xdb'),_0x32c6eb['type'],util['inspect'](_0x39f398['query'],{'showHidden':![],'depth':null}));switch(_0x32c6eb[_0x9d46('0x43')]){case _0x9d46('0x8a'):if(_0x39f398[_0x9d46('0x45')][_0x9d46('0xdc')]&&_0x39f398[_0x9d46('0x45')][_0x9d46('0xdd')]){_0x8f0b4=_0x39f398['query'][_0x9d46('0xdd')];return db['SmsMessage'][_0x9d46('0x64')]({'where':{'messageId':_0x39f398['query'][_0x9d46('0xdc')]}});}break;}}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1ac65c,null))[_0x9d46('0x1f')](function(_0x35e27f){if(_0x35e27f){_0x3996fa=_0x35e27f;switch(_0x3391b7['type']){case _0x9d46('0x8a'):if(_0x8f0b4==='2'||_0x8f0b4==='6'){return _0x3996fa[_0x9d46('0x35')]({'read':!![]});}else{logger[_0x9d46('0x24')](_0x9d46('0xd3'),_0x9d46('0x2b'),_0x9d46('0x8a'),util[_0x9d46('0xca')](_0x39f398['query'],{'showHidden':![],'depth':null}));};break;}return _0x3996fa;}})[_0x9d46('0x1f')](respondWithResult(_0x1ac65c,null))[_0x9d46('0x29')](handleError(_0x1ac65c,null));};exports['addAgents']=function(_0x4817f0,_0x10019f,_0x42985f){return db[_0x9d46('0x41')][_0x9d46('0x64')]({'where':{'id':_0x4817f0['params']['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x10019f,null))['then'](function(_0x4ce66d){if(_0x4ce66d){return _0x4ce66d[_0x9d46('0xde')](_0x4817f0[_0x9d46('0x5d')][_0x9d46('0x6b')],_[_0x9d46('0x9c')](_0x4817f0[_0x9d46('0x5d')],[_0x9d46('0x6b'),'id'])||{})[_0x9d46('0x9f')](function(_0x49aeb3){for(var _0x1205a0=0x0;_0x1205a0<_0x4817f0[_0x9d46('0x5d')][_0x9d46('0x6b')][_0x9d46('0x4b')];_0x1205a0+=0x1){socket[_0x9d46('0xdf')](_0x9d46('0xe0'),{'UserId':Number(_0x4817f0[_0x9d46('0x5d')][_0x9d46('0x6b')][_0x1205a0]),'SmsAccountId':Number(_0x4817f0['params']['id'])});}return _0x49aeb3;});}})[_0x9d46('0x1f')](respondWithResult(_0x10019f,null))[_0x9d46('0x29')](handleError(_0x10019f,null));};exports['removeAgents']=function(_0x5d0cb8,_0x1b5cb4,_0x4a05aa){return db[_0x9d46('0x41')]['find']({'where':{'id':_0x5d0cb8['params']['id']}})[_0x9d46('0x1f')](handleEntityNotFound(_0x1b5cb4,null))['then'](function(_0x5c8c7c){if(_0x5c8c7c){return _0x5c8c7c['removeAgents'](_0x5d0cb8[_0x9d46('0x45')][_0x9d46('0x6b')])[_0x9d46('0x1f')](function(){if(_[_0x9d46('0xe1')](_0x5d0cb8['query'][_0x9d46('0x6b')])){for(var _0x29e8a3=0x0;_0x29e8a3<_0x5d0cb8[_0x9d46('0x45')][_0x9d46('0x6b')][_0x9d46('0x4b')];_0x29e8a3+=0x1){socket[_0x9d46('0xdf')](_0x9d46('0xe2'),{'UserId':Number(_0x5d0cb8[_0x9d46('0x45')][_0x9d46('0x6b')][_0x29e8a3]),'SmsAccountId':Number(_0x5d0cb8[_0x9d46('0x5b')]['id'])});}}else{socket[_0x9d46('0xdf')](_0x9d46('0xe2'),{'UserId':Number(_0x5d0cb8[_0x9d46('0x45')][_0x9d46('0x6b')]),'SmsAccountId':Number(_0x5d0cb8[_0x9d46('0x5b')]['id'])});}});}})[_0x9d46('0x1f')](respondWithStatusCode(_0x1b5cb4,null))[_0x9d46('0x29')](handleError(_0x1b5cb4,null));};exports[_0x9d46('0xe3')]=function(_0x299c55,_0x12ea79,_0x53fd1e){var _0x4e537a={};var _0x3a0cc0={};var _0x1e945e;var _0x46a076;return db[_0x9d46('0x41')]['findOne']({'where':{'id':_0x299c55[_0x9d46('0x5b')]['id']}})['then'](handleEntityNotFound(_0x12ea79,null))[_0x9d46('0x1f')](function(_0x2d88eb){if(_0x2d88eb){_0x1e945e=_0x2d88eb;_0x3a0cc0[_0x9d46('0x48')]=_[_0x9d46('0x46')](db[_0x9d46('0xbd')]['rawAttributes']);_0x3a0cc0[_0x9d46('0x45')]=_[_0x9d46('0x46')](_0x299c55[_0x9d46('0x45')]);_0x3a0cc0[_0x9d46('0x52')]=_['intersection'](_0x3a0cc0[_0x9d46('0x48')],_0x3a0cc0['query']);_0x4e537a[_0x9d46('0x49')]=_[_0x9d46('0x47')](_0x3a0cc0[_0x9d46('0x48')],qs[_0x9d46('0x4a')](_0x299c55['query'][_0x9d46('0x4a')]));_0x4e537a[_0x9d46('0x49')]=_0x4e537a[_0x9d46('0x49')][_0x9d46('0x4b')]?_0x4e537a[_0x9d46('0x49')]:_0x3a0cc0[_0x9d46('0x48')];_0x4e537a[_0x9d46('0x4e')]=qs['sort'](_0x299c55[_0x9d46('0x45')][_0x9d46('0x4f')]);_0x4e537a[_0x9d46('0x50')]=qs['filters'](_[_0x9d46('0x51')](_0x299c55['query'],_0x3a0cc0[_0x9d46('0x52')]));if(_0x299c55['query'][_0x9d46('0x53')]){_0x4e537a[_0x9d46('0x50')]=_[_0x9d46('0x54')](_0x4e537a[_0x9d46('0x50')],{'$or':_[_0x9d46('0x40')](_0x4e537a[_0x9d46('0x49')],function(_0x15fbdc){var _0x418872={};_0x418872[_0x15fbdc]={'$like':'%'+_0x299c55[_0x9d46('0x45')][_0x9d46('0x53')]+'%'};return _0x418872;})});}_0x4e537a=_[_0x9d46('0x54')]({},_0x4e537a,_0x299c55[_0x9d46('0x56')]);return _0x1e945e[_0x9d46('0xe3')](_0x4e537a);}})[_0x9d46('0x1f')](function(_0xcb7511){if(_0xcb7511){_0x46a076=_0xcb7511[_0x9d46('0x4b')];if(!_0x299c55[_0x9d46('0x45')][_0x9d46('0x4c')](_0x9d46('0x4d'))){_0x4e537a[_0x9d46('0x2f')]=qs[_0x9d46('0x2f')](_0x299c55[_0x9d46('0x45')][_0x9d46('0x2f')]);_0x4e537a['offset']=qs[_0x9d46('0x2d')](_0x299c55[_0x9d46('0x45')][_0x9d46('0x2d')]);}return _0x1e945e[_0x9d46('0xe3')](_0x4e537a);}})[_0x9d46('0x1f')](function(_0x254134){if(_0x254134){return _0x254134?{'count':_0x46a076,'rows':_0x254134}:null;}})[_0x9d46('0x1f')](respondWithResult(_0x12ea79,null))[_0x9d46('0x29')](handleError(_0x12ea79,null));}; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.events.js b/server/api/smsAccount/smsAccount.events.js new file mode 100644 index 0000000..3f49cf3 --- /dev/null +++ b/server/api/smsAccount/smsAccount.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4b35=['save','remove','emit','hasOwnProperty','exports','events','../../mysqldb','SmsAccount','setMaxListeners'];(function(_0x2e34c4,_0x4fb4c0){var _0xac971d=function(_0x1c16e2){while(--_0x1c16e2){_0x2e34c4['push'](_0x2e34c4['shift']());}};_0xac971d(++_0x4fb4c0);}(_0x4b35,0x95));var _0x54b3=function(_0x236ac8,_0xa798d6){_0x236ac8=_0x236ac8-0x0;var _0x1ff538=_0x4b35[_0x236ac8];return _0x1ff538;};'use strict';var EventEmitter=require(_0x54b3('0x0'));var SmsAccount=require(_0x54b3('0x1'))['db'][_0x54b3('0x2')];var SmsAccountEvents=new EventEmitter();SmsAccountEvents[_0x54b3('0x3')](0x0);var events={'afterCreate':_0x54b3('0x4'),'afterUpdate':'update','afterDestroy':_0x54b3('0x5')};function emitEvent(_0x1f63ab){return function(_0x5bfaf2,_0x4db480,_0x5c7472){SmsAccountEvents[_0x54b3('0x6')](_0x1f63ab+':'+_0x5bfaf2['id'],_0x5bfaf2);SmsAccountEvents['emit'](_0x1f63ab,_0x5bfaf2);_0x5c7472(null);};}for(var e in events){if(events[_0x54b3('0x7')](e)){var event=events[e];SmsAccount['hook'](e,emitEvent(event));}}module[_0x54b3('0x8')]=SmsAccountEvents; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.model.js b/server/api/smsAccount/smsAccount.model.js new file mode 100644 index 0000000..bb6cf11 --- /dev/null +++ b/server/api/smsAccount/smsAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x844d=['./smsAccount.attributes','exports','define','SmsAccount','sms_accounts','util','api','request-promise','path','rimraf','../../config/environment'];(function(_0xef8fab,_0x13938e){var _0x1fc438=function(_0x49f6b9){while(--_0x49f6b9){_0xef8fab['push'](_0xef8fab['shift']());}};_0x1fc438(++_0x13938e);}(_0x844d,0xec));var _0xd844=function(_0x43f489,_0x2b4fea){_0x43f489=_0x43f489-0x0;var _0x4134b4=_0x844d[_0x43f489];return _0x4134b4;};'use strict';var _=require('lodash');var util=require(_0xd844('0x0'));var logger=require('../../config/logger')(_0xd844('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xd844('0x2'));var fs=require('fs');var path=require(_0xd844('0x3'));var rimraf=require(_0xd844('0x4'));var config=require(_0xd844('0x5'));var attributes=require(_0xd844('0x6'));module[_0xd844('0x7')]=function(_0x296298,_0x4752d7){return _0x296298[_0xd844('0x8')](_0xd844('0x9'),attributes,{'tableName':_0xd844('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.rpc.js b/server/api/smsAccount/smsAccount.rpc.js new file mode 100644 index 0000000..7c97002 --- /dev/null +++ b/server/api/smsAccount/smsAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadce=['catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','ShowSmsAccount','SmsAccount','find','options','raw','where','attributes','include','map','model','debug'];(function(_0x67655b,_0x15ff31){var _0x71c09d=function(_0x50c331){while(--_0x50c331){_0x67655b['push'](_0x67655b['shift']());}};_0x71c09d(++_0x15ff31);}(_0xadce,0xc9));var _0xeadc=function(_0x599e60,_0x5b6519){_0x599e60=_0x599e60-0x0;var _0x468e19=_0xadce[_0x599e60];return _0x468e19;};'use strict';var _=require(_0xeadc('0x0'));var util=require(_0xeadc('0x1'));var moment=require(_0xeadc('0x2'));var BPromise=require(_0xeadc('0x3'));var rs=require(_0xeadc('0x4'));var fs=require('fs');var Redis=require(_0xeadc('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xeadc('0x6'));var logger=require('../../config/logger')(_0xeadc('0x7'));var config=require('../../config/environment');var jayson=require(_0xeadc('0x8'));var client=jayson[_0xeadc('0x9')][_0xeadc('0xa')]({'port':0x232a});config['redis']=_[_0xeadc('0xb')](config[_0xeadc('0xc')],{'host':_0xeadc('0xd'),'port':0x18eb});var socket=require(_0xeadc('0xe'))(new Redis(config[_0xeadc('0xc')]));require(_0xeadc('0xf'))[_0xeadc('0x10')](socket);function respondWithRpcPromise(_0x260891,_0x5a7c9a,_0x4d16a9){return new BPromise(function(_0x1184d4,_0x1d18f9){return client[_0xeadc('0x11')](_0x260891,_0x4d16a9)[_0xeadc('0x12')](function(_0x3a0019){logger[_0xeadc('0x13')](_0xeadc('0x14'),_0x5a7c9a,'request\x20sent');logger['debug'](_0xeadc('0x15'),_0x5a7c9a,_0xeadc('0x16'),JSON[_0xeadc('0x17')](_0x3a0019));if(_0x3a0019[_0xeadc('0x18')]){if(_0x3a0019[_0xeadc('0x18')][_0xeadc('0x19')]===0x1f4){logger[_0xeadc('0x18')](_0xeadc('0x14'),_0x5a7c9a,_0x3a0019['error'][_0xeadc('0x1a')]);return _0x1d18f9(_0x3a0019[_0xeadc('0x18')][_0xeadc('0x1a')]);}logger[_0xeadc('0x18')]('SmsAccount,\x20%s,\x20%s',_0x5a7c9a,_0x3a0019[_0xeadc('0x18')]['message']);return _0x1184d4(_0x3a0019[_0xeadc('0x18')][_0xeadc('0x1a')]);}else{logger[_0xeadc('0x13')](_0xeadc('0x14'),_0x5a7c9a,'request\x20sent');_0x1184d4(_0x3a0019[_0xeadc('0x1b')][_0xeadc('0x1a')]);}})['catch'](function(_0x953a9f){logger[_0xeadc('0x18')]('SmsAccount,\x20%s,\x20%s',_0x5a7c9a,_0x953a9f);_0x1d18f9(_0x953a9f);});});}exports[_0xeadc('0x1c')]=function(_0x16eb82){var _0x3b00aa=this;return new Promise(function(_0x5d29ca,_0x5950b0){return db[_0xeadc('0x1d')][_0xeadc('0x1e')]({'raw':_0x16eb82[_0xeadc('0x1f')]?_0x16eb82[_0xeadc('0x1f')][_0xeadc('0x20')]===undefined?!![]:![]:!![],'where':_0x16eb82[_0xeadc('0x1f')]?_0x16eb82['options'][_0xeadc('0x21')]||null:null,'attributes':_0x16eb82['options']?_0x16eb82[_0xeadc('0x1f')][_0xeadc('0x22')]||null:null,'include':_0x16eb82[_0xeadc('0x1f')]?_0x16eb82[_0xeadc('0x1f')][_0xeadc('0x23')]?_[_0xeadc('0x24')](_0x16eb82[_0xeadc('0x1f')][_0xeadc('0x23')],function(_0x4b6652){return{'model':db[_0x4b6652[_0xeadc('0x25')]],'as':_0x4b6652['as'],'attributes':_0x4b6652[_0xeadc('0x22')],'include':_0x4b6652[_0xeadc('0x23')]?_[_0xeadc('0x24')](_0x4b6652[_0xeadc('0x23')],function(_0x384187){return{'model':db[_0x384187['model']],'as':_0x384187['as'],'attributes':_0x384187[_0xeadc('0x22')],'include':_0x384187[_0xeadc('0x23')]?_[_0xeadc('0x24')](_0x384187[_0xeadc('0x23')],function(_0x3d581a){return{'model':db[_0x3d581a['model']],'as':_0x3d581a['as'],'attributes':_0x3d581a[_0xeadc('0x22')]};}):[]};}):[]};}):[]:[]})[_0xeadc('0x12')](function(_0x3b1324){logger['info']('ShowSmsAccount',_0x16eb82);logger[_0xeadc('0x26')]('ShowSmsAccount',_0x16eb82,JSON[_0xeadc('0x17')](_0x3b1324));_0x5d29ca(_0x3b1324);})[_0xeadc('0x27')](function(_0x1b1cd4){logger[_0xeadc('0x18')](_0xeadc('0x1c'),_0x1b1cd4['message'],_0x16eb82);_0x5950b0(_0x3b00aa['error'](0x1f4,_0x1b1cd4[_0xeadc('0x1a')]));});});}; \ No newline at end of file diff --git a/server/api/smsAccount/smsAccount.socket.js b/server/api/smsAccount/smsAccount.socket.js new file mode 100644 index 0000000..9c36c52 --- /dev/null +++ b/server/api/smsAccount/smsAccount.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['register','length','smsAccount:','./smsAccount.events','save','remove','emit','removeListener'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0xa9e0,0x123));var _0x0a9e=function(_0x43d11d,_0xccff91){_0x43d11d=_0x43d11d-0x0;var _0x38cd08=_0xa9e0[_0x43d11d];return _0x38cd08;};'use strict';var SmsAccountEvents=require(_0x0a9e('0x0'));var events=[_0x0a9e('0x1'),_0x0a9e('0x2'),'update'];function createListener(_0x550fbc,_0x18d5c9){return function(_0x4ce2f1){_0x18d5c9[_0x0a9e('0x3')](_0x550fbc,_0x4ce2f1);};}function removeListener(_0x432180,_0x2ab90b){return function(){SmsAccountEvents[_0x0a9e('0x4')](_0x432180,_0x2ab90b);};}exports[_0x0a9e('0x5')]=function(_0x57b080){for(var _0x219af0=0x0,_0x441e3a=events[_0x0a9e('0x6')];_0x219af0<_0x441e3a;_0x219af0++){var _0x5f41ea=events[_0x219af0];var _0x503809=createListener(_0x0a9e('0x7')+_0x5f41ea,_0x57b080);SmsAccountEvents['on'](_0x5f41ea,_0x503809);}}; \ No newline at end of file diff --git a/server/api/smsApplication/index.js b/server/api/smsApplication/index.js new file mode 100644 index 0000000..d6bf747 --- /dev/null +++ b/server/api/smsApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x34e8=['../../config/environment','./smsApplication.controller','get','index','/:id','isAuthenticated','show','post','create','put','update','delete','destroy','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service'];(function(_0x3da3c4,_0x2b874d){var _0x36a3af=function(_0x6d3f2d){while(--_0x6d3f2d){_0x3da3c4['push'](_0x3da3c4['shift']());}};_0x36a3af(++_0x2b874d);}(_0x34e8,0x12c));var _0x834e=function(_0x150d0e,_0x31dd36){_0x150d0e=_0x150d0e-0x0;var _0x1fabcb=_0x34e8[_0x150d0e];return _0x1fabcb;};'use strict';var multer=require(_0x834e('0x0'));var util=require(_0x834e('0x1'));var path=require(_0x834e('0x2'));var timeout=require(_0x834e('0x3'));var express=require('express');var router=express[_0x834e('0x4')]();var fs_extra=require(_0x834e('0x5'));var auth=require(_0x834e('0x6'));var interaction=require(_0x834e('0x7'));var config=require(_0x834e('0x8'));var controller=require(_0x834e('0x9'));router[_0x834e('0xa')]('/',auth['isAuthenticated'](),controller[_0x834e('0xb')]);router['get'](_0x834e('0xc'),auth[_0x834e('0xd')](),controller[_0x834e('0xe')]);router[_0x834e('0xf')]('/',auth[_0x834e('0xd')](),controller[_0x834e('0x10')]);router[_0x834e('0x11')](_0x834e('0xc'),auth[_0x834e('0xd')](),controller[_0x834e('0x12')]);router[_0x834e('0x13')](_0x834e('0xc'),auth[_0x834e('0xd')](),controller[_0x834e('0x14')]);module[_0x834e('0x15')]=router; \ No newline at end of file diff --git a/server/api/smsApplication/smsApplication.attributes.js b/server/api/smsApplication/smsApplication.attributes.js new file mode 100644 index 0000000..f5d908a --- /dev/null +++ b/server/api/smsApplication/smsApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x227e=['STRING','*,*,*,*','INTEGER'];(function(_0x3254a7,_0x1187a5){var _0x446a65=function(_0x3afd5a){while(--_0x3afd5a){_0x3254a7['push'](_0x3254a7['shift']());}};_0x446a65(++_0x1187a5);}(_0x227e,0xf2));var _0xe227=function(_0x22a2e1,_0x5c1836){_0x22a2e1=_0x22a2e1-0x0;var _0x4a78dc=_0x227e[_0x22a2e1];return _0x4a78dc;};'use strict';var Sequelize=require('sequelize');module['exports']={'priority':{'type':Sequelize[_0xe227('0x0')],'allowNull':![]},'app':{'type':Sequelize[_0xe227('0x1')],'allowNull':![],'defaultValue':'noop'},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize[_0xe227('0x1')]},'interval':{'type':Sequelize[_0xe227('0x1')],'defaultValue':_0xe227('0x2')}}; \ No newline at end of file diff --git a/server/api/smsApplication/smsApplication.controller.js b/server/api/smsApplication/smsApplication.controller.js new file mode 100644 index 0000000..4c5b6d0 --- /dev/null +++ b/server/api/smsApplication/smsApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcfa6=['status','end','json','limit','undefined','offset','set','Content-Range','reject','update','then','destroy','error','stack','name','send','index','map','SmsApplication','rawAttributes','fieldName','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','count','includeAll','include','findAll','rows','show','params','find','catch','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus'];(function(_0x1fe9ad,_0x44176a){var _0xbc7389=function(_0x9eabb2){while(--_0x9eabb2){_0x1fe9ad['push'](_0x1fe9ad['shift']());}};_0xbc7389(++_0x44176a);}(_0xcfa6,0x1ba));var _0x6cfa=function(_0x3d6ad7,_0x5258aa){_0x3d6ad7=_0x3d6ad7-0x0;var _0x5d36d9=_0xcfa6[_0x3d6ad7];return _0x5d36d9;};'use strict';var emlformat=require(_0x6cfa('0x0'));var rimraf=require(_0x6cfa('0x1'));var zipdir=require(_0x6cfa('0x2'));var jsonpatch=require(_0x6cfa('0x3'));var rp=require(_0x6cfa('0x4'));var moment=require(_0x6cfa('0x5'));var BPromise=require(_0x6cfa('0x6'));var Mustache=require(_0x6cfa('0x7'));var util=require('util');var path=require(_0x6cfa('0x8'));var sox=require(_0x6cfa('0x9'));var csv=require(_0x6cfa('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6cfa('0xb'));var squel=require(_0x6cfa('0xc'));var crypto=require(_0x6cfa('0xd'));var jsforce=require(_0x6cfa('0xe'));var deskjs=require(_0x6cfa('0xf'));var toCsv=require(_0x6cfa('0xa'));var querystring=require(_0x6cfa('0x10'));var Papa=require('papaparse');var Redis=require(_0x6cfa('0x11'));var authService=require(_0x6cfa('0x12'));var qs=require(_0x6cfa('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x6cfa('0x14'))('api');var utils=require(_0x6cfa('0x15'));var config=require(_0x6cfa('0x16'));var licenseUtil=require(_0x6cfa('0x17'));var db=require(_0x6cfa('0x18'))['db'];function respondWithStatusCode(_0x112d1d,_0x2a1a20){_0x2a1a20=_0x2a1a20||0xcc;return function(_0x2ac066){if(_0x2ac066){return _0x112d1d[_0x6cfa('0x19')](_0x2a1a20);}return _0x112d1d[_0x6cfa('0x1a')](_0x2a1a20)[_0x6cfa('0x1b')]();};}function respondWithResult(_0x2efff1,_0x51b8b2){_0x51b8b2=_0x51b8b2||0xc8;return function(_0x31d516){if(_0x31d516){return _0x2efff1[_0x6cfa('0x1a')](_0x51b8b2)[_0x6cfa('0x1c')](_0x31d516);}};}function respondWithFilteredResult(_0x2d2c42,_0x42e0ca){return function(_0x4c60e8){if(_0x4c60e8){var _0x13d05f=typeof _0x42e0ca['offset']==='undefined'&&typeof _0x42e0ca[_0x6cfa('0x1d')]===_0x6cfa('0x1e');var _0x23aca1=_0x4c60e8['count'];var _0x3c575e=_0x13d05f?0x0:_0x42e0ca['offset'];var _0x4c697b=_0x13d05f?_0x4c60e8['count']:_0x42e0ca[_0x6cfa('0x1f')]+_0x42e0ca[_0x6cfa('0x1d')];var _0x1d00ce;if(_0x4c697b>=_0x23aca1){_0x4c697b=_0x23aca1;_0x1d00ce=0xc8;}else{_0x1d00ce=0xce;}_0x2d2c42[_0x6cfa('0x1a')](_0x1d00ce);return _0x2d2c42[_0x6cfa('0x20')](_0x6cfa('0x21'),_0x3c575e+'-'+_0x4c697b+'/'+_0x23aca1)['json'](_0x4c60e8);}return null;};}function patchUpdates(_0x28a757){return function(_0x7c3026){try{jsonpatch['apply'](_0x7c3026,_0x28a757,!![]);}catch(_0x2da53d){return BPromise[_0x6cfa('0x22')](_0x2da53d);}return _0x7c3026['save']();};}function saveUpdates(_0x324ef1,_0x1842f3){return function(_0xc9a510){if(_0xc9a510){return _0xc9a510[_0x6cfa('0x23')](_0x324ef1)[_0x6cfa('0x24')](function(_0x5340a2){return _0x5340a2;});}return null;};}function removeEntity(_0x4c2448,_0x459310){return function(_0x209afc){if(_0x209afc){return _0x209afc[_0x6cfa('0x25')]()['then'](function(){_0x4c2448[_0x6cfa('0x1a')](0xcc)[_0x6cfa('0x1b')]();});}};}function handleEntityNotFound(_0x3bc9b0,_0x228cd1){return function(_0x3faf77){if(!_0x3faf77){_0x3bc9b0[_0x6cfa('0x19')](0x194);}return _0x3faf77;};}function handleError(_0x3162f3,_0x1b4f5e){_0x1b4f5e=_0x1b4f5e||0x1f4;return function(_0x4326a5){logger[_0x6cfa('0x26')](_0x4326a5[_0x6cfa('0x27')]);if(_0x4326a5[_0x6cfa('0x28')]){delete _0x4326a5['name'];}_0x3162f3['status'](_0x1b4f5e)[_0x6cfa('0x29')](_0x4326a5);};}exports[_0x6cfa('0x2a')]=function(_0x50a880,_0xddde34){var _0x37686a={},_0x3585dc={},_0xed1b75={'count':0x0,'rows':[]};var _0x3252a0=_[_0x6cfa('0x2b')](db[_0x6cfa('0x2c')][_0x6cfa('0x2d')],function(_0xaad3d1){return{'name':_0xaad3d1[_0x6cfa('0x2e')],'type':_0xaad3d1['type'][_0x6cfa('0x2f')]};});_0x3585dc[_0x6cfa('0x30')]=_[_0x6cfa('0x2b')](_0x3252a0,_0x6cfa('0x28'));_0x3585dc['query']=_[_0x6cfa('0x31')](_0x50a880[_0x6cfa('0x32')]);_0x3585dc[_0x6cfa('0x33')]=_[_0x6cfa('0x34')](_0x3585dc[_0x6cfa('0x30')],_0x3585dc[_0x6cfa('0x32')]);_0x37686a[_0x6cfa('0x35')]=_[_0x6cfa('0x34')](_0x3585dc[_0x6cfa('0x30')],qs[_0x6cfa('0x36')](_0x50a880[_0x6cfa('0x32')]['fields']));_0x37686a[_0x6cfa('0x35')]=_0x37686a[_0x6cfa('0x35')][_0x6cfa('0x37')]?_0x37686a[_0x6cfa('0x35')]:_0x3585dc['model'];if(!_0x50a880[_0x6cfa('0x32')][_0x6cfa('0x38')](_0x6cfa('0x39'))){_0x37686a[_0x6cfa('0x1d')]=qs['limit'](_0x50a880[_0x6cfa('0x32')][_0x6cfa('0x1d')]);_0x37686a[_0x6cfa('0x1f')]=qs['offset'](_0x50a880['query']['offset']);}_0x37686a[_0x6cfa('0x3a')]=qs[_0x6cfa('0x3b')](_0x50a880[_0x6cfa('0x32')]['sort']);_0x37686a['where']=qs[_0x6cfa('0x33')](_[_0x6cfa('0x3c')](_0x50a880[_0x6cfa('0x32')],_0x3585dc[_0x6cfa('0x33')]),_0x3252a0);if(_0x50a880[_0x6cfa('0x32')][_0x6cfa('0x3d')]){_0x37686a[_0x6cfa('0x3e')]=_[_0x6cfa('0x3f')](_0x37686a[_0x6cfa('0x3e')],{'$or':_[_0x6cfa('0x2b')](_0x3252a0,function(_0x375d4b){if(_0x375d4b[_0x6cfa('0x40')]!==_0x6cfa('0x41')){var _0x271203={};_0x271203[_0x375d4b[_0x6cfa('0x28')]]={'$like':'%'+_0x50a880[_0x6cfa('0x32')][_0x6cfa('0x3d')]+'%'};return _0x271203;}})});}_0x37686a=_['merge']({},_0x37686a,_0x50a880[_0x6cfa('0x42')]);var _0x19f042={'where':_0x37686a['where']};return db[_0x6cfa('0x2c')][_0x6cfa('0x43')](_0x19f042)[_0x6cfa('0x24')](function(_0x4c450d){_0xed1b75[_0x6cfa('0x43')]=_0x4c450d;if(_0x50a880['query'][_0x6cfa('0x44')]){_0x37686a[_0x6cfa('0x45')]=[{'all':!![]}];}return db[_0x6cfa('0x2c')][_0x6cfa('0x46')](_0x37686a);})['then'](function(_0x28068){_0xed1b75[_0x6cfa('0x47')]=_0x28068;return _0xed1b75;})['then'](respondWithFilteredResult(_0xddde34,_0x37686a))['catch'](handleError(_0xddde34,null));};exports[_0x6cfa('0x48')]=function(_0x366f02,_0x831bcf){var _0x27e9da={'raw':!![],'where':{'id':_0x366f02[_0x6cfa('0x49')]['id']}},_0x15de2b={};_0x15de2b[_0x6cfa('0x30')]=_['keys'](db[_0x6cfa('0x2c')]['rawAttributes']);_0x15de2b[_0x6cfa('0x32')]=_[_0x6cfa('0x31')](_0x366f02[_0x6cfa('0x32')]);_0x15de2b[_0x6cfa('0x33')]=_[_0x6cfa('0x34')](_0x15de2b[_0x6cfa('0x30')],_0x15de2b['query']);_0x27e9da[_0x6cfa('0x35')]=_[_0x6cfa('0x34')](_0x15de2b[_0x6cfa('0x30')],qs[_0x6cfa('0x36')](_0x366f02[_0x6cfa('0x32')][_0x6cfa('0x36')]));_0x27e9da[_0x6cfa('0x35')]=_0x27e9da[_0x6cfa('0x35')][_0x6cfa('0x37')]?_0x27e9da['attributes']:_0x15de2b[_0x6cfa('0x30')];if(_0x366f02[_0x6cfa('0x32')][_0x6cfa('0x44')]){_0x27e9da[_0x6cfa('0x45')]=[{'all':!![]}];}_0x27e9da=_[_0x6cfa('0x3f')]({},_0x27e9da,_0x366f02['options']);return db[_0x6cfa('0x2c')][_0x6cfa('0x4a')](_0x27e9da)[_0x6cfa('0x24')](handleEntityNotFound(_0x831bcf,null))[_0x6cfa('0x24')](respondWithResult(_0x831bcf,null))[_0x6cfa('0x4b')](handleError(_0x831bcf,null));};exports[_0x6cfa('0x4c')]=function(_0xb3bda1,_0x30f749){return db[_0x6cfa('0x2c')][_0x6cfa('0x4c')](_0xb3bda1[_0x6cfa('0x4d')],{})[_0x6cfa('0x24')](respondWithResult(_0x30f749,0xc9))[_0x6cfa('0x4b')](handleError(_0x30f749,null));};exports['update']=function(_0x2a5b03,_0x3b23f0){if(_0x2a5b03[_0x6cfa('0x4d')]['id']){delete _0x2a5b03[_0x6cfa('0x4d')]['id'];}return db[_0x6cfa('0x2c')][_0x6cfa('0x4a')]({'where':{'id':_0x2a5b03[_0x6cfa('0x49')]['id']}})[_0x6cfa('0x24')](handleEntityNotFound(_0x3b23f0,null))[_0x6cfa('0x24')](saveUpdates(_0x2a5b03[_0x6cfa('0x4d')],null))[_0x6cfa('0x24')](respondWithResult(_0x3b23f0,null))['catch'](handleError(_0x3b23f0,null));};exports[_0x6cfa('0x25')]=function(_0x3d73fb,_0x18529f){return db['SmsApplication'][_0x6cfa('0x4a')]({'where':{'id':_0x3d73fb['params']['id']}})[_0x6cfa('0x24')](handleEntityNotFound(_0x18529f,null))[_0x6cfa('0x24')](removeEntity(_0x18529f,null))[_0x6cfa('0x4b')](handleError(_0x18529f,null));}; \ No newline at end of file diff --git a/server/api/smsApplication/smsApplication.model.js b/server/api/smsApplication/smsApplication.model.js new file mode 100644 index 0000000..1f63b72 --- /dev/null +++ b/server/api/smsApplication/smsApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2aba=['utf8mb4','utf8mb4_unicode_ci','lodash','util','request-promise','path','../../config/environment','./smsApplication.attributes','exports','define','SmsApplication','sms_applications'];(function(_0x2f05bd,_0x424ac5){var _0x5da135=function(_0x2f094d){while(--_0x2f094d){_0x2f05bd['push'](_0x2f05bd['shift']());}};_0x5da135(++_0x424ac5);}(_0x2aba,0x19a));var _0xa2ab=function(_0x2b5b9b,_0x5116a9){_0x2b5b9b=_0x2b5b9b-0x0;var _0x12720e=_0x2aba[_0x2b5b9b];return _0x12720e;};'use strict';var _=require(_0xa2ab('0x0'));var util=require(_0xa2ab('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xa2ab('0x2'));var fs=require('fs');var path=require(_0xa2ab('0x3'));var rimraf=require('rimraf');var config=require(_0xa2ab('0x4'));var attributes=require(_0xa2ab('0x5'));module[_0xa2ab('0x6')]=function(_0x285676,_0x2d4d89){return _0x285676[_0xa2ab('0x7')](_0xa2ab('0x8'),attributes,{'tableName':_0xa2ab('0x9'),'paranoid':![],'indexes':[],'timestamps':!![],'charset':_0xa2ab('0xa'),'collate':_0xa2ab('0xb')});}; \ No newline at end of file diff --git a/server/api/smsApplication/smsApplication.rpc.js b/server/api/smsApplication/smsApplication.rpc.js new file mode 100644 index 0000000..27b269d --- /dev/null +++ b/server/api/smsApplication/smsApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3c32=['request\x20sent','debug','SmsApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','SmsApplication,\x20%s,\x20%s'];(function(_0x5a29e0,_0x56678a){var _0x5fc0a2=function(_0x6397d2){while(--_0x6397d2){_0x5a29e0['push'](_0x5a29e0['shift']());}};_0x5fc0a2(++_0x56678a);}(_0x3c32,0x161));var _0x23c3=function(_0x34e341,_0xbddc4f){_0x34e341=_0x34e341-0x0;var _0x2b4f95=_0x3c32[_0x34e341];return _0x2b4f95;};'use strict';var _=require(_0x23c3('0x0'));var util=require(_0x23c3('0x1'));var moment=require(_0x23c3('0x2'));var BPromise=require('bluebird');var rs=require(_0x23c3('0x3'));var fs=require('fs');var Redis=require(_0x23c3('0x4'));var db=require(_0x23c3('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x23c3('0x6'))('rpc');var config=require(_0x23c3('0x7'));var jayson=require(_0x23c3('0x8'));var client=jayson[_0x23c3('0x9')][_0x23c3('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4a6364,_0x56568e,_0x493ca6){return new BPromise(function(_0x4df5ee,_0x422558){return client[_0x23c3('0xb')](_0x4a6364,_0x493ca6)[_0x23c3('0xc')](function(_0x420987){logger[_0x23c3('0xd')](_0x23c3('0xe'),_0x56568e,_0x23c3('0xf'));logger[_0x23c3('0x10')](_0x23c3('0x11'),_0x56568e,_0x23c3('0xf'),JSON[_0x23c3('0x12')](_0x420987));if(_0x420987[_0x23c3('0x13')]){if(_0x420987[_0x23c3('0x13')][_0x23c3('0x14')]===0x1f4){logger[_0x23c3('0x13')](_0x23c3('0xe'),_0x56568e,_0x420987[_0x23c3('0x13')][_0x23c3('0x15')]);return _0x422558(_0x420987[_0x23c3('0x13')][_0x23c3('0x15')]);}logger['error']('SmsApplication,\x20%s,\x20%s',_0x56568e,_0x420987[_0x23c3('0x13')][_0x23c3('0x15')]);return _0x4df5ee(_0x420987[_0x23c3('0x13')][_0x23c3('0x15')]);}else{logger[_0x23c3('0xd')](_0x23c3('0xe'),_0x56568e,_0x23c3('0xf'));_0x4df5ee(_0x420987['result']['message']);}})[_0x23c3('0x16')](function(_0x43534b){logger['error'](_0x23c3('0xe'),_0x56568e,_0x43534b);_0x422558(_0x43534b);});});} \ No newline at end of file diff --git a/server/api/smsInteraction/index.js b/server/api/smsInteraction/index.js new file mode 100644 index 0000000..a25bfa0 --- /dev/null +++ b/server/api/smsInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8603=['sms','addTags','put','/:id','smsinteraction:update','update','delete','destroy','removeTags','exports','util','path','connect-timeout','fs-extra','../../components/auth/service','../../components/interaction/service','./smsInteraction.controller','isAuthenticated','index','get','/describe','show','/:id/messages','/:id/download','download','post','create','addMessage','/:id/tags','tracked'];(function(_0x1f8921,_0x38bd21){var _0x2c2f34=function(_0x33d700){while(--_0x33d700){_0x1f8921['push'](_0x1f8921['shift']());}};_0x2c2f34(++_0x38bd21);}(_0x8603,0x190));var _0x3860=function(_0x528687,_0x55bc89){_0x528687=_0x528687-0x0;var _0x31e7ab=_0x8603[_0x528687];return _0x31e7ab;};'use strict';var multer=require('multer');var util=require(_0x3860('0x0'));var path=require(_0x3860('0x1'));var timeout=require(_0x3860('0x2'));var express=require('express');var router=express['Router']();var fs_extra=require(_0x3860('0x3'));var auth=require(_0x3860('0x4'));var interaction=require(_0x3860('0x5'));var config=require('../../config/environment');var controller=require(_0x3860('0x6'));router['get']('/',auth[_0x3860('0x7')](),controller[_0x3860('0x8')]);router[_0x3860('0x9')](_0x3860('0xa'),auth[_0x3860('0x7')](),controller['describe']);router['get']('/:id',auth[_0x3860('0x7')](),controller[_0x3860('0xb')]);router['get'](_0x3860('0xc'),auth[_0x3860('0x7')](),controller['getMessages']);router[_0x3860('0x9')](_0x3860('0xd'),auth['isAuthenticated'](),controller[_0x3860('0xe')]);router[_0x3860('0xf')]('/',auth['isAuthenticated'](),controller[_0x3860('0x10')]);router[_0x3860('0xf')](_0x3860('0xc'),auth[_0x3860('0x7')](),controller[_0x3860('0x11')]);router[_0x3860('0xf')](_0x3860('0x12'),auth[_0x3860('0x7')](),interaction[_0x3860('0x13')](_0x3860('0x14'),'smsinteraction:addtags'),controller[_0x3860('0x15')]);router[_0x3860('0x16')](_0x3860('0x17'),auth[_0x3860('0x7')](),interaction[_0x3860('0x13')](_0x3860('0x14'),_0x3860('0x18')),controller[_0x3860('0x19')]);router[_0x3860('0x1a')](_0x3860('0x17'),auth[_0x3860('0x7')](),interaction[_0x3860('0x13')]('sms','smsinteraction:destroy'),controller[_0x3860('0x1b')]);router[_0x3860('0x1a')](_0x3860('0x12'),auth['isAuthenticated'](),controller[_0x3860('0x1c')]);module[_0x3860('0x1d')]=router; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.attributes.js b/server/api/smsInteraction/smsInteraction.attributes.js new file mode 100644 index 0000000..d5e21fe --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0024=['moment','BOOLEAN','STRING','out','DATE','ENUM'];(function(_0x1b02bb,_0x3d9fde){var _0x131245=function(_0x2fd1d8){while(--_0x2fd1d8){_0x1b02bb['push'](_0x1b02bb['shift']());}};_0x131245(++_0x3d9fde);}(_0x0024,0xa8));var _0x4002=function(_0x5bfaa7,_0x404773){_0x5bfaa7=_0x5bfaa7-0x0;var _0xe1b1a3=_0x0024[_0x5bfaa7];return _0xe1b1a3;};'use strict';var Sequelize=require('sequelize');var moment=require(_0x4002('0x0'));module['exports']={'closed':{'type':Sequelize[_0x4002('0x1')],'defaultValue':![]},'closedAt':{'type':Sequelize['DATE']},'disposition':{'type':Sequelize[_0x4002('0x2')]},'secondDisposition':{'type':Sequelize['STRING']},'thirdDisposition':{'type':Sequelize['STRING']},'note':{'type':Sequelize[_0x4002('0x2')]},'phone':{'type':Sequelize[_0x4002('0x2')]},'read1stAt':{'type':Sequelize['DATE']},'firstMsgDirection':{'type':Sequelize['ENUM']('in',_0x4002('0x3')),'defaultValue':'in','allowNull':![]},'lastMsgAt':{'type':Sequelize[_0x4002('0x4')]},'lastMsgDirection':{'type':Sequelize[_0x4002('0x5')]('in',_0x4002('0x3')),'defaultValue':'in','allowNull':![]},'autoreplyExecuted':{'type':Sequelize['BOOLEAN'],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.controller.js b/server/api/smsInteraction/smsInteraction.controller.js new file mode 100644 index 0000000..225eeb3 --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x169f=['pick','filter','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','include','rows','addTags','setTags','emit','smsInteractionTags:save','download','unix','toString','root','server','tmp','join','transcript-%d-%s.zip','push','User','fullname','CmContact','firstName','lastName','createdAt','direction','secret','Account','Owner','Sms','N.A.','closedAt','disposition','Messages','Contact','out','read','renderFile','views','.pdf','err','zip-dir','moment','bluebird','util','path','lodash','../../components/interaction/service','../../components/parsers/qs','../../components/export/pdf','../../config/logger','redis','defaults','localhost','register','sendStatus','status','end','offset','undefined','count','set','Content-Range','json','update','then','destroy','name','send','index','map','SmsInteraction','rawAttributes','type','key','findAll','sms','query','user','catch','show','params','keys','intersection','model','attributes','fields','includeAll','merge','options','find','create','body','describe','addMessage','ids','omit','getMessages','findOne','SmsMessage','filters','hasOwnProperty','nolimit','limit','order','sort','where'];(function(_0x114abb,_0x373ee1){var _0x4b2759=function(_0x527529){while(--_0x527529){_0x114abb['push'](_0x114abb['shift']());}};_0x4b2759(++_0x373ee1);}(_0x169f,0x172));var _0xf169=function(_0x253c0c,_0x55f71f){_0x253c0c=_0x253c0c-0x0;var _0x53fb71=_0x169f[_0x253c0c];return _0x53fb71;};'use strict';var rimraf=require('rimraf');var zipdir=require(_0xf169('0x0'));var moment=require(_0xf169('0x1'));var BPromise=require(_0xf169('0x2'));var util=require(_0xf169('0x3'));var path=require(_0xf169('0x4'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf169('0x5'));var Redis=require('ioredis');var interaction=require(_0xf169('0x6'));var qs=require(_0xf169('0x7'));var pdf=require(_0xf169('0x8'));var logger=require(_0xf169('0x9'))('api');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0xf169('0xa')]=_[_0xf169('0xb')](config[_0xf169('0xa')],{'host':_0xf169('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf169('0xa')]));require('./smsInteraction.socket')[_0xf169('0xd')](socket);function respondWithStatusCode(_0x3f1eb0,_0x147bbc){_0x147bbc=_0x147bbc||0xcc;return function(_0x524983){if(_0x524983){return _0x3f1eb0[_0xf169('0xe')](_0x147bbc);}return _0x3f1eb0[_0xf169('0xf')](_0x147bbc)[_0xf169('0x10')]();};}function respondWithResult(_0x5c186f,_0x46bb00){_0x46bb00=_0x46bb00||0xc8;return function(_0x516fba){if(_0x516fba){return _0x5c186f[_0xf169('0xf')](_0x46bb00)['json'](_0x516fba);}};}function respondWithFilteredResult(_0x22d0c8,_0x2fc12c){return function(_0x19a646){if(_0x19a646){var _0x49c50c=typeof _0x2fc12c[_0xf169('0x11')]==='undefined'&&typeof _0x2fc12c['limit']===_0xf169('0x12');var _0x2206f0=_0x19a646[_0xf169('0x13')];var _0x4c9e2c=_0x49c50c?0x0:_0x2fc12c[_0xf169('0x11')];var _0x2c8433=_0x49c50c?_0x19a646[_0xf169('0x13')]:_0x2fc12c[_0xf169('0x11')]+_0x2fc12c['limit'];var _0x1101d7;if(_0x2c8433>=_0x2206f0){_0x2c8433=_0x2206f0;_0x1101d7=0xc8;}else{_0x1101d7=0xce;}_0x22d0c8[_0xf169('0xf')](_0x1101d7);return _0x22d0c8[_0xf169('0x14')](_0xf169('0x15'),_0x4c9e2c+'-'+_0x2c8433+'/'+_0x2206f0)[_0xf169('0x16')](_0x19a646);}return null;};}function saveUpdates(_0x13e753){return function(_0x4956ae){if(_0x4956ae){return _0x4956ae[_0xf169('0x17')](_0x13e753)[_0xf169('0x18')](function(_0x58108e){return _0x58108e;});}return null;};}function removeEntity(_0x565f9e){return function(_0x13f9dc){if(_0x13f9dc){return _0x13f9dc[_0xf169('0x19')]()[_0xf169('0x18')](function(){_0x565f9e[_0xf169('0xf')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1e09cd){return function(_0x103ecf){if(!_0x103ecf){_0x1e09cd['sendStatus'](0x194);}return _0x103ecf;};}function handleError(_0x301c47,_0x539eca){_0x539eca=_0x539eca||0x1f4;return function(_0x45f6bb){logger['error'](_0x45f6bb['stack']);if(_0x45f6bb[_0xf169('0x1a')]){delete _0x45f6bb[_0xf169('0x1a')];}_0x301c47[_0xf169('0xf')](_0x539eca)[_0xf169('0x1b')](_0x45f6bb);};}exports[_0xf169('0x1c')]=function(_0x201ad7,_0xe50264){var _0x5ecd50={};var _0x25a5e9=_[_0xf169('0x1d')](db[_0xf169('0x1e')][_0xf169('0x1f')],function(_0x513e24){return{'name':_0x513e24['fieldName'],'type':_0x513e24[_0xf169('0x20')][_0xf169('0x21')]};});_0x5ecd50=qs['getOptions'](_0x25a5e9,_0x201ad7);return interaction[_0xf169('0x22')](_0xf169('0x23'),_0x201ad7[_0xf169('0x24')],_0x201ad7[_0xf169('0x25')],_0x5ecd50,_0x25a5e9)[_0xf169('0x18')](respondWithFilteredResult(_0xe50264,_0x5ecd50))[_0xf169('0x26')](handleError(_0xe50264,null));};exports[_0xf169('0x27')]=function(_0x4d1f0d,_0x4b4095){var _0x4d37cc={'raw':![],'where':{'id':_0x4d1f0d[_0xf169('0x28')]['id']}},_0x5edf96={};_0x5edf96['model']=_['keys'](db[_0xf169('0x1e')][_0xf169('0x1f')]);_0x5edf96[_0xf169('0x24')]=_[_0xf169('0x29')](_0x4d1f0d[_0xf169('0x24')]);_0x5edf96['filters']=_[_0xf169('0x2a')](_0x5edf96[_0xf169('0x2b')],_0x5edf96[_0xf169('0x24')]);_0x4d37cc[_0xf169('0x2c')]=_['intersection'](_0x5edf96[_0xf169('0x2b')],qs[_0xf169('0x2d')](_0x4d1f0d[_0xf169('0x24')][_0xf169('0x2d')]));_0x4d37cc['attributes']=_0x4d37cc['attributes']['length']?_0x4d37cc[_0xf169('0x2c')]:_0x5edf96[_0xf169('0x2b')];if(_0x4d1f0d[_0xf169('0x24')][_0xf169('0x2e')]){_0x4d37cc['include']=[{'all':!![]}];}_0x4d37cc=_[_0xf169('0x2f')]({},_0x4d37cc,_0x4d1f0d[_0xf169('0x30')]);return db['SmsInteraction'][_0xf169('0x31')](_0x4d37cc)['then'](handleEntityNotFound(_0x4b4095,null))['then'](respondWithResult(_0x4b4095,null))[_0xf169('0x26')](handleError(_0x4b4095,null));};exports['create']=function(_0x56ef43,_0x501ac4){return db[_0xf169('0x1e')][_0xf169('0x32')](_0x56ef43[_0xf169('0x33')],{})['then'](respondWithResult(_0x501ac4,0xc9))['catch'](handleError(_0x501ac4,null));};exports[_0xf169('0x17')]=function(_0x273757,_0x4563d2){if(_0x273757[_0xf169('0x33')]['id']){delete _0x273757[_0xf169('0x33')]['id'];}return db[_0xf169('0x1e')][_0xf169('0x31')]({'where':{'id':_0x273757['params']['id']}})[_0xf169('0x18')](handleEntityNotFound(_0x4563d2,null))['then'](saveUpdates(_0x273757[_0xf169('0x33')],null))[_0xf169('0x18')](respondWithResult(_0x4563d2,null))[_0xf169('0x26')](handleError(_0x4563d2,null));};exports['destroy']=function(_0x1fb77d,_0x2a7e34){return db[_0xf169('0x1e')][_0xf169('0x31')]({'where':{'id':_0x1fb77d[_0xf169('0x28')]['id']}})[_0xf169('0x18')](handleEntityNotFound(_0x2a7e34,null))['then'](removeEntity(_0x2a7e34,null))[_0xf169('0x26')](handleError(_0x2a7e34,null));};exports[_0xf169('0x34')]=function(_0x3ca585,_0x48b202){return db[_0xf169('0x1e')][_0xf169('0x34')]()['then'](respondWithResult(_0x48b202,null))['catch'](handleError(_0x48b202,null));};exports[_0xf169('0x35')]=function(_0x2f9f52,_0x37f53c){return db['SmsMessage'][_0xf169('0x31')]({'where':{'id':_0x2f9f52[_0xf169('0x28')]['id']}})['then'](handleEntityNotFound(_0x37f53c,null))[_0xf169('0x18')](function(_0x52d980){if(_0x52d980){return _0x52d980[_0xf169('0x35')](_0x2f9f52[_0xf169('0x33')][_0xf169('0x36')],_[_0xf169('0x37')](_0x2f9f52['body'],[_0xf169('0x36'),'id'])||{});}})[_0xf169('0x18')](respondWithResult(_0x37f53c,null))[_0xf169('0x26')](handleError(_0x37f53c,null));};exports[_0xf169('0x38')]=function(_0x437cde,_0x18162e){var _0x3b62c3={'raw':![],'where':{}};var _0xe76c72={};var _0x2ccae9={'count':0x0,'rows':[]};return db['SmsInteraction'][_0xf169('0x39')]({'where':{'id':_0x437cde[_0xf169('0x28')]['id']}})['then'](handleEntityNotFound(_0x18162e,null))[_0xf169('0x18')](function(_0x5d2d8b){if(_0x5d2d8b){_0xe76c72['model']=_[_0xf169('0x29')](db[_0xf169('0x3a')][_0xf169('0x1f')]);_0xe76c72[_0xf169('0x24')]=_[_0xf169('0x29')](_0x437cde[_0xf169('0x24')]);_0xe76c72[_0xf169('0x3b')]=_[_0xf169('0x2a')](_0xe76c72[_0xf169('0x2b')],_0xe76c72[_0xf169('0x24')]);_0x3b62c3[_0xf169('0x2c')]=_[_0xf169('0x2a')](_0xe76c72[_0xf169('0x2b')],qs[_0xf169('0x2d')](_0x437cde['query'][_0xf169('0x2d')]));_0x3b62c3[_0xf169('0x2c')]=_0x3b62c3[_0xf169('0x2c')]['length']?_0x3b62c3[_0xf169('0x2c')]:_0xe76c72['model'];if(!_0x437cde[_0xf169('0x24')][_0xf169('0x3c')](_0xf169('0x3d'))){_0x3b62c3[_0xf169('0x3e')]=qs[_0xf169('0x3e')](_0x437cde[_0xf169('0x24')][_0xf169('0x3e')]);_0x3b62c3[_0xf169('0x11')]=qs['offset'](_0x437cde[_0xf169('0x24')][_0xf169('0x11')]);}_0x3b62c3[_0xf169('0x3f')]=qs[_0xf169('0x40')](_0x437cde[_0xf169('0x24')][_0xf169('0x40')]);_0x3b62c3[_0xf169('0x41')]=qs['filters'](_[_0xf169('0x42')](_0x437cde[_0xf169('0x24')],_0xe76c72[_0xf169('0x3b')]));_0x3b62c3['where']['SmsInteractionId']=_0x5d2d8b['id'];if(_0x437cde['query'][_0xf169('0x43')]){_0x3b62c3[_0xf169('0x41')]=_[_0xf169('0x2f')](_0x3b62c3[_0xf169('0x41')],{'$or':_[_0xf169('0x1d')](_0x3b62c3[_0xf169('0x2c')],function(_0x317909){var _0x4752b5={};_0x4752b5[_0x317909]={'$like':'%'+_0x437cde[_0xf169('0x24')][_0xf169('0x43')]+'%'};return _0x4752b5;})});}if(_0x437cde[_0xf169('0x24')][_0xf169('0x44')]){var _0x41a12b=_0x437cde['query']['$gte'][_0xf169('0x45')](',');var _0x114f08={};_0x114f08[_0x41a12b[0x0]]={'$gte':moment(_0x41a12b[0x1])[_0xf169('0x46')](_0xf169('0x47'))};_0x3b62c3[_0xf169('0x41')]=_[_0xf169('0x2f')](_0x3b62c3[_0xf169('0x41')],_0x114f08);}_0x3b62c3=_[_0xf169('0x2f')]({},_0x3b62c3,_0x437cde[_0xf169('0x30')]);return db[_0xf169('0x3a')][_0xf169('0x13')]({'where':_0x3b62c3[_0xf169('0x41')]})['then'](function(_0x14a72a){_0x2ccae9['count']=_0x14a72a;if(_0x437cde[_0xf169('0x24')]['includeAll']){_0x3b62c3[_0xf169('0x48')]=[{'all':!![]}];}return db[_0xf169('0x3a')]['findAll'](_0x3b62c3);})[_0xf169('0x18')](function(_0x46c407){_0x2ccae9[_0xf169('0x49')]=_0x46c407;return _0x2ccae9;});}})[_0xf169('0x18')](respondWithFilteredResult(_0x18162e,_0x3b62c3))['catch'](handleError(_0x18162e,null));};exports[_0xf169('0x4a')]=function(_0x106078,_0x344ac9){return db[_0xf169('0x1e')][_0xf169('0x31')]({'where':{'id':_0x106078[_0xf169('0x28')]['id']}})['then'](handleEntityNotFound(_0x344ac9,null))[_0xf169('0x18')](function(_0x520877){if(_0x520877){return _0x520877[_0xf169('0x4b')](_0x106078[_0xf169('0x33')][_0xf169('0x36')],_['omit'](_0x106078[_0xf169('0x33')],['ids','id'])||{})['spread'](function(){return db['Tag'][_0xf169('0x22')]({'attributes':['id','name','color'],'where':{'id':_0x106078[_0xf169('0x33')][_0xf169('0x36')]}});})[_0xf169('0x18')](function(_0x5336f4){socket[_0xf169('0x4c')](_0xf169('0x4d'),{'id':Number(_0x106078[_0xf169('0x28')]['id']),'tags':_0x5336f4||[]});return{'id':Number(_0x106078[_0xf169('0x28')]['id']),'tags':_0x5336f4||[]};});}})[_0xf169('0x18')](respondWithResult(_0x344ac9,null))[_0xf169('0x26')](handleError(_0x344ac9,null));};exports['removeTags']=function(_0x219912,_0x27d76b){return db[_0xf169('0x1e')]['find']({'where':{'id':_0x219912[_0xf169('0x28')]['id']}})[_0xf169('0x18')](handleEntityNotFound(_0x27d76b,null))[_0xf169('0x18')](function(_0x4190bf){if(_0x4190bf){return _0x4190bf['removeTags'](_0x219912[_0xf169('0x24')][_0xf169('0x36')]);}})[_0xf169('0x18')](respondWithStatusCode(_0x27d76b,null))['catch'](handleError(_0x27d76b,null));};exports[_0xf169('0x4e')]=function(_0xbecd49,_0x1730e2){var _0x54bbb3=moment()[_0xf169('0x4f')]()[_0xf169('0x50')]();var _0x3fa6db=path['join'](config[_0xf169('0x51')],_0xf169('0x52'),'files',_0xf169('0x53'));var _0x38bcfd=path[_0xf169('0x54')](_0x3fa6db,_0x54bbb3);var _0x555aa1=util[_0xf169('0x46')](_0xf169('0x55'),_0xbecd49[_0xf169('0x28')]['id'],_0x54bbb3);var _0x18852a=path[_0xf169('0x54')](_0x3fa6db,_0x555aa1);var _0x269b5b=[];_0x269b5b[_0xf169('0x56')]({'model':db['User'],'as':_0xf169('0x57'),'attributes':['id',_0xf169('0x58')],'raw':!![]});_0x269b5b[_0xf169('0x56')]({'model':db[_0xf169('0x59')],'as':'Contact','attributes':['id',_0xf169('0x5a'),_0xf169('0x5b')],'raw':!![]});var _0xb333a4=[{'model':db['SmsMessage'],'as':'Messages','attributes':['id',_0xf169('0x33'),_0xf169('0x5c'),_0xf169('0x5d'),_0xf169('0x5e'),'read'],'include':_0x269b5b}];_0xb333a4[_0xf169('0x56')]({'model':db['SmsAccount'],'as':_0xf169('0x5f'),'attributes':['id',_0xf169('0x1a')]});_0xb333a4['push']({'model':db[_0xf169('0x57')],'as':_0xf169('0x60'),'attributes':['id','fullname']});return db[_0xf169('0x1e')][_0xf169('0x31')]({'where':{'id':_0xbecd49[_0xf169('0x28')]['id']},'include':_0xb333a4})[_0xf169('0x18')](handleEntityNotFound(_0x1730e2,null))['then'](function(_0x1faf85){if(_0x1faf85){var _0x3e1903=_0x1faf85['get']({'plain':!![]});fs['mkdirSync'](_0x38bcfd);var _0x19515c={'channel':_0xf169('0x61'),'account':_0x3e1903[_0xf169('0x5f')][_0xf169('0x1a')],'agent':_0x3e1903[_0xf169('0x60')]?_0x3e1903[_0xf169('0x60')]['fullname']:_0xf169('0x62'),'createdAt':moment(_0x3e1903[_0xf169('0x5c')])['format'](_0xf169('0x47'))['toString'](),'closedAt':_0x3e1903['closed']?moment(_0x3e1903[_0xf169('0x63')])[_0xf169('0x46')](_0xf169('0x47'))['toString']():'','disposition':_0x3e1903[_0xf169('0x64')],'messages':_(_0x3e1903[_0xf169('0x65')])[_0xf169('0x43')]({'secret':![]})['map'](function(_0x23fb19){return{'date':moment(_0x23fb19[_0xf169('0x5c')])['format'](_0xf169('0x47'))[_0xf169('0x50')](),'sender':_0x23fb19['direction']==='out'?_0x23fb19[_0xf169('0x57')]?_0x23fb19[_0xf169('0x57')]['fullname']:'System':_0x23fb19[_0xf169('0x66')]['firstName']+(_0x23fb19[_0xf169('0x66')]['lastName']?'\x20'+_0x23fb19[_0xf169('0x66')][_0xf169('0x5b')]:''),'body':_0x23fb19[_0xf169('0x33')],'direction':_0x23fb19[_0xf169('0x5d')]===_0xf169('0x67')?'A':'C','secret':_0x23fb19[_0xf169('0x5e')],'read':_0x23fb19[_0xf169('0x68')]};})['value']()};return ejs[_0xf169('0x69')](path[_0xf169('0x54')](config['root'],_0xf169('0x52'),_0xf169('0x6a'),'downloadInteraction.ejs'),{'interaction':_0x19515c})[_0xf169('0x18')](function(_0x3dda1b){var _0x14b15c=path[_0xf169('0x54')](_0x38bcfd,'transcript-'+_0x3e1903['id']+'-'+_0x54bbb3+_0xf169('0x6b'));var _0x302481={'path':_0x14b15c,'channel':_0xf169('0x61'),'interactionId':_0x3e1903['id']};return pdf['createPdfFromHTML'](_0x3dda1b,_0x302481);})[_0xf169('0x18')](function(){return new BPromise(function(_0xf46078,_0x536b63){zipdir(_0x38bcfd,{'saveTo':_0x18852a},function(_0x71687e,_0x7921ce){if(_0x71687e)return _0x536b63(_0x71687e);return _0xf46078(_0x7921ce);});})['then'](function(){return new BPromise(function(_0x5b0350,_0x25548d){rimraf(_0x38bcfd,function(_0xff798){if(_0xff798)_0x25548d(_0xff798);return _0x5b0350();});});})[_0xf169('0x18')](function(){return _0x1730e2[_0xf169('0x4e')](_0x18852a,_0x555aa1,function(_0x331056){if(_0x331056){console['log'](_0xf169('0x6c'),_0x331056);}else{fs['unlinkSync'](_0x18852a);}});});});}else{return _0x1730e2[_0xf169('0xe')](0xc8);}})['catch'](handleError(_0x1730e2,null));}; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.events.js b/server/api/smsInteraction/smsInteraction.events.js new file mode 100644 index 0000000..58bf224 --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3266=['length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','SmsInteraction','SmsMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','map','findAll','unreadMessages'];(function(_0x1e78c1,_0x8ec6ad){var _0x3c827c=function(_0x41ce54){while(--_0x41ce54){_0x1e78c1['push'](_0x1e78c1['shift']());}};_0x3c827c(++_0x8ec6ad);}(_0x3266,0x6a));var _0x6326=function(_0x44b3bd,_0x44c97d){_0x44b3bd=_0x44b3bd-0x0;var _0x1efc4a=_0x3266[_0x44b3bd];return _0x1efc4a;};'use strict';var EventEmitter=require(_0x6326('0x0'));var SmsInteraction=require(_0x6326('0x1'))['db'][_0x6326('0x2')];var SmsMessage=require(_0x6326('0x1'))['db'][_0x6326('0x3')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x6326('0x4')](0x0);var events={'afterCreate':_0x6326('0x5'),'afterUpdate':_0x6326('0x6'),'afterDestroy':_0x6326('0x7')};function emitEvent(_0x5a6b4d){return function(_0x30b22e,_0x5f38a3,_0x25ecd8){_0x30b22e[_0x6326('0x8')]({'attributes':['id'],'raw':!![]})[_0x6326('0x9')](function(_0x5402e5){_0x30b22e[_0x6326('0xa')]('Users',_0x5402e5[_0x6326('0xb')](function(_0x90c0f){return{'id':_0x90c0f['id']};}));return SmsMessage[_0x6326('0xc')]({'where':{'SmsInteractionId':_0x30b22e['id'],'direction':'in','read':![]},'raw':!![]});})[_0x6326('0x9')](function(_0x37a23d){_0x30b22e['setDataValue'](_0x6326('0xd'),_0x37a23d[_0x6326('0xe')]);SmsInteractionEvents[_0x6326('0xf')](_0x5a6b4d+':'+_0x30b22e['id'],_0x30b22e);SmsInteractionEvents[_0x6326('0xf')](_0x5a6b4d,_0x30b22e);_0x25ecd8(null);})[_0x6326('0x10')](_0x25ecd8(null));};}for(var e in events){if(events[_0x6326('0x11')](e)){var event=events[e];SmsInteraction[_0x6326('0x12')](e,emitEvent(event));}}module[_0x6326('0x13')]=SmsInteractionEvents; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.model.js b/server/api/smsInteraction/smsInteraction.model.js new file mode 100644 index 0000000..feb9892 --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa2e4=['util','moment','request-promise','path','rimraf','../../config/environment','./smsInteraction.attributes','exports','define','SmsInteraction','sms_interactions','changed','closed','closedAt','format','YYYY-MM-DD\x20HH:mm:ss','lodash'];(function(_0x1d6e3d,_0x51b0c5){var _0x27d1e4=function(_0x37d6c4){while(--_0x37d6c4){_0x1d6e3d['push'](_0x1d6e3d['shift']());}};_0x27d1e4(++_0x51b0c5);}(_0xa2e4,0x153));var _0x4a2e=function(_0x184a28,_0x5edabd){_0x184a28=_0x184a28-0x0;var _0xdd5f60=_0xa2e4[_0x184a28];return _0xdd5f60;};'use strict';var _=require(_0x4a2e('0x0'));var util=require(_0x4a2e('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0x4a2e('0x2'));var BPromise=require('bluebird');var rp=require(_0x4a2e('0x3'));var fs=require('fs');var path=require(_0x4a2e('0x4'));var rimraf=require(_0x4a2e('0x5'));var config=require(_0x4a2e('0x6'));var attributes=require(_0x4a2e('0x7'));module[_0x4a2e('0x8')]=function(_0x3ef64e,_0x8c64a3){return _0x3ef64e[_0x4a2e('0x9')](_0x4a2e('0xa'),attributes,{'tableName':_0x4a2e('0xb'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x292b87,_0x185e22,_0x34aa2c){if(_0x292b87[_0x4a2e('0xc')](_0x4a2e('0xd'))){_0x292b87[_0x4a2e('0xe')]=moment()[_0x4a2e('0xf')](_0x4a2e('0x10'));}_0x34aa2c(null,_0x292b87);}}});}; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.rpc.js b/server/api/smsInteraction/smsInteraction.rpc.js new file mode 100644 index 0000000..3649dff --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe48b=['AddTags','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','./smsInteraction.socket','register','request','then','info','SmsInteraction,\x20%s,\x20%s','code','error','message','request\x20sent','UpdateSmsInteraction','SmsInteraction','update','body','options','raw','where','attributes','limit','debug','stringify','catch','AddTagsToSmsInteraction','addTags','ids','spread'];(function(_0x540e4e,_0x1dd221){var _0x13bd45=function(_0x5a1ef){while(--_0x5a1ef){_0x540e4e['push'](_0x540e4e['shift']());}};_0x13bd45(++_0x1dd221);}(_0xe48b,0xa5));var _0xbe48=function(_0x34a617,_0x3412b){_0x34a617=_0x34a617-0x0;var _0x41b538=_0xe48b[_0x34a617];return _0x41b538;};'use strict';var _=require(_0xbe48('0x0'));var util=require(_0xbe48('0x1'));var moment=require(_0xbe48('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbe48('0x3'));var db=require(_0xbe48('0x4'))['db'];var utils=require(_0xbe48('0x5'));var logger=require(_0xbe48('0x6'))(_0xbe48('0x7'));var config=require(_0xbe48('0x8'));var jayson=require(_0xbe48('0x9'));var client=jayson[_0xbe48('0xa')][_0xbe48('0xb')]({'port':0x232a});config[_0xbe48('0xc')]=_[_0xbe48('0xd')](config[_0xbe48('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xbe48('0xe'))[_0xbe48('0xf')](socket);function respondWithRpcPromise(_0x2c6931,_0x587882,_0x3f75e9){return new BPromise(function(_0x192d27,_0x30a4ea){return client[_0xbe48('0x10')](_0x2c6931,_0x3f75e9)[_0xbe48('0x11')](function(_0x241660){logger[_0xbe48('0x12')](_0xbe48('0x13'),_0x587882,'request\x20sent');logger['debug']('SmsInteraction,\x20%s,\x20%s,\x20%s',_0x587882,'request\x20sent',JSON['stringify'](_0x241660));if(_0x241660['error']){if(_0x241660['error'][_0xbe48('0x14')]===0x1f4){logger[_0xbe48('0x15')](_0xbe48('0x13'),_0x587882,_0x241660[_0xbe48('0x15')][_0xbe48('0x16')]);return _0x30a4ea(_0x241660[_0xbe48('0x15')][_0xbe48('0x16')]);}logger[_0xbe48('0x15')](_0xbe48('0x13'),_0x587882,_0x241660[_0xbe48('0x15')][_0xbe48('0x16')]);return _0x192d27(_0x241660['error'][_0xbe48('0x16')]);}else{logger['info'](_0xbe48('0x13'),_0x587882,_0xbe48('0x17'));_0x192d27(_0x241660['result'][_0xbe48('0x16')]);}})['catch'](function(_0x1c2c25){logger[_0xbe48('0x15')](_0xbe48('0x13'),_0x587882,_0x1c2c25);_0x30a4ea(_0x1c2c25);});});}exports[_0xbe48('0x18')]=function(_0x3e9e63){var _0xb249b8=this;return new Promise(function(_0x531f2d,_0x4a5766){return db[_0xbe48('0x19')][_0xbe48('0x1a')](_0x3e9e63[_0xbe48('0x1b')],{'raw':_0x3e9e63['options']?_0x3e9e63[_0xbe48('0x1c')][_0xbe48('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3e9e63[_0xbe48('0x1c')]?_0x3e9e63[_0xbe48('0x1c')][_0xbe48('0x1e')]||null:null,'attributes':_0x3e9e63['options']?_0x3e9e63[_0xbe48('0x1c')][_0xbe48('0x1f')]||null:null,'limit':_0x3e9e63['options']?_0x3e9e63['options'][_0xbe48('0x20')]||null:null})['then'](function(_0x59997f){logger[_0xbe48('0x12')](_0xbe48('0x18'),_0x3e9e63);logger[_0xbe48('0x21')]('UpdateSmsInteraction',_0x3e9e63,JSON[_0xbe48('0x22')](_0x59997f));_0x531f2d(_0x59997f);})[_0xbe48('0x23')](function(_0x2ff19d){logger[_0xbe48('0x15')](_0xbe48('0x18'),_0x2ff19d['message'],_0x3e9e63);_0x4a5766(_0xb249b8[_0xbe48('0x15')](0x1f4,_0x2ff19d['message']));});});};exports[_0xbe48('0x24')]=function(_0x355cfb){return new Promise(function(_0x2250ed,_0x458bee){return db[_0xbe48('0x19')]['find']({'where':_0x355cfb[_0xbe48('0x1c')]?_0x355cfb['options'][_0xbe48('0x1e')]||null:null})[_0xbe48('0x11')](function(_0x1997e2){if(_0x1997e2){return _0x1997e2[_0xbe48('0x25')](_0x355cfb[_0xbe48('0x1b')][_0xbe48('0x26')],_['omit'](_0x355cfb[_0xbe48('0x1b')],[_0xbe48('0x26'),'id'])||{});}})[_0xbe48('0x27')](function(_0x208d56){logger[_0xbe48('0x12')](_0xbe48('0x28'),_0x355cfb);logger[_0xbe48('0x21')](_0xbe48('0x28'),_0x355cfb,JSON[_0xbe48('0x22')](_0x208d56));_0x2250ed(_0x208d56);})[_0xbe48('0x23')](function(_0x3942d8){logger[_0xbe48('0x15')](_0xbe48('0x28'),_0x3942d8['message'],_0x355cfb);_0x458bee(_this[_0xbe48('0x15')](0x1f4,_0x3942d8[_0xbe48('0x16')]));});});}; \ No newline at end of file diff --git a/server/api/smsInteraction/smsInteraction.socket.js b/server/api/smsInteraction/smsInteraction.socket.js new file mode 100644 index 0000000..6495634 --- /dev/null +++ b/server/api/smsInteraction/smsInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc94=['removeListener','register','smsInteraction:','./smsInteraction.events','update','emit'];(function(_0x2d8546,_0x5e75ee){var _0x4ae61d=function(_0x404e17){while(--_0x404e17){_0x2d8546['push'](_0x2d8546['shift']());}};_0x4ae61d(++_0x5e75ee);}(_0xfc94,0x1ef));var _0x4fc9=function(_0x413feb,_0x10477f){_0x413feb=_0x413feb-0x0;var _0x40ee88=_0xfc94[_0x413feb];return _0x40ee88;};'use strict';var SmsInteractionEvents=require(_0x4fc9('0x0'));var events=['save','remove',_0x4fc9('0x1')];function createListener(_0x286b45,_0xece44){return function(_0x196ae5){_0xece44[_0x4fc9('0x2')](_0x286b45,_0x196ae5);};}function removeListener(_0x500a19,_0x4c8610){return function(){SmsInteractionEvents[_0x4fc9('0x3')](_0x500a19,_0x4c8610);};}exports[_0x4fc9('0x4')]=function(_0x104877){for(var _0x5d5801=0x0,_0x5c093b=events['length'];_0x5d5801<_0x5c093b;_0x5d5801++){var _0x3fdf67=events[_0x5d5801];var _0x4d74b6=createListener(_0x4fc9('0x5')+_0x3fdf67,_0x104877);SmsInteractionEvents['on'](_0x3fdf67,_0x4d74b6);}}; \ No newline at end of file diff --git a/server/api/smsMessage/index.js b/server/api/smsMessage/index.js new file mode 100644 index 0000000..f54c52f --- /dev/null +++ b/server/api/smsMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6f18=['./smsMessage.controller','get','isAuthenticated','index','describe','/:id','post','tracked','sms','smsmessage:create','create','/:id/status','put','update','/:id/accept','accept','/:id/reject','reject','delete','exports','multer','path','express','Router','../../components/auth/service','../../components/interaction/service'];(function(_0x2d85ae,_0x47fd0a){var _0x17c0ec=function(_0x3d18fb){while(--_0x3d18fb){_0x2d85ae['push'](_0x2d85ae['shift']());}};_0x17c0ec(++_0x47fd0a);}(_0x6f18,0x1b4));var _0x86f1=function(_0xe460a,_0x10af0e){_0xe460a=_0xe460a-0x0;var _0x5affc7=_0x6f18[_0xe460a];return _0x5affc7;};'use strict';var multer=require(_0x86f1('0x0'));var util=require('util');var path=require(_0x86f1('0x1'));var timeout=require('connect-timeout');var express=require(_0x86f1('0x2'));var router=express[_0x86f1('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x86f1('0x4'));var interaction=require(_0x86f1('0x5'));var config=require('../../config/environment');var controller=require(_0x86f1('0x6'));router[_0x86f1('0x7')]('/',auth[_0x86f1('0x8')](),controller[_0x86f1('0x9')]);router[_0x86f1('0x7')]('/describe',auth[_0x86f1('0x8')](),controller[_0x86f1('0xa')]);router[_0x86f1('0x7')](_0x86f1('0xb'),auth[_0x86f1('0x8')](),controller['show']);router[_0x86f1('0xc')]('/',auth[_0x86f1('0x8')](),interaction[_0x86f1('0xd')](_0x86f1('0xe'),_0x86f1('0xf')),controller[_0x86f1('0x10')]);router[_0x86f1('0xc')](_0x86f1('0x11'),controller['status']);router[_0x86f1('0x12')](_0x86f1('0xb'),auth[_0x86f1('0x8')](),controller[_0x86f1('0x13')]);router[_0x86f1('0x12')](_0x86f1('0x14'),auth['isAuthenticated'](),controller[_0x86f1('0x15')]);router[_0x86f1('0x12')](_0x86f1('0x16'),auth[_0x86f1('0x8')](),controller[_0x86f1('0x17')]);router[_0x86f1('0x18')](_0x86f1('0xb'),auth[_0x86f1('0x8')](),controller['destroy']);module[_0x86f1('0x19')]=router; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.attributes.js b/server/api/smsMessage/smsMessage.attributes.js new file mode 100644 index 0000000..93cc93b --- /dev/null +++ b/server/api/smsMessage/smsMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdfc3=['TEXT','medium','BOOLEAN','out','STRING','DATE','sequelize','exports'];(function(_0x4b8b31,_0x241247){var _0x5a790f=function(_0x4ebc26){while(--_0x4ebc26){_0x4b8b31['push'](_0x4b8b31['shift']());}};_0x5a790f(++_0x241247);}(_0xdfc3,0x1de));var _0x3dfc=function(_0x342baa,_0x4a110f){_0x342baa=_0x342baa-0x0;var _0x1208f3=_0xdfc3[_0x342baa];return _0x1208f3;};'use strict';var Sequelize=require(_0x3dfc('0x0'));module[_0x3dfc('0x1')]={'body':{'type':Sequelize[_0x3dfc('0x2')](_0x3dfc('0x3')),'allowNull':![]},'read':{'type':Sequelize[_0x3dfc('0x4')],'defaultValue':![]},'direction':{'type':Sequelize['ENUM']('in',_0x3dfc('0x5')),'defaultValue':_0x3dfc('0x5'),'allowNull':![]},'messageId':{'type':Sequelize[_0x3dfc('0x6')](0xbe)},'phone':{'type':Sequelize[_0x3dfc('0x6')]},'readAt':{'type':Sequelize[_0x3dfc('0x7')]},'secret':{'type':Sequelize[_0x3dfc('0x4')],'defaultValue':![]},'providerName':{'type':Sequelize[_0x3dfc('0x6')]},'providerResponse':{'type':Sequelize['TEXT']}}; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.controller.js b/server/api/smsMessage/smsMessage.controller.js new file mode 100644 index 0000000..8c6984d --- /dev/null +++ b/server/api/smsMessage/smsMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe98f=['fields','length','hasOwnProperty','order','sort','where','filters','filter','merge','VIRTUAL','options','SmsMessage','includeAll','include','findAll','catch','show','params','intersection','find','create','body','describe','sms-interactions','accept','sms','read','format','UserId','user','agent','SmsInteraction','SmsInteractionId','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','get','[SMSMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','fullname','email','internal','manual','interface','SIP/%s','channel','motionChannel','EventManager','acceptmessage','[SMSMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','contact','User','event','rejectmessage','SmsAccountId','received\x20delivery\x20report\x20from','inspect','MessageSid','messageId','twilio','plivo','MessageUUID','indexOf','SmsAccount,\x20%s,\x20%s,\x20%s','groupName','DELIVERED','infobip','eml-format','zip-dir','request-promise','moment','util','sox','to-csv','fs-extra','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','register','jayson/promise','client','http','request','then','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','model','query','keys','attributes'];(function(_0x30e0fc,_0x39acb6){var _0x4802ed=function(_0x22a4fd){while(--_0x22a4fd){_0x30e0fc['push'](_0x30e0fc['shift']());}};_0x4802ed(++_0x39acb6);}(_0xe98f,0xde));var _0xfe98=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0xe98f[_0x19950b];return _0x3c6b41;};'use strict';var emlformat=require(_0xfe98('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xfe98('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xfe98('0x2'));var moment=require(_0xfe98('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xfe98('0x4'));var path=require('path');var sox=require(_0xfe98('0x5'));var csv=require(_0xfe98('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xfe98('0x7'));var _=require('lodash');var squel=require(_0xfe98('0x8'));var crypto=require(_0xfe98('0x9'));var jsforce=require(_0xfe98('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xfe98('0x6'));var querystring=require(_0xfe98('0xb'));var Papa=require('papaparse');var Redis=require(_0xfe98('0xc'));var authService=require(_0xfe98('0xd'));var qs=require(_0xfe98('0xe'));var as=require(_0xfe98('0xf'));var hardwareService=require(_0xfe98('0x10'));var logger=require(_0xfe98('0x11'))('api');var utils=require(_0xfe98('0x12'));var config=require(_0xfe98('0x13'));var licenseUtil=require(_0xfe98('0x14'));var db=require(_0xfe98('0x15'))['db'];config[_0xfe98('0x16')]=_['defaults'](config[_0xfe98('0x16')],{'host':_0xfe98('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xfe98('0x16')]));require('./smsMessage.socket')[_0xfe98('0x18')](socket);var jayson=require(_0xfe98('0x19'));var client=jayson[_0xfe98('0x1a')][_0xfe98('0x1b')]({'port':0x232c});var client9002=jayson['client'][_0xfe98('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x4d92fc,_0x416c4c,_0x8c527c,_0x20d565){return new BPromise(function(_0x476932,_0x4deba7){var _0x56c0f4=_0x20d565||client;return _0x56c0f4[_0xfe98('0x1c')](_0x4d92fc,_0x8c527c)[_0xfe98('0x1d')](function(_0x31bb37){logger['info'](_0xfe98('0x1e'),_0x416c4c,_0xfe98('0x1f'));logger[_0xfe98('0x20')](_0xfe98('0x21'),_0x416c4c,_0xfe98('0x1f'),JSON[_0xfe98('0x22')](_0x31bb37));if(_0x31bb37[_0xfe98('0x23')]){if(_0x31bb37['error'][_0xfe98('0x24')]===0x1f4){logger['error'](_0xfe98('0x1e'),_0x416c4c,_0x31bb37['error']['message']);return _0x4deba7(_0x31bb37[_0xfe98('0x23')][_0xfe98('0x25')]);}logger[_0xfe98('0x23')](_0xfe98('0x1e'),_0x416c4c,_0x31bb37['error'][_0xfe98('0x25')]);return _0x476932(_0x31bb37['error'][_0xfe98('0x25')]);}else{logger[_0xfe98('0x26')](_0xfe98('0x1e'),_0x416c4c,'request\x20sent');_0x476932(_0x31bb37['result'][_0xfe98('0x25')]);}})['catch'](function(_0x7b629e){logger[_0xfe98('0x23')]('SmsMessage,\x20%s,\x20%s',_0x416c4c,_0x7b629e);_0x4deba7(_0x7b629e);});});}function respondWithStatusCode(_0x3dc31d,_0x25f675){_0x25f675=_0x25f675||0xcc;return function(_0x21325b){if(_0x21325b){return _0x3dc31d[_0xfe98('0x27')](_0x25f675);}return _0x3dc31d['status'](_0x25f675)['end']();};}function respondWithResult(_0x5921f0,_0x51da63){_0x51da63=_0x51da63||0xc8;return function(_0xc68e94){if(_0xc68e94){return _0x5921f0[_0xfe98('0x28')](_0x51da63)[_0xfe98('0x29')](_0xc68e94);}};}function respondWithFilteredResult(_0x21c730,_0x1f3fb5){return function(_0x1017b5){if(_0x1017b5){var _0x3029=typeof _0x1f3fb5[_0xfe98('0x2a')]===_0xfe98('0x2b')&&typeof _0x1f3fb5[_0xfe98('0x2c')]==='undefined';var _0x1bed97=_0x1017b5[_0xfe98('0x2d')];var _0x9eb9c9=_0x3029?0x0:_0x1f3fb5[_0xfe98('0x2a')];var _0x3094df=_0x3029?_0x1017b5[_0xfe98('0x2d')]:_0x1f3fb5[_0xfe98('0x2a')]+_0x1f3fb5[_0xfe98('0x2c')];var _0xdbb15e;if(_0x3094df>=_0x1bed97){_0x3094df=_0x1bed97;_0xdbb15e=0xc8;}else{_0xdbb15e=0xce;}_0x21c730[_0xfe98('0x28')](_0xdbb15e);return _0x21c730[_0xfe98('0x2e')](_0xfe98('0x2f'),_0x9eb9c9+'-'+_0x3094df+'/'+_0x1bed97)[_0xfe98('0x29')](_0x1017b5);}return null;};}function patchUpdates(_0x269899){return function(_0x9b0a91){try{jsonpatch['apply'](_0x9b0a91,_0x269899,!![]);}catch(_0x504b58){return BPromise[_0xfe98('0x30')](_0x504b58);}return _0x9b0a91[_0xfe98('0x31')]();};}function saveUpdates(_0x582efe,_0x1a1288){return function(_0x405ebf){if(_0x405ebf){return _0x405ebf[_0xfe98('0x32')](_0x582efe)[_0xfe98('0x1d')](function(_0x22a132){return _0x22a132;});}return null;};}function removeEntity(_0x5ceb1c,_0x2712b9){return function(_0x3a8ad9){if(_0x3a8ad9){return _0x3a8ad9[_0xfe98('0x33')]()[_0xfe98('0x1d')](function(){_0x5ceb1c[_0xfe98('0x28')](0xcc)['end']();});}};}function handleEntityNotFound(_0x17dd03,_0x596609){return function(_0x19f0f1){if(!_0x19f0f1){_0x17dd03[_0xfe98('0x27')](0x194);}return _0x19f0f1;};}function handleError(_0x20738c,_0x15a19b){_0x15a19b=_0x15a19b||0x1f4;return function(_0x4131a4){logger[_0xfe98('0x23')](_0x4131a4[_0xfe98('0x34')]);if(_0x4131a4[_0xfe98('0x35')]){delete _0x4131a4['name'];}_0x20738c['status'](_0x15a19b)[_0xfe98('0x36')](_0x4131a4);};}exports[_0xfe98('0x37')]=function(_0x4002c1,_0x35502e){var _0x207a6c={},_0x535a61={},_0x3e996c={'count':0x0,'rows':[]};var _0xb371b=_[_0xfe98('0x38')](db['SmsMessage'][_0xfe98('0x39')],function(_0x30723b){return{'name':_0x30723b[_0xfe98('0x3a')],'type':_0x30723b[_0xfe98('0x3b')]['key']};});_0x535a61[_0xfe98('0x3c')]=_[_0xfe98('0x38')](_0xb371b,'name');_0x535a61[_0xfe98('0x3d')]=_[_0xfe98('0x3e')](_0x4002c1[_0xfe98('0x3d')]);_0x535a61['filters']=_['intersection'](_0x535a61['model'],_0x535a61['query']);_0x207a6c[_0xfe98('0x3f')]=_['intersection'](_0x535a61[_0xfe98('0x3c')],qs[_0xfe98('0x40')](_0x4002c1['query'][_0xfe98('0x40')]));_0x207a6c[_0xfe98('0x3f')]=_0x207a6c[_0xfe98('0x3f')][_0xfe98('0x41')]?_0x207a6c[_0xfe98('0x3f')]:_0x535a61[_0xfe98('0x3c')];if(!_0x4002c1[_0xfe98('0x3d')][_0xfe98('0x42')]('nolimit')){_0x207a6c[_0xfe98('0x2c')]=qs[_0xfe98('0x2c')](_0x4002c1['query'][_0xfe98('0x2c')]);_0x207a6c[_0xfe98('0x2a')]=qs[_0xfe98('0x2a')](_0x4002c1[_0xfe98('0x3d')]['offset']);}_0x207a6c[_0xfe98('0x43')]=qs['sort'](_0x4002c1[_0xfe98('0x3d')][_0xfe98('0x44')]);_0x207a6c[_0xfe98('0x45')]=qs[_0xfe98('0x46')](_['pick'](_0x4002c1[_0xfe98('0x3d')],_0x535a61[_0xfe98('0x46')]),_0xb371b);if(_0x4002c1[_0xfe98('0x3d')][_0xfe98('0x47')]){_0x207a6c[_0xfe98('0x45')]=_[_0xfe98('0x48')](_0x207a6c['where'],{'$or':_[_0xfe98('0x38')](_0xb371b,function(_0x1d430a){if(_0x1d430a[_0xfe98('0x3b')]!==_0xfe98('0x49')){var _0x46d5bb={};_0x46d5bb[_0x1d430a[_0xfe98('0x35')]]={'$like':'%'+_0x4002c1[_0xfe98('0x3d')]['filter']+'%'};return _0x46d5bb;}})});}_0x207a6c=_[_0xfe98('0x48')]({},_0x207a6c,_0x4002c1[_0xfe98('0x4a')]);var _0x183385={'where':_0x207a6c[_0xfe98('0x45')]};return db[_0xfe98('0x4b')]['count'](_0x183385)[_0xfe98('0x1d')](function(_0x5d9cb9){_0x3e996c[_0xfe98('0x2d')]=_0x5d9cb9;if(_0x4002c1[_0xfe98('0x3d')][_0xfe98('0x4c')]){_0x207a6c[_0xfe98('0x4d')]=[{'all':!![]}];}return db[_0xfe98('0x4b')][_0xfe98('0x4e')](_0x207a6c);})[_0xfe98('0x1d')](function(_0x754f39){_0x3e996c['rows']=_0x754f39;return _0x3e996c;})[_0xfe98('0x1d')](respondWithFilteredResult(_0x35502e,_0x207a6c))[_0xfe98('0x4f')](handleError(_0x35502e,null));};exports[_0xfe98('0x50')]=function(_0x1720d3,_0x5ad61e){var _0x26cb3d={'raw':!![],'where':{'id':_0x1720d3[_0xfe98('0x51')]['id']}},_0xc0573c={};_0xc0573c[_0xfe98('0x3c')]=_[_0xfe98('0x3e')](db[_0xfe98('0x4b')]['rawAttributes']);_0xc0573c[_0xfe98('0x3d')]=_[_0xfe98('0x3e')](_0x1720d3[_0xfe98('0x3d')]);_0xc0573c[_0xfe98('0x46')]=_[_0xfe98('0x52')](_0xc0573c['model'],_0xc0573c['query']);_0x26cb3d[_0xfe98('0x3f')]=_[_0xfe98('0x52')](_0xc0573c[_0xfe98('0x3c')],qs[_0xfe98('0x40')](_0x1720d3[_0xfe98('0x3d')][_0xfe98('0x40')]));_0x26cb3d[_0xfe98('0x3f')]=_0x26cb3d[_0xfe98('0x3f')][_0xfe98('0x41')]?_0x26cb3d[_0xfe98('0x3f')]:_0xc0573c['model'];if(_0x1720d3[_0xfe98('0x3d')]['includeAll']){_0x26cb3d[_0xfe98('0x4d')]=[{'all':!![]}];}_0x26cb3d=_[_0xfe98('0x48')]({},_0x26cb3d,_0x1720d3[_0xfe98('0x4a')]);return db['SmsMessage'][_0xfe98('0x53')](_0x26cb3d)['then'](handleEntityNotFound(_0x5ad61e,null))['then'](respondWithResult(_0x5ad61e,null))[_0xfe98('0x4f')](handleError(_0x5ad61e,null));};exports[_0xfe98('0x54')]=function(_0x2d7246,_0x3dfb51){return db[_0xfe98('0x4b')][_0xfe98('0x54')](_0x2d7246['body'],{})[_0xfe98('0x1d')](respondWithResult(_0x3dfb51,0xc9))['catch'](handleError(_0x3dfb51,null));};exports[_0xfe98('0x32')]=function(_0x4a5690,_0x54823a){if(_0x4a5690['body']['id']){delete _0x4a5690[_0xfe98('0x55')]['id'];}return db[_0xfe98('0x4b')][_0xfe98('0x53')]({'where':{'id':_0x4a5690[_0xfe98('0x51')]['id']}})['then'](handleEntityNotFound(_0x54823a,null))[_0xfe98('0x1d')](saveUpdates(_0x4a5690['body'],null))[_0xfe98('0x1d')](respondWithResult(_0x54823a,null))[_0xfe98('0x4f')](handleError(_0x54823a,null));};exports['destroy']=function(_0x7096d5,_0x6299e9){return db[_0xfe98('0x4b')][_0xfe98('0x53')]({'where':{'id':_0x7096d5['params']['id']}})[_0xfe98('0x1d')](handleEntityNotFound(_0x6299e9,null))[_0xfe98('0x1d')](removeEntity(_0x6299e9,null))[_0xfe98('0x4f')](handleError(_0x6299e9,null));};exports[_0xfe98('0x56')]=function(_0x4ab9c4,_0x4192e0){return db['SmsMessage'][_0xfe98('0x56')]()[_0xfe98('0x1d')](respondWithResult(_0x4192e0,null))[_0xfe98('0x4f')](handleError(_0x4192e0,null));};var interaction_log=require(_0xfe98('0x11'))(_0xfe98('0x57'));exports[_0xfe98('0x58')]=function(_0x4435d1,_0x247044,_0x36a92f){var _0x3b8626={'agent':{},'channel':_0xfe98('0x59')};if(_0x4435d1[_0xfe98('0x55')]['id']){delete _0x4435d1[_0xfe98('0x55')]['id'];}_0x4435d1['body'][_0xfe98('0x5a')]=!![];_0x4435d1['body']['readAt']=moment()[_0xfe98('0x5b')]('YYYY-MM-DD\x20HH:mm:ss');_0x4435d1[_0xfe98('0x55')][_0xfe98('0x5c')]=_0x4435d1[_0xfe98('0x55')][_0xfe98('0x5c')]||_0x4435d1[_0xfe98('0x5d')]['id'];_0x3b8626[_0xfe98('0x5e')]['id']=_0x4435d1[_0xfe98('0x55')][_0xfe98('0x5c')];return db[_0xfe98('0x4b')][_0xfe98('0x53')]({'where':{'id':_0x4435d1[_0xfe98('0x51')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x247044,null))[_0xfe98('0x1d')](saveUpdates(_0x4435d1[_0xfe98('0x55')],null))[_0xfe98('0x1d')](function(_0x3d86ea){if(_0x3d86ea){_0x3b8626[_0xfe98('0x25')]=_0x3d86ea['get']({'plain':!![]});return db[_0xfe98('0x5f')][_0xfe98('0x53')]({'where':{'id':_0x3d86ea[_0xfe98('0x60')]}});}return null;})[_0xfe98('0x1d')](handleEntityNotFound(_0x247044,null))[_0xfe98('0x1d')](function(_0x15f053){if(_0x15f053){return _0x15f053['update']({'UserId':_0x4435d1[_0xfe98('0x55')][_0xfe98('0x5c')],'read1stAt':_[_0xfe98('0x61')](_0x15f053[_0xfe98('0x62')])?moment()[_0xfe98('0x5b')](_0xfe98('0x63')):undefined});}return null;})[_0xfe98('0x1d')](function(_0x534f43){if(_0x534f43){_0x3b8626[_0xfe98('0x64')]=_0x534f43[_0xfe98('0x65')]({'plain':!![]});interaction_log[_0xfe98('0x26')](_0xfe98('0x66'),_0x4435d1[_0xfe98('0x5d')]['id'],_0x4435d1[_0xfe98('0x5d')][_0xfe98('0x35')],_0x4435d1[_0xfe98('0x5d')][_0xfe98('0x67')],_0x3b8626[_0xfe98('0x64')]['id'],_0x4435d1[_0xfe98('0x55')]?JSON[_0xfe98('0x22')](_0x4435d1[_0xfe98('0x55')]):_0xfe98('0x68'));return respondWithRpcPromise(_0xfe98('0x69'),_0xfe98('0x6a'),_0x3b8626);}return null;})[_0xfe98('0x1d')](function(_0x172754){var _0x259e75=_0xfe98('0x6b')+_0x172754[_0xfe98('0x25')][_0xfe98('0x6c')];return db[_0xfe98('0x6d')][_0xfe98('0x3d')](_0x259e75,{'type':db[_0xfe98('0x6e')][_0xfe98('0x6f')][_0xfe98('0x70')],'raw':!![]})['then'](function(_0x5b0125){return _0x5b0125;});})[_0xfe98('0x1d')](function(_0x1ab844){if(_0x1ab844){_0x3b8626[_0xfe98('0x25')]['contact']=_0x1ab844[0x0];if(!_0x4435d1['body'][_0xfe98('0x5c')])return;return db['User'][_0xfe98('0x53')]({'where':{'id':_0x4435d1[_0xfe98('0x55')]['UserId'],'role':_0xfe98('0x5e')},'attributes':['id',_0xfe98('0x35'),_0xfe98('0x71'),_0xfe98('0x72'),_0xfe98('0x73')],'raw':!![]});}return null;})[_0xfe98('0x1d')](function(_0x271c09){if(!_0x271c09)return null;_0x3b8626[_0xfe98('0x25')][_0xfe98('0x5e')]=_0x271c09;return _0x3b8626;})['then'](function(_0x2c9d80){if(_0x2c9d80){if(_0x4435d1['body'][_0xfe98('0x74')]){_0x3b8626[_0xfe98('0x25')][_0xfe98('0x75')]=util[_0xfe98('0x5b')](_0xfe98('0x76'),_0x4435d1[_0xfe98('0x5d')][_0xfe98('0x35')]);_0x3b8626[_0xfe98('0x25')][_0xfe98('0x77')]=_0x3b8626[_0xfe98('0x77')];_0x3b8626[_0xfe98('0x25')][_0xfe98('0x78')]=_0x3b8626[_0xfe98('0x77')];_0x3b8626['message']['event']=_0xfe98('0x58');return respondWithRpcPromise(_0xfe98('0x79'),_0xfe98('0x79'),{'event':_0xfe98('0x7a'),'message':_0x3b8626[_0xfe98('0x25')]},client9002)[_0xfe98('0x1d')](function(){return _0x3b8626;});}return _0x3b8626;}return null;})[_0xfe98('0x1d')](respondWithResult(_0x247044,null))[_0xfe98('0x4f')](handleError(_0x247044,null));};var interaction_log=require(_0xfe98('0x11'))(_0xfe98('0x57'));exports[_0xfe98('0x30')]=function(_0x25dea1,_0x162294,_0x27f70e){var _0x3ddb98={'agent':{},'channel':_0xfe98('0x59')};if(_0x25dea1['body']['id']){delete _0x25dea1[_0xfe98('0x55')]['id'];}_0x25dea1[_0xfe98('0x55')][_0xfe98('0x5c')]=_0x25dea1['body'][_0xfe98('0x5c')]||_0x25dea1[_0xfe98('0x5d')]['id'];_0x3ddb98[_0xfe98('0x5e')]['id']=_0x25dea1[_0xfe98('0x55')][_0xfe98('0x5c')];return db['SmsMessage']['find']({'where':{'id':_0x25dea1[_0xfe98('0x51')]['id'],'UserId':null}})[_0xfe98('0x1d')](handleEntityNotFound(_0x162294,null))['then'](function(_0x56d390){if(_0x56d390){_0x3ddb98['message']=_0x56d390['get']({'plain':!![]});return db[_0xfe98('0x5f')][_0xfe98('0x53')]({'where':{'id':_0x56d390[_0xfe98('0x60')]}});}return null;})['then'](handleEntityNotFound(_0x162294,null))[_0xfe98('0x1d')](function(_0x450c06){if(_0x450c06){_0x3ddb98[_0xfe98('0x64')]=_0x450c06[_0xfe98('0x65')]({'plain':!![]});interaction_log[_0xfe98('0x26')](_0xfe98('0x7b'),_0x25dea1[_0xfe98('0x5d')]['id'],_0x25dea1['user']['name'],_0x25dea1['user'][_0xfe98('0x67')],_0x3ddb98[_0xfe98('0x64')]['id'],_0x25dea1[_0xfe98('0x55')]?JSON[_0xfe98('0x22')](_0x25dea1[_0xfe98('0x55')]):_0xfe98('0x68'));return respondWithRpcPromise(_0xfe98('0x7c'),_0xfe98('0x7d'),_0x3ddb98);}return null;})['then'](function(_0x5df11e){var _0x55322a='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x5df11e[_0xfe98('0x25')][_0xfe98('0x6c')];return db[_0xfe98('0x6d')][_0xfe98('0x3d')](_0x55322a,{'type':db[_0xfe98('0x6e')][_0xfe98('0x6f')]['SELECT'],'raw':!![]})[_0xfe98('0x1d')](function(_0x2798d9){return _0x2798d9;});})['then'](function(_0x4a9028){if(_0x4a9028){_0x3ddb98[_0xfe98('0x25')][_0xfe98('0x7e')]=_0x4a9028[0x0];if(!_0x25dea1['body'][_0xfe98('0x5c')])return;return db[_0xfe98('0x7f')]['find']({'where':{'id':_0x25dea1[_0xfe98('0x55')]['UserId'],'role':_0xfe98('0x5e')},'attributes':['id',_0xfe98('0x35'),_0xfe98('0x71'),_0xfe98('0x72'),'internal'],'raw':!![]});}return null;})[_0xfe98('0x1d')](function(_0x42921a){if(!_0x42921a)return null;_0x3ddb98[_0xfe98('0x25')]['agent']=_0x42921a;return _0x3ddb98;})[_0xfe98('0x1d')](function(_0x406758){if(_0x406758){_0x406758['message'][_0xfe98('0x75')]=util[_0xfe98('0x5b')](_0xfe98('0x76'),_0x25dea1[_0xfe98('0x5d')]['name']);_0x406758[_0xfe98('0x25')][_0xfe98('0x77')]=_0x3ddb98[_0xfe98('0x77')];_0x406758[_0xfe98('0x25')]['motionChannel']=_0x3ddb98['channel'];_0x406758['message'][_0xfe98('0x80')]=_0xfe98('0x30');respondWithRpcPromise(_0xfe98('0x79'),_0xfe98('0x79'),{'event':_0xfe98('0x81'),'message':_0x406758[_0xfe98('0x25')]},client9002);return _0x3ddb98;}return null;})[_0xfe98('0x1d')](respondWithResult(_0x162294,null))[_0xfe98('0x4f')](handleError(_0x162294,null));};exports[_0xfe98('0x28')]=function(_0x1f21f7,_0xd367d9,_0x5cf971){if(_0x1f21f7[_0xfe98('0x55')]['id']){delete _0x1f21f7['body']['id'];}var _0xf1118;return db[_0xfe98('0x4b')][_0xfe98('0x53')]({'where':{'id':_0x1f21f7[_0xfe98('0x51')]['id']}})['then'](handleEntityNotFound(_0xd367d9,null))['then'](function(_0x1598db){if(_0x1598db){_0xf1118=_0x1598db;return db['SmsAccount'][_0xfe98('0x53')]({'where':{'id':_0x1598db[_0xfe98('0x82')]}});}})[_0xfe98('0x1d')](handleEntityNotFound(_0xd367d9,null))[_0xfe98('0x1d')](function(_0x362854){if(_0x362854){logger[_0xfe98('0x20')](_0xfe98('0x21'),_0xfe98('0x28'),_0xfe98('0x83'),_0x362854[_0xfe98('0x3b')],util[_0xfe98('0x84')](_0x1f21f7['body'],{'showHidden':![],'depth':null}));switch(_0x362854[_0xfe98('0x3b')]){case'twilio':if(_0x1f21f7[_0xfe98('0x55')]['MessageSid']&&_0x1f21f7[_0xfe98('0x55')][_0xfe98('0x85')]===_0xf1118[_0xfe98('0x86')]){return _0xf1118[_0xfe98('0x32')]({'read':!![]});}else{logger[_0xfe98('0x23')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xfe98('0x28'),_0xfe98('0x87'),util['inspect'](_0x1f21f7[_0xfe98('0x55')],{'showHidden':![],'depth':null}));}break;case _0xfe98('0x88'):if(_0x1f21f7[_0xfe98('0x55')][_0xfe98('0x89')]&&_0x1f21f7[_0xfe98('0x55')][_0xfe98('0x89')]===_0xf1118[_0xfe98('0x86')]&&_[_0xfe98('0x8a')](['sent','delivered'],_0x1f21f7[_0xfe98('0x55')]['Status'])>=0x0){return _0xf1118[_0xfe98('0x32')]({'read':!![]});}else{logger[_0xfe98('0x23')](_0xfe98('0x8b'),_0xfe98('0x28'),'plivio',util['inspect'](_0x1f21f7[_0xfe98('0x55')],{'showHidden':![],'depth':null}));}break;case'infobip':var _0x4b0c1e=_0x1f21f7[_0xfe98('0x55')]['results'][0x0];if(_0x4b0c1e[_0xfe98('0x28')][_0xfe98('0x8c')]===_0xfe98('0x8d')){return _0xf1118[_0xfe98('0x32')]({'read':!![]});}else{logger[_0xfe98('0x23')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0xfe98('0x28'),_0xfe98('0x8e'),util[_0xfe98('0x84')](_0x1f21f7[_0xfe98('0x55')],{'showHidden':![],'depth':null}));}break;}return _0xf1118;}})[_0xfe98('0x1d')](respondWithResult(_0xd367d9,null))[_0xfe98('0x4f')](handleError(_0xd367d9,null));}; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.events.js b/server/api/smsMessage/smsMessage.events.js new file mode 100644 index 0000000..30da7e4 --- /dev/null +++ b/server/api/smsMessage/smsMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5af1=['hasOwnProperty','hook','exports','events','../../mysqldb','SmsMessage','setMaxListeners','save','update','emit'];(function(_0x3b720b,_0x5ec82e){var _0x1ce3fe=function(_0x167a43){while(--_0x167a43){_0x3b720b['push'](_0x3b720b['shift']());}};_0x1ce3fe(++_0x5ec82e);}(_0x5af1,0xfd));var _0x15af=function(_0x4e93a9,_0x413f30){_0x4e93a9=_0x4e93a9-0x0;var _0x43013c=_0x5af1[_0x4e93a9];return _0x43013c;};'use strict';var EventEmitter=require(_0x15af('0x0'));var SmsMessage=require(_0x15af('0x1'))['db'][_0x15af('0x2')];var SmsMessageEvents=new EventEmitter();SmsMessageEvents[_0x15af('0x3')](0x0);var events={'afterCreate':_0x15af('0x4'),'afterUpdate':_0x15af('0x5'),'afterDestroy':'remove'};function emitEvent(_0x304117){return function(_0x40afd9,_0x5c1f3b,_0x47ac6e){SmsMessageEvents[_0x15af('0x6')](_0x304117+':'+_0x40afd9['id'],_0x40afd9);SmsMessageEvents['emit'](_0x304117,_0x40afd9);_0x47ac6e(null);};}for(var e in events){if(events[_0x15af('0x7')](e)){var event=events[e];SmsMessage[_0x15af('0x8')](e,emitEvent(event));}}module[_0x15af('0x9')]=SmsMessageEvents; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.model.js b/server/api/smsMessage/smsMessage.model.js new file mode 100644 index 0000000..4e1d4ad --- /dev/null +++ b/server/api/smsMessage/smsMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9528=['body','remote','/api/sms/messages/','/status?token=','token','sid','update','error','SmsMessage,\x20%s,\x20%s,\x20%s','inspect','afterCreate','skebby','username','smsMethod','sender','login?username=','&password=','password','GET','split','POST','user_key','internal_order_id','read','Missing\x20parameters:\x20username,\x20password','connectel','senderString','requestid','deliveryReport','clicksend','xCALLY\x20Motion','%s:%s','https://rest.clicksend.com/v3/sms/send','format','toString','base64','http_code','data','head','message_id','clickSend','authId','https://api.plivo.com/v1/Account/%s/Message/','Basic\x20%s','plivo','Missing\x20parameters:\x20authId,\x20authToken','baseUrl','/auth/1/session','/sms/2/text/advanced','application/json','IBSSO\x20','infobip','Missing\x20parameters:\x20base_url','csc','crypto','login','text','keys','sort','length','apiKey','md5','digest','hex','signature=','/external/get/send.php?','id_sms','clickatell','https://platform.clickatell.com/messages','uuid','UTF-8','apiMessageId','bandwidth','accountId','intelepeer','https://api.intelepeer.com/_rest/v4/app/sms/send','Bearer\x20','message','https://api.intelepeer.com/_rest/v4/app/sms/mdr','refid','status','Token\x20not\x20received','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./smsMessage.attributes','exports','define','messageId','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','SmsInteraction','findOne','then','createdAt','catch','find','SmsAccountId','type','twilio','authToken','phone','accountSid','messages','create'];(function(_0x38f82a,_0x7d8152){var _0x339806=function(_0x4ae87d){while(--_0x4ae87d){_0x38f82a['push'](_0x38f82a['shift']());}};_0x339806(++_0x7d8152);}(_0x9528,0x1bc));var _0x8952=function(_0x5e42a3,_0x5b36a9){_0x5e42a3=_0x5e42a3-0x0;var _0x17d0a6=_0x9528[_0x5e42a3];return _0x17d0a6;};'use strict';var _=require(_0x8952('0x0'));var util=require(_0x8952('0x1'));var logger=require(_0x8952('0x2'))(_0x8952('0x3'));var moment=require(_0x8952('0x4'));var BPromise=require(_0x8952('0x5'));var rp=require(_0x8952('0x6'));var fs=require('fs');var path=require(_0x8952('0x7'));var rimraf=require(_0x8952('0x8'));var config=require(_0x8952('0x9'));var attributes=require(_0x8952('0xa'));module[_0x8952('0xb')]=function(_0x24eebd,_0x142f2f){return _0x24eebd[_0x8952('0xc')]('SmsMessage',attributes,{'tableName':'sms_messages','paranoid':![],'indexes':[{'name':'messageId','fields':[_0x8952('0xd')]},{'name':'fti_sms_messages','fields':['body'],'type':_0x8952('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2f3db6,_0xacbf1d,_0x37ff42){var _0x3c6e10=_0x24eebd[_0x8952('0xf')];var _0xd22858=_0x2f3db6[_0x8952('0x10')]({'plain':!![]});if(_0xd22858[_0x8952('0x11')][_0x8952('0x12')]()==='in'||_0xd22858[_0x8952('0x11')][_0x8952('0x12')]()===_0x8952('0x13')&&!_0xd22858[_0x8952('0x14')]&&!_[_0x8952('0x15')](_0xd22858['UserId'])&&!_[_0x8952('0x15')](_0xd22858['SmsInteractionId'])){_0x3c6e10[_0x8952('0x16')][_0x8952('0x17')]({'where':{'id':_0xd22858['SmsInteractionId']}})[_0x8952('0x18')](function(_0x466474){if(_0x466474){_0x466474['update']({'lastMsgAt':_0xd22858[_0x8952('0x19')],'lastMsgDirection':_0xd22858[_0x8952('0x11')][_0x8952('0x12')]()});}})[_0x8952('0x1a')](function(_0x526a3d){console['error'](_0x526a3d);});}if(_0xd22858[_0x8952('0x11')]===_0x8952('0x13')&&!_0xd22858['secret']){var _0x35aeed;_0x3c6e10['SmsAccount'][_0x8952('0x1b')]({'where':{'id':_0xd22858[_0x8952('0x1c')]},'raw':!![]})[_0x8952('0x18')](function(_0x5ad27b){_0x35aeed=_0x5ad27b;if(_0x35aeed&&_0x35aeed[_0x8952('0x1d')]){switch(_0x35aeed[_0x8952('0x1d')]){case _0x8952('0x1e'):var _0x4fb74a=require(_0x8952('0x1e'));if(_0x35aeed['accountSid']&&_0x35aeed[_0x8952('0x1f')]&&_0x35aeed[_0x8952('0x20')]){var _0x32fee5=new _0x4fb74a(_0x35aeed[_0x8952('0x21')],_0x35aeed[_0x8952('0x1f')]);_0x32fee5[_0x8952('0x22')][_0x8952('0x23')]({'body':_0xd22858[_0x8952('0x24')],'to':_0xd22858[_0x8952('0x20')],'from':_0x35aeed['phone'],'statusCallback':_0x35aeed[_0x8952('0x25')]+_0x8952('0x26')+_0xd22858['id']+_0x8952('0x27')+_0x35aeed[_0x8952('0x28')]})['then'](function(_0x5b76bc){if(_0x5b76bc[_0x8952('0x29')]){return _0x2f3db6[_0x8952('0x2a')]({'messageId':_0x5b76bc['sid']});}})['catch'](function(_0x10fbac){logger[_0x8952('0x2b')](_0x8952('0x2c'),'afterCreate',_0x8952('0x1e'),util[_0x8952('0x2d')](_0x10fbac,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x1e'),'Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken');}break;case _0x8952('0x2f'):var _0x2972e6='https://api.skebby.it/API/v1.0/REST/';if(_0x35aeed[_0x8952('0x30')]&&_0x35aeed['password']){var _0x1657dd={'recipient':[_0xd22858[_0x8952('0x20')]],'message':_0xd22858[_0x8952('0x24')],'message_type':_0x35aeed[_0x8952('0x31')]};if(_0x35aeed[_0x8952('0x31')]&&_0x35aeed[_0x8952('0x31')]!=='SI'){_0x1657dd[_0x8952('0x32')]=_0x35aeed[_0x8952('0x20')];}var _0x3ba6d5={'url':_0x2972e6+_0x8952('0x33')+_0x35aeed[_0x8952('0x30')]+_0x8952('0x34')+_0x35aeed[_0x8952('0x35')],'method':_0x8952('0x36')};rp(_0x3ba6d5)['then'](function(_0x129f76){var _0x2a41e6=_0x129f76[_0x8952('0x37')](';');var _0x40ef55={'user_key':_0x2a41e6[0x0],'session_key':_0x2a41e6[0x1]};_0x3ba6d5={'url':_0x2972e6+'sms','method':_0x8952('0x38'),'headers':{'user_key':_0x40ef55[_0x8952('0x39')],'Session_key':_0x40ef55['session_key']},'json':!![],'body':_0x1657dd};return rp(_0x3ba6d5);})[_0x8952('0x18')](function(_0x25f05c){if(_0x25f05c['total_sent']>=0x1){var _0x45b430={'messageId':_0x25f05c[_0x8952('0x3a')]};if(_0x35aeed[_0x8952('0x31')]!=='GP'||!_0x35aeed['deliveryReport']){_0x45b430[_0x8952('0x3b')]=!![];}return _0x2f3db6[_0x8952('0x2a')](_0x45b430);}else{return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x2f'),util[_0x8952('0x2d')](_0x25f05c,{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x4dd23a){return logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x2f'),util[_0x8952('0x2d')](_0x4dd23a,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),'skebby',_0x8952('0x3c'));}break;case _0x8952('0x3d'):if(_0x35aeed[_0x8952('0x1f')]){var _0x314602={'recipient':_0xd22858[_0x8952('0x20')],'message':_0xd22858['body'],'sender':_0x35aeed[_0x8952('0x3e')]||_0x35aeed[_0x8952('0x20')],'authorization':_0x35aeed['authToken']};var _0xacbf1d={'method':_0x8952('0x38'),'uri':'https://smsapi.connectel.se/api/v2/send/','body':_0x314602,'json':!![]};rp(_0xacbf1d)[_0x8952('0x18')](function(_0x1197a7){var _0x2730b3={'messageId':_0x1197a7[_0x8952('0x3f')]};if(!_0x35aeed[_0x8952('0x40')]){_0x2730b3[_0x8952('0x3b')]=!![];}return _0x2f3db6['update'](_0x2730b3);})['catch'](function(_0x24b94b){logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x3d'),util[_0x8952('0x2d')](_0x24b94b,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x3d'),'Missing\x20parameters:\x20authToken');}break;case _0x8952('0x41'):if(_0x35aeed[_0x8952('0x30')]&&_0x35aeed[_0x8952('0x35')]){var _0x314602={'messages':[{'source':_0x8952('0x42'),'to':_0xd22858[_0x8952('0x20')],'body':_0xd22858['body'],'from':_0x35aeed[_0x8952('0x3e')]||_0x35aeed[_0x8952('0x20')]}]};var _0x2ea7c3=util['format'](_0x8952('0x43'),_0x35aeed['username'],_0x35aeed[_0x8952('0x35')]);var _0xacbf1d={'method':_0x8952('0x38'),'uri':_0x8952('0x44'),'body':_0x314602,'headers':{'Authorization':util[_0x8952('0x45')]('Basic\x20%s',new Buffer(_0x2ea7c3)[_0x8952('0x46')](_0x8952('0x47')))},'json':!![]};rp(_0xacbf1d)[_0x8952('0x18')](function(_0xef00be){if(_0xef00be[_0x8952('0x48')]>=0xc8&&_0xef00be[_0x8952('0x48')]<=0xce){if(_0xef00be['data']&&_0xef00be[_0x8952('0x49')]['queued_count']>0x0){var _0x46522f=_[_0x8952('0x4a')](_0xef00be[_0x8952('0x49')][_0x8952('0x22')]);var _0x36b433={'messageId':_0x46522f[_0x8952('0x4b')]};if(!_0x35aeed[_0x8952('0x40')]){_0x36b433[_0x8952('0x3b')]=!![];}return _0x2f3db6[_0x8952('0x2a')](_0x36b433);}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x4c'),util[_0x8952('0x2d')](_0xef00be,{'showHidden':![],'depth':null}));}}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate','clickSend',util['inspect'](_0xef00be,{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x5959d0){logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x4c'),util['inspect'](_0x5959d0,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x4c'),_0x8952('0x3c'));}break;case'plivo':if(_0x35aeed[_0x8952('0x4d')]&&_0x35aeed['authToken']){var _0x314602={'dst':_0xd22858[_0x8952('0x20')],'text':_0xd22858['body'],'src':_0x35aeed['senderString']||_0x35aeed[_0x8952('0x20')],'url':_0x35aeed[_0x8952('0x25')]+'/api/sms/messages/'+_0xd22858['id']+_0x8952('0x27')+_0x35aeed[_0x8952('0x28')]};var _0x2ea7c3=util[_0x8952('0x45')](_0x8952('0x43'),_0x35aeed[_0x8952('0x4d')],_0x35aeed['authToken']);var _0xacbf1d={'method':_0x8952('0x38'),'uri':util[_0x8952('0x45')](_0x8952('0x4e'),_0x35aeed[_0x8952('0x4d')]),'body':_0x314602,'headers':{'Authorization':util[_0x8952('0x45')](_0x8952('0x4f'),new Buffer(_0x2ea7c3)['toString'](_0x8952('0x47')))},'json':!![]};rp(_0xacbf1d)[_0x8952('0x18')](function(_0x2e88dc){var _0x391691={'messageId':_0x2e88dc['message_uuid'][0x0]};return _0x2f3db6['update'](_0x391691);})[_0x8952('0x1a')](function(_0x5c6e26){logger[_0x8952('0x2b')](_0x8952('0x2c'),'afterCreate',_0x8952('0x50'),util[_0x8952('0x2d')](_0x5c6e26,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),'plivo',_0x8952('0x51'));}break;case'infobip':if(_0x35aeed[_0x8952('0x30')]&&_0x35aeed[_0x8952('0x35')]){if(_0x35aeed[_0x8952('0x52')]){var _0x46aa19={'method':_0x8952('0x38'),'uri':_0x35aeed[_0x8952('0x52')]+_0x8952('0x53'),'body':{'username':_0x35aeed[_0x8952('0x30')],'password':_0x35aeed[_0x8952('0x35')]},'json':!![]};return rp(_0x46aa19)['then'](function(_0x2b5d2d){var _0x416917={'method':_0x8952('0x38'),'uri':_0x35aeed[_0x8952('0x52')]+_0x8952('0x54'),'body':{'messages':[{'from':_0x35aeed[_0x8952('0x20')],'destinations':[{'to':_0xd22858[_0x8952('0x20')]}],'text':_0xd22858[_0x8952('0x24')],'notifyUrl':_0x35aeed[_0x8952('0x25')]+'/api/sms/messages/'+_0xd22858['id']+_0x8952('0x27')+_0x35aeed[_0x8952('0x28')],'notifyContentType':_0x8952('0x55'),'callbackData':_0x35aeed[_0x8952('0x20')]+';'+_0xd22858[_0x8952('0x24')]}]},'headers':{'Authorization':_0x8952('0x56')+_0x2b5d2d[_0x8952('0x28')]},'json':!![]};return rp(_0x416917)[_0x8952('0x18')](function(_0x5a22b2){if(_0x5a22b2[_0x8952('0x22')]){var _0x1a7ae6={'messageId':_0x5a22b2[_0x8952('0x22')][0x0]['messageId']};if(!_0x35aeed['deliveryReport']){_0x1a7ae6['read']=!![];}return _0x2f3db6[_0x8952('0x2a')](_0x1a7ae6);}else{return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x57'),util['inspect'](_0x5a22b2,{'showHidden':![],'depth':null}));}});})[_0x8952('0x1a')](function(_0x5ba1de){return logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x57'),util[_0x8952('0x2d')](_0x5ba1de,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x57'),_0x8952('0x58'));}}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate','infobip',_0x8952('0x3c'));}break;case _0x8952('0x59'):var _0x4bc649=require(_0x8952('0x5a'));if(_0x35aeed['apiKey']){var _0x15ed5b={};_0x15ed5b[_0x8952('0x5b')]=_0x35aeed['username'];_0x15ed5b['phone']=_0xd22858[_0x8952('0x20')];_0x15ed5b[_0x8952('0x32')]=_0x35aeed['phone'];_0x15ed5b[_0x8952('0x5c')]=_0xd22858[_0x8952('0x24')];_0x15ed5b['timestamp']=+new Date();var _0x386a7b='';var _0x3ecde4='';var _0x4bc077=Object[_0x8952('0x5d')](_0x15ed5b);_0x4bc077[_0x8952('0x5e')]();for(var _0x4804e7=0x0;_0x4804e7<_0x4bc077[_0x8952('0x5f')];_0x4804e7++){if(_0x386a7b!=''){_0x386a7b+='&';}_0x386a7b+=_0x4bc077[_0x4804e7]+'='+encodeURIComponent(_0x15ed5b[_0x4bc077[_0x4804e7]]);_0x3ecde4+=_0x15ed5b[_0x4bc077[_0x4804e7]];}_0x3ecde4+=_0x35aeed[_0x8952('0x60')];_0x3ecde4=_0x4bc649['createHash'](_0x8952('0x61'))[_0x8952('0x2a')](_0x3ecde4)[_0x8952('0x62')](_0x8952('0x63'));if(_0x386a7b!==''){_0x386a7b+='&';}_0x386a7b+=_0x8952('0x64')+_0x3ecde4;var _0x3ba6d5={'method':_0x8952('0x36'),'uri':_0x35aeed['baseUrl']+_0x8952('0x65')+_0x386a7b,'json':!![]};return rp(_0x3ba6d5)['then'](function(_0x18f4b){var _0x5bacd9=Object[_0x8952('0x5d')](_0x18f4b);if(_0x18f4b[_0x5bacd9[0x0]]['error']&&parseInt(_0x18f4b[_0x5bacd9[0x0]][_0x8952('0x2b')])===0x0){var _0x506e76={'messageId':_0x18f4b[_0x5bacd9[0x0]][_0x8952('0x66')]};if(!_0x35aeed[_0x8952('0x40')]){_0x506e76[_0x8952('0x3b')]=!![];}return _0x2f3db6['update'](_0x506e76);}else{return logger[_0x8952('0x2b')](_0x8952('0x2c'),'afterCreate','csc',util[_0x8952('0x2d')](_0x18f4b[_0x8952('0x2b')],{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x509a67){return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x59'),util[_0x8952('0x2d')](_0x509a67,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x59'),'Missing\x20parameters:\x20apiKey');}break;case _0x8952('0x67'):if(_0x35aeed[_0x8952('0x60')]){var _0xbc83ad={'method':_0x8952('0x38'),'uri':_0x8952('0x68'),'headers':{'Authorization':_0x35aeed[_0x8952('0x60')]},'body':{'content':_0xd22858[_0x8952('0x24')],'to':[_0xd22858[_0x8952('0x20')]],'from':_0x35aeed[_0x8952('0x20')],'binary':![],'clientMessageId':_0x8952('0x69'),'charset':_0x8952('0x6a')},'json':!![]};rp(_0xbc83ad)[_0x8952('0x18')](function(_0x38eb16){if(!_0x38eb16[_0x8952('0x2b')]){var _0x19649c={'messageId':_0x38eb16['messages'][0x0][_0x8952('0x6b')]};if(!_0x35aeed['deliveryReport']){_0x19649c[_0x8952('0x3b')]=!![];}return _0x2f3db6[_0x8952('0x2a')](_0x19649c);}else{return logger[_0x8952('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x8952('0x2e'),_0x8952('0x67'),util[_0x8952('0x2d')](_0x38eb16['error'],{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x43bda6){return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x67'),util['inspect'](_0x43bda6,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x67'),'Missing\x20parameters:\x20apiKey');}break;case _0x8952('0x6c'):if(_0x35aeed[_0x8952('0x30')]&&_0x35aeed[_0x8952('0x35')]){var _0x2ea7c3=util['format'](_0x8952('0x43'),_0x35aeed['username'],_0x35aeed[_0x8952('0x35')]);var _0xacbf1d={'method':_0x8952('0x38'),'uri':'https://messaging.bandwidth.com/api/v2/users/'+_0x35aeed[_0x8952('0x6d')]+'/messages','body':{'to':[_0xd22858['phone']],'text':_0xd22858['body'],'from':_0x35aeed[_0x8952('0x20')],'applicationId':_0x35aeed['applicationId']},'headers':{'Authorization':util[_0x8952('0x45')](_0x8952('0x4f'),new Buffer(_0x2ea7c3)[_0x8952('0x46')](_0x8952('0x47')))},'json':!![]};rp(_0xacbf1d)['then'](function(_0x1a1b23){if(_0x1a1b23['id']){var _0x2ecd0f={'messageId':_0x1a1b23['id']};return _0x2f3db6[_0x8952('0x2a')](_0x2ecd0f);}else{logger['error'](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x6c'),util[_0x8952('0x2d')](_0x1a1b23,{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x447f44){logger['error'](_0x8952('0x2c'),'afterCreate',_0x8952('0x6c'),util[_0x8952('0x2d')](_0x447f44,{'showHidden':![],'depth':null}));});}else{logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),'bandwidth',_0x8952('0x3c'));}break;case _0x8952('0x6e'):if(_0x35aeed['apiKey']){var _0x46ff54={};var _0x3ba6d5={'method':_0x8952('0x38'),'uri':_0x8952('0x6f'),'headers':{'Authorization':_0x8952('0x70')+_0x35aeed[_0x8952('0x60')],'Content-Type':_0x8952('0x55')},'body':{'from':_0x35aeed[_0x8952('0x20')],'to':_0xd22858[_0x8952('0x20')],'text':_0xd22858['body']},'json':!![]};return rp(_0x3ba6d5)[_0x8952('0x18')](function(_0x25414a){if(_0x25414a['code']==0xca){_0x46ff54[_0x8952('0x71')]=_0x25414a;var _0x5d56d0={'method':_0x8952('0x38'),'uri':_0x8952('0x72'),'headers':{'Authorization':_0x8952('0x70')+_0x35aeed[_0x8952('0x60')],'Content-Type':_0x8952('0x55')},'body':{'refid':_0x46ff54[_0x8952('0x71')][_0x8952('0x73')]},'json':!![]};return rp(_0x5d56d0)[_0x8952('0x18')](function(_0x5e4310){_0x46ff54[_0x8952('0x74')]=_0x5e4310;var _0x44843e={'messageId':_0x46ff54[_0x8952('0x71')][_0x8952('0x73')],'read':!![]};return _0x2f3db6[_0x8952('0x2a')](_0x44843e);});}else{return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x6e'),util[_0x8952('0x2d')](_0x25414a,{'showHidden':![],'depth':null}));}})[_0x8952('0x1a')](function(_0x22ea51){return logger['error'](_0x8952('0x2c'),'afterCreate','intelepeer',util[_0x8952('0x2d')](_0x22ea51,{'showHidden':![],'depth':null}));});}else{return logger[_0x8952('0x2b')](_0x8952('0x2c'),_0x8952('0x2e'),_0x8952('0x6e'),_0x8952('0x75'));}break;}}})['finally'](function(){_0x37ff42();});}else{_0x37ff42();}}},'charset':_0x8952('0x76'),'collate':_0x8952('0x77')});}; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.rpc.js b/server/api/smsMessage/smsMessage.rpc.js new file mode 100644 index 0000000..42a6b9e --- /dev/null +++ b/server/api/smsMessage/smsMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd6d1=['debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','SmsMessage,\x20%s,\x20%s','message','result','catch','CreateSmsMessage','SmsMessage','create','options','raw','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','socket.io-emitter','register','request','then','info','request\x20sent'];(function(_0xa5caf7,_0x3ec2fe){var _0x14eca9=function(_0x1ca9b6){while(--_0x1ca9b6){_0xa5caf7['push'](_0xa5caf7['shift']());}};_0x14eca9(++_0x3ec2fe);}(_0xd6d1,0x137));var _0x1d6d=function(_0x36c078,_0x4072a7){_0x36c078=_0x36c078-0x0;var _0x29c6ed=_0xd6d1[_0x36c078];return _0x29c6ed;};'use strict';var _=require(_0x1d6d('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x1d6d('0x1'));var rs=require(_0x1d6d('0x2'));var fs=require('fs');var Redis=require(_0x1d6d('0x3'));var db=require(_0x1d6d('0x4'))['db'];var utils=require(_0x1d6d('0x5'));var logger=require('../../config/logger')(_0x1d6d('0x6'));var config=require(_0x1d6d('0x7'));var jayson=require(_0x1d6d('0x8'));var client=jayson[_0x1d6d('0x9')][_0x1d6d('0xa')]({'port':0x232a});config['redis']=_[_0x1d6d('0xb')](config['redis'],{'host':_0x1d6d('0xc'),'port':0x18eb});var socket=require(_0x1d6d('0xd'))(new Redis(config['redis']));require('./smsMessage.socket')[_0x1d6d('0xe')](socket);function respondWithRpcPromise(_0x2dca75,_0x2f81e5,_0x53ce80){return new BPromise(function(_0x46469f,_0x423762){return client[_0x1d6d('0xf')](_0x2dca75,_0x53ce80)[_0x1d6d('0x10')](function(_0x10908e){logger[_0x1d6d('0x11')]('SmsMessage,\x20%s,\x20%s',_0x2f81e5,_0x1d6d('0x12'));logger[_0x1d6d('0x13')](_0x1d6d('0x14'),_0x2f81e5,_0x1d6d('0x12'),JSON[_0x1d6d('0x15')](_0x10908e));if(_0x10908e[_0x1d6d('0x16')]){if(_0x10908e['error'][_0x1d6d('0x17')]===0x1f4){logger[_0x1d6d('0x16')](_0x1d6d('0x18'),_0x2f81e5,_0x10908e[_0x1d6d('0x16')]['message']);return _0x423762(_0x10908e[_0x1d6d('0x16')][_0x1d6d('0x19')]);}logger['error'](_0x1d6d('0x18'),_0x2f81e5,_0x10908e[_0x1d6d('0x16')][_0x1d6d('0x19')]);return _0x46469f(_0x10908e[_0x1d6d('0x16')]['message']);}else{logger[_0x1d6d('0x11')]('SmsMessage,\x20%s,\x20%s',_0x2f81e5,'request\x20sent');_0x46469f(_0x10908e[_0x1d6d('0x1a')]['message']);}})[_0x1d6d('0x1b')](function(_0x593dac){logger[_0x1d6d('0x16')](_0x1d6d('0x18'),_0x2f81e5,_0x593dac);_0x423762(_0x593dac);});});}exports[_0x1d6d('0x1c')]=function(_0x477aab){var _0x246df9=this;return new Promise(function(_0x43e8d0,_0x287586){return db[_0x1d6d('0x1d')][_0x1d6d('0x1e')](_0x477aab['body'],{'raw':_0x477aab[_0x1d6d('0x1f')]?_0x477aab[_0x1d6d('0x1f')][_0x1d6d('0x20')]===undefined?!![]:![]:!![]})[_0x1d6d('0x10')](function(_0x3505ea){logger[_0x1d6d('0x11')]('CreateSmsMessage',_0x477aab);logger[_0x1d6d('0x13')](_0x1d6d('0x1c'),_0x477aab,JSON[_0x1d6d('0x15')](_0x3505ea));_0x43e8d0(_0x3505ea);})[_0x1d6d('0x1b')](function(_0x1c16f4){logger[_0x1d6d('0x16')](_0x1d6d('0x1c'),_0x1c16f4[_0x1d6d('0x19')],_0x477aab);_0x287586(_0x246df9[_0x1d6d('0x16')](0x1f4,_0x1c16f4[_0x1d6d('0x19')]));});});}; \ No newline at end of file diff --git a/server/api/smsMessage/smsMessage.socket.js b/server/api/smsMessage/smsMessage.socket.js new file mode 100644 index 0000000..6e74bdf --- /dev/null +++ b/server/api/smsMessage/smsMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x02ae=['update','removeListener','register','smsMessage:','save'];(function(_0x5443ac,_0x2cb686){var _0x2e4780=function(_0x54addf){while(--_0x54addf){_0x5443ac['push'](_0x5443ac['shift']());}};_0x2e4780(++_0x2cb686);}(_0x02ae,0x1c6));var _0xe02a=function(_0x57ec43,_0x5cd0f8){_0x57ec43=_0x57ec43-0x0;var _0x31c313=_0x02ae[_0x57ec43];return _0x31c313;};'use strict';var SmsMessageEvents=require('./smsMessage.events');var events=[_0xe02a('0x0'),'remove',_0xe02a('0x1')];function createListener(_0xbed195,_0x56e66d){return function(_0x436819){_0x56e66d['emit'](_0xbed195,_0x436819);};}function removeListener(_0x2d6a6a,_0x4e75b7){return function(){SmsMessageEvents[_0xe02a('0x2')](_0x2d6a6a,_0x4e75b7);};}exports[_0xe02a('0x3')]=function(_0x2c290b){for(var _0x3d9303=0x0,_0x1c87e1=events['length'];_0x3d9303<_0x1c87e1;_0x3d9303++){var _0x3af94b=events[_0x3d9303];var _0x29798d=createListener(_0xe02a('0x4')+_0x3af94b,_0x2c290b);SmsMessageEvents['on'](_0x3af94b,_0x29798d);}}; \ No newline at end of file diff --git a/server/api/smsQueue/index.js b/server/api/smsQueue/index.js new file mode 100644 index 0000000..6208a1b --- /dev/null +++ b/server/api/smsQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0874=['/:id','show','getMembers','/:id/users','getAgents','post','create','/:id/teams','addTeams','put','update','delete','destroy','removeTeams','multer','util','path','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./smsQueue.controller','get','isAuthenticated','index','describe'];(function(_0x58a4fe,_0x11d439){var _0x697de2=function(_0xe38c14){while(--_0xe38c14){_0x58a4fe['push'](_0x58a4fe['shift']());}};_0x697de2(++_0x11d439);}(_0x0874,0xe6));var _0x4087=function(_0x194d1c,_0x496df0){_0x194d1c=_0x194d1c-0x0;var _0x5c399b=_0x0874[_0x194d1c];return _0x5c399b;};'use strict';var multer=require(_0x4087('0x0'));var util=require(_0x4087('0x1'));var path=require(_0x4087('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x4087('0x3')]();var fs_extra=require(_0x4087('0x4'));var auth=require(_0x4087('0x5'));var interaction=require(_0x4087('0x6'));var config=require(_0x4087('0x7'));var controller=require(_0x4087('0x8'));router[_0x4087('0x9')]('/',auth[_0x4087('0xa')](),controller[_0x4087('0xb')]);router[_0x4087('0x9')]('/describe',auth[_0x4087('0xa')](),controller[_0x4087('0xc')]);router[_0x4087('0x9')](_0x4087('0xd'),auth[_0x4087('0xa')](),controller[_0x4087('0xe')]);router[_0x4087('0x9')]('/:id/members',auth[_0x4087('0xa')](),controller[_0x4087('0xf')]);router['get']('/:id/teams',auth[_0x4087('0xa')](),controller['getTeams']);router[_0x4087('0x9')](_0x4087('0x10'),auth['isAuthenticated'](),controller[_0x4087('0x11')]);router[_0x4087('0x12')]('/',auth[_0x4087('0xa')](),controller[_0x4087('0x13')]);router['post'](_0x4087('0x14'),auth[_0x4087('0xa')](),controller[_0x4087('0x15')]);router[_0x4087('0x12')](_0x4087('0x10'),auth[_0x4087('0xa')](),controller['addAgents']);router[_0x4087('0x16')]('/:id',auth[_0x4087('0xa')](),controller[_0x4087('0x17')]);router[_0x4087('0x18')](_0x4087('0xd'),auth['isAuthenticated'](),controller[_0x4087('0x19')]);router['delete'](_0x4087('0x14'),auth[_0x4087('0xa')](),controller[_0x4087('0x1a')]);router[_0x4087('0x18')](_0x4087('0x10'),auth[_0x4087('0xa')](),controller['removeAgents']);module['exports']=router; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.attributes.js b/server/api/smsQueue/smsQueue.attributes.js new file mode 100644 index 0000000..fa65090 --- /dev/null +++ b/server/api/smsQueue/smsQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe087=['sequelize','STRING','INTEGER','rrmemory','beepall','roundrobin'];(function(_0x539fa9,_0x3f506d){var _0x4774b1=function(_0x22ecb9){while(--_0x22ecb9){_0x539fa9['push'](_0x539fa9['shift']());}};_0x4774b1(++_0x3f506d);}(_0xe087,0x1bc));var _0x7e08=function(_0x34407a,_0x30aec6){_0x34407a=_0x34407a-0x0;var _0x56fc57=_0xe087[_0x34407a];return _0x56fc57;};'use strict';var Sequelize=require(_0x7e08('0x0'));module['exports']={'name':{'type':Sequelize['STRING'],'unique':'name','validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'description':{'type':Sequelize[_0x7e08('0x1')]},'timeout':{'type':Sequelize[_0x7e08('0x2')],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize['ENUM'](_0x7e08('0x3'),_0x7e08('0x4'),_0x7e08('0x5'))}}; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.controller.js b/server/api/smsQueue/smsQueue.controller.js new file mode 100644 index 0000000..99726d9 --- /dev/null +++ b/server/api/smsQueue/smsQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x547e=['../../mysqldb','redis','localhost','./smsQueue.socket','register','sendStatus','end','status','json','offset','undefined','limit','count','Content-Range','apply','save','then','destroy','SmsQueues','UserProfileResource','error','stack','name','send','SmsQueue','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','length','find','catch','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','findOne','UserSmsQueue','order','SmsQueueId','User','findAndCountAll','UserId','agent','smsPause','updatedAt','createdAt','format','SIP','getTeams','Team','addTeams','ids','Agents','online','voicePause','interface','sequelize','transaction','each','findOrCreate','forEach','emit','removeTeams','select','field','tq.TeamId','from','team_has_sms_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','SmsQueueId\x20=\x20?','clone','toString','SELECT','TeamId','includes','union','compact','value','isEmpty','removeAgents','userSmsQueue:remove','addAgents','spread','userSmsQueue:save','getAgents','eml-format','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment'];(function(_0x3eb3e9,_0x34745a){var _0x4100cc=function(_0x5b78fa){while(--_0x5b78fa){_0x3eb3e9['push'](_0x3eb3e9['shift']());}};_0x4100cc(++_0x34745a);}(_0x547e,0xfd));var _0xe547=function(_0x16c6f0,_0x9a213a){_0x16c6f0=_0x16c6f0-0x0;var _0x6d3732=_0x547e[_0x16c6f0];return _0x6d3732;};'use strict';var emlformat=require(_0xe547('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe547('0x1'));var jsonpatch=require(_0xe547('0x2'));var rp=require('request-promise');var moment=require(_0xe547('0x3'));var BPromise=require(_0xe547('0x4'));var Mustache=require('mustache');var util=require(_0xe547('0x5'));var path=require(_0xe547('0x6'));var sox=require('sox');var csv=require(_0xe547('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe547('0x8'));var _=require(_0xe547('0x9'));var squel=require('squel');var crypto=require(_0xe547('0xa'));var jsforce=require(_0xe547('0xb'));var deskjs=require(_0xe547('0xc'));var toCsv=require(_0xe547('0x7'));var querystring=require(_0xe547('0xd'));var Papa=require(_0xe547('0xe'));var Redis=require(_0xe547('0xf'));var authService=require(_0xe547('0x10'));var qs=require(_0xe547('0x11'));var as=require(_0xe547('0x12'));var hardwareService=require(_0xe547('0x13'));var logger=require(_0xe547('0x14'))('api');var utils=require(_0xe547('0x15'));var config=require(_0xe547('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xe547('0x17'))['db'];config[_0xe547('0x18')]=_['defaults'](config['redis'],{'host':_0xe547('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe547('0x1a'))[_0xe547('0x1b')](socket);function respondWithStatusCode(_0x4102d5,_0x2cd2a0){_0x2cd2a0=_0x2cd2a0||0xcc;return function(_0x49a13f){if(_0x49a13f){return _0x4102d5[_0xe547('0x1c')](_0x2cd2a0);}return _0x4102d5['status'](_0x2cd2a0)[_0xe547('0x1d')]();};}function respondWithResult(_0x5b28fc,_0x3c7124){_0x3c7124=_0x3c7124||0xc8;return function(_0x31ba00){if(_0x31ba00){return _0x5b28fc[_0xe547('0x1e')](_0x3c7124)[_0xe547('0x1f')](_0x31ba00);}};}function respondWithFilteredResult(_0x3e3555,_0x216661){return function(_0x11ad38){if(_0x11ad38){var _0x5a968d=typeof _0x216661[_0xe547('0x20')]===_0xe547('0x21')&&typeof _0x216661[_0xe547('0x22')]===_0xe547('0x21');var _0x383801=_0x11ad38[_0xe547('0x23')];var _0x450701=_0x5a968d?0x0:_0x216661['offset'];var _0x5bc104=_0x5a968d?_0x11ad38[_0xe547('0x23')]:_0x216661['offset']+_0x216661[_0xe547('0x22')];var _0x50dbb0;if(_0x5bc104>=_0x383801){_0x5bc104=_0x383801;_0x50dbb0=0xc8;}else{_0x50dbb0=0xce;}_0x3e3555[_0xe547('0x1e')](_0x50dbb0);return _0x3e3555['set'](_0xe547('0x24'),_0x450701+'-'+_0x5bc104+'/'+_0x383801)[_0xe547('0x1f')](_0x11ad38);}return null;};}function patchUpdates(_0x5f40b7){return function(_0x5a2e80){try{jsonpatch[_0xe547('0x25')](_0x5a2e80,_0x5f40b7,!![]);}catch(_0x1cf90e){return BPromise['reject'](_0x1cf90e);}return _0x5a2e80[_0xe547('0x26')]();};}function saveUpdates(_0x259644,_0x3939fb){return function(_0x44ac10){if(_0x44ac10){return _0x44ac10['update'](_0x259644)[_0xe547('0x27')](function(_0x418d45){return _0x418d45;});}return null;};}function removeEntity(_0x46958f,_0x43ed5c){return function(_0x43ec18){if(_0x43ec18){return _0x43ec18[_0xe547('0x28')]()[_0xe547('0x27')](function(){var _0x2e0075=_0x43ec18['get']({'plain':!![]});var _0x4ff0ed=_0xe547('0x29');return db[_0xe547('0x2a')][_0xe547('0x28')]({'where':{'type':_0x4ff0ed,'resourceId':_0x2e0075['id']}})[_0xe547('0x27')](function(){return _0x43ec18;});})['then'](function(){_0x46958f['status'](0xcc)[_0xe547('0x1d')]();});}};}function handleEntityNotFound(_0x38a4ae,_0x46be34){return function(_0x2c97a5){if(!_0x2c97a5){_0x38a4ae[_0xe547('0x1c')](0x194);}return _0x2c97a5;};}function handleError(_0xc8f420,_0x5c5ed8){_0x5c5ed8=_0x5c5ed8||0x1f4;return function(_0x4a23a6){logger[_0xe547('0x2b')](_0x4a23a6[_0xe547('0x2c')]);if(_0x4a23a6['name']){delete _0x4a23a6[_0xe547('0x2d')];}_0xc8f420[_0xe547('0x1e')](_0x5c5ed8)[_0xe547('0x2e')](_0x4a23a6);};}exports['index']=function(_0xfda88c,_0x47c347){var _0x275264={},_0x1b5cc1={},_0x16b5e4={'count':0x0,'rows':[]};var _0x4c33d7=_['map'](db[_0xe547('0x2f')][_0xe547('0x30')],function(_0x5aafa8){return{'name':_0x5aafa8['fieldName'],'type':_0x5aafa8[_0xe547('0x31')][_0xe547('0x32')]};});_0x1b5cc1[_0xe547('0x33')]=_[_0xe547('0x34')](_0x4c33d7,_0xe547('0x2d'));_0x1b5cc1[_0xe547('0x35')]=_[_0xe547('0x36')](_0xfda88c['query']);_0x1b5cc1[_0xe547('0x37')]=_[_0xe547('0x38')](_0x1b5cc1[_0xe547('0x33')],_0x1b5cc1['query']);_0x275264[_0xe547('0x39')]=_['intersection'](_0x1b5cc1[_0xe547('0x33')],qs[_0xe547('0x3a')](_0xfda88c['query'][_0xe547('0x3a')]));_0x275264[_0xe547('0x39')]=_0x275264[_0xe547('0x39')]['length']?_0x275264[_0xe547('0x39')]:_0x1b5cc1[_0xe547('0x33')];if(!_0xfda88c['query'][_0xe547('0x3b')](_0xe547('0x3c'))){_0x275264[_0xe547('0x22')]=qs[_0xe547('0x22')](_0xfda88c[_0xe547('0x35')][_0xe547('0x22')]);_0x275264['offset']=qs['offset'](_0xfda88c[_0xe547('0x35')][_0xe547('0x20')]);}_0x275264['order']=qs[_0xe547('0x3d')](_0xfda88c[_0xe547('0x35')][_0xe547('0x3d')]);_0x275264[_0xe547('0x3e')]=qs['filters'](_[_0xe547('0x3f')](_0xfda88c[_0xe547('0x35')],_0x1b5cc1[_0xe547('0x37')]),_0x4c33d7);if(_0xfda88c['query'][_0xe547('0x40')]){_0x275264[_0xe547('0x3e')]=_[_0xe547('0x41')](_0x275264[_0xe547('0x3e')],{'$or':_['map'](_0x4c33d7,function(_0x3760ca){if(_0x3760ca[_0xe547('0x31')]!==_0xe547('0x42')){var _0x265623={};_0x265623[_0x3760ca[_0xe547('0x2d')]]={'$like':'%'+_0xfda88c[_0xe547('0x35')][_0xe547('0x40')]+'%'};return _0x265623;}})});}_0x275264=_[_0xe547('0x41')]({},_0x275264,_0xfda88c[_0xe547('0x43')]);var _0x4a9517={'where':_0x275264[_0xe547('0x3e')]};return db['SmsQueue']['count'](_0x4a9517)[_0xe547('0x27')](function(_0xa8656b){_0x16b5e4[_0xe547('0x23')]=_0xa8656b;if(_0xfda88c['query'][_0xe547('0x44')]){_0x275264[_0xe547('0x45')]=[{'all':!![]}];}return db[_0xe547('0x2f')][_0xe547('0x46')](_0x275264);})['then'](function(_0x4e73ad){_0x16b5e4[_0xe547('0x47')]=_0x4e73ad;return _0x16b5e4;})[_0xe547('0x27')](respondWithFilteredResult(_0x47c347,_0x275264))['catch'](handleError(_0x47c347,null));};exports['show']=function(_0x1e48b9,_0x379368){var _0xe97ef5={'raw':!![],'where':{'id':_0x1e48b9[_0xe547('0x48')]['id']}},_0x4376db={};_0x4376db['model']=_[_0xe547('0x36')](db[_0xe547('0x2f')][_0xe547('0x30')]);_0x4376db[_0xe547('0x35')]=_[_0xe547('0x36')](_0x1e48b9['query']);_0x4376db['filters']=_[_0xe547('0x38')](_0x4376db[_0xe547('0x33')],_0x4376db['query']);_0xe97ef5[_0xe547('0x39')]=_[_0xe547('0x38')](_0x4376db['model'],qs[_0xe547('0x3a')](_0x1e48b9[_0xe547('0x35')][_0xe547('0x3a')]));_0xe97ef5['attributes']=_0xe97ef5[_0xe547('0x39')][_0xe547('0x49')]?_0xe97ef5[_0xe547('0x39')]:_0x4376db['model'];if(_0x1e48b9[_0xe547('0x35')][_0xe547('0x44')]){_0xe97ef5['include']=[{'all':!![]}];}_0xe97ef5=_['merge']({},_0xe97ef5,_0x1e48b9['options']);return db['SmsQueue'][_0xe547('0x4a')](_0xe97ef5)[_0xe547('0x27')](handleEntityNotFound(_0x379368,null))[_0xe547('0x27')](respondWithResult(_0x379368,null))[_0xe547('0x4b')](handleError(_0x379368,null));};exports[_0xe547('0x4c')]=function(_0x4c88ca,_0x107546){return db[_0xe547('0x2f')][_0xe547('0x4c')](_0x4c88ca['body'],{})[_0xe547('0x27')](function(_0x41b305){var _0x4b54e0=_0x4c88ca['user'][_0xe547('0x4d')]({'plain':!![]});if(!_0x4b54e0)throw new Error(_0xe547('0x4e'));if(_0x4b54e0['role']===_0xe547('0x4f')){var _0x3545e1=_0x41b305[_0xe547('0x4d')]({'plain':!![]});var _0x31a479=_0xe547('0x29');return db[_0xe547('0x50')][_0xe547('0x4a')]({'where':{'name':_0x31a479,'userProfileId':_0x4b54e0[_0xe547('0x51')]},'raw':!![]})[_0xe547('0x27')](function(_0x14d89c){if(_0x14d89c&&_0x14d89c['autoAssociation']===0x0){return db[_0xe547('0x2a')]['create']({'name':_0x3545e1[_0xe547('0x2d')],'resourceId':_0x3545e1['id'],'type':_0x14d89c[_0xe547('0x2d')],'sectionId':_0x14d89c['id']},{})['then'](function(){return _0x41b305;});}else{return _0x41b305;}})[_0xe547('0x4b')](function(_0x3f0d88){logger[_0xe547('0x2b')](_0xe547('0x52'),_0x3f0d88);throw _0x3f0d88;});}return _0x41b305;})[_0xe547('0x27')](respondWithResult(_0x107546,0xc9))['catch'](handleError(_0x107546,null));};exports[_0xe547('0x53')]=function(_0x25ae22,_0x553357){if(_0x25ae22[_0xe547('0x54')]['id']){delete _0x25ae22['body']['id'];}return db['SmsQueue'][_0xe547('0x4a')]({'where':{'id':_0x25ae22[_0xe547('0x48')]['id']}})[_0xe547('0x27')](handleEntityNotFound(_0x553357,null))[_0xe547('0x27')](saveUpdates(_0x25ae22['body'],null))[_0xe547('0x27')](respondWithResult(_0x553357,null))[_0xe547('0x4b')](handleError(_0x553357,null));};exports[_0xe547('0x28')]=function(_0x1eed90,_0x2b9359){return db[_0xe547('0x2f')][_0xe547('0x4a')]({'where':{'id':_0x1eed90[_0xe547('0x48')]['id']}})['then'](handleEntityNotFound(_0x2b9359,null))['then'](removeEntity(_0x2b9359,null))[_0xe547('0x4b')](handleError(_0x2b9359,null));};exports[_0xe547('0x55')]=function(_0x5c4b97,_0x26099d){return db[_0xe547('0x2f')][_0xe547('0x55')]()[_0xe547('0x27')](respondWithResult(_0x26099d,null))[_0xe547('0x4b')](handleError(_0x26099d,null));};exports['getMembers']=function(_0x29f3be,_0x151834,_0x1a561a){var _0x42d4dd={'raw':!![],'where':{}},_0x26544a={},_0x24a1d5;return db[_0xe547('0x2f')][_0xe547('0x56')]({'where':{'id':_0x29f3be[_0xe547('0x48')]['id']}})[_0xe547('0x27')](handleEntityNotFound(_0x151834,null))[_0xe547('0x27')](function(_0x581e53){if(_0x581e53){_0x24a1d5=_0x581e53[_0xe547('0x4d')]({'plain':!![]});_0x26544a[_0xe547('0x33')]=_[_0xe547('0x36')](db[_0xe547('0x57')][_0xe547('0x30')]);_0x26544a[_0xe547('0x35')]=_[_0xe547('0x36')](_0x29f3be[_0xe547('0x35')]);_0x26544a[_0xe547('0x37')]=_[_0xe547('0x38')](_0x26544a[_0xe547('0x33')],_0x26544a[_0xe547('0x35')]);_0x42d4dd[_0xe547('0x39')]=_[_0xe547('0x38')](_0x26544a[_0xe547('0x33')],qs[_0xe547('0x3a')](_0x29f3be[_0xe547('0x35')][_0xe547('0x3a')]));_0x42d4dd[_0xe547('0x39')]=_0x42d4dd[_0xe547('0x39')][_0xe547('0x49')]?_0x42d4dd[_0xe547('0x39')]:_0x26544a[_0xe547('0x33')];if(!_0x29f3be[_0xe547('0x35')][_0xe547('0x3b')](_0xe547('0x3c'))){_0x42d4dd[_0xe547('0x22')]=qs[_0xe547('0x22')](_0x29f3be['query'][_0xe547('0x22')]);_0x42d4dd['offset']=qs['offset'](_0x29f3be['query'][_0xe547('0x20')]);}_0x42d4dd[_0xe547('0x58')]=qs[_0xe547('0x3d')](_0x29f3be[_0xe547('0x35')][_0xe547('0x3d')]);_0x42d4dd[_0xe547('0x3e')]=qs[_0xe547('0x37')](_['pick'](_0x29f3be['query'],_0x26544a[_0xe547('0x37')]));_0x42d4dd[_0xe547('0x3e')][_0xe547('0x59')]=_0x581e53['id'];if(_0x29f3be[_0xe547('0x35')][_0xe547('0x40')]){_0x42d4dd['where']=_[_0xe547('0x41')](_0x42d4dd[_0xe547('0x3e')],{'$or':_['map'](_0x42d4dd[_0xe547('0x39')],function(_0x32acf3){var _0x675d8={};_0x675d8[_0x32acf3]={'$like':'%'+_0x29f3be[_0xe547('0x35')][_0xe547('0x40')]+'%'};return _0x675d8;})});}_0x42d4dd=_[_0xe547('0x41')]({},_0x42d4dd,_0x29f3be[_0xe547('0x43')]);return db['UserSmsQueue']['findAll'](_0x42d4dd);}})[_0xe547('0x27')](function(_0x479f36){if(_0x479f36){return db[_0xe547('0x5a')][_0xe547('0x5b')]({'where':{'id':_[_0xe547('0x34')](_0x479f36,_0xe547('0x5c')),'role':_0xe547('0x5d')},'attributes':['id',_0xe547('0x2d'),_0xe547('0x5e'),_0xe547('0x5f'),_0xe547('0x60')]});}})['then'](function(_0x4b43a9){if(_0x4b43a9){return{'count':_0x4b43a9[_0xe547('0x23')],'rows':_[_0xe547('0x34')](_0x4b43a9[_0xe547('0x47')],function(_0x5b7a48){return{'membername':_0x5b7a48['name'],'UserId':_0x5b7a48['id'],'queue_name':_0x24a1d5[_0xe547('0x2d')],'SmsQueueId':_0x24a1d5['id'],'interface':util[_0xe547('0x61')]('%s/%s',_0xe547('0x62'),_0x5b7a48[_0xe547('0x2d')]),'penalty':0x0,'paused':_0x5b7a48['smsPause'],'createdAt':_0x5b7a48[_0xe547('0x60')],'updatedAt':_0x5b7a48['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xe547('0x27')](respondWithFilteredResult(_0x151834,_0x42d4dd))[_0xe547('0x4b')](handleError(_0x151834,null));};exports[_0xe547('0x63')]=function(_0x2d4705,_0x5d3f0b,_0x9c34dc){var _0x49fb12={};var _0x29c194={};var _0xb5e381;var _0x5dfdce;return db[_0xe547('0x2f')][_0xe547('0x56')]({'where':{'id':_0x2d4705[_0xe547('0x48')]['id']}})[_0xe547('0x27')](handleEntityNotFound(_0x5d3f0b,null))[_0xe547('0x27')](function(_0x597ce){if(_0x597ce){_0xb5e381=_0x597ce;_0x29c194[_0xe547('0x33')]=_[_0xe547('0x36')](db[_0xe547('0x64')][_0xe547('0x30')]);_0x29c194['query']=_[_0xe547('0x36')](_0x2d4705[_0xe547('0x35')]);_0x29c194[_0xe547('0x37')]=_[_0xe547('0x38')](_0x29c194['model'],_0x29c194[_0xe547('0x35')]);_0x49fb12['attributes']=_[_0xe547('0x38')](_0x29c194[_0xe547('0x33')],qs[_0xe547('0x3a')](_0x2d4705[_0xe547('0x35')]['fields']));_0x49fb12['attributes']=_0x49fb12[_0xe547('0x39')][_0xe547('0x49')]?_0x49fb12[_0xe547('0x39')]:_0x29c194[_0xe547('0x33')];_0x49fb12[_0xe547('0x58')]=qs[_0xe547('0x3d')](_0x2d4705[_0xe547('0x35')][_0xe547('0x3d')]);_0x49fb12[_0xe547('0x3e')]=qs['filters'](_[_0xe547('0x3f')](_0x2d4705[_0xe547('0x35')],_0x29c194[_0xe547('0x37')]));if(_0x2d4705[_0xe547('0x35')][_0xe547('0x40')]){_0x49fb12['where']=_[_0xe547('0x41')](_0x49fb12[_0xe547('0x3e')],{'$or':_['map'](_0x49fb12[_0xe547('0x39')],function(_0x8f865b){var _0x2f6831={};_0x2f6831[_0x8f865b]={'$like':'%'+_0x2d4705[_0xe547('0x35')][_0xe547('0x40')]+'%'};return _0x2f6831;})});}_0x49fb12=_['merge']({},_0x49fb12,_0x2d4705[_0xe547('0x43')]);return _0xb5e381[_0xe547('0x63')](_0x49fb12);}})[_0xe547('0x27')](function(_0x45adc0){if(_0x45adc0){_0x5dfdce=_0x45adc0[_0xe547('0x49')];if(!_0x2d4705['query'][_0xe547('0x3b')]('nolimit')){_0x49fb12[_0xe547('0x22')]=qs[_0xe547('0x22')](_0x2d4705[_0xe547('0x35')]['limit']);_0x49fb12['offset']=qs[_0xe547('0x20')](_0x2d4705[_0xe547('0x35')]['offset']);}return _0xb5e381[_0xe547('0x63')](_0x49fb12);}})[_0xe547('0x27')](function(_0x1f6301){if(_0x1f6301){return _0x1f6301?{'count':_0x5dfdce,'rows':_0x1f6301}:null;}})['then'](respondWithResult(_0x5d3f0b,null))['catch'](handleError(_0x5d3f0b,null));};exports[_0xe547('0x65')]=function(_0x482ed2,_0x20b113,_0x13b010){var _0x1b382e=_0x482ed2[_0xe547('0x54')][_0xe547('0x66')];return db[_0xe547('0x64')][_0xe547('0x46')]({'where':{'id':_0x1b382e},'attributes':['id'],'include':[{'model':db['User'],'as':_0xe547('0x67'),'attributes':['id',_0xe547('0x2d'),_0xe547('0x68'),_0xe547('0x69'),_0xe547('0x6a')],'raw':!![]}]})[_0xe547('0x27')](function(_0x418b01){if(_0x418b01){var _0x27cc98=_['flatMap'](_0x418b01,function(_0x221b10){var _0x261b0b=_0x221b10['get']({'plain':!![]});return _0x261b0b['Agents'];});return db[_0xe547('0x2f')][_0xe547('0x4a')]({'where':{'id':_0x482ed2[_0xe547('0x48')]['id']}})['then'](function(_0x7bcf5a){return db[_0xe547('0x6b')][_0xe547('0x6c')](function(_0x288b0d){return _0x7bcf5a[_0xe547('0x65')](_0x1b382e,{'transaction':_0x288b0d})[_0xe547('0x27')](function(){return BPromise[_0xe547('0x6d')](_0x27cc98,function(_0x5e93d0){return db[_0xe547('0x57')][_0xe547('0x6e')]({'where':{'UserId':_0x5e93d0['id'],'SmsQueueId':_0x482ed2[_0xe547('0x48')]['id']},'transaction':_0x288b0d});});})[_0xe547('0x27')](function(){_0x27cc98[_0xe547('0x6f')](function(_0x504521){socket[_0xe547('0x70')]('userSmsQueue:save',{'UserId':_0x504521['id'],'SmsQueueId':_0x7bcf5a['id']});});});});});}})['then'](respondWithStatusCode(_0x20b113,null))[_0xe547('0x4b')](handleError(_0x20b113,null));};exports[_0xe547('0x71')]=function(_0x43b154,_0x47b4c7,_0x155693){return db[_0xe547('0x64')][_0xe547('0x46')]({'where':{'id':_0x43b154[_0xe547('0x35')][_0xe547('0x66')]},'attributes':['id'],'include':[{'model':db[_0xe547('0x5a')],'as':_0xe547('0x67'),'attributes':['id'],'raw':!![]}]})[_0xe547('0x27')](handleEntityNotFound(_0x47b4c7,null))[_0xe547('0x27')](function(_0x26b107){var _0x5cca18=_[_0xe547('0x34')](_0x26b107,'id');var _0x370f6f=[];var _0x44f540=[];var _0x58ff41=squel[_0xe547('0x72')]();_0x58ff41[_0xe547('0x73')](_0xe547('0x74'))[_0xe547('0x75')](_0xe547('0x76'),'tq')[_0xe547('0x77')](_0xe547('0x78'),'ut',_0xe547('0x79'))['where'](_0xe547('0x7a'),_0x43b154[_0xe547('0x48')]['id']);for(var _0x3a38b0=0x0;_0x3a38b0<_0x26b107[_0xe547('0x49')];_0x3a38b0+=0x1){let _0x3dbc52=_0x26b107[_0x3a38b0];for(var _0x2d13dc=0x0;_0x2d13dc<_0x3dbc52[_0xe547('0x67')][_0xe547('0x49')];_0x2d13dc+=0x1){let _0x10a9f4=_0x3dbc52['Agents'][_0x2d13dc];var _0x5e032e=_0x58ff41[_0xe547('0x7b')]();_0x5e032e[_0xe547('0x3e')]('ut.UserId\x20=\x20?',_0x10a9f4['id']);_0x44f540['push'](db[_0xe547('0x6b')][_0xe547('0x35')](_0x5e032e[_0xe547('0x7c')](),{'type':db['sequelize']['QueryTypes'][_0xe547('0x7d')]})['then'](function(_0x37973f){if(_0x37973f[_0xe547('0x49')]===0x1){return _0x10a9f4['id'];}else{var _0x216938=_['every'](_[_0xe547('0x34')](_0x37973f,_0xe547('0x7e')),function(_0x395547){return _[_0xe547('0x7f')](_0x5cca18,_0x395547);});if(_0x216938){return _0x10a9f4['id'];}}}));}}return BPromise['all'](_0x44f540)[_0xe547('0x27')](function(_0x342411){_0x370f6f=_(_0x370f6f)[_0xe547('0x80')](_0x342411)[_0xe547('0x81')]()[_0xe547('0x82')]();return db['SmsQueue'][_0xe547('0x4a')]({'where':{'id':_0x43b154[_0xe547('0x48')]['id']}})[_0xe547('0x27')](function(_0x43372b){return db[_0xe547('0x6b')][_0xe547('0x6c')](function(_0x5be988){return _0x43372b[_0xe547('0x71')](_0x43b154['query'][_0xe547('0x66')],{'transaction':_0x5be988})['then'](function(){if(!_[_0xe547('0x83')](_0x370f6f)){return _0x43372b[_0xe547('0x84')](_0x370f6f,{'transaction':_0x5be988});}})[_0xe547('0x27')](function(){_0x370f6f[_0xe547('0x6f')](function(_0x435d59){socket[_0xe547('0x70')](_0xe547('0x85'),{'UserId':_0x435d59,'SmsQueueId':_0x43372b['id']});});});});});});})[_0xe547('0x27')](respondWithStatusCode(_0x47b4c7,null))[_0xe547('0x4b')](handleError(_0x47b4c7,null));};exports[_0xe547('0x86')]=function(_0x1a1824,_0x386faf,_0x25f4e0){return db[_0xe547('0x2f')]['find']({'where':{'id':_0x1a1824['params']['id']}})[_0xe547('0x27')](handleEntityNotFound(_0x386faf,null))[_0xe547('0x27')](function(_0x1186e8){if(_0x1186e8){return _0x1186e8[_0xe547('0x86')](_0x1a1824[_0xe547('0x54')][_0xe547('0x66')],_['omit'](_0x1a1824[_0xe547('0x54')],[_0xe547('0x66'),'id'])||{})[_0xe547('0x87')](function(_0x379716){for(var _0x52ce7e=0x0;_0x52ce7e<_0x1a1824[_0xe547('0x54')][_0xe547('0x66')][_0xe547('0x49')];_0x52ce7e+=0x1){socket[_0xe547('0x70')](_0xe547('0x88'),{'UserId':Number(_0x1a1824['body']['ids'][_0x52ce7e]),'SmsQueueId':Number(_0x1a1824[_0xe547('0x48')]['id'])});}return _0x379716;});}})[_0xe547('0x27')](respondWithResult(_0x386faf,null))[_0xe547('0x4b')](handleError(_0x386faf,null));};exports['removeAgents']=function(_0x5cd43e,_0x1bdc18,_0xc22a84){return db['SmsQueue'][_0xe547('0x4a')]({'where':{'id':_0x5cd43e[_0xe547('0x48')]['id']}})['then'](handleEntityNotFound(_0x1bdc18,null))[_0xe547('0x27')](function(_0x5277b1){if(_0x5277b1){return _0x5277b1['removeAgents'](_0x5cd43e['query'][_0xe547('0x66')])[_0xe547('0x27')](function(){if(_['isArray'](_0x5cd43e['query'][_0xe547('0x66')])){for(var _0x242b80=0x0;_0x242b80<_0x5cd43e['query']['ids'][_0xe547('0x49')];_0x242b80+=0x1){socket[_0xe547('0x70')](_0xe547('0x85'),{'UserId':Number(_0x5cd43e[_0xe547('0x35')][_0xe547('0x66')][_0x242b80]),'SmsQueueId':Number(_0x5cd43e[_0xe547('0x48')]['id'])});}}else{socket[_0xe547('0x70')](_0xe547('0x85'),{'UserId':Number(_0x5cd43e[_0xe547('0x35')][_0xe547('0x66')]),'SmsQueueId':Number(_0x5cd43e[_0xe547('0x48')]['id'])});}});}})[_0xe547('0x27')](respondWithStatusCode(_0x1bdc18,null))[_0xe547('0x4b')](handleError(_0x1bdc18,null));};exports[_0xe547('0x89')]=function(_0x849e7c,_0x4d1d94,_0x5ae194){var _0xf33b49={};var _0x48983b={};var _0x3ca0cb;var _0x1282f0;return db[_0xe547('0x2f')][_0xe547('0x56')]({'where':{'id':_0x849e7c[_0xe547('0x48')]['id']}})[_0xe547('0x27')](handleEntityNotFound(_0x4d1d94,null))[_0xe547('0x27')](function(_0x3d7ef9){if(_0x3d7ef9){_0x3ca0cb=_0x3d7ef9;_0x48983b['model']=_[_0xe547('0x36')](db[_0xe547('0x5a')][_0xe547('0x30')]);_0x48983b['query']=_['keys'](_0x849e7c[_0xe547('0x35')]);_0x48983b[_0xe547('0x37')]=_[_0xe547('0x38')](_0x48983b[_0xe547('0x33')],_0x48983b['query']);_0xf33b49[_0xe547('0x39')]=_['intersection'](_0x48983b[_0xe547('0x33')],qs[_0xe547('0x3a')](_0x849e7c['query'][_0xe547('0x3a')]));_0xf33b49['attributes']=_0xf33b49[_0xe547('0x39')][_0xe547('0x49')]?_0xf33b49[_0xe547('0x39')]:_0x48983b['model'];_0xf33b49[_0xe547('0x58')]=qs['sort'](_0x849e7c[_0xe547('0x35')][_0xe547('0x3d')]);_0xf33b49[_0xe547('0x3e')]=qs[_0xe547('0x37')](_[_0xe547('0x3f')](_0x849e7c[_0xe547('0x35')],_0x48983b[_0xe547('0x37')]));if(_0x849e7c[_0xe547('0x35')]['filter']){_0xf33b49[_0xe547('0x3e')]=_[_0xe547('0x41')](_0xf33b49['where'],{'$or':_[_0xe547('0x34')](_0xf33b49['attributes'],function(_0x1b412f){var _0x5480b6={};_0x5480b6[_0x1b412f]={'$like':'%'+_0x849e7c[_0xe547('0x35')][_0xe547('0x40')]+'%'};return _0x5480b6;})});}_0xf33b49=_[_0xe547('0x41')]({},_0xf33b49,_0x849e7c[_0xe547('0x43')]);return _0x3ca0cb[_0xe547('0x89')](_0xf33b49);}})[_0xe547('0x27')](function(_0x5b5328){if(_0x5b5328){_0x1282f0=_0x5b5328[_0xe547('0x49')];if(!_0x849e7c[_0xe547('0x35')][_0xe547('0x3b')](_0xe547('0x3c'))){_0xf33b49[_0xe547('0x22')]=qs[_0xe547('0x22')](_0x849e7c[_0xe547('0x35')][_0xe547('0x22')]);_0xf33b49[_0xe547('0x20')]=qs['offset'](_0x849e7c[_0xe547('0x35')][_0xe547('0x20')]);}return _0x3ca0cb[_0xe547('0x89')](_0xf33b49);}})[_0xe547('0x27')](function(_0x143715){if(_0x143715){return _0x143715?{'count':_0x1282f0,'rows':_0x143715}:null;}})[_0xe547('0x27')](respondWithResult(_0x4d1d94,null))[_0xe547('0x4b')](handleError(_0x4d1d94,null));}; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.events.js b/server/api/smsQueue/smsQueue.events.js new file mode 100644 index 0000000..8d21196 --- /dev/null +++ b/server/api/smsQueue/smsQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1859=['events','../../mysqldb','SmsQueue','setMaxListeners','update','emit','hasOwnProperty','hook','exports'];(function(_0x4864ea,_0x7764ed){var _0x12e74f=function(_0x3fe41d){while(--_0x3fe41d){_0x4864ea['push'](_0x4864ea['shift']());}};_0x12e74f(++_0x7764ed);}(_0x1859,0x183));var _0x9185=function(_0x177701,_0x3a9273){_0x177701=_0x177701-0x0;var _0xa4527e=_0x1859[_0x177701];return _0xa4527e;};'use strict';var EventEmitter=require(_0x9185('0x0'));var SmsQueue=require(_0x9185('0x1'))['db'][_0x9185('0x2')];var SmsQueueEvents=new EventEmitter();SmsQueueEvents[_0x9185('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x9185('0x4'),'afterDestroy':'remove'};function emitEvent(_0x3b3d3d){return function(_0x3246b1,_0x1b8133,_0x208136){SmsQueueEvents[_0x9185('0x5')](_0x3b3d3d+':'+_0x3246b1['id'],_0x3246b1);SmsQueueEvents[_0x9185('0x5')](_0x3b3d3d,_0x3246b1);_0x208136(null);};}for(var e in events){if(events[_0x9185('0x6')](e)){var event=events[e];SmsQueue[_0x9185('0x7')](e,emitEvent(event));}}module[_0x9185('0x8')]=SmsQueueEvents; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.model.js b/server/api/smsQueue/smsQueue.model.js new file mode 100644 index 0000000..b1bee86 --- /dev/null +++ b/server/api/smsQueue/smsQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7f63=['moment','bluebird','path','rimraf','../../config/environment','./smsQueue.attributes','exports','SmsQueue','sms_queues','lodash','../../config/logger','api'];(function(_0x2c7d03,_0x467e23){var _0x1892e1=function(_0x40d09f){while(--_0x40d09f){_0x2c7d03['push'](_0x2c7d03['shift']());}};_0x1892e1(++_0x467e23);}(_0x7f63,0xd5));var _0x37f6=function(_0x191c4c,_0x3b7c2b){_0x191c4c=_0x191c4c-0x0;var _0x2fd037=_0x7f63[_0x191c4c];return _0x2fd037;};'use strict';var _=require(_0x37f6('0x0'));var util=require('util');var logger=require(_0x37f6('0x1'))(_0x37f6('0x2'));var moment=require(_0x37f6('0x3'));var BPromise=require(_0x37f6('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x37f6('0x5'));var rimraf=require(_0x37f6('0x6'));var config=require(_0x37f6('0x7'));var attributes=require(_0x37f6('0x8'));module[_0x37f6('0x9')]=function(_0x16a637,_0x6ba279){return _0x16a637['define'](_0x37f6('0xa'),attributes,{'tableName':_0x37f6('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.rpc.js b/server/api/smsQueue/smsQueue.rpc.js new file mode 100644 index 0000000..f70346f --- /dev/null +++ b/server/api/smsQueue/smsQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa993=['options','raw','where','attributes','include','map','model','ShowSmsQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSmsQueue','SmsQueue','findAll'];(function(_0x5cd87c,_0x5e4540){var _0x4e9f40=function(_0x2964e0){while(--_0x2964e0){_0x5cd87c['push'](_0x5cd87c['shift']());}};_0x4e9f40(++_0x5e4540);}(_0xa993,0x1b6));var _0x3a99=function(_0x3fb5fa,_0x99815a){_0x3fb5fa=_0x3fb5fa-0x0;var _0x368105=_0xa993[_0x3fb5fa];return _0x368105;};'use strict';var _=require(_0x3a99('0x0'));var util=require(_0x3a99('0x1'));var moment=require(_0x3a99('0x2'));var BPromise=require(_0x3a99('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3a99('0x4'));var db=require(_0x3a99('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x3a99('0x6'));var jayson=require(_0x3a99('0x7'));var client=jayson[_0x3a99('0x8')][_0x3a99('0x9')]({'port':0x232a});config[_0x3a99('0xa')]=_[_0x3a99('0xb')](config['redis'],{'host':_0x3a99('0xc'),'port':0x18eb});var socket=require(_0x3a99('0xd'))(new Redis(config[_0x3a99('0xa')]));require(_0x3a99('0xe'))['register'](socket);function respondWithRpcPromise(_0x1be3d1,_0x31c45f,_0x3fc34d){return new BPromise(function(_0x2499af,_0x373241){return client['request'](_0x1be3d1,_0x3fc34d)[_0x3a99('0xf')](function(_0x41b5ad){logger[_0x3a99('0x10')](_0x3a99('0x11'),_0x31c45f,_0x3a99('0x12'));logger[_0x3a99('0x13')](_0x3a99('0x14'),_0x31c45f,_0x3a99('0x12'),JSON[_0x3a99('0x15')](_0x41b5ad));if(_0x41b5ad[_0x3a99('0x16')]){if(_0x41b5ad['error'][_0x3a99('0x17')]===0x1f4){logger[_0x3a99('0x16')](_0x3a99('0x11'),_0x31c45f,_0x41b5ad[_0x3a99('0x16')][_0x3a99('0x18')]);return _0x373241(_0x41b5ad['error'][_0x3a99('0x18')]);}logger[_0x3a99('0x16')](_0x3a99('0x11'),_0x31c45f,_0x41b5ad['error'][_0x3a99('0x18')]);return _0x2499af(_0x41b5ad[_0x3a99('0x16')]['message']);}else{logger[_0x3a99('0x10')]('SmsQueue,\x20%s,\x20%s',_0x31c45f,_0x3a99('0x12'));_0x2499af(_0x41b5ad[_0x3a99('0x19')]['message']);}})[_0x3a99('0x1a')](function(_0x33f3e4){logger[_0x3a99('0x16')](_0x3a99('0x11'),_0x31c45f,_0x33f3e4);_0x373241(_0x33f3e4);});});}exports[_0x3a99('0x1b')]=function(_0x4ca7dd){var _0x5c4c7d=this;return new Promise(function(_0x557ffb,_0x41d96e){return db[_0x3a99('0x1c')][_0x3a99('0x1d')]({'raw':_0x4ca7dd[_0x3a99('0x1e')]?_0x4ca7dd[_0x3a99('0x1e')][_0x3a99('0x1f')]===undefined?!![]:![]:!![],'where':_0x4ca7dd[_0x3a99('0x1e')]?_0x4ca7dd[_0x3a99('0x1e')][_0x3a99('0x20')]||null:null,'attributes':_0x4ca7dd[_0x3a99('0x1e')]?_0x4ca7dd[_0x3a99('0x1e')][_0x3a99('0x21')]||null:null,'limit':_0x4ca7dd[_0x3a99('0x1e')]?_0x4ca7dd[_0x3a99('0x1e')]['limit']||null:null,'include':_0x4ca7dd['options']?_0x4ca7dd[_0x3a99('0x1e')][_0x3a99('0x22')]?_[_0x3a99('0x23')](_0x4ca7dd['options'][_0x3a99('0x22')],function(_0x34ae45){return{'model':db[_0x34ae45['model']],'as':_0x34ae45['as'],'attributes':_0x34ae45[_0x3a99('0x21')],'include':_0x34ae45['include']?_[_0x3a99('0x23')](_0x34ae45[_0x3a99('0x22')],function(_0xa3872){return{'model':db[_0xa3872['model']],'as':_0xa3872['as'],'attributes':_0xa3872[_0x3a99('0x21')],'include':_0xa3872[_0x3a99('0x22')]?_[_0x3a99('0x23')](_0xa3872[_0x3a99('0x22')],function(_0x571e6f){return{'model':db[_0x571e6f[_0x3a99('0x24')]],'as':_0x571e6f['as'],'attributes':_0x571e6f[_0x3a99('0x21')]};}):[]};}):[]};}):[]:[]})[_0x3a99('0xf')](function(_0x5d7e74){logger[_0x3a99('0x10')]('GetSmsQueue',_0x4ca7dd);logger[_0x3a99('0x13')](_0x3a99('0x1b'),_0x4ca7dd,JSON['stringify'](_0x5d7e74));_0x557ffb(_0x5d7e74);})[_0x3a99('0x1a')](function(_0x35ddee){logger['error'](_0x3a99('0x1b'),_0x35ddee[_0x3a99('0x18')],_0x4ca7dd);_0x41d96e(_0x5c4c7d[_0x3a99('0x16')](0x1f4,_0x35ddee[_0x3a99('0x18')]));});});};exports[_0x3a99('0x25')]=function(_0x335fc0){var _0x23fd81=this;return new Promise(function(_0x37fcf8,_0x314e40){return db[_0x3a99('0x1c')][_0x3a99('0x26')]({'raw':_0x335fc0[_0x3a99('0x1e')]?_0x335fc0[_0x3a99('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x335fc0[_0x3a99('0x1e')]?_0x335fc0[_0x3a99('0x1e')][_0x3a99('0x20')]||null:null,'attributes':_0x335fc0['options']?_0x335fc0['options'][_0x3a99('0x21')]||null:null,'include':_0x335fc0[_0x3a99('0x1e')]?_0x335fc0[_0x3a99('0x1e')][_0x3a99('0x22')]?_[_0x3a99('0x23')](_0x335fc0['options']['include'],function(_0x481710){return{'model':db[_0x481710[_0x3a99('0x24')]],'as':_0x481710['as'],'attributes':_0x481710[_0x3a99('0x21')],'include':_0x481710[_0x3a99('0x22')]?_[_0x3a99('0x23')](_0x481710[_0x3a99('0x22')],function(_0x4ea8ca){return{'model':db[_0x4ea8ca[_0x3a99('0x24')]],'as':_0x4ea8ca['as'],'attributes':_0x4ea8ca[_0x3a99('0x21')],'include':_0x4ea8ca['include']?_['map'](_0x4ea8ca[_0x3a99('0x22')],function(_0x3a2250){return{'model':db[_0x3a2250[_0x3a99('0x24')]],'as':_0x3a2250['as'],'attributes':_0x3a2250[_0x3a99('0x21')]};}):[]};}):[]};}):[]:[]})[_0x3a99('0xf')](function(_0x5980fd){logger['info']('ShowSmsQueue',_0x335fc0);logger[_0x3a99('0x13')](_0x3a99('0x25'),_0x335fc0,JSON[_0x3a99('0x15')](_0x5980fd));_0x37fcf8(_0x5980fd);})[_0x3a99('0x1a')](function(_0x47d04d){logger['error']('ShowSmsQueue',_0x47d04d['message'],_0x335fc0);_0x314e40(_0x23fd81[_0x3a99('0x16')](0x1f4,_0x47d04d[_0x3a99('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/smsQueue/smsQueue.socket.js b/server/api/smsQueue/smsQueue.socket.js new file mode 100644 index 0000000..00324ec --- /dev/null +++ b/server/api/smsQueue/smsQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xac22=['smsQueue:','save','remove','update','emit','removeListener'];(function(_0x53ccf2,_0x13cb67){var _0x5a2964=function(_0x3b0514){while(--_0x3b0514){_0x53ccf2['push'](_0x53ccf2['shift']());}};_0x5a2964(++_0x13cb67);}(_0xac22,0x133));var _0x2ac2=function(_0x5471f5,_0x1eb932){_0x5471f5=_0x5471f5-0x0;var _0x2ef429=_0xac22[_0x5471f5];return _0x2ef429;};'use strict';var SmsQueueEvents=require('./smsQueue.events');var events=[_0x2ac2('0x0'),_0x2ac2('0x1'),_0x2ac2('0x2')];function createListener(_0x722f0,_0x1a4b3b){return function(_0x165994){_0x1a4b3b[_0x2ac2('0x3')](_0x722f0,_0x165994);};}function removeListener(_0xced1c7,_0x1cdff4){return function(){SmsQueueEvents[_0x2ac2('0x4')](_0xced1c7,_0x1cdff4);};}exports['register']=function(_0x4a51cb){for(var _0x5db06a=0x0,_0x19fb8c=events['length'];_0x5db06a<_0x19fb8c;_0x5db06a++){var _0x31db8c=events[_0x5db06a];var _0x49d334=createListener(_0x2ac2('0x5')+_0x31db8c,_0x4a51cb);SmsQueueEvents['on'](_0x31db8c,_0x49d334);}}; \ No newline at end of file diff --git a/server/api/smsQueueReport/index.js b/server/api/smsQueueReport/index.js new file mode 100644 index 0000000..13b2c70 --- /dev/null +++ b/server/api/smsQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc7b9=['multer','util','path','Router','fs-extra','../../components/auth/service','../../config/environment','get','isAuthenticated','index','/describe','describe','/:id','show','post','create','put','update','delete','destroy','exports'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0xc7b9,0xa8));var _0x9c7b=function(_0x5cc3ad,_0x169e2a){_0x5cc3ad=_0x5cc3ad-0x0;var _0x773e57=_0xc7b9[_0x5cc3ad];return _0x773e57;};'use strict';var multer=require(_0x9c7b('0x0'));var util=require(_0x9c7b('0x1'));var path=require(_0x9c7b('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x9c7b('0x3')]();var fs_extra=require(_0x9c7b('0x4'));var auth=require(_0x9c7b('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0x9c7b('0x6'));var controller=require('./smsQueueReport.controller');router[_0x9c7b('0x7')]('/',auth[_0x9c7b('0x8')](),controller[_0x9c7b('0x9')]);router[_0x9c7b('0x7')](_0x9c7b('0xa'),auth['isAuthenticated'](),controller[_0x9c7b('0xb')]);router[_0x9c7b('0x7')](_0x9c7b('0xc'),auth[_0x9c7b('0x8')](),controller[_0x9c7b('0xd')]);router[_0x9c7b('0xe')]('/',auth[_0x9c7b('0x8')](),controller[_0x9c7b('0xf')]);router[_0x9c7b('0x10')]('/:id',auth[_0x9c7b('0x8')](),controller[_0x9c7b('0x11')]);router[_0x9c7b('0x12')]('/:id',auth[_0x9c7b('0x8')](),controller[_0x9c7b('0x13')]);module[_0x9c7b('0x14')]=router; \ No newline at end of file diff --git a/server/api/smsQueueReport/smsQueueReport.attributes.js b/server/api/smsQueueReport/smsQueueReport.attributes.js new file mode 100644 index 0000000..1a54185 --- /dev/null +++ b/server/api/smsQueueReport/smsQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9a6b=['sequelize','exports','STRING','DATE','moment'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x9a6b,0x77));var _0xb9a6=function(_0x186888,_0xe402a8){_0x186888=_0x186888-0x0;var _0x3224bf=_0x9a6b[_0x186888];return _0x3224bf;};'use strict';var moment=require(_0xb9a6('0x0'));var Sequelize=require(_0xb9a6('0x1'));module[_0xb9a6('0x2')]={'uniqueid':{'type':Sequelize[_0xb9a6('0x3')],'allowNull':![]},'from':{'type':Sequelize[_0xb9a6('0x3')]},'joinAt':{'type':Sequelize[_0xb9a6('0x4')]},'leaveAt':{'type':Sequelize['DATE']},'acceptAt':{'type':Sequelize[_0xb9a6('0x4')]},'exitAt':{'type':Sequelize['DATE']},'reason':{'type':Sequelize[_0xb9a6('0x3')]}}; \ No newline at end of file diff --git a/server/api/smsQueueReport/smsQueueReport.controller.js b/server/api/smsQueueReport/smsQueueReport.controller.js new file mode 100644 index 0000000..cf09775 --- /dev/null +++ b/server/api/smsQueueReport/smsQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xea02=['fs-extra','lodash','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','send','index','rawAttributes','key','map','query','keys','filters','intersection','attributes','model','fields','hasOwnProperty','nolimit','order','sort','where','type','VIRTUAL','filter','merge','options','SmsQueueReport','includeAll','include','findAll','catch','show','params','find','create','body','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs'];(function(_0x4efcad,_0x4ed9a7){var _0x5a6d2a=function(_0x908dca){while(--_0x908dca){_0x4efcad['push'](_0x4efcad['shift']());}};_0x5a6d2a(++_0x4ed9a7);}(_0xea02,0x1c2));var _0x2ea0=function(_0x1ffc15,_0x1dcef3){_0x1ffc15=_0x1ffc15-0x0;var _0x351b0a=_0xea02[_0x1ffc15];return _0x351b0a;};'use strict';var emlformat=require(_0x2ea0('0x0'));var rimraf=require(_0x2ea0('0x1'));var zipdir=require(_0x2ea0('0x2'));var jsonpatch=require(_0x2ea0('0x3'));var rp=require(_0x2ea0('0x4'));var moment=require(_0x2ea0('0x5'));var BPromise=require(_0x2ea0('0x6'));var Mustache=require(_0x2ea0('0x7'));var util=require(_0x2ea0('0x8'));var path=require(_0x2ea0('0x9'));var sox=require('sox');var csv=require(_0x2ea0('0xa'));var ejs=require(_0x2ea0('0xb'));var fs=require('fs');var fs_extra=require(_0x2ea0('0xc'));var _=require(_0x2ea0('0xd'));var squel=require('squel');var crypto=require(_0x2ea0('0xe'));var jsforce=require(_0x2ea0('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x2ea0('0x10'));var Redis=require(_0x2ea0('0x11'));var authService=require(_0x2ea0('0x12'));var qs=require(_0x2ea0('0x13'));var as=require(_0x2ea0('0x14'));var hardwareService=require(_0x2ea0('0x15'));var logger=require(_0x2ea0('0x16'))('api');var utils=require(_0x2ea0('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x2ea0('0x18'));var db=require(_0x2ea0('0x19'))['db'];function respondWithStatusCode(_0x351216,_0x5a3ee9){_0x5a3ee9=_0x5a3ee9||0xcc;return function(_0x580cbc){if(_0x580cbc){return _0x351216[_0x2ea0('0x1a')](_0x5a3ee9);}return _0x351216[_0x2ea0('0x1b')](_0x5a3ee9)[_0x2ea0('0x1c')]();};}function respondWithResult(_0x22b2d5,_0x47a43e){_0x47a43e=_0x47a43e||0xc8;return function(_0x1bffc3){if(_0x1bffc3){return _0x22b2d5['status'](_0x47a43e)[_0x2ea0('0x1d')](_0x1bffc3);}};}function respondWithFilteredResult(_0x1c75ca,_0x39d4bc){return function(_0x541e08){if(_0x541e08){var _0x2ad334=typeof _0x39d4bc[_0x2ea0('0x1e')]===_0x2ea0('0x1f')&&typeof _0x39d4bc[_0x2ea0('0x20')]==='undefined';var _0x1448db=_0x541e08['count'];var _0x3bd5a4=_0x2ad334?0x0:_0x39d4bc[_0x2ea0('0x1e')];var _0x39862f=_0x2ad334?_0x541e08[_0x2ea0('0x21')]:_0x39d4bc[_0x2ea0('0x1e')]+_0x39d4bc[_0x2ea0('0x20')];var _0xee6c3e;if(_0x39862f>=_0x1448db){_0x39862f=_0x1448db;_0xee6c3e=0xc8;}else{_0xee6c3e=0xce;}_0x1c75ca[_0x2ea0('0x1b')](_0xee6c3e);return _0x1c75ca[_0x2ea0('0x22')](_0x2ea0('0x23'),_0x3bd5a4+'-'+_0x39862f+'/'+_0x1448db)['json'](_0x541e08);}return null;};}function patchUpdates(_0x5dbc87){return function(_0x9254b1){try{jsonpatch[_0x2ea0('0x24')](_0x9254b1,_0x5dbc87,!![]);}catch(_0x49a15a){return BPromise[_0x2ea0('0x25')](_0x49a15a);}return _0x9254b1[_0x2ea0('0x26')]();};}function saveUpdates(_0x47be97,_0x58b97f){return function(_0x457ec2){if(_0x457ec2){return _0x457ec2[_0x2ea0('0x27')](_0x47be97)[_0x2ea0('0x28')](function(_0x47af26){return _0x47af26;});}return null;};}function removeEntity(_0x45830f,_0x17373b){return function(_0x21b28e){if(_0x21b28e){return _0x21b28e[_0x2ea0('0x29')]()[_0x2ea0('0x28')](function(){_0x45830f[_0x2ea0('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x17b5c4,_0x174219){return function(_0x3cb828){if(!_0x3cb828){_0x17b5c4[_0x2ea0('0x1a')](0x194);}return _0x3cb828;};}function handleError(_0x210ac0,_0xcd9f2e){_0xcd9f2e=_0xcd9f2e||0x1f4;return function(_0x38767a){logger['error'](_0x38767a[_0x2ea0('0x2a')]);if(_0x38767a[_0x2ea0('0x2b')]){delete _0x38767a[_0x2ea0('0x2b')];}_0x210ac0['status'](_0xcd9f2e)[_0x2ea0('0x2c')](_0x38767a);};}exports[_0x2ea0('0x2d')]=function(_0x5df443,_0x53a105){var _0x5d0a0a={},_0x247187={},_0x24a07f={'count':0x0,'rows':[]};var _0x451691=_['map'](db['SmsQueueReport'][_0x2ea0('0x2e')],function(_0x8ca81e){return{'name':_0x8ca81e['fieldName'],'type':_0x8ca81e['type'][_0x2ea0('0x2f')]};});_0x247187['model']=_[_0x2ea0('0x30')](_0x451691,'name');_0x247187[_0x2ea0('0x31')]=_[_0x2ea0('0x32')](_0x5df443[_0x2ea0('0x31')]);_0x247187[_0x2ea0('0x33')]=_[_0x2ea0('0x34')](_0x247187['model'],_0x247187[_0x2ea0('0x31')]);_0x5d0a0a[_0x2ea0('0x35')]=_[_0x2ea0('0x34')](_0x247187[_0x2ea0('0x36')],qs[_0x2ea0('0x37')](_0x5df443['query'][_0x2ea0('0x37')]));_0x5d0a0a[_0x2ea0('0x35')]=_0x5d0a0a['attributes']['length']?_0x5d0a0a['attributes']:_0x247187['model'];if(!_0x5df443['query'][_0x2ea0('0x38')](_0x2ea0('0x39'))){_0x5d0a0a['limit']=qs[_0x2ea0('0x20')](_0x5df443['query'][_0x2ea0('0x20')]);_0x5d0a0a['offset']=qs[_0x2ea0('0x1e')](_0x5df443[_0x2ea0('0x31')][_0x2ea0('0x1e')]);}_0x5d0a0a[_0x2ea0('0x3a')]=qs[_0x2ea0('0x3b')](_0x5df443[_0x2ea0('0x31')][_0x2ea0('0x3b')]);_0x5d0a0a[_0x2ea0('0x3c')]=qs[_0x2ea0('0x33')](_['pick'](_0x5df443[_0x2ea0('0x31')],_0x247187['filters']),_0x451691);if(_0x5df443[_0x2ea0('0x31')]['filter']){_0x5d0a0a['where']=_['merge'](_0x5d0a0a[_0x2ea0('0x3c')],{'$or':_['map'](_0x451691,function(_0x149400){if(_0x149400[_0x2ea0('0x3d')]!==_0x2ea0('0x3e')){var _0x35cae0={};_0x35cae0[_0x149400[_0x2ea0('0x2b')]]={'$like':'%'+_0x5df443[_0x2ea0('0x31')][_0x2ea0('0x3f')]+'%'};return _0x35cae0;}})});}_0x5d0a0a=_[_0x2ea0('0x40')]({},_0x5d0a0a,_0x5df443[_0x2ea0('0x41')]);var _0x46c521={'where':_0x5d0a0a[_0x2ea0('0x3c')]};return db[_0x2ea0('0x42')][_0x2ea0('0x21')](_0x46c521)['then'](function(_0x34c7fb){_0x24a07f[_0x2ea0('0x21')]=_0x34c7fb;if(_0x5df443[_0x2ea0('0x31')][_0x2ea0('0x43')]){_0x5d0a0a[_0x2ea0('0x44')]=[{'all':!![]}];}return db['SmsQueueReport'][_0x2ea0('0x45')](_0x5d0a0a);})[_0x2ea0('0x28')](function(_0x83f07d){_0x24a07f['rows']=_0x83f07d;return _0x24a07f;})[_0x2ea0('0x28')](respondWithFilteredResult(_0x53a105,_0x5d0a0a))[_0x2ea0('0x46')](handleError(_0x53a105,null));};exports[_0x2ea0('0x47')]=function(_0x16bab6,_0x2f8085){var _0x3f53af={'raw':!![],'where':{'id':_0x16bab6[_0x2ea0('0x48')]['id']}},_0x3eea46={};_0x3eea46[_0x2ea0('0x36')]=_['keys'](db['SmsQueueReport'][_0x2ea0('0x2e')]);_0x3eea46[_0x2ea0('0x31')]=_[_0x2ea0('0x32')](_0x16bab6[_0x2ea0('0x31')]);_0x3eea46[_0x2ea0('0x33')]=_[_0x2ea0('0x34')](_0x3eea46[_0x2ea0('0x36')],_0x3eea46[_0x2ea0('0x31')]);_0x3f53af['attributes']=_['intersection'](_0x3eea46[_0x2ea0('0x36')],qs[_0x2ea0('0x37')](_0x16bab6['query']['fields']));_0x3f53af[_0x2ea0('0x35')]=_0x3f53af[_0x2ea0('0x35')]['length']?_0x3f53af['attributes']:_0x3eea46['model'];if(_0x16bab6[_0x2ea0('0x31')]['includeAll']){_0x3f53af[_0x2ea0('0x44')]=[{'all':!![]}];}_0x3f53af=_[_0x2ea0('0x40')]({},_0x3f53af,_0x16bab6[_0x2ea0('0x41')]);return db['SmsQueueReport'][_0x2ea0('0x49')](_0x3f53af)[_0x2ea0('0x28')](handleEntityNotFound(_0x2f8085,null))['then'](respondWithResult(_0x2f8085,null))[_0x2ea0('0x46')](handleError(_0x2f8085,null));};exports[_0x2ea0('0x4a')]=function(_0x44f26b,_0x2c641b){return db['SmsQueueReport'][_0x2ea0('0x4a')](_0x44f26b[_0x2ea0('0x4b')],{})[_0x2ea0('0x28')](respondWithResult(_0x2c641b,0xc9))[_0x2ea0('0x46')](handleError(_0x2c641b,null));};exports[_0x2ea0('0x27')]=function(_0x161bee,_0x26a772){if(_0x161bee['body']['id']){delete _0x161bee[_0x2ea0('0x4b')]['id'];}return db[_0x2ea0('0x42')]['find']({'where':{'id':_0x161bee[_0x2ea0('0x48')]['id']}})[_0x2ea0('0x28')](handleEntityNotFound(_0x26a772,null))[_0x2ea0('0x28')](saveUpdates(_0x161bee[_0x2ea0('0x4b')],null))[_0x2ea0('0x28')](respondWithResult(_0x26a772,null))[_0x2ea0('0x46')](handleError(_0x26a772,null));};exports[_0x2ea0('0x29')]=function(_0x38e14f,_0x3083d2){return db[_0x2ea0('0x42')][_0x2ea0('0x49')]({'where':{'id':_0x38e14f[_0x2ea0('0x48')]['id']}})[_0x2ea0('0x28')](handleEntityNotFound(_0x3083d2,null))['then'](removeEntity(_0x3083d2,null))[_0x2ea0('0x46')](handleError(_0x3083d2,null));};exports[_0x2ea0('0x4c')]=function(_0x29bc6c,_0x42f738){return db[_0x2ea0('0x42')][_0x2ea0('0x4c')]()[_0x2ea0('0x28')](respondWithResult(_0x42f738,null))[_0x2ea0('0x46')](handleError(_0x42f738,null));}; \ No newline at end of file diff --git a/server/api/smsQueueReport/smsQueueReport.model.js b/server/api/smsQueueReport/smsQueueReport.model.js new file mode 100644 index 0000000..dbc4eb3 --- /dev/null +++ b/server/api/smsQueueReport/smsQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['define','report_sms_queue','uniqueid','lodash','util','bluebird','request-promise','path','rimraf','../../config/environment'];(function(_0x1e944f,_0x59fe91){var _0x20612c=function(_0xe002b4){while(--_0xe002b4){_0x1e944f['push'](_0x1e944f['shift']());}};_0x20612c(++_0x59fe91);}(_0xd8b0,0xad));var _0x0d8b=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xd8b0[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x0d8b('0x0'));var util=require(_0x0d8b('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x0d8b('0x2'));var rp=require(_0x0d8b('0x3'));var fs=require('fs');var path=require(_0x0d8b('0x4'));var rimraf=require(_0x0d8b('0x5'));var config=require(_0x0d8b('0x6'));var attributes=require('./smsQueueReport.attributes');module['exports']=function(_0x3f8b6f,_0x227c63){return _0x3f8b6f[_0x0d8b('0x7')]('SmsQueueReport',attributes,{'tableName':_0x0d8b('0x8'),'paranoid':![],'indexes':[{'name':_0x0d8b('0x9'),'fields':['uniqueid']}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/smsQueueReport/smsQueueReport.rpc.js b/server/api/smsQueueReport/smsQueueReport.rpc.js new file mode 100644 index 0000000..a820d74 --- /dev/null +++ b/server/api/smsQueueReport/smsQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdebb=['request\x20sent','SmsQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSmsQueueReport','create','body','options','raw','debug','SmsQueueReport','update','where','attributes','limit','UpdateSmsQueueReport','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','info','SmsQueueReport,\x20%s,\x20%s'];(function(_0x283127,_0x54d4d5){var _0x43da5d=function(_0x10947f){while(--_0x10947f){_0x283127['push'](_0x283127['shift']());}};_0x43da5d(++_0x54d4d5);}(_0xdebb,0x14f));var _0xbdeb=function(_0xe539a7,_0x5733d8){_0xe539a7=_0xe539a7-0x0;var _0x3f2233=_0xdebb[_0xe539a7];return _0x3f2233;};'use strict';var _=require(_0xbdeb('0x0'));var util=require(_0xbdeb('0x1'));var moment=require(_0xbdeb('0x2'));var BPromise=require('bluebird');var rs=require(_0xbdeb('0x3'));var fs=require('fs');var Redis=require(_0xbdeb('0x4'));var db=require(_0xbdeb('0x5'))['db'];var utils=require(_0xbdeb('0x6'));var logger=require('../../config/logger')(_0xbdeb('0x7'));var config=require(_0xbdeb('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xbdeb('0x9')][_0xbdeb('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x112a61,_0x140203,_0x178608){return new BPromise(function(_0x44b80a,_0x5dc8ed){return client[_0xbdeb('0xb')](_0x112a61,_0x178608)[_0xbdeb('0xc')](function(_0x53b32b){logger[_0xbdeb('0xd')](_0xbdeb('0xe'),_0x140203,_0xbdeb('0xf'));logger['debug'](_0xbdeb('0x10'),_0x140203,'request\x20sent',JSON[_0xbdeb('0x11')](_0x53b32b));if(_0x53b32b[_0xbdeb('0x12')]){if(_0x53b32b['error'][_0xbdeb('0x13')]===0x1f4){logger[_0xbdeb('0x12')](_0xbdeb('0xe'),_0x140203,_0x53b32b[_0xbdeb('0x12')]['message']);return _0x5dc8ed(_0x53b32b[_0xbdeb('0x12')][_0xbdeb('0x14')]);}logger[_0xbdeb('0x12')]('SmsQueueReport,\x20%s,\x20%s',_0x140203,_0x53b32b[_0xbdeb('0x12')][_0xbdeb('0x14')]);return _0x44b80a(_0x53b32b[_0xbdeb('0x12')][_0xbdeb('0x14')]);}else{logger[_0xbdeb('0xd')]('SmsQueueReport,\x20%s,\x20%s',_0x140203,_0xbdeb('0xf'));_0x44b80a(_0x53b32b[_0xbdeb('0x15')][_0xbdeb('0x14')]);}})[_0xbdeb('0x16')](function(_0x56c49e){logger['error'](_0xbdeb('0xe'),_0x140203,_0x56c49e);_0x5dc8ed(_0x56c49e);});});}exports[_0xbdeb('0x17')]=function(_0x2ee33c){var _0x3af4cf=this;return new Promise(function(_0x26f5c8,_0x4489cc){return db['SmsQueueReport'][_0xbdeb('0x18')](_0x2ee33c[_0xbdeb('0x19')],{'raw':_0x2ee33c[_0xbdeb('0x1a')]?_0x2ee33c[_0xbdeb('0x1a')][_0xbdeb('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x5f1eae){logger[_0xbdeb('0xd')](_0xbdeb('0x17'),_0x2ee33c);logger[_0xbdeb('0x1c')](_0xbdeb('0x17'),_0x2ee33c,JSON['stringify'](_0x5f1eae));_0x26f5c8(_0x5f1eae);})[_0xbdeb('0x16')](function(_0x4b994e){logger[_0xbdeb('0x12')]('CreateSmsQueueReport',_0x4b994e[_0xbdeb('0x14')],_0x2ee33c);_0x4489cc(_0x3af4cf[_0xbdeb('0x12')](0x1f4,_0x4b994e[_0xbdeb('0x14')]));});});};exports['UpdateSmsQueueReport']=function(_0x302f6c){var _0x349d55=this;return new Promise(function(_0x41bf16,_0x1b903b){return db[_0xbdeb('0x1d')][_0xbdeb('0x1e')](_0x302f6c['body'],{'raw':_0x302f6c['options']?_0x302f6c[_0xbdeb('0x1a')][_0xbdeb('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x302f6c[_0xbdeb('0x1a')]?_0x302f6c[_0xbdeb('0x1a')][_0xbdeb('0x1f')]||null:null,'attributes':_0x302f6c[_0xbdeb('0x1a')]?_0x302f6c['options'][_0xbdeb('0x20')]||null:null,'limit':_0x302f6c['options']?_0x302f6c[_0xbdeb('0x1a')][_0xbdeb('0x21')]||null:null})[_0xbdeb('0xc')](function(_0x38e937){logger[_0xbdeb('0xd')]('UpdateSmsQueueReport',_0x302f6c);logger[_0xbdeb('0x1c')](_0xbdeb('0x22'),_0x302f6c,JSON['stringify'](_0x38e937));_0x41bf16(_0x38e937);})[_0xbdeb('0x16')](function(_0x50cf86){logger[_0xbdeb('0x12')](_0xbdeb('0x22'),_0x50cf86[_0xbdeb('0x14')],_0x302f6c);_0x1b903b(_0x349d55[_0xbdeb('0x12')](0x1f4,_0x50cf86[_0xbdeb('0x14')]));});});}; \ No newline at end of file diff --git a/server/api/smsTransferReport/index.js b/server/api/smsTransferReport/index.js new file mode 100644 index 0000000..60ee3b4 --- /dev/null +++ b/server/api/smsTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x446c=['destroy','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../config/environment','isAuthenticated','index','describe','get','/:id','post','create','put','update','delete'];(function(_0x50b63c,_0x690d99){var _0x258408=function(_0x57d169){while(--_0x57d169){_0x50b63c['push'](_0x50b63c['shift']());}};_0x258408(++_0x690d99);}(_0x446c,0x156));var _0xc446=function(_0x219fa0,_0x18b239){_0x219fa0=_0x219fa0-0x0;var _0xc603fb=_0x446c[_0x219fa0];return _0xc603fb;};'use strict';var multer=require(_0xc446('0x0'));var util=require(_0xc446('0x1'));var path=require(_0xc446('0x2'));var timeout=require(_0xc446('0x3'));var express=require('express');var router=express[_0xc446('0x4')]();var fs_extra=require(_0xc446('0x5'));var auth=require(_0xc446('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0xc446('0x7'));var controller=require('./smsTransferReport.controller');router['get']('/',auth[_0xc446('0x8')](),controller[_0xc446('0x9')]);router['get']('/describe',auth[_0xc446('0x8')](),controller[_0xc446('0xa')]);router[_0xc446('0xb')](_0xc446('0xc'),auth[_0xc446('0x8')](),controller['show']);router[_0xc446('0xd')]('/',auth[_0xc446('0x8')](),controller[_0xc446('0xe')]);router[_0xc446('0xf')]('/:id',auth[_0xc446('0x8')](),controller[_0xc446('0x10')]);router[_0xc446('0x11')](_0xc446('0xc'),auth[_0xc446('0x8')](),controller[_0xc446('0x12')]);module[_0xc446('0x13')]=router; \ No newline at end of file diff --git a/server/api/smsTransferReport/smsTransferReport.attributes.js b/server/api/smsTransferReport/smsTransferReport.attributes.js new file mode 100644 index 0000000..4cf5721 --- /dev/null +++ b/server/api/smsTransferReport/smsTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x008c=['ENUM','agent','queue','DATE','NOW','moment','sequelize','exports','STRING'];(function(_0x24b852,_0x2bad67){var _0x180ad2=function(_0x454562){while(--_0x454562){_0x24b852['push'](_0x24b852['shift']());}};_0x180ad2(++_0x2bad67);}(_0x008c,0x188));var _0xc008=function(_0xc67084,_0x3e2efc){_0xc67084=_0xc67084-0x0;var _0x4d06c6=_0x008c[_0xc67084];return _0x4d06c6;};'use strict';var moment=require(_0xc008('0x0'));var Sequelize=require(_0xc008('0x1'));module[_0xc008('0x2')]={'uniqueid':{'type':Sequelize[_0xc008('0x3')],'allowNull':![]},'type':{'type':Sequelize[_0xc008('0x4')]('account',_0xc008('0x5'),_0xc008('0x6')),'allowNull':![],'defaultValue':_0xc008('0x6')},'transferredAt':{'type':Sequelize[_0xc008('0x7')],'allowNull':![],'defaultValue':Sequelize[_0xc008('0x8')]}}; \ No newline at end of file diff --git a/server/api/smsTransferReport/smsTransferReport.controller.js b/server/api/smsTransferReport/smsTransferReport.controller.js new file mode 100644 index 0000000..11e83f0 --- /dev/null +++ b/server/api/smsTransferReport/smsTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xae0f=['sendStatus','error','stack','name','send','index','map','SmsTransferReport','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','include','findAll','rows','catch','show','params','keys','find','create','body','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then'];(function(_0x3d42d8,_0x4cffaa){var _0x27fc41=function(_0x3a363b){while(--_0x3a363b){_0x3d42d8['push'](_0x3d42d8['shift']());}};_0x27fc41(++_0x4cffaa);}(_0xae0f,0xbc));var _0xfae0=function(_0x584892,_0x3c53bf){_0x584892=_0x584892-0x0;var _0x210ce2=_0xae0f[_0x584892];return _0x210ce2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xfae0('0x0'));var zipdir=require(_0xfae0('0x1'));var jsonpatch=require(_0xfae0('0x2'));var rp=require(_0xfae0('0x3'));var moment=require(_0xfae0('0x4'));var BPromise=require(_0xfae0('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xfae0('0x6'));var ejs=require(_0xfae0('0x7'));var fs=require('fs');var fs_extra=require(_0xfae0('0x8'));var _=require(_0xfae0('0x9'));var squel=require(_0xfae0('0xa'));var crypto=require('crypto');var jsforce=require(_0xfae0('0xb'));var deskjs=require(_0xfae0('0xc'));var toCsv=require('to-csv');var querystring=require(_0xfae0('0xd'));var Papa=require(_0xfae0('0xe'));var Redis=require('ioredis');var authService=require(_0xfae0('0xf'));var qs=require(_0xfae0('0x10'));var as=require(_0xfae0('0x11'));var hardwareService=require(_0xfae0('0x12'));var logger=require(_0xfae0('0x13'))(_0xfae0('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xfae0('0x15'));var db=require(_0xfae0('0x16'))['db'];function respondWithStatusCode(_0x498145,_0x1c100a){_0x1c100a=_0x1c100a||0xcc;return function(_0x26c7bd){if(_0x26c7bd){return _0x498145['sendStatus'](_0x1c100a);}return _0x498145['status'](_0x1c100a)[_0xfae0('0x17')]();};}function respondWithResult(_0x26a7ef,_0x39535f){_0x39535f=_0x39535f||0xc8;return function(_0x23c393){if(_0x23c393){return _0x26a7ef[_0xfae0('0x18')](_0x39535f)[_0xfae0('0x19')](_0x23c393);}};}function respondWithFilteredResult(_0x484f5c,_0x442cd6){return function(_0x293fee){if(_0x293fee){var _0x329514=typeof _0x442cd6[_0xfae0('0x1a')]===_0xfae0('0x1b')&&typeof _0x442cd6[_0xfae0('0x1c')]==='undefined';var _0x2ccdd8=_0x293fee[_0xfae0('0x1d')];var _0xaeb197=_0x329514?0x0:_0x442cd6[_0xfae0('0x1a')];var _0x11080b=_0x329514?_0x293fee['count']:_0x442cd6[_0xfae0('0x1a')]+_0x442cd6[_0xfae0('0x1c')];var _0x24498b;if(_0x11080b>=_0x2ccdd8){_0x11080b=_0x2ccdd8;_0x24498b=0xc8;}else{_0x24498b=0xce;}_0x484f5c[_0xfae0('0x18')](_0x24498b);return _0x484f5c[_0xfae0('0x1e')](_0xfae0('0x1f'),_0xaeb197+'-'+_0x11080b+'/'+_0x2ccdd8)[_0xfae0('0x19')](_0x293fee);}return null;};}function patchUpdates(_0x1e99f1){return function(_0x52992f){try{jsonpatch[_0xfae0('0x20')](_0x52992f,_0x1e99f1,!![]);}catch(_0x2ba164){return BPromise[_0xfae0('0x21')](_0x2ba164);}return _0x52992f['save']();};}function saveUpdates(_0x1d3a04,_0x214faa){return function(_0x28d673){if(_0x28d673){return _0x28d673[_0xfae0('0x22')](_0x1d3a04)['then'](function(_0x5a3493){return _0x5a3493;});}return null;};}function removeEntity(_0x19903a,_0x569a83){return function(_0x2faad2){if(_0x2faad2){return _0x2faad2[_0xfae0('0x23')]()[_0xfae0('0x24')](function(){_0x19903a[_0xfae0('0x18')](0xcc)[_0xfae0('0x17')]();});}};}function handleEntityNotFound(_0x472cde,_0x21f02c){return function(_0x3d611f){if(!_0x3d611f){_0x472cde[_0xfae0('0x25')](0x194);}return _0x3d611f;};}function handleError(_0x3775fb,_0x37aa01){_0x37aa01=_0x37aa01||0x1f4;return function(_0x48feba){logger[_0xfae0('0x26')](_0x48feba[_0xfae0('0x27')]);if(_0x48feba[_0xfae0('0x28')]){delete _0x48feba[_0xfae0('0x28')];}_0x3775fb[_0xfae0('0x18')](_0x37aa01)[_0xfae0('0x29')](_0x48feba);};}exports[_0xfae0('0x2a')]=function(_0x3e10cc,_0x1951a1){var _0x1aab6c={},_0x27755c={},_0x551281={'count':0x0,'rows':[]};var _0x142c0b=_[_0xfae0('0x2b')](db[_0xfae0('0x2c')][_0xfae0('0x2d')],function(_0x6ad10e){return{'name':_0x6ad10e[_0xfae0('0x2e')],'type':_0x6ad10e[_0xfae0('0x2f')][_0xfae0('0x30')]};});_0x27755c['model']=_[_0xfae0('0x2b')](_0x142c0b,_0xfae0('0x28'));_0x27755c[_0xfae0('0x31')]=_['keys'](_0x3e10cc['query']);_0x27755c[_0xfae0('0x32')]=_[_0xfae0('0x33')](_0x27755c[_0xfae0('0x34')],_0x27755c[_0xfae0('0x31')]);_0x1aab6c[_0xfae0('0x35')]=_[_0xfae0('0x33')](_0x27755c[_0xfae0('0x34')],qs[_0xfae0('0x36')](_0x3e10cc[_0xfae0('0x31')][_0xfae0('0x36')]));_0x1aab6c[_0xfae0('0x35')]=_0x1aab6c[_0xfae0('0x35')][_0xfae0('0x37')]?_0x1aab6c[_0xfae0('0x35')]:_0x27755c[_0xfae0('0x34')];if(!_0x3e10cc[_0xfae0('0x31')][_0xfae0('0x38')]('nolimit')){_0x1aab6c[_0xfae0('0x1c')]=qs['limit'](_0x3e10cc[_0xfae0('0x31')]['limit']);_0x1aab6c[_0xfae0('0x1a')]=qs[_0xfae0('0x1a')](_0x3e10cc[_0xfae0('0x31')][_0xfae0('0x1a')]);}_0x1aab6c[_0xfae0('0x39')]=qs[_0xfae0('0x3a')](_0x3e10cc['query'][_0xfae0('0x3a')]);_0x1aab6c[_0xfae0('0x3b')]=qs[_0xfae0('0x32')](_[_0xfae0('0x3c')](_0x3e10cc[_0xfae0('0x31')],_0x27755c[_0xfae0('0x32')]),_0x142c0b);if(_0x3e10cc['query'][_0xfae0('0x3d')]){_0x1aab6c[_0xfae0('0x3b')]=_[_0xfae0('0x3e')](_0x1aab6c[_0xfae0('0x3b')],{'$or':_[_0xfae0('0x2b')](_0x142c0b,function(_0x477770){if(_0x477770['type']!=='VIRTUAL'){var _0x3a5535={};_0x3a5535[_0x477770[_0xfae0('0x28')]]={'$like':'%'+_0x3e10cc['query'][_0xfae0('0x3d')]+'%'};return _0x3a5535;}})});}_0x1aab6c=_[_0xfae0('0x3e')]({},_0x1aab6c,_0x3e10cc[_0xfae0('0x3f')]);var _0x2c0de0={'where':_0x1aab6c[_0xfae0('0x3b')]};return db[_0xfae0('0x2c')][_0xfae0('0x1d')](_0x2c0de0)[_0xfae0('0x24')](function(_0x21c3a8){_0x551281[_0xfae0('0x1d')]=_0x21c3a8;if(_0x3e10cc[_0xfae0('0x31')]['includeAll']){_0x1aab6c[_0xfae0('0x40')]=[{'all':!![]}];}return db[_0xfae0('0x2c')][_0xfae0('0x41')](_0x1aab6c);})[_0xfae0('0x24')](function(_0xa9e27c){_0x551281[_0xfae0('0x42')]=_0xa9e27c;return _0x551281;})[_0xfae0('0x24')](respondWithFilteredResult(_0x1951a1,_0x1aab6c))[_0xfae0('0x43')](handleError(_0x1951a1,null));};exports[_0xfae0('0x44')]=function(_0x29da7e,_0x419949){var _0x18eb37={'raw':!![],'where':{'id':_0x29da7e[_0xfae0('0x45')]['id']}},_0xfcf69a={};_0xfcf69a[_0xfae0('0x34')]=_[_0xfae0('0x46')](db[_0xfae0('0x2c')]['rawAttributes']);_0xfcf69a['query']=_[_0xfae0('0x46')](_0x29da7e[_0xfae0('0x31')]);_0xfcf69a['filters']=_[_0xfae0('0x33')](_0xfcf69a[_0xfae0('0x34')],_0xfcf69a[_0xfae0('0x31')]);_0x18eb37[_0xfae0('0x35')]=_[_0xfae0('0x33')](_0xfcf69a[_0xfae0('0x34')],qs[_0xfae0('0x36')](_0x29da7e[_0xfae0('0x31')]['fields']));_0x18eb37['attributes']=_0x18eb37[_0xfae0('0x35')][_0xfae0('0x37')]?_0x18eb37[_0xfae0('0x35')]:_0xfcf69a[_0xfae0('0x34')];if(_0x29da7e[_0xfae0('0x31')]['includeAll']){_0x18eb37[_0xfae0('0x40')]=[{'all':!![]}];}_0x18eb37=_[_0xfae0('0x3e')]({},_0x18eb37,_0x29da7e[_0xfae0('0x3f')]);return db['SmsTransferReport'][_0xfae0('0x47')](_0x18eb37)['then'](handleEntityNotFound(_0x419949,null))[_0xfae0('0x24')](respondWithResult(_0x419949,null))[_0xfae0('0x43')](handleError(_0x419949,null));};exports[_0xfae0('0x48')]=function(_0x46e1e4,_0x2b61f9){return db[_0xfae0('0x2c')][_0xfae0('0x48')](_0x46e1e4['body'],{})[_0xfae0('0x24')](respondWithResult(_0x2b61f9,0xc9))[_0xfae0('0x43')](handleError(_0x2b61f9,null));};exports[_0xfae0('0x22')]=function(_0x1f4834,_0x2d2ee5){if(_0x1f4834[_0xfae0('0x49')]['id']){delete _0x1f4834[_0xfae0('0x49')]['id'];}return db[_0xfae0('0x2c')]['find']({'where':{'id':_0x1f4834[_0xfae0('0x45')]['id']}})[_0xfae0('0x24')](handleEntityNotFound(_0x2d2ee5,null))[_0xfae0('0x24')](saveUpdates(_0x1f4834[_0xfae0('0x49')],null))['then'](respondWithResult(_0x2d2ee5,null))[_0xfae0('0x43')](handleError(_0x2d2ee5,null));};exports['destroy']=function(_0xe089dc,_0x19f419){return db['SmsTransferReport'][_0xfae0('0x47')]({'where':{'id':_0xe089dc[_0xfae0('0x45')]['id']}})[_0xfae0('0x24')](handleEntityNotFound(_0x19f419,null))[_0xfae0('0x24')](removeEntity(_0x19f419,null))[_0xfae0('0x43')](handleError(_0x19f419,null));};exports[_0xfae0('0x4a')]=function(_0x28abf3,_0x5621fd){return db['SmsTransferReport'][_0xfae0('0x4a')]()['then'](respondWithResult(_0x5621fd,null))['catch'](handleError(_0x5621fd,null));}; \ No newline at end of file diff --git a/server/api/smsTransferReport/smsTransferReport.model.js b/server/api/smsTransferReport/smsTransferReport.model.js new file mode 100644 index 0000000..42bb5c3 --- /dev/null +++ b/server/api/smsTransferReport/smsTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x92ba=['bluebird','path','rimraf','../../config/environment','./smsTransferReport.attributes','exports','define','report_sms_transfer','uniqueid','util','../../config/logger','api','moment'];(function(_0x3987d3,_0x5e9a84){var _0x389897=function(_0x307c3c){while(--_0x307c3c){_0x3987d3['push'](_0x3987d3['shift']());}};_0x389897(++_0x5e9a84);}(_0x92ba,0x1d0));var _0xa92b=function(_0x3e4a00,_0x5549e3){_0x3e4a00=_0x3e4a00-0x0;var _0x45598a=_0x92ba[_0x3e4a00];return _0x45598a;};'use strict';var _=require('lodash');var util=require(_0xa92b('0x0'));var logger=require(_0xa92b('0x1'))(_0xa92b('0x2'));var moment=require(_0xa92b('0x3'));var BPromise=require(_0xa92b('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xa92b('0x5'));var rimraf=require(_0xa92b('0x6'));var config=require(_0xa92b('0x7'));var attributes=require(_0xa92b('0x8'));module[_0xa92b('0x9')]=function(_0x15dbe0,_0x171f67){return _0x15dbe0[_0xa92b('0xa')]('SmsTransferReport',attributes,{'tableName':_0xa92b('0xb'),'paranoid':![],'indexes':[{'name':_0xa92b('0xc'),'fields':[_0xa92b('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/smsTransferReport/smsTransferReport.rpc.js b/server/api/smsTransferReport/smsTransferReport.rpc.js new file mode 100644 index 0000000..55e815c --- /dev/null +++ b/server/api/smsTransferReport/smsTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x79a8=['message','result','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SmsTransferReport,\x20%s,\x20%s','request\x20sent','SmsTransferReport,\x20%s,\x20%s,\x20%s','error','code'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x79a8,0x1d0));var _0x879a=function(_0x1e9604,_0x5de613){_0x1e9604=_0x1e9604-0x0;var _0x522053=_0x79a8[_0x1e9604];return _0x522053;};'use strict';var _=require(_0x879a('0x0'));var util=require('util');var moment=require(_0x879a('0x1'));var BPromise=require(_0x879a('0x2'));var rs=require(_0x879a('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x879a('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x879a('0x5'))(_0x879a('0x6'));var config=require(_0x879a('0x7'));var jayson=require(_0x879a('0x8'));var client=jayson[_0x879a('0x9')][_0x879a('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1d353e,_0x2427bf,_0x4bf3ab){return new BPromise(function(_0xe27fe6,_0x5cb5c9){return client[_0x879a('0xb')](_0x1d353e,_0x4bf3ab)[_0x879a('0xc')](function(_0x5eba04){logger[_0x879a('0xd')](_0x879a('0xe'),_0x2427bf,_0x879a('0xf'));logger['debug'](_0x879a('0x10'),_0x2427bf,_0x879a('0xf'),JSON['stringify'](_0x5eba04));if(_0x5eba04['error']){if(_0x5eba04[_0x879a('0x11')][_0x879a('0x12')]===0x1f4){logger[_0x879a('0x11')](_0x879a('0xe'),_0x2427bf,_0x5eba04['error'][_0x879a('0x13')]);return _0x5cb5c9(_0x5eba04[_0x879a('0x11')][_0x879a('0x13')]);}logger[_0x879a('0x11')](_0x879a('0xe'),_0x2427bf,_0x5eba04[_0x879a('0x11')][_0x879a('0x13')]);return _0xe27fe6(_0x5eba04[_0x879a('0x11')][_0x879a('0x13')]);}else{logger[_0x879a('0xd')]('SmsTransferReport,\x20%s,\x20%s',_0x2427bf,'request\x20sent');_0xe27fe6(_0x5eba04[_0x879a('0x14')][_0x879a('0x13')]);}})['catch'](function(_0x119260){logger[_0x879a('0x11')](_0x879a('0xe'),_0x2427bf,_0x119260);_0x5cb5c9(_0x119260);});});} \ No newline at end of file diff --git a/server/api/sound/index.js b/server/api/sound/index.js new file mode 100644 index 0000000..fd8d425 --- /dev/null +++ b/server/api/sound/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcc02=['multer','util','path','express','Router','fs-extra','../../config/environment','get','isAuthenticated','index','/:id','/:id/download','download','diskStorage','root','server/files/sounds/original/','originalname','replace','basename','post','single','file','create','put','update','delete'];(function(_0x18b9cc,_0x42bafc){var _0x373cc9=function(_0x46aa3d){while(--_0x46aa3d){_0x18b9cc['push'](_0x18b9cc['shift']());}};_0x373cc9(++_0x42bafc);}(_0xcc02,0x9c));var _0x2cc0=function(_0x4a9b47,_0x8b9c3e){_0x4a9b47=_0x4a9b47-0x0;var _0x31ec47=_0xcc02[_0x4a9b47];return _0x31ec47;};'use strict';var multer=require(_0x2cc0('0x0'));var util=require(_0x2cc0('0x1'));var path=require(_0x2cc0('0x2'));var timeout=require('connect-timeout');var express=require(_0x2cc0('0x3'));var router=express[_0x2cc0('0x4')]();var fs_extra=require(_0x2cc0('0x5'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require(_0x2cc0('0x6'));var controller=require('./sound.controller');router[_0x2cc0('0x7')]('/',auth[_0x2cc0('0x8')](),controller[_0x2cc0('0x9')]);router['get'](_0x2cc0('0xa'),auth[_0x2cc0('0x8')](),controller['show']);router[_0x2cc0('0x7')](_0x2cc0('0xb'),auth[_0x2cc0('0x8')](),controller[_0x2cc0('0xc')]);var upload=multer({'storage':multer[_0x2cc0('0xd')]({'destination':function(_0x301c5e,_0x4635a4,_0x494a5e){_0x494a5e(null,path['join'](config[_0x2cc0('0xe')],_0x2cc0('0xf')));},'filename':function(_0x4afd6b,_0x1238d0,_0x2715d0){_0x1238d0[_0x2cc0('0x10')]=_0x1238d0[_0x2cc0('0x10')][_0x2cc0('0x11')](/[+@&\/\\#,+()$~%'":*?<>{}\s\\|]/g,'-');_0x2715d0(null,util['format']('%s-%s%s',path[_0x2cc0('0x12')](_0x1238d0[_0x2cc0('0x10')],path['extname'](_0x1238d0[_0x2cc0('0x10')])),Date['now'](),path['extname'](_0x1238d0['originalname'])));}})});router[_0x2cc0('0x13')]('/',upload[_0x2cc0('0x14')](_0x2cc0('0x15')),controller[_0x2cc0('0x16')]);router[_0x2cc0('0x17')](_0x2cc0('0xa'),auth[_0x2cc0('0x8')](),controller[_0x2cc0('0x18')]);router[_0x2cc0('0x19')](_0x2cc0('0xa'),auth['isAuthenticated'](),controller[_0x2cc0('0x19')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/sound/sound.attributes.js b/server/api/sound/sound.attributes.js new file mode 100644 index 0000000..818dd23 --- /dev/null +++ b/server/api/sound/sound.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4121=['INTEGER','sequelize','STRING','name','FLOAT','BIGINT'];(function(_0x1e8f6b,_0x36ef00){var _0x171dfc=function(_0x573798){while(--_0x573798){_0x1e8f6b['push'](_0x1e8f6b['shift']());}};_0x171dfc(++_0x36ef00);}(_0x4121,0x14b));var _0x1412=function(_0x4133a2,_0x2287b6){_0x4133a2=_0x4133a2-0x0;var _0x4d8387=_0x4121[_0x4133a2];return _0x4d8387;};'use strict';var Sequelize=require(_0x1412('0x0'));module['exports']={'name':{'type':Sequelize[_0x1412('0x1')],'unique':_0x1412('0x2'),'allowNull':![]},'save_name':{'type':Sequelize[_0x1412('0x1')]},'display_name':{'type':Sequelize['STRING'],'defaultValue':''},'description':{'type':Sequelize[_0x1412('0x1')]},'original_format':{'type':Sequelize[_0x1412('0x1')]},'original_duration':{'type':Sequelize[_0x1412('0x3')]},'original_sampleCount':{'type':Sequelize[_0x1412('0x4')]},'original_channelCount':{'type':Sequelize[_0x1412('0x5')]},'original_bitRate':{'type':Sequelize[_0x1412('0x4')]},'original_sampleRate':{'type':Sequelize[_0x1412('0x5')]},'converted_format':{'type':Sequelize[_0x1412('0x1')]},'converted_duration':{'type':Sequelize[_0x1412('0x3')]},'converted_sampleCount':{'type':Sequelize[_0x1412('0x4')]},'converted_channelCount':{'type':Sequelize[_0x1412('0x5')]},'converted_bitRate':{'type':Sequelize[_0x1412('0x4')]},'converted_sampleRate':{'type':Sequelize[_0x1412('0x5')]}}; \ No newline at end of file diff --git a/server/api/sound/sound.controller.js b/server/api/sound/sound.controller.js new file mode 100644 index 0000000..fc7051b --- /dev/null +++ b/server/api/sound/sound.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfaef=['body','role','userProfileId','user','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','description','delete','params','save_name','original_format','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','limit','undefined','offset','count','set','Content-Range','apply','save','update','then','get','Sounds','UserProfileResource','destroy','sendStatus','name','send','rawAttributes','fieldName','key','model','map','keys','query','filters','intersection','attributes','fields','length','order','sort','where','pick','filter','merge','type','VIRTUAL','options','Sound','includeAll','include','findAll','rows','catch','show','find','download','join','converted_format','Sequelize','ValidationError','Sound\x20not\x20found','root','server/files/sounds/converted','%s.%s','create','basename','file','originalname','extname','filename','substring','format','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','transcode','wav','unlinkSync','original_duration','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','bitRate','original_sampleRate','sampleRate','converted_duration','converted_sampleCount','converted_channelCount','converted_sampleRate'];(function(_0x15ec92,_0x1e80d2){var _0x376fc6=function(_0x4fb6ed){while(--_0x4fb6ed){_0x15ec92['push'](_0x15ec92['shift']());}};_0x376fc6(++_0x1e80d2);}(_0xfaef,0x8d));var _0xffae=function(_0x3e99cb,_0x1d2fe0){_0x3e99cb=_0x3e99cb-0x0;var _0x1bc729=_0xfaef[_0x3e99cb];return _0x1bc729;};'use strict';var emlformat=require(_0xffae('0x0'));var rimraf=require(_0xffae('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xffae('0x2'));var rp=require(_0xffae('0x3'));var moment=require(_0xffae('0x4'));var BPromise=require(_0xffae('0x5'));var Mustache=require(_0xffae('0x6'));var util=require(_0xffae('0x7'));var path=require(_0xffae('0x8'));var sox=require(_0xffae('0x9'));var csv=require(_0xffae('0xa'));var ejs=require(_0xffae('0xb'));var fs=require('fs');var fs_extra=require(_0xffae('0xc'));var _=require(_0xffae('0xd'));var squel=require(_0xffae('0xe'));var crypto=require(_0xffae('0xf'));var jsforce=require(_0xffae('0x10'));var deskjs=require(_0xffae('0x11'));var toCsv=require(_0xffae('0xa'));var querystring=require(_0xffae('0x12'));var Papa=require(_0xffae('0x13'));var Redis=require('ioredis');var authService=require(_0xffae('0x14'));var qs=require(_0xffae('0x15'));var as=require(_0xffae('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xffae('0x17'))(_0xffae('0x18'));var utils=require(_0xffae('0x19'));var config=require(_0xffae('0x1a'));var licenseUtil=require(_0xffae('0x1b'));var db=require(_0xffae('0x1c'))['db'];function respondWithStatusCode(_0x1a6546,_0xfb6c18){_0xfb6c18=_0xfb6c18||0xcc;return function(_0x5d1c35){if(_0x5d1c35){return _0x1a6546['sendStatus'](_0xfb6c18);}return _0x1a6546[_0xffae('0x1d')](_0xfb6c18)[_0xffae('0x1e')]();};}function respondWithResult(_0x102fb3,_0xd4d71e){_0xd4d71e=_0xd4d71e||0xc8;return function(_0x5e3b60){if(_0x5e3b60){return _0x102fb3[_0xffae('0x1d')](_0xd4d71e)[_0xffae('0x1f')](_0x5e3b60);}};}function respondWithFilteredResult(_0x2bfadf,_0x3b61cd){return function(_0x3d8879){if(_0x3d8879){var _0x420a47=typeof _0x3b61cd['offset']==='undefined'&&typeof _0x3b61cd[_0xffae('0x20')]===_0xffae('0x21');var _0x1c3b50=_0x3d8879['count'];var _0x12e55d=_0x420a47?0x0:_0x3b61cd[_0xffae('0x22')];var _0x5e911e=_0x420a47?_0x3d8879[_0xffae('0x23')]:_0x3b61cd[_0xffae('0x22')]+_0x3b61cd[_0xffae('0x20')];var _0x454ba6;if(_0x5e911e>=_0x1c3b50){_0x5e911e=_0x1c3b50;_0x454ba6=0xc8;}else{_0x454ba6=0xce;}_0x2bfadf['status'](_0x454ba6);return _0x2bfadf[_0xffae('0x24')](_0xffae('0x25'),_0x12e55d+'-'+_0x5e911e+'/'+_0x1c3b50)[_0xffae('0x1f')](_0x3d8879);}return null;};}function patchUpdates(_0x4da60d){return function(_0x414495){try{jsonpatch[_0xffae('0x26')](_0x414495,_0x4da60d,!![]);}catch(_0x30eae2){return BPromise['reject'](_0x30eae2);}return _0x414495[_0xffae('0x27')]();};}function saveUpdates(_0x2778fd,_0x3af01e){return function(_0x5e2f27){if(_0x5e2f27){return _0x5e2f27[_0xffae('0x28')](_0x2778fd)[_0xffae('0x29')](function(_0x5e7e7d){return _0x5e7e7d;});}return null;};}function removeEntity(_0x47b9de,_0x35ea0b){return function(_0x2c28ff){if(_0x2c28ff){return _0x2c28ff['destroy']()[_0xffae('0x29')](function(){var _0x232bdb=_0x2c28ff[_0xffae('0x2a')]({'plain':!![]});var _0x206708=_0xffae('0x2b');return db[_0xffae('0x2c')][_0xffae('0x2d')]({'where':{'type':_0x206708,'resourceId':_0x232bdb['id']}})[_0xffae('0x29')](function(){return _0x2c28ff;});})['then'](function(){_0x47b9de[_0xffae('0x1d')](0xcc)[_0xffae('0x1e')]();});}};}function handleEntityNotFound(_0x35ba21,_0x2ab192){return function(_0x5c570f){if(!_0x5c570f){_0x35ba21[_0xffae('0x2e')](0x194);}return _0x5c570f;};}function handleError(_0x50b1e9,_0xd91a93){_0xd91a93=_0xd91a93||0x1f4;return function(_0x394de9){logger['error'](_0x394de9['stack']);if(_0x394de9[_0xffae('0x2f')]){delete _0x394de9[_0xffae('0x2f')];}_0x50b1e9[_0xffae('0x1d')](_0xd91a93)[_0xffae('0x30')](_0x394de9);};}exports['index']=function(_0x1cefed,_0x4714ff){var _0x1ebf77={},_0x167fd0={},_0x394720={'count':0x0,'rows':[]};var _0x5dfccf=_['map'](db['Sound'][_0xffae('0x31')],function(_0x294bb){return{'name':_0x294bb[_0xffae('0x32')],'type':_0x294bb['type'][_0xffae('0x33')]};});_0x167fd0[_0xffae('0x34')]=_[_0xffae('0x35')](_0x5dfccf,_0xffae('0x2f'));_0x167fd0['query']=_[_0xffae('0x36')](_0x1cefed[_0xffae('0x37')]);_0x167fd0[_0xffae('0x38')]=_[_0xffae('0x39')](_0x167fd0[_0xffae('0x34')],_0x167fd0[_0xffae('0x37')]);_0x1ebf77[_0xffae('0x3a')]=_['intersection'](_0x167fd0[_0xffae('0x34')],qs[_0xffae('0x3b')](_0x1cefed[_0xffae('0x37')]['fields']));_0x1ebf77[_0xffae('0x3a')]=_0x1ebf77[_0xffae('0x3a')][_0xffae('0x3c')]?_0x1ebf77[_0xffae('0x3a')]:_0x167fd0[_0xffae('0x34')];if(!_0x1cefed[_0xffae('0x37')]['hasOwnProperty']('nolimit')){_0x1ebf77[_0xffae('0x20')]=qs['limit'](_0x1cefed[_0xffae('0x37')]['limit']);_0x1ebf77[_0xffae('0x22')]=qs['offset'](_0x1cefed[_0xffae('0x37')][_0xffae('0x22')]);}_0x1ebf77[_0xffae('0x3d')]=qs['sort'](_0x1cefed['query'][_0xffae('0x3e')]);_0x1ebf77[_0xffae('0x3f')]=qs['filters'](_[_0xffae('0x40')](_0x1cefed[_0xffae('0x37')],_0x167fd0[_0xffae('0x38')]),_0x5dfccf);if(_0x1cefed['query'][_0xffae('0x41')]){_0x1ebf77[_0xffae('0x3f')]=_[_0xffae('0x42')](_0x1ebf77['where'],{'$or':_[_0xffae('0x35')](_0x5dfccf,function(_0x522390){if(_0x522390[_0xffae('0x43')]!==_0xffae('0x44')){var _0x13d8b7={};_0x13d8b7[_0x522390[_0xffae('0x2f')]]={'$like':'%'+_0x1cefed['query'][_0xffae('0x41')]+'%'};return _0x13d8b7;}})});}_0x1ebf77=_[_0xffae('0x42')]({},_0x1ebf77,_0x1cefed[_0xffae('0x45')]);var _0x46aa71={'where':_0x1ebf77['where']};return db[_0xffae('0x46')][_0xffae('0x23')](_0x46aa71)[_0xffae('0x29')](function(_0x3ea6dc){_0x394720[_0xffae('0x23')]=_0x3ea6dc;if(_0x1cefed[_0xffae('0x37')][_0xffae('0x47')]){_0x1ebf77[_0xffae('0x48')]=[{'all':!![]}];}return db[_0xffae('0x46')][_0xffae('0x49')](_0x1ebf77);})['then'](function(_0x194880){_0x394720[_0xffae('0x4a')]=_0x194880;return _0x394720;})['then'](respondWithFilteredResult(_0x4714ff,_0x1ebf77))[_0xffae('0x4b')](handleError(_0x4714ff,null));};exports[_0xffae('0x4c')]=function(_0x2d2802,_0x2cebf2){var _0x35485b={'raw':!![],'where':{'id':_0x2d2802['params']['id']}},_0x95315d={};_0x95315d['model']=_['keys'](db[_0xffae('0x46')][_0xffae('0x31')]);_0x95315d[_0xffae('0x37')]=_['keys'](_0x2d2802[_0xffae('0x37')]);_0x95315d[_0xffae('0x38')]=_['intersection'](_0x95315d[_0xffae('0x34')],_0x95315d[_0xffae('0x37')]);_0x35485b[_0xffae('0x3a')]=_[_0xffae('0x39')](_0x95315d['model'],qs[_0xffae('0x3b')](_0x2d2802[_0xffae('0x37')][_0xffae('0x3b')]));_0x35485b[_0xffae('0x3a')]=_0x35485b[_0xffae('0x3a')][_0xffae('0x3c')]?_0x35485b[_0xffae('0x3a')]:_0x95315d['model'];if(_0x2d2802[_0xffae('0x37')][_0xffae('0x47')]){_0x35485b['include']=[{'all':!![]}];}_0x35485b=_[_0xffae('0x42')]({},_0x35485b,_0x2d2802[_0xffae('0x45')]);return db[_0xffae('0x46')][_0xffae('0x4d')](_0x35485b)['then'](handleEntityNotFound(_0x2cebf2,null))[_0xffae('0x29')](respondWithResult(_0x2cebf2,null))[_0xffae('0x4b')](handleError(_0x2cebf2,null));};exports[_0xffae('0x4e')]=function(_0x2803a7,_0x27cf07,_0x2902bd){return db[_0xffae('0x46')][_0xffae('0x4d')]({'where':{'id':_0x2803a7['params']['id']},'attributes':[_0xffae('0x2f'),'save_name','converted_format'],'raw':!![]})[_0xffae('0x29')](handleEntityNotFound(_0x27cf07,null))[_0xffae('0x29')](function(_0x5b01cf){if(_0x5b01cf){if(!fs['existsSync'](path[_0xffae('0x4f')](config['root'],'server/files/sounds/converted',_0x5b01cf['save_name']+'.'+_0x5b01cf[_0xffae('0x50')]))){throw new db[(_0xffae('0x51'))][(_0xffae('0x52'))](_0xffae('0x53'));}return _0x27cf07['download'](path[_0xffae('0x4f')](config[_0xffae('0x54')],_0xffae('0x55'),util['format'](_0xffae('0x56'),_0x5b01cf['save_name'],_0x5b01cf['converted_format'])),util['format'](_0xffae('0x56'),_0x5b01cf['name'],_0x5b01cf[_0xffae('0x50')]));}return null;})['catch'](handleError(_0x27cf07,null));};exports[_0xffae('0x57')]=function(_0x44f03e,_0x2b60f2,_0x5578c0){var _0x5328b2={'name':path[_0xffae('0x58')](_0x44f03e[_0xffae('0x59')][_0xffae('0x5a')],path[_0xffae('0x5b')](_0x44f03e[_0xffae('0x59')]['originalname'])),'save_name':path[_0xffae('0x58')](_0x44f03e[_0xffae('0x59')][_0xffae('0x5c')],path[_0xffae('0x5b')](_0x44f03e['file'][_0xffae('0x5c')])),'original_format':path['extname'](_0x44f03e['file']['originalname'])[_0xffae('0x5d')](0x1),'converted_format':'wav'};var _0xc7ee21=path[_0xffae('0x4f')](config[_0xffae('0x54')],'server/files/sounds/original',_0x44f03e[_0xffae('0x59')][_0xffae('0x5c')]);var _0x23886b=path['join'](config['root'],'server/files/sounds/converted',util[_0xffae('0x5e')](_0xffae('0x56'),path['basename'](_0x44f03e[_0xffae('0x59')][_0xffae('0x5c')],path[_0xffae('0x5b')](_0x44f03e[_0xffae('0x59')][_0xffae('0x5c')])),_0x5328b2[_0xffae('0x50')]));logger[_0xffae('0x5f')](_0xffae('0x60'),_0xc7ee21);logger[_0xffae('0x5f')](_0xffae('0x61'),_0x23886b);try{fs[_0xffae('0x62')](_0xc7ee21,parseInt('0777',0x8));var _0xb03ccc=sox[_0xffae('0x63')](_0xc7ee21,_0x23886b,{'sampleRate':0x1f40,'format':_0xffae('0x64'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0xb03ccc['on']('error',function(_0x5785c3){fs[_0xffae('0x65')](_0xc7ee21);_0x2b60f2[_0xffae('0x1d')](0x1f4)[_0xffae('0x30')](_0x5785c3);});_0xb03ccc['on']('src',function(_0x1c83e7){_0x5328b2[_0xffae('0x66')]=isNaN(_0x1c83e7[_0xffae('0x67')])?null:_0x1c83e7[_0xffae('0x67')]*0x3e8;_0x5328b2[_0xffae('0x68')]=isNaN(_0x1c83e7['sampleCount'])?null:_0x1c83e7[_0xffae('0x69')];_0x5328b2[_0xffae('0x6a')]=isNaN(_0x1c83e7[_0xffae('0x6b')])?null:_0x1c83e7[_0xffae('0x6b')];_0x5328b2['original_bitRate']=isNaN(_0x1c83e7[_0xffae('0x6c')])?null:_0x1c83e7[_0xffae('0x6c')];_0x5328b2[_0xffae('0x6d')]=isNaN(_0x1c83e7[_0xffae('0x6e')])?null:_0x1c83e7[_0xffae('0x6e')];});_0xb03ccc['on']('dest',function(_0x99fc7d){_0x5328b2[_0xffae('0x6f')]=isNaN(_0x99fc7d[_0xffae('0x67')])?null:_0x99fc7d[_0xffae('0x67')]*0x3e8;_0x5328b2[_0xffae('0x70')]=isNaN(_0x99fc7d[_0xffae('0x69')])?null:_0x99fc7d[_0xffae('0x69')];_0x5328b2[_0xffae('0x71')]=isNaN(_0x99fc7d['channelCount'])?null:_0x99fc7d['channelCount'];_0x5328b2['converted_bitRate']=isNaN(_0x99fc7d['bitRate'])?null:_0x99fc7d[_0xffae('0x6c')];_0x5328b2[_0xffae('0x72')]=isNaN(_0x99fc7d['sampleRate'])?null:_0x99fc7d[_0xffae('0x6e')];});_0xb03ccc['on'](_0xffae('0x1e'),function(){fs['chmodSync'](_0x23886b,parseInt('0777',0x8));return db[_0xffae('0x46')][_0xffae('0x57')](_0x5328b2)['then'](function(_0x52c51e){var _0x4565a0={'role':_0x44f03e[_0xffae('0x73')][_0xffae('0x74')],'userProfileId':_0x44f03e['body'][_0xffae('0x75')]};if(!_0x4565a0)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4565a0[_0xffae('0x74')]===_0xffae('0x76')){var _0x45266d=_0x52c51e['get']({'plain':!![]});return db[_0xffae('0x77')][_0xffae('0x4d')]({'where':{'name':_0xffae('0x2b'),'userProfileId':_0x4565a0[_0xffae('0x75')]},'raw':!![]})[_0xffae('0x29')](function(_0x46b170){if(_0x46b170&&_0x46b170[_0xffae('0x78')]===0x0){return db[_0xffae('0x2c')][_0xffae('0x57')]({'name':_0x45266d[_0xffae('0x2f')],'resourceId':_0x45266d['id'],'type':_0x46b170[_0xffae('0x2f')],'sectionId':_0x46b170['id']},{})['then'](function(){return _0x52c51e;});}else{return _0x52c51e;}})['catch'](function(_0x367cc8){logger[_0xffae('0x79')](_0xffae('0x7a'),_0x367cc8);throw _0x367cc8;});}return _0x52c51e;})[_0xffae('0x29')](respondWithResult(_0x2b60f2,null))[_0xffae('0x4b')](handleError(_0x2b60f2,null));});_0xb03ccc['start']();}catch(_0x192199){_0x2b60f2[_0xffae('0x1d')](0x1f4)[_0xffae('0x30')](_0x192199);}};exports[_0xffae('0x28')]=function(_0x5d7760,_0x16df68,_0x5af6c3){return db['Sound'][_0xffae('0x4d')]({'where':{'id':_0x5d7760['params']['id']}})['then'](handleEntityNotFound(_0x16df68,null))[_0xffae('0x29')](saveUpdates(_[_0xffae('0x40')](_0x5d7760[_0xffae('0x73')],['name',_0xffae('0x7b')]),null))[_0xffae('0x29')](respondWithResult(_0x16df68,null))[_0xffae('0x4b')](handleError(_0x16df68,null));};exports[_0xffae('0x7c')]=function(_0xb5059a,_0x1920fd,_0x3d7d8f){return db['Sound']['find']({'where':{'id':_0xb5059a[_0xffae('0x7d')]['id']}})[_0xffae('0x29')](function(_0x5d0279){if(_0x5d0279){return _0x5d0279[_0xffae('0x2d')]();}})[_0xffae('0x29')](function(_0x50809c){var _0xd2b6cc=path['join'](config[_0xffae('0x54')],'server/files/sounds/original',util[_0xffae('0x5e')](_0xffae('0x56'),_0x50809c[_0xffae('0x7e')],_0x50809c[_0xffae('0x7f')]));var _0x5b0427=path['join'](config[_0xffae('0x54')],_0xffae('0x55'),util[_0xffae('0x5e')](_0xffae('0x56'),_0x50809c[_0xffae('0x7e')],_0x50809c['converted_format']));fs[_0xffae('0x65')](_0xd2b6cc);fs['unlinkSync'](_0x5b0427);return _0x50809c;})['then'](function(_0x1fba0){if(_0x1fba0){return _0x1920fd[_0xffae('0x1d')](0xcc)[_0xffae('0x1e')]();}})[_0xffae('0x29')](handleEntityNotFound(_0x1920fd,null))['catch'](handleError(_0x1920fd,null));}; \ No newline at end of file diff --git a/server/api/sound/sound.model.js b/server/api/sound/sound.model.js new file mode 100644 index 0000000..8c01b43 --- /dev/null +++ b/server/api/sound/sound.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xad7c=['path','rimraf','../../config/environment','./sound.attributes','exports','define','Sound','tools_sounds','lodash','util','../../config/logger','api','moment','bluebird'];(function(_0xc368f5,_0x5ef6a3){var _0x5855ef=function(_0x791ae1){while(--_0x791ae1){_0xc368f5['push'](_0xc368f5['shift']());}};_0x5855ef(++_0x5ef6a3);}(_0xad7c,0x1d6));var _0xcad7=function(_0x59c718,_0x5e3a4d){_0x59c718=_0x59c718-0x0;var _0x5edd9b=_0xad7c[_0x59c718];return _0x5edd9b;};'use strict';var _=require(_0xcad7('0x0'));var util=require(_0xcad7('0x1'));var logger=require(_0xcad7('0x2'))(_0xcad7('0x3'));var moment=require(_0xcad7('0x4'));var BPromise=require(_0xcad7('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xcad7('0x6'));var rimraf=require(_0xcad7('0x7'));var config=require(_0xcad7('0x8'));var attributes=require(_0xcad7('0x9'));module[_0xcad7('0xa')]=function(_0x2f73d9,_0x522a64){return _0x2f73d9[_0xcad7('0xb')](_0xcad7('0xc'),attributes,{'tableName':_0xcad7('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/sound/sound.rpc.js b/server/api/sound/sound.rpc.js new file mode 100644 index 0000000..f84dd98 --- /dev/null +++ b/server/api/sound/sound.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb957=['message','request\x20sent','result','ShowSound','find','options','where','attributes','include','model','map','then','debug','catch','lodash','util','bluebird','../../config/logger','rpc','../../config/environment','client','http','request','info','Sound,\x20%s,\x20%s','Sound,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x4bec27,_0x529585){var _0x5ab08f=function(_0x45e6d5){while(--_0x45e6d5){_0x4bec27['push'](_0x4bec27['shift']());}};_0x5ab08f(++_0x529585);}(_0xb957,0x126));var _0x7b95=function(_0x4402f3,_0xd95eca){_0x4402f3=_0x4402f3-0x0;var _0x3b4f40=_0xb957[_0x4402f3];return _0x3b4f40;};'use strict';var _=require(_0x7b95('0x0'));var util=require(_0x7b95('0x1'));var moment=require('moment');var BPromise=require(_0x7b95('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x7b95('0x3'))(_0x7b95('0x4'));var config=require(_0x7b95('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x7b95('0x6')][_0x7b95('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x164ca2,_0xa823b5,_0x591267){return new BPromise(function(_0x4b02a5,_0x1616f8){return client[_0x7b95('0x8')](_0x164ca2,_0x591267)['then'](function(_0x4e8633){logger[_0x7b95('0x9')](_0x7b95('0xa'),_0xa823b5,'request\x20sent');logger['debug'](_0x7b95('0xb'),_0xa823b5,'request\x20sent',JSON[_0x7b95('0xc')](_0x4e8633));if(_0x4e8633[_0x7b95('0xd')]){if(_0x4e8633[_0x7b95('0xd')]['code']===0x1f4){logger[_0x7b95('0xd')](_0x7b95('0xa'),_0xa823b5,_0x4e8633[_0x7b95('0xd')][_0x7b95('0xe')]);return _0x1616f8(_0x4e8633[_0x7b95('0xd')][_0x7b95('0xe')]);}logger[_0x7b95('0xd')](_0x7b95('0xa'),_0xa823b5,_0x4e8633['error'][_0x7b95('0xe')]);return _0x4b02a5(_0x4e8633[_0x7b95('0xd')][_0x7b95('0xe')]);}else{logger[_0x7b95('0x9')](_0x7b95('0xa'),_0xa823b5,_0x7b95('0xf'));_0x4b02a5(_0x4e8633[_0x7b95('0x10')]['message']);}})['catch'](function(_0x16b3ae){logger[_0x7b95('0xd')]('Sound,\x20%s,\x20%s',_0xa823b5,_0x16b3ae);_0x1616f8(_0x16b3ae);});});}exports[_0x7b95('0x11')]=function(_0x48c5dc){var _0x59d66a=this;return new Promise(function(_0x543ff0,_0x1b04f3){return db['Sound'][_0x7b95('0x12')]({'raw':_0x48c5dc[_0x7b95('0x13')]?_0x48c5dc[_0x7b95('0x13')]['raw']===undefined?!![]:![]:!![],'where':_0x48c5dc[_0x7b95('0x13')]?_0x48c5dc[_0x7b95('0x13')][_0x7b95('0x14')]||null:null,'attributes':_0x48c5dc[_0x7b95('0x13')]?_0x48c5dc['options'][_0x7b95('0x15')]||null:null,'include':_0x48c5dc[_0x7b95('0x13')]?_0x48c5dc[_0x7b95('0x13')][_0x7b95('0x16')]?_['map'](_0x48c5dc[_0x7b95('0x13')][_0x7b95('0x16')],function(_0x5cea27){return{'model':db[_0x5cea27[_0x7b95('0x17')]],'as':_0x5cea27['as'],'attributes':_0x5cea27[_0x7b95('0x15')],'include':_0x5cea27[_0x7b95('0x16')]?_['map'](_0x5cea27[_0x7b95('0x16')],function(_0x23bdd3){return{'model':db[_0x23bdd3['model']],'as':_0x23bdd3['as'],'attributes':_0x23bdd3[_0x7b95('0x15')],'include':_0x23bdd3[_0x7b95('0x16')]?_[_0x7b95('0x18')](_0x23bdd3['include'],function(_0x1296ea){return{'model':db[_0x1296ea['model']],'as':_0x1296ea['as'],'attributes':_0x1296ea['attributes']};}):[]};}):[]};}):[]:[]})[_0x7b95('0x19')](function(_0x5770fb){logger[_0x7b95('0x9')]('ShowSound',_0x48c5dc);logger[_0x7b95('0x1a')](_0x7b95('0x11'),_0x48c5dc,JSON[_0x7b95('0xc')](_0x5770fb));_0x543ff0(_0x5770fb);})[_0x7b95('0x1b')](function(_0x6b25fa){logger[_0x7b95('0xd')]('ShowSound',_0x6b25fa[_0x7b95('0xe')],_0x48c5dc);_0x1b04f3(_0x59d66a[_0x7b95('0xd')](0x1f4,_0x6b25fa['message']));});});}; \ No newline at end of file diff --git a/server/api/squareMessage/index.js b/server/api/squareMessage/index.js new file mode 100644 index 0000000..b9ce4f9 --- /dev/null +++ b/server/api/squareMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5eb8=['fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./squareMessage.controller','get','isAuthenticated','index','/:id','show','put','update','delete','exports','path','connect-timeout','express','Router'];(function(_0x53dacc,_0x1ab9b6){var _0x38eff2=function(_0x5b3814){while(--_0x5b3814){_0x53dacc['push'](_0x53dacc['shift']());}};_0x38eff2(++_0x1ab9b6);}(_0x5eb8,0xb0));var _0x85eb=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x5eb8[_0x321bb2];return _0x9c12ed;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x85eb('0x0'));var timeout=require(_0x85eb('0x1'));var express=require(_0x85eb('0x2'));var router=express[_0x85eb('0x3')]();var fs_extra=require(_0x85eb('0x4'));var auth=require(_0x85eb('0x5'));var interaction=require(_0x85eb('0x6'));var config=require(_0x85eb('0x7'));var controller=require(_0x85eb('0x8'));router[_0x85eb('0x9')]('/',auth[_0x85eb('0xa')](),controller[_0x85eb('0xb')]);router['get'](_0x85eb('0xc'),auth[_0x85eb('0xa')](),controller[_0x85eb('0xd')]);router['post']('/',auth[_0x85eb('0xa')](),controller['create']);router[_0x85eb('0xe')](_0x85eb('0xc'),auth[_0x85eb('0xa')](),controller[_0x85eb('0xf')]);router[_0x85eb('0x10')](_0x85eb('0xc'),auth[_0x85eb('0xa')](),controller['destroy']);module[_0x85eb('0x11')]=router; \ No newline at end of file diff --git a/server/api/squareMessage/squareMessage.attributes.js b/server/api/squareMessage/squareMessage.attributes.js new file mode 100644 index 0000000..dfdae37 --- /dev/null +++ b/server/api/squareMessage/squareMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x83cf=['sequelize','exports','STRING','TEXT','ENUM','out'];(function(_0x1cd674,_0x8d3638){var _0x27928f=function(_0x5e3c70){while(--_0x5e3c70){_0x1cd674['push'](_0x1cd674['shift']());}};_0x27928f(++_0x8d3638);}(_0x83cf,0x180));var _0xf83c=function(_0xd384ec,_0x4f1c7c){_0xd384ec=_0xd384ec-0x0;var _0x4f0f80=_0x83cf[_0xd384ec];return _0x4f0f80;};'use strict';var Sequelize=require(_0xf83c('0x0'));module[_0xf83c('0x1')]={'uniqueid':{'type':Sequelize[_0xf83c('0x2')]},'body':{'type':Sequelize[_0xf83c('0x3')]('medium'),'allowNull':![]},'direction':{'type':Sequelize[_0xf83c('0x4')]('in',_0xf83c('0x5')),'defaultValue':'out','allowNull':![]},'providerName':{'type':Sequelize[_0xf83c('0x2')]},'providerResponse':{'type':Sequelize['TEXT']}}; \ No newline at end of file diff --git a/server/api/squareMessage/squareMessage.controller.js b/server/api/squareMessage/squareMessage.controller.js new file mode 100644 index 0000000..31f2a2d --- /dev/null +++ b/server/api/squareMessage/squareMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc4d8=['nolimit','limit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','show','params','fields','find','create','body','eml-format','zip-dir','fast-json-patch','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','count','set','Content-Range','json','apply','save','update','then','destroy','name','index','map','SquareMessage','rawAttributes','fieldName','type','query','keys','filters','attributes','intersection','model','length','hasOwnProperty'];(function(_0x506a60,_0x46793f){var _0x4d12df=function(_0x27b10b){while(--_0x27b10b){_0x506a60['push'](_0x506a60['shift']());}};_0x4d12df(++_0x46793f);}(_0xc4d8,0xa6));var _0x8c4d=function(_0x5bd426,_0x4878e5){_0x5bd426=_0x5bd426-0x0;var _0x23a7eb=_0xc4d8[_0x5bd426];return _0x23a7eb;};'use strict';var emlformat=require(_0x8c4d('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x8c4d('0x1'));var jsonpatch=require(_0x8c4d('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x8c4d('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0x8c4d('0x4'));var sox=require(_0x8c4d('0x5'));var csv=require(_0x8c4d('0x6'));var ejs=require(_0x8c4d('0x7'));var fs=require('fs');var fs_extra=require(_0x8c4d('0x8'));var _=require(_0x8c4d('0x9'));var squel=require(_0x8c4d('0xa'));var crypto=require(_0x8c4d('0xb'));var jsforce=require(_0x8c4d('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x8c4d('0x6'));var querystring=require(_0x8c4d('0xd'));var Papa=require(_0x8c4d('0xe'));var Redis=require(_0x8c4d('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x8c4d('0x10'));var hardwareService=require(_0x8c4d('0x11'));var logger=require(_0x8c4d('0x12'))(_0x8c4d('0x13'));var utils=require(_0x8c4d('0x14'));var config=require(_0x8c4d('0x15'));var licenseUtil=require(_0x8c4d('0x16'));var db=require(_0x8c4d('0x17'))['db'];function respondWithStatusCode(_0x50de53,_0x21768d){_0x21768d=_0x21768d||0xcc;return function(_0x303bbc){if(_0x303bbc){return _0x50de53[_0x8c4d('0x18')](_0x21768d);}return _0x50de53[_0x8c4d('0x19')](_0x21768d)[_0x8c4d('0x1a')]();};}function respondWithResult(_0x207f67,_0x3d42f1){_0x3d42f1=_0x3d42f1||0xc8;return function(_0x220cfa){if(_0x220cfa){return _0x207f67['status'](_0x3d42f1)['json'](_0x220cfa);}};}function respondWithFilteredResult(_0x20ab4f,_0x1d410e){return function(_0x498e5d){if(_0x498e5d){var _0x355345=typeof _0x1d410e[_0x8c4d('0x1b')]===_0x8c4d('0x1c')&&typeof _0x1d410e['limit']===_0x8c4d('0x1c');var _0x3d082f=_0x498e5d[_0x8c4d('0x1d')];var _0x3a9321=_0x355345?0x0:_0x1d410e[_0x8c4d('0x1b')];var _0x59cc48=_0x355345?_0x498e5d[_0x8c4d('0x1d')]:_0x1d410e[_0x8c4d('0x1b')]+_0x1d410e['limit'];var _0x409568;if(_0x59cc48>=_0x3d082f){_0x59cc48=_0x3d082f;_0x409568=0xc8;}else{_0x409568=0xce;}_0x20ab4f[_0x8c4d('0x19')](_0x409568);return _0x20ab4f[_0x8c4d('0x1e')](_0x8c4d('0x1f'),_0x3a9321+'-'+_0x59cc48+'/'+_0x3d082f)[_0x8c4d('0x20')](_0x498e5d);}return null;};}function patchUpdates(_0x10ef16){return function(_0x17c206){try{jsonpatch[_0x8c4d('0x21')](_0x17c206,_0x10ef16,!![]);}catch(_0x17708c){return BPromise['reject'](_0x17708c);}return _0x17c206[_0x8c4d('0x22')]();};}function saveUpdates(_0x16ddc9,_0x33f0a2){return function(_0x663624){if(_0x663624){return _0x663624[_0x8c4d('0x23')](_0x16ddc9)[_0x8c4d('0x24')](function(_0x54d835){return _0x54d835;});}return null;};}function removeEntity(_0x3fd1e1,_0x10ea9b){return function(_0x52114f){if(_0x52114f){return _0x52114f[_0x8c4d('0x25')]()['then'](function(){_0x3fd1e1[_0x8c4d('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2a0d83,_0x292602){return function(_0x3f428b){if(!_0x3f428b){_0x2a0d83[_0x8c4d('0x18')](0x194);}return _0x3f428b;};}function handleError(_0x3dec4b,_0x10ed15){_0x10ed15=_0x10ed15||0x1f4;return function(_0x33d5f1){logger['error'](_0x33d5f1['stack']);if(_0x33d5f1[_0x8c4d('0x26')]){delete _0x33d5f1[_0x8c4d('0x26')];}_0x3dec4b[_0x8c4d('0x19')](_0x10ed15)['send'](_0x33d5f1);};}exports[_0x8c4d('0x27')]=function(_0x2c829b,_0x10ef81){var _0x5dfb6f={},_0x22f944={},_0x476266={'count':0x0,'rows':[]};var _0x2e4076=_[_0x8c4d('0x28')](db[_0x8c4d('0x29')][_0x8c4d('0x2a')],function(_0x5b35b6){return{'name':_0x5b35b6[_0x8c4d('0x2b')],'type':_0x5b35b6[_0x8c4d('0x2c')]['key']};});_0x22f944['model']=_['map'](_0x2e4076,_0x8c4d('0x26'));_0x22f944[_0x8c4d('0x2d')]=_[_0x8c4d('0x2e')](_0x2c829b[_0x8c4d('0x2d')]);_0x22f944[_0x8c4d('0x2f')]=_['intersection'](_0x22f944['model'],_0x22f944['query']);_0x5dfb6f[_0x8c4d('0x30')]=_[_0x8c4d('0x31')](_0x22f944[_0x8c4d('0x32')],qs['fields'](_0x2c829b[_0x8c4d('0x2d')]['fields']));_0x5dfb6f[_0x8c4d('0x30')]=_0x5dfb6f[_0x8c4d('0x30')][_0x8c4d('0x33')]?_0x5dfb6f[_0x8c4d('0x30')]:_0x22f944['model'];if(!_0x2c829b[_0x8c4d('0x2d')][_0x8c4d('0x34')](_0x8c4d('0x35'))){_0x5dfb6f[_0x8c4d('0x36')]=qs[_0x8c4d('0x36')](_0x2c829b[_0x8c4d('0x2d')][_0x8c4d('0x36')]);_0x5dfb6f[_0x8c4d('0x1b')]=qs['offset'](_0x2c829b[_0x8c4d('0x2d')]['offset']);}_0x5dfb6f[_0x8c4d('0x37')]=qs[_0x8c4d('0x38')](_0x2c829b[_0x8c4d('0x2d')][_0x8c4d('0x38')]);_0x5dfb6f[_0x8c4d('0x39')]=qs['filters'](_[_0x8c4d('0x3a')](_0x2c829b[_0x8c4d('0x2d')],_0x22f944[_0x8c4d('0x2f')]),_0x2e4076);if(_0x2c829b[_0x8c4d('0x2d')][_0x8c4d('0x3b')]){_0x5dfb6f[_0x8c4d('0x39')]=_[_0x8c4d('0x3c')](_0x5dfb6f[_0x8c4d('0x39')],{'$or':_[_0x8c4d('0x28')](_0x2e4076,function(_0x1b67b5){if(_0x1b67b5[_0x8c4d('0x2c')]!=='VIRTUAL'){var _0x3391d6={};_0x3391d6[_0x1b67b5[_0x8c4d('0x26')]]={'$like':'%'+_0x2c829b['query']['filter']+'%'};return _0x3391d6;}})});}_0x5dfb6f=_[_0x8c4d('0x3c')]({},_0x5dfb6f,_0x2c829b[_0x8c4d('0x3d')]);var _0x40d23c={'where':_0x5dfb6f[_0x8c4d('0x39')]};return db[_0x8c4d('0x29')][_0x8c4d('0x1d')](_0x40d23c)[_0x8c4d('0x24')](function(_0x1fa027){_0x476266['count']=_0x1fa027;if(_0x2c829b[_0x8c4d('0x2d')][_0x8c4d('0x3e')]){_0x5dfb6f[_0x8c4d('0x3f')]=[{'all':!![]}];}return db['SquareMessage'][_0x8c4d('0x40')](_0x5dfb6f);})[_0x8c4d('0x24')](function(_0x5d930c){_0x476266[_0x8c4d('0x41')]=_0x5d930c;return _0x476266;})['then'](respondWithFilteredResult(_0x10ef81,_0x5dfb6f))[_0x8c4d('0x42')](handleError(_0x10ef81,null));};exports[_0x8c4d('0x43')]=function(_0xf30b0d,_0x22487e){var _0x5ed269={'raw':!![],'where':{'id':_0xf30b0d[_0x8c4d('0x44')]['id']}},_0x3d95fd={};_0x3d95fd[_0x8c4d('0x32')]=_[_0x8c4d('0x2e')](db['SquareMessage']['rawAttributes']);_0x3d95fd['query']=_[_0x8c4d('0x2e')](_0xf30b0d[_0x8c4d('0x2d')]);_0x3d95fd[_0x8c4d('0x2f')]=_['intersection'](_0x3d95fd['model'],_0x3d95fd[_0x8c4d('0x2d')]);_0x5ed269[_0x8c4d('0x30')]=_[_0x8c4d('0x31')](_0x3d95fd['model'],qs[_0x8c4d('0x45')](_0xf30b0d[_0x8c4d('0x2d')][_0x8c4d('0x45')]));_0x5ed269[_0x8c4d('0x30')]=_0x5ed269[_0x8c4d('0x30')]['length']?_0x5ed269[_0x8c4d('0x30')]:_0x3d95fd['model'];if(_0xf30b0d['query'][_0x8c4d('0x3e')]){_0x5ed269['include']=[{'all':!![]}];}_0x5ed269=_['merge']({},_0x5ed269,_0xf30b0d[_0x8c4d('0x3d')]);return db[_0x8c4d('0x29')][_0x8c4d('0x46')](_0x5ed269)[_0x8c4d('0x24')](handleEntityNotFound(_0x22487e,null))['then'](respondWithResult(_0x22487e,null))[_0x8c4d('0x42')](handleError(_0x22487e,null));};exports[_0x8c4d('0x47')]=function(_0x590c79,_0x44c0d8){return db[_0x8c4d('0x29')][_0x8c4d('0x47')](_0x590c79[_0x8c4d('0x48')],{})[_0x8c4d('0x24')](respondWithResult(_0x44c0d8,0xc9))['catch'](handleError(_0x44c0d8,null));};exports[_0x8c4d('0x23')]=function(_0x1b7801,_0x3018e2){if(_0x1b7801[_0x8c4d('0x48')]['id']){delete _0x1b7801['body']['id'];}return db[_0x8c4d('0x29')][_0x8c4d('0x46')]({'where':{'id':_0x1b7801[_0x8c4d('0x44')]['id']}})[_0x8c4d('0x24')](handleEntityNotFound(_0x3018e2,null))[_0x8c4d('0x24')](saveUpdates(_0x1b7801[_0x8c4d('0x48')],null))[_0x8c4d('0x24')](respondWithResult(_0x3018e2,null))[_0x8c4d('0x42')](handleError(_0x3018e2,null));};exports[_0x8c4d('0x25')]=function(_0xa4ec88,_0x396e8c){return db[_0x8c4d('0x29')][_0x8c4d('0x46')]({'where':{'id':_0xa4ec88[_0x8c4d('0x44')]['id']}})[_0x8c4d('0x24')](handleEntityNotFound(_0x396e8c,null))[_0x8c4d('0x24')](removeEntity(_0x396e8c,null))[_0x8c4d('0x42')](handleError(_0x396e8c,null));}; \ No newline at end of file diff --git a/server/api/squareMessage/squareMessage.model.js b/server/api/squareMessage/squareMessage.model.js new file mode 100644 index 0000000..b4ae52b --- /dev/null +++ b/server/api/squareMessage/squareMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x85f3=['path','rimraf','./squareMessage.attributes','exports','define','SquareMessage','square_messages','lodash','../../config/logger','api','moment','bluebird','request-promise'];(function(_0x2ba24f,_0x1e67d4){var _0x564da4=function(_0x3f3c06){while(--_0x3f3c06){_0x2ba24f['push'](_0x2ba24f['shift']());}};_0x564da4(++_0x1e67d4);}(_0x85f3,0x132));var _0x385f=function(_0xd73d53,_0x598443){_0xd73d53=_0xd73d53-0x0;var _0x560148=_0x85f3[_0xd73d53];return _0x560148;};'use strict';var _=require(_0x385f('0x0'));var util=require('util');var logger=require(_0x385f('0x1'))(_0x385f('0x2'));var moment=require(_0x385f('0x3'));var BPromise=require(_0x385f('0x4'));var rp=require(_0x385f('0x5'));var fs=require('fs');var path=require(_0x385f('0x6'));var rimraf=require(_0x385f('0x7'));var config=require('../../config/environment');var attributes=require(_0x385f('0x8'));module[_0x385f('0x9')]=function(_0x18ae19,_0x5c8a1e){return _0x18ae19[_0x385f('0xa')](_0x385f('0xb'),attributes,{'tableName':_0x385f('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/squareMessage/squareMessage.rpc.js b/server/api/squareMessage/squareMessage.rpc.js new file mode 100644 index 0000000..d979fc0 --- /dev/null +++ b/server/api/squareMessage/squareMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8e27=['lodash','util','moment','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','client','http','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareMessage','body','options','raw','debug'];(function(_0x2a2840,_0x19c9a2){var _0xecebc9=function(_0x1777af){while(--_0x1777af){_0x2a2840['push'](_0x2a2840['shift']());}};_0xecebc9(++_0x19c9a2);}(_0x8e27,0xa2));var _0x78e2=function(_0x291e0e,_0x792683){_0x291e0e=_0x291e0e-0x0;var _0x3f85f3=_0x8e27[_0x291e0e];return _0x3f85f3;};'use strict';var _=require(_0x78e2('0x0'));var util=require(_0x78e2('0x1'));var moment=require(_0x78e2('0x2'));var BPromise=require(_0x78e2('0x3'));var rs=require(_0x78e2('0x4'));var fs=require('fs');var Redis=require(_0x78e2('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x78e2('0x6'));var config=require(_0x78e2('0x7'));var jayson=require(_0x78e2('0x8'));var client=jayson[_0x78e2('0x9')][_0x78e2('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2e71ce,_0x356ea9,_0x17a522){return new BPromise(function(_0x1a5fc9,_0x286a10){return client['request'](_0x2e71ce,_0x17a522)[_0x78e2('0xb')](function(_0xbf81c2){logger[_0x78e2('0xc')](_0x78e2('0xd'),_0x356ea9,_0x78e2('0xe'));logger['debug'](_0x78e2('0xf'),_0x356ea9,_0x78e2('0xe'),JSON[_0x78e2('0x10')](_0xbf81c2));if(_0xbf81c2[_0x78e2('0x11')]){if(_0xbf81c2[_0x78e2('0x11')][_0x78e2('0x12')]===0x1f4){logger[_0x78e2('0x11')]('SquareMessage,\x20%s,\x20%s',_0x356ea9,_0xbf81c2[_0x78e2('0x11')]['message']);return _0x286a10(_0xbf81c2[_0x78e2('0x11')][_0x78e2('0x13')]);}logger[_0x78e2('0x11')]('SquareMessage,\x20%s,\x20%s',_0x356ea9,_0xbf81c2[_0x78e2('0x11')][_0x78e2('0x13')]);return _0x1a5fc9(_0xbf81c2[_0x78e2('0x11')][_0x78e2('0x13')]);}else{logger['info'](_0x78e2('0xd'),_0x356ea9,_0x78e2('0xe'));_0x1a5fc9(_0xbf81c2[_0x78e2('0x14')][_0x78e2('0x13')]);}})[_0x78e2('0x15')](function(_0x2d8a9f){logger['error'](_0x78e2('0xd'),_0x356ea9,_0x2d8a9f);_0x286a10(_0x2d8a9f);});});}exports[_0x78e2('0x16')]=function(_0x3f8b4b){var _0x5509a0=this;return new Promise(function(_0x516a2a,_0x2e958e){return db['SquareMessage']['create'](_0x3f8b4b[_0x78e2('0x17')],{'raw':_0x3f8b4b[_0x78e2('0x18')]?_0x3f8b4b[_0x78e2('0x18')][_0x78e2('0x19')]===undefined?!![]:![]:!![]})[_0x78e2('0xb')](function(_0x343257){logger[_0x78e2('0xc')](_0x78e2('0x16'),_0x3f8b4b);logger[_0x78e2('0x1a')](_0x78e2('0x16'),_0x3f8b4b,JSON[_0x78e2('0x10')](_0x343257));_0x516a2a(_0x343257);})[_0x78e2('0x15')](function(_0x359a08){logger[_0x78e2('0x11')](_0x78e2('0x16'),_0x359a08[_0x78e2('0x13')],_0x3f8b4b);_0x2e958e(_0x5509a0[_0x78e2('0x11')](0x1f4,_0x359a08[_0x78e2('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/squareOdbc/index.js b/server/api/squareOdbc/index.js new file mode 100644 index 0000000..f64c703 --- /dev/null +++ b/server/api/squareOdbc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc609=['delete','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','/:id','isAuthenticated','/:id/test','15s','post','create','put'];(function(_0x1e451e,_0x5c27d1){var _0x324014=function(_0x1a2b32){while(--_0x1a2b32){_0x1e451e['push'](_0x1e451e['shift']());}};_0x324014(++_0x5c27d1);}(_0xc609,0x1d1));var _0x9c60=function(_0x316ff9,_0x2ed79f){_0x316ff9=_0x316ff9-0x0;var _0x3a1328=_0xc609[_0x316ff9];return _0x3a1328;};'use strict';var multer=require(_0x9c60('0x0'));var util=require(_0x9c60('0x1'));var path=require(_0x9c60('0x2'));var timeout=require(_0x9c60('0x3'));var express=require(_0x9c60('0x4'));var router=express[_0x9c60('0x5')]();var fs_extra=require(_0x9c60('0x6'));var auth=require(_0x9c60('0x7'));var interaction=require(_0x9c60('0x8'));var config=require(_0x9c60('0x9'));var controller=require('./squareOdbc.controller');router[_0x9c60('0xa')]('/',auth['isAuthenticated'](),controller['index']);router[_0x9c60('0xa')](_0x9c60('0xb'),auth[_0x9c60('0xc')](),controller['show']);router[_0x9c60('0xa')](_0x9c60('0xd'),auth[_0x9c60('0xc')](),timeout(_0x9c60('0xe')),controller['test']);router[_0x9c60('0xf')]('/',auth[_0x9c60('0xc')](),controller[_0x9c60('0x10')]);router[_0x9c60('0x11')](_0x9c60('0xb'),auth['isAuthenticated'](),controller['update']);router[_0x9c60('0x12')](_0x9c60('0xb'),auth['isAuthenticated'](),controller[_0x9c60('0x13')]);module[_0x9c60('0x14')]=router; \ No newline at end of file diff --git a/server/api/squareOdbc/squareOdbc.attributes.js b/server/api/squareOdbc/squareOdbc.attributes.js new file mode 100644 index 0000000..e875c90 --- /dev/null +++ b/server/api/squareOdbc/squareOdbc.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5c5f=['STRING','sequelize','exports'];(function(_0x5e7de0,_0x3d6b19){var _0x3a627d=function(_0x1ffee2){while(--_0x1ffee2){_0x5e7de0['push'](_0x5e7de0['shift']());}};_0x3a627d(++_0x3d6b19);}(_0x5c5f,0x1d8));var _0xf5c5=function(_0x456a49,_0x80653c){_0x456a49=_0x456a49-0x0;var _0x4dc2ba=_0x5c5f[_0x456a49];return _0x4dc2ba;};'use strict';var Sequelize=require(_0xf5c5('0x0'));module[_0xf5c5('0x1')]={'name':{'type':Sequelize[_0xf5c5('0x2')],'unique':'name','allowNull':![]},'dsn':{'type':Sequelize[_0xf5c5('0x2')]},'description':{'type':Sequelize[_0xf5c5('0x2')]}}; \ No newline at end of file diff --git a/server/api/squareOdbc/squareOdbc.controller.js b/server/api/squareOdbc/squareOdbc.controller.js new file mode 100644 index 0000000..f5a436a --- /dev/null +++ b/server/api/squareOdbc/squareOdbc.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7f97=['offset','set','Content-Range','reject','save','destroy','then','get','ODBC','end','name','send','map','rawAttributes','fieldName','type','key','model','query','intersection','attributes','fields','length','limit','order','sort','where','filters','pick','filter','merge','VIRTUAL','include','SquareOdbc','findAll','rows','catch','show','params','keys','includeAll','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','dsn','odbc','openSync','closeSync','rimraf','zip-dir','request-promise','bluebird','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','json','undefined','count'];(function(_0x542da8,_0x509c26){var _0x533d7e=function(_0x2a3d04){while(--_0x2a3d04){_0x542da8['push'](_0x542da8['shift']());}};_0x533d7e(++_0x509c26);}(_0x7f97,0x196));var _0x77f9=function(_0x382384,_0x446aba){_0x382384=_0x382384-0x0;var _0x6d92b5=_0x7f97[_0x382384];return _0x6d92b5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x77f9('0x0'));var zipdir=require(_0x77f9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x77f9('0x2'));var moment=require('moment');var BPromise=require(_0x77f9('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0x77f9('0x4'));var sox=require(_0x77f9('0x5'));var csv=require(_0x77f9('0x6'));var ejs=require(_0x77f9('0x7'));var fs=require('fs');var fs_extra=require(_0x77f9('0x8'));var _=require('lodash');var squel=require(_0x77f9('0x9'));var crypto=require(_0x77f9('0xa'));var jsforce=require(_0x77f9('0xb'));var deskjs=require(_0x77f9('0xc'));var toCsv=require(_0x77f9('0x6'));var querystring=require(_0x77f9('0xd'));var Papa=require(_0x77f9('0xe'));var Redis=require(_0x77f9('0xf'));var authService=require(_0x77f9('0x10'));var qs=require(_0x77f9('0x11'));var as=require(_0x77f9('0x12'));var hardwareService=require(_0x77f9('0x13'));var logger=require(_0x77f9('0x14'))(_0x77f9('0x15'));var utils=require(_0x77f9('0x16'));var config=require(_0x77f9('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4aac03,_0x1ae84b){_0x1ae84b=_0x1ae84b||0xcc;return function(_0x2edd21){if(_0x2edd21){return _0x4aac03[_0x77f9('0x18')](_0x1ae84b);}return _0x4aac03[_0x77f9('0x19')](_0x1ae84b)['end']();};}function respondWithResult(_0x335fe5,_0x6415b1){_0x6415b1=_0x6415b1||0xc8;return function(_0x3dc699){if(_0x3dc699){return _0x335fe5[_0x77f9('0x19')](_0x6415b1)[_0x77f9('0x1a')](_0x3dc699);}};}function respondWithFilteredResult(_0x561417,_0x340431){return function(_0x21a619){if(_0x21a619){var _0x3e515d=typeof _0x340431['offset']==='undefined'&&typeof _0x340431['limit']===_0x77f9('0x1b');var _0x2813fa=_0x21a619[_0x77f9('0x1c')];var _0x38ceea=_0x3e515d?0x0:_0x340431[_0x77f9('0x1d')];var _0x162b4a=_0x3e515d?_0x21a619[_0x77f9('0x1c')]:_0x340431[_0x77f9('0x1d')]+_0x340431['limit'];var _0x123171;if(_0x162b4a>=_0x2813fa){_0x162b4a=_0x2813fa;_0x123171=0xc8;}else{_0x123171=0xce;}_0x561417[_0x77f9('0x19')](_0x123171);return _0x561417[_0x77f9('0x1e')](_0x77f9('0x1f'),_0x38ceea+'-'+_0x162b4a+'/'+_0x2813fa)['json'](_0x21a619);}return null;};}function patchUpdates(_0x2ba8d6){return function(_0x56ed54){try{jsonpatch['apply'](_0x56ed54,_0x2ba8d6,!![]);}catch(_0x4f525a){return BPromise[_0x77f9('0x20')](_0x4f525a);}return _0x56ed54[_0x77f9('0x21')]();};}function saveUpdates(_0x15c8f6,_0x4b3181){return function(_0x13135f){if(_0x13135f){return _0x13135f['update'](_0x15c8f6)['then'](function(_0x5d3951){return _0x5d3951;});}return null;};}function removeEntity(_0x270243,_0x34ce34){return function(_0x581c40){if(_0x581c40){return _0x581c40[_0x77f9('0x22')]()[_0x77f9('0x23')](function(){var _0x399bef=_0x581c40[_0x77f9('0x24')]({'plain':!![]});var _0xf9636d=_0x77f9('0x25');return db['UserProfileResource']['destroy']({'where':{'type':_0xf9636d,'resourceId':_0x399bef['id']}})[_0x77f9('0x23')](function(){return _0x581c40;});})[_0x77f9('0x23')](function(){_0x270243[_0x77f9('0x19')](0xcc)[_0x77f9('0x26')]();});}};}function handleEntityNotFound(_0x143048,_0x2414d9){return function(_0x2c5027){if(!_0x2c5027){_0x143048[_0x77f9('0x18')](0x194);}return _0x2c5027;};}function handleError(_0x52d7b6,_0x3b525b){_0x3b525b=_0x3b525b||0x1f4;return function(_0x4c9483){logger['error'](_0x4c9483['stack']);if(_0x4c9483[_0x77f9('0x27')]){delete _0x4c9483[_0x77f9('0x27')];}_0x52d7b6[_0x77f9('0x19')](_0x3b525b)[_0x77f9('0x28')](_0x4c9483);};}exports['index']=function(_0x31a80e,_0xae58e2){var _0x386077={},_0x355d65={},_0x4fc7fb={'count':0x0,'rows':[]};var _0x346a58=_[_0x77f9('0x29')](db['SquareOdbc'][_0x77f9('0x2a')],function(_0x26a621){return{'name':_0x26a621[_0x77f9('0x2b')],'type':_0x26a621[_0x77f9('0x2c')][_0x77f9('0x2d')]};});_0x355d65[_0x77f9('0x2e')]=_[_0x77f9('0x29')](_0x346a58,_0x77f9('0x27'));_0x355d65[_0x77f9('0x2f')]=_['keys'](_0x31a80e[_0x77f9('0x2f')]);_0x355d65['filters']=_[_0x77f9('0x30')](_0x355d65[_0x77f9('0x2e')],_0x355d65[_0x77f9('0x2f')]);_0x386077[_0x77f9('0x31')]=_[_0x77f9('0x30')](_0x355d65[_0x77f9('0x2e')],qs['fields'](_0x31a80e[_0x77f9('0x2f')][_0x77f9('0x32')]));_0x386077[_0x77f9('0x31')]=_0x386077[_0x77f9('0x31')][_0x77f9('0x33')]?_0x386077[_0x77f9('0x31')]:_0x355d65[_0x77f9('0x2e')];if(!_0x31a80e[_0x77f9('0x2f')]['hasOwnProperty']('nolimit')){_0x386077[_0x77f9('0x34')]=qs[_0x77f9('0x34')](_0x31a80e['query'][_0x77f9('0x34')]);_0x386077[_0x77f9('0x1d')]=qs[_0x77f9('0x1d')](_0x31a80e['query']['offset']);}_0x386077[_0x77f9('0x35')]=qs['sort'](_0x31a80e['query'][_0x77f9('0x36')]);_0x386077[_0x77f9('0x37')]=qs[_0x77f9('0x38')](_[_0x77f9('0x39')](_0x31a80e['query'],_0x355d65[_0x77f9('0x38')]),_0x346a58);if(_0x31a80e[_0x77f9('0x2f')][_0x77f9('0x3a')]){_0x386077[_0x77f9('0x37')]=_[_0x77f9('0x3b')](_0x386077['where'],{'$or':_[_0x77f9('0x29')](_0x346a58,function(_0x1aa776){if(_0x1aa776[_0x77f9('0x2c')]!==_0x77f9('0x3c')){var _0x1df8ad={};_0x1df8ad[_0x1aa776[_0x77f9('0x27')]]={'$like':'%'+_0x31a80e[_0x77f9('0x2f')][_0x77f9('0x3a')]+'%'};return _0x1df8ad;}})});}_0x386077=_['merge']({},_0x386077,_0x31a80e['options']);var _0x284602={'where':_0x386077[_0x77f9('0x37')]};return db['SquareOdbc'][_0x77f9('0x1c')](_0x284602)[_0x77f9('0x23')](function(_0x42bd69){_0x4fc7fb[_0x77f9('0x1c')]=_0x42bd69;if(_0x31a80e[_0x77f9('0x2f')]['includeAll']){_0x386077[_0x77f9('0x3d')]=[{'all':!![]}];}return db[_0x77f9('0x3e')][_0x77f9('0x3f')](_0x386077);})[_0x77f9('0x23')](function(_0x32e2d0){_0x4fc7fb[_0x77f9('0x40')]=_0x32e2d0;return _0x4fc7fb;})['then'](respondWithFilteredResult(_0xae58e2,_0x386077))[_0x77f9('0x41')](handleError(_0xae58e2,null));};exports[_0x77f9('0x42')]=function(_0x1d7597,_0x1e3d6b){var _0x4d794c={'raw':!![],'where':{'id':_0x1d7597[_0x77f9('0x43')]['id']}},_0x2aef9f={};_0x2aef9f['model']=_[_0x77f9('0x44')](db[_0x77f9('0x3e')][_0x77f9('0x2a')]);_0x2aef9f[_0x77f9('0x2f')]=_[_0x77f9('0x44')](_0x1d7597[_0x77f9('0x2f')]);_0x2aef9f[_0x77f9('0x38')]=_[_0x77f9('0x30')](_0x2aef9f[_0x77f9('0x2e')],_0x2aef9f[_0x77f9('0x2f')]);_0x4d794c[_0x77f9('0x31')]=_[_0x77f9('0x30')](_0x2aef9f[_0x77f9('0x2e')],qs[_0x77f9('0x32')](_0x1d7597[_0x77f9('0x2f')][_0x77f9('0x32')]));_0x4d794c['attributes']=_0x4d794c['attributes']['length']?_0x4d794c[_0x77f9('0x31')]:_0x2aef9f[_0x77f9('0x2e')];if(_0x1d7597['query'][_0x77f9('0x45')]){_0x4d794c[_0x77f9('0x3d')]=[{'all':!![]}];}_0x4d794c=_[_0x77f9('0x3b')]({},_0x4d794c,_0x1d7597[_0x77f9('0x46')]);return db['SquareOdbc'][_0x77f9('0x47')](_0x4d794c)[_0x77f9('0x23')](handleEntityNotFound(_0x1e3d6b,null))[_0x77f9('0x23')](respondWithResult(_0x1e3d6b,null))['catch'](handleError(_0x1e3d6b,null));};exports[_0x77f9('0x48')]=function(_0x52a87f,_0x4abad5){return db[_0x77f9('0x3e')][_0x77f9('0x48')](_0x52a87f['body'],{})[_0x77f9('0x23')](function(_0xa2cafa){var _0x15d728=_0x52a87f[_0x77f9('0x49')][_0x77f9('0x24')]({'plain':!![]});if(!_0x15d728)throw new Error(_0x77f9('0x4a'));if(_0x15d728[_0x77f9('0x4b')]===_0x77f9('0x49')){var _0x12fde4=_0xa2cafa[_0x77f9('0x24')]({'plain':!![]});var _0x2313c2=_0x77f9('0x25');return db['UserProfileSection'][_0x77f9('0x47')]({'where':{'name':_0x2313c2,'userProfileId':_0x15d728[_0x77f9('0x4c')]},'raw':!![]})[_0x77f9('0x23')](function(_0x410fae){if(_0x410fae&&_0x410fae[_0x77f9('0x4d')]===0x0){return db[_0x77f9('0x4e')][_0x77f9('0x48')]({'name':_0x12fde4[_0x77f9('0x27')],'resourceId':_0x12fde4['id'],'type':_0x410fae[_0x77f9('0x27')],'sectionId':_0x410fae['id']},{})['then'](function(){return _0xa2cafa;});}else{return _0xa2cafa;}})[_0x77f9('0x41')](function(_0x24266d){logger[_0x77f9('0x4f')](_0x77f9('0x50'),_0x24266d);throw _0x24266d;});}return _0xa2cafa;})[_0x77f9('0x23')](respondWithResult(_0x4abad5,0xc9))[_0x77f9('0x41')](handleError(_0x4abad5,null));};exports[_0x77f9('0x51')]=function(_0x2980f6,_0x89351d){if(_0x2980f6[_0x77f9('0x52')]['id']){delete _0x2980f6[_0x77f9('0x52')]['id'];}return db[_0x77f9('0x3e')]['find']({'where':{'id':_0x2980f6['params']['id']}})['then'](handleEntityNotFound(_0x89351d,null))[_0x77f9('0x23')](saveUpdates(_0x2980f6[_0x77f9('0x52')],null))['then'](respondWithResult(_0x89351d,null))[_0x77f9('0x41')](handleError(_0x89351d,null));};exports[_0x77f9('0x22')]=function(_0x3b0a8d,_0x514628){return db[_0x77f9('0x3e')][_0x77f9('0x47')]({'where':{'id':_0x3b0a8d['params']['id']}})[_0x77f9('0x23')](handleEntityNotFound(_0x514628,null))[_0x77f9('0x23')](removeEntity(_0x514628,null))[_0x77f9('0x41')](handleError(_0x514628,null));};exports['test']=function(_0x572b5a,_0x19484d,_0x4b3007){var _0x549954;return db[_0x77f9('0x3e')][_0x77f9('0x47')]({'where':{'id':_0x572b5a[_0x77f9('0x43')]['id']},'attributes':['id',_0x77f9('0x53')]})[_0x77f9('0x23')](handleEntityNotFound(_0x19484d,null))[_0x77f9('0x23')](function(_0x32ba99){if(_0x32ba99){var _0x4b1354=require(_0x77f9('0x54'))();_0x4b1354[_0x77f9('0x55')](_0x32ba99[_0x77f9('0x53')]);_0x4b1354[_0x77f9('0x56')]();return _0x32ba99;}})['then'](respondWithResult(_0x19484d,null))['catch'](handleError(_0x19484d,null));}; \ No newline at end of file diff --git a/server/api/squareOdbc/squareOdbc.model.js b/server/api/squareOdbc/squareOdbc.model.js new file mode 100644 index 0000000..a6a783c --- /dev/null +++ b/server/api/squareOdbc/squareOdbc.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x59d7=['square_odbc','lodash','util','../../config/logger','api','moment','rimraf','../../config/environment','./squareOdbc.attributes','define','SquareOdbc'];(function(_0x1cc8fe,_0x105328){var _0x230054=function(_0x1a1b56){while(--_0x1a1b56){_0x1cc8fe['push'](_0x1cc8fe['shift']());}};_0x230054(++_0x105328);}(_0x59d7,0x1f0));var _0x759d=function(_0x396466,_0xe9857b){_0x396466=_0x396466-0x0;var _0x5e9ab4=_0x59d7[_0x396466];return _0x5e9ab4;};'use strict';var _=require(_0x759d('0x0'));var util=require(_0x759d('0x1'));var logger=require(_0x759d('0x2'))(_0x759d('0x3'));var moment=require(_0x759d('0x4'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x759d('0x5'));var config=require(_0x759d('0x6'));var attributes=require(_0x759d('0x7'));module['exports']=function(_0x1f188d,_0x4c5167){return _0x1f188d[_0x759d('0x8')](_0x759d('0x9'),attributes,{'tableName':_0x759d('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/squareOdbc/squareOdbc.rpc.js b/server/api/squareOdbc/squareOdbc.rpc.js new file mode 100644 index 0000000..29f2262 --- /dev/null +++ b/server/api/squareOdbc/squareOdbc.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x52e9=['model','lodash','moment','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','then','info','SquareOdbc,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','ShowSquareOdbc','SquareOdbc','find','options','where','attributes','map','include'];(function(_0x3fd603,_0x5f5b06){var _0x5026af=function(_0x5f199d){while(--_0x5f199d){_0x3fd603['push'](_0x3fd603['shift']());}};_0x5026af(++_0x5f5b06);}(_0x52e9,0x145));var _0x952e=function(_0x4f6692,_0x298a79){_0x4f6692=_0x4f6692-0x0;var _0x58b110=_0x52e9[_0x4f6692];return _0x58b110;};'use strict';var _=require(_0x952e('0x0'));var util=require('util');var moment=require(_0x952e('0x1'));var BPromise=require('bluebird');var rs=require(_0x952e('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x952e('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x952e('0x4'))(_0x952e('0x5'));var config=require(_0x952e('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x952e('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x99d4e1,_0x319fef,_0x381146){return new BPromise(function(_0x283ba1,_0x282bd7){return client['request'](_0x99d4e1,_0x381146)[_0x952e('0x8')](function(_0x22fae9){logger[_0x952e('0x9')](_0x952e('0xa'),_0x319fef,_0x952e('0xb'));logger[_0x952e('0xc')]('SquareOdbc,\x20%s,\x20%s,\x20%s',_0x319fef,_0x952e('0xb'),JSON[_0x952e('0xd')](_0x22fae9));if(_0x22fae9[_0x952e('0xe')]){if(_0x22fae9[_0x952e('0xe')][_0x952e('0xf')]===0x1f4){logger[_0x952e('0xe')]('SquareOdbc,\x20%s,\x20%s',_0x319fef,_0x22fae9[_0x952e('0xe')]['message']);return _0x282bd7(_0x22fae9['error'][_0x952e('0x10')]);}logger[_0x952e('0xe')](_0x952e('0xa'),_0x319fef,_0x22fae9[_0x952e('0xe')][_0x952e('0x10')]);return _0x283ba1(_0x22fae9[_0x952e('0xe')][_0x952e('0x10')]);}else{logger[_0x952e('0x9')](_0x952e('0xa'),_0x319fef,_0x952e('0xb'));_0x283ba1(_0x22fae9['result'][_0x952e('0x10')]);}})[_0x952e('0x11')](function(_0x47be9a){logger['error'](_0x952e('0xa'),_0x319fef,_0x47be9a);_0x282bd7(_0x47be9a);});});}exports[_0x952e('0x12')]=function(_0x2829cf){var _0x3df865=this;return new Promise(function(_0x74cb7f,_0x4722e7){return db[_0x952e('0x13')][_0x952e('0x14')]({'raw':_0x2829cf[_0x952e('0x15')]?_0x2829cf[_0x952e('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x2829cf[_0x952e('0x15')]?_0x2829cf[_0x952e('0x15')][_0x952e('0x16')]||null:null,'attributes':_0x2829cf[_0x952e('0x15')]?_0x2829cf[_0x952e('0x15')][_0x952e('0x17')]||null:null,'include':_0x2829cf['options']?_0x2829cf[_0x952e('0x15')]['include']?_[_0x952e('0x18')](_0x2829cf[_0x952e('0x15')][_0x952e('0x19')],function(_0x54deb6){return{'model':db[_0x54deb6[_0x952e('0x1a')]],'as':_0x54deb6['as'],'attributes':_0x54deb6[_0x952e('0x17')],'include':_0x54deb6['include']?_['map'](_0x54deb6['include'],function(_0x377bcc){return{'model':db[_0x377bcc['model']],'as':_0x377bcc['as'],'attributes':_0x377bcc[_0x952e('0x17')],'include':_0x377bcc[_0x952e('0x19')]?_[_0x952e('0x18')](_0x377bcc['include'],function(_0x40f760){return{'model':db[_0x40f760[_0x952e('0x1a')]],'as':_0x40f760['as'],'attributes':_0x40f760[_0x952e('0x17')]};}):[]};}):[]};}):[]:[]})[_0x952e('0x8')](function(_0x164a09){logger[_0x952e('0x9')](_0x952e('0x12'),_0x2829cf);logger[_0x952e('0xc')](_0x952e('0x12'),_0x2829cf,JSON['stringify'](_0x164a09));_0x74cb7f(_0x164a09);})[_0x952e('0x11')](function(_0x5e7e3d){logger[_0x952e('0xe')](_0x952e('0x12'),_0x5e7e3d[_0x952e('0x10')],_0x2829cf);_0x4722e7(_0x3df865['error'](0x1f4,_0x5e7e3d[_0x952e('0x10')]));});});}; \ No newline at end of file diff --git a/server/api/squareProject/index.js b/server/api/squareProject/index.js new file mode 100644 index 0000000..4a7ce00 --- /dev/null +++ b/server/api/squareProject/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xea02=['index','/:id','show','post','create','put','delete','multer','path','connect-timeout','express','Router','../../components/interaction/service','../../config/environment','./squareProject.controller','get','isAuthenticated'];(function(_0x55b6e1,_0x18d927){var _0x5e69af=function(_0x47d45f){while(--_0x47d45f){_0x55b6e1['push'](_0x55b6e1['shift']());}};_0x5e69af(++_0x18d927);}(_0xea02,0xb1));var _0x2ea0=function(_0x51a03c,_0x28e37a){_0x51a03c=_0x51a03c-0x0;var _0x4d9b98=_0xea02[_0x51a03c];return _0x4d9b98;};'use strict';var multer=require(_0x2ea0('0x0'));var util=require('util');var path=require(_0x2ea0('0x1'));var timeout=require(_0x2ea0('0x2'));var express=require(_0x2ea0('0x3'));var router=express[_0x2ea0('0x4')]();var fs_extra=require('fs-extra');var auth=require('../../components/auth/service');var interaction=require(_0x2ea0('0x5'));var config=require(_0x2ea0('0x6'));var controller=require(_0x2ea0('0x7'));router[_0x2ea0('0x8')]('/',auth[_0x2ea0('0x9')](),controller[_0x2ea0('0xa')]);router[_0x2ea0('0x8')](_0x2ea0('0xb'),auth[_0x2ea0('0x9')](),controller[_0x2ea0('0xc')]);router[_0x2ea0('0xd')]('/',auth[_0x2ea0('0x9')](),controller[_0x2ea0('0xe')]);router[_0x2ea0('0xf')](_0x2ea0('0xb'),auth['isAuthenticated'](),controller['update']);router[_0x2ea0('0x10')](_0x2ea0('0xb'),auth['isAuthenticated'](),controller['destroy']);module['exports']=router; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.attributes.js b/server/api/squareProject/squareProject.attributes.js new file mode 100644 index 0000000..14901a7 --- /dev/null +++ b/server/api/squareProject/squareProject.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe396=['long','getDataValue','preproduction','toString','utf8','production','DATE','sequelize','exports','STRING','name','TEXT','BLOB'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xe396,0xa3));var _0x6e39=function(_0xe2b853,_0x114638){_0xe2b853=_0xe2b853-0x0;var _0x3717ed=_0xe396[_0xe2b853];return _0x3717ed;};'use strict';var Sequelize=require(_0x6e39('0x0'));module[_0x6e39('0x1')]={'name':{'type':Sequelize[_0x6e39('0x2')],'unique':_0x6e39('0x3'),'allowNull':![]},'description':{'type':Sequelize[_0x6e39('0x2')]},'notes':{'type':Sequelize[_0x6e39('0x4')]},'preproduction':{'type':Sequelize[_0x6e39('0x5')](_0x6e39('0x6')),'get':function(){if(this[_0x6e39('0x7')]('preproduction')){return this[_0x6e39('0x7')](_0x6e39('0x8'))[_0x6e39('0x9')](_0x6e39('0xa'));}}},'production':{'type':Sequelize[_0x6e39('0x5')](_0x6e39('0x6')),'get':function(){if(this['getDataValue']('production')){return this[_0x6e39('0x7')](_0x6e39('0xb'))[_0x6e39('0x9')](_0x6e39('0xa'));}}},'savedAt':{'type':Sequelize[_0x6e39('0xc')]},'publishedAt':{'type':Sequelize[_0x6e39('0xc')]}}; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.controller.js b/server/api/squareProject/squareProject.controller.js new file mode 100644 index 0000000..1d9fc4c --- /dev/null +++ b/server/api/squareProject/squareProject.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37ea=['pick','filter','merge','VIRTUAL','options','SquareProject','includeAll','include','rows','show','params','keys','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','production','ioredis','../../components/parsers/qs','api','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','json','limit','undefined','count','offset','set','Content-Range','then','destroy','get','SquareProjects','publish','agi','stringify','status','end','sendStatus','error','stack','name','send','index','rawAttributes','fieldName','type','key','map','query','intersection','model','attributes','fields','length','nolimit','order','sort','where','filters'];(function(_0x238942,_0x3fe35e){var _0x17b205=function(_0x307c77){while(--_0x307c77){_0x238942['push'](_0x238942['shift']());}};_0x17b205(++_0x3fe35e);}(_0x37ea,0x1c3));var _0xa37e=function(_0x6a088b,_0x7000f8){_0x6a088b=_0x6a088b-0x0;var _0x18e69b=_0x37ea[_0x6a088b];return _0x18e69b;};'use strict';var _=require('lodash');var Redis=require(_0xa37e('0x0'));var qs=require(_0xa37e('0x1'));var logger=require('../../config/logger')(_0xa37e('0x2'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0xa37e('0x3')]=_[_0xa37e('0x4')](config[_0xa37e('0x3')],{'host':_0xa37e('0x5'),'port':0x18eb});var socket=require(_0xa37e('0x6'))(new Redis(config[_0xa37e('0x3')]));require(_0xa37e('0x7'))['register'](socket);function respondWithResult(_0x54ca7b,_0x163ffe){_0x163ffe=_0x163ffe||0xc8;return function(_0x3a05e0){if(_0x3a05e0){return _0x54ca7b['status'](_0x163ffe)[_0xa37e('0x8')](_0x3a05e0);}};}function respondWithFilteredResult(_0x5b831f,_0x332d16){return function(_0x2964e9){if(_0x2964e9){var _0x14d4ae=typeof _0x332d16['offset']==='undefined'&&typeof _0x332d16[_0xa37e('0x9')]===_0xa37e('0xa');var _0x55ddb7=_0x2964e9[_0xa37e('0xb')];var _0xc4cfbd=_0x14d4ae?0x0:_0x332d16[_0xa37e('0xc')];var _0x242598=_0x14d4ae?_0x2964e9[_0xa37e('0xb')]:_0x332d16['offset']+_0x332d16['limit'];var _0x164c3b;if(_0x242598>=_0x55ddb7){_0x242598=_0x55ddb7;_0x164c3b=0xc8;}else{_0x164c3b=0xce;}_0x5b831f['status'](_0x164c3b);return _0x5b831f[_0xa37e('0xd')](_0xa37e('0xe'),_0xc4cfbd+'-'+_0x242598+'/'+_0x55ddb7)[_0xa37e('0x8')](_0x2964e9);}return null;};}function saveUpdates(_0x6595a){return function(_0x5939c7){if(_0x5939c7){return _0x5939c7['update'](_0x6595a)[_0xa37e('0xf')](function(_0x5c9596){return _0x5c9596;});}return null;};}function removeEntity(_0x5c3dce){return function(_0x476baa){if(_0x476baa){return _0x476baa[_0xa37e('0x10')]()[_0xa37e('0xf')](function(){var _0x26e369=_0x476baa[_0xa37e('0x11')]({'plain':!![]});var _0xef3fe1=_0xa37e('0x12');return db['UserProfileResource'][_0xa37e('0x10')]({'where':{'type':_0xef3fe1,'resourceId':_0x26e369['id']}})['then'](function(){return _0x476baa;});})['then'](function(){var _0xdb8974=new Redis(config[_0xa37e('0x3')]);_0xdb8974[_0xa37e('0x13')](_0xa37e('0x14'),JSON[_0xa37e('0x15')]({'id':_0x476baa['id'],'deleted':!![]}));})[_0xa37e('0xf')](function(){_0x5c3dce[_0xa37e('0x16')](0xcc)[_0xa37e('0x17')]();});}};}function handleEntityNotFound(_0x112e93){return function(_0x5d378e){if(!_0x5d378e){_0x112e93[_0xa37e('0x18')](0x194);}return _0x5d378e;};}function handleError(_0x5c1ab8,_0x3f1ec7){_0x3f1ec7=_0x3f1ec7||0x1f4;return function(_0x8b4e70){logger[_0xa37e('0x19')](_0x8b4e70[_0xa37e('0x1a')]);if(_0x8b4e70[_0xa37e('0x1b')]){delete _0x8b4e70[_0xa37e('0x1b')];}_0x5c1ab8[_0xa37e('0x16')](_0x3f1ec7)[_0xa37e('0x1c')](_0x8b4e70);};}exports[_0xa37e('0x1d')]=function(_0xe9e9e7,_0x5d47b0){var _0x489947={},_0x5ac340={},_0x530b0f={'count':0x0,'rows':[]};var _0x463936=_['map'](db['SquareProject'][_0xa37e('0x1e')],function(_0x504c32){return{'name':_0x504c32[_0xa37e('0x1f')],'type':_0x504c32[_0xa37e('0x20')][_0xa37e('0x21')]};});_0x5ac340['model']=_[_0xa37e('0x22')](_0x463936,_0xa37e('0x1b'));_0x5ac340['query']=_['keys'](_0xe9e9e7[_0xa37e('0x23')]);_0x5ac340['filters']=_[_0xa37e('0x24')](_0x5ac340[_0xa37e('0x25')],_0x5ac340['query']);_0x489947[_0xa37e('0x26')]=_[_0xa37e('0x24')](_0x5ac340[_0xa37e('0x25')],qs[_0xa37e('0x27')](_0xe9e9e7[_0xa37e('0x23')][_0xa37e('0x27')]));_0x489947['attributes']=_0x489947['attributes'][_0xa37e('0x28')]?_0x489947['attributes']:_0x5ac340[_0xa37e('0x25')];if(!_0xe9e9e7[_0xa37e('0x23')]['hasOwnProperty'](_0xa37e('0x29'))){_0x489947[_0xa37e('0x9')]=qs['limit'](_0xe9e9e7[_0xa37e('0x23')]['limit']);_0x489947[_0xa37e('0xc')]=qs[_0xa37e('0xc')](_0xe9e9e7[_0xa37e('0x23')][_0xa37e('0xc')]);}_0x489947[_0xa37e('0x2a')]=qs[_0xa37e('0x2b')](_0xe9e9e7['query'][_0xa37e('0x2b')]);_0x489947[_0xa37e('0x2c')]=qs[_0xa37e('0x2d')](_[_0xa37e('0x2e')](_0xe9e9e7[_0xa37e('0x23')],_0x5ac340[_0xa37e('0x2d')]),_0x463936);if(_0xe9e9e7['query'][_0xa37e('0x2f')]){_0x489947['where']=_[_0xa37e('0x30')](_0x489947[_0xa37e('0x2c')],{'$or':_['map'](_0x463936,function(_0x1d978c){if(_0x1d978c[_0xa37e('0x20')]!==_0xa37e('0x31')){var _0x5527fd={};_0x5527fd[_0x1d978c[_0xa37e('0x1b')]]={'$like':'%'+_0xe9e9e7[_0xa37e('0x23')][_0xa37e('0x2f')]+'%'};return _0x5527fd;}})});}_0x489947=_[_0xa37e('0x30')]({},_0x489947,_0xe9e9e7[_0xa37e('0x32')]);var _0x3edbd9={'where':_0x489947[_0xa37e('0x2c')]};return db[_0xa37e('0x33')][_0xa37e('0xb')](_0x3edbd9)[_0xa37e('0xf')](function(_0x5ee82e){_0x530b0f['count']=_0x5ee82e;if(_0xe9e9e7[_0xa37e('0x23')][_0xa37e('0x34')]){_0x489947[_0xa37e('0x35')]=[{'all':!![]}];}return db[_0xa37e('0x33')]['findAll'](_0x489947);})[_0xa37e('0xf')](function(_0x49c149){_0x530b0f[_0xa37e('0x36')]=_0x49c149;return _0x530b0f;})[_0xa37e('0xf')](respondWithFilteredResult(_0x5d47b0,_0x489947))['catch'](handleError(_0x5d47b0,null));};exports[_0xa37e('0x37')]=function(_0x559a18,_0x4840b4){var _0x586f7e={'raw':![],'where':{'id':_0x559a18[_0xa37e('0x38')]['id']}},_0x7e8c55={};_0x7e8c55[_0xa37e('0x25')]=_['keys'](db[_0xa37e('0x33')][_0xa37e('0x1e')]);_0x7e8c55[_0xa37e('0x23')]=_[_0xa37e('0x39')](_0x559a18[_0xa37e('0x23')]);_0x7e8c55['filters']=_[_0xa37e('0x24')](_0x7e8c55[_0xa37e('0x25')],_0x7e8c55[_0xa37e('0x23')]);_0x586f7e[_0xa37e('0x26')]=_[_0xa37e('0x24')](_0x7e8c55[_0xa37e('0x25')],qs['fields'](_0x559a18[_0xa37e('0x23')][_0xa37e('0x27')]));_0x586f7e[_0xa37e('0x26')]=_0x586f7e[_0xa37e('0x26')][_0xa37e('0x28')]?_0x586f7e[_0xa37e('0x26')]:_0x7e8c55[_0xa37e('0x25')];if(_0x559a18[_0xa37e('0x23')][_0xa37e('0x34')]){_0x586f7e[_0xa37e('0x35')]=[{'all':!![]}];}_0x586f7e=_[_0xa37e('0x30')]({},_0x586f7e,_0x559a18[_0xa37e('0x32')]);return db[_0xa37e('0x33')][_0xa37e('0x3a')](_0x586f7e)[_0xa37e('0xf')](handleEntityNotFound(_0x4840b4,null))['then'](respondWithResult(_0x4840b4,null))['catch'](handleError(_0x4840b4,null));};exports['create']=function(_0x5c44d9,_0x166aea){return db[_0xa37e('0x33')][_0xa37e('0x3b')](_0x5c44d9[_0xa37e('0x3c')],{})[_0xa37e('0xf')](function(_0x38ad10){var _0x410198=_0x5c44d9['user'][_0xa37e('0x11')]({'plain':!![]});if(!_0x410198)throw new Error(_0xa37e('0x3d'));if(_0x410198[_0xa37e('0x3e')]==='user'){var _0xcbc764=_0x38ad10[_0xa37e('0x11')]({'plain':!![]});var _0x5f37da=_0xa37e('0x12');return db[_0xa37e('0x3f')][_0xa37e('0x3a')]({'where':{'name':_0x5f37da,'userProfileId':_0x410198[_0xa37e('0x40')]},'raw':!![]})[_0xa37e('0xf')](function(_0x4eabf9){if(_0x4eabf9&&_0x4eabf9[_0xa37e('0x41')]===0x0){return db[_0xa37e('0x42')][_0xa37e('0x3b')]({'name':_0xcbc764[_0xa37e('0x1b')],'resourceId':_0xcbc764['id'],'type':_0x4eabf9[_0xa37e('0x1b')],'sectionId':_0x4eabf9['id']},{})[_0xa37e('0xf')](function(){return _0x38ad10;});}else{return _0x38ad10;}})[_0xa37e('0x43')](function(_0x260da0){logger[_0xa37e('0x19')](_0xa37e('0x44'),_0x260da0);throw _0x260da0;});}return _0x38ad10;})[_0xa37e('0xf')](respondWithResult(_0x166aea,0xc9))['catch'](handleError(_0x166aea,null));};exports[_0xa37e('0x45')]=function(_0x501040,_0x4085b5){if(_0x501040[_0xa37e('0x3c')]['id']){delete _0x501040['body']['id'];}return db['SquareProject'][_0xa37e('0x3a')]({'where':{'id':_0x501040['params']['id']}})[_0xa37e('0xf')](handleEntityNotFound(_0x4085b5,null))[_0xa37e('0xf')](saveUpdates(_0x501040['body'],null))['then'](function(_0x1fc20e){if(!_0x1fc20e)return;var _0x30ae8f=_0x1fc20e[_0xa37e('0x11')]({'plain':!![]});return _0x30ae8f;})[_0xa37e('0xf')](function(_0x2f2f0c){var _0x2e8af6=new Redis(config['redis']);_0x2e8af6[_0xa37e('0x13')]('agi',JSON['stringify'](_[_0xa37e('0x2e')](_0x2f2f0c,['id',_0xa37e('0x1b'),_0xa37e('0x46')])));return _0x2f2f0c;})[_0xa37e('0xf')](respondWithResult(_0x4085b5,null))[_0xa37e('0x43')](handleError(_0x4085b5,null));};exports[_0xa37e('0x10')]=function(_0x1f8b3c,_0x4fbb50){return db[_0xa37e('0x33')]['find']({'where':{'id':_0x1f8b3c[_0xa37e('0x38')]['id']}})[_0xa37e('0xf')](handleEntityNotFound(_0x4fbb50,null))[_0xa37e('0xf')](removeEntity(_0x4fbb50,null))[_0xa37e('0x43')](handleError(_0x4fbb50,null));}; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.events.js b/server/api/squareProject/squareProject.events.js new file mode 100644 index 0000000..2dde876 --- /dev/null +++ b/server/api/squareProject/squareProject.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfd1c=['setMaxListeners','save','update','remove','hook','exports','events','../../mysqldb','SquareProject'];(function(_0x1976a1,_0x522f17){var _0x85e7=function(_0x24ca63){while(--_0x24ca63){_0x1976a1['push'](_0x1976a1['shift']());}};_0x85e7(++_0x522f17);}(_0xfd1c,0x96));var _0xcfd1=function(_0xfad1a7,_0x2e3b8d){_0xfad1a7=_0xfad1a7-0x0;var _0x571012=_0xfd1c[_0xfad1a7];return _0x571012;};'use strict';var EventEmitter=require(_0xcfd1('0x0'));var SquareProject=require(_0xcfd1('0x1'))['db'][_0xcfd1('0x2')];var SquareProjectEvents=new EventEmitter();SquareProjectEvents[_0xcfd1('0x3')](0x0);var events={'afterCreate':_0xcfd1('0x4'),'afterUpdate':_0xcfd1('0x5'),'afterDestroy':_0xcfd1('0x6')};function emitEvent(_0x5f5ad8){return function(_0xcfcc7e,_0xd0fcb2,_0x2d6c5b){SquareProjectEvents['emit'](_0x5f5ad8+':'+_0xcfcc7e['id'],_0xcfcc7e);SquareProjectEvents['emit'](_0x5f5ad8,_0xcfcc7e);_0x2d6c5b(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];SquareProject[_0xcfd1('0x7')](e,emitEvent(event));}}module[_0xcfd1('0x8')]=SquareProjectEvents; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.model.js b/server/api/squareProject/squareProject.model.js new file mode 100644 index 0000000..505a2cd --- /dev/null +++ b/server/api/squareProject/squareProject.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd6f1=['changed','savedAt','format','YYYY-MM-DD\x20HH:mm:ss','production','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./squareProject.attributes','exports','define','SquareProject','square_projects'];(function(_0x2c9062,_0x525a88){var _0x48fa9f=function(_0x2d2731){while(--_0x2d2731){_0x2c9062['push'](_0x2c9062['shift']());}};_0x48fa9f(++_0x525a88);}(_0xd6f1,0x145));var _0x1d6f=function(_0x28947d,_0x4cc9c6){_0x28947d=_0x28947d-0x0;var _0x12d2ee=_0xd6f1[_0x28947d];return _0x12d2ee;};'use strict';var _=require(_0x1d6f('0x0'));var util=require(_0x1d6f('0x1'));var logger=require(_0x1d6f('0x2'))(_0x1d6f('0x3'));var moment=require(_0x1d6f('0x4'));var BPromise=require(_0x1d6f('0x5'));var rp=require(_0x1d6f('0x6'));var fs=require('fs');var path=require(_0x1d6f('0x7'));var rimraf=require(_0x1d6f('0x8'));var config=require(_0x1d6f('0x9'));var attributes=require(_0x1d6f('0xa'));module[_0x1d6f('0xb')]=function(_0x1dcb94,_0x69e6f2){return _0x1dcb94[_0x1d6f('0xc')](_0x1d6f('0xd'),attributes,{'tableName':_0x1d6f('0xe'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x155da3,_0x3e7326,_0x56d4ed){if(_0x155da3[_0x1d6f('0xf')]('preproduction')){_0x155da3[_0x1d6f('0x10')]=moment()[_0x1d6f('0x11')](_0x1d6f('0x12'));}if(_0x155da3['changed'](_0x1d6f('0x13'))){_0x155da3['publishedAt']=moment()['format'](_0x1d6f('0x12'));}_0x56d4ed(null,_0x155da3);}}});}; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.rpc.js b/server/api/squareProject/squareProject.rpc.js new file mode 100644 index 0000000..00e4596 --- /dev/null +++ b/server/api/squareProject/squareProject.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x131e=['model','then','info','GetSquareProjects','debug','stringify','catch','error','message','ShowSquareProject','find','where','lodash','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','redis','localhost','./squareProject.socket','register','SquareProject','findAll','options','raw','attributes','limit','include','map'];(function(_0x24e91d,_0x5d6ffe){var _0x324d8d=function(_0x53a0e0){while(--_0x53a0e0){_0x24e91d['push'](_0x24e91d['shift']());}};_0x324d8d(++_0x5d6ffe);}(_0x131e,0xfc));var _0xe131=function(_0x1f58ad,_0x959626){_0x1f58ad=_0x1f58ad-0x0;var _0x211dd4=_0x131e[_0x1f58ad];return _0x211dd4;};'use strict';var _=require(_0xe131('0x0'));var Redis=require(_0xe131('0x1'));var db=require(_0xe131('0x2'))['db'];var logger=require(_0xe131('0x3'))(_0xe131('0x4'));var config=require(_0xe131('0x5'));config[_0xe131('0x6')]=_['defaults'](config[_0xe131('0x6')],{'host':_0xe131('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe131('0x8'))[_0xe131('0x9')](socket);exports['GetSquareProjects']=function(_0x45962d){var _0x1277dc=this;return new Promise(function(_0x36f26e,_0x54caa4){return db[_0xe131('0xa')][_0xe131('0xb')]({'raw':_0x45962d[_0xe131('0xc')]?_0x45962d['options'][_0xe131('0xd')]===undefined?!![]:![]:!![],'where':_0x45962d[_0xe131('0xc')]?_0x45962d[_0xe131('0xc')]['where']||null:null,'attributes':_0x45962d[_0xe131('0xc')]?_0x45962d[_0xe131('0xc')][_0xe131('0xe')]||null:null,'limit':_0x45962d[_0xe131('0xc')]?_0x45962d[_0xe131('0xc')][_0xe131('0xf')]||null:null,'include':_0x45962d[_0xe131('0xc')]?_0x45962d[_0xe131('0xc')][_0xe131('0x10')]?_[_0xe131('0x11')](_0x45962d[_0xe131('0xc')][_0xe131('0x10')],function(_0x5f209f){return{'model':db[_0x5f209f['model']],'as':_0x5f209f['as'],'attributes':_0x5f209f[_0xe131('0xe')],'include':_0x5f209f[_0xe131('0x10')]?_[_0xe131('0x11')](_0x5f209f[_0xe131('0x10')],function(_0x2c2a49){return{'model':db[_0x2c2a49[_0xe131('0x12')]],'as':_0x2c2a49['as'],'attributes':_0x2c2a49[_0xe131('0xe')],'include':_0x2c2a49[_0xe131('0x10')]?_[_0xe131('0x11')](_0x2c2a49['include'],function(_0x20b9c9){return{'model':db[_0x20b9c9[_0xe131('0x12')]],'as':_0x20b9c9['as'],'attributes':_0x20b9c9[_0xe131('0xe')]};}):[]};}):[]};}):[]:[]})[_0xe131('0x13')](function(_0x5f4678){logger[_0xe131('0x14')](_0xe131('0x15'),_0x45962d);logger[_0xe131('0x16')](_0xe131('0x15'),_0x45962d,JSON[_0xe131('0x17')](_0x5f4678));_0x36f26e(_0x5f4678);})[_0xe131('0x18')](function(_0x9df200){logger[_0xe131('0x19')](_0xe131('0x15'),_0x9df200[_0xe131('0x1a')],_0x45962d);_0x54caa4(_0x1277dc[_0xe131('0x19')](0x1f4,_0x9df200['message']));});});};exports[_0xe131('0x1b')]=function(_0x5c9ddb){var _0x46deb0=this;return new Promise(function(_0x3d96ed,_0x1c4d00){return db[_0xe131('0xa')][_0xe131('0x1c')]({'raw':_0x5c9ddb[_0xe131('0xc')]?_0x5c9ddb[_0xe131('0xc')][_0xe131('0xd')]===undefined?!![]:![]:!![],'where':_0x5c9ddb[_0xe131('0xc')]?_0x5c9ddb[_0xe131('0xc')][_0xe131('0x1d')]||null:null,'attributes':_0x5c9ddb['options']?_0x5c9ddb['options'][_0xe131('0xe')]||null:null,'include':_0x5c9ddb[_0xe131('0xc')]?_0x5c9ddb[_0xe131('0xc')][_0xe131('0x10')]?_[_0xe131('0x11')](_0x5c9ddb['options']['include'],function(_0x524c8b){return{'model':db[_0x524c8b[_0xe131('0x12')]],'as':_0x524c8b['as'],'attributes':_0x524c8b[_0xe131('0xe')],'include':_0x524c8b[_0xe131('0x10')]?_['map'](_0x524c8b[_0xe131('0x10')],function(_0x2e3767){return{'model':db[_0x2e3767['model']],'as':_0x2e3767['as'],'attributes':_0x2e3767[_0xe131('0xe')],'include':_0x2e3767[_0xe131('0x10')]?_['map'](_0x2e3767[_0xe131('0x10')],function(_0x4be986){return{'model':db[_0x4be986['model']],'as':_0x4be986['as'],'attributes':_0x4be986[_0xe131('0xe')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4aee1f){logger[_0xe131('0x14')](_0xe131('0x1b'),_0x5c9ddb);logger[_0xe131('0x16')](_0xe131('0x1b'),_0x5c9ddb,JSON[_0xe131('0x17')](_0x4aee1f));_0x3d96ed(_0x4aee1f);})['catch'](function(_0x1a5cfe){logger[_0xe131('0x19')](_0xe131('0x1b'),_0x1a5cfe['message'],_0x5c9ddb);_0x1c4d00(_0x46deb0['error'](0x1f4,_0x1a5cfe['message']));});});}; \ No newline at end of file diff --git a/server/api/squareProject/squareProject.socket.js b/server/api/squareProject/squareProject.socket.js new file mode 100644 index 0000000..7f56e09 --- /dev/null +++ b/server/api/squareProject/squareProject.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa283=['save','remove','update','removeListener','register','length','squareProject:','./squareProject.events'];(function(_0x2e08d1,_0x3ee7c3){var _0x5e76ec=function(_0x5d070f){while(--_0x5d070f){_0x2e08d1['push'](_0x2e08d1['shift']());}};_0x5e76ec(++_0x3ee7c3);}(_0xa283,0xbf));var _0x3a28=function(_0x212d2f,_0x2522bd){_0x212d2f=_0x212d2f-0x0;var _0x537dba=_0xa283[_0x212d2f];return _0x537dba;};'use strict';var SquareProjectEvents=require(_0x3a28('0x0'));var events=[_0x3a28('0x1'),_0x3a28('0x2'),_0x3a28('0x3')];function createListener(_0x1ba5d9,_0x4ca068){return function(_0x17c869){_0x4ca068['emit'](_0x1ba5d9,_0x17c869);};}function removeListener(_0x318dad,_0x1f269f){return function(){SquareProjectEvents[_0x3a28('0x4')](_0x318dad,_0x1f269f);};}exports[_0x3a28('0x5')]=function(_0x219555){for(var _0x3a2621=0x0,_0x5d34f4=events[_0x3a28('0x6')];_0x3a2621<_0x5d34f4;_0x3a2621++){var _0x467b86=events[_0x3a2621];var _0x320fe1=createListener(_0x3a28('0x7')+_0x467b86,_0x219555);SquareProjectEvents['on'](_0x467b86,_0x320fe1);}}; \ No newline at end of file diff --git a/server/api/squareRecording/index.js b/server/api/squareRecording/index.js new file mode 100644 index 0000000..9d63737 --- /dev/null +++ b/server/api/squareRecording/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['isAuthenticated','show','/:id/download','post','create','/:id','delete','destroy','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./squareRecording.controller','index','get'];(function(_0x1f38db,_0x2af54a){var _0x598816=function(_0x3c82d2){while(--_0x3c82d2){_0x1f38db['push'](_0x1f38db['shift']());}};_0x598816(++_0x2af54a);}(_0x1261,0x144));var _0x1126=function(_0x598b78,_0xf4ee7e){_0x598b78=_0x598b78-0x0;var _0x6392fa=_0x1261[_0x598b78];return _0x6392fa;};'use strict';var multer=require('multer');var util=require(_0x1126('0x0'));var path=require(_0x1126('0x1'));var timeout=require(_0x1126('0x2'));var express=require(_0x1126('0x3'));var router=express[_0x1126('0x4')]();var fs_extra=require(_0x1126('0x5'));var auth=require(_0x1126('0x6'));var interaction=require(_0x1126('0x7'));var config=require(_0x1126('0x8'));var controller=require(_0x1126('0x9'));router['get']('/',auth['isAuthenticated'](),controller[_0x1126('0xa')]);router[_0x1126('0xb')]('/:id',auth[_0x1126('0xc')](),controller[_0x1126('0xd')]);router[_0x1126('0xb')](_0x1126('0xe'),auth[_0x1126('0xc')](),controller['download']);router[_0x1126('0xf')]('/',auth[_0x1126('0xc')](),controller[_0x1126('0x10')]);router['put'](_0x1126('0x11'),auth['isAuthenticated'](),controller['update']);router[_0x1126('0x12')]('/:id',auth[_0x1126('0xc')](),controller[_0x1126('0x13')]);module[_0x1126('0x14')]=router; \ No newline at end of file diff --git a/server/api/squareRecording/squareRecording.attributes.js b/server/api/squareRecording/squareRecording.attributes.js new file mode 100644 index 0000000..5975dcd --- /dev/null +++ b/server/api/squareRecording/squareRecording.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbd51=['VIRTUAL','getDataValue','savePath','lastIndexOf','sequelize','STRING'];(function(_0x1e673a,_0x3070c4){var _0x4350b7=function(_0x26b207){while(--_0x26b207){_0x1e673a['push'](_0x1e673a['shift']());}};_0x4350b7(++_0x3070c4);}(_0xbd51,0x1a8));var _0x1bd5=function(_0x5aa2d7,_0x2a0504){_0x5aa2d7=_0x5aa2d7-0x0;var _0x1328f2=_0xbd51[_0x5aa2d7];return _0x1328f2;};'use strict';var Sequelize=require(_0x1bd5('0x0'));module['exports']={'uniqueid':{'type':Sequelize[_0x1bd5('0x1')]},'callerid':{'type':Sequelize[_0x1bd5('0x1')]},'calleridname':{'type':Sequelize[_0x1bd5('0x1')]},'context':{'type':Sequelize[_0x1bd5('0x1')]},'extension':{'type':Sequelize['STRING']},'priority':{'type':Sequelize['STRING']},'accountcode':{'type':Sequelize['STRING']},'dnid':{'type':Sequelize['STRING']},'projectName':{'type':Sequelize[_0x1bd5('0x1')]},'saveName':{'type':Sequelize[_0x1bd5('0x1')]},'filename':{'type':Sequelize[_0x1bd5('0x1')]},'savePath':{'type':Sequelize['STRING']},'format':{'type':Sequelize[_0x1bd5('0x2')],'get':function(){var _0x30a385='';var _0x19077c=this[_0x1bd5('0x3')](_0x1bd5('0x4'));if(_0x19077c){_0x30a385=_0x19077c['substring'](_0x19077c[_0x1bd5('0x5')]('.'));}return _0x30a385;}}}; \ No newline at end of file diff --git a/server/api/squareRecording/squareRecording.controller.js b/server/api/squareRecording/squareRecording.controller.js new file mode 100644 index 0000000..3543f53 --- /dev/null +++ b/server/api/squareRecording/squareRecording.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x94ce=['SquareRecording','includeAll','include','findAll','catch','params','create','body','find','download','../../components/encryptor','uniqueid','savePath','existsSync','decryptFile','secrets','recording','Sequelize','ValidationError','SquareRecording\x20not\x20found','filename','extname','Not\x20found','cancellazione\x20fisica\x20documento\x20%s','isNil','info','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','unlinkSync','.cypher','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','update','destroy','then','stack','name','send','index','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options'];(function(_0x3c7fbf,_0x57c5eb){var _0x2b0aa4=function(_0x21460c){while(--_0x21460c){_0x3c7fbf['push'](_0x3c7fbf['shift']());}};_0x2b0aa4(++_0x57c5eb);}(_0x94ce,0xd4));var _0xe94c=function(_0x53dac4,_0x436fac){_0x53dac4=_0x53dac4-0x0;var _0x589366=_0x94ce[_0x53dac4];return _0x589366;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe94c('0x0'));var zipdir=require(_0xe94c('0x1'));var jsonpatch=require(_0xe94c('0x2'));var rp=require('request-promise');var moment=require(_0xe94c('0x3'));var BPromise=require(_0xe94c('0x4'));var Mustache=require(_0xe94c('0x5'));var util=require('util');var path=require(_0xe94c('0x6'));var sox=require(_0xe94c('0x7'));var csv=require(_0xe94c('0x8'));var ejs=require(_0xe94c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0xe94c('0xa'));var jsforce=require(_0xe94c('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xe94c('0x8'));var querystring=require(_0xe94c('0xc'));var Papa=require(_0xe94c('0xd'));var Redis=require(_0xe94c('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xe94c('0xf'));var as=require(_0xe94c('0x10'));var hardwareService=require(_0xe94c('0x11'));var logger=require(_0xe94c('0x12'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xe94c('0x13'))['db'];function respondWithStatusCode(_0x5c563b,_0x5a9b68){_0x5a9b68=_0x5a9b68||0xcc;return function(_0x39151d){if(_0x39151d){return _0x5c563b[_0xe94c('0x14')](_0x5a9b68);}return _0x5c563b[_0xe94c('0x15')](_0x5a9b68)[_0xe94c('0x16')]();};}function respondWithResult(_0x5b09e2,_0x404478){_0x404478=_0x404478||0xc8;return function(_0x1ac0fe){if(_0x1ac0fe){return _0x5b09e2[_0xe94c('0x15')](_0x404478)['json'](_0x1ac0fe);}};}function respondWithFilteredResult(_0x2b3508,_0xc0911d){return function(_0x48a470){if(_0x48a470){var _0x216e6d=typeof _0xc0911d[_0xe94c('0x17')]===_0xe94c('0x18')&&typeof _0xc0911d[_0xe94c('0x19')]===_0xe94c('0x18');var _0x3e03a9=_0x48a470['count'];var _0x433373=_0x216e6d?0x0:_0xc0911d[_0xe94c('0x17')];var _0x19cf11=_0x216e6d?_0x48a470[_0xe94c('0x1a')]:_0xc0911d[_0xe94c('0x17')]+_0xc0911d[_0xe94c('0x19')];var _0x459109;if(_0x19cf11>=_0x3e03a9){_0x19cf11=_0x3e03a9;_0x459109=0xc8;}else{_0x459109=0xce;}_0x2b3508[_0xe94c('0x15')](_0x459109);return _0x2b3508[_0xe94c('0x1b')](_0xe94c('0x1c'),_0x433373+'-'+_0x19cf11+'/'+_0x3e03a9)[_0xe94c('0x1d')](_0x48a470);}return null;};}function patchUpdates(_0x4fcd2d){return function(_0x5bbb10){try{jsonpatch[_0xe94c('0x1e')](_0x5bbb10,_0x4fcd2d,!![]);}catch(_0x134323){return BPromise[_0xe94c('0x1f')](_0x134323);}return _0x5bbb10['save']();};}function saveUpdates(_0xe6612f,_0x2d60f4){return function(_0x52a5c2){if(_0x52a5c2){return _0x52a5c2[_0xe94c('0x20')](_0xe6612f)['then'](function(_0xb11e48){return _0xb11e48;});}return null;};}function removeEntity(_0x5d71c0,_0xc19af2){return function(_0x1df2c7){if(_0x1df2c7){return _0x1df2c7[_0xe94c('0x21')]()[_0xe94c('0x22')](function(){_0x5d71c0['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x4ff532,_0x230397){return function(_0x86a400){if(!_0x86a400){_0x4ff532[_0xe94c('0x14')](0x194);}return _0x86a400;};}function handleError(_0x1f5632,_0x33a155){_0x33a155=_0x33a155||0x1f4;return function(_0x2c125d){logger['error'](_0x2c125d[_0xe94c('0x23')]);if(_0x2c125d['name']){delete _0x2c125d[_0xe94c('0x24')];}_0x1f5632[_0xe94c('0x15')](_0x33a155)[_0xe94c('0x25')](_0x2c125d);};}exports[_0xe94c('0x26')]=function(_0x1ccea8,_0x1eeade){var _0x7926c1={},_0x4478e0={},_0x34f507={'count':0x0,'rows':[]};var _0x1a4b47=_['map'](db['SquareRecording'][_0xe94c('0x27')],function(_0x47e61c){return{'name':_0x47e61c[_0xe94c('0x28')],'type':_0x47e61c[_0xe94c('0x29')]['key']};});_0x4478e0['model']=_[_0xe94c('0x2a')](_0x1a4b47,_0xe94c('0x24'));_0x4478e0[_0xe94c('0x2b')]=_[_0xe94c('0x2c')](_0x1ccea8[_0xe94c('0x2b')]);_0x4478e0[_0xe94c('0x2d')]=_[_0xe94c('0x2e')](_0x4478e0['model'],_0x4478e0[_0xe94c('0x2b')]);_0x7926c1['attributes']=_[_0xe94c('0x2e')](_0x4478e0[_0xe94c('0x2f')],qs[_0xe94c('0x30')](_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x30')]));_0x7926c1[_0xe94c('0x31')]=_0x7926c1[_0xe94c('0x31')][_0xe94c('0x32')]?_0x7926c1[_0xe94c('0x31')]:_0x4478e0[_0xe94c('0x2f')];if(!_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x33')](_0xe94c('0x34'))){_0x7926c1[_0xe94c('0x19')]=qs[_0xe94c('0x19')](_0x1ccea8['query'][_0xe94c('0x19')]);_0x7926c1[_0xe94c('0x17')]=qs[_0xe94c('0x17')](_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x17')]);}_0x7926c1[_0xe94c('0x35')]=qs[_0xe94c('0x36')](_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x36')]);_0x7926c1[_0xe94c('0x37')]=qs[_0xe94c('0x2d')](_[_0xe94c('0x38')](_0x1ccea8[_0xe94c('0x2b')],_0x4478e0['filters']),_0x1a4b47);if(_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x39')]){_0x7926c1[_0xe94c('0x37')]=_['merge'](_0x7926c1[_0xe94c('0x37')],{'$or':_['map'](_0x1a4b47,function(_0x31e6c8){if(_0x31e6c8[_0xe94c('0x29')]!==_0xe94c('0x3a')){var _0x5b46ce={};_0x5b46ce[_0x31e6c8[_0xe94c('0x24')]]={'$like':'%'+_0x1ccea8[_0xe94c('0x2b')]['filter']+'%'};return _0x5b46ce;}})});}_0x7926c1=_[_0xe94c('0x3b')]({},_0x7926c1,_0x1ccea8[_0xe94c('0x3c')]);var _0x37a335={'where':_0x7926c1[_0xe94c('0x37')]};return db[_0xe94c('0x3d')][_0xe94c('0x1a')](_0x37a335)[_0xe94c('0x22')](function(_0x46d1ae){_0x34f507[_0xe94c('0x1a')]=_0x46d1ae;if(_0x1ccea8[_0xe94c('0x2b')][_0xe94c('0x3e')]){_0x7926c1[_0xe94c('0x3f')]=[{'all':!![]}];}return db[_0xe94c('0x3d')][_0xe94c('0x40')](_0x7926c1);})[_0xe94c('0x22')](function(_0x1ea345){_0x34f507['rows']=_0x1ea345;return _0x34f507;})[_0xe94c('0x22')](respondWithFilteredResult(_0x1eeade,_0x7926c1))[_0xe94c('0x41')](handleError(_0x1eeade,null));};exports['show']=function(_0x4d63bb,_0x4efc3b){var _0x3016f6={'raw':!![],'where':{'id':_0x4d63bb[_0xe94c('0x42')]['id']}},_0x2b9ce7={};_0x2b9ce7[_0xe94c('0x2f')]=_[_0xe94c('0x2c')](db[_0xe94c('0x3d')]['rawAttributes']);_0x2b9ce7[_0xe94c('0x2b')]=_[_0xe94c('0x2c')](_0x4d63bb['query']);_0x2b9ce7['filters']=_['intersection'](_0x2b9ce7[_0xe94c('0x2f')],_0x2b9ce7['query']);_0x3016f6[_0xe94c('0x31')]=_[_0xe94c('0x2e')](_0x2b9ce7[_0xe94c('0x2f')],qs[_0xe94c('0x30')](_0x4d63bb[_0xe94c('0x2b')]['fields']));_0x3016f6[_0xe94c('0x31')]=_0x3016f6[_0xe94c('0x31')][_0xe94c('0x32')]?_0x3016f6['attributes']:_0x2b9ce7['model'];if(_0x4d63bb[_0xe94c('0x2b')][_0xe94c('0x3e')]){_0x3016f6[_0xe94c('0x3f')]=[{'all':!![]}];}_0x3016f6=_['merge']({},_0x3016f6,_0x4d63bb[_0xe94c('0x3c')]);return db['SquareRecording']['find'](_0x3016f6)[_0xe94c('0x22')](handleEntityNotFound(_0x4efc3b,null))[_0xe94c('0x22')](respondWithResult(_0x4efc3b,null))[_0xe94c('0x41')](handleError(_0x4efc3b,null));};exports['create']=function(_0x569f62,_0x51d8a2){return db[_0xe94c('0x3d')][_0xe94c('0x43')](_0x569f62['body'],{})['then'](respondWithResult(_0x51d8a2,0xc9))['catch'](handleError(_0x51d8a2,null));};exports['update']=function(_0x181a8c,_0x201bbb){if(_0x181a8c[_0xe94c('0x44')]['id']){delete _0x181a8c[_0xe94c('0x44')]['id'];}return db['SquareRecording'][_0xe94c('0x45')]({'where':{'id':_0x181a8c['params']['id']}})[_0xe94c('0x22')](handleEntityNotFound(_0x201bbb,null))[_0xe94c('0x22')](saveUpdates(_0x181a8c[_0xe94c('0x44')],null))[_0xe94c('0x22')](respondWithResult(_0x201bbb,null))[_0xe94c('0x41')](handleError(_0x201bbb,null));};exports[_0xe94c('0x46')]=function(_0xbf8090,_0x222807,_0x13b3c0){var _0x3f2fd=require(_0xe94c('0x47'));var _0xbe587e=![];var _0x3e0e5b={};if(_0xbf8090[_0xe94c('0x2b')]['type']&&_0xbf8090[_0xe94c('0x2b')][_0xe94c('0x29')]===_0xe94c('0x48')){_0x3e0e5b['uniqueid']=_0xbf8090['params']['id'];}else{_0x3e0e5b['id']=_0xbf8090[_0xe94c('0x42')]['id'];}return db[_0xe94c('0x3d')]['find']({'where':_0x3e0e5b,'attributes':['id',_0xe94c('0x49'),'filename'],'raw':!![]})[_0xe94c('0x22')](handleEntityNotFound(_0x222807,null))[_0xe94c('0x22')](function(_0x27a0b5){if(_0x27a0b5){var _0x1f269e=_0x27a0b5[_0xe94c('0x49')];var _0x309001=util['format']('%s.cypher',_0x1f269e);if(fs[_0xe94c('0x4a')](_0x309001)){_0xbe587e=!![];return _0x3f2fd[_0xe94c('0x4b')](_0x309001,_0x1f269e,config[_0xe94c('0x4c')][_0xe94c('0x4d')])[_0xe94c('0x22')](function(){return _0x27a0b5;});}return _0x27a0b5;}})[_0xe94c('0x22')](function(_0x51cbc7){if(_0x51cbc7){var _0x19209e=_0x51cbc7['savePath'];if(!fs[_0xe94c('0x4a')](_0x19209e)){throw new db[(_0xe94c('0x4e'))][(_0xe94c('0x4f'))](_0xe94c('0x50'));}if(_0x51cbc7[_0xe94c('0x51')]){return _0x222807['download'](_0x19209e,_0x51cbc7['filename']+path[_0xe94c('0x52')](_0x19209e),function(){if(_0xbe587e){fs['unlink'](_0x19209e);}});}else{return _0x222807[_0xe94c('0x46')](_0x19209e,function(_0x2e3e67){if(_0xbe587e){fs['unlink'](_0x19209e);}});}}})['catch'](function(_0x1ba590){if(_0x1ba590['message']===_0xe94c('0x50')){_0x222807[_0xe94c('0x15')](0x194)['send'](_0xe94c('0x53'));}else{return handleError(_0x222807,null);}});};exports[_0xe94c('0x21')]=function(_0x304559,_0x53b5cf){return db[_0xe94c('0x3d')][_0xe94c('0x45')]({'where':{'id':_0x304559['params']['id']}})[_0xe94c('0x22')](function(_0x27db64){if(_['isNil'](_0x27db64)){throw new ReferenceError('Entity\x20not\x20found');}return _0x27db64;})[_0xe94c('0x22')](function(_0x4f656c){var _0x25bf48=_0x4f656c[_0xe94c('0x49')];logger['info'](_0xe94c('0x54'),_0x25bf48);if(!_[_0xe94c('0x55')](_0x4f656c['savePath'])&&fs[_0xe94c('0x4a')](_0x25bf48)){logger[_0xe94c('0x56')](_0xe94c('0x57')+_0x25bf48+_0xe94c('0x58'));fs[_0xe94c('0x59')](_0x25bf48);}_0x25bf48=_0x25bf48+_0xe94c('0x5a');if(!_['isNil'](_0x4f656c['savePath'])&&fs[_0xe94c('0x4a')](_0x25bf48)){logger['info'](_0xe94c('0x57')+_0x25bf48+_0xe94c('0x58'));fs[_0xe94c('0x59')](_0x25bf48);}return _0x4f656c;})[_0xe94c('0x22')](function(_0x5ec6f3){if(!_0x5ec6f3)throw new InternalError();return _0x5ec6f3[_0xe94c('0x21')]();})[_0xe94c('0x22')](function(){_0x53b5cf[_0xe94c('0x15')](0xcc)[_0xe94c('0x16')]();})[_0xe94c('0x41')](handleError(_0x53b5cf,null));}; \ No newline at end of file diff --git a/server/api/squareRecording/squareRecording.model.js b/server/api/squareRecording/squareRecording.model.js new file mode 100644 index 0000000..08dfc47 --- /dev/null +++ b/server/api/squareRecording/squareRecording.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe3da=['util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./squareRecording.attributes','exports','define','SquareRecording','lodash'];(function(_0x46d0c9,_0x526bfa){var _0x174506=function(_0x654bc6){while(--_0x654bc6){_0x46d0c9['push'](_0x46d0c9['shift']());}};_0x174506(++_0x526bfa);}(_0xe3da,0x1cd));var _0xae3d=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xe3da[_0x2641f9];return _0x585741;};'use strict';var _=require(_0xae3d('0x0'));var util=require(_0xae3d('0x1'));var logger=require(_0xae3d('0x2'))(_0xae3d('0x3'));var moment=require(_0xae3d('0x4'));var BPromise=require(_0xae3d('0x5'));var rp=require(_0xae3d('0x6'));var fs=require('fs');var path=require(_0xae3d('0x7'));var rimraf=require(_0xae3d('0x8'));var config=require(_0xae3d('0x9'));var attributes=require(_0xae3d('0xa'));module[_0xae3d('0xb')]=function(_0xa9a1a,_0xa54808){return _0xa9a1a[_0xae3d('0xc')](_0xae3d('0xd'),attributes,{'tableName':'square_recordings','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/squareRecording/squareRecording.rpc.js b/server/api/squareRecording/squareRecording.rpc.js new file mode 100644 index 0000000..260ec5e --- /dev/null +++ b/server/api/squareRecording/squareRecording.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9934=['stringify','error','code','message','CreateSquareRecording','SquareRecording','create','body','options','raw','then','catch','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s'];(function(_0x1d1779,_0x284147){var _0x2377e9=function(_0x299f6f){while(--_0x299f6f){_0x1d1779['push'](_0x1d1779['shift']());}};_0x2377e9(++_0x284147);}(_0x9934,0x7c));var _0x4993=function(_0x58a4ac,_0x43fd42){_0x58a4ac=_0x58a4ac-0x0;var _0x545810=_0x9934[_0x58a4ac];return _0x545810;};'use strict';var _=require('lodash');var util=require(_0x4993('0x0'));var moment=require('moment');var BPromise=require(_0x4993('0x1'));var rs=require(_0x4993('0x2'));var fs=require('fs');var Redis=require(_0x4993('0x3'));var db=require(_0x4993('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x4993('0x5'))(_0x4993('0x6'));var config=require(_0x4993('0x7'));var jayson=require(_0x4993('0x8'));var client=jayson[_0x4993('0x9')][_0x4993('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x484c87,_0x4afbb7,_0x31354d){return new BPromise(function(_0x1171aa,_0x5125dc){return client['request'](_0x484c87,_0x31354d)['then'](function(_0x390beb){logger[_0x4993('0xb')](_0x4993('0xc'),_0x4afbb7,_0x4993('0xd'));logger[_0x4993('0xe')](_0x4993('0xf'),_0x4afbb7,'request\x20sent',JSON[_0x4993('0x10')](_0x390beb));if(_0x390beb[_0x4993('0x11')]){if(_0x390beb[_0x4993('0x11')][_0x4993('0x12')]===0x1f4){logger['error'](_0x4993('0xc'),_0x4afbb7,_0x390beb[_0x4993('0x11')][_0x4993('0x13')]);return _0x5125dc(_0x390beb['error'][_0x4993('0x13')]);}logger[_0x4993('0x11')]('SquareRecording,\x20%s,\x20%s',_0x4afbb7,_0x390beb[_0x4993('0x11')][_0x4993('0x13')]);return _0x1171aa(_0x390beb[_0x4993('0x11')][_0x4993('0x13')]);}else{logger[_0x4993('0xb')](_0x4993('0xc'),_0x4afbb7,_0x4993('0xd'));_0x1171aa(_0x390beb['result'][_0x4993('0x13')]);}})['catch'](function(_0x4b4a27){logger[_0x4993('0x11')](_0x4993('0xc'),_0x4afbb7,_0x4b4a27);_0x5125dc(_0x4b4a27);});});}exports[_0x4993('0x14')]=function(_0x276282){var _0x57eefd=this;return new Promise(function(_0x5d8d07,_0x4c0172){return db[_0x4993('0x15')][_0x4993('0x16')](_0x276282[_0x4993('0x17')],{'raw':_0x276282[_0x4993('0x18')]?_0x276282[_0x4993('0x18')][_0x4993('0x19')]===undefined?!![]:![]:!![]})[_0x4993('0x1a')](function(_0x49b97a){logger[_0x4993('0xb')](_0x4993('0x14'),_0x276282);logger[_0x4993('0xe')]('CreateSquareRecording',_0x276282,JSON['stringify'](_0x49b97a));_0x5d8d07(_0x49b97a);})[_0x4993('0x1b')](function(_0x498490){logger[_0x4993('0x11')](_0x4993('0x14'),_0x498490[_0x4993('0x13')],_0x276282);_0x4c0172(_0x57eefd[_0x4993('0x11')](0x1f4,_0x498490[_0x4993('0x13')]));});});}; \ No newline at end of file diff --git a/server/api/squareReport/index.js b/server/api/squareReport/index.js new file mode 100644 index 0000000..6a98abe --- /dev/null +++ b/server/api/squareReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['isAuthenticated','create','put','/:id','destroy','exports','multer','util','path','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./squareReport.controller','get','index','/describe','show','post'];(function(_0x879e31,_0x139d02){var _0x3467e8=function(_0x544fc6){while(--_0x544fc6){_0x879e31['push'](_0x879e31['shift']());}};_0x3467e8(++_0x139d02);}(_0xa9e0,0x123));var _0x0a9e=function(_0x433a86,_0x175b5c){_0x433a86=_0x433a86-0x0;var _0x23000c=_0xa9e0[_0x433a86];return _0x23000c;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['describe']);router[_0x0a9e('0x8')]('/:id',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);router[_0x0a9e('0xc')]('/',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0xf')](_0x0a9e('0x10'),auth['isAuthenticated'](),controller['update']);router['delete']('/:id',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x11')]);module[_0x0a9e('0x12')]=router; \ No newline at end of file diff --git a/server/api/squareReport/squareReport.attributes.js b/server/api/squareReport/squareReport.attributes.js new file mode 100644 index 0000000..9012e1e --- /dev/null +++ b/server/api/squareReport/squareReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x633c=['BOOLEAN','sequelize','STRING','DATE'];(function(_0x2b78e5,_0x3126f8){var _0xa8d52d=function(_0x51fd7f){while(--_0x51fd7f){_0x2b78e5['push'](_0x2b78e5['shift']());}};_0xa8d52d(++_0x3126f8);}(_0x633c,0x1c5));var _0xc633=function(_0x21839e,_0x22f8ed){_0x21839e=_0x21839e-0x0;var _0x5cf6ba=_0x633c[_0x21839e];return _0x5cf6ba;};'use strict';var Sequelize=require(_0xc633('0x0'));module['exports']={'network':{'type':Sequelize['STRING']},'network_script':{'type':Sequelize[_0xc633('0x1')]},'request':{'type':Sequelize[_0xc633('0x1')]},'channel':{'type':Sequelize['STRING']},'language':{'type':Sequelize[_0xc633('0x1')]},'type':{'type':Sequelize['STRING']},'uniqueid':{'type':Sequelize[_0xc633('0x1')]},'version':{'type':Sequelize[_0xc633('0x1')]},'callerid':{'type':Sequelize[_0xc633('0x1')]},'calleridname':{'type':Sequelize[_0xc633('0x1')]},'callingpres':{'type':Sequelize[_0xc633('0x1')]},'callingani2':{'type':Sequelize[_0xc633('0x1')]},'callington':{'type':Sequelize[_0xc633('0x1')]},'callingtns':{'type':Sequelize[_0xc633('0x1')]},'dnid':{'type':Sequelize[_0xc633('0x1')]},'rdnis':{'type':Sequelize[_0xc633('0x1')]},'context':{'type':Sequelize[_0xc633('0x1')]},'extension':{'type':Sequelize['STRING']},'priority':{'type':Sequelize['STRING']},'enhanced':{'type':Sequelize[_0xc633('0x1')]},'accountcode':{'type':Sequelize[_0xc633('0x1')]},'threadid':{'type':Sequelize[_0xc633('0x1')]},'project_name':{'type':Sequelize[_0xc633('0x1')]},'joinAt':{'type':Sequelize[_0xc633('0x2')]},'leaveAt':{'type':Sequelize[_0xc633('0x2')]},'bot':{'type':Sequelize[_0xc633('0x3')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/squareReport/squareReport.controller.js b/server/api/squareReport/squareReport.controller.js new file mode 100644 index 0000000..a842d18 --- /dev/null +++ b/server/api/squareReport/squareReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x54aa=['path','sox','ejs','fs-extra','squel','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','error','stack','name','map','SquareReport','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','describe','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x54aa,0x1c1));var _0xa54a=function(_0x12c007,_0xe2c490){_0x12c007=_0x12c007-0x0;var _0x5bc14b=_0x54aa[_0x12c007];return _0x5bc14b;};'use strict';var emlformat=require(_0xa54a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa54a('0x1'));var jsonpatch=require(_0xa54a('0x2'));var rp=require(_0xa54a('0x3'));var moment=require(_0xa54a('0x4'));var BPromise=require(_0xa54a('0x5'));var Mustache=require(_0xa54a('0x6'));var util=require('util');var path=require(_0xa54a('0x7'));var sox=require(_0xa54a('0x8'));var csv=require('to-csv');var ejs=require(_0xa54a('0x9'));var fs=require('fs');var fs_extra=require(_0xa54a('0xa'));var _=require('lodash');var squel=require(_0xa54a('0xb'));var crypto=require('crypto');var jsforce=require(_0xa54a('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xa54a('0xd'));var querystring=require(_0xa54a('0xe'));var Papa=require(_0xa54a('0xf'));var Redis=require(_0xa54a('0x10'));var authService=require(_0xa54a('0x11'));var qs=require(_0xa54a('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa54a('0x13'));var logger=require(_0xa54a('0x14'))('api');var utils=require(_0xa54a('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xa54a('0x16'));var db=require(_0xa54a('0x17'))['db'];function respondWithStatusCode(_0x2f7cf2,_0x4c9cca){_0x4c9cca=_0x4c9cca||0xcc;return function(_0x294d62){if(_0x294d62){return _0x2f7cf2['sendStatus'](_0x4c9cca);}return _0x2f7cf2[_0xa54a('0x18')](_0x4c9cca)['end']();};}function respondWithResult(_0x1f8b0e,_0x43e94f){_0x43e94f=_0x43e94f||0xc8;return function(_0x4d1da9){if(_0x4d1da9){return _0x1f8b0e[_0xa54a('0x18')](_0x43e94f)[_0xa54a('0x19')](_0x4d1da9);}};}function respondWithFilteredResult(_0x352268,_0x5580c8){return function(_0x2212bc){if(_0x2212bc){var _0x503526=typeof _0x5580c8['offset']===_0xa54a('0x1a')&&typeof _0x5580c8[_0xa54a('0x1b')]===_0xa54a('0x1a');var _0xe5e79b=_0x2212bc[_0xa54a('0x1c')];var _0x485885=_0x503526?0x0:_0x5580c8[_0xa54a('0x1d')];var _0x3d993f=_0x503526?_0x2212bc[_0xa54a('0x1c')]:_0x5580c8[_0xa54a('0x1d')]+_0x5580c8[_0xa54a('0x1b')];var _0x189b32;if(_0x3d993f>=_0xe5e79b){_0x3d993f=_0xe5e79b;_0x189b32=0xc8;}else{_0x189b32=0xce;}_0x352268[_0xa54a('0x18')](_0x189b32);return _0x352268[_0xa54a('0x1e')](_0xa54a('0x1f'),_0x485885+'-'+_0x3d993f+'/'+_0xe5e79b)['json'](_0x2212bc);}return null;};}function patchUpdates(_0x51b9b7){return function(_0x3dd310){try{jsonpatch[_0xa54a('0x20')](_0x3dd310,_0x51b9b7,!![]);}catch(_0x426a5a){return BPromise[_0xa54a('0x21')](_0x426a5a);}return _0x3dd310[_0xa54a('0x22')]();};}function saveUpdates(_0x455c74,_0x2ae94b){return function(_0x13ed15){if(_0x13ed15){return _0x13ed15[_0xa54a('0x23')](_0x455c74)[_0xa54a('0x24')](function(_0x4a9da6){return _0x4a9da6;});}return null;};}function removeEntity(_0x33e794,_0x1ebd62){return function(_0x1ef230){if(_0x1ef230){return _0x1ef230[_0xa54a('0x25')]()[_0xa54a('0x24')](function(){_0x33e794[_0xa54a('0x18')](0xcc)[_0xa54a('0x26')]();});}};}function handleEntityNotFound(_0x5b01f2,_0x3c8279){return function(_0x314e2d){if(!_0x314e2d){_0x5b01f2[_0xa54a('0x27')](0x194);}return _0x314e2d;};}function handleError(_0x109469,_0x395053){_0x395053=_0x395053||0x1f4;return function(_0x3d59e0){logger[_0xa54a('0x28')](_0x3d59e0[_0xa54a('0x29')]);if(_0x3d59e0[_0xa54a('0x2a')]){delete _0x3d59e0[_0xa54a('0x2a')];}_0x109469[_0xa54a('0x18')](_0x395053)['send'](_0x3d59e0);};}exports['index']=function(_0x6b0ba5,_0x295fd8){var _0x17aa6b={},_0x52376f={},_0x1369df={'count':0x0,'rows':[]};var _0x5958d4=_[_0xa54a('0x2b')](db[_0xa54a('0x2c')][_0xa54a('0x2d')],function(_0x4476ec){return{'name':_0x4476ec['fieldName'],'type':_0x4476ec[_0xa54a('0x2e')][_0xa54a('0x2f')]};});_0x52376f[_0xa54a('0x30')]=_[_0xa54a('0x2b')](_0x5958d4,_0xa54a('0x2a'));_0x52376f[_0xa54a('0x31')]=_[_0xa54a('0x32')](_0x6b0ba5[_0xa54a('0x31')]);_0x52376f[_0xa54a('0x33')]=_[_0xa54a('0x34')](_0x52376f[_0xa54a('0x30')],_0x52376f[_0xa54a('0x31')]);_0x17aa6b[_0xa54a('0x35')]=_[_0xa54a('0x34')](_0x52376f[_0xa54a('0x30')],qs[_0xa54a('0x36')](_0x6b0ba5[_0xa54a('0x31')][_0xa54a('0x36')]));_0x17aa6b['attributes']=_0x17aa6b[_0xa54a('0x35')][_0xa54a('0x37')]?_0x17aa6b[_0xa54a('0x35')]:_0x52376f['model'];if(!_0x6b0ba5[_0xa54a('0x31')]['hasOwnProperty'](_0xa54a('0x38'))){_0x17aa6b[_0xa54a('0x1b')]=qs['limit'](_0x6b0ba5[_0xa54a('0x31')][_0xa54a('0x1b')]);_0x17aa6b[_0xa54a('0x1d')]=qs[_0xa54a('0x1d')](_0x6b0ba5[_0xa54a('0x31')]['offset']);}_0x17aa6b[_0xa54a('0x39')]=qs[_0xa54a('0x3a')](_0x6b0ba5[_0xa54a('0x31')]['sort']);_0x17aa6b['where']=qs[_0xa54a('0x33')](_[_0xa54a('0x3b')](_0x6b0ba5[_0xa54a('0x31')],_0x52376f[_0xa54a('0x33')]),_0x5958d4);if(_0x6b0ba5[_0xa54a('0x31')]['filter']){_0x17aa6b[_0xa54a('0x3c')]=_[_0xa54a('0x3d')](_0x17aa6b[_0xa54a('0x3c')],{'$or':_[_0xa54a('0x2b')](_0x5958d4,function(_0x512d1d){if(_0x512d1d[_0xa54a('0x2e')]!==_0xa54a('0x3e')){var _0x287604={};_0x287604[_0x512d1d[_0xa54a('0x2a')]]={'$like':'%'+_0x6b0ba5['query'][_0xa54a('0x3f')]+'%'};return _0x287604;}})});}_0x17aa6b=_[_0xa54a('0x3d')]({},_0x17aa6b,_0x6b0ba5[_0xa54a('0x40')]);var _0x3f542f={'where':_0x17aa6b[_0xa54a('0x3c')]};return db[_0xa54a('0x2c')]['count'](_0x3f542f)['then'](function(_0x29af18){_0x1369df['count']=_0x29af18;if(_0x6b0ba5[_0xa54a('0x31')][_0xa54a('0x41')]){_0x17aa6b[_0xa54a('0x42')]=[{'all':!![]}];}return db[_0xa54a('0x2c')][_0xa54a('0x43')](_0x17aa6b);})['then'](function(_0x577a48){_0x1369df[_0xa54a('0x44')]=_0x577a48;return _0x1369df;})[_0xa54a('0x24')](respondWithFilteredResult(_0x295fd8,_0x17aa6b))['catch'](handleError(_0x295fd8,null));};exports[_0xa54a('0x45')]=function(_0x21181b,_0x1091da){var _0x317015={'raw':!![],'where':{'id':_0x21181b[_0xa54a('0x46')]['id']}},_0x277936={};_0x277936[_0xa54a('0x30')]=_[_0xa54a('0x32')](db[_0xa54a('0x2c')][_0xa54a('0x2d')]);_0x277936[_0xa54a('0x31')]=_[_0xa54a('0x32')](_0x21181b[_0xa54a('0x31')]);_0x277936[_0xa54a('0x33')]=_[_0xa54a('0x34')](_0x277936['model'],_0x277936[_0xa54a('0x31')]);_0x317015[_0xa54a('0x35')]=_[_0xa54a('0x34')](_0x277936[_0xa54a('0x30')],qs[_0xa54a('0x36')](_0x21181b[_0xa54a('0x31')][_0xa54a('0x36')]));_0x317015[_0xa54a('0x35')]=_0x317015['attributes'][_0xa54a('0x37')]?_0x317015['attributes']:_0x277936[_0xa54a('0x30')];if(_0x21181b[_0xa54a('0x31')][_0xa54a('0x41')]){_0x317015[_0xa54a('0x42')]=[{'all':!![]}];}_0x317015=_[_0xa54a('0x3d')]({},_0x317015,_0x21181b['options']);return db[_0xa54a('0x2c')][_0xa54a('0x47')](_0x317015)['then'](handleEntityNotFound(_0x1091da,null))[_0xa54a('0x24')](respondWithResult(_0x1091da,null))[_0xa54a('0x48')](handleError(_0x1091da,null));};exports[_0xa54a('0x49')]=function(_0x749d2b,_0xca62a6){return db[_0xa54a('0x2c')][_0xa54a('0x49')](_0x749d2b[_0xa54a('0x4a')],{})[_0xa54a('0x24')](respondWithResult(_0xca62a6,0xc9))[_0xa54a('0x48')](handleError(_0xca62a6,null));};exports['update']=function(_0x2a05b8,_0x4baa75){if(_0x2a05b8[_0xa54a('0x4a')]['id']){delete _0x2a05b8['body']['id'];}return db[_0xa54a('0x2c')][_0xa54a('0x47')]({'where':{'id':_0x2a05b8[_0xa54a('0x46')]['id']}})['then'](handleEntityNotFound(_0x4baa75,null))[_0xa54a('0x24')](saveUpdates(_0x2a05b8[_0xa54a('0x4a')],null))[_0xa54a('0x24')](respondWithResult(_0x4baa75,null))[_0xa54a('0x48')](handleError(_0x4baa75,null));};exports[_0xa54a('0x25')]=function(_0x526f27,_0x4f2159){return db[_0xa54a('0x2c')][_0xa54a('0x47')]({'where':{'id':_0x526f27[_0xa54a('0x46')]['id']}})[_0xa54a('0x24')](handleEntityNotFound(_0x4f2159,null))[_0xa54a('0x24')](removeEntity(_0x4f2159,null))['catch'](handleError(_0x4f2159,null));};exports[_0xa54a('0x4b')]=function(_0x49e963,_0x122b91){return db['SquareReport'][_0xa54a('0x4b')]()['then'](respondWithResult(_0x122b91,null))[_0xa54a('0x48')](handleError(_0x122b91,null));}; \ No newline at end of file diff --git a/server/api/squareReport/squareReport.model.js b/server/api/squareReport/squareReport.model.js new file mode 100644 index 0000000..5110438 --- /dev/null +++ b/server/api/squareReport/squareReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x81f5=['moment','request-promise','path','./squareReport.attributes','define','SquareReport','report_square','uid_pname','uniqueid','project_name','leaveAt','lodash','util','../../config/logger','api'];(function(_0xc7d42d,_0x27afe7){var _0x1f5389=function(_0x8f0a0a){while(--_0x8f0a0a){_0xc7d42d['push'](_0xc7d42d['shift']());}};_0x1f5389(++_0x27afe7);}(_0x81f5,0xec));var _0x581f=function(_0x49ca18,_0x5e6d05){_0x49ca18=_0x49ca18-0x0;var _0x145d54=_0x81f5[_0x49ca18];return _0x145d54;};'use strict';var _=require(_0x581f('0x0'));var util=require(_0x581f('0x1'));var logger=require(_0x581f('0x2'))(_0x581f('0x3'));var moment=require(_0x581f('0x4'));var BPromise=require('bluebird');var rp=require(_0x581f('0x5'));var fs=require('fs');var path=require(_0x581f('0x6'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x581f('0x7'));module['exports']=function(_0x4861ba,_0x4bdd78){return _0x4861ba[_0x581f('0x8')](_0x581f('0x9'),attributes,{'tableName':_0x581f('0xa'),'paranoid':![],'indexes':[{'name':_0x581f('0xb'),'fields':[_0x581f('0xc'),_0x581f('0xd')]},{'name':_0x581f('0xe'),'fields':[_0x581f('0xe')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/squareReport/squareReport.rpc.js b/server/api/squareReport/squareReport.rpc.js new file mode 100644 index 0000000..afde7af --- /dev/null +++ b/server/api/squareReport/squareReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1b27=['moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','request','info','SquareReport,\x20%s,\x20%s','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','CreateSquareReport','SquareReport','create','body','options','raw','then','catch','UpdateSquareReport','where','limit','lodash','util'];(function(_0x162f3d,_0x431654){var _0x2f5437=function(_0x37483f){while(--_0x37483f){_0x162f3d['push'](_0x162f3d['shift']());}};_0x2f5437(++_0x431654);}(_0x1b27,0x14e));var _0x71b2=function(_0x2a9461,_0x25ecf8){_0x2a9461=_0x2a9461-0x0;var _0x15b1f0=_0x1b27[_0x2a9461];return _0x15b1f0;};'use strict';var _=require(_0x71b2('0x0'));var util=require(_0x71b2('0x1'));var moment=require(_0x71b2('0x2'));var BPromise=require(_0x71b2('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x71b2('0x4'));var db=require(_0x71b2('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x71b2('0x6'));var config=require(_0x71b2('0x7'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x22e912,_0xa9dac2,_0x100945){return new BPromise(function(_0xc4de6b,_0x4dc169){return client[_0x71b2('0x8')](_0x22e912,_0x100945)['then'](function(_0x5a7a07){logger[_0x71b2('0x9')](_0x71b2('0xa'),_0xa9dac2,'request\x20sent');logger[_0x71b2('0xb')](_0x71b2('0xc'),_0xa9dac2,'request\x20sent',JSON[_0x71b2('0xd')](_0x5a7a07));if(_0x5a7a07[_0x71b2('0xe')]){if(_0x5a7a07['error'][_0x71b2('0xf')]===0x1f4){logger[_0x71b2('0xe')]('SquareReport,\x20%s,\x20%s',_0xa9dac2,_0x5a7a07[_0x71b2('0xe')][_0x71b2('0x10')]);return _0x4dc169(_0x5a7a07['error'][_0x71b2('0x10')]);}logger[_0x71b2('0xe')](_0x71b2('0xa'),_0xa9dac2,_0x5a7a07[_0x71b2('0xe')]['message']);return _0xc4de6b(_0x5a7a07['error'][_0x71b2('0x10')]);}else{logger[_0x71b2('0x9')](_0x71b2('0xa'),_0xa9dac2,'request\x20sent');_0xc4de6b(_0x5a7a07['result']['message']);}})['catch'](function(_0x575719){logger[_0x71b2('0xe')](_0x71b2('0xa'),_0xa9dac2,_0x575719);_0x4dc169(_0x575719);});});}exports[_0x71b2('0x11')]=function(_0x3b4bd0){var _0x3e906f=this;return new Promise(function(_0x50dc52,_0x3e2568){return db[_0x71b2('0x12')][_0x71b2('0x13')](_0x3b4bd0[_0x71b2('0x14')],{'raw':_0x3b4bd0[_0x71b2('0x15')]?_0x3b4bd0[_0x71b2('0x15')][_0x71b2('0x16')]===undefined?!![]:![]:!![]})[_0x71b2('0x17')](function(_0x629550){logger[_0x71b2('0x9')](_0x71b2('0x11'),_0x3b4bd0);logger['debug']('CreateSquareReport',_0x3b4bd0,JSON[_0x71b2('0xd')](_0x629550));_0x50dc52(_0x629550);})[_0x71b2('0x18')](function(_0x5c971d){logger['error']('CreateSquareReport',_0x5c971d[_0x71b2('0x10')],_0x3b4bd0);_0x3e2568(_0x3e906f[_0x71b2('0xe')](0x1f4,_0x5c971d[_0x71b2('0x10')]));});});};exports[_0x71b2('0x19')]=function(_0x20efb3){var _0x12f56f=this;return new Promise(function(_0x26de16,_0x530cff){return db['SquareReport']['update'](_0x20efb3[_0x71b2('0x14')],{'raw':_0x20efb3[_0x71b2('0x15')]?_0x20efb3[_0x71b2('0x15')][_0x71b2('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x20efb3[_0x71b2('0x15')]?_0x20efb3[_0x71b2('0x15')][_0x71b2('0x1a')]||null:null,'attributes':_0x20efb3[_0x71b2('0x15')]?_0x20efb3[_0x71b2('0x15')]['attributes']||null:null,'limit':_0x20efb3['options']?_0x20efb3[_0x71b2('0x15')][_0x71b2('0x1b')]||null:null})[_0x71b2('0x17')](function(_0x32f3da){logger[_0x71b2('0x9')](_0x71b2('0x19'),_0x20efb3);logger[_0x71b2('0xb')](_0x71b2('0x19'),_0x20efb3,JSON[_0x71b2('0xd')](_0x32f3da));_0x26de16(_0x32f3da);})[_0x71b2('0x18')](function(_0x159763){logger[_0x71b2('0xe')](_0x71b2('0x19'),_0x159763[_0x71b2('0x10')],_0x20efb3);_0x530cff(_0x12f56f[_0x71b2('0xe')](0x1f4,_0x159763[_0x71b2('0x10')]));});});}; \ No newline at end of file diff --git a/server/api/squareReportDetail/index.js b/server/api/squareReportDetail/index.js new file mode 100644 index 0000000..a9bb203 --- /dev/null +++ b/server/api/squareReportDetail/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x66d3=['path','express','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./squareReportDetail.controller','get','index','/describe','isAuthenticated','describe','/:id','show','post','create','update','delete','destroy','exports','multer','util'];(function(_0x4e8c42,_0x36dc88){var _0x22952f=function(_0x31a013){while(--_0x31a013){_0x4e8c42['push'](_0x4e8c42['shift']());}};_0x22952f(++_0x36dc88);}(_0x66d3,0x106));var _0x366d=function(_0x43d31b,_0x1f6c4c){_0x43d31b=_0x43d31b-0x0;var _0x3b7e15=_0x66d3[_0x43d31b];return _0x3b7e15;};'use strict';var multer=require(_0x366d('0x0'));var util=require(_0x366d('0x1'));var path=require(_0x366d('0x2'));var timeout=require('connect-timeout');var express=require(_0x366d('0x3'));var router=express[_0x366d('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x366d('0x5'));var interaction=require(_0x366d('0x6'));var config=require(_0x366d('0x7'));var controller=require(_0x366d('0x8'));router[_0x366d('0x9')]('/',auth['isAuthenticated'](),controller[_0x366d('0xa')]);router[_0x366d('0x9')](_0x366d('0xb'),auth[_0x366d('0xc')](),controller[_0x366d('0xd')]);router[_0x366d('0x9')](_0x366d('0xe'),auth[_0x366d('0xc')](),controller[_0x366d('0xf')]);router[_0x366d('0x10')]('/',auth[_0x366d('0xc')](),controller[_0x366d('0x11')]);router['put']('/:id',auth[_0x366d('0xc')](),controller[_0x366d('0x12')]);router[_0x366d('0x13')](_0x366d('0xe'),auth[_0x366d('0xc')](),controller[_0x366d('0x14')]);module[_0x366d('0x15')]=router; \ No newline at end of file diff --git a/server/api/squareReportDetail/squareReportDetail.attributes.js b/server/api/squareReportDetail/squareReportDetail.attributes.js new file mode 100644 index 0000000..1a08011 --- /dev/null +++ b/server/api/squareReportDetail/squareReportDetail.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4b23=['STRING','TEXT','sequelize'];(function(_0x166d93,_0x301f09){var _0xba708=function(_0x349bf7){while(--_0x349bf7){_0x166d93['push'](_0x166d93['shift']());}};_0xba708(++_0x301f09);}(_0x4b23,0xb6));var _0x34b2=function(_0x2d61b2,_0x142947){_0x2d61b2=_0x2d61b2-0x0;var _0x12df89=_0x4b23[_0x2d61b2];return _0x12df89;};'use strict';var Sequelize=require(_0x34b2('0x0'));module['exports']={'uniqueid':{'type':Sequelize[_0x34b2('0x1')]},'node':{'type':Sequelize[_0x34b2('0x1')]},'application':{'type':Sequelize[_0x34b2('0x1')]},'data':{'type':Sequelize[_0x34b2('0x2')]},'project_name':{'type':Sequelize[_0x34b2('0x1')]},'callerid':{'type':Sequelize[_0x34b2('0x1')]}}; \ No newline at end of file diff --git a/server/api/squareReportDetail/squareReportDetail.controller.js b/server/api/squareReportDetail/squareReportDetail.controller.js new file mode 100644 index 0000000..6992346 --- /dev/null +++ b/server/api/squareReportDetail/squareReportDetail.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x52de=['limit','count','offset','set','Content-Range','apply','save','destroy','error','stack','name','send','map','SquareDetailsReport','rawAttributes','fieldName','type','model','keys','intersection','attributes','fields','query','length','hasOwnProperty','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','then','includeAll','include','findAll','rows','catch','show','params','find','create','body','update','describe','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','undefined'];(function(_0x51b14d,_0x2d7ac5){var _0x3af577=function(_0x4ef060){while(--_0x4ef060){_0x51b14d['push'](_0x51b14d['shift']());}};_0x3af577(++_0x2d7ac5);}(_0x52de,0x119));var _0xe52d=function(_0x4565bf,_0x5ad9d6){_0x4565bf=_0x4565bf-0x0;var _0x5610ba=_0x52de[_0x4565bf];return _0x5610ba;};'use strict';var emlformat=require(_0xe52d('0x0'));var rimraf=require(_0xe52d('0x1'));var zipdir=require(_0xe52d('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe52d('0x3'));var moment=require(_0xe52d('0x4'));var BPromise=require(_0xe52d('0x5'));var Mustache=require(_0xe52d('0x6'));var util=require('util');var path=require(_0xe52d('0x7'));var sox=require(_0xe52d('0x8'));var csv=require('to-csv');var ejs=require(_0xe52d('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xe52d('0xa'));var squel=require(_0xe52d('0xb'));var crypto=require(_0xe52d('0xc'));var jsforce=require(_0xe52d('0xd'));var deskjs=require(_0xe52d('0xe'));var toCsv=require(_0xe52d('0xf'));var querystring=require(_0xe52d('0x10'));var Papa=require(_0xe52d('0x11'));var Redis=require('ioredis');var authService=require(_0xe52d('0x12'));var qs=require(_0xe52d('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe52d('0x14'));var logger=require(_0xe52d('0x15'))(_0xe52d('0x16'));var utils=require(_0xe52d('0x17'));var config=require(_0xe52d('0x18'));var licenseUtil=require(_0xe52d('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x49a7f0,_0x107688){_0x107688=_0x107688||0xcc;return function(_0x192de5){if(_0x192de5){return _0x49a7f0[_0xe52d('0x1a')](_0x107688);}return _0x49a7f0[_0xe52d('0x1b')](_0x107688)[_0xe52d('0x1c')]();};}function respondWithResult(_0x2468ea,_0x407cd4){_0x407cd4=_0x407cd4||0xc8;return function(_0x23020b){if(_0x23020b){return _0x2468ea[_0xe52d('0x1b')](_0x407cd4)[_0xe52d('0x1d')](_0x23020b);}};}function respondWithFilteredResult(_0x4c8a6c,_0x12c009){return function(_0x19346d){if(_0x19346d){var _0x2148b1=typeof _0x12c009['offset']===_0xe52d('0x1e')&&typeof _0x12c009[_0xe52d('0x1f')]===_0xe52d('0x1e');var _0x9a12b7=_0x19346d[_0xe52d('0x20')];var _0x6f28d9=_0x2148b1?0x0:_0x12c009[_0xe52d('0x21')];var _0x3c7d7e=_0x2148b1?_0x19346d[_0xe52d('0x20')]:_0x12c009[_0xe52d('0x21')]+_0x12c009[_0xe52d('0x1f')];var _0x50cc43;if(_0x3c7d7e>=_0x9a12b7){_0x3c7d7e=_0x9a12b7;_0x50cc43=0xc8;}else{_0x50cc43=0xce;}_0x4c8a6c[_0xe52d('0x1b')](_0x50cc43);return _0x4c8a6c[_0xe52d('0x22')](_0xe52d('0x23'),_0x6f28d9+'-'+_0x3c7d7e+'/'+_0x9a12b7)[_0xe52d('0x1d')](_0x19346d);}return null;};}function patchUpdates(_0x15e278){return function(_0x33a816){try{jsonpatch[_0xe52d('0x24')](_0x33a816,_0x15e278,!![]);}catch(_0x12560c){return BPromise['reject'](_0x12560c);}return _0x33a816[_0xe52d('0x25')]();};}function saveUpdates(_0x1aef7c,_0x4e581d){return function(_0x257a18){if(_0x257a18){return _0x257a18['update'](_0x1aef7c)['then'](function(_0xc67ef7){return _0xc67ef7;});}return null;};}function removeEntity(_0x28752a,_0x123097){return function(_0x5c5625){if(_0x5c5625){return _0x5c5625[_0xe52d('0x26')]()['then'](function(){_0x28752a[_0xe52d('0x1b')](0xcc)[_0xe52d('0x1c')]();});}};}function handleEntityNotFound(_0x53fbac,_0x1ab7f0){return function(_0x3636dc){if(!_0x3636dc){_0x53fbac[_0xe52d('0x1a')](0x194);}return _0x3636dc;};}function handleError(_0x448ea4,_0x3d24cc){_0x3d24cc=_0x3d24cc||0x1f4;return function(_0x15d356){logger[_0xe52d('0x27')](_0x15d356[_0xe52d('0x28')]);if(_0x15d356['name']){delete _0x15d356[_0xe52d('0x29')];}_0x448ea4[_0xe52d('0x1b')](_0x3d24cc)[_0xe52d('0x2a')](_0x15d356);};}exports['index']=function(_0x3ebffa,_0x3110cd){var _0x705b82={},_0x3329e0={},_0x37a5ec={'count':0x0,'rows':[]};var _0x454573=_[_0xe52d('0x2b')](db[_0xe52d('0x2c')][_0xe52d('0x2d')],function(_0x5e8ee8){return{'name':_0x5e8ee8[_0xe52d('0x2e')],'type':_0x5e8ee8[_0xe52d('0x2f')]['key']};});_0x3329e0[_0xe52d('0x30')]=_['map'](_0x454573,_0xe52d('0x29'));_0x3329e0['query']=_[_0xe52d('0x31')](_0x3ebffa['query']);_0x3329e0['filters']=_[_0xe52d('0x32')](_0x3329e0[_0xe52d('0x30')],_0x3329e0['query']);_0x705b82[_0xe52d('0x33')]=_[_0xe52d('0x32')](_0x3329e0[_0xe52d('0x30')],qs[_0xe52d('0x34')](_0x3ebffa[_0xe52d('0x35')]['fields']));_0x705b82['attributes']=_0x705b82[_0xe52d('0x33')][_0xe52d('0x36')]?_0x705b82[_0xe52d('0x33')]:_0x3329e0[_0xe52d('0x30')];if(!_0x3ebffa['query'][_0xe52d('0x37')]('nolimit')){_0x705b82[_0xe52d('0x1f')]=qs[_0xe52d('0x1f')](_0x3ebffa[_0xe52d('0x35')][_0xe52d('0x1f')]);_0x705b82[_0xe52d('0x21')]=qs[_0xe52d('0x21')](_0x3ebffa['query']['offset']);}_0x705b82[_0xe52d('0x38')]=qs[_0xe52d('0x39')](_0x3ebffa[_0xe52d('0x35')][_0xe52d('0x39')]);_0x705b82[_0xe52d('0x3a')]=qs['filters'](_[_0xe52d('0x3b')](_0x3ebffa[_0xe52d('0x35')],_0x3329e0[_0xe52d('0x3c')]),_0x454573);if(_0x3ebffa['query'][_0xe52d('0x3d')]){_0x705b82[_0xe52d('0x3a')]=_[_0xe52d('0x3e')](_0x705b82[_0xe52d('0x3a')],{'$or':_[_0xe52d('0x2b')](_0x454573,function(_0x784d7f){if(_0x784d7f[_0xe52d('0x2f')]!==_0xe52d('0x3f')){var _0x23842f={};_0x23842f[_0x784d7f['name']]={'$like':'%'+_0x3ebffa[_0xe52d('0x35')][_0xe52d('0x3d')]+'%'};return _0x23842f;}})});}_0x705b82=_[_0xe52d('0x3e')]({},_0x705b82,_0x3ebffa[_0xe52d('0x40')]);var _0x3f2c93={'where':_0x705b82[_0xe52d('0x3a')]};return db[_0xe52d('0x2c')][_0xe52d('0x20')](_0x3f2c93)[_0xe52d('0x41')](function(_0x44ad2e){_0x37a5ec[_0xe52d('0x20')]=_0x44ad2e;if(_0x3ebffa['query'][_0xe52d('0x42')]){_0x705b82[_0xe52d('0x43')]=[{'all':!![]}];}return db['SquareDetailsReport'][_0xe52d('0x44')](_0x705b82);})['then'](function(_0x1ef696){_0x37a5ec[_0xe52d('0x45')]=_0x1ef696;return _0x37a5ec;})[_0xe52d('0x41')](respondWithFilteredResult(_0x3110cd,_0x705b82))[_0xe52d('0x46')](handleError(_0x3110cd,null));};exports[_0xe52d('0x47')]=function(_0x492247,_0x47319a){var _0x344dc8={'raw':!![],'where':{'id':_0x492247[_0xe52d('0x48')]['id']}},_0x44068c={};_0x44068c['model']=_['keys'](db['SquareDetailsReport'][_0xe52d('0x2d')]);_0x44068c[_0xe52d('0x35')]=_[_0xe52d('0x31')](_0x492247[_0xe52d('0x35')]);_0x44068c[_0xe52d('0x3c')]=_[_0xe52d('0x32')](_0x44068c[_0xe52d('0x30')],_0x44068c['query']);_0x344dc8['attributes']=_[_0xe52d('0x32')](_0x44068c[_0xe52d('0x30')],qs[_0xe52d('0x34')](_0x492247['query'][_0xe52d('0x34')]));_0x344dc8[_0xe52d('0x33')]=_0x344dc8[_0xe52d('0x33')][_0xe52d('0x36')]?_0x344dc8[_0xe52d('0x33')]:_0x44068c['model'];if(_0x492247[_0xe52d('0x35')]['includeAll']){_0x344dc8['include']=[{'all':!![]}];}_0x344dc8=_[_0xe52d('0x3e')]({},_0x344dc8,_0x492247[_0xe52d('0x40')]);return db['SquareDetailsReport'][_0xe52d('0x49')](_0x344dc8)[_0xe52d('0x41')](handleEntityNotFound(_0x47319a,null))[_0xe52d('0x41')](respondWithResult(_0x47319a,null))[_0xe52d('0x46')](handleError(_0x47319a,null));};exports[_0xe52d('0x4a')]=function(_0x149321,_0x73a082){return db[_0xe52d('0x2c')][_0xe52d('0x4a')](_0x149321[_0xe52d('0x4b')],{})[_0xe52d('0x41')](respondWithResult(_0x73a082,0xc9))[_0xe52d('0x46')](handleError(_0x73a082,null));};exports[_0xe52d('0x4c')]=function(_0x3b516d,_0x5818df){if(_0x3b516d[_0xe52d('0x4b')]['id']){delete _0x3b516d[_0xe52d('0x4b')]['id'];}return db['SquareDetailsReport']['find']({'where':{'id':_0x3b516d['params']['id']}})[_0xe52d('0x41')](handleEntityNotFound(_0x5818df,null))[_0xe52d('0x41')](saveUpdates(_0x3b516d[_0xe52d('0x4b')],null))[_0xe52d('0x41')](respondWithResult(_0x5818df,null))[_0xe52d('0x46')](handleError(_0x5818df,null));};exports[_0xe52d('0x26')]=function(_0x65601e,_0x3c2989){return db[_0xe52d('0x2c')][_0xe52d('0x49')]({'where':{'id':_0x65601e[_0xe52d('0x48')]['id']}})[_0xe52d('0x41')](handleEntityNotFound(_0x3c2989,null))['then'](removeEntity(_0x3c2989,null))[_0xe52d('0x46')](handleError(_0x3c2989,null));};exports[_0xe52d('0x4d')]=function(_0x27f04a,_0xd07cbc){return db[_0xe52d('0x2c')][_0xe52d('0x4d')]()['then'](respondWithResult(_0xd07cbc,null))[_0xe52d('0x46')](handleError(_0xd07cbc,null));}; \ No newline at end of file diff --git a/server/api/squareReportDetail/squareReportDetail.model.js b/server/api/squareReportDetail/squareReportDetail.model.js new file mode 100644 index 0000000..94e1071 --- /dev/null +++ b/server/api/squareReportDetail/squareReportDetail.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xff9d=['../../config/logger','api','moment','bluebird','request-promise','path','../../config/environment','./squareReportDetail.attributes','exports','SquareDetailsReport','report_square_details','lodash','util'];(function(_0x100f34,_0x15422f){var _0x422458=function(_0x2596cf){while(--_0x2596cf){_0x100f34['push'](_0x100f34['shift']());}};_0x422458(++_0x15422f);}(_0xff9d,0x11c));var _0xdff9=function(_0x419fff,_0x2827cd){_0x419fff=_0x419fff-0x0;var _0x57bb43=_0xff9d[_0x419fff];return _0x57bb43;};'use strict';var _=require(_0xdff9('0x0'));var util=require(_0xdff9('0x1'));var logger=require(_0xdff9('0x2'))(_0xdff9('0x3'));var moment=require(_0xdff9('0x4'));var BPromise=require(_0xdff9('0x5'));var rp=require(_0xdff9('0x6'));var fs=require('fs');var path=require(_0xdff9('0x7'));var rimraf=require('rimraf');var config=require(_0xdff9('0x8'));var attributes=require(_0xdff9('0x9'));module[_0xdff9('0xa')]=function(_0x400d59,_0x39f13b){return _0x400d59['define'](_0xdff9('0xb'),attributes,{'tableName':_0xdff9('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/squareReportDetail/squareReportDetail.rpc.js b/server/api/squareReportDetail/squareReportDetail.rpc.js new file mode 100644 index 0000000..9b09152 --- /dev/null +++ b/server/api/squareReportDetail/squareReportDetail.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfef3=['../../config/environment','jayson/promise','http','request','then','info','SquareDetailsReport,\x20%s,\x20%s','request\x20sent','debug','SquareDetailsReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CreateSquareDetailsReport','SquareDetailsReport','body','options','raw','catch','lodash','moment','randomstring','ioredis','../../config/utils','../../config/logger'];(function(_0x4246bd,_0xdab764){var _0x20e0b7=function(_0x402785){while(--_0x402785){_0x4246bd['push'](_0x4246bd['shift']());}};_0x20e0b7(++_0xdab764);}(_0xfef3,0x118));var _0x3fef=function(_0x3aa48e,_0x22eb8d){_0x3aa48e=_0x3aa48e-0x0;var _0x26f857=_0xfef3[_0x3aa48e];return _0x26f857;};'use strict';var _=require(_0x3fef('0x0'));var util=require('util');var moment=require(_0x3fef('0x1'));var BPromise=require('bluebird');var rs=require(_0x3fef('0x2'));var fs=require('fs');var Redis=require(_0x3fef('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x3fef('0x4'));var logger=require(_0x3fef('0x5'))('rpc');var config=require(_0x3fef('0x6'));var jayson=require(_0x3fef('0x7'));var client=jayson['client'][_0x3fef('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5f5b72,_0x800850,_0x33e00a){return new BPromise(function(_0x1fffc5,_0x41960c){return client[_0x3fef('0x9')](_0x5f5b72,_0x33e00a)[_0x3fef('0xa')](function(_0x31c30f){logger[_0x3fef('0xb')](_0x3fef('0xc'),_0x800850,_0x3fef('0xd'));logger[_0x3fef('0xe')](_0x3fef('0xf'),_0x800850,'request\x20sent',JSON[_0x3fef('0x10')](_0x31c30f));if(_0x31c30f[_0x3fef('0x11')]){if(_0x31c30f[_0x3fef('0x11')]['code']===0x1f4){logger[_0x3fef('0x11')]('SquareDetailsReport,\x20%s,\x20%s',_0x800850,_0x31c30f[_0x3fef('0x11')][_0x3fef('0x12')]);return _0x41960c(_0x31c30f[_0x3fef('0x11')]['message']);}logger[_0x3fef('0x11')]('SquareDetailsReport,\x20%s,\x20%s',_0x800850,_0x31c30f[_0x3fef('0x11')][_0x3fef('0x12')]);return _0x1fffc5(_0x31c30f['error'][_0x3fef('0x12')]);}else{logger[_0x3fef('0xb')](_0x3fef('0xc'),_0x800850,_0x3fef('0xd'));_0x1fffc5(_0x31c30f[_0x3fef('0x13')][_0x3fef('0x12')]);}})['catch'](function(_0x1cbdbb){logger[_0x3fef('0x11')](_0x3fef('0xc'),_0x800850,_0x1cbdbb);_0x41960c(_0x1cbdbb);});});}exports[_0x3fef('0x14')]=function(_0x1613ad){var _0xaa0ae3=this;return new Promise(function(_0x53d993,_0x36669d){return db[_0x3fef('0x15')]['create'](_0x1613ad[_0x3fef('0x16')],{'raw':_0x1613ad[_0x3fef('0x17')]?_0x1613ad[_0x3fef('0x17')][_0x3fef('0x18')]===undefined?!![]:![]:!![]})[_0x3fef('0xa')](function(_0x2b5226){logger[_0x3fef('0xb')](_0x3fef('0x14'),_0x1613ad);logger[_0x3fef('0xe')](_0x3fef('0x14'),_0x1613ad,JSON[_0x3fef('0x10')](_0x2b5226));_0x53d993(_0x2b5226);})[_0x3fef('0x19')](function(_0x2eb578){logger[_0x3fef('0x11')](_0x3fef('0x14'),_0x2eb578['message'],_0x1613ad);_0x36669d(_0xaa0ae3['error'](0x1f4,_0x2eb578['message']));});});}; \ No newline at end of file diff --git a/server/api/system/index.js b/server/api/system/index.js new file mode 100644 index 0000000..505d342 --- /dev/null +++ b/server/api/system/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e44=['index','/process/:pid/kill','exports','express','Router','get','isAuthenticated'];(function(_0x4e349e,_0x92589f){var _0x20abd3=function(_0x29837f){while(--_0x29837f){_0x4e349e['push'](_0x4e349e['shift']());}};_0x20abd3(++_0x92589f);}(_0x3e44,0x6c));var _0x43e4=function(_0x362bed,_0x40d4c3){_0x362bed=_0x362bed-0x0;var _0x197fd6=_0x3e44[_0x362bed];return _0x197fd6;};'use strict';var express=require(_0x43e4('0x0'));var router=express[_0x43e4('0x1')]();var auth=require('../../components/auth/service');var controller=require('./system.controller');router[_0x43e4('0x2')]('/',auth[_0x43e4('0x3')](),controller[_0x43e4('0x4')]);router[_0x43e4('0x2')](_0x43e4('0x5'),auth[_0x43e4('0x3')](),controller['killProcess']);module[_0x43e4('0x6')]=router; \ No newline at end of file diff --git a/server/api/system/system.controller.js b/server/api/system/system.controller.js new file mode 100644 index 0000000..f140a15 --- /dev/null +++ b/server/api/system/system.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdd40=['catch','killProcess','components/import/cm','format','ps\x20-p\x20%s\x20-ww\x20-o\x20args','params','pid','length','indexOf','Process\x20with\x20pid\x20%s\x20not\x20found!','kill','SIGINT','Process\x20with\x20pid\x20%s\x20killed\x20correctly','systeminformation','child_process','exec','../../config/logger','api','lodash','error','<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s','inspect','send','index','getAllData','status','json'];(function(_0x2a0a56,_0x209e23){var _0x3b959e=function(_0x91be9d){while(--_0x91be9d){_0x2a0a56['push'](_0x2a0a56['shift']());}};_0x3b959e(++_0x209e23);}(_0xdd40,0x151));var _0x0dd4=function(_0xa9e64b,_0x4701f4){_0xa9e64b=_0xa9e64b-0x0;var _0x389dc9=_0xdd40[_0xa9e64b];return _0x389dc9;};'use strict';var info=require(_0x0dd4('0x0'));var exec=require(_0x0dd4('0x1'))[_0x0dd4('0x2')];var logger=require(_0x0dd4('0x3'))(_0x0dd4('0x4'));var util=require('util');var BPromise=require('bluebird');var _=require(_0x0dd4('0x5'));function handleError(_0x109c7e,_0x44cfc0,_0x73c505){_0x44cfc0=_0x44cfc0||0x1f4;return function(_0x40c72c){logger[_0x0dd4('0x6')](_0x0dd4('0x7'),_0x73c505,_0x44cfc0,util[_0x0dd4('0x8')](_0x40c72c,{'showHidden':![],'depth':null}));delete _0x40c72c['name'];_0x109c7e['status'](_0x44cfc0)[_0x0dd4('0x9')](_0x40c72c);};}exports[_0x0dd4('0xa')]=function(_0x5d1d68,_0x20a518){return info[_0x0dd4('0xb')]()['then'](function(_0x4b2b3a){return _0x20a518[_0x0dd4('0xc')](0xc8)[_0x0dd4('0xd')](_0x4b2b3a);})[_0x0dd4('0xe')](function(_0x3e54a4){return _0x20a518[_0x0dd4('0xc')](0x1f4)[_0x0dd4('0xd')](_0x3e54a4);});};exports[_0x0dd4('0xf')]=function(_0x67803,_0x50053e){var _0x18d3c7=[_0x0dd4('0x10')];return new BPromise(function(_0x4fbca2,_0x5ec7af){return exec(util[_0x0dd4('0x11')](_0x0dd4('0x12'),_0x67803[_0x0dd4('0x13')][_0x0dd4('0x14')]),function(_0x650f76,_0x1de3fd,_0x46668f){if(_0x650f76){return _0x5ec7af(_0x650f76);}return _0x4fbca2(_0x1de3fd);});})['then'](function(_0x58dcf5){var _0x250cd9=![];var _0xae26c6=_0x58dcf5['split'](/\n/);for(var _0x43e263=0x0,_0x44dd52=_0x18d3c7[_0x0dd4('0x15')];_0x43e263<_0x44dd52,_0x250cd9===![];_0x43e263+=0x1){if(_0x58dcf5[_0x0dd4('0x16')](_0x18d3c7[_0x43e263])>=0x0){_0x250cd9=!![];}}if(!_0x250cd9){throw new Error(util[_0x0dd4('0x11')](_0x0dd4('0x17'),_0x67803['params'][_0x0dd4('0x14')]));}process[_0x0dd4('0x18')](_0x67803['params'][_0x0dd4('0x14')],_0x0dd4('0x19'));return _0x50053e[_0x0dd4('0xc')](0xc8)[_0x0dd4('0xd')]({'message':util[_0x0dd4('0x11')](_0x0dd4('0x1a'),_0x67803[_0x0dd4('0x13')][_0x0dd4('0x14')])});})[_0x0dd4('0xe')](handleError(_0x50053e,null,_0x0dd4('0xf')));}; \ No newline at end of file diff --git a/server/api/tag/index.js b/server/api/tag/index.js new file mode 100644 index 0000000..aa8a9e0 --- /dev/null +++ b/server/api/tag/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7e0c=['/:id','isAuthenticated','show','create','update','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../config/environment','./tag.controller','get'];(function(_0x3ec71b,_0x1d3472){var _0x4ed32b=function(_0x381497){while(--_0x381497){_0x3ec71b['push'](_0x3ec71b['shift']());}};_0x4ed32b(++_0x1d3472);}(_0x7e0c,0xdf));var _0xc7e0=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7e0c[_0x3dd15e];return _0x231fd0;};'use strict';var multer=require(_0xc7e0('0x0'));var util=require(_0xc7e0('0x1'));var path=require(_0xc7e0('0x2'));var timeout=require(_0xc7e0('0x3'));var express=require(_0xc7e0('0x4'));var router=express[_0xc7e0('0x5')]();var fs_extra=require(_0xc7e0('0x6'));var auth=require(_0xc7e0('0x7'));var interaction=require('../../components/interaction/service');var config=require(_0xc7e0('0x8'));var controller=require(_0xc7e0('0x9'));router[_0xc7e0('0xa')]('/',auth['isAuthenticated'](),controller['index']);router[_0xc7e0('0xa')](_0xc7e0('0xb'),auth[_0xc7e0('0xc')](),controller[_0xc7e0('0xd')]);router['post']('/',auth[_0xc7e0('0xc')](),controller[_0xc7e0('0xe')]);router['put'](_0xc7e0('0xb'),auth[_0xc7e0('0xc')](),controller[_0xc7e0('0xf')]);router['delete'](_0xc7e0('0xb'),auth[_0xc7e0('0xc')](),controller[_0xc7e0('0x10')]);module[_0xc7e0('0x11')]=router; \ No newline at end of file diff --git a/server/api/tag/tag.attributes.js b/server/api/tag/tag.attributes.js new file mode 100644 index 0000000..3283501 --- /dev/null +++ b/server/api/tag/tag.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8227=['STRING','#0091EA','exports','name'];(function(_0x2dde6e,_0x41f1c4){var _0x321eb2=function(_0x424a90){while(--_0x424a90){_0x2dde6e['push'](_0x2dde6e['shift']());}};_0x321eb2(++_0x41f1c4);}(_0x8227,0x146));var _0x7822=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x8227[_0x321bb2];return _0x9c12ed;};'use strict';var Sequelize=require('sequelize');module[_0x7822('0x0')]={'name':{'type':Sequelize['STRING'],'unique':_0x7822('0x1'),'allowNull':![],'validate':{'is':/[A-Za-z0-9._\\+*!-]+/,'notEmpty':!![]}},'color':{'type':Sequelize[_0x7822('0x2')],'defaultValue':_0x7822('0x3')},'description':{'type':Sequelize[_0x7822('0x2')]}}; \ No newline at end of file diff --git a/server/api/tag/tag.controller.js b/server/api/tag/tag.controller.js new file mode 100644 index 0000000..4996007 --- /dev/null +++ b/server/api/tag/tag.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x407f=['filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','params','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','then','destroy','get','Tags','error','stack','name','send','index','map','Tag','rawAttributes','fieldName','type','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick'];(function(_0x46a60a,_0x1c54fe){var _0x1ff42a=function(_0x55f6c3){while(--_0x55f6c3){_0x46a60a['push'](_0x46a60a['shift']());}};_0x1ff42a(++_0x1c54fe);}(_0x407f,0xc2));var _0xf407=function(_0x5b37e5,_0x101120){_0x5b37e5=_0x5b37e5-0x0;var _0x5d285c=_0x407f[_0x5b37e5];return _0x5d285c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf407('0x0'));var rp=require(_0xf407('0x1'));var moment=require(_0xf407('0x2'));var BPromise=require(_0xf407('0x3'));var Mustache=require(_0xf407('0x4'));var util=require(_0xf407('0x5'));var path=require(_0xf407('0x6'));var sox=require(_0xf407('0x7'));var csv=require(_0xf407('0x8'));var ejs=require(_0xf407('0x9'));var fs=require('fs');var fs_extra=require(_0xf407('0xa'));var _=require(_0xf407('0xb'));var squel=require(_0xf407('0xc'));var crypto=require(_0xf407('0xd'));var jsforce=require(_0xf407('0xe'));var deskjs=require(_0xf407('0xf'));var toCsv=require('to-csv');var querystring=require(_0xf407('0x10'));var Papa=require(_0xf407('0x11'));var Redis=require(_0xf407('0x12'));var authService=require(_0xf407('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xf407('0x14'))(_0xf407('0x15'));var utils=require(_0xf407('0x16'));var config=require(_0xf407('0x17'));var licenseUtil=require(_0xf407('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2ee485,_0x3f4ca0){_0x3f4ca0=_0x3f4ca0||0xcc;return function(_0x3b26ae){if(_0x3b26ae){return _0x2ee485[_0xf407('0x19')](_0x3f4ca0);}return _0x2ee485[_0xf407('0x1a')](_0x3f4ca0)[_0xf407('0x1b')]();};}function respondWithResult(_0x242f43,_0x5257ef){_0x5257ef=_0x5257ef||0xc8;return function(_0x5d80ab){if(_0x5d80ab){return _0x242f43['status'](_0x5257ef)[_0xf407('0x1c')](_0x5d80ab);}};}function respondWithFilteredResult(_0x593e36,_0x454710){return function(_0x4c1320){if(_0x4c1320){var _0x48fd5d=typeof _0x454710[_0xf407('0x1d')]===_0xf407('0x1e')&&typeof _0x454710[_0xf407('0x1f')]===_0xf407('0x1e');var _0x351252=_0x4c1320[_0xf407('0x20')];var _0x4ddbe6=_0x48fd5d?0x0:_0x454710[_0xf407('0x1d')];var _0x588fe4=_0x48fd5d?_0x4c1320[_0xf407('0x20')]:_0x454710[_0xf407('0x1d')]+_0x454710[_0xf407('0x1f')];var _0x334c1a;if(_0x588fe4>=_0x351252){_0x588fe4=_0x351252;_0x334c1a=0xc8;}else{_0x334c1a=0xce;}_0x593e36[_0xf407('0x1a')](_0x334c1a);return _0x593e36[_0xf407('0x21')]('Content-Range',_0x4ddbe6+'-'+_0x588fe4+'/'+_0x351252)[_0xf407('0x1c')](_0x4c1320);}return null;};}function patchUpdates(_0x39febd){return function(_0x2f7ed0){try{jsonpatch[_0xf407('0x22')](_0x2f7ed0,_0x39febd,!![]);}catch(_0x4eb0c3){return BPromise[_0xf407('0x23')](_0x4eb0c3);}return _0x2f7ed0[_0xf407('0x24')]();};}function saveUpdates(_0x23659c,_0xa6f11e){return function(_0x5f32bb){if(_0x5f32bb){return _0x5f32bb['update'](_0x23659c)[_0xf407('0x25')](function(_0x100e6e){return _0x100e6e;});}return null;};}function removeEntity(_0x2558a1,_0x2cea00){return function(_0x9406cf){if(_0x9406cf){return _0x9406cf[_0xf407('0x26')]()[_0xf407('0x25')](function(){var _0x5aecf2=_0x9406cf[_0xf407('0x27')]({'plain':!![]});var _0x1996c8=_0xf407('0x28');return db['UserProfileResource'][_0xf407('0x26')]({'where':{'type':_0x1996c8,'resourceId':_0x5aecf2['id']}})[_0xf407('0x25')](function(){return _0x9406cf;});})[_0xf407('0x25')](function(){_0x2558a1[_0xf407('0x1a')](0xcc)[_0xf407('0x1b')]();});}};}function handleEntityNotFound(_0x187c93,_0x524b34){return function(_0x3953c5){if(!_0x3953c5){_0x187c93['sendStatus'](0x194);}return _0x3953c5;};}function handleError(_0x4fc4df,_0x949669){_0x949669=_0x949669||0x1f4;return function(_0x115dce){logger[_0xf407('0x29')](_0x115dce[_0xf407('0x2a')]);if(_0x115dce[_0xf407('0x2b')]){delete _0x115dce[_0xf407('0x2b')];}_0x4fc4df['status'](_0x949669)[_0xf407('0x2c')](_0x115dce);};}exports[_0xf407('0x2d')]=function(_0xa91b61,_0x89915b){var _0x15cd8d={},_0x5e12da={},_0x4a763e={'count':0x0,'rows':[]};var _0xce3a12=_[_0xf407('0x2e')](db[_0xf407('0x2f')][_0xf407('0x30')],function(_0x153287){return{'name':_0x153287[_0xf407('0x31')],'type':_0x153287[_0xf407('0x32')]['key']};});_0x5e12da[_0xf407('0x33')]=_['map'](_0xce3a12,_0xf407('0x2b'));_0x5e12da[_0xf407('0x34')]=_['keys'](_0xa91b61['query']);_0x5e12da['filters']=_[_0xf407('0x35')](_0x5e12da[_0xf407('0x33')],_0x5e12da['query']);_0x15cd8d[_0xf407('0x36')]=_[_0xf407('0x35')](_0x5e12da[_0xf407('0x33')],qs[_0xf407('0x37')](_0xa91b61['query']['fields']));_0x15cd8d[_0xf407('0x36')]=_0x15cd8d[_0xf407('0x36')][_0xf407('0x38')]?_0x15cd8d[_0xf407('0x36')]:_0x5e12da[_0xf407('0x33')];if(!_0xa91b61[_0xf407('0x34')][_0xf407('0x39')](_0xf407('0x3a'))){_0x15cd8d[_0xf407('0x1f')]=qs[_0xf407('0x1f')](_0xa91b61['query'][_0xf407('0x1f')]);_0x15cd8d['offset']=qs[_0xf407('0x1d')](_0xa91b61[_0xf407('0x34')][_0xf407('0x1d')]);}_0x15cd8d[_0xf407('0x3b')]=qs[_0xf407('0x3c')](_0xa91b61['query'][_0xf407('0x3c')]);_0x15cd8d[_0xf407('0x3d')]=qs[_0xf407('0x3e')](_[_0xf407('0x3f')](_0xa91b61['query'],_0x5e12da[_0xf407('0x3e')]),_0xce3a12);if(_0xa91b61[_0xf407('0x34')][_0xf407('0x40')]){_0x15cd8d['where']=_['merge'](_0x15cd8d[_0xf407('0x3d')],{'$or':_['map'](_0xce3a12,function(_0x573fae){if(_0x573fae[_0xf407('0x32')]!==_0xf407('0x41')){var _0x4890ae={};_0x4890ae[_0x573fae[_0xf407('0x2b')]]={'$like':'%'+_0xa91b61[_0xf407('0x34')][_0xf407('0x40')]+'%'};return _0x4890ae;}})});}_0x15cd8d=_[_0xf407('0x42')]({},_0x15cd8d,_0xa91b61[_0xf407('0x43')]);var _0x5c27c4={'where':_0x15cd8d[_0xf407('0x3d')]};return db['Tag']['count'](_0x5c27c4)[_0xf407('0x25')](function(_0x1ddb15){_0x4a763e['count']=_0x1ddb15;if(_0xa91b61[_0xf407('0x34')][_0xf407('0x44')]){_0x15cd8d[_0xf407('0x45')]=[{'all':!![]}];}return db[_0xf407('0x2f')][_0xf407('0x46')](_0x15cd8d);})[_0xf407('0x25')](function(_0x1c8f17){_0x4a763e[_0xf407('0x47')]=_0x1c8f17;return _0x4a763e;})['then'](respondWithFilteredResult(_0x89915b,_0x15cd8d))[_0xf407('0x48')](handleError(_0x89915b,null));};exports['show']=function(_0x2def2e,_0x571188){var _0x444b01={'raw':!![],'where':{'id':_0x2def2e[_0xf407('0x49')]['id']}},_0x56ea2b={};_0x56ea2b[_0xf407('0x33')]=_[_0xf407('0x4a')](db[_0xf407('0x2f')][_0xf407('0x30')]);_0x56ea2b[_0xf407('0x34')]=_[_0xf407('0x4a')](_0x2def2e['query']);_0x56ea2b[_0xf407('0x3e')]=_[_0xf407('0x35')](_0x56ea2b[_0xf407('0x33')],_0x56ea2b[_0xf407('0x34')]);_0x444b01[_0xf407('0x36')]=_[_0xf407('0x35')](_0x56ea2b['model'],qs[_0xf407('0x37')](_0x2def2e[_0xf407('0x34')][_0xf407('0x37')]));_0x444b01[_0xf407('0x36')]=_0x444b01[_0xf407('0x36')][_0xf407('0x38')]?_0x444b01['attributes']:_0x56ea2b[_0xf407('0x33')];if(_0x2def2e[_0xf407('0x34')][_0xf407('0x44')]){_0x444b01['include']=[{'all':!![]}];}_0x444b01=_[_0xf407('0x42')]({},_0x444b01,_0x2def2e['options']);return db[_0xf407('0x2f')][_0xf407('0x4b')](_0x444b01)[_0xf407('0x25')](handleEntityNotFound(_0x571188,null))[_0xf407('0x25')](respondWithResult(_0x571188,null))['catch'](handleError(_0x571188,null));};exports[_0xf407('0x4c')]=function(_0x3b6c44,_0x16cf14){return db['Tag']['create'](_0x3b6c44[_0xf407('0x4d')],{})[_0xf407('0x25')](function(_0x45e9ab){var _0x4799c1=_0x3b6c44[_0xf407('0x4e')][_0xf407('0x27')]({'plain':!![]});if(!_0x4799c1)throw new Error(_0xf407('0x4f'));if(_0x4799c1[_0xf407('0x50')]==='user'){var _0x1282df=_0x45e9ab[_0xf407('0x27')]({'plain':!![]});var _0x4e8483=_0xf407('0x28');return db[_0xf407('0x51')][_0xf407('0x4b')]({'where':{'name':_0x4e8483,'userProfileId':_0x4799c1['userProfileId']},'raw':!![]})[_0xf407('0x25')](function(_0xd168af){if(_0xd168af&&_0xd168af[_0xf407('0x52')]===0x0){return db[_0xf407('0x53')]['create']({'name':_0x1282df[_0xf407('0x2b')],'resourceId':_0x1282df['id'],'type':_0xd168af[_0xf407('0x2b')],'sectionId':_0xd168af['id']},{})['then'](function(){return _0x45e9ab;});}else{return _0x45e9ab;}})[_0xf407('0x48')](function(_0x588fd7){logger[_0xf407('0x29')](_0xf407('0x54'),_0x588fd7);throw _0x588fd7;});}return _0x45e9ab;})['then'](respondWithResult(_0x16cf14,0xc9))[_0xf407('0x48')](handleError(_0x16cf14,null));};exports[_0xf407('0x55')]=function(_0x4b161b,_0x289d00){if(_0x4b161b['body']['id']){delete _0x4b161b['body']['id'];}return db[_0xf407('0x2f')][_0xf407('0x4b')]({'where':{'id':_0x4b161b[_0xf407('0x49')]['id']}})[_0xf407('0x25')](handleEntityNotFound(_0x289d00,null))[_0xf407('0x25')](saveUpdates(_0x4b161b[_0xf407('0x4d')],null))['then'](respondWithResult(_0x289d00,null))['catch'](handleError(_0x289d00,null));};exports[_0xf407('0x26')]=function(_0x34cdf1,_0x417bdd){return db[_0xf407('0x2f')][_0xf407('0x4b')]({'where':{'id':_0x34cdf1[_0xf407('0x49')]['id']}})['then'](handleEntityNotFound(_0x417bdd,null))[_0xf407('0x25')](removeEntity(_0x417bdd,null))[_0xf407('0x48')](handleError(_0x417bdd,null));}; \ No newline at end of file diff --git a/server/api/tag/tag.model.js b/server/api/tag/tag.model.js new file mode 100644 index 0000000..0e431f4 --- /dev/null +++ b/server/api/tag/tag.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf8bc=['path','../../config/environment','./tag.attributes','exports','define','Tag','tools_tags','lodash','util','../../config/logger','api','moment','bluebird'];(function(_0x450689,_0x3b857c){var _0x46ffb0=function(_0x5d3679){while(--_0x5d3679){_0x450689['push'](_0x450689['shift']());}};_0x46ffb0(++_0x3b857c);}(_0xf8bc,0x180));var _0xcf8b=function(_0x1d04b5,_0x30792c){_0x1d04b5=_0x1d04b5-0x0;var _0x161342=_0xf8bc[_0x1d04b5];return _0x161342;};'use strict';var _=require(_0xcf8b('0x0'));var util=require(_0xcf8b('0x1'));var logger=require(_0xcf8b('0x2'))(_0xcf8b('0x3'));var moment=require(_0xcf8b('0x4'));var BPromise=require(_0xcf8b('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xcf8b('0x6'));var rimraf=require('rimraf');var config=require(_0xcf8b('0x7'));var attributes=require(_0xcf8b('0x8'));module[_0xcf8b('0x9')]=function(_0x5aef34,_0x597405){return _0x5aef34[_0xcf8b('0xa')](_0xcf8b('0xb'),attributes,{'tableName':_0xcf8b('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/tag/tag.rpc.js b/server/api/tag/tag.rpc.js new file mode 100644 index 0000000..0203402 --- /dev/null +++ b/server/api/tag/tag.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe13a=['code','message','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Tag,\x20%s,\x20%s','request\x20sent','Tag,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x14815b,_0x258a44){var _0x3ccb14=function(_0xb53a){while(--_0xb53a){_0x14815b['push'](_0x14815b['shift']());}};_0x3ccb14(++_0x258a44);}(_0xe13a,0x178));var _0xae13=function(_0x484f49,_0x247163){_0x484f49=_0x484f49-0x0;var _0x4dcedc=_0xe13a[_0x484f49];return _0x4dcedc;};'use strict';var _=require('lodash');var util=require(_0xae13('0x0'));var moment=require(_0xae13('0x1'));var BPromise=require(_0xae13('0x2'));var rs=require(_0xae13('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xae13('0x4'))['db'];var utils=require(_0xae13('0x5'));var logger=require(_0xae13('0x6'))(_0xae13('0x7'));var config=require(_0xae13('0x8'));var jayson=require(_0xae13('0x9'));var client=jayson[_0xae13('0xa')][_0xae13('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x341ba4,_0x4ae51f,_0x2f6d10){return new BPromise(function(_0x2b2e1f,_0x27fefd){return client[_0xae13('0xc')](_0x341ba4,_0x2f6d10)[_0xae13('0xd')](function(_0x41bf44){logger[_0xae13('0xe')](_0xae13('0xf'),_0x4ae51f,_0xae13('0x10'));logger['debug'](_0xae13('0x11'),_0x4ae51f,_0xae13('0x10'),JSON[_0xae13('0x12')](_0x41bf44));if(_0x41bf44[_0xae13('0x13')]){if(_0x41bf44[_0xae13('0x13')][_0xae13('0x14')]===0x1f4){logger[_0xae13('0x13')]('Tag,\x20%s,\x20%s',_0x4ae51f,_0x41bf44[_0xae13('0x13')][_0xae13('0x15')]);return _0x27fefd(_0x41bf44['error']['message']);}logger['error']('Tag,\x20%s,\x20%s',_0x4ae51f,_0x41bf44['error'][_0xae13('0x15')]);return _0x2b2e1f(_0x41bf44[_0xae13('0x13')][_0xae13('0x15')]);}else{logger[_0xae13('0xe')](_0xae13('0xf'),_0x4ae51f,_0xae13('0x10'));_0x2b2e1f(_0x41bf44['result'][_0xae13('0x15')]);}})['catch'](function(_0xe10aab){logger[_0xae13('0x13')](_0xae13('0xf'),_0x4ae51f,_0xe10aab);_0x27fefd(_0xe10aab);});});} \ No newline at end of file diff --git a/server/api/team/index.js b/server/api/team/index.js new file mode 100644 index 0000000..67bd2a0 --- /dev/null +++ b/server/api/team/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['Router','../../components/auth/service','../../components/interaction/service','../../config/environment','./team.controller','get','index','/:id','getQueues','/:id/users','isAuthenticated','getAgents','post','addQueues','addAgents','update','delete','removeAgents','multer','util','path'];(function(_0x46e363,_0x45d7e2){var _0x3fb059=function(_0x5e6274){while(--_0x5e6274){_0x46e363['push'](_0x46e363['shift']());}};_0x3fb059(++_0x45d7e2);}(_0xa9e0,0x123));var _0x0a9e=function(_0x5c351c,_0x2046d8){_0x5c351c=_0x5c351c-0x0;var _0x26f3b3=_0xa9e0[_0x5c351c];return _0x26f3b3;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var controller=require(_0x0a9e('0x7'));router[_0x0a9e('0x8')]('/',auth['isAuthenticated'](),controller[_0x0a9e('0x9')]);router[_0x0a9e('0x8')](_0x0a9e('0xa'),auth['isAuthenticated'](),controller['show']);router[_0x0a9e('0x8')]('/:id/queues',auth['isAuthenticated'](),controller[_0x0a9e('0xb')]);router[_0x0a9e('0x8')](_0x0a9e('0xc'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0xe')]);router[_0x0a9e('0xf')]('/',auth['isAuthenticated'](),controller['create']);router['post']('/:id/queues',auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x10')]);router[_0x0a9e('0xf')](_0x0a9e('0xc'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x11')]);router['put'](_0x0a9e('0xa'),auth[_0x0a9e('0xd')](),controller[_0x0a9e('0x12')]);router[_0x0a9e('0x13')](_0x0a9e('0xa'),auth[_0x0a9e('0xd')](),controller['destroy']);router[_0x0a9e('0x13')]('/:id/queues',auth[_0x0a9e('0xd')](),controller['removeQueues']);router[_0x0a9e('0x13')](_0x0a9e('0xc'),auth['isAuthenticated'](),controller[_0x0a9e('0x14')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/team/team.attributes.js b/server/api/team/team.attributes.js new file mode 100644 index 0000000..b8fa0d2 --- /dev/null +++ b/server/api/team/team.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb7e7=['STRING','sequelize'];(function(_0x504df1,_0x289598){var _0x1063b5=function(_0x627abd){while(--_0x627abd){_0x504df1['push'](_0x504df1['shift']());}};_0x1063b5(++_0x289598);}(_0xb7e7,0x121));var _0x7b7e=function(_0x4b7b62,_0x4920a9){_0x4b7b62=_0x4b7b62-0x0;var _0x2280df=_0xb7e7[_0x4b7b62];return _0x2280df;};'use strict';var Sequelize=require(_0x7b7e('0x0'));module['exports']={'name':{'type':Sequelize[_0x7b7e('0x1')],'allowNull':![],'unique':'name'},'description':{'type':Sequelize[_0x7b7e('0x1')]}}; \ No newline at end of file diff --git a/server/api/team/team.controller.js b/server/api/team/team.controller.js new file mode 100644 index 0000000..cc7d5e5 --- /dev/null +++ b/server/api/team/team.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x29f5=['register','sendStatus','status','end','undefined','limit','count','offset','json','save','then','error','name','index','Team','fieldName','type','key','model','map','query','keys','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','filters','pick','where','VIRTUAL','options','includeAll','include','findAll','rows','params','length','merge','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','Teams','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','sequelize','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','Sequelize','QueryTypes','SELECT','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','VoiceQueueId','UserVoiceQueue','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','MailQueueId','UserMailQueue','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','SmsQueueId','UserSmsQueue','UserChatQueue','SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20','FaxQueueId','UserFaxQueue','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','UserWhatsappQueue','TeamVoicePrefix','UserVoicePrefix','send','channel','isValidChannel','Unknown\x20channel','capitalize','toLowerCase','Queue','rawAttributes','Queues','addQueues','findOne','ValidationError','ids','removeQueues','remove','addAgents','isArray','Voice','Mail','Sms','Whatsapp','through','penalty','QueueId','TeamVoiceQueue','User','emit','Queue:save','online','interface','UserVoiceQueueRt','upsert','isNil','voicePause','all','VoicePrefixId','spread','removeAgents','Chat','Openchannel','Queue:remove','getAgents','filter','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','defaults','redis','localhost','./team.socket'];(function(_0x7fab1f,_0x3b5399){var _0x1699e2=function(_0x340ffd){while(--_0x340ffd){_0x7fab1f['push'](_0x7fab1f['shift']());}};_0x1699e2(++_0x3b5399);}(_0x29f5,0x1ac));var _0x529f=function(_0x1a5059,_0x48e6b2){_0x1a5059=_0x1a5059-0x0;var _0x318d5b=_0x29f5[_0x1a5059];return _0x318d5b;};'use strict';var emlformat=require(_0x529f('0x0'));var rimraf=require(_0x529f('0x1'));var zipdir=require(_0x529f('0x2'));var jsonpatch=require(_0x529f('0x3'));var rp=require(_0x529f('0x4'));var moment=require(_0x529f('0x5'));var BPromise=require(_0x529f('0x6'));var Mustache=require(_0x529f('0x7'));var util=require(_0x529f('0x8'));var path=require('path');var sox=require(_0x529f('0x9'));var csv=require(_0x529f('0xa'));var ejs=require(_0x529f('0xb'));var fs=require('fs');var fs_extra=require(_0x529f('0xc'));var _=require(_0x529f('0xd'));var squel=require(_0x529f('0xe'));var crypto=require(_0x529f('0xf'));var jsforce=require(_0x529f('0x10'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x529f('0x11'));var Papa=require(_0x529f('0x12'));var Redis=require(_0x529f('0x13'));var authService=require(_0x529f('0x14'));var qs=require(_0x529f('0x15'));var as=require(_0x529f('0x16'));var hardwareService=require(_0x529f('0x17'));var logger=require('../../config/logger')(_0x529f('0x18'));var utils=require(_0x529f('0x19'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x529f('0x1a'))['db'];config['redis']=_[_0x529f('0x1b')](config[_0x529f('0x1c')],{'host':_0x529f('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x529f('0x1e'))[_0x529f('0x1f')](socket);function respondWithStatusCode(_0x59012f,_0x46d07a){_0x46d07a=_0x46d07a||0xcc;return function(_0x238319){if(_0x238319){return _0x59012f[_0x529f('0x20')](_0x46d07a);}return _0x59012f[_0x529f('0x21')](_0x46d07a)[_0x529f('0x22')]();};}function respondWithResult(_0x40404f,_0x492751){_0x492751=_0x492751||0xc8;return function(_0x5cdc28){if(_0x5cdc28){return _0x40404f['status'](_0x492751)['json'](_0x5cdc28);}};}function respondWithFilteredResult(_0x5b6561,_0x483d3e){return function(_0x80d2d){if(_0x80d2d){var _0x1cfb38=typeof _0x483d3e['offset']===_0x529f('0x23')&&typeof _0x483d3e[_0x529f('0x24')]===_0x529f('0x23');var _0x18bdaf=_0x80d2d[_0x529f('0x25')];var _0x5b8d0a=_0x1cfb38?0x0:_0x483d3e[_0x529f('0x26')];var _0x2b3c2a=_0x1cfb38?_0x80d2d['count']:_0x483d3e[_0x529f('0x26')]+_0x483d3e[_0x529f('0x24')];var _0x512fb7;if(_0x2b3c2a>=_0x18bdaf){_0x2b3c2a=_0x18bdaf;_0x512fb7=0xc8;}else{_0x512fb7=0xce;}_0x5b6561[_0x529f('0x21')](_0x512fb7);return _0x5b6561['set']('Content-Range',_0x5b8d0a+'-'+_0x2b3c2a+'/'+_0x18bdaf)[_0x529f('0x27')](_0x80d2d);}return null;};}function patchUpdates(_0x3415c9){return function(_0x310b8c){try{jsonpatch['apply'](_0x310b8c,_0x3415c9,!![]);}catch(_0xae27d7){return BPromise['reject'](_0xae27d7);}return _0x310b8c[_0x529f('0x28')]();};}function saveUpdates(_0x539080,_0x451f55){return function(_0x3c24ce){if(_0x3c24ce){return _0x3c24ce['update'](_0x539080)[_0x529f('0x29')](function(_0x58874d){return _0x58874d;});}return null;};}function handleEntityNotFound(_0x10f0a3,_0xd52676){return function(_0x3cb06b){if(!_0x3cb06b){_0x10f0a3[_0x529f('0x20')](0x194);}return _0x3cb06b;};}function handleError(_0x2571b6,_0x3ca0b4){_0x3ca0b4=_0x3ca0b4||0x1f4;return function(_0x5ca83f){logger[_0x529f('0x2a')](_0x5ca83f['stack']);if(_0x5ca83f[_0x529f('0x2b')]){delete _0x5ca83f[_0x529f('0x2b')];}_0x2571b6[_0x529f('0x21')](_0x3ca0b4)['send'](_0x5ca83f);};}exports[_0x529f('0x2c')]=function(_0x4a13ce,_0x4c10ee){var _0x37e5ab={},_0x364cd7={},_0x48b00d={'count':0x0,'rows':[]};var _0x51027d=_['map'](db[_0x529f('0x2d')]['rawAttributes'],function(_0x5e5a64){return{'name':_0x5e5a64[_0x529f('0x2e')],'type':_0x5e5a64[_0x529f('0x2f')][_0x529f('0x30')]};});_0x364cd7[_0x529f('0x31')]=_[_0x529f('0x32')](_0x51027d,_0x529f('0x2b'));_0x364cd7[_0x529f('0x33')]=_[_0x529f('0x34')](_0x4a13ce[_0x529f('0x33')]);_0x364cd7['filters']=_['intersection'](_0x364cd7[_0x529f('0x31')],_0x364cd7[_0x529f('0x33')]);_0x37e5ab[_0x529f('0x35')]=_[_0x529f('0x36')](_0x364cd7[_0x529f('0x31')],qs[_0x529f('0x37')](_0x4a13ce[_0x529f('0x33')][_0x529f('0x37')]));_0x37e5ab[_0x529f('0x35')]=_0x37e5ab[_0x529f('0x35')]['length']?_0x37e5ab[_0x529f('0x35')]:_0x364cd7[_0x529f('0x31')];if(!_0x4a13ce[_0x529f('0x33')][_0x529f('0x38')](_0x529f('0x39'))){_0x37e5ab[_0x529f('0x24')]=qs[_0x529f('0x24')](_0x4a13ce[_0x529f('0x33')][_0x529f('0x24')]);_0x37e5ab[_0x529f('0x26')]=qs[_0x529f('0x26')](_0x4a13ce[_0x529f('0x33')][_0x529f('0x26')]);}_0x37e5ab[_0x529f('0x3a')]=qs[_0x529f('0x3b')](_0x4a13ce[_0x529f('0x33')][_0x529f('0x3b')]);_0x37e5ab['where']=qs[_0x529f('0x3c')](_[_0x529f('0x3d')](_0x4a13ce['query'],_0x364cd7[_0x529f('0x3c')]),_0x51027d);if(_0x4a13ce['query']['filter']){_0x37e5ab['where']=_['merge'](_0x37e5ab[_0x529f('0x3e')],{'$or':_['map'](_0x51027d,function(_0x56a2f7){if(_0x56a2f7[_0x529f('0x2f')]!==_0x529f('0x3f')){var _0x254c87={};_0x254c87[_0x56a2f7[_0x529f('0x2b')]]={'$like':'%'+_0x4a13ce['query']['filter']+'%'};return _0x254c87;}})});}_0x37e5ab=_['merge']({},_0x37e5ab,_0x4a13ce[_0x529f('0x40')]);var _0x19928b={'where':_0x37e5ab[_0x529f('0x3e')]};return db['Team']['count'](_0x19928b)[_0x529f('0x29')](function(_0x852c41){_0x48b00d[_0x529f('0x25')]=_0x852c41;if(_0x4a13ce[_0x529f('0x33')][_0x529f('0x41')]){_0x37e5ab[_0x529f('0x42')]=[{'all':!![]}];}return db['Team'][_0x529f('0x43')](_0x37e5ab);})[_0x529f('0x29')](function(_0x41c831){_0x48b00d[_0x529f('0x44')]=_0x41c831;return _0x48b00d;})[_0x529f('0x29')](respondWithFilteredResult(_0x4c10ee,_0x37e5ab))['catch'](handleError(_0x4c10ee,null));};exports['show']=function(_0x4bfa40,_0x1414a5){var _0x147238={'raw':![],'where':{'id':_0x4bfa40[_0x529f('0x45')]['id']}},_0x46926b={};_0x46926b[_0x529f('0x31')]=_[_0x529f('0x34')](db[_0x529f('0x2d')]['rawAttributes']);_0x46926b[_0x529f('0x33')]=_[_0x529f('0x34')](_0x4bfa40['query']);_0x46926b[_0x529f('0x3c')]=_[_0x529f('0x36')](_0x46926b[_0x529f('0x31')],_0x46926b[_0x529f('0x33')]);_0x147238['attributes']=_[_0x529f('0x36')](_0x46926b[_0x529f('0x31')],qs[_0x529f('0x37')](_0x4bfa40['query'][_0x529f('0x37')]));_0x147238[_0x529f('0x35')]=_0x147238[_0x529f('0x35')][_0x529f('0x46')]?_0x147238['attributes']:_0x46926b[_0x529f('0x31')];if(_0x4bfa40[_0x529f('0x33')][_0x529f('0x41')]){_0x147238[_0x529f('0x42')]=[{'all':!![]}];}_0x147238=_[_0x529f('0x47')]({},_0x147238,_0x4bfa40[_0x529f('0x40')]);return db[_0x529f('0x2d')][_0x529f('0x48')](_0x147238)[_0x529f('0x29')](handleEntityNotFound(_0x1414a5,null))['then'](respondWithResult(_0x1414a5,null))[_0x529f('0x49')](handleError(_0x1414a5,null));};exports['create']=function(_0x4b476d,_0x534f8e){return db[_0x529f('0x2d')][_0x529f('0x4a')](_0x4b476d[_0x529f('0x4b')],{})[_0x529f('0x29')](function(_0x332457){var _0x5def85=_0x4b476d[_0x529f('0x4c')][_0x529f('0x4d')]({'plain':!![]});if(!_0x5def85)throw new Error(_0x529f('0x4e'));if(_0x5def85['role']===_0x529f('0x4c')){var _0x483ec7=_0x332457[_0x529f('0x4d')]({'plain':!![]});var _0x4ce297=_0x529f('0x4f');return db['UserProfileSection']['find']({'where':{'name':_0x4ce297,'userProfileId':_0x5def85[_0x529f('0x50')]},'raw':!![]})[_0x529f('0x29')](function(_0x491aaf){if(_0x491aaf&&_0x491aaf[_0x529f('0x51')]===0x0){return db[_0x529f('0x52')][_0x529f('0x4a')]({'name':_0x483ec7['name'],'resourceId':_0x483ec7['id'],'type':_0x491aaf['name'],'sectionId':_0x491aaf['id']},{})[_0x529f('0x29')](function(){return _0x332457;});}else{return _0x332457;}})[_0x529f('0x49')](function(_0x320e1a){logger[_0x529f('0x2a')](_0x529f('0x53'),_0x320e1a);throw _0x320e1a;});}return _0x332457;})[_0x529f('0x29')](respondWithResult(_0x534f8e,0xc9))[_0x529f('0x49')](handleError(_0x534f8e,null));};exports['update']=function(_0x5044ae,_0x365088){if(_0x5044ae[_0x529f('0x4b')]['id']){delete _0x5044ae['body']['id'];}return db[_0x529f('0x2d')]['find']({'where':{'id':_0x5044ae[_0x529f('0x45')]['id']}})[_0x529f('0x29')](handleEntityNotFound(_0x365088,null))[_0x529f('0x29')](saveUpdates(_0x5044ae[_0x529f('0x4b')],null))[_0x529f('0x29')](respondWithResult(_0x365088,null))[_0x529f('0x49')](handleError(_0x365088,null));};exports[_0x529f('0x54')]=function(_0x211cf6,_0x5413ff){var _0x4dd668=_0x211cf6[_0x529f('0x45')]['id'];var _0x2db0d6=[];return db[_0x529f('0x55')][_0x529f('0x56')](function(_0xab075f){var _0x4d0205=_0x529f('0x57')+_0x4dd668;return db[_0x529f('0x55')][_0x529f('0x33')](_0x4d0205,{'type':db[_0x529f('0x58')][_0x529f('0x59')][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f})['then'](function(_0x7ffddd){_0x2db0d6=_[_0x529f('0x32')](_0x7ffddd,function(_0x3e487b){return Number(_0x3e487b[_0x529f('0x5b')]);});})[_0x529f('0x29')](function(){var _0x17b4b5=_0x529f('0x5c')+_0x4dd668;return db[_0x529f('0x55')]['query'](_0x17b4b5,{'type':db['Sequelize'][_0x529f('0x59')][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x2f65c8){var _0x14c4f1=_[_0x529f('0x32')](_0x2f65c8,function(_0x5ba69d){return Number(_0x5ba69d[_0x529f('0x5d')]);});return db[_0x529f('0x5e')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'VoiceQueueId':{'$in':_0x14c4f1}},'transaction':_0xab075f});})[_0x529f('0x29')](function(){var _0x5d9bff=_0x529f('0x5f')+_0x4dd668;return db[_0x529f('0x55')]['query'](_0x5d9bff,{'type':db[_0x529f('0x58')]['QueryTypes'][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x5477e6){var _0x5e8b2b=_[_0x529f('0x32')](_0x5477e6,function(_0x57ecf4){return Number(_0x57ecf4[_0x529f('0x60')]);});return db[_0x529f('0x61')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'MailQueueId':{'$in':_0x5e8b2b}},'transaction':_0xab075f});})[_0x529f('0x29')](function(){var _0x48e05e=_0x529f('0x62')+_0x4dd668;return db[_0x529f('0x55')]['query'](_0x48e05e,{'type':db[_0x529f('0x58')][_0x529f('0x59')][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x1d543a){var _0xf095c2=_[_0x529f('0x32')](_0x1d543a,function(_0xe352f4){return Number(_0xe352f4[_0x529f('0x63')]);});return db[_0x529f('0x64')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'SmsQueueId':{'$in':_0xf095c2}},'transaction':_0xab075f});})['then'](function(){var _0x4791ab='SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20'+_0x4dd668;return db[_0x529f('0x55')][_0x529f('0x33')](_0x4791ab,{'type':db['Sequelize']['QueryTypes'][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x4c8000){var _0x4d37cb=_[_0x529f('0x32')](_0x4c8000,function(_0x438c06){return Number(_0x438c06['ChatQueueId']);});return db[_0x529f('0x65')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'ChatQueueId':{'$in':_0x4d37cb}},'transaction':_0xab075f});})['then'](function(){var _0x479900=_0x529f('0x66')+_0x4dd668;return db['sequelize'][_0x529f('0x33')](_0x479900,{'type':db['Sequelize']['QueryTypes'][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})['then'](function(_0x33ef7d){var _0xc853ca=_[_0x529f('0x32')](_0x33ef7d,function(_0xd1a964){return Number(_0xd1a964[_0x529f('0x67')]);});return db[_0x529f('0x68')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'FaxQueueId':{'$in':_0xc853ca}},'transaction':_0xab075f});})[_0x529f('0x29')](function(){var _0xa79758='SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20'+_0x4dd668;return db[_0x529f('0x55')]['query'](_0xa79758,{'type':db['Sequelize'][_0x529f('0x59')][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x543950){var _0x12b6aa=_['map'](_0x543950,function(_0x491169){return Number(_0x491169['OpenchannelQueueId']);});return db[_0x529f('0x69')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'OpenchannelQueueId':{'$in':_0x12b6aa}},'transaction':_0xab075f});})[_0x529f('0x29')](function(){var _0x1be5d3=_0x529f('0x6a')+_0x4dd668;return db[_0x529f('0x55')][_0x529f('0x33')](_0x1be5d3,{'type':db[_0x529f('0x58')]['QueryTypes'][_0x529f('0x5a')],'raw':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x2bded7){var _0x5d1f9b=_[_0x529f('0x32')](_0x2bded7,function(_0x259288){return Number(_0x259288['WhatsappQueueId']);});return db[_0x529f('0x6b')][_0x529f('0x54')]({'where':{'UserId':{'$in':_0x2db0d6},'WhatsappQueueId':{'$in':_0x5d1f9b}},'transaction':_0xab075f});})['then'](function(){return db[_0x529f('0x6c')][_0x529f('0x48')]({'where':{'TeamId':_0x4dd668}});})['then'](function(_0x4ae59e){if(_0x4ae59e===null){return;}return db[_0x529f('0x6d')]['destroy']({'where':{'UserId':{'$in':_0x2db0d6},'VoicePrefixId':_0x4ae59e['VoicePrefixId']},'transaction':_0xab075f});})['then'](function(){return db['Team']['destroy']({'where':{'id':_0x4dd668},'cascade':!![],'transaction':_0xab075f});})[_0x529f('0x29')](function(_0x5c1837){if(_0x5c1837===0x0){_0x5413ff['sendStatus'](0x194);}else{return db[_0x529f('0x52')][_0x529f('0x54')]({'where':{'type':_0x529f('0x4f'),'resourceId':_0x4dd668},'cascade':!![],'transaction':_0xab075f})[_0x529f('0x29')](function(){_0x5413ff[_0x529f('0x21')](0xcc)[_0x529f('0x22')]();});}})[_0x529f('0x49')](function(_0x30a800){_0x5413ff['status'](0x1f4)[_0x529f('0x6e')](_0x30a800);});});};exports['getQueues']=function(_0x533107,_0x43b795,_0x40da34){return db[_0x529f('0x2d')]['findOne']({'where':{'id':_0x533107[_0x529f('0x45')]['id']}})[_0x529f('0x29')](handleEntityNotFound(_0x43b795,null))[_0x529f('0x29')](function(_0x9c43a5){if(!_0x533107['query'][_0x529f('0x6f')]||!utils[_0x529f('0x70')](_0x533107[_0x529f('0x33')][_0x529f('0x6f')])){throw new db[(_0x529f('0x58'))]['ValidationError'](_0x529f('0x71'));}var _0x2cde23={};var _0x3ac992={};_0x3ac992[_0x529f('0x31')]=_[_0x529f('0x34')](db[_[_0x529f('0x72')](_0x533107[_0x529f('0x33')]['channel'][_0x529f('0x73')]())+_0x529f('0x74')][_0x529f('0x75')]);_0x3ac992['query']=_[_0x529f('0x34')](_0x533107[_0x529f('0x33')]);_0x3ac992['filters']=_[_0x529f('0x36')](_0x3ac992[_0x529f('0x31')],_0x3ac992[_0x529f('0x33')]);_0x2cde23[_0x529f('0x35')]=_['intersection'](_0x3ac992[_0x529f('0x31')],qs[_0x529f('0x37')](_0x533107[_0x529f('0x33')][_0x529f('0x37')]));_0x2cde23['attributes']=_0x2cde23[_0x529f('0x35')][_0x529f('0x46')]?_0x2cde23[_0x529f('0x35')]:_0x3ac992[_0x529f('0x31')];_0x2cde23[_0x529f('0x24')]=qs[_0x529f('0x24')](_0x533107[_0x529f('0x33')][_0x529f('0x24')]);_0x2cde23['offset']=qs[_0x529f('0x26')](_0x533107['query'][_0x529f('0x26')]);_0x2cde23['order']=qs[_0x529f('0x3b')](_0x533107[_0x529f('0x33')][_0x529f('0x3b')]);_0x2cde23[_0x529f('0x3e')]=qs[_0x529f('0x3c')](_[_0x529f('0x3d')](_0x533107['query'],_0x3ac992[_0x529f('0x3c')]));_0x2cde23=_['merge']({},_0x2cde23,_0x533107[_0x529f('0x40')]);return _0x9c43a5[_0x529f('0x4d')+_[_0x529f('0x72')](_0x533107[_0x529f('0x33')][_0x529f('0x6f')][_0x529f('0x73')]())+_0x529f('0x76')](_0x2cde23);})[_0x529f('0x29')](respondWithResult(_0x43b795,null))[_0x529f('0x49')](handleError(_0x43b795,null));};exports[_0x529f('0x77')]=function(_0x135769,_0x45737d,_0x274738){return db[_0x529f('0x2d')][_0x529f('0x78')]({'where':{'id':_0x135769['params']['id']}})['then'](function(_0x2e34ba){if(_0x2e34ba){if(!_0x135769[_0x529f('0x4b')][_0x529f('0x6f')]||!utils[_0x529f('0x70')](_0x135769[_0x529f('0x4b')][_0x529f('0x6f')])){throw new db[(_0x529f('0x58'))][(_0x529f('0x79'))](_0x529f('0x71'));}return _0x2e34ba['add'+_[_0x529f('0x72')](_0x135769[_0x529f('0x4b')][_0x529f('0x6f')]['toLowerCase']())+_0x529f('0x76')](_0x135769[_0x529f('0x4b')][_0x529f('0x7a')]);}return null;})['then'](handleEntityNotFound(_0x45737d,null))[_0x529f('0x29')](respondWithStatusCode(_0x45737d,null))[_0x529f('0x49')](handleError(_0x45737d,null));};exports[_0x529f('0x7b')]=function(_0x40788c,_0x69a984,_0x4bb6bf){return db[_0x529f('0x2d')][_0x529f('0x78')]({'where':{'id':_0x40788c[_0x529f('0x45')]['id']}})[_0x529f('0x29')](function(_0x306a13){if(_0x306a13){if(!_0x40788c[_0x529f('0x33')][_0x529f('0x6f')]||!utils['isValidChannel'](_0x40788c[_0x529f('0x33')][_0x529f('0x6f')])){throw new db[(_0x529f('0x58'))][(_0x529f('0x79'))](_0x529f('0x71'));}return _0x306a13[_0x529f('0x7c')+_['capitalize'](_0x40788c[_0x529f('0x33')]['channel']['toLowerCase']())+_0x529f('0x76')](_0x40788c[_0x529f('0x33')][_0x529f('0x7a')]);}return null;})[_0x529f('0x29')](handleEntityNotFound(_0x69a984,null))['then'](respondWithStatusCode(_0x69a984,null))['catch'](handleError(_0x69a984,null));};exports[_0x529f('0x7d')]=function(_0x29cc35,_0x342816){var _0x458ada=_[_0x529f('0x7e')](_0x29cc35[_0x529f('0x4b')][_0x529f('0x7a')])?_0x29cc35[_0x529f('0x4b')][_0x529f('0x7a')]:[_0x29cc35[_0x529f('0x4b')][_0x529f('0x7a')]];var _0x1e2a4f=_0x29cc35[_0x529f('0x45')]['id'];return db['Team'][_0x529f('0x48')]({'where':{'id':_0x1e2a4f}})[_0x529f('0x29')](handleEntityNotFound(_0x342816,null))[_0x529f('0x29')](function(_0xae677e){if(_0xae677e){var _0x537896=[_0x529f('0x7f'),'Chat',_0x529f('0x80'),_0x529f('0x81'),'Fax','Openchannel',_0x529f('0x82')];return db[_0x529f('0x55')][_0x529f('0x56')](function(_0x2df48c){var _0x2e28a8=_[_0x529f('0x32')](_0x537896,function(_0x3667e3){var _0x51cd29={'attributes':['id',_0x529f('0x2b')]};if(_0x3667e3===_0x529f('0x7f')){_0x51cd29[_0x529f('0x83')]={'attributes':[_0x529f('0x84')]};}return _0xae677e[_0x529f('0x4d')+_0x3667e3+_0x529f('0x76')](_0x51cd29)[_0x529f('0x29')](function(_0x2b7963){var _0x2ebadc=_[_0x529f('0x32')](_0x2b7963,function(_0x38d051){var _0x3bfe83=_[_0x529f('0x32')](_0x458ada,function(_0x39dc78){var _0xc6486b={'where':{'UserId':_0x39dc78,[_0x3667e3+_0x529f('0x85')]:_0x38d051['id']},'transaction':_0x2df48c};if(_0x3667e3==='Voice'){_0xc6486b[_0x529f('0x1b')]={'penalty':_0x38d051[_0x529f('0x86')]['penalty']};}return db[_0x529f('0x87')+_0x3667e3+_0x529f('0x74')]['findOrCreate'](_0xc6486b)[_0x529f('0x29')](function(){socket[_0x529f('0x88')]('user'+_0x3667e3+_0x529f('0x89'),{'UserId':_0x39dc78,[_0x3667e3+_0x529f('0x85')]:_0x38d051['id']});if(_0x3667e3!==_0x529f('0x7f')){return;}return db[_0x529f('0x87')][_0x529f('0x43')]({'where':{'id':_0x458ada,'online':0x1},'attributes':['id',_0x529f('0x2b'),_0x529f('0x8a'),'voicePause',_0x529f('0x8b')],'raw':!![]})[_0x529f('0x29')](function(_0x31f645){var _0x26fad8=_[_0x529f('0x32')](_0x31f645,function(_0x205065){return db[_0x529f('0x8c')][_0x529f('0x8d')]({'membername':_0x205065['name'],'UserId':_0x205065['id'],'queue_name':_0x38d051[_0x529f('0x2b')],'VoiceQueueId':_0x38d051['id'],'interface':_[_0x529f('0x8e')](_0x205065[_0x529f('0x8b')])?util['format']('SIP/%s',_0x205065[_0x529f('0x2b')]):_0x205065[_0x529f('0x8b')],'paused':_0x205065[_0x529f('0x8f')]||![],'penalty':_0x38d051['TeamVoiceQueue'][_0x529f('0x84')]},{'transaction':_0x2df48c});});return Promise[_0x529f('0x90')](_0x26fad8);});});});return Promise[_0x529f('0x90')](_0x3bfe83);});return Promise['all'](_0x2ebadc);})[_0x529f('0x29')](function(){return db['TeamVoicePrefix']['findOne']({'where':{'teamId':_0x1e2a4f}})['then'](function(_0x185b72){if(_0x185b72){var _0x5a7b8c=_['map'](_0x458ada,function(_0x963c63){db[_0x529f('0x6d')][_0x529f('0x8d')]({'UserId':_0x963c63,'VoicePrefixId':_0x185b72[_0x529f('0x91')]});});return Promise[_0x529f('0x90')](_0x5a7b8c);}});});});return Promise[_0x529f('0x90')](_0x2e28a8)['then'](function(){return _0xae677e[_0x529f('0x7d')](_0x458ada,{'transaction':_0x2df48c})[_0x529f('0x92')](function(_0x464c19){return _0x464c19;});});});}})[_0x529f('0x29')](respondWithResult(_0x342816,null))[_0x529f('0x49')](handleError(_0x342816,null));};exports[_0x529f('0x93')]=function(_0x2aa253,_0x4cded4){var _0xaeaeba=_[_0x529f('0x7e')](_0x2aa253['query'][_0x529f('0x7a')])?_0x2aa253[_0x529f('0x33')][_0x529f('0x7a')]:[_0x2aa253[_0x529f('0x33')]['ids']];var _0xd54448=_0x2aa253['params']['id'];return db[_0x529f('0x2d')][_0x529f('0x48')]({'where':{'id':_0xd54448}})[_0x529f('0x29')](handleEntityNotFound(_0x4cded4,null))[_0x529f('0x29')](function(_0x21b2f4){if(_0x21b2f4){var _0x4bcbc8=[_0x529f('0x7f'),_0x529f('0x94'),'Mail',_0x529f('0x81'),'Fax',_0x529f('0x95'),_0x529f('0x82')];return db[_0x529f('0x55')][_0x529f('0x56')](function(_0xe660a4){var _0x3dd7f3=_[_0x529f('0x32')](_0x4bcbc8,function(_0x1708be){var _0x204394={'attributes':['id',_0x529f('0x2b')]};return _0x21b2f4[_0x529f('0x4d')+_0x1708be+'Queues'](_0x204394)[_0x529f('0x29')](function(_0xf4183){var _0x16a811=_[_0x529f('0x32')](_0xf4183,function(_0x1cf5ae){return _0x1cf5ae['removeAgents'](_0xaeaeba,{'transaction':_0xe660a4})[_0x529f('0x29')](function(){var _0x424c27=_['map'](_0xaeaeba,function(_0x43172b){socket['emit'](_0x529f('0x4c')+_0x1708be+_0x529f('0x96'),{'UserId':Number(_0x43172b),[_0x1708be+_0x529f('0x85')]:_0x1cf5ae['id']});if(_0x1708be!==_0x529f('0x7f')){return;}return db[_0x529f('0x8c')]['destroy']({'where':{'VoiceQueueId':_0x1cf5ae['id'],'UserId':_0x43172b},'transaction':_0xe660a4});});return Promise[_0x529f('0x90')](_0x424c27);});});return Promise[_0x529f('0x90')](_0x16a811);});});return Promise['all'](_0x3dd7f3)[_0x529f('0x29')](function(){return _0x21b2f4[_0x529f('0x93')](_0xaeaeba,{'transaction':_0xe660a4});})[_0x529f('0x29')](function(){return db['TeamVoicePrefix'][_0x529f('0x78')]({'where':{'teamId':_0xd54448}})[_0x529f('0x29')](function(_0x28e15f){if(_0x28e15f){var _0x3f1b0a=_[_0x529f('0x32')](_0xaeaeba,function(_0x315d16){db[_0x529f('0x6d')][_0x529f('0x54')]({'where':{'UserId':_0x315d16,'VoicePrefixId':_0x28e15f[_0x529f('0x91')]}});});return Promise[_0x529f('0x90')](_0x3f1b0a);}});});});}})['then'](respondWithStatusCode(_0x4cded4,null))[_0x529f('0x49')](handleError(_0x4cded4,null));};exports[_0x529f('0x97')]=function(_0x54af22,_0x385baa,_0xb0dd65){var _0x1eef02={};var _0x40ce20={};var _0x48de07;var _0xca906b;return db[_0x529f('0x2d')]['findOne']({'where':{'id':_0x54af22['params']['id']}})[_0x529f('0x29')](handleEntityNotFound(_0x385baa,null))[_0x529f('0x29')](function(_0x5b3e23){if(_0x5b3e23){_0x48de07=_0x5b3e23;_0x40ce20['model']=_[_0x529f('0x34')](db[_0x529f('0x87')][_0x529f('0x75')]);_0x40ce20[_0x529f('0x33')]=_[_0x529f('0x34')](_0x54af22[_0x529f('0x33')]);_0x40ce20[_0x529f('0x3c')]=_[_0x529f('0x36')](_0x40ce20['model'],_0x40ce20['query']);_0x1eef02[_0x529f('0x35')]=_['intersection'](_0x40ce20[_0x529f('0x31')],qs[_0x529f('0x37')](_0x54af22[_0x529f('0x33')]['fields']));_0x1eef02['attributes']=_0x1eef02[_0x529f('0x35')][_0x529f('0x46')]?_0x1eef02[_0x529f('0x35')]:_0x40ce20[_0x529f('0x31')];_0x1eef02[_0x529f('0x3a')]=qs[_0x529f('0x3b')](_0x54af22[_0x529f('0x33')][_0x529f('0x3b')]);_0x1eef02[_0x529f('0x3e')]=qs[_0x529f('0x3c')](_[_0x529f('0x3d')](_0x54af22[_0x529f('0x33')],_0x40ce20[_0x529f('0x3c')]));if(_0x54af22[_0x529f('0x33')][_0x529f('0x98')]){_0x1eef02['where']=_[_0x529f('0x47')](_0x1eef02['where'],{'$or':_[_0x529f('0x32')](_0x1eef02['attributes'],function(_0x48677d){var _0x40ed05={};_0x40ed05[_0x48677d]={'$like':'%'+_0x54af22[_0x529f('0x33')]['filter']+'%'};return _0x40ed05;})});}_0x1eef02=_[_0x529f('0x47')]({},_0x1eef02,_0x54af22[_0x529f('0x40')]);return _0x48de07['getAgents'](_0x1eef02);}})[_0x529f('0x29')](function(_0x392c7a){if(_0x392c7a){_0xca906b=_0x392c7a['length'];if(!_0x54af22[_0x529f('0x33')][_0x529f('0x38')]('nolimit')){_0x1eef02[_0x529f('0x24')]=qs[_0x529f('0x24')](_0x54af22[_0x529f('0x33')][_0x529f('0x24')]);_0x1eef02[_0x529f('0x26')]=qs[_0x529f('0x26')](_0x54af22[_0x529f('0x33')][_0x529f('0x26')]);}return _0x48de07['getAgents'](_0x1eef02);}})[_0x529f('0x29')](function(_0x17aa20){if(_0x17aa20){return _0x17aa20?{'count':_0xca906b,'rows':_0x17aa20}:null;}})[_0x529f('0x29')](respondWithResult(_0x385baa,null))[_0x529f('0x49')](handleError(_0x385baa,null));}; \ No newline at end of file diff --git a/server/api/team/team.events.js b/server/api/team/team.events.js new file mode 100644 index 0000000..1060eff --- /dev/null +++ b/server/api/team/team.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x680b=['remove','emit','hasOwnProperty','hook','exports','events','save'];(function(_0x81e39d,_0x4c3934){var _0x548fbb=function(_0x1adda5){while(--_0x1adda5){_0x81e39d['push'](_0x81e39d['shift']());}};_0x548fbb(++_0x4c3934);}(_0x680b,0x10f));var _0xb680=function(_0x1a2ccd,_0x356f8c){_0x1a2ccd=_0x1a2ccd-0x0;var _0x52fb4f=_0x680b[_0x1a2ccd];return _0x52fb4f;};'use strict';var EventEmitter=require(_0xb680('0x0'));var Team=require('../../mysqldb')['db']['Team'];var TeamEvents=new EventEmitter();TeamEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xb680('0x1'),'afterUpdate':'update','afterDestroy':_0xb680('0x2')};function emitEvent(_0x50ba97){return function(_0x12a8cf,_0x4869c4,_0x302f73){TeamEvents[_0xb680('0x3')](_0x50ba97+':'+_0x12a8cf['id'],_0x12a8cf);TeamEvents['emit'](_0x50ba97,_0x12a8cf);_0x302f73(null);};}for(var e in events){if(events[_0xb680('0x4')](e)){var event=events[e];Team[_0xb680('0x5')](e,emitEvent(event));}}module[_0xb680('0x6')]=TeamEvents; \ No newline at end of file diff --git a/server/api/team/team.model.js b/server/api/team/team.model.js new file mode 100644 index 0000000..6d5d104 --- /dev/null +++ b/server/api/team/team.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbb00=['then','map','catch','exports','define','Team','teams','Fax','Mail','Openchannel','Sms','Voice','resolve','all','lodash','get'];(function(_0x32f7d7,_0x54231b){var _0x133d09=function(_0x41a7ab){while(--_0x41a7ab){_0x32f7d7['push'](_0x32f7d7['shift']());}};_0x133d09(++_0x54231b);}(_0xbb00,0x13e));var _0x0bb0=function(_0x29b1b7,_0x9947f){_0x29b1b7=_0x29b1b7-0x0;var _0x326e97=_0xbb00[_0x29b1b7];return _0x326e97;};'use strict';var _=require(_0x0bb0('0x0'));var attributes=require('./team.attributes');function getQueuesByChannel(_0x1a24fc,_0x35b047){var _0x1bd1aa=_0x0bb0('0x1')+_0x35b047+'Queues';return _0x1a24fc[_0x1bd1aa]()[_0x0bb0('0x2')](function(_0x217ceb){return _[_0x0bb0('0x3')](_0x217ceb,function(_0x1a114d){_0x1a114d['setDataValue']('channel',_0x35b047);return _0x1a114d;});})[_0x0bb0('0x4')](function(_0x321ddb){throw _0x321ddb;});}module[_0x0bb0('0x5')]=function(_0x1a5f38){return _0x1a5f38[_0x0bb0('0x6')](_0x0bb0('0x7'),attributes,{'tableName':_0x0bb0('0x8'),'paranoid':![],'indexes':[],'timestamps':!![],'instanceMethods':{'getAssociatedQueues':function(){var _0x5c1960=this;var _0x22b9bd=['Chat',_0x0bb0('0x9'),_0x0bb0('0xa'),_0x0bb0('0xb'),_0x0bb0('0xc'),_0x0bb0('0xd'),'Whatsapp'];return Promise[_0x0bb0('0xe')]()['then'](function(){var _0xad7d2d=_[_0x0bb0('0x3')](_0x22b9bd,function(_0x237c49){return getQueuesByChannel(_0x5c1960,_0x237c49);});return Promise[_0x0bb0('0xf')](_0xad7d2d);})['catch'](function(_0x4ffdf0){throw _0x4ffdf0;});}}});}; \ No newline at end of file diff --git a/server/api/team/team.rpc.js b/server/api/team/team.rpc.js new file mode 100644 index 0000000..e54ca3a --- /dev/null +++ b/server/api/team/team.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4855=['moment','bluebird','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./team.socket','register','request','info','request\x20sent','Team,\x20%s,\x20%s,\x20%s','error','code','Team,\x20%s,\x20%s','message','catch','lodash','util'];(function(_0x1b85b3,_0x23861a){var _0x35a6b9=function(_0x1b663e){while(--_0x1b663e){_0x1b85b3['push'](_0x1b85b3['shift']());}};_0x35a6b9(++_0x23861a);}(_0x4855,0x1d9));var _0x5485=function(_0x10bae6,_0x41d85f){_0x10bae6=_0x10bae6-0x0;var _0x251123=_0x4855[_0x10bae6];return _0x251123;};'use strict';var _=require(_0x5485('0x0'));var util=require(_0x5485('0x1'));var moment=require(_0x5485('0x2'));var BPromise=require(_0x5485('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5485('0x4'));var db=require(_0x5485('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x5485('0x6'))('rpc');var config=require(_0x5485('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x5485('0x8')][_0x5485('0x9')]({'port':0x232a});config[_0x5485('0xa')]=_[_0x5485('0xb')](config[_0x5485('0xa')],{'host':_0x5485('0xc'),'port':0x18eb});var socket=require(_0x5485('0xd'))(new Redis(config[_0x5485('0xa')]));require(_0x5485('0xe'))[_0x5485('0xf')](socket);function respondWithRpcPromise(_0x7ce15e,_0x76b576,_0x233cc1){return new BPromise(function(_0x5b9662,_0x31786f){return client[_0x5485('0x10')](_0x7ce15e,_0x233cc1)['then'](function(_0x30688c){logger[_0x5485('0x11')]('Team,\x20%s,\x20%s',_0x76b576,_0x5485('0x12'));logger['debug'](_0x5485('0x13'),_0x76b576,_0x5485('0x12'),JSON['stringify'](_0x30688c));if(_0x30688c['error']){if(_0x30688c[_0x5485('0x14')][_0x5485('0x15')]===0x1f4){logger[_0x5485('0x14')](_0x5485('0x16'),_0x76b576,_0x30688c[_0x5485('0x14')][_0x5485('0x17')]);return _0x31786f(_0x30688c['error'][_0x5485('0x17')]);}logger[_0x5485('0x14')](_0x5485('0x16'),_0x76b576,_0x30688c[_0x5485('0x14')][_0x5485('0x17')]);return _0x5b9662(_0x30688c[_0x5485('0x14')][_0x5485('0x17')]);}else{logger[_0x5485('0x11')]('Team,\x20%s,\x20%s',_0x76b576,_0x5485('0x12'));_0x5b9662(_0x30688c['result']['message']);}})[_0x5485('0x18')](function(_0x36e66c){logger[_0x5485('0x14')]('Team,\x20%s,\x20%s',_0x76b576,_0x36e66c);_0x31786f(_0x36e66c);});});} \ No newline at end of file diff --git a/server/api/team/team.socket.js b/server/api/team/team.socket.js new file mode 100644 index 0000000..837f455 --- /dev/null +++ b/server/api/team/team.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe62a=['team:','./team.events','save','emit','removeListener','register','length'];(function(_0x1f951b,_0x654997){var _0x503af0=function(_0x40a7d9){while(--_0x40a7d9){_0x1f951b['push'](_0x1f951b['shift']());}};_0x503af0(++_0x654997);}(_0xe62a,0x143));var _0xae62=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0xe62a[_0x19950b];return _0x3c6b41;};'use strict';var TeamEvents=require(_0xae62('0x0'));var events=[_0xae62('0x1'),'remove','update'];function createListener(_0x4b6bce,_0x10f15b){return function(_0x37923c){_0x10f15b[_0xae62('0x2')](_0x4b6bce,_0x37923c);};}function removeListener(_0x3ce754,_0x2bb2ba){return function(){TeamEvents[_0xae62('0x3')](_0x3ce754,_0x2bb2ba);};}exports[_0xae62('0x4')]=function(_0x1c69d8){for(var _0x10a5dd=0x0,_0x362244=events[_0xae62('0x5')];_0x10a5dd<_0x362244;_0x10a5dd++){var _0x2a8d24=events[_0x10a5dd];var _0x891ab3=createListener(_0xae62('0x6')+_0x2a8d24,_0x1c69d8);TeamEvents['on'](_0x2a8d24,_0x891ab3);}}; \ No newline at end of file diff --git a/server/api/teamVoicePrefix/teamVoicePrefix.attributes.js b/server/api/teamVoicePrefix/teamVoicePrefix.attributes.js new file mode 100644 index 0000000..23ebf6a --- /dev/null +++ b/server/api/teamVoicePrefix/teamVoicePrefix.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbc47=['exports','INTEGER','sequelize'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xbc47,0x7a));var _0x7bc4=function(_0x279d37,_0x14de3f){_0x279d37=_0x279d37-0x0;var _0x530173=_0xbc47[_0x279d37];return _0x530173;};'use strict';var Sequelize=require(_0x7bc4('0x0'));module[_0x7bc4('0x1')]={'TeamId':{'type':Sequelize[_0x7bc4('0x2')]},'VoicePrefixId':{'type':Sequelize[_0x7bc4('0x2')]}}; \ No newline at end of file diff --git a/server/api/teamVoicePrefix/teamVoicePrefix.model.js b/server/api/teamVoicePrefix/teamVoicePrefix.model.js new file mode 100644 index 0000000..c663263 --- /dev/null +++ b/server/api/teamVoicePrefix/teamVoicePrefix.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf996=['path','rimraf','../../config/environment','./teamVoicePrefix.attributes','exports','define','TeamVoicePrefix','team_has_voice_prefixes','lodash','util','../../config/logger','moment'];(function(_0x50d984,_0x4d41e4){var _0xa81ece=function(_0x45e047){while(--_0x45e047){_0x50d984['push'](_0x50d984['shift']());}};_0xa81ece(++_0x4d41e4);}(_0xf996,0x74));var _0x6f99=function(_0x48b7ca,_0x592d87){_0x48b7ca=_0x48b7ca-0x0;var _0x2d4fda=_0xf996[_0x48b7ca];return _0x2d4fda;};'use strict';var _=require(_0x6f99('0x0'));var util=require(_0x6f99('0x1'));var logger=require(_0x6f99('0x2'))('api');var moment=require(_0x6f99('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0x6f99('0x4'));var rimraf=require(_0x6f99('0x5'));var config=require(_0x6f99('0x6'));var attributes=require(_0x6f99('0x7'));module[_0x6f99('0x8')]=function(_0xf2b5ee,_0xa07ac1){return _0xf2b5ee[_0x6f99('0x9')](_0x6f99('0xa'),attributes,{'tableName':_0x6f99('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/teamVoiceQueue/index.js b/server/api/teamVoiceQueue/index.js new file mode 100644 index 0000000..a6b752c --- /dev/null +++ b/server/api/teamVoiceQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','multer','util'];(function(_0x2c3255,_0x4e00ae){var _0x282aba=function(_0x5721d5){while(--_0x5721d5){_0x2c3255['push'](_0x2c3255['shift']());}};_0x282aba(++_0x4e00ae);}(_0xd8b0,0xad));var _0x0d8b=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xd8b0[_0x20a584];return _0x4b41a8;};'use strict';var multer=require(_0x0d8b('0x0'));var util=require(_0x0d8b('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0d8b('0x2')]();var fs_extra=require(_0x0d8b('0x3'));var auth=require(_0x0d8b('0x4'));var interaction=require(_0x0d8b('0x5'));var config=require(_0x0d8b('0x6'));module['exports']=router; \ No newline at end of file diff --git a/server/api/teamVoiceQueue/teamVoiceQueue.attributes.js b/server/api/teamVoiceQueue/teamVoiceQueue.attributes.js new file mode 100644 index 0000000..c9b7819 --- /dev/null +++ b/server/api/teamVoiceQueue/teamVoiceQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3697=['INTEGER','sequelize','exports'];(function(_0x2921de,_0x5896b3){var _0x3b8d59=function(_0x435c59){while(--_0x435c59){_0x2921de['push'](_0x2921de['shift']());}};_0x3b8d59(++_0x5896b3);}(_0x3697,0x1ea));var _0x7369=function(_0x37e0a0,_0x462179){_0x37e0a0=_0x37e0a0-0x0;var _0x21badd=_0x3697[_0x37e0a0];return _0x21badd;};'use strict';var Sequelize=require(_0x7369('0x0'));module[_0x7369('0x1')]={'penalty':{'type':Sequelize[_0x7369('0x2')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/teamVoiceQueue/teamVoiceQueue.model.js b/server/api/teamVoiceQueue/teamVoiceQueue.model.js new file mode 100644 index 0000000..635e863 --- /dev/null +++ b/server/api/teamVoiceQueue/teamVoiceQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5636=['./teamVoiceQueue.attributes','exports','define','TeamVoiceQueue','team_has_voice_queues','lodash','util','bluebird','request-promise','path','../../config/environment'];(function(_0x287883,_0x39bc56){var _0x477ce9=function(_0x28e702){while(--_0x28e702){_0x287883['push'](_0x287883['shift']());}};_0x477ce9(++_0x39bc56);}(_0x5636,0x102));var _0x6563=function(_0x48666f,_0x2c7e1a){_0x48666f=_0x48666f-0x0;var _0xc3d576=_0x5636[_0x48666f];return _0xc3d576;};'use strict';var _=require(_0x6563('0x0'));var util=require(_0x6563('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x6563('0x2'));var rp=require(_0x6563('0x3'));var fs=require('fs');var path=require(_0x6563('0x4'));var rimraf=require('rimraf');var config=require(_0x6563('0x5'));var attributes=require(_0x6563('0x6'));module[_0x6563('0x7')]=function(_0x39792f,_0x29f687){return _0x39792f[_0x6563('0x8')](_0x6563('0x9'),attributes,{'tableName':_0x6563('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/teamVoiceQueue/teamVoiceQueue.rpc.js b/server/api/teamVoiceQueue/teamVoiceQueue.rpc.js new file mode 100644 index 0000000..8634c39 --- /dev/null +++ b/server/api/teamVoiceQueue/teamVoiceQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa952=['../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','debug','error','code','TeamVoiceQueue,\x20%s,\x20%s','message','catch','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x54a14f,_0x59c124){var _0x47d334=function(_0xfe197f){while(--_0xfe197f){_0x54a14f['push'](_0x54a14f['shift']());}};_0x47d334(++_0x59c124);}(_0xa952,0x1b2));var _0x2a95=function(_0x1c0713,_0xb12e42){_0x1c0713=_0x1c0713-0x0;var _0x3559a6=_0xa952[_0x1c0713];return _0x3559a6;};'use strict';var _=require(_0x2a95('0x0'));var util=require(_0x2a95('0x1'));var moment=require(_0x2a95('0x2'));var BPromise=require(_0x2a95('0x3'));var rs=require(_0x2a95('0x4'));var fs=require('fs');var Redis=require(_0x2a95('0x5'));var db=require(_0x2a95('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x2a95('0x7'))(_0x2a95('0x8'));var config=require(_0x2a95('0x9'));var jayson=require(_0x2a95('0xa'));var client=jayson['client'][_0x2a95('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1c279d,_0x36e284,_0x538ef9){return new BPromise(function(_0x2a9705,_0x4922bc){return client[_0x2a95('0xc')](_0x1c279d,_0x538ef9)[_0x2a95('0xd')](function(_0x15b1c8){logger[_0x2a95('0xe')]('TeamVoiceQueue,\x20%s,\x20%s',_0x36e284,_0x2a95('0xf'));logger[_0x2a95('0x10')]('TeamVoiceQueue,\x20%s,\x20%s,\x20%s',_0x36e284,_0x2a95('0xf'),JSON['stringify'](_0x15b1c8));if(_0x15b1c8[_0x2a95('0x11')]){if(_0x15b1c8[_0x2a95('0x11')][_0x2a95('0x12')]===0x1f4){logger[_0x2a95('0x11')](_0x2a95('0x13'),_0x36e284,_0x15b1c8[_0x2a95('0x11')][_0x2a95('0x14')]);return _0x4922bc(_0x15b1c8[_0x2a95('0x11')][_0x2a95('0x14')]);}logger['error'](_0x2a95('0x13'),_0x36e284,_0x15b1c8[_0x2a95('0x11')][_0x2a95('0x14')]);return _0x2a9705(_0x15b1c8[_0x2a95('0x11')][_0x2a95('0x14')]);}else{logger[_0x2a95('0xe')]('TeamVoiceQueue,\x20%s,\x20%s',_0x36e284,'request\x20sent');_0x2a9705(_0x15b1c8['result'][_0x2a95('0x14')]);}})[_0x2a95('0x15')](function(_0x3d3448){logger[_0x2a95('0x11')](_0x2a95('0x13'),_0x36e284,_0x3d3448);_0x4922bc(_0x3d3448);});});} \ No newline at end of file diff --git a/server/api/template/index.js b/server/api/template/index.js new file mode 100644 index 0000000..ddf1707 --- /dev/null +++ b/server/api/template/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9fc=['exports','multer','util','path','connect-timeout','express','fs-extra','../../components/interaction/service','../../config/environment','index','/:id','isAuthenticated','show','post','create','put','update','delete'];(function(_0x3743d4,_0x73ba92){var _0x4e3e2f=function(_0x40a8af){while(--_0x40a8af){_0x3743d4['push'](_0x3743d4['shift']());}};_0x4e3e2f(++_0x73ba92);}(_0xa9fc,0x19f));var _0xca9f=function(_0x1602fb,_0x20b6b3){_0x1602fb=_0x1602fb-0x0;var _0x461831=_0xa9fc[_0x1602fb];return _0x461831;};'use strict';var multer=require(_0xca9f('0x0'));var util=require(_0xca9f('0x1'));var path=require(_0xca9f('0x2'));var timeout=require(_0xca9f('0x3'));var express=require(_0xca9f('0x4'));var router=express['Router']();var fs_extra=require(_0xca9f('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0xca9f('0x6'));var config=require(_0xca9f('0x7'));var controller=require('./template.controller');router['get']('/',auth['isAuthenticated'](),controller[_0xca9f('0x8')]);router['get'](_0xca9f('0x9'),auth[_0xca9f('0xa')](),controller[_0xca9f('0xb')]);router[_0xca9f('0xc')]('/',auth[_0xca9f('0xa')](),controller[_0xca9f('0xd')]);router[_0xca9f('0xe')](_0xca9f('0x9'),auth['isAuthenticated'](),controller[_0xca9f('0xf')]);router[_0xca9f('0x10')](_0xca9f('0x9'),auth[_0xca9f('0xa')](),controller['destroy']);module[_0xca9f('0x11')]=router; \ No newline at end of file diff --git a/server/api/template/template.attributes.js b/server/api/template/template.attributes.js new file mode 100644 index 0000000..d346158 --- /dev/null +++ b/server/api/template/template.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8f53=['exports','STRING','sequelize'];(function(_0x496b11,_0x576cb0){var _0x3030ac=function(_0x38185b){while(--_0x38185b){_0x496b11['push'](_0x496b11['shift']());}};_0x3030ac(++_0x576cb0);}(_0x8f53,0x125));var _0x38f5=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x8f53[_0x14add3];return _0x4a174f;};'use strict';var Sequelize=require(_0x38f5('0x0'));module[_0x38f5('0x1')]={'name':{'type':Sequelize[_0x38f5('0x2')]},'description':{'type':Sequelize['STRING']},'html':{'type':Sequelize['TEXT']}}; \ No newline at end of file diff --git a/server/api/template/template.controller.js b/server/api/template/template.controller.js new file mode 100644 index 0000000..841cace --- /dev/null +++ b/server/api/template/template.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4388=['../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','then','end','error','name','send','index','map','Template','fieldName','type','key','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','params','rawAttributes','find','catch','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','Templates','UserProfileSection','userProfileId','body','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment'];(function(_0x2d7e09,_0x16be83){var _0x1ba707=function(_0x4d3063){while(--_0x4d3063){_0x2d7e09['push'](_0x2d7e09['shift']());}};_0x1ba707(++_0x16be83);}(_0x4388,0x127));var _0x8438=function(_0x10a951,_0x5da875){_0x10a951=_0x10a951-0x0;var _0x6da0d=_0x4388[_0x10a951];return _0x6da0d;};'use strict';var emlformat=require(_0x8438('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x8438('0x1'));var jsonpatch=require(_0x8438('0x2'));var rp=require(_0x8438('0x3'));var moment=require(_0x8438('0x4'));var BPromise=require(_0x8438('0x5'));var Mustache=require('mustache');var util=require(_0x8438('0x6'));var path=require(_0x8438('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x8438('0x8'));var _=require('lodash');var squel=require(_0x8438('0x9'));var crypto=require(_0x8438('0xa'));var jsforce=require(_0x8438('0xb'));var deskjs=require(_0x8438('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x8438('0xd'));var Redis=require(_0x8438('0xe'));var authService=require(_0x8438('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x8438('0x10'));var hardwareService=require(_0x8438('0x11'));var logger=require(_0x8438('0x12'))('api');var utils=require(_0x8438('0x13'));var config=require(_0x8438('0x14'));var licenseUtil=require(_0x8438('0x15'));var db=require(_0x8438('0x16'))['db'];function respondWithStatusCode(_0x43fcb5,_0x4fe2d2){_0x4fe2d2=_0x4fe2d2||0xcc;return function(_0x1cf599){if(_0x1cf599){return _0x43fcb5[_0x8438('0x17')](_0x4fe2d2);}return _0x43fcb5[_0x8438('0x18')](_0x4fe2d2)['end']();};}function respondWithResult(_0x403773,_0x57f98e){_0x57f98e=_0x57f98e||0xc8;return function(_0x53224d){if(_0x53224d){return _0x403773[_0x8438('0x18')](_0x57f98e)[_0x8438('0x19')](_0x53224d);}};}function respondWithFilteredResult(_0x562c66,_0x5639f4){return function(_0x4601d9){if(_0x4601d9){var _0x4171f2=typeof _0x5639f4[_0x8438('0x1a')]===_0x8438('0x1b')&&typeof _0x5639f4[_0x8438('0x1c')]===_0x8438('0x1b');var _0x2cbf37=_0x4601d9['count'];var _0x58110d=_0x4171f2?0x0:_0x5639f4['offset'];var _0xccb427=_0x4171f2?_0x4601d9[_0x8438('0x1d')]:_0x5639f4['offset']+_0x5639f4[_0x8438('0x1c')];var _0xa0edc0;if(_0xccb427>=_0x2cbf37){_0xccb427=_0x2cbf37;_0xa0edc0=0xc8;}else{_0xa0edc0=0xce;}_0x562c66['status'](_0xa0edc0);return _0x562c66[_0x8438('0x1e')](_0x8438('0x1f'),_0x58110d+'-'+_0xccb427+'/'+_0x2cbf37)[_0x8438('0x19')](_0x4601d9);}return null;};}function patchUpdates(_0x3c62be){return function(_0x23d43e){try{jsonpatch['apply'](_0x23d43e,_0x3c62be,!![]);}catch(_0x441a8c){return BPromise[_0x8438('0x20')](_0x441a8c);}return _0x23d43e[_0x8438('0x21')]();};}function saveUpdates(_0xcc7d67,_0x391848){return function(_0x59a60c){if(_0x59a60c){return _0x59a60c[_0x8438('0x22')](_0xcc7d67)['then'](function(_0x3ea90b){return _0x3ea90b;});}return null;};}function removeEntity(_0x23947c,_0xd81cf1){return function(_0x2a947b){if(_0x2a947b){return _0x2a947b[_0x8438('0x23')]()[_0x8438('0x24')](function(){var _0x5d4369=_0x2a947b['get']({'plain':!![]});var _0x31a318='Templates';return db['UserProfileResource'][_0x8438('0x23')]({'where':{'type':_0x31a318,'resourceId':_0x5d4369['id']}})['then'](function(){return _0x2a947b;});})[_0x8438('0x24')](function(){_0x23947c['status'](0xcc)[_0x8438('0x25')]();});}};}function handleEntityNotFound(_0x5a80e3,_0x4b4069){return function(_0x1f101a){if(!_0x1f101a){_0x5a80e3[_0x8438('0x17')](0x194);}return _0x1f101a;};}function handleError(_0x3359e6,_0xad7dd4){_0xad7dd4=_0xad7dd4||0x1f4;return function(_0x3f8bae){logger[_0x8438('0x26')](_0x3f8bae['stack']);if(_0x3f8bae[_0x8438('0x27')]){delete _0x3f8bae['name'];}_0x3359e6[_0x8438('0x18')](_0xad7dd4)[_0x8438('0x28')](_0x3f8bae);};}exports[_0x8438('0x29')]=function(_0x1efe7f,_0x5a07d9){var _0x103b8b={},_0x5787a1={},_0x28d6a3={'count':0x0,'rows':[]};var _0x3b0bee=_[_0x8438('0x2a')](db[_0x8438('0x2b')]['rawAttributes'],function(_0x51af99){return{'name':_0x51af99[_0x8438('0x2c')],'type':_0x51af99[_0x8438('0x2d')][_0x8438('0x2e')]};});_0x5787a1['model']=_['map'](_0x3b0bee,'name');_0x5787a1['query']=_[_0x8438('0x2f')](_0x1efe7f[_0x8438('0x30')]);_0x5787a1['filters']=_[_0x8438('0x31')](_0x5787a1[_0x8438('0x32')],_0x5787a1['query']);_0x103b8b[_0x8438('0x33')]=_[_0x8438('0x31')](_0x5787a1[_0x8438('0x32')],qs[_0x8438('0x34')](_0x1efe7f[_0x8438('0x30')]['fields']));_0x103b8b[_0x8438('0x33')]=_0x103b8b['attributes'][_0x8438('0x35')]?_0x103b8b['attributes']:_0x5787a1[_0x8438('0x32')];if(!_0x1efe7f['query'][_0x8438('0x36')](_0x8438('0x37'))){_0x103b8b[_0x8438('0x1c')]=qs[_0x8438('0x1c')](_0x1efe7f[_0x8438('0x30')][_0x8438('0x1c')]);_0x103b8b['offset']=qs[_0x8438('0x1a')](_0x1efe7f[_0x8438('0x30')]['offset']);}_0x103b8b['order']=qs[_0x8438('0x38')](_0x1efe7f[_0x8438('0x30')]['sort']);_0x103b8b[_0x8438('0x39')]=qs[_0x8438('0x3a')](_[_0x8438('0x3b')](_0x1efe7f['query'],_0x5787a1[_0x8438('0x3a')]),_0x3b0bee);if(_0x1efe7f[_0x8438('0x30')][_0x8438('0x3c')]){_0x103b8b['where']=_['merge'](_0x103b8b[_0x8438('0x39')],{'$or':_[_0x8438('0x2a')](_0x3b0bee,function(_0x2687ac){if(_0x2687ac[_0x8438('0x2d')]!==_0x8438('0x3d')){var _0x1197fb={};_0x1197fb[_0x2687ac['name']]={'$like':'%'+_0x1efe7f[_0x8438('0x30')][_0x8438('0x3c')]+'%'};return _0x1197fb;}})});}_0x103b8b=_[_0x8438('0x3e')]({},_0x103b8b,_0x1efe7f[_0x8438('0x3f')]);var _0x5793c4={'where':_0x103b8b[_0x8438('0x39')]};return db['Template'][_0x8438('0x1d')](_0x5793c4)[_0x8438('0x24')](function(_0x303ada){_0x28d6a3[_0x8438('0x1d')]=_0x303ada;if(_0x1efe7f[_0x8438('0x30')][_0x8438('0x40')]){_0x103b8b[_0x8438('0x41')]=[{'all':!![]}];}return db['Template'][_0x8438('0x42')](_0x103b8b);})[_0x8438('0x24')](function(_0x3727e3){_0x28d6a3['rows']=_0x3727e3;return _0x28d6a3;})[_0x8438('0x24')](respondWithFilteredResult(_0x5a07d9,_0x103b8b))['catch'](handleError(_0x5a07d9,null));};exports['show']=function(_0x4d7d60,_0x1781b1){var _0x2d744e={'raw':!![],'where':{'id':_0x4d7d60[_0x8438('0x43')]['id']}},_0x9879b7={};_0x9879b7[_0x8438('0x32')]=_[_0x8438('0x2f')](db[_0x8438('0x2b')][_0x8438('0x44')]);_0x9879b7[_0x8438('0x30')]=_[_0x8438('0x2f')](_0x4d7d60['query']);_0x9879b7['filters']=_[_0x8438('0x31')](_0x9879b7[_0x8438('0x32')],_0x9879b7[_0x8438('0x30')]);_0x2d744e[_0x8438('0x33')]=_[_0x8438('0x31')](_0x9879b7[_0x8438('0x32')],qs[_0x8438('0x34')](_0x4d7d60[_0x8438('0x30')]['fields']));_0x2d744e[_0x8438('0x33')]=_0x2d744e['attributes'][_0x8438('0x35')]?_0x2d744e[_0x8438('0x33')]:_0x9879b7['model'];if(_0x4d7d60[_0x8438('0x30')][_0x8438('0x40')]){_0x2d744e[_0x8438('0x41')]=[{'all':!![]}];}_0x2d744e=_[_0x8438('0x3e')]({},_0x2d744e,_0x4d7d60[_0x8438('0x3f')]);return db[_0x8438('0x2b')][_0x8438('0x45')](_0x2d744e)[_0x8438('0x24')](handleEntityNotFound(_0x1781b1,null))['then'](respondWithResult(_0x1781b1,null))[_0x8438('0x46')](handleError(_0x1781b1,null));};exports[_0x8438('0x47')]=function(_0x30da72,_0x2369b6){return db[_0x8438('0x2b')][_0x8438('0x47')](_0x30da72['body'],{})[_0x8438('0x24')](function(_0x9a11c9){var _0x361630=_0x30da72[_0x8438('0x48')][_0x8438('0x49')]({'plain':!![]});if(!_0x361630)throw new Error(_0x8438('0x4a'));if(_0x361630['role']===_0x8438('0x48')){var _0x54e116=_0x9a11c9['get']({'plain':!![]});var _0x48c290=_0x8438('0x4b');return db[_0x8438('0x4c')]['find']({'where':{'name':_0x48c290,'userProfileId':_0x361630[_0x8438('0x4d')]},'raw':!![]})[_0x8438('0x24')](function(_0xb83c7b){if(_0xb83c7b&&_0xb83c7b['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x54e116[_0x8438('0x27')],'resourceId':_0x54e116['id'],'type':_0xb83c7b[_0x8438('0x27')],'sectionId':_0xb83c7b['id']},{})['then'](function(){return _0x9a11c9;});}else{return _0x9a11c9;}})['catch'](function(_0x3170e9){logger[_0x8438('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3170e9);throw _0x3170e9;});}return _0x9a11c9;})[_0x8438('0x24')](respondWithResult(_0x2369b6,0xc9))['catch'](handleError(_0x2369b6,null));};exports[_0x8438('0x22')]=function(_0x5b9aad,_0x42aab3){if(_0x5b9aad[_0x8438('0x4e')]['id']){delete _0x5b9aad['body']['id'];}return db['Template'][_0x8438('0x45')]({'where':{'id':_0x5b9aad[_0x8438('0x43')]['id']}})[_0x8438('0x24')](handleEntityNotFound(_0x42aab3,null))[_0x8438('0x24')](saveUpdates(_0x5b9aad[_0x8438('0x4e')],null))['then'](respondWithResult(_0x42aab3,null))[_0x8438('0x46')](handleError(_0x42aab3,null));};exports[_0x8438('0x23')]=function(_0x166456,_0xa1de40){return db[_0x8438('0x2b')][_0x8438('0x45')]({'where':{'id':_0x166456[_0x8438('0x43')]['id']}})[_0x8438('0x24')](handleEntityNotFound(_0xa1de40,null))[_0x8438('0x24')](removeEntity(_0xa1de40,null))[_0x8438('0x46')](handleError(_0xa1de40,null));}; \ No newline at end of file diff --git a/server/api/template/template.model.js b/server/api/template/template.model.js new file mode 100644 index 0000000..2abc473 --- /dev/null +++ b/server/api/template/template.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x267f=['rimraf','exports','define','Template','lodash','util','api','request-promise'];(function(_0x88cd7b,_0x4c884c){var _0x56fcc8=function(_0x513b3d){while(--_0x513b3d){_0x88cd7b['push'](_0x88cd7b['shift']());}};_0x56fcc8(++_0x4c884c);}(_0x267f,0x64));var _0xf267=function(_0x562c31,_0x15841a){_0x562c31=_0x562c31-0x0;var _0x480eb4=_0x267f[_0x562c31];return _0x480eb4;};'use strict';var _=require(_0xf267('0x0'));var util=require(_0xf267('0x1'));var logger=require('../../config/logger')(_0xf267('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xf267('0x3'));var fs=require('fs');var path=require('path');var rimraf=require(_0xf267('0x4'));var config=require('../../config/environment');var attributes=require('./template.attributes');module[_0xf267('0x5')]=function(_0xaab24,_0xfb8eca){return _0xaab24[_0xf267('0x6')](_0xf267('0x7'),attributes,{'tableName':'tools_templates','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/template/template.rpc.js b/server/api/template/template.rpc.js new file mode 100644 index 0000000..58868e2 --- /dev/null +++ b/server/api/template/template.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd84=['rpc','../../config/environment','http','request','then','info','Template,\x20%s,\x20%s','request\x20sent','debug','Template,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetTemplate','Template','findAll','options','raw','where','include','map','attributes','model','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0xb24a3e,_0x4a3594){var _0x4038d7=function(_0x1ea3c3){while(--_0x1ea3c3){_0xb24a3e['push'](_0xb24a3e['shift']());}};_0x4038d7(++_0x4a3594);}(_0xcd84,0x1d9));var _0x4cd8=function(_0x236812,_0x40484a){_0x236812=_0x236812-0x0;var _0x28b8e2=_0xcd84[_0x236812];return _0x28b8e2;};'use strict';var _=require('lodash');var util=require(_0x4cd8('0x0'));var moment=require(_0x4cd8('0x1'));var BPromise=require(_0x4cd8('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4cd8('0x3'));var db=require(_0x4cd8('0x4'))['db'];var utils=require(_0x4cd8('0x5'));var logger=require(_0x4cd8('0x6'))(_0x4cd8('0x7'));var config=require(_0x4cd8('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x4cd8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x427835,_0x2fc73f,_0x6cfede){return new BPromise(function(_0x25400f,_0x3389c6){return client[_0x4cd8('0xa')](_0x427835,_0x6cfede)[_0x4cd8('0xb')](function(_0xc4ab9f){logger[_0x4cd8('0xc')](_0x4cd8('0xd'),_0x2fc73f,_0x4cd8('0xe'));logger[_0x4cd8('0xf')](_0x4cd8('0x10'),_0x2fc73f,'request\x20sent',JSON[_0x4cd8('0x11')](_0xc4ab9f));if(_0xc4ab9f[_0x4cd8('0x12')]){if(_0xc4ab9f[_0x4cd8('0x12')][_0x4cd8('0x13')]===0x1f4){logger[_0x4cd8('0x12')](_0x4cd8('0xd'),_0x2fc73f,_0xc4ab9f[_0x4cd8('0x12')][_0x4cd8('0x14')]);return _0x3389c6(_0xc4ab9f[_0x4cd8('0x12')][_0x4cd8('0x14')]);}logger[_0x4cd8('0x12')](_0x4cd8('0xd'),_0x2fc73f,_0xc4ab9f[_0x4cd8('0x12')]['message']);return _0x25400f(_0xc4ab9f[_0x4cd8('0x12')]['message']);}else{logger[_0x4cd8('0xc')](_0x4cd8('0xd'),_0x2fc73f,_0x4cd8('0xe'));_0x25400f(_0xc4ab9f['result'][_0x4cd8('0x14')]);}})[_0x4cd8('0x15')](function(_0x3d0f97){logger[_0x4cd8('0x12')]('Template,\x20%s,\x20%s',_0x2fc73f,_0x3d0f97);_0x3389c6(_0x3d0f97);});});}exports[_0x4cd8('0x16')]=function(_0x47a364){var _0x216aa0=this;return new Promise(function(_0x21b3b6,_0x2a666e){return db[_0x4cd8('0x17')][_0x4cd8('0x18')]({'raw':_0x47a364[_0x4cd8('0x19')]?_0x47a364[_0x4cd8('0x19')][_0x4cd8('0x1a')]===undefined?!![]:![]:!![],'where':_0x47a364[_0x4cd8('0x19')]?_0x47a364[_0x4cd8('0x19')][_0x4cd8('0x1b')]||null:null,'attributes':_0x47a364[_0x4cd8('0x19')]?_0x47a364['options']['attributes']||null:null,'limit':_0x47a364[_0x4cd8('0x19')]?_0x47a364[_0x4cd8('0x19')]['limit']||null:null,'include':_0x47a364[_0x4cd8('0x19')]?_0x47a364[_0x4cd8('0x19')][_0x4cd8('0x1c')]?_[_0x4cd8('0x1d')](_0x47a364[_0x4cd8('0x19')]['include'],function(_0x4ea593){return{'model':db[_0x4ea593['model']],'as':_0x4ea593['as'],'attributes':_0x4ea593[_0x4cd8('0x1e')],'include':_0x4ea593[_0x4cd8('0x1c')]?_['map'](_0x4ea593[_0x4cd8('0x1c')],function(_0x5b0f5f){return{'model':db[_0x5b0f5f[_0x4cd8('0x1f')]],'as':_0x5b0f5f['as'],'attributes':_0x5b0f5f['attributes'],'include':_0x5b0f5f[_0x4cd8('0x1c')]?_[_0x4cd8('0x1d')](_0x5b0f5f[_0x4cd8('0x1c')],function(_0x2675ab){return{'model':db[_0x2675ab[_0x4cd8('0x1f')]],'as':_0x2675ab['as'],'attributes':_0x2675ab[_0x4cd8('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4cd8('0xb')](function(_0x4656d4){logger[_0x4cd8('0xc')](_0x4cd8('0x16'),_0x47a364);logger['debug'](_0x4cd8('0x16'),_0x47a364,JSON[_0x4cd8('0x11')](_0x4656d4));_0x21b3b6(_0x4656d4);})[_0x4cd8('0x15')](function(_0x3cda62){logger[_0x4cd8('0x12')]('GetTemplate',_0x3cda62[_0x4cd8('0x14')],_0x47a364);_0x2a666e(_0x216aa0['error'](0x1f4,_0x3cda62['message']));});});}; \ No newline at end of file diff --git a/server/api/trigger/index.js b/server/api/trigger/index.js new file mode 100644 index 0000000..8c2170e --- /dev/null +++ b/server/api/trigger/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe3f6=['isAuthenticated','index','/:id/all_conditions','/:id/any_conditions','getAnyConditions','/:id/actions','create','post','addAllCondition','addAction','put','/:id','update','exports','multer','util','path','express','fs-extra','../../components/auth/service','../../config/environment','get'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xe3f6,0x92));var _0x6e3f=function(_0x616290,_0x280b7f){_0x616290=_0x616290-0x0;var _0x453879=_0xe3f6[_0x616290];return _0x453879;};'use strict';var multer=require(_0x6e3f('0x0'));var util=require(_0x6e3f('0x1'));var path=require(_0x6e3f('0x2'));var timeout=require('connect-timeout');var express=require(_0x6e3f('0x3'));var router=express['Router']();var fs_extra=require(_0x6e3f('0x4'));var auth=require(_0x6e3f('0x5'));var interaction=require('../../components/interaction/service');var config=require(_0x6e3f('0x6'));var controller=require('./trigger.controller');router[_0x6e3f('0x7')]('/',auth[_0x6e3f('0x8')](),controller[_0x6e3f('0x9')]);router[_0x6e3f('0x7')]('/:id',auth[_0x6e3f('0x8')](),controller['show']);router[_0x6e3f('0x7')](_0x6e3f('0xa'),auth[_0x6e3f('0x8')](),controller['getAllConditions']);router[_0x6e3f('0x7')](_0x6e3f('0xb'),auth[_0x6e3f('0x8')](),controller[_0x6e3f('0xc')]);router[_0x6e3f('0x7')](_0x6e3f('0xd'),auth[_0x6e3f('0x8')](),controller['getActions']);router['post']('/',auth['isAuthenticated'](),controller[_0x6e3f('0xe')]);router[_0x6e3f('0xf')](_0x6e3f('0xa'),auth[_0x6e3f('0x8')](),controller[_0x6e3f('0x10')]);router[_0x6e3f('0xf')]('/:id/any_conditions',auth[_0x6e3f('0x8')](),controller['addAnyCondition']);router['post'](_0x6e3f('0xd'),auth[_0x6e3f('0x8')](),controller[_0x6e3f('0x11')]);router[_0x6e3f('0x12')](_0x6e3f('0x13'),auth['isAuthenticated'](),controller[_0x6e3f('0x14')]);router['delete'](_0x6e3f('0x13'),auth['isAuthenticated'](),controller['destroy']);module[_0x6e3f('0x15')]=router; \ No newline at end of file diff --git a/server/api/trigger/trigger.attributes.js b/server/api/trigger/trigger.attributes.js new file mode 100644 index 0000000..ebea0b9 --- /dev/null +++ b/server/api/trigger/trigger.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaf70=['STRING','exports'];(function(_0x39a6ca,_0x10c9f0){var _0x752c2f=function(_0x3f6ed1){while(--_0x3f6ed1){_0x39a6ca['push'](_0x39a6ca['shift']());}};_0x752c2f(++_0x10c9f0);}(_0xaf70,0x10d));var _0x0af7=function(_0x5c737b,_0x13ad79){_0x5c737b=_0x5c737b-0x0;var _0x2b0492=_0xaf70[_0x5c737b];return _0x2b0492;};'use strict';var Sequelize=require('sequelize');module[_0x0af7('0x0')]={'name':{'type':Sequelize['STRING']},'channel':{'type':Sequelize[_0x0af7('0x1')]},'description':{'type':Sequelize['STRING']},'status':{'type':Sequelize['BOOLEAN'],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/trigger/trigger.controller.js b/server/api/trigger/trigger.controller.js new file mode 100644 index 0000000..2477d69 --- /dev/null +++ b/server/api/trigger/trigger.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5eb4=['TriggerAnyId','Condition','getAllConditions','findOne','getAnyConditions','pick','addAction','TriggerId','Action','getActions','eml-format','rimraf','zip-dir','fast-json-patch','moment','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','apply','reject','save','update','UserProfileResource','destroy','then','sendStatus','error','stack','name','send','index','map','Trigger','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','VIRTUAL','merge','options','includeAll','rows','params','include','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','catch','body','addAllCondition','TriggerAllId'];(function(_0x51d84c,_0x303457){var _0x52a4f2=function(_0x267d3a){while(--_0x267d3a){_0x51d84c['push'](_0x51d84c['shift']());}};_0x52a4f2(++_0x303457);}(_0x5eb4,0x1d6));var _0x45eb=function(_0x15c83b,_0x1299cc){_0x15c83b=_0x15c83b-0x0;var _0x1a54ef=_0x5eb4[_0x15c83b];return _0x1a54ef;};'use strict';var emlformat=require(_0x45eb('0x0'));var rimraf=require(_0x45eb('0x1'));var zipdir=require(_0x45eb('0x2'));var jsonpatch=require(_0x45eb('0x3'));var rp=require('request-promise');var moment=require(_0x45eb('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x45eb('0x5'));var path=require(_0x45eb('0x6'));var sox=require(_0x45eb('0x7'));var csv=require(_0x45eb('0x8'));var ejs=require(_0x45eb('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x45eb('0xa'));var crypto=require(_0x45eb('0xb'));var jsforce=require(_0x45eb('0xc'));var deskjs=require(_0x45eb('0xd'));var toCsv=require(_0x45eb('0x8'));var querystring=require(_0x45eb('0xe'));var Papa=require(_0x45eb('0xf'));var Redis=require('ioredis');var authService=require(_0x45eb('0x10'));var qs=require(_0x45eb('0x11'));var as=require(_0x45eb('0x12'));var hardwareService=require(_0x45eb('0x13'));var logger=require('../../config/logger')(_0x45eb('0x14'));var utils=require(_0x45eb('0x15'));var config=require(_0x45eb('0x16'));var licenseUtil=require(_0x45eb('0x17'));var db=require(_0x45eb('0x18'))['db'];function respondWithStatusCode(_0x4cc905,_0x3c581f){_0x3c581f=_0x3c581f||0xcc;return function(_0x1761b6){if(_0x1761b6){return _0x4cc905['sendStatus'](_0x3c581f);}return _0x4cc905[_0x45eb('0x19')](_0x3c581f)[_0x45eb('0x1a')]();};}function respondWithResult(_0x3163ad,_0x210c03){_0x210c03=_0x210c03||0xc8;return function(_0x4bd580){if(_0x4bd580){return _0x3163ad[_0x45eb('0x19')](_0x210c03)[_0x45eb('0x1b')](_0x4bd580);}};}function respondWithFilteredResult(_0x371524,_0xe528f){return function(_0x2aba46){if(_0x2aba46){var _0xe24d6d=typeof _0xe528f[_0x45eb('0x1c')]===_0x45eb('0x1d')&&typeof _0xe528f[_0x45eb('0x1e')]===_0x45eb('0x1d');var _0x103cd9=_0x2aba46[_0x45eb('0x1f')];var _0x49720a=_0xe24d6d?0x0:_0xe528f[_0x45eb('0x1c')];var _0x51dcab=_0xe24d6d?_0x2aba46['count']:_0xe528f['offset']+_0xe528f[_0x45eb('0x1e')];var _0x4e2e1a;if(_0x51dcab>=_0x103cd9){_0x51dcab=_0x103cd9;_0x4e2e1a=0xc8;}else{_0x4e2e1a=0xce;}_0x371524['status'](_0x4e2e1a);return _0x371524['set']('Content-Range',_0x49720a+'-'+_0x51dcab+'/'+_0x103cd9)[_0x45eb('0x1b')](_0x2aba46);}return null;};}function patchUpdates(_0x50ddd2){return function(_0x241099){try{jsonpatch[_0x45eb('0x20')](_0x241099,_0x50ddd2,!![]);}catch(_0x262b55){return BPromise[_0x45eb('0x21')](_0x262b55);}return _0x241099[_0x45eb('0x22')]();};}function saveUpdates(_0x5e0435,_0x231082){return function(_0x26e976){if(_0x26e976){return _0x26e976[_0x45eb('0x23')](_0x5e0435)['then'](function(_0x164ddf){return _0x164ddf;});}return null;};}function removeEntity(_0x473e2d,_0x167725){return function(_0x289902){if(_0x289902){return _0x289902['destroy']()['then'](function(){var _0x56cc58=_0x289902['get']({'plain':!![]});var _0x4b9fb4='Triggers';return db[_0x45eb('0x24')][_0x45eb('0x25')]({'where':{'type':_0x4b9fb4,'resourceId':_0x56cc58['id']}})[_0x45eb('0x26')](function(){return _0x289902;});})[_0x45eb('0x26')](function(){_0x473e2d[_0x45eb('0x19')](0xcc)[_0x45eb('0x1a')]();});}};}function handleEntityNotFound(_0x12524d,_0x2d0373){return function(_0xdd6a28){if(!_0xdd6a28){_0x12524d[_0x45eb('0x27')](0x194);}return _0xdd6a28;};}function handleError(_0x150ac4,_0x5b4a4a){_0x5b4a4a=_0x5b4a4a||0x1f4;return function(_0x2a62e1){logger[_0x45eb('0x28')](_0x2a62e1[_0x45eb('0x29')]);if(_0x2a62e1[_0x45eb('0x2a')]){delete _0x2a62e1['name'];}_0x150ac4[_0x45eb('0x19')](_0x5b4a4a)[_0x45eb('0x2b')](_0x2a62e1);};}exports[_0x45eb('0x2c')]=function(_0x44ac5e,_0x455b85){var _0x56acb8={},_0x4e3122={},_0x5ed7b2={'count':0x0,'rows':[]};var _0x3c15f0=_[_0x45eb('0x2d')](db[_0x45eb('0x2e')][_0x45eb('0x2f')],function(_0x2ddc63){return{'name':_0x2ddc63[_0x45eb('0x30')],'type':_0x2ddc63[_0x45eb('0x31')]['key']};});_0x4e3122[_0x45eb('0x32')]=_[_0x45eb('0x2d')](_0x3c15f0,_0x45eb('0x2a'));_0x4e3122[_0x45eb('0x33')]=_[_0x45eb('0x34')](_0x44ac5e[_0x45eb('0x33')]);_0x4e3122[_0x45eb('0x35')]=_[_0x45eb('0x36')](_0x4e3122[_0x45eb('0x32')],_0x4e3122[_0x45eb('0x33')]);_0x56acb8[_0x45eb('0x37')]=_[_0x45eb('0x36')](_0x4e3122['model'],qs[_0x45eb('0x38')](_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x38')]));_0x56acb8[_0x45eb('0x37')]=_0x56acb8['attributes'][_0x45eb('0x39')]?_0x56acb8[_0x45eb('0x37')]:_0x4e3122[_0x45eb('0x32')];if(!_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x3a')](_0x45eb('0x3b'))){_0x56acb8[_0x45eb('0x1e')]=qs[_0x45eb('0x1e')](_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x1e')]);_0x56acb8[_0x45eb('0x1c')]=qs[_0x45eb('0x1c')](_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x1c')]);}_0x56acb8[_0x45eb('0x3c')]=qs[_0x45eb('0x3d')](_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x3d')]);_0x56acb8[_0x45eb('0x3e')]=qs[_0x45eb('0x35')](_['pick'](_0x44ac5e[_0x45eb('0x33')],_0x4e3122[_0x45eb('0x35')]),_0x3c15f0);if(_0x44ac5e['query'][_0x45eb('0x3f')]){_0x56acb8['where']=_['merge'](_0x56acb8[_0x45eb('0x3e')],{'$or':_[_0x45eb('0x2d')](_0x3c15f0,function(_0x1d7207){if(_0x1d7207[_0x45eb('0x31')]!==_0x45eb('0x40')){var _0x2c7d27={};_0x2c7d27[_0x1d7207[_0x45eb('0x2a')]]={'$like':'%'+_0x44ac5e['query']['filter']+'%'};return _0x2c7d27;}})});}_0x56acb8=_[_0x45eb('0x41')]({},_0x56acb8,_0x44ac5e[_0x45eb('0x42')]);var _0x38c350={'where':_0x56acb8[_0x45eb('0x3e')]};return db[_0x45eb('0x2e')][_0x45eb('0x1f')](_0x38c350)[_0x45eb('0x26')](function(_0x705c5e){_0x5ed7b2[_0x45eb('0x1f')]=_0x705c5e;if(_0x44ac5e[_0x45eb('0x33')][_0x45eb('0x43')]){_0x56acb8['include']=[{'all':!![]}];}return db[_0x45eb('0x2e')]['findAll'](_0x56acb8);})['then'](function(_0x3ab2d1){_0x5ed7b2[_0x45eb('0x44')]=_0x3ab2d1;return _0x5ed7b2;})[_0x45eb('0x26')](respondWithFilteredResult(_0x455b85,_0x56acb8))['catch'](handleError(_0x455b85,null));};exports['show']=function(_0x4a56d1,_0xcdf901){var _0x3ffefa={'raw':![],'where':{'id':_0x4a56d1[_0x45eb('0x45')]['id']}},_0x5ec5a5={};_0x5ec5a5[_0x45eb('0x32')]=_[_0x45eb('0x34')](db[_0x45eb('0x2e')]['rawAttributes']);_0x5ec5a5[_0x45eb('0x33')]=_[_0x45eb('0x34')](_0x4a56d1[_0x45eb('0x33')]);_0x5ec5a5['filters']=_[_0x45eb('0x36')](_0x5ec5a5['model'],_0x5ec5a5[_0x45eb('0x33')]);_0x3ffefa['attributes']=_[_0x45eb('0x36')](_0x5ec5a5[_0x45eb('0x32')],qs[_0x45eb('0x38')](_0x4a56d1[_0x45eb('0x33')][_0x45eb('0x38')]));_0x3ffefa['attributes']=_0x3ffefa[_0x45eb('0x37')][_0x45eb('0x39')]?_0x3ffefa[_0x45eb('0x37')]:_0x5ec5a5[_0x45eb('0x32')];if(_0x4a56d1['query'][_0x45eb('0x43')]){_0x3ffefa[_0x45eb('0x46')]=[{'all':!![]}];}_0x3ffefa=_['merge']({},_0x3ffefa,_0x4a56d1[_0x45eb('0x42')]);return db['Trigger'][_0x45eb('0x47')](_0x3ffefa)[_0x45eb('0x26')](handleEntityNotFound(_0xcdf901,null))[_0x45eb('0x26')](respondWithResult(_0xcdf901,null))['catch'](handleError(_0xcdf901,null));};exports[_0x45eb('0x48')]=function(_0x1e5adc,_0x4738f7){return db[_0x45eb('0x2e')]['create'](_0x1e5adc['body'],{})[_0x45eb('0x26')](function(_0x4bfe7d){var _0x150285=_0x1e5adc[_0x45eb('0x49')][_0x45eb('0x4a')]({'plain':!![]});if(!_0x150285)throw new Error(_0x45eb('0x4b'));if(_0x150285[_0x45eb('0x4c')]===_0x45eb('0x49')){var _0xc77996=_0x4bfe7d[_0x45eb('0x4a')]({'plain':!![]});var _0x1d801c='Triggers';return db[_0x45eb('0x4d')][_0x45eb('0x47')]({'where':{'name':_0x1d801c,'userProfileId':_0x150285['userProfileId']},'raw':!![]})[_0x45eb('0x26')](function(_0x3fe992){if(_0x3fe992&&_0x3fe992['autoAssociation']===0x0){return db[_0x45eb('0x24')][_0x45eb('0x48')]({'name':_0xc77996['name'],'resourceId':_0xc77996['id'],'type':_0x3fe992[_0x45eb('0x2a')],'sectionId':_0x3fe992['id']},{})[_0x45eb('0x26')](function(){return _0x4bfe7d;});}else{return _0x4bfe7d;}})[_0x45eb('0x4e')](function(_0xae871b){logger[_0x45eb('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xae871b);throw _0xae871b;});}return _0x4bfe7d;})['then'](respondWithResult(_0x4738f7,0xc9))[_0x45eb('0x4e')](handleError(_0x4738f7,null));};exports[_0x45eb('0x23')]=function(_0x421be8,_0x1e8604){if(_0x421be8[_0x45eb('0x4f')]['id']){delete _0x421be8['body']['id'];}return db['Trigger'][_0x45eb('0x47')]({'where':{'id':_0x421be8[_0x45eb('0x45')]['id']}})['then'](handleEntityNotFound(_0x1e8604,null))[_0x45eb('0x26')](saveUpdates(_0x421be8[_0x45eb('0x4f')],null))[_0x45eb('0x26')](respondWithResult(_0x1e8604,null))[_0x45eb('0x4e')](handleError(_0x1e8604,null));};exports[_0x45eb('0x25')]=function(_0x24eb54,_0xaf5b03){return db[_0x45eb('0x2e')]['find']({'where':{'id':_0x24eb54[_0x45eb('0x45')]['id']}})['then'](handleEntityNotFound(_0xaf5b03,null))[_0x45eb('0x26')](removeEntity(_0xaf5b03,null))['catch'](handleError(_0xaf5b03,null));};exports[_0x45eb('0x50')]=function(_0x218fb8,_0xc02d32,_0x2c78a2){if(_0x218fb8[_0x45eb('0x4f')]['id']){delete _0x218fb8[_0x45eb('0x4f')]['id'];}return db[_0x45eb('0x2e')][_0x45eb('0x47')]({'where':{'id':_0x218fb8[_0x45eb('0x45')]['id']}})[_0x45eb('0x26')](handleEntityNotFound(_0xc02d32,null))[_0x45eb('0x26')](function(_0x52a76f){if(_0x52a76f){_0x218fb8[_0x45eb('0x4f')][_0x45eb('0x51')]=_0x52a76f['id'];return db['Condition'][_0x45eb('0x48')](_0x218fb8['body']);}})[_0x45eb('0x26')](respondWithResult(_0xc02d32,null))[_0x45eb('0x4e')](handleError(_0xc02d32,null));};exports['addAnyCondition']=function(_0x3e94a7,_0x9ee309,_0x5ef509){if(_0x3e94a7['body']['id']){delete _0x3e94a7[_0x45eb('0x4f')]['id'];}return db[_0x45eb('0x2e')]['find']({'where':{'id':_0x3e94a7[_0x45eb('0x45')]['id']}})[_0x45eb('0x26')](handleEntityNotFound(_0x9ee309,null))[_0x45eb('0x26')](function(_0x214b9d){if(_0x214b9d){_0x3e94a7[_0x45eb('0x4f')][_0x45eb('0x52')]=_0x214b9d['id'];return db[_0x45eb('0x53')][_0x45eb('0x48')](_0x3e94a7[_0x45eb('0x4f')]);}})['then'](respondWithResult(_0x9ee309,null))['catch'](handleError(_0x9ee309,null));};exports[_0x45eb('0x54')]=function(_0x277a1d,_0x2b9d52,_0x153228){var _0x15a910={};var _0x4fc7c6={};var _0xe8c72e;var _0x5afcee;return db[_0x45eb('0x2e')][_0x45eb('0x55')]({'where':{'id':_0x277a1d['params']['id']}})['then'](handleEntityNotFound(_0x2b9d52,null))['then'](function(_0x12a767){if(_0x12a767){_0xe8c72e=_0x12a767;_0x4fc7c6[_0x45eb('0x32')]=_[_0x45eb('0x34')](db[_0x45eb('0x53')][_0x45eb('0x2f')]);_0x4fc7c6['query']=_[_0x45eb('0x34')](_0x277a1d[_0x45eb('0x33')]);_0x4fc7c6['filters']=_[_0x45eb('0x36')](_0x4fc7c6[_0x45eb('0x32')],_0x4fc7c6['query']);_0x15a910[_0x45eb('0x37')]=_[_0x45eb('0x36')](_0x4fc7c6['model'],qs[_0x45eb('0x38')](_0x277a1d[_0x45eb('0x33')][_0x45eb('0x38')]));_0x15a910[_0x45eb('0x37')]=_0x15a910[_0x45eb('0x37')][_0x45eb('0x39')]?_0x15a910[_0x45eb('0x37')]:_0x4fc7c6['model'];_0x15a910['order']=qs[_0x45eb('0x3d')](_0x277a1d[_0x45eb('0x33')][_0x45eb('0x3d')]);_0x15a910[_0x45eb('0x3e')]=qs[_0x45eb('0x35')](_['pick'](_0x277a1d['query'],_0x4fc7c6[_0x45eb('0x35')]));if(_0x277a1d[_0x45eb('0x33')][_0x45eb('0x3f')]){_0x15a910[_0x45eb('0x3e')]=_[_0x45eb('0x41')](_0x15a910[_0x45eb('0x3e')],{'$or':_['map'](_0x15a910['attributes'],function(_0x2ab2e6){var _0x2ae790={};_0x2ae790[_0x2ab2e6]={'$like':'%'+_0x277a1d[_0x45eb('0x33')][_0x45eb('0x3f')]+'%'};return _0x2ae790;})});}_0x15a910=_[_0x45eb('0x41')]({},_0x15a910,_0x277a1d[_0x45eb('0x42')]);return _0xe8c72e[_0x45eb('0x54')](_0x15a910);}})[_0x45eb('0x26')](function(_0x49fb58){if(_0x49fb58){_0x5afcee=_0x49fb58[_0x45eb('0x39')];if(!_0x277a1d[_0x45eb('0x33')]['hasOwnProperty']('nolimit')){_0x15a910[_0x45eb('0x1e')]=qs[_0x45eb('0x1e')](_0x277a1d[_0x45eb('0x33')][_0x45eb('0x1e')]);_0x15a910['offset']=qs['offset'](_0x277a1d[_0x45eb('0x33')]['offset']);}return _0xe8c72e[_0x45eb('0x54')](_0x15a910);}})[_0x45eb('0x26')](function(_0x971fa1){if(_0x971fa1){return _0x971fa1?{'count':_0x5afcee,'rows':_0x971fa1}:null;}})[_0x45eb('0x26')](respondWithResult(_0x2b9d52,null))['catch'](handleError(_0x2b9d52,null));};exports[_0x45eb('0x56')]=function(_0x2a2a5f,_0x215b48,_0x193f92){var _0x2a2959={};var _0x398266={};var _0x1d35b3;var _0x1093dd;return db[_0x45eb('0x2e')][_0x45eb('0x55')]({'where':{'id':_0x2a2a5f[_0x45eb('0x45')]['id']}})[_0x45eb('0x26')](handleEntityNotFound(_0x215b48,null))[_0x45eb('0x26')](function(_0x2ad73b){if(_0x2ad73b){_0x1d35b3=_0x2ad73b;_0x398266['model']=_['keys'](db[_0x45eb('0x53')][_0x45eb('0x2f')]);_0x398266[_0x45eb('0x33')]=_['keys'](_0x2a2a5f[_0x45eb('0x33')]);_0x398266[_0x45eb('0x35')]=_[_0x45eb('0x36')](_0x398266['model'],_0x398266[_0x45eb('0x33')]);_0x2a2959[_0x45eb('0x37')]=_['intersection'](_0x398266[_0x45eb('0x32')],qs['fields'](_0x2a2a5f[_0x45eb('0x33')][_0x45eb('0x38')]));_0x2a2959[_0x45eb('0x37')]=_0x2a2959[_0x45eb('0x37')][_0x45eb('0x39')]?_0x2a2959[_0x45eb('0x37')]:_0x398266[_0x45eb('0x32')];_0x2a2959[_0x45eb('0x3c')]=qs[_0x45eb('0x3d')](_0x2a2a5f[_0x45eb('0x33')]['sort']);_0x2a2959[_0x45eb('0x3e')]=qs[_0x45eb('0x35')](_[_0x45eb('0x57')](_0x2a2a5f['query'],_0x398266[_0x45eb('0x35')]));if(_0x2a2a5f[_0x45eb('0x33')][_0x45eb('0x3f')]){_0x2a2959[_0x45eb('0x3e')]=_[_0x45eb('0x41')](_0x2a2959[_0x45eb('0x3e')],{'$or':_['map'](_0x2a2959['attributes'],function(_0x392d2b){var _0x4a685f={};_0x4a685f[_0x392d2b]={'$like':'%'+_0x2a2a5f['query'][_0x45eb('0x3f')]+'%'};return _0x4a685f;})});}_0x2a2959=_[_0x45eb('0x41')]({},_0x2a2959,_0x2a2a5f[_0x45eb('0x42')]);return _0x1d35b3[_0x45eb('0x56')](_0x2a2959);}})[_0x45eb('0x26')](function(_0x4d2f28){if(_0x4d2f28){_0x1093dd=_0x4d2f28[_0x45eb('0x39')];if(!_0x2a2a5f[_0x45eb('0x33')][_0x45eb('0x3a')](_0x45eb('0x3b'))){_0x2a2959[_0x45eb('0x1e')]=qs[_0x45eb('0x1e')](_0x2a2a5f['query']['limit']);_0x2a2959['offset']=qs[_0x45eb('0x1c')](_0x2a2a5f['query'][_0x45eb('0x1c')]);}return _0x1d35b3[_0x45eb('0x56')](_0x2a2959);}})['then'](function(_0xf45206){if(_0xf45206){return _0xf45206?{'count':_0x1093dd,'rows':_0xf45206}:null;}})[_0x45eb('0x26')](respondWithResult(_0x215b48,null))[_0x45eb('0x4e')](handleError(_0x215b48,null));};exports[_0x45eb('0x58')]=function(_0x81c22f,_0x55a18d,_0x3292d7){if(_0x81c22f[_0x45eb('0x4f')]['id']){delete _0x81c22f['body']['id'];}return db[_0x45eb('0x2e')][_0x45eb('0x47')]({'where':{'id':_0x81c22f['params']['id']}})[_0x45eb('0x26')](handleEntityNotFound(_0x55a18d,null))[_0x45eb('0x26')](function(_0x663c5f){if(_0x663c5f){_0x81c22f[_0x45eb('0x4f')][_0x45eb('0x59')]=_0x663c5f['id'];return db['Action'][_0x45eb('0x48')](_0x81c22f['body']);}})[_0x45eb('0x26')](respondWithResult(_0x55a18d,null))[_0x45eb('0x4e')](handleError(_0x55a18d,null));};exports['getActions']=function(_0x2cc0f2,_0x223608,_0x4b7195){var _0x400b58={};var _0x57453e={};var _0x171d25;var _0x522a21;return db[_0x45eb('0x2e')][_0x45eb('0x55')]({'where':{'id':_0x2cc0f2['params']['id']}})[_0x45eb('0x26')](handleEntityNotFound(_0x223608,null))[_0x45eb('0x26')](function(_0x5344da){if(_0x5344da){_0x171d25=_0x5344da;_0x57453e[_0x45eb('0x32')]=_[_0x45eb('0x34')](db[_0x45eb('0x5a')][_0x45eb('0x2f')]);_0x57453e['query']=_['keys'](_0x2cc0f2['query']);_0x57453e[_0x45eb('0x35')]=_[_0x45eb('0x36')](_0x57453e[_0x45eb('0x32')],_0x57453e[_0x45eb('0x33')]);_0x400b58['attributes']=_['intersection'](_0x57453e[_0x45eb('0x32')],qs[_0x45eb('0x38')](_0x2cc0f2['query'][_0x45eb('0x38')]));_0x400b58[_0x45eb('0x37')]=_0x400b58[_0x45eb('0x37')][_0x45eb('0x39')]?_0x400b58[_0x45eb('0x37')]:_0x57453e[_0x45eb('0x32')];_0x400b58[_0x45eb('0x3c')]=qs[_0x45eb('0x3d')](_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x3d')]);_0x400b58['where']=qs[_0x45eb('0x35')](_[_0x45eb('0x57')](_0x2cc0f2[_0x45eb('0x33')],_0x57453e[_0x45eb('0x35')]));if(_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x3f')]){_0x400b58[_0x45eb('0x3e')]=_[_0x45eb('0x41')](_0x400b58['where'],{'$or':_[_0x45eb('0x2d')](_0x400b58['attributes'],function(_0x5b7a8f){var _0x1d2bdc={};_0x1d2bdc[_0x5b7a8f]={'$like':'%'+_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x3f')]+'%'};return _0x1d2bdc;})});}_0x400b58=_[_0x45eb('0x41')]({},_0x400b58,_0x2cc0f2[_0x45eb('0x42')]);return _0x171d25[_0x45eb('0x5b')](_0x400b58);}})['then'](function(_0x51e6de){if(_0x51e6de){_0x522a21=_0x51e6de[_0x45eb('0x39')];if(!_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x3a')](_0x45eb('0x3b'))){_0x400b58[_0x45eb('0x1e')]=qs[_0x45eb('0x1e')](_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x1e')]);_0x400b58[_0x45eb('0x1c')]=qs[_0x45eb('0x1c')](_0x2cc0f2[_0x45eb('0x33')][_0x45eb('0x1c')]);}return _0x171d25[_0x45eb('0x5b')](_0x400b58);}})[_0x45eb('0x26')](function(_0x3f1650){if(_0x3f1650){return _0x3f1650?{'count':_0x522a21,'rows':_0x3f1650}:null;}})[_0x45eb('0x26')](respondWithResult(_0x223608,null))[_0x45eb('0x4e')](handleError(_0x223608,null));}; \ No newline at end of file diff --git a/server/api/trigger/trigger.model.js b/server/api/trigger/trigger.model.js new file mode 100644 index 0000000..51c4e69 --- /dev/null +++ b/server/api/trigger/trigger.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfe60=['define','Trigger','tools_triggers','util','api','moment','bluebird','path','rimraf','../../config/environment','./trigger.attributes','exports'];(function(_0x4cba56,_0x5b2c44){var _0x3cc9f3=function(_0x5bb80a){while(--_0x5bb80a){_0x4cba56['push'](_0x4cba56['shift']());}};_0x3cc9f3(++_0x5b2c44);}(_0xfe60,0x1cb));var _0x0fe6=function(_0x25962a,_0x1011b2){_0x25962a=_0x25962a-0x0;var _0x117af3=_0xfe60[_0x25962a];return _0x117af3;};'use strict';var _=require('lodash');var util=require(_0x0fe6('0x0'));var logger=require('../../config/logger')(_0x0fe6('0x1'));var moment=require(_0x0fe6('0x2'));var BPromise=require(_0x0fe6('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x0fe6('0x4'));var rimraf=require(_0x0fe6('0x5'));var config=require(_0x0fe6('0x6'));var attributes=require(_0x0fe6('0x7'));module[_0x0fe6('0x8')]=function(_0x1281fc,_0x13b947){return _0x1281fc[_0x0fe6('0x9')](_0x0fe6('0xa'),attributes,{'tableName':_0x0fe6('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/trigger/trigger.rpc.js b/server/api/trigger/trigger.rpc.js new file mode 100644 index 0000000..fbcda6a --- /dev/null +++ b/server/api/trigger/trigger.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf68c=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','then','request\x20sent','stringify','error','code','Trigger,\x20%s,\x20%s','message','info','result','catch','GetTrigger','Trigger','findAll','options','raw','where','limit','include','map','model','attributes','ShowTrigger','lodash','util'];(function(_0x5cbe5e,_0x259669){var _0x57db9f=function(_0x14c544){while(--_0x14c544){_0x5cbe5e['push'](_0x5cbe5e['shift']());}};_0x57db9f(++_0x259669);}(_0xf68c,0x152));var _0xcf68=function(_0x4d0856,_0x102ed6){_0x4d0856=_0x4d0856-0x0;var _0x783ff6=_0xf68c[_0x4d0856];return _0x783ff6;};'use strict';var _=require(_0xcf68('0x0'));var util=require(_0xcf68('0x1'));var moment=require(_0xcf68('0x2'));var BPromise=require(_0xcf68('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcf68('0x4'));var db=require(_0xcf68('0x5'))['db'];var utils=require(_0xcf68('0x6'));var logger=require('../../config/logger')(_0xcf68('0x7'));var config=require(_0xcf68('0x8'));var jayson=require(_0xcf68('0x9'));var client=jayson[_0xcf68('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x546e73,_0x57edc5,_0x5a6091){return new BPromise(function(_0x48e749,_0x37a783){return client[_0xcf68('0xb')](_0x546e73,_0x5a6091)[_0xcf68('0xc')](function(_0x36c02d){logger['info']('Trigger,\x20%s,\x20%s',_0x57edc5,_0xcf68('0xd'));logger['debug']('Trigger,\x20%s,\x20%s,\x20%s',_0x57edc5,_0xcf68('0xd'),JSON[_0xcf68('0xe')](_0x36c02d));if(_0x36c02d['error']){if(_0x36c02d[_0xcf68('0xf')][_0xcf68('0x10')]===0x1f4){logger[_0xcf68('0xf')](_0xcf68('0x11'),_0x57edc5,_0x36c02d[_0xcf68('0xf')][_0xcf68('0x12')]);return _0x37a783(_0x36c02d['error'][_0xcf68('0x12')]);}logger[_0xcf68('0xf')](_0xcf68('0x11'),_0x57edc5,_0x36c02d['error'][_0xcf68('0x12')]);return _0x48e749(_0x36c02d[_0xcf68('0xf')][_0xcf68('0x12')]);}else{logger[_0xcf68('0x13')]('Trigger,\x20%s,\x20%s',_0x57edc5,'request\x20sent');_0x48e749(_0x36c02d[_0xcf68('0x14')]['message']);}})[_0xcf68('0x15')](function(_0xd8896b){logger['error'](_0xcf68('0x11'),_0x57edc5,_0xd8896b);_0x37a783(_0xd8896b);});});}exports[_0xcf68('0x16')]=function(_0x5e17aa){var _0x598c32=this;return new Promise(function(_0x3c5bf5,_0x35e546){return db[_0xcf68('0x17')][_0xcf68('0x18')]({'raw':_0x5e17aa[_0xcf68('0x19')]?_0x5e17aa[_0xcf68('0x19')][_0xcf68('0x1a')]===undefined?!![]:![]:!![],'where':_0x5e17aa[_0xcf68('0x19')]?_0x5e17aa[_0xcf68('0x19')][_0xcf68('0x1b')]||null:null,'attributes':_0x5e17aa[_0xcf68('0x19')]?_0x5e17aa[_0xcf68('0x19')]['attributes']||null:null,'limit':_0x5e17aa[_0xcf68('0x19')]?_0x5e17aa[_0xcf68('0x19')][_0xcf68('0x1c')]||null:null,'include':_0x5e17aa[_0xcf68('0x19')]?_0x5e17aa[_0xcf68('0x19')][_0xcf68('0x1d')]?_[_0xcf68('0x1e')](_0x5e17aa[_0xcf68('0x19')]['include'],function(_0x542b6c){return{'model':db[_0x542b6c[_0xcf68('0x1f')]],'as':_0x542b6c['as'],'attributes':_0x542b6c[_0xcf68('0x20')],'include':_0x542b6c[_0xcf68('0x1d')]?_['map'](_0x542b6c[_0xcf68('0x1d')],function(_0xc48bb0){return{'model':db[_0xc48bb0['model']],'as':_0xc48bb0['as'],'attributes':_0xc48bb0[_0xcf68('0x20')],'include':_0xc48bb0[_0xcf68('0x1d')]?_[_0xcf68('0x1e')](_0xc48bb0[_0xcf68('0x1d')],function(_0x182a0d){return{'model':db[_0x182a0d[_0xcf68('0x1f')]],'as':_0x182a0d['as'],'attributes':_0x182a0d[_0xcf68('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1411db){logger[_0xcf68('0x13')]('GetTrigger',_0x5e17aa);logger['debug'](_0xcf68('0x16'),_0x5e17aa,JSON[_0xcf68('0xe')](_0x1411db));_0x3c5bf5(_0x1411db);})[_0xcf68('0x15')](function(_0x48816b){logger['error'](_0xcf68('0x16'),_0x48816b[_0xcf68('0x12')],_0x5e17aa);_0x35e546(_0x598c32[_0xcf68('0xf')](0x1f4,_0x48816b[_0xcf68('0x12')]));});});};exports[_0xcf68('0x21')]=function(_0x53d9d3){var _0x224e14=this;return new Promise(function(_0x42e643,_0x2d7ea4){return db[_0xcf68('0x17')]['find']({'raw':_0x53d9d3[_0xcf68('0x19')]?_0x53d9d3[_0xcf68('0x19')][_0xcf68('0x1a')]===undefined?!![]:![]:!![],'where':_0x53d9d3[_0xcf68('0x19')]?_0x53d9d3['options'][_0xcf68('0x1b')]||null:null,'attributes':_0x53d9d3[_0xcf68('0x19')]?_0x53d9d3[_0xcf68('0x19')]['attributes']||null:null,'include':_0x53d9d3[_0xcf68('0x19')]?_0x53d9d3[_0xcf68('0x19')][_0xcf68('0x1d')]?_['map'](_0x53d9d3[_0xcf68('0x19')][_0xcf68('0x1d')],function(_0x317d10){return{'model':db[_0x317d10['model']],'as':_0x317d10['as'],'attributes':_0x317d10['attributes'],'include':_0x317d10['include']?_[_0xcf68('0x1e')](_0x317d10[_0xcf68('0x1d')],function(_0x42d53a){return{'model':db[_0x42d53a[_0xcf68('0x1f')]],'as':_0x42d53a['as'],'attributes':_0x42d53a[_0xcf68('0x20')],'include':_0x42d53a['include']?_['map'](_0x42d53a['include'],function(_0xb36283){return{'model':db[_0xb36283['model']],'as':_0xb36283['as'],'attributes':_0xb36283['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x53cdf0){logger[_0xcf68('0x13')]('ShowTrigger',_0x53d9d3);logger['debug'](_0xcf68('0x21'),_0x53d9d3,JSON[_0xcf68('0xe')](_0x53cdf0));_0x42e643(_0x53cdf0);})[_0xcf68('0x15')](function(_0xd89388){logger[_0xcf68('0xf')](_0xcf68('0x21'),_0xd89388[_0xcf68('0x12')],_0x53d9d3);_0x2d7ea4(_0x224e14['error'](0x1f4,_0xd89388[_0xcf68('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/trunk/index.js b/server/api/trunk/index.js new file mode 100644 index 0000000..ec940dc --- /dev/null +++ b/server/api/trunk/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0937=['show','post','/:id/clone','isAuthenticated','clone','create','put','/:id','update','destroy','exports','multer','util','path','fs-extra','../../components/auth/service','../../config/environment','./trunk.controller'];(function(_0x322743,_0x3903b9){var _0x13de4d=function(_0x13a597){while(--_0x13a597){_0x322743['push'](_0x322743['shift']());}};_0x13de4d(++_0x3903b9);}(_0x0937,0x197));var _0x7093=function(_0x427ba3,_0x37c2ce){_0x427ba3=_0x427ba3-0x0;var _0x49a8d1=_0x0937[_0x427ba3];return _0x49a8d1;};'use strict';var multer=require(_0x7093('0x0'));var util=require(_0x7093('0x1'));var path=require(_0x7093('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express['Router']();var fs_extra=require(_0x7093('0x3'));var auth=require(_0x7093('0x4'));var interaction=require('../../components/interaction/service');var config=require(_0x7093('0x5'));var controller=require(_0x7093('0x6'));router['get']('/',auth['isAuthenticated'](),controller['index']);router['get']('/:id',auth['isAuthenticated'](),controller[_0x7093('0x7')]);router[_0x7093('0x8')](_0x7093('0x9'),auth[_0x7093('0xa')](),controller[_0x7093('0xb')]);router[_0x7093('0x8')]('/',auth[_0x7093('0xa')](),controller[_0x7093('0xc')]);router[_0x7093('0xd')](_0x7093('0xe'),auth['isAuthenticated'](),controller[_0x7093('0xf')]);router['delete'](_0x7093('0xe'),auth['isAuthenticated'](),controller[_0x7093('0x10')]);module[_0x7093('0x11')]=router; \ No newline at end of file diff --git a/server/api/trunk/trunk.attributes.js b/server/api/trunk/trunk.attributes.js new file mode 100644 index 0000000..49353ca --- /dev/null +++ b/server/api/trunk/trunk.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x48a3=['insecure','never','INTEGER','\x22\x22\x20<>','always','refuse','originate','uac','uas','pai','fingerprint','active','passive','dynamic','nonat','BOOLEAN','sequelize','exports','name','ENUM','user','peer','friend','STRING','ALLOWED_NOT_SCREENED','ALLOWED_PASSED_SCREEN','ALLOWED','PROHIB_NOT_SCREENED','PROHIB_PASSED_SCREEN','PROHIB','udp','transport','join','split','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22udp\x22,\x20\x22tcp\x22]','info','shortinfo','inband','auto','rfc2833','yes','update','outgoing','force_rport,comedia','setDataValue','nat','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22force_rport\x22,\x20\x22comedia\x22]','all','ulaw;alaw;gsm','allow','getDataValue','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22ulaw\x22,\x20\x22alaw\x22,\x20\x22alaw\x22]','port,invite'];(function(_0x3d966a,_0x447353){var _0x4180f0=function(_0x424871){while(--_0x424871){_0x3d966a['push'](_0x3d966a['shift']());}};_0x4180f0(++_0x447353);}(_0x48a3,0x1ed));var _0x348a=function(_0x64e3c1,_0x14da00){_0x64e3c1=_0x64e3c1-0x0;var _0x44adc8=_0x48a3[_0x64e3c1];return _0x44adc8;};'use strict';var Sequelize=require(_0x348a('0x0'));module[_0x348a('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![],'unique':_0x348a('0x2'),'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'type':{'type':Sequelize[_0x348a('0x3')]('friend',_0x348a('0x4'),_0x348a('0x5')),'allowNull':![],'defaultValue':_0x348a('0x6')},'context':{'type':Sequelize[_0x348a('0x7')],'allowNull':![],'defaultValue':'from-voip-provider'},'callingpres':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x8'),_0x348a('0x9'),'ALLOWED_FAILED_SCREEN',_0x348a('0xa'),_0x348a('0xb'),_0x348a('0xc'),'PROHIB_FAILED_SCREEN',_0x348a('0xd'))},'deny':{'type':Sequelize[_0x348a('0x7')]},'permit':{'type':Sequelize[_0x348a('0x7')]},'secret':{'type':Sequelize['STRING']},'md5secret':{'type':Sequelize[_0x348a('0x7')]},'remotesecret':{'type':Sequelize[_0x348a('0x7')]},'transport':{'type':Sequelize[_0x348a('0x7')],'defaultValue':_0x348a('0xe'),'set':function(_0xa2da0d){this['setDataValue'](_0x348a('0xf'),_0xa2da0d?_0xa2da0d[_0x348a('0x10')](','):null);},'get':function(){return this['getDataValue'](_0x348a('0xf'))?this['getDataValue'](_0x348a('0xf'))[_0x348a('0x11')](','):null;},'comment':_0x348a('0x12')},'dtmfmode':{'type':Sequelize[_0x348a('0x3')]('rfc2833',_0x348a('0x13'),_0x348a('0x14'),_0x348a('0x15'),_0x348a('0x16')),'defaultValue':_0x348a('0x17')},'directmedia':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no','nonat',_0x348a('0x19'),_0x348a('0x1a')),'defaultValue':'no'},'directrtpsetup':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no'),'defaultValue':'no'},'directmediapermit':{'type':Sequelize[_0x348a('0x7')]},'directmediadeny':{'type':Sequelize[_0x348a('0x7')]},'nat':{'type':Sequelize[_0x348a('0x7')],'defaultValue':_0x348a('0x1b'),'set':function(_0x1e92d6){this[_0x348a('0x1c')](_0x348a('0x1d'),_0x1e92d6?_0x1e92d6['join'](','):null);},'get':function(){return this['getDataValue'](_0x348a('0x1d'))?this['getDataValue'](_0x348a('0x1d'))[_0x348a('0x11')](','):null;},'comment':_0x348a('0x1e')},'callgroup':{'type':Sequelize[_0x348a('0x7')]},'namedcallgroup':{'type':Sequelize[_0x348a('0x7')]},'pickupgroup':{'type':Sequelize[_0x348a('0x7')]},'namedpickupgroup':{'type':Sequelize[_0x348a('0x7')]},'language':{'type':Sequelize[_0x348a('0x7')],'defaultValue':'en'},'tonezone':{'type':Sequelize['STRING'],'allowNull':!![]},'disallow':{'type':Sequelize['STRING'],'defaultValue':_0x348a('0x1f')},'allow':{'type':Sequelize[_0x348a('0x7')],'allowNull':![],'defaultValue':_0x348a('0x20'),'set':function(_0x30ebcd){this[_0x348a('0x1c')](_0x348a('0x21'),_0x30ebcd?_0x30ebcd[_0x348a('0x10')](';'):_0x348a('0x20'));},'get':function(){return this[_0x348a('0x22')](_0x348a('0x21'))?this[_0x348a('0x22')](_0x348a('0x21'))[_0x348a('0x11')](';'):null;},'comment':_0x348a('0x23')},'autoframing':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'insecure':{'type':Sequelize[_0x348a('0x7')],'defaultValue':_0x348a('0x24'),'set':function(_0x10e120){this[_0x348a('0x1c')]('insecure',_0x10e120?_0x10e120['join'](','):null);},'get':function(){return this[_0x348a('0x22')](_0x348a('0x25'))?this[_0x348a('0x22')](_0x348a('0x25'))[_0x348a('0x11')](','):null;},'comment':'String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22port\x22,\x20\x22invite\x22]'},'trustrpid':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no'),'defaultValue':'no'},'trust_id_outbound':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no'),'defaultValue':'no'},'progressinband':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no',_0x348a('0x26'))},'promiscredir':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no')},'useclientcode':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'accountcode':{'type':Sequelize[_0x348a('0x27')](0xb)},'setvar':{'type':Sequelize['STRING']},'callerid':{'type':Sequelize[_0x348a('0x7')],'defaultValue':_0x348a('0x28')},'amaflags':{'type':Sequelize[_0x348a('0x7')]},'callcounter':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no'),'defaultValue':_0x348a('0x18')},'busylevel':{'type':Sequelize[_0x348a('0x27')](0xb)},'allowoverlap':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no')},'allowsubscribe':{'type':Sequelize['ENUM']('yes','no')},'allowtransfer':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'ignoresdpversion':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'subscribecontext':{'type':Sequelize['STRING']},'template':{'type':Sequelize['STRING']},'videosupport':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no',_0x348a('0x29')),'defaultValue':'no'},'maxcallbitrate':{'type':Sequelize[_0x348a('0x27')](0xb)},'rfc2833compensate':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no')},'mailbox':{'type':Sequelize[_0x348a('0x7')]},'session_timers':{'type':Sequelize[_0x348a('0x3')]('accept',_0x348a('0x2a'),_0x348a('0x2b'))},'session_expires':{'type':Sequelize['INTEGER'](0xb)},'session_minse':{'type':Sequelize[_0x348a('0x27')](0xb)},'session_refresher':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x2c'),_0x348a('0x2d')),'defaultValue':'uas'},'t38pt_usertpsource':{'type':Sequelize[_0x348a('0x7')]},'regexten':{'type':Sequelize[_0x348a('0x7')]},'fromdomain':{'type':Sequelize[_0x348a('0x7')]},'fromuser':{'type':Sequelize[_0x348a('0x7')]},'port':{'type':Sequelize[_0x348a('0x27')](0x5)},'qualify':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no'),'defaultValue':_0x348a('0x18')},'keepalive':{'type':Sequelize[_0x348a('0x27')](0xb)},'defaultip':{'type':Sequelize[_0x348a('0x7')]},'defaultuser':{'type':Sequelize['STRING']},'rtptimeout':{'type':Sequelize[_0x348a('0x27')](0xb)},'rtpholdtimeout':{'type':Sequelize[_0x348a('0x27')](0xb)},'rtpkeepalive':{'type':Sequelize['INTEGER'](0xb)},'sendrpid':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no',_0x348a('0x2e')),'defaultValue':'no'},'outboundproxy':{'type':Sequelize[_0x348a('0x7')]},'callbackextension':{'type':Sequelize[_0x348a('0x7')]},'timert1':{'type':Sequelize['INTEGER'](0xb)},'timerb':{'type':Sequelize[_0x348a('0x27')](0xb)},'qualifyfreq':{'type':Sequelize[_0x348a('0x27')](0xb)},'contactpermit':{'type':Sequelize['STRING']},'contactdeny':{'type':Sequelize[_0x348a('0x7')]},'contactacl':{'type':Sequelize[_0x348a('0x7')]},'unsolicited_mailbox':{'type':Sequelize[_0x348a('0x7')]},'use_q850_reason':{'type':Sequelize[_0x348a('0x7')]},'maxforwards':{'type':Sequelize[_0x348a('0x27')](0xb)},'encryption':{'type':Sequelize[_0x348a('0x3')]('yes','no'),'defaultValue':'no'},'avpf':{'type':Sequelize[_0x348a('0x3')]('yes','no')},'force_avp':{'type':Sequelize[_0x348a('0x3')]('yes','no')},'icesupport':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'dtlsenable':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x18'),'no')},'dtlsverify':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no',_0x348a('0x2f'),'certificate')},'dtlsrekey':{'type':Sequelize[_0x348a('0x27')](0xb)},'dtlscertfile':{'type':Sequelize[_0x348a('0x7')]},'dtlsprivatekey':{'type':Sequelize[_0x348a('0x7')]},'dtlscipher':{'type':Sequelize[_0x348a('0x7')]},'dtlscafile':{'type':Sequelize[_0x348a('0x7')]},'dtlscapath':{'type':Sequelize['STRING']},'dtlssetup':{'type':Sequelize[_0x348a('0x3')](_0x348a('0x30'),_0x348a('0x31'),'actpass'),'allowNull':!![]},'dtlsfingerprint':{'type':Sequelize[_0x348a('0x7')]},'usereqphone':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no'),'defaultValue':'no'},'recordonfeature':{'type':Sequelize[_0x348a('0x7')]},'recordofffeature':{'type':Sequelize[_0x348a('0x7')]},'call_limit':{'type':Sequelize[_0x348a('0x27')](0xb),'defaultValue':0x3e8},'registertrying':{'type':Sequelize[_0x348a('0x3')]('yes','no')},'subscribemwi':{'type':Sequelize[_0x348a('0x3')]('yes','no')},'vmexten':{'type':Sequelize[_0x348a('0x7')]},'mohinterpret':{'type':Sequelize[_0x348a('0x7')]},'mohsuggest':{'type':Sequelize[_0x348a('0x7')]},'parkinglot':{'type':Sequelize[_0x348a('0x7')]},'description':{'type':Sequelize['STRING']},'host':{'type':Sequelize[_0x348a('0x7')],'defaultValue':_0x348a('0x32')},'canreinvite':{'type':Sequelize['ENUM'](_0x348a('0x18'),'no',_0x348a('0x33'),_0x348a('0x19'),'update,nonat'),'defaultValue':'no'},'registry':{'type':Sequelize[_0x348a('0x7')]},'otherFields':{'type':Sequelize[_0x348a('0x7')]},'active':{'type':Sequelize[_0x348a('0x34')],'allowNull':![],'defaultValue':!![]},'t38pt_udptl':{'type':Sequelize[_0x348a('0x7')],'defaultValue':'no'}}; \ No newline at end of file diff --git a/server/api/trunk/trunk.controller.js b/server/api/trunk/trunk.controller.js new file mode 100644 index 0000000..11bfe24 --- /dev/null +++ b/server/api/trunk/trunk.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9a19=['query','keys','filters','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','show','include','find','clone','params','omit','updatedAt','body','createdAt','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','server/files/templates/trunk.ejs','utf8','root','server/files/templates/registry.ejs','/etc/asterisk/sip_xcally_trunks.conf','registry','render','/etc/asterisk/sip_xcally_registers.conf','chan_sip.so','role','autoAssociation','findAll','readFileSync','writeFileSync','Reload','update','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','then','info','Trunk,\x20%s,\x20%s','request\x20sent','debug','Trunk,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','destroy','get','Trunks','UserProfileResource','stack','name','index','map','Trunk','rawAttributes','fieldName','type'];(function(_0x4ae39d,_0x5c3787){var _0x1015a7=function(_0x261278){while(--_0x261278){_0x4ae39d['push'](_0x4ae39d['shift']());}};_0x1015a7(++_0x5c3787);}(_0x9a19,0x114));var _0x99a1=function(_0x152fe3,_0x12b0c8){_0x152fe3=_0x152fe3-0x0;var _0xc5bb39=_0x9a19[_0x152fe3];return _0xc5bb39;};'use strict';var emlformat=require(_0x99a1('0x0'));var rimraf=require(_0x99a1('0x1'));var zipdir=require(_0x99a1('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x99a1('0x3'));var moment=require(_0x99a1('0x4'));var BPromise=require(_0x99a1('0x5'));var Mustache=require(_0x99a1('0x6'));var util=require(_0x99a1('0x7'));var path=require(_0x99a1('0x8'));var sox=require(_0x99a1('0x9'));var csv=require(_0x99a1('0xa'));var ejs=require(_0x99a1('0xb'));var fs=require('fs');var fs_extra=require(_0x99a1('0xc'));var _=require(_0x99a1('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x99a1('0xe'));var toCsv=require(_0x99a1('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x99a1('0xf'));var authService=require(_0x99a1('0x10'));var qs=require(_0x99a1('0x11'));var as=require(_0x99a1('0x12'));var hardwareService=require(_0x99a1('0x13'));var logger=require('../../config/logger')(_0x99a1('0x14'));var utils=require(_0x99a1('0x15'));var config=require(_0x99a1('0x16'));var licenseUtil=require(_0x99a1('0x17'));var db=require(_0x99a1('0x18'))['db'];var jayson=require(_0x99a1('0x19'));var client=jayson[_0x99a1('0x1a')][_0x99a1('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0xf713b9,_0x40c19c,_0x3a865c,_0x47815e){return new BPromise(function(_0xe1a1f,_0x3c9ef4){var _0x39ee55=_0x47815e||client;return _0x39ee55['request'](_0xf713b9,_0x3a865c)[_0x99a1('0x1c')](function(_0x3e45d4){logger[_0x99a1('0x1d')](_0x99a1('0x1e'),_0x40c19c,_0x99a1('0x1f'));logger[_0x99a1('0x20')](_0x99a1('0x21'),_0x40c19c,'request\x20sent',JSON['stringify'](_0x3e45d4));if(_0x3e45d4[_0x99a1('0x22')]){if(_0x3e45d4[_0x99a1('0x22')][_0x99a1('0x23')]===0x1f4){logger[_0x99a1('0x22')](_0x99a1('0x1e'),_0x40c19c,_0x3e45d4[_0x99a1('0x22')][_0x99a1('0x24')]);return _0x3c9ef4(_0x3e45d4[_0x99a1('0x22')][_0x99a1('0x24')]);}logger[_0x99a1('0x22')](_0x99a1('0x1e'),_0x40c19c,_0x3e45d4['error'][_0x99a1('0x24')]);return _0xe1a1f(_0x3e45d4[_0x99a1('0x22')]['message']);}else{logger[_0x99a1('0x1d')]('Trunk,\x20%s,\x20%s',_0x40c19c,_0x99a1('0x1f'));_0xe1a1f(_0x3e45d4[_0x99a1('0x25')][_0x99a1('0x24')]);}})[_0x99a1('0x26')](function(_0x5a88c6){logger[_0x99a1('0x22')](_0x99a1('0x1e'),_0x40c19c,_0x5a88c6);_0x3c9ef4(_0x5a88c6);});});}function respondWithStatusCode(_0x483c17,_0x44df2d){_0x44df2d=_0x44df2d||0xcc;return function(_0x5b5dfa){if(_0x5b5dfa){return _0x483c17[_0x99a1('0x27')](_0x44df2d);}return _0x483c17[_0x99a1('0x28')](_0x44df2d)[_0x99a1('0x29')]();};}function respondWithResult(_0xdaa27d,_0x3c813){_0x3c813=_0x3c813||0xc8;return function(_0x491341){if(_0x491341){return _0xdaa27d['status'](_0x3c813)[_0x99a1('0x2a')](_0x491341);}};}function respondWithFilteredResult(_0x5dabd9,_0x5dc733){return function(_0xafea84){if(_0xafea84){var _0x440879=typeof _0x5dc733[_0x99a1('0x2b')]===_0x99a1('0x2c')&&typeof _0x5dc733[_0x99a1('0x2d')]===_0x99a1('0x2c');var _0x183037=_0xafea84['count'];var _0xf41b0d=_0x440879?0x0:_0x5dc733['offset'];var _0x255197=_0x440879?_0xafea84[_0x99a1('0x2e')]:_0x5dc733[_0x99a1('0x2b')]+_0x5dc733['limit'];var _0x371edf;if(_0x255197>=_0x183037){_0x255197=_0x183037;_0x371edf=0xc8;}else{_0x371edf=0xce;}_0x5dabd9[_0x99a1('0x28')](_0x371edf);return _0x5dabd9['set'](_0x99a1('0x2f'),_0xf41b0d+'-'+_0x255197+'/'+_0x183037)[_0x99a1('0x2a')](_0xafea84);}return null;};}function patchUpdates(_0x36aa34){return function(_0x303d1e){try{jsonpatch[_0x99a1('0x30')](_0x303d1e,_0x36aa34,!![]);}catch(_0x969f6e){return BPromise[_0x99a1('0x31')](_0x969f6e);}return _0x303d1e[_0x99a1('0x32')]();};}function saveUpdates(_0x52da8d,_0x4960e4){return function(_0x3fa342){if(_0x3fa342){return _0x3fa342['update'](_0x52da8d)[_0x99a1('0x1c')](function(_0x400581){return _0x400581;});}return null;};}function removeEntity(_0x5b1a79,_0xa5972b){return function(_0x3503d5){if(_0x3503d5){return _0x3503d5[_0x99a1('0x33')]()[_0x99a1('0x1c')](function(){var _0x13f4db=_0x3503d5[_0x99a1('0x34')]({'plain':!![]});var _0x3081cd=_0x99a1('0x35');return db[_0x99a1('0x36')][_0x99a1('0x33')]({'where':{'type':_0x3081cd,'resourceId':_0x13f4db['id']}})[_0x99a1('0x1c')](function(){return _0x3503d5;});})[_0x99a1('0x1c')](function(){_0x5b1a79[_0x99a1('0x28')](0xcc)[_0x99a1('0x29')]();});}};}function handleEntityNotFound(_0x55005e,_0x53fed5){return function(_0x46e3f2){if(!_0x46e3f2){_0x55005e[_0x99a1('0x27')](0x194);}return _0x46e3f2;};}function handleError(_0x416a36,_0x4131e0){_0x4131e0=_0x4131e0||0x1f4;return function(_0x2690bd){logger[_0x99a1('0x22')](_0x2690bd[_0x99a1('0x37')]);if(_0x2690bd['name']){delete _0x2690bd[_0x99a1('0x38')];}_0x416a36[_0x99a1('0x28')](_0x4131e0)['send'](_0x2690bd);};}exports[_0x99a1('0x39')]=function(_0x2d328c,_0x391afa){var _0x3cd1a0={},_0x430cbc={},_0x399fd4={'count':0x0,'rows':[]};var _0x30e8a9=_[_0x99a1('0x3a')](db[_0x99a1('0x3b')][_0x99a1('0x3c')],function(_0x1da3e7){return{'name':_0x1da3e7[_0x99a1('0x3d')],'type':_0x1da3e7[_0x99a1('0x3e')]['key']};});_0x430cbc['model']=_['map'](_0x30e8a9,_0x99a1('0x38'));_0x430cbc[_0x99a1('0x3f')]=_[_0x99a1('0x40')](_0x2d328c[_0x99a1('0x3f')]);_0x430cbc[_0x99a1('0x41')]=_['intersection'](_0x430cbc[_0x99a1('0x42')],_0x430cbc[_0x99a1('0x3f')]);_0x3cd1a0[_0x99a1('0x43')]=_['intersection'](_0x430cbc['model'],qs[_0x99a1('0x44')](_0x2d328c[_0x99a1('0x3f')][_0x99a1('0x44')]));_0x3cd1a0['attributes']=_0x3cd1a0[_0x99a1('0x43')][_0x99a1('0x45')]?_0x3cd1a0[_0x99a1('0x43')]:_0x430cbc[_0x99a1('0x42')];if(!_0x2d328c[_0x99a1('0x3f')][_0x99a1('0x46')](_0x99a1('0x47'))){_0x3cd1a0[_0x99a1('0x2d')]=qs[_0x99a1('0x2d')](_0x2d328c[_0x99a1('0x3f')]['limit']);_0x3cd1a0[_0x99a1('0x2b')]=qs[_0x99a1('0x2b')](_0x2d328c[_0x99a1('0x3f')]['offset']);}_0x3cd1a0[_0x99a1('0x48')]=qs['sort'](_0x2d328c[_0x99a1('0x3f')][_0x99a1('0x49')]);_0x3cd1a0[_0x99a1('0x4a')]=qs[_0x99a1('0x41')](_[_0x99a1('0x4b')](_0x2d328c[_0x99a1('0x3f')],_0x430cbc['filters']),_0x30e8a9);if(_0x2d328c[_0x99a1('0x3f')]['filter']){_0x3cd1a0[_0x99a1('0x4a')]=_[_0x99a1('0x4c')](_0x3cd1a0[_0x99a1('0x4a')],{'$or':_[_0x99a1('0x3a')](_0x30e8a9,function(_0x3a0b44){if(_0x3a0b44[_0x99a1('0x3e')]!==_0x99a1('0x4d')){var _0x3861b6={};_0x3861b6[_0x3a0b44[_0x99a1('0x38')]]={'$like':'%'+_0x2d328c[_0x99a1('0x3f')][_0x99a1('0x4e')]+'%'};return _0x3861b6;}})});}_0x3cd1a0=_['merge']({},_0x3cd1a0,_0x2d328c[_0x99a1('0x4f')]);var _0x330e3b={'where':_0x3cd1a0['where']};return db[_0x99a1('0x3b')][_0x99a1('0x2e')](_0x330e3b)[_0x99a1('0x1c')](function(_0x2e377b){_0x399fd4[_0x99a1('0x2e')]=_0x2e377b;if(_0x2d328c[_0x99a1('0x3f')][_0x99a1('0x50')]){_0x3cd1a0['include']=[{'all':!![]}];}return db[_0x99a1('0x3b')]['findAll'](_0x3cd1a0);})[_0x99a1('0x1c')](function(_0x269798){_0x399fd4['rows']=_0x269798;return _0x399fd4;})['then'](respondWithFilteredResult(_0x391afa,_0x3cd1a0))[_0x99a1('0x26')](handleError(_0x391afa,null));};exports[_0x99a1('0x51')]=function(_0x462c15,_0x4519fb){var _0xee2b1b={'raw':![],'where':{'id':_0x462c15['params']['id']}},_0x597836={};_0x597836['model']=_[_0x99a1('0x40')](db[_0x99a1('0x3b')][_0x99a1('0x3c')]);_0x597836[_0x99a1('0x3f')]=_[_0x99a1('0x40')](_0x462c15[_0x99a1('0x3f')]);_0x597836[_0x99a1('0x41')]=_['intersection'](_0x597836[_0x99a1('0x42')],_0x597836[_0x99a1('0x3f')]);_0xee2b1b[_0x99a1('0x43')]=_['intersection'](_0x597836[_0x99a1('0x42')],qs['fields'](_0x462c15['query'][_0x99a1('0x44')]));_0xee2b1b[_0x99a1('0x43')]=_0xee2b1b[_0x99a1('0x43')][_0x99a1('0x45')]?_0xee2b1b[_0x99a1('0x43')]:_0x597836[_0x99a1('0x42')];if(_0x462c15[_0x99a1('0x3f')][_0x99a1('0x50')]){_0xee2b1b[_0x99a1('0x52')]=[{'all':!![]}];}_0xee2b1b=_['merge']({},_0xee2b1b,_0x462c15[_0x99a1('0x4f')]);return db['Trunk'][_0x99a1('0x53')](_0xee2b1b)[_0x99a1('0x1c')](handleEntityNotFound(_0x4519fb,null))['then'](respondWithResult(_0x4519fb,null))[_0x99a1('0x26')](handleError(_0x4519fb,null));};exports[_0x99a1('0x54')]=function(_0x469e10,_0x2b2d63){var _0x2800d5={'where':{'id':_0x469e10[_0x99a1('0x55')]['id']}},_0x1bff78={};_0x1bff78[_0x99a1('0x42')]=_[_0x99a1('0x40')](db[_0x99a1('0x3b')][_0x99a1('0x3c')]);_0x2800d5[_0x99a1('0x43')]=_['intersection'](_0x1bff78['model'],qs[_0x99a1('0x44')](_0x469e10[_0x99a1('0x3f')][_0x99a1('0x44')]));_0x2800d5[_0x99a1('0x43')]=_0x2800d5[_0x99a1('0x43')]['length']?_0x2800d5[_0x99a1('0x43')]:_0x1bff78[_0x99a1('0x42')];if(_0x469e10['query'][_0x99a1('0x50')]){_0x2800d5[_0x99a1('0x52')]=[{'all':!![]}];}_0x2800d5=_[_0x99a1('0x4c')]({},_0x2800d5,_0x469e10[_0x99a1('0x4f')]);return db[_0x99a1('0x3b')]['find'](_0x2800d5)[_0x99a1('0x1c')](handleEntityNotFound(_0x2b2d63,null))[_0x99a1('0x1c')](function(_0x1bb1cb){if(_0x1bb1cb){var _0x22811f=_0x1bb1cb[_0x99a1('0x34')]({'plain':!![]});_0x22811f=qs[_0x99a1('0x56')](_0x22811f,['id','createdAt',_0x99a1('0x57')]);_0x469e10[_0x99a1('0x58')]=_['omit'](_0x469e10[_0x99a1('0x58')],['id',_0x99a1('0x59'),_0x99a1('0x57')]);return db[_0x99a1('0x3b')][_0x99a1('0x5a')](_['merge'](_0x22811f,_0x469e10[_0x99a1('0x58')]),{'include':_0x469e10['query']['includeAll']?[{'all':!![]}]:undefined})['then'](function(_0x38ce3c){var _0x3f7c16=_0x469e10['user']['get']({'plain':!![]});if(!_0x3f7c16)throw new Error(_0x99a1('0x5b'));if(_0x3f7c16['role']===_0x99a1('0x5c')){var _0x263db3=_0x38ce3c[_0x99a1('0x34')]({'plain':!![]});var _0x180c1e='Trunks';return db[_0x99a1('0x5d')][_0x99a1('0x53')]({'where':{'name':_0x180c1e,'userProfileId':_0x3f7c16[_0x99a1('0x5e')]},'raw':!![]})['then'](function(_0x3a62c6){if(_0x3a62c6&&_0x3a62c6['autoAssociation']===0x0){return db[_0x99a1('0x36')][_0x99a1('0x5a')]({'name':_0x263db3[_0x99a1('0x38')],'resourceId':_0x263db3['id'],'type':_0x3a62c6[_0x99a1('0x38')],'sectionId':_0x3a62c6['id']},{})[_0x99a1('0x1c')](function(){return _0x38ce3c;});}else{return _0x38ce3c;}})['catch'](function(_0x4d37f8){logger['error'](_0x99a1('0x5f'),_0x4d37f8);throw _0x4d37f8;});}return _0x38ce3c;});}})[_0x99a1('0x1c')](respondWithResult(_0x2b2d63,0xc9))['catch'](handleError(_0x2b2d63,null));};exports['create']=function(_0x1fe7af,_0x2f5587,_0x401c8f){var _0x509d4f;return db['Trunk'][_0x99a1('0x5a')](_0x1fe7af['body'],{'raw':!![]})[_0x99a1('0x1c')](function(_0x129690){_0x509d4f=_0x129690;return db[_0x99a1('0x3b')]['findAll']({'raw':!![]});})[_0x99a1('0x1c')](function(_0x28c7d8){var _0x4ac99e=fs['readFileSync'](path[_0x99a1('0x60')](config['root'],_0x99a1('0x61')),_0x99a1('0x62'));var _0x30a0a5=fs['readFileSync'](path[_0x99a1('0x60')](config[_0x99a1('0x63')],_0x99a1('0x64')),_0x99a1('0x62'));var _0x3d0ff6=ejs['render'](_0x4ac99e,{'trunks':_0x28c7d8||[]});fs['writeFileSync'](_0x99a1('0x65'),_0x3d0ff6);if(_0x509d4f[_0x99a1('0x66')]){var _0x1750d5=ejs[_0x99a1('0x67')](_0x30a0a5,{'trunks':_0x28c7d8||[]});fs['writeFileSync'](_0x99a1('0x68'),_0x1750d5);}})['then'](function(){return respondWithRpcPromise('Reload',_0x99a1('0x5a'),{'module':_0x99a1('0x69')});})[_0x99a1('0x1c')](function(){var _0x525969=_0x1fe7af[_0x99a1('0x5c')][_0x99a1('0x34')]({'plain':!![]});if(!_0x525969)throw new Error(_0x99a1('0x5b'));if(_0x525969[_0x99a1('0x6a')]===_0x99a1('0x5c')){var _0x4ae313=_0x509d4f[_0x99a1('0x34')]({'plain':!![]});return db[_0x99a1('0x5d')][_0x99a1('0x53')]({'where':{'name':_0x99a1('0x35'),'userProfileId':_0x525969[_0x99a1('0x5e')]},'raw':!![]})[_0x99a1('0x1c')](function(_0x5e42be){if(_0x5e42be&&_0x5e42be[_0x99a1('0x6b')]===0x0){return db[_0x99a1('0x36')][_0x99a1('0x5a')]({'name':_0x4ae313[_0x99a1('0x38')],'resourceId':_0x4ae313['id'],'type':_0x5e42be[_0x99a1('0x38')],'sectionId':_0x5e42be['id']},{})['then'](function(){return _0x509d4f;});}else{return _0x509d4f;}})[_0x99a1('0x26')](function(_0x68c944){logger[_0x99a1('0x22')](_0x99a1('0x5f'),_0x68c944);throw _0x68c944;});}return _0x509d4f;})[_0x99a1('0x1c')](respondWithResult(_0x2f5587,0xc9))[_0x99a1('0x26')](handleError(_0x2f5587,null));};exports['update']=function(_0xaa953e,_0x33d96b,_0x4a5617){var _0x56716a;return db[_0x99a1('0x3b')][_0x99a1('0x53')]({'where':{'id':_0xaa953e['params']['id']}})[_0x99a1('0x1c')](handleEntityNotFound(_0x33d96b,null))[_0x99a1('0x1c')](saveUpdates(_0xaa953e[_0x99a1('0x58')],null))[_0x99a1('0x1c')](function(_0x43156f){if(_0x43156f){_0x56716a=_0x43156f;return db[_0x99a1('0x3b')][_0x99a1('0x6c')]({'raw':!![]});}})[_0x99a1('0x1c')](function(_0x4260d7){if(_0x4260d7){var _0x3e099c=fs[_0x99a1('0x6d')](path[_0x99a1('0x60')](config[_0x99a1('0x63')],'server/files/templates/trunk.ejs'),_0x99a1('0x62'));var _0x5a9a7d=fs['readFileSync'](path[_0x99a1('0x60')](config[_0x99a1('0x63')],_0x99a1('0x64')),_0x99a1('0x62'));var _0xbbbe26=ejs[_0x99a1('0x67')](_0x3e099c,{'trunks':_0x4260d7||[]});fs[_0x99a1('0x6e')](_0x99a1('0x65'),_0xbbbe26);var _0x361ce6=ejs['render'](_0x5a9a7d,{'trunks':_0x4260d7||[]});fs[_0x99a1('0x6e')](_0x99a1('0x68'),_0x361ce6);return respondWithRpcPromise(_0x99a1('0x6f'),_0x99a1('0x70'),{'module':_0x99a1('0x69')});}return null;})[_0x99a1('0x1c')](function(_0x6dab29){if(_0x6dab29){return _0x56716a;}})[_0x99a1('0x1c')](respondWithResult(_0x33d96b,null))['catch'](handleError(_0x33d96b,null));};exports['destroy']=function(_0x51c289,_0x2dd29b,_0x353f25){var _0x53cdb3;return db[_0x99a1('0x3b')][_0x99a1('0x53')]({'where':{'id':_0x51c289[_0x99a1('0x55')]['id']}})[_0x99a1('0x1c')](handleEntityNotFound(_0x2dd29b,null))['then'](removeEntity(_0x2dd29b,null))[_0x99a1('0x1c')](function(){return db[_0x99a1('0x3b')][_0x99a1('0x6c')]({'raw':!![]});})[_0x99a1('0x1c')](function(_0x4e9fe9){var _0x24aa05=fs['readFileSync'](path['join'](config['root'],_0x99a1('0x61')),'utf8');var _0xb7744c=fs[_0x99a1('0x6d')](path[_0x99a1('0x60')](config[_0x99a1('0x63')],_0x99a1('0x64')),_0x99a1('0x62'));var _0x444e43=ejs['render'](_0x24aa05,{'trunks':_0x4e9fe9});var _0x4fcd65=ejs[_0x99a1('0x67')](_0xb7744c,{'trunks':_0x4e9fe9});fs[_0x99a1('0x6e')](_0x99a1('0x65'),_0x444e43);fs['writeFileSync'](_0x99a1('0x68'),_0x4fcd65);return respondWithRpcPromise(_0x99a1('0x6f'),_0x99a1('0x33'),{'module':'chan_sip.so'});})[_0x99a1('0x26')](handleError(_0x2dd29b,null));}; \ No newline at end of file diff --git a/server/api/trunk/trunk.model.js b/server/api/trunk/trunk.model.js new file mode 100644 index 0000000..5999c9c --- /dev/null +++ b/server/api/trunk/trunk.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa7f8=['api','moment','request-promise','path','rimraf','exports','define','Trunk','tools_trunks','lodash','util','../../config/logger'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa7f8,0x195));var _0x8a7f=function(_0x3d34da,_0x3abcc1){_0x3d34da=_0x3d34da-0x0;var _0xcf6af8=_0xa7f8[_0x3d34da];return _0xcf6af8;};'use strict';var _=require(_0x8a7f('0x0'));var util=require(_0x8a7f('0x1'));var logger=require(_0x8a7f('0x2'))(_0x8a7f('0x3'));var moment=require(_0x8a7f('0x4'));var BPromise=require('bluebird');var rp=require(_0x8a7f('0x5'));var fs=require('fs');var path=require(_0x8a7f('0x6'));var rimraf=require(_0x8a7f('0x7'));var config=require('../../config/environment');var attributes=require('./trunk.attributes');module[_0x8a7f('0x8')]=function(_0x3369b5,_0x345f63){return _0x3369b5[_0x8a7f('0x9')](_0x8a7f('0xa'),attributes,{'tableName':_0x8a7f('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/trunk/trunk.rpc.js b/server/api/trunk/trunk.rpc.js new file mode 100644 index 0000000..f7e9d85 --- /dev/null +++ b/server/api/trunk/trunk.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9f5=['Trunk,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','GetTrunk','Trunk','findAll','options','raw','where','attributes','map','include','model','catch','find','ShowTrunk','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','Trunk,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x8a25ce,_0x1d3d41){var _0x195a76=function(_0x37787e){while(--_0x37787e){_0x8a25ce['push'](_0x8a25ce['shift']());}};_0x195a76(++_0x1d3d41);}(_0xa9f5,0x17c));var _0x5a9f=function(_0x24c643,_0x5555c6){_0x24c643=_0x24c643-0x0;var _0x51afe6=_0xa9f5[_0x24c643];return _0x51afe6;};'use strict';var _=require(_0x5a9f('0x0'));var util=require(_0x5a9f('0x1'));var moment=require('moment');var BPromise=require(_0x5a9f('0x2'));var rs=require(_0x5a9f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5a9f('0x4'))['db'];var utils=require(_0x5a9f('0x5'));var logger=require(_0x5a9f('0x6'))(_0x5a9f('0x7'));var config=require(_0x5a9f('0x8'));var jayson=require(_0x5a9f('0x9'));var client=jayson[_0x5a9f('0xa')][_0x5a9f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4393c,_0xb4234e,_0x53e462){return new BPromise(function(_0x3c2a53,_0x543cc3){return client['request'](_0x4393c,_0x53e462)[_0x5a9f('0xc')](function(_0x321803){logger['info'](_0x5a9f('0xd'),_0xb4234e,_0x5a9f('0xe'));logger[_0x5a9f('0xf')](_0x5a9f('0x10'),_0xb4234e,_0x5a9f('0xe'),JSON[_0x5a9f('0x11')](_0x321803));if(_0x321803[_0x5a9f('0x12')]){if(_0x321803[_0x5a9f('0x12')][_0x5a9f('0x13')]===0x1f4){logger[_0x5a9f('0x12')](_0x5a9f('0xd'),_0xb4234e,_0x321803[_0x5a9f('0x12')][_0x5a9f('0x14')]);return _0x543cc3(_0x321803[_0x5a9f('0x12')][_0x5a9f('0x14')]);}logger[_0x5a9f('0x12')](_0x5a9f('0xd'),_0xb4234e,_0x321803[_0x5a9f('0x12')]['message']);return _0x3c2a53(_0x321803[_0x5a9f('0x12')][_0x5a9f('0x14')]);}else{logger[_0x5a9f('0x15')]('Trunk,\x20%s,\x20%s',_0xb4234e,_0x5a9f('0xe'));_0x3c2a53(_0x321803[_0x5a9f('0x16')][_0x5a9f('0x14')]);}})['catch'](function(_0x1092ac){logger[_0x5a9f('0x12')](_0x5a9f('0xd'),_0xb4234e,_0x1092ac);_0x543cc3(_0x1092ac);});});}exports[_0x5a9f('0x17')]=function(_0x4706e0){var _0x3038e1=this;return new Promise(function(_0x7dfda6,_0x55649f){return db[_0x5a9f('0x18')][_0x5a9f('0x19')]({'raw':_0x4706e0[_0x5a9f('0x1a')]?_0x4706e0[_0x5a9f('0x1a')][_0x5a9f('0x1b')]===undefined?!![]:![]:!![],'where':_0x4706e0[_0x5a9f('0x1a')]?_0x4706e0[_0x5a9f('0x1a')][_0x5a9f('0x1c')]||null:null,'attributes':_0x4706e0['options']?_0x4706e0[_0x5a9f('0x1a')][_0x5a9f('0x1d')]||null:null,'limit':_0x4706e0['options']?_0x4706e0[_0x5a9f('0x1a')]['limit']||null:null,'include':_0x4706e0[_0x5a9f('0x1a')]?_0x4706e0[_0x5a9f('0x1a')]['include']?_[_0x5a9f('0x1e')](_0x4706e0[_0x5a9f('0x1a')][_0x5a9f('0x1f')],function(_0x3bb460){return{'model':db[_0x3bb460['model']],'as':_0x3bb460['as'],'attributes':_0x3bb460[_0x5a9f('0x1d')],'include':_0x3bb460[_0x5a9f('0x1f')]?_['map'](_0x3bb460['include'],function(_0x36f1dc){return{'model':db[_0x36f1dc['model']],'as':_0x36f1dc['as'],'attributes':_0x36f1dc[_0x5a9f('0x1d')],'include':_0x36f1dc[_0x5a9f('0x1f')]?_[_0x5a9f('0x1e')](_0x36f1dc[_0x5a9f('0x1f')],function(_0x361dd1){return{'model':db[_0x361dd1[_0x5a9f('0x20')]],'as':_0x361dd1['as'],'attributes':_0x361dd1[_0x5a9f('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5a9f('0xc')](function(_0x6a089a){logger[_0x5a9f('0x15')](_0x5a9f('0x17'),_0x4706e0);logger['debug']('GetTrunk',_0x4706e0,JSON[_0x5a9f('0x11')](_0x6a089a));_0x7dfda6(_0x6a089a);})[_0x5a9f('0x21')](function(_0x3c10a9){logger['error'](_0x5a9f('0x17'),_0x3c10a9[_0x5a9f('0x14')],_0x4706e0);_0x55649f(_0x3038e1[_0x5a9f('0x12')](0x1f4,_0x3c10a9[_0x5a9f('0x14')]));});});};exports['ShowTrunk']=function(_0x2c518a){var _0xf7efa9=this;return new Promise(function(_0x4a0d1f,_0x103a6c){return db['Trunk'][_0x5a9f('0x22')]({'raw':_0x2c518a[_0x5a9f('0x1a')]?_0x2c518a[_0x5a9f('0x1a')][_0x5a9f('0x1b')]===undefined?!![]:![]:!![],'where':_0x2c518a[_0x5a9f('0x1a')]?_0x2c518a['options'][_0x5a9f('0x1c')]||null:null,'attributes':_0x2c518a['options']?_0x2c518a[_0x5a9f('0x1a')]['attributes']||null:null,'include':_0x2c518a[_0x5a9f('0x1a')]?_0x2c518a['options'][_0x5a9f('0x1f')]?_['map'](_0x2c518a['options'][_0x5a9f('0x1f')],function(_0x1c51af){return{'model':db[_0x1c51af[_0x5a9f('0x20')]],'as':_0x1c51af['as'],'attributes':_0x1c51af[_0x5a9f('0x1d')],'include':_0x1c51af[_0x5a9f('0x1f')]?_[_0x5a9f('0x1e')](_0x1c51af[_0x5a9f('0x1f')],function(_0x186f87){return{'model':db[_0x186f87[_0x5a9f('0x20')]],'as':_0x186f87['as'],'attributes':_0x186f87['attributes'],'include':_0x186f87[_0x5a9f('0x1f')]?_[_0x5a9f('0x1e')](_0x186f87['include'],function(_0x2e8c49){return{'model':db[_0x2e8c49[_0x5a9f('0x20')]],'as':_0x2e8c49['as'],'attributes':_0x2e8c49[_0x5a9f('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5a9f('0xc')](function(_0x2f05bd){logger[_0x5a9f('0x15')](_0x5a9f('0x23'),_0x2c518a);logger['debug']('ShowTrunk',_0x2c518a,JSON['stringify'](_0x2f05bd));_0x4a0d1f(_0x2f05bd);})['catch'](function(_0x4a920b){logger['error'](_0x5a9f('0x23'),_0x4a920b[_0x5a9f('0x14')],_0x2c518a);_0x103a6c(_0xf7efa9[_0x5a9f('0x12')](0x1f4,_0x4a920b[_0x5a9f('0x14')]));});});}; \ No newline at end of file diff --git a/server/api/user-setting/index.js b/server/api/user-setting/index.js new file mode 100644 index 0000000..3e0cba0 --- /dev/null +++ b/server/api/user-setting/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x21d0=['update','exports','../../components/auth/service','./user-setting.controller','put','/:id','isAuthenticated'];(function(_0x3f4def,_0x21d1aa){var _0x5a2c09=function(_0xefd26b){while(--_0xefd26b){_0x3f4def['push'](_0x3f4def['shift']());}};_0x5a2c09(++_0x21d1aa);}(_0x21d0,0x16e));var _0x021d=function(_0x56d54c,_0x24037a){_0x56d54c=_0x56d54c-0x0;var _0x35fd91=_0x21d0[_0x56d54c];return _0x35fd91;};'use strict';var express=require('express');var router=express['Router']();var auth=require(_0x021d('0x0'));var controller=require(_0x021d('0x1'));router[_0x021d('0x2')](_0x021d('0x3'),auth[_0x021d('0x4')](),controller[_0x021d('0x5')]);module[_0x021d('0x6')]=router; \ No newline at end of file diff --git a/server/api/user-setting/user-setting.attributes.js b/server/api/user-setting/user-setting.attributes.js new file mode 100644 index 0000000..d9bf19f --- /dev/null +++ b/server/api/user-setting/user-setting.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb702=['error','info','debug','exports','ENUM','DATE','INTEGER','UserId'];(function(_0x502eb9,_0x279312){var _0x49f697=function(_0x287dc2){while(--_0x287dc2){_0x502eb9['push'](_0x502eb9['shift']());}};_0x49f697(++_0x279312);}(_0xb702,0x130));var _0x2b70=function(_0x5e8c32,_0x1b1f3f){_0x5e8c32=_0x5e8c32-0x0;var _0x595f7b=_0xb702[_0x5e8c32];return _0x595f7b;};'use strict';var Sequelize=require('sequelize');const CLIENT_SIDE_LOG_LEVELS=[_0x2b70('0x0'),'warning',_0x2b70('0x1'),_0x2b70('0x2')];module[_0x2b70('0x3')]={'clientSideLoggingLevel':{'type':Sequelize[_0x2b70('0x4')](CLIENT_SIDE_LOG_LEVELS),'allowNull':![],'defaultValue':_0x2b70('0x0'),'validate':{'isIn':[CLIENT_SIDE_LOG_LEVELS]}},'clientSideLoggingEnabled':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'clientSideLoggingScopes':{'type':Sequelize['TEXT'],'allowNull':!![]},'clientSideLoggingEnabledSince':{'type':Sequelize[_0x2b70('0x5')],'allowNull':!![],'defaultValue':null},'UserId':{'type':Sequelize[_0x2b70('0x6')],'unique':_0x2b70('0x7')}}; \ No newline at end of file diff --git a/server/api/user-setting/user-setting.controller.js b/server/api/user-setting/user-setting.controller.js new file mode 100644 index 0000000..da09c70 --- /dev/null +++ b/server/api/user-setting/user-setting.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd2ea=['catch','lodash','ioredis','../../config/logger','api','../../config/environment','socket.io-emitter','redis','./user-setting.socket','register','defaults','json','update','sendStatus','error','stack','name','send','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','then','body'];(function(_0x488602,_0x3a62aa){var _0x4e53db=function(_0x4db67d){while(--_0x4db67d){_0x488602['push'](_0x488602['shift']());}};_0x4e53db(++_0x3a62aa);}(_0xd2ea,0x15f));var _0xad2e=function(_0x155c6d,_0xcb4e2d){_0x155c6d=_0x155c6d-0x0;var _0x3080c8=_0xd2ea[_0x155c6d];return _0x3080c8;};'use strict';var _=require(_0xad2e('0x0'));var Redis=require(_0xad2e('0x1'));var logger=require(_0xad2e('0x2'))(_0xad2e('0x3'));var config=require(_0xad2e('0x4'));var db=require('../../mysqldb')['db'];var socket=require(_0xad2e('0x5'))(new Redis(config[_0xad2e('0x6')]));require(_0xad2e('0x7'))[_0xad2e('0x8')](socket);config[_0xad2e('0x6')]=_[_0xad2e('0x9')](config[_0xad2e('0x6')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x3b5170,_0x3e3d1f){_0x3e3d1f=_0x3e3d1f||0xc8;return function(_0x2ff7b2){if(_0x2ff7b2){return _0x3b5170['status'](_0x3e3d1f)[_0xad2e('0xa')](_0x2ff7b2);}};}function saveUpdates(_0x19bb0d){return function(_0x4b45f2){if(_0x4b45f2){return _0x4b45f2[_0xad2e('0xb')](_0x19bb0d)['then'](function(_0x430443){return _0x430443;});}return null;};}function handleEntityNotFound(_0x415a41){return function(_0x9879f2){if(!_0x9879f2){_0x415a41[_0xad2e('0xc')](0x194);}return _0x9879f2;};}function handleError(_0x489f25,_0x7df3c6){_0x7df3c6=_0x7df3c6||0x1f4;return function(_0x5707a5){logger[_0xad2e('0xd')](_0x5707a5[_0xad2e('0xe')]);if(_0x5707a5[_0xad2e('0xf')]){delete _0x5707a5[_0xad2e('0xf')];}_0x489f25['status'](_0x7df3c6)[_0xad2e('0x10')](_0x5707a5);};}exports['update']=function(_0x1a91ce,_0x5772f0){if(_0x1a91ce['user']['role']!=='admin')throw new Error(_0xad2e('0x11'));if(isNaN(Number(_0x1a91ce[_0xad2e('0x12')]['id'])))throw new Error(_0xad2e('0x13'));return db[_0xad2e('0x14')][_0xad2e('0x15')]({'where':{'id':_0x1a91ce[_0xad2e('0x12')]['id']}})[_0xad2e('0x16')](handleEntityNotFound(_0x5772f0,null))[_0xad2e('0x16')](saveUpdates(_0x1a91ce[_0xad2e('0x17')],null))[_0xad2e('0x16')](respondWithResult(_0x5772f0,null))[_0xad2e('0x18')](handleError(_0x5772f0,null));}; \ No newline at end of file diff --git a/server/api/user-setting/user-setting.events.js b/server/api/user-setting/user-setting.events.js new file mode 100644 index 0000000..0560d86 --- /dev/null +++ b/server/api/user-setting/user-setting.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2ce5=['remove','emit','hook','exports','../../mysqldb','UserSetting','setMaxListeners','save','update'];(function(_0x585fae,_0x21653d){var _0x5516dc=function(_0x1aba97){while(--_0x1aba97){_0x585fae['push'](_0x585fae['shift']());}};_0x5516dc(++_0x21653d);}(_0x2ce5,0xa6));var _0x52ce=function(_0x3f3b4b,_0x42e5aa){_0x3f3b4b=_0x3f3b4b-0x0;var _0x26f149=_0x2ce5[_0x3f3b4b];return _0x26f149;};'use strict';var EventEmitter=require('events');var UserSetting=require(_0x52ce('0x0'))['db'][_0x52ce('0x1')];var UserSettingEvents=new EventEmitter();UserSettingEvents[_0x52ce('0x2')](0x0);var events={'afterCreate':_0x52ce('0x3'),'afterUpdate':_0x52ce('0x4'),'afterDestroy':_0x52ce('0x5')};function emitEvent(_0x533231){return function(_0x2b6723,_0x1f81c7,_0x2c38fe){UserSettingEvents[_0x52ce('0x6')](_0x533231+':'+_0x2b6723['id'],_0x2b6723);UserSettingEvents['emit'](_0x533231,_0x2b6723);_0x2c38fe(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];UserSetting[_0x52ce('0x7')](e,emitEvent(event));}}module[_0x52ce('0x8')]=UserSettingEvents; \ No newline at end of file diff --git a/server/api/user-setting/user-setting.model.js b/server/api/user-setting/user-setting.model.js new file mode 100644 index 0000000..a7e147c --- /dev/null +++ b/server/api/user-setting/user-setting.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9354=['exports','UserSetting','user_settings','clientSideLoggingEnabled','clientSideLoggingEnabledSince'];(function(_0x1f5ee7,_0x1e4b82){var _0x25d695=function(_0x2756a2){while(--_0x2756a2){_0x1f5ee7['push'](_0x1f5ee7['shift']());}};_0x25d695(++_0x1e4b82);}(_0x9354,0x96));var _0x4935=function(_0x4ee9cd,_0xd375b0){_0x4ee9cd=_0x4ee9cd-0x0;var _0x328a5b=_0x9354[_0x4ee9cd];return _0x328a5b;};'use strict';var attributes=require('./user-setting.attributes');module[_0x4935('0x0')]=function(_0xc3c1f3){return _0xc3c1f3['define'](_0x4935('0x1'),attributes,{'tableName':_0x4935('0x2'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x29d1eb){if(!_0x29d1eb[_0x4935('0x3')])_0x29d1eb['clientSideLoggingEnabledSince']=null;else if(_0x29d1eb[_0x4935('0x4')]===null)_0x29d1eb[_0x4935('0x4')]=new Date();}}});}; \ No newline at end of file diff --git a/server/api/user-setting/user-setting.socket.js b/server/api/user-setting/user-setting.socket.js new file mode 100644 index 0000000..d526443 --- /dev/null +++ b/server/api/user-setting/user-setting.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd547=['save','remove','update','emit','user-setting:update','user-setting:update:user-','UserId','register','length','user-setting:','./user-setting.events'];(function(_0x1ba955,_0x3bbd8a){var _0x345c04=function(_0x5be11f){while(--_0x5be11f){_0x1ba955['push'](_0x1ba955['shift']());}};_0x345c04(++_0x3bbd8a);}(_0xd547,0x1a1));var _0x7d54=function(_0x799123,_0x4e7fbc){_0x799123=_0x799123-0x0;var _0x46d7bc=_0xd547[_0x799123];return _0x46d7bc;};'use strict';var UserSettingEvents=require(_0x7d54('0x0'));var events=[_0x7d54('0x1'),_0x7d54('0x2'),_0x7d54('0x3')];function createListener(_0x3f2a6f,_0x3068bd){return function(_0x5a1b05){_0x3068bd[_0x7d54('0x4')](_0x3f2a6f,_0x5a1b05);if(_0x3f2a6f===_0x7d54('0x5')){_0x3068bd['emit'](_0x7d54('0x6')+_0x5a1b05[_0x7d54('0x7')],_0x5a1b05);}};}exports[_0x7d54('0x8')]=function(_0x32d549){for(var _0x4985eb=0x0,_0x1d6982=events[_0x7d54('0x9')];_0x4985eb<_0x1d6982;_0x4985eb++){var _0x45aae0=events[_0x4985eb];var _0x228e3b=createListener(_0x7d54('0xa')+_0x45aae0,_0x32d549);UserSettingEvents['on'](_0x45aae0,_0x228e3b);}}; \ No newline at end of file diff --git a/server/api/user/index.js b/server/api/user/index.js new file mode 100644 index 0000000..7bf0a44 --- /dev/null +++ b/server/api/user/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc25=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./user.controller','get','isAuthenticated','index','/describe','describe','/presence','/:id','show','/:id/open_tabs','getOpenTabs','/:id/contacts','getQueues','/:id/queues_rt','getVoiceQueuesRt','/:id/groups','getGroups','/:id/recordings','getRecordings','/:id/screen_recordings','getScreenRecordings','/:id/chat/interactions','/:id/openchannel/interactions','getOpenchannelInteractions','getMailInteractions','/:id/fax/interactions','/:id/whatsapp/interactions','getWhatsappInteractions','/:id/teams','/:id/lists','getLists','/:id/agents','getAgents','/:id/prefixes','getVoicePrefixes','/:id/fax_accounts','/:id/mail_accounts','getMailAccounts','/:id/openchannel_accounts','getOpenchannelAccounts','getSmsAccounts','/:id/chat_websites','getChatWebsites','/:id/whatsapp_accounts','/:id/scheduled_calls','addContacts','post','addQueues','server/files/images/','format','now','originalname','/:id/avatar','file','addAvatar','/:id/login','login','/:id/logout','logout','/:id/pause','pause','/:id/unpause','addTeams','/:id/chat_interactions','addMailInteractions','addFaxInteractions','addSmsInteractions','/:id/openchannel_interactions','/:id/whatsapp_interactions','addWhatsappInteractions','addOpenchannelAccounts','createApiKey','put','update','/:id/password','changePassword','delete','removeTeams','destroy','removeChatInteractions','/:id/mail_interactions','removeFaxInteractions','/:id/sms_interactions','removeOpenchannelInteractions','removeWhatsappInteractions','removeFaxAccounts','removeMailAccounts','removeOpenchannelAccounts','removeSmsAccounts','/:id/api_key','removeApiKey','multer','util','path','connect-timeout'];(function(_0x42fb74,_0xd10771){var _0x88ec64=function(_0x458dc6){while(--_0x458dc6){_0x42fb74['push'](_0x42fb74['shift']());}};_0x88ec64(++_0xd10771);}(_0xdc25,0x128));var _0x5dc2=function(_0xf53f90,_0x1f94cb){_0xf53f90=_0xf53f90-0x0;var _0x2a3e6b=_0xdc25[_0xf53f90];return _0x2a3e6b;};'use strict';var multer=require(_0x5dc2('0x0'));var util=require(_0x5dc2('0x1'));var path=require(_0x5dc2('0x2'));var timeout=require(_0x5dc2('0x3'));var express=require('express');var router=express[_0x5dc2('0x4')]();var fs_extra=require(_0x5dc2('0x5'));var auth=require(_0x5dc2('0x6'));var interaction=require(_0x5dc2('0x7'));var config=require(_0x5dc2('0x8'));var controller=require(_0x5dc2('0x9'));router[_0x5dc2('0xa')]('/',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0xc')]);router[_0x5dc2('0xa')](_0x5dc2('0xd'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0xe')]);router[_0x5dc2('0xa')]('/whoami',auth[_0x5dc2('0xb')](),controller['whoami']);router[_0x5dc2('0xa')](_0x5dc2('0xf'),auth[_0x5dc2('0xb')](),controller['getPresence']);router[_0x5dc2('0xa')](_0x5dc2('0x10'),auth['isAuthenticated'](),controller[_0x5dc2('0x11')]);router[_0x5dc2('0xa')]('/:id/avatar',controller['getAvatar']);router['get'](_0x5dc2('0x12'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x13')]);router[_0x5dc2('0xa')](_0x5dc2('0x14'),auth[_0x5dc2('0xb')](),controller['getContacts']);router[_0x5dc2('0xa')]('/:id/queues',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x15')]);router[_0x5dc2('0xa')](_0x5dc2('0x16'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x17')]);router[_0x5dc2('0xa')](_0x5dc2('0x18'),auth['isAuthenticated'](),controller[_0x5dc2('0x19')]);router[_0x5dc2('0xa')](_0x5dc2('0x1a'),auth['isAuthenticated'](),controller[_0x5dc2('0x1b')]);router[_0x5dc2('0xa')](_0x5dc2('0x1c'),auth['isAuthenticated'](),controller[_0x5dc2('0x1d')]);router[_0x5dc2('0xa')](_0x5dc2('0x1e'),auth[_0x5dc2('0xb')](),controller['getChatInteractions']);router[_0x5dc2('0xa')](_0x5dc2('0x1f'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x20')]);router[_0x5dc2('0xa')]('/:id/mail/interactions',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x21')]);router[_0x5dc2('0xa')]('/:id/sms/interactions',auth[_0x5dc2('0xb')](),controller['getSmsInteractions']);router[_0x5dc2('0xa')](_0x5dc2('0x22'),auth['isAuthenticated'](),controller['getFaxInteractions']);router['get'](_0x5dc2('0x23'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x24')]);router['get'](_0x5dc2('0x25'),auth[_0x5dc2('0xb')](),controller['getTeams']);router[_0x5dc2('0xa')](_0x5dc2('0x26'),auth['isAuthenticated'](),controller[_0x5dc2('0x27')]);router[_0x5dc2('0xa')](_0x5dc2('0x28'),auth['isAuthenticated'](),controller[_0x5dc2('0x29')]);router[_0x5dc2('0xa')](_0x5dc2('0x2a'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x2b')]);router[_0x5dc2('0xa')](_0x5dc2('0x2c'),auth[_0x5dc2('0xb')](),controller['getFaxAccounts']);router[_0x5dc2('0xa')](_0x5dc2('0x2d'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x2e')]);router[_0x5dc2('0xa')](_0x5dc2('0x2f'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x30')]);router[_0x5dc2('0xa')]('/:id/sms_accounts',auth['isAuthenticated'](),controller[_0x5dc2('0x31')]);router['get'](_0x5dc2('0x32'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x33')]);router['get'](_0x5dc2('0x34'),auth[_0x5dc2('0xb')](),controller['getWhatsappAccounts']);router['get'](_0x5dc2('0x35'),auth['isAuthenticated'](),controller['getScheduledCalls']);router['get']('/:id/api_key',auth[_0x5dc2('0xb')](),controller['getApiKey']);router['post'](_0x5dc2('0x14'),auth['isAuthenticated'](),controller[_0x5dc2('0x36')]);router[_0x5dc2('0x37')]('/',auth[_0x5dc2('0xb')](),controller['create']);router['post']('/create_many',auth[_0x5dc2('0xb')](),controller['bulkCreate']);router[_0x5dc2('0x37')]('/:id/queues',auth['isAuthenticated'](),controller[_0x5dc2('0x38')]);var upload=multer({'storage':multer['diskStorage']({'destination':function(_0x1f1f8e,_0x1b551c,_0x5993cc){_0x5993cc(null,path['join'](config['root'],_0x5dc2('0x39')));},'filename':function(_0x4027de,_0x3eb518,_0x491f96){_0x491f96(null,util[_0x5dc2('0x3a')]('%s-%s',Date[_0x5dc2('0x3b')](),_0x3eb518[_0x5dc2('0x3c')]));}})});router[_0x5dc2('0x37')](_0x5dc2('0x3d'),upload['single'](_0x5dc2('0x3e')),controller[_0x5dc2('0x3f')]);router['post'](_0x5dc2('0x40'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x41')]);router['post'](_0x5dc2('0x42'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x43')]);router['post'](_0x5dc2('0x44'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x45')]);router[_0x5dc2('0x37')](_0x5dc2('0x46'),auth[_0x5dc2('0xb')](),controller['unpause']);router[_0x5dc2('0x37')]('/:id/teams',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x47')]);router[_0x5dc2('0x37')](_0x5dc2('0x48'),auth[_0x5dc2('0xb')](),controller['addChatInteractions']);router[_0x5dc2('0x37')]('/:id/mail_interactions',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x49')]);router['post']('/:id/fax_interactions',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x4a')]);router[_0x5dc2('0x37')]('/:id/sms_interactions',auth['isAuthenticated'](),controller[_0x5dc2('0x4b')]);router[_0x5dc2('0x37')](_0x5dc2('0x4c'),auth[_0x5dc2('0xb')](),controller['addOpenchannelInteractions']);router[_0x5dc2('0x37')](_0x5dc2('0x4d'),auth['isAuthenticated'](),controller[_0x5dc2('0x4e')]);router['post'](_0x5dc2('0x2c'),auth['isAuthenticated'](),controller['addFaxAccounts']);router['post']('/:id/mail_accounts',auth['isAuthenticated'](),controller['addMailAccounts']);router[_0x5dc2('0x37')](_0x5dc2('0x2f'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x4f')]);router[_0x5dc2('0x37')]('/:id/sms_accounts',auth[_0x5dc2('0xb')](),controller['addSmsAccounts']);router[_0x5dc2('0x37')](_0x5dc2('0x32'),auth[_0x5dc2('0xb')](),controller['addChatWebsites']);router[_0x5dc2('0x37')](_0x5dc2('0x34'),auth[_0x5dc2('0xb')](),controller['addWhatsappAccounts']);router[_0x5dc2('0x37')]('/:id/api_key',auth['isAuthenticated'](),controller[_0x5dc2('0x50')]);router[_0x5dc2('0x51')](_0x5dc2('0x10'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x52')]);router[_0x5dc2('0x51')](_0x5dc2('0x53'),auth['isAuthenticated'](),controller[_0x5dc2('0x54')]);router[_0x5dc2('0x55')]('/:id/queues',auth[_0x5dc2('0xb')](),controller['removeQueues']);router[_0x5dc2('0x55')](_0x5dc2('0x25'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x56')]);router['delete'](_0x5dc2('0x10'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x57')]);router[_0x5dc2('0x55')](_0x5dc2('0x48'),auth['isAuthenticated'](),controller[_0x5dc2('0x58')]);router[_0x5dc2('0x55')](_0x5dc2('0x59'),auth['isAuthenticated'](),controller['removeMailInteractions']);router[_0x5dc2('0x55')]('/:id/fax_interactions',auth['isAuthenticated'](),controller[_0x5dc2('0x5a')]);router[_0x5dc2('0x55')](_0x5dc2('0x5b'),auth[_0x5dc2('0xb')](),controller['removeSmsInteractions']);router[_0x5dc2('0x55')](_0x5dc2('0x4c'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x5c')]);router['delete'](_0x5dc2('0x4d'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x5d')]);router[_0x5dc2('0x55')](_0x5dc2('0x2c'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x5e')]);router[_0x5dc2('0x55')]('/:id/mail_accounts',auth['isAuthenticated'](),controller[_0x5dc2('0x5f')]);router[_0x5dc2('0x55')](_0x5dc2('0x2f'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x60')]);router['delete']('/:id/sms_accounts',auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x61')]);router['delete'](_0x5dc2('0x32'),auth[_0x5dc2('0xb')](),controller['removeChatWebsites']);router[_0x5dc2('0x55')](_0x5dc2('0x34'),auth['isAuthenticated'](),controller['removeWhatsappAccounts']);router['delete'](_0x5dc2('0x62'),auth[_0x5dc2('0xb')](),controller[_0x5dc2('0x63')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/user/user.attributes.js b/server/api/user/user.attributes.js new file mode 100644 index 0000000..6b108c1 --- /dev/null +++ b/server/api/user/user.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x34e8=['isArray','wss','encryption','force_avp','icesupport','dtlsenable','dtlsverify','dtlssetup','dtlscertfile','rtcp_mux','avpf','/etc/pki/tls/certs/motion.crt','dtlsprivatekey','permissions','map','phoneBarEnableScreenRecordingByAgent','string','true','false','screenrecording','blockedAt','sequelize','moment','util','lodash','STRING','name','setDataValue','defaultuser','fullname','callerid','format','\x22%s\x22\x20<%s>','getDataValue','internal','email','toLowerCase','ENUM','admin','agent','telephone','local','INTEGER','accountcode','BOOLEAN','DEFAULT\x20PAUSE','DATE','dynamic','friend','from-sip','ALLOWED_NOT_SCREENED','ALLOWED_PASSED_SCREEN','ALLOWED_FAILED_SCREEN','ALLOWED','PROHIB_NOT_SCREENED','PROHIB_PASSED_SCREEN','PROHIB_FAILED_SCREEN','PROHIB','udp','transport','join','split','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22udp\x22,\x20\x22tcp\x22]','rfc2833','shortinfo','inband','yes','nonat','update','outgoing','force_rport,comedia','nat','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22force_rport\x22,\x20\x22comedia\x22]','all','ulaw;alaw;gsm','allow','String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22ulaw\x22,\x20\x22alaw\x22,\x20\x22gsm\x22]','insecure','never','\x22\x22\x20<>','always','accept','refuse','originate','uac','uas','certificate','passive','actpass','update,nonat','TEXT','showWebBar','get'];(function(_0x444bb4,_0x327ffb){var _0x14905d=function(_0x11465d){while(--_0x11465d){_0x444bb4['push'](_0x444bb4['shift']());}};_0x14905d(++_0x327ffb);}(_0x34e8,0x12c));var _0x834e=function(_0x4a960a,_0x21ee52){_0x4a960a=_0x4a960a-0x0;var _0xb9972a=_0x34e8[_0x4a960a];return _0xb9972a;};'use strict';var Sequelize=require(_0x834e('0x0'));var moment=require(_0x834e('0x1'));var util=require(_0x834e('0x2'));var _=require(_0x834e('0x3'));module['exports']={'name':{'type':Sequelize[_0x834e('0x4')],'allowNull':![],'unique':_0x834e('0x5'),'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i},'set':function(_0x472111){this[_0x834e('0x6')](_0x834e('0x5'),_0x472111);this[_0x834e('0x6')](_0x834e('0x7'),_0x472111);},'comment':'The\x20name\x20of\x20the\x20user'},'fullname':{'type':Sequelize[_0x834e('0x4')],'allowNull':![],'set':function(_0x52056d){this[_0x834e('0x6')](_0x834e('0x8'),_0x52056d);this[_0x834e('0x6')](_0x834e('0x9'),util[_0x834e('0xa')](_0x834e('0xb'),_0x52056d,this[_0x834e('0xc')](_0x834e('0xd'))));}},'alias':{'type':Sequelize[_0x834e('0x4')]},'email':{'type':Sequelize[_0x834e('0x4')],'allowNull':![],'unique':_0x834e('0xe'),'validate':{'isEmail':!![]},'set':function(_0x36e124){if(_0x36e124){this[_0x834e('0x6')](_0x834e('0xe'),_0x36e124[_0x834e('0xf')]());}}},'role':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x11'),'user',_0x834e('0x12'),_0x834e('0x13')),'allowNull':![]},'password':{'type':Sequelize['STRING'],'allowNull':![],'validate':{'notEmpty':!![]}},'provider':{'type':Sequelize[_0x834e('0x4')],'defaultValue':_0x834e('0x14')},'internal':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':![],'unique':_0x834e('0xd'),'set':function(_0x50e860){this[_0x834e('0x6')](_0x834e('0xd'),_0x50e860);this['setDataValue'](_0x834e('0x16'),_0x50e860);this['setDataValue'](_0x834e('0x9'),util[_0x834e('0xa')]('\x22%s\x22\x20<%s>',this[_0x834e('0xc')](_0x834e('0x8')),_0x50e860));}},'salt':{'type':Sequelize[_0x834e('0x4')]},'phone':{'type':Sequelize['STRING']},'mobile':{'type':Sequelize[_0x834e('0x4')]},'address':{'type':Sequelize[_0x834e('0x4')]},'zipcode':{'type':Sequelize[_0x834e('0x4')]},'userpic':{'type':Sequelize[_0x834e('0x4')]},'city':{'type':Sequelize[_0x834e('0x4')]},'country':{'type':Sequelize[_0x834e('0x4')]},'online':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'lastLoginAt':{'type':Sequelize['DATE']},'voicePause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'chatPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'mailPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'faxPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'smsPause':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'whatsappPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'openchannelPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'pauseType':{'type':Sequelize['STRING'],'defaultValue':_0x834e('0x18')},'lastPauseAt':{'type':Sequelize[_0x834e('0x19')]},'chatCapacity':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'mailCapacity':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'faxCapacity':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'smsCapacity':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'whatsappCapacity':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'openchannelCapacity':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'phoneBarAutoAnswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarEnableSettings':{'type':Sequelize[_0x834e('0x17')],'defaultValue':!![]},'phoneBarListenPort':{'type':Sequelize['INTEGER'](0x5),'defaultValue':0x1428},'phoneBarExpires':{'type':Sequelize[_0x834e('0x15')](0x5),'defaultValue':0x78},'phoneBarRemoteControl':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarRemoteControlPort':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x26a0},'phoneBarEnableRecording':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'phoneBarRingInUse':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'chanspy':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'description':{'type':Sequelize['STRING'],'allowNull':!![]},'host':{'type':Sequelize['STRING'],'allowNull':!![],'defaultValue':_0x834e('0x1a')},'ipaddr':{'type':Sequelize['STRING'],'allowNull':!![]},'port':{'type':Sequelize[_0x834e('0x15')](0x5),'allowNull':!![]},'regseconds':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'fullcontact':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'regserver':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'useragent':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'lastms':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'type':{'type':Sequelize['ENUM']('friend','user','peer'),'allowNull':!![],'defaultValue':_0x834e('0x1b')},'context':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![],'defaultValue':_0x834e('0x1c')},'callingpres':{'type':Sequelize['ENUM'](_0x834e('0x1d'),_0x834e('0x1e'),_0x834e('0x1f'),_0x834e('0x20'),_0x834e('0x21'),_0x834e('0x22'),_0x834e('0x23'),_0x834e('0x24')),'allowNull':!![]},'deny':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'permit':{'type':Sequelize['STRING'],'allowNull':!![]},'secret':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'md5secret':{'type':Sequelize['STRING'],'allowNull':!![]},'remotesecret':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'transport':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![],'defaultValue':_0x834e('0x25'),'set':function(_0x2b3418){this[_0x834e('0x6')](_0x834e('0x26'),_0x2b3418?_0x2b3418[_0x834e('0x27')](','):null);},'get':function(){return this[_0x834e('0xc')](_0x834e('0x26'))?this[_0x834e('0xc')]('transport')[_0x834e('0x28')](','):null;},'comment':_0x834e('0x29')},'dtmfmode':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2a'),'info',_0x834e('0x2b'),_0x834e('0x2c'),'auto'),'allowNull':!![],'defaultValue':'rfc2833'},'directmedia':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no',_0x834e('0x2e'),_0x834e('0x2f'),_0x834e('0x30')),'allowNull':!![],'defaultValue':'no'},'directrtpsetup':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![],'defaultValue':'no'},'directmediapermit':{'type':Sequelize['STRING'],'allowNull':!![]},'directmediadeny':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'nat':{'type':Sequelize['STRING'],'allowNull':!![],'defaultValue':_0x834e('0x31'),'set':function(_0x6a3ac){this['setDataValue'](_0x834e('0x32'),_0x6a3ac?_0x6a3ac[_0x834e('0x27')](','):null);},'get':function(){return this['getDataValue']('nat')?this[_0x834e('0xc')](_0x834e('0x32'))[_0x834e('0x28')](','):null;},'comment':_0x834e('0x33')},'callgroup':{'type':Sequelize[_0x834e('0x4')]},'namedcallgroup':{'type':Sequelize['STRING']},'pickupgroup':{'type':Sequelize[_0x834e('0x4')]},'namedpickupgroup':{'type':Sequelize['STRING']},'language':{'type':Sequelize['STRING'],'defaultValue':'en'},'tonezone':{'type':Sequelize[_0x834e('0x4')]},'disallow':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0x834e('0x34')},'allow':{'type':Sequelize[_0x834e('0x4')],'allowNull':![],'defaultValue':_0x834e('0x35'),'set':function(_0x3c59af){this[_0x834e('0x6')]('allow',_0x3c59af?_0x3c59af[_0x834e('0x27')](';'):_0x834e('0x35'));},'get':function(){return this[_0x834e('0xc')]('allow')?this[_0x834e('0xc')](_0x834e('0x36'))['split'](';'):null;},'comment':_0x834e('0x37')},'autoframing':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no'),'allowNull':!![]},'insecure':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![],'set':function(_0x4a18bb){this['setDataValue'](_0x834e('0x38'),_0x4a18bb?_0x4a18bb[_0x834e('0x27')](','):null);},'get':function(){return this[_0x834e('0xc')](_0x834e('0x38'))?this[_0x834e('0xc')](_0x834e('0x38'))[_0x834e('0x28')](','):null;},'comment':'String\x20is\x20deprecated.\x20Please\x20use\x20an\x20Array\x20as\x20[\x22port\x22,\x20\x22invite\x22]'},'trustrpid':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![],'defaultValue':'no'},'trust_id_outbound':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![],'defaultValue':'no'},'progressinband':{'type':Sequelize[_0x834e('0x10')]('yes','no',_0x834e('0x39')),'allowNull':!![]},'promiscredir':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![]},'useclientcode':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'accountcode':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'setvar':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'callerid':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![],'defaultValue':_0x834e('0x3a')},'amaflags':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'callcounter':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![],'defaultValue':_0x834e('0x2d')},'busylevel':{'type':Sequelize['INTEGER'](0xb),'allowNull':!![]},'allowoverlap':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'allowsubscribe':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no'),'allowNull':!![]},'allowtransfer':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'ignoresdpversion':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'subscribecontext':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'template':{'type':Sequelize['STRING'],'allowNull':!![]},'videosupport':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no',_0x834e('0x3b')),'allowNull':!![],'defaultValue':'no'},'maxcallbitrate':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'rfc2833compensate':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'mailbox':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'session_timers':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x3c'),_0x834e('0x3d'),_0x834e('0x3e')),'allowNull':!![]},'session_expires':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'session_minse':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'session_refresher':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x3f'),_0x834e('0x40')),'allowNull':!![],'defaultValue':_0x834e('0x40')},'t38pt_usertpsource':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'regexten':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'fromdomain':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'fromuser':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'qualify':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no'),'allowNull':!![],'defaultValue':_0x834e('0x2d')},'keepalive':{'type':Sequelize['INTEGER'](0xb),'allowNull':!![]},'defaultip':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'defaultuser':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'rtptimeout':{'type':Sequelize['INTEGER'](0xb),'allowNull':!![]},'rtpholdtimeout':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'rtpkeepalive':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'sendrpid':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![],'defaultValue':'no'},'outboundproxy':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'callbackextension':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'timert1':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'timerb':{'type':Sequelize['INTEGER'](0xb),'allowNull':!![]},'qualifyfreq':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'contactpermit':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'contactdeny':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'contactacl':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'unsolicited_mailbox':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'use_q850_reason':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'maxforwards':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'encryption':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![],'defaultValue':'no'},'avpf':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![]},'force_avp':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![]},'icesupport':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![]},'dtlsenable':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no'),'allowNull':!![]},'dtlsverify':{'type':Sequelize[_0x834e('0x10')]('yes','no','fingerprint',_0x834e('0x41')),'allowNull':!![]},'dtlsrekey':{'type':Sequelize[_0x834e('0x15')](0xb),'allowNull':!![]},'dtlscertfile':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'dtlsprivatekey':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'dtlscipher':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'dtlscafile':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'dtlscapath':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'dtlssetup':{'type':Sequelize[_0x834e('0x10')]('active',_0x834e('0x42'),_0x834e('0x43')),'allowNull':!![]},'dtlsfingerprint':{'type':Sequelize['STRING'],'allowNull':!![]},'usereqphone':{'type':Sequelize[_0x834e('0x10')]('yes','no'),'allowNull':!![],'defaultValue':'no'},'recordonfeature':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'recordofffeature':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'call_limit':{'type':Sequelize['INTEGER'](0xb),'allowNull':!![],'defaultValue':0xa},'registertrying':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'subscribemwi':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'allowNull':!![]},'vmexten':{'type':Sequelize['STRING'],'allowNull':!![]},'mohinterpret':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'mohsuggest':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'parkinglot':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'canreinvite':{'type':Sequelize['ENUM'](_0x834e('0x2d'),'no',_0x834e('0x2e'),_0x834e('0x2f'),_0x834e('0x44')),'allowNull':!![],'defaultValue':'no'},'loginInPause':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'resetPasswordToken':{'type':Sequelize[_0x834e('0x4')]},'resetPasswordExpires':{'type':Sequelize[_0x834e('0x19')]},'passwordResetAt':{'type':Sequelize[_0x834e('0x19')],'defaultValue':null},'previousPasswords':{'type':Sequelize[_0x834e('0x45')]},'showWebBar':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0,'set':function(_0x1e4310){this[_0x834e('0x6')](_0x834e('0x46'),_0x1e4310);var _0x1659c8=this[_0x834e('0x47')]({'plain':!![]});switch(_0x1e4310){case 0x0:case 0x1:var _0x17b8e3=_0x1659c8[_0x834e('0x26')]?_[_0x834e('0x48')](_0x1659c8[_0x834e('0x26')])?_0x1659c8[_0x834e('0x26')][_0x834e('0x27')]():_0x1659c8[_0x834e('0x26')]:'udp';if(_0x17b8e3===_0x834e('0x49')){_0x17b8e3=_0x834e('0x25');}this[_0x834e('0x6')](_0x834e('0x26'),_0x17b8e3);this['setDataValue'](_0x834e('0x4a'),'no');this['setDataValue']('avpf',null);this[_0x834e('0x6')](_0x834e('0x4b'),null);this[_0x834e('0x6')](_0x834e('0x4c'),null);this[_0x834e('0x6')](_0x834e('0x4d'),null);this[_0x834e('0x6')](_0x834e('0x4e'),null);this['setDataValue'](_0x834e('0x4f'),null);this['setDataValue'](_0x834e('0x50'),null);this[_0x834e('0x6')]('dtlsprivatekey',null);this['setDataValue'](_0x834e('0x51'),'no');break;case 0x2:this[_0x834e('0x6')](_0x834e('0x26'),_0x834e('0x49'));this[_0x834e('0x6')]('encryption',_0x834e('0x2d'));this[_0x834e('0x6')](_0x834e('0x52'),_0x834e('0x2d'));this[_0x834e('0x6')](_0x834e('0x4b'),_0x834e('0x2d'));this[_0x834e('0x6')](_0x834e('0x4c'),_0x834e('0x2d'));this['setDataValue'](_0x834e('0x4d'),_0x834e('0x2d'));this[_0x834e('0x6')](_0x834e('0x4e'),'no');this['setDataValue'](_0x834e('0x4f'),'actpass');this['setDataValue']('dtlscertfile',_0x1659c8[_0x834e('0x50')]||_0x834e('0x53'));this['setDataValue'](_0x834e('0x54'),_0x1659c8[_0x834e('0x54')]||'/etc/pki/tls/private/motion.key');this[_0x834e('0x6')](_0x834e('0x51'),'yes');break;default:}}},'permissions':{'type':Sequelize['TEXT'],'set':function(_0x346be5){this[_0x834e('0x6')](_0x834e('0x55'),_0x346be5?_0x346be5[_0x834e('0x27')](','):[]);},'get':function(){return this[_0x834e('0xc')]('permissions')?_[_0x834e('0x56')](this['getDataValue'](_0x834e('0x55'))[_0x834e('0x28')](','),function(_0x2c758c){return parseInt(_0x2c758c,0xa);}):[];}},'phoneBarUnconditionalNumber':{'type':Sequelize['STRING']},'phoneBarNoReplyNumber':{'type':Sequelize[_0x834e('0x4')]},'phoneBarBusyNumber':{'type':Sequelize[_0x834e('0x4')]},'phoneBarUnconditional':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'phoneBarNoReply':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarBusy':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarDnd':{'type':Sequelize[_0x834e('0x17')],'defaultValue':!![]},'phoneBarUnansweredCallBadge':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'phoneBarEnableDtmfTone':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarAutoAnswerDelay':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'extensionMonitor':{'type':Sequelize[_0x834e('0x4')],'defaultValue':''},'crudPermissions':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'rtcp_mux':{'type':Sequelize[_0x834e('0x10')](_0x834e('0x2d'),'no'),'defaultValue':'no'},'allowmessenger':{'type':Sequelize[_0x834e('0x17')],'defaultValue':!![]},'phoneBarOutboundProxy':{'type':Sequelize[_0x834e('0x4')]},'phoneBarEnableJaws':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarEnableScreenRecordingByAgent':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarEnableVideoRecording':{'type':Sequelize['VIRTUAL'],'get':function(){return this['getDataValue']('phoneBarEnableScreenRecordingByAgent')?this[_0x834e('0xc')](_0x834e('0x57')):![];}},'phoneBarEnableAutomaticScreenRecording':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'phoneBarPrefixRequired':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'hotdesk':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'interface':{'type':Sequelize['STRING'],'defaultValue':null},'privacyEnabled':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'apiKeyNonce':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'apiKeyIat':{'type':Sequelize[_0x834e('0x4')],'allowNull':!![]},'screenrecording':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![],'set':function(_0x18ddac){if(typeof _0x18ddac===_0x834e('0x58')){var _0x5acf5c=_0x18ddac==='1'?!![]:_0x18ddac==='0'?![]:_0x18ddac===_0x834e('0x59')?!![]:_0x18ddac===_0x834e('0x5a')?![]:![];this[_0x834e('0x6')]('screenrecording',_0x5acf5c);}else{this[_0x834e('0x6')](_0x834e('0x5b'),_0x18ddac);}}},'blocked':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![],'set':function(_0x443633){this[_0x834e('0x6')]('blocked',_0x443633);if(_0x443633===!![]){this['setDataValue'](_0x834e('0x5c'),moment());this[_0x834e('0x6')]('loginAttempts',0x0);}else{this[_0x834e('0x6')]('blockedAt',null);}}},'blockedAt':{'type':Sequelize[_0x834e('0x19')],'defaultValue':null},'loginAttempts':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'disabled':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'settingsEnabled':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'wssPort':{'type':Sequelize[_0x834e('0x15')](0x5)['UNSIGNED'],'defaultValue':0x1f99},'downloadAttachments':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'downloadOmnichannelInteractions':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'downloadVoiceRecordings':{'type':Sequelize[_0x834e('0x17')],'defaultValue':!![]},'ignorePauseForPreviewCalls':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'selectRecallMeCampaign':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'adSsoEnabled':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'chatAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'chatAutoanswerDelay':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'emailAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'emailAutoanswerDelay':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'smsAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'smsAutoanswerDelay':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'openchannelAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'openchannelAutoanswerDelay':{'type':Sequelize['INTEGER'],'defaultValue':0x0},'faxAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'faxAutoanswerDelay':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0},'whatsappAutoanswer':{'type':Sequelize[_0x834e('0x17')],'defaultValue':![]},'whatsappAutoanswerDelay':{'type':Sequelize[_0x834e('0x15')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/user/user.controller.js b/server/api/user/user.controller.js new file mode 100644 index 0000000..d3b4956 --- /dev/null +++ b/server/api/user/user.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb449=['uniqBy','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','result','client','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','offline','idle','unknown','unavailable','ringing','voiceStatus','busy','slice','SELECT','select','InteractionId','field','ui.createdAt','_interactions','ui.UserId\x20=\x20?','OpenTabs','moment','util','lodash','squel','jayson/promise','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','APIBadRequestError','../../errors/api','APINotFoundError','handleError','../../mysqldb','socket.io-emitter','redis','defaults','localhost','http','request','then','info','User,\x20%s,\x20%s','debug','request\x20sent','error','code','message','catch','sendStatus','status','end','offset','undefined','limit','count','json','update','role','agent','emit','userNotification:recalc:','get','user','Agents','Telephones','telephone','filter','ignore','map','value','includes','find','name','destroy','stack','send','index','User','fieldName','type','key','getOptions','where','query','userSetting','true','UserSetting','attributes','push','findAll','rows','openTabs','length','chat','dataValues','sms','fax','mail','openchannel','whatsapp','all','show','params','model','differenceBy','keys','rawAttributes','password','salt','filters','intersection','fields','includeAll','include','options','body','describe','addContacts','ids','internal','findById','validatePasswordPattern','max','min_internal','isNil','sequelize','select\x20(select\x20IFNULL(max(internal)+1,1)\x20from\x20users\x20where\x20internal\x20<\x20md.internal)\x20as\x20\x27from\x27,\x20md.internal\x20-\x201\x20as\x20\x27to\x27\x20from\x20users\x20md\x20where\x20md.internal\x20!=\x201\x20and\x20not\x20exists\x20(select\x201\x20from\x20users\x20md2\x20where\x20md2.internal\x20=\x20md.internal\x20-\x201)','QueryTypes','from','mailbox','VoiceMail','fullname','email','permissions','101','102','103','113','104','107','108','100','111','114','115','Unauthorized','admin','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20another\x20administrator','checkUserLimits','settingsEnabled','userProfileId','UserProfileSection','UserProfileResource','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','some','Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20administrator','isEmpty','autoAssociation','compact','changePassword','oldPassword','newPassword','Sequelize','authenticate','Wrong\x20credentials','ValidationError','New\x20password\x20must\x20be\x20different\x20from\x20old\x20password','Invalid\x20body\x20format.\x20Use\x20newPassword','Setting','securePassword','enforcePasswordHistory','passwordHistoryLimit','previousPasswords','addQueues','channel','loginInPause','isValidChannel','Unknown\x20channel','add','capitalize','toLowerCase','penalty','QueueId','Queue:save','voice','online','interface','format','SIP/%s','voicePause','UserVoiceQueueRt','upsert','remove','Queues','isArray','Queue:remove','addAvatar','filename','join','root','server/files/images/logos/default_profile.png','userpic','download','existsSync','server/files/images/','getOpenTabs','ChatOpenTabs','CHAT','createdAt','FAX','OpenchannelOpenTabs','OPENCHANNEL','MailOpenTabs','SmsOpenTabs','WhatsappOpenTabs','WHATSAPP','getContacts','findOne','order','sort','pick','merge','hasOwnProperty','CmList','List','Tag','Tags','color','tag','nolimit','getQueues','Queue','getVoiceQueuesRt','getGroups','getRecordings','UserId','VoiceRecording','getScreenRecordings','ScreenRecording','getChatInteractions','getOpenchannelInteractions','OpenchannelInteraction','getMailInteractions','MailInteraction','getSmsInteractions','getFaxInteractions','getWhatsappInteractions','WhatsappInteraction','phone','LOCAL/%s@from-sip/n','intrf','headers','x-forwarded-for','connection','remoteAddress','socket','User\x20not\x20found\x20or\x20not\x20allowed\x20to\x20perform\x20login\x20method','getVoiceQueues','MemberReport','forEach','YYYY-MM-DD\x20HH:mm:ss','getChannels','PAUSE','LOGININPAUSE','bulkCreate','concat','resolve','logout','pause','QueuePause','DEFAULT\x20PAUSE','unpause','mailPause','faxPause','openchannelPause','smsPause','whatsappPause','pauseType','lastPauseAt','User\x20with\x20id\x20%s\x20not\x20found','getTeams','Body\x20parameter\x20\x27ids\x27\x20is\x20required','transaction','addTeams','Team','getAssociatedQueues','flattenDeep','getDataValue','Voice','TeamVoicePrefix','UserVoicePrefix','removeTeams','Query\x20parameter\x20\x27ids\x27\x20is\x20required','getLists','getAgents','addChatInteractions','omit','spread','user_has_chat_interactions:save','removeChatInteractions','user_has_chat_interactions:remove','addMailInteractions','removeMailInteractions','user_has_mail_interactions:remove','addFaxInteractions','user_has_fax_interactions:save','removeFaxInteractions','user_has_fax_interactions:remove','addSmsInteractions','user_has_sms_interactions:save','removeSmsInteractions','user_has_sms_interactions:remove','addOpenchannelInteractions','user_has_openchannel_interactions:save','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','addWhatsappInteractions','user_has_whatsapp_interactions:save','removeWhatsappInteractions','getVoicePrefixes','VoicePrefix','FaxAccount','getFaxAccounts','addFaxAccounts','removeFaxAccounts','getMailAccounts','addMailAccounts','getOpenchannelAccounts','OpenchannelAccount','addOpenchannelAccounts','removeOpenchannelAccounts','getSmsAccounts','SmsAccount','addSmsAccounts','removeSmsAccounts','ChatWebsite','getChatWebsites','addChatWebsites','removeChatWebsites','getWhatsappAccounts','WhatsappAccount','addWhatsappAccounts','removeWhatsappAccounts','getScheduledCalls','CmHopper','$and','$or','$gt','$gte','$lt','$lte','$ne','$eq','$not','$between','$in','$notIn','$like','$notILike','$overlap','$contains','$contained','firstName','lastName','dialActive','VoiceQueue','getApiKey','retrieveApiKey','token','You\x20don\x27t\x20have\x20sufficient\x20privileges\x20to\x20access\x20this\x20resource.','generateApiKey','iat','nonce','apiKeyNonce','whoami','getUserSetting','getPresence','teams','queues','flatten','col','toString','asc','desc','substring'];(function(_0xcc84ec,_0x348bb6){var _0x3e9632=function(_0x317c71){while(--_0x317c71){_0xcc84ec['push'](_0xcc84ec['shift']());}};_0x3e9632(++_0x348bb6);}(_0xb449,0x19d));var _0x9b44=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xb449[_0x3dd15e];return _0x231fd0;};'use strict';var moment=require(_0x9b44('0x0'));var util=require(_0x9b44('0x1'));var path=require('path');var fs=require('fs');var _=require(_0x9b44('0x2'));var squel=require(_0x9b44('0x3'));var jayson=require(_0x9b44('0x4'));var Redis=require(_0x9b44('0x5'));var authService=require(_0x9b44('0x6'));var qs=require(_0x9b44('0x7'));var logger=require(_0x9b44('0x8'))('api');var utils=require(_0x9b44('0x9'));var config=require(_0x9b44('0xa'));var licenseUtil=require(_0x9b44('0xb'));var APIBadRequestError=require('../../errors/api')[_0x9b44('0xc')];var APINotFoundError=require(_0x9b44('0xd'))[_0x9b44('0xe')];var APIHandleError=require('../../errors/api')[_0x9b44('0xf')];var db=require(_0x9b44('0x10'))['db'];var socket=require(_0x9b44('0x11'))(new Redis(config[_0x9b44('0x12')]));require('./user.socket')['register'](socket);config[_0x9b44('0x12')]=_[_0x9b44('0x13')](config[_0x9b44('0x12')],{'host':_0x9b44('0x14'),'port':0x18eb});var amiClient=jayson['client'][_0x9b44('0x15')]({'port':0x232a});var values;function respondWithRpcPromise(_0x5af290,_0xdf7a5,_0x3b052f,_0x3e3cb3){return new Promise(function(_0x2a7d4e,_0x1ba7b9){var _0x50fd16=_0x3e3cb3||amiClient;return _0x50fd16[_0x9b44('0x16')](_0x5af290,_0x3b052f)[_0x9b44('0x17')](function(_0x5e25f3){logger[_0x9b44('0x18')](_0x9b44('0x19'),_0xdf7a5,'request\x20sent');logger[_0x9b44('0x1a')]('User,\x20%s,\x20%s,\x20%s',_0xdf7a5,_0x9b44('0x1b'),JSON['stringify'](_0x5e25f3));if(_0x5e25f3[_0x9b44('0x1c')]){if(_0x5e25f3['error'][_0x9b44('0x1d')]===0x1f4){logger['error'](_0x9b44('0x19'),_0xdf7a5,_0x5e25f3[_0x9b44('0x1c')][_0x9b44('0x1e')]);return _0x1ba7b9(_0x5e25f3[_0x9b44('0x1c')][_0x9b44('0x1e')]);}logger['error'](_0x9b44('0x19'),_0xdf7a5,_0x5e25f3[_0x9b44('0x1c')][_0x9b44('0x1e')]);return _0x2a7d4e(_0x5e25f3[_0x9b44('0x1c')][_0x9b44('0x1e')]);}else{logger[_0x9b44('0x18')]('User,\x20%s,\x20%s',_0xdf7a5,_0x9b44('0x1b'));_0x2a7d4e(_0x5e25f3['result'][_0x9b44('0x1e')]);}})[_0x9b44('0x1f')](function(_0x33d69a){logger[_0x9b44('0x1c')]('User,\x20%s,\x20%s',_0xdf7a5,_0x33d69a);_0x1ba7b9(_0x33d69a);});});}function respondWithStatusCode(_0x2910cf,_0x129ed4){_0x129ed4=_0x129ed4||0xcc;return function(_0x16baa3){if(_0x16baa3){return _0x2910cf[_0x9b44('0x20')](_0x129ed4);}return _0x2910cf[_0x9b44('0x21')](_0x129ed4)[_0x9b44('0x22')]();};}function respondWithResult(_0x658819,_0xc57f15){_0xc57f15=_0xc57f15||0xc8;return function(_0x592743){if(_0x592743){return _0x658819['status'](_0xc57f15)['json'](_0x592743);}};}function respondWithFilteredResult(_0x4b25a5,_0x1cbb79){return function(_0x15f49d){if(_0x15f49d){var _0x913b68=typeof _0x1cbb79[_0x9b44('0x23')]===_0x9b44('0x24')&&typeof _0x1cbb79[_0x9b44('0x25')]===_0x9b44('0x24');var _0x1085d1=_0x15f49d[_0x9b44('0x26')];var _0x276dfc=_0x913b68?0x0:_0x1cbb79['offset'];var _0x1cc388=_0x913b68?_0x15f49d['count']:_0x1cbb79['offset']+_0x1cbb79[_0x9b44('0x25')];var _0x1932f4;if(_0x1cc388>=_0x1085d1){_0x1cc388=_0x1085d1;_0x1932f4=0xc8;}else{_0x1932f4=0xce;}_0x4b25a5[_0x9b44('0x21')](_0x1932f4);return _0x4b25a5['set']('Content-Range',_0x276dfc+'-'+_0x1cc388+'/'+_0x1085d1)[_0x9b44('0x27')](_0x15f49d);}return null;};}function saveUpdates(_0x2920e8){return function(_0x380e19){if(_0x380e19){return _0x380e19[_0x9b44('0x28')](_0x2920e8)[_0x9b44('0x17')](function(_0x56b456){if(_0x56b456[_0x9b44('0x29')]===_0x9b44('0x2a')){socket[_0x9b44('0x2b')](_0x9b44('0x2c')+_0x56b456['id'],_0x56b456);}return _0x56b456;});}return null;};}function removeEntity(_0xc7a7f5){return function(_0x3e8e4b){if(_0x3e8e4b){return _0x3e8e4b['destroy']()['then'](function(){var _0x4f4ee0=_0x3e8e4b[_0x9b44('0x2d')]({'plain':!![]});if(_0x4f4ee0[_0x9b44('0x29')]==='admin')return;var _0xa3875b=[{'name':'Users','value':_0x9b44('0x2e'),'ignore':!![]},{'name':_0x9b44('0x2f'),'value':_0x9b44('0x2a'),'ignore':![]},{'name':_0x9b44('0x30'),'value':_0x9b44('0x31'),'ignore':![]}];var _0x710d91=_(_0xa3875b)[_0x9b44('0x32')](_0x9b44('0x33'))[_0x9b44('0x34')](_0x9b44('0x35'))['value']();if(_[_0x9b44('0x36')](_0x710d91,_0x4f4ee0['role'])){return;}var _0x3d66d5=_[_0x9b44('0x37')](_0xa3875b,[_0x9b44('0x35'),_0x4f4ee0['role']])[_0x9b44('0x38')];return db['UserProfileResource'][_0x9b44('0x39')]({'where':{'type':_0x3d66d5,'resourceId':_0x4f4ee0['id']}})[_0x9b44('0x17')](function(){return _0x3e8e4b;});})[_0x9b44('0x17')](function(){_0xc7a7f5[_0x9b44('0x21')](0xcc)[_0x9b44('0x22')]();});}};}function handleEntityNotFound(_0x3cec7d){return function(_0x242809){if(!_0x242809){_0x3cec7d[_0x9b44('0x20')](0x194);}return _0x242809;};}function handleError(_0x5826be,_0x17401a){_0x17401a=_0x17401a||0x1f4;return function(_0x187d0d){logger[_0x9b44('0x1c')](_0x187d0d[_0x9b44('0x3a')]);if(_0x187d0d['name']){delete _0x187d0d['name'];}_0x5826be[_0x9b44('0x21')](_0x17401a)[_0x9b44('0x3b')](_0x187d0d);};}exports[_0x9b44('0x3c')]=function(_0x361368,_0x4f37d8){var _0xc16d90={},_0x5c459f={'count':0x0,'rows':[]};var _0x200baf=_(db[_0x9b44('0x3d')]['rawAttributes'])[_0x9b44('0x34')](function(_0x30905c){return{'name':_0x30905c[_0x9b44('0x3e')],'type':_0x30905c[_0x9b44('0x3f')][_0x9b44('0x40')]};})[_0x9b44('0x32')](function(_0x42e7de){return!_[_0x9b44('0x36')](['password','salt'],_0x42e7de['name']);})[_0x9b44('0x35')]();_0xc16d90=qs[_0x9b44('0x41')](_0x200baf,_0x361368);var _0x1fe244={'where':_0xc16d90[_0x9b44('0x42')]};return db[_0x9b44('0x3d')][_0x9b44('0x26')](_0x1fe244)[_0x9b44('0x17')](function(_0x2d1afc){_0x5c459f[_0x9b44('0x26')]=_0x2d1afc;if(_0x361368[_0x9b44('0x43')]['includeAll']){_0xc16d90['include']=[{'all':!![]}];}if(_0x361368[_0x9b44('0x43')][_0x9b44('0x44')]===_0x9b44('0x45')){_0xc16d90['include']=[{'model':db[_0x9b44('0x46')],'as':_0x9b44('0x44')}];}if(!_['includes'](_0xc16d90[_0x9b44('0x47')],'id')){_0xc16d90[_0x9b44('0x47')][_0x9b44('0x48')]('id');}return db[_0x9b44('0x3d')][_0x9b44('0x49')](_0xc16d90);})[_0x9b44('0x17')](function(_0x32ccaa){_0x5c459f[_0x9b44('0x4a')]=_0x32ccaa;if(_0x361368['query'][_0x9b44('0x4b')]===_0x9b44('0x45')){var _0x91fee1=[];for(var _0x5a3615=0x0;_0x5a3615<_0x5c459f[_0x9b44('0x4a')][_0x9b44('0x4c')];_0x5a3615++){_0x91fee1[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4d'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615][_0x9b44('0x4e')]));_0x91fee1[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4f'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615]['dataValues']));_0x91fee1[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x50'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615]['dataValues']));_0x91fee1[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x51'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615][_0x9b44('0x4e')]));_0x91fee1[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x52'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615][_0x9b44('0x4e')]));_0x91fee1['push'](get_open_tabs(_0x9b44('0x53'),_0x5c459f[_0x9b44('0x4a')][_0x5a3615][_0x9b44('0x4e')]));}return Promise[_0x9b44('0x54')](_0x91fee1)[_0x9b44('0x17')](function(){return _0x5c459f;});}else{return _0x5c459f;}})['then'](respondWithFilteredResult(_0x4f37d8,_0xc16d90))[_0x9b44('0x1f')](handleError(_0x4f37d8,null));};exports[_0x9b44('0x55')]=function(_0x108fcb,_0x4d9521){var _0x278abb={'raw':![],'where':{'id':_0x108fcb[_0x9b44('0x56')]['id']}},_0x3883fb={};_0x3883fb[_0x9b44('0x57')]=_[_0x9b44('0x58')](_[_0x9b44('0x59')](db['User'][_0x9b44('0x5a')]),[_0x9b44('0x5b'),_0x9b44('0x5c')]);_0x3883fb['query']=_[_0x9b44('0x59')](_0x108fcb[_0x9b44('0x43')]);_0x3883fb[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x3883fb[_0x9b44('0x57')],_0x3883fb[_0x9b44('0x43')]);_0x278abb['attributes']=_[_0x9b44('0x5e')](_0x3883fb[_0x9b44('0x57')],qs[_0x9b44('0x5f')](_0x108fcb['query'][_0x9b44('0x5f')]));_0x278abb[_0x9b44('0x47')]=_0x278abb[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x278abb[_0x9b44('0x47')]:_0x3883fb[_0x9b44('0x57')];if(_0x108fcb[_0x9b44('0x43')][_0x9b44('0x60')]){_0x278abb['include']=[{'all':!![]}];}if(_0x108fcb['query'][_0x9b44('0x44')]==='true'){_0x278abb[_0x9b44('0x61')]=[{'model':db[_0x9b44('0x46')],'as':_0x9b44('0x44')}];}_0x278abb=_['merge']({},_0x278abb,_0x108fcb[_0x9b44('0x62')]);if(!_[_0x9b44('0x36')](_0x278abb[_0x9b44('0x47')],'id')){_0x278abb[_0x9b44('0x47')][_0x9b44('0x48')]('id');}return db['User'][_0x9b44('0x37')](_0x278abb)['then'](handleEntityNotFound(_0x4d9521,null))[_0x9b44('0x17')](function(_0x4a2462){var _0x55ac4f=[];values=_0x4a2462;if(_0x108fcb[_0x9b44('0x43')][_0x9b44('0x4b')]===_0x9b44('0x45')){_0x55ac4f[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4d'),_0x4a2462['dataValues']));_0x55ac4f[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4f'),_0x4a2462[_0x9b44('0x4e')]));_0x55ac4f['push'](get_open_tabs(_0x9b44('0x52'),_0x4a2462['dataValues']));_0x55ac4f[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x53'),_0x4a2462['dataValues']));_0x55ac4f[_0x9b44('0x48')](get_open_tabs('fax',_0x4a2462[_0x9b44('0x4e')]));_0x55ac4f[_0x9b44('0x48')](get_open_tabs('mail',_0x4a2462[_0x9b44('0x4e')]));return Promise[_0x9b44('0x54')](_0x55ac4f);}else{return values;}})[_0x9b44('0x17')](function(){return values;})[_0x9b44('0x17')](respondWithResult(_0x4d9521,null))[_0x9b44('0x1f')](handleError(_0x4d9521,null));};exports[_0x9b44('0x28')]=function(_0x525750,_0xb7e0e7){if(_0x525750[_0x9b44('0x63')]['id']){delete _0x525750['body']['id'];}delete _0x525750[_0x9b44('0x63')][_0x9b44('0x29')];return db[_0x9b44('0x3d')]['find']({'where':{'id':_0x525750[_0x9b44('0x56')]['id']}})['then'](handleEntityNotFound(_0xb7e0e7,null))[_0x9b44('0x17')](saveUpdates(_0x525750[_0x9b44('0x63')],null))['then'](respondWithResult(_0xb7e0e7,null))[_0x9b44('0x1f')](handleError(_0xb7e0e7,null));};exports[_0x9b44('0x64')]=function(_0x8689f,_0xd9091f){return db[_0x9b44('0x3d')]['describe']()[_0x9b44('0x17')](respondWithResult(_0xd9091f,null))[_0x9b44('0x1f')](handleError(_0xd9091f,null));};exports[_0x9b44('0x65')]=function(_0x31bf22,_0x4402e3){return db['User'][_0x9b44('0x37')]({'where':{'id':_0x31bf22[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x4402e3,null))['then'](function(_0x5b5333){if(_0x5b5333){return _0x5b5333[_0x9b44('0x65')](_0x31bf22[_0x9b44('0x63')][_0x9b44('0x66')],_['omit'](_0x31bf22[_0x9b44('0x63')],['ids','id'])||{});}})['then'](respondWithResult(_0x4402e3,null))[_0x9b44('0x1f')](handleError(_0x4402e3,null));};function validateUser(_0x77b17e){return new Promise(function(_0x1b3756,_0x31c703){if(_0x77b17e[_0x9b44('0x67')])return _0x1b3756(_0x77b17e);return db['Setting'][_0x9b44('0x68')](0x1)['then'](function(_0x34e7c3){if(_0x34e7c3['securePassword'])authService[_0x9b44('0x69')](_0x77b17e[_0x9b44('0x5b')]);db[_0x9b44('0x3d')][_0x9b44('0x6a')](_0x9b44('0x67'))[_0x9b44('0x17')](function(_0x2b4edb){if(_['isNil'](_0x2b4edb)){_0x77b17e['internal']=_0x34e7c3[_0x9b44('0x6b')]||0x1;return;}if(_[_0x9b44('0x6c')](_0x34e7c3['min_internal'])||_0x34e7c3[_0x9b44('0x6b')]===_0x2b4edb){_0x77b17e[_0x9b44('0x67')]=_0x2b4edb+0x1;return;}if(_0x34e7c3['min_internal']>_0x2b4edb){_0x77b17e[_0x9b44('0x67')]=_0x34e7c3[_0x9b44('0x6b')];return;}return db[_0x9b44('0x6d')][_0x9b44('0x43')](_0x9b44('0x6e'),{'type':db[_0x9b44('0x6d')][_0x9b44('0x6f')]['SELECT']})[_0x9b44('0x17')](function(_0x4d676e){if(_0x4d676e&&_0x4d676e[_0x9b44('0x4c')]){for(var _0x42feea=0x0,_0x5c8f7c=_0x4d676e[_0x9b44('0x4c')];_0x42feea<_0x5c8f7c&&_[_0x9b44('0x6c')](_0x77b17e[_0x9b44('0x67')]);_0x42feea++){if(_0x34e7c3['min_internal']<=_0x4d676e[_0x42feea][_0x9b44('0x70')]){_0x77b17e[_0x9b44('0x67')]=_0x4d676e[_0x42feea][_0x9b44('0x70')];}else if(_0x34e7c3[_0x9b44('0x6b')]>_0x4d676e[_0x42feea][_0x9b44('0x70')]&&_0x34e7c3[_0x9b44('0x6b')]<=_0x4d676e[_0x42feea]['to']){_0x77b17e[_0x9b44('0x67')]=_0x34e7c3[_0x9b44('0x6b')];}}}if(_['isNil'](_0x77b17e[_0x9b44('0x67')])){_0x77b17e['internal']=_0x2b4edb+0x1;}return _0x1b3756(_0x77b17e);});});})[_0x9b44('0x1f')](function(_0x1e79fa){_0x31c703(_0x1e79fa);});});}function updateUser(_0x52699c){return new Promise(function(_0x41d002,_0x366c02){try{if(_0x52699c['voicemail']){_0x52699c[_0x9b44('0x71')]=_0x52699c[_0x9b44('0x67')];_0x52699c[_0x9b44('0x72')]={'mailbox':_0x52699c['internal'],'password':_0x52699c[_0x9b44('0x5b')],'fullname':_0x52699c[_0x9b44('0x73')],'email':_0x52699c[_0x9b44('0x74')]};}if(_0x52699c[_0x9b44('0x29')]===_0x9b44('0x2a')){if(!_0x52699c['permissions'])_0x52699c[_0x9b44('0x75')]=[_0x9b44('0x76'),_0x9b44('0x77'),_0x9b44('0x78'),_0x9b44('0x79'),'110',_0x9b44('0x7a'),'105','106',_0x9b44('0x7b'),_0x9b44('0x7c'),'109',_0x9b44('0x7d'),_0x9b44('0x7e'),_0x9b44('0x7f'),_0x9b44('0x80')];}_0x41d002(_0x52699c);}catch(_0x3f8317){_0x366c02(_0x3f8317);}});}exports['create']=function(_0x13f4bd,_0x81ff4c){if(_0x13f4bd[_0x9b44('0x2e')][_0x9b44('0x29')]===_0x9b44('0x2a'))throw new Error(_0x9b44('0x81'));if(_0x13f4bd[_0x9b44('0x63')][_0x9b44('0x29')]===_0x9b44('0x2e')&&_0x13f4bd['user'][_0x9b44('0x29')]!==_0x9b44('0x82')){throw new Error(_0x9b44('0x83'));}if(_0x13f4bd[_0x9b44('0x63')][_0x9b44('0x29')]===_0x9b44('0x82')&&_0x13f4bd[_0x9b44('0x2e')][_0x9b44('0x29')]!==_0x9b44('0x82')){throw new Error(_0x9b44('0x84'));}return licenseUtil[_0x9b44('0x85')]([_0x13f4bd[_0x9b44('0x63')]])[_0x9b44('0x17')](function(){return validateUser(_0x13f4bd[_0x9b44('0x63')]);})[_0x9b44('0x17')](function(_0x420129){return updateUser(_0x420129)[_0x9b44('0x17')](function(_0x11ee8f){if(_0x11ee8f[_0x9b44('0x29')]===_0x9b44('0x82')){_0x11ee8f[_0x9b44('0x86')]=_0x13f4bd[_0x9b44('0x2e')][_0x9b44('0x86')];delete _0x11ee8f[_0x9b44('0x87')];}return _0x11ee8f;});})[_0x9b44('0x17')](function(_0x1dd28b){return db[_0x9b44('0x3d')]['create'](_0x1dd28b,{'include':[{'model':db[_0x9b44('0x72')],'as':_0x9b44('0x72')}]});})[_0x9b44('0x17')](function(_0x5c55ea){if(_0x13f4bd[_0x9b44('0x63')]['role']===_0x9b44('0x2e'))return _0x5c55ea;if(_0x13f4bd['user']['role']!==_0x9b44('0x2e'))return _0x5c55ea;return db[_0x9b44('0x88')][_0x9b44('0x37')]({'where':{'name':_0x5c55ea[_0x9b44('0x29')]==='agent'?_0x9b44('0x2f'):_0x9b44('0x30'),'userProfileId':_0x13f4bd[_0x9b44('0x2e')][_0x9b44('0x87')]},'raw':!![]})[_0x9b44('0x17')](function(_0x55ebde){if(!_0x55ebde||_0x55ebde['autoAssociation']!=0x0)return _0x5c55ea;return db[_0x9b44('0x89')][_0x9b44('0x8a')]({'name':_0x5c55ea[_0x9b44('0x38')],'resourceId':_0x5c55ea['id'],'type':_0x55ebde[_0x9b44('0x38')],'sectionId':_0x55ebde['id']},{})[_0x9b44('0x17')](function(){return _0x5c55ea;});})[_0x9b44('0x1f')](function(_0x1b6946){logger['error'](_0x9b44('0x8b'),_0x1b6946);throw _0x1b6946;});})[_0x9b44('0x17')](respondWithResult(_0x81ff4c,0xc9))[_0x9b44('0x1f')](handleError(_0x81ff4c,null));};exports['bulkCreate']=function(_0x15d436,_0x22dc9c){var _0x4b8a89=_0x15d436[_0x9b44('0x63')];var _0x53744b=[];if(_0x15d436[_0x9b44('0x2e')][_0x9b44('0x29')]===_0x9b44('0x2a'))throw new Error(_0x9b44('0x81'));if(_[_0x9b44('0x8c')](_0x4b8a89,[_0x9b44('0x29'),'user'])&&_0x15d436[_0x9b44('0x2e')][_0x9b44('0x29')]!==_0x9b44('0x82')){throw new Error('Unauthorized.\x20You\x20must\x20be\x20an\x20administrator\x20in\x20order\x20to\x20create\x20an\x20user');}if(_['some'](_0x4b8a89,['role',_0x9b44('0x82')])&&_0x15d436['user']['role']!==_0x9b44('0x82')){throw new Error(_0x9b44('0x8d'));}return licenseUtil[_0x9b44('0x85')](_0x4b8a89)[_0x9b44('0x17')](function(){return validateUser(_0x4b8a89[0x0]);})[_0x9b44('0x17')](function(){for(var _0x10ec7c=0x1;_0x10ec7c<_0x4b8a89[_0x9b44('0x4c')];_0x10ec7c++){var _0x5b406d=_0x4b8a89[_0x10ec7c-0x1][_0x9b44('0x67')];if(!_0x4b8a89[_0x10ec7c]['internal'])_0x4b8a89[_0x10ec7c]['internal']=_0x5b406d+0x1;_0x53744b[_0x9b44('0x48')](validateUser(_0x4b8a89[_0x10ec7c]));}return Promise[_0x9b44('0x54')](_0x53744b);})[_0x9b44('0x17')](function(){_0x53744b=[];for(var _0x5c08b5=0x0;_0x5c08b5<_0x4b8a89[_0x9b44('0x4c')];_0x5c08b5++){_0x53744b[_0x9b44('0x48')](updateUser(_0x4b8a89[_0x5c08b5]));}return Promise[_0x9b44('0x54')](_0x53744b);})[_0x9b44('0x17')](function(){_0x53744b=_0x4b8a89[_0x9b44('0x34')](function(_0x5858c7){return db['User'][_0x9b44('0x8a')](_0x5858c7,{'include':[{'model':db['VoiceMail'],'as':_0x9b44('0x72')}]})[_0x9b44('0x17')](function(_0x513f86){_0x5858c7['id']=_0x513f86['id'];return _0x5858c7;});});return Promise[_0x9b44('0x54')](_0x53744b);})['then'](function(_0x3591c7){if(_0x15d436[_0x9b44('0x63')]['role']==='user')return _0x3591c7;if(_0x15d436['user'][_0x9b44('0x29')]!==_0x9b44('0x2e'))return _0x3591c7;var _0x384f7a=_[_0x9b44('0x8c')](_0x3591c7,function(_0x445f6c){return _0x445f6c[_0x9b44('0x29')]==='agent'||_0x445f6c[_0x9b44('0x29')]===_0x9b44('0x31');});if(!_0x384f7a)return _0x3591c7;return db[_0x9b44('0x88')]['findAll']({'where':{'name':{'$or':['Agents','Telephones']},'userProfileId':_0x15d436[_0x9b44('0x2e')][_0x9b44('0x87')]},'raw':!![]})[_0x9b44('0x17')](function(_0x1a19d2){if(_[_0x9b44('0x8e')](_0x1a19d2)||!_[_0x9b44('0x8c')](_0x1a19d2,[_0x9b44('0x8f'),0x0]))return _0x3591c7;_0x53744b=[];var _0x3d93c5=_(_0x1a19d2)[_0x9b44('0x34')](function(_0x1ddbf3){if(_0x1ddbf3['autoAssociation']===0x1)return;return _0x1ddbf3['name']===_0x9b44('0x2f')?'agent':_0x9b44('0x31');})[_0x9b44('0x90')]()[_0x9b44('0x35')]();for(var _0x42f1c5=0x0;_0x42f1c5<_0x3591c7[_0x9b44('0x4c')];_0x42f1c5++){if(!_[_0x9b44('0x36')](_0x3d93c5,_0x3591c7[_0x42f1c5]['role']))return;var _0x5b976d=_0x3591c7[_0x42f1c5][_0x9b44('0x29')]===_0x9b44('0x2a')?_0x9b44('0x2f'):_0x9b44('0x30');_0x53744b['push'](db['UserProfileResource']['create']({'name':_0x3591c7[_0x42f1c5][_0x9b44('0x38')],'resourceId':_0x3591c7[_0x42f1c5]['id'],'type':_0x5b976d,'sectionId':_[_0x9b44('0x37')](_0x1a19d2,[_0x9b44('0x38'),_0x5b976d])['id']},{}));}return Promise[_0x9b44('0x54')](_0x53744b);});})[_0x9b44('0x17')](respondWithResult(_0x22dc9c,0xc9))[_0x9b44('0x1f')](handleError(_0x22dc9c,null));};exports[_0x9b44('0x91')]=function(_0x250916,_0xe67782){if(_0x250916['body']['id']){delete _0x250916[_0x9b44('0x63')]['id'];}return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x250916[_0x9b44('0x56')]['id']}})['then'](function(_0x446fd0){if(!_0x446fd0)return null;if(_0x446fd0['id']===_0x250916['user']['id']){if(!_0x250916[_0x9b44('0x63')][_0x9b44('0x92')]||!_0x250916[_0x9b44('0x63')][_0x9b44('0x93')]){throw new db[(_0x9b44('0x94'))]['ValidationError']('Invalid\x20body\x20format.\x20Use\x20oldPassword\x20and\x20newPassword');}if(!_0x446fd0[_0x9b44('0x95')](_0x250916[_0x9b44('0x63')][_0x9b44('0x92')])){throw new db[(_0x9b44('0x94'))]['ValidationError'](_0x9b44('0x96'));}if(_0x250916[_0x9b44('0x63')][_0x9b44('0x92')]===_0x250916[_0x9b44('0x63')][_0x9b44('0x93')]){throw new db[(_0x9b44('0x94'))][(_0x9b44('0x97'))](_0x9b44('0x98'));}}else if(_0x250916['user'][_0x9b44('0x29')]===_0x9b44('0x82')){if(!_0x250916[_0x9b44('0x63')][_0x9b44('0x93')]){throw new db[(_0x9b44('0x94'))]['ValidationError'](_0x9b44('0x99'));}}else if(_0x250916[_0x9b44('0x2e')]['role']===_0x9b44('0x2e')){if(!_0x250916[_0x9b44('0x63')][_0x9b44('0x93')]){throw new db[(_0x9b44('0x94'))][(_0x9b44('0x97'))](_0x9b44('0x99'));}if(_0x446fd0['role']!=='agent'){throw new db[(_0x9b44('0x94'))]['ValidationError'](_0x9b44('0x81'));}}else{throw new db[(_0x9b44('0x94'))][(_0x9b44('0x97'))](_0x9b44('0x81'));}return _0x446fd0;})[_0x9b44('0x17')](handleEntityNotFound(_0xe67782,null))[_0x9b44('0x17')](function(_0x4c4f0f){return db[_0x9b44('0x9a')]['findOne']({'attributes':['id',_0x9b44('0x9b'),_0x9b44('0x9c'),_0x9b44('0x9d')]})['then'](function(_0x270f18){if(_0x270f18[_0x9b44('0x9b')])authService[_0x9b44('0x69')](_0x250916['body'][_0x9b44('0x93')]);if(!_0x270f18['enforcePasswordHistory']||!_0x4c4f0f[_0x9b44('0x9e')])return _0x4c4f0f;authService['validatePasswordHistory'](_0x250916['body'][_0x9b44('0x93')],_0x4c4f0f[_0x9b44('0x9e')],_0x270f18[_0x9b44('0x9d')]);return _0x4c4f0f;})[_0x9b44('0x17')](saveUpdates({'password':_0x250916[_0x9b44('0x63')][_0x9b44('0x93')],'passwordResetAt':_0x250916[_0x9b44('0x2e')]['id']==_0x250916[_0x9b44('0x56')]['id']?moment():null,'previousPasswords':authService['updatePasswordsHistory'](_0x250916[_0x9b44('0x63')][_0x9b44('0x93')],_0x4c4f0f[_0x9b44('0x9e')])},null));})[_0x9b44('0x17')](respondWithResult(_0xe67782,null))[_0x9b44('0x1f')](handleError(_0xe67782,null));};exports[_0x9b44('0x9f')]=function(_0x2b592d,_0x15baca){var _0xd3f04d=_0x2b592d[_0x9b44('0x63')][_0x9b44('0xa0')];return db[_0x9b44('0x3d')]['find']({'where':{'id':_0x2b592d[_0x9b44('0x56')]['id']},'attributes':['id','name',_0x9b44('0x29'),'online',_0x9b44('0xa1'),'voicePause','interface']})[_0x9b44('0x17')](handleEntityNotFound(_0x15baca,null))[_0x9b44('0x17')](function(_0x49124b){if(_0x49124b){if(!utils[_0x9b44('0xa2')](_0xd3f04d)){throw new db['Sequelize'][(_0x9b44('0x97'))](_0x9b44('0xa3'));}return _0x49124b[_0x9b44('0xa4')+_[_0x9b44('0xa5')](_0xd3f04d[_0x9b44('0xa6')]())+'Queues'](_0x2b592d[_0x9b44('0x63')]['ids'],{'penalty':_0x2b592d['body'][_0x9b44('0xa7')]||0x0})['spread'](function(_0x25ac2f){for(var _0x162f12=0x0;_0x162f12<_0x2b592d[_0x9b44('0x63')][_0x9b44('0x66')][_0x9b44('0x4c')];_0x162f12+=0x1){var _0x222dd2={'UserId':Number(_0x2b592d['params']['id'])};_0x222dd2[_[_0x9b44('0xa5')](_0xd3f04d[_0x9b44('0xa6')]())+_0x9b44('0xa8')]=Number(_0x2b592d['body'][_0x9b44('0x66')][_0x162f12]);socket[_0x9b44('0x2b')]('user'+_[_0x9b44('0xa5')](_0xd3f04d[_0x9b44('0xa6')]())+_0x9b44('0xa9'),_0x222dd2);}return _0x25ac2f;})['then'](function(){if(_0xd3f04d===_0x9b44('0xaa')){return db['VoiceQueue']['findAll']({'where':{'id':_0x2b592d[_0x9b44('0x63')][_0x9b44('0x66')]||[]},'raw':!![],'attributes':['id',_0x9b44('0x38')]});}})['then'](function(_0x33623f){var _0x425ced=_0x49124b['get']({'plain':!![]});var _0x5778e6=[];if(_0xd3f04d===_0x9b44('0xaa')&&_0x425ced[_0x9b44('0x29')]==='agent'&&_0x425ced[_0x9b44('0xab')]){for(let _0x346d86=0x0;_0x346d86<_0x33623f['length'];_0x346d86+=0x1){_0x5778e6[_0x9b44('0x48')]({'membername':_0x425ced['name'],'UserId':_0x425ced['id'],'queue_name':_0x33623f[_0x346d86][_0x9b44('0x38')],'VoiceQueueId':_0x33623f[_0x346d86]['id'],'interface':_[_0x9b44('0x6c')](_0x425ced[_0x9b44('0xac')])?util[_0x9b44('0xad')](_0x9b44('0xae'),_0x425ced[_0x9b44('0x38')]):_0x425ced[_0x9b44('0xac')],'paused':_0x425ced[_0x9b44('0xaf')]||![],'penalty':_0x2b592d[_0x9b44('0x63')]['penalty']||0x0});}return Promise[_0x9b44('0x54')](_0x5778e6[_0x9b44('0x34')](function(_0x4fc836){return db[_0x9b44('0xb0')][_0x9b44('0xb1')](_0x4fc836);}));}return _0x49124b;});}})[_0x9b44('0x17')](respondWithStatusCode(_0x15baca,null))[_0x9b44('0x1f')](handleError(_0x15baca,null));};exports['removeQueues']=function(_0xc75f8a,_0x3d2410){var _0x3a190d,_0x1e66ee;return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0xc75f8a['params']['id']},'attributes':['id',_0x9b44('0x38'),_0x9b44('0x29')]})[_0x9b44('0x17')](handleEntityNotFound(_0x3d2410,null))['then'](function(_0x38584b){if(_0x38584b){_0x3a190d=_0x38584b;if(!_0xc75f8a[_0x9b44('0x43')][_0x9b44('0xa0')]||!utils[_0x9b44('0xa2')](_0xc75f8a['query']['channel'])){throw new db[(_0x9b44('0x94'))]['ValidationError'](_0x9b44('0xa3'));}return _0x38584b[_0x9b44('0xb2')+_[_0x9b44('0xa5')](_0xc75f8a['query'][_0x9b44('0xa0')][_0x9b44('0xa6')]())+_0x9b44('0xb3')](_0xc75f8a[_0x9b44('0x43')][_0x9b44('0x66')]);}})[_0x9b44('0x17')](function(_0x46428b){if(_[_0x9b44('0xb4')](_0xc75f8a[_0x9b44('0x43')][_0x9b44('0x66')])){for(var _0x213424=0x0;_0x213424<_0xc75f8a[_0x9b44('0x43')][_0x9b44('0x66')]['length'];_0x213424+=0x1){_0x1e66ee={'UserId':Number(_0xc75f8a[_0x9b44('0x56')]['id'])};_0x1e66ee[_[_0x9b44('0xa5')](_0xc75f8a['query']['channel'][_0x9b44('0xa6')]())+_0x9b44('0xa8')]=Number(_0xc75f8a['query'][_0x9b44('0x66')][_0x213424]);socket[_0x9b44('0x2b')]('user'+_[_0x9b44('0xa5')](_0xc75f8a[_0x9b44('0x43')]['channel']['toLowerCase']())+_0x9b44('0xb5'),_0x1e66ee);}}else{_0x1e66ee={'UserId':Number(_0xc75f8a[_0x9b44('0x56')]['id'])};_0x1e66ee[_['capitalize'](_0xc75f8a['query'][_0x9b44('0xa0')]['toLowerCase']())+_0x9b44('0xa8')]=Number(_0xc75f8a[_0x9b44('0x43')][_0x9b44('0x66')]);socket[_0x9b44('0x2b')]('user'+_[_0x9b44('0xa5')](_0xc75f8a['query'][_0x9b44('0xa0')][_0x9b44('0xa6')]())+_0x9b44('0xb5'),_0x1e66ee);}return _0x46428b;})['then'](function(){if(_0xc75f8a[_0x9b44('0x43')][_0x9b44('0xa0')]===_0x9b44('0xaa')){return db['UserVoiceQueueRt'][_0x9b44('0x39')]({'where':{'UserId':_0xc75f8a[_0x9b44('0x56')]['id'],'VoiceQueueId':_0xc75f8a['query'][_0x9b44('0x66')]},'individualHooks':!![]})[_0x9b44('0x17')](function(){return _0x3a190d;});}return _0x3a190d;})[_0x9b44('0x17')](respondWithStatusCode(_0x3d2410,null))[_0x9b44('0x1f')](handleError(_0x3d2410,null));};exports[_0x9b44('0xb6')]=function(_0x54ec4e,_0x140bf1){_0x54ec4e[_0x9b44('0x63')]['userpic']=_0x54ec4e['file'][_0x9b44('0xb7')];return db['User'][_0x9b44('0x37')]({'where':{'id':_0x54ec4e[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x140bf1,null))[_0x9b44('0x17')](saveUpdates(_0x54ec4e[_0x9b44('0x63')],null))[_0x9b44('0x17')](respondWithResult(_0x140bf1,null))[_0x9b44('0x1f')](handleError(_0x140bf1,null));};exports['getAvatar']=function(_0x31e27a,_0x203f87){var _0x27866d=path[_0x9b44('0xb8')](config[_0x9b44('0xb9')],_0x9b44('0xba'));return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x31e27a[_0x9b44('0x56')]['id']},'attributes':['id',_0x9b44('0xbb')],'raw':!![]})[_0x9b44('0x17')](handleEntityNotFound(_0x203f87,null))[_0x9b44('0x17')](function(_0x57108e){if(_0x57108e){if(_[_0x9b44('0x6c')](_0x57108e[_0x9b44('0xbb')])){return _0x203f87[_0x9b44('0xbc')](_0x27866d);}else{if(!fs[_0x9b44('0xbd')](path['join'](config[_0x9b44('0xb9')],_0x9b44('0xbe'),_0x57108e[_0x9b44('0xbb')]))){return _0x203f87[_0x9b44('0xbc')](_0x27866d);}return _0x203f87['download'](path[_0x9b44('0xb8')](config[_0x9b44('0xb9')],_0x9b44('0xbe'),_0x57108e[_0x9b44('0xbb')]));}}})[_0x9b44('0x1f')](handleError(_0x203f87,null));};exports[_0x9b44('0xbf')]=function(_0x4a7794,_0x23a591){return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x4a7794[_0x9b44('0x56')]['id']},'attributes':['id']})[_0x9b44('0x17')](handleEntityNotFound(_0x23a591,null))[_0x9b44('0x17')](function(_0x2c85a9){var _0x37cc2c=[];values=_0x2c85a9['dataValues'];_0x37cc2c[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4d'),_0x2c85a9[_0x9b44('0x4e')]));_0x37cc2c[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x4f'),_0x2c85a9[_0x9b44('0x4e')]));_0x37cc2c[_0x9b44('0x48')](get_open_tabs('openchannel',_0x2c85a9[_0x9b44('0x4e')]));_0x37cc2c[_0x9b44('0x48')](get_open_tabs(_0x9b44('0x53'),_0x2c85a9[_0x9b44('0x4e')]));_0x37cc2c['push'](get_open_tabs(_0x9b44('0x50'),_0x2c85a9[_0x9b44('0x4e')]));_0x37cc2c['push'](get_open_tabs(_0x9b44('0x51'),_0x2c85a9['dataValues']));return Promise[_0x9b44('0x54')](_0x37cc2c);})['then'](function(_0x297078){if(_0x297078){var _0x5ce485=_[_0x9b44('0x34')](values[_0x9b44('0xc0')],function(_0xee4c8){return{'channel':_0x9b44('0xc1'),'id':_0xee4c8['id'],'createdAt':_0xee4c8[_0x9b44('0xc2')]};});var _0x1eeef8=_[_0x9b44('0x34')](values['FaxOpenTabs'],function(_0x50facd){return{'channel':_0x9b44('0xc3'),'id':_0x50facd['id'],'createdAt':_0x50facd[_0x9b44('0xc2')]};});var _0x1a6257=_[_0x9b44('0x34')](values[_0x9b44('0xc4')],function(_0x50ab68){return{'channel':_0x9b44('0xc5'),'id':_0x50ab68['id'],'createdAt':_0x50ab68['createdAt']};});var _0x347255=_['map'](values[_0x9b44('0xc6')],function(_0x573015){return{'channel':'MAIL','id':_0x573015['id'],'createdAt':_0x573015[_0x9b44('0xc2')]};});var _0x9c06e5=_['map'](values[_0x9b44('0xc7')],function(_0x38a352){return{'channel':'SMS','id':_0x38a352['id'],'createdAt':_0x38a352[_0x9b44('0xc2')]};});var _0x15637e=_[_0x9b44('0x34')](values[_0x9b44('0xc8')],function(_0x24078f){return{'channel':_0x9b44('0xc9'),'id':_0x24078f['id'],'createdAt':_0x24078f['createdAt']};});var _0x58c10d=_['concat'](_0x5ce485,_0x1eeef8,_0x1a6257,_0x347255,_0x9c06e5,_0x15637e);var _0x5721cb={'count':_0x58c10d[_0x9b44('0x4c')],'rows':_0x58c10d};return _0x5721cb;}else return null;})[_0x9b44('0x17')](respondWithResult(_0x23a591,null))[_0x9b44('0x1f')](handleError(_0x23a591,null));};exports[_0x9b44('0xca')]=function(_0x8fc349,_0x3bf98d){var _0x4948e7={};var _0x1f279d={};var _0x260297;var _0x3c2bf8;return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x8fc349['params']['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x3bf98d,null))['then'](function(_0x56b392){if(_0x56b392){_0x260297=_0x56b392;_0x1f279d['model']=_['keys'](db['CmContact'][_0x9b44('0x5a')]);_0x1f279d[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x8fc349[_0x9b44('0x43')]);_0x1f279d['filters']=_[_0x9b44('0x5e')](_0x1f279d[_0x9b44('0x57')],_0x1f279d[_0x9b44('0x43')]);_0x4948e7[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x1f279d[_0x9b44('0x57')],qs[_0x9b44('0x5f')](_0x8fc349[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x4948e7[_0x9b44('0x47')]=_0x4948e7[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x4948e7[_0x9b44('0x47')]:_0x1f279d[_0x9b44('0x57')];_0x4948e7[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0x8fc349[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x4948e7['where']=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x8fc349['query'],_0x1f279d['filters']));if(_0x8fc349[_0x9b44('0x43')]['filter']){_0x4948e7[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x4948e7[_0x9b44('0x42')],{'$or':_['map'](_0x4948e7[_0x9b44('0x47')],function(_0x56eb12){var _0x4eb608={};_0x4eb608[_0x56eb12]={'$like':'%'+_0x8fc349['query'][_0x9b44('0x32')]+'%'};return _0x4eb608;})});}_0x4948e7=_[_0x9b44('0xcf')]({},_0x4948e7,_0x8fc349[_0x9b44('0x62')]);return _0x260297[_0x9b44('0xca')](_0x4948e7);}})[_0x9b44('0x17')](function(_0x1970aa){if(_0x1970aa){_0x3c2bf8=_0x1970aa[_0x9b44('0x4c')];if(_0x8fc349['query'][_0x9b44('0xd0')](_0x9b44('0x60'))){_0x4948e7[_0x9b44('0x61')]=[{'model':db[_0x9b44('0xd1')],'as':_0x9b44('0xd2'),'required':![]},{'model':db[_0x9b44('0xd3')],'as':_0x9b44('0xd4'),'attributes':['id',_0x9b44('0x38'),_0x9b44('0xd5')],'where':_0x8fc349[_0x9b44('0x43')]['tag']?{'id':_0x8fc349[_0x9b44('0x43')][_0x9b44('0xd6')]}:undefined,'required':_0x8fc349[_0x9b44('0x43')]['tag']?!![]:![]}];}if(!_0x8fc349[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x4948e7['limit']=qs[_0x9b44('0x25')](_0x8fc349[_0x9b44('0x43')]['limit']);_0x4948e7['offset']=qs['offset'](_0x8fc349[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x260297[_0x9b44('0xca')](_0x4948e7);}})['then'](function(_0x3e6607){if(_0x3e6607){return _0x3e6607?{'count':_0x3c2bf8,'rows':_0x3e6607}:null;}})[_0x9b44('0x17')](respondWithResult(_0x3bf98d,null))[_0x9b44('0x1f')](handleError(_0x3bf98d,null));};exports[_0x9b44('0xd8')]=function(_0x26cc53,_0x596edb){var _0x5ee4d5;var _0xcb8e47={};var _0x34b3c6;return db[_0x9b44('0x3d')]['findOne']({'where':{'id':_0x26cc53[_0x9b44('0x56')]['id']},'attributes':['id',_0x9b44('0x38'),_0x9b44('0x29')]})[_0x9b44('0x17')](handleEntityNotFound(_0x596edb,null))[_0x9b44('0x17')](function(_0x250aba){if(!utils[_0x9b44('0xa2')](_0x26cc53[_0x9b44('0x43')][_0x9b44('0xa0')])){throw new db[(_0x9b44('0x94'))][(_0x9b44('0x97'))]('Unknown\x20channel');}_0x5ee4d5=_0x250aba;var _0xf92ca1={};_0xf92ca1[_0x9b44('0x57')]=_[_0x9b44('0x59')](db[_[_0x9b44('0xa5')](_0x26cc53[_0x9b44('0x43')][_0x9b44('0xa0')])+'Queue'][_0x9b44('0x5a')]);_0xf92ca1[_0x9b44('0x43')]=_['keys'](_0x26cc53['query']);_0xf92ca1[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0xf92ca1['model'],_0xf92ca1[_0x9b44('0x43')]);_0xcb8e47[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0xf92ca1[_0x9b44('0x57')],qs['fields'](_0x26cc53[_0x9b44('0x43')][_0x9b44('0x5f')]));_0xcb8e47[_0x9b44('0x47')]=_0xcb8e47[_0x9b44('0x47')][_0x9b44('0x4c')]?_0xcb8e47['attributes']:_0xf92ca1[_0x9b44('0x57')];_0xcb8e47['order']=qs[_0x9b44('0xcd')](_0x26cc53[_0x9b44('0x43')]['sort']);_0xcb8e47['where']=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x26cc53[_0x9b44('0x43')],_0xf92ca1[_0x9b44('0x5d')]));if(_0x26cc53[_0x9b44('0x43')]['filter']){_0xcb8e47['where']=_[_0x9b44('0xcf')](_0xcb8e47['where'],{'$or':_[_0x9b44('0x34')](_0xcb8e47[_0x9b44('0x47')],function(_0x34a4ad){var _0x51cb9e={};_0x51cb9e[_0x34a4ad]={'$like':'%'+_0x26cc53[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x51cb9e;})});}_0xcb8e47=_[_0x9b44('0xcf')]({},_0xcb8e47,_0x26cc53[_0x9b44('0x62')]);switch(_0x5ee4d5[_0x9b44('0x29')]){case _0x9b44('0x82'):return db[_['capitalize'](_0x26cc53['query'][_0x9b44('0xa0')])+_0x9b44('0xd9')][_0x9b44('0x49')](_0xcb8e47);case'user':case _0x9b44('0x2a'):return _0x5ee4d5[_0x9b44('0x2d')+_[_0x9b44('0xa5')](_0x26cc53[_0x9b44('0x43')][_0x9b44('0xa0')])+_0x9b44('0xb3')](_0xcb8e47);default:throw new db[(_0x9b44('0x94'))]['ValidationError']('Unknown\x20role');}})[_0x9b44('0x17')](function(_0x55186d){_0x34b3c6=_0x55186d['length'];if(!_0x26cc53['query'][_0x9b44('0xd0')]('nolimit')){_0xcb8e47[_0x9b44('0x25')]=qs[_0x9b44('0x25')](_0x26cc53[_0x9b44('0x43')][_0x9b44('0x25')]);_0xcb8e47[_0x9b44('0x23')]=qs['offset'](_0x26cc53[_0x9b44('0x43')][_0x9b44('0x23')]);}switch(_0x5ee4d5[_0x9b44('0x29')]){case _0x9b44('0x82'):return db[_[_0x9b44('0xa5')](_0x26cc53[_0x9b44('0x43')]['channel'])+_0x9b44('0xd9')][_0x9b44('0x49')](_0xcb8e47);case _0x9b44('0x2e'):case _0x9b44('0x2a'):return _0x5ee4d5[_0x9b44('0x2d')+_[_0x9b44('0xa5')](_0x26cc53[_0x9b44('0x43')][_0x9b44('0xa0')])+'Queues'](_0xcb8e47);}})['then'](function(_0x5366d8){return{'count':_0x34b3c6,'rows':_0x5366d8};})[_0x9b44('0x17')](respondWithResult(_0x596edb,null))[_0x9b44('0x1f')](handleError(_0x596edb,null));};exports[_0x9b44('0xda')]=function(_0x4aa8b7,_0x14ee44){var _0x53824d={};var _0x20426a={};var _0x4c4d3c;var _0x401e32;return db[_0x9b44('0x3d')]['findOne']({'where':{'id':_0x4aa8b7['params']['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x14ee44,null))[_0x9b44('0x17')](function(_0x1f8e2d){if(_0x1f8e2d){_0x4c4d3c=_0x1f8e2d;_0x20426a[_0x9b44('0x57')]=_[_0x9b44('0x59')](db['UserVoiceQueueRt'][_0x9b44('0x5a')]);_0x20426a[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x4aa8b7['query']);_0x20426a[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x20426a['model'],_0x20426a[_0x9b44('0x43')]);_0x53824d[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x20426a[_0x9b44('0x57')],qs[_0x9b44('0x5f')](_0x4aa8b7[_0x9b44('0x43')]['fields']));_0x53824d[_0x9b44('0x47')]=_0x53824d[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x53824d['attributes']:_0x20426a[_0x9b44('0x57')];_0x53824d[_0x9b44('0xcc')]=qs['sort'](_0x4aa8b7['query'][_0x9b44('0xcd')]);_0x53824d[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x4aa8b7[_0x9b44('0x43')],_0x20426a[_0x9b44('0x5d')]));if(_0x4aa8b7['query'][_0x9b44('0x32')]){_0x53824d['where']=_['merge'](_0x53824d[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x53824d[_0x9b44('0x47')],function(_0x1e6948){var _0x5c740c={};_0x5c740c[_0x1e6948]={'$like':'%'+_0x4aa8b7[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x5c740c;})});}_0x53824d=_[_0x9b44('0xcf')]({},_0x53824d,_0x4aa8b7['options']);return _0x4c4d3c[_0x9b44('0xda')](_0x53824d);}})[_0x9b44('0x17')](function(_0x536272){if(_0x536272){_0x401e32=_0x536272[_0x9b44('0x4c')];if(!_0x4aa8b7[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x53824d['limit']=qs[_0x9b44('0x25')](_0x4aa8b7[_0x9b44('0x43')]['limit']);_0x53824d[_0x9b44('0x23')]=qs['offset'](_0x4aa8b7[_0x9b44('0x43')]['offset']);}return _0x4c4d3c[_0x9b44('0xda')](_0x53824d);}})[_0x9b44('0x17')](function(_0x3fadc9){if(_0x3fadc9){return _0x3fadc9?{'count':_0x401e32,'rows':_0x3fadc9}:null;}})[_0x9b44('0x17')](respondWithResult(_0x14ee44,null))[_0x9b44('0x1f')](handleError(_0x14ee44,null));};exports[_0x9b44('0xdb')]=function(_0x462c24,_0x47e748){var _0x3f7edc={};var _0x294daa={};var _0x54d49a;var _0x401248;return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x462c24[_0x9b44('0x56')]['id']}})['then'](handleEntityNotFound(_0x47e748,null))[_0x9b44('0x17')](function(_0x21727){if(_0x21727){_0x54d49a=_0x21727;_0x294daa['model']=_['keys'](db['ChatGroup'][_0x9b44('0x5a')]);_0x294daa['query']=_[_0x9b44('0x59')](_0x462c24[_0x9b44('0x43')]);_0x294daa[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x294daa[_0x9b44('0x57')],_0x294daa[_0x9b44('0x43')]);_0x3f7edc[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x294daa['model'],qs[_0x9b44('0x5f')](_0x462c24[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x3f7edc[_0x9b44('0x47')]=_0x3f7edc[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x3f7edc['attributes']:_0x294daa[_0x9b44('0x57')];_0x3f7edc['order']=qs[_0x9b44('0xcd')](_0x462c24[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x3f7edc[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x462c24[_0x9b44('0x43')],_0x294daa[_0x9b44('0x5d')]));if(_0x462c24['query'][_0x9b44('0x32')]){_0x3f7edc[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x3f7edc['where'],{'$or':_[_0x9b44('0x34')](_0x3f7edc[_0x9b44('0x47')],function(_0x2af8cd){var _0x48a221={};_0x48a221[_0x2af8cd]={'$like':'%'+_0x462c24['query'][_0x9b44('0x32')]+'%'};return _0x48a221;})});}_0x3f7edc=_[_0x9b44('0xcf')]({},_0x3f7edc,_0x462c24['options']);return _0x54d49a[_0x9b44('0xdb')](_0x3f7edc);}})['then'](function(_0x3f0bfd){if(_0x3f0bfd){_0x401248=_0x3f0bfd[_0x9b44('0x4c')];if(!_0x462c24[_0x9b44('0x43')][_0x9b44('0xd0')]('nolimit')){_0x3f7edc['limit']=qs[_0x9b44('0x25')](_0x462c24[_0x9b44('0x43')][_0x9b44('0x25')]);_0x3f7edc[_0x9b44('0x23')]=qs['offset'](_0x462c24[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x54d49a['getGroups'](_0x3f7edc);}})[_0x9b44('0x17')](function(_0x2ca0c8){if(_0x2ca0c8){return _0x2ca0c8?{'count':_0x401248,'rows':_0x2ca0c8}:null;}})[_0x9b44('0x17')](respondWithResult(_0x47e748,null))[_0x9b44('0x1f')](handleError(_0x47e748,null));};exports[_0x9b44('0xdc')]=function(_0x20894f,_0x37b4de){var _0x5d2f75={'raw':!![],'where':{}};var _0x39c6df={};var _0x1cbec7={'count':0x0,'rows':[]};return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x20894f[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x37b4de,null))[_0x9b44('0x17')](function(_0x99305c){if(_0x99305c){_0x39c6df['model']=_[_0x9b44('0x59')](db['VoiceRecording']['rawAttributes']);_0x39c6df[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x20894f[_0x9b44('0x43')]);_0x39c6df[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x39c6df[_0x9b44('0x57')],_0x39c6df['query']);_0x5d2f75[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x39c6df['model'],qs['fields'](_0x20894f['query'][_0x9b44('0x5f')]));_0x5d2f75['attributes']=_0x5d2f75[_0x9b44('0x47')]['length']?_0x5d2f75[_0x9b44('0x47')]:_0x39c6df['model'];if(!_0x20894f[_0x9b44('0x43')]['hasOwnProperty']('nolimit')){_0x5d2f75['limit']=qs[_0x9b44('0x25')](_0x20894f[_0x9b44('0x43')][_0x9b44('0x25')]);_0x5d2f75[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x20894f[_0x9b44('0x43')][_0x9b44('0x23')]);}_0x5d2f75['order']=qs[_0x9b44('0xcd')](_0x20894f['query'][_0x9b44('0xcd')]);_0x5d2f75[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_['pick'](_0x20894f[_0x9b44('0x43')],_0x39c6df[_0x9b44('0x5d')]));_0x5d2f75[_0x9b44('0x42')][_0x9b44('0xdd')]=_0x99305c['id'];if(_0x20894f['query'][_0x9b44('0x32')]){_0x5d2f75[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x5d2f75[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x5d2f75[_0x9b44('0x47')],function(_0x70ef58){var _0x5eddcf={};_0x5eddcf[_0x70ef58]={'$like':'%'+_0x20894f[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x5eddcf;})});}_0x5d2f75=_['merge']({},_0x5d2f75,_0x20894f[_0x9b44('0x62')]);return db['VoiceRecording'][_0x9b44('0x26')]({'where':_0x5d2f75[_0x9b44('0x42')]})[_0x9b44('0x17')](function(_0x521f33){_0x1cbec7['count']=_0x521f33;if(_0x20894f[_0x9b44('0x43')][_0x9b44('0x60')]){_0x5d2f75['include']=[{'all':!![]}];}return db[_0x9b44('0xde')][_0x9b44('0x49')](_0x5d2f75);})[_0x9b44('0x17')](function(_0x19d445){_0x1cbec7[_0x9b44('0x4a')]=_0x19d445;return _0x1cbec7;});}})[_0x9b44('0x17')](respondWithFilteredResult(_0x37b4de,_0x5d2f75))['catch'](handleError(_0x37b4de,null));};exports[_0x9b44('0xdf')]=function(_0x3b715b,_0x109042){var _0x232aa6={'raw':!![],'where':{}};var _0x44c17f={};var _0x4746a8={'count':0x0,'rows':[]};return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x3b715b[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x109042,null))[_0x9b44('0x17')](function(_0x4cedfa){if(_0x4cedfa){_0x44c17f['model']=_[_0x9b44('0x59')](db[_0x9b44('0xe0')][_0x9b44('0x5a')]);_0x44c17f[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x3b715b[_0x9b44('0x43')]);_0x44c17f[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x44c17f[_0x9b44('0x57')],_0x44c17f[_0x9b44('0x43')]);_0x232aa6[_0x9b44('0x47')]=_['intersection'](_0x44c17f[_0x9b44('0x57')],qs['fields'](_0x3b715b['query'][_0x9b44('0x5f')]));_0x232aa6[_0x9b44('0x47')]=_0x232aa6[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x232aa6[_0x9b44('0x47')]:_0x44c17f['model'];if(!_0x3b715b[_0x9b44('0x43')][_0x9b44('0xd0')]('nolimit')){_0x232aa6[_0x9b44('0x25')]=qs['limit'](_0x3b715b[_0x9b44('0x43')]['limit']);_0x232aa6['offset']=qs[_0x9b44('0x23')](_0x3b715b[_0x9b44('0x43')]['offset']);}_0x232aa6[_0x9b44('0xcc')]=qs['sort'](_0x3b715b['query']['sort']);_0x232aa6[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x3b715b[_0x9b44('0x43')],_0x44c17f[_0x9b44('0x5d')]));_0x232aa6['where'][_0x9b44('0xdd')]=_0x4cedfa['id'];if(_0x3b715b[_0x9b44('0x43')][_0x9b44('0x32')]){_0x232aa6['where']=_[_0x9b44('0xcf')](_0x232aa6[_0x9b44('0x42')],{'$or':_['map'](_0x232aa6['attributes'],function(_0x37a7e6){var _0x2ec918={};_0x2ec918[_0x37a7e6]={'$like':'%'+_0x3b715b['query']['filter']+'%'};return _0x2ec918;})});}_0x232aa6=_[_0x9b44('0xcf')]({},_0x232aa6,_0x3b715b[_0x9b44('0x62')]);return db[_0x9b44('0xe0')][_0x9b44('0x26')]({'where':_0x232aa6[_0x9b44('0x42')]})[_0x9b44('0x17')](function(_0x24fdf0){_0x4746a8[_0x9b44('0x26')]=_0x24fdf0;if(_0x3b715b[_0x9b44('0x43')][_0x9b44('0x60')]){_0x232aa6[_0x9b44('0x61')]=[{'all':!![]}];}return db['ScreenRecording'][_0x9b44('0x49')](_0x232aa6);})[_0x9b44('0x17')](function(_0x8a8e2e){_0x4746a8[_0x9b44('0x4a')]=_0x8a8e2e;return _0x4746a8;});}})[_0x9b44('0x17')](respondWithFilteredResult(_0x109042,_0x232aa6))[_0x9b44('0x1f')](handleError(_0x109042,null));};exports[_0x9b44('0xe1')]=function(_0xa02d2,_0x2029c5){var _0x47282e={};var _0x543c47={};var _0x1c6587;var _0xc411c7;return db[_0x9b44('0x3d')]['findOne']({'where':{'id':_0xa02d2['params']['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x2029c5,null))[_0x9b44('0x17')](function(_0x1c4239){if(_0x1c4239){_0x1c6587=_0x1c4239;_0x543c47[_0x9b44('0x57')]=_[_0x9b44('0x59')](db['ChatInteraction'][_0x9b44('0x5a')]);_0x543c47['query']=_[_0x9b44('0x59')](_0xa02d2[_0x9b44('0x43')]);_0x543c47[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x543c47[_0x9b44('0x57')],_0x543c47['query']);_0x47282e[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x543c47[_0x9b44('0x57')],qs[_0x9b44('0x5f')](_0xa02d2[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x47282e[_0x9b44('0x47')]=_0x47282e[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x47282e[_0x9b44('0x47')]:_0x543c47[_0x9b44('0x57')];_0x47282e[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0xa02d2[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x47282e[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0xa02d2[_0x9b44('0x43')],_0x543c47[_0x9b44('0x5d')]));if(_0xa02d2[_0x9b44('0x43')]['filter']){_0x47282e[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x47282e[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x47282e[_0x9b44('0x47')],function(_0x46e5b2){var _0x5612af={};_0x5612af[_0x46e5b2]={'$like':'%'+_0xa02d2[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x5612af;})});}_0x47282e=_['merge']({},_0x47282e,_0xa02d2['options']);return _0x1c6587[_0x9b44('0xe1')](_0x47282e);}})[_0x9b44('0x17')](function(_0x101119){if(_0x101119){_0xc411c7=_0x101119[_0x9b44('0x4c')];if(!_0xa02d2[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x47282e[_0x9b44('0x25')]=qs['limit'](_0xa02d2[_0x9b44('0x43')]['limit']);_0x47282e[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0xa02d2[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x1c6587[_0x9b44('0xe1')](_0x47282e);}})[_0x9b44('0x17')](function(_0x227084){if(_0x227084){return _0x227084?{'count':_0xc411c7,'rows':_0x227084}:null;}})[_0x9b44('0x17')](respondWithResult(_0x2029c5,null))[_0x9b44('0x1f')](handleError(_0x2029c5,null));};exports[_0x9b44('0xe2')]=function(_0x198853,_0x19f616){var _0x1566bb={};var _0x57783d={};var _0x37e870;var _0x43a7b9;return db['User'][_0x9b44('0xcb')]({'where':{'id':_0x198853[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x19f616,null))[_0x9b44('0x17')](function(_0x5d06ea){if(_0x5d06ea){_0x37e870=_0x5d06ea;_0x57783d[_0x9b44('0x57')]=_['keys'](db[_0x9b44('0xe3')][_0x9b44('0x5a')]);_0x57783d[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x198853[_0x9b44('0x43')]);_0x57783d[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x57783d[_0x9b44('0x57')],_0x57783d['query']);_0x1566bb[_0x9b44('0x47')]=_['intersection'](_0x57783d['model'],qs['fields'](_0x198853[_0x9b44('0x43')]['fields']));_0x1566bb['attributes']=_0x1566bb[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x1566bb[_0x9b44('0x47')]:_0x57783d[_0x9b44('0x57')];_0x1566bb[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0x198853[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x1566bb['where']=qs[_0x9b44('0x5d')](_['pick'](_0x198853[_0x9b44('0x43')],_0x57783d[_0x9b44('0x5d')]));if(_0x198853[_0x9b44('0x43')][_0x9b44('0x32')]){_0x1566bb['where']=_[_0x9b44('0xcf')](_0x1566bb['where'],{'$or':_[_0x9b44('0x34')](_0x1566bb['attributes'],function(_0x93fd3d){var _0x45f611={};_0x45f611[_0x93fd3d]={'$like':'%'+_0x198853['query']['filter']+'%'};return _0x45f611;})});}_0x1566bb=_[_0x9b44('0xcf')]({},_0x1566bb,_0x198853['options']);return _0x37e870[_0x9b44('0xe2')](_0x1566bb);}})[_0x9b44('0x17')](function(_0x468761){if(_0x468761){_0x43a7b9=_0x468761[_0x9b44('0x4c')];if(!_0x198853['query'][_0x9b44('0xd0')]('nolimit')){_0x1566bb[_0x9b44('0x25')]=qs[_0x9b44('0x25')](_0x198853[_0x9b44('0x43')][_0x9b44('0x25')]);_0x1566bb[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x198853[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x37e870[_0x9b44('0xe2')](_0x1566bb);}})[_0x9b44('0x17')](function(_0x2c44e0){if(_0x2c44e0){return _0x2c44e0?{'count':_0x43a7b9,'rows':_0x2c44e0}:null;}})[_0x9b44('0x17')](respondWithResult(_0x19f616,null))['catch'](handleError(_0x19f616,null));};exports[_0x9b44('0xe4')]=function(_0x30aa13,_0x2f70b5){var _0x1fe3d1={'raw':!![],'where':{}};var _0x4bd72b={};var _0x1daec0={'count':0x0,'rows':[]};return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x30aa13[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x2f70b5,null))[_0x9b44('0x17')](function(_0x3cc661){if(_0x3cc661){_0x4bd72b[_0x9b44('0x57')]=_[_0x9b44('0x59')](db[_0x9b44('0xe5')]['rawAttributes']);_0x4bd72b[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x30aa13[_0x9b44('0x43')]);_0x4bd72b[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x4bd72b['model'],_0x4bd72b['query']);_0x1fe3d1[_0x9b44('0x47')]=_['intersection'](_0x4bd72b['model'],qs['fields'](_0x30aa13[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x1fe3d1[_0x9b44('0x47')]=_0x1fe3d1[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x1fe3d1['attributes']:_0x4bd72b[_0x9b44('0x57')];if(!_0x30aa13[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x1fe3d1[_0x9b44('0x25')]=qs['limit'](_0x30aa13[_0x9b44('0x43')][_0x9b44('0x25')]);_0x1fe3d1[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x30aa13['query'][_0x9b44('0x23')]);}_0x1fe3d1['order']=qs['sort'](_0x30aa13[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x1fe3d1[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x30aa13['query'],_0x4bd72b[_0x9b44('0x5d')]));_0x1fe3d1[_0x9b44('0x42')][_0x9b44('0xdd')]=_0x3cc661['id'];if(_0x30aa13[_0x9b44('0x43')][_0x9b44('0x32')]){_0x1fe3d1[_0x9b44('0x42')]=_['merge'](_0x1fe3d1['where'],{'$or':_[_0x9b44('0x34')](_0x1fe3d1[_0x9b44('0x47')],function(_0x384ecd){var _0x1c8987={};_0x1c8987[_0x384ecd]={'$like':'%'+_0x30aa13[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x1c8987;})});}_0x1fe3d1=_[_0x9b44('0xcf')]({},_0x1fe3d1,_0x30aa13[_0x9b44('0x62')]);return db[_0x9b44('0xe5')][_0x9b44('0x26')]({'where':_0x1fe3d1[_0x9b44('0x42')]})[_0x9b44('0x17')](function(_0x379c64){_0x1daec0[_0x9b44('0x26')]=_0x379c64;if(_0x30aa13['query'][_0x9b44('0x60')]){_0x1fe3d1['include']=[{'all':!![]}];}return db[_0x9b44('0xe5')][_0x9b44('0x49')](_0x1fe3d1);})[_0x9b44('0x17')](function(_0xe59014){_0x1daec0[_0x9b44('0x4a')]=_0xe59014;return _0x1daec0;});}})[_0x9b44('0x17')](respondWithFilteredResult(_0x2f70b5,_0x1fe3d1))[_0x9b44('0x1f')](handleError(_0x2f70b5,null));};exports['getSmsInteractions']=function(_0x4b877d,_0x156abd){var _0x428219={};var _0x18013c={};var _0x48cb20;var _0x24aeb7;return db['User'][_0x9b44('0xcb')]({'where':{'id':_0x4b877d[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x156abd,null))[_0x9b44('0x17')](function(_0x377abc){if(_0x377abc){_0x48cb20=_0x377abc;_0x18013c[_0x9b44('0x57')]=_[_0x9b44('0x59')](db['SmsInteraction'][_0x9b44('0x5a')]);_0x18013c[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x4b877d[_0x9b44('0x43')]);_0x18013c['filters']=_['intersection'](_0x18013c[_0x9b44('0x57')],_0x18013c[_0x9b44('0x43')]);_0x428219[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x18013c[_0x9b44('0x57')],qs['fields'](_0x4b877d[_0x9b44('0x43')]['fields']));_0x428219[_0x9b44('0x47')]=_0x428219['attributes'][_0x9b44('0x4c')]?_0x428219['attributes']:_0x18013c['model'];_0x428219[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0x4b877d[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x428219[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x4b877d[_0x9b44('0x43')],_0x18013c['filters']));if(_0x4b877d['query']['filter']){_0x428219[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x428219[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x428219['attributes'],function(_0x2a3777){var _0x2a6696={};_0x2a6696[_0x2a3777]={'$like':'%'+_0x4b877d[_0x9b44('0x43')]['filter']+'%'};return _0x2a6696;})});}_0x428219=_[_0x9b44('0xcf')]({},_0x428219,_0x4b877d[_0x9b44('0x62')]);return _0x48cb20[_0x9b44('0xe6')](_0x428219);}})[_0x9b44('0x17')](function(_0x4ecfce){if(_0x4ecfce){_0x24aeb7=_0x4ecfce['length'];if(!_0x4b877d[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x428219['limit']=qs[_0x9b44('0x25')](_0x4b877d[_0x9b44('0x43')]['limit']);_0x428219[_0x9b44('0x23')]=qs['offset'](_0x4b877d[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x48cb20[_0x9b44('0xe6')](_0x428219);}})[_0x9b44('0x17')](function(_0x4d9773){if(_0x4d9773){return _0x4d9773?{'count':_0x24aeb7,'rows':_0x4d9773}:null;}})[_0x9b44('0x17')](respondWithResult(_0x156abd,null))[_0x9b44('0x1f')](handleError(_0x156abd,null));};exports[_0x9b44('0xe7')]=function(_0x17d237,_0x2b2b46){var _0x3ad785={};var _0x1cdf42={};var _0x4cbe59;var _0x448069;return db['User'][_0x9b44('0xcb')]({'where':{'id':_0x17d237[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x2b2b46,null))['then'](function(_0x560a6f){if(_0x560a6f){_0x4cbe59=_0x560a6f;_0x1cdf42['model']=_[_0x9b44('0x59')](db['FaxInteraction']['rawAttributes']);_0x1cdf42[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x17d237['query']);_0x1cdf42['filters']=_['intersection'](_0x1cdf42['model'],_0x1cdf42['query']);_0x3ad785['attributes']=_['intersection'](_0x1cdf42[_0x9b44('0x57')],qs['fields'](_0x17d237['query']['fields']));_0x3ad785[_0x9b44('0x47')]=_0x3ad785[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x3ad785[_0x9b44('0x47')]:_0x1cdf42[_0x9b44('0x57')];_0x3ad785['order']=qs[_0x9b44('0xcd')](_0x17d237['query'][_0x9b44('0xcd')]);_0x3ad785[_0x9b44('0x42')]=qs['filters'](_['pick'](_0x17d237[_0x9b44('0x43')],_0x1cdf42[_0x9b44('0x5d')]));if(_0x17d237['query'][_0x9b44('0x32')]){_0x3ad785['where']=_[_0x9b44('0xcf')](_0x3ad785[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x3ad785[_0x9b44('0x47')],function(_0x5d8239){var _0x58d9be={};_0x58d9be[_0x5d8239]={'$like':'%'+_0x17d237[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x58d9be;})});}_0x3ad785=_[_0x9b44('0xcf')]({},_0x3ad785,_0x17d237['options']);return _0x4cbe59['getFaxInteractions'](_0x3ad785);}})[_0x9b44('0x17')](function(_0x355866){if(_0x355866){_0x448069=_0x355866[_0x9b44('0x4c')];if(!_0x17d237[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x3ad785['limit']=qs['limit'](_0x17d237[_0x9b44('0x43')]['limit']);_0x3ad785[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x17d237[_0x9b44('0x43')]['offset']);}return _0x4cbe59['getFaxInteractions'](_0x3ad785);}})[_0x9b44('0x17')](function(_0x671958){if(_0x671958){return _0x671958?{'count':_0x448069,'rows':_0x671958}:null;}})[_0x9b44('0x17')](respondWithResult(_0x2b2b46,null))[_0x9b44('0x1f')](handleError(_0x2b2b46,null));};exports[_0x9b44('0xe8')]=function(_0x11c473,_0x2bb52c){var _0x4a1e39={};var _0x2e53a9={};var _0x8977df;var _0xe20893;return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x11c473[_0x9b44('0x56')]['id']}})['then'](handleEntityNotFound(_0x2bb52c,null))[_0x9b44('0x17')](function(_0x10df79){if(_0x10df79){_0x8977df=_0x10df79;_0x2e53a9['model']=_[_0x9b44('0x59')](db[_0x9b44('0xe9')][_0x9b44('0x5a')]);_0x2e53a9[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x11c473[_0x9b44('0x43')]);_0x2e53a9[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x2e53a9[_0x9b44('0x57')],_0x2e53a9['query']);_0x4a1e39[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x2e53a9[_0x9b44('0x57')],qs['fields'](_0x11c473[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x4a1e39[_0x9b44('0x47')]=_0x4a1e39[_0x9b44('0x47')][_0x9b44('0x4c')]?_0x4a1e39['attributes']:_0x2e53a9[_0x9b44('0x57')];_0x4a1e39[_0x9b44('0xcc')]=qs['sort'](_0x11c473[_0x9b44('0x43')]['sort']);_0x4a1e39['where']=qs[_0x9b44('0x5d')](_['pick'](_0x11c473[_0x9b44('0x43')],_0x2e53a9[_0x9b44('0x5d')]));if(_0x11c473[_0x9b44('0x43')]['filter']){_0x4a1e39['where']=_[_0x9b44('0xcf')](_0x4a1e39[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x4a1e39[_0x9b44('0x47')],function(_0x5854d4){var _0x56dfcb={};_0x56dfcb[_0x5854d4]={'$like':'%'+_0x11c473[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x56dfcb;})});}_0x4a1e39=_[_0x9b44('0xcf')]({},_0x4a1e39,_0x11c473[_0x9b44('0x62')]);return _0x8977df[_0x9b44('0xe8')](_0x4a1e39);}})[_0x9b44('0x17')](function(_0x37a509){if(_0x37a509){_0xe20893=_0x37a509['length'];if(!_0x11c473[_0x9b44('0x43')]['hasOwnProperty'](_0x9b44('0xd7'))){_0x4a1e39['limit']=qs[_0x9b44('0x25')](_0x11c473[_0x9b44('0x43')][_0x9b44('0x25')]);_0x4a1e39[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x11c473[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x8977df['getWhatsappInteractions'](_0x4a1e39);}})['then'](function(_0x2b0612){if(_0x2b0612){return _0x2b0612?{'count':_0xe20893,'rows':_0x2b0612}:null;}})[_0x9b44('0x17')](respondWithResult(_0x2bb52c,null))[_0x9b44('0x1f')](handleError(_0x2bb52c,null));};exports['login']=function(_0x2b7a18,_0x4db032,_0x4da05a){var _0x3845e5;var _0x3cc011;var _0xbddaf9;var _0x3e8262=!_[_0x9b44('0x6c')](_0x2b7a18[_0x9b44('0x56')]['id'])?_0x2b7a18['params']['id']:!_[_0x9b44('0x6c')](_0x2b7a18[_0x9b44('0x2e')]['id'])?_0x2b7a18[_0x9b44('0x2e')]['id']:null;return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x3e8262,'role':{'$or':[_0x9b44('0x82'),'user','agent']}},'attributes':['id','name',_0x9b44('0xea'),'mobile',_0x9b44('0x29'),_0x9b44('0x67'),'loginInPause']})[_0x9b44('0x17')](function(_0x2b1cca){if(_0x2b1cca){if(_0x2b1cca[_0x9b44('0x29')]==='agent'){_0x3845e5=_0x2b1cca;if(_0x2b7a18['body'][_0x9b44('0xac')]){_0xbddaf9=util[_0x9b44('0xad')](_0x9b44('0xeb'),_0x3845e5[_0x2b7a18['body']['interface']]);}else if(_0x2b7a18[_0x9b44('0x63')]['intrf']){_0xbddaf9=util['format'](_0x9b44('0xae'),_0x2b7a18[_0x9b44('0x63')][_0x9b44('0xec')]);}else{_0xbddaf9=util[_0x9b44('0xad')](_0x9b44('0xae'),_0x3845e5[_0x9b44('0x38')]);}socket['to'](util[_0x9b44('0xad')]('user:%s',_0x3845e5['name']))[_0x9b44('0x2b')]('user:forcelogout',{'user':{'id':_0x3845e5['id'],'name':_0x3845e5[_0x9b44('0x38')]},'ip':_0x2b7a18[_0x9b44('0xed')][_0x9b44('0xee')]||_0x2b7a18[_0x9b44('0xef')][_0x9b44('0xf0')]||_0x2b7a18[_0x9b44('0xf1')]['remoteAddress']||_0x2b7a18[_0x9b44('0xef')][_0x9b44('0xf1')]['remoteAddress']});return db[_0x9b44('0xb0')][_0x9b44('0x39')]({'where':{'membername':_0x3845e5['name']},'individualHooks':!![]});}}else{throw new db[(_0x9b44('0x94'))][(_0x9b44('0x97'))](_0x9b44('0xf2'));}})[_0x9b44('0x17')](function(){if(_0x3845e5){return _0x3845e5[_0x9b44('0xf3')]({'raw':!![]});}})[_0x9b44('0x17')](function(_0x154a32){if(_0x3845e5){if(_0x154a32){_0x3cc011=_0x154a32;if(_0x3cc011['length']){var _0x75ec0a=_0x3cc011['map'](function(_0x483696){var _0x36938a={'membername':_0x3845e5['name'],'UserId':_0x3845e5['id'],'queue_name':_0x483696[_0x9b44('0x38')],'VoiceQueueId':_0x483696['id'],'interface':_0xbddaf9,'paused':_0x3845e5[_0x9b44('0xa1')]||![],'penalty':_0x483696['UserVoiceQueue.penalty']||0x0};return db[_0x9b44('0xb0')][_0x9b44('0xb1')](_0x36938a);});return Promise[_0x9b44('0x54')](_0x75ec0a);}}}})[_0x9b44('0x17')](function(){if(_0x3845e5){return db[_0x9b44('0xf4')]['findAll']({'where':{'membername':_0x3845e5['name'],'exitAt':null}});}})['then'](function(_0x1d6e73){if(_0x3845e5){var _0x497bfd=[];_0x1d6e73[_0x9b44('0xf5')](function(_0x1076b6){_0x497bfd['push'](_0x1076b6['update']({'exitAt':moment()['format'](_0x9b44('0xf6'))}));});return Promise['all'](_0x497bfd);}})[_0x9b44('0x17')](function(){if(_0x3845e5){var _0x305207=[];var _0x373b95=[];var _0x485cc5=utils[_0x9b44('0xf7')]();var _0x40b8b0={'membername':_0x3845e5[_0x9b44('0x38')],'interface':_0xbddaf9,'enterAt':moment()[_0x9b44('0xad')](_0x9b44('0xf6')),'role':_0x3845e5[_0x9b44('0x29')],'internal':_0x3845e5[_0x9b44('0x67')]};_0x485cc5[_0x9b44('0xf5')](function(_0x9bd5c2){_0x305207[_0x9b44('0x48')](_[_0x9b44('0xcf')]({'channel':_0x9bd5c2,'type':'LOGIN','data1':_0x2b7a18[_0x9b44('0x63')]['device'],'data2':_0xbddaf9},_0x40b8b0));if(_0x3845e5[_0x9b44('0xa1')]){_0x373b95[_0x9b44('0x48')](_[_0x9b44('0xcf')]({'channel':_0x9bd5c2,'type':_0x9b44('0xf8'),'data1':_0x9b44('0xf9')},_0x40b8b0));}});return db[_0x9b44('0xf4')][_0x9b44('0xfa')](_0x305207[_0x9b44('0xfb')](_0x373b95),{'individualHooks':!![]});}})[_0x9b44('0x17')](function(){if(_0x3845e5){return _0x3845e5[_0x9b44('0x28')]({'online':!![],'lastLoginAt':moment()[_0x9b44('0xad')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x3845e5[_0x9b44('0xa1')]||![],'mailPause':_0x3845e5[_0x9b44('0xa1')]||![],'chatPause':_0x3845e5[_0x9b44('0xa1')]||![],'faxPause':_0x3845e5['loginInPause']||![],'smsPause':_0x3845e5['loginInPause']||![],'openchannelPause':_0x3845e5['loginInPause']||![],'whatsappPause':_0x3845e5[_0x9b44('0xa1')]||![],'pauseType':_0x3845e5[_0x9b44('0xa1')]?'LOGININPAUSE':null,'interface':_0xbddaf9,'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});}})[_0x9b44('0x17')](function(_0x56639d){if(_0x2b7a18['isMiddleware']){return _0x4da05a();}else{return Promise[_0x9b44('0xfc')](_0x56639d)[_0x9b44('0x17')](respondWithResult(_0x4db032,null));}})[_0x9b44('0x1f')](handleError(_0x4db032,null));};exports[_0x9b44('0xfd')]=function(_0x3e3c1b,_0x5cea85){var _0x56d9b5;return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x3e3c1b[_0x9b44('0x56')]['id'],'role':_0x9b44('0x2a')},'attributes':['id',_0x9b44('0x38'),'role']})[_0x9b44('0x17')](handleEntityNotFound(_0x5cea85,null))['then'](function(_0x52cb52){if(_0x52cb52){_0x56d9b5=_0x52cb52;return db[_0x9b44('0xb0')]['destroy']({'where':{'membername':_0x56d9b5[_0x9b44('0x38')]},'individualHooks':!![]});}})[_0x9b44('0x17')](function(){return db[_0x9b44('0xf4')][_0x9b44('0x49')]({'where':{'membername':_0x56d9b5[_0x9b44('0x38')],'exitAt':null}});})[_0x9b44('0x17')](function(_0x4fc976){var _0x20c710=[];_0x4fc976[_0x9b44('0xf5')](function(_0x30597f){_0x20c710[_0x9b44('0x48')](_0x30597f[_0x9b44('0x28')]({'exitAt':moment()[_0x9b44('0xad')]('YYYY-MM-DD\x20HH:mm:ss')}));});return Promise[_0x9b44('0x54')](_0x20c710);})['then'](function(){return _0x56d9b5[_0x9b44('0x28')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![],'interface':null});})[_0x9b44('0x17')](respondWithResult(_0x5cea85,null))[_0x9b44('0x1f')](handleError(_0x5cea85,null));};exports[_0x9b44('0xfe')]=function(_0x3b6766,_0x44dda6){var _0x32819c;return db[_0x9b44('0xb0')][_0x9b44('0x28')]({'paused':0x1},{'where':{'UserId':_0x3b6766['params']['id']},'individualHooks':!![]})[_0x9b44('0x17')](function(){return db[_0x9b44('0x3d')]['find']({'where':{'id':_0x3b6766[_0x9b44('0x56')]['id'],'role':_0x9b44('0x2a')},'attributes':['id',_0x9b44('0x38'),_0x9b44('0x29'),_0x9b44('0x67'),'interface',_0x9b44('0xab')]});})[_0x9b44('0x17')](handleEntityNotFound(_0x44dda6,null))['then'](function(_0x139078){if(_0x139078){_0x32819c=_0x139078;return respondWithRpcPromise(_0x9b44('0xff'),'pause',{'id':_0x32819c['id'],'name':_0x32819c['name'],'pause':!![]});}})[_0x9b44('0x17')](function(){if(_0x32819c){return db[_0x9b44('0xf4')][_0x9b44('0x49')]({'where':{'membername':_0x32819c[_0x9b44('0x38')],'type':_0x9b44('0xf8'),'exitAt':null}});}})[_0x9b44('0x17')](function(_0x490129){if(_0x490129['length']){var _0x577b02=moment()[_0x9b44('0xad')](_0x9b44('0xf6'));for(var _0x58fcc4=0x0,_0x58df9a=_0x490129[_0x9b44('0x4c')];_0x58fcc4<_0x58df9a;_0x58fcc4++){_0x490129[_0x58fcc4]['updateAttributes']({'exitAt':_0x577b02});}}})[_0x9b44('0x17')](function(){var _0x527ebf=[];var _0xec3bc3=utils[_0x9b44('0xf7')]();_0xec3bc3[_0x9b44('0xf5')](function(_0x22e4b0){_0x527ebf[_0x9b44('0x48')]({'channel':_0x22e4b0,'membername':_0x32819c[_0x9b44('0x38')],'interface':_[_0x9b44('0x6c')](_0x32819c[_0x9b44('0xac')])?util[_0x9b44('0xad')]('SIP/%s',_0x32819c[_0x9b44('0x38')]):_0x32819c[_0x9b44('0xac')],'type':_0x9b44('0xf8'),'enterAt':moment()[_0x9b44('0xad')](_0x9b44('0xf6')),'data1':_0x3b6766[_0x9b44('0x63')][_0x9b44('0x3f')]||'DEFAULT\x20PAUSE','role':_0x32819c[_0x9b44('0x29')],'internal':_0x32819c['internal']});});return db[_0x9b44('0xf4')][_0x9b44('0xfa')](_0x527ebf,{'individualHooks':!![]});})[_0x9b44('0x17')](function(){return _0x32819c[_0x9b44('0x28')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'whatsappPause':!![],'openchannelPause':!![],'pauseType':_0x3b6766[_0x9b44('0x63')]['type']||_0x9b44('0x100'),'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});})[_0x9b44('0x17')](respondWithResult(_0x44dda6,null))[_0x9b44('0x1f')](handleError(_0x44dda6,null));};exports[_0x9b44('0x101')]=function(_0x92d0a1,_0x276d96){if(_0x92d0a1[_0x9b44('0x63')][_0x9b44('0xa0')]&&!utils['isValidChannel'](_0x92d0a1['body'][_0x9b44('0xa0')])){throw new APIBadRequestError(util[_0x9b44('0xad')]('Channel\x20parameter\x20%s\x20is\x20invalid',_0x92d0a1[_0x9b44('0x63')][_0x9b44('0xa0')]));}return db[_0x9b44('0x3d')][_0x9b44('0x37')]({'where':{'id':_0x92d0a1[_0x9b44('0x56')]['id']},'attributes':['id',_0x9b44('0x38'),'role',_0x9b44('0x67'),_0x9b44('0xac'),'online',_0x9b44('0xaf'),_0x9b44('0x102'),'chatPause',_0x9b44('0x103'),_0x9b44('0x104'),_0x9b44('0x105'),_0x9b44('0x106'),_0x9b44('0x107'),_0x9b44('0x108')]})['then'](function(_0x443188){if(!_0x443188){throw new APINotFoundError(util[_0x9b44('0xad')](_0x9b44('0x109'),_0x92d0a1[_0x9b44('0x56')]['id']));}return _0x443188[_0x9b44('0x101')](_0x92d0a1['body'][_0x9b44('0xa0')]);})[_0x9b44('0x17')](respondWithResult(_0x276d96,null))[_0x9b44('0x1f')](APIHandleError(_0x276d96));};exports[_0x9b44('0x10a')]=function(_0x1acefa,_0x1c05a6){var _0x7d825b={};var _0x41c807={};var _0x29b1f6;var _0x58f81b;return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x1acefa[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x1c05a6,null))[_0x9b44('0x17')](function(_0x560894){if(_0x560894){_0x29b1f6=_0x560894;_0x41c807[_0x9b44('0x57')]=_[_0x9b44('0x59')](db['Team']['rawAttributes']);_0x41c807[_0x9b44('0x43')]=_[_0x9b44('0x59')](_0x1acefa[_0x9b44('0x43')]);_0x41c807['filters']=_['intersection'](_0x41c807[_0x9b44('0x57')],_0x41c807[_0x9b44('0x43')]);_0x7d825b[_0x9b44('0x47')]=_['intersection'](_0x41c807['model'],qs[_0x9b44('0x5f')](_0x1acefa[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x7d825b[_0x9b44('0x47')]=_0x7d825b['attributes'][_0x9b44('0x4c')]?_0x7d825b[_0x9b44('0x47')]:_0x41c807[_0x9b44('0x57')];_0x7d825b[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0x1acefa[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x7d825b[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x1acefa[_0x9b44('0x43')],_0x41c807[_0x9b44('0x5d')]));if(_0x1acefa[_0x9b44('0x43')][_0x9b44('0x32')]){_0x7d825b[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x7d825b[_0x9b44('0x42')],{'$or':_[_0x9b44('0x34')](_0x7d825b[_0x9b44('0x47')],function(_0xbce6c6){var _0x44bf42={};_0x44bf42[_0xbce6c6]={'$like':'%'+_0x1acefa['query'][_0x9b44('0x32')]+'%'};return _0x44bf42;})});}_0x7d825b=_[_0x9b44('0xcf')]({},_0x7d825b,_0x1acefa['options']);return _0x29b1f6[_0x9b44('0x10a')](_0x7d825b);}})[_0x9b44('0x17')](function(_0x3ecfd4){if(_0x3ecfd4){_0x58f81b=_0x3ecfd4[_0x9b44('0x4c')];if(!_0x1acefa[_0x9b44('0x43')][_0x9b44('0xd0')]('nolimit')){_0x7d825b['limit']=qs[_0x9b44('0x25')](_0x1acefa['query'][_0x9b44('0x25')]);_0x7d825b[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x1acefa[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x29b1f6[_0x9b44('0x10a')](_0x7d825b);}})['then'](function(_0x4f29bf){if(_0x4f29bf){return _0x4f29bf?{'count':_0x58f81b,'rows':_0x4f29bf}:null;}})['then'](respondWithResult(_0x1c05a6,null))[_0x9b44('0x1f')](handleError(_0x1c05a6,null));};exports['addTeams']=function(_0x2109d8,_0x3f7fc5){var _0x3b8558=_0x2109d8['params']['id'];var _0x1a2247=_0x2109d8[_0x9b44('0x63')]?_0x2109d8['body'][_0x9b44('0x66')]:null;var _0x1b009a=[];return Promise[_0x9b44('0xfc')]()[_0x9b44('0x17')](function(){if(!_0x1a2247)throw new APIBadRequestError(_0x9b44('0x10b'));})[_0x9b44('0x17')](function(){return db[_0x9b44('0x3d')]['findOne']({'where':{'id':_0x3b8558}});})[_0x9b44('0x17')](function(_0x15c315){if(!_0x15c315)throw new APINotFoundError(util[_0x9b44('0xad')](_0x9b44('0x109'),_0x2109d8[_0x9b44('0x56')]['id']));return db[_0x9b44('0x6d')][_0x9b44('0x10c')](function(_0x1963e2){return _0x15c315[_0x9b44('0x10d')](_0x1a2247,{'transaction':_0x1963e2})[_0x9b44('0x17')](function(){return db[_0x9b44('0x10e')]['findAll']({'where':{'id':{'$in':_0x1a2247}}});})[_0x9b44('0x17')](function(_0x4329ca){var _0x2633cc=_[_0x9b44('0x34')](_0x4329ca,function(_0x3c917a){return _0x3c917a[_0x9b44('0x10f')]();});return Promise[_0x9b44('0x54')](_0x2633cc);})[_0x9b44('0x17')](function(_0x299693){_0x1b009a=_[_0x9b44('0x110')](_0x299693);var _0x172ff0=_[_0x9b44('0x34')](_0x1b009a,function(_0x2cc464){return _0x2cc464['addAgent'](_0x15c315['id'],{'transaction':_0x1963e2});});return Promise[_0x9b44('0x54')](_0x172ff0);})[_0x9b44('0x17')](function(){if(!_0x15c315[_0x9b44('0xab')])return;var _0x29235b=_['filter'](_0x1b009a,function(_0x5a24d1){return _0x5a24d1[_0x9b44('0x111')]('channel')===_0x9b44('0x112');});var _0x4504bb=_[_0x9b44('0x34')](_0x29235b,function(_0x5d3d28){return db['UserVoiceQueueRt'][_0x9b44('0xb1')]({'membername':_0x15c315[_0x9b44('0x38')],'UserId':_0x15c315['id'],'queue_name':_0x5d3d28[_0x9b44('0x38')],'VoiceQueueId':_0x5d3d28['id'],'interface':_[_0x9b44('0x6c')](_0x15c315[_0x9b44('0xac')])?util[_0x9b44('0xad')](_0x9b44('0xae'),_0x15c315[_0x9b44('0x38')]):_0x15c315['interface'],'paused':_0x15c315[_0x9b44('0xaf')]||![],'penalty':_0x15c315[_0x9b44('0xa7')]},{'transaction':_0x1963e2});});return Promise[_0x9b44('0x54')](_0x4504bb);})[_0x9b44('0x17')](function(){return db[_0x9b44('0x113')]['findAll']({'where':{'teamId':{'$in':_0x1a2247}}});})[_0x9b44('0x17')](function(_0x213628){var _0x212bee=_[_0x9b44('0x34')](_0x213628,function(_0x1dbc0){return db[_0x9b44('0x114')]['create']({'UserId':_0x15c315['id'],'VoicePrefixId':_0x1dbc0['VoicePrefixId']},{'transaction':_0x1963e2});});return Promise['all'](_0x212bee);});});})[_0x9b44('0x17')](function(){for(var _0x210c3e=0x0;_0x210c3e<_0x1b009a[_0x9b44('0x4c')];_0x210c3e++){var _0xab1552=_0x1b009a[_0x210c3e][_0x9b44('0x111')]('channel');var _0x13d8db=_0xab1552+_0x9b44('0xa8');socket[_0x9b44('0x2b')](_0x9b44('0x2e')+_0xab1552+_0x9b44('0xa9'),{'UserId':_0x3b8558,['queueField']:_0x1b009a[_0x210c3e]['id']});}})[_0x9b44('0x17')](respondWithStatusCode(_0x3f7fc5,null))['catch'](APIHandleError(_0x3f7fc5));};exports[_0x9b44('0x115')]=function(_0xa7aac6,_0x4f885d){var _0x27aeb3=_0xa7aac6[_0x9b44('0x56')]['id'];var _0x120270=null;if(_0xa7aac6['query']['ids']){_0x120270=_[_0x9b44('0xb4')](_0xa7aac6[_0x9b44('0x43')][_0x9b44('0x66')])?_0xa7aac6[_0x9b44('0x43')][_0x9b44('0x66')]:[_0xa7aac6[_0x9b44('0x43')][_0x9b44('0x66')]];}var _0x866737=[];return Promise[_0x9b44('0xfc')]()[_0x9b44('0x17')](function(){if(!_0x120270)throw new APIBadRequestError(_0x9b44('0x116'));})[_0x9b44('0x17')](function(){return db[_0x9b44('0x3d')][_0x9b44('0xcb')]({'where':{'id':_0x27aeb3}});})['then'](function(_0x1d1b92){if(!_0x1d1b92)throw new APINotFoundError(util[_0x9b44('0xad')]('User\x20with\x20id\x20%s\x20not\x20found',_0xa7aac6['params']['id']));return db['sequelize']['transaction'](function(_0x193c16){return _0x1d1b92[_0x9b44('0x115')](_0x120270,{'transaction':_0x193c16})['then'](function(){return db[_0x9b44('0x10e')]['findAll']({'where':{'id':{'$in':_0x120270}}});})['then'](function(_0x21c332){var _0x1ef137=_['map'](_0x21c332,function(_0xa33c0){return _0xa33c0[_0x9b44('0x10f')]();});return Promise[_0x9b44('0x54')](_0x1ef137);})[_0x9b44('0x17')](function(_0x352080){_0x866737=_[_0x9b44('0x110')](_0x352080);var _0x53249c=_['map'](_0x866737,function(_0x5637c1){return _0x5637c1['removeAgent'](_0x1d1b92['id'],{'transaction':_0x193c16});});return Promise[_0x9b44('0x54')](_0x53249c);})[_0x9b44('0x17')](function(){if(!_0x1d1b92[_0x9b44('0xab')])return;var _0x1e88b5=_[_0x9b44('0x32')](_0x866737,function(_0x4a7525){return _0x4a7525[_0x9b44('0x111')]('channel')===_0x9b44('0x112');});var _0x271dc1=_['map'](_0x1e88b5,function(_0x272f1a){return db[_0x9b44('0xb0')]['destroy']({'where':{'VoiceQueueId':_0x272f1a['id'],'UserId':_0x1d1b92['id']},'transaction':_0x193c16});});return Promise[_0x9b44('0x54')](_0x271dc1);})[_0x9b44('0x17')](function(){return db[_0x9b44('0x113')][_0x9b44('0x49')]({'where':{'teamId':{'$in':_0x120270}}});})[_0x9b44('0x17')](function(_0x32bc9e){var _0x29117b=_[_0x9b44('0x34')](_0x32bc9e,function(_0x4c61dc){return db[_0x9b44('0x114')][_0x9b44('0x39')]({'where':{'UserId':_0x1d1b92['id'],'VoicePrefixId':_0x4c61dc['VoicePrefixId']}},{'transaction':_0x193c16});});return Promise[_0x9b44('0x54')](_0x29117b);});});})[_0x9b44('0x17')](function(){for(var _0x5e096b=0x0;_0x5e096b<_0x866737[_0x9b44('0x4c')];_0x5e096b++){var _0x1a3471=_0x866737[_0x5e096b]['getDataValue']('channel');var _0x5daa29=_0x1a3471+_0x9b44('0xa8');socket[_0x9b44('0x2b')](_0x9b44('0x2e')+_0x1a3471+_0x9b44('0xb5'),{'UserId':_0x27aeb3,['queueField']:_0x866737[_0x5e096b]['id']});}})['then'](respondWithStatusCode(_0x4f885d,null))[_0x9b44('0x1f')](APIHandleError(_0x4f885d));};exports[_0x9b44('0x117')]=function(_0x241f43,_0x3dc834){var _0x588bda={};var _0x34e740={};var _0x1032db;var _0x3e00be;return db['User'][_0x9b44('0xcb')]({'where':{'id':_0x241f43[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x3dc834,null))[_0x9b44('0x17')](function(_0x620c89){if(_0x620c89){_0x1032db=_0x620c89;_0x34e740['model']=_[_0x9b44('0x59')](db[_0x9b44('0xd1')]['rawAttributes']);_0x34e740[_0x9b44('0x43')]=_['keys'](_0x241f43['query']);_0x34e740[_0x9b44('0x5d')]=_[_0x9b44('0x5e')](_0x34e740[_0x9b44('0x57')],_0x34e740[_0x9b44('0x43')]);_0x588bda[_0x9b44('0x47')]=_['intersection'](_0x34e740[_0x9b44('0x57')],qs[_0x9b44('0x5f')](_0x241f43[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x588bda[_0x9b44('0x47')]=_0x588bda['attributes'][_0x9b44('0x4c')]?_0x588bda['attributes']:_0x34e740[_0x9b44('0x57')];_0x588bda[_0x9b44('0xcc')]=qs[_0x9b44('0xcd')](_0x241f43[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x588bda[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_[_0x9b44('0xce')](_0x241f43[_0x9b44('0x43')],_0x34e740[_0x9b44('0x5d')]));if(_0x241f43['query']['filter']){_0x588bda[_0x9b44('0x42')]=_[_0x9b44('0xcf')](_0x588bda[_0x9b44('0x42')],{'$or':_['map'](_0x588bda[_0x9b44('0x47')],function(_0x3ce887){var _0x3aa9fc={};_0x3aa9fc[_0x3ce887]={'$like':'%'+_0x241f43[_0x9b44('0x43')]['filter']+'%'};return _0x3aa9fc;})});}_0x588bda=_[_0x9b44('0xcf')]({},_0x588bda,_0x241f43['options']);return _0x1032db[_0x9b44('0x117')](_0x588bda);}})[_0x9b44('0x17')](function(_0x1b749c){if(_0x1b749c){_0x3e00be=_0x1b749c[_0x9b44('0x4c')];if(!_0x241f43[_0x9b44('0x43')][_0x9b44('0xd0')](_0x9b44('0xd7'))){_0x588bda[_0x9b44('0x25')]=qs[_0x9b44('0x25')](_0x241f43[_0x9b44('0x43')]['limit']);_0x588bda[_0x9b44('0x23')]=qs[_0x9b44('0x23')](_0x241f43[_0x9b44('0x43')][_0x9b44('0x23')]);}return _0x1032db[_0x9b44('0x117')](_0x588bda);}})[_0x9b44('0x17')](function(_0x454d86){if(_0x454d86){return _0x454d86?{'count':_0x3e00be,'rows':_0x454d86}:null;}})[_0x9b44('0x17')](respondWithResult(_0x3dc834,null))[_0x9b44('0x1f')](handleError(_0x3dc834,null));};exports[_0x9b44('0x118')]=function(_0x30e14e,_0x324991){var _0x1e0603={};var _0x502622={};var _0x3c33db;return db['User'][_0x9b44('0xcb')]({'where':{'id':_0x30e14e[_0x9b44('0x56')]['id']}})[_0x9b44('0x17')](handleEntityNotFound(_0x324991,null))['then'](function(_0x228b37){if(_0x228b37){_0x3c33db=_0x228b37;_0x502622[_0x9b44('0x57')]=_['keys'](db[_0x9b44('0x3d')][_0x9b44('0x5a')]);_0x502622['query']=_['keys'](_0x30e14e[_0x9b44('0x43')]);_0x502622['filters']=_[_0x9b44('0x5e')](_0x502622[_0x9b44('0x57')],_0x502622[_0x9b44('0x43')]);_0x1e0603[_0x9b44('0x47')]=_[_0x9b44('0x5e')](_0x502622['model'],qs[_0x9b44('0x5f')](_0x30e14e[_0x9b44('0x43')][_0x9b44('0x5f')]));_0x1e0603[_0x9b44('0x47')]=_0x1e0603['attributes'][_0x9b44('0x4c')]?_0x1e0603['attributes']:_0x502622[_0x9b44('0x57')];_0x1e0603[_0x9b44('0xcc')]=qs['sort'](_0x30e14e[_0x9b44('0x43')][_0x9b44('0xcd')]);_0x1e0603[_0x9b44('0x42')]=qs[_0x9b44('0x5d')](_['pick'](_0x30e14e['query'],_0x502622[_0x9b44('0x5d')]));if(_0x30e14e[_0x9b44('0x43')][_0x9b44('0x32')]){_0x1e0603[_0x9b44('0x42')]=_['merge'](_0x1e0603[_0x9b44('0x42')],{'$or':_['map'](_0x1e0603['attributes'],function(_0x5ce254){var _0x952f78={};_0x952f78[_0x5ce254]={'$like':'%'+_0x30e14e[_0x9b44('0x43')][_0x9b44('0x32')]+'%'};return _0x952f78;})});}_0x1e0603[_0x9b44('0x57')]=db[_0x9b44('0x3d')];_0x1e0603['as']=_0x9b44('0x2f');_0x1e0603=_['merge']({},_0x1e0603,_0x30e14e[_0x9b44('0x62')]);return _0x3c33db[_0x9b44('0xf3')]({'include':[_0x1e0603]});}})['then'](function(_0x4c8412){if(_0x4c8412){var _0x2a04c1={},_0x13c535=[];for(var _0x3ec50b=0x0;_0x3ec50b<_0x4c8412[_0x9b44('0x4c')];_0x3ec50b+=0x1){for(var _0x5674ce=0x0,_0x5e0b05;_0x5674ce<_0x4c8412[_0x3ec50b][_0x9b44('0x2f')]['length'];_0x5674ce+=0x1){_0x5e0b05=_0x4c8412[_0x3ec50b][_0x9b44('0x2f')][_0x5674ce][_0x9b44('0x2d')]({'plain':!![]});_0x2a04c1[_0x5e0b05['id']]=_0x5e0b05;}}_0x2a04c1=_['values'](_0x2a04c1);for(var _0x59bcab=qs['offset'](_0x30e14e[_0x9b44('0x43')]['offset']);_0x59bcab<_0x2a04c1[_0x9b44('0x4c')]&&_0x13c535[_0x9b44('0x4c')]=_0x3e1283['agents']){throw new Error(_0xfe0f('0x4d'));}})['then'](function(){if(_0x1d228d){return db['UserVoiceQueueRt'][_0xfe0f('0x43')]({'where':{'membername':_0x1d228d['name']},'individualHooks':!![]});}})[_0xfe0f('0x14')](function(){if(_0x1d228d){return _0x1d228d[_0xfe0f('0x4e')]({'raw':!![]});}})[_0xfe0f('0x14')](function(_0x392610){if(_0x1d228d){if(_0x392610){var _0x37a8cc=[];_0x56db4b=_0x392610;if(_0x56db4b[_0xfe0f('0x2a')]){for(var _0x4c8bf4=0x0;_0x4c8bf4<_0x56db4b[_0xfe0f('0x2a')];_0x4c8bf4++){_0x37a8cc['push'](db[_0xfe0f('0x26')][_0xfe0f('0x4f')]({'membername':_0x1d228d['name'],'UserId':_0x1d228d['id'],'queue_name':_0x56db4b[_0x4c8bf4][_0xfe0f('0x20')],'VoiceQueueId':_0x56db4b[_0x4c8bf4]['id'],'interface':_0x5eb6c3,'paused':_0x1d228d[_0xfe0f('0x48')]||![],'penalty':_0x56db4b[_0x4c8bf4][_0xfe0f('0x50')]||0x0}));}return BPromise['all'](_0x37a8cc);}}}})[_0xfe0f('0x14')](function(){if(_0x1d228d){return db['MemberReport'][_0xfe0f('0xc')]({'where':{'membername':_0x1d228d[_0xfe0f('0x20')],'exitAt':null}});}})[_0xfe0f('0x14')](function(_0xd44ca4){if(_0x1d228d){if(_0xd44ca4&&_0xd44ca4[_0xfe0f('0x2a')]){var _0x52b669=[];_0xd44ca4[_0xfe0f('0x2e')](function(_0x645dee){_0x52b669[_0xfe0f('0x44')](_0x645dee[_0xfe0f('0x27')]({'exitAt':moment()[_0xfe0f('0x23')]('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise[_0xfe0f('0x45')](_0x52b669);}}})[_0xfe0f('0x14')](function(){if(_0x1d228d){var _0x3408eb=[];var _0x48c95a=[];var _0x14f22a=utils[_0xfe0f('0x2d')]();var _0x46d646={'membername':_0x1d228d['name'],'interface':_0x5eb6c3,'enterAt':moment()[_0xfe0f('0x23')](_0xfe0f('0x2b')),'role':_0x1d228d[_0xfe0f('0x21')],'internal':_0x1d228d[_0xfe0f('0x22')]};_0x14f22a[_0xfe0f('0x2e')](function(_0x4005dd){_0x3408eb['push'](_[_0xfe0f('0x51')]({'channel':_0x4005dd,'type':_0xfe0f('0x52'),'data1':_0xfe0f('0x53'),'data2':_0x5eb6c3},_0x46d646));if(_0x1d228d[_0xfe0f('0x48')]){_0x48c95a['push'](_[_0xfe0f('0x51')]({'channel':_0x4005dd,'type':_0xfe0f('0x29'),'data1':_0xfe0f('0x54')},_0x46d646));}});return db[_0xfe0f('0x28')][_0xfe0f('0x34')](_0x3408eb[_0xfe0f('0x55')](_0x48c95a),{'individualHooks':!![]});}})[_0xfe0f('0x14')](function(){if(_0x1d228d){return _0x1d228d[_0xfe0f('0x27')]({'online':!![],'lastLoginAt':moment()[_0xfe0f('0x23')](_0xfe0f('0x2b')),'voicePause':_0x1d228d[_0xfe0f('0x48')]||![],'mailPause':_0x1d228d[_0xfe0f('0x48')]||![],'chatPause':_0x1d228d[_0xfe0f('0x48')]||![],'faxPause':_0x1d228d['loginInPause']||![],'smsPause':_0x1d228d[_0xfe0f('0x48')]||![],'openchannelPause':_0x1d228d[_0xfe0f('0x48')]||![],'pauseType':_0x1d228d[_0xfe0f('0x48')]?_0xfe0f('0x54'):null,'lastPauseAt':moment()[_0xfe0f('0x23')]('YYYY-MM-DD\x20HH:mm:ss'),'interface':_0x5eb6c3});}})['then'](function(_0x21c85e){_0x1eb2a9(_0x21c85e);})['catch'](function(_0x5a3f42){_0x1e46be(_0x58cdd2[_0xfe0f('0x18')](0x1f4,_0x5a3f42[_0xfe0f('0x19')]));});});}; \ No newline at end of file diff --git a/server/api/user/user.socket.js b/server/api/user/user.socket.js new file mode 100644 index 0000000..eca77f2 --- /dev/null +++ b/server/api/user/user.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x25b6=['update','removeListener','length','user:'];(function(_0x487f07,_0x5256f4){var _0x30f811=function(_0x56bc87){while(--_0x56bc87){_0x487f07['push'](_0x487f07['shift']());}};_0x30f811(++_0x5256f4);}(_0x25b6,0x150));var _0x625b=function(_0x46111d,_0x5d286b){_0x46111d=_0x46111d-0x0;var _0xe82586=_0x25b6[_0x46111d];return _0xe82586;};'use strict';var UserEvents=require('./user.events');var events=['save','remove',_0x625b('0x0')];function createListener(_0x5edd04,_0xfbe237){return function(_0x5bc4d5){_0xfbe237['emit'](_0x5edd04,_0x5bc4d5);};}function removeListener(_0x509e3d,_0x1cc4e5){return function(){UserEvents[_0x625b('0x1')](_0x509e3d,_0x1cc4e5);};}exports['register']=function(_0x107b93){for(var _0x70681f=0x0,_0xb18ac6=events[_0x625b('0x2')];_0x70681f<_0xb18ac6;_0x70681f++){var _0x442979=events[_0x70681f];var _0x353cb7=createListener(_0x625b('0x3')+_0x442979,_0x107b93);UserEvents['on'](_0x442979,_0x353cb7);}}; \ No newline at end of file diff --git a/server/api/userChatQueue/index.js b/server/api/userChatQueue/index.js new file mode 100644 index 0000000..deb4ff7 --- /dev/null +++ b/server/api/userChatQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../components/interaction/service','../../config/environment','exports','multer','util','path','Router','../../components/auth/service'];(function(_0x17543f,_0x34a3aa){var _0x479c57=function(_0x10207e){while(--_0x10207e){_0x17543f['push'](_0x17543f['shift']());}};_0x479c57(++_0x34a3aa);}(_0xa9e0,0x123));var _0x0a9e=function(_0x5ddb1c,_0x5ea4df){_0x5ddb1c=_0x5ddb1c-0x0;var _0x354adc=_0xa9e0[_0x5ddb1c];return _0x354adc;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));module[_0x0a9e('0x7')]=router; \ No newline at end of file diff --git a/server/api/userChatQueue/userChatQueue.attributes.js b/server/api/userChatQueue/userChatQueue.attributes.js new file mode 100644 index 0000000..e2aaf0d --- /dev/null +++ b/server/api/userChatQueue/userChatQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc7e2=['sequelize','exports'];(function(_0x330d71,_0x23b7f2){var _0x463119=function(_0x5c0510){while(--_0x5c0510){_0x330d71['push'](_0x330d71['shift']());}};_0x463119(++_0x23b7f2);}(_0xc7e2,0x1d4));var _0x2c7e=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xc7e2[_0x3dd15e];return _0x231fd0;};'use strict';var Sequelize=require(_0x2c7e('0x0'));module[_0x2c7e('0x1')]={'penalty':{'type':Sequelize['INTEGER'],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userChatQueue/userChatQueue.model.js b/server/api/userChatQueue/userChatQueue.model.js new file mode 100644 index 0000000..d6afbed --- /dev/null +++ b/server/api/userChatQueue/userChatQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5b51=['api','bluebird','rimraf','../../config/environment','./userChatQueue.attributes','exports','UserChatQueue','lodash','util','../../config/logger'];(function(_0xaa1b3e,_0x47d976){var _0x454d7d=function(_0x575b32){while(--_0x575b32){_0xaa1b3e['push'](_0xaa1b3e['shift']());}};_0x454d7d(++_0x47d976);}(_0x5b51,0x9d));var _0x15b5=function(_0x5cfb92,_0x5797e6){_0x5cfb92=_0x5cfb92-0x0;var _0x1cd7c2=_0x5b51[_0x5cfb92];return _0x1cd7c2;};'use strict';var _=require(_0x15b5('0x0'));var util=require(_0x15b5('0x1'));var logger=require(_0x15b5('0x2'))(_0x15b5('0x3'));var moment=require('moment');var BPromise=require(_0x15b5('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x15b5('0x5'));var config=require(_0x15b5('0x6'));var attributes=require(_0x15b5('0x7'));module[_0x15b5('0x8')]=function(_0xf65df3,_0x28e2c6){return _0xf65df3['define'](_0x15b5('0x9'),attributes,{'tableName':'user_has_chat_queues','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userChatQueue/userChatQueue.rpc.js b/server/api/userChatQueue/userChatQueue.rpc.js new file mode 100644 index 0000000..ed3b959 --- /dev/null +++ b/server/api/userChatQueue/userChatQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37ad=['code','message','result','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','then','UserChatQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error'];(function(_0xc45495,_0x4e59bf){var _0x131eb5=function(_0x1b55d4){while(--_0x1b55d4){_0xc45495['push'](_0xc45495['shift']());}};_0x131eb5(++_0x4e59bf);}(_0x37ad,0x1a5));var _0xd37a=function(_0x1c5209,_0x1a557d){_0x1c5209=_0x1c5209-0x0;var _0x2a9911=_0x37ad[_0x1c5209];return _0x2a9911;};'use strict';var _=require(_0xd37a('0x0'));var util=require(_0xd37a('0x1'));var moment=require(_0xd37a('0x2'));var BPromise=require(_0xd37a('0x3'));var rs=require(_0xd37a('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xd37a('0x5'));var logger=require(_0xd37a('0x6'))('rpc');var config=require(_0xd37a('0x7'));var jayson=require(_0xd37a('0x8'));var client=jayson[_0xd37a('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2e6891,_0x188228,_0x4afaf5){return new BPromise(function(_0x1d85ca,_0x5ee0dd){return client['request'](_0x2e6891,_0x4afaf5)[_0xd37a('0xa')](function(_0x5f43d1){logger['info'](_0xd37a('0xb'),_0x188228,_0xd37a('0xc'));logger[_0xd37a('0xd')]('UserChatQueue,\x20%s,\x20%s,\x20%s',_0x188228,'request\x20sent',JSON[_0xd37a('0xe')](_0x5f43d1));if(_0x5f43d1['error']){if(_0x5f43d1[_0xd37a('0xf')][_0xd37a('0x10')]===0x1f4){logger[_0xd37a('0xf')](_0xd37a('0xb'),_0x188228,_0x5f43d1[_0xd37a('0xf')][_0xd37a('0x11')]);return _0x5ee0dd(_0x5f43d1['error'][_0xd37a('0x11')]);}logger[_0xd37a('0xf')](_0xd37a('0xb'),_0x188228,_0x5f43d1[_0xd37a('0xf')][_0xd37a('0x11')]);return _0x1d85ca(_0x5f43d1[_0xd37a('0xf')][_0xd37a('0x11')]);}else{logger['info']('UserChatQueue,\x20%s,\x20%s',_0x188228,_0xd37a('0xc'));_0x1d85ca(_0x5f43d1[_0xd37a('0x12')][_0xd37a('0x11')]);}})['catch'](function(_0x143e75){logger['error']('UserChatQueue,\x20%s,\x20%s',_0x188228,_0x143e75);_0x5ee0dd(_0x143e75);});});} \ No newline at end of file diff --git a/server/api/userFaxQueue/index.js b/server/api/userFaxQueue/index.js new file mode 100644 index 0000000..041c545 --- /dev/null +++ b/server/api/userFaxQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','multer','util'];(function(_0x2c17c7,_0x171f6a){var _0x2c0cda=function(_0xe91723){while(--_0xe91723){_0x2c17c7['push'](_0x2c17c7['shift']());}};_0x2c0cda(++_0x171f6a);}(_0xd8b0,0xad));var _0x0d8b=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xd8b0[_0x122ef9];return _0x42fba0;};'use strict';var multer=require(_0x0d8b('0x0'));var util=require(_0x0d8b('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0d8b('0x2')]();var fs_extra=require(_0x0d8b('0x3'));var auth=require(_0x0d8b('0x4'));var interaction=require(_0x0d8b('0x5'));var config=require(_0x0d8b('0x6'));module['exports']=router; \ No newline at end of file diff --git a/server/api/userFaxQueue/userFaxQueue.attributes.js b/server/api/userFaxQueue/userFaxQueue.attributes.js new file mode 100644 index 0000000..e2aab7f --- /dev/null +++ b/server/api/userFaxQueue/userFaxQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf461=['exports','INTEGER','STRING','sequelize'];(function(_0x2b3b07,_0xa237cb){var _0x553ac5=function(_0x3d9297){while(--_0x3d9297){_0x2b3b07['push'](_0x2b3b07['shift']());}};_0x553ac5(++_0xa237cb);}(_0xf461,0x14f));var _0x1f46=function(_0x246be2,_0x120bca){_0x246be2=_0x246be2-0x0;var _0x3a08c7=_0xf461[_0x246be2];return _0x3a08c7;};'use strict';var Sequelize=require(_0x1f46('0x0'));module[_0x1f46('0x1')]={'penalty':{'type':Sequelize[_0x1f46('0x2')],'defaultValue':0x0},'assigned':{'type':Sequelize[_0x1f46('0x2')],'defaultValue':0x0},'queue':{'type':Sequelize[_0x1f46('0x3')]}}; \ No newline at end of file diff --git a/server/api/userFaxQueue/userFaxQueue.model.js b/server/api/userFaxQueue/userFaxQueue.model.js new file mode 100644 index 0000000..1b9f607 --- /dev/null +++ b/server/api/userFaxQueue/userFaxQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x97ca=['./userFaxQueue.attributes','UserFaxQueue','user_has_fax_queues','lodash','util','../../config/logger','api','moment','request-promise','path','rimraf','../../config/environment'];(function(_0xbca1b1,_0x33f0ce){var _0x4e1686=function(_0x58a80c){while(--_0x58a80c){_0xbca1b1['push'](_0xbca1b1['shift']());}};_0x4e1686(++_0x33f0ce);}(_0x97ca,0x19b));var _0xa97c=function(_0x1cccea,_0x27acc2){_0x1cccea=_0x1cccea-0x0;var _0x571972=_0x97ca[_0x1cccea];return _0x571972;};'use strict';var _=require(_0xa97c('0x0'));var util=require(_0xa97c('0x1'));var logger=require(_0xa97c('0x2'))(_0xa97c('0x3'));var moment=require(_0xa97c('0x4'));var BPromise=require('bluebird');var rp=require(_0xa97c('0x5'));var fs=require('fs');var path=require(_0xa97c('0x6'));var rimraf=require(_0xa97c('0x7'));var config=require(_0xa97c('0x8'));var attributes=require(_0xa97c('0x9'));module['exports']=function(_0x2f3cd5,_0x3119cd){return _0x2f3cd5['define'](_0xa97c('0xa'),attributes,{'tableName':_0xa97c('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userFaxQueue/userFaxQueue.rpc.js b/server/api/userFaxQueue/userFaxQueue.rpc.js new file mode 100644 index 0000000..dd0902a --- /dev/null +++ b/server/api/userFaxQueue/userFaxQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc19=['http','request','then','info','UserFaxQueue,\x20%s,\x20%s','request\x20sent','debug','UserFaxQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise'];(function(_0x3bf83e,_0x36169b){var _0xa24fe5=function(_0x4c427f){while(--_0x4c427f){_0x3bf83e['push'](_0x3bf83e['shift']());}};_0xa24fe5(++_0x36169b);}(_0xfc19,0x64));var _0x9fc1=function(_0x4d4ef0,_0x5c6861){_0x4d4ef0=_0x4d4ef0-0x0;var _0x2a7d05=_0xfc19[_0x4d4ef0];return _0x2a7d05;};'use strict';var _=require(_0x9fc1('0x0'));var util=require(_0x9fc1('0x1'));var moment=require(_0x9fc1('0x2'));var BPromise=require(_0x9fc1('0x3'));var rs=require(_0x9fc1('0x4'));var fs=require('fs');var Redis=require(_0x9fc1('0x5'));var db=require(_0x9fc1('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x9fc1('0x7'));var config=require(_0x9fc1('0x8'));var jayson=require(_0x9fc1('0x9'));var client=jayson['client'][_0x9fc1('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x19ad5e,_0x313c8c,_0x141949){return new BPromise(function(_0x1c40d2,_0x51a42e){return client[_0x9fc1('0xb')](_0x19ad5e,_0x141949)[_0x9fc1('0xc')](function(_0x2af6e2){logger[_0x9fc1('0xd')](_0x9fc1('0xe'),_0x313c8c,_0x9fc1('0xf'));logger[_0x9fc1('0x10')](_0x9fc1('0x11'),_0x313c8c,_0x9fc1('0xf'),JSON['stringify'](_0x2af6e2));if(_0x2af6e2[_0x9fc1('0x12')]){if(_0x2af6e2[_0x9fc1('0x12')][_0x9fc1('0x13')]===0x1f4){logger[_0x9fc1('0x12')](_0x9fc1('0xe'),_0x313c8c,_0x2af6e2[_0x9fc1('0x12')][_0x9fc1('0x14')]);return _0x51a42e(_0x2af6e2[_0x9fc1('0x12')][_0x9fc1('0x14')]);}logger[_0x9fc1('0x12')](_0x9fc1('0xe'),_0x313c8c,_0x2af6e2['error'][_0x9fc1('0x14')]);return _0x1c40d2(_0x2af6e2['error'][_0x9fc1('0x14')]);}else{logger[_0x9fc1('0xd')](_0x9fc1('0xe'),_0x313c8c,'request\x20sent');_0x1c40d2(_0x2af6e2['result']['message']);}})[_0x9fc1('0x15')](function(_0x5c5322){logger['error'](_0x9fc1('0xe'),_0x313c8c,_0x5c5322);_0x51a42e(_0x5c5322);});});} \ No newline at end of file diff --git a/server/api/userMailQueue/index.js b/server/api/userMailQueue/index.js new file mode 100644 index 0000000..c06c4e6 --- /dev/null +++ b/server/api/userMailQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../components/interaction/service','../../config/environment','exports','multer','util','path','Router','../../components/auth/service'];(function(_0x4316d5,_0x17ca8c){var _0x304ce7=function(_0x7b464a){while(--_0x7b464a){_0x4316d5['push'](_0x4316d5['shift']());}};_0x304ce7(++_0x17ca8c);}(_0xa9e0,0x123));var _0x0a9e=function(_0x6131cd,_0x4c26a1){_0x6131cd=_0x6131cd-0x0;var _0x47e916=_0xa9e0[_0x6131cd];return _0x47e916;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));module[_0x0a9e('0x7')]=router; \ No newline at end of file diff --git a/server/api/userMailQueue/userMailQueue.attributes.js b/server/api/userMailQueue/userMailQueue.attributes.js new file mode 100644 index 0000000..e95e28d --- /dev/null +++ b/server/api/userMailQueue/userMailQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x49be=['exports','sequelize'];(function(_0xf7d967,_0x8bf1cb){var _0x2a4f92=function(_0x59b128){while(--_0x59b128){_0xf7d967['push'](_0xf7d967['shift']());}};_0x2a4f92(++_0x8bf1cb);}(_0x49be,0x12b));var _0xe49b=function(_0x47878f,_0x48d3bf){_0x47878f=_0x47878f-0x0;var _0x4b05b8=_0x49be[_0x47878f];return _0x4b05b8;};'use strict';var Sequelize=require(_0xe49b('0x0'));module[_0xe49b('0x1')]={'penalty':{'type':Sequelize['INTEGER'],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userMailQueue/userMailQueue.model.js b/server/api/userMailQueue/userMailQueue.model.js new file mode 100644 index 0000000..06bbfe7 --- /dev/null +++ b/server/api/userMailQueue/userMailQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9b39=['path','./userMailQueue.attributes','exports','define','UserMailQueue','user_has_mail_queues','lodash','util','api','moment','bluebird'];(function(_0x169c39,_0x5d9651){var _0x820530=function(_0x498674){while(--_0x498674){_0x169c39['push'](_0x169c39['shift']());}};_0x820530(++_0x5d9651);}(_0x9b39,0x17c));var _0x99b3=function(_0x9731fe,_0x3116cf){_0x9731fe=_0x9731fe-0x0;var _0x45adea=_0x9b39[_0x9731fe];return _0x45adea;};'use strict';var _=require(_0x99b3('0x0'));var util=require(_0x99b3('0x1'));var logger=require('../../config/logger')(_0x99b3('0x2'));var moment=require(_0x99b3('0x3'));var BPromise=require(_0x99b3('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x99b3('0x5'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x99b3('0x6'));module[_0x99b3('0x7')]=function(_0x4537f9,_0x26d0c4){return _0x4537f9[_0x99b3('0x8')](_0x99b3('0x9'),attributes,{'tableName':_0x99b3('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userMailQueue/userMailQueue.rpc.js b/server/api/userMailQueue/userMailQueue.rpc.js new file mode 100644 index 0000000..7894b32 --- /dev/null +++ b/server/api/userMailQueue/userMailQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x00bb=['stringify','error','message','catch','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','request','info','UserMailQueue,\x20%s,\x20%s','request\x20sent','debug','UserMailQueue,\x20%s,\x20%s,\x20%s'];(function(_0x1a9c91,_0x5ddb25){var _0x2ea348=function(_0x9695a5){while(--_0x9695a5){_0x1a9c91['push'](_0x1a9c91['shift']());}};_0x2ea348(++_0x5ddb25);}(_0x00bb,0x1d8));var _0xb00b=function(_0x2d7f0e,_0x3e6fbd){_0x2d7f0e=_0x2d7f0e-0x0;var _0x110b07=_0x00bb[_0x2d7f0e];return _0x110b07;};'use strict';var _=require(_0xb00b('0x0'));var util=require(_0xb00b('0x1'));var moment=require(_0xb00b('0x2'));var BPromise=require('bluebird');var rs=require(_0xb00b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb00b('0x4'))['db'];var utils=require(_0xb00b('0x5'));var logger=require('../../config/logger')(_0xb00b('0x6'));var config=require(_0xb00b('0x7'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x36e363,_0xf737d0,_0x41dfc9){return new BPromise(function(_0x37f07d,_0xfa4181){return client[_0xb00b('0x8')](_0x36e363,_0x41dfc9)['then'](function(_0x51d12b){logger[_0xb00b('0x9')](_0xb00b('0xa'),_0xf737d0,_0xb00b('0xb'));logger[_0xb00b('0xc')](_0xb00b('0xd'),_0xf737d0,'request\x20sent',JSON[_0xb00b('0xe')](_0x51d12b));if(_0x51d12b['error']){if(_0x51d12b['error']['code']===0x1f4){logger[_0xb00b('0xf')](_0xb00b('0xa'),_0xf737d0,_0x51d12b[_0xb00b('0xf')][_0xb00b('0x10')]);return _0xfa4181(_0x51d12b[_0xb00b('0xf')][_0xb00b('0x10')]);}logger['error'](_0xb00b('0xa'),_0xf737d0,_0x51d12b[_0xb00b('0xf')]['message']);return _0x37f07d(_0x51d12b[_0xb00b('0xf')][_0xb00b('0x10')]);}else{logger['info']('UserMailQueue,\x20%s,\x20%s',_0xf737d0,_0xb00b('0xb'));_0x37f07d(_0x51d12b['result']['message']);}})[_0xb00b('0x11')](function(_0x638443){logger[_0xb00b('0xf')](_0xb00b('0xa'),_0xf737d0,_0x638443);_0xfa4181(_0x638443);});});} \ No newline at end of file diff --git a/server/api/userNotification/index.js b/server/api/userNotification/index.js new file mode 100644 index 0000000..c187fde --- /dev/null +++ b/server/api/userNotification/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9700=['isAuthenticated','sendUserNotification','multer','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment','./userNotification.controller','post'];(function(_0x32cc68,_0x5d2b21){var _0x472ab1=function(_0x14ff66){while(--_0x14ff66){_0x32cc68['push'](_0x32cc68['shift']());}};_0x472ab1(++_0x5d2b21);}(_0x9700,0x178));var _0x0970=function(_0x2b06ef,_0x413e75){_0x2b06ef=_0x2b06ef-0x0;var _0x35f5d1=_0x9700[_0x2b06ef];return _0x35f5d1;};'use strict';var multer=require(_0x0970('0x0'));var util=require('util');var path=require(_0x0970('0x1'));var timeout=require(_0x0970('0x2'));var express=require('express');var router=express[_0x0970('0x3')]();var fs_extra=require(_0x0970('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x0970('0x5'));var config=require(_0x0970('0x6'));var controller=require(_0x0970('0x7'));router[_0x0970('0x8')]('/',auth[_0x0970('0x9')](),controller[_0x0970('0xa')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/userNotification/userNotification.attributes.js b/server/api/userNotification/userNotification.attributes.js new file mode 100644 index 0000000..63a5a95 --- /dev/null +++ b/server/api/userNotification/userNotification.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4ffd=['STRING','sequelize','TEXT'];(function(_0x45ce90,_0x114609){var _0x313c45=function(_0x55102a){while(--_0x55102a){_0x45ce90['push'](_0x45ce90['shift']());}};_0x313c45(++_0x114609);}(_0x4ffd,0xb2));var _0xd4ff=function(_0xf9a6cf,_0x11870e){_0xf9a6cf=_0xf9a6cf-0x0;var _0x59e2bc=_0x4ffd[_0xf9a6cf];return _0x59e2bc;};'use strict';var Sequelize=require(_0xd4ff('0x0'));module['exports']={'body':{'type':Sequelize[_0xd4ff('0x1')]},'senderName':{'type':Sequelize[_0xd4ff('0x2')]},'recipientsId':{'type':Sequelize[_0xd4ff('0x1')]},'recipientsDescription':{'type':Sequelize['STRING']},'beep':{'type':Sequelize['BOOLEAN']}}; \ No newline at end of file diff --git a/server/api/userNotification/userNotification.controller.js b/server/api/userNotification/userNotification.controller.js new file mode 100644 index 0000000..cd6c191 --- /dev/null +++ b/server/api/userNotification/userNotification.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xff2d=['sendUserNotification','body','hasOwnProperty','text','TemplateId','Sequelize','ValidationError','Must\x20specify\x20at\x20least\x20one\x20argument\x20for\x20\x27text\x27\x20or\x20\x27TemplateId\x27','view','Missing\x20\x27view\x27\x20parameter','recipients','Missing\x20\x27recipients\x27\x20parameter','parse','Invalid\x20\x27recipients\x27\x20object','chatqueue','faxqueue','openchannelqueue','voicequeue','team','user','some','toLowerCase','Invalid\x20model\x20in\x20\x27recipients\x27\x20object','senderName','fullname','recipientsDescription','beep','SenderId','recipientsId','sortBy','join','transaction','UserNotification','create','forEach','recipient','emit','userNotification:send','catch','Template','findOne','html','Invalid\x20\x27TemplateId\x27\x20parameter','render','startCase','model','queue','replace','Queue','ids','push','all','union','flatten','map','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','sox','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./userNotification.socket','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','sendStatus','error','stack','name','send'];(function(_0xaf404b,_0x35df1d){var _0x356cbd=function(_0x39250c){while(--_0x39250c){_0xaf404b['push'](_0xaf404b['shift']());}};_0x356cbd(++_0x35df1d);}(_0xff2d,0x9a));var _0xdff2=function(_0x342700,_0x569f75){_0x342700=_0x342700-0x0;var _0x53406f=_0xff2d[_0x342700];return _0x53406f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xdff2('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xdff2('0x1'));var rp=require(_0xdff2('0x2'));var moment=require(_0xdff2('0x3'));var BPromise=require(_0xdff2('0x4'));var Mustache=require(_0xdff2('0x5'));var util=require('util');var path=require('path');var sox=require(_0xdff2('0x6'));var csv=require('to-csv');var ejs=require(_0xdff2('0x7'));var fs=require('fs');var fs_extra=require(_0xdff2('0x8'));var _=require(_0xdff2('0x9'));var squel=require(_0xdff2('0xa'));var crypto=require(_0xdff2('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xdff2('0xc'));var toCsv=require('to-csv');var querystring=require(_0xdff2('0xd'));var Papa=require(_0xdff2('0xe'));var Redis=require('ioredis');var authService=require(_0xdff2('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xdff2('0x10'));var hardwareService=require(_0xdff2('0x11'));var logger=require('../../config/logger')(_0xdff2('0x12'));var utils=require(_0xdff2('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xdff2('0x14'));var db=require(_0xdff2('0x15'))['db'];config[_0xdff2('0x16')]=_['defaults'](config[_0xdff2('0x16')],{'host':'localhost','port':0x18eb});var socket=require(_0xdff2('0x17'))(new Redis(config[_0xdff2('0x16')]));require(_0xdff2('0x18'))['register'](socket);function respondWithStatusCode(_0x159af7,_0x4b018d){_0x4b018d=_0x4b018d||0xcc;return function(_0x161c93){if(_0x161c93){return _0x159af7['sendStatus'](_0x4b018d);}return _0x159af7['status'](_0x4b018d)[_0xdff2('0x19')]();};}function respondWithResult(_0x305cbe,_0x9589d6){_0x9589d6=_0x9589d6||0xc8;return function(_0x299a0d){if(_0x299a0d){return _0x305cbe[_0xdff2('0x1a')](_0x9589d6)[_0xdff2('0x1b')](_0x299a0d);}};}function respondWithFilteredResult(_0x584c47,_0x2acc81){return function(_0x5c6ec9){if(_0x5c6ec9){var _0x584bba=typeof _0x2acc81[_0xdff2('0x1c')]===_0xdff2('0x1d')&&typeof _0x2acc81[_0xdff2('0x1e')]===_0xdff2('0x1d');var _0x4e9440=_0x5c6ec9['count'];var _0xf6e49c=_0x584bba?0x0:_0x2acc81[_0xdff2('0x1c')];var _0x36732d=_0x584bba?_0x5c6ec9[_0xdff2('0x1f')]:_0x2acc81[_0xdff2('0x1c')]+_0x2acc81[_0xdff2('0x1e')];var _0x137575;if(_0x36732d>=_0x4e9440){_0x36732d=_0x4e9440;_0x137575=0xc8;}else{_0x137575=0xce;}_0x584c47['status'](_0x137575);return _0x584c47[_0xdff2('0x20')](_0xdff2('0x21'),_0xf6e49c+'-'+_0x36732d+'/'+_0x4e9440)[_0xdff2('0x1b')](_0x5c6ec9);}return null;};}function patchUpdates(_0x405372){return function(_0x30e825){try{jsonpatch[_0xdff2('0x22')](_0x30e825,_0x405372,!![]);}catch(_0x1a18b9){return BPromise[_0xdff2('0x23')](_0x1a18b9);}return _0x30e825['save']();};}function saveUpdates(_0x1f0ad9,_0x26ef12){return function(_0x4acc1a){if(_0x4acc1a){return _0x4acc1a[_0xdff2('0x24')](_0x1f0ad9)[_0xdff2('0x25')](function(_0x3b2a91){return _0x3b2a91;});}return null;};}function removeEntity(_0x40db12,_0x2c4c03){return function(_0x4c5174){if(_0x4c5174){return _0x4c5174[_0xdff2('0x26')]()['then'](function(){_0x40db12[_0xdff2('0x1a')](0xcc)[_0xdff2('0x19')]();});}};}function handleEntityNotFound(_0x3e0eb2,_0x4aaa60){return function(_0x1a982d){if(!_0x1a982d){_0x3e0eb2[_0xdff2('0x27')](0x194);}return _0x1a982d;};}function handleError(_0x4b5321,_0x3f27b6){_0x3f27b6=_0x3f27b6||0x1f4;return function(_0x51f8fd){logger[_0xdff2('0x28')](_0x51f8fd[_0xdff2('0x29')]);if(_0x51f8fd[_0xdff2('0x2a')]){delete _0x51f8fd['name'];}_0x4b5321[_0xdff2('0x1a')](_0x3f27b6)[_0xdff2('0x2b')](_0x51f8fd);};}exports[_0xdff2('0x2c')]=function(_0x5b8db8,_0x54efab,_0x1d480b){if(!_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x2e')](_0xdff2('0x2f'))&&!_0x5b8db8['body'][_0xdff2('0x2e')](_0xdff2('0x30'))){throw new db[(_0xdff2('0x31'))][(_0xdff2('0x32'))](_0xdff2('0x33'));}else{if(_0x5b8db8[_0xdff2('0x2d')]['hasOwnProperty'](_0xdff2('0x30'))&&!_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x2e')](_0xdff2('0x34'))){throw new db[(_0xdff2('0x31'))]['ValidationError'](_0xdff2('0x35'));}if(!_0x5b8db8['body'][_0xdff2('0x2e')](_0xdff2('0x36'))){throw new db[(_0xdff2('0x31'))]['ValidationError'](_0xdff2('0x37'));}else{try{var _0x5c7ca=JSON[_0xdff2('0x38')](_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x36')]);}catch(_0x17796a){logger['error'](_0x17796a);throw new db[(_0xdff2('0x31'))][(_0xdff2('0x32'))](_0xdff2('0x39'));}var _0x13a568=[_0xdff2('0x3a'),_0xdff2('0x3b'),'mailqueue',_0xdff2('0x3c'),'smsqueue',_0xdff2('0x3d'),'whatsappqueue',_0xdff2('0x3e'),_0xdff2('0x3f')];if(_[_0xdff2('0x40')](_0x5c7ca,function(_0x144556){return!_['includes'](_0x13a568,_0x144556['model'][_0xdff2('0x41')]());})){throw new db[(_0xdff2('0x31'))][(_0xdff2('0x32'))](_0xdff2('0x42'));}}}var _0x217c45={};_0x217c45[_0xdff2('0x43')]=_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x2e')](_0xdff2('0x43'))?_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x43')]:_0x5b8db8[_0xdff2('0x3f')][_0xdff2('0x44')];_0x217c45['recipientsDescription']=_['isEmpty'](_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x45')])?null:_0x5b8db8['body'][_0xdff2('0x45')];_0x217c45['beep']=_0x5b8db8[_0xdff2('0x2d')][_0xdff2('0x46')]||![];_0x217c45[_0xdff2('0x47')]=_0x5b8db8['user']['id'];return getContent(_0x5b8db8[_0xdff2('0x2d')])[_0xdff2('0x25')](function(_0x265931){_0x217c45[_0xdff2('0x2d')]=_0x265931;return getRecipients(_0x5c7ca);})[_0xdff2('0x25')](function(_0x5092ab){_0x217c45[_0xdff2('0x48')]=_[_0xdff2('0x49')](_0x5092ab)[_0xdff2('0x4a')](',');return db['sequelize'][_0xdff2('0x4b')](function(_0x978724){return db[_0xdff2('0x4c')][_0xdff2('0x4d')](_0x217c45,{'raw':!![],'transaction':_0x978724})[_0xdff2('0x25')](function(_0x17a10d){var _0x255297={'sender':_0x217c45[_0xdff2('0x43')],'description':_0x217c45['recipientsDescription'],'content':_0x217c45[_0xdff2('0x2d')],'beep':_0x217c45['beep']};_0x5092ab[_0xdff2('0x4e')](function(_0x444be8){_0x255297[_0xdff2('0x4f')]=_0x444be8;socket[_0xdff2('0x50')](_0xdff2('0x51'),_0x255297);});return _0x17a10d;});});})['then'](respondWithResult(_0x54efab,0xc9))[_0xdff2('0x52')](handleError(_0x54efab,null));};function getContent(_0x120ac7){return new BPromise(function(_0x3744f7,_0x34c3f0){if(_0x120ac7[_0xdff2('0x2f')]){_0x3744f7(_0x120ac7[_0xdff2('0x2f')]);return;}return db[_0xdff2('0x53')][_0xdff2('0x54')]({'attributes':[_0xdff2('0x55')],'where':{'id':_0x120ac7[_0xdff2('0x30')]},'raw':!![]})['then'](function(_0x4e2726){if(!_0x4e2726)throw new db[(_0xdff2('0x31'))][(_0xdff2('0x32'))](_0xdff2('0x56'));var _0x4d058e=Mustache[_0xdff2('0x57')](_0x4e2726[_0xdff2('0x55')],_0x120ac7[_0xdff2('0x34')]);_0x3744f7(_0x4d058e);})['catch'](function(_0x4c9ae1){_0x34c3f0(_0x4c9ae1);});});}function getRecipients(_0x37c03e){return new BPromise(function(_0x3b6ba0,_0xc8d74e){var _0x5282b7=[];var _0x4b2a9=[];_0x37c03e[_0xdff2('0x4e')](function(_0x5e64b8){var _0x1c4992=_[_0xdff2('0x58')](_0x5e64b8[_0xdff2('0x59')][_0xdff2('0x41')]());if(_0x1c4992==='User'){_0x5282b7=_['union'](_0x5282b7,_0x5e64b8['ids']);}else{if(_['includes'](_0x1c4992,_0xdff2('0x5a')))_0x1c4992=_0x1c4992[_0xdff2('0x5b')](_0xdff2('0x5a'),_0xdff2('0x5c'));_0x5e64b8[_0xdff2('0x5d')][_0xdff2('0x4e')](function(_0x542cf6){_0x4b2a9[_0xdff2('0x5e')](getAgents(_0x1c4992,_0x542cf6));});}});return BPromise[_0xdff2('0x5f')](_0x4b2a9)[_0xdff2('0x25')](function(_0x2884cf){_0x5282b7=_[_0xdff2('0x60')](_0x5282b7,_[_0xdff2('0x61')](_0x2884cf));_0x3b6ba0(_0x5282b7);})[_0xdff2('0x52')](function(_0xa63476){_0xc8d74e(_0xa63476);});});}function getAgents(_0x238169,_0x22e493){return new BPromise(function(_0x53a27b,_0x2ef94c){return db[_0x238169][_0xdff2('0x54')]({'where':{'id':_0x22e493}})[_0xdff2('0x25')](function(_0x242899){return _0x242899['getAgents']({'attributes':['id'],'raw':!![]})[_0xdff2('0x25')](function(_0x5e9980){var _0x1c1c16=_[_0xdff2('0x62')](_0x5e9980,'id');_0x53a27b(_0x1c1c16);});})['catch'](function(_0x7b5c33){_0x2ef94c(_0x7b5c33);});});} \ No newline at end of file diff --git a/server/api/userNotification/userNotification.events.js b/server/api/userNotification/userNotification.events.js new file mode 100644 index 0000000..02aceea --- /dev/null +++ b/server/api/userNotification/userNotification.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0077=['hasOwnProperty','hook','exports','events','../../mysqldb','UserNotification','setMaxListeners','update','emit'];(function(_0x1df4be,_0x5965c1){var _0x218122=function(_0x1af9ad){while(--_0x1af9ad){_0x1df4be['push'](_0x1df4be['shift']());}};_0x218122(++_0x5965c1);}(_0x0077,0x1e9));var _0x7007=function(_0x6bfd74,_0x558572){_0x6bfd74=_0x6bfd74-0x0;var _0x28acb3=_0x0077[_0x6bfd74];return _0x28acb3;};'use strict';var EventEmitter=require(_0x7007('0x0'));var UserNotification=require(_0x7007('0x1'))['db'][_0x7007('0x2')];var UserNotificationEvents=new EventEmitter();UserNotificationEvents[_0x7007('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x7007('0x4'),'afterDestroy':'remove'};function emitEvent(_0x1c7f3f){return function(_0x16a076,_0x25cf07,_0x46d172){UserNotificationEvents[_0x7007('0x5')](_0x1c7f3f+':'+_0x16a076['id'],_0x16a076);UserNotificationEvents[_0x7007('0x5')](_0x1c7f3f,_0x16a076);_0x46d172(null);};}for(var e in events){if(events[_0x7007('0x6')](e)){var event=events[e];UserNotification[_0x7007('0x7')](e,emitEvent(event));}}module[_0x7007('0x8')]=UserNotificationEvents; \ No newline at end of file diff --git a/server/api/userNotification/userNotification.model.js b/server/api/userNotification/userNotification.model.js new file mode 100644 index 0000000..a07b281 --- /dev/null +++ b/server/api/userNotification/userNotification.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9bd8=['bluebird','request-promise','path','rimraf','./userNotification.attributes','define','UserNotification','utf8mb4','utf8mb4_unicode_ci','../../config/logger','api'];(function(_0x12e7c6,_0x4273e8){var _0x25be4d=function(_0x21e55e){while(--_0x21e55e){_0x12e7c6['push'](_0x12e7c6['shift']());}};_0x25be4d(++_0x4273e8);}(_0x9bd8,0x82));var _0x89bd=function(_0x29de96,_0x42cc38){_0x29de96=_0x29de96-0x0;var _0x1b9352=_0x9bd8[_0x29de96];return _0x1b9352;};'use strict';var _=require('lodash');var util=require('util');var logger=require(_0x89bd('0x0'))(_0x89bd('0x1'));var moment=require('moment');var BPromise=require(_0x89bd('0x2'));var rp=require(_0x89bd('0x3'));var fs=require('fs');var path=require(_0x89bd('0x4'));var rimraf=require(_0x89bd('0x5'));var config=require('../../config/environment');var attributes=require(_0x89bd('0x6'));module['exports']=function(_0x506768,_0x186885){return _0x506768[_0x89bd('0x7')](_0x89bd('0x8'),attributes,{'tableName':'userNotifications','paranoid':![],'indexes':[],'timestamps':!![],'charset':_0x89bd('0x9'),'collate':_0x89bd('0xa')});}; \ No newline at end of file diff --git a/server/api/userNotification/userNotification.rpc.js b/server/api/userNotification/userNotification.rpc.js new file mode 100644 index 0000000..4fd5f94 --- /dev/null +++ b/server/api/userNotification/userNotification.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x527b=['then','info','debug','UserNotification,\x20%s,\x20%s,\x20%s','stringify','code','error','UserNotification,\x20%s,\x20%s','message','request\x20sent','result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost','request'];(function(_0x397680,_0x4eb586){var _0x3fd9a9=function(_0x2f3718){while(--_0x2f3718){_0x397680['push'](_0x397680['shift']());}};_0x3fd9a9(++_0x4eb586);}(_0x527b,0xec));var _0xb527=function(_0x3e91a9,_0x53c466){_0x3e91a9=_0x3e91a9-0x0;var _0x25c9ad=_0x527b[_0x3e91a9];return _0x25c9ad;};'use strict';var _=require(_0xb527('0x0'));var util=require(_0xb527('0x1'));var moment=require(_0xb527('0x2'));var BPromise=require(_0xb527('0x3'));var rs=require(_0xb527('0x4'));var fs=require('fs');var Redis=require(_0xb527('0x5'));var db=require(_0xb527('0x6'))['db'];var utils=require(_0xb527('0x7'));var logger=require(_0xb527('0x8'))('rpc');var config=require(_0xb527('0x9'));var jayson=require(_0xb527('0xa'));var client=jayson[_0xb527('0xb')][_0xb527('0xc')]({'port':0x232a});config['redis']=_['defaults'](config[_0xb527('0xd')],{'host':_0xb527('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb527('0xd')]));require('./userNotification.socket')['register'](socket);function respondWithRpcPromise(_0x92196,_0xe383a3,_0x5ddce4){return new BPromise(function(_0x11adac,_0x114b7f){return client[_0xb527('0xf')](_0x92196,_0x5ddce4)[_0xb527('0x10')](function(_0x19e807){logger[_0xb527('0x11')]('UserNotification,\x20%s,\x20%s',_0xe383a3,'request\x20sent');logger[_0xb527('0x12')](_0xb527('0x13'),_0xe383a3,'request\x20sent',JSON[_0xb527('0x14')](_0x19e807));if(_0x19e807['error']){if(_0x19e807['error'][_0xb527('0x15')]===0x1f4){logger[_0xb527('0x16')](_0xb527('0x17'),_0xe383a3,_0x19e807['error'][_0xb527('0x18')]);return _0x114b7f(_0x19e807[_0xb527('0x16')][_0xb527('0x18')]);}logger[_0xb527('0x16')](_0xb527('0x17'),_0xe383a3,_0x19e807['error']['message']);return _0x11adac(_0x19e807[_0xb527('0x16')][_0xb527('0x18')]);}else{logger['info'](_0xb527('0x17'),_0xe383a3,_0xb527('0x19'));_0x11adac(_0x19e807[_0xb527('0x1a')][_0xb527('0x18')]);}})[_0xb527('0x1b')](function(_0x50d355){logger[_0xb527('0x16')](_0xb527('0x17'),_0xe383a3,_0x50d355);_0x114b7f(_0x50d355);});});} \ No newline at end of file diff --git a/server/api/userNotification/userNotification.socket.js b/server/api/userNotification/userNotification.socket.js new file mode 100644 index 0000000..ad27b6c --- /dev/null +++ b/server/api/userNotification/userNotification.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e1a=['update','emit','removeListener','register','length','./userNotification.events','save','remove'];(function(_0x44fc85,_0x1e97b9){var _0x3b5be3=function(_0x500539){while(--_0x500539){_0x44fc85['push'](_0x44fc85['shift']());}};_0x3b5be3(++_0x1e97b9);}(_0x4e1a,0x11d));var _0xa4e1=function(_0x3fbde2,_0x4296b4){_0x3fbde2=_0x3fbde2-0x0;var _0x5721e6=_0x4e1a[_0x3fbde2];return _0x5721e6;};'use strict';var UserNotificationEvents=require(_0xa4e1('0x0'));var events=[_0xa4e1('0x1'),_0xa4e1('0x2'),_0xa4e1('0x3')];function createListener(_0x3162eb,_0x535d3d){return function(_0x5dbca4){_0x535d3d[_0xa4e1('0x4')](_0x3162eb,_0x5dbca4);};}function removeListener(_0x73540b,_0x26cf7b){return function(){UserNotificationEvents[_0xa4e1('0x5')](_0x73540b,_0x26cf7b);};}exports[_0xa4e1('0x6')]=function(_0x27e819){for(var _0x33e2ef=0x0,_0x55c1e6=events[_0xa4e1('0x7')];_0x33e2ef<_0x55c1e6;_0x33e2ef++){var _0x803dd7=events[_0x33e2ef];var _0x204173=createListener('userNotification:'+_0x803dd7,_0x27e819);UserNotificationEvents['on'](_0x803dd7,_0x204173);}}; \ No newline at end of file diff --git a/server/api/userOpenchannelQueue/index.js b/server/api/userOpenchannelQueue/index.js new file mode 100644 index 0000000..c6cf2a7 --- /dev/null +++ b/server/api/userOpenchannelQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../components/interaction/service','../../config/environment','exports','multer','util','path','Router','../../components/auth/service'];(function(_0x1a3e23,_0xce45e){var _0x5ee0d8=function(_0x4b932f){while(--_0x4b932f){_0x1a3e23['push'](_0x1a3e23['shift']());}};_0x5ee0d8(++_0xce45e);}(_0xa9e0,0x123));var _0x0a9e=function(_0x8de54f,_0x271987){_0x8de54f=_0x8de54f-0x0;var _0x14cba4=_0xa9e0[_0x8de54f];return _0x14cba4;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));module[_0x0a9e('0x7')]=router; \ No newline at end of file diff --git a/server/api/userOpenchannelQueue/userOpenchannelQueue.attributes.js b/server/api/userOpenchannelQueue/userOpenchannelQueue.attributes.js new file mode 100644 index 0000000..081b522 --- /dev/null +++ b/server/api/userOpenchannelQueue/userOpenchannelQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcc7a=['sequelize'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0xcc7a,0x1e0));var _0xacc7=function(_0x2d982d,_0x121028){_0x2d982d=_0x2d982d-0x0;var _0x4f36b0=_0xcc7a[_0x2d982d];return _0x4f36b0;};'use strict';var Sequelize=require(_0xacc7('0x0'));module['exports']={'penalty':{'type':Sequelize['INTEGER'],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userOpenchannelQueue/userOpenchannelQueue.model.js b/server/api/userOpenchannelQueue/userOpenchannelQueue.model.js new file mode 100644 index 0000000..e5575ac --- /dev/null +++ b/server/api/userOpenchannelQueue/userOpenchannelQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc53=['UserOpenchannelQueue','user_has_openchannel_queues','lodash','util','api','moment','rimraf','../../config/environment','./userOpenchannelQueue.attributes','define'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xdc53,0x8e));var _0x3dc5=function(_0x288f5e,_0x205edd){_0x288f5e=_0x288f5e-0x0;var _0x476cc9=_0xdc53[_0x288f5e];return _0x476cc9;};'use strict';var _=require(_0x3dc5('0x0'));var util=require(_0x3dc5('0x1'));var logger=require('../../config/logger')(_0x3dc5('0x2'));var moment=require(_0x3dc5('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x3dc5('0x4'));var config=require(_0x3dc5('0x5'));var attributes=require(_0x3dc5('0x6'));module['exports']=function(_0x3c25a6,_0xa40be8){return _0x3c25a6[_0x3dc5('0x7')](_0x3dc5('0x8'),attributes,{'tableName':_0x3dc5('0x9'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userOpenchannelQueue/userOpenchannelQueue.rpc.js b/server/api/userOpenchannelQueue/userOpenchannelQueue.rpc.js new file mode 100644 index 0000000..e822b38 --- /dev/null +++ b/server/api/userOpenchannelQueue/userOpenchannelQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x66ba=['rpc','../../config/environment','jayson/promise','client','http','then','info','UserOpenchannelQueue,\x20%s,\x20%s','debug','UserOpenchannelQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','lodash','util','moment','bluebird','ioredis','../../config/utils'];(function(_0x29570a,_0x124a5b){var _0x7be1a2=function(_0x44faaf){while(--_0x44faaf){_0x29570a['push'](_0x29570a['shift']());}};_0x7be1a2(++_0x124a5b);}(_0x66ba,0x1c8));var _0xa66b=function(_0x9641f8,_0x5c2372){_0x9641f8=_0x9641f8-0x0;var _0x3881b4=_0x66ba[_0x9641f8];return _0x3881b4;};'use strict';var _=require(_0xa66b('0x0'));var util=require(_0xa66b('0x1'));var moment=require(_0xa66b('0x2'));var BPromise=require(_0xa66b('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa66b('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xa66b('0x5'));var logger=require('../../config/logger')(_0xa66b('0x6'));var config=require(_0xa66b('0x7'));var jayson=require(_0xa66b('0x8'));var client=jayson[_0xa66b('0x9')][_0xa66b('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4c40b6,_0x56c39f,_0xe1b781){return new BPromise(function(_0x128c94,_0x48d25b){return client['request'](_0x4c40b6,_0xe1b781)[_0xa66b('0xb')](function(_0x24a72a){logger[_0xa66b('0xc')](_0xa66b('0xd'),_0x56c39f,'request\x20sent');logger[_0xa66b('0xe')](_0xa66b('0xf'),_0x56c39f,_0xa66b('0x10'),JSON['stringify'](_0x24a72a));if(_0x24a72a['error']){if(_0x24a72a['error']['code']===0x1f4){logger[_0xa66b('0x11')](_0xa66b('0xd'),_0x56c39f,_0x24a72a[_0xa66b('0x11')][_0xa66b('0x12')]);return _0x48d25b(_0x24a72a[_0xa66b('0x11')][_0xa66b('0x12')]);}logger[_0xa66b('0x11')](_0xa66b('0xd'),_0x56c39f,_0x24a72a[_0xa66b('0x11')][_0xa66b('0x12')]);return _0x128c94(_0x24a72a['error'][_0xa66b('0x12')]);}else{logger[_0xa66b('0xc')]('UserOpenchannelQueue,\x20%s,\x20%s',_0x56c39f,_0xa66b('0x10'));_0x128c94(_0x24a72a[_0xa66b('0x13')]['message']);}})[_0xa66b('0x14')](function(_0x24b968){logger['error'](_0xa66b('0xd'),_0x56c39f,_0x24b968);_0x48d25b(_0x24b968);});});} \ No newline at end of file diff --git a/server/api/userProfile/index.js b/server/api/userProfile/index.js new file mode 100644 index 0000000..f653d2f --- /dev/null +++ b/server/api/userProfile/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4dd8=['express','Router','fs-extra','../../components/auth/service','../../config/environment','./userProfile.controller','get','isAuthenticated','index','/describe','describe','/:id','show','/:id/resources','post','create','/:id/clone','clone','/:id/sections','addSections','addResources','put','delete','destroy','removeResources','exports','multer','path','connect-timeout'];(function(_0xb2acdf,_0x42b3fa){var _0x4ba468=function(_0x2bf136){while(--_0x2bf136){_0xb2acdf['push'](_0xb2acdf['shift']());}};_0x4ba468(++_0x42b3fa);}(_0x4dd8,0x71));var _0x84dd=function(_0x2a90d0,_0x48b69c){_0x2a90d0=_0x2a90d0-0x0;var _0x59b931=_0x4dd8[_0x2a90d0];return _0x59b931;};'use strict';var multer=require(_0x84dd('0x0'));var util=require('util');var path=require(_0x84dd('0x1'));var timeout=require(_0x84dd('0x2'));var express=require(_0x84dd('0x3'));var router=express[_0x84dd('0x4')]();var fs_extra=require(_0x84dd('0x5'));var auth=require(_0x84dd('0x6'));var interaction=require('../../components/interaction/service');var config=require(_0x84dd('0x7'));var controller=require(_0x84dd('0x8'));router[_0x84dd('0x9')]('/',auth[_0x84dd('0xa')](),controller[_0x84dd('0xb')]);router[_0x84dd('0x9')](_0x84dd('0xc'),auth['isAuthenticated'](),controller[_0x84dd('0xd')]);router[_0x84dd('0x9')](_0x84dd('0xe'),auth[_0x84dd('0xa')](),controller[_0x84dd('0xf')]);router[_0x84dd('0x9')]('/:id/sections',auth['isAuthenticated'](),controller['getSections']);router['get'](_0x84dd('0x10'),auth[_0x84dd('0xa')](),controller['getResources']);router[_0x84dd('0x11')]('/',auth[_0x84dd('0xa')](),controller[_0x84dd('0x12')]);router[_0x84dd('0x11')](_0x84dd('0x13'),auth['isAuthenticated'](),controller[_0x84dd('0x14')]);router[_0x84dd('0x11')](_0x84dd('0x15'),auth['isAuthenticated'](),controller[_0x84dd('0x16')]);router[_0x84dd('0x11')]('/:id/resources',auth[_0x84dd('0xa')](),controller[_0x84dd('0x17')]);router[_0x84dd('0x18')]('/:id',auth[_0x84dd('0xa')](),controller['update']);router[_0x84dd('0x19')](_0x84dd('0xe'),auth['isAuthenticated'](),controller[_0x84dd('0x1a')]);router[_0x84dd('0x19')](_0x84dd('0x15'),auth[_0x84dd('0xa')](),controller['removeSections']);router['delete'](_0x84dd('0x10'),auth[_0x84dd('0xa')](),controller[_0x84dd('0x1b')]);module[_0x84dd('0x1c')]=router; \ No newline at end of file diff --git a/server/api/userProfile/userProfile.attributes.js b/server/api/userProfile/userProfile.attributes.js new file mode 100644 index 0000000..dc038f9 --- /dev/null +++ b/server/api/userProfile/userProfile.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa06f=['BOOLEAN','exports','STRING','setDataValue','crudPermissions','join','getDataValue','split'];(function(_0x488069,_0x55c204){var _0x592336=function(_0x127efb){while(--_0x127efb){_0x488069['push'](_0x488069['shift']());}};_0x592336(++_0x55c204);}(_0xa06f,0x79));var _0xfa06=function(_0x28c585,_0x1b2cdc){_0x28c585=_0x28c585-0x0;var _0x1b9a9b=_0xa06f[_0x28c585];return _0x1b9a9b;};'use strict';var Sequelize=require('sequelize');module[_0xfa06('0x0')]={'name':{'type':Sequelize[_0xfa06('0x1')],'allowNull':![],'unique':'name'},'crudPermissions':{'type':Sequelize[_0xfa06('0x1')],'set':function(_0x1b70a2){this[_0xfa06('0x2')](_0xfa06('0x3'),_0x1b70a2?_0x1b70a2[_0xfa06('0x4')](''):[]);},'get':function(){return this['getDataValue'](_0xfa06('0x3'))?this[_0xfa06('0x5')]('crudPermissions')[_0xfa06('0x6')](''):[];},'allowNull':![],'defaultValue':'r'},'description':{'type':Sequelize[_0xfa06('0x1')],'allowNull':!![]},'privacyEnabled':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':![]},'downloadAttachments':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]},'downloadCallySquareRecordings':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]},'downloadContactManagerLists':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'downloadJscriptySessions':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]},'downloadOmnichannelInteractions':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]},'downloadScreenRecordings':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]},'downloadVoiceRecordings':{'type':Sequelize[_0xfa06('0x7')],'defaultValue':!![]}}; \ No newline at end of file diff --git a/server/api/userProfile/userProfile.controller.js b/server/api/userProfile/userProfile.controller.js new file mode 100644 index 0000000..d4a547d --- /dev/null +++ b/server/api/userProfile/userProfile.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7861=['removeResources','getResources','Missing\x20section\x20parameter','nolimit','No\x20User\x20Profile\x20found\x20for\x20id\x20','zip-dir','fast-json-patch','moment','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','end','status','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','error','stack','name','send','index','map','UserProfile','key','query','keys','intersection','model','attributes','fields','hasOwnProperty','sort','where','filters','pick','filter','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','rawAttributes','length','include','merge','body','clone','find','get','omit','createdAt','updatedAt','crudPermissions','sequelize','transaction','UserProfileSection','autoAssociation','UserProfileResource','sectionId','Resources','create','describe','addSections','userProfileId','each','removeSections','ids','getSections','enabled','includes','isEmpty','subsections','concat','push','findOne','forEach','resourceId','Plugin','bulkCreate'];(function(_0x47a5ba,_0x1b8463){var _0x2a3e43=function(_0x45e858){while(--_0x45e858){_0x47a5ba['push'](_0x47a5ba['shift']());}};_0x2a3e43(++_0x1b8463);}(_0x7861,0xeb));var _0x1786=function(_0x364bc0,_0x90e05b){_0x364bc0=_0x364bc0-0x0;var _0x31f133=_0x7861[_0x364bc0];return _0x31f133;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x1786('0x0'));var jsonpatch=require(_0x1786('0x1'));var rp=require('request-promise');var moment=require(_0x1786('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x1786('0x3'));var util=require(_0x1786('0x4'));var path=require(_0x1786('0x5'));var sox=require(_0x1786('0x6'));var csv=require('to-csv');var ejs=require(_0x1786('0x7'));var fs=require('fs');var fs_extra=require(_0x1786('0x8'));var _=require(_0x1786('0x9'));var squel=require(_0x1786('0xa'));var crypto=require(_0x1786('0xb'));var jsforce=require(_0x1786('0xc'));var deskjs=require(_0x1786('0xd'));var toCsv=require(_0x1786('0xe'));var querystring=require(_0x1786('0xf'));var Papa=require(_0x1786('0x10'));var Redis=require('ioredis');var authService=require(_0x1786('0x11'));var qs=require(_0x1786('0x12'));var as=require(_0x1786('0x13'));var hardwareService=require(_0x1786('0x14'));var logger=require('../../config/logger')(_0x1786('0x15'));var utils=require('../../config/utils');var config=require(_0x1786('0x16'));var licenseUtil=require(_0x1786('0x17'));var db=require(_0x1786('0x18'))['db'];config[_0x1786('0x19')]=_[_0x1786('0x1a')](config[_0x1786('0x19')],{'host':_0x1786('0x1b'),'port':0x18eb});var socket=require(_0x1786('0x1c'))(new Redis(config[_0x1786('0x19')]));require('./userProfile.socket')['register'](socket);function respondWithStatusCode(_0x29645c,_0x421fcd){_0x421fcd=_0x421fcd||0xcc;return function(_0x1a14c1){if(_0x1a14c1){return _0x29645c[_0x1786('0x1d')](_0x421fcd);}return _0x29645c['status'](_0x421fcd)[_0x1786('0x1e')]();};}function respondWithResult(_0x448352,_0x4da861){_0x4da861=_0x4da861||0xc8;return function(_0x178128){if(_0x178128){return _0x448352[_0x1786('0x1f')](_0x4da861)['json'](_0x178128);}};}function respondWithFilteredResult(_0x476b3b,_0x33eca3){return function(_0x10a634){if(_0x10a634){var _0x5a2179=typeof _0x33eca3[_0x1786('0x20')]===_0x1786('0x21')&&typeof _0x33eca3[_0x1786('0x22')]===_0x1786('0x21');var _0x855925=_0x10a634[_0x1786('0x23')];var _0x39ae2a=_0x5a2179?0x0:_0x33eca3[_0x1786('0x20')];var _0x1bd0c1=_0x5a2179?_0x10a634[_0x1786('0x23')]:_0x33eca3[_0x1786('0x20')]+_0x33eca3[_0x1786('0x22')];var _0x5f1640;if(_0x1bd0c1>=_0x855925){_0x1bd0c1=_0x855925;_0x5f1640=0xc8;}else{_0x5f1640=0xce;}_0x476b3b[_0x1786('0x1f')](_0x5f1640);return _0x476b3b[_0x1786('0x24')](_0x1786('0x25'),_0x39ae2a+'-'+_0x1bd0c1+'/'+_0x855925)['json'](_0x10a634);}return null;};}function patchUpdates(_0x5749ee){return function(_0xdb2ae9){try{jsonpatch['apply'](_0xdb2ae9,_0x5749ee,!![]);}catch(_0x2610ba){return BPromise[_0x1786('0x26')](_0x2610ba);}return _0xdb2ae9[_0x1786('0x27')]();};}function saveUpdates(_0x39892b,_0x47a565){return function(_0xf539fe){if(_0xf539fe){return _0xf539fe[_0x1786('0x28')](_0x39892b)[_0x1786('0x29')](function(_0x7278dd){return _0x7278dd;});}return null;};}function removeEntity(_0x2098c7,_0x50688a){return function(_0x1f7850){if(_0x1f7850){return _0x1f7850[_0x1786('0x2a')]()[_0x1786('0x29')](function(){_0x2098c7[_0x1786('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4b3b01,_0x5f33dd){return function(_0x430932){if(!_0x430932){_0x4b3b01[_0x1786('0x1d')](0x194);}return _0x430932;};}function handleError(_0x2dbc31,_0x1d0397){_0x1d0397=_0x1d0397||0x1f4;return function(_0x1d5372){logger[_0x1786('0x2b')](_0x1d5372[_0x1786('0x2c')]);if(_0x1d5372['name']){delete _0x1d5372[_0x1786('0x2d')];}_0x2dbc31[_0x1786('0x1f')](_0x1d0397)[_0x1786('0x2e')](_0x1d5372);};}exports[_0x1786('0x2f')]=function(_0x2ad3a4,_0x12308c){var _0x582312={},_0x3416b6={},_0x500470={'count':0x0,'rows':[]};var _0x20bc93=_[_0x1786('0x30')](db[_0x1786('0x31')]['rawAttributes'],function(_0x10dcf9){return{'name':_0x10dcf9['fieldName'],'type':_0x10dcf9['type'][_0x1786('0x32')]};});_0x3416b6['model']=_[_0x1786('0x30')](_0x20bc93,_0x1786('0x2d'));_0x3416b6[_0x1786('0x33')]=_[_0x1786('0x34')](_0x2ad3a4[_0x1786('0x33')]);_0x3416b6['filters']=_[_0x1786('0x35')](_0x3416b6[_0x1786('0x36')],_0x3416b6['query']);_0x582312[_0x1786('0x37')]=_[_0x1786('0x35')](_0x3416b6[_0x1786('0x36')],qs[_0x1786('0x38')](_0x2ad3a4['query']['fields']));_0x582312[_0x1786('0x37')]=_0x582312['attributes']['length']?_0x582312['attributes']:_0x3416b6['model'];if(!_0x2ad3a4[_0x1786('0x33')][_0x1786('0x39')]('nolimit')){_0x582312[_0x1786('0x22')]=qs[_0x1786('0x22')](_0x2ad3a4[_0x1786('0x33')][_0x1786('0x22')]);_0x582312[_0x1786('0x20')]=qs[_0x1786('0x20')](_0x2ad3a4[_0x1786('0x33')]['offset']);}_0x582312['order']=qs[_0x1786('0x3a')](_0x2ad3a4[_0x1786('0x33')]['sort']);_0x582312[_0x1786('0x3b')]=qs[_0x1786('0x3c')](_[_0x1786('0x3d')](_0x2ad3a4['query'],_0x3416b6[_0x1786('0x3c')]),_0x20bc93);if(_0x2ad3a4['query'][_0x1786('0x3e')]){_0x582312[_0x1786('0x3b')]=_['merge'](_0x582312[_0x1786('0x3b')],{'$or':_[_0x1786('0x30')](_0x20bc93,function(_0x202c79){if(_0x202c79[_0x1786('0x3f')]!==_0x1786('0x40')){var _0x27770c={};_0x27770c[_0x202c79[_0x1786('0x2d')]]={'$like':'%'+_0x2ad3a4['query'][_0x1786('0x3e')]+'%'};return _0x27770c;}})});}_0x582312=_['merge']({},_0x582312,_0x2ad3a4[_0x1786('0x41')]);var _0x22a6ec={'where':_0x582312[_0x1786('0x3b')]};return db[_0x1786('0x31')][_0x1786('0x23')](_0x22a6ec)[_0x1786('0x29')](function(_0x3f8e77){_0x500470[_0x1786('0x23')]=_0x3f8e77;if(_0x2ad3a4[_0x1786('0x33')][_0x1786('0x42')]){_0x582312['include']=[{'all':!![]}];}return db[_0x1786('0x31')][_0x1786('0x43')](_0x582312);})[_0x1786('0x29')](function(_0x1c3185){_0x500470[_0x1786('0x44')]=_0x1c3185;return _0x500470;})[_0x1786('0x29')](respondWithFilteredResult(_0x12308c,_0x582312))[_0x1786('0x45')](handleError(_0x12308c,null));};exports[_0x1786('0x46')]=function(_0x2aea47,_0x15d6c2){var _0x3f58a4={'raw':![],'where':{'id':_0x2aea47[_0x1786('0x47')]['id']}},_0x493a48={};_0x493a48['model']=_['keys'](db[_0x1786('0x31')][_0x1786('0x48')]);_0x493a48['query']=_[_0x1786('0x34')](_0x2aea47[_0x1786('0x33')]);_0x493a48['filters']=_[_0x1786('0x35')](_0x493a48[_0x1786('0x36')],_0x493a48[_0x1786('0x33')]);_0x3f58a4[_0x1786('0x37')]=_[_0x1786('0x35')](_0x493a48['model'],qs[_0x1786('0x38')](_0x2aea47[_0x1786('0x33')][_0x1786('0x38')]));_0x3f58a4[_0x1786('0x37')]=_0x3f58a4[_0x1786('0x37')][_0x1786('0x49')]?_0x3f58a4[_0x1786('0x37')]:_0x493a48[_0x1786('0x36')];if(_0x2aea47[_0x1786('0x33')][_0x1786('0x42')]){_0x3f58a4[_0x1786('0x4a')]=[{'all':!![]}];}_0x3f58a4=_[_0x1786('0x4b')]({},_0x3f58a4,_0x2aea47['options']);return db[_0x1786('0x31')]['find'](_0x3f58a4)[_0x1786('0x29')](handleEntityNotFound(_0x15d6c2,null))[_0x1786('0x29')](respondWithResult(_0x15d6c2,null))[_0x1786('0x45')](handleError(_0x15d6c2,null));};exports['create']=function(_0x48fd52,_0x16e881){return db['UserProfile']['create'](_0x48fd52[_0x1786('0x4c')],{})[_0x1786('0x29')](respondWithResult(_0x16e881,0xc9))[_0x1786('0x45')](handleError(_0x16e881,null));};exports[_0x1786('0x4d')]=function(_0x15f1fa,_0x50ff9f){var _0x1f8e35={'where':{'id':_0x15f1fa['params']['id']}},_0x3ff112={};_0x3ff112['model']=_[_0x1786('0x34')](db[_0x1786('0x31')][_0x1786('0x48')]);_0x1f8e35['attributes']=_[_0x1786('0x35')](_0x3ff112[_0x1786('0x36')],qs[_0x1786('0x38')](_0x15f1fa[_0x1786('0x33')][_0x1786('0x38')]));_0x1f8e35[_0x1786('0x37')]=_0x1f8e35[_0x1786('0x37')][_0x1786('0x49')]?_0x1f8e35[_0x1786('0x37')]:_0x3ff112[_0x1786('0x36')];if(_0x15f1fa[_0x1786('0x33')][_0x1786('0x42')]){_0x1f8e35[_0x1786('0x4a')]=[{'all':!![]}];}_0x1f8e35=_[_0x1786('0x4b')]({},_0x1f8e35,_0x15f1fa[_0x1786('0x41')]);return db[_0x1786('0x31')][_0x1786('0x4e')](_0x1f8e35)[_0x1786('0x29')](handleEntityNotFound(_0x50ff9f,null))[_0x1786('0x29')](function(_0x52462f){if(_0x52462f){var _0x4a21a8=_0x52462f[_0x1786('0x4f')]({'plain':!![]});_0x4a21a8=qs[_0x1786('0x50')](_0x4a21a8,['id',_0x1786('0x51'),_0x1786('0x52'),_0x1786('0x53')]);_0x15f1fa[_0x1786('0x4c')]=_[_0x1786('0x50')](_0x15f1fa[_0x1786('0x4c')],['id',_0x1786('0x51'),_0x1786('0x52')]);return db[_0x1786('0x54')][_0x1786('0x55')](function(_0x1813d2){return db[_0x1786('0x31')]['create'](_[_0x1786('0x4b')](_0x4a21a8,_0x15f1fa[_0x1786('0x4c')]),{'include':_0x15f1fa[_0x1786('0x33')][_0x1786('0x42')]?[{'all':!![]}]:undefined,'transaction':_0x1813d2})[_0x1786('0x29')](function(_0x3e3b22){var _0x324492=_0x3e3b22[_0x1786('0x4f')]({'plain':!![]});return db[_0x1786('0x56')]['findAll']({'where':{'userProfileId':_0x15f1fa['params']['id']},'raw':!![]})['then'](function(_0x6f1155){if(_0x6f1155){return BPromise['each'](_0x6f1155,function(_0x46475f){return new BPromise(function(_0x97e8a4,_0x357152){if(_0x46475f[_0x1786('0x57')]===null||_0x46475f[_0x1786('0x57')]===0x1)_0x97e8a4(null);return db[_0x1786('0x58')][_0x1786('0x43')]({'where':{'sectionId':_0x46475f['id']},'raw':!![]})[_0x1786('0x29')](function(_0x2c110c){var _0x301537=_[_0x1786('0x30')](_0x2c110c,function(_0x2d4180){return qs[_0x1786('0x50')](_0x2d4180,['id','createdAt',_0x1786('0x52'),_0x1786('0x59')]);});_0x97e8a4(_0x301537);})[_0x1786('0x45')](function(_0x264906){_0x357152(_0x264906);});})['then'](function(_0x28f8f5){var _0x29864f=qs[_0x1786('0x50')](_0x46475f,['id','createdAt',_0x1786('0x52')]);_0x29864f['userProfileId']=_0x324492['id'];if(_0x28f8f5)_0x29864f[_0x1786('0x5a')]=_0x28f8f5;return _0x29864f;})[_0x1786('0x29')](function(_0xc62704){return db['UserProfileSection'][_0x1786('0x5b')](_0xc62704,{'include':[{'model':db['UserProfileResource'],'as':_0x1786('0x5a')}],'raw':!![],'transaction':_0x1813d2});});})[_0x1786('0x29')](function(){return _0x324492;});}});});});}})[_0x1786('0x29')](respondWithResult(_0x50ff9f,0xc9))['catch'](handleError(_0x50ff9f,null));};exports['update']=function(_0x5e1b57,_0x11756a){if(_0x5e1b57[_0x1786('0x4c')]['id']){delete _0x5e1b57[_0x1786('0x4c')]['id'];}return db[_0x1786('0x31')][_0x1786('0x4e')]({'where':{'id':_0x5e1b57[_0x1786('0x47')]['id']}})[_0x1786('0x29')](handleEntityNotFound(_0x11756a,null))[_0x1786('0x29')](saveUpdates(_0x5e1b57[_0x1786('0x4c')],null))[_0x1786('0x29')](respondWithResult(_0x11756a,null))[_0x1786('0x45')](handleError(_0x11756a,null));};exports[_0x1786('0x2a')]=function(_0x59fd3d,_0xd249e7){return db[_0x1786('0x31')]['find']({'where':{'id':_0x59fd3d[_0x1786('0x47')]['id']}})[_0x1786('0x29')](handleEntityNotFound(_0xd249e7,null))[_0x1786('0x29')](removeEntity(_0xd249e7,null))[_0x1786('0x45')](handleError(_0xd249e7,null));};exports[_0x1786('0x5c')]=function(_0x28ff57,_0x3e725e){return db['UserProfile']['describe']()['then'](respondWithResult(_0x3e725e,null))[_0x1786('0x45')](handleError(_0x3e725e,null));};exports[_0x1786('0x5d')]=function(_0x187f9c,_0x125263){var _0x3a5045=_0x187f9c['body'];return db[_0x1786('0x31')]['find']({'where':{'id':_0x187f9c[_0x1786('0x47')]['id']}})[_0x1786('0x29')](handleEntityNotFound(_0x125263,null))[_0x1786('0x29')](function(_0x2db3e1){if(_0x2db3e1){return db[_0x1786('0x54')]['transaction'](function(_0x280847){return db[_0x1786('0x56')][_0x1786('0x2a')]({'where':{'userProfileId':_0x187f9c[_0x1786('0x47')]['id'],'sectionId':_['map'](_0x3a5045,function(_0x891d78){return _0x891d78[_0x1786('0x59')];})},'transaction':_0x280847})[_0x1786('0x29')](function(){var _0x2b0f4e=_['map'](_0x3a5045,function(_0x138471){_0x138471[_0x1786('0x5e')]=_0x187f9c[_0x1786('0x47')]['id'];return _0x138471;});var _0x458863=[];return BPromise[_0x1786('0x5f')](_0x2b0f4e,function(_0x5f2a8b){return db['UserProfileSection'][_0x1786('0x5b')](_0x5f2a8b,{'include':[{'model':db[_0x1786('0x58')],'as':_0x1786('0x5a')}],'raw':!![],'transaction':_0x280847})['then'](function(_0x1547c0){_0x458863['push'](_0x1547c0['get']({'plain':!![]}));});})['then'](function(){return _0x458863;});});});}})['then'](function(_0x1966b8){return _0x1966b8;})[_0x1786('0x29')](respondWithResult(_0x125263,null))['catch'](handleError(_0x125263,null));};exports[_0x1786('0x60')]=function(_0x18dc17,_0x21a81b){var _0x7615f9;return db[_0x1786('0x31')][_0x1786('0x4e')]({'where':{'id':_0x18dc17['params']['id']},'attributes':['id',_0x1786('0x2d')]})['then'](handleEntityNotFound(_0x21a81b,null))[_0x1786('0x29')](function(_0x4d2a1b){if(_0x4d2a1b){_0x7615f9=_0x4d2a1b;return db[_0x1786('0x56')][_0x1786('0x2a')]({'where':{'userProfileId':_0x18dc17[_0x1786('0x47')]['id'],'sectionId':_0x18dc17['query'][_0x1786('0x61')]}});}})[_0x1786('0x29')](function(){return _0x7615f9;})['then'](respondWithStatusCode(_0x21a81b,null))[_0x1786('0x45')](handleError(_0x21a81b,null));};exports[_0x1786('0x62')]=function(_0x131fe7,_0x5cf131){var _0x588a75=[];var _0x389303=[];return db[_0x1786('0x56')][_0x1786('0x43')]({'where':{'userProfileId':_0x131fe7[_0x1786('0x47')]['id']},'raw':!![]})[_0x1786('0x29')](function(_0x20c035){_0x588a75=_['filter'](_0x20c035,function(_0x40ca39){return _0x40ca39[_0x1786('0x63')]===0x1||_[_0x1786('0x64')]([0x3eb,0x709],_0x40ca39[_0x1786('0x59')]);});if(!_[_0x1786('0x65')](_0x588a75)){return _[_0x1786('0x30')](_0x588a75,function(_0x150c0d){return _0x150c0d[_0x1786('0x59')];});}else{return;}})['then'](function(_0x379fde){if(_0x379fde)_0x389303=_0x379fde;if(_[_0x1786('0x64')](_0x389303,0x64)){var _0x38b2b8=_[_0x1786('0x4e')](_0x588a75,{'sectionId':0x64});return hasDefaultDashboard(_0x38b2b8)[_0x1786('0x29')](function(_0x51e3c0){return _[_0x1786('0x30')](_0x588a75,function(_0x5194c5){if(_0x5194c5[_0x1786('0x59')]===0x64){_0x5194c5[_0x1786('0x66')]=_0x51e3c0;}return _0x5194c5;});});}else{return;}})[_0x1786('0x29')](function(_0x1da714){if(_0x1da714)_0x588a75=_0x1da714;if(_[_0x1786('0x64')](_0x389303,0x3eb)){var _0x58faff=_[_0x1786('0x4e')](_0x588a75,{'sectionId':0x3eb});return getCustomDashboards(_0x58faff)[_0x1786('0x29')](function(_0x3f779b){return _['map'](_0x588a75,function(_0x4c7aff){if(_0x58faff['enabled']){if(_0x4c7aff[_0x1786('0x59')]===0x3eb){_0x4c7aff[_0x1786('0x66')]=_0x3f779b;}}else{if(_0x4c7aff[_0x1786('0x59')]===0x64){if(!_0x4c7aff[_0x1786('0x66')]){_0x4c7aff[_0x1786('0x66')]=[];}_0x4c7aff['subsections']=_0x4c7aff['subsections'][_0x1786('0x67')](_0x3f779b);}}return _0x4c7aff;});});}else{return;}})[_0x1786('0x29')](function(_0x8a5875){if(_0x8a5875)_0x588a75=_0x8a5875;if(_['includes'](_0x389303,0x709)){var _0x400c58=_['find'](_0x588a75,{'sectionId':0x709});return getPlugins(_0x400c58)['then'](function(_0x1b9e7e){if(_0x400c58[_0x1786('0x63')]){return _[_0x1786('0x30')](_0x588a75,function(_0x5333a7){if(_0x5333a7[_0x1786('0x59')]===0x709){_0x5333a7[_0x1786('0x66')]=_0x1b9e7e;}return _0x5333a7;});}else{var _0x325123={'sectionId':0x76c,'enabled':0x1,'subsections':_0x1b9e7e};var _0x23bac0=_[_0x1786('0x30')](_0x588a75);_0x23bac0[_0x1786('0x68')](_0x325123);return _0x23bac0;}});}else{return;}})[_0x1786('0x29')](function(_0x30371c){if(_0x30371c)_0x588a75=_0x30371c;return _[_0x1786('0x3e')](_0x588a75,[_0x1786('0x63'),0x1]);})[_0x1786('0x29')](respondWithResult(_0x5cf131,null))[_0x1786('0x45')](handleError(_0x5cf131,null));};function hasDefaultDashboard(_0x259bb5){var _0x15d6a1=[0x65];return new BPromise(function(_0x5a9ab6,_0x58f02f){try{if(_0x259bb5[_0x1786('0x57')]){_0x5a9ab6(_0x15d6a1);}else{return db[_0x1786('0x58')][_0x1786('0x69')]({'where':{'sectionId':_0x259bb5['id']},'raw':!![]})[_0x1786('0x29')](function(_0x306037){_0x306037?_0x5a9ab6(_0x15d6a1):_0x5a9ab6();});}}catch(_0x47b80b){_0x58f02f(_0x47b80b);}});}function getCustomDashboards(_0x517c43){var _0xf0a8c1=[];return new BPromise(function(_0x1429e1,_0x3c7648){try{if(_0x517c43[_0x1786('0x57')]){return db['Dashboard']['findAll']({'raw':!![]})[_0x1786('0x29')](function(_0x4df0be){_0x4df0be['forEach'](function(_0xd1bd64){_0xf0a8c1[_0x1786('0x68')](_0xd1bd64['id']+0x1869f);});_0x1429e1(_0xf0a8c1);});}else{return db[_0x1786('0x58')][_0x1786('0x43')]({'where':{'sectionId':_0x517c43['id']},'raw':!![]})[_0x1786('0x29')](function(_0x56b0f6){_0x56b0f6[_0x1786('0x6a')](function(_0x45d48e){_0xf0a8c1[_0x1786('0x68')](_0x45d48e[_0x1786('0x6b')]+0x1869f);});_0x1429e1(_0xf0a8c1);});}}catch(_0xdeaecf){_0x3c7648(_0xdeaecf);}});}function getPlugins(_0x2697ed){var _0x402334=[];return new BPromise(function(_0x5215bb,_0x47de57){try{if(_0x2697ed[_0x1786('0x57')]){return db[_0x1786('0x6c')][_0x1786('0x43')]({'raw':!![]})[_0x1786('0x29')](function(_0x1332e5){_0x1332e5[_0x1786('0x6a')](function(_0x2a8f7e){_0x402334['push'](_0x2a8f7e['id']+0x15b38);});_0x5215bb(_0x402334);});}else{return db['UserProfileResource']['findAll']({'where':{'sectionId':_0x2697ed['id']},'raw':!![]})[_0x1786('0x29')](function(_0x23dd01){_0x23dd01['forEach'](function(_0x39fd37){_0x402334[_0x1786('0x68')](_0x39fd37[_0x1786('0x6b')]+0x15b38);});_0x5215bb(_0x402334);});}}catch(_0x24bf09){_0x47de57(_0x24bf09);}});}exports['addResources']=function(_0x4757e4,_0xdfb599){return db[_0x1786('0x31')][_0x1786('0x4e')]({'where':{'id':_0x4757e4[_0x1786('0x47')]['id']}})[_0x1786('0x29')](handleEntityNotFound(_0xdfb599,null))[_0x1786('0x29')](function(_0x159162){if(_0x159162){return db[_0x1786('0x54')][_0x1786('0x55')](function(_0x1e2ebe){return db[_0x1786('0x56')][_0x1786('0x43')]({'where':{'userProfileId':_0x4757e4[_0x1786('0x47')]['id']},'attributes':['id'],'raw':!![]})[_0x1786('0x29')](function(_0x576446){if(_0x576446){return db[_0x1786('0x56')]['destroy']({'where':{'userProfileId':_0x4757e4[_0x1786('0x47')]['id'],'id':_[_0x1786('0x30')](_0x576446,function(_0x26ab56){return _0x26ab56['id'];})},'transaction':_0x1e2ebe});}})[_0x1786('0x29')](function(_0x41610e){var _0x47c369=_[_0x1786('0x30')](_0x4757e4[_0x1786('0x4c')],function(_0x2b1249){_0x2b1249[_0x1786('0x5e')]=_0x4757e4[_0x1786('0x47')]['id'];return _0x2b1249;});return db[_0x1786('0x56')][_0x1786('0x6d')](_0x47c369,{'raw':!![],'transaction':_0x1e2ebe});})[_0x1786('0x29')](function(_0x8eea44){var _0x4c6ada=_[_0x1786('0x3e')](_[_0x1786('0x30')](_0x8eea44,function(_0xb2b032){return _0xb2b032[_0x1786('0x4f')]({'plain':!![]});}),{'includeAll':![]});if(_0x4c6ada){return db[_0x1786('0x56')][_0x1786('0x43')]({'where':{'userProfileId':_0x4757e4[_0x1786('0x47')]['id'],'sectionId':_[_0x1786('0x30')](_0x4c6ada,function(_0x10d157){return _0x10d157['sectionId'];})},'attributes':['id',_0x1786('0x59')],'raw':!![]})[_0x1786('0x29')](function(_0xd27636){var _0x547a07=_[_0x1786('0x30')](_0x4757e4[_0x1786('0x4c')],function(_0x88b46){_0x88b46[_0x1786('0x5e')]=_0x4757e4[_0x1786('0x47')]['id'];return _0x88b46;});return db[_0x1786('0x58')]['bulkCreate'](_0x547a07,{'raw':!![],'transaction':_0x1e2ebe});});}})[_0x1786('0x45')](handleError(_0xdfb599,null));});}})['then'](function(_0x4bef51){var _0x5e3c91=_[_0x1786('0x30')](_0x4bef51,function(_0x1bb572){return _0x1bb572[_0x1786('0x4f')]({'plain':!![]});});})[_0x1786('0x29')](respondWithResult(_0xdfb599,null))[_0x1786('0x45')](handleError(_0xdfb599,null));};exports[_0x1786('0x6e')]=function(_0x5bad38,_0x54069a,_0x4d9455){return db[_0x1786('0x31')][_0x1786('0x4e')]({'where':{'id':_0x5bad38[_0x1786('0x47')]['id']}})[_0x1786('0x29')](handleEntityNotFound(_0x54069a,null))[_0x1786('0x29')](function(_0x2dd64d){if(_0x2dd64d){return _0x2dd64d[_0x1786('0x6e')](_0x5bad38[_0x1786('0x33')]['ids']);}})['then'](respondWithStatusCode(_0x54069a,null))[_0x1786('0x45')](handleError(_0x54069a,null));};exports[_0x1786('0x6f')]=function(_0x240aaf,_0x206a2b){var _0x230c34={};if(!_0x240aaf[_0x1786('0x33')]['section'])throw new Error(_0x1786('0x70'));if(!_0x240aaf[_0x1786('0x33')][_0x1786('0x39')](_0x1786('0x71'))){_0x230c34[_0x1786('0x22')]=qs[_0x1786('0x22')](_0x240aaf[_0x1786('0x33')][_0x1786('0x22')]);_0x230c34['offset']=qs[_0x1786('0x20')](_0x240aaf[_0x1786('0x33')][_0x1786('0x20')]);}return db[_0x1786('0x31')][_0x1786('0x4e')]({'where':{'id':_0x240aaf[_0x1786('0x47')]['id']}})['then'](function(_0x19e70d){if(!_0x19e70d)throw new Error(_0x1786('0x72')+_0x240aaf[_0x1786('0x47')]['id']);return db['UserProfile'][_0x1786('0x6f')](_0x240aaf);})[_0x1786('0x29')](respondWithFilteredResult(_0x206a2b,_0x230c34))[_0x1786('0x45')](handleError(_0x206a2b,null));}; \ No newline at end of file diff --git a/server/api/userProfile/userProfile.events.js b/server/api/userProfile/userProfile.events.js new file mode 100644 index 0000000..995efbe --- /dev/null +++ b/server/api/userProfile/userProfile.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x01a6=['emit','hasOwnProperty','hook','events','UserProfile','setMaxListeners','save','update','remove'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x01a6,0x162));var _0x601a=function(_0x500841,_0x4f5d59){_0x500841=_0x500841-0x0;var _0x3766ba=_0x01a6[_0x500841];return _0x3766ba;};'use strict';var EventEmitter=require(_0x601a('0x0'));var UserProfile=require('../../mysqldb')['db'][_0x601a('0x1')];var UserProfileEvents=new EventEmitter();UserProfileEvents[_0x601a('0x2')](0x0);var events={'afterCreate':_0x601a('0x3'),'afterUpdate':_0x601a('0x4'),'afterDestroy':_0x601a('0x5')};function emitEvent(_0x526c19){return function(_0x2ac499,_0x4c666c,_0x245bd0){UserProfileEvents[_0x601a('0x6')](_0x526c19+':'+_0x2ac499['id'],_0x2ac499);UserProfileEvents[_0x601a('0x6')](_0x526c19,_0x2ac499);_0x245bd0(null);};}for(var e in events){if(events[_0x601a('0x7')](e)){var event=events[e];UserProfile[_0x601a('0x8')](e,emitEvent(event));}}module['exports']=UserProfileEvents; \ No newline at end of file diff --git a/server/api/userProfile/userProfile.model.js b/server/api/userProfile/userProfile.model.js new file mode 100644 index 0000000..50621e0 --- /dev/null +++ b/server/api/userProfile/userProfile.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0735=['WhatsappAccount','teams','voicequeues','queuecampaigns','users','agents','telephones','Users','admin','Telephones','zendeskaccounts','ZendeskAccount','salesforceaccounts','sugarcrmaccounts','deskaccounts','DeskAccount','zohoaccounts','vtigeraccounts','CannedAnswer','dispositions','customdashboards','Dashboard','intervals','Interval','scheduler','Schedule','sounds','Sound','tags','Tag','Template','Trigger','variables','extractedreports','metrics','AnalyticMetric','charAt','toUpperCase','slice','Sequelize','QueryTypes','SELECT','ui.','InteractionId','ui.createdAt','from','user_has_','_interactions','where','ui.UserId\x20=\x20?','query','toString','OpenTabs','define','UserProfile','user_profiles','raw','section','mergeResources','Invalid\x20section\x20\x27','isEmpty','length','find','all','union','ignore','autoAssociation','push','keys','intersection','fields','attributes','model','hasOwnProperty','limit','offset','sort','filters','pick','key','VIRTUAL','foreignKey','forEach','merge','includeAll','reportType','default','DefaultReports','custom','reportId','CustomReports','count','ids','customSorting','include','Tags','color','tag','ThroughTags','Agents','rows','dataValues','sms','mail','lodash','./userProfile.attributes','../../components/parsers/qs','exports','models','filter','field','value','findAll','then','associatedResources','map','catch','resolve','UserProfileResource','AnalyticExtractedReport','resourceId','squareprojects','childModel','SquareProject','odbc','SquareOdbc','SquareRecording','SquareProjects','name','projects','JscriptyProject','parentSections','Lists','lists','CmList','companies','globalcustomfields','CmCustomField','chatqueues','ChatQueue','chatwebsites','ChatWebsite','faxqueues','FaxQueue','FaxAccount','inboundroutes','outboundroutes','VoiceExtension','contexts','voicemails','VoiceMail','voicerecordings','VoiceRecording','User','agent','role','telephone','VoiceQueues','queue','VoiceQueue','type','inbound','QueueCampaigns','outbound','chanspies','VoiceChanSpy','voiceprefixes','VoicePrefix','ivrcampaigns','Campaign','mailqueues','MailQueue','mailaccounts','mailsubstatuses','MailSubstatus','openchannelqueues','OpenchannelQueue','openchannelaccounts','smsqueues','SmsQueue','smsaccounts','SmsAccount','whatsappqueues','WhatsappQueue','whatsappaccounts'];(function(_0x1deb03,_0xd05ad8){var _0x189fe7=function(_0x321225){while(--_0x321225){_0x1deb03['push'](_0x1deb03['shift']());}};_0x189fe7(++_0xd05ad8);}(_0x0735,0x68));var _0x5073=function(_0x24237f,_0x4cf32c){_0x24237f=_0x24237f-0x0;var _0x48298e=_0x0735[_0x24237f];return _0x48298e;};'use strict';var _=require(_0x5073('0x0'));var attributes=require(_0x5073('0x1'));var qs=require(_0x5073('0x2'));var squel=require('squel');module[_0x5073('0x3')]=function(_0x7ec072){var _0x4ee954=_0x7ec072[_0x5073('0x4')];function _0x2be9c3(_0x1336a5,_0xe818e4){return new Promise(function(_0xd2e42f,_0x4c6fa1){if(!_0xe818e4)return _0xd2e42f(null);var _0x1693c4=_0xe818e4[_0x5073('0x5')]?{[_0xe818e4[_0x5073('0x5')][_0x5073('0x6')]]:_0xe818e4[_0x5073('0x5')][_0x5073('0x7')]}:undefined;return _0x4ee954[_0x1336a5][_0x5073('0x8')]({'where':_0x1693c4,'raw':!![]})[_0x5073('0x9')](function(_0xdca88d){_0xe818e4[_0x5073('0xa')]=_[_0x5073('0xb')](_0xdca88d,'id');_0xd2e42f(_0xe818e4);})[_0x5073('0xc')](function(_0x29600e){_0x4c6fa1(_0x29600e);});});}function _0x4a3ceb(_0x4f00d1,_0x196fca){return new Promise(function(_0x52be01,_0x404e06){var _0x223cca=_0x4f00d1['filter']?{[_0x4f00d1[_0x5073('0x5')][_0x5073('0x6')]]:_0x4f00d1['filter'][_0x5073('0x7')]}:undefined;return _0x4ee954[_0x4f00d1['model']][_0x5073('0x8')]({'where':_0x223cca,'raw':!![]})[_0x5073('0x9')](function(_0xd5005b){_0x196fca[_0x5073('0xa')]=_[_0x5073('0xb')](_0xd5005b,function(_0x17db19){return _0x17db19['name'];});_0x52be01(_0x196fca);})['catch'](function(_0x41fc0e){_0x404e06(_0x41fc0e);});});}function _0x578b97(_0x34867d,_0x495a34,_0x3b2875){if(!_0x495a34)return Promise[_0x5073('0xd')](null);return new Promise(function(_0x54585c,_0x4e78d9){return _0x4ee954[_0x5073('0xe')][_0x5073('0x8')]({'where':{'sectionId':_0x495a34['id']},'raw':!![]})[_0x5073('0x9')](function(_0x15afe7){if(_0x34867d[_0x5073('0x6')]&&_0x34867d[_0x5073('0x6')]!=='id'){_0x495a34[_0x5073('0xa')]=_[_0x5073('0xb')](_0x15afe7,function(_0x167fc5){return _0x167fc5[_0x34867d[_0x5073('0x6')]];});}else{if(_0x3b2875===_0x5073('0xf')){_0x495a34[_0x5073('0xa')]=_[_0x5073('0xb')](_0x15afe7,function(_0x5b4819){return{'id':_0x5b4819[_0x5073('0x10')],'type':_0x5b4819['type']};});}else{_0x495a34[_0x5073('0xa')]=_['map'](_0x15afe7,function(_0x3fd864){return _0x3fd864['resourceId'];});}}_0x54585c(_0x495a34);})[_0x5073('0xc')](function(_0x37a82a){_0x4e78d9(_0x37a82a);});});}function _0x1d361b(_0x431e25,_0x4844e8){var _0x937b7d={'parentSections':[]};switch(_0x431e25['toLowerCase']()){case _0x5073('0x11'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x13');break;case _0x5073('0x14'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x15');break;case'squarerecordings':_0x937b7d[_0x5073('0x12')]=_0x5073('0x16');_0x937b7d['parentSections']=[{'name':_0x5073('0x17'),'field':_0x5073('0x18'),'foreignKey':'projectName'}];break;case _0x5073('0x19'):_0x937b7d['childModel']=_0x5073('0x1a');break;case'contacts':_0x937b7d[_0x5073('0x12')]='CmContact';_0x937b7d[_0x5073('0x1b')]=[{'name':_0x5073('0x1c'),'field':'id','foreignKey':'ListId'}];break;case _0x5073('0x1d'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x1e');break;case _0x5073('0x1f'):_0x937b7d['childModel']='CmCompany';break;case _0x5073('0x20'):_0x937b7d['childModel']=_0x5073('0x21');break;case _0x5073('0x22'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x23');break;case _0x5073('0x24'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x25');break;case _0x5073('0x26'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x27');break;case'faxaccounts':_0x937b7d[_0x5073('0x12')]=_0x5073('0x28');break;case _0x5073('0x29'):case'internalroutes':case _0x5073('0x2a'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x2b');break;case _0x5073('0x2c'):_0x937b7d[_0x5073('0x12')]='VoiceContext';break;case _0x5073('0x2d'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x2e');break;case _0x5073('0x2f'):_0x937b7d['childModel']=_0x5073('0x30');_0x937b7d[_0x5073('0x1b')]=[{'name':'Agents','field':_0x5073('0x18'),'foreignKey':'membername','model':_0x5073('0x31'),'filter':{'field':'role','value':[_0x5073('0x32')]}},{'name':'Telephones','field':_0x5073('0x18'),'foreignKey':'membername','model':_0x5073('0x31'),'filter':{'field':_0x5073('0x33'),'value':[_0x5073('0x34')]}},{'name':_0x5073('0x35'),'field':_0x5073('0x18'),'foreignKey':_0x5073('0x36'),'model':_0x5073('0x37'),'filter':{'field':_0x5073('0x38'),'value':[_0x5073('0x39')]}},{'name':_0x5073('0x3a'),'field':_0x5073('0x18'),'foreignKey':_0x5073('0x36'),'model':_0x5073('0x37'),'filter':{'field':'type','value':[_0x5073('0x3b')]}}];break;case'musiconholds':_0x937b7d[_0x5073('0x12')]='VoiceMusicOnHold';break;case _0x5073('0x3c'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x3d');break;case _0x5073('0x3e'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x3f');break;case _0x5073('0x40'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x41');break;case _0x5073('0x42'):_0x937b7d['childModel']=_0x5073('0x43');break;case _0x5073('0x44'):_0x937b7d['childModel']='MailAccount';break;case _0x5073('0x45'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x46');break;case _0x5073('0x47'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x48');break;case _0x5073('0x49'):_0x937b7d[_0x5073('0x12')]='OpenchannelAccount';break;case _0x5073('0x4a'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x4b');break;case _0x5073('0x4c'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x4d');break;case _0x5073('0x4e'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x4f');break;case _0x5073('0x50'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x51');break;case _0x5073('0x52'):_0x937b7d[_0x5073('0x12')]='Team';break;case _0x5073('0x53'):case _0x5073('0x54'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x37');if(_0x4844e8){_0x937b7d[_0x5073('0x1b')]=[{'name':_0x5073('0x35')},{'name':_0x5073('0x3a')}];}break;case _0x5073('0x55'):case _0x5073('0x56'):case _0x5073('0x57'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x31');if(_0x4844e8){_0x937b7d[_0x5073('0x1b')]=[{'name':_0x5073('0x58'),'filter':{'field':_0x5073('0x33'),'value':[_0x5073('0x59'),'user']},'ignore':!![]},{'name':'Agents'},{'name':_0x5073('0x5a')}];}break;case _0x5073('0x5b'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x5c');break;case _0x5073('0x5d'):_0x937b7d['childModel']='SalesforceAccount';break;case'freshdeskaccounts':_0x937b7d[_0x5073('0x12')]='FreshdeskAccount';break;case _0x5073('0x5e'):_0x937b7d['childModel']='SugarcrmAccount';break;case _0x5073('0x5f'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x60');break;case _0x5073('0x61'):_0x937b7d[_0x5073('0x12')]='ZohoAccount';break;case _0x5073('0x62'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x31');break;case'cannedanswers':_0x937b7d[_0x5073('0x12')]=_0x5073('0x63');break;case _0x5073('0x64'):_0x937b7d[_0x5073('0x12')]='Disposition';break;case _0x5073('0x65'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x66');break;case _0x5073('0x67'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x68');break;case'pauses':_0x937b7d[_0x5073('0x12')]='Pause';break;case _0x5073('0x69'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x6a');break;case _0x5073('0x6b'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x6c');break;case _0x5073('0x6d'):_0x937b7d['childModel']=_0x5073('0x6e');break;case'templates':_0x937b7d[_0x5073('0x12')]=_0x5073('0x6f');break;case'triggers':_0x937b7d[_0x5073('0x12')]=_0x5073('0x70');break;case'trunks':_0x937b7d[_0x5073('0x12')]='Trunk';break;case _0x5073('0x71'):_0x937b7d['childModel']='Variable';break;case'plugins':_0x937b7d[_0x5073('0x12')]='Plugin';break;case _0x5073('0x72'):_0x937b7d[_0x5073('0x12')]=_0x5073('0xf');_0x937b7d['parentSections']=[{'name':'Reports','field':'id','foreignKey':'reportId'}];break;case _0x5073('0x73'):_0x937b7d[_0x5073('0x12')]=_0x5073('0x74');break;}return _0x937b7d;}function _0x5a096e(_0x433d45,_0x4ceb67){var _0x617795=_0x433d45[_0x5073('0x75')](0x0)[_0x5073('0x76')]()+_0x433d45[_0x5073('0x77')](0x1);var _0x1c1836={'type':_0x4ee954[_0x5073('0x78')][_0x5073('0x79')][_0x5073('0x7a')],'raw':!![]};return new Promise(function(_0x15fcdf,_0x3f816b){var _0x2db0c4=squel['select']()[_0x5073('0x6')](_0x5073('0x7b')+_0x617795+_0x5073('0x7c'),'id')['field'](_0x5073('0x7d'))[_0x5073('0x7e')](_0x5073('0x7f')+_0x433d45+_0x5073('0x80'),'ui')[_0x5073('0x81')](_0x5073('0x82'),_0x4ceb67['id']);return _0x4ee954['sequelize'][_0x5073('0x83')](_0x2db0c4[_0x5073('0x84')](),_0x1c1836)[_0x5073('0x9')](function(_0x587fbe){_0x4ceb67[_0x617795+_0x5073('0x85')]=_0x587fbe;_0x15fcdf(_0x587fbe);})['catch'](function(_0x49bb5d){_0x3f816b(_0x49bb5d);});});}return _0x7ec072[_0x5073('0x86')](_0x5073('0x87'),attributes,{'tableName':_0x5073('0x88'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x5b16f9){var _0x41381a={'raw':_0x5b16f9['query'][_0x5073('0x89')],'where':{}};var _0x3e6d9f={};var _0x3a6d09={'count':0x0,'rows':[]};var _0x14d07e=_0x5b16f9['query'][_0x5073('0x8a')];var _0x3a4de1=_0x5b16f9[_0x5073('0x83')][_0x5073('0x8b')]||![];var _0x43a411=_0x1d361b(_0x14d07e,_0x3a4de1);if(!_0x43a411[_0x5073('0x12')])throw new Error(_0x5073('0x8c')+_0x14d07e+'\x27');var _0x52a76a=[{'name':_0x14d07e}];if(!_[_0x5073('0x8d')](_0x43a411[_0x5073('0x1b')]))_0x52a76a=_0x43a411[_0x5073('0x1b')];var _0x12a704=[];for(var _0x21529a=0x0;_0x21529a<_0x52a76a[_0x5073('0x8e')];_0x21529a++){_0x12a704['push'](_0x4ee954['UserProfileSection'][_0x5073('0x8f')]({'where':{'userProfileId':_0x5b16f9['params']['id'],'name':_0x52a76a[_0x21529a][_0x5073('0x18')]},'raw':!![]}));}return Promise[_0x5073('0x90')](_0x12a704)[_0x5073('0x9')](function(_0x578d69){var _0x2c9c24=_[_0x5073('0x5')](_0x578d69,function(_0x1a6c8b){return _0x1a6c8b?_0x1a6c8b:undefined;});var _0x20ff06=_['filter'](_0x52a76a,['ignore',!![]]);var _0x297d9d=_[_0x5073('0x8d')](_0x2c9c24)&&_['isEmpty'](_0x20ff06)?null:_[_0x5073('0x91')](_0x20ff06,_0x2c9c24);if(!_0x297d9d)return null;var _0x4915f8=[];for(var _0x5471cc=0x0;_0x5471cc<_0x297d9d[_0x5073('0x8e')];_0x5471cc++){var _0x2c85b6=_[_0x5073('0x8f')](_0x52a76a,function(_0x2b4140){return _0x297d9d[_0x5471cc]?_0x2b4140['name']===_0x297d9d[_0x5471cc][_0x5073('0x18')]:null;});if(_0x2c85b6){if(_0x297d9d[_0x5471cc][_0x5073('0x92')]){_0x4915f8['push'](_0x2be9c3(_0x43a411[_0x5073('0x12')],_0x297d9d[_0x5471cc]));}else{if(!_0x297d9d[_0x5471cc][_0x5073('0x93')]){_0x4915f8[_0x5073('0x94')](_0x578b97(_0x2c85b6,_0x297d9d[_0x5471cc],_0x43a411[_0x5073('0x12')]));}else{if(_0x2c85b6['model']){_0x4915f8[_0x5073('0x94')](_0x4a3ceb(_0x2c85b6,_0x297d9d[_0x5471cc]));}}}}}return Promise[_0x5073('0x90')](_0x4915f8);})[_0x5073('0x9')](function(_0x17a77e){var _0x59ef15=_0x17a77e;var _0x343bd1=null;if(_0x59ef15){_0x343bd1=_0x59ef15['length']===0x1?_0x59ef15[0x0]:null;}if(!_0x343bd1&&!_0x59ef15)return _0x3a6d09;var _0x4f6194=_0x4ee954[_0x43a411[_0x5073('0x12')]]['rawAttributes'];_0x3e6d9f['model']=_[_0x5073('0x95')](_0x4f6194);_0x3e6d9f[_0x5073('0x83')]=_[_0x5073('0x95')](_0x5b16f9[_0x5073('0x83')]);_0x3e6d9f['filters']=_['intersection'](_0x3e6d9f['model'],_0x3e6d9f[_0x5073('0x83')]);_0x41381a['attributes']=_[_0x5073('0x96')](_0x3e6d9f['model'],qs[_0x5073('0x97')](_0x5b16f9[_0x5073('0x83')][_0x5073('0x97')]));_0x41381a[_0x5073('0x98')]=_0x41381a['attributes'][_0x5073('0x8e')]?_0x41381a[_0x5073('0x98')]:_0x3e6d9f[_0x5073('0x99')];if(!_0x5b16f9[_0x5073('0x83')][_0x5073('0x9a')]('nolimit')){_0x41381a[_0x5073('0x9b')]=qs[_0x5073('0x9b')](_0x5b16f9['query'][_0x5073('0x9b')]);_0x41381a[_0x5073('0x9c')]=qs['offset'](_0x5b16f9[_0x5073('0x83')][_0x5073('0x9c')]);}_0x41381a['order']=qs[_0x5073('0x9d')](_0x5b16f9[_0x5073('0x83')]['sort']);_0x41381a['where']=qs[_0x5073('0x9e')](_[_0x5073('0x9f')](_0x5b16f9[_0x5073('0x83')],_0x3e6d9f['filters']));if(_0x5b16f9['query'][_0x5073('0x5')]){_0x41381a[_0x5073('0x81')]=_['merge'](_0x41381a[_0x5073('0x81')],{'$or':_['map'](_0x4f6194,function(_0x106262){if(_0x106262[_0x5073('0x38')][_0x5073('0xa0')]!==_0x5073('0xa1')){var _0x215f14={};_0x215f14[_0x106262[_0x5073('0x6')]]={'$like':'%'+_0x5b16f9[_0x5073('0x83')]['filter']+'%'};return _0x215f14;}})});}var _0x4451f5=[];var _0x9c5a47=null;var _0x16395d={};if(_0x343bd1){_0x9c5a47=_['find'](_0x52a76a,['name',_0x343bd1[_0x5073('0x18')]]);if(_0x9c5a47[_0x5073('0x6')]){_0x16395d={};if(_0x43a411[_0x5073('0x12')]===_0x5073('0xf')){_0x16395d[_0x9c5a47['foreignKey']]=_[_0x5073('0xb')](_0x343bd1[_0x5073('0xa')],'id');}else{_0x16395d[_0x9c5a47['foreignKey']]=_0x343bd1[_0x5073('0xa')];}_0x4451f5[_0x5073('0x94')](_0x16395d);}else{_0x41381a[_0x5073('0x81')]['id']=_0x343bd1[_0x5073('0xa')];}}else{for(var _0x115134=0x0;_0x115134<_0x59ef15['length'];_0x115134++){_0x9c5a47=_['find'](_0x52a76a,[_0x5073('0x18'),_0x59ef15[_0x115134][_0x5073('0x18')]]);if(_0x9c5a47[_0x5073('0x6')]){_0x16395d={};_0x16395d[_0x9c5a47[_0x5073('0xa2')]]=_0x59ef15[_0x115134][_0x5073('0xa')];_0x4451f5[_0x5073('0x94')](_0x16395d);}else{if(!_0x41381a[_0x5073('0x81')]['id'])_0x41381a[_0x5073('0x81')]['id']=[];_0x59ef15[_0x115134][_0x5073('0xa')][_0x5073('0xa3')](function(_0x3b3b19){_0x41381a[_0x5073('0x81')]['id']['push'](_0x3b3b19);});}}}if(!_[_0x5073('0x8d')](_0x4451f5)){_0x41381a['where']=_['merge'](_0x41381a[_0x5073('0x81')],{'$and':{'$or':_0x4451f5}});}_0x41381a=_[_0x5073('0xa4')]({},_0x41381a,_0x5b16f9['options']);if(_0x343bd1&&!_0x343bd1['autoAssociation']&&_0x43a411[_0x5073('0x12')]==='AnalyticExtractedReport'){if(_0x5b16f9[_0x5073('0x83')][_0x5073('0xa5')]){_0x41381a['include']=[{'all':!![]}];}return _0x4ee954[_0x43a411[_0x5073('0x12')]][_0x5073('0x8')](_0x41381a)[_0x5073('0x9')](function(_0x2322d0){var _0x363389=[];_0x2322d0[_0x5073('0xa3')](function(_0x35a728){var _0x2f0944;switch(_0x35a728[_0x5073('0xa6')]){case _0x5073('0xa7'):_0x2f0944=_['find'](_0x343bd1['associatedResources'],function(_0x326d22){return _0x326d22['id']===_0x35a728['reportId']&&_0x326d22['type']===_0x5073('0xa8');});break;case _0x5073('0xa9'):_0x2f0944=_[_0x5073('0x8f')](_0x343bd1[_0x5073('0xa')],function(_0x53969b){return _0x53969b['id']===_0x35a728[_0x5073('0xaa')]&&_0x53969b[_0x5073('0x38')]===_0x5073('0xab');});break;}if(_0x2f0944)_0x363389[_0x5073('0x94')](_0x35a728);});_0x3a6d09[_0x5073('0xac')]=_0x363389['length'];_0x3a6d09['rows']=_0x363389;return _0x3a6d09;});}else{if(!_['isEmpty'](_0x5b16f9[_0x5073('0x83')][_0x5073('0xad')])){_0x41381a['where']['id']=_0x41381a[_0x5073('0x81')]['id']?_['intersection'](_0x41381a[_0x5073('0x81')]['id'],_0x5b16f9['query'][_0x5073('0xad')]):_0x5b16f9[_0x5073('0x83')][_0x5073('0xad')];if(_0x5b16f9['query'][_0x5073('0xae')]){_0x41381a['order']=_0x5b16f9['query'][_0x5073('0xae')];}}if(_0x5b16f9[_0x5073('0x83')]['extraQueryConditions']){_0x41381a[_0x5073('0x81')]=_[_0x5073('0xa4')](_0x41381a[_0x5073('0x81')],{'$and':_0x5b16f9[_0x5073('0x83')]['extraQueryConditions']});}return _0x4ee954[_0x43a411[_0x5073('0x12')]][_0x5073('0xac')]({'where':_0x41381a[_0x5073('0x81')]})[_0x5073('0x9')](function(_0x3a3b43){_0x3a6d09[_0x5073('0xac')]=_0x3a3b43;if(_0x5b16f9[_0x5073('0x83')][_0x5073('0xa5')]){if(_0x43a411[_0x5073('0x12')]==='CmContact'){_0x41381a[_0x5073('0xaf')]=[{'model':_0x4ee954[_0x5073('0x6e')],'as':_0x5073('0xb0'),'attributes':['id',_0x5073('0x18'),_0x5073('0xb1')],'required':_0x5b16f9[_0x5073('0x83')][_0x5073('0xb2')]?!![]:![]},{'model':_0x4ee954[_0x5073('0x6e')],'as':_0x5073('0xb3'),'attributes':['id',_0x5073('0x18'),'color'],'through':_0x5b16f9[_0x5073('0x83')][_0x5073('0xb2')]?{'attributes':[],'where':{'TagId':_0x5b16f9[_0x5073('0x83')]['tag']||undefined}}:{},'required':_0x5b16f9['query']['tag']?!![]:![]}];}else{_0x41381a[_0x5073('0xaf')]=[{'all':!![]}];}}return _0x4ee954[_0x43a411[_0x5073('0x12')]][_0x5073('0x8')](_0x41381a);})[_0x5073('0x9')](function(_0x29dbb6){_0x3a6d09['rows']=_0x29dbb6;if(_0x14d07e===_0x5073('0xb4')&&_0x5b16f9[_0x5073('0x83')]['openTabs']==='true'){var _0x347046=[];for(var _0x1b07d5=0x0;_0x1b07d5<_0x3a6d09[_0x5073('0xb5')][_0x5073('0x8e')];_0x1b07d5++){_0x347046[_0x5073('0x94')](_0x5a096e('chat',_0x3a6d09[_0x5073('0xb5')][_0x1b07d5][_0x5073('0xb6')]));_0x347046[_0x5073('0x94')](_0x5a096e(_0x5073('0xb7'),_0x3a6d09[_0x5073('0xb5')][_0x1b07d5][_0x5073('0xb6')]));_0x347046['push'](_0x5a096e('fax',_0x3a6d09['rows'][_0x1b07d5][_0x5073('0xb6')]));_0x347046[_0x5073('0x94')](_0x5a096e(_0x5073('0xb8'),_0x3a6d09[_0x5073('0xb5')][_0x1b07d5][_0x5073('0xb6')]));_0x347046[_0x5073('0x94')](_0x5a096e('openchannel',_0x3a6d09[_0x5073('0xb5')][_0x1b07d5]['dataValues']));_0x347046[_0x5073('0x94')](_0x5a096e('whatsapp',_0x3a6d09[_0x5073('0xb5')][_0x1b07d5]['dataValues']));}return Promise[_0x5073('0x90')](_0x347046)[_0x5073('0x9')](function(){return _0x3a6d09;});}return _0x3a6d09;});}});}}});}; \ No newline at end of file diff --git a/server/api/userProfile/userProfile.rpc.js b/server/api/userProfile/userProfile.rpc.js new file mode 100644 index 0000000..758da0a --- /dev/null +++ b/server/api/userProfile/userProfile.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x598a=['result','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./userProfile.socket','register','request','then','UserProfile,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info'];(function(_0x934754,_0x15bd40){var _0x5cf1fc=function(_0x2c1de6){while(--_0x2c1de6){_0x934754['push'](_0x934754['shift']());}};_0x5cf1fc(++_0x15bd40);}(_0x598a,0xfb));var _0xa598=function(_0x57e9b5,_0x657a46){_0x57e9b5=_0x57e9b5-0x0;var _0x5eee02=_0x598a[_0x57e9b5];return _0x5eee02;};'use strict';var _=require(_0xa598('0x0'));var util=require(_0xa598('0x1'));var moment=require(_0xa598('0x2'));var BPromise=require(_0xa598('0x3'));var rs=require(_0xa598('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa598('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xa598('0x6'));var jayson=require(_0xa598('0x7'));var client=jayson[_0xa598('0x8')][_0xa598('0x9')]({'port':0x232a});config[_0xa598('0xa')]=_['defaults'](config['redis'],{'host':_0xa598('0xb'),'port':0x18eb});var socket=require(_0xa598('0xc'))(new Redis(config[_0xa598('0xa')]));require(_0xa598('0xd'))[_0xa598('0xe')](socket);function respondWithRpcPromise(_0x387afc,_0x5207d5,_0x5871a3){return new BPromise(function(_0x3ea1e4,_0x3cb7b8){return client[_0xa598('0xf')](_0x387afc,_0x5871a3)[_0xa598('0x10')](function(_0xa1c53){logger['info'](_0xa598('0x11'),_0x5207d5,_0xa598('0x12'));logger[_0xa598('0x13')]('UserProfile,\x20%s,\x20%s,\x20%s',_0x5207d5,_0xa598('0x12'),JSON['stringify'](_0xa1c53));if(_0xa1c53[_0xa598('0x14')]){if(_0xa1c53[_0xa598('0x14')][_0xa598('0x15')]===0x1f4){logger[_0xa598('0x14')](_0xa598('0x11'),_0x5207d5,_0xa1c53[_0xa598('0x14')][_0xa598('0x16')]);return _0x3cb7b8(_0xa1c53[_0xa598('0x14')][_0xa598('0x16')]);}logger['error'](_0xa598('0x11'),_0x5207d5,_0xa1c53[_0xa598('0x14')][_0xa598('0x16')]);return _0x3ea1e4(_0xa1c53[_0xa598('0x14')][_0xa598('0x16')]);}else{logger[_0xa598('0x17')](_0xa598('0x11'),_0x5207d5,_0xa598('0x12'));_0x3ea1e4(_0xa1c53[_0xa598('0x18')][_0xa598('0x16')]);}})['catch'](function(_0x1ed03f){logger[_0xa598('0x14')](_0xa598('0x11'),_0x5207d5,_0x1ed03f);_0x3cb7b8(_0x1ed03f);});});} \ No newline at end of file diff --git a/server/api/userProfile/userProfile.socket.js b/server/api/userProfile/userProfile.socket.js new file mode 100644 index 0000000..3ce064e --- /dev/null +++ b/server/api/userProfile/userProfile.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x63f4=['update','emit','removeListener','length','userProfile:','./userProfile.events','save'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x63f4,0x9f));var _0x463f=function(_0x26e031,_0x8dd228){_0x26e031=_0x26e031-0x0;var _0x5c3cc7=_0x63f4[_0x26e031];return _0x5c3cc7;};'use strict';var UserProfileEvents=require(_0x463f('0x0'));var events=[_0x463f('0x1'),'remove',_0x463f('0x2')];function createListener(_0x4e2e71,_0x350a7f){return function(_0x1330d4){_0x350a7f[_0x463f('0x3')](_0x4e2e71,_0x1330d4);};}function removeListener(_0x1c357e,_0x14dc8e){return function(){UserProfileEvents[_0x463f('0x4')](_0x1c357e,_0x14dc8e);};}exports['register']=function(_0x4777fe){for(var _0x30375b=0x0,_0xcdf461=events[_0x463f('0x5')];_0x30375b<_0xcdf461;_0x30375b++){var _0x1b8b2c=events[_0x30375b];var _0x16d9ba=createListener(_0x463f('0x6')+_0x1b8b2c,_0x4777fe);UserProfileEvents['on'](_0x1b8b2c,_0x16d9ba);}}; \ No newline at end of file diff --git a/server/api/userProfileResource/index.js b/server/api/userProfileResource/index.js new file mode 100644 index 0000000..3d3174c --- /dev/null +++ b/server/api/userProfileResource/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd812=['fs-extra','../../components/interaction/service','../../config/environment','./userProfileResource.controller','get','index','/describe','isAuthenticated','/:id','show','post','create','put','update','delete','destroy','exports','connect-timeout','express'];(function(_0x12a201,_0x30aaba){var _0x52a4d2=function(_0x5ca28d){while(--_0x5ca28d){_0x12a201['push'](_0x12a201['shift']());}};_0x52a4d2(++_0x30aaba);}(_0xd812,0x18d));var _0x2d81=function(_0x5db313,_0x3c8f0c){_0x5db313=_0x5db313-0x0;var _0x36d503=_0xd812[_0x5db313];return _0x36d503;};'use strict';var multer=require('multer');var util=require('util');var path=require('path');var timeout=require(_0x2d81('0x0'));var express=require(_0x2d81('0x1'));var router=express['Router']();var fs_extra=require(_0x2d81('0x2'));var auth=require('../../components/auth/service');var interaction=require(_0x2d81('0x3'));var config=require(_0x2d81('0x4'));var controller=require(_0x2d81('0x5'));router[_0x2d81('0x6')]('/',auth['isAuthenticated'](),controller[_0x2d81('0x7')]);router[_0x2d81('0x6')](_0x2d81('0x8'),auth[_0x2d81('0x9')](),controller['describe']);router[_0x2d81('0x6')](_0x2d81('0xa'),auth[_0x2d81('0x9')](),controller[_0x2d81('0xb')]);router[_0x2d81('0xc')]('/',auth[_0x2d81('0x9')](),controller[_0x2d81('0xd')]);router[_0x2d81('0xe')](_0x2d81('0xa'),auth[_0x2d81('0x9')](),controller[_0x2d81('0xf')]);router[_0x2d81('0x10')](_0x2d81('0xa'),auth[_0x2d81('0x9')](),controller[_0x2d81('0x11')]);module[_0x2d81('0x12')]=router; \ No newline at end of file diff --git a/server/api/userProfileResource/userProfileResource.attributes.js b/server/api/userProfileResource/userProfileResource.attributes.js new file mode 100644 index 0000000..0078c61 --- /dev/null +++ b/server/api/userProfileResource/userProfileResource.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0a84=['sequelize','exports','STRING','INTEGER'];(function(_0x32fcf8,_0x3b1c96){var _0x11fe25=function(_0x1a243d){while(--_0x1a243d){_0x32fcf8['push'](_0x32fcf8['shift']());}};_0x11fe25(++_0x3b1c96);}(_0x0a84,0x1f4));var _0x40a8=function(_0x79a88b,_0x31698c){_0x79a88b=_0x79a88b-0x0;var _0x4cca8d=_0x0a84[_0x79a88b];return _0x4cca8d;};'use strict';var Sequelize=require(_0x40a8('0x0'));module[_0x40a8('0x1')]={'name':{'type':Sequelize[_0x40a8('0x2')],'allowNull':![]},'resourceId':{'type':Sequelize[_0x40a8('0x3')],'allowNull':![]},'type':{'type':Sequelize['STRING'],'allowNull':![]}}; \ No newline at end of file diff --git a/server/api/userProfileResource/userProfileResource.controller.js b/server/api/userProfileResource/userProfileResource.controller.js new file mode 100644 index 0000000..469eba9 --- /dev/null +++ b/server/api/userProfileResource/userProfileResource.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9f0e=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','apply','update','then','destroy','end','error','name','send','index','map','UserProfileResource','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','catch','options','find','create','body','params','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x9f0e,0x116));var _0xe9f0=function(_0xb6e19c,_0x4639b8){_0xb6e19c=_0xb6e19c-0x0;var _0x5b6fbb=_0x9f0e[_0xb6e19c];return _0x5b6fbb;};'use strict';var emlformat=require(_0xe9f0('0x0'));var rimraf=require(_0xe9f0('0x1'));var zipdir=require(_0xe9f0('0x2'));var jsonpatch=require(_0xe9f0('0x3'));var rp=require(_0xe9f0('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xe9f0('0x5'));var util=require(_0xe9f0('0x6'));var path=require(_0xe9f0('0x7'));var sox=require(_0xe9f0('0x8'));var csv=require(_0xe9f0('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xe9f0('0xa'));var squel=require(_0xe9f0('0xb'));var crypto=require(_0xe9f0('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xe9f0('0xd'));var toCsv=require(_0xe9f0('0x9'));var querystring=require(_0xe9f0('0xe'));var Papa=require(_0xe9f0('0xf'));var Redis=require(_0xe9f0('0x10'));var authService=require(_0xe9f0('0x11'));var qs=require(_0xe9f0('0x12'));var as=require(_0xe9f0('0x13'));var hardwareService=require(_0xe9f0('0x14'));var logger=require('../../config/logger')(_0xe9f0('0x15'));var utils=require(_0xe9f0('0x16'));var config=require(_0xe9f0('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xe9f0('0x18'))['db'];function respondWithStatusCode(_0x586763,_0x367545){_0x367545=_0x367545||0xcc;return function(_0xd82420){if(_0xd82420){return _0x586763[_0xe9f0('0x19')](_0x367545);}return _0x586763[_0xe9f0('0x1a')](_0x367545)['end']();};}function respondWithResult(_0x2cf75d,_0x5a10c6){_0x5a10c6=_0x5a10c6||0xc8;return function(_0x1e3ba8){if(_0x1e3ba8){return _0x2cf75d[_0xe9f0('0x1a')](_0x5a10c6)[_0xe9f0('0x1b')](_0x1e3ba8);}};}function respondWithFilteredResult(_0x59320d,_0x28bfac){return function(_0x33e9e4){if(_0x33e9e4){var _0x2e68ef=typeof _0x28bfac['offset']===_0xe9f0('0x1c')&&typeof _0x28bfac[_0xe9f0('0x1d')]===_0xe9f0('0x1c');var _0xd71ac8=_0x33e9e4[_0xe9f0('0x1e')];var _0x2ab12b=_0x2e68ef?0x0:_0x28bfac[_0xe9f0('0x1f')];var _0x59bf5a=_0x2e68ef?_0x33e9e4[_0xe9f0('0x1e')]:_0x28bfac[_0xe9f0('0x1f')]+_0x28bfac[_0xe9f0('0x1d')];var _0x5c4182;if(_0x59bf5a>=_0xd71ac8){_0x59bf5a=_0xd71ac8;_0x5c4182=0xc8;}else{_0x5c4182=0xce;}_0x59320d[_0xe9f0('0x1a')](_0x5c4182);return _0x59320d[_0xe9f0('0x20')](_0xe9f0('0x21'),_0x2ab12b+'-'+_0x59bf5a+'/'+_0xd71ac8)[_0xe9f0('0x1b')](_0x33e9e4);}return null;};}function patchUpdates(_0x5ba788){return function(_0x33f143){try{jsonpatch[_0xe9f0('0x22')](_0x33f143,_0x5ba788,!![]);}catch(_0x583687){return BPromise['reject'](_0x583687);}return _0x33f143['save']();};}function saveUpdates(_0x12fe9f,_0xa1ddc){return function(_0x1211ae){if(_0x1211ae){return _0x1211ae[_0xe9f0('0x23')](_0x12fe9f)[_0xe9f0('0x24')](function(_0x4a5c27){return _0x4a5c27;});}return null;};}function removeEntity(_0x229fe0,_0x38b7ee){return function(_0x437d43){if(_0x437d43){return _0x437d43[_0xe9f0('0x25')]()[_0xe9f0('0x24')](function(){_0x229fe0[_0xe9f0('0x1a')](0xcc)[_0xe9f0('0x26')]();});}};}function handleEntityNotFound(_0x1321bb,_0x3c4ba9){return function(_0x3fce54){if(!_0x3fce54){_0x1321bb['sendStatus'](0x194);}return _0x3fce54;};}function handleError(_0x371095,_0x27541f){_0x27541f=_0x27541f||0x1f4;return function(_0x2ddfba){logger[_0xe9f0('0x27')](_0x2ddfba['stack']);if(_0x2ddfba[_0xe9f0('0x28')]){delete _0x2ddfba[_0xe9f0('0x28')];}_0x371095[_0xe9f0('0x1a')](_0x27541f)[_0xe9f0('0x29')](_0x2ddfba);};}exports[_0xe9f0('0x2a')]=function(_0x5457f6,_0x130f96){var _0xdc16bc={},_0x44fb5b={},_0xab3d81={'count':0x0,'rows':[]};var _0xa27c84=_[_0xe9f0('0x2b')](db[_0xe9f0('0x2c')][_0xe9f0('0x2d')],function(_0x2b6503){return{'name':_0x2b6503[_0xe9f0('0x2e')],'type':_0x2b6503[_0xe9f0('0x2f')][_0xe9f0('0x30')]};});_0x44fb5b[_0xe9f0('0x31')]=_[_0xe9f0('0x2b')](_0xa27c84,_0xe9f0('0x28'));_0x44fb5b[_0xe9f0('0x32')]=_[_0xe9f0('0x33')](_0x5457f6[_0xe9f0('0x32')]);_0x44fb5b[_0xe9f0('0x34')]=_[_0xe9f0('0x35')](_0x44fb5b[_0xe9f0('0x31')],_0x44fb5b[_0xe9f0('0x32')]);_0xdc16bc[_0xe9f0('0x36')]=_[_0xe9f0('0x35')](_0x44fb5b['model'],qs['fields'](_0x5457f6['query'][_0xe9f0('0x37')]));_0xdc16bc['attributes']=_0xdc16bc[_0xe9f0('0x36')][_0xe9f0('0x38')]?_0xdc16bc['attributes']:_0x44fb5b[_0xe9f0('0x31')];if(!_0x5457f6['query']['hasOwnProperty']('nolimit')){_0xdc16bc[_0xe9f0('0x1d')]=qs[_0xe9f0('0x1d')](_0x5457f6['query'][_0xe9f0('0x1d')]);_0xdc16bc[_0xe9f0('0x1f')]=qs[_0xe9f0('0x1f')](_0x5457f6['query']['offset']);}_0xdc16bc[_0xe9f0('0x39')]=qs[_0xe9f0('0x3a')](_0x5457f6[_0xe9f0('0x32')]['sort']);_0xdc16bc[_0xe9f0('0x3b')]=qs[_0xe9f0('0x34')](_[_0xe9f0('0x3c')](_0x5457f6[_0xe9f0('0x32')],_0x44fb5b[_0xe9f0('0x34')]),_0xa27c84);if(_0x5457f6['query'][_0xe9f0('0x3d')]){_0xdc16bc[_0xe9f0('0x3b')]=_[_0xe9f0('0x3e')](_0xdc16bc['where'],{'$or':_[_0xe9f0('0x2b')](_0xa27c84,function(_0xbec11f){if(_0xbec11f['type']!==_0xe9f0('0x3f')){var _0x5154c3={};_0x5154c3[_0xbec11f[_0xe9f0('0x28')]]={'$like':'%'+_0x5457f6['query']['filter']+'%'};return _0x5154c3;}})});}_0xdc16bc=_['merge']({},_0xdc16bc,_0x5457f6['options']);var _0x5165f7={'where':_0xdc16bc[_0xe9f0('0x3b')]};return db[_0xe9f0('0x2c')][_0xe9f0('0x1e')](_0x5165f7)[_0xe9f0('0x24')](function(_0x2560c6){_0xab3d81[_0xe9f0('0x1e')]=_0x2560c6;if(_0x5457f6[_0xe9f0('0x32')][_0xe9f0('0x40')]){_0xdc16bc[_0xe9f0('0x41')]=[{'all':!![]}];}return db['UserProfileResource'][_0xe9f0('0x42')](_0xdc16bc);})[_0xe9f0('0x24')](function(_0x36b00a){_0xab3d81['rows']=_0x36b00a;return _0xab3d81;})['then'](respondWithFilteredResult(_0x130f96,_0xdc16bc))[_0xe9f0('0x43')](handleError(_0x130f96,null));};exports['show']=function(_0x297689,_0x52613a){var _0x314f0e={'raw':![],'where':{'id':_0x297689['params']['id']}},_0x42d9d2={};_0x42d9d2[_0xe9f0('0x31')]=_[_0xe9f0('0x33')](db[_0xe9f0('0x2c')][_0xe9f0('0x2d')]);_0x42d9d2[_0xe9f0('0x32')]=_['keys'](_0x297689[_0xe9f0('0x32')]);_0x42d9d2[_0xe9f0('0x34')]=_[_0xe9f0('0x35')](_0x42d9d2[_0xe9f0('0x31')],_0x42d9d2[_0xe9f0('0x32')]);_0x314f0e['attributes']=_[_0xe9f0('0x35')](_0x42d9d2['model'],qs['fields'](_0x297689[_0xe9f0('0x32')][_0xe9f0('0x37')]));_0x314f0e['attributes']=_0x314f0e[_0xe9f0('0x36')][_0xe9f0('0x38')]?_0x314f0e[_0xe9f0('0x36')]:_0x42d9d2[_0xe9f0('0x31')];if(_0x297689[_0xe9f0('0x32')][_0xe9f0('0x40')]){_0x314f0e[_0xe9f0('0x41')]=[{'all':!![]}];}_0x314f0e=_['merge']({},_0x314f0e,_0x297689[_0xe9f0('0x44')]);return db['UserProfileResource'][_0xe9f0('0x45')](_0x314f0e)['then'](handleEntityNotFound(_0x52613a,null))[_0xe9f0('0x24')](respondWithResult(_0x52613a,null))['catch'](handleError(_0x52613a,null));};exports[_0xe9f0('0x46')]=function(_0x2023b4,_0x422324){return db['UserProfileResource'][_0xe9f0('0x46')](_0x2023b4[_0xe9f0('0x47')],{})[_0xe9f0('0x24')](respondWithResult(_0x422324,0xc9))[_0xe9f0('0x43')](handleError(_0x422324,null));};exports[_0xe9f0('0x23')]=function(_0x135175,_0x6ece3f){if(_0x135175[_0xe9f0('0x47')]['id']){delete _0x135175[_0xe9f0('0x47')]['id'];}return db[_0xe9f0('0x2c')][_0xe9f0('0x45')]({'where':{'id':_0x135175[_0xe9f0('0x48')]['id']}})['then'](handleEntityNotFound(_0x6ece3f,null))['then'](saveUpdates(_0x135175[_0xe9f0('0x47')],null))[_0xe9f0('0x24')](respondWithResult(_0x6ece3f,null))[_0xe9f0('0x43')](handleError(_0x6ece3f,null));};exports['destroy']=function(_0x1ac381,_0x4d8b2e){return db[_0xe9f0('0x2c')][_0xe9f0('0x45')]({'where':{'id':_0x1ac381[_0xe9f0('0x48')]['id']}})[_0xe9f0('0x24')](handleEntityNotFound(_0x4d8b2e,null))['then'](removeEntity(_0x4d8b2e,null))[_0xe9f0('0x43')](handleError(_0x4d8b2e,null));};exports[_0xe9f0('0x49')]=function(_0x5163ea,_0x2bf65c){return db[_0xe9f0('0x2c')][_0xe9f0('0x49')]()[_0xe9f0('0x24')](respondWithResult(_0x2bf65c,null))['catch'](handleError(_0x2bf65c,null));}; \ No newline at end of file diff --git a/server/api/userProfileResource/userProfileResource.model.js b/server/api/userProfileResource/userProfileResource.model.js new file mode 100644 index 0000000..6792e68 --- /dev/null +++ b/server/api/userProfileResource/userProfileResource.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7c39=['../../config/environment','./userProfileResource.attributes','exports','define','user_profile_has_resources','compositeIndex','resourceId','sectionId','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf'];(function(_0x12978f,_0x527378){var _0x1041ad=function(_0x394add){while(--_0x394add){_0x12978f['push'](_0x12978f['shift']());}};_0x1041ad(++_0x527378);}(_0x7c39,0x1c8));var _0x97c3=function(_0x3b1198,_0x41650f){_0x3b1198=_0x3b1198-0x0;var _0x1505a6=_0x7c39[_0x3b1198];return _0x1505a6;};'use strict';var _=require('lodash');var util=require(_0x97c3('0x0'));var logger=require(_0x97c3('0x1'))(_0x97c3('0x2'));var moment=require(_0x97c3('0x3'));var BPromise=require(_0x97c3('0x4'));var rp=require(_0x97c3('0x5'));var fs=require('fs');var path=require(_0x97c3('0x6'));var rimraf=require(_0x97c3('0x7'));var config=require(_0x97c3('0x8'));var attributes=require(_0x97c3('0x9'));module[_0x97c3('0xa')]=function(_0x38a54e,_0x8a292b){return _0x38a54e[_0x97c3('0xb')]('UserProfileResource',attributes,{'tableName':_0x97c3('0xc'),'paranoid':![],'indexes':[{'name':_0x97c3('0xd'),'fields':[_0x97c3('0xe'),_0x97c3('0xf')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userProfileResource/userProfileResource.rpc.js b/server/api/userProfileResource/userProfileResource.rpc.js new file mode 100644 index 0000000..b545e34 --- /dev/null +++ b/server/api/userProfileResource/userProfileResource.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3df6=['result','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','info','request\x20sent','UserProfileResource,\x20%s,\x20%s,\x20%s','stringify','error','UserProfileResource,\x20%s,\x20%s','message'];(function(_0x25ada9,_0x5f0e07){var _0x59e1ab=function(_0x241d91){while(--_0x241d91){_0x25ada9['push'](_0x25ada9['shift']());}};_0x59e1ab(++_0x5f0e07);}(_0x3df6,0xfe));var _0x63df=function(_0x96a338,_0x57ee18){_0x96a338=_0x96a338-0x0;var _0x1ef407=_0x3df6[_0x96a338];return _0x1ef407;};'use strict';var _=require(_0x63df('0x0'));var util=require(_0x63df('0x1'));var moment=require(_0x63df('0x2'));var BPromise=require(_0x63df('0x3'));var rs=require(_0x63df('0x4'));var fs=require('fs');var Redis=require(_0x63df('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x63df('0x6'));var logger=require(_0x63df('0x7'))('rpc');var config=require(_0x63df('0x8'));var jayson=require(_0x63df('0x9'));var client=jayson[_0x63df('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1b2fe9,_0x159ef4,_0x534dde){return new BPromise(function(_0x29d4ae,_0x1875a6){return client[_0x63df('0xb')](_0x1b2fe9,_0x534dde)['then'](function(_0x4fae3b){logger[_0x63df('0xc')]('UserProfileResource,\x20%s,\x20%s',_0x159ef4,_0x63df('0xd'));logger['debug'](_0x63df('0xe'),_0x159ef4,_0x63df('0xd'),JSON[_0x63df('0xf')](_0x4fae3b));if(_0x4fae3b[_0x63df('0x10')]){if(_0x4fae3b['error']['code']===0x1f4){logger[_0x63df('0x10')](_0x63df('0x11'),_0x159ef4,_0x4fae3b[_0x63df('0x10')][_0x63df('0x12')]);return _0x1875a6(_0x4fae3b['error'][_0x63df('0x12')]);}logger[_0x63df('0x10')]('UserProfileResource,\x20%s,\x20%s',_0x159ef4,_0x4fae3b[_0x63df('0x10')][_0x63df('0x12')]);return _0x29d4ae(_0x4fae3b[_0x63df('0x10')][_0x63df('0x12')]);}else{logger[_0x63df('0xc')](_0x63df('0x11'),_0x159ef4,_0x63df('0xd'));_0x29d4ae(_0x4fae3b[_0x63df('0x13')][_0x63df('0x12')]);}})[_0x63df('0x14')](function(_0x3e749e){logger[_0x63df('0x10')](_0x63df('0x11'),_0x159ef4,_0x3e749e);_0x1875a6(_0x3e749e);});});} \ No newline at end of file diff --git a/server/api/userProfileSection/index.js b/server/api/userProfileSection/index.js new file mode 100644 index 0000000..07c6df3 --- /dev/null +++ b/server/api/userProfileSection/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfd67=['delete','destroy','exports','multer','connect-timeout','express','Router','fs-extra','../../components/interaction/service','./userProfileSection.controller','index','describe','/:id','isAuthenticated','show','put','update'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xfd67,0x8b));var _0x7fd6=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xfd67[_0x3dd15e];return _0x231fd0;};'use strict';var multer=require(_0x7fd6('0x0'));var util=require('util');var path=require('path');var timeout=require(_0x7fd6('0x1'));var express=require(_0x7fd6('0x2'));var router=express[_0x7fd6('0x3')]();var fs_extra=require(_0x7fd6('0x4'));var auth=require('../../components/auth/service');var interaction=require(_0x7fd6('0x5'));var config=require('../../config/environment');var controller=require(_0x7fd6('0x6'));router['get']('/',auth['isAuthenticated'](),controller[_0x7fd6('0x7')]);router['get']('/describe',auth['isAuthenticated'](),controller[_0x7fd6('0x8')]);router['get'](_0x7fd6('0x9'),auth[_0x7fd6('0xa')](),controller[_0x7fd6('0xb')]);router['post']('/',auth[_0x7fd6('0xa')](),controller['create']);router[_0x7fd6('0xc')]('/:id',auth[_0x7fd6('0xa')](),controller[_0x7fd6('0xd')]);router[_0x7fd6('0xe')](_0x7fd6('0x9'),auth['isAuthenticated'](),controller[_0x7fd6('0xf')]);module[_0x7fd6('0x10')]=router; \ No newline at end of file diff --git a/server/api/userProfileSection/userProfileSection.attributes.js b/server/api/userProfileSection/userProfileSection.attributes.js new file mode 100644 index 0000000..64f87c9 --- /dev/null +++ b/server/api/userProfileSection/userProfileSection.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c00=['STRING','setDataValue','crudPermissions','join','getDataValue','split','sequelize','exports','INTEGER','BOOLEAN'];(function(_0x4b369d,_0x265eb8){var _0x571a98=function(_0x56341a){while(--_0x56341a){_0x4b369d['push'](_0x4b369d['shift']());}};_0x571a98(++_0x265eb8);}(_0x9c00,0x1a0));var _0x09c0=function(_0x39ce5a,_0x260622){_0x39ce5a=_0x39ce5a-0x0;var _0x46cd9a=_0x9c00[_0x39ce5a];return _0x46cd9a;};'use strict';var Sequelize=require(_0x09c0('0x0'));module[_0x09c0('0x1')]={'name':{'type':Sequelize['STRING'],'allowNull':![]},'category':{'type':Sequelize['STRING'],'allowNull':![]},'sectionId':{'type':Sequelize[_0x09c0('0x2')],'allowNull':![]},'enabled':{'type':Sequelize[_0x09c0('0x3')],'defaultValue':null},'autoAssociation':{'type':Sequelize['BOOLEAN'],'defaultValue':null},'crudPermissions':{'type':Sequelize[_0x09c0('0x4')],'set':function(_0x2c702c){this[_0x09c0('0x5')](_0x09c0('0x6'),_0x2c702c?_0x2c702c[_0x09c0('0x7')](''):[]);},'get':function(){return this['getDataValue']('crudPermissions')?this[_0x09c0('0x8')](_0x09c0('0x6'))[_0x09c0('0x9')](''):[];}}}; \ No newline at end of file diff --git a/server/api/userProfileSection/userProfileSection.controller.js b/server/api/userProfileSection/userProfileSection.controller.js new file mode 100644 index 0000000..e11b25d --- /dev/null +++ b/server/api/userProfileSection/userProfileSection.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb631=['send','index','map','UserProfileSection','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','sort','filters','pick','filter','where','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','find','create','body','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','update','then','destroy','error','name'];(function(_0x3adeb5,_0x3c2c44){var _0x1ccf64=function(_0x1ac079){while(--_0x1ac079){_0x3adeb5['push'](_0x3adeb5['shift']());}};_0x1ccf64(++_0x3c2c44);}(_0xb631,0x105));var _0x1b63=function(_0x5d45e7,_0x227c05){_0x5d45e7=_0x5d45e7-0x0;var _0x26a8d4=_0xb631[_0x5d45e7];return _0x26a8d4;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x1b63('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0x1b63('0x1'));var moment=require(_0x1b63('0x2'));var BPromise=require(_0x1b63('0x3'));var Mustache=require('mustache');var util=require(_0x1b63('0x4'));var path=require(_0x1b63('0x5'));var sox=require(_0x1b63('0x6'));var csv=require(_0x1b63('0x7'));var ejs=require(_0x1b63('0x8'));var fs=require('fs');var fs_extra=require(_0x1b63('0x9'));var _=require(_0x1b63('0xa'));var squel=require(_0x1b63('0xb'));var crypto=require(_0x1b63('0xc'));var jsforce=require(_0x1b63('0xd'));var deskjs=require(_0x1b63('0xe'));var toCsv=require(_0x1b63('0x7'));var querystring=require(_0x1b63('0xf'));var Papa=require(_0x1b63('0x10'));var Redis=require(_0x1b63('0x11'));var authService=require(_0x1b63('0x12'));var qs=require(_0x1b63('0x13'));var as=require(_0x1b63('0x14'));var hardwareService=require(_0x1b63('0x15'));var logger=require(_0x1b63('0x16'))(_0x1b63('0x17'));var utils=require('../../config/utils');var config=require(_0x1b63('0x18'));var licenseUtil=require(_0x1b63('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1c532e,_0x5b326c){_0x5b326c=_0x5b326c||0xcc;return function(_0x1c2da5){if(_0x1c2da5){return _0x1c532e[_0x1b63('0x1a')](_0x5b326c);}return _0x1c532e[_0x1b63('0x1b')](_0x5b326c)[_0x1b63('0x1c')]();};}function respondWithResult(_0x3d472d,_0x2c4ae8){_0x2c4ae8=_0x2c4ae8||0xc8;return function(_0x526be0){if(_0x526be0){return _0x3d472d[_0x1b63('0x1b')](_0x2c4ae8)['json'](_0x526be0);}};}function respondWithFilteredResult(_0x7a7e44,_0x5abee1){return function(_0x2e471a){if(_0x2e471a){var _0x3f054b=typeof _0x5abee1[_0x1b63('0x1d')]===_0x1b63('0x1e')&&typeof _0x5abee1[_0x1b63('0x1f')]===_0x1b63('0x1e');var _0x539e23=_0x2e471a[_0x1b63('0x20')];var _0x549b1c=_0x3f054b?0x0:_0x5abee1[_0x1b63('0x1d')];var _0x49e255=_0x3f054b?_0x2e471a[_0x1b63('0x20')]:_0x5abee1[_0x1b63('0x1d')]+_0x5abee1['limit'];var _0x598321;if(_0x49e255>=_0x539e23){_0x49e255=_0x539e23;_0x598321=0xc8;}else{_0x598321=0xce;}_0x7a7e44[_0x1b63('0x1b')](_0x598321);return _0x7a7e44['set'](_0x1b63('0x21'),_0x549b1c+'-'+_0x49e255+'/'+_0x539e23)[_0x1b63('0x22')](_0x2e471a);}return null;};}function patchUpdates(_0x3007aa){return function(_0xe10444){try{jsonpatch[_0x1b63('0x23')](_0xe10444,_0x3007aa,!![]);}catch(_0xea7028){return BPromise[_0x1b63('0x24')](_0xea7028);}return _0xe10444[_0x1b63('0x25')]();};}function saveUpdates(_0x39ac68,_0x1e9b14){return function(_0x2b26bf){if(_0x2b26bf){return _0x2b26bf[_0x1b63('0x26')](_0x39ac68)[_0x1b63('0x27')](function(_0x327476){return _0x327476;});}return null;};}function removeEntity(_0x4bfbcd,_0x5a97ef){return function(_0x180d24){if(_0x180d24){return _0x180d24[_0x1b63('0x28')]()['then'](function(){_0x4bfbcd['status'](0xcc)[_0x1b63('0x1c')]();});}};}function handleEntityNotFound(_0x1a4da3,_0x650a68){return function(_0x455fd7){if(!_0x455fd7){_0x1a4da3[_0x1b63('0x1a')](0x194);}return _0x455fd7;};}function handleError(_0x103ae8,_0x16be77){_0x16be77=_0x16be77||0x1f4;return function(_0x2322d4){logger[_0x1b63('0x29')](_0x2322d4['stack']);if(_0x2322d4['name']){delete _0x2322d4[_0x1b63('0x2a')];}_0x103ae8[_0x1b63('0x1b')](_0x16be77)[_0x1b63('0x2b')](_0x2322d4);};}exports[_0x1b63('0x2c')]=function(_0x47a154,_0x1ae903){var _0x40a083={},_0x502027={},_0x244bef={'count':0x0,'rows':[]};var _0x48ab1e=_[_0x1b63('0x2d')](db[_0x1b63('0x2e')][_0x1b63('0x2f')],function(_0xf14a3f){return{'name':_0xf14a3f[_0x1b63('0x30')],'type':_0xf14a3f[_0x1b63('0x31')][_0x1b63('0x32')]};});_0x502027[_0x1b63('0x33')]=_[_0x1b63('0x2d')](_0x48ab1e,_0x1b63('0x2a'));_0x502027[_0x1b63('0x34')]=_[_0x1b63('0x35')](_0x47a154[_0x1b63('0x34')]);_0x502027['filters']=_['intersection'](_0x502027[_0x1b63('0x33')],_0x502027['query']);_0x40a083[_0x1b63('0x36')]=_[_0x1b63('0x37')](_0x502027[_0x1b63('0x33')],qs[_0x1b63('0x38')](_0x47a154[_0x1b63('0x34')]['fields']));_0x40a083[_0x1b63('0x36')]=_0x40a083[_0x1b63('0x36')][_0x1b63('0x39')]?_0x40a083[_0x1b63('0x36')]:_0x502027[_0x1b63('0x33')];if(!_0x47a154['query'][_0x1b63('0x3a')]('nolimit')){_0x40a083[_0x1b63('0x1f')]=qs[_0x1b63('0x1f')](_0x47a154[_0x1b63('0x34')]['limit']);_0x40a083[_0x1b63('0x1d')]=qs[_0x1b63('0x1d')](_0x47a154[_0x1b63('0x34')][_0x1b63('0x1d')]);}_0x40a083['order']=qs['sort'](_0x47a154[_0x1b63('0x34')][_0x1b63('0x3b')]);_0x40a083['where']=qs[_0x1b63('0x3c')](_[_0x1b63('0x3d')](_0x47a154[_0x1b63('0x34')],_0x502027[_0x1b63('0x3c')]),_0x48ab1e);if(_0x47a154[_0x1b63('0x34')][_0x1b63('0x3e')]){_0x40a083[_0x1b63('0x3f')]=_[_0x1b63('0x40')](_0x40a083[_0x1b63('0x3f')],{'$or':_[_0x1b63('0x2d')](_0x48ab1e,function(_0x398419){if(_0x398419[_0x1b63('0x31')]!==_0x1b63('0x41')){var _0x2ac04a={};_0x2ac04a[_0x398419[_0x1b63('0x2a')]]={'$like':'%'+_0x47a154['query'][_0x1b63('0x3e')]+'%'};return _0x2ac04a;}})});}_0x40a083=_[_0x1b63('0x40')]({},_0x40a083,_0x47a154['options']);var _0x30c7d6={'where':_0x40a083['where']};return db[_0x1b63('0x2e')][_0x1b63('0x20')](_0x30c7d6)['then'](function(_0x6ddbe9){_0x244bef[_0x1b63('0x20')]=_0x6ddbe9;if(_0x47a154[_0x1b63('0x34')][_0x1b63('0x42')]){_0x40a083[_0x1b63('0x43')]=[{'all':!![]}];}return db[_0x1b63('0x2e')][_0x1b63('0x44')](_0x40a083);})['then'](function(_0x2539c6){_0x244bef[_0x1b63('0x45')]=_0x2539c6;return _0x244bef;})[_0x1b63('0x27')](respondWithFilteredResult(_0x1ae903,_0x40a083))[_0x1b63('0x46')](handleError(_0x1ae903,null));};exports[_0x1b63('0x47')]=function(_0x56a1ea,_0x10a17c){var _0x56ee9e={'raw':![],'where':{'id':_0x56a1ea[_0x1b63('0x48')]['id']}},_0x5a5864={};_0x5a5864['model']=_[_0x1b63('0x35')](db['UserProfileSection'][_0x1b63('0x2f')]);_0x5a5864[_0x1b63('0x34')]=_[_0x1b63('0x35')](_0x56a1ea['query']);_0x5a5864['filters']=_[_0x1b63('0x37')](_0x5a5864['model'],_0x5a5864['query']);_0x56ee9e[_0x1b63('0x36')]=_[_0x1b63('0x37')](_0x5a5864[_0x1b63('0x33')],qs['fields'](_0x56a1ea[_0x1b63('0x34')][_0x1b63('0x38')]));_0x56ee9e[_0x1b63('0x36')]=_0x56ee9e[_0x1b63('0x36')][_0x1b63('0x39')]?_0x56ee9e['attributes']:_0x5a5864[_0x1b63('0x33')];if(_0x56a1ea[_0x1b63('0x34')][_0x1b63('0x42')]){_0x56ee9e[_0x1b63('0x43')]=[{'all':!![]}];}_0x56ee9e=_['merge']({},_0x56ee9e,_0x56a1ea['options']);return db['UserProfileSection'][_0x1b63('0x49')](_0x56ee9e)[_0x1b63('0x27')](handleEntityNotFound(_0x10a17c,null))[_0x1b63('0x27')](respondWithResult(_0x10a17c,null))[_0x1b63('0x46')](handleError(_0x10a17c,null));};exports[_0x1b63('0x4a')]=function(_0x12137a,_0x30235e){return db['UserProfileSection'][_0x1b63('0x4a')](_0x12137a[_0x1b63('0x4b')],{})[_0x1b63('0x27')](respondWithResult(_0x30235e,0xc9))[_0x1b63('0x46')](handleError(_0x30235e,null));};exports['update']=function(_0x49758e,_0x2f0f01){if(_0x49758e[_0x1b63('0x4b')]['id']){delete _0x49758e[_0x1b63('0x4b')]['id'];}return db[_0x1b63('0x2e')][_0x1b63('0x49')]({'where':{'id':_0x49758e[_0x1b63('0x48')]['id']}})[_0x1b63('0x27')](handleEntityNotFound(_0x2f0f01,null))[_0x1b63('0x27')](saveUpdates(_0x49758e[_0x1b63('0x4b')],null))['then'](respondWithResult(_0x2f0f01,null))[_0x1b63('0x46')](handleError(_0x2f0f01,null));};exports['destroy']=function(_0x4936ee,_0x1052b2){return db['UserProfileSection'][_0x1b63('0x49')]({'where':{'id':_0x4936ee[_0x1b63('0x48')]['id']}})[_0x1b63('0x27')](handleEntityNotFound(_0x1052b2,null))[_0x1b63('0x27')](removeEntity(_0x1052b2,null))[_0x1b63('0x46')](handleError(_0x1052b2,null));};exports['describe']=function(_0x542655,_0x1ec0f5){return db[_0x1b63('0x2e')]['describe']()[_0x1b63('0x27')](respondWithResult(_0x1ec0f5,null))[_0x1b63('0x46')](handleError(_0x1ec0f5,null));}; \ No newline at end of file diff --git a/server/api/userProfileSection/userProfileSection.model.js b/server/api/userProfileSection/userProfileSection.model.js new file mode 100644 index 0000000..43ff600 --- /dev/null +++ b/server/api/userProfileSection/userProfileSection.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0109=['request-promise','path','../../config/environment','exports','UserProfileSection','user_profile_has_sections','compositeIndex','sectionId','userProfileId','lodash','util','../../config/logger','api','moment','bluebird'];(function(_0x4a46b0,_0x27c455){var _0x2ffdee=function(_0x118bed){while(--_0x118bed){_0x4a46b0['push'](_0x4a46b0['shift']());}};_0x2ffdee(++_0x27c455);}(_0x0109,0xea));var _0x9010=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x0109[_0x3b380d];return _0x54502b;};'use strict';var _=require(_0x9010('0x0'));var util=require(_0x9010('0x1'));var logger=require(_0x9010('0x2'))(_0x9010('0x3'));var moment=require(_0x9010('0x4'));var BPromise=require(_0x9010('0x5'));var rp=require(_0x9010('0x6'));var fs=require('fs');var path=require(_0x9010('0x7'));var rimraf=require('rimraf');var config=require(_0x9010('0x8'));var attributes=require('./userProfileSection.attributes');module[_0x9010('0x9')]=function(_0x199ac4,_0x3b2418){return _0x199ac4['define'](_0x9010('0xa'),attributes,{'tableName':_0x9010('0xb'),'paranoid':![],'indexes':[{'name':_0x9010('0xc'),'fields':[_0x9010('0xd'),_0x9010('0xe')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userProfileSection/userProfileSection.rpc.js b/server/api/userProfileSection/userProfileSection.rpc.js new file mode 100644 index 0000000..a7b21e7 --- /dev/null +++ b/server/api/userProfileSection/userProfileSection.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd5f7=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','UserProfileSection,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','lodash'];(function(_0x47c9be,_0x2aedd9){var _0x51282a=function(_0x11d341){while(--_0x11d341){_0x47c9be['push'](_0x47c9be['shift']());}};_0x51282a(++_0x2aedd9);}(_0xd5f7,0x16f));var _0x7d5f=function(_0x4f91c5,_0x2ea939){_0x4f91c5=_0x4f91c5-0x0;var _0x1ddbae=_0xd5f7[_0x4f91c5];return _0x1ddbae;};'use strict';var _=require(_0x7d5f('0x0'));var util=require(_0x7d5f('0x1'));var moment=require(_0x7d5f('0x2'));var BPromise=require(_0x7d5f('0x3'));var rs=require(_0x7d5f('0x4'));var fs=require('fs');var Redis=require(_0x7d5f('0x5'));var db=require(_0x7d5f('0x6'))['db'];var utils=require(_0x7d5f('0x7'));var logger=require(_0x7d5f('0x8'))(_0x7d5f('0x9'));var config=require(_0x7d5f('0xa'));var jayson=require(_0x7d5f('0xb'));var client=jayson['client'][_0x7d5f('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x92c404,_0x2b191d,_0x3b7e34){return new BPromise(function(_0x470589,_0x1e404a){return client['request'](_0x92c404,_0x3b7e34)[_0x7d5f('0xd')](function(_0x416872){logger[_0x7d5f('0xe')](_0x7d5f('0xf'),_0x2b191d,_0x7d5f('0x10'));logger[_0x7d5f('0x11')]('UserProfileSection,\x20%s,\x20%s,\x20%s',_0x2b191d,_0x7d5f('0x10'),JSON[_0x7d5f('0x12')](_0x416872));if(_0x416872[_0x7d5f('0x13')]){if(_0x416872['error']['code']===0x1f4){logger[_0x7d5f('0x13')](_0x7d5f('0xf'),_0x2b191d,_0x416872[_0x7d5f('0x13')][_0x7d5f('0x14')]);return _0x1e404a(_0x416872[_0x7d5f('0x13')][_0x7d5f('0x14')]);}logger[_0x7d5f('0x13')]('UserProfileSection,\x20%s,\x20%s',_0x2b191d,_0x416872[_0x7d5f('0x13')]['message']);return _0x470589(_0x416872[_0x7d5f('0x13')][_0x7d5f('0x14')]);}else{logger[_0x7d5f('0xe')](_0x7d5f('0xf'),_0x2b191d,_0x7d5f('0x10'));_0x470589(_0x416872[_0x7d5f('0x15')][_0x7d5f('0x14')]);}})[_0x7d5f('0x16')](function(_0x5965cc){logger[_0x7d5f('0x13')]('UserProfileSection,\x20%s,\x20%s',_0x2b191d,_0x5965cc);_0x1e404a(_0x5965cc);});});} \ No newline at end of file diff --git a/server/api/userSmsQueue/index.js b/server/api/userSmsQueue/index.js new file mode 100644 index 0000000..ff15cbb --- /dev/null +++ b/server/api/userSmsQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcb91=['express','Router','../../components/auth/service','../../components/interaction/service','exports','path','connect-timeout'];(function(_0x2a9536,_0x5a801e){var _0x181aeb=function(_0x3662d5){while(--_0x3662d5){_0x2a9536['push'](_0x2a9536['shift']());}};_0x181aeb(++_0x5a801e);}(_0xcb91,0x1a9));var _0x1cb9=function(_0x226ad1,_0x2858e2){_0x226ad1=_0x226ad1-0x0;var _0x16b625=_0xcb91[_0x226ad1];return _0x16b625;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x1cb9('0x0'));var timeout=require(_0x1cb9('0x1'));var express=require(_0x1cb9('0x2'));var router=express[_0x1cb9('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x1cb9('0x4'));var interaction=require(_0x1cb9('0x5'));var config=require('../../config/environment');module[_0x1cb9('0x6')]=router; \ No newline at end of file diff --git a/server/api/userSmsQueue/userSmsQueue.attributes.js b/server/api/userSmsQueue/userSmsQueue.attributes.js new file mode 100644 index 0000000..734cd79 --- /dev/null +++ b/server/api/userSmsQueue/userSmsQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc7fb=['exports','INTEGER','sequelize'];(function(_0xb632a3,_0x526b16){var _0x139ec4=function(_0x141d0d){while(--_0x141d0d){_0xb632a3['push'](_0xb632a3['shift']());}};_0x139ec4(++_0x526b16);}(_0xc7fb,0x68));var _0xbc7f=function(_0x177fb3,_0x4b2f47){_0x177fb3=_0x177fb3-0x0;var _0x366c11=_0xc7fb[_0x177fb3];return _0x366c11;};'use strict';var Sequelize=require(_0xbc7f('0x0'));module[_0xbc7f('0x1')]={'penalty':{'type':Sequelize[_0xbc7f('0x2')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userSmsQueue/userSmsQueue.model.js b/server/api/userSmsQueue/userSmsQueue.model.js new file mode 100644 index 0000000..b2aa38e --- /dev/null +++ b/server/api/userSmsQueue/userSmsQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7096=['exports','define','UserSmsQueue','user_has_sms_queues','util','api','bluebird','request-promise','path','rimraf','../../config/environment','./userSmsQueue.attributes'];(function(_0x4b2b03,_0xbf34ee){var _0x1bf0ed=function(_0x562785){while(--_0x562785){_0x4b2b03['push'](_0x4b2b03['shift']());}};_0x1bf0ed(++_0xbf34ee);}(_0x7096,0x10c));var _0x6709=function(_0x23e7c1,_0x35110c){_0x23e7c1=_0x23e7c1-0x0;var _0x1add43=_0x7096[_0x23e7c1];return _0x1add43;};'use strict';var _=require('lodash');var util=require(_0x6709('0x0'));var logger=require('../../config/logger')(_0x6709('0x1'));var moment=require('moment');var BPromise=require(_0x6709('0x2'));var rp=require(_0x6709('0x3'));var fs=require('fs');var path=require(_0x6709('0x4'));var rimraf=require(_0x6709('0x5'));var config=require(_0x6709('0x6'));var attributes=require(_0x6709('0x7'));module[_0x6709('0x8')]=function(_0x9d630f,_0xa35832){return _0x9d630f[_0x6709('0x9')](_0x6709('0xa'),attributes,{'tableName':_0x6709('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userSmsQueue/userSmsQueue.rpc.js b/server/api/userSmsQueue/userSmsQueue.rpc.js new file mode 100644 index 0000000..64f68bb --- /dev/null +++ b/server/api/userSmsQueue/userSmsQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfe7f=['request\x20sent','debug','UserSmsQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','info','UserSmsQueue,\x20%s,\x20%s'];(function(_0x2be00b,_0x309873){var _0x2f7b52=function(_0x57759b){while(--_0x57759b){_0x2be00b['push'](_0x2be00b['shift']());}};_0x2f7b52(++_0x309873);}(_0xfe7f,0x1eb));var _0xffe7=function(_0x1d0f10,_0x4de9fb){_0x1d0f10=_0x1d0f10-0x0;var _0xa1dcaf=_0xfe7f[_0x1d0f10];return _0xa1dcaf;};'use strict';var _=require('lodash');var util=require(_0xffe7('0x0'));var moment=require(_0xffe7('0x1'));var BPromise=require(_0xffe7('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xffe7('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xffe7('0x4'));var logger=require(_0xffe7('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0xffe7('0x6'));var client=jayson[_0xffe7('0x7')][_0xffe7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1d84b9,_0x13a2cf,_0x189bb8){return new BPromise(function(_0x231656,_0x3f7894){return client[_0xffe7('0x9')](_0x1d84b9,_0x189bb8)[_0xffe7('0xa')](function(_0x5c13a8){logger[_0xffe7('0xb')](_0xffe7('0xc'),_0x13a2cf,_0xffe7('0xd'));logger[_0xffe7('0xe')](_0xffe7('0xf'),_0x13a2cf,_0xffe7('0xd'),JSON['stringify'](_0x5c13a8));if(_0x5c13a8['error']){if(_0x5c13a8[_0xffe7('0x10')][_0xffe7('0x11')]===0x1f4){logger[_0xffe7('0x10')]('UserSmsQueue,\x20%s,\x20%s',_0x13a2cf,_0x5c13a8['error']['message']);return _0x3f7894(_0x5c13a8[_0xffe7('0x10')][_0xffe7('0x12')]);}logger[_0xffe7('0x10')](_0xffe7('0xc'),_0x13a2cf,_0x5c13a8[_0xffe7('0x10')][_0xffe7('0x12')]);return _0x231656(_0x5c13a8['error'][_0xffe7('0x12')]);}else{logger[_0xffe7('0xb')]('UserSmsQueue,\x20%s,\x20%s',_0x13a2cf,'request\x20sent');_0x231656(_0x5c13a8[_0xffe7('0x13')][_0xffe7('0x12')]);}})[_0xffe7('0x14')](function(_0x1eab8c){logger[_0xffe7('0x10')](_0xffe7('0xc'),_0x13a2cf,_0x1eab8c);_0x3f7894(_0x1eab8c);});});} \ No newline at end of file diff --git a/server/api/userVoicePrefix/userVoicePrefix.attributes.js b/server/api/userVoicePrefix/userVoicePrefix.attributes.js new file mode 100644 index 0000000..2388f60 --- /dev/null +++ b/server/api/userVoicePrefix/userVoicePrefix.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8240=['sequelize','INTEGER'];(function(_0x4b2873,_0x368dcc){var _0x169a18=function(_0x22f7ab){while(--_0x22f7ab){_0x4b2873['push'](_0x4b2873['shift']());}};_0x169a18(++_0x368dcc);}(_0x8240,0x124));var _0x0824=function(_0x31b5a5,_0x44376a){_0x31b5a5=_0x31b5a5-0x0;var _0x364cc9=_0x8240[_0x31b5a5];return _0x364cc9;};'use strict';var Sequelize=require(_0x0824('0x0'));module['exports']={'UserId':{'type':Sequelize[_0x0824('0x1')]},'VoicePrefixId':{'type':Sequelize[_0x0824('0x1')]}}; \ No newline at end of file diff --git a/server/api/userVoicePrefix/userVoicePrefix.model.js b/server/api/userVoicePrefix/userVoicePrefix.model.js new file mode 100644 index 0000000..fd53baf --- /dev/null +++ b/server/api/userVoicePrefix/userVoicePrefix.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../config/environment','./userVoicePrefix.attributes','exports','define','UserVoicePrefix','lodash','util','../../config/logger','bluebird','path','rimraf'];(function(_0x27827e,_0x5c842d){var _0x585ab3=function(_0x467637){while(--_0x467637){_0x27827e['push'](_0x27827e['shift']());}};_0x585ab3(++_0x5c842d);}(_0xa9e0,0x123));var _0x0a9e=function(_0x13ea00,_0x12f610){_0x13ea00=_0x13ea00-0x0;var _0x1f7347=_0xa9e0[_0x13ea00];return _0x1f7347;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var logger=require(_0x0a9e('0x2'))('api');var moment=require('moment');var BPromise=require(_0x0a9e('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x0a9e('0x4'));var rimraf=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var attributes=require(_0x0a9e('0x7'));module[_0x0a9e('0x8')]=function(_0x57b080,_0x219af0){return _0x57b080[_0x0a9e('0x9')](_0x0a9e('0xa'),attributes,{'tableName':'user_has_voice_prefixes','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userVoiceQueue/index.js b/server/api/userVoiceQueue/index.js new file mode 100644 index 0000000..a377e10 --- /dev/null +++ b/server/api/userVoiceQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c44=['express','Router','fs-extra','../../components/auth/service','exports','path','connect-timeout'];(function(_0x30c57f,_0x4e26ca){var _0x570756=function(_0xd1ee2e){while(--_0xd1ee2e){_0x30c57f['push'](_0x30c57f['shift']());}};_0x570756(++_0x4e26ca);}(_0x9c44,0x178));var _0x49c4=function(_0x2064e5,_0x4f6fa2){_0x2064e5=_0x2064e5-0x0;var _0x21a233=_0x9c44[_0x2064e5];return _0x21a233;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x49c4('0x0'));var timeout=require(_0x49c4('0x1'));var express=require(_0x49c4('0x2'));var router=express[_0x49c4('0x3')]();var fs_extra=require(_0x49c4('0x4'));var auth=require(_0x49c4('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');module[_0x49c4('0x6')]=router; \ No newline at end of file diff --git a/server/api/userVoiceQueue/userVoiceQueue.attributes.js b/server/api/userVoiceQueue/userVoiceQueue.attributes.js new file mode 100644 index 0000000..c5872c8 --- /dev/null +++ b/server/api/userVoiceQueue/userVoiceQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x99fc=['INTEGER','sequelize'];(function(_0x2f0723,_0x3ecd67){var _0x34f47b=function(_0x155ad7){while(--_0x155ad7){_0x2f0723['push'](_0x2f0723['shift']());}};_0x34f47b(++_0x3ecd67);}(_0x99fc,0x1df));var _0xc99f=function(_0x7f038a,_0xcbf254){_0x7f038a=_0x7f038a-0x0;var _0x4cb3dd=_0x99fc[_0x7f038a];return _0x4cb3dd;};'use strict';var Sequelize=require(_0xc99f('0x0'));module['exports']={'penalty':{'type':Sequelize[_0xc99f('0x1')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userVoiceQueue/userVoiceQueue.model.js b/server/api/userVoiceQueue/userVoiceQueue.model.js new file mode 100644 index 0000000..ee704c7 --- /dev/null +++ b/server/api/userVoiceQueue/userVoiceQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdf14=['UserVoiceQueue','user_has_voice_queues','lodash','util','../../config/logger','moment','rimraf','../../config/environment','./userVoiceQueue.attributes','exports','define'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0xdf14,0x162));var _0x4df1=function(_0x22d862,_0x37e96b){_0x22d862=_0x22d862-0x0;var _0x16def8=_0xdf14[_0x22d862];return _0x16def8;};'use strict';var _=require(_0x4df1('0x0'));var util=require(_0x4df1('0x1'));var logger=require(_0x4df1('0x2'))('api');var moment=require(_0x4df1('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0x4df1('0x4'));var config=require(_0x4df1('0x5'));var attributes=require(_0x4df1('0x6'));module[_0x4df1('0x7')]=function(_0x37c6df,_0x51f1b5){return _0x37c6df[_0x4df1('0x8')](_0x4df1('0x9'),attributes,{'tableName':_0x4df1('0xa'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userVoiceQueue/userVoiceQueue.rpc.js b/server/api/userVoiceQueue/userVoiceQueue.rpc.js new file mode 100644 index 0000000..82bf0f7 --- /dev/null +++ b/server/api/userVoiceQueue/userVoiceQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9ba9=['util','moment','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','UserVoiceQueue,\x20%s,\x20%s','request\x20sent','debug','UserVoiceQueue,\x20%s,\x20%s,\x20%s','error','message','result','catch'];(function(_0x5a0d75,_0x4ef5c2){var _0x37b4f9=function(_0x4fdda0){while(--_0x4fdda0){_0x5a0d75['push'](_0x5a0d75['shift']());}};_0x37b4f9(++_0x4ef5c2);}(_0x9ba9,0x190));var _0x99ba=function(_0x11a4d7,_0x55c864){_0x11a4d7=_0x11a4d7-0x0;var _0x64cbcf=_0x9ba9[_0x11a4d7];return _0x64cbcf;};'use strict';var _=require('lodash');var util=require(_0x99ba('0x0'));var moment=require(_0x99ba('0x1'));var BPromise=require(_0x99ba('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x99ba('0x3'));var logger=require(_0x99ba('0x4'))(_0x99ba('0x5'));var config=require(_0x99ba('0x6'));var jayson=require(_0x99ba('0x7'));var client=jayson[_0x99ba('0x8')][_0x99ba('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1c7c18,_0x25e29a,_0x977814){return new BPromise(function(_0x3e592a,_0x1166e2){return client['request'](_0x1c7c18,_0x977814)[_0x99ba('0xa')](function(_0x2b32f4){logger[_0x99ba('0xb')](_0x99ba('0xc'),_0x25e29a,_0x99ba('0xd'));logger[_0x99ba('0xe')](_0x99ba('0xf'),_0x25e29a,_0x99ba('0xd'),JSON['stringify'](_0x2b32f4));if(_0x2b32f4['error']){if(_0x2b32f4[_0x99ba('0x10')]['code']===0x1f4){logger[_0x99ba('0x10')](_0x99ba('0xc'),_0x25e29a,_0x2b32f4['error'][_0x99ba('0x11')]);return _0x1166e2(_0x2b32f4[_0x99ba('0x10')][_0x99ba('0x11')]);}logger[_0x99ba('0x10')]('UserVoiceQueue,\x20%s,\x20%s',_0x25e29a,_0x2b32f4[_0x99ba('0x10')]['message']);return _0x3e592a(_0x2b32f4[_0x99ba('0x10')]['message']);}else{logger['info'](_0x99ba('0xc'),_0x25e29a,'request\x20sent');_0x3e592a(_0x2b32f4[_0x99ba('0x12')][_0x99ba('0x11')]);}})[_0x99ba('0x13')](function(_0x5ce9ab){logger[_0x99ba('0x10')]('UserVoiceQueue,\x20%s,\x20%s',_0x25e29a,_0x5ce9ab);_0x1166e2(_0x5ce9ab);});});} \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/index.js b/server/api/userVoiceQueueRt/index.js new file mode 100644 index 0000000..0f5275e --- /dev/null +++ b/server/api/userVoiceQueueRt/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['../../components/interaction/service','../../config/environment','exports','multer','util','path','Router','../../components/auth/service'];(function(_0x523671,_0x4657fc){var _0x5b0bdc=function(_0x301007){while(--_0x301007){_0x523671['push'](_0x523671['shift']());}};_0x5b0bdc(++_0x4657fc);}(_0xa9e0,0x123));var _0x0a9e=function(_0x24237f,_0x4cf32c){_0x24237f=_0x24237f-0x0;var _0x48298e=_0xa9e0[_0x24237f];return _0x48298e;};'use strict';var multer=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x0a9e('0x3')]();var fs_extra=require('fs-extra');var auth=require(_0x0a9e('0x4'));var interaction=require(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));module[_0x0a9e('0x7')]=router; \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/userVoiceQueueRt.attributes.js b/server/api/userVoiceQueueRt/userVoiceQueueRt.attributes.js new file mode 100644 index 0000000..497f4ce --- /dev/null +++ b/server/api/userVoiceQueueRt/userVoiceQueueRt.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8d6a=['exports','INTEGER','STRING','Required\x20by\x20Asterisk','queue_interface','sequelize'];(function(_0x5d407f,_0xae041c){var _0x3dbf71=function(_0x5f42c0){while(--_0x5f42c0){_0x5d407f['push'](_0x5d407f['shift']());}};_0x3dbf71(++_0xae041c);}(_0x8d6a,0x143));var _0xa8d6=function(_0x56482c,_0x16118d){_0x56482c=_0x56482c-0x0;var _0x5aae7a=_0x8d6a[_0x56482c];return _0x5aae7a;};'use strict';var Sequelize=require(_0xa8d6('0x0'));module[_0xa8d6('0x1')]={'uniqueid':{'type':Sequelize[_0xa8d6('0x2')],'primaryKey':!![],'autoIncrement':!![],'comment':'Required\x20by\x20Asterisk'},'membername':{'type':Sequelize[_0xa8d6('0x3')],'allowNull':![],'comment':_0xa8d6('0x4')},'UserId':{'type':Sequelize['INTEGER'],'allowNull':![]},'queue_name':{'type':Sequelize[_0xa8d6('0x3')],'allowNull':![],'unique':_0xa8d6('0x5'),'comment':'Required\x20by\x20Asterisk'},'VoiceQueueId':{'type':Sequelize[_0xa8d6('0x2')],'allowNull':![]},'interface':{'type':Sequelize[_0xa8d6('0x3')],'allowNull':![],'unique':_0xa8d6('0x5'),'comment':'Required\x20by\x20Asterisk'},'penalty':{'type':Sequelize['INTEGER'](0xb),'defaultValue':0x0,'comment':_0xa8d6('0x4')},'paused':{'type':Sequelize[_0xa8d6('0x2')](0xb),'defaultValue':0x0,'comment':'Required\x20by\x20Asterisk'}}; \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/userVoiceQueueRt.events.js b/server/api/userVoiceQueueRt/userVoiceQueueRt.events.js new file mode 100644 index 0000000..e9a21d3 --- /dev/null +++ b/server/api/userVoiceQueueRt/userVoiceQueueRt.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xed50=['UserVoiceQueueRt','setMaxListeners','update','remove','emit','hook','events','../../mysqldb'];(function(_0x35f191,_0x1ff4ad){var _0x42ade7=function(_0x3c0b1d){while(--_0x3c0b1d){_0x35f191['push'](_0x35f191['shift']());}};_0x42ade7(++_0x1ff4ad);}(_0xed50,0x1a6));var _0x0ed5=function(_0x1b7368,_0x3286ed){_0x1b7368=_0x1b7368-0x0;var _0x25d54c=_0xed50[_0x1b7368];return _0x25d54c;};'use strict';var EventEmitter=require(_0x0ed5('0x0'));var UserVoiceQueueRt=require(_0x0ed5('0x1'))['db'][_0x0ed5('0x2')];var UserVoiceQueueRtEvents=new EventEmitter();UserVoiceQueueRtEvents[_0x0ed5('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':_0x0ed5('0x4'),'afterDestroy':_0x0ed5('0x5')};function emitEvent(_0x31244f){return function(_0x200229,_0x523874,_0x2e2b6f){UserVoiceQueueRtEvents[_0x0ed5('0x6')](_0x31244f+':'+_0x200229['id'],_0x200229);UserVoiceQueueRtEvents['emit'](_0x31244f,_0x200229);_0x2e2b6f(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];UserVoiceQueueRt[_0x0ed5('0x7')](e,emitEvent(event));}}module['exports']=UserVoiceQueueRtEvents; \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/userVoiceQueueRt.model.js b/server/api/userVoiceQueueRt/userVoiceQueueRt.model.js new file mode 100644 index 0000000..d7bfbd8 --- /dev/null +++ b/server/api/userVoiceQueueRt/userVoiceQueueRt.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf7df=['bluebird','request-promise','path','../../config/environment','./userVoiceQueueRt.attributes','exports','define','UserVoiceQueueRt','user_has_voice_queues_rt','util','../../config/logger','moment'];(function(_0x20520f,_0x4bf423){var _0xf893fd=function(_0x35f8dc){while(--_0x35f8dc){_0x20520f['push'](_0x20520f['shift']());}};_0xf893fd(++_0x4bf423);}(_0xf7df,0x1d1));var _0xff7d=function(_0x2628fd,_0x1e3921){_0x2628fd=_0x2628fd-0x0;var _0x3763ed=_0xf7df[_0x2628fd];return _0x3763ed;};'use strict';var _=require('lodash');var util=require(_0xff7d('0x0'));var logger=require(_0xff7d('0x1'))('api');var moment=require(_0xff7d('0x2'));var BPromise=require(_0xff7d('0x3'));var rp=require(_0xff7d('0x4'));var fs=require('fs');var path=require(_0xff7d('0x5'));var rimraf=require('rimraf');var config=require(_0xff7d('0x6'));var attributes=require(_0xff7d('0x7'));module[_0xff7d('0x8')]=function(_0x78f2ea,_0x3fb1b0){return _0x78f2ea[_0xff7d('0x9')](_0xff7d('0xa'),attributes,{'tableName':_0xff7d('0xb'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/userVoiceQueueRt.rpc.js b/server/api/userVoiceQueueRt/userVoiceQueueRt.rpc.js new file mode 100644 index 0000000..60218eb --- /dev/null +++ b/server/api/userVoiceQueueRt/userVoiceQueueRt.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2553=['then','info','UserVoiceQueueRt,\x20%s,\x20%s','debug','UserVoiceQueueRt,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','catch','GetVoiceQueueRtPauses','UserVoiceQueueRt','findAll','options','raw','where','sequelize','COUNT','literal','`paused`\x20=\x201,\x201,\x20null','outboundQueuePauses','lodash','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','defaults','localhost','redis','./userVoiceQueueRt.socket','register','request'];(function(_0xd6ca7,_0xf8aca2){var _0x5f269f=function(_0x1c58b9){while(--_0x1c58b9){_0xd6ca7['push'](_0xd6ca7['shift']());}};_0x5f269f(++_0xf8aca2);}(_0x2553,0xfa));var _0x3255=function(_0x4adfa4,_0x121c5a){_0x4adfa4=_0x4adfa4-0x0;var _0x14cec1=_0x2553[_0x4adfa4];return _0x14cec1;};'use strict';var _=require(_0x3255('0x0'));var util=require('util');var moment=require(_0x3255('0x1'));var BPromise=require(_0x3255('0x2'));var rs=require(_0x3255('0x3'));var fs=require('fs');var Redis=require(_0x3255('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x3255('0x5'))('rpc');var config=require(_0x3255('0x6'));var jayson=require(_0x3255('0x7'));var client=jayson[_0x3255('0x8')][_0x3255('0x9')]({'port':0x232a});config['redis']=_[_0x3255('0xa')](config['redis'],{'host':_0x3255('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3255('0xc')]));require(_0x3255('0xd'))[_0x3255('0xe')](socket);function respondWithRpcPromise(_0xc58677,_0x4fb06f,_0x2d8784){return new BPromise(function(_0x4e607e,_0x5a7d20){return client[_0x3255('0xf')](_0xc58677,_0x2d8784)[_0x3255('0x10')](function(_0x456596){logger[_0x3255('0x11')](_0x3255('0x12'),_0x4fb06f,'request\x20sent');logger[_0x3255('0x13')](_0x3255('0x14'),_0x4fb06f,'request\x20sent',JSON[_0x3255('0x15')](_0x456596));if(_0x456596[_0x3255('0x16')]){if(_0x456596['error'][_0x3255('0x17')]===0x1f4){logger['error'](_0x3255('0x12'),_0x4fb06f,_0x456596[_0x3255('0x16')][_0x3255('0x18')]);return _0x5a7d20(_0x456596['error'][_0x3255('0x18')]);}logger[_0x3255('0x16')](_0x3255('0x12'),_0x4fb06f,_0x456596[_0x3255('0x16')]['message']);return _0x4e607e(_0x456596[_0x3255('0x16')][_0x3255('0x18')]);}else{logger['info'](_0x3255('0x12'),_0x4fb06f,_0x3255('0x19'));_0x4e607e(_0x456596['result']['message']);}})[_0x3255('0x1a')](function(_0x5e6791){logger[_0x3255('0x16')](_0x3255('0x12'),_0x4fb06f,_0x5e6791);_0x5a7d20(_0x5e6791);});});}exports[_0x3255('0x1b')]=function(_0x3a45b7){var _0x48a551=this;return new Promise(function(_0x2a868e,_0x259222){return db[_0x3255('0x1c')][_0x3255('0x1d')]({'raw':_0x3a45b7[_0x3255('0x1e')]?_0x3a45b7[_0x3255('0x1e')][_0x3255('0x1f')]===undefined?!![]:![]:!![],'where':_0x3a45b7['options']?_0x3a45b7[_0x3255('0x1e')][_0x3255('0x20')]||null:null,'attributes':[[db[_0x3255('0x21')]['fn'](_0x3255('0x22'),db[_0x3255('0x21')]['fn']('IF',db[_0x3255('0x21')][_0x3255('0x23')](_0x3255('0x24')))),_0x3255('0x25')]]})[_0x3255('0x10')](function(_0x539299){logger[_0x3255('0x11')](_0x3255('0x1b'),_0x3a45b7);logger['debug']('GetVoiceQueueRtPauses',_0x3a45b7,JSON[_0x3255('0x15')](_0x539299));_0x2a868e(_0x539299);})[_0x3255('0x1a')](function(_0x18ea81){logger[_0x3255('0x16')](_0x3255('0x1b'),_0x18ea81[_0x3255('0x18')],_0x3a45b7);_0x259222(_0x48a551['error'](0x1f4,_0x18ea81[_0x3255('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/userVoiceQueueRt/userVoiceQueueRt.socket.js b/server/api/userVoiceQueueRt/userVoiceQueueRt.socket.js new file mode 100644 index 0000000..19d9cb9 --- /dev/null +++ b/server/api/userVoiceQueueRt/userVoiceQueueRt.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd307=['./userVoiceQueueRt.events','save','remove','update','emit','removeListener','length','userVoiceQueueRt:'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0xd307,0x110));var _0x7d30=function(_0x2ba4e9,_0x5cdea4){_0x2ba4e9=_0x2ba4e9-0x0;var _0x36ea64=_0xd307[_0x2ba4e9];return _0x36ea64;};'use strict';var UserVoiceQueueRtEvents=require(_0x7d30('0x0'));var events=[_0x7d30('0x1'),_0x7d30('0x2'),_0x7d30('0x3')];function createListener(_0x2917cd,_0x3c6f99){return function(_0x359ef3){_0x3c6f99[_0x7d30('0x4')](_0x2917cd,_0x359ef3);};}function removeListener(_0x57cf6e,_0x2a0bb8){return function(){UserVoiceQueueRtEvents[_0x7d30('0x5')](_0x57cf6e,_0x2a0bb8);};}exports['register']=function(_0x400916){for(var _0x449938=0x0,_0x9451ed=events[_0x7d30('0x6')];_0x449938<_0x9451ed;_0x449938++){var _0x43b35e=events[_0x449938];var _0x1ef3e7=createListener(_0x7d30('0x7')+_0x43b35e,_0x400916);UserVoiceQueueRtEvents['on'](_0x43b35e,_0x1ef3e7);}}; \ No newline at end of file diff --git a/server/api/userWhatsappQueue/index.js b/server/api/userWhatsappQueue/index.js new file mode 100644 index 0000000..07a4d25 --- /dev/null +++ b/server/api/userWhatsappQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xedd9=['util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','exports'];(function(_0xc27fe1,_0x1f51ba){var _0xde1ffc=function(_0x1421bb){while(--_0x1421bb){_0xc27fe1['push'](_0xc27fe1['shift']());}};_0xde1ffc(++_0x1f51ba);}(_0xedd9,0xfc));var _0x9edd=function(_0x281ad6,_0x4e02f8){_0x281ad6=_0x281ad6-0x0;var _0x73f177=_0xedd9[_0x281ad6];return _0x73f177;};'use strict';var multer=require('multer');var util=require(_0x9edd('0x0'));var path=require(_0x9edd('0x1'));var timeout=require(_0x9edd('0x2'));var express=require(_0x9edd('0x3'));var router=express[_0x9edd('0x4')]();var fs_extra=require(_0x9edd('0x5'));var auth=require(_0x9edd('0x6'));var interaction=require(_0x9edd('0x7'));var config=require('../../config/environment');module[_0x9edd('0x8')]=router; \ No newline at end of file diff --git a/server/api/userWhatsappQueue/userWhatsappQueue.attributes.js b/server/api/userWhatsappQueue/userWhatsappQueue.attributes.js new file mode 100644 index 0000000..43a80ef --- /dev/null +++ b/server/api/userWhatsappQueue/userWhatsappQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfc76=['INTEGER','exports'];(function(_0x189963,_0x319152){var _0x4d94e7=function(_0x18b744){while(--_0x18b744){_0x189963['push'](_0x189963['shift']());}};_0x4d94e7(++_0x319152);}(_0xfc76,0xb5));var _0x6fc7=function(_0x264444,_0x3a51d6){_0x264444=_0x264444-0x0;var _0x937f30=_0xfc76[_0x264444];return _0x937f30;};'use strict';var Sequelize=require('sequelize');module[_0x6fc7('0x0')]={'penalty':{'type':Sequelize[_0x6fc7('0x1')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/userWhatsappQueue/userWhatsappQueue.model.js b/server/api/userWhatsappQueue/userWhatsappQueue.model.js new file mode 100644 index 0000000..6f3d69b --- /dev/null +++ b/server/api/userWhatsappQueue/userWhatsappQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0d06=['request-promise','path','rimraf','./userWhatsappQueue.attributes','exports','UserWhatsappQueue','lodash','api','moment'];(function(_0x5a67ed,_0xb5fff7){var _0x4b59e3=function(_0x3bd063){while(--_0x3bd063){_0x5a67ed['push'](_0x5a67ed['shift']());}};_0x4b59e3(++_0xb5fff7);}(_0x0d06,0x1d1));var _0x60d0=function(_0x559aab,_0x4b7dc4){_0x559aab=_0x559aab-0x0;var _0x5e5801=_0x0d06[_0x559aab];return _0x5e5801;};'use strict';var _=require(_0x60d0('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x60d0('0x1'));var moment=require(_0x60d0('0x2'));var BPromise=require('bluebird');var rp=require(_0x60d0('0x3'));var fs=require('fs');var path=require(_0x60d0('0x4'));var rimraf=require(_0x60d0('0x5'));var config=require('../../config/environment');var attributes=require(_0x60d0('0x6'));module[_0x60d0('0x7')]=function(_0x31151f,_0x3cad37){return _0x31151f['define'](_0x60d0('0x8'),attributes,{'tableName':'user_has_whatsapp_queues','paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/userWhatsappQueue/userWhatsappQueue.rpc.js b/server/api/userWhatsappQueue/userWhatsappQueue.rpc.js new file mode 100644 index 0000000..cdc71ac --- /dev/null +++ b/server/api/userWhatsappQueue/userWhatsappQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xae5b=['error','message','UserWhatsappQueue,\x20%s,\x20%s','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','client','http','request','then','info','debug','UserWhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x4f6ad2,_0x5f36c8){var _0x358b3a=function(_0x5c694a){while(--_0x5c694a){_0x4f6ad2['push'](_0x4f6ad2['shift']());}};_0x358b3a(++_0x5f36c8);}(_0xae5b,0x1d2));var _0xbae5=function(_0x4ecb49,_0x432e82){_0x4ecb49=_0x4ecb49-0x0;var _0x50a24c=_0xae5b[_0x4ecb49];return _0x50a24c;};'use strict';var _=require(_0xbae5('0x0'));var util=require(_0xbae5('0x1'));var moment=require(_0xbae5('0x2'));var BPromise=require(_0xbae5('0x3'));var rs=require(_0xbae5('0x4'));var fs=require('fs');var Redis=require(_0xbae5('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xbae5('0x6'));var logger=require(_0xbae5('0x7'))(_0xbae5('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xbae5('0x9')][_0xbae5('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xcffe25,_0x305819,_0x4b78fd){return new BPromise(function(_0x4a207e,_0x295024){return client[_0xbae5('0xb')](_0xcffe25,_0x4b78fd)[_0xbae5('0xc')](function(_0x199984){logger[_0xbae5('0xd')]('UserWhatsappQueue,\x20%s,\x20%s',_0x305819,'request\x20sent');logger[_0xbae5('0xe')](_0xbae5('0xf'),_0x305819,_0xbae5('0x10'),JSON[_0xbae5('0x11')](_0x199984));if(_0x199984[_0xbae5('0x12')]){if(_0x199984['error']['code']===0x1f4){logger[_0xbae5('0x12')]('UserWhatsappQueue,\x20%s,\x20%s',_0x305819,_0x199984[_0xbae5('0x12')][_0xbae5('0x13')]);return _0x295024(_0x199984[_0xbae5('0x12')][_0xbae5('0x13')]);}logger[_0xbae5('0x12')]('UserWhatsappQueue,\x20%s,\x20%s',_0x305819,_0x199984[_0xbae5('0x12')][_0xbae5('0x13')]);return _0x4a207e(_0x199984[_0xbae5('0x12')][_0xbae5('0x13')]);}else{logger[_0xbae5('0xd')](_0xbae5('0x14'),_0x305819,_0xbae5('0x10'));_0x4a207e(_0x199984['result'][_0xbae5('0x13')]);}})[_0xbae5('0x15')](function(_0x203885){logger[_0xbae5('0x12')](_0xbae5('0x14'),_0x305819,_0x203885);_0x295024(_0x203885);});});} \ No newline at end of file diff --git a/server/api/variable/index.js b/server/api/variable/index.js new file mode 100644 index 0000000..7592ba3 --- /dev/null +++ b/server/api/variable/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcf1c=['destroy','multer','util','connect-timeout','express','Router','fs-extra','./variable.controller','isAuthenticated','index','get','/:id','show','post','create','put','update','delete'];(function(_0x245095,_0x512248){var _0x411cce=function(_0x5820ea){while(--_0x5820ea){_0x245095['push'](_0x245095['shift']());}};_0x411cce(++_0x512248);}(_0xcf1c,0x18d));var _0xccf1=function(_0x161341,_0x1c054d){_0x161341=_0x161341-0x0;var _0x5e06c3=_0xcf1c[_0x161341];return _0x5e06c3;};'use strict';var multer=require(_0xccf1('0x0'));var util=require(_0xccf1('0x1'));var path=require('path');var timeout=require(_0xccf1('0x2'));var express=require(_0xccf1('0x3'));var router=express[_0xccf1('0x4')]();var fs_extra=require(_0xccf1('0x5'));var auth=require('../../components/auth/service');var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0xccf1('0x6'));router['get']('/',auth[_0xccf1('0x7')](),controller[_0xccf1('0x8')]);router[_0xccf1('0x9')](_0xccf1('0xa'),auth[_0xccf1('0x7')](),controller[_0xccf1('0xb')]);router[_0xccf1('0xc')]('/',auth[_0xccf1('0x7')](),controller[_0xccf1('0xd')]);router[_0xccf1('0xe')](_0xccf1('0xa'),auth[_0xccf1('0x7')](),controller[_0xccf1('0xf')]);router[_0xccf1('0x10')](_0xccf1('0xa'),auth[_0xccf1('0x7')](),controller[_0xccf1('0x11')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/variable/variable.attributes.js b/server/api/variable/variable.attributes.js new file mode 100644 index 0000000..54f7501 --- /dev/null +++ b/server/api/variable/variable.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2881=['name','sequelize','exports','STRING'];(function(_0x28407a,_0x2a7269){var _0x8bd6ef=function(_0x3c886f){while(--_0x3c886f){_0x28407a['push'](_0x28407a['shift']());}};_0x8bd6ef(++_0x2a7269);}(_0x2881,0x1f1));var _0x1288=function(_0x4201a4,_0x347560){_0x4201a4=_0x4201a4-0x0;var _0x2ffadd=_0x2881[_0x4201a4];return _0x2ffadd;};'use strict';var Sequelize=require(_0x1288('0x0'));module[_0x1288('0x1')]={'name':{'type':Sequelize[_0x1288('0x2')],'unique':_0x1288('0x3'),'allowNull':![],'validate':{'notEmpty':!![]}},'description':{'type':Sequelize[_0x1288('0x2')]}}; \ No newline at end of file diff --git a/server/api/variable/variable.controller.js b/server/api/variable/variable.controller.js new file mode 100644 index 0000000..2e64d89 --- /dev/null +++ b/server/api/variable/variable.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe134=['then','destroy','get','Variables','UserProfileResource','sendStatus','error','stack','name','send','index','map','Variable','type','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','squel','desk.js','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update'];(function(_0x3a7bb2,_0x4d9a9b){var _0x138ef1=function(_0x19bdd6){while(--_0x19bdd6){_0x3a7bb2['push'](_0x3a7bb2['shift']());}};_0x138ef1(++_0x4d9a9b);}(_0xe134,0x122));var _0x4e13=function(_0x595c8e,_0x394e77){_0x595c8e=_0x595c8e-0x0;var _0x3087b1=_0xe134[_0x595c8e];return _0x3087b1;};'use strict';var emlformat=require(_0x4e13('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4e13('0x1'));var jsonpatch=require(_0x4e13('0x2'));var rp=require(_0x4e13('0x3'));var moment=require(_0x4e13('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x4e13('0x5'));var path=require(_0x4e13('0x6'));var sox=require('sox');var csv=require(_0x4e13('0x7'));var ejs=require(_0x4e13('0x8'));var fs=require('fs');var fs_extra=require(_0x4e13('0x9'));var _=require(_0x4e13('0xa'));var squel=require(_0x4e13('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x4e13('0xc'));var toCsv=require(_0x4e13('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x4e13('0xd'));var authService=require(_0x4e13('0xe'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4e13('0xf'));var logger=require(_0x4e13('0x10'))(_0x4e13('0x11'));var utils=require(_0x4e13('0x12'));var config=require(_0x4e13('0x13'));var licenseUtil=require(_0x4e13('0x14'));var db=require(_0x4e13('0x15'))['db'];function respondWithStatusCode(_0x295dfb,_0x3cb5a7){_0x3cb5a7=_0x3cb5a7||0xcc;return function(_0x72ceab){if(_0x72ceab){return _0x295dfb['sendStatus'](_0x3cb5a7);}return _0x295dfb['status'](_0x3cb5a7)[_0x4e13('0x16')]();};}function respondWithResult(_0x1ebfac,_0x4f73e4){_0x4f73e4=_0x4f73e4||0xc8;return function(_0x5b8a4d){if(_0x5b8a4d){return _0x1ebfac[_0x4e13('0x17')](_0x4f73e4)['json'](_0x5b8a4d);}};}function respondWithFilteredResult(_0x4423c1,_0x2ae2f4){return function(_0xc8e21c){if(_0xc8e21c){var _0x177d22=typeof _0x2ae2f4[_0x4e13('0x18')]===_0x4e13('0x19')&&typeof _0x2ae2f4[_0x4e13('0x1a')]==='undefined';var _0x56b769=_0xc8e21c['count'];var _0x3e0c7e=_0x177d22?0x0:_0x2ae2f4['offset'];var _0x3ef929=_0x177d22?_0xc8e21c[_0x4e13('0x1b')]:_0x2ae2f4['offset']+_0x2ae2f4[_0x4e13('0x1a')];var _0x54c9a8;if(_0x3ef929>=_0x56b769){_0x3ef929=_0x56b769;_0x54c9a8=0xc8;}else{_0x54c9a8=0xce;}_0x4423c1[_0x4e13('0x17')](_0x54c9a8);return _0x4423c1[_0x4e13('0x1c')](_0x4e13('0x1d'),_0x3e0c7e+'-'+_0x3ef929+'/'+_0x56b769)['json'](_0xc8e21c);}return null;};}function patchUpdates(_0x5d206e){return function(_0x48b48d){try{jsonpatch[_0x4e13('0x1e')](_0x48b48d,_0x5d206e,!![]);}catch(_0x460753){return BPromise[_0x4e13('0x1f')](_0x460753);}return _0x48b48d[_0x4e13('0x20')]();};}function saveUpdates(_0x26bfd,_0x2271af){return function(_0x43b1e9){if(_0x43b1e9){return _0x43b1e9[_0x4e13('0x21')](_0x26bfd)[_0x4e13('0x22')](function(_0x52bf73){return _0x52bf73;});}return null;};}function removeEntity(_0xf05bc0,_0x4279ec){return function(_0x68aad5){if(_0x68aad5){return _0x68aad5[_0x4e13('0x23')]()[_0x4e13('0x22')](function(){var _0x51aa82=_0x68aad5[_0x4e13('0x24')]({'plain':!![]});var _0x4b5734=_0x4e13('0x25');return db[_0x4e13('0x26')][_0x4e13('0x23')]({'where':{'type':_0x4b5734,'resourceId':_0x51aa82['id']}})[_0x4e13('0x22')](function(){return _0x68aad5;});})[_0x4e13('0x22')](function(){_0xf05bc0[_0x4e13('0x17')](0xcc)[_0x4e13('0x16')]();});}};}function handleEntityNotFound(_0x2cdd4b,_0x38aa27){return function(_0xcfb98c){if(!_0xcfb98c){_0x2cdd4b[_0x4e13('0x27')](0x194);}return _0xcfb98c;};}function handleError(_0x42d50c,_0x4927bb){_0x4927bb=_0x4927bb||0x1f4;return function(_0x1c3fdb){logger[_0x4e13('0x28')](_0x1c3fdb[_0x4e13('0x29')]);if(_0x1c3fdb[_0x4e13('0x2a')]){delete _0x1c3fdb['name'];}_0x42d50c[_0x4e13('0x17')](_0x4927bb)[_0x4e13('0x2b')](_0x1c3fdb);};}exports[_0x4e13('0x2c')]=function(_0x1ec73a,_0x33e7d4){var _0x584e1c={},_0x3b04eb={},_0x2dfab3={'count':0x0,'rows':[]};var _0x189ae0=_[_0x4e13('0x2d')](db[_0x4e13('0x2e')]['rawAttributes'],function(_0x1d00bb){return{'name':_0x1d00bb['fieldName'],'type':_0x1d00bb[_0x4e13('0x2f')]['key']};});_0x3b04eb[_0x4e13('0x30')]=_['map'](_0x189ae0,_0x4e13('0x2a'));_0x3b04eb['query']=_[_0x4e13('0x31')](_0x1ec73a['query']);_0x3b04eb[_0x4e13('0x32')]=_[_0x4e13('0x33')](_0x3b04eb[_0x4e13('0x30')],_0x3b04eb[_0x4e13('0x34')]);_0x584e1c[_0x4e13('0x35')]=_[_0x4e13('0x33')](_0x3b04eb[_0x4e13('0x30')],qs[_0x4e13('0x36')](_0x1ec73a[_0x4e13('0x34')][_0x4e13('0x36')]));_0x584e1c[_0x4e13('0x35')]=_0x584e1c[_0x4e13('0x35')][_0x4e13('0x37')]?_0x584e1c[_0x4e13('0x35')]:_0x3b04eb[_0x4e13('0x30')];if(!_0x1ec73a[_0x4e13('0x34')][_0x4e13('0x38')]('nolimit')){_0x584e1c[_0x4e13('0x1a')]=qs[_0x4e13('0x1a')](_0x1ec73a['query'][_0x4e13('0x1a')]);_0x584e1c[_0x4e13('0x18')]=qs[_0x4e13('0x18')](_0x1ec73a[_0x4e13('0x34')][_0x4e13('0x18')]);}_0x584e1c[_0x4e13('0x39')]=qs['sort'](_0x1ec73a['query'][_0x4e13('0x3a')]);_0x584e1c[_0x4e13('0x3b')]=qs[_0x4e13('0x32')](_[_0x4e13('0x3c')](_0x1ec73a[_0x4e13('0x34')],_0x3b04eb[_0x4e13('0x32')]),_0x189ae0);if(_0x1ec73a[_0x4e13('0x34')][_0x4e13('0x3d')]){_0x584e1c[_0x4e13('0x3b')]=_['merge'](_0x584e1c['where'],{'$or':_['map'](_0x189ae0,function(_0xa768bb){if(_0xa768bb['type']!=='VIRTUAL'){var _0x114653={};_0x114653[_0xa768bb[_0x4e13('0x2a')]]={'$like':'%'+_0x1ec73a[_0x4e13('0x34')][_0x4e13('0x3d')]+'%'};return _0x114653;}})});}_0x584e1c=_[_0x4e13('0x3e')]({},_0x584e1c,_0x1ec73a[_0x4e13('0x3f')]);var _0x15210a={'where':_0x584e1c[_0x4e13('0x3b')]};return db['Variable'][_0x4e13('0x1b')](_0x15210a)[_0x4e13('0x22')](function(_0x4e6eca){_0x2dfab3['count']=_0x4e6eca;if(_0x1ec73a['query'][_0x4e13('0x40')]){_0x584e1c[_0x4e13('0x41')]=[{'all':!![]}];}return db[_0x4e13('0x2e')][_0x4e13('0x42')](_0x584e1c);})[_0x4e13('0x22')](function(_0x3d2800){_0x2dfab3[_0x4e13('0x43')]=_0x3d2800;return _0x2dfab3;})[_0x4e13('0x22')](respondWithFilteredResult(_0x33e7d4,_0x584e1c))['catch'](handleError(_0x33e7d4,null));};exports[_0x4e13('0x44')]=function(_0x2becb5,_0x3592fa){var _0x4f50dd={'raw':!![],'where':{'id':_0x2becb5[_0x4e13('0x45')]['id']}},_0x204924={};_0x204924[_0x4e13('0x30')]=_[_0x4e13('0x31')](db['Variable'][_0x4e13('0x46')]);_0x204924[_0x4e13('0x34')]=_[_0x4e13('0x31')](_0x2becb5[_0x4e13('0x34')]);_0x204924[_0x4e13('0x32')]=_[_0x4e13('0x33')](_0x204924['model'],_0x204924[_0x4e13('0x34')]);_0x4f50dd[_0x4e13('0x35')]=_[_0x4e13('0x33')](_0x204924['model'],qs[_0x4e13('0x36')](_0x2becb5[_0x4e13('0x34')][_0x4e13('0x36')]));_0x4f50dd[_0x4e13('0x35')]=_0x4f50dd['attributes'][_0x4e13('0x37')]?_0x4f50dd[_0x4e13('0x35')]:_0x204924[_0x4e13('0x30')];if(_0x2becb5[_0x4e13('0x34')][_0x4e13('0x40')]){_0x4f50dd[_0x4e13('0x41')]=[{'all':!![]}];}_0x4f50dd=_['merge']({},_0x4f50dd,_0x2becb5['options']);return db[_0x4e13('0x2e')][_0x4e13('0x47')](_0x4f50dd)[_0x4e13('0x22')](handleEntityNotFound(_0x3592fa,null))[_0x4e13('0x22')](respondWithResult(_0x3592fa,null))[_0x4e13('0x48')](handleError(_0x3592fa,null));};exports['create']=function(_0x2d7983,_0x16eb4d){return db['Variable'][_0x4e13('0x49')](_0x2d7983[_0x4e13('0x4a')],{})[_0x4e13('0x22')](function(_0x1507bc){var _0x177c74=_0x2d7983[_0x4e13('0x4b')][_0x4e13('0x24')]({'plain':!![]});if(!_0x177c74)throw new Error(_0x4e13('0x4c'));if(_0x177c74['role']==='user'){var _0x2bf97d=_0x1507bc[_0x4e13('0x24')]({'plain':!![]});var _0x2355ce=_0x4e13('0x25');return db[_0x4e13('0x4d')][_0x4e13('0x47')]({'where':{'name':_0x2355ce,'userProfileId':_0x177c74[_0x4e13('0x4e')]},'raw':!![]})[_0x4e13('0x22')](function(_0x4d19a2){if(_0x4d19a2&&_0x4d19a2[_0x4e13('0x4f')]===0x0){return db[_0x4e13('0x26')][_0x4e13('0x49')]({'name':_0x2bf97d[_0x4e13('0x2a')],'resourceId':_0x2bf97d['id'],'type':_0x4d19a2['name'],'sectionId':_0x4d19a2['id']},{})[_0x4e13('0x22')](function(){return _0x1507bc;});}else{return _0x1507bc;}})[_0x4e13('0x48')](function(_0x19d009){logger[_0x4e13('0x28')](_0x4e13('0x50'),_0x19d009);throw _0x19d009;});}return _0x1507bc;})[_0x4e13('0x22')](respondWithResult(_0x16eb4d,0xc9))['catch'](handleError(_0x16eb4d,null));};exports[_0x4e13('0x21')]=function(_0x1ceb29,_0x4198a8){if(_0x1ceb29[_0x4e13('0x4a')]['id']){delete _0x1ceb29[_0x4e13('0x4a')]['id'];}return db[_0x4e13('0x2e')][_0x4e13('0x47')]({'where':{'id':_0x1ceb29[_0x4e13('0x45')]['id']}})[_0x4e13('0x22')](handleEntityNotFound(_0x4198a8,null))[_0x4e13('0x22')](saveUpdates(_0x1ceb29[_0x4e13('0x4a')],null))[_0x4e13('0x22')](respondWithResult(_0x4198a8,null))['catch'](handleError(_0x4198a8,null));};exports[_0x4e13('0x23')]=function(_0x2c82ff,_0x3aab7e){return db[_0x4e13('0x2e')][_0x4e13('0x47')]({'where':{'id':_0x2c82ff['params']['id']}})[_0x4e13('0x22')](handleEntityNotFound(_0x3aab7e,null))[_0x4e13('0x22')](removeEntity(_0x3aab7e,null))[_0x4e13('0x48')](handleError(_0x3aab7e,null));}; \ No newline at end of file diff --git a/server/api/variable/variable.model.js b/server/api/variable/variable.model.js new file mode 100644 index 0000000..9eee38d --- /dev/null +++ b/server/api/variable/variable.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb0d5=['../../config/logger','api','moment','bluebird','request-promise','path','tools_variables','lodash','util'];(function(_0xc8a931,_0x260690){var _0x28bd27=function(_0x591b9f){while(--_0x591b9f){_0xc8a931['push'](_0xc8a931['shift']());}};_0x28bd27(++_0x260690);}(_0xb0d5,0x18a));var _0x5b0d=function(_0x2e612a,_0x106dd7){_0x2e612a=_0x2e612a-0x0;var _0x3cb97c=_0xb0d5[_0x2e612a];return _0x3cb97c;};'use strict';var _=require(_0x5b0d('0x0'));var util=require(_0x5b0d('0x1'));var logger=require(_0x5b0d('0x2'))(_0x5b0d('0x3'));var moment=require(_0x5b0d('0x4'));var BPromise=require(_0x5b0d('0x5'));var rp=require(_0x5b0d('0x6'));var fs=require('fs');var path=require(_0x5b0d('0x7'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require('./variable.attributes');module['exports']=function(_0x42f98d,_0x1be8a8){return _0x42f98d['define']('Variable',attributes,{'tableName':_0x5b0d('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/variable/variable.rpc.js b/server/api/variable/variable.rpc.js new file mode 100644 index 0000000..0541d8c --- /dev/null +++ b/server/api/variable/variable.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5fc3=['info','request\x20sent','debug','stringify','error','code','message','Variable,\x20%s,\x20%s','result','catch','ShowVariable','find','options','where','attributes','include','map','model','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','request','then'];(function(_0x2d2949,_0x24c559){var _0x4bb11f=function(_0x2a75d7){while(--_0x2a75d7){_0x2d2949['push'](_0x2d2949['shift']());}};_0x4bb11f(++_0x24c559);}(_0x5fc3,0xa8));var _0x35fc=function(_0x1992f1,_0x5c61f0){_0x1992f1=_0x1992f1-0x0;var _0x413dfe=_0x5fc3[_0x1992f1];return _0x413dfe;};'use strict';var _=require(_0x35fc('0x0'));var util=require(_0x35fc('0x1'));var moment=require('moment');var BPromise=require(_0x35fc('0x2'));var rs=require(_0x35fc('0x3'));var fs=require('fs');var Redis=require(_0x35fc('0x4'));var db=require(_0x35fc('0x5'))['db'];var utils=require(_0x35fc('0x6'));var logger=require('../../config/logger')(_0x35fc('0x7'));var config=require(_0x35fc('0x8'));var jayson=require(_0x35fc('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x19a0d1,_0x508b32,_0x16e153){return new BPromise(function(_0x27524f,_0xc72d93){return client[_0x35fc('0xa')](_0x19a0d1,_0x16e153)[_0x35fc('0xb')](function(_0xf9d3a6){logger[_0x35fc('0xc')]('Variable,\x20%s,\x20%s',_0x508b32,_0x35fc('0xd'));logger[_0x35fc('0xe')]('Variable,\x20%s,\x20%s,\x20%s',_0x508b32,_0x35fc('0xd'),JSON[_0x35fc('0xf')](_0xf9d3a6));if(_0xf9d3a6['error']){if(_0xf9d3a6[_0x35fc('0x10')][_0x35fc('0x11')]===0x1f4){logger['error']('Variable,\x20%s,\x20%s',_0x508b32,_0xf9d3a6[_0x35fc('0x10')]['message']);return _0xc72d93(_0xf9d3a6[_0x35fc('0x10')][_0x35fc('0x12')]);}logger[_0x35fc('0x10')](_0x35fc('0x13'),_0x508b32,_0xf9d3a6[_0x35fc('0x10')]['message']);return _0x27524f(_0xf9d3a6['error']['message']);}else{logger['info'](_0x35fc('0x13'),_0x508b32,_0x35fc('0xd'));_0x27524f(_0xf9d3a6[_0x35fc('0x14')][_0x35fc('0x12')]);}})[_0x35fc('0x15')](function(_0x1121fa){logger['error'](_0x35fc('0x13'),_0x508b32,_0x1121fa);_0xc72d93(_0x1121fa);});});}exports[_0x35fc('0x16')]=function(_0x553677){var _0x41e165=this;return new Promise(function(_0x363e47,_0x2e513b){return db['Variable'][_0x35fc('0x17')]({'raw':_0x553677[_0x35fc('0x18')]?_0x553677[_0x35fc('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x553677[_0x35fc('0x18')]?_0x553677[_0x35fc('0x18')][_0x35fc('0x19')]||null:null,'attributes':_0x553677[_0x35fc('0x18')]?_0x553677[_0x35fc('0x18')][_0x35fc('0x1a')]||null:null,'include':_0x553677[_0x35fc('0x18')]?_0x553677[_0x35fc('0x18')][_0x35fc('0x1b')]?_[_0x35fc('0x1c')](_0x553677['options'][_0x35fc('0x1b')],function(_0xd5399f){return{'model':db[_0xd5399f[_0x35fc('0x1d')]],'as':_0xd5399f['as'],'attributes':_0xd5399f[_0x35fc('0x1a')],'include':_0xd5399f[_0x35fc('0x1b')]?_['map'](_0xd5399f[_0x35fc('0x1b')],function(_0x4c587a){return{'model':db[_0x4c587a['model']],'as':_0x4c587a['as'],'attributes':_0x4c587a[_0x35fc('0x1a')],'include':_0x4c587a[_0x35fc('0x1b')]?_[_0x35fc('0x1c')](_0x4c587a['include'],function(_0x4086e9){return{'model':db[_0x4086e9['model']],'as':_0x4086e9['as'],'attributes':_0x4086e9[_0x35fc('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x35fc('0xb')](function(_0x5cb986){logger['info'](_0x35fc('0x16'),_0x553677);logger['debug'](_0x35fc('0x16'),_0x553677,JSON[_0x35fc('0xf')](_0x5cb986));_0x363e47(_0x5cb986);})['catch'](function(_0x26b7cb){logger[_0x35fc('0x10')](_0x35fc('0x16'),_0x26b7cb[_0x35fc('0x12')],_0x553677);_0x2e513b(_0x41e165[_0x35fc('0x10')](0x1f4,_0x26b7cb[_0x35fc('0x12')]));});});}; \ No newline at end of file diff --git a/server/api/version/index.js b/server/api/version/index.js new file mode 100644 index 0000000..67cfb15 --- /dev/null +++ b/server/api/version/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe5a7=['index','/fetch','isAuthenticated','fetch','/reset','canUpdate','reset','/pull','pull','/migrations','migrations','exports','./version.controller','get'];(function(_0x3c3e72,_0x3e1858){var _0x48a7e5=function(_0x3d1c72){while(--_0x3d1c72){_0x3c3e72['push'](_0x3c3e72['shift']());}};_0x48a7e5(++_0x3e1858);}(_0xe5a7,0xa6));var _0x7e5a=function(_0x311c35,_0x534915){_0x311c35=_0x311c35-0x0;var _0x5cc50c=_0xe5a7[_0x311c35];return _0x5cc50c;};'use strict';var express=require('express');var router=express['Router']();var auth=require('../../components/auth/service');var controller=require(_0x7e5a('0x0'));router[_0x7e5a('0x1')]('/',controller[_0x7e5a('0x2')]);router['get'](_0x7e5a('0x3'),auth[_0x7e5a('0x4')](),auth['canUpdate'](),controller[_0x7e5a('0x5')]);router[_0x7e5a('0x1')](_0x7e5a('0x6'),auth[_0x7e5a('0x4')](),auth[_0x7e5a('0x7')](),controller[_0x7e5a('0x8')]);router[_0x7e5a('0x1')](_0x7e5a('0x9'),auth['isAuthenticated'](),auth[_0x7e5a('0x7')](),controller[_0x7e5a('0xa')]);router['get']('/restart',auth['isAuthenticated'](),controller['restart']);router['get'](_0x7e5a('0xb'),controller[_0x7e5a('0xc')]);module[_0x7e5a('0xd')]=router; \ No newline at end of file diff --git a/server/api/version/version.controller.js b/server/api/version/version.controller.js new file mode 100644 index 0000000..aca98f5 --- /dev/null +++ b/server/api/version/version.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2c5f=['length','.js','push','Migration','sequelize','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','map','then','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','path','pkginfo','compare-versions','exec','../../mysqldb','../../config/logger','simple-git','root','index','exports','version','query','latest','fetch','status','json','origin','master','error','info','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','pull','restart','motion2','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','join','server'];(function(_0x1e243a,_0x412fd0){var _0x561939=function(_0x25b5f8){while(--_0x25b5f8){_0x1e243a['push'](_0x1e243a['shift']());}};_0x561939(++_0x412fd0);}(_0x2c5f,0x9e));var _0xf2c5=function(_0x5627e1,_0x1b2dbf){_0x5627e1=_0x5627e1-0x0;var _0x2f013f=_0x2c5f[_0x5627e1];return _0x2f013f;};'use strict';var Umzug=require('umzug');var path=require(_0xf2c5('0x0'));var fs=require('fs');var _=require('lodash');var pkginfo=require(_0xf2c5('0x1'))(module,'version');var compareVersions=require(_0xf2c5('0x2'));var exec=require('child_process')[_0xf2c5('0x3')];var db=require(_0xf2c5('0x4'))['db'];var config=require('../../config/environment');var pm2=require('../../config/pm2');var logger=require(_0xf2c5('0x5'))('update');var git=require(_0xf2c5('0x6'))(config[_0xf2c5('0x7')]);exports[_0xf2c5('0x8')]=function(_0x26baa0,_0x21d3d7){var _0x2e2369={'current':module[_0xf2c5('0x9')][_0xf2c5('0xa')],'phonebar':0x2};if(_0x26baa0[_0xf2c5('0xb')]&&_0x26baa0['query'][_0xf2c5('0xc')]){return git[_0xf2c5('0xd')]()['tags'](function(_0x452eae,_0x126510){_0x2e2369[_0xf2c5('0xc')]=(_0x452eae?module[_0xf2c5('0x9')][_0xf2c5('0xa')]:_0x126510[_0xf2c5('0xc')])||'2.0.0';return _0x21d3d7[_0xf2c5('0xe')](0xc8)[_0xf2c5('0xf')](_0x2e2369);});}else{return _0x21d3d7[_0xf2c5('0xe')](0xc8)['json'](_0x2e2369);}};exports[_0xf2c5('0xd')]=function(_0x2b967a,_0xff535){return git[_0xf2c5('0xd')]([_0xf2c5('0x10'),_0xf2c5('0x11')],function(_0x4b9fc0){if(_0x4b9fc0){logger[_0xf2c5('0x12')](_0x4b9fc0);return _0xff535[_0xf2c5('0xe')](0x1f4)[_0xf2c5('0xf')](_0x4b9fc0);}logger[_0xf2c5('0x13')]('git\x20fetch');return _0xff535[_0xf2c5('0xe')](0xc8)['json']({'output':_0xf2c5('0x14')});});};exports[_0xf2c5('0x15')]=function(_0x41d47f,_0xbe22c){return git[_0xf2c5('0x15')]([_0xf2c5('0x16'),_0xf2c5('0x17')],function(_0xb2defc){if(_0xb2defc){logger[_0xf2c5('0x12')](_0xb2defc);return _0xbe22c['status'](0x1f4)[_0xf2c5('0xf')](_0xb2defc);}logger[_0xf2c5('0x13')](_0xf2c5('0x18'));return _0xbe22c[_0xf2c5('0xe')](0xc8)[_0xf2c5('0xf')]({'output':_0xf2c5('0x19')});});};exports[_0xf2c5('0x1a')]=function(_0x4cbb56,_0x3a9b12){exec('npm\x20install\x20--production',function(_0x5143cc,_0x3a01c0,_0x4aeeb6){logger[_0xf2c5('0x13')](_0x3a01c0);logger[_0xf2c5('0x13')](_0x4aeeb6);if(_0x5143cc){logger[_0xf2c5('0x12')](_0x5143cc);return _0x3a9b12[_0xf2c5('0xe')](0x1f4)['json'](_0x5143cc);}return _0x3a9b12[_0xf2c5('0xe')](0xc8)[_0xf2c5('0xf')]({'output':_0x3a01c0});});};exports[_0xf2c5('0x1b')]=function(_0x5d5449,_0x22df07){return pm2[_0xf2c5('0x1b')](_0xf2c5('0x1c'))['then'](function(_0x277680){logger[_0xf2c5('0x13')]('pm2\x20restart\x20motion\x20%s',_0x277680);return _0x22df07[_0xf2c5('0xe')](0xc8)['json']({'output':_0xf2c5('0x1d')});})[_0xf2c5('0x1e')](function(_0x14341b){logger[_0xf2c5('0x12')](_0x14341b);return _0x22df07[_0xf2c5('0xe')](0x1f4)['json'](_0x14341b);});};exports[_0xf2c5('0x1f')]=function(_0x34e9f1,_0x19482b){var _0x345462=fs['readdirSync'](path[_0xf2c5('0x20')](config[_0xf2c5('0x7')],_0xf2c5('0x21'),'migrations'));var _0x52188e=[];for(var _0x157488=0x0;_0x157488<_0x345462[_0xf2c5('0x22')];_0x157488++){var _0x38fb36=_0x345462[_0x157488]['replace'](_0xf2c5('0x23'),'');if(compareVersions(module[_0xf2c5('0x9')][_0xf2c5('0xa')],_0x38fb36)===-0x1){_0x52188e[_0xf2c5('0x24')](_0x38fb36);}}if(_0x52188e[_0xf2c5('0x22')]){var _0xb9e661=_0x52188e['sort'](compareVersions);var _0x2f2028=new Umzug({'storage':'sequelize','storageOptions':{'model':db[_0xf2c5('0x25')],'modelName':_0xf2c5('0x25'),'columnName':_0xf2c5('0xa')},'migrations':{'params':[db[_0xf2c5('0x26')]['getQueryInterface'](),db[_0xf2c5('0x26')][_0xf2c5('0x27')],function(){throw new Error(_0xf2c5('0x28'));}],'path':path['join'](config[_0xf2c5('0x7')],'server',_0xf2c5('0x1f')),'pattern':/\.js$/}});_0x2f2028['up']({'migrations':_[_0xf2c5('0x29')](_0xb9e661,function(_0x3888a7){return _0x3888a7+_0xf2c5('0x23');})})[_0xf2c5('0x2a')](function(){return _0x19482b[_0xf2c5('0xe')](0xc8)['json']({'output':_0xf2c5('0x2b')+module[_0xf2c5('0x9')][_0xf2c5('0xa')]+_0xf2c5('0x2c')+_[_0xf2c5('0x2d')](_0xb9e661),'migrations':_[_0xf2c5('0x20')](_0xb9e661)});})[_0xf2c5('0x1e')](function(_0x29a35a){if(_0x29a35a instanceof db[_0xf2c5('0x26')][_0xf2c5('0x2e')]){return _0x19482b[_0xf2c5('0xe')](0xc8)[_0xf2c5('0xf')]({'output':_0xf2c5('0x2f')});}else{return _0x19482b['status'](0x1f4)[_0xf2c5('0xf')](_0x29a35a);}});}else{return _0x19482b[_0xf2c5('0xe')](0xc8)[_0xf2c5('0xf')]({'output':_0xf2c5('0x2f')});}}; \ No newline at end of file diff --git a/server/api/voiceAgentReport/index.js b/server/api/voiceAgentReport/index.js new file mode 100644 index 0000000..afcf71b --- /dev/null +++ b/server/api/voiceAgentReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x496a=['./voiceAgentReport.controller','get','isAuthenticated','index','/describe','describe','/:id','post','create','put','update','delete','destroy','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment'];(function(_0x357444,_0x5bb343){var _0x41a0e2=function(_0x2e0244){while(--_0x2e0244){_0x357444['push'](_0x357444['shift']());}};_0x41a0e2(++_0x5bb343);}(_0x496a,0x17d));var _0xa496=function(_0x36844a,_0x3bcf46){_0x36844a=_0x36844a-0x0;var _0xbab229=_0x496a[_0x36844a];return _0xbab229;};'use strict';var multer=require(_0xa496('0x0'));var util=require(_0xa496('0x1'));var path=require(_0xa496('0x2'));var timeout=require(_0xa496('0x3'));var express=require(_0xa496('0x4'));var router=express[_0xa496('0x5')]();var fs_extra=require(_0xa496('0x6'));var auth=require(_0xa496('0x7'));var interaction=require(_0xa496('0x8'));var config=require(_0xa496('0x9'));var controller=require(_0xa496('0xa'));router[_0xa496('0xb')]('/',auth[_0xa496('0xc')](),controller[_0xa496('0xd')]);router[_0xa496('0xb')](_0xa496('0xe'),auth['isAuthenticated'](),controller[_0xa496('0xf')]);router['get'](_0xa496('0x10'),auth[_0xa496('0xc')](),controller['show']);router[_0xa496('0x11')]('/',auth[_0xa496('0xc')](),controller[_0xa496('0x12')]);router[_0xa496('0x13')](_0xa496('0x10'),auth[_0xa496('0xc')](),controller[_0xa496('0x14')]);router[_0xa496('0x15')](_0xa496('0x10'),auth[_0xa496('0xc')](),controller[_0xa496('0x16')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/voiceAgentReport/voiceAgentReport.attributes.js b/server/api/voiceAgentReport/voiceAgentReport.attributes.js new file mode 100644 index 0000000..56584ed --- /dev/null +++ b/server/api/voiceAgentReport/voiceAgentReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x282b=['STRING','DATE','INTEGER','BOOLEAN','FORWARD,\x20BLIND,\x20ATTENDED','sequelize','exports'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0x282b,0xec));var _0xb282=function(_0x48b9d5,_0x191b27){_0x48b9d5=_0x48b9d5-0x0;var _0x4739c3=_0x282b[_0x48b9d5];return _0x4739c3;};'use strict';var Sequelize=require(_0xb282('0x0'));module[_0xb282('0x1')]={'type':{'type':Sequelize[_0xb282('0x2')]},'uniqueid':{'type':Sequelize[_0xb282('0x2')]},'calleridnum':{'type':Sequelize[_0xb282('0x2')]},'calleridname':{'type':Sequelize['STRING']},'queue':{'type':Sequelize['STRING']},'interface':{'type':Sequelize[_0xb282('0x2')]},'membername':{'type':Sequelize['STRING']},'agentcalledAt':{'type':Sequelize[_0xb282('0x3')]},'agentconnectAt':{'type':Sequelize[_0xb282('0x3')]},'agentcompleteAt':{'type':Sequelize[_0xb282('0x3')]},'agentringnoanswerAt':{'type':Sequelize[_0xb282('0x3')]},'agentdumpAt':{'type':Sequelize[_0xb282('0x3')]},'holdtime':{'type':Sequelize[_0xb282('0x4')]},'agentcomplete':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'agentringnoanswer':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'agentdump':{'type':Sequelize[_0xb282('0x5')],'defaultValue':![]},'talktime':{'type':Sequelize[_0xb282('0x4')]},'agentacw':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'acwtime':{'type':Sequelize[_0xb282('0x4')]},'reason':{'type':Sequelize[_0xb282('0x2')]},'lastevent':{'type':Sequelize[_0xb282('0x2')]},'channel':{'type':Sequelize[_0xb282('0x2')]},'channelstate':{'type':Sequelize['INTEGER']},'channelstatedesc':{'type':Sequelize['STRING']},'connectedlinenum':{'type':Sequelize[_0xb282('0x2')]},'connectedlinename':{'type':Sequelize[_0xb282('0x2')]},'language':{'type':Sequelize[_0xb282('0x2')]},'accountcode':{'type':Sequelize[_0xb282('0x2')]},'context':{'type':Sequelize[_0xb282('0x2')]},'exten':{'type':Sequelize['STRING']},'priority':{'type':Sequelize['STRING']},'destchannel':{'type':Sequelize[_0xb282('0x2')]},'destchannelstate':{'type':Sequelize[_0xb282('0x4')]},'destchannelstatedesc':{'type':Sequelize[_0xb282('0x2')]},'destcalleridnum':{'type':Sequelize[_0xb282('0x2')]},'destcalleridname':{'type':Sequelize[_0xb282('0x2')]},'destconnectedlinenum':{'type':Sequelize['STRING']},'destconnectedlinename':{'type':Sequelize[_0xb282('0x2')]},'destlanguage':{'type':Sequelize['STRING']},'destaccountcode':{'type':Sequelize[_0xb282('0x2')]},'destcontext':{'type':Sequelize[_0xb282('0x2')]},'destexten':{'type':Sequelize['STRING']},'destpriority':{'type':Sequelize['STRING']},'destuniqueid':{'type':Sequelize['STRING']},'answeredelsewheredestinationuniqueid':{'type':Sequelize[_0xb282('0x2')]},'answeredelsewheremembername':{'type':Sequelize[_0xb282('0x2')]},'transfer':{'type':Sequelize[_0xb282('0x5')],'defaultValue':![]},'transfertype':{'type':Sequelize[_0xb282('0x2')],'comment':_0xb282('0x6')},'transferexten':{'type':Sequelize['STRING']},'transferuniqueid':{'type':Sequelize[_0xb282('0x2')]},'agententerreason':{'type':Sequelize[_0xb282('0x4')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/voiceAgentReport/voiceAgentReport.controller.js b/server/api/voiceAgentReport/voiceAgentReport.controller.js new file mode 100644 index 0000000..6b203c2 --- /dev/null +++ b/server/api/voiceAgentReport/voiceAgentReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['type','options','includeAll','include','findAll','catch','show','params','find','body','describe','eml-format','rimraf','zip-dir','moment','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','sendStatus','end','status','json','undefined','limit','offset','count','set','Content-Range','apply','save','update','then','destroy','stack','name','send','index','VoiceAgentReport','rawAttributes','fieldName','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filter','merge'];(function(_0x5a3cf0,_0x160a68){var _0x5a64ee=function(_0x34cd1d){while(--_0x34cd1d){_0x5a3cf0['push'](_0x5a3cf0['shift']());}};_0x5a64ee(++_0x160a68);}(_0xa9e0,0x123));var _0x0a9e=function(_0xae7c2f,_0xf31e04){_0xae7c2f=_0xae7c2f-0x0;var _0x5d7001=_0xa9e0[_0xae7c2f];return _0x5d7001;};'use strict';var emlformat=require(_0x0a9e('0x0'));var rimraf=require(_0x0a9e('0x1'));var zipdir=require(_0x0a9e('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0a9e('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x0a9e('0x4'));var util=require(_0x0a9e('0x5'));var path=require(_0x0a9e('0x6'));var sox=require(_0x0a9e('0x7'));var csv=require(_0x0a9e('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0a9e('0x9'));var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];function respondWithStatusCode(_0xd5b662,_0x26d672){_0x26d672=_0x26d672||0xcc;return function(_0x32d742){if(_0x32d742){return _0xd5b662[_0x0a9e('0x15')](_0x26d672);}return _0xd5b662['status'](_0x26d672)[_0x0a9e('0x16')]();};}function respondWithResult(_0x239b12,_0x2b4227){_0x2b4227=_0x2b4227||0xc8;return function(_0x281129){if(_0x281129){return _0x239b12[_0x0a9e('0x17')](_0x2b4227)[_0x0a9e('0x18')](_0x281129);}};}function respondWithFilteredResult(_0x52a03d,_0x22dccb){return function(_0x5d0880){if(_0x5d0880){var _0x1985b6=typeof _0x22dccb['offset']===_0x0a9e('0x19')&&typeof _0x22dccb[_0x0a9e('0x1a')]==='undefined';var _0x225616=_0x5d0880['count'];var _0x459eb1=_0x1985b6?0x0:_0x22dccb[_0x0a9e('0x1b')];var _0x106033=_0x1985b6?_0x5d0880[_0x0a9e('0x1c')]:_0x22dccb[_0x0a9e('0x1b')]+_0x22dccb[_0x0a9e('0x1a')];var _0x530eb7;if(_0x106033>=_0x225616){_0x106033=_0x225616;_0x530eb7=0xc8;}else{_0x530eb7=0xce;}_0x52a03d[_0x0a9e('0x17')](_0x530eb7);return _0x52a03d[_0x0a9e('0x1d')](_0x0a9e('0x1e'),_0x459eb1+'-'+_0x106033+'/'+_0x225616)[_0x0a9e('0x18')](_0x5d0880);}return null;};}function patchUpdates(_0x105080){return function(_0x4bb1e3){try{jsonpatch[_0x0a9e('0x1f')](_0x4bb1e3,_0x105080,!![]);}catch(_0x155cce){return BPromise['reject'](_0x155cce);}return _0x4bb1e3[_0x0a9e('0x20')]();};}function saveUpdates(_0x5a09ef,_0x588269){return function(_0x3a02e1){if(_0x3a02e1){return _0x3a02e1[_0x0a9e('0x21')](_0x5a09ef)[_0x0a9e('0x22')](function(_0x30bae6){return _0x30bae6;});}return null;};}function removeEntity(_0x4abc77,_0xfb6e48){return function(_0x2fb0e4){if(_0x2fb0e4){return _0x2fb0e4[_0x0a9e('0x23')]()[_0x0a9e('0x22')](function(){_0x4abc77[_0x0a9e('0x17')](0xcc)[_0x0a9e('0x16')]();});}};}function handleEntityNotFound(_0x16b1ca,_0x5ea472){return function(_0x59181e){if(!_0x59181e){_0x16b1ca[_0x0a9e('0x15')](0x194);}return _0x59181e;};}function handleError(_0x3a8e58,_0x40c424){_0x40c424=_0x40c424||0x1f4;return function(_0x33161b){logger['error'](_0x33161b[_0x0a9e('0x24')]);if(_0x33161b['name']){delete _0x33161b[_0x0a9e('0x25')];}_0x3a8e58['status'](_0x40c424)[_0x0a9e('0x26')](_0x33161b);};}exports[_0x0a9e('0x27')]=function(_0x25fba9,_0x14433c){var _0x140511={},_0x1538a4={},_0x11c3b6={'count':0x0,'rows':[]};var _0x14de77=_['map'](db[_0x0a9e('0x28')][_0x0a9e('0x29')],function(_0x2b1f27){return{'name':_0x2b1f27[_0x0a9e('0x2a')],'type':_0x2b1f27['type'][_0x0a9e('0x2b')]};});_0x1538a4[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x14de77,_0x0a9e('0x25'));_0x1538a4[_0x0a9e('0x2e')]=_[_0x0a9e('0x2f')](_0x25fba9[_0x0a9e('0x2e')]);_0x1538a4[_0x0a9e('0x30')]=_[_0x0a9e('0x31')](_0x1538a4['model'],_0x1538a4[_0x0a9e('0x2e')]);_0x140511['attributes']=_[_0x0a9e('0x31')](_0x1538a4[_0x0a9e('0x2c')],qs[_0x0a9e('0x32')](_0x25fba9[_0x0a9e('0x2e')][_0x0a9e('0x32')]));_0x140511['attributes']=_0x140511[_0x0a9e('0x33')][_0x0a9e('0x34')]?_0x140511[_0x0a9e('0x33')]:_0x1538a4[_0x0a9e('0x2c')];if(!_0x25fba9[_0x0a9e('0x2e')][_0x0a9e('0x35')](_0x0a9e('0x36'))){_0x140511[_0x0a9e('0x1a')]=qs['limit'](_0x25fba9[_0x0a9e('0x2e')]['limit']);_0x140511[_0x0a9e('0x1b')]=qs[_0x0a9e('0x1b')](_0x25fba9[_0x0a9e('0x2e')][_0x0a9e('0x1b')]);}_0x140511['order']=qs[_0x0a9e('0x37')](_0x25fba9[_0x0a9e('0x2e')][_0x0a9e('0x37')]);_0x140511[_0x0a9e('0x38')]=qs['filters'](_['pick'](_0x25fba9[_0x0a9e('0x2e')],_0x1538a4['filters']),_0x14de77);if(_0x25fba9[_0x0a9e('0x2e')][_0x0a9e('0x39')]){_0x140511[_0x0a9e('0x38')]=_[_0x0a9e('0x3a')](_0x140511['where'],{'$or':_[_0x0a9e('0x2d')](_0x14de77,function(_0x3bfce8){if(_0x3bfce8[_0x0a9e('0x3b')]!=='VIRTUAL'){var _0x1dbf74={};_0x1dbf74[_0x3bfce8[_0x0a9e('0x25')]]={'$like':'%'+_0x25fba9[_0x0a9e('0x2e')]['filter']+'%'};return _0x1dbf74;}})});}_0x140511=_['merge']({},_0x140511,_0x25fba9[_0x0a9e('0x3c')]);var _0x40d766={'where':_0x140511['where']};return db[_0x0a9e('0x28')][_0x0a9e('0x1c')](_0x40d766)[_0x0a9e('0x22')](function(_0x148f55){_0x11c3b6['count']=_0x148f55;if(_0x25fba9['query'][_0x0a9e('0x3d')]){_0x140511[_0x0a9e('0x3e')]=[{'all':!![]}];}return db['VoiceAgentReport'][_0x0a9e('0x3f')](_0x140511);})[_0x0a9e('0x22')](function(_0x1459bb){_0x11c3b6['rows']=_0x1459bb;return _0x11c3b6;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x14433c,_0x140511))[_0x0a9e('0x40')](handleError(_0x14433c,null));};exports[_0x0a9e('0x41')]=function(_0x43dd5b,_0x13cb1f){var _0xeaa5e5={'raw':![],'where':{'id':_0x43dd5b[_0x0a9e('0x42')]['id']}},_0x2881b3={};_0x2881b3[_0x0a9e('0x2c')]=_[_0x0a9e('0x2f')](db[_0x0a9e('0x28')][_0x0a9e('0x29')]);_0x2881b3[_0x0a9e('0x2e')]=_[_0x0a9e('0x2f')](_0x43dd5b[_0x0a9e('0x2e')]);_0x2881b3['filters']=_['intersection'](_0x2881b3[_0x0a9e('0x2c')],_0x2881b3[_0x0a9e('0x2e')]);_0xeaa5e5[_0x0a9e('0x33')]=_[_0x0a9e('0x31')](_0x2881b3[_0x0a9e('0x2c')],qs[_0x0a9e('0x32')](_0x43dd5b[_0x0a9e('0x2e')][_0x0a9e('0x32')]));_0xeaa5e5[_0x0a9e('0x33')]=_0xeaa5e5[_0x0a9e('0x33')][_0x0a9e('0x34')]?_0xeaa5e5[_0x0a9e('0x33')]:_0x2881b3['model'];if(_0x43dd5b[_0x0a9e('0x2e')][_0x0a9e('0x3d')]){_0xeaa5e5[_0x0a9e('0x3e')]=[{'all':!![]}];}_0xeaa5e5=_[_0x0a9e('0x3a')]({},_0xeaa5e5,_0x43dd5b[_0x0a9e('0x3c')]);return db[_0x0a9e('0x28')][_0x0a9e('0x43')](_0xeaa5e5)[_0x0a9e('0x22')](handleEntityNotFound(_0x13cb1f,null))['then'](respondWithResult(_0x13cb1f,null))[_0x0a9e('0x40')](handleError(_0x13cb1f,null));};exports['create']=function(_0x473dc8,_0x476688){return db[_0x0a9e('0x28')]['create'](_0x473dc8[_0x0a9e('0x44')],{})[_0x0a9e('0x22')](respondWithResult(_0x476688,0xc9))[_0x0a9e('0x40')](handleError(_0x476688,null));};exports[_0x0a9e('0x21')]=function(_0x45c845,_0x37be73){if(_0x45c845[_0x0a9e('0x44')]['id']){delete _0x45c845['body']['id'];}return db[_0x0a9e('0x28')][_0x0a9e('0x43')]({'where':{'id':_0x45c845[_0x0a9e('0x42')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x37be73,null))[_0x0a9e('0x22')](saveUpdates(_0x45c845[_0x0a9e('0x44')],null))[_0x0a9e('0x22')](respondWithResult(_0x37be73,null))[_0x0a9e('0x40')](handleError(_0x37be73,null));};exports[_0x0a9e('0x23')]=function(_0x58a5c2,_0xe401a){return db[_0x0a9e('0x28')]['find']({'where':{'id':_0x58a5c2['params']['id']}})['then'](handleEntityNotFound(_0xe401a,null))[_0x0a9e('0x22')](removeEntity(_0xe401a,null))[_0x0a9e('0x40')](handleError(_0xe401a,null));};exports[_0x0a9e('0x45')]=function(_0x11545a,_0x61bb17){return db[_0x0a9e('0x28')][_0x0a9e('0x45')]()[_0x0a9e('0x22')](respondWithResult(_0x61bb17,null))['catch'](handleError(_0x61bb17,null));}; \ No newline at end of file diff --git a/server/api/voiceAgentReport/voiceAgentReport.model.js b/server/api/voiceAgentReport/voiceAgentReport.model.js new file mode 100644 index 0000000..5b35b3d --- /dev/null +++ b/server/api/voiceAgentReport/voiceAgentReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1501=['path','rimraf','./voiceAgentReport.attributes','define','VoiceAgentReport','report_agent','uniqueid','destuniqueid','util','../../config/logger','api','bluebird','request-promise'];(function(_0x49f913,_0x12ccd8){var _0xf48ea5=function(_0xfd48b0){while(--_0xfd48b0){_0x49f913['push'](_0x49f913['shift']());}};_0xf48ea5(++_0x12ccd8);}(_0x1501,0x126));var _0x1150=function(_0x3ed0e4,_0x473e73){_0x3ed0e4=_0x3ed0e4-0x0;var _0x13d9ee=_0x1501[_0x3ed0e4];return _0x13d9ee;};'use strict';var _=require('lodash');var util=require(_0x1150('0x0'));var logger=require(_0x1150('0x1'))(_0x1150('0x2'));var moment=require('moment');var BPromise=require(_0x1150('0x3'));var rp=require(_0x1150('0x4'));var fs=require('fs');var path=require(_0x1150('0x5'));var rimraf=require(_0x1150('0x6'));var config=require('../../config/environment');var attributes=require(_0x1150('0x7'));module['exports']=function(_0x63c724,_0x316a7d){return _0x63c724[_0x1150('0x8')](_0x1150('0x9'),attributes,{'tableName':_0x1150('0xa'),'paranoid':![],'indexes':[{'fields':[_0x1150('0xb'),_0x1150('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceAgentReport/voiceAgentReport.rpc.js b/server/api/voiceAgentReport/voiceAgentReport.rpc.js new file mode 100644 index 0000000..6ccb997 --- /dev/null +++ b/server/api/voiceAgentReport/voiceAgentReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x99bb=['then','VoiceAgentReport,\x20%s,\x20%s','debug','VoiceAgentReport,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','info','catch','VoiceAgentReport','create','options','raw','CreateVoiceAgentReport','UpdateVoiceAgentReport','update','body','attributes','lodash','util','moment','bluebird','../../mysqldb','../../config/environment','client','request'];(function(_0x1c7586,_0x1d46bd){var _0x3bd9a1=function(_0x2f2d4d){while(--_0x2f2d4d){_0x1c7586['push'](_0x1c7586['shift']());}};_0x3bd9a1(++_0x1d46bd);}(_0x99bb,0x14a));var _0xb99b=function(_0x1bcf55,_0x3eefa4){_0x1bcf55=_0x1bcf55-0x0;var _0x30bf4c=_0x99bb[_0x1bcf55];return _0x30bf4c;};'use strict';var _=require(_0xb99b('0x0'));var util=require(_0xb99b('0x1'));var moment=require(_0xb99b('0x2'));var BPromise=require(_0xb99b('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb99b('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xb99b('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xb99b('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4a21a7,_0x5d150b,_0x5c87c2){return new BPromise(function(_0x56ea5f,_0x5ab2b7){return client[_0xb99b('0x7')](_0x4a21a7,_0x5c87c2)[_0xb99b('0x8')](function(_0x8b1cdb){logger['info'](_0xb99b('0x9'),_0x5d150b,'request\x20sent');logger[_0xb99b('0xa')](_0xb99b('0xb'),_0x5d150b,_0xb99b('0xc'),JSON['stringify'](_0x8b1cdb));if(_0x8b1cdb[_0xb99b('0xd')]){if(_0x8b1cdb['error']['code']===0x1f4){logger[_0xb99b('0xd')](_0xb99b('0x9'),_0x5d150b,_0x8b1cdb[_0xb99b('0xd')][_0xb99b('0xe')]);return _0x5ab2b7(_0x8b1cdb[_0xb99b('0xd')]['message']);}logger[_0xb99b('0xd')](_0xb99b('0x9'),_0x5d150b,_0x8b1cdb['error']['message']);return _0x56ea5f(_0x8b1cdb[_0xb99b('0xd')][_0xb99b('0xe')]);}else{logger[_0xb99b('0xf')](_0xb99b('0x9'),_0x5d150b,_0xb99b('0xc'));_0x56ea5f(_0x8b1cdb['result'][_0xb99b('0xe')]);}})[_0xb99b('0x10')](function(_0x4b7e3b){logger[_0xb99b('0xd')](_0xb99b('0x9'),_0x5d150b,_0x4b7e3b);_0x5ab2b7(_0x4b7e3b);});});}exports['CreateVoiceAgentReport']=function(_0x27391d){var _0x35e859=this;return new Promise(function(_0xb94620,_0x1e17ce){return db[_0xb99b('0x11')][_0xb99b('0x12')](_0x27391d['body'],{'raw':_0x27391d[_0xb99b('0x13')]?_0x27391d[_0xb99b('0x13')][_0xb99b('0x14')]===undefined?!![]:![]:!![]})[_0xb99b('0x8')](function(_0x14d08c){logger[_0xb99b('0xf')]('CreateVoiceAgentReport',_0x27391d);logger[_0xb99b('0xa')]('CreateVoiceAgentReport',_0x27391d,JSON['stringify'](_0x14d08c));_0xb94620(_0x14d08c);})[_0xb99b('0x10')](function(_0x5d90ed){logger[_0xb99b('0xd')](_0xb99b('0x15'),_0x5d90ed[_0xb99b('0xe')],_0x27391d);_0x1e17ce(_0x35e859[_0xb99b('0xd')](0x1f4,_0x5d90ed['message']));});});};exports[_0xb99b('0x16')]=function(_0x911442){var _0x156e95=this;return new Promise(function(_0x505f7e,_0x543ba0){return db[_0xb99b('0x11')][_0xb99b('0x17')](_0x911442[_0xb99b('0x18')],{'raw':_0x911442['options']?_0x911442[_0xb99b('0x13')][_0xb99b('0x14')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x911442[_0xb99b('0x13')]?_0x911442[_0xb99b('0x13')]['where']||null:null,'attributes':_0x911442[_0xb99b('0x13')]?_0x911442[_0xb99b('0x13')][_0xb99b('0x19')]||null:null,'limit':_0x911442[_0xb99b('0x13')]?_0x911442[_0xb99b('0x13')]['limit']||null:null})[_0xb99b('0x8')](function(_0x8a5bf0){logger['info']('UpdateVoiceAgentReport',_0x911442);logger[_0xb99b('0xa')](_0xb99b('0x16'),_0x911442,JSON['stringify'](_0x8a5bf0));_0x505f7e(_0x8a5bf0);})['catch'](function(_0x11c816){logger['error'](_0xb99b('0x16'),_0x11c816[_0xb99b('0xe')],_0x911442);_0x543ba0(_0x156e95[_0xb99b('0xd')](0x1f4,_0x11c816[_0xb99b('0xe')]));});});}; \ No newline at end of file diff --git a/server/api/voiceCallReport/index.js b/server/api/voiceCallReport/index.js new file mode 100644 index 0000000..ad21f30 --- /dev/null +++ b/server/api/voiceCallReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x46ed=['util','connect-timeout','express','Router','../../components/auth/service','../../components/interaction/service','./voiceCallReport.controller','get','isAuthenticated','index','/describe','describe','/:id','post','put','update','delete','destroy','multer'];(function(_0x11e2b0,_0x386c82){var _0x1b9672=function(_0x51096d){while(--_0x51096d){_0x11e2b0['push'](_0x11e2b0['shift']());}};_0x1b9672(++_0x386c82);}(_0x46ed,0x168));var _0xd46e=function(_0x46e363,_0x45d7e2){_0x46e363=_0x46e363-0x0;var _0x3fb059=_0x46ed[_0x46e363];return _0x3fb059;};'use strict';var multer=require(_0xd46e('0x0'));var util=require(_0xd46e('0x1'));var path=require('path');var timeout=require(_0xd46e('0x2'));var express=require(_0xd46e('0x3'));var router=express[_0xd46e('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0xd46e('0x5'));var interaction=require(_0xd46e('0x6'));var config=require('../../config/environment');var controller=require(_0xd46e('0x7'));router[_0xd46e('0x8')]('/',auth[_0xd46e('0x9')](),controller[_0xd46e('0xa')]);router[_0xd46e('0x8')](_0xd46e('0xb'),auth[_0xd46e('0x9')](),controller[_0xd46e('0xc')]);router[_0xd46e('0x8')](_0xd46e('0xd'),auth[_0xd46e('0x9')](),controller['show']);router[_0xd46e('0xe')]('/',auth[_0xd46e('0x9')](),controller['create']);router[_0xd46e('0xf')](_0xd46e('0xd'),auth[_0xd46e('0x9')](),controller[_0xd46e('0x10')]);router[_0xd46e('0x11')](_0xd46e('0xd'),auth['isAuthenticated'](),controller[_0xd46e('0x12')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/voiceCallReport/voiceCallReport.attributes.js b/server/api/voiceCallReport/voiceCallReport.attributes.js new file mode 100644 index 0000000..56ac657 --- /dev/null +++ b/server/api/voiceCallReport/voiceCallReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xed0b=['STRING','ENUM','inbound','outbound-fax','TEXT','DATE','INTEGER','sequelize'];(function(_0x135705,_0x1e4438){var _0x3cdb42=function(_0x4fe1bd){while(--_0x4fe1bd){_0x135705['push'](_0x135705['shift']());}};_0x3cdb42(++_0x1e4438);}(_0xed0b,0x15f));var _0xbed0=function(_0x20589d,_0x55d5bf){_0x20589d=_0x20589d-0x0;var _0x422de9=_0xed0b[_0x20589d];return _0x422de9;};'use strict';var Sequelize=require(_0xbed0('0x0'));module['exports']={'uniqueid':{'type':Sequelize[_0xbed0('0x1')]},'type':{'type':Sequelize[_0xbed0('0x2')](_0xbed0('0x3'),'internal','outbound','inbound-fax',_0xbed0('0x4'),'dialer')},'tag':{'type':Sequelize[_0xbed0('0x1')]},'accountcode':{'type':Sequelize['STRING']},'source':{'type':Sequelize['STRING']},'destination':{'type':Sequelize[_0xbed0('0x1')]},'destinationcontext':{'type':Sequelize[_0xbed0('0x1')]},'callerid':{'type':Sequelize[_0xbed0('0x1')]},'channel':{'type':Sequelize[_0xbed0('0x1')]},'destinationchannel':{'type':Sequelize[_0xbed0('0x1')]},'lastapplication':{'type':Sequelize['STRING']},'lastdata':{'type':Sequelize[_0xbed0('0x5')]},'starttime':{'type':Sequelize[_0xbed0('0x6')]},'systemanswertime':{'type':Sequelize[_0xbed0('0x6')]},'answertime':{'type':Sequelize[_0xbed0('0x6')]},'endtime':{'type':Sequelize[_0xbed0('0x6')]},'duration':{'type':Sequelize['INTEGER']},'billableseconds':{'type':Sequelize[_0xbed0('0x7')]},'mohtime':{'type':Sequelize[_0xbed0('0x7')],'defaultValue':0x0},'disposition':{'type':Sequelize[_0xbed0('0x1')]},'amaflags':{'type':Sequelize['STRING']},'userfield':{'type':Sequelize[_0xbed0('0x1')]},'userDisposition':{'type':Sequelize['STRING']},'userSecondDisposition':{'type':Sequelize[_0xbed0('0x1')]},'userThirdDisposition':{'type':Sequelize[_0xbed0('0x1')]},'note':{'type':Sequelize[_0xbed0('0x1')]},'prefix':{'type':Sequelize[_0xbed0('0x1')]},'routeid':{'type':Sequelize[_0xbed0('0x7')]},'sipcallid':{'type':Sequelize[_0xbed0('0x1')]}}; \ No newline at end of file diff --git a/server/api/voiceCallReport/voiceCallReport.controller.js b/server/api/voiceCallReport/voiceCallReport.controller.js new file mode 100644 index 0000000..ad389a3 --- /dev/null +++ b/server/api/voiceCallReport/voiceCallReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb10b=['desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','reject','update','then','destroy','end','error','stack','name','send','index','map','rawAttributes','fieldName','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','VIRTUAL','filter','merge','options','VoiceCallReport','includeAll','include','alias','User','rows','show','find','create','body','catch','params','describe','uniqueid','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce'];(function(_0x20765e,_0x4ef104){var _0x4a6213=function(_0x18cf51){while(--_0x18cf51){_0x20765e['push'](_0x20765e['shift']());}};_0x4a6213(++_0x4ef104);}(_0xb10b,0x12a));var _0xbb10=function(_0x213295,_0x465d81){_0x213295=_0x213295-0x0;var _0x43a797=_0xb10b[_0x213295];return _0x43a797;};'use strict';var emlformat=require(_0xbb10('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbb10('0x1'));var jsonpatch=require(_0xbb10('0x2'));var rp=require(_0xbb10('0x3'));var moment=require('moment');var BPromise=require(_0xbb10('0x4'));var Mustache=require(_0xbb10('0x5'));var util=require(_0xbb10('0x6'));var path=require(_0xbb10('0x7'));var sox=require(_0xbb10('0x8'));var csv=require(_0xbb10('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xbb10('0xa'));var _=require(_0xbb10('0xb'));var squel=require('squel');var crypto=require(_0xbb10('0xc'));var jsforce=require(_0xbb10('0xd'));var deskjs=require(_0xbb10('0xe'));var toCsv=require(_0xbb10('0x9'));var querystring=require(_0xbb10('0xf'));var Papa=require(_0xbb10('0x10'));var Redis=require(_0xbb10('0x11'));var authService=require(_0xbb10('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbb10('0x13'));var logger=require(_0xbb10('0x14'))(_0xbb10('0x15'));var utils=require('../../config/utils');var config=require(_0xbb10('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xbb10('0x17'))['db'];function respondWithStatusCode(_0x916a32,_0x285009){_0x285009=_0x285009||0xcc;return function(_0x193a27){if(_0x193a27){return _0x916a32[_0xbb10('0x18')](_0x285009);}return _0x916a32[_0xbb10('0x19')](_0x285009)['end']();};}function respondWithResult(_0x26e021,_0x42d7e4){_0x42d7e4=_0x42d7e4||0xc8;return function(_0x45b9d6){if(_0x45b9d6){return _0x26e021[_0xbb10('0x19')](_0x42d7e4)[_0xbb10('0x1a')](_0x45b9d6);}};}function respondWithFilteredResult(_0x2f2ebf,_0x24a57b){return function(_0x36b5e8){if(_0x36b5e8){var _0x3e26f4=typeof _0x24a57b[_0xbb10('0x1b')]==='undefined'&&typeof _0x24a57b[_0xbb10('0x1c')]===_0xbb10('0x1d');var _0x133ac2=_0x36b5e8[_0xbb10('0x1e')];var _0x378da8=_0x3e26f4?0x0:_0x24a57b[_0xbb10('0x1b')];var _0x575cca=_0x3e26f4?_0x36b5e8[_0xbb10('0x1e')]:_0x24a57b[_0xbb10('0x1b')]+_0x24a57b[_0xbb10('0x1c')];var _0x48b6e9;if(_0x575cca>=_0x133ac2){_0x575cca=_0x133ac2;_0x48b6e9=0xc8;}else{_0x48b6e9=0xce;}_0x2f2ebf[_0xbb10('0x19')](_0x48b6e9);return _0x2f2ebf[_0xbb10('0x1f')](_0xbb10('0x20'),_0x378da8+'-'+_0x575cca+'/'+_0x133ac2)[_0xbb10('0x1a')](_0x36b5e8);}return null;};}function patchUpdates(_0xdf237d){return function(_0x44e563){try{jsonpatch['apply'](_0x44e563,_0xdf237d,!![]);}catch(_0x12f888){return BPromise[_0xbb10('0x21')](_0x12f888);}return _0x44e563['save']();};}function saveUpdates(_0x4c4b0d,_0x8e2b97){return function(_0x311abe){if(_0x311abe){return _0x311abe[_0xbb10('0x22')](_0x4c4b0d)[_0xbb10('0x23')](function(_0x445761){return _0x445761;});}return null;};}function removeEntity(_0x1824b7,_0x407cb4){return function(_0x436104){if(_0x436104){return _0x436104[_0xbb10('0x24')]()[_0xbb10('0x23')](function(){_0x1824b7[_0xbb10('0x19')](0xcc)[_0xbb10('0x25')]();});}};}function handleEntityNotFound(_0x537898,_0x4fedac){return function(_0x4fb5e0){if(!_0x4fb5e0){_0x537898[_0xbb10('0x18')](0x194);}return _0x4fb5e0;};}function handleError(_0x3c5ae7,_0x2c89b9){_0x2c89b9=_0x2c89b9||0x1f4;return function(_0x4e25ff){logger[_0xbb10('0x26')](_0x4e25ff[_0xbb10('0x27')]);if(_0x4e25ff[_0xbb10('0x28')]){delete _0x4e25ff[_0xbb10('0x28')];}_0x3c5ae7[_0xbb10('0x19')](_0x2c89b9)[_0xbb10('0x29')](_0x4e25ff);};}exports[_0xbb10('0x2a')]=function(_0x4aabb9,_0x3796c7){var _0x21ac54={},_0xfc3595={},_0x2e0249={'count':0x0,'rows':[]};var _0x1d30aa=_[_0xbb10('0x2b')](db['VoiceCallReport'][_0xbb10('0x2c')],function(_0x4ee02e){return{'name':_0x4ee02e[_0xbb10('0x2d')],'type':_0x4ee02e['type'][_0xbb10('0x2e')]};});_0xfc3595[_0xbb10('0x2f')]=_[_0xbb10('0x2b')](_0x1d30aa,'name');_0xfc3595['query']=_[_0xbb10('0x30')](_0x4aabb9[_0xbb10('0x31')]);_0xfc3595['filters']=_[_0xbb10('0x32')](_0xfc3595[_0xbb10('0x2f')],_0xfc3595[_0xbb10('0x31')]);_0x21ac54[_0xbb10('0x33')]=_[_0xbb10('0x32')](_0xfc3595[_0xbb10('0x2f')],qs[_0xbb10('0x34')](_0x4aabb9['query'][_0xbb10('0x34')]));_0x21ac54[_0xbb10('0x33')]=_0x21ac54[_0xbb10('0x33')][_0xbb10('0x35')]?_0x21ac54[_0xbb10('0x33')]:_0xfc3595[_0xbb10('0x2f')];if(!_0x4aabb9[_0xbb10('0x31')][_0xbb10('0x36')](_0xbb10('0x37'))){_0x21ac54['limit']=qs[_0xbb10('0x1c')](_0x4aabb9[_0xbb10('0x31')][_0xbb10('0x1c')]);_0x21ac54[_0xbb10('0x1b')]=qs['offset'](_0x4aabb9[_0xbb10('0x31')]['offset']);}_0x21ac54['order']=qs[_0xbb10('0x38')](_0x4aabb9[_0xbb10('0x31')][_0xbb10('0x38')]);_0x21ac54[_0xbb10('0x39')]=qs[_0xbb10('0x3a')](_[_0xbb10('0x3b')](_0x4aabb9['query'],_0xfc3595[_0xbb10('0x3a')]),_0x1d30aa);if(_0x4aabb9[_0xbb10('0x31')]['filter']){_0x21ac54['where']=_['merge'](_0x21ac54[_0xbb10('0x39')],{'$or':_[_0xbb10('0x2b')](_0x1d30aa,function(_0x2b658a){if(_0x2b658a['type']!==_0xbb10('0x3c')){var _0x3e8538={};_0x3e8538[_0x2b658a[_0xbb10('0x28')]]={'$like':'%'+_0x4aabb9['query'][_0xbb10('0x3d')]+'%'};return _0x3e8538;}})});}_0x21ac54=_[_0xbb10('0x3e')]({},_0x21ac54,_0x4aabb9[_0xbb10('0x3f')]);var _0x446f49={'where':_0x21ac54['where']};return db[_0xbb10('0x40')][_0xbb10('0x1e')](_0x446f49)['then'](function(_0xe2040f){_0x2e0249[_0xbb10('0x1e')]=_0xe2040f;if(_0x4aabb9[_0xbb10('0x31')][_0xbb10('0x41')]){_0x21ac54[_0xbb10('0x42')]=[{'attributes':['id',_0xbb10('0x28'),'fullname',_0xbb10('0x43')],'model':db[_0xbb10('0x44')],'as':_0xbb10('0x44')}];}return db[_0xbb10('0x40')]['findAll'](_0x21ac54);})[_0xbb10('0x23')](function(_0x331751){_0x2e0249[_0xbb10('0x45')]=_0x331751;return _0x2e0249;})[_0xbb10('0x23')](respondWithFilteredResult(_0x3796c7,_0x21ac54))['catch'](handleError(_0x3796c7,null));};exports[_0xbb10('0x46')]=function(_0x202c60,_0x54ac18){var _0x5d9a4f={'raw':!![],'where':{'id':_0x202c60['params']['id']}},_0x38d78f={};_0x38d78f[_0xbb10('0x2f')]=_[_0xbb10('0x30')](db['VoiceCallReport'][_0xbb10('0x2c')]);_0x38d78f[_0xbb10('0x31')]=_[_0xbb10('0x30')](_0x202c60['query']);_0x38d78f[_0xbb10('0x3a')]=_[_0xbb10('0x32')](_0x38d78f[_0xbb10('0x2f')],_0x38d78f[_0xbb10('0x31')]);_0x5d9a4f[_0xbb10('0x33')]=_[_0xbb10('0x32')](_0x38d78f[_0xbb10('0x2f')],qs[_0xbb10('0x34')](_0x202c60[_0xbb10('0x31')][_0xbb10('0x34')]));_0x5d9a4f[_0xbb10('0x33')]=_0x5d9a4f[_0xbb10('0x33')]['length']?_0x5d9a4f[_0xbb10('0x33')]:_0x38d78f[_0xbb10('0x2f')];if(_0x202c60['query'][_0xbb10('0x41')]){_0x5d9a4f[_0xbb10('0x42')]=[{'all':!![]}];}_0x5d9a4f=_[_0xbb10('0x3e')]({},_0x5d9a4f,_0x202c60[_0xbb10('0x3f')]);return db[_0xbb10('0x40')][_0xbb10('0x47')](_0x5d9a4f)[_0xbb10('0x23')](handleEntityNotFound(_0x54ac18,null))['then'](respondWithResult(_0x54ac18,null))['catch'](handleError(_0x54ac18,null));};exports[_0xbb10('0x48')]=function(_0x76a208,_0x2b12bd){return db['VoiceCallReport']['create'](_0x76a208[_0xbb10('0x49')],{})[_0xbb10('0x23')](respondWithResult(_0x2b12bd,0xc9))[_0xbb10('0x4a')](handleError(_0x2b12bd,null));};exports[_0xbb10('0x24')]=function(_0x10159b,_0x22b315){return db[_0xbb10('0x40')][_0xbb10('0x47')]({'where':{'id':_0x10159b[_0xbb10('0x4b')]['id']}})[_0xbb10('0x23')](handleEntityNotFound(_0x22b315,null))['then'](removeEntity(_0x22b315,null))['catch'](handleError(_0x22b315,null));};exports[_0xbb10('0x4c')]=function(_0x467dba,_0x36ab7d){return db[_0xbb10('0x40')][_0xbb10('0x4c')]()[_0xbb10('0x23')](respondWithResult(_0x36ab7d,null))[_0xbb10('0x4a')](handleError(_0x36ab7d,null));};exports[_0xbb10('0x22')]=function(_0x1c0d8f,_0x1214f7){if(_0x1c0d8f[_0xbb10('0x49')][_0xbb10('0x4d')]){delete _0x1c0d8f[_0xbb10('0x49')][_0xbb10('0x4d')];}return db[_0xbb10('0x40')]['find']({'where':{'uniqueid':_0x1c0d8f[_0xbb10('0x4b')]['id'],'UserId':{'$or':[null,_0x1c0d8f['user']['id']]}}})[_0xbb10('0x23')](handleEntityNotFound(_0x1214f7,null))[_0xbb10('0x23')](saveUpdates(_0x1c0d8f[_0xbb10('0x49')],null))[_0xbb10('0x23')](respondWithResult(_0x1214f7,null))[_0xbb10('0x4a')](handleError(_0x1214f7,null));}; \ No newline at end of file diff --git a/server/api/voiceCallReport/voiceCallReport.model.js b/server/api/voiceCallReport/voiceCallReport.model.js new file mode 100644 index 0000000..be5051e --- /dev/null +++ b/server/api/voiceCallReport/voiceCallReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1d5c=['rimraf','./voiceCallReport.attributes','exports','define','VoiceCallReport','report_call','uniqueid','lodash','util','../../config/logger','api','moment'];(function(_0x552b21,_0x4e6e66){var _0x535611=function(_0x518b19){while(--_0x518b19){_0x552b21['push'](_0x552b21['shift']());}};_0x535611(++_0x4e6e66);}(_0x1d5c,0xeb));var _0xc1d5=function(_0x1d2f15,_0x1107c6){_0x1d2f15=_0x1d2f15-0x0;var _0x19efd2=_0x1d5c[_0x1d2f15];return _0x19efd2;};'use strict';var _=require(_0xc1d5('0x0'));var util=require(_0xc1d5('0x1'));var logger=require(_0xc1d5('0x2'))(_0xc1d5('0x3'));var moment=require(_0xc1d5('0x4'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0xc1d5('0x5'));var config=require('../../config/environment');var attributes=require(_0xc1d5('0x6'));module[_0xc1d5('0x7')]=function(_0x4a80ad,_0x2accf0){return _0x4a80ad[_0xc1d5('0x8')](_0xc1d5('0x9'),attributes,{'tableName':_0xc1d5('0xa'),'paranoid':![],'indexes':[{'fields':[_0xc1d5('0xb')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceCallReport/voiceCallReport.rpc.js b/server/api/voiceCallReport/voiceCallReport.rpc.js new file mode 100644 index 0000000..61fa13a --- /dev/null +++ b/server/api/voiceCallReport/voiceCallReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe081=['create','body','update','where','UpdateVoiceCallReport','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceCallReport','VoiceCallReport','findAll','options','raw','attributes','limit','include','map','model','CreateVoiceCallReport'];(function(_0x27a057,_0x255f9c){var _0xff90bc=function(_0x403f71){while(--_0x403f71){_0x27a057['push'](_0x27a057['shift']());}};_0xff90bc(++_0x255f9c);}(_0xe081,0x1bd));var _0x1e08=function(_0x1c7115,_0x47b37a){_0x1c7115=_0x1c7115-0x0;var _0xca4fac=_0xe081[_0x1c7115];return _0xca4fac;};'use strict';var _=require('lodash');var util=require(_0x1e08('0x0'));var moment=require(_0x1e08('0x1'));var BPromise=require(_0x1e08('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1e08('0x3'));var db=require(_0x1e08('0x4'))['db'];var utils=require(_0x1e08('0x5'));var logger=require(_0x1e08('0x6'))(_0x1e08('0x7'));var config=require(_0x1e08('0x8'));var jayson=require(_0x1e08('0x9'));var client=jayson[_0x1e08('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x24d6bc,_0x4a9345,_0x258a41){return new BPromise(function(_0xc2f6d9,_0x418ff9){return client[_0x1e08('0xb')](_0x24d6bc,_0x258a41)[_0x1e08('0xc')](function(_0x127097){logger[_0x1e08('0xd')](_0x1e08('0xe'),_0x4a9345,_0x1e08('0xf'));logger[_0x1e08('0x10')](_0x1e08('0x11'),_0x4a9345,_0x1e08('0xf'),JSON[_0x1e08('0x12')](_0x127097));if(_0x127097[_0x1e08('0x13')]){if(_0x127097[_0x1e08('0x13')][_0x1e08('0x14')]===0x1f4){logger[_0x1e08('0x13')](_0x1e08('0xe'),_0x4a9345,_0x127097[_0x1e08('0x13')][_0x1e08('0x15')]);return _0x418ff9(_0x127097[_0x1e08('0x13')][_0x1e08('0x15')]);}logger[_0x1e08('0x13')](_0x1e08('0xe'),_0x4a9345,_0x127097['error'][_0x1e08('0x15')]);return _0xc2f6d9(_0x127097[_0x1e08('0x13')][_0x1e08('0x15')]);}else{logger[_0x1e08('0xd')](_0x1e08('0xe'),_0x4a9345,_0x1e08('0xf'));_0xc2f6d9(_0x127097[_0x1e08('0x16')]['message']);}})[_0x1e08('0x17')](function(_0x3afaeb){logger[_0x1e08('0x13')](_0x1e08('0xe'),_0x4a9345,_0x3afaeb);_0x418ff9(_0x3afaeb);});});}exports[_0x1e08('0x18')]=function(_0x384714){var _0x5c70eb=this;return new Promise(function(_0x19914d,_0x226b3c){return db[_0x1e08('0x19')][_0x1e08('0x1a')]({'raw':_0x384714[_0x1e08('0x1b')]?_0x384714['options'][_0x1e08('0x1c')]===undefined?!![]:![]:!![],'where':_0x384714[_0x1e08('0x1b')]?_0x384714[_0x1e08('0x1b')]['where']||null:null,'attributes':_0x384714[_0x1e08('0x1b')]?_0x384714['options'][_0x1e08('0x1d')]||null:null,'limit':_0x384714[_0x1e08('0x1b')]?_0x384714[_0x1e08('0x1b')][_0x1e08('0x1e')]||null:null,'include':_0x384714[_0x1e08('0x1b')]?_0x384714[_0x1e08('0x1b')][_0x1e08('0x1f')]?_[_0x1e08('0x20')](_0x384714[_0x1e08('0x1b')][_0x1e08('0x1f')],function(_0x40b187){return{'model':db[_0x40b187[_0x1e08('0x21')]],'as':_0x40b187['as'],'attributes':_0x40b187['attributes'],'include':_0x40b187[_0x1e08('0x1f')]?_[_0x1e08('0x20')](_0x40b187['include'],function(_0x49c8da){return{'model':db[_0x49c8da[_0x1e08('0x21')]],'as':_0x49c8da['as'],'attributes':_0x49c8da['attributes'],'include':_0x49c8da[_0x1e08('0x1f')]?_['map'](_0x49c8da[_0x1e08('0x1f')],function(_0x5eb9a2){return{'model':db[_0x5eb9a2[_0x1e08('0x21')]],'as':_0x5eb9a2['as'],'attributes':_0x5eb9a2[_0x1e08('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x1e08('0xc')](function(_0xaf73b5){logger[_0x1e08('0xd')](_0x1e08('0x18'),_0x384714);logger[_0x1e08('0x10')](_0x1e08('0x18'),_0x384714,JSON[_0x1e08('0x12')](_0xaf73b5));_0x19914d(_0xaf73b5);})[_0x1e08('0x17')](function(_0x4411a8){logger[_0x1e08('0x13')](_0x1e08('0x18'),_0x4411a8['message'],_0x384714);_0x226b3c(_0x5c70eb[_0x1e08('0x13')](0x1f4,_0x4411a8[_0x1e08('0x15')]));});});};exports[_0x1e08('0x22')]=function(_0x230f2a){var _0x15441d=this;return new Promise(function(_0x13e62,_0x2b6baf){return db[_0x1e08('0x19')][_0x1e08('0x23')](_0x230f2a[_0x1e08('0x24')],{'raw':_0x230f2a['options']?_0x230f2a[_0x1e08('0x1b')]['raw']===undefined?!![]:![]:!![]})[_0x1e08('0xc')](function(_0x325d6e){logger[_0x1e08('0xd')](_0x1e08('0x22'),_0x230f2a);logger[_0x1e08('0x10')]('CreateVoiceCallReport',_0x230f2a,JSON[_0x1e08('0x12')](_0x325d6e));_0x13e62(_0x325d6e);})[_0x1e08('0x17')](function(_0x20d263){logger[_0x1e08('0x13')](_0x1e08('0x22'),_0x20d263[_0x1e08('0x15')],_0x230f2a);_0x2b6baf(_0x15441d[_0x1e08('0x13')](0x1f4,_0x20d263['message']));});});};exports['UpdateVoiceCallReport']=function(_0x341ef8){var _0x3094c8=this;return new Promise(function(_0x302686,_0x53f8ed){return db[_0x1e08('0x19')][_0x1e08('0x25')](_0x341ef8['body'],{'raw':_0x341ef8[_0x1e08('0x1b')]?_0x341ef8[_0x1e08('0x1b')][_0x1e08('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x341ef8['options']?_0x341ef8['options'][_0x1e08('0x26')]||null:null,'attributes':_0x341ef8[_0x1e08('0x1b')]?_0x341ef8[_0x1e08('0x1b')]['attributes']||null:null,'limit':_0x341ef8[_0x1e08('0x1b')]?_0x341ef8[_0x1e08('0x1b')]['limit']||null:null})[_0x1e08('0xc')](function(_0x591b8d){logger['info'](_0x1e08('0x27'),_0x341ef8);logger[_0x1e08('0x10')](_0x1e08('0x27'),_0x341ef8,JSON['stringify'](_0x591b8d));_0x302686(_0x591b8d);})[_0x1e08('0x17')](function(_0x2c2281){logger[_0x1e08('0x13')](_0x1e08('0x27'),_0x2c2281['message'],_0x341ef8);_0x53f8ed(_0x3094c8[_0x1e08('0x13')](0x1f4,_0x2c2281[_0x1e08('0x15')]));});});}; \ No newline at end of file diff --git a/server/api/voiceChanSpy/index.js b/server/api/voiceChanSpy/index.js new file mode 100644 index 0000000..015c93b --- /dev/null +++ b/server/api/voiceChanSpy/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc134=['util','path','connect-timeout','express','Router','../../components/auth/service','get','isAuthenticated','index','show','post','create','put','/:id','update','exports'];(function(_0x430524,_0x23b611){var _0x3a726d=function(_0x5cc39d){while(--_0x5cc39d){_0x430524['push'](_0x430524['shift']());}};_0x3a726d(++_0x23b611);}(_0xc134,0x1a0));var _0x4c13=function(_0x57fc1e,_0x1dfca2){_0x57fc1e=_0x57fc1e-0x0;var _0x54616e=_0xc134[_0x57fc1e];return _0x54616e;};'use strict';var multer=require('multer');var util=require(_0x4c13('0x0'));var path=require(_0x4c13('0x1'));var timeout=require(_0x4c13('0x2'));var express=require(_0x4c13('0x3'));var router=express[_0x4c13('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0x4c13('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require('./voiceChanSpy.controller');router[_0x4c13('0x6')]('/',auth[_0x4c13('0x7')](),controller[_0x4c13('0x8')]);router[_0x4c13('0x6')]('/:id',auth[_0x4c13('0x7')](),controller[_0x4c13('0x9')]);router[_0x4c13('0xa')]('/',auth[_0x4c13('0x7')](),controller[_0x4c13('0xb')]);router[_0x4c13('0xc')](_0x4c13('0xd'),auth[_0x4c13('0x7')](),controller[_0x4c13('0xe')]);router['delete'](_0x4c13('0xd'),auth[_0x4c13('0x7')](),controller['destroy']);module[_0x4c13('0xf')]=router; \ No newline at end of file diff --git a/server/api/voiceChanSpy/voiceChanSpy.attributes.js b/server/api/voiceChanSpy/voiceChanSpy.attributes.js new file mode 100644 index 0000000..97ca58c --- /dev/null +++ b/server/api/voiceChanSpy/voiceChanSpy.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3027=['options','BOOLEAN','sequelize','exports','STRING','getDataValue'];(function(_0x396be2,_0x16d201){var _0x3197ef=function(_0x2c97bb){while(--_0x2c97bb){_0x396be2['push'](_0x396be2['shift']());}};_0x3197ef(++_0x16d201);}(_0x3027,0x128));var _0x7302=function(_0x232be6,_0x58c722){_0x232be6=_0x232be6-0x0;var _0x5c4524=_0x3027[_0x232be6];return _0x5c4524;};'use strict';var Sequelize=require(_0x7302('0x0'));module[_0x7302('0x1')]={'name':{'type':Sequelize['STRING']},'prefix':{'type':Sequelize[_0x7302('0x2')],'unique':'name','allowNull':![]},'options':{'type':Sequelize[_0x7302('0x2')],'set':function(_0x565732){this['setDataValue']('options',_0x565732?_0x565732['join'](''):[]);},'get':function(){return this[_0x7302('0x3')](_0x7302('0x4'))?this[_0x7302('0x3')](_0x7302('0x4'))['split'](''):[];}},'auth':{'type':Sequelize[_0x7302('0x5')],'defaultValue':![]},'password':{'type':Sequelize[_0x7302('0x2')]},'record':{'type':Sequelize[_0x7302('0x5')],'defaultValue':![]},'recordingFormat':{'type':Sequelize[_0x7302('0x2')]},'description':{'type':Sequelize[_0x7302('0x2')]}}; \ No newline at end of file diff --git a/server/api/voiceChanSpy/voiceChanSpy.controller.js b/server/api/voiceChanSpy/voiceChanSpy.controller.js new file mode 100644 index 0000000..9cedb2a --- /dev/null +++ b/server/api/voiceChanSpy/voiceChanSpy.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1ddc=['merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','keys','rawAttributes','length','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','Content-Range','apply','reject','save','then','destroy','get','ChanSpies','UserProfileResource','error','stack','name','send','index','VoiceChanSpy','fieldName','type','model','map','query','filters','intersection','attributes','fields','nolimit','order','sort','where','pick'];(function(_0x299c54,_0x5ba02a){var _0x17a1d8=function(_0x25d3fe){while(--_0x25d3fe){_0x299c54['push'](_0x299c54['shift']());}};_0x17a1d8(++_0x5ba02a);}(_0x1ddc,0x6e));var _0xc1dd=function(_0x3ea99a,_0x4f3f9d){_0x3ea99a=_0x3ea99a-0x0;var _0x579c5b=_0x1ddc[_0x3ea99a];return _0x579c5b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc1dd('0x0'));var zipdir=require(_0xc1dd('0x1'));var jsonpatch=require(_0xc1dd('0x2'));var rp=require('request-promise');var moment=require(_0xc1dd('0x3'));var BPromise=require(_0xc1dd('0x4'));var Mustache=require('mustache');var util=require(_0xc1dd('0x5'));var path=require(_0xc1dd('0x6'));var sox=require('sox');var csv=require(_0xc1dd('0x7'));var ejs=require(_0xc1dd('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc1dd('0x9'));var squel=require(_0xc1dd('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xc1dd('0xb'));var toCsv=require(_0xc1dd('0x7'));var querystring=require(_0xc1dd('0xc'));var Papa=require(_0xc1dd('0xd'));var Redis=require('ioredis');var authService=require(_0xc1dd('0xe'));var qs=require(_0xc1dd('0xf'));var as=require(_0xc1dd('0x10'));var hardwareService=require(_0xc1dd('0x11'));var logger=require('../../config/logger')(_0xc1dd('0x12'));var utils=require(_0xc1dd('0x13'));var config=require(_0xc1dd('0x14'));var licenseUtil=require(_0xc1dd('0x15'));var db=require(_0xc1dd('0x16'))['db'];function respondWithStatusCode(_0x2613c9,_0x1d9815){_0x1d9815=_0x1d9815||0xcc;return function(_0x83a291){if(_0x83a291){return _0x2613c9[_0xc1dd('0x17')](_0x1d9815);}return _0x2613c9[_0xc1dd('0x18')](_0x1d9815)[_0xc1dd('0x19')]();};}function respondWithResult(_0x576fc1,_0x3d4c7f){_0x3d4c7f=_0x3d4c7f||0xc8;return function(_0x30f49a){if(_0x30f49a){return _0x576fc1[_0xc1dd('0x18')](_0x3d4c7f)[_0xc1dd('0x1a')](_0x30f49a);}};}function respondWithFilteredResult(_0x104177,_0x52a9b8){return function(_0xe5a17a){if(_0xe5a17a){var _0x76994c=typeof _0x52a9b8[_0xc1dd('0x1b')]===_0xc1dd('0x1c')&&typeof _0x52a9b8['limit']==='undefined';var _0x3e7e6f=_0xe5a17a['count'];var _0x35139a=_0x76994c?0x0:_0x52a9b8['offset'];var _0x6198a7=_0x76994c?_0xe5a17a[_0xc1dd('0x1d')]:_0x52a9b8[_0xc1dd('0x1b')]+_0x52a9b8[_0xc1dd('0x1e')];var _0x312054;if(_0x6198a7>=_0x3e7e6f){_0x6198a7=_0x3e7e6f;_0x312054=0xc8;}else{_0x312054=0xce;}_0x104177[_0xc1dd('0x18')](_0x312054);return _0x104177['set'](_0xc1dd('0x1f'),_0x35139a+'-'+_0x6198a7+'/'+_0x3e7e6f)[_0xc1dd('0x1a')](_0xe5a17a);}return null;};}function patchUpdates(_0x5e99a6){return function(_0x3d22bb){try{jsonpatch[_0xc1dd('0x20')](_0x3d22bb,_0x5e99a6,!![]);}catch(_0x3650fd){return BPromise[_0xc1dd('0x21')](_0x3650fd);}return _0x3d22bb[_0xc1dd('0x22')]();};}function saveUpdates(_0x266147,_0x228626){return function(_0x60ef4a){if(_0x60ef4a){return _0x60ef4a['update'](_0x266147)[_0xc1dd('0x23')](function(_0x16a2b0){return _0x16a2b0;});}return null;};}function removeEntity(_0x22f9be,_0x3363ff){return function(_0x5f4c9e){if(_0x5f4c9e){return _0x5f4c9e[_0xc1dd('0x24')]()[_0xc1dd('0x23')](function(){var _0x30b4b8=_0x5f4c9e[_0xc1dd('0x25')]({'plain':!![]});var _0x16fb8b=_0xc1dd('0x26');return db[_0xc1dd('0x27')][_0xc1dd('0x24')]({'where':{'type':_0x16fb8b,'resourceId':_0x30b4b8['id']}})[_0xc1dd('0x23')](function(){return _0x5f4c9e;});})[_0xc1dd('0x23')](function(){_0x22f9be[_0xc1dd('0x18')](0xcc)[_0xc1dd('0x19')]();});}};}function handleEntityNotFound(_0x1d3b04,_0xc6607f){return function(_0x5b8edc){if(!_0x5b8edc){_0x1d3b04['sendStatus'](0x194);}return _0x5b8edc;};}function handleError(_0x388f35,_0x19d818){_0x19d818=_0x19d818||0x1f4;return function(_0x25a651){logger[_0xc1dd('0x28')](_0x25a651[_0xc1dd('0x29')]);if(_0x25a651[_0xc1dd('0x2a')]){delete _0x25a651[_0xc1dd('0x2a')];}_0x388f35['status'](_0x19d818)[_0xc1dd('0x2b')](_0x25a651);};}exports[_0xc1dd('0x2c')]=function(_0x34abb7,_0xed3d4c){var _0x5ce3eb={},_0x14b1d4={},_0x2fe0ba={'count':0x0,'rows':[]};var _0x2938e2=_['map'](db[_0xc1dd('0x2d')]['rawAttributes'],function(_0x26f119){return{'name':_0x26f119[_0xc1dd('0x2e')],'type':_0x26f119[_0xc1dd('0x2f')]['key']};});_0x14b1d4[_0xc1dd('0x30')]=_[_0xc1dd('0x31')](_0x2938e2,_0xc1dd('0x2a'));_0x14b1d4[_0xc1dd('0x32')]=_['keys'](_0x34abb7[_0xc1dd('0x32')]);_0x14b1d4[_0xc1dd('0x33')]=_[_0xc1dd('0x34')](_0x14b1d4['model'],_0x14b1d4['query']);_0x5ce3eb[_0xc1dd('0x35')]=_[_0xc1dd('0x34')](_0x14b1d4[_0xc1dd('0x30')],qs[_0xc1dd('0x36')](_0x34abb7[_0xc1dd('0x32')]['fields']));_0x5ce3eb[_0xc1dd('0x35')]=_0x5ce3eb[_0xc1dd('0x35')]['length']?_0x5ce3eb[_0xc1dd('0x35')]:_0x14b1d4[_0xc1dd('0x30')];if(!_0x34abb7[_0xc1dd('0x32')]['hasOwnProperty'](_0xc1dd('0x37'))){_0x5ce3eb['limit']=qs[_0xc1dd('0x1e')](_0x34abb7[_0xc1dd('0x32')]['limit']);_0x5ce3eb[_0xc1dd('0x1b')]=qs[_0xc1dd('0x1b')](_0x34abb7[_0xc1dd('0x32')][_0xc1dd('0x1b')]);}_0x5ce3eb[_0xc1dd('0x38')]=qs[_0xc1dd('0x39')](_0x34abb7[_0xc1dd('0x32')][_0xc1dd('0x39')]);_0x5ce3eb[_0xc1dd('0x3a')]=qs[_0xc1dd('0x33')](_[_0xc1dd('0x3b')](_0x34abb7[_0xc1dd('0x32')],_0x14b1d4['filters']),_0x2938e2);if(_0x34abb7[_0xc1dd('0x32')]['filter']){_0x5ce3eb[_0xc1dd('0x3a')]=_[_0xc1dd('0x3c')](_0x5ce3eb[_0xc1dd('0x3a')],{'$or':_[_0xc1dd('0x31')](_0x2938e2,function(_0x4764d2){if(_0x4764d2[_0xc1dd('0x2f')]!==_0xc1dd('0x3d')){var _0x583688={};_0x583688[_0x4764d2[_0xc1dd('0x2a')]]={'$like':'%'+_0x34abb7['query'][_0xc1dd('0x3e')]+'%'};return _0x583688;}})});}_0x5ce3eb=_[_0xc1dd('0x3c')]({},_0x5ce3eb,_0x34abb7[_0xc1dd('0x3f')]);var _0x27bea1={'where':_0x5ce3eb[_0xc1dd('0x3a')]};return db[_0xc1dd('0x2d')][_0xc1dd('0x1d')](_0x27bea1)['then'](function(_0x2d903f){_0x2fe0ba[_0xc1dd('0x1d')]=_0x2d903f;if(_0x34abb7[_0xc1dd('0x32')][_0xc1dd('0x40')]){_0x5ce3eb[_0xc1dd('0x41')]=[{'all':!![]}];}return db[_0xc1dd('0x2d')][_0xc1dd('0x42')](_0x5ce3eb);})[_0xc1dd('0x23')](function(_0x445586){_0x2fe0ba[_0xc1dd('0x43')]=_0x445586;return _0x2fe0ba;})[_0xc1dd('0x23')](respondWithFilteredResult(_0xed3d4c,_0x5ce3eb))[_0xc1dd('0x44')](handleError(_0xed3d4c,null));};exports[_0xc1dd('0x45')]=function(_0x5d5bdb,_0x285b38){var _0x2f50f5={'raw':![],'where':{'id':_0x5d5bdb[_0xc1dd('0x46')]['id']}},_0x3f3aae={};_0x3f3aae[_0xc1dd('0x30')]=_[_0xc1dd('0x47')](db[_0xc1dd('0x2d')][_0xc1dd('0x48')]);_0x3f3aae['query']=_['keys'](_0x5d5bdb[_0xc1dd('0x32')]);_0x3f3aae[_0xc1dd('0x33')]=_[_0xc1dd('0x34')](_0x3f3aae[_0xc1dd('0x30')],_0x3f3aae[_0xc1dd('0x32')]);_0x2f50f5[_0xc1dd('0x35')]=_['intersection'](_0x3f3aae[_0xc1dd('0x30')],qs[_0xc1dd('0x36')](_0x5d5bdb[_0xc1dd('0x32')][_0xc1dd('0x36')]));_0x2f50f5[_0xc1dd('0x35')]=_0x2f50f5['attributes'][_0xc1dd('0x49')]?_0x2f50f5[_0xc1dd('0x35')]:_0x3f3aae['model'];if(_0x5d5bdb[_0xc1dd('0x32')][_0xc1dd('0x40')]){_0x2f50f5[_0xc1dd('0x41')]=[{'all':!![]}];}_0x2f50f5=_['merge']({},_0x2f50f5,_0x5d5bdb[_0xc1dd('0x3f')]);return db[_0xc1dd('0x2d')]['find'](_0x2f50f5)[_0xc1dd('0x23')](handleEntityNotFound(_0x285b38,null))[_0xc1dd('0x23')](respondWithResult(_0x285b38,null))[_0xc1dd('0x44')](handleError(_0x285b38,null));};exports[_0xc1dd('0x4a')]=function(_0x55fbc9,_0x53763d){return db[_0xc1dd('0x2d')]['create'](_0x55fbc9['body'],{})['then'](function(_0x16991d){var _0x1e2319=_0x55fbc9[_0xc1dd('0x4b')]['get']({'plain':!![]});if(!_0x1e2319)throw new Error(_0xc1dd('0x4c'));if(_0x1e2319[_0xc1dd('0x4d')]===_0xc1dd('0x4b')){var _0x9e7cb7=_0x16991d[_0xc1dd('0x25')]({'plain':!![]});var _0x745e54=_0xc1dd('0x26');return db[_0xc1dd('0x4e')][_0xc1dd('0x4f')]({'where':{'name':_0x745e54,'userProfileId':_0x1e2319[_0xc1dd('0x50')]},'raw':!![]})[_0xc1dd('0x23')](function(_0x50ce4c){if(_0x50ce4c&&_0x50ce4c[_0xc1dd('0x51')]===0x0){return db[_0xc1dd('0x27')]['create']({'name':_0x9e7cb7[_0xc1dd('0x2a')],'resourceId':_0x9e7cb7['id'],'type':_0x50ce4c[_0xc1dd('0x2a')],'sectionId':_0x50ce4c['id']},{})[_0xc1dd('0x23')](function(){return _0x16991d;});}else{return _0x16991d;}})['catch'](function(_0xe1bf9a){logger['error'](_0xc1dd('0x52'),_0xe1bf9a);throw _0xe1bf9a;});}return _0x16991d;})[_0xc1dd('0x23')](respondWithResult(_0x53763d,0xc9))[_0xc1dd('0x44')](handleError(_0x53763d,null));};exports[_0xc1dd('0x53')]=function(_0x343fc2,_0x5980c8){if(_0x343fc2['body']['id']){delete _0x343fc2[_0xc1dd('0x54')]['id'];}return db[_0xc1dd('0x2d')][_0xc1dd('0x4f')]({'where':{'id':_0x343fc2[_0xc1dd('0x46')]['id']}})[_0xc1dd('0x23')](handleEntityNotFound(_0x5980c8,null))[_0xc1dd('0x23')](saveUpdates(_0x343fc2[_0xc1dd('0x54')],null))[_0xc1dd('0x23')](respondWithResult(_0x5980c8,null))[_0xc1dd('0x44')](handleError(_0x5980c8,null));};exports[_0xc1dd('0x24')]=function(_0x261028,_0x2cd794){return db[_0xc1dd('0x2d')][_0xc1dd('0x4f')]({'where':{'id':_0x261028[_0xc1dd('0x46')]['id']}})[_0xc1dd('0x23')](handleEntityNotFound(_0x2cd794,null))[_0xc1dd('0x23')](removeEntity(_0x2cd794,null))[_0xc1dd('0x44')](handleError(_0x2cd794,null));}; \ No newline at end of file diff --git a/server/api/voiceChanSpy/voiceChanSpy.model.js b/server/api/voiceChanSpy/voiceChanSpy.model.js new file mode 100644 index 0000000..6d7b8d9 --- /dev/null +++ b/server/api/voiceChanSpy/voiceChanSpy.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x52b2=['concat','internal','User','findAll','then','exports','define','voice_chanspy','VoiceExtension','catch','bulkCreate','lodash','bluebird','./voiceChanSpy.attributes','context','from-sip','format','%s%s','prefix','system','push','merge','Set','CDR(type)=%s','chanspy','record','MixMonitor','recordingFormat','auth','Authenticate','password','SIP/%s,%s','name','options','join','StopMixMonitor','length'];(function(_0x51db0c,_0x346f5a){var _0xfa1c1e=function(_0x2f9478){while(--_0x2f9478){_0x51db0c['push'](_0x51db0c['shift']());}};_0xfa1c1e(++_0x346f5a);}(_0x52b2,0x158));var _0x252b=function(_0x37ffad,_0x443124){_0x37ffad=_0x37ffad-0x0;var _0x290d04=_0x52b2[_0x37ffad];return _0x290d04;};'use strict';var _=require(_0x252b('0x0'));var util=require('util');var BPromise=require(_0x252b('0x1'));var attributes=require(_0x252b('0x2'));var getUserApplications=function(_0x38ab10,_0xe3a3a4,_0x4dd102){var _0x20eadc=0x1;var _0x3bcef2=[];var _0x352179={'context':_0xe3a3a4[_0x252b('0x3')]||_0x252b('0x4'),'exten':util[_0x252b('0x5')](_0x252b('0x6'),_0x38ab10[_0x252b('0x7')],_0x4dd102),'type':_0x252b('0x8'),'isApp':![],'ChanSpyId':_0x38ab10['id'],'UserId':_0xe3a3a4['id']};_0x3bcef2[_0x252b('0x9')](_[_0x252b('0xa')]({'app':_0x252b('0xb'),'appdata':util[_0x252b('0x5')](_0x252b('0xc'),_0x252b('0xd')),'priority':_0x20eadc++},_0x352179));if(_0x38ab10[_0x252b('0xe')]){_0x3bcef2[_0x252b('0x9')](_[_0x252b('0xa')]({'app':_0x252b('0xf'),'appdata':util[_0x252b('0x5')]('${UNIQUEID}.%s,a',_0x38ab10[_0x252b('0x10')]),'priority':_0x20eadc++},_0x352179));}if(_0x38ab10[_0x252b('0x11')]){_0x3bcef2['push'](_[_0x252b('0xa')]({'app':_0x252b('0x12'),'appdata':_0x38ab10[_0x252b('0x13')],'priority':_0x20eadc++},_0x352179));}_0x3bcef2[_0x252b('0x9')](_[_0x252b('0xa')]({'app':'ChanSpy','appdata':util[_0x252b('0x5')](_0x252b('0x14'),_0xe3a3a4[_0x252b('0x15')],_0x38ab10[_0x252b('0x16')]?_0x38ab10[_0x252b('0x16')][_0x252b('0x17')](''):''),'priority':_0x20eadc++},_0x352179));if(_0x38ab10['record']){_0x3bcef2[_0x252b('0x9')](_[_0x252b('0xa')]({'app':_0x252b('0x18'),'priority':_0x20eadc++},_0x352179));}return _0x3bcef2;};var getChanSpyApplications=function(_0x2c49fe,_0x5cc762){var _0x2eab33=[];for(var _0x141490=0x0,_0x38f4fe=0x1;_0x141490<_0x5cc762[_0x252b('0x19')];_0x141490++,_0x38f4fe=0x1){_0x2eab33=_0x2eab33[_0x252b('0x1a')](getUserApplications(_0x2c49fe,_0x5cc762[_0x141490],_0x5cc762[_0x141490][_0x252b('0x1b')]));if(_0x5cc762[_0x141490][_0x252b('0x1b')]!=_0x5cc762[_0x141490][_0x252b('0x15')]){_0x2eab33=_0x2eab33[_0x252b('0x1a')](getUserApplications(_0x2c49fe,_0x5cc762[_0x141490],_0x5cc762[_0x141490]['name']));}}return _0x2eab33;};var getChanSpyPromise=function(_0x116b62,_0x5d6019){return new BPromise(function(_0x1a607e,_0x2d05e5){return _0x116b62[_0x252b('0x1c')][_0x252b('0x1d')]({'attributes':['id',_0x252b('0x15'),'internal'],'where':{'role':'agent','chanspy':!![]},'raw':!![]})[_0x252b('0x1e')](function(_0x4045f9){if(_0x4045f9){return _0x1a607e(getChanSpyApplications(_0x5d6019,_0x4045f9));}return _0x1a607e([]);})['catch'](function(_0x4129ac){_0x2d05e5(_0x4129ac);});});};module[_0x252b('0x1f')]=function(_0x229fcd,_0x99852c){var _0x24767c=_0x229fcd['models'];return _0x229fcd[_0x252b('0x20')]('VoiceChanSpy',attributes,{'tableName':_0x252b('0x21'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x1645bb,_0x49920a,_0x1c1c33){return getChanSpyPromise(_0x24767c,_0x1645bb)['then'](function(_0x3aba2f){if(_0x3aba2f&&_0x3aba2f[_0x252b('0x19')]){return _0x24767c[_0x252b('0x22')]['bulkCreate'](_0x3aba2f);}})['then'](function(){_0x1c1c33();})[_0x252b('0x23')](function(_0x308872){_0x1c1c33(_0x308872);});},'afterUpdate':function(_0x4e7e0f,_0x5ab10,_0x3965e3){return _0x24767c[_0x252b('0x22')]['destroy']({'where':{'ChanSpyId':_0x4e7e0f['id']}})['then'](function(){return getChanSpyPromise(_0x24767c,_0x4e7e0f);})['then'](function(_0x2eaf31){if(_0x2eaf31&&_0x2eaf31['length']){return _0x24767c[_0x252b('0x22')][_0x252b('0x24')](_0x2eaf31);}})[_0x252b('0x1e')](function(){_0x3965e3();})[_0x252b('0x23')](function(_0x5300a2){_0x3965e3(_0x5300a2);});},'afterDestroy':function(_0x2b24a3,_0x57876d,_0x34e55c){return _0x24767c[_0x252b('0x22')]['destroy']({'where':{'ChanSpyId':_0x2b24a3['id']}})['then'](function(){_0x34e55c();})[_0x252b('0x23')](function(_0x13cf2d){_0x34e55c(_0x13cf2d);});}}});}; \ No newline at end of file diff --git a/server/api/voiceChanSpy/voiceChanSpy.rpc.js b/server/api/voiceChanSpy/voiceChanSpy.rpc.js new file mode 100644 index 0000000..fb86462 --- /dev/null +++ b/server/api/voiceChanSpy/voiceChanSpy.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x41bb=['VoiceChanSpy,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','then','info'];(function(_0x9df2ab,_0xbf33b7){var _0x4273a4=function(_0x4444eb){while(--_0x4444eb){_0x9df2ab['push'](_0x9df2ab['shift']());}};_0x4273a4(++_0xbf33b7);}(_0x41bb,0xc5));var _0xb41b=function(_0x690c93,_0x3941e8){_0x690c93=_0x690c93-0x0;var _0x4b5bd5=_0x41bb[_0x690c93];return _0x4b5bd5;};'use strict';var _=require(_0xb41b('0x0'));var util=require(_0xb41b('0x1'));var moment=require('moment');var BPromise=require(_0xb41b('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb41b('0x3'));var db=require(_0xb41b('0x4'))['db'];var utils=require(_0xb41b('0x5'));var logger=require(_0xb41b('0x6'))('rpc');var config=require(_0xb41b('0x7'));var jayson=require(_0xb41b('0x8'));var client=jayson[_0xb41b('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5455ce,_0x497242,_0x2704f0){return new BPromise(function(_0x29c30d,_0x53722a){return client[_0xb41b('0xa')](_0x5455ce,_0x2704f0)[_0xb41b('0xb')](function(_0x11b8b2){logger[_0xb41b('0xc')](_0xb41b('0xd'),_0x497242,_0xb41b('0xe'));logger[_0xb41b('0xf')]('VoiceChanSpy,\x20%s,\x20%s,\x20%s',_0x497242,_0xb41b('0xe'),JSON['stringify'](_0x11b8b2));if(_0x11b8b2[_0xb41b('0x10')]){if(_0x11b8b2[_0xb41b('0x10')][_0xb41b('0x11')]===0x1f4){logger[_0xb41b('0x10')](_0xb41b('0xd'),_0x497242,_0x11b8b2['error'][_0xb41b('0x12')]);return _0x53722a(_0x11b8b2[_0xb41b('0x10')][_0xb41b('0x12')]);}logger[_0xb41b('0x10')](_0xb41b('0xd'),_0x497242,_0x11b8b2['error']['message']);return _0x29c30d(_0x11b8b2['error'][_0xb41b('0x12')]);}else{logger[_0xb41b('0xc')](_0xb41b('0xd'),_0x497242,_0xb41b('0xe'));_0x29c30d(_0x11b8b2[_0xb41b('0x13')]['message']);}})[_0xb41b('0x14')](function(_0xd0b6b5){logger[_0xb41b('0x10')](_0xb41b('0xd'),_0x497242,_0xd0b6b5);_0x53722a(_0xd0b6b5);});});} \ No newline at end of file diff --git a/server/api/voiceContext/index.js b/server/api/voiceContext/index.js new file mode 100644 index 0000000..7b9b5d9 --- /dev/null +++ b/server/api/voiceContext/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xef85=['destroy','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./voiceContext.controller','get','isAuthenticated','index','/:id','show','post','create','put','update','delete'];(function(_0x14e06c,_0x219a79){var _0x1a0533=function(_0x54dd04){while(--_0x54dd04){_0x14e06c['push'](_0x14e06c['shift']());}};_0x1a0533(++_0x219a79);}(_0xef85,0x1ba));var _0x5ef8=function(_0x11f0a2,_0x1a1c6f){_0x11f0a2=_0x11f0a2-0x0;var _0x1da82b=_0xef85[_0x11f0a2];return _0x1da82b;};'use strict';var multer=require(_0x5ef8('0x0'));var util=require(_0x5ef8('0x1'));var path=require(_0x5ef8('0x2'));var timeout=require(_0x5ef8('0x3'));var express=require('express');var router=express[_0x5ef8('0x4')]();var fs_extra=require(_0x5ef8('0x5'));var auth=require(_0x5ef8('0x6'));var interaction=require(_0x5ef8('0x7'));var config=require(_0x5ef8('0x8'));var controller=require(_0x5ef8('0x9'));router[_0x5ef8('0xa')]('/',auth[_0x5ef8('0xb')](),controller[_0x5ef8('0xc')]);router['get'](_0x5ef8('0xd'),auth[_0x5ef8('0xb')](),controller[_0x5ef8('0xe')]);router[_0x5ef8('0xf')]('/',auth[_0x5ef8('0xb')](),controller[_0x5ef8('0x10')]);router[_0x5ef8('0x11')](_0x5ef8('0xd'),auth[_0x5ef8('0xb')](),controller[_0x5ef8('0x12')]);router[_0x5ef8('0x13')](_0x5ef8('0xd'),auth[_0x5ef8('0xb')](),controller[_0x5ef8('0x14')]);module[_0x5ef8('0x15')]=router; \ No newline at end of file diff --git a/server/api/voiceContext/voiceContext.attributes.js b/server/api/voiceContext/voiceContext.attributes.js new file mode 100644 index 0000000..5821814 --- /dev/null +++ b/server/api/voiceContext/voiceContext.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6dbc=['exports','name','STRING','BOOLEAN','sequelize'];(function(_0x84ae3,_0x5a3052){var _0x59401b=function(_0x58b3d5){while(--_0x58b3d5){_0x84ae3['push'](_0x84ae3['shift']());}};_0x59401b(++_0x5a3052);}(_0x6dbc,0x1e4));var _0xc6db=function(_0x565c49,_0x54acd0){_0x565c49=_0x565c49-0x0;var _0x20ca34=_0x6dbc[_0x565c49];return _0x20ca34;};'use strict';var Sequelize=require(_0xc6db('0x0'));module[_0xc6db('0x1')]={'name':{'type':Sequelize['STRING'],'unique':_0xc6db('0x2')},'description':{'type':Sequelize[_0xc6db('0x3')],'allowNull':!![]},'defaultEntry':{'type':Sequelize[_0xc6db('0x4')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/voiceContext/voiceContext.controller.js b/server/api/voiceContext/voiceContext.controller.js new file mode 100644 index 0000000..fbb68ee --- /dev/null +++ b/server/api/voiceContext/voiceContext.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf415=['offset','undefined','limit','count','set','Content-Range','apply','save','update','destroy','get','Contexts','sendStatus','stack','name','send','map','rawAttributes','model','query','keys','filters','intersection','attributes','fields','length','order','sort','pick','filter','where','type','VIRTUAL','options','VoiceContext','include','findAll','rows','params','includeAll','find','catch','create','body','join','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','readFileSync','root','chan_sip.so','Reload','eml-format','zip-dir','fast-json-patch','moment','bluebird','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','VoiceContext,\x20%s,\x20%s','message','result','status','end','json'];(function(_0x363e6f,_0x342898){var _0x14cf12=function(_0x140849){while(--_0x140849){_0x363e6f['push'](_0x363e6f['shift']());}};_0x14cf12(++_0x342898);}(_0xf415,0x1dd));var _0x5f41=function(_0x13b02f,_0x462a53){_0x13b02f=_0x13b02f-0x0;var _0x12e9a6=_0xf415[_0x13b02f];return _0x12e9a6;};'use strict';var emlformat=require(_0x5f41('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5f41('0x1'));var jsonpatch=require(_0x5f41('0x2'));var rp=require('request-promise');var moment=require(_0x5f41('0x3'));var BPromise=require(_0x5f41('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x5f41('0x5'));var sox=require(_0x5f41('0x6'));var csv=require('to-csv');var ejs=require(_0x5f41('0x7'));var fs=require('fs');var fs_extra=require(_0x5f41('0x8'));var _=require(_0x5f41('0x9'));var squel=require(_0x5f41('0xa'));var crypto=require('crypto');var jsforce=require(_0x5f41('0xb'));var deskjs=require(_0x5f41('0xc'));var toCsv=require(_0x5f41('0xd'));var querystring=require(_0x5f41('0xe'));var Papa=require(_0x5f41('0xf'));var Redis=require(_0x5f41('0x10'));var authService=require(_0x5f41('0x11'));var qs=require(_0x5f41('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5f41('0x13'));var logger=require(_0x5f41('0x14'))(_0x5f41('0x15'));var utils=require(_0x5f41('0x16'));var config=require(_0x5f41('0x17'));var licenseUtil=require(_0x5f41('0x18'));var db=require(_0x5f41('0x19'))['db'];var jayson=require(_0x5f41('0x1a'));var client=jayson[_0x5f41('0x1b')][_0x5f41('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x20e02d,_0x2a1727,_0x3613aa,_0x159cce){return new BPromise(function(_0x47bef5,_0x3f48e1){var _0x5cd230=_0x159cce||client;return _0x5cd230[_0x5f41('0x1d')](_0x20e02d,_0x3613aa)[_0x5f41('0x1e')](function(_0x5da658){logger[_0x5f41('0x1f')]('VoiceContext,\x20%s,\x20%s',_0x2a1727,_0x5f41('0x20'));logger[_0x5f41('0x21')](_0x5f41('0x22'),_0x2a1727,'request\x20sent',JSON[_0x5f41('0x23')](_0x5da658));if(_0x5da658[_0x5f41('0x24')]){if(_0x5da658[_0x5f41('0x24')]['code']===0x1f4){logger[_0x5f41('0x24')](_0x5f41('0x25'),_0x2a1727,_0x5da658[_0x5f41('0x24')][_0x5f41('0x26')]);return _0x3f48e1(_0x5da658[_0x5f41('0x24')][_0x5f41('0x26')]);}logger[_0x5f41('0x24')](_0x5f41('0x25'),_0x2a1727,_0x5da658[_0x5f41('0x24')][_0x5f41('0x26')]);return _0x47bef5(_0x5da658[_0x5f41('0x24')][_0x5f41('0x26')]);}else{logger[_0x5f41('0x1f')](_0x5f41('0x25'),_0x2a1727,_0x5f41('0x20'));_0x47bef5(_0x5da658[_0x5f41('0x27')][_0x5f41('0x26')]);}})['catch'](function(_0x1020d0){logger[_0x5f41('0x24')](_0x5f41('0x25'),_0x2a1727,_0x1020d0);_0x3f48e1(_0x1020d0);});});}function respondWithStatusCode(_0x4d6720,_0x549131){_0x549131=_0x549131||0xcc;return function(_0x3443fb){if(_0x3443fb){return _0x4d6720['sendStatus'](_0x549131);}return _0x4d6720[_0x5f41('0x28')](_0x549131)[_0x5f41('0x29')]();};}function respondWithResult(_0x20c7b5,_0x5ef051){_0x5ef051=_0x5ef051||0xc8;return function(_0x11f84b){if(_0x11f84b){return _0x20c7b5['status'](_0x5ef051)[_0x5f41('0x2a')](_0x11f84b);}};}function respondWithFilteredResult(_0x15e70c,_0x471aed){return function(_0x2da2f1){if(_0x2da2f1){var _0x19119d=typeof _0x471aed[_0x5f41('0x2b')]===_0x5f41('0x2c')&&typeof _0x471aed[_0x5f41('0x2d')]==='undefined';var _0x1305f0=_0x2da2f1[_0x5f41('0x2e')];var _0x2865ff=_0x19119d?0x0:_0x471aed[_0x5f41('0x2b')];var _0xcd345a=_0x19119d?_0x2da2f1['count']:_0x471aed[_0x5f41('0x2b')]+_0x471aed[_0x5f41('0x2d')];var _0x54969a;if(_0xcd345a>=_0x1305f0){_0xcd345a=_0x1305f0;_0x54969a=0xc8;}else{_0x54969a=0xce;}_0x15e70c[_0x5f41('0x28')](_0x54969a);return _0x15e70c[_0x5f41('0x2f')](_0x5f41('0x30'),_0x2865ff+'-'+_0xcd345a+'/'+_0x1305f0)[_0x5f41('0x2a')](_0x2da2f1);}return null;};}function patchUpdates(_0x391e6e){return function(_0x38830d){try{jsonpatch[_0x5f41('0x31')](_0x38830d,_0x391e6e,!![]);}catch(_0x3378e0){return BPromise['reject'](_0x3378e0);}return _0x38830d[_0x5f41('0x32')]();};}function saveUpdates(_0x104a37,_0x8cf4ef){return function(_0xc223a5){if(_0xc223a5){return _0xc223a5[_0x5f41('0x33')](_0x104a37)[_0x5f41('0x1e')](function(_0x4ce13b){return _0x4ce13b;});}return null;};}function removeEntity(_0x1e9576,_0x5cc45a){return function(_0x504df4){if(_0x504df4){return _0x504df4[_0x5f41('0x34')]()[_0x5f41('0x1e')](function(){var _0x4c44fb=_0x504df4[_0x5f41('0x35')]({'plain':!![]});var _0x1ce9d2=_0x5f41('0x36');return db['UserProfileResource'][_0x5f41('0x34')]({'where':{'type':_0x1ce9d2,'resourceId':_0x4c44fb['id']}})[_0x5f41('0x1e')](function(){return _0x504df4;});})[_0x5f41('0x1e')](function(){_0x1e9576['status'](0xcc)[_0x5f41('0x29')]();});}};}function handleEntityNotFound(_0x11ac5c,_0x39a72b){return function(_0x19b5ea){if(!_0x19b5ea){_0x11ac5c[_0x5f41('0x37')](0x194);}return _0x19b5ea;};}function handleError(_0xa90d72,_0x3c0301){_0x3c0301=_0x3c0301||0x1f4;return function(_0x3593e8){logger['error'](_0x3593e8[_0x5f41('0x38')]);if(_0x3593e8['name']){delete _0x3593e8[_0x5f41('0x39')];}_0xa90d72[_0x5f41('0x28')](_0x3c0301)[_0x5f41('0x3a')](_0x3593e8);};}exports['index']=function(_0x583fb9,_0x54f301){var _0x2f72b2={},_0x59b453={},_0x507c22={'count':0x0,'rows':[]};var _0x39a521=_[_0x5f41('0x3b')](db['VoiceContext'][_0x5f41('0x3c')],function(_0x3c76cc){return{'name':_0x3c76cc['fieldName'],'type':_0x3c76cc['type']['key']};});_0x59b453[_0x5f41('0x3d')]=_[_0x5f41('0x3b')](_0x39a521,_0x5f41('0x39'));_0x59b453[_0x5f41('0x3e')]=_[_0x5f41('0x3f')](_0x583fb9[_0x5f41('0x3e')]);_0x59b453[_0x5f41('0x40')]=_[_0x5f41('0x41')](_0x59b453['model'],_0x59b453[_0x5f41('0x3e')]);_0x2f72b2[_0x5f41('0x42')]=_['intersection'](_0x59b453[_0x5f41('0x3d')],qs[_0x5f41('0x43')](_0x583fb9[_0x5f41('0x3e')][_0x5f41('0x43')]));_0x2f72b2[_0x5f41('0x42')]=_0x2f72b2['attributes'][_0x5f41('0x44')]?_0x2f72b2[_0x5f41('0x42')]:_0x59b453[_0x5f41('0x3d')];if(!_0x583fb9['query']['hasOwnProperty']('nolimit')){_0x2f72b2[_0x5f41('0x2d')]=qs[_0x5f41('0x2d')](_0x583fb9['query'][_0x5f41('0x2d')]);_0x2f72b2[_0x5f41('0x2b')]=qs[_0x5f41('0x2b')](_0x583fb9[_0x5f41('0x3e')]['offset']);}_0x2f72b2[_0x5f41('0x45')]=qs[_0x5f41('0x46')](_0x583fb9[_0x5f41('0x3e')][_0x5f41('0x46')]);_0x2f72b2['where']=qs[_0x5f41('0x40')](_[_0x5f41('0x47')](_0x583fb9[_0x5f41('0x3e')],_0x59b453[_0x5f41('0x40')]),_0x39a521);if(_0x583fb9['query'][_0x5f41('0x48')]){_0x2f72b2[_0x5f41('0x49')]=_['merge'](_0x2f72b2[_0x5f41('0x49')],{'$or':_[_0x5f41('0x3b')](_0x39a521,function(_0x529c21){if(_0x529c21[_0x5f41('0x4a')]!==_0x5f41('0x4b')){var _0x3c56ee={};_0x3c56ee[_0x529c21[_0x5f41('0x39')]]={'$like':'%'+_0x583fb9[_0x5f41('0x3e')][_0x5f41('0x48')]+'%'};return _0x3c56ee;}})});}_0x2f72b2=_['merge']({},_0x2f72b2,_0x583fb9[_0x5f41('0x4c')]);var _0x50e780={'where':_0x2f72b2['where']};return db[_0x5f41('0x4d')][_0x5f41('0x2e')](_0x50e780)[_0x5f41('0x1e')](function(_0x10398d){_0x507c22[_0x5f41('0x2e')]=_0x10398d;if(_0x583fb9[_0x5f41('0x3e')]['includeAll']){_0x2f72b2[_0x5f41('0x4e')]=[{'all':!![]}];}return db['VoiceContext'][_0x5f41('0x4f')](_0x2f72b2);})[_0x5f41('0x1e')](function(_0x43ed86){_0x507c22[_0x5f41('0x50')]=_0x43ed86;return _0x507c22;})[_0x5f41('0x1e')](respondWithFilteredResult(_0x54f301,_0x2f72b2))['catch'](handleError(_0x54f301,null));};exports['show']=function(_0x5917b3,_0xcbbff9){var _0x1898a2={'raw':![],'where':{'id':_0x5917b3[_0x5f41('0x51')]['id']}},_0xdfe9e2={};_0xdfe9e2[_0x5f41('0x3d')]=_['keys'](db[_0x5f41('0x4d')][_0x5f41('0x3c')]);_0xdfe9e2[_0x5f41('0x3e')]=_[_0x5f41('0x3f')](_0x5917b3[_0x5f41('0x3e')]);_0xdfe9e2[_0x5f41('0x40')]=_['intersection'](_0xdfe9e2[_0x5f41('0x3d')],_0xdfe9e2[_0x5f41('0x3e')]);_0x1898a2[_0x5f41('0x42')]=_['intersection'](_0xdfe9e2[_0x5f41('0x3d')],qs['fields'](_0x5917b3['query'][_0x5f41('0x43')]));_0x1898a2['attributes']=_0x1898a2['attributes']['length']?_0x1898a2['attributes']:_0xdfe9e2[_0x5f41('0x3d')];if(_0x5917b3[_0x5f41('0x3e')][_0x5f41('0x52')]){_0x1898a2[_0x5f41('0x4e')]=[{'all':!![]}];}_0x1898a2=_['merge']({},_0x1898a2,_0x5917b3[_0x5f41('0x4c')]);return db['VoiceContext'][_0x5f41('0x53')](_0x1898a2)['then'](handleEntityNotFound(_0xcbbff9,null))[_0x5f41('0x1e')](respondWithResult(_0xcbbff9,null))[_0x5f41('0x54')](handleError(_0xcbbff9,null));};exports[_0x5f41('0x55')]=function(_0x3a2f54,_0x170c2c,_0x36cebb){var _0x734bc9;return db[_0x5f41('0x4d')][_0x5f41('0x55')](_0x3a2f54[_0x5f41('0x56')],{'raw':!![]})[_0x5f41('0x1e')](function(_0x2f9db3){_0x734bc9=_0x2f9db3;return db['VoiceContext'][_0x5f41('0x4f')]({'raw':!![]});})[_0x5f41('0x1e')](function(_0x2344c2){var _0x156b40=fs['readFileSync'](path[_0x5f41('0x57')](config['root'],_0x5f41('0x58')),_0x5f41('0x59'));var _0x327f72=ejs[_0x5f41('0x5a')](_0x156b40,{'contexts':_0x2344c2||[]});fs[_0x5f41('0x5b')](_0x5f41('0x5c'),_0x327f72);})[_0x5f41('0x1e')](function(){return respondWithRpcPromise('Reload',_0x5f41('0x55'),{'module':'chan_sip.so'});})['then'](function(){var _0x42ae35=_0x3a2f54[_0x5f41('0x5d')]['get']({'plain':!![]});if(!_0x42ae35)throw new Error(_0x5f41('0x5e'));if(_0x42ae35[_0x5f41('0x5f')]===_0x5f41('0x5d')){var _0x35c272=_0x734bc9['get']({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':_0x5f41('0x36'),'userProfileId':_0x42ae35[_0x5f41('0x60')]},'raw':!![]})[_0x5f41('0x1e')](function(_0x42b729){if(_0x42b729&&_0x42b729[_0x5f41('0x61')]===0x0){return db[_0x5f41('0x62')]['create']({'name':_0x35c272[_0x5f41('0x39')],'resourceId':_0x35c272['id'],'type':_0x42b729['name'],'sectionId':_0x42b729['id']},{})[_0x5f41('0x1e')](function(){return _0x734bc9;});}else{return _0x734bc9;}})[_0x5f41('0x54')](function(_0x2914a6){logger[_0x5f41('0x24')](_0x5f41('0x63'),_0x2914a6);throw _0x2914a6;});}return _0x734bc9;})[_0x5f41('0x1e')](respondWithResult(_0x170c2c,0xc9))[_0x5f41('0x54')](handleError(_0x170c2c,null));};exports[_0x5f41('0x33')]=function(_0x782c1,_0x5978b6,_0x400a03){var _0x64766e;return db[_0x5f41('0x4d')][_0x5f41('0x53')]({'where':{'id':_0x782c1[_0x5f41('0x51')]['id']}})['then'](handleEntityNotFound(_0x5978b6,null))[_0x5f41('0x1e')](saveUpdates(_0x782c1[_0x5f41('0x56')],null))[_0x5f41('0x1e')](function(_0x233a81){if(_0x233a81){_0x64766e=_0x233a81;return db['VoiceContext']['findAll']({'raw':!![]});}})[_0x5f41('0x1e')](function(_0x3ebde7){var _0x1da7f3=fs[_0x5f41('0x64')](path[_0x5f41('0x57')](config[_0x5f41('0x65')],_0x5f41('0x58')),_0x5f41('0x59'));var _0x2cb00b=ejs[_0x5f41('0x5a')](_0x1da7f3,{'contexts':_0x3ebde7||[]});fs[_0x5f41('0x5b')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x2cb00b);})[_0x5f41('0x1e')](function(){return respondWithRpcPromise('Reload',_0x5f41('0x33'),{'module':_0x5f41('0x66')});})['then'](function(){return _0x64766e;})[_0x5f41('0x1e')](respondWithResult(_0x5978b6,null))[_0x5f41('0x54')](handleError(_0x5978b6,null));};exports[_0x5f41('0x34')]=function(_0x5809bc,_0x1ae494,_0x5adc0e){var _0x13baac;return db[_0x5f41('0x4d')]['find']({'where':{'id':_0x5809bc['params']['id']}})['then'](handleEntityNotFound(_0x1ae494,null))[_0x5f41('0x1e')](removeEntity(_0x1ae494,null))['then'](function(){return db[_0x5f41('0x4d')][_0x5f41('0x4f')]({'raw':!![]});})['then'](function(_0x1f5fb5){var _0x11718e=fs[_0x5f41('0x64')](path['join'](config[_0x5f41('0x65')],_0x5f41('0x58')),_0x5f41('0x59'));var _0x4cd315=ejs[_0x5f41('0x5a')](_0x11718e,{'contexts':_0x1f5fb5});fs[_0x5f41('0x5b')](_0x5f41('0x5c'),_0x4cd315);return respondWithRpcPromise(_0x5f41('0x67'),_0x5f41('0x34'),{'module':'chan_sip.so'});})[_0x5f41('0x54')](handleError(_0x1ae494,null));}; \ No newline at end of file diff --git a/server/api/voiceContext/voiceContext.model.js b/server/api/voiceContext/voiceContext.model.js new file mode 100644 index 0000000..d06f0aa --- /dev/null +++ b/server/api/voiceContext/voiceContext.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe886=['api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./voiceContext.attributes','exports','define','VoiceContext','voice_contexts','lodash','util','../../config/logger'];(function(_0x5180c3,_0x4b35f7){var _0x55c975=function(_0x4746cb){while(--_0x4746cb){_0x5180c3['push'](_0x5180c3['shift']());}};_0x55c975(++_0x4b35f7);}(_0xe886,0x183));var _0x6e88=function(_0x5e2cd6,_0x193f61){_0x5e2cd6=_0x5e2cd6-0x0;var _0x5e9163=_0xe886[_0x5e2cd6];return _0x5e9163;};'use strict';var _=require(_0x6e88('0x0'));var util=require(_0x6e88('0x1'));var logger=require(_0x6e88('0x2'))(_0x6e88('0x3'));var moment=require(_0x6e88('0x4'));var BPromise=require(_0x6e88('0x5'));var rp=require(_0x6e88('0x6'));var fs=require('fs');var path=require(_0x6e88('0x7'));var rimraf=require(_0x6e88('0x8'));var config=require(_0x6e88('0x9'));var attributes=require(_0x6e88('0xa'));module[_0x6e88('0xb')]=function(_0x38609f,_0x53345f){return _0x38609f[_0x6e88('0xc')](_0x6e88('0xd'),attributes,{'tableName':_0x6e88('0xe'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceContext/voiceContext.rpc.js b/server/api/voiceContext/voiceContext.rpc.js new file mode 100644 index 0000000..9e213ec --- /dev/null +++ b/server/api/voiceContext/voiceContext.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x605a=['message','result','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x625e10,_0xe85ecc){var _0x5f12da=function(_0x3dc311){while(--_0x3dc311){_0x625e10['push'](_0x625e10['shift']());}};_0x5f12da(++_0xe85ecc);}(_0x605a,0x1d7));var _0xa605=function(_0x74ce70,_0x2b02cf){_0x74ce70=_0x74ce70-0x0;var _0x4da6a8=_0x605a[_0x74ce70];return _0x4da6a8;};'use strict';var _=require(_0xa605('0x0'));var util=require('util');var moment=require(_0xa605('0x1'));var BPromise=require(_0xa605('0x2'));var rs=require(_0xa605('0x3'));var fs=require('fs');var Redis=require(_0xa605('0x4'));var db=require(_0xa605('0x5'))['db'];var utils=require(_0xa605('0x6'));var logger=require(_0xa605('0x7'))(_0xa605('0x8'));var config=require(_0xa605('0x9'));var jayson=require(_0xa605('0xa'));var client=jayson[_0xa605('0xb')][_0xa605('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x5bf362,_0x4c300e,_0x3573f5){return new BPromise(function(_0xe23170,_0x243d8d){return client[_0xa605('0xd')](_0x5bf362,_0x3573f5)[_0xa605('0xe')](function(_0x15f775){logger[_0xa605('0xf')](_0xa605('0x10'),_0x4c300e,_0xa605('0x11'));logger[_0xa605('0x12')](_0xa605('0x13'),_0x4c300e,_0xa605('0x11'),JSON[_0xa605('0x14')](_0x15f775));if(_0x15f775[_0xa605('0x15')]){if(_0x15f775[_0xa605('0x15')][_0xa605('0x16')]===0x1f4){logger[_0xa605('0x15')](_0xa605('0x10'),_0x4c300e,_0x15f775[_0xa605('0x15')]['message']);return _0x243d8d(_0x15f775[_0xa605('0x15')][_0xa605('0x17')]);}logger['error'](_0xa605('0x10'),_0x4c300e,_0x15f775[_0xa605('0x15')][_0xa605('0x17')]);return _0xe23170(_0x15f775[_0xa605('0x15')][_0xa605('0x17')]);}else{logger[_0xa605('0xf')](_0xa605('0x10'),_0x4c300e,_0xa605('0x11'));_0xe23170(_0x15f775[_0xa605('0x18')]['message']);}})[_0xa605('0x19')](function(_0x32c75e){logger[_0xa605('0x15')](_0xa605('0x10'),_0x4c300e,_0x32c75e);_0x243d8d(_0x32c75e);});});} \ No newline at end of file diff --git a/server/api/voiceDialReport/index.js b/server/api/voiceDialReport/index.js new file mode 100644 index 0000000..656fec4 --- /dev/null +++ b/server/api/voiceDialReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb0fc=['show','post','create','update','delete','exports','multer','util','connect-timeout','express','Router','../../components/auth/service','../../components/interaction/service','../../config/environment','isAuthenticated','index','/describe','describe','get','/:id'];(function(_0x5736df,_0x377e0b){var _0x4de591=function(_0x30dd4f){while(--_0x30dd4f){_0x5736df['push'](_0x5736df['shift']());}};_0x4de591(++_0x377e0b);}(_0xb0fc,0xf6));var _0xcb0f=function(_0x598b78,_0xf4ee7e){_0x598b78=_0x598b78-0x0;var _0x6392fa=_0xb0fc[_0x598b78];return _0x6392fa;};'use strict';var multer=require(_0xcb0f('0x0'));var util=require(_0xcb0f('0x1'));var path=require('path');var timeout=require(_0xcb0f('0x2'));var express=require(_0xcb0f('0x3'));var router=express[_0xcb0f('0x4')]();var fs_extra=require('fs-extra');var auth=require(_0xcb0f('0x5'));var interaction=require(_0xcb0f('0x6'));var config=require(_0xcb0f('0x7'));var controller=require('./voiceDialReport.controller');router['get']('/',auth[_0xcb0f('0x8')](),controller[_0xcb0f('0x9')]);router['get'](_0xcb0f('0xa'),auth[_0xcb0f('0x8')](),controller[_0xcb0f('0xb')]);router[_0xcb0f('0xc')](_0xcb0f('0xd'),auth[_0xcb0f('0x8')](),controller[_0xcb0f('0xe')]);router[_0xcb0f('0xf')]('/',auth['isAuthenticated'](),controller[_0xcb0f('0x10')]);router['put'](_0xcb0f('0xd'),auth[_0xcb0f('0x8')](),controller[_0xcb0f('0x11')]);router[_0xcb0f('0x12')](_0xcb0f('0xd'),auth[_0xcb0f('0x8')](),controller['destroy']);module[_0xcb0f('0x13')]=router; \ No newline at end of file diff --git a/server/api/voiceDialReport/voiceDialReport.attributes.js b/server/api/voiceDialReport/voiceDialReport.attributes.js new file mode 100644 index 0000000..4a09b2c --- /dev/null +++ b/server/api/voiceDialReport/voiceDialReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9a19=['sequelize','exports','STRING','INTEGER','DATE','called,connect,complete'];(function(_0x3194b6,_0x4d04af){var _0x7534f6=function(_0x561885){while(--_0x561885){_0x3194b6['push'](_0x3194b6['shift']());}};_0x7534f6(++_0x4d04af);}(_0x9a19,0x114));var _0x99a1=function(_0x2bcb75,_0x5789a7){_0x2bcb75=_0x2bcb75-0x0;var _0x175345=_0x9a19[_0x2bcb75];return _0x175345;};'use strict';var Sequelize=require(_0x99a1('0x0'));module[_0x99a1('0x1')]={'privilege':{'type':Sequelize[_0x99a1('0x2')]},'channel':{'type':Sequelize['STRING']},'channelstate':{'type':Sequelize[_0x99a1('0x3')]},'channelstatedesc':{'type':Sequelize[_0x99a1('0x2')]},'calleridnum':{'type':Sequelize[_0x99a1('0x2')]},'calleridname':{'type':Sequelize[_0x99a1('0x2')]},'connectedlinenum':{'type':Sequelize[_0x99a1('0x2')]},'connectedlinename':{'type':Sequelize[_0x99a1('0x2')]},'language':{'type':Sequelize[_0x99a1('0x2')]},'accountcode':{'type':Sequelize[_0x99a1('0x2')]},'context':{'type':Sequelize[_0x99a1('0x2')]},'exten':{'type':Sequelize[_0x99a1('0x2')]},'priority':{'type':Sequelize[_0x99a1('0x3')]},'uniqueid':{'type':Sequelize['STRING']},'linkedid':{'type':Sequelize['STRING']},'destchannel':{'type':Sequelize['STRING']},'destchannelstate':{'type':Sequelize[_0x99a1('0x3')]},'destchannelstatedesc':{'type':Sequelize[_0x99a1('0x2')]},'destcalleridnum':{'type':Sequelize['STRING']},'destcalleridname':{'type':Sequelize['STRING']},'destconnectedlinenum':{'type':Sequelize[_0x99a1('0x2')]},'destconnectedlinename':{'type':Sequelize[_0x99a1('0x2')]},'destlanguage':{'type':Sequelize[_0x99a1('0x2')]},'destaccountcode':{'type':Sequelize[_0x99a1('0x2')]},'destcontext':{'type':Sequelize[_0x99a1('0x2')]},'destexten':{'type':Sequelize['STRING']},'destpriority':{'type':Sequelize[_0x99a1('0x3')]},'destuniqueid':{'type':Sequelize[_0x99a1('0x2')]},'destlinkedid':{'type':Sequelize[_0x99a1('0x2')]},'dialstring':{'type':Sequelize[_0x99a1('0x2')]},'dialstatus':{'type':Sequelize[_0x99a1('0x2')]},'starttime':{'type':Sequelize[_0x99a1('0x4')]},'answertime':{'type':Sequelize[_0x99a1('0x4')]},'endtime':{'type':Sequelize[_0x99a1('0x4')]},'lastevent':{'type':Sequelize[_0x99a1('0x2')],'comment':_0x99a1('0x5')},'routeId':{'type':Sequelize[_0x99a1('0x3')]},'duration':{'type':Sequelize[_0x99a1('0x3')]},'holdtime':{'type':Sequelize[_0x99a1('0x3')]},'billableseconds':{'type':Sequelize[_0x99a1('0x3')]}}; \ No newline at end of file diff --git a/server/api/voiceDialReport/voiceDialReport.controller.js b/server/api/voiceDialReport/voiceDialReport.controller.js new file mode 100644 index 0000000..6f5ee24 --- /dev/null +++ b/server/api/voiceDialReport/voiceDialReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x645c=['catch','show','params','keys','intersection','include','find','create','body','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','querystring','../../components/auth/service','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../mysqldb','status','end','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VoiceDialReport','includeAll','findAll','rows'];(function(_0x14a2da,_0x6c5759){var _0x5d5122=function(_0x2dd379){while(--_0x2dd379){_0x14a2da['push'](_0x14a2da['shift']());}};_0x5d5122(++_0x6c5759);}(_0x645c,0xe5));var _0xc645=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x645c[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xc645('0x0'));var rimraf=require(_0xc645('0x1'));var zipdir=require(_0xc645('0x2'));var jsonpatch=require(_0xc645('0x3'));var rp=require(_0xc645('0x4'));var moment=require(_0xc645('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xc645('0x6'));var util=require('util');var path=require('path');var sox=require(_0xc645('0x7'));var csv=require(_0xc645('0x8'));var ejs=require(_0xc645('0x9'));var fs=require('fs');var fs_extra=require(_0xc645('0xa'));var _=require(_0xc645('0xb'));var squel=require(_0xc645('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xc645('0x8'));var querystring=require(_0xc645('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xc645('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0xc645('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0xc645('0x10'));var config=require(_0xc645('0x11'));var licenseUtil=require('../../config/license/util');var db=require(_0xc645('0x12'))['db'];function respondWithStatusCode(_0x481f1e,_0x2a9e89){_0x2a9e89=_0x2a9e89||0xcc;return function(_0x851e25){if(_0x851e25){return _0x481f1e['sendStatus'](_0x2a9e89);}return _0x481f1e[_0xc645('0x13')](_0x2a9e89)[_0xc645('0x14')]();};}function respondWithResult(_0x293d92,_0x269489){_0x269489=_0x269489||0xc8;return function(_0xc55729){if(_0xc55729){return _0x293d92[_0xc645('0x13')](_0x269489)['json'](_0xc55729);}};}function respondWithFilteredResult(_0x489caa,_0x45eb8a){return function(_0x270722){if(_0x270722){var _0x1dc313=typeof _0x45eb8a[_0xc645('0x15')]===_0xc645('0x16')&&typeof _0x45eb8a[_0xc645('0x17')]===_0xc645('0x16');var _0x33a8f5=_0x270722[_0xc645('0x18')];var _0x55133c=_0x1dc313?0x0:_0x45eb8a[_0xc645('0x15')];var _0x5c5e04=_0x1dc313?_0x270722[_0xc645('0x18')]:_0x45eb8a['offset']+_0x45eb8a[_0xc645('0x17')];var _0x1ea196;if(_0x5c5e04>=_0x33a8f5){_0x5c5e04=_0x33a8f5;_0x1ea196=0xc8;}else{_0x1ea196=0xce;}_0x489caa[_0xc645('0x13')](_0x1ea196);return _0x489caa['set'](_0xc645('0x19'),_0x55133c+'-'+_0x5c5e04+'/'+_0x33a8f5)['json'](_0x270722);}return null;};}function patchUpdates(_0x29b592){return function(_0x1059f3){try{jsonpatch[_0xc645('0x1a')](_0x1059f3,_0x29b592,!![]);}catch(_0x1f36f0){return BPromise[_0xc645('0x1b')](_0x1f36f0);}return _0x1059f3[_0xc645('0x1c')]();};}function saveUpdates(_0x40641b,_0x484b9c){return function(_0xedd89b){if(_0xedd89b){return _0xedd89b[_0xc645('0x1d')](_0x40641b)[_0xc645('0x1e')](function(_0x524945){return _0x524945;});}return null;};}function removeEntity(_0xfcbe58,_0x273e62){return function(_0x1a17a0){if(_0x1a17a0){return _0x1a17a0[_0xc645('0x1f')]()[_0xc645('0x1e')](function(){_0xfcbe58[_0xc645('0x13')](0xcc)[_0xc645('0x14')]();});}};}function handleEntityNotFound(_0x1f188a,_0x10c957){return function(_0x3ada34){if(!_0x3ada34){_0x1f188a[_0xc645('0x20')](0x194);}return _0x3ada34;};}function handleError(_0x17ebe9,_0x3a8769){_0x3a8769=_0x3a8769||0x1f4;return function(_0xefd8b2){logger[_0xc645('0x21')](_0xefd8b2[_0xc645('0x22')]);if(_0xefd8b2['name']){delete _0xefd8b2[_0xc645('0x23')];}_0x17ebe9[_0xc645('0x13')](_0x3a8769)[_0xc645('0x24')](_0xefd8b2);};}exports[_0xc645('0x25')]=function(_0x7c3c5c,_0x3d3117){var _0x539927={},_0x5e217a={},_0x52d9e0={'count':0x0,'rows':[]};var _0x42abbd=_[_0xc645('0x26')](db['VoiceDialReport'][_0xc645('0x27')],function(_0x1781a9){return{'name':_0x1781a9[_0xc645('0x28')],'type':_0x1781a9[_0xc645('0x29')][_0xc645('0x2a')]};});_0x5e217a[_0xc645('0x2b')]=_['map'](_0x42abbd,_0xc645('0x23'));_0x5e217a[_0xc645('0x2c')]=_['keys'](_0x7c3c5c['query']);_0x5e217a[_0xc645('0x2d')]=_['intersection'](_0x5e217a[_0xc645('0x2b')],_0x5e217a[_0xc645('0x2c')]);_0x539927[_0xc645('0x2e')]=_['intersection'](_0x5e217a[_0xc645('0x2b')],qs[_0xc645('0x2f')](_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x2f')]));_0x539927['attributes']=_0x539927['attributes'][_0xc645('0x30')]?_0x539927[_0xc645('0x2e')]:_0x5e217a[_0xc645('0x2b')];if(!_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x31')](_0xc645('0x32'))){_0x539927[_0xc645('0x17')]=qs[_0xc645('0x17')](_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x17')]);_0x539927[_0xc645('0x15')]=qs[_0xc645('0x15')](_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x15')]);}_0x539927[_0xc645('0x33')]=qs[_0xc645('0x34')](_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x34')]);_0x539927[_0xc645('0x35')]=qs[_0xc645('0x2d')](_[_0xc645('0x36')](_0x7c3c5c[_0xc645('0x2c')],_0x5e217a[_0xc645('0x2d')]),_0x42abbd);if(_0x7c3c5c[_0xc645('0x2c')][_0xc645('0x37')]){_0x539927[_0xc645('0x35')]=_[_0xc645('0x38')](_0x539927[_0xc645('0x35')],{'$or':_[_0xc645('0x26')](_0x42abbd,function(_0x2d7c21){if(_0x2d7c21[_0xc645('0x29')]!==_0xc645('0x39')){var _0x2bf603={};_0x2bf603[_0x2d7c21[_0xc645('0x23')]]={'$like':'%'+_0x7c3c5c[_0xc645('0x2c')]['filter']+'%'};return _0x2bf603;}})});}_0x539927=_['merge']({},_0x539927,_0x7c3c5c[_0xc645('0x3a')]);var _0x2d221c={'where':_0x539927[_0xc645('0x35')]};return db[_0xc645('0x3b')]['count'](_0x2d221c)[_0xc645('0x1e')](function(_0x468160){_0x52d9e0[_0xc645('0x18')]=_0x468160;if(_0x7c3c5c['query'][_0xc645('0x3c')]){_0x539927['include']=[{'all':!![]}];}return db[_0xc645('0x3b')][_0xc645('0x3d')](_0x539927);})[_0xc645('0x1e')](function(_0x48e117){_0x52d9e0[_0xc645('0x3e')]=_0x48e117;return _0x52d9e0;})[_0xc645('0x1e')](respondWithFilteredResult(_0x3d3117,_0x539927))[_0xc645('0x3f')](handleError(_0x3d3117,null));};exports[_0xc645('0x40')]=function(_0x2dc907,_0x5ea738){var _0x4b03d6={'raw':!![],'where':{'id':_0x2dc907[_0xc645('0x41')]['id']}},_0x5918cb={};_0x5918cb[_0xc645('0x2b')]=_['keys'](db['VoiceDialReport'][_0xc645('0x27')]);_0x5918cb[_0xc645('0x2c')]=_[_0xc645('0x42')](_0x2dc907[_0xc645('0x2c')]);_0x5918cb[_0xc645('0x2d')]=_['intersection'](_0x5918cb[_0xc645('0x2b')],_0x5918cb[_0xc645('0x2c')]);_0x4b03d6[_0xc645('0x2e')]=_[_0xc645('0x43')](_0x5918cb[_0xc645('0x2b')],qs[_0xc645('0x2f')](_0x2dc907['query'][_0xc645('0x2f')]));_0x4b03d6['attributes']=_0x4b03d6[_0xc645('0x2e')][_0xc645('0x30')]?_0x4b03d6[_0xc645('0x2e')]:_0x5918cb[_0xc645('0x2b')];if(_0x2dc907[_0xc645('0x2c')]['includeAll']){_0x4b03d6[_0xc645('0x44')]=[{'all':!![]}];}_0x4b03d6=_[_0xc645('0x38')]({},_0x4b03d6,_0x2dc907[_0xc645('0x3a')]);return db[_0xc645('0x3b')][_0xc645('0x45')](_0x4b03d6)[_0xc645('0x1e')](handleEntityNotFound(_0x5ea738,null))[_0xc645('0x1e')](respondWithResult(_0x5ea738,null))['catch'](handleError(_0x5ea738,null));};exports['create']=function(_0xe37212,_0x1a7a03){return db[_0xc645('0x3b')][_0xc645('0x46')](_0xe37212[_0xc645('0x47')],{})['then'](respondWithResult(_0x1a7a03,0xc9))[_0xc645('0x3f')](handleError(_0x1a7a03,null));};exports[_0xc645('0x1d')]=function(_0x26d697,_0x3cdac0){if(_0x26d697[_0xc645('0x47')]['id']){delete _0x26d697['body']['id'];}return db['VoiceDialReport'][_0xc645('0x45')]({'where':{'id':_0x26d697[_0xc645('0x41')]['id']}})[_0xc645('0x1e')](handleEntityNotFound(_0x3cdac0,null))['then'](saveUpdates(_0x26d697[_0xc645('0x47')],null))[_0xc645('0x1e')](respondWithResult(_0x3cdac0,null))[_0xc645('0x3f')](handleError(_0x3cdac0,null));};exports[_0xc645('0x1f')]=function(_0x3e3344,_0x384c24){return db[_0xc645('0x3b')][_0xc645('0x45')]({'where':{'id':_0x3e3344[_0xc645('0x41')]['id']}})['then'](handleEntityNotFound(_0x384c24,null))[_0xc645('0x1e')](removeEntity(_0x384c24,null))[_0xc645('0x3f')](handleError(_0x384c24,null));};exports['describe']=function(_0x26d8e1,_0x30efe5){return db[_0xc645('0x3b')][_0xc645('0x48')]()[_0xc645('0x1e')](respondWithResult(_0x30efe5,null))[_0xc645('0x3f')](handleError(_0x30efe5,null));}; \ No newline at end of file diff --git a/server/api/voiceDialReport/voiceDialReport.model.js b/server/api/voiceDialReport/voiceDialReport.model.js new file mode 100644 index 0000000..8129624 --- /dev/null +++ b/server/api/voiceDialReport/voiceDialReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2411=['bluebird','request-promise','rimraf','../../config/environment','./voiceDialReport.attributes','exports','define','report_dial','uniqueid','util','../../config/logger','api','moment'];(function(_0x3f0800,_0x6eb84){var _0x19267e=function(_0x4fe065){while(--_0x4fe065){_0x3f0800['push'](_0x3f0800['shift']());}};_0x19267e(++_0x6eb84);}(_0x2411,0x175));var _0x1241=function(_0x5ac1e5,_0x4b5012){_0x5ac1e5=_0x5ac1e5-0x0;var _0x1bccc6=_0x2411[_0x5ac1e5];return _0x1bccc6;};'use strict';var _=require('lodash');var util=require(_0x1241('0x0'));var logger=require(_0x1241('0x1'))(_0x1241('0x2'));var moment=require(_0x1241('0x3'));var BPromise=require(_0x1241('0x4'));var rp=require(_0x1241('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x1241('0x6'));var config=require(_0x1241('0x7'));var attributes=require(_0x1241('0x8'));module[_0x1241('0x9')]=function(_0x3b2074,_0x1f9d02){return _0x3b2074[_0x1241('0xa')]('VoiceDialReport',attributes,{'tableName':_0x1241('0xb'),'paranoid':![],'indexes':[{'fields':[_0x1241('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceDialReport/voiceDialReport.rpc.js b/server/api/voiceDialReport/voiceDialReport.rpc.js new file mode 100644 index 0000000..42c42c2 --- /dev/null +++ b/server/api/voiceDialReport/voiceDialReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x45e1=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','request\x20sent','debug','stringify','error','code','VoiceDialReport,\x20%s,\x20%s','message','info','catch','CreateVoiceDialReport','VoiceDialReport','body','options','then','UpdateVoiceDialReport','update','where','attributes','lodash','moment','randomstring','ioredis'];(function(_0x13843f,_0x50422d){var _0x1063ae=function(_0x12fd6b){while(--_0x12fd6b){_0x13843f['push'](_0x13843f['shift']());}};_0x1063ae(++_0x50422d);}(_0x45e1,0x10a));var _0x145e=function(_0x515283,_0x813dea){_0x515283=_0x515283-0x0;var _0x38f836=_0x45e1[_0x515283];return _0x38f836;};'use strict';var _=require(_0x145e('0x0'));var util=require('util');var moment=require(_0x145e('0x1'));var BPromise=require('bluebird');var rs=require(_0x145e('0x2'));var fs=require('fs');var Redis=require(_0x145e('0x3'));var db=require(_0x145e('0x4'))['db'];var utils=require(_0x145e('0x5'));var logger=require(_0x145e('0x6'))(_0x145e('0x7'));var config=require(_0x145e('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x145e('0x9')][_0x145e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x54850b,_0xe50be0,_0x37c3e2){return new BPromise(function(_0x26f840,_0x470ba0){return client[_0x145e('0xb')](_0x54850b,_0x37c3e2)['then'](function(_0x4035b4){logger['info']('VoiceDialReport,\x20%s,\x20%s',_0xe50be0,_0x145e('0xc'));logger[_0x145e('0xd')]('VoiceDialReport,\x20%s,\x20%s,\x20%s',_0xe50be0,_0x145e('0xc'),JSON[_0x145e('0xe')](_0x4035b4));if(_0x4035b4[_0x145e('0xf')]){if(_0x4035b4['error'][_0x145e('0x10')]===0x1f4){logger[_0x145e('0xf')](_0x145e('0x11'),_0xe50be0,_0x4035b4[_0x145e('0xf')][_0x145e('0x12')]);return _0x470ba0(_0x4035b4[_0x145e('0xf')][_0x145e('0x12')]);}logger[_0x145e('0xf')](_0x145e('0x11'),_0xe50be0,_0x4035b4[_0x145e('0xf')]['message']);return _0x26f840(_0x4035b4[_0x145e('0xf')][_0x145e('0x12')]);}else{logger[_0x145e('0x13')](_0x145e('0x11'),_0xe50be0,_0x145e('0xc'));_0x26f840(_0x4035b4['result'][_0x145e('0x12')]);}})[_0x145e('0x14')](function(_0xc3e47c){logger['error'](_0x145e('0x11'),_0xe50be0,_0xc3e47c);_0x470ba0(_0xc3e47c);});});}exports[_0x145e('0x15')]=function(_0x12a905){var _0x5ae142=this;return new Promise(function(_0x38fc99,_0x52ea60){return db[_0x145e('0x16')]['create'](_0x12a905[_0x145e('0x17')],{'raw':_0x12a905[_0x145e('0x18')]?_0x12a905[_0x145e('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x145e('0x19')](function(_0x5b137c){logger['info'](_0x145e('0x15'),_0x12a905);logger['debug'](_0x145e('0x15'),_0x12a905,JSON[_0x145e('0xe')](_0x5b137c));_0x38fc99(_0x5b137c);})[_0x145e('0x14')](function(_0x271788){logger[_0x145e('0xf')](_0x145e('0x15'),_0x271788['message'],_0x12a905);_0x52ea60(_0x5ae142['error'](0x1f4,_0x271788['message']));});});};exports[_0x145e('0x1a')]=function(_0x2a81e0){var _0x2d1bee=this;return new Promise(function(_0x57a37d,_0x38657a){return db['VoiceDialReport'][_0x145e('0x1b')](_0x2a81e0[_0x145e('0x17')],{'raw':_0x2a81e0[_0x145e('0x18')]?_0x2a81e0[_0x145e('0x18')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2a81e0[_0x145e('0x18')]?_0x2a81e0[_0x145e('0x18')][_0x145e('0x1c')]||null:null,'attributes':_0x2a81e0[_0x145e('0x18')]?_0x2a81e0['options'][_0x145e('0x1d')]||null:null,'limit':_0x2a81e0[_0x145e('0x18')]?_0x2a81e0[_0x145e('0x18')]['limit']||null:null})[_0x145e('0x19')](function(_0x4add22){logger[_0x145e('0x13')]('UpdateVoiceDialReport',_0x2a81e0);logger[_0x145e('0xd')](_0x145e('0x1a'),_0x2a81e0,JSON['stringify'](_0x4add22));_0x57a37d(_0x4add22);})[_0x145e('0x14')](function(_0x2d3441){logger[_0x145e('0xf')](_0x145e('0x1a'),_0x2d3441[_0x145e('0x12')],_0x2a81e0);_0x38657a(_0x2d1bee['error'](0x1f4,_0x2d3441['message']));});});}; \ No newline at end of file diff --git a/server/api/voiceExtension/index.js b/server/api/voiceExtension/index.js new file mode 100644 index 0000000..d200a99 --- /dev/null +++ b/server/api/voiceExtension/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc6af=['exports','multer','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./voiceExtension.controller','get','index','/:id','show','post','isAuthenticated','/:id/applications','update','delete'];(function(_0x32c819,_0x1f75c3){var _0x2a5145=function(_0x519b06){while(--_0x519b06){_0x32c819['push'](_0x32c819['shift']());}};_0x2a5145(++_0x1f75c3);}(_0xc6af,0x1e1));var _0xfc6a=function(_0x28bc39,_0x384426){_0x28bc39=_0x28bc39-0x0;var _0x2d40be=_0xc6af[_0x28bc39];return _0x2d40be;};'use strict';var multer=require(_0xfc6a('0x0'));var util=require('util');var path=require(_0xfc6a('0x1'));var timeout=require(_0xfc6a('0x2'));var express=require(_0xfc6a('0x3'));var router=express[_0xfc6a('0x4')]();var fs_extra=require(_0xfc6a('0x5'));var auth=require(_0xfc6a('0x6'));var interaction=require(_0xfc6a('0x7'));var config=require(_0xfc6a('0x8'));var controller=require(_0xfc6a('0x9'));router[_0xfc6a('0xa')]('/',auth['isAuthenticated'](),controller[_0xfc6a('0xb')]);router[_0xfc6a('0xa')](_0xfc6a('0xc'),auth['isAuthenticated'](),controller[_0xfc6a('0xd')]);router[_0xfc6a('0xe')]('/',auth[_0xfc6a('0xf')](),controller['create']);router[_0xfc6a('0xe')](_0xfc6a('0x10'),auth[_0xfc6a('0xf')](),controller['addApplications']);router['put'](_0xfc6a('0xc'),auth[_0xfc6a('0xf')](),controller[_0xfc6a('0x11')]);router[_0xfc6a('0x12')](_0xfc6a('0xc'),auth[_0xfc6a('0xf')](),controller['destroy']);module[_0xfc6a('0x13')]=router; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.attributes.js b/server/api/voiceExtension/voiceExtension.attributes.js new file mode 100644 index 0000000..6138ee3 --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xce7f=['internal','inbound-fax','outbound-fax','system','any','*,*,*,*','INTEGER','BOOLEAN','wav','getDataValue','exten','exports','STRING','NoOp','ENUM','inbound','outbound'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0xce7f,0x170));var _0xfce7=function(_0x23af31,_0x8a1add){_0x23af31=_0x23af31-0x0;var _0x49b82f=_0xce7f[_0x23af31];return _0x49b82f;};'use strict';var Sequelize=require('sequelize');module[_0xfce7('0x0')]={'context':{'type':Sequelize[_0xfce7('0x1')],'allowNull':![],'unique':'compositeIndex','validate':{'notEmpty':!![],'is':/[A-Za-z0-9._\+*!\-\[\]]+$/i}},'exten':{'type':Sequelize['STRING'],'allowNull':![],'unique':'compositeIndex'},'priority':{'type':Sequelize[_0xfce7('0x1')],'allowNull':![],'defaultValue':'1','unique':'compositeIndex'},'tag':{'type':Sequelize[_0xfce7('0x1')],'allowNull':![],'defaultValue':'--'},'app':{'type':Sequelize['STRING'],'allowNull':![],'defaultValue':_0xfce7('0x2')},'appdata':{'type':Sequelize[_0xfce7('0x1')](0x1000),'allowNull':!![],'defaultValue':''},'type':{'type':Sequelize[_0xfce7('0x3')](_0xfce7('0x4'),_0xfce7('0x5'),_0xfce7('0x6'),_0xfce7('0x7'),_0xfce7('0x8'),_0xfce7('0x9'),_0xfce7('0xa')),'allowNull':![]},'description':{'type':Sequelize['STRING']},'interval':{'type':Sequelize[_0xfce7('0x1')],'allowNull':![],'defaultValue':_0xfce7('0xb')},'IntervalId':{'type':Sequelize[_0xfce7('0xc')]},'isApp':{'type':Sequelize[_0xfce7('0xd')],'allowNull':![],'defaultValue':![]},'appType':{'type':Sequelize[_0xfce7('0x1')],'defaultValue':null},'callerID':{'type':Sequelize['STRING'],'allowNull':!![]},'record':{'type':Sequelize[_0xfce7('0xd')],'defaultValue':![]},'cutdigits':{'type':Sequelize['INTEGER']},'recordingFormat':{'type':Sequelize[_0xfce7('0x1')],'defaultValue':_0xfce7('0xe')},'answer':{'type':Sequelize['BOOLEAN'],'defaultValue':!![]},'name':{'type':Sequelize['VIRTUAL'],'get':function(_0x20f820){return this[_0xfce7('0xf')](_0xfce7('0x10'));}},'alias':{'type':Sequelize[_0xfce7('0x1')],'allowNull':!![]}}; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.controller.js b/server/api/voiceExtension/voiceExtension.controller.js new file mode 100644 index 0000000..9cc461b --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9faf=['error','stack','name','send','VoiceExtension','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','options','find','create','outbound','body','exten','concat','user','value','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','context','description','recordingFormat','cutdigits','mandatoryDisposition','alias','addApplications','sequelize','transaction','ISOLATION_LEVELS','READ_COMMITTED','createRouting','bulkCreate','cast(priority\x20as\x20unsigned)','finally','lodash','ioredis','../../components/parsers/qs','api','../../mysqldb','redis','defaults','localhost','./voiceExtension.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','destroy','then','get','InboundRoutes','inbound','OutboundRoutes','InternalRoutes','internal','map','includes','type','UserProfileResource'];(function(_0x4a5c7a,_0x6e37d4){var _0x1650ac=function(_0x484bf7){while(--_0x484bf7){_0x4a5c7a['push'](_0x4a5c7a['shift']());}};_0x1650ac(++_0x6e37d4);}(_0x9faf,0xf4));var _0xf9fa=function(_0x226c3f,_0x18fbd7){_0x226c3f=_0x226c3f-0x0;var _0x2f9232=_0x9faf[_0x226c3f];return _0x2f9232;};'use strict';var _=require(_0xf9fa('0x0'));var Redis=require(_0xf9fa('0x1'));var qs=require(_0xf9fa('0x2'));var logger=require('../../config/logger')(_0xf9fa('0x3'));var config=require('../../config/environment');var db=require(_0xf9fa('0x4'))['db'];config[_0xf9fa('0x5')]=_[_0xf9fa('0x6')](config[_0xf9fa('0x5')],{'host':_0xf9fa('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf9fa('0x5')]));require(_0xf9fa('0x8'))[_0xf9fa('0x9')](socket);function respondWithStatusCode(_0x615f21,_0x13ac56){_0x13ac56=_0x13ac56||0xcc;return function(_0x50898b){if(_0x50898b){return _0x615f21[_0xf9fa('0xa')](_0x13ac56);}return _0x615f21[_0xf9fa('0xb')](_0x13ac56)[_0xf9fa('0xc')]();};}function respondWithResult(_0x180af1,_0x172046){_0x172046=_0x172046||0xc8;return function(_0x4603f6){if(_0x4603f6){return _0x180af1[_0xf9fa('0xb')](_0x172046)[_0xf9fa('0xd')](_0x4603f6);}};}function respondWithFilteredResult(_0xad49f0,_0x270b01){return function(_0x4896e9){if(_0x4896e9){var _0x2803f2=typeof _0x270b01[_0xf9fa('0xe')]===_0xf9fa('0xf')&&typeof _0x270b01[_0xf9fa('0x10')]==='undefined';var _0x334f5a=_0x4896e9[_0xf9fa('0x11')];var _0x598695=_0x2803f2?0x0:_0x270b01['offset'];var _0x1d5fb7=_0x2803f2?_0x4896e9['count']:_0x270b01[_0xf9fa('0xe')]+_0x270b01['limit'];var _0x468933;if(_0x1d5fb7>=_0x334f5a){_0x1d5fb7=_0x334f5a;_0x468933=0xc8;}else{_0x468933=0xce;}_0xad49f0[_0xf9fa('0xb')](_0x468933);return _0xad49f0[_0xf9fa('0x12')](_0xf9fa('0x13'),_0x598695+'-'+_0x1d5fb7+'/'+_0x334f5a)[_0xf9fa('0xd')](_0x4896e9);}return null;};}function removeEntity(_0x2014ac){return function(_0x34cd3c){if(_0x34cd3c){return _0x34cd3c[_0xf9fa('0x14')]()[_0xf9fa('0x15')](function(){var _0x1fd132=_0x34cd3c[_0xf9fa('0x16')]({'plain':!![]});var _0x455005=[{'name':_0xf9fa('0x17'),'value':_0xf9fa('0x18'),'ignore':![]},{'name':_0xf9fa('0x19'),'value':'outbound','ignore':![]},{'name':_0xf9fa('0x1a'),'value':_0xf9fa('0x1b'),'ignore':![]}];var _0xadb6d4=_(_0x455005)['filter']('ignore')[_0xf9fa('0x1c')]('value')['value']();if(_[_0xf9fa('0x1d')](_0xadb6d4,_0x1fd132[_0xf9fa('0x1e')])){return;}var _0x5b7a77=_['find'](_0x455005,['value',_0x1fd132['type']])['name'];return db[_0xf9fa('0x1f')][_0xf9fa('0x14')]({'where':{'type':_0x5b7a77,'resourceId':_0x1fd132['id']}})['then'](function(){return _0x34cd3c;});})['then'](function(){_0x2014ac[_0xf9fa('0xb')](0xcc)[_0xf9fa('0xc')]();});}};}function handleEntityNotFound(_0x2eb1a5){return function(_0x4a39d3){if(!_0x4a39d3){_0x2eb1a5['sendStatus'](0x194);}return _0x4a39d3;};}function handleError(_0x2de098,_0x442697){_0x442697=_0x442697||0x1f4;return function(_0x2b5b30){logger[_0xf9fa('0x20')](_0x2b5b30[_0xf9fa('0x21')]);if(_0x2b5b30[_0xf9fa('0x22')]){delete _0x2b5b30[_0xf9fa('0x22')];}_0x2de098[_0xf9fa('0xb')](_0x442697)[_0xf9fa('0x23')](_0x2b5b30);};}exports['index']=function(_0x2ac541,_0x1c0ff4){var _0x504114={},_0x3df9a1={},_0x2661a2={'count':0x0,'rows':[]};var _0x2b1036=_[_0xf9fa('0x1c')](db[_0xf9fa('0x24')]['rawAttributes'],function(_0x4b1085){return{'name':_0x4b1085[_0xf9fa('0x25')],'type':_0x4b1085['type'][_0xf9fa('0x26')]};});_0x3df9a1[_0xf9fa('0x27')]=_['map'](_0x2b1036,_0xf9fa('0x22'));_0x3df9a1[_0xf9fa('0x28')]=_[_0xf9fa('0x29')](_0x2ac541['query']);_0x3df9a1[_0xf9fa('0x2a')]=_[_0xf9fa('0x2b')](_0x3df9a1['model'],_0x3df9a1[_0xf9fa('0x28')]);_0x504114['attributes']=_[_0xf9fa('0x2b')](_0x3df9a1[_0xf9fa('0x27')],qs[_0xf9fa('0x2c')](_0x2ac541['query']['fields']));_0x504114[_0xf9fa('0x2d')]=_0x504114[_0xf9fa('0x2d')][_0xf9fa('0x2e')]?_0x504114[_0xf9fa('0x2d')]:_0x3df9a1[_0xf9fa('0x27')];if(!_0x2ac541[_0xf9fa('0x28')][_0xf9fa('0x2f')](_0xf9fa('0x30'))){_0x504114[_0xf9fa('0x10')]=qs[_0xf9fa('0x10')](_0x2ac541[_0xf9fa('0x28')][_0xf9fa('0x10')]);_0x504114['offset']=qs[_0xf9fa('0xe')](_0x2ac541[_0xf9fa('0x28')][_0xf9fa('0xe')]);}_0x504114[_0xf9fa('0x31')]=qs[_0xf9fa('0x32')](_0x2ac541[_0xf9fa('0x28')]['sort']);_0x504114[_0xf9fa('0x33')]=qs[_0xf9fa('0x2a')](_[_0xf9fa('0x34')](_0x2ac541['query'],_0x3df9a1[_0xf9fa('0x2a')]),_0x2b1036);if(_0x2ac541[_0xf9fa('0x28')][_0xf9fa('0x35')]){_0x504114['where']=_[_0xf9fa('0x36')](_0x504114['where'],{'$or':_['map'](_0x2b1036,function(_0x36f32a){if(_0x36f32a['type']!==_0xf9fa('0x37')){var _0x30feef={};_0x30feef[_0x36f32a['name']]={'$like':'%'+_0x2ac541[_0xf9fa('0x28')]['filter']+'%'};return _0x30feef;}})});}_0x504114=_[_0xf9fa('0x36')]({},_0x504114,_0x2ac541['options']);var _0x5e1eb7={'where':_0x504114[_0xf9fa('0x33')]};return db['VoiceExtension'][_0xf9fa('0x11')](_0x5e1eb7)['then'](function(_0x55d5fc){_0x2661a2['count']=_0x55d5fc;if(_0x2ac541[_0xf9fa('0x28')][_0xf9fa('0x38')]){_0x504114[_0xf9fa('0x39')]=[{'all':!![]}];}return db[_0xf9fa('0x24')][_0xf9fa('0x3a')](_0x504114);})[_0xf9fa('0x15')](function(_0x574189){_0x2661a2[_0xf9fa('0x3b')]=_0x574189;return _0x2661a2;})[_0xf9fa('0x15')](respondWithFilteredResult(_0x1c0ff4,_0x504114))[_0xf9fa('0x3c')](handleError(_0x1c0ff4,null));};exports[_0xf9fa('0x3d')]=function(_0x53db8a,_0x3cfc2b){var _0x433835={'raw':![],'where':{'id':_0x53db8a[_0xf9fa('0x3e')]['id']}},_0x63f1fc={};_0x63f1fc[_0xf9fa('0x27')]=_[_0xf9fa('0x29')](db['VoiceExtension']['rawAttributes']);_0x63f1fc[_0xf9fa('0x28')]=_[_0xf9fa('0x29')](_0x53db8a[_0xf9fa('0x28')]);_0x63f1fc[_0xf9fa('0x2a')]=_['intersection'](_0x63f1fc[_0xf9fa('0x27')],_0x63f1fc[_0xf9fa('0x28')]);_0x433835[_0xf9fa('0x2d')]=_[_0xf9fa('0x2b')](_0x63f1fc[_0xf9fa('0x27')],qs[_0xf9fa('0x2c')](_0x53db8a['query'][_0xf9fa('0x2c')]));_0x433835['attributes']=_0x433835[_0xf9fa('0x2d')][_0xf9fa('0x2e')]?_0x433835[_0xf9fa('0x2d')]:_0x63f1fc[_0xf9fa('0x27')];if(_0x53db8a['query'][_0xf9fa('0x38')]){_0x433835[_0xf9fa('0x39')]=[{'all':!![]}];}_0x433835=_[_0xf9fa('0x36')]({},_0x433835,_0x53db8a[_0xf9fa('0x3f')]);return db[_0xf9fa('0x24')][_0xf9fa('0x40')](_0x433835)['then'](handleEntityNotFound(_0x3cfc2b,null))[_0xf9fa('0x15')](respondWithResult(_0x3cfc2b,null))[_0xf9fa('0x3c')](handleError(_0x3cfc2b,null));};exports[_0xf9fa('0x14')]=function(_0xaf4bc9,_0x968bff){return db[_0xf9fa('0x24')][_0xf9fa('0x40')]({'where':{'id':_0xaf4bc9[_0xf9fa('0x3e')]['id']}})[_0xf9fa('0x15')](handleEntityNotFound(_0x968bff,null))[_0xf9fa('0x15')](removeEntity(_0x968bff,null))['catch'](handleError(_0x968bff,null));};exports[_0xf9fa('0x41')]=function(_0x244bce,_0x10bd7f){if(_0x244bce['body'][_0xf9fa('0x1e')]===_0xf9fa('0x42')&&!_['startsWith'](_0x244bce[_0xf9fa('0x43')][_0xf9fa('0x44')],'_')){_0x244bce[_0xf9fa('0x43')][_0xf9fa('0x44')]='_'[_0xf9fa('0x45')](_0x244bce[_0xf9fa('0x43')][_0xf9fa('0x44')]);}return db[_0xf9fa('0x24')]['create'](_0x244bce[_0xf9fa('0x43')],{'raw':![]})[_0xf9fa('0x15')](function(_0x513a2){var _0x23f25d=_0x244bce[_0xf9fa('0x46')]['get']({'plain':!![]});if(!_0x23f25d)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x23f25d['role']===_0xf9fa('0x46')){var _0x58d3a2=_0x513a2[_0xf9fa('0x16')]({'plain':!![]});var _0x259550=[{'name':'InboundRoutes','value':_0xf9fa('0x18')},{'name':_0xf9fa('0x19'),'value':_0xf9fa('0x42')},{'name':'InternalRoutes','value':_0xf9fa('0x1b')}];var _0x5b6120=_[_0xf9fa('0x40')](_0x259550,[_0xf9fa('0x47'),_0x58d3a2['type']])['name'];return db[_0xf9fa('0x48')][_0xf9fa('0x40')]({'where':{'name':_0x5b6120,'userProfileId':_0x23f25d[_0xf9fa('0x49')]},'raw':!![]})[_0xf9fa('0x15')](function(_0x5af1e7){if(_0x5af1e7&&_0x5af1e7[_0xf9fa('0x4a')]===0x0){return db[_0xf9fa('0x1f')][_0xf9fa('0x41')]({'name':_0x58d3a2[_0xf9fa('0x22')],'resourceId':_0x58d3a2['id'],'type':_0x5af1e7['name'],'sectionId':_0x5af1e7['id']},{})[_0xf9fa('0x15')](function(){return _0x513a2;});}else{return _0x513a2;}})[_0xf9fa('0x3c')](function(_0x1dbed7){logger[_0xf9fa('0x20')](_0xf9fa('0x4b'),_0x1dbed7);throw _0x1dbed7;});}return _0x513a2;})[_0xf9fa('0x15')](respondWithResult(_0x10bd7f,0xc9))[_0xf9fa('0x3c')](handleError(_0x10bd7f,null));};exports[_0xf9fa('0x4c')]=function(_0x5ef0b8,_0x1e3619){if(_0x5ef0b8[_0xf9fa('0x43')]['id']){delete _0x5ef0b8[_0xf9fa('0x43')]['id'];}return db[_0xf9fa('0x24')][_0xf9fa('0x40')]({'where':{'id':_0x5ef0b8[_0xf9fa('0x3e')]['id']}})[_0xf9fa('0x15')](handleEntityNotFound(_0x1e3619,null))[_0xf9fa('0x15')](function(_0x566e56){if(_0x566e56){return db['VoiceExtension']['update'](_['pick'](_0x5ef0b8[_0xf9fa('0x43')],['exten',_0xf9fa('0x4d'),_0xf9fa('0x4e'),_0xf9fa('0x4f'),_0xf9fa('0x50'),_0xf9fa('0x51'),_0xf9fa('0x52')]),{'where':{'context':_0x566e56[_0xf9fa('0x4d')],'exten':_0x566e56[_0xf9fa('0x44')]},'individualHooks':!![]})[_0xf9fa('0x15')](function(_0x41d6a5){return _0x41d6a5;});}return null;})['then'](respondWithStatusCode(_0x1e3619,null))[_0xf9fa('0x3c')](handleError(_0x1e3619,null));};exports[_0xf9fa('0x53')]=function(_0x2f22db,_0x5e74f2){var _0x3e9045=_0x2f22db[_0xf9fa('0x3e')]['id'];var _0x587be4=_0x2f22db[_0xf9fa('0x43')];var _0x39b215=0xc8;var _0x39d51d=null;return db[_0xf9fa('0x54')][_0xf9fa('0x55')]({'isolationLevel':db[_0xf9fa('0x54')]['Transaction'][_0xf9fa('0x56')][_0xf9fa('0x57')]},function(_0x99f98){return db[_0xf9fa('0x24')]['findOne']({'where':{'id':_0x3e9045},'transaction':_0x99f98})[_0xf9fa('0x15')](function(_0xebaa84){if(_0xebaa84){return db['VoiceExtension'][_0xf9fa('0x14')]({'where':{'VoiceExtensionId':_0x3e9045},'transaction':_0x99f98})[_0xf9fa('0x15')](function(){var _0x5e9792=_[_0xf9fa('0x1c')](_0x587be4,function(_0x26b938){_0x26b938['VoiceExtensionId']=_0x3e9045;_0x26b938['isApp']=!![];return _0x26b938;});return _0xebaa84[_0xf9fa('0x58')](_0x5e9792);})['then'](function(_0x53f3bb){return db[_0xf9fa('0x24')][_0xf9fa('0x59')](_0x53f3bb,{'transaction':_0x99f98});});}else{_0x39b215=0x194;_0x39d51d=[];}});})[_0xf9fa('0x15')](function(){if(_0x39b215!==0x194){return db[_0xf9fa('0x24')]['findAndCountAll']({'where':{'isApp':!![],'VoiceExtensionId':_0x3e9045},'order':_0xf9fa('0x5a')})[_0xf9fa('0x15')](function(_0x1471e7){_0x39d51d=_0x1471e7;});}})['catch'](function(_0x392d4b){_0x39b215=0x1f4;logger[_0xf9fa('0x20')](_0x392d4b[_0xf9fa('0x21')]);if(_0x392d4b[_0xf9fa('0x22')]){delete _0x392d4b[_0xf9fa('0x22')];}_0x39d51d=_0x392d4b;})[_0xf9fa('0x5b')](function(){if(_0x39d51d===null){_0x5e74f2['sendStatus'](_0x39b215);}else{if(_0x39b215===0x1f4){_0x5e74f2['status'](_0x39b215)[_0xf9fa('0x23')](_0x39d51d);}else{_0x5e74f2[_0xf9fa('0xb')](_0x39b215)[_0xf9fa('0xd')](_0x39d51d);}}});}; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.events.js b/server/api/voiceExtension/voiceExtension.events.js new file mode 100644 index 0000000..f256ff6 --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0c49=['events','../../mysqldb','setMaxListeners','save','update','emit','hook','exports'];(function(_0x439e8b,_0x456333){var _0x1389ef=function(_0x186832){while(--_0x186832){_0x439e8b['push'](_0x439e8b['shift']());}};_0x1389ef(++_0x456333);}(_0x0c49,0x198));var _0x90c4=function(_0x3adc1c,_0x277bc8){_0x3adc1c=_0x3adc1c-0x0;var _0xa592bc=_0x0c49[_0x3adc1c];return _0xa592bc;};'use strict';var EventEmitter=require(_0x90c4('0x0'));var VoiceExtension=require(_0x90c4('0x1'))['db']['VoiceExtension'];var VoiceExtensionEvents=new EventEmitter();VoiceExtensionEvents[_0x90c4('0x2')](0x0);var events={'afterCreate':_0x90c4('0x3'),'afterUpdate':_0x90c4('0x4'),'afterDestroy':'remove'};function emitEvent(_0x33159b){return function(_0x59b197,_0x13b37d,_0x154242){VoiceExtensionEvents[_0x90c4('0x5')](_0x33159b+':'+_0x59b197['id'],_0x59b197);VoiceExtensionEvents['emit'](_0x33159b,_0x59b197);_0x154242(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];VoiceExtension[_0x90c4('0x6')](e,emitEvent(event));}}module[_0x90c4('0x7')]=VoiceExtensionEvents; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.model.js b/server/api/voiceExtension/voiceExtension.model.js new file mode 100644 index 0000000..cfebc58 --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbeea=['$[${XCALLY-MOTION-PROGRESS}=0]?Progress','XCALLY-MOTION-PROGRESS=1','GotoIfTime',',${EXTEN},','outboundDial','appdata','last','priority','concat','catch','VoiceExtension','voice_extensions','get','then','Hangup','lodash','exports','type','Set','CDR(type)=','exten','alias','CDR(routeAlias)=','No\x20alias\x20set','context','inbound','push','CDR(routeid)=','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','outbound','CDR(type)=outbound','cutdigits','ExecIf','$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto(','):Goto(','CDR(prefix)=${EXTEN:0:','CDR(prefix)=noprefix','XCALLY-MOTION-ANSWER=0','outboundrouteid=','recordingFormat','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','wav','trunk','timeout','options','url','split','param','prefix','phone','${EXTEN:','${EXTEN}','SIP','none','indexOf','U(xcally-mixmonitor-context)','replace','join','isEmpty','Interval','findAll','interval','IntervalId','intervals','map','filter','toLowerCase','hasOwnProperty','tag','length','callerID','Set(CALLERID(all)=','NoOp(No\x20number\x20available)','answer','queue','playback','app','appType','$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1'];(function(_0x36504d,_0x2918e7){var _0x1200a6=function(_0x326c8c){while(--_0x326c8c){_0x36504d['push'](_0x36504d['shift']());}};_0x1200a6(++_0x2918e7);}(_0xbeea,0xb1));var _0xabee=function(_0x46226f,_0x1abd11){_0x46226f=_0x46226f-0x0;var _0x15fc73=_0xbeea[_0x46226f];return _0x15fc73;};'use strict';var _=require(_0xabee('0x0'));var attributes=require('./voiceExtension.attributes');module[_0xabee('0x1')]=function(_0x3b377b){var _0x35ca8b=_0x3b377b['models'];function _0x972e88(_0x59e264){var _0x58afa7=0x2;var _0x33571e=[{'type':_0x59e264[_0xabee('0x2')],'app':_0xabee('0x3'),'appdata':_0xabee('0x4')+_0x59e264['type'],'context':_0x59e264['context'],'exten':_0x59e264[_0xabee('0x5')],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']},{'type':_0x59e264[_0xabee('0x2')],'app':_0x59e264['alias']?_0xabee('0x3'):'NoOp','appdata':_0x59e264[_0xabee('0x6')]?_0xabee('0x7')+_0x59e264[_0xabee('0x6')]:_0xabee('0x8'),'context':_0x59e264[_0xabee('0x9')],'exten':_0x59e264[_0xabee('0x5')],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']}];if(_0x59e264['type']===_0xabee('0xa')){_0x33571e[_0xabee('0xb')]({'type':_0xabee('0xa'),'app':'Set','appdata':_0xabee('0xc')+_0x59e264['id'],'context':_0x59e264[_0xabee('0x9')],'exten':_0x59e264[_0xabee('0x5')],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']});}_0x33571e['push']({'type':_0x59e264['type'],'app':'Set','appdata':'XCALLY-MOTION-ANSWER=0','context':_0x59e264['context'],'exten':_0x59e264[_0xabee('0x5')],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']},{'type':_0x59e264[_0xabee('0x2')],'app':_0xabee('0x3'),'appdata':_0xabee('0xd'),'context':_0x59e264[_0xabee('0x9')],'exten':_0x59e264['exten'],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']},{'type':_0x59e264[_0xabee('0x2')],'app':_0xabee('0x3'),'appdata':_0xabee('0xe'),'context':_0x59e264[_0xabee('0x9')],'exten':_0x59e264[_0xabee('0x5')],'priority':_0x58afa7++,'VoiceExtensionId':_0x59e264['id']});return _0x33571e;}function _0x2d6e69(_0x440413){var _0x5a9562=0x2;var _0x33e3c0=[{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0xabee('0x10'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':'outbound','app':_0x440413['alias']?_0xabee('0x3'):'NoOp','appdata':_0x440413['alias']?_0xabee('0x7')+_0x440413[_0xabee('0x6')]:_0xabee('0x8'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':'outbound','app':_0xabee('0x3'),'appdata':'CDR(destination)='+(_0x440413['cutdigits']?'${EXTEN:'+_0x440413[_0xabee('0x11')]+'}':'${EXTEN}'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0xabee('0xc')+_0x440413['id'],'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':'outbound','app':_0xabee('0x12'),'appdata':_0xabee('0x13')+(_0x5a9562+0x2)+_0xabee('0x14')+(_0x5a9562+0x1)+')','context':_0x440413[_0xabee('0x9')],'exten':_0x440413['exten'],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0x440413['cutdigits']?_0xabee('0x15')+_0x440413[_0xabee('0x11')]+'}':_0xabee('0x16'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413['exten'],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0xabee('0x17'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0xabee('0xd'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413['exten'],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':'Set','appdata':_0xabee('0xe'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':'Set','appdata':_0xabee('0x18')+_0x440413['id'],'context':_0x440413['context'],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']}];if(_0x440413['hasOwnProperty'](_0xabee('0x19'))&&_0x440413['recordingFormat']!=='none'){_0x33e3c0[_0xabee('0xb')]({'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':_0xabee('0x1a'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']},{'type':_0xabee('0xf'),'app':_0xabee('0x3'),'appdata':'_XCALLY_MIXMONITOR_FORMAT='+_0x440413[_0xabee('0x19')]||_0xabee('0x1b'),'context':_0x440413[_0xabee('0x9')],'exten':_0x440413[_0xabee('0x5')],'priority':_0x5a9562++,'VoiceExtensionId':_0x440413['id']});}return _0x33e3c0;}function _0x146ae9(_0x77c942,_0x9703eb){var _0x2d0953=[{'name':_0xabee('0x1c'),'param':0x0},{'name':_0xabee('0x1d'),'param':0x1},{'name':_0xabee('0x1e'),'param':0x2},{'name':_0xabee('0x1f'),'param':0x3}];var _0xb1ef34={};var _0x2ca217=_0x9703eb[_0xabee('0x20')](',');var _0x2e2769=[];for(var _0x3db173=0x0;_0x3db173<_0x2d0953['length'];_0x3db173++){switch(_0x2d0953[_0x3db173]['name']){case _0xabee('0x1c'):_0xb1ef34[_0xabee('0x1c')]=_0x2ca217[_0x2d0953[_0x3db173][_0xabee('0x21')]][_0xabee('0x20')]('/')[0x1];_0xb1ef34['phone']=_0x2ca217[_0x2d0953[_0x3db173][_0xabee('0x21')]][_0xabee('0x20')]('/')[0x2];_0xb1ef34[_0xabee('0x22')]=_0xb1ef34['phone']?_0xb1ef34[_0xabee('0x23')]['split']('$')[0x0]:undefined;_0xb1ef34[_0xabee('0x23')]=_0x77c942[_0xabee('0x11')]?(_0xb1ef34[_0xabee('0x22')]||'')+_0xabee('0x24')+_0x77c942['cutdigits']+'}':(_0xb1ef34['prefix']||'')+_0xabee('0x25');_0x2e2769[_0x2d0953[_0x3db173][_0xabee('0x21')]]=[_0xabee('0x26'),_0xb1ef34[_0xabee('0x1c')],_0xb1ef34[_0xabee('0x23')]]['join']('/');break;case _0xabee('0x1e'):_0xb1ef34[_0xabee('0x1e')]=_0x2ca217[_0x2d0953[_0x3db173]['param']];if(_0x77c942[_0xabee('0x19')]!==_0xabee('0x27')){if(_0xb1ef34['options'][_0xabee('0x28')](_0xabee('0x29'))<0x0){_0xb1ef34[_0xabee('0x1e')]+=_0xabee('0x29');}}else{_0xb1ef34[_0xabee('0x1e')]=_0xb1ef34[_0xabee('0x1e')][_0xabee('0x2a')]('U(xcally-mixmonitor-context)','');}_0x2e2769[_0x2d0953[_0x3db173][_0xabee('0x21')]]=_0xb1ef34[_0xabee('0x1e')];break;default:_0x2e2769[_0x2d0953[_0x3db173][_0xabee('0x21')]]=_0x2ca217[_0x2d0953[_0x3db173]['param']];}}return _0x2e2769[_0xabee('0x2b')](',');}function _0x2701b7(_0x5a918e,_0x29ffe9,_0x1475f3){return new Promise(function(_0x50b996,_0x1ce8ae){var _0x2e3675=[];if(_[_0xabee('0x2c')](_0x29ffe9))return _0x50b996(_0x2e3675);_0x35ca8b[_0xabee('0x2d')][_0xabee('0x2e')]({'attributes':['id',_0xabee('0x2f'),_0xabee('0x30')],'raw':!![]})['then'](function(_0x2aa2f0){for(var _0x23735d=0x0,_0x441af1=0x0;_0x23735d<_0x29ffe9['length'];_0x23735d++,_0x441af1=0x0){var _0x444a92=_0x29ffe9[_0x23735d];var _0x2e83e0=[];var _0x5ae15a=[];delete _0x444a92['id'];if(_0x444a92['interval']!=='*,*,*,*'){_0x444a92[_0xabee('0x31')]=[_0x444a92[_0xabee('0x2f')]];}else{_0x444a92['intervals']=_0x444a92['IntervalId']?_[_0xabee('0x32')](_[_0xabee('0x33')](_0x2aa2f0,{'IntervalId':_0x444a92[_0xabee('0x30')]}),_0xabee('0x2f')):[];}_0x444a92[_0xabee('0x9')]=_0x5a918e[_0xabee('0x9')];_0x444a92[_0xabee('0x5')]=_0x5a918e[_0xabee('0x5')];if(_0x444a92[_0xabee('0x2')])_0x444a92[_0xabee('0x2')]=_0x444a92[_0xabee('0x2')][_0xabee('0x34')]();if(_0x5a918e[_0xabee('0x2')]===_0xabee('0xf')){if(_0x444a92[_0xabee('0x35')](_0xabee('0x36'))&&_0x444a92[_0xabee('0x36')]&&_0x444a92[_0xabee('0x36')]!=='--'){_0x2e83e0['push']({'type':_0x444a92[_0xabee('0x2')][_0xabee('0x34')](),'app':'Set','appdata':'CDR(tag)='+_0x444a92[_0xabee('0x36')],'context':_0x5a918e[_0xabee('0x9')],'exten':_0x5a918e[_0xabee('0x5')],'priority':_0x444a92[_0xabee('0x31')][_0xabee('0x37')]+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});}_0x2e83e0[_0xabee('0xb')]({'type':_0x444a92[_0xabee('0x2')]['toLowerCase'](),'app':_0xabee('0x12'),'appdata':'$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):'+(_0x444a92[_0xabee('0x38')]?_0xabee('0x39')+_0x444a92['callerID']+')':_0xabee('0x3a')),'context':_0x5a918e[_0xabee('0x9')],'exten':_0x5a918e[_0xabee('0x5')],'priority':_0x444a92['intervals'][_0xabee('0x37')]+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});}else{if(_0x444a92['hasOwnProperty'](_0xabee('0x3b'))){if([_0xabee('0x3c'),_0xabee('0x3d')]['includes'](_0x444a92[_0xabee('0x3e')][_0xabee('0x34')]())&&_0x444a92[_0xabee('0x3f')]!=='custom'){if(_0x444a92[_0xabee('0x3b')]){_0x2e83e0[_0xabee('0xb')]({'type':_0x444a92[_0xabee('0x2')][_0xabee('0x34')](),'app':'ExecIf','appdata':_0xabee('0x40'),'context':_0x5a918e[_0xabee('0x9')],'exten':_0x5a918e[_0xabee('0x5')],'priority':_0x444a92['intervals'][_0xabee('0x37')]+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});_0x2e83e0[_0xabee('0xb')]({'type':_0x444a92[_0xabee('0x2')][_0xabee('0x34')](),'app':_0xabee('0x3'),'appdata':_0xabee('0x41'),'context':_0x5a918e[_0xabee('0x9')],'exten':_0x5a918e[_0xabee('0x5')],'priority':_0x444a92[_0xabee('0x31')]['length']+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});}else{_0x2e83e0['push']({'type':_0x444a92[_0xabee('0x2')][_0xabee('0x34')](),'app':_0xabee('0x12'),'appdata':_0xabee('0x42'),'context':_0x5a918e[_0xabee('0x9')],'exten':_0x5a918e[_0xabee('0x5')],'priority':_0x444a92['intervals'][_0xabee('0x37')]+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});_0x2e83e0[_0xabee('0xb')]({'type':_0x444a92[_0xabee('0x2')]['toLowerCase'](),'app':'Set','appdata':_0xabee('0x43'),'context':_0x5a918e['context'],'exten':_0x5a918e['exten'],'priority':_0x444a92['intervals'][_0xabee('0x37')]+_0x1475f3+_0x441af1++,'VoiceExtensionId':_0x5a918e['id']});}}}}for(var _0x5b975b=0x0;_0x5b975b<_0x444a92[_0xabee('0x31')]['length'];_0x5b975b++){var _0x12240a=_0x1475f3+_0x444a92['intervals'][_0xabee('0x37')];var _0x2c88fc=_0x5b975b===_0x444a92[_0xabee('0x31')][_0xabee('0x37')]-0x1?_0x1475f3+_0x2e83e0['length']+_0x5ae15a[_0xabee('0x37')]+0x2:_0x1475f3+_0x5b975b+0x1;_0x2e83e0['splice'](_0x5b975b,0x0,{'type':_0x5a918e[_0xabee('0x2')],'app':_0xabee('0x44'),'appdata':_0x444a92[_0xabee('0x31')][_0x5b975b]+'?'+_0x5a918e[_0xabee('0x9')]+_0xabee('0x45')+_0x12240a+':'+_0x5a918e[_0xabee('0x9')]+_0xabee('0x45')+_0x2c88fc,'exten':_0x5a918e[_0xabee('0x5')],'context':_0x5a918e['context'],'priority':_0x1475f3+_0x5b975b,'VoiceExtensionId':_0x5a918e['id']});}if(_0x444a92[_0xabee('0x3f')]===_0xabee('0x46'))_0x444a92['appdata']=_0x146ae9(_0x5a918e,_0x444a92[_0xabee('0x47')]);_0x444a92['priority']=_0x2e83e0[_0xabee('0x37')]?_[_0xabee('0x48')](_0x2e83e0)[_0xabee('0x49')]+0x1:_0x1475f3;_0x2e3675=_[_0xabee('0x4a')](_0x2e3675,_0x2e83e0,[_0x444a92],_0x5ae15a);_0x1475f3=_['last'](_0x2e3675)[_0xabee('0x49')]+0x1;}return _0x50b996(_0x2e3675);})[_0xabee('0x4b')](function(_0x2bfdb5){_0x1ce8ae(_0x2bfdb5);});});}return _0x3b377b['define'](_0xabee('0x4c'),attributes,{'tableName':_0xabee('0x4d'),'paranoid':![],'indexes':[],'timestamps':!![],'instanceMethods':{'createRouting':function(_0x4861e5){var _0x47a561=this[_0xabee('0x4e')]({'plain':!![]});var _0x1e0082=_0x47a561['type']===_0xabee('0xf')?_0x2d6e69(_0x47a561):_0x972e88(_0x47a561);return _0x2701b7(_0x47a561,_0x4861e5,_['last'](_0x1e0082)[_0xabee('0x49')]+0x1)[_0xabee('0x4f')](function(_0x5e0133){var _0x1f87da=_[_0xabee('0x4a')](_0x1e0082,_0x5e0133);_0x1f87da[_0xabee('0xb')]({'type':_0x47a561[_0xabee('0x2')],'app':_0xabee('0x50'),'exten':_0x47a561[_0xabee('0x5')],'context':_0x47a561['context'],'priority':_[_0xabee('0x48')](_0x1f87da)[_0xabee('0x49')]+0x1,'VoiceExtensionId':_0x47a561['id']});return _0x1f87da;});}}});}; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.rpc.js b/server/api/voiceExtension/voiceExtension.rpc.js new file mode 100644 index 0000000..0990a60 --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6eed=['VoiceExtension','options','raw','limit','include','map','model','attributes','then','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','localhost','register','request','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','message','GetVoiceExtension'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x6eed,0xff));var _0xd6ee=function(_0x2717eb,_0x39ea39){_0x2717eb=_0x2717eb-0x0;var _0xc7342c=_0x6eed[_0x2717eb];return _0xc7342c;};'use strict';var _=require(_0xd6ee('0x0'));var util=require(_0xd6ee('0x1'));var moment=require(_0xd6ee('0x2'));var BPromise=require(_0xd6ee('0x3'));var rs=require(_0xd6ee('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xd6ee('0x5'))['db'];var utils=require(_0xd6ee('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xd6ee('0x7'));var jayson=require(_0xd6ee('0x8'));var client=jayson[_0xd6ee('0x9')][_0xd6ee('0xa')]({'port':0x232a});config[_0xd6ee('0xb')]=_['defaults'](config['redis'],{'host':_0xd6ee('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./voiceExtension.socket')[_0xd6ee('0xd')](socket);function respondWithRpcPromise(_0x213396,_0x5c3c61,_0x24385c){return new BPromise(function(_0xc3f404,_0x2e55a2){return client[_0xd6ee('0xe')](_0x213396,_0x24385c)['then'](function(_0x15baf3){logger[_0xd6ee('0xf')](_0xd6ee('0x10'),_0x5c3c61,_0xd6ee('0x11'));logger[_0xd6ee('0x12')](_0xd6ee('0x13'),_0x5c3c61,'request\x20sent',JSON[_0xd6ee('0x14')](_0x15baf3));if(_0x15baf3[_0xd6ee('0x15')]){if(_0x15baf3['error'][_0xd6ee('0x16')]===0x1f4){logger[_0xd6ee('0x15')](_0xd6ee('0x10'),_0x5c3c61,_0x15baf3[_0xd6ee('0x15')][_0xd6ee('0x17')]);return _0x2e55a2(_0x15baf3[_0xd6ee('0x15')]['message']);}logger[_0xd6ee('0x15')](_0xd6ee('0x10'),_0x5c3c61,_0x15baf3[_0xd6ee('0x15')]['message']);return _0xc3f404(_0x15baf3[_0xd6ee('0x15')]['message']);}else{logger[_0xd6ee('0xf')](_0xd6ee('0x10'),_0x5c3c61,_0xd6ee('0x11'));_0xc3f404(_0x15baf3['result'][_0xd6ee('0x17')]);}})['catch'](function(_0x391488){logger['error'](_0xd6ee('0x10'),_0x5c3c61,_0x391488);_0x2e55a2(_0x391488);});});}exports[_0xd6ee('0x18')]=function(_0x23ff1f){var _0x2888ef=this;return new Promise(function(_0x134c65,_0x4b33f1){return db[_0xd6ee('0x19')]['findAll']({'raw':_0x23ff1f[_0xd6ee('0x1a')]?_0x23ff1f[_0xd6ee('0x1a')][_0xd6ee('0x1b')]===undefined?!![]:![]:!![],'where':_0x23ff1f[_0xd6ee('0x1a')]?_0x23ff1f[_0xd6ee('0x1a')]['where']||null:null,'attributes':_0x23ff1f['options']?_0x23ff1f[_0xd6ee('0x1a')]['attributes']||null:null,'limit':_0x23ff1f[_0xd6ee('0x1a')]?_0x23ff1f['options'][_0xd6ee('0x1c')]||null:null,'include':_0x23ff1f[_0xd6ee('0x1a')]?_0x23ff1f[_0xd6ee('0x1a')][_0xd6ee('0x1d')]?_[_0xd6ee('0x1e')](_0x23ff1f['options']['include'],function(_0x2f438c){return{'model':db[_0x2f438c[_0xd6ee('0x1f')]],'as':_0x2f438c['as'],'attributes':_0x2f438c['attributes'],'include':_0x2f438c[_0xd6ee('0x1d')]?_[_0xd6ee('0x1e')](_0x2f438c[_0xd6ee('0x1d')],function(_0x373308){return{'model':db[_0x373308[_0xd6ee('0x1f')]],'as':_0x373308['as'],'attributes':_0x373308[_0xd6ee('0x20')],'include':_0x373308[_0xd6ee('0x1d')]?_['map'](_0x373308[_0xd6ee('0x1d')],function(_0x124ab7){return{'model':db[_0x124ab7['model']],'as':_0x124ab7['as'],'attributes':_0x124ab7['attributes']};}):[]};}):[]};}):[]:[]})[_0xd6ee('0x21')](function(_0x4580a7){logger[_0xd6ee('0xf')](_0xd6ee('0x18'),_0x23ff1f);logger[_0xd6ee('0x12')]('GetVoiceExtension',_0x23ff1f,JSON[_0xd6ee('0x14')](_0x4580a7));_0x134c65(_0x4580a7);})[_0xd6ee('0x22')](function(_0x21ce09){logger['error'](_0xd6ee('0x18'),_0x21ce09[_0xd6ee('0x17')],_0x23ff1f);_0x4b33f1(_0x2888ef[_0xd6ee('0x15')](0x1f4,_0x21ce09['message']));});});}; \ No newline at end of file diff --git a/server/api/voiceExtension/voiceExtension.socket.js b/server/api/voiceExtension/voiceExtension.socket.js new file mode 100644 index 0000000..b20bce2 --- /dev/null +++ b/server/api/voiceExtension/voiceExtension.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1261=['save','remove','update','emit','removeListener','voiceExtension:'];(function(_0x51f58d,_0x210643){var _0x4ee1c7=function(_0xfa4ece){while(--_0xfa4ece){_0x51f58d['push'](_0x51f58d['shift']());}};_0x4ee1c7(++_0x210643);}(_0x1261,0x144));var _0x1126=function(_0xf26d40,_0x2f4f46){_0xf26d40=_0xf26d40-0x0;var _0x50b68c=_0x1261[_0xf26d40];return _0x50b68c;};'use strict';var VoiceExtensionEvents=require('./voiceExtension.events');var events=[_0x1126('0x0'),_0x1126('0x1'),_0x1126('0x2')];function createListener(_0x331a2c,_0x39b786){return function(_0x350f3a){_0x39b786[_0x1126('0x3')](_0x331a2c,_0x350f3a);};}function removeListener(_0x4245ca,_0x21a480){return function(){VoiceExtensionEvents[_0x1126('0x4')](_0x4245ca,_0x21a480);};}exports['register']=function(_0x5c68c8){for(var _0x40ba58=0x0,_0x907180=events['length'];_0x40ba58<_0x907180;_0x40ba58++){var _0x17e5f0=events[_0x40ba58];var _0x28772d=createListener(_0x1126('0x5')+_0x17e5f0,_0x5c68c8);VoiceExtensionEvents['on'](_0x17e5f0,_0x28772d);}}; \ No newline at end of file diff --git a/server/api/voiceMail/index.js b/server/api/voiceMail/index.js new file mode 100644 index 0000000..645f371 --- /dev/null +++ b/server/api/voiceMail/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x32f4=['multer','util','path','connect-timeout','Router','fs-extra','../../components/interaction/service','../../config/environment','./voiceMail.controller','get','isAuthenticated','/:id','getMessages','post','create','update','exports'];(function(_0x2dfbb4,_0x532b0e){var _0x16ad9c=function(_0x1bff62){while(--_0x1bff62){_0x2dfbb4['push'](_0x2dfbb4['shift']());}};_0x16ad9c(++_0x532b0e);}(_0x32f4,0x154));var _0x432f=function(_0x393cdc,_0x5bb732){_0x393cdc=_0x393cdc-0x0;var _0x1333a3=_0x32f4[_0x393cdc];return _0x1333a3;};'use strict';var multer=require(_0x432f('0x0'));var util=require(_0x432f('0x1'));var path=require(_0x432f('0x2'));var timeout=require(_0x432f('0x3'));var express=require('express');var router=express[_0x432f('0x4')]();var fs_extra=require(_0x432f('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x432f('0x6'));var config=require(_0x432f('0x7'));var controller=require(_0x432f('0x8'));router[_0x432f('0x9')]('/',auth[_0x432f('0xa')](),controller['index']);router['get'](_0x432f('0xb'),auth[_0x432f('0xa')](),controller['show']);router[_0x432f('0x9')]('/:id/messages',auth[_0x432f('0xa')](),controller[_0x432f('0xc')]);router[_0x432f('0xd')]('/',auth[_0x432f('0xa')](),controller[_0x432f('0xe')]);router['put'](_0x432f('0xb'),auth['isAuthenticated'](),controller[_0x432f('0xf')]);router['delete'](_0x432f('0xb'),auth[_0x432f('0xa')](),controller['destroy']);module[_0x432f('0x10')]=router; \ No newline at end of file diff --git a/server/api/voiceMail/voiceMail.attributes.js b/server/api/voiceMail/voiceMail.attributes.js new file mode 100644 index 0000000..73cb2b1 --- /dev/null +++ b/server/api/voiceMail/voiceMail.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4885=['from-voicemail','contest_mailbox','setDataValue','email','string','trim','ENUM','yes','TINYINT(4)','TIMESTAMP','INTEGER','VIRTUAL','getDataValue','fullname','\x20-\x20','mailbox','exports','STRING'];(function(_0x527824,_0xc824a9){var _0xc8b8ed=function(_0x1b0e19){while(--_0x1b0e19){_0x527824['push'](_0x527824['shift']());}};_0xc8b8ed(++_0xc824a9);}(_0x4885,0x7c));var _0x5488=function(_0x4dfc72,_0x20e817){_0x4dfc72=_0x4dfc72-0x0;var _0x2413f1=_0x4885[_0x4dfc72];return _0x2413f1;};'use strict';var Sequelize=require('sequelize');module[_0x5488('0x0')]={'customer_id':{'type':Sequelize[_0x5488('0x1')]},'context':{'type':Sequelize[_0x5488('0x1')],'defaultValue':_0x5488('0x2'),'unique':_0x5488('0x3')},'mailbox':{'type':Sequelize[_0x5488('0x1')],'defaultValue':'','allowNull':![],'unique':_0x5488('0x3')},'password':{'type':Sequelize['STRING']},'fullname':{'type':Sequelize[_0x5488('0x1')]},'email':{'type':Sequelize[_0x5488('0x1')],'validate':{'isEmail':!![]},'set':function(_0xabe059){this[_0x5488('0x4')](_0x5488('0x5'),typeof _0xabe059===_0x5488('0x6')&&_0xabe059[_0x5488('0x7')]()?_0xabe059['trim']():null);}},'pager':{'type':Sequelize[_0x5488('0x1')]},'tz':{'type':Sequelize[_0x5488('0x1')],'defaultValue':'central'},'attach':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':_0x5488('0x9'),'allowNull':![]},'saycid':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':'yes','allowNull':![]},'dialout':{'type':Sequelize[_0x5488('0x1')]},'callback':{'type':Sequelize['STRING']},'review':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'operator':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'envelope':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'sayduration':{'type':Sequelize['ENUM'](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'saydurationm':{'type':_0x5488('0xa'),'defaultValue':0x1,'allowNull':![]},'sendvoicemail':{'type':Sequelize['ENUM']('yes','no'),'defaultValue':'no','allowNull':![]},'delete':{'type':Sequelize[_0x5488('0x8')]('yes','no'),'defaultValue':'no','allowNull':![]},'nextaftercmd':{'type':Sequelize[_0x5488('0x8')]('yes','no'),'defaultValue':_0x5488('0x9'),'allowNull':![]},'forcename':{'type':Sequelize['ENUM'](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'forcegreetings':{'type':Sequelize[_0x5488('0x8')](_0x5488('0x9'),'no'),'defaultValue':'no','allowNull':![]},'hidefromdir':{'type':Sequelize[_0x5488('0x8')]('yes','no'),'defaultValue':_0x5488('0x9'),'allowNull':![]},'stamp':{'type':_0x5488('0xb')},'emailsubject':{'type':Sequelize[_0x5488('0x1')]},'emailbody':{'type':Sequelize[_0x5488('0x1')]},'maxsecs':{'type':Sequelize['INTEGER'](0xff),'defaultValue':0xb4,'allowNull':![]},'maxmsg':{'type':Sequelize[_0x5488('0xc')](0xff),'defaultValue':0x64,'allowNull':![]},'name':{'type':Sequelize[_0x5488('0xd')],'get':function(){return this[_0x5488('0xe')](_0x5488('0xf'))+_0x5488('0x10')+this[_0x5488('0xe')](_0x5488('0x11'));}}}; \ No newline at end of file diff --git a/server/api/voiceMail/voiceMail.controller.js b/server/api/voiceMail/voiceMail.controller.js new file mode 100644 index 0000000..12b387f --- /dev/null +++ b/server/api/voiceMail/voiceMail.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa478=['UserProfileResource','destroy','name','send','index','map','VoiceMail','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','filters','where','merge','VIRTUAL','filter','options','includeAll','include','rows','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','catch','error','getMessages','findOne','VoiceMailMessage','pick','findAndCountAll','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','get','Voicemails'];(function(_0x524e28,_0x1992af){var _0x10ccdc=function(_0x31cd97){while(--_0x31cd97){_0x524e28['push'](_0x524e28['shift']());}};_0x10ccdc(++_0x1992af);}(_0xa478,0x136));var _0x8a47=function(_0x5c4e16,_0x113035){_0x5c4e16=_0x5c4e16-0x0;var _0x36044a=_0xa478[_0x5c4e16];return _0x36044a;};'use strict';var emlformat=require(_0x8a47('0x0'));var rimraf=require(_0x8a47('0x1'));var zipdir=require(_0x8a47('0x2'));var jsonpatch=require(_0x8a47('0x3'));var rp=require(_0x8a47('0x4'));var moment=require(_0x8a47('0x5'));var BPromise=require(_0x8a47('0x6'));var Mustache=require(_0x8a47('0x7'));var util=require(_0x8a47('0x8'));var path=require(_0x8a47('0x9'));var sox=require(_0x8a47('0xa'));var csv=require(_0x8a47('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x8a47('0xc'));var _=require(_0x8a47('0xd'));var squel=require(_0x8a47('0xe'));var crypto=require(_0x8a47('0xf'));var jsforce=require('jsforce');var deskjs=require(_0x8a47('0x10'));var toCsv=require('to-csv');var querystring=require(_0x8a47('0x11'));var Papa=require(_0x8a47('0x12'));var Redis=require(_0x8a47('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x8a47('0x14'));var as=require(_0x8a47('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8a47('0x16'))('api');var utils=require(_0x8a47('0x17'));var config=require(_0x8a47('0x18'));var licenseUtil=require(_0x8a47('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5e3166,_0x59efc7){_0x59efc7=_0x59efc7||0xcc;return function(_0x36941a){if(_0x36941a){return _0x5e3166[_0x8a47('0x1a')](_0x59efc7);}return _0x5e3166['status'](_0x59efc7)[_0x8a47('0x1b')]();};}function respondWithResult(_0x28bbc5,_0x1a9a6f){_0x1a9a6f=_0x1a9a6f||0xc8;return function(_0x55985c){if(_0x55985c){return _0x28bbc5[_0x8a47('0x1c')](_0x1a9a6f)[_0x8a47('0x1d')](_0x55985c);}};}function respondWithFilteredResult(_0x2f682e,_0x1c8488){return function(_0x41bdaf){if(_0x41bdaf){var _0x18f2be=typeof _0x1c8488[_0x8a47('0x1e')]===_0x8a47('0x1f')&&typeof _0x1c8488[_0x8a47('0x20')]==='undefined';var _0x20fbf7=_0x41bdaf[_0x8a47('0x21')];var _0x3f9093=_0x18f2be?0x0:_0x1c8488['offset'];var _0x341089=_0x18f2be?_0x41bdaf['count']:_0x1c8488['offset']+_0x1c8488[_0x8a47('0x20')];var _0x2174b1;if(_0x341089>=_0x20fbf7){_0x341089=_0x20fbf7;_0x2174b1=0xc8;}else{_0x2174b1=0xce;}_0x2f682e[_0x8a47('0x1c')](_0x2174b1);return _0x2f682e[_0x8a47('0x22')](_0x8a47('0x23'),_0x3f9093+'-'+_0x341089+'/'+_0x20fbf7)[_0x8a47('0x1d')](_0x41bdaf);}return null;};}function patchUpdates(_0x44e119){return function(_0x1bbed6){try{jsonpatch[_0x8a47('0x24')](_0x1bbed6,_0x44e119,!![]);}catch(_0xc2065a){return BPromise['reject'](_0xc2065a);}return _0x1bbed6[_0x8a47('0x25')]();};}function saveUpdates(_0x5923ec,_0x289f28){return function(_0x3d7993){if(_0x3d7993){return _0x3d7993[_0x8a47('0x26')](_0x5923ec)[_0x8a47('0x27')](function(_0x5d4b6c){return _0x5d4b6c;});}return null;};}function removeEntity(_0x116b5e,_0x5ae186){return function(_0x50f6ba){if(_0x50f6ba){return _0x50f6ba['destroy']()['then'](function(){var _0xf46d2c=_0x50f6ba[_0x8a47('0x28')]({'plain':!![]});var _0x5bed3e=_0x8a47('0x29');return db[_0x8a47('0x2a')][_0x8a47('0x2b')]({'where':{'type':_0x5bed3e,'resourceId':_0xf46d2c['id']}})[_0x8a47('0x27')](function(){return _0x50f6ba;});})[_0x8a47('0x27')](function(){_0x116b5e[_0x8a47('0x1c')](0xcc)[_0x8a47('0x1b')]();});}};}function handleEntityNotFound(_0x576fb3,_0x22a52f){return function(_0x4a10c3){if(!_0x4a10c3){_0x576fb3[_0x8a47('0x1a')](0x194);}return _0x4a10c3;};}function handleError(_0x3a8685,_0x54d4b2){_0x54d4b2=_0x54d4b2||0x1f4;return function(_0x1e89b1){logger['error'](_0x1e89b1['stack']);if(_0x1e89b1[_0x8a47('0x2c')]){delete _0x1e89b1[_0x8a47('0x2c')];}_0x3a8685[_0x8a47('0x1c')](_0x54d4b2)[_0x8a47('0x2d')](_0x1e89b1);};}exports[_0x8a47('0x2e')]=function(_0x18bfd3,_0x58aa06){var _0x353576={},_0x4d78b5={},_0x549913={'count':0x0,'rows':[]};var _0x448459=_[_0x8a47('0x2f')](db[_0x8a47('0x30')][_0x8a47('0x31')],function(_0x16e024){return{'name':_0x16e024[_0x8a47('0x32')],'type':_0x16e024[_0x8a47('0x33')][_0x8a47('0x34')]};});_0x4d78b5[_0x8a47('0x35')]=_[_0x8a47('0x2f')](_0x448459,'name');_0x4d78b5[_0x8a47('0x36')]=_[_0x8a47('0x37')](_0x18bfd3[_0x8a47('0x36')]);_0x4d78b5['filters']=_[_0x8a47('0x38')](_0x4d78b5[_0x8a47('0x35')],_0x4d78b5['query']);_0x353576[_0x8a47('0x39')]=_[_0x8a47('0x38')](_0x4d78b5[_0x8a47('0x35')],qs[_0x8a47('0x3a')](_0x18bfd3['query']['fields']));_0x353576[_0x8a47('0x39')]=_0x353576[_0x8a47('0x39')][_0x8a47('0x3b')]?_0x353576[_0x8a47('0x39')]:_0x4d78b5[_0x8a47('0x35')];if(!_0x18bfd3[_0x8a47('0x36')][_0x8a47('0x3c')]('nolimit')){_0x353576['limit']=qs[_0x8a47('0x20')](_0x18bfd3[_0x8a47('0x36')][_0x8a47('0x20')]);_0x353576[_0x8a47('0x1e')]=qs[_0x8a47('0x1e')](_0x18bfd3[_0x8a47('0x36')][_0x8a47('0x1e')]);}_0x353576[_0x8a47('0x3d')]=qs[_0x8a47('0x3e')](_0x18bfd3[_0x8a47('0x36')][_0x8a47('0x3e')]);_0x353576['where']=qs[_0x8a47('0x3f')](_['pick'](_0x18bfd3['query'],_0x4d78b5['filters']),_0x448459);if(_0x18bfd3['query']['filter']){_0x353576[_0x8a47('0x40')]=_[_0x8a47('0x41')](_0x353576[_0x8a47('0x40')],{'$or':_[_0x8a47('0x2f')](_0x448459,function(_0x10c483){if(_0x10c483[_0x8a47('0x33')]!==_0x8a47('0x42')){var _0x29beee={};_0x29beee[_0x10c483['name']]={'$like':'%'+_0x18bfd3['query'][_0x8a47('0x43')]+'%'};return _0x29beee;}})});}_0x353576=_[_0x8a47('0x41')]({},_0x353576,_0x18bfd3[_0x8a47('0x44')]);var _0x19298d={'where':_0x353576['where']};return db[_0x8a47('0x30')][_0x8a47('0x21')](_0x19298d)[_0x8a47('0x27')](function(_0x369dd5){_0x549913[_0x8a47('0x21')]=_0x369dd5;if(_0x18bfd3['query'][_0x8a47('0x45')]){_0x353576[_0x8a47('0x46')]=[{'all':!![]}];}return db[_0x8a47('0x30')]['findAll'](_0x353576);})[_0x8a47('0x27')](function(_0x2c70ea){_0x549913[_0x8a47('0x47')]=_0x2c70ea;return _0x549913;})[_0x8a47('0x27')](respondWithFilteredResult(_0x58aa06,_0x353576))['catch'](handleError(_0x58aa06,null));};exports[_0x8a47('0x48')]=function(_0x2f523f,_0x2fa701){var _0x2e2520={'raw':!![],'where':{'id':_0x2f523f[_0x8a47('0x49')]['id']}},_0x22b0d6={};_0x22b0d6['model']=_['keys'](db[_0x8a47('0x30')][_0x8a47('0x31')]);_0x22b0d6[_0x8a47('0x36')]=_['keys'](_0x2f523f[_0x8a47('0x36')]);_0x22b0d6[_0x8a47('0x3f')]=_['intersection'](_0x22b0d6['model'],_0x22b0d6[_0x8a47('0x36')]);_0x2e2520['attributes']=_[_0x8a47('0x38')](_0x22b0d6[_0x8a47('0x35')],qs[_0x8a47('0x3a')](_0x2f523f[_0x8a47('0x36')][_0x8a47('0x3a')]));_0x2e2520[_0x8a47('0x39')]=_0x2e2520['attributes']['length']?_0x2e2520[_0x8a47('0x39')]:_0x22b0d6[_0x8a47('0x35')];if(_0x2f523f[_0x8a47('0x36')][_0x8a47('0x45')]){_0x2e2520[_0x8a47('0x46')]=[{'all':!![]}];}_0x2e2520=_['merge']({},_0x2e2520,_0x2f523f['options']);return db[_0x8a47('0x30')]['find'](_0x2e2520)[_0x8a47('0x27')](handleEntityNotFound(_0x2fa701,null))[_0x8a47('0x27')](respondWithResult(_0x2fa701,null))['catch'](handleError(_0x2fa701,null));};exports[_0x8a47('0x4a')]=function(_0x237ed1,_0x14e22c){return db[_0x8a47('0x30')][_0x8a47('0x4a')](_0x237ed1[_0x8a47('0x4b')],{})[_0x8a47('0x27')](function(_0x2d2455){var _0x512938=_0x237ed1[_0x8a47('0x4c')][_0x8a47('0x28')]({'plain':!![]});if(!_0x512938)throw new Error(_0x8a47('0x4d'));if(_0x512938[_0x8a47('0x4e')]==='user'){var _0x11db4e=_0x2d2455[_0x8a47('0x28')]({'plain':!![]});var _0x24e123=_0x8a47('0x29');return db[_0x8a47('0x4f')][_0x8a47('0x50')]({'where':{'name':_0x24e123,'userProfileId':_0x512938['userProfileId']},'raw':!![]})['then'](function(_0x456cfb){if(_0x456cfb&&_0x456cfb['autoAssociation']===0x0){return db[_0x8a47('0x2a')][_0x8a47('0x4a')]({'name':_0x11db4e['name'],'resourceId':_0x11db4e['id'],'type':_0x456cfb[_0x8a47('0x2c')],'sectionId':_0x456cfb['id']},{})['then'](function(){return _0x2d2455;});}else{return _0x2d2455;}})[_0x8a47('0x51')](function(_0x5c5577){logger[_0x8a47('0x52')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5c5577);throw _0x5c5577;});}return _0x2d2455;})[_0x8a47('0x27')](respondWithResult(_0x14e22c,0xc9))[_0x8a47('0x51')](handleError(_0x14e22c,null));};exports[_0x8a47('0x26')]=function(_0x144ce6,_0x4590ae){if(_0x144ce6[_0x8a47('0x4b')]['id']){delete _0x144ce6[_0x8a47('0x4b')]['id'];}return db[_0x8a47('0x30')][_0x8a47('0x50')]({'where':{'id':_0x144ce6[_0x8a47('0x49')]['id']}})[_0x8a47('0x27')](handleEntityNotFound(_0x4590ae,null))['then'](saveUpdates(_0x144ce6[_0x8a47('0x4b')],null))[_0x8a47('0x27')](respondWithResult(_0x4590ae,null))['catch'](handleError(_0x4590ae,null));};exports[_0x8a47('0x2b')]=function(_0x408ce2,_0x436c27){return db[_0x8a47('0x30')][_0x8a47('0x50')]({'where':{'id':_0x408ce2[_0x8a47('0x49')]['id']}})[_0x8a47('0x27')](handleEntityNotFound(_0x436c27,null))[_0x8a47('0x27')](removeEntity(_0x436c27,null))[_0x8a47('0x51')](handleError(_0x436c27,null));};exports[_0x8a47('0x53')]=function(_0x2100cb,_0x385087,_0x5f448e){return db[_0x8a47('0x30')][_0x8a47('0x54')]({'where':{'id':_0x2100cb[_0x8a47('0x49')]['id']}})[_0x8a47('0x27')](handleEntityNotFound(_0x385087,null))[_0x8a47('0x27')](function(_0x6c2f83){var _0x134fc5;var _0x3242b7={},_0x41cc36={};_0x41cc36[_0x8a47('0x35')]=_[_0x8a47('0x37')](db[_0x8a47('0x55')][_0x8a47('0x31')]);_0x41cc36[_0x8a47('0x36')]=_[_0x8a47('0x37')](_0x2100cb[_0x8a47('0x36')]);_0x41cc36['filters']=_[_0x8a47('0x38')](_0x41cc36['model'],_0x41cc36[_0x8a47('0x36')]);_0x3242b7[_0x8a47('0x39')]=_[_0x8a47('0x38')](_0x41cc36[_0x8a47('0x35')],qs[_0x8a47('0x3a')](_0x2100cb[_0x8a47('0x36')]['fields']));_0x3242b7[_0x8a47('0x39')]=_0x3242b7[_0x8a47('0x39')][_0x8a47('0x3b')]?_0x3242b7['attributes']:_0x41cc36['model'];if(!_0x2100cb[_0x8a47('0x36')][_0x8a47('0x3c')]('nolimit')){_0x3242b7[_0x8a47('0x20')]=qs[_0x8a47('0x20')](_0x2100cb[_0x8a47('0x36')][_0x8a47('0x20')]);_0x3242b7[_0x8a47('0x1e')]=qs[_0x8a47('0x1e')](_0x2100cb[_0x8a47('0x36')][_0x8a47('0x1e')]);}_0x3242b7[_0x8a47('0x3d')]=qs[_0x8a47('0x3e')](_0x2100cb[_0x8a47('0x36')][_0x8a47('0x3e')]);_0x3242b7[_0x8a47('0x40')]=qs['filters'](_[_0x8a47('0x56')](_0x2100cb[_0x8a47('0x36')],_0x41cc36[_0x8a47('0x3f')]));if(_0x2100cb[_0x8a47('0x36')][_0x8a47('0x43')]){_0x3242b7[_0x8a47('0x40')]=_['merge'](_0x3242b7[_0x8a47('0x40')],{'$or':_['map'](_0x3242b7['attributes'],function(_0x400c4e){var _0x439172={};_0x439172[_0x400c4e]={'$like':'%'+_0x2100cb[_0x8a47('0x36')][_0x8a47('0x43')]+'%'};return _0x439172;})});}_0x3242b7[_0x8a47('0x40')]=_[_0x8a47('0x41')](_0x3242b7['where'],{'mailboxuser':_0x6c2f83['mailbox']});_0x3242b7=_[_0x8a47('0x41')]({},_0x3242b7,_0x2100cb['options']);return db[_0x8a47('0x55')][_0x8a47('0x57')](_0x3242b7)[_0x8a47('0x27')](respondWithFilteredResult(_0x385087,_0x3242b7));})[_0x8a47('0x51')](handleError(_0x385087,null));}; \ No newline at end of file diff --git a/server/api/voiceMail/voiceMail.model.js b/server/api/voiceMail/voiceMail.model.js new file mode 100644 index 0000000..110862a --- /dev/null +++ b/server/api/voiceMail/voiceMail.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x34cf=['bluebird','request-promise','path','rimraf','./voiceMail.attributes','exports','define','VoiceMail','mailbox_context','mailbox','util','../../config/logger'];(function(_0x3abdcf,_0x15b602){var _0x2ed52b=function(_0x3ee7f0){while(--_0x3ee7f0){_0x3abdcf['push'](_0x3abdcf['shift']());}};_0x2ed52b(++_0x15b602);}(_0x34cf,0x9a));var _0xf34c=function(_0x40e1f5,_0x4d480f){_0x40e1f5=_0x40e1f5-0x0;var _0x473b7e=_0x34cf[_0x40e1f5];return _0x473b7e;};'use strict';var _=require('lodash');var util=require(_0xf34c('0x0'));var logger=require(_0xf34c('0x1'))('api');var moment=require('moment');var BPromise=require(_0xf34c('0x2'));var rp=require(_0xf34c('0x3'));var fs=require('fs');var path=require(_0xf34c('0x4'));var rimraf=require(_0xf34c('0x5'));var config=require('../../config/environment');var attributes=require(_0xf34c('0x6'));module[_0xf34c('0x7')]=function(_0x225513,_0xdf85da){return _0x225513[_0xf34c('0x8')](_0xf34c('0x9'),attributes,{'tableName':'voice_voicemail','paranoid':![],'indexes':[{'name':_0xf34c('0xa'),'fields':[_0xf34c('0xb'),'context']}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceMail/voiceMail.rpc.js b/server/api/voiceMail/voiceMail.rpc.js new file mode 100644 index 0000000..75991f1 --- /dev/null +++ b/server/api/voiceMail/voiceMail.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x955b=['randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','request','info','VoiceMail,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','lodash','util','moment','bluebird'];(function(_0x5e2953,_0x79755){var _0x44608c=function(_0x1a20d6){while(--_0x1a20d6){_0x5e2953['push'](_0x5e2953['shift']());}};_0x44608c(++_0x79755);}(_0x955b,0x1dc));var _0xb955=function(_0x258238,_0x219494){_0x258238=_0x258238-0x0;var _0x126c77=_0x955b[_0x258238];return _0x126c77;};'use strict';var _=require(_0xb955('0x0'));var util=require(_0xb955('0x1'));var moment=require(_0xb955('0x2'));var BPromise=require(_0xb955('0x3'));var rs=require(_0xb955('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb955('0x5'))['db'];var utils=require(_0xb955('0x6'));var logger=require('../../config/logger')(_0xb955('0x7'));var config=require(_0xb955('0x8'));var jayson=require(_0xb955('0x9'));var client=jayson['client'][_0xb955('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2d589d,_0x247033,_0x5b73f7){return new BPromise(function(_0x5ae251,_0x888f76){return client[_0xb955('0xb')](_0x2d589d,_0x5b73f7)['then'](function(_0x59c5ce){logger[_0xb955('0xc')](_0xb955('0xd'),_0x247033,_0xb955('0xe'));logger['debug']('VoiceMail,\x20%s,\x20%s,\x20%s',_0x247033,_0xb955('0xe'),JSON[_0xb955('0xf')](_0x59c5ce));if(_0x59c5ce['error']){if(_0x59c5ce[_0xb955('0x10')]['code']===0x1f4){logger[_0xb955('0x10')](_0xb955('0xd'),_0x247033,_0x59c5ce[_0xb955('0x10')][_0xb955('0x11')]);return _0x888f76(_0x59c5ce[_0xb955('0x10')][_0xb955('0x11')]);}logger[_0xb955('0x10')]('VoiceMail,\x20%s,\x20%s',_0x247033,_0x59c5ce[_0xb955('0x10')][_0xb955('0x11')]);return _0x5ae251(_0x59c5ce['error'][_0xb955('0x11')]);}else{logger[_0xb955('0xc')]('VoiceMail,\x20%s,\x20%s',_0x247033,_0xb955('0xe'));_0x5ae251(_0x59c5ce[_0xb955('0x12')][_0xb955('0x11')]);}})[_0xb955('0x13')](function(_0x18b750){logger['error'](_0xb955('0xd'),_0x247033,_0x18b750);_0x888f76(_0x18b750);});});} \ No newline at end of file diff --git a/server/api/voiceMailMessage/index.js b/server/api/voiceMailMessage/index.js new file mode 100644 index 0000000..55bf9d1 --- /dev/null +++ b/server/api/voiceMailMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x110c=['../../config/environment','get','index','/:id','isAuthenticated','create','update','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service'];(function(_0x25bea7,_0x49ab45){var _0x175952=function(_0x56a0b5){while(--_0x56a0b5){_0x25bea7['push'](_0x25bea7['shift']());}};_0x175952(++_0x49ab45);}(_0x110c,0x1cb));var _0xc110=function(_0x1cc8fe,_0x105328){_0x1cc8fe=_0x1cc8fe-0x0;var _0x230054=_0x110c[_0x1cc8fe];return _0x230054;};'use strict';var multer=require(_0xc110('0x0'));var util=require(_0xc110('0x1'));var path=require(_0xc110('0x2'));var timeout=require(_0xc110('0x3'));var express=require(_0xc110('0x4'));var router=express[_0xc110('0x5')]();var fs_extra=require(_0xc110('0x6'));var auth=require(_0xc110('0x7'));var interaction=require(_0xc110('0x8'));var config=require(_0xc110('0x9'));var controller=require('./voiceMailMessage.controller');router[_0xc110('0xa')]('/',auth['isAuthenticated'](),controller[_0xc110('0xb')]);router['get'](_0xc110('0xc'),auth[_0xc110('0xd')](),controller['show']);router['get']('/:id/download',auth['isAuthenticated'](),controller['download']);router['post']('/',auth[_0xc110('0xd')](),controller[_0xc110('0xe')]);router['put'](_0xc110('0xc'),auth[_0xc110('0xd')](),controller[_0xc110('0xf')]);router['delete'](_0xc110('0xc'),auth['isAuthenticated'](),controller[_0xc110('0x10')]);module[_0xc110('0x11')]=router; \ No newline at end of file diff --git a/server/api/voiceMailMessage/voiceMailMessage.attributes.js b/server/api/voiceMailMessage/voiceMailMessage.attributes.js new file mode 100644 index 0000000..ecd697f --- /dev/null +++ b/server/api/voiceMailMessage/voiceMailMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf809=['sequelize','exports','getDataValue','INTEGER','STRING','long','TIMESTAMP','literal','CURRENT_TIMESTAMP\x20ON\x20UPDATE\x20CURRENT_TIMESTAMP'];(function(_0x11fd0f,_0x2398dc){var _0x58deaf=function(_0x34b034){while(--_0x34b034){_0x11fd0f['push'](_0x11fd0f['shift']());}};_0x58deaf(++_0x2398dc);}(_0xf809,0x183));var _0x9f80=function(_0x115eda,_0x30c8f6){_0x115eda=_0x115eda-0x0;var _0x55d6a7=_0xf809[_0x115eda];return _0x55d6a7;};'use strict';var Sequelize=require(_0x9f80('0x0'));module[_0x9f80('0x1')]={'name':{'type':Sequelize['VIRTUAL'],'get':function(_0x795d48){return this[_0x9f80('0x2')]('id');}},'msgnum':{'type':Sequelize[_0x9f80('0x3')](0xb),'defaultValue':0x0,'allowNull':![]},'dir':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'context':{'type':Sequelize['STRING'],'defaultValue':''},'macrocontext':{'type':Sequelize['STRING'],'defaultValue':''},'callerid':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'origtime':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'duration':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'mailboxuser':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'mailboxcontext':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'recording':{'type':Sequelize['BLOB'](_0x9f80('0x5')),'defaultValue':null},'flag':{'type':Sequelize[_0x9f80('0x4')],'defaultValue':''},'msg_id':{'type':Sequelize['STRING'],'defaultValue':''},'stamp':{'type':_0x9f80('0x6'),'defaultValue':Sequelize[_0x9f80('0x7')](_0x9f80('0x8'))}}; \ No newline at end of file diff --git a/server/api/voiceMailMessage/voiceMailMessage.controller.js b/server/api/voiceMailMessage/voiceMailMessage.controller.js new file mode 100644 index 0000000..6a78983 --- /dev/null +++ b/server/api/voiceMailMessage/voiceMailMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1f8a=['download','recording','msg_id','ValidationError','audio/wav','attachment','Content-Disposition','attachment;\x20filename=\x22','.wav\x22','send','eml-format','rimraf','fast-json-patch','request-promise','mustache','sox','ejs','lodash','crypto','jsforce','to-csv','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','undefined','limit','offset','count','set','Content-Range','apply','reject','update','then','destroy','error','stack','name','VoiceMailMessage','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','map','type','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','create','body','find','params'];(function(_0x15ff47,_0x3d08c5){var _0x239fb9=function(_0x395f25){while(--_0x395f25){_0x15ff47['push'](_0x15ff47['shift']());}};_0x239fb9(++_0x3d08c5);}(_0x1f8a,0x18b));var _0xa1f8=function(_0x4818a0,_0x130415){_0x4818a0=_0x4818a0-0x0;var _0x465228=_0x1f8a[_0x4818a0];return _0x465228;};'use strict';var emlformat=require(_0xa1f8('0x0'));var rimraf=require(_0xa1f8('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa1f8('0x2'));var rp=require(_0xa1f8('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xa1f8('0x4'));var util=require('util');var path=require('path');var sox=require(_0xa1f8('0x5'));var csv=require('to-csv');var ejs=require(_0xa1f8('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa1f8('0x7'));var squel=require('squel');var crypto=require(_0xa1f8('0x8'));var jsforce=require(_0xa1f8('0x9'));var deskjs=require('desk.js');var toCsv=require(_0xa1f8('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xa1f8('0xb'));var authService=require(_0xa1f8('0xc'));var qs=require(_0xa1f8('0xd'));var as=require(_0xa1f8('0xe'));var hardwareService=require(_0xa1f8('0xf'));var logger=require(_0xa1f8('0x10'))('api');var utils=require(_0xa1f8('0x11'));var config=require(_0xa1f8('0x12'));var licenseUtil=require(_0xa1f8('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x50d50b,_0x408e48){_0x408e48=_0x408e48||0xcc;return function(_0x424012){if(_0x424012){return _0x50d50b[_0xa1f8('0x14')](_0x408e48);}return _0x50d50b[_0xa1f8('0x15')](_0x408e48)[_0xa1f8('0x16')]();};}function respondWithResult(_0x122b64,_0x37ac22){_0x37ac22=_0x37ac22||0xc8;return function(_0x2ddfad){if(_0x2ddfad){return _0x122b64[_0xa1f8('0x15')](_0x37ac22)['json'](_0x2ddfad);}};}function respondWithFilteredResult(_0x13cf65,_0x31835c){return function(_0xd13fc0){if(_0xd13fc0){var _0x2645ab=typeof _0x31835c['offset']===_0xa1f8('0x17')&&typeof _0x31835c[_0xa1f8('0x18')]==='undefined';var _0x906427=_0xd13fc0['count'];var _0x164585=_0x2645ab?0x0:_0x31835c[_0xa1f8('0x19')];var _0x4393f4=_0x2645ab?_0xd13fc0[_0xa1f8('0x1a')]:_0x31835c['offset']+_0x31835c['limit'];var _0xa1edf0;if(_0x4393f4>=_0x906427){_0x4393f4=_0x906427;_0xa1edf0=0xc8;}else{_0xa1edf0=0xce;}_0x13cf65[_0xa1f8('0x15')](_0xa1edf0);return _0x13cf65[_0xa1f8('0x1b')](_0xa1f8('0x1c'),_0x164585+'-'+_0x4393f4+'/'+_0x906427)['json'](_0xd13fc0);}return null;};}function patchUpdates(_0x2c9087){return function(_0x2534d7){try{jsonpatch[_0xa1f8('0x1d')](_0x2534d7,_0x2c9087,!![]);}catch(_0x342167){return BPromise[_0xa1f8('0x1e')](_0x342167);}return _0x2534d7['save']();};}function saveUpdates(_0x161aee,_0xa8f73a){return function(_0x527722){if(_0x527722){return _0x527722[_0xa1f8('0x1f')](_0x161aee)[_0xa1f8('0x20')](function(_0x29b883){return _0x29b883;});}return null;};}function removeEntity(_0x2a6de6,_0x316ac5){return function(_0x4322fa){if(_0x4322fa){return _0x4322fa[_0xa1f8('0x21')]()['then'](function(){_0x2a6de6[_0xa1f8('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4b48a8,_0x12b7ee){return function(_0x4a32fa){if(!_0x4a32fa){_0x4b48a8['sendStatus'](0x194);}return _0x4a32fa;};}function handleError(_0x12d848,_0x3b36a8){_0x3b36a8=_0x3b36a8||0x1f4;return function(_0x5f470b){logger[_0xa1f8('0x22')](_0x5f470b[_0xa1f8('0x23')]);if(_0x5f470b[_0xa1f8('0x24')]){delete _0x5f470b[_0xa1f8('0x24')];}_0x12d848[_0xa1f8('0x15')](_0x3b36a8)['send'](_0x5f470b);};}exports['index']=function(_0x5be46e,_0x59e157){var _0x5c3a50={},_0x25222e={},_0x253152={'count':0x0,'rows':[]};var _0x5a99db=_['map'](db[_0xa1f8('0x25')]['rawAttributes'],function(_0x869359){return{'name':_0x869359['fieldName'],'type':_0x869359['type'][_0xa1f8('0x26')]};});_0x25222e[_0xa1f8('0x27')]=_['differenceBy'](_['map'](_0x5a99db,_0xa1f8('0x24')),[_0xa1f8('0x24')]);_0x25222e[_0xa1f8('0x28')]=_[_0xa1f8('0x29')](_0x5be46e['query']);_0x25222e[_0xa1f8('0x2a')]=_[_0xa1f8('0x2b')](_0x25222e[_0xa1f8('0x27')],_0x25222e['query']);_0x5c3a50[_0xa1f8('0x2c')]=_[_0xa1f8('0x2b')](_0x25222e['model'],qs['fields'](_0x5be46e[_0xa1f8('0x28')][_0xa1f8('0x2d')]));_0x5c3a50[_0xa1f8('0x2c')]=_0x5c3a50[_0xa1f8('0x2c')]['length']?_0x5c3a50[_0xa1f8('0x2c')]:_0x25222e[_0xa1f8('0x27')];if(!_0x5be46e['query'][_0xa1f8('0x2e')]('nolimit')){_0x5c3a50['limit']=qs[_0xa1f8('0x18')](_0x5be46e[_0xa1f8('0x28')]['limit']);_0x5c3a50[_0xa1f8('0x19')]=qs['offset'](_0x5be46e[_0xa1f8('0x28')][_0xa1f8('0x19')]);}_0x5c3a50[_0xa1f8('0x2f')]=qs[_0xa1f8('0x30')](_0x5be46e['query'][_0xa1f8('0x30')]);_0x5c3a50[_0xa1f8('0x31')]=qs[_0xa1f8('0x2a')](_[_0xa1f8('0x32')](_0x5be46e[_0xa1f8('0x28')],_0x25222e[_0xa1f8('0x2a')]),_0x5a99db);if(_0x5be46e[_0xa1f8('0x28')][_0xa1f8('0x33')]){_0x5c3a50['where']=_[_0xa1f8('0x34')](_0x5c3a50[_0xa1f8('0x31')],{'$or':_[_0xa1f8('0x35')](_0x5a99db,function(_0x20b1ce){if(_0x20b1ce[_0xa1f8('0x36')]!==_0xa1f8('0x37')){var _0x273079={};_0x273079[_0x20b1ce['name']]={'$like':'%'+_0x5be46e[_0xa1f8('0x28')][_0xa1f8('0x33')]+'%'};return _0x273079;}})});}_0x5c3a50=_[_0xa1f8('0x34')]({},_0x5c3a50,_0x5be46e[_0xa1f8('0x38')]);var _0x2e7c1a={'where':_0x5c3a50[_0xa1f8('0x31')]};return db[_0xa1f8('0x25')][_0xa1f8('0x1a')](_0x2e7c1a)[_0xa1f8('0x20')](function(_0x24b4de){_0x253152[_0xa1f8('0x1a')]=_0x24b4de;if(_0x5be46e[_0xa1f8('0x28')][_0xa1f8('0x39')]){_0x5c3a50[_0xa1f8('0x3a')]=[{'all':!![]}];}return db['VoiceMailMessage'][_0xa1f8('0x3b')](_0x5c3a50);})[_0xa1f8('0x20')](function(_0x269780){_0x253152[_0xa1f8('0x3c')]=_0x269780;return _0x253152;})['then'](respondWithFilteredResult(_0x59e157,_0x5c3a50))[_0xa1f8('0x3d')](handleError(_0x59e157,null));};exports[_0xa1f8('0x3e')]=function(_0x716b65,_0x1c3b5a){var _0x19966c={'raw':!![],'where':{'id':_0x716b65['params']['id']}},_0xab5ff2={};_0xab5ff2['model']=_[_0xa1f8('0x29')](db[_0xa1f8('0x25')]['rawAttributes']);_0xab5ff2[_0xa1f8('0x28')]=_['keys'](_0x716b65['query']);_0xab5ff2[_0xa1f8('0x2a')]=_[_0xa1f8('0x2b')](_0xab5ff2[_0xa1f8('0x27')],_0xab5ff2[_0xa1f8('0x28')]);_0x19966c[_0xa1f8('0x2c')]=_[_0xa1f8('0x2b')](_0xab5ff2[_0xa1f8('0x27')],qs['fields'](_0x716b65['query'][_0xa1f8('0x2d')]));_0x19966c[_0xa1f8('0x2c')]=_0x19966c[_0xa1f8('0x2c')]['length']?_0x19966c[_0xa1f8('0x2c')]:_0xab5ff2[_0xa1f8('0x27')];if(_0x716b65['query']['includeAll']){_0x19966c[_0xa1f8('0x3a')]=[{'all':!![]}];}_0x19966c=_['merge']({},_0x19966c,_0x716b65[_0xa1f8('0x38')]);return db['VoiceMailMessage']['find'](_0x19966c)[_0xa1f8('0x20')](handleEntityNotFound(_0x1c3b5a,null))[_0xa1f8('0x20')](respondWithResult(_0x1c3b5a,null))[_0xa1f8('0x3d')](handleError(_0x1c3b5a,null));};exports[_0xa1f8('0x3f')]=function(_0x35cb7f,_0x6ca13e){return db[_0xa1f8('0x25')][_0xa1f8('0x3f')](_0x35cb7f[_0xa1f8('0x40')],{})[_0xa1f8('0x20')](respondWithResult(_0x6ca13e,0xc9))[_0xa1f8('0x3d')](handleError(_0x6ca13e,null));};exports['update']=function(_0x9e24ee,_0x319471){if(_0x9e24ee['body']['id']){delete _0x9e24ee['body']['id'];}return db[_0xa1f8('0x25')][_0xa1f8('0x41')]({'where':{'id':_0x9e24ee[_0xa1f8('0x42')]['id']}})[_0xa1f8('0x20')](handleEntityNotFound(_0x319471,null))['then'](saveUpdates(_0x9e24ee['body'],null))[_0xa1f8('0x20')](respondWithResult(_0x319471,null))['catch'](handleError(_0x319471,null));};exports[_0xa1f8('0x21')]=function(_0x24cd6d,_0x252a7c){return db[_0xa1f8('0x25')][_0xa1f8('0x41')]({'where':{'id':_0x24cd6d[_0xa1f8('0x42')]['id']}})[_0xa1f8('0x20')](handleEntityNotFound(_0x252a7c,null))[_0xa1f8('0x20')](removeEntity(_0x252a7c,null))[_0xa1f8('0x3d')](handleError(_0x252a7c,null));};exports[_0xa1f8('0x43')]=function(_0x3b0cbf,_0x5d07e3,_0x4bf82f){return db['VoiceMailMessage'][_0xa1f8('0x41')]({'where':{'id':_0x3b0cbf['params']['id']},'attributes':['id',_0xa1f8('0x44'),_0xa1f8('0x45')]})[_0xa1f8('0x20')](handleEntityNotFound(_0x5d07e3,null))[_0xa1f8('0x20')](function(_0x21b3b6){if(_0x21b3b6){if(!_0x21b3b6['recording']){throw new db['Sequelize'][(_0xa1f8('0x46'))]('VoiceMailMessage\x20not\x20found');}var _0x28508a={'Content-Type':_0xa1f8('0x47'),'Content-Disposition':_0xa1f8('0x48')};if(_0x21b3b6['msg_id']){_0x28508a[_0xa1f8('0x49')]=_0xa1f8('0x4a')+_0x21b3b6[_0xa1f8('0x45')]+_0xa1f8('0x4b');}_0x5d07e3[_0xa1f8('0x1b')](_0x28508a);return _0x5d07e3[_0xa1f8('0x4c')](new Buffer(_0x21b3b6['recording']));}})[_0xa1f8('0x3d')](handleError(_0x5d07e3,null));}; \ No newline at end of file diff --git a/server/api/voiceMailMessage/voiceMailMessage.model.js b/server/api/voiceMailMessage/voiceMailMessage.model.js new file mode 100644 index 0000000..5a3f88a --- /dev/null +++ b/server/api/voiceMailMessage/voiceMailMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5c35=['exports','define','VoiceMailMessage','voice_voicemail_messages','dir','lodash','../../config/logger','api','moment','path','rimraf','../../config/environment'];(function(_0xb24a3e,_0x4a3594){var _0x4038d7=function(_0x1ea3c3){while(--_0x1ea3c3){_0xb24a3e['push'](_0xb24a3e['shift']());}};_0x4038d7(++_0x4a3594);}(_0x5c35,0x1a9));var _0x55c3=function(_0x78a014,_0x5eb19b){_0x78a014=_0x78a014-0x0;var _0x1e5802=_0x5c35[_0x78a014];return _0x1e5802;};'use strict';var _=require(_0x55c3('0x0'));var util=require('util');var logger=require(_0x55c3('0x1'))(_0x55c3('0x2'));var moment=require(_0x55c3('0x3'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0x55c3('0x4'));var rimraf=require(_0x55c3('0x5'));var config=require(_0x55c3('0x6'));var attributes=require('./voiceMailMessage.attributes');module[_0x55c3('0x7')]=function(_0x5575a1,_0x48e606){return _0x5575a1[_0x55c3('0x8')](_0x55c3('0x9'),attributes,{'tableName':_0x55c3('0xa'),'paranoid':![],'indexes':[{'name':_0x55c3('0xb'),'fields':[_0x55c3('0xb')]}],'timestamps':![]});}; \ No newline at end of file diff --git a/server/api/voiceMailMessage/voiceMailMessage.rpc.js b/server/api/voiceMailMessage/voiceMailMessage.rpc.js new file mode 100644 index 0000000..5bf9096 --- /dev/null +++ b/server/api/voiceMailMessage/voiceMailMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6314=['VoiceMailMessage,\x20%s,\x20%s,\x20%s','error','code','message','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','http','request','then','info','VoiceMailMessage,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x317d31,_0x353b8a){var _0xf92210=function(_0x1b3fe8){while(--_0x1b3fe8){_0x317d31['push'](_0x317d31['shift']());}};_0xf92210(++_0x353b8a);}(_0x6314,0xad));var _0x4631=function(_0x1cfa0d,_0x4391f2){_0x1cfa0d=_0x1cfa0d-0x0;var _0xe33279=_0x6314[_0x1cfa0d];return _0xe33279;};'use strict';var _=require('lodash');var util=require(_0x4631('0x0'));var moment=require(_0x4631('0x1'));var BPromise=require(_0x4631('0x2'));var rs=require(_0x4631('0x3'));var fs=require('fs');var Redis=require(_0x4631('0x4'));var db=require(_0x4631('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x4631('0x6'));var config=require(_0x4631('0x7'));var jayson=require(_0x4631('0x8'));var client=jayson['client'][_0x4631('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1a9cbb,_0x3d2bc0,_0x4984f0){return new BPromise(function(_0x2bb9a9,_0x499e50){return client[_0x4631('0xa')](_0x1a9cbb,_0x4984f0)[_0x4631('0xb')](function(_0x13c06c){logger[_0x4631('0xc')](_0x4631('0xd'),_0x3d2bc0,_0x4631('0xe'));logger[_0x4631('0xf')](_0x4631('0x10'),_0x3d2bc0,'request\x20sent',JSON['stringify'](_0x13c06c));if(_0x13c06c[_0x4631('0x11')]){if(_0x13c06c[_0x4631('0x11')][_0x4631('0x12')]===0x1f4){logger[_0x4631('0x11')]('VoiceMailMessage,\x20%s,\x20%s',_0x3d2bc0,_0x13c06c[_0x4631('0x11')]['message']);return _0x499e50(_0x13c06c[_0x4631('0x11')][_0x4631('0x13')]);}logger['error']('VoiceMailMessage,\x20%s,\x20%s',_0x3d2bc0,_0x13c06c[_0x4631('0x11')][_0x4631('0x13')]);return _0x2bb9a9(_0x13c06c[_0x4631('0x11')][_0x4631('0x13')]);}else{logger[_0x4631('0xc')]('VoiceMailMessage,\x20%s,\x20%s',_0x3d2bc0,_0x4631('0xe'));_0x2bb9a9(_0x13c06c['result'][_0x4631('0x13')]);}})[_0x4631('0x14')](function(_0x5af0bc){logger[_0x4631('0x11')](_0x4631('0xd'),_0x3d2bc0,_0x5af0bc);_0x499e50(_0x5af0bc);});});} \ No newline at end of file diff --git a/server/api/voiceMusicOnHold/index.js b/server/api/voiceMusicOnHold/index.js new file mode 100644 index 0000000..2a91590 --- /dev/null +++ b/server/api/voiceMusicOnHold/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5737=['isAuthenticated','/:id','/:id/sounds','addSound','put','delete','destroy','removeSound','exports','util','path','connect-timeout','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./voiceMusicOnHold.controller','get'];(function(_0x405dc0,_0x5f2898){var _0x1ed46d=function(_0x5efad7){while(--_0x5efad7){_0x405dc0['push'](_0x405dc0['shift']());}};_0x1ed46d(++_0x5f2898);}(_0x5737,0xb4));var _0x7573=function(_0x3416d9,_0x6a56f9){_0x3416d9=_0x3416d9-0x0;var _0x589ad9=_0x5737[_0x3416d9];return _0x589ad9;};'use strict';var multer=require('multer');var util=require(_0x7573('0x0'));var path=require(_0x7573('0x1'));var timeout=require(_0x7573('0x2'));var express=require('express');var router=express[_0x7573('0x3')]();var fs_extra=require(_0x7573('0x4'));var auth=require(_0x7573('0x5'));var interaction=require(_0x7573('0x6'));var config=require(_0x7573('0x7'));var controller=require(_0x7573('0x8'));router[_0x7573('0x9')]('/',auth[_0x7573('0xa')](),controller['index']);router['get'](_0x7573('0xb'),auth[_0x7573('0xa')](),controller['show']);router[_0x7573('0x9')]('/:id/sounds',auth[_0x7573('0xa')](),controller['getSounds']);router['post']('/',auth[_0x7573('0xa')](),controller['create']);router['post'](_0x7573('0xc'),auth[_0x7573('0xa')](),controller[_0x7573('0xd')]);router[_0x7573('0xe')](_0x7573('0xb'),auth[_0x7573('0xa')](),controller['update']);router[_0x7573('0xf')](_0x7573('0xb'),auth[_0x7573('0xa')](),controller[_0x7573('0x10')]);router[_0x7573('0xf')]('/:id/sounds/:id2',auth[_0x7573('0xa')](),controller[_0x7573('0x11')]);module[_0x7573('0x12')]=router; \ No newline at end of file diff --git a/server/api/voiceMusicOnHold/voiceMusicOnHold.attributes.js b/server/api/voiceMusicOnHold/voiceMusicOnHold.attributes.js new file mode 100644 index 0000000..5823f75 --- /dev/null +++ b/server/api/voiceMusicOnHold/voiceMusicOnHold.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8afd=['alpha','BOOLEAN','sequelize','exports','STRING','name','mp3nb','quietmp3nb','quietmp3','mp3','files'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x8afd,0x178));var _0xd8af=function(_0x43bce3,_0x5c12b4){_0x43bce3=_0x43bce3-0x0;var _0x4f0bd0=_0x8afd[_0x43bce3];return _0x4f0bd0;};'use strict';var Sequelize=require(_0xd8af('0x0'));module[_0xd8af('0x1')]={'name':{'type':Sequelize[_0xd8af('0x2')],'allowNull':![],'unique':_0xd8af('0x3')},'mode':{'type':Sequelize['ENUM']('custom','files',_0xd8af('0x4'),_0xd8af('0x5'),_0xd8af('0x6'),_0xd8af('0x7')),'allowNull':!![],'defaultValue':_0xd8af('0x8')},'directory':{'type':Sequelize[_0xd8af('0x2')],'allowNull':!![]},'application':{'type':Sequelize['STRING'],'allowNull':!![]},'digit':{'type':Sequelize[_0xd8af('0x2')],'allowNull':!![]},'sort':{'type':Sequelize[_0xd8af('0x2')],'allowNull':!![],'defaultValue':_0xd8af('0x9')},'format':{'type':Sequelize[_0xd8af('0x2')],'allowNull':!![]},'stamp':{'type':'TIMESTAMP'},'defaultEntry':{'type':Sequelize[_0xd8af('0xa')],'defaultValue':0x0}}; \ No newline at end of file diff --git a/server/api/voiceMusicOnHold/voiceMusicOnHold.controller.js b/server/api/voiceMusicOnHold/voiceMusicOnHold.controller.js new file mode 100644 index 0000000..14329fc --- /dev/null +++ b/server/api/voiceMusicOnHold/voiceMusicOnHold.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8d3=['apply','reject','save','then','get','MusicOnHolds','error','name','send','index','VoiceMusicOnHold','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','where','merge','filter','options','includeAll','include','findAll','catch','params','body','find','transaction','mode','files','directory','join','root','server/files/moh','create','mkdirSync','0777','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','destroy','readdirSync','forEach','unlinkSync','rmdirSync','Sequelize','ValidationError','message','sequelize','addSound','Sound','findOne','save_name','converted_format','createdAt','server/files/sounds/converted','format','%s.%s','basename','extname','symlinkSync','removeSound','id2','rawAttributes','getSounds','eml-format','fast-json-patch','bluebird','mustache','util','path','sox','fs-extra','lodash','squel','crypto','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','undefined','limit','count','set'];(function(_0x4a5bf4,_0x1e45d5){var _0x350cb9=function(_0x18a1fe){while(--_0x18a1fe){_0x4a5bf4['push'](_0x4a5bf4['shift']());}};_0x350cb9(++_0x1e45d5);}(_0xd8d3,0xbd));var _0x3d8d=function(_0x4eba91,_0x55b74c){_0x4eba91=_0x4eba91-0x0;var _0x185e37=_0xd8d3[_0x4eba91];return _0x185e37;};'use strict';var emlformat=require(_0x3d8d('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x3d8d('0x1'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x3d8d('0x2'));var Mustache=require(_0x3d8d('0x3'));var util=require(_0x3d8d('0x4'));var path=require(_0x3d8d('0x5'));var sox=require(_0x3d8d('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x3d8d('0x7'));var _=require(_0x3d8d('0x8'));var squel=require(_0x3d8d('0x9'));var crypto=require(_0x3d8d('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x3d8d('0xb'));var toCsv=require(_0x3d8d('0xc'));var querystring=require(_0x3d8d('0xd'));var Papa=require('papaparse');var Redis=require(_0x3d8d('0xe'));var authService=require(_0x3d8d('0xf'));var qs=require(_0x3d8d('0x10'));var as=require(_0x3d8d('0x11'));var hardwareService=require(_0x3d8d('0x12'));var logger=require(_0x3d8d('0x13'))('api');var utils=require(_0x3d8d('0x14'));var config=require(_0x3d8d('0x15'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x30f791,_0x458d70){_0x458d70=_0x458d70||0xcc;return function(_0x1e977e){if(_0x1e977e){return _0x30f791[_0x3d8d('0x16')](_0x458d70);}return _0x30f791[_0x3d8d('0x17')](_0x458d70)[_0x3d8d('0x18')]();};}function respondWithResult(_0x90aa43,_0x2c934b){_0x2c934b=_0x2c934b||0xc8;return function(_0x50b5bc){if(_0x50b5bc){return _0x90aa43[_0x3d8d('0x17')](_0x2c934b)[_0x3d8d('0x19')](_0x50b5bc);}};}function respondWithFilteredResult(_0x49600d,_0x3538de){return function(_0x1343ea){if(_0x1343ea){var _0x59b81b=typeof _0x3538de[_0x3d8d('0x1a')]===_0x3d8d('0x1b')&&typeof _0x3538de[_0x3d8d('0x1c')]===_0x3d8d('0x1b');var _0x1fb45d=_0x1343ea[_0x3d8d('0x1d')];var _0x5c3008=_0x59b81b?0x0:_0x3538de[_0x3d8d('0x1a')];var _0x43c8e8=_0x59b81b?_0x1343ea['count']:_0x3538de[_0x3d8d('0x1a')]+_0x3538de[_0x3d8d('0x1c')];var _0x5ace44;if(_0x43c8e8>=_0x1fb45d){_0x43c8e8=_0x1fb45d;_0x5ace44=0xc8;}else{_0x5ace44=0xce;}_0x49600d[_0x3d8d('0x17')](_0x5ace44);return _0x49600d[_0x3d8d('0x1e')]('Content-Range',_0x5c3008+'-'+_0x43c8e8+'/'+_0x1fb45d)[_0x3d8d('0x19')](_0x1343ea);}return null;};}function patchUpdates(_0x45c9d3){return function(_0x5e0e3a){try{jsonpatch[_0x3d8d('0x1f')](_0x5e0e3a,_0x45c9d3,!![]);}catch(_0x16f1a9){return BPromise[_0x3d8d('0x20')](_0x16f1a9);}return _0x5e0e3a[_0x3d8d('0x21')]();};}function saveUpdates(_0xf6dc2b,_0x5339d0){return function(_0x5c513a){if(_0x5c513a){return _0x5c513a['update'](_0xf6dc2b)[_0x3d8d('0x22')](function(_0x414e03){return _0x414e03;});}return null;};}function removeEntity(_0x16d0ce,_0x42208a){return function(_0x4cbbb1){if(_0x4cbbb1){return _0x4cbbb1['destroy']()[_0x3d8d('0x22')](function(){var _0x2121b3=_0x4cbbb1[_0x3d8d('0x23')]({'plain':!![]});var _0x1ff2aa=_0x3d8d('0x24');return db['UserProfileResource']['destroy']({'where':{'type':_0x1ff2aa,'resourceId':_0x2121b3['id']}})[_0x3d8d('0x22')](function(){return _0x4cbbb1;});})[_0x3d8d('0x22')](function(){_0x16d0ce['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x480709,_0xd562b9){return function(_0x5c99dc){if(!_0x5c99dc){_0x480709[_0x3d8d('0x16')](0x194);}return _0x5c99dc;};}function handleError(_0xdb72b1,_0x37a682){_0x37a682=_0x37a682||0x1f4;return function(_0x1e8e64){logger[_0x3d8d('0x25')](_0x1e8e64['stack']);if(_0x1e8e64['name']){delete _0x1e8e64[_0x3d8d('0x26')];}_0xdb72b1[_0x3d8d('0x17')](_0x37a682)[_0x3d8d('0x27')](_0x1e8e64);};}exports[_0x3d8d('0x28')]=function(_0x17ec4e,_0xc3f95a){var _0x3b4a18={},_0x2c5040={},_0x2001bf={'count':0x0,'rows':[]};var _0x45c0a0=_['map'](db[_0x3d8d('0x29')]['rawAttributes'],function(_0x30a8ee){return{'name':_0x30a8ee[_0x3d8d('0x2a')],'type':_0x30a8ee[_0x3d8d('0x2b')][_0x3d8d('0x2c')]};});_0x2c5040[_0x3d8d('0x2d')]=_[_0x3d8d('0x2e')](_0x45c0a0,_0x3d8d('0x26'));_0x2c5040[_0x3d8d('0x2f')]=_[_0x3d8d('0x30')](_0x17ec4e[_0x3d8d('0x2f')]);_0x2c5040[_0x3d8d('0x31')]=_['intersection'](_0x2c5040[_0x3d8d('0x2d')],_0x2c5040['query']);_0x3b4a18['attributes']=_[_0x3d8d('0x32')](_0x2c5040[_0x3d8d('0x2d')],qs[_0x3d8d('0x33')](_0x17ec4e[_0x3d8d('0x2f')]['fields']));_0x3b4a18['attributes']=_0x3b4a18[_0x3d8d('0x34')][_0x3d8d('0x35')]?_0x3b4a18[_0x3d8d('0x34')]:_0x2c5040[_0x3d8d('0x2d')];if(!_0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x36')](_0x3d8d('0x37'))){_0x3b4a18[_0x3d8d('0x1c')]=qs[_0x3d8d('0x1c')](_0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x1c')]);_0x3b4a18[_0x3d8d('0x1a')]=qs['offset'](_0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x1a')]);}_0x3b4a18[_0x3d8d('0x38')]=qs[_0x3d8d('0x39')](_0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x39')]);delete _0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x39')];_0x3b4a18['where']=qs[_0x3d8d('0x31')](_[_0x3d8d('0x3a')](_0x17ec4e[_0x3d8d('0x2f')],_0x2c5040[_0x3d8d('0x31')]),_0x45c0a0);if(_0x17ec4e[_0x3d8d('0x2f')]['filter']){_0x3b4a18[_0x3d8d('0x3b')]=_[_0x3d8d('0x3c')](_0x3b4a18[_0x3d8d('0x3b')],{'$or':_[_0x3d8d('0x2e')](_0x45c0a0,function(_0x24009e){if(_0x24009e[_0x3d8d('0x2b')]!=='VIRTUAL'){var _0x5241f6={};_0x5241f6[_0x24009e[_0x3d8d('0x26')]]={'$like':'%'+_0x17ec4e[_0x3d8d('0x2f')][_0x3d8d('0x3d')]+'%'};return _0x5241f6;}})});}_0x3b4a18=_[_0x3d8d('0x3c')]({},_0x3b4a18,_0x17ec4e[_0x3d8d('0x3e')]);var _0x43c74c={'where':_0x3b4a18[_0x3d8d('0x3b')]};return db[_0x3d8d('0x29')][_0x3d8d('0x1d')](_0x43c74c)[_0x3d8d('0x22')](function(_0x84200c){_0x2001bf[_0x3d8d('0x1d')]=_0x84200c;if(_0x17ec4e['query'][_0x3d8d('0x3f')]){_0x3b4a18[_0x3d8d('0x40')]=[{'all':!![]}];}return db[_0x3d8d('0x29')][_0x3d8d('0x41')](_0x3b4a18);})['then'](function(_0x4ae34a){_0x2001bf['rows']=_0x4ae34a;return _0x2001bf;})['then'](respondWithFilteredResult(_0xc3f95a,_0x3b4a18))[_0x3d8d('0x42')](handleError(_0xc3f95a,null));};exports['show']=function(_0x2a6026,_0x2c6a61){var _0x4118d6={'raw':![],'where':{'id':_0x2a6026[_0x3d8d('0x43')]['id']}},_0x50c743={};_0x50c743[_0x3d8d('0x2d')]=_[_0x3d8d('0x30')](db[_0x3d8d('0x29')]['rawAttributes']);_0x50c743['query']=_['keys'](_0x2a6026['query']);_0x50c743[_0x3d8d('0x31')]=_['intersection'](_0x50c743[_0x3d8d('0x2d')],_0x50c743[_0x3d8d('0x2f')]);_0x4118d6[_0x3d8d('0x34')]=_[_0x3d8d('0x32')](_0x50c743[_0x3d8d('0x2d')],qs[_0x3d8d('0x33')](_0x2a6026[_0x3d8d('0x2f')][_0x3d8d('0x33')]));_0x4118d6['attributes']=_0x4118d6[_0x3d8d('0x34')]['length']?_0x4118d6[_0x3d8d('0x34')]:_0x50c743['model'];if(_0x2a6026['query'][_0x3d8d('0x3f')]){_0x4118d6['include']=[{'all':!![]}];}_0x4118d6=_[_0x3d8d('0x3c')]({},_0x4118d6,_0x2a6026[_0x3d8d('0x3e')]);return db[_0x3d8d('0x29')]['find'](_0x4118d6)[_0x3d8d('0x22')](handleEntityNotFound(_0x2c6a61,null))['then'](respondWithResult(_0x2c6a61,null))[_0x3d8d('0x42')](handleError(_0x2c6a61,null));};exports['update']=function(_0x2c6d0f,_0x430d39){if(_0x2c6d0f['body']['id']){delete _0x2c6d0f[_0x3d8d('0x44')]['id'];}return db[_0x3d8d('0x29')][_0x3d8d('0x45')]({'where':{'id':_0x2c6d0f[_0x3d8d('0x43')]['id']}})['then'](handleEntityNotFound(_0x430d39,null))[_0x3d8d('0x22')](saveUpdates(_0x2c6d0f[_0x3d8d('0x44')],null))['then'](respondWithResult(_0x430d39,null))[_0x3d8d('0x42')](handleError(_0x430d39,null));};exports['create']=function(_0x5ed283,_0x3f71f1,_0x8af153){return db['sequelize'][_0x3d8d('0x46')](function(_0x19553e){if(_0x5ed283[_0x3d8d('0x44')][_0x3d8d('0x47')]===_0x3d8d('0x48')){_0x5ed283[_0x3d8d('0x44')][_0x3d8d('0x49')]=path[_0x3d8d('0x4a')](config[_0x3d8d('0x4b')],_0x3d8d('0x4c'),_0x5ed283['body'][_0x3d8d('0x26')]);}return db[_0x3d8d('0x29')][_0x3d8d('0x4d')](_0x5ed283[_0x3d8d('0x44')],{'transaction':_0x19553e})['then'](function(_0x32227b){if(_0x5ed283['body'][_0x3d8d('0x47')]==='files'){fs[_0x3d8d('0x4e')](_0x32227b[_0x3d8d('0x49')],parseInt(_0x3d8d('0x4f'),0x8));}var _0x1fe3b5=_0x5ed283['user']['get']({'plain':!![]});if(!_0x1fe3b5)throw new Error(_0x3d8d('0x50'));if(_0x1fe3b5[_0x3d8d('0x51')]===_0x3d8d('0x52')){var _0x16651f=_0x32227b[_0x3d8d('0x23')]({'plain':!![]});return db['UserProfileSection'][_0x3d8d('0x45')]({'where':{'name':_0x3d8d('0x24'),'userProfileId':_0x1fe3b5[_0x3d8d('0x53')]},'raw':!![]})[_0x3d8d('0x22')](function(_0x15616f){if(_0x15616f&&_0x15616f[_0x3d8d('0x54')]===0x0){return db['UserProfileResource'][_0x3d8d('0x4d')]({'name':_0x16651f[_0x3d8d('0x26')],'resourceId':_0x16651f['id'],'type':_0x15616f[_0x3d8d('0x26')],'sectionId':_0x15616f['id']},{})['then'](function(){return _0x32227b;});}else{return _0x32227b;}})['catch'](function(_0x5796eb){logger[_0x3d8d('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5796eb);});}return _0x32227b;});})[_0x3d8d('0x22')](respondWithResult(_0x3f71f1,0xc9))[_0x3d8d('0x42')](handleError(_0x3f71f1,null));};exports[_0x3d8d('0x55')]=function(_0x56dee8,_0x1df669,_0x3b328c){var _0x3648b3;return db[_0x3d8d('0x29')][_0x3d8d('0x45')]({'where':{'id':_0x56dee8['params']['id']}})[_0x3d8d('0x22')](function(_0x4ac6cb){if(_0x4ac6cb){return db['sequelize'][_0x3d8d('0x46')](function(_0x389d3b){return _0x4ac6cb[_0x3d8d('0x55')]({'transaction':_0x389d3b,'raw':!![]})[_0x3d8d('0x22')](function(_0x44a664){if(_0x44a664[_0x3d8d('0x49')]){fs[_0x3d8d('0x56')](_0x44a664['directory'])[_0x3d8d('0x57')](function(_0x2502e0){fs[_0x3d8d('0x58')](path[_0x3d8d('0x4a')](_0x44a664[_0x3d8d('0x49')],_0x2502e0));});fs[_0x3d8d('0x59')](_0x44a664[_0x3d8d('0x49')]);}return _0x44a664;});})[_0x3d8d('0x42')](function(_0x16e871){throw new db[(_0x3d8d('0x5a'))][(_0x3d8d('0x5b'))](_0x16e871[_0x3d8d('0x5c')]);});}})[_0x3d8d('0x22')](handleEntityNotFound(_0x1df669,null))[_0x3d8d('0x22')](removeEntity(_0x1df669,null))[_0x3d8d('0x42')](handleError(_0x1df669,null));};exports['addSound']=function(_0xbca50f,_0x5b0911,_0x18604b){return db[_0x3d8d('0x5d')][_0x3d8d('0x46')](function(_0x5d6a3f){var _0x1bdc6e;return db['VoiceMusicOnHold'][_0x3d8d('0x45')]({'where':{'id':_0xbca50f[_0x3d8d('0x43')]['id']}})[_0x3d8d('0x22')](function(_0x117dde){if(_0x117dde){_0x1bdc6e=_0x117dde;return _0x117dde[_0x3d8d('0x5e')](_0xbca50f[_0x3d8d('0x44')]['id'],{'transaction':_0x5d6a3f});}})[_0x3d8d('0x22')](function(_0xd3f262){if(_0xd3f262){return db[_0x3d8d('0x5f')][_0x3d8d('0x60')]({'where':{'id':_0xbca50f[_0x3d8d('0x44')]['id']},'attributes':['id','name',_0x3d8d('0x61'),_0x3d8d('0x62'),_0x3d8d('0x63')],'raw':!![]});}})[_0x3d8d('0x22')](function(_0x52ea50){if(_0x52ea50){var _0x143ffa=path[_0x3d8d('0x4a')](config[_0x3d8d('0x4b')],_0x3d8d('0x64'),util[_0x3d8d('0x65')](_0x3d8d('0x66'),path[_0x3d8d('0x67')](_0x52ea50[_0x3d8d('0x61')],path[_0x3d8d('0x68')](_0x52ea50['save_name'])),_0x52ea50[_0x3d8d('0x62')]));var _0x112f8f=path['join'](config[_0x3d8d('0x4b')],_0x3d8d('0x4c'),_0x1bdc6e[_0x3d8d('0x26')],util[_0x3d8d('0x65')](_0x3d8d('0x66'),_0x52ea50[_0x3d8d('0x26')],_0x52ea50[_0x3d8d('0x62')]));fs[_0x3d8d('0x69')](_0x143ffa,_0x112f8f);return _0x52ea50;}})[_0x3d8d('0x42')](function(_0xe7637d){throw new db[(_0x3d8d('0x5a'))]['ValidationError'](_0xe7637d[_0x3d8d('0x5c')]);});})['then'](handleEntityNotFound(_0x5b0911,null))[_0x3d8d('0x22')](respondWithResult(_0x5b0911,0xc9))[_0x3d8d('0x42')](handleError(_0x5b0911,null));};exports[_0x3d8d('0x6a')]=function(_0x3491a1,_0x106566,_0x3dc648){return db[_0x3d8d('0x5d')][_0x3d8d('0x46')](function(_0x16a504){var _0xae368;return db['VoiceMusicOnHold'][_0x3d8d('0x60')]({'where':{'id':_0x3491a1[_0x3d8d('0x43')]['id']}})[_0x3d8d('0x22')](handleEntityNotFound(_0x106566,null))[_0x3d8d('0x22')](function(_0x50249d){if(_0x50249d){_0xae368=_0x50249d;return _0x50249d[_0x3d8d('0x6a')](_0x3491a1['params'][_0x3d8d('0x6b')]);}})[_0x3d8d('0x22')](function(_0x1e8df3){if(_0x1e8df3){return db[_0x3d8d('0x5f')][_0x3d8d('0x60')]({'where':{'id':_0x3491a1[_0x3d8d('0x43')][_0x3d8d('0x6b')]},'attributes':['id',_0x3d8d('0x26'),'save_name','converted_format','createdAt'],'raw':!![]});}})[_0x3d8d('0x22')](function(_0x5bff97){if(_0x5bff97){fs[_0x3d8d('0x58')](path[_0x3d8d('0x4a')](_0xae368['directory'],util['format'](_0x3d8d('0x66'),_0x5bff97[_0x3d8d('0x26')],_0x5bff97['converted_format'])));return _0x5bff97;}})[_0x3d8d('0x42')](function(_0x27789a){throw new db['Sequelize']['ValidationError'](_0x27789a['message']);});})[_0x3d8d('0x22')](handleEntityNotFound(_0x106566,null))[_0x3d8d('0x22')](respondWithStatusCode(_0x106566,0xcc))[_0x3d8d('0x42')](handleError(_0x106566,null));};exports['getSounds']=function(_0x587d10,_0x16cac8,_0x50844e){var _0x17af8e={};var _0x30b9={};var _0x5b84eb;var _0x4ae936;return db[_0x3d8d('0x29')][_0x3d8d('0x60')]({'where':{'id':_0x587d10[_0x3d8d('0x43')]['id']}})[_0x3d8d('0x22')](handleEntityNotFound(_0x16cac8,null))[_0x3d8d('0x22')](function(_0x512d06){if(_0x512d06){_0x5b84eb=_0x512d06;_0x30b9[_0x3d8d('0x2d')]=_[_0x3d8d('0x30')](db['Sound'][_0x3d8d('0x6c')]);_0x30b9[_0x3d8d('0x2f')]=_[_0x3d8d('0x30')](_0x587d10[_0x3d8d('0x2f')]);_0x30b9[_0x3d8d('0x31')]=_['intersection'](_0x30b9[_0x3d8d('0x2d')],_0x30b9[_0x3d8d('0x2f')]);_0x17af8e[_0x3d8d('0x34')]=_[_0x3d8d('0x32')](_0x30b9[_0x3d8d('0x2d')],qs[_0x3d8d('0x33')](_0x587d10[_0x3d8d('0x2f')][_0x3d8d('0x33')]));_0x17af8e[_0x3d8d('0x34')]=_0x17af8e[_0x3d8d('0x34')][_0x3d8d('0x35')]?_0x17af8e[_0x3d8d('0x34')]:_0x30b9[_0x3d8d('0x2d')];_0x17af8e['order']=qs[_0x3d8d('0x39')](_0x587d10['query']['sort']);_0x17af8e[_0x3d8d('0x3b')]=qs['filters'](_[_0x3d8d('0x3a')](_0x587d10[_0x3d8d('0x2f')],_0x30b9[_0x3d8d('0x31')]));if(_0x587d10[_0x3d8d('0x2f')][_0x3d8d('0x3d')]){_0x17af8e[_0x3d8d('0x3b')]=_[_0x3d8d('0x3c')](_0x17af8e[_0x3d8d('0x3b')],{'$or':_['map'](_0x17af8e[_0x3d8d('0x34')],function(_0x2a5ebc){var _0x39093a={};_0x39093a[_0x2a5ebc]={'$like':'%'+_0x587d10[_0x3d8d('0x2f')][_0x3d8d('0x3d')]+'%'};return _0x39093a;})});}_0x17af8e=_['merge']({},_0x17af8e,_0x587d10[_0x3d8d('0x3e')]);return _0x5b84eb[_0x3d8d('0x6d')](_0x17af8e);}})[_0x3d8d('0x22')](function(_0x5325cf){if(_0x5325cf){_0x4ae936=_0x5325cf[_0x3d8d('0x35')];if(!_0x587d10[_0x3d8d('0x2f')]['hasOwnProperty'](_0x3d8d('0x37'))){_0x17af8e[_0x3d8d('0x1c')]=qs[_0x3d8d('0x1c')](_0x587d10[_0x3d8d('0x2f')][_0x3d8d('0x1c')]);_0x17af8e[_0x3d8d('0x1a')]=qs['offset'](_0x587d10[_0x3d8d('0x2f')]['offset']);}return _0x5b84eb['getSounds'](_0x17af8e);}})[_0x3d8d('0x22')](function(_0x3fb665){if(_0x3fb665){return _0x3fb665?{'count':_0x4ae936,'rows':_0x3fb665}:null;}})['then'](respondWithResult(_0x16cac8,null))['catch'](handleError(_0x16cac8,null));}; \ No newline at end of file diff --git a/server/api/voiceMusicOnHold/voiceMusicOnHold.model.js b/server/api/voiceMusicOnHold/voiceMusicOnHold.model.js new file mode 100644 index 0000000..c216201 --- /dev/null +++ b/server/api/voiceMusicOnHold/voiceMusicOnHold.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd0da=['request-promise','path','rimraf','voice_musiconhold','lodash','util','../../config/logger','moment'];(function(_0x53dd63,_0x5e1852){var _0x460c0a=function(_0x599511){while(--_0x599511){_0x53dd63['push'](_0x53dd63['shift']());}};_0x460c0a(++_0x5e1852);}(_0xd0da,0x7c));var _0xad0d=function(_0x3a6194,_0x4574e2){_0x3a6194=_0x3a6194-0x0;var _0x298116=_0xd0da[_0x3a6194];return _0x298116;};'use strict';var _=require(_0xad0d('0x0'));var util=require(_0xad0d('0x1'));var logger=require(_0xad0d('0x2'))('api');var moment=require(_0xad0d('0x3'));var BPromise=require('bluebird');var rp=require(_0xad0d('0x4'));var fs=require('fs');var path=require(_0xad0d('0x5'));var rimraf=require(_0xad0d('0x6'));var config=require('../../config/environment');var attributes=require('./voiceMusicOnHold.attributes');module['exports']=function(_0x46e793,_0x54245e){return _0x46e793['define']('VoiceMusicOnHold',attributes,{'tableName':_0xad0d('0x7'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceMusicOnHold/voiceMusicOnHold.rpc.js b/server/api/voiceMusicOnHold/voiceMusicOnHold.rpc.js new file mode 100644 index 0000000..60763c5 --- /dev/null +++ b/server/api/voiceMusicOnHold/voiceMusicOnHold.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x70e0=['code','VoiceMusicOnHold,\x20%s,\x20%s','message','result','catch','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','request','then','info','debug','VoiceMusicOnHold,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x395cea,_0x137431){var _0x104804=function(_0x5c43ba){while(--_0x5c43ba){_0x395cea['push'](_0x395cea['shift']());}};_0x104804(++_0x137431);}(_0x70e0,0x17b));var _0x070e=function(_0x289906,_0x40f55d){_0x289906=_0x289906-0x0;var _0xb4a82b=_0x70e0[_0x289906];return _0xb4a82b;};'use strict';var _=require(_0x070e('0x0'));var util=require(_0x070e('0x1'));var moment=require(_0x070e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x070e('0x3'));var db=require(_0x070e('0x4'))['db'];var utils=require(_0x070e('0x5'));var logger=require(_0x070e('0x6'))('rpc');var config=require(_0x070e('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x070e('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x56e420,_0x5032e5,_0x35ab0c){return new BPromise(function(_0x1e11f0,_0x604664){return client[_0x070e('0x9')](_0x56e420,_0x35ab0c)[_0x070e('0xa')](function(_0x68a09e){logger[_0x070e('0xb')]('VoiceMusicOnHold,\x20%s,\x20%s',_0x5032e5,'request\x20sent');logger[_0x070e('0xc')](_0x070e('0xd'),_0x5032e5,_0x070e('0xe'),JSON[_0x070e('0xf')](_0x68a09e));if(_0x68a09e[_0x070e('0x10')]){if(_0x68a09e[_0x070e('0x10')][_0x070e('0x11')]===0x1f4){logger[_0x070e('0x10')](_0x070e('0x12'),_0x5032e5,_0x68a09e[_0x070e('0x10')][_0x070e('0x13')]);return _0x604664(_0x68a09e['error']['message']);}logger[_0x070e('0x10')]('VoiceMusicOnHold,\x20%s,\x20%s',_0x5032e5,_0x68a09e['error']['message']);return _0x1e11f0(_0x68a09e[_0x070e('0x10')][_0x070e('0x13')]);}else{logger['info']('VoiceMusicOnHold,\x20%s,\x20%s',_0x5032e5,_0x070e('0xe'));_0x1e11f0(_0x68a09e[_0x070e('0x14')][_0x070e('0x13')]);}})[_0x070e('0x15')](function(_0x5bc71e){logger['error'](_0x070e('0x12'),_0x5032e5,_0x5bc71e);_0x604664(_0x5bc71e);});});} \ No newline at end of file diff --git a/server/api/voicePrefix/index.js b/server/api/voicePrefix/index.js new file mode 100644 index 0000000..acf25f1 --- /dev/null +++ b/server/api/voicePrefix/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe444=['show','/:id/users','getTeams','post','create','addAgents','/:id/teams','addTeams','put','/:id','update','destroy','delete','removeAgents','removeTeams','exports','multer','util','express','Router','fs-extra','../../components/auth/service','./voicePrefix.controller','get','isAuthenticated','/describe'];(function(_0x233d84,_0x3f63c9){var _0x33f28f=function(_0x27646b){while(--_0x27646b){_0x233d84['push'](_0x233d84['shift']());}};_0x33f28f(++_0x3f63c9);}(_0xe444,0xe0));var _0x4e44=function(_0x2c0464,_0x5316c4){_0x2c0464=_0x2c0464-0x0;var _0x5818d7=_0xe444[_0x2c0464];return _0x5818d7;};'use strict';var multer=require(_0x4e44('0x0'));var util=require(_0x4e44('0x1'));var path=require('path');var timeout=require('connect-timeout');var express=require(_0x4e44('0x2'));var router=express[_0x4e44('0x3')]();var fs_extra=require(_0x4e44('0x4'));var auth=require(_0x4e44('0x5'));var interaction=require('../../components/interaction/service');var config=require('../../config/environment');var controller=require(_0x4e44('0x6'));router[_0x4e44('0x7')]('/',auth[_0x4e44('0x8')](),controller['index']);router[_0x4e44('0x7')](_0x4e44('0x9'),auth[_0x4e44('0x8')](),controller['describe']);router[_0x4e44('0x7')]('/:id',auth[_0x4e44('0x8')](),controller[_0x4e44('0xa')]);router[_0x4e44('0x7')](_0x4e44('0xb'),auth[_0x4e44('0x8')](),controller['getAgents']);router[_0x4e44('0x7')]('/:id/teams',auth[_0x4e44('0x8')](),controller[_0x4e44('0xc')]);router[_0x4e44('0xd')]('/',auth[_0x4e44('0x8')](),controller[_0x4e44('0xe')]);router['post']('/:id/users',auth['isAuthenticated'](),controller[_0x4e44('0xf')]);router['post'](_0x4e44('0x10'),auth[_0x4e44('0x8')](),controller[_0x4e44('0x11')]);router[_0x4e44('0x12')](_0x4e44('0x13'),auth[_0x4e44('0x8')](),controller[_0x4e44('0x14')]);router['delete'](_0x4e44('0x13'),auth[_0x4e44('0x8')](),controller[_0x4e44('0x15')]);router[_0x4e44('0x16')](_0x4e44('0xb'),auth[_0x4e44('0x8')](),controller[_0x4e44('0x17')]);router['delete'](_0x4e44('0x10'),auth[_0x4e44('0x8')](),controller[_0x4e44('0x18')]);module[_0x4e44('0x19')]=router; \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.attributes.js b/server/api/voicePrefix/voicePrefix.attributes.js new file mode 100644 index 0000000..114c46c --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8f7e=['getDataValue','INTEGER','exports','STRING','name','VIRTUAL','system-'];(function(_0x2763f2,_0x416af8){var _0x3ef471=function(_0x288aa2){while(--_0x288aa2){_0x2763f2['push'](_0x2763f2['shift']());}};_0x3ef471(++_0x416af8);}(_0x8f7e,0x13d));var _0xe8f7=function(_0x45a150,_0x6ace92){_0x45a150=_0x45a150-0x0;var _0x1e0cb1=_0x8f7e[_0x45a150];return _0x1e0cb1;};'use strict';var Sequelize=require('sequelize');module[_0xe8f7('0x0')]={'name':{'type':Sequelize[_0xe8f7('0x1')],'allowNull':![],'unique':_0xe8f7('0x2')},'prefix':{'type':Sequelize[_0xe8f7('0x3')],'get':function(_0x157ad7){return _0xe8f7('0x4')+this[_0xe8f7('0x5')]('name')+'-';}},'description':{'type':Sequelize[_0xe8f7('0x1')]},'callerIdAll':{'type':Sequelize['STRING']},'VoiceExtensionId':{'type':Sequelize[_0xe8f7('0x6')]}}; \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.controller.js b/server/api/voicePrefix/voicePrefix.controller.js new file mode 100644 index 0000000..4ddf74e --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x02ce=['apply','reject','save','update','destroy','then','get','VoicePrefixes','UserProfileResource','sendStatus','error','name','send','index','map','VoicePrefix','rawAttributes','key','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','merge','options','includeAll','include','findAll','rows','show','params','length','find','catch','sequelize','body','VoiceExtensionId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','create','context','from-sip','exten','app','type','description','Voice\x20Prefix\x20Extension','prefix','NoOp','Voice\x20Prefix','VoicePrefixId','bulkCreate','Extensions\x20creation\x20failed','push','callerIdAll','Set','PREFIX-CALLERIDALL=','${EXTEN:','charAt','system-','transaction','VoiceExtension','findById','ids','omit','spread','emit','userVoicePrefix:save','removeAgents','isArray','getAgents','User','pick','findOne','Team','getTeams','addTeams','online','voicePause','flatMap','Agents','each','TeamVoicePrefix','upsert','forEach','removeTeams','select','field','tq.TeamId','from','team_has_voice_prefixes','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoicePrefixId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','every','TeamId','includes','union','compact','value','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./voicePrefix.socket','status','end','json','undefined','limit','count','offset','set'];(function(_0x5afaf2,_0xe98979){var _0x4cb867=function(_0x472969){while(--_0x472969){_0x5afaf2['push'](_0x5afaf2['shift']());}};_0x4cb867(++_0xe98979);}(_0x02ce,0x1ac));var _0xe02c=function(_0x1d4a8,_0x496c80){_0x1d4a8=_0x1d4a8-0x0;var _0x382be7=_0x02ce[_0x1d4a8];return _0x382be7;};'use strict';var emlformat=require(_0xe02c('0x0'));var rimraf=require(_0xe02c('0x1'));var zipdir=require(_0xe02c('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe02c('0x3'));var moment=require('moment');var BPromise=require(_0xe02c('0x4'));var Mustache=require(_0xe02c('0x5'));var util=require(_0xe02c('0x6'));var path=require(_0xe02c('0x7'));var sox=require(_0xe02c('0x8'));var csv=require(_0xe02c('0x9'));var ejs=require(_0xe02c('0xa'));var fs=require('fs');var fs_extra=require(_0xe02c('0xb'));var _=require(_0xe02c('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xe02c('0xd'));var deskjs=require(_0xe02c('0xe'));var toCsv=require(_0xe02c('0x9'));var querystring=require(_0xe02c('0xf'));var Papa=require(_0xe02c('0x10'));var Redis=require(_0xe02c('0x11'));var authService=require(_0xe02c('0x12'));var qs=require(_0xe02c('0x13'));var as=require(_0xe02c('0x14'));var hardwareService=require(_0xe02c('0x15'));var logger=require(_0xe02c('0x16'))(_0xe02c('0x17'));var utils=require(_0xe02c('0x18'));var config=require(_0xe02c('0x19'));var licenseUtil=require(_0xe02c('0x1a'));var db=require(_0xe02c('0x1b'))['db'];config[_0xe02c('0x1c')]=_[_0xe02c('0x1d')](config['redis'],{'host':_0xe02c('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xe02c('0x1f'))['register'](socket);function respondWithStatusCode(_0x221910,_0x59614c){_0x59614c=_0x59614c||0xcc;return function(_0x3a5a2c){if(_0x3a5a2c){return _0x221910['sendStatus'](_0x59614c);}return _0x221910[_0xe02c('0x20')](_0x59614c)[_0xe02c('0x21')]();};}function respondWithResult(_0x59f2f6,_0x10a2a6){_0x10a2a6=_0x10a2a6||0xc8;return function(_0x226a80){if(_0x226a80){return _0x59f2f6['status'](_0x10a2a6)[_0xe02c('0x22')](_0x226a80);}};}function respondWithFilteredResult(_0x20f492,_0x5a4583){return function(_0x52917f){if(_0x52917f){var _0x3e37bf=typeof _0x5a4583['offset']===_0xe02c('0x23')&&typeof _0x5a4583[_0xe02c('0x24')]===_0xe02c('0x23');var _0x36fed0=_0x52917f[_0xe02c('0x25')];var _0x54c5b0=_0x3e37bf?0x0:_0x5a4583[_0xe02c('0x26')];var _0x59026f=_0x3e37bf?_0x52917f['count']:_0x5a4583[_0xe02c('0x26')]+_0x5a4583[_0xe02c('0x24')];var _0x480b9a;if(_0x59026f>=_0x36fed0){_0x59026f=_0x36fed0;_0x480b9a=0xc8;}else{_0x480b9a=0xce;}_0x20f492[_0xe02c('0x20')](_0x480b9a);return _0x20f492[_0xe02c('0x27')]('Content-Range',_0x54c5b0+'-'+_0x59026f+'/'+_0x36fed0)[_0xe02c('0x22')](_0x52917f);}return null;};}function patchUpdates(_0x45fd82){return function(_0x39b00c){try{jsonpatch[_0xe02c('0x28')](_0x39b00c,_0x45fd82,!![]);}catch(_0x2d44c8){return BPromise[_0xe02c('0x29')](_0x2d44c8);}return _0x39b00c[_0xe02c('0x2a')]();};}function saveUpdates(_0xf41d4c,_0xeae877){return function(_0x18b538){if(_0x18b538){return _0x18b538[_0xe02c('0x2b')](_0xf41d4c)['then'](function(_0xefd882){return _0xefd882;});}return null;};}function removeEntity(_0x4411d8,_0x3592ca){return function(_0x14ffba){if(_0x14ffba){return _0x14ffba[_0xe02c('0x2c')]()[_0xe02c('0x2d')](function(){var _0x43dc78=_0x14ffba[_0xe02c('0x2e')]({'plain':!![]});var _0x55ef2a=_0xe02c('0x2f');return db[_0xe02c('0x30')][_0xe02c('0x2c')]({'where':{'type':_0x55ef2a,'resourceId':_0x43dc78['id']}})['then'](function(){return _0x14ffba;});})[_0xe02c('0x2d')](function(){_0x4411d8[_0xe02c('0x20')](0xcc)[_0xe02c('0x21')]();});}};}function handleEntityNotFound(_0x287f7e,_0x1e7eab){return function(_0x35a309){if(!_0x35a309){_0x287f7e[_0xe02c('0x31')](0x194);}return _0x35a309;};}function handleError(_0x1b8f21,_0x9ee479){_0x9ee479=_0x9ee479||0x1f4;return function(_0x288004){logger[_0xe02c('0x32')](_0x288004['stack']);if(_0x288004[_0xe02c('0x33')]){delete _0x288004[_0xe02c('0x33')];}_0x1b8f21[_0xe02c('0x20')](_0x9ee479)[_0xe02c('0x34')](_0x288004);};}exports[_0xe02c('0x35')]=function(_0x14d27a,_0x58bf16){var _0x436bcc={},_0x1e605c={},_0x4fc4fd={'count':0x0,'rows':[]};var _0x1ce34c=_[_0xe02c('0x36')](db[_0xe02c('0x37')][_0xe02c('0x38')],function(_0x2b5ebe){return{'name':_0x2b5ebe['fieldName'],'type':_0x2b5ebe['type'][_0xe02c('0x39')]};});_0x1e605c[_0xe02c('0x3a')]=_['map'](_0x1ce34c,_0xe02c('0x33'));_0x1e605c['query']=_[_0xe02c('0x3b')](_0x14d27a[_0xe02c('0x3c')]);_0x1e605c[_0xe02c('0x3d')]=_[_0xe02c('0x3e')](_0x1e605c[_0xe02c('0x3a')],_0x1e605c['query']);_0x436bcc[_0xe02c('0x3f')]=_['intersection'](_0x1e605c[_0xe02c('0x3a')],qs[_0xe02c('0x40')](_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x40')]));_0x436bcc[_0xe02c('0x3f')]=_0x436bcc[_0xe02c('0x3f')]['length']?_0x436bcc[_0xe02c('0x3f')]:_0x1e605c[_0xe02c('0x3a')];if(!_0x14d27a['query'][_0xe02c('0x41')](_0xe02c('0x42'))){_0x436bcc['limit']=qs[_0xe02c('0x24')](_0x14d27a['query'][_0xe02c('0x24')]);_0x436bcc[_0xe02c('0x26')]=qs['offset'](_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x26')]);}_0x436bcc[_0xe02c('0x43')]=qs[_0xe02c('0x44')](_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x44')]);_0x436bcc['where']=qs[_0xe02c('0x3d')](_['pick'](_0x14d27a['query'],_0x1e605c[_0xe02c('0x3d')]),_0x1ce34c);if(_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x45')]){_0x436bcc[_0xe02c('0x46')]=_['merge'](_0x436bcc[_0xe02c('0x46')],{'$or':_[_0xe02c('0x36')](_0x1ce34c,function(_0x163573){if(_0x163573['type']!=='VIRTUAL'){var _0x33c6da={};_0x33c6da[_0x163573[_0xe02c('0x33')]]={'$like':'%'+_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x45')]+'%'};return _0x33c6da;}})});}_0x436bcc=_[_0xe02c('0x47')]({},_0x436bcc,_0x14d27a[_0xe02c('0x48')]);var _0x25f8ae={'where':_0x436bcc[_0xe02c('0x46')]};return db[_0xe02c('0x37')]['count'](_0x25f8ae)[_0xe02c('0x2d')](function(_0x5ef4a1){_0x4fc4fd['count']=_0x5ef4a1;if(_0x14d27a[_0xe02c('0x3c')][_0xe02c('0x49')]){_0x436bcc[_0xe02c('0x4a')]=[{'all':!![]}];}return db[_0xe02c('0x37')][_0xe02c('0x4b')](_0x436bcc);})[_0xe02c('0x2d')](function(_0x165f4a){_0x4fc4fd[_0xe02c('0x4c')]=_0x165f4a;return _0x4fc4fd;})['then'](respondWithFilteredResult(_0x58bf16,_0x436bcc))['catch'](handleError(_0x58bf16,null));};exports[_0xe02c('0x4d')]=function(_0xf89a57,_0x304ece){var _0x52f239={'raw':![],'where':{'id':_0xf89a57[_0xe02c('0x4e')]['id']}},_0x1cf443={};_0x1cf443[_0xe02c('0x3a')]=_[_0xe02c('0x3b')](db[_0xe02c('0x37')][_0xe02c('0x38')]);_0x1cf443[_0xe02c('0x3c')]=_[_0xe02c('0x3b')](_0xf89a57[_0xe02c('0x3c')]);_0x1cf443[_0xe02c('0x3d')]=_['intersection'](_0x1cf443[_0xe02c('0x3a')],_0x1cf443[_0xe02c('0x3c')]);_0x52f239[_0xe02c('0x3f')]=_[_0xe02c('0x3e')](_0x1cf443[_0xe02c('0x3a')],qs[_0xe02c('0x40')](_0xf89a57[_0xe02c('0x3c')][_0xe02c('0x40')]));_0x52f239[_0xe02c('0x3f')]=_0x52f239[_0xe02c('0x3f')][_0xe02c('0x4f')]?_0x52f239[_0xe02c('0x3f')]:_0x1cf443[_0xe02c('0x3a')];if(_0xf89a57['query'][_0xe02c('0x49')]){_0x52f239['include']=[{'all':!![]}];}_0x52f239=_[_0xe02c('0x47')]({},_0x52f239,_0xf89a57[_0xe02c('0x48')]);return db[_0xe02c('0x37')][_0xe02c('0x50')](_0x52f239)[_0xe02c('0x2d')](handleEntityNotFound(_0x304ece,null))[_0xe02c('0x2d')](respondWithResult(_0x304ece,null))[_0xe02c('0x51')](handleError(_0x304ece,null));};exports[_0xe02c('0x2c')]=function(_0xc6ea7b,_0x385497){return db['VoicePrefix'][_0xe02c('0x50')]({'where':{'id':_0xc6ea7b[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](handleEntityNotFound(_0x385497,null))['then'](removeEntity(_0x385497,null))[_0xe02c('0x51')](handleError(_0x385497,null));};exports['describe']=function(_0x21a126,_0x56b9e2){return db['VoicePrefix']['describe']()['then'](respondWithResult(_0x56b9e2,null))['catch'](handleError(_0x56b9e2,null));};exports['create']=function(_0x107f3f,_0x3ac0a5){var _0x1510aa;return db[_0xe02c('0x52')]['transaction'](function(_0x274beb){return db[_0xe02c('0x37')]['create'](_0x107f3f[_0xe02c('0x53')],{'transaction':_0x274beb})[_0xe02c('0x2d')](function(_0x221e5e){_0x1510aa=_0x221e5e['get']({'plain':!![]});return db['VoiceExtension'][_0xe02c('0x50')]({'where':{'id':_0x1510aa[_0xe02c('0x54')]},'raw':!![]})[_0xe02c('0x2d')](function(_0x5b2d2b){return createVoicePrefixExtensions(_0x1510aa,_0x5b2d2b,_0x274beb);});});})[_0xe02c('0x2d')](function(){var _0x53765c=_0x107f3f['user'][_0xe02c('0x2e')]({'plain':!![]});if(!_0x53765c)throw new Error(_0xe02c('0x55'));if(_0x53765c['role']===_0xe02c('0x56')){var _0x849eea=_0x1510aa;return db[_0xe02c('0x57')]['find']({'where':{'name':_0xe02c('0x2f'),'userProfileId':_0x53765c[_0xe02c('0x58')]},'raw':!![]})['then'](function(_0x3788e8){if(_0x3788e8&&_0x3788e8[_0xe02c('0x59')]===0x0){return db[_0xe02c('0x30')][_0xe02c('0x5a')]({'name':_0x849eea[_0xe02c('0x33')],'resourceId':_0x849eea['id'],'type':_0x3788e8[_0xe02c('0x33')],'sectionId':_0x3788e8['id']},{})[_0xe02c('0x2d')](function(){return _0x1510aa;});}else{return _0x1510aa;}})[_0xe02c('0x51')](function(_0xf7e836){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xf7e836);throw _0xf7e836;});}return _0x1510aa;})['then'](respondWithResult(_0x3ac0a5,null))[_0xe02c('0x51')](handleError(_0x3ac0a5,null));};function Extension(_0x299770,_0x42f2fd,_0x496eb1,_0x4eb35d){this[_0xe02c('0x5b')]=_0xe02c('0x5c');this[_0xe02c('0x5d')]=_0x299770;this[_0xe02c('0x5e')]=_0x496eb1;this[_0xe02c('0x5f')]='system';this[_0xe02c('0x60')]=_0xe02c('0x61');this['priority']=_0x42f2fd;this['appdata']=_0x4eb35d;}function createVoicePrefixExtensions(_0x879d99,_0x566204,_0x4da197){return new BPromise(function(_0x480d49,_0x3b19c9){var _0x28d7a2=new Extension(formatPrefixName(_0x879d99[_0xe02c('0x62')]),0x1,_0xe02c('0x63'),_0xe02c('0x64'));_0x28d7a2[_0xe02c('0x65')]=_0x879d99['id'];return db['VoiceExtension'][_0xe02c('0x5a')](_0x28d7a2,{'transaction':_0x4da197})['then'](function(_0x4f3c9a){var _0x185dc2=_0x4f3c9a[_0xe02c('0x2e')]({'plain':!![]});var _0x44ba68=_[_0xe02c('0x36')](addVoicePrefixExtensions(_0x879d99,_0x566204),function(_0x5b6979){_0x5b6979[_0xe02c('0x54')]=_0x185dc2['id'];_0x5b6979[_0xe02c('0x65')]=_0x879d99['id'];return _0x5b6979;});return db['VoiceExtension'][_0xe02c('0x66')](_0x44ba68,{'transaction':_0x4da197})[_0xe02c('0x2d')](function(_0x4cc74d){if(!_0x4cc74d){return _0x3b19c9(_0xe02c('0x67'));}else{return _0x480d49(_0x4cc74d);}})[_0xe02c('0x51')](function(_0x44f28f){return _0x3b19c9(_0x44f28f);});});;});};function addVoicePrefixExtensions(_0x4053e6,_0x323f3b){var _0x3a62a2=[];var _0x31b281=formatPrefixName(_0x4053e6['prefix']);_0x3a62a2[_0xe02c('0x68')](new Extension(_0x31b281,0x2,'Set','CDR(prefix)='+_0x4053e6['name']));if(_0x4053e6[_0xe02c('0x69')]){_0x3a62a2[_0xe02c('0x68')](new Extension(_0x31b281,0x3,_0xe02c('0x6a'),_0xe02c('0x6b')+_0x4053e6['callerIdAll']));}else{_0x3a62a2[_0xe02c('0x68')](new Extension(_0x31b281,0x3,_0xe02c('0x63'),'No\x20callerid\x20available'));}_0x3a62a2['push'](new Extension(_0x31b281,0x4,'goto',_0x323f3b[_0xe02c('0x5b')]+','+_0xe02c('0x6c')+(0x8+_0x4053e6['name']['length'])+'}'+','+0x1));return _0x3a62a2;}function formatPrefixName(_0x38789c){var _0x30ad9f='_';for(var _0x120ef1=0x0;_0x120ef1<_0x38789c[_0xe02c('0x4f')];_0x120ef1++){if(_0x38789c[_0xe02c('0x6d')](_0x120ef1)=='-'){_0x30ad9f+=_0x38789c['charAt'](_0x120ef1);}else{_0x30ad9f+='['+_0x38789c[_0xe02c('0x6d')](_0x120ef1)+']';}}_0x30ad9f+='.';return _0x30ad9f;}exports[_0xe02c('0x2b')]=function(_0x3f277b,_0x2776c0,_0x11c506){var _0x119119=_0x3f277b['body'];_0x119119[_0xe02c('0x62')]=_0xe02c('0x6e')+_0x119119['name']+'-';return db[_0xe02c('0x52')][_0xe02c('0x6f')](function(_0x123ca9){return db[_0xe02c('0x37')]['update'](_0x119119,{'where':{'id':_0x119119['id']},'transaction':_0x123ca9})[_0xe02c('0x2d')](function(){return db[_0xe02c('0x70')]['destroy']({'where':{'VoicePrefixId':_0x119119['id']},'transaction':_0x123ca9})['then'](function(){return db['VoiceExtension'][_0xe02c('0x50')]({'where':{'id':_0x119119[_0xe02c('0x54')]},'raw':!![]})[_0xe02c('0x2d')](function(_0x34e692){return createVoicePrefixExtensions(_0x119119,_0x34e692,_0x123ca9);});});});})[_0xe02c('0x2d')](function(){return db['VoicePrefix'][_0xe02c('0x71')](_0x119119['id']);})[_0xe02c('0x2d')](respondWithResult(_0x2776c0,null))[_0xe02c('0x51')](handleError(_0x2776c0,null));};exports['addAgents']=function(_0x4a7783,_0x4c3c91,_0x3cd802){return db[_0xe02c('0x37')][_0xe02c('0x50')]({'where':{'id':_0x4a7783[_0xe02c('0x4e')]['id']}})['then'](handleEntityNotFound(_0x4c3c91,null))[_0xe02c('0x2d')](function(_0x48f524){if(_0x48f524){return _0x48f524['addAgents'](_0x4a7783[_0xe02c('0x53')][_0xe02c('0x72')],_[_0xe02c('0x73')](_0x4a7783[_0xe02c('0x53')],[_0xe02c('0x72'),'id'])||{})[_0xe02c('0x74')](function(_0x748217){for(var _0x12aaea=0x0;_0x12aaea<_0x4a7783['body'][_0xe02c('0x72')][_0xe02c('0x4f')];_0x12aaea+=0x1){socket[_0xe02c('0x75')](_0xe02c('0x76'),{'UserId':Number(_0x4a7783[_0xe02c('0x53')][_0xe02c('0x72')][_0x12aaea]),'VoicePrefixId':Number(_0x4a7783[_0xe02c('0x4e')]['id'])});}return _0x748217;});}})[_0xe02c('0x2d')](respondWithResult(_0x4c3c91,null))[_0xe02c('0x51')](handleError(_0x4c3c91,null));};exports[_0xe02c('0x77')]=function(_0x5e6df5,_0x58acfd,_0x120dd7){return db[_0xe02c('0x37')][_0xe02c('0x50')]({'where':{'id':_0x5e6df5[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](handleEntityNotFound(_0x58acfd,null))['then'](function(_0x405b16){if(_0x405b16){return _0x405b16[_0xe02c('0x77')](_0x5e6df5[_0xe02c('0x3c')][_0xe02c('0x72')])[_0xe02c('0x2d')](function(){if(_[_0xe02c('0x78')](_0x5e6df5[_0xe02c('0x3c')][_0xe02c('0x72')])){for(var _0x1d594c=0x0;_0x1d594c<_0x5e6df5[_0xe02c('0x3c')][_0xe02c('0x72')][_0xe02c('0x4f')];_0x1d594c+=0x1){socket['emit']('userVoicePrefix:remove',{'UserId':Number(_0x5e6df5[_0xe02c('0x3c')][_0xe02c('0x72')][_0x1d594c]),'VoicePrefixId':Number(_0x5e6df5['params']['id'])});}}else{socket[_0xe02c('0x75')]('userVoicePrefix:remove',{'UserId':Number(_0x5e6df5[_0xe02c('0x3c')]['ids']),'VoicePrefixId':Number(_0x5e6df5[_0xe02c('0x4e')]['id'])});}});}})[_0xe02c('0x2d')](respondWithStatusCode(_0x58acfd,null))[_0xe02c('0x51')](handleError(_0x58acfd,null));};exports[_0xe02c('0x79')]=function(_0x28755a,_0x3c44d3,_0x119439){var _0x10d067={};var _0x3d3954={};var _0xd0d895;var _0x567478;return db['VoicePrefix']['findOne']({'where':{'id':_0x28755a[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](handleEntityNotFound(_0x3c44d3,null))[_0xe02c('0x2d')](function(_0x1133ce){if(_0x1133ce){_0xd0d895=_0x1133ce;_0x3d3954[_0xe02c('0x3a')]=_[_0xe02c('0x3b')](db[_0xe02c('0x7a')][_0xe02c('0x38')]);_0x3d3954[_0xe02c('0x3c')]=_[_0xe02c('0x3b')](_0x28755a[_0xe02c('0x3c')]);_0x3d3954[_0xe02c('0x3d')]=_[_0xe02c('0x3e')](_0x3d3954['model'],_0x3d3954['query']);_0x10d067[_0xe02c('0x3f')]=_[_0xe02c('0x3e')](_0x3d3954[_0xe02c('0x3a')],qs['fields'](_0x28755a[_0xe02c('0x3c')][_0xe02c('0x40')]));_0x10d067[_0xe02c('0x3f')]=_0x10d067[_0xe02c('0x3f')][_0xe02c('0x4f')]?_0x10d067['attributes']:_0x3d3954[_0xe02c('0x3a')];_0x10d067[_0xe02c('0x43')]=qs[_0xe02c('0x44')](_0x28755a['query'][_0xe02c('0x44')]);_0x10d067[_0xe02c('0x46')]=qs[_0xe02c('0x3d')](_[_0xe02c('0x7b')](_0x28755a[_0xe02c('0x3c')],_0x3d3954['filters']));if(_0x28755a[_0xe02c('0x3c')][_0xe02c('0x45')]){_0x10d067[_0xe02c('0x46')]=_['merge'](_0x10d067[_0xe02c('0x46')],{'$or':_[_0xe02c('0x36')](_0x10d067[_0xe02c('0x3f')],function(_0x3a5ec8){var _0x45e463={};_0x45e463[_0x3a5ec8]={'$like':'%'+_0x28755a['query'][_0xe02c('0x45')]+'%'};return _0x45e463;})});}_0x10d067=_[_0xe02c('0x47')]({},_0x10d067,_0x28755a['options']);return _0xd0d895[_0xe02c('0x79')](_0x10d067);}})['then'](function(_0x52fcd6){if(_0x52fcd6){_0x567478=_0x52fcd6['length'];if(!_0x28755a[_0xe02c('0x3c')][_0xe02c('0x41')](_0xe02c('0x42'))){_0x10d067[_0xe02c('0x24')]=qs[_0xe02c('0x24')](_0x28755a[_0xe02c('0x3c')][_0xe02c('0x24')]);_0x10d067[_0xe02c('0x26')]=qs[_0xe02c('0x26')](_0x28755a[_0xe02c('0x3c')][_0xe02c('0x26')]);}return _0xd0d895[_0xe02c('0x79')](_0x10d067);}})[_0xe02c('0x2d')](function(_0xfe0b1c){if(_0xfe0b1c){return _0xfe0b1c?{'count':_0x567478,'rows':_0xfe0b1c}:null;}})[_0xe02c('0x2d')](respondWithResult(_0x3c44d3,null))[_0xe02c('0x51')](handleError(_0x3c44d3,null));};exports['getTeams']=function(_0x283de9,_0x4cfbc0,_0x3650cb){var _0xdc8df0={};var _0x4564f1={};var _0x2c6d29;var _0x5b75ed;return db[_0xe02c('0x37')][_0xe02c('0x7c')]({'where':{'id':_0x283de9[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](handleEntityNotFound(_0x4cfbc0,null))[_0xe02c('0x2d')](function(_0xced62f){if(_0xced62f){_0x2c6d29=_0xced62f;_0x4564f1[_0xe02c('0x3a')]=_['keys'](db[_0xe02c('0x7d')][_0xe02c('0x38')]);_0x4564f1['query']=_[_0xe02c('0x3b')](_0x283de9['query']);_0x4564f1['filters']=_[_0xe02c('0x3e')](_0x4564f1[_0xe02c('0x3a')],_0x4564f1[_0xe02c('0x3c')]);_0xdc8df0[_0xe02c('0x3f')]=_['intersection'](_0x4564f1['model'],qs[_0xe02c('0x40')](_0x283de9[_0xe02c('0x3c')]['fields']));_0xdc8df0[_0xe02c('0x3f')]=_0xdc8df0[_0xe02c('0x3f')][_0xe02c('0x4f')]?_0xdc8df0[_0xe02c('0x3f')]:_0x4564f1[_0xe02c('0x3a')];_0xdc8df0[_0xe02c('0x43')]=qs['sort'](_0x283de9[_0xe02c('0x3c')][_0xe02c('0x44')]);_0xdc8df0[_0xe02c('0x46')]=qs[_0xe02c('0x3d')](_[_0xe02c('0x7b')](_0x283de9[_0xe02c('0x3c')],_0x4564f1[_0xe02c('0x3d')]));if(_0x283de9[_0xe02c('0x3c')][_0xe02c('0x45')]){_0xdc8df0[_0xe02c('0x46')]=_[_0xe02c('0x47')](_0xdc8df0[_0xe02c('0x46')],{'$or':_[_0xe02c('0x36')](_0xdc8df0[_0xe02c('0x3f')],function(_0x5c4ed7){var _0x1abb2d={};_0x1abb2d[_0x5c4ed7]={'$like':'%'+_0x283de9[_0xe02c('0x3c')][_0xe02c('0x45')]+'%'};return _0x1abb2d;})});}_0xdc8df0=_['merge']({},_0xdc8df0,_0x283de9[_0xe02c('0x48')]);return _0x2c6d29[_0xe02c('0x7e')](_0xdc8df0);}})[_0xe02c('0x2d')](function(_0x2127e7){if(_0x2127e7){_0x5b75ed=_0x2127e7[_0xe02c('0x4f')];if(!_0x283de9[_0xe02c('0x3c')][_0xe02c('0x41')]('nolimit')){_0xdc8df0[_0xe02c('0x24')]=qs[_0xe02c('0x24')](_0x283de9[_0xe02c('0x3c')][_0xe02c('0x24')]);_0xdc8df0[_0xe02c('0x26')]=qs[_0xe02c('0x26')](_0x283de9[_0xe02c('0x3c')][_0xe02c('0x26')]);}return _0x2c6d29[_0xe02c('0x7e')](_0xdc8df0);}})['then'](function(_0x4297b2){if(_0x4297b2){return _0x4297b2?{'count':_0x5b75ed,'rows':_0x4297b2}:null;}})[_0xe02c('0x2d')](respondWithResult(_0x4cfbc0,null))['catch'](handleError(_0x4cfbc0,null));};exports[_0xe02c('0x7f')]=function(_0x4081f5,_0x1d23ed,_0x46fd38){var _0x7cd9df=_0x4081f5[_0xe02c('0x53')]['ids'];var _0xc21958;return db[_0xe02c('0x7d')][_0xe02c('0x4b')]({'where':{'id':_0x7cd9df},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xe02c('0x33'),_0xe02c('0x80'),_0xe02c('0x81'),'interface'],'raw':!![]}]})[_0xe02c('0x2d')](function(_0x35b30c){if(_0x35b30c){_0xc21958=_0x35b30c;var _0x469eac=_[_0xe02c('0x82')](_0x35b30c,function(_0x7441e6){var _0x56e35d=_0x7441e6[_0xe02c('0x2e')]({'plain':!![]});return _0x56e35d[_0xe02c('0x83')];});return db[_0xe02c('0x37')][_0xe02c('0x50')]({'where':{'id':_0x4081f5[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](function(_0x327507){return db[_0xe02c('0x52')][_0xe02c('0x6f')](function(_0x2ee007){return _0x327507[_0xe02c('0x7f')](_0x7cd9df,{'transaction':_0x2ee007})[_0xe02c('0x2d')](function(){return BPromise[_0xe02c('0x84')](_0xc21958,function(_0x1de725){return db[_0xe02c('0x85')][_0xe02c('0x86')]({'TeamId':_0x1de725['id'],'VoicePrefixId':_0x4081f5[_0xe02c('0x4e')]['id']},{'transaction':_0x2ee007});});})['then'](function(){return BPromise['each'](_0x469eac,function(_0x4400b2){return db['UserVoicePrefix']['findOrCreate']({'where':{'UserId':_0x4400b2['id'],'VoicePrefixId':_0x4081f5['params']['id']},'transaction':_0x2ee007});});})[_0xe02c('0x2d')](function(){_0x469eac[_0xe02c('0x87')](function(_0x889cef){socket['emit'](_0xe02c('0x76'),{'UserId':_0x889cef['id'],'VoicePrefixId':_0x327507['id']});});});});});}})['then'](respondWithStatusCode(_0x1d23ed,null))['catch'](handleError(_0x1d23ed,null));};exports[_0xe02c('0x88')]=function(_0x3ca665,_0x4eb163,_0x1433bd){return db['Team']['findAll']({'where':{'id':_0x3ca665[_0xe02c('0x3c')][_0xe02c('0x72')]},'attributes':['id'],'include':[{'model':db[_0xe02c('0x7a')],'as':_0xe02c('0x83'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4eb163,null))[_0xe02c('0x2d')](function(_0x25933f){var _0x323d81=_[_0xe02c('0x36')](_0x25933f,'id');var _0x3b6e15=[];var _0x1c96cc=[];var _0x322b4a=squel[_0xe02c('0x89')]();_0x322b4a[_0xe02c('0x8a')](_0xe02c('0x8b'))[_0xe02c('0x8c')](_0xe02c('0x8d'),'tq')[_0xe02c('0x8e')](_0xe02c('0x8f'),'ut',_0xe02c('0x90'))[_0xe02c('0x46')](_0xe02c('0x91'),_0x3ca665['params']['id']);for(var _0x252f5f=0x0;_0x252f5f<_0x25933f[_0xe02c('0x4f')];_0x252f5f+=0x1){let _0x4d112d=_0x25933f[_0x252f5f];for(var _0x3e0961=0x0;_0x3e0961<_0x4d112d[_0xe02c('0x83')][_0xe02c('0x4f')];_0x3e0961+=0x1){let _0x4b7886=_0x4d112d[_0xe02c('0x83')][_0x3e0961];var _0x505074=_0x322b4a[_0xe02c('0x92')]();_0x505074['where'](_0xe02c('0x93'),_0x4b7886['id']);_0x1c96cc[_0xe02c('0x68')](db[_0xe02c('0x52')][_0xe02c('0x3c')](_0x505074[_0xe02c('0x94')](),{'type':db['sequelize'][_0xe02c('0x95')]['SELECT']})[_0xe02c('0x2d')](function(_0x47d3fa){if(_0x47d3fa[_0xe02c('0x4f')]===0x1){return _0x4b7886['id'];}else{var _0x534002=_[_0xe02c('0x96')](_[_0xe02c('0x36')](_0x47d3fa,_0xe02c('0x97')),function(_0x45c425){return _[_0xe02c('0x98')](_0x323d81,_0x45c425);});if(_0x534002){return _0x4b7886['id'];}}}));}}return BPromise['all'](_0x1c96cc)['then'](function(_0x27ea6e){_0x3b6e15=_(_0x3b6e15)[_0xe02c('0x99')](_0x27ea6e)[_0xe02c('0x9a')]()[_0xe02c('0x9b')]();return db[_0xe02c('0x37')]['find']({'where':{'id':_0x3ca665[_0xe02c('0x4e')]['id']}})[_0xe02c('0x2d')](function(_0x34b426){return db['sequelize'][_0xe02c('0x6f')](function(_0x2a8e1d){return _0x34b426[_0xe02c('0x88')](_0x3ca665[_0xe02c('0x3c')][_0xe02c('0x72')],{'transaction':_0x2a8e1d})[_0xe02c('0x2d')](function(){if(!_['isEmpty'](_0x3b6e15)){return _0x34b426['removeAgents'](_0x3b6e15,{'transaction':_0x2a8e1d});}})[_0xe02c('0x2d')](function(){_0x3b6e15[_0xe02c('0x87')](function(_0x4b9fb7){socket['emit']('userVoicePrefix:remove',{'UserId':_0x4b9fb7,'VoicePrefixId':_0x34b426['id']});});});});});});})['then'](respondWithStatusCode(_0x4eb163,null))[_0xe02c('0x51')](handleError(_0x4eb163,null));}; \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.events.js b/server/api/voicePrefix/voicePrefix.events.js new file mode 100644 index 0000000..83abc3e --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8007=['save','remove','emit','hasOwnProperty','hook','exports','events','../../mysqldb','VoicePrefix','setMaxListeners'];(function(_0x3fd695,_0x2c0419){var _0x1b9f21=function(_0x476f99){while(--_0x476f99){_0x3fd695['push'](_0x3fd695['shift']());}};_0x1b9f21(++_0x2c0419);}(_0x8007,0x1aa));var _0x7800=function(_0x4ab5da,_0x514fb7){_0x4ab5da=_0x4ab5da-0x0;var _0x21c927=_0x8007[_0x4ab5da];return _0x21c927;};'use strict';var EventEmitter=require(_0x7800('0x0'));var VoicePrefix=require(_0x7800('0x1'))['db'][_0x7800('0x2')];var VoicePrefixEvents=new EventEmitter();VoicePrefixEvents[_0x7800('0x3')](0x0);var events={'afterCreate':_0x7800('0x4'),'afterUpdate':'update','afterDestroy':_0x7800('0x5')};function emitEvent(_0x47d5d1){return function(_0xe4b12,_0xecf907,_0x51c22e){VoicePrefixEvents[_0x7800('0x6')](_0x47d5d1+':'+_0xe4b12['id'],_0xe4b12);VoicePrefixEvents[_0x7800('0x6')](_0x47d5d1,_0xe4b12);_0x51c22e(null);};}for(var e in events){if(events[_0x7800('0x7')](e)){var event=events[e];VoicePrefix[_0x7800('0x8')](e,emitEvent(event));}}module[_0x7800('0x9')]=VoicePrefixEvents; \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.model.js b/server/api/voicePrefix/voicePrefix.model.js new file mode 100644 index 0000000..ff8d346 --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcf2f=['bluebird','request-promise','path','rimraf','./voicePrefix.attributes','exports','define','VoicePrefix','voice_prefixes','lodash','util','../../config/logger','api','moment'];(function(_0x1f23b1,_0x57c83f){var _0x3c9197=function(_0x2f6e4a){while(--_0x2f6e4a){_0x1f23b1['push'](_0x1f23b1['shift']());}};_0x3c9197(++_0x57c83f);}(_0xcf2f,0xbf));var _0xfcf2=function(_0x10df71,_0x4dbaf4){_0x10df71=_0x10df71-0x0;var _0x1fd8c3=_0xcf2f[_0x10df71];return _0x1fd8c3;};'use strict';var _=require(_0xfcf2('0x0'));var util=require(_0xfcf2('0x1'));var logger=require(_0xfcf2('0x2'))(_0xfcf2('0x3'));var moment=require(_0xfcf2('0x4'));var BPromise=require(_0xfcf2('0x5'));var rp=require(_0xfcf2('0x6'));var fs=require('fs');var path=require(_0xfcf2('0x7'));var rimraf=require(_0xfcf2('0x8'));var config=require('../../config/environment');var attributes=require(_0xfcf2('0x9'));module[_0xfcf2('0xa')]=function(_0x293344,_0x55b46a){return _0x293344[_0xfcf2('0xb')](_0xfcf2('0xc'),attributes,{'tableName':_0xfcf2('0xd'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.rpc.js b/server/api/voicePrefix/voicePrefix.rpc.js new file mode 100644 index 0000000..0369950 --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9134=['error','code','message','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','socket.io-emitter','request','then','VoicePrefix,\x20%s,\x20%s','debug','request\x20sent','stringify'];(function(_0xca4cee,_0x44a631){var _0x5d2fdd=function(_0x3d4215){while(--_0x3d4215){_0xca4cee['push'](_0xca4cee['shift']());}};_0x5d2fdd(++_0x44a631);}(_0x9134,0x87));var _0x4913=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x9134[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var util=require(_0x4913('0x0'));var moment=require(_0x4913('0x1'));var BPromise=require(_0x4913('0x2'));var rs=require(_0x4913('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x4913('0x4'));var logger=require(_0x4913('0x5'))(_0x4913('0x6'));var config=require(_0x4913('0x7'));var jayson=require(_0x4913('0x8'));var client=jayson[_0x4913('0x9')]['http']({'port':0x232a});config[_0x4913('0xa')]=_[_0x4913('0xb')](config[_0x4913('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x4913('0xc'))(new Redis(config[_0x4913('0xa')]));require('./voicePrefix.socket')['register'](socket);function respondWithRpcPromise(_0x4d9eb2,_0xae5842,_0x57260f){return new BPromise(function(_0x28f919,_0x1c08ac){return client[_0x4913('0xd')](_0x4d9eb2,_0x57260f)[_0x4913('0xe')](function(_0x3c3272){logger['info'](_0x4913('0xf'),_0xae5842,'request\x20sent');logger[_0x4913('0x10')]('VoicePrefix,\x20%s,\x20%s,\x20%s',_0xae5842,_0x4913('0x11'),JSON[_0x4913('0x12')](_0x3c3272));if(_0x3c3272[_0x4913('0x13')]){if(_0x3c3272['error'][_0x4913('0x14')]===0x1f4){logger[_0x4913('0x13')]('VoicePrefix,\x20%s,\x20%s',_0xae5842,_0x3c3272['error'][_0x4913('0x15')]);return _0x1c08ac(_0x3c3272[_0x4913('0x13')][_0x4913('0x15')]);}logger[_0x4913('0x13')]('VoicePrefix,\x20%s,\x20%s',_0xae5842,_0x3c3272[_0x4913('0x13')][_0x4913('0x15')]);return _0x28f919(_0x3c3272['error'][_0x4913('0x15')]);}else{logger['info'](_0x4913('0xf'),_0xae5842,_0x4913('0x11'));_0x28f919(_0x3c3272['result'][_0x4913('0x15')]);}})['catch'](function(_0x50584a){logger[_0x4913('0x13')](_0x4913('0xf'),_0xae5842,_0x50584a);_0x1c08ac(_0x50584a);});});} \ No newline at end of file diff --git a/server/api/voicePrefix/voicePrefix.socket.js b/server/api/voicePrefix/voicePrefix.socket.js new file mode 100644 index 0000000..f5cfff2 --- /dev/null +++ b/server/api/voicePrefix/voicePrefix.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0db9=['emit','removeListener','length','./voicePrefix.events'];(function(_0x513c68,_0x3d15e2){var _0x361e7d=function(_0x131ed6){while(--_0x131ed6){_0x513c68['push'](_0x513c68['shift']());}};_0x361e7d(++_0x3d15e2);}(_0x0db9,0xa3));var _0x90db=function(_0x59145a,_0x1f60f1){_0x59145a=_0x59145a-0x0;var _0xf04d7=_0x0db9[_0x59145a];return _0xf04d7;};'use strict';var VoicePrefixEvents=require(_0x90db('0x0'));var events=['save','remove','update'];function createListener(_0x2c73bc,_0x405229){return function(_0x553431){_0x405229[_0x90db('0x1')](_0x2c73bc,_0x553431);};}function removeListener(_0x500dcf,_0x1e0f41){return function(){VoicePrefixEvents[_0x90db('0x2')](_0x500dcf,_0x1e0f41);};}exports['register']=function(_0x2d02a1){for(var _0x242774=0x0,_0x476491=events[_0x90db('0x3')];_0x242774<_0x476491;_0x242774++){var _0x915ca=events[_0x242774];var _0x9b6d0d=createListener('voicePrefix:'+_0x915ca,_0x2d02a1);VoicePrefixEvents['on'](_0x915ca,_0x9b6d0d);}}; \ No newline at end of file diff --git a/server/api/voiceQueue/index.js b/server/api/voiceQueue/index.js new file mode 100644 index 0000000..40b0d41 --- /dev/null +++ b/server/api/voiceQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb10b=['express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./voiceQueue.controller','get','index','isAuthenticated','show','/:id/hoppers','getHoppers','/:id/hopper_histories','/:id/hopper_finals','getHopperBlacks','/:id/teams','getTeams','/:id/users','getAgents','/:id/members','getMembers','/:id/lists','/:id/blacklists','getBlackLists','post','create','/:id/clone','addTeams','addAgents','addLists','addBlackLists','put','/:id','update','delete','removeTeams','removeAgents','removeLists','removeBlackLists','exports','multer','path','connect-timeout'];(function(_0x24cc72,_0x4dc73a){var _0xd49f1e=function(_0x39f581){while(--_0x39f581){_0x24cc72['push'](_0x24cc72['shift']());}};_0xd49f1e(++_0x4dc73a);}(_0xb10b,0x12a));var _0xbb10=function(_0x953a55,_0x736d43){_0x953a55=_0x953a55-0x0;var _0x43fa9a=_0xb10b[_0x953a55];return _0x43fa9a;};'use strict';var multer=require(_0xbb10('0x0'));var util=require('util');var path=require(_0xbb10('0x1'));var timeout=require(_0xbb10('0x2'));var express=require(_0xbb10('0x3'));var router=express['Router']();var fs_extra=require(_0xbb10('0x4'));var auth=require(_0xbb10('0x5'));var interaction=require(_0xbb10('0x6'));var config=require(_0xbb10('0x7'));var controller=require(_0xbb10('0x8'));router[_0xbb10('0x9')]('/',auth['isAuthenticated'](),controller[_0xbb10('0xa')]);router[_0xbb10('0x9')]('/:id',auth[_0xbb10('0xb')](),controller[_0xbb10('0xc')]);router[_0xbb10('0x9')](_0xbb10('0xd'),auth[_0xbb10('0xb')](),controller[_0xbb10('0xe')]);router[_0xbb10('0x9')](_0xbb10('0xf'),auth['isAuthenticated'](),controller['getHopperHistories']);router[_0xbb10('0x9')](_0xbb10('0x10'),auth[_0xbb10('0xb')](),controller['getHopperFinals']);router[_0xbb10('0x9')]('/:id/hopper_black',auth[_0xbb10('0xb')](),controller[_0xbb10('0x11')]);router[_0xbb10('0x9')](_0xbb10('0x12'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x13')]);router['get'](_0xbb10('0x14'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x15')]);router[_0xbb10('0x9')](_0xbb10('0x16'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x17')]);router[_0xbb10('0x9')](_0xbb10('0x18'),auth[_0xbb10('0xb')](),controller['getLists']);router[_0xbb10('0x9')](_0xbb10('0x19'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x1a')]);router[_0xbb10('0x1b')]('/',auth[_0xbb10('0xb')](),controller[_0xbb10('0x1c')]);router[_0xbb10('0x1b')](_0xbb10('0x1d'),auth[_0xbb10('0xb')](),controller['clone']);router[_0xbb10('0x1b')](_0xbb10('0x12'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x1e')]);router[_0xbb10('0x1b')](_0xbb10('0x14'),auth['isAuthenticated'](),controller[_0xbb10('0x1f')]);router[_0xbb10('0x1b')]('/:id/lists',auth['isAuthenticated'](),controller[_0xbb10('0x20')]);router[_0xbb10('0x1b')](_0xbb10('0x19'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x21')]);router[_0xbb10('0x22')](_0xbb10('0x23'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x24')]);router[_0xbb10('0x25')](_0xbb10('0x23'),auth[_0xbb10('0xb')](),controller['destroy']);router['delete']('/:id/teams',auth[_0xbb10('0xb')](),controller[_0xbb10('0x26')]);router[_0xbb10('0x25')]('/:id/users',auth[_0xbb10('0xb')](),controller[_0xbb10('0x27')]);router[_0xbb10('0x25')](_0xbb10('0x18'),auth[_0xbb10('0xb')](),controller[_0xbb10('0x28')]);router[_0xbb10('0x25')]('/:id/blacklists',auth[_0xbb10('0xb')](),controller[_0xbb10('0x29')]);module[_0xbb10('0x2a')]=router; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.attributes.js b/server/api/voiceQueue/voiceQueue.attributes.js new file mode 100644 index 0000000..e2d3e05 --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbb7b=['onlyIfOpen','always','Active/Disactive\x20AMD','#AMD\x20Initial\x20Silence','#AMD\x20After\x20Greeting\x20Silence','#AMD\x20Total\x20Analysis\x20Time','#AMD\x20Min\x20Word\x20Length','#AMD\x20Maximum\x20Number\x20Of\x20Words','#AMD\x20Silence\x20Threshold\x20(min:0,\x20max:32767)','#RecallMe\x20Timeout\x20(min:1)','Active/Disactive\x20Recall\x20In\x20Queue','ASC','DESC','Random\x20Last\x20Digit\x20(min:1,\x20max:15)','#Drop\x20Retry\x20(min:1,\x20max:999)','Drop\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','Abandoned\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#Machine\x20Retry\x20(min:1,\x20max:999)','Machine\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#AgentReject\x20Retry\x20(min:1,\x20max:999)','AgentReject\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled','mandatoryDispositionPauseId','mandatoryDisposition','sequelize','exports','STRING','ENUM','inbound','default','ringall','leastrecent','rrmemory','linear','wrandom','rrordered','setDataValue','strategy','type','dialMethod','getDataValue','preview','booked','roundrobin','includes','INTEGER','yes','all','once','TEXT','join','periodic_announce','joinempty','split','leavewhenempty','BOOLEAN','acw','wrapuptime','power','predictive','progressive','Max\x209999\x20channels,\x200\x20means\x20unlimited.','UNSIGNED','Max\x209999\x20member\x20in\x20queue(min:1,\x20max:9999),\x200\x20means\x20unlimited.','FLOAT','agentBusyFactor','dropRate','Only\x20for\x20predictive\x20method.','Interval\x20Predictive\x20Minutes\x20(min:5\x20max:30)','Originate\x20Timeout\x20Seconds\x20(min:1,\x20max:999)','tTxX','Queue\x20Timeout\x20Seconds\x20(min:1,\x20max:999)','AGI\x20queue\x20option\x20(use:\x20agi://127.0.0.1/square,)','#Congestion\x20Retry\x20(min:1,\x20max:999)','Congestion\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#Busy\x20Retry\x20(min:1,\x20max:999)','#NoAnswer\x20Retry\x20(min:1,\x20max:999)','NoAnswer\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)','#Global\x20Max\x20Retry\x20(min:1,\x20max:999)','never'];(function(_0xff2f6d,_0x3fde1c){var _0x5e7681=function(_0x53f971){while(--_0x53f971){_0xff2f6d['push'](_0xff2f6d['shift']());}};_0x5e7681(++_0x3fde1c);}(_0xbb7b,0x158));var _0xbbb7=function(_0x276580,_0x18b849){_0x276580=_0x276580-0x0;var _0x47c12f=_0xbb7b[_0x276580];return _0x47c12f;};'use strict';var Sequelize=require(_0xbbb7('0x0'));module[_0xbbb7('0x1')]={'name':{'type':Sequelize[_0xbbb7('0x2')],'allowNull':![],'unique':'name','validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'type':{'type':Sequelize[_0xbbb7('0x3')]('inbound','outbound'),'allowNull':![],'defaultValue':_0xbbb7('0x4')},'musiconhold':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':_0xbbb7('0x5')},'announce':{'type':Sequelize['STRING'],'defaultValue':''},'strategy':{'type':Sequelize[_0xbbb7('0x3')]('rr',_0xbbb7('0x6'),_0xbbb7('0x7'),'fewestcalls','random',_0xbbb7('0x8'),_0xbbb7('0x9'),_0xbbb7('0xa'),_0xbbb7('0xb')),'allowNull':![],'defaultValue':_0xbbb7('0x6'),'set':function(_0x8a69c0){this[_0xbbb7('0xc')](_0xbbb7('0xd'),_0x8a69c0?_0x8a69c0:_0xbbb7('0x8'));},'get':function(){var _0x48b911=this['getDataValue'](_0xbbb7('0xe'));var _0x44aa2d=this['getDataValue'](_0xbbb7('0xf'));var _0x53ca5e=this[_0xbbb7('0x10')](_0xbbb7('0xd'));if(_0x48b911==='outbound'){if(_0x44aa2d===_0xbbb7('0x11')){return null;}if(_0x44aa2d===_0xbbb7('0x12')&&!['rrmemory',_0xbbb7('0x13')][_0xbbb7('0x14')](_0x53ca5e)){this[_0xbbb7('0xc')](_0xbbb7('0xd'),_0xbbb7('0x8'));}}return _0x53ca5e;}},'servicelevel':{'type':Sequelize['INTEGER'](0xb),'defaultValue':0x0},'context':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'penaltymemberslimit':{'type':Sequelize[_0xbbb7('0x15')](0xb)},'timeout':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0xf},'retry':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x2},'timeoutpriority':{'type':Sequelize[_0xbbb7('0x2')]},'weight':{'type':Sequelize[_0xbbb7('0x15')](0xb),'allowNull':!![],'defaultValue':0x0},'wrapuptime':{'type':Sequelize['INTEGER'](0xb),'defaultValue':0x0},'autofill':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':_0xbbb7('0x16')},'autopause':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no',_0xbbb7('0x17')),'defaultValue':'no'},'autopausedelay':{'type':Sequelize[_0xbbb7('0x15')](0xb)},'autopausebusy':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'autopauseunavail':{'type':Sequelize['ENUM'](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'maxlen':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x0},'setinterfacevar':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'setqueueentryvar':{'type':Sequelize['ENUM'](_0xbbb7('0x16'),'no'),'defautValue':'no'},'setqueuevar':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'eventmemberstatus':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'membermacro':{'type':Sequelize[_0xbbb7('0x2')],'allowNull':!![]},'membergosub':{'type':Sequelize[_0xbbb7('0x2')],'allowNull':!![]},'announce_frequency':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x0},'min_announce_frequency':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x0},'periodic_announce_frequency':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x0},'random_periodic_announce':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'relative_periodic_announce':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'yes'},'announce_holdtime':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no',_0xbbb7('0x18')),'defaultValue':'no'},'announce_position':{'type':Sequelize['STRING'],'defaultValue':'no'},'announce_to_first_user':{'type':Sequelize['ENUM']('yes','no')},'announce_position_limit':{'type':Sequelize[_0xbbb7('0x15')](0xb)},'announce_round_seconds':{'type':Sequelize[_0xbbb7('0x3')]('0','5','10','15','20','30'),'defaultValue':'0'},'monitor_format':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':''},'monitor_type':{'type':Sequelize['STRING']},'queue_youarenext':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'queue_thereare':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'queue_callswaiting':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'queue_holdtime':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'queue_minute':{'type':Sequelize[_0xbbb7('0x2')],'allowNull':!![],'defaultValue':null},'queue_minutes':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'queue_seconds':{'type':Sequelize['STRING'],'defaultValue':null},'queue_thankyou':{'type':Sequelize['STRING'],'defaultValue':null},'queue_reporthold':{'type':Sequelize[_0xbbb7('0x2')]},'queue_quantity1':{'type':Sequelize[_0xbbb7('0x2')]},'queue_quantity2':{'type':Sequelize[_0xbbb7('0x2')]},'queue_periodic_announce':{'type':Sequelize[_0xbbb7('0x2')]},'queue_less_than':{'type':Sequelize[_0xbbb7('0x2')]},'periodic_announce':{'type':Sequelize[_0xbbb7('0x19')],'set':function(_0xc2b350){this[_0xbbb7('0xc')]('periodic_announce',_0xc2b350?_0xc2b350[_0xbbb7('0x1a')](','):[]);},'get':function(){return this[_0xbbb7('0x10')](_0xbbb7('0x1b'))?this[_0xbbb7('0x10')](_0xbbb7('0x1b'))['split'](','):[];}},'joinempty':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':_0xbbb7('0x16'),'set':function(_0x2d082c){this['setDataValue']('joinempty',_0x2d082c?_0x2d082c[_0xbbb7('0x1a')](','):undefined);},'get':function(){return this['getDataValue'](_0xbbb7('0x1c'))?this['getDataValue'](_0xbbb7('0x1c'))[_0xbbb7('0x1d')](','):undefined;}},'leavewhenempty':{'type':Sequelize['STRING'],'defaultValue':'no','set':function(_0x89c48e){this[_0xbbb7('0xc')](_0xbbb7('0x1e'),_0x89c48e?_0x89c48e[_0xbbb7('0x1a')](','):undefined);},'get':function(){return this[_0xbbb7('0x10')](_0xbbb7('0x1e'))?this[_0xbbb7('0x10')]('leavewhenempty')[_0xbbb7('0x1d')](','):undefined;}},'reportholdtime':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'ringinuse':{'type':Sequelize['ENUM'](_0xbbb7('0x16'),'no'),'defaultValue':'no'},'memberdelay':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0x0},'timeoutrestart':{'type':Sequelize['ENUM']('yes','no'),'defaultValue':'no'},'defaultrule':{'type':Sequelize[_0xbbb7('0x2')]},'description':{'type':Sequelize[_0xbbb7('0x2')]},'acw':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':0x0,'set':function(_0x3ecf35){this['setDataValue'](_0xbbb7('0x20'),_0x3ecf35);if(_0x3ecf35){if(this[_0xbbb7('0x10')](_0xbbb7('0x21'))<0x2){this[_0xbbb7('0xc')](_0xbbb7('0x21'),0x2);}}}},'acwTimeout':{'type':Sequelize[_0xbbb7('0x15')](0xb),'defaultValue':0xa},'dialActive':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':0x0,'comment':'Active/Disactive\x20Campaign'},'dialMethod':{'type':Sequelize[_0xbbb7('0x3')]('preview','progressive',_0xbbb7('0x22'),_0xbbb7('0x23'),_0xbbb7('0x12')),'defaultValue':_0xbbb7('0x24'),'comment':'Dial\x20Method.'},'dialLimitChannel':{'type':Sequelize[_0xbbb7('0x15')](0x4)['UNSIGNED'],'defaultValue':0x0,'validate':{'min':0x0,'max':0x270f},'comment':_0xbbb7('0x25')},'dialLimitQueue':{'type':Sequelize['INTEGER'](0x4)[_0xbbb7('0x26')],'defaultValue':0x0,'validate':{'min':0x0,'max':0x270f},'comment':_0xbbb7('0x27')},'dialPowerLevel':{'type':Sequelize[_0xbbb7('0x28')](0x2)[_0xbbb7('0x26')],'defaultValue':0x1,'validate':{'min':0x1,'max':0xa},'comment':'Power\x20Level:\x20Calls\x20for\x20agents\x20(min:1,\x20max:10).'},'dialPredictiveOptimization':{'type':Sequelize[_0xbbb7('0x3')](_0xbbb7('0x29'),_0xbbb7('0x2a')),'defaultValue':_0xbbb7('0x2a'),'comment':_0xbbb7('0x2b')},'dialPredictiveOptimizationPercentage':{'type':Sequelize[_0xbbb7('0x28')](0x2)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x5f},'comment':'Predictive\x20Optimization\x20Percentage\x20(min:\x201,\x20max:\x2095)'},'dialPredictiveInterval':{'type':Sequelize['INTEGER'](0x3)[_0xbbb7('0x26')],'defaultValue':0xa,'validate':{'min':0x5,'max':0x1e},'comment':_0xbbb7('0x2c')},'dialOriginateCallerIdName':{'type':Sequelize['STRING']},'dialOriginateCallerIdNumber':{'type':Sequelize[_0xbbb7('0x2')]},'dialOriginateTimeout':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x1e,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x2d')},'dialQueueOptions':{'type':Sequelize['STRING'],'defaultValue':_0xbbb7('0x2e'),'comment':'https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Queue'},'dialQueueTimeout':{'type':Sequelize['INTEGER'](0x3)['UNSIGNED'],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x2f')},'dialQueueProject':{'type':Sequelize[_0xbbb7('0x2')],'comment':_0xbbb7('0x30')},'dialCongestionMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x31')},'dialCongestionRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)['UNSIGNED'],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x32')},'dialBusyMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)['UNSIGNED'],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x33')},'dialBusyRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':'Busy\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)'},'dialNoAnswerMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'comment':_0xbbb7('0x34')},'dialNoAnswerRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)['UNSIGNED'],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x35')},'dialGlobalMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x3e7},'defaultValue':0x4,'comment':_0xbbb7('0x36')},'dialTimezone':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'dialGlobalInterval':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':'07:00-22:00,*,*,*'},'dialPrefix':{'type':Sequelize[_0xbbb7('0x2')],'defaultValue':null},'dialCheckDuplicateType':{'type':Sequelize[_0xbbb7('0x3')]('always',_0xbbb7('0x37'),_0xbbb7('0x38')),'defaultValue':_0xbbb7('0x39')},'dialAMDActive':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':0x0,'comment':_0xbbb7('0x3a')},'dialAMDInitialSilence':{'type':Sequelize['INTEGER'](0x9)[_0xbbb7('0x26')],'defaultValue':0x9c4,'validate':{'min':0x0},'comment':_0xbbb7('0x3b')},'dialAMDGreeting':{'type':Sequelize[_0xbbb7('0x15')](0x9)[_0xbbb7('0x26')],'defaultValue':0x5dc,'validate':{'min':0x0},'comment':'#AMD\x20Greeting'},'dialAMDAfterGreetingSilence':{'type':Sequelize['INTEGER'](0x9)[_0xbbb7('0x26')],'defaultValue':0x320,'validate':{'min':0x0},'comment':_0xbbb7('0x3c')},'dialAMDTotalAnalysisTime':{'type':Sequelize[_0xbbb7('0x15')](0x9)[_0xbbb7('0x26')],'defaultValue':0x1388,'validate':{'min':0x0},'comment':_0xbbb7('0x3d')},'dialAMDMinWordLength':{'type':Sequelize[_0xbbb7('0x15')](0x9)[_0xbbb7('0x26')],'defaultValue':0x64,'validate':{'min':0x0},'comment':_0xbbb7('0x3e')},'dialAMDBetweenWordsSilence':{'type':Sequelize[_0xbbb7('0x15')](0x9)[_0xbbb7('0x26')],'defaultValue':0x32,'validate':{'min':0x0},'comment':'#AMD\x20Between\x20Words\x20Silence'},'dialAMDMaximumNumberOfWords':{'type':Sequelize[_0xbbb7('0x15')](0x9)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x0},'comment':_0xbbb7('0x3f')},'dialAMDSilenceThreshold':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x0,'max':0x7fff},'defaultValue':0x100,'comment':_0xbbb7('0x40')},'dialAMDMaximumWordLength':{'type':Sequelize['INTEGER'](0x9)['UNSIGNED'],'defaultValue':0x1388,'validate':{'min':0x0},'comment':'#AMD\x20Maximum\x20Word\x20Length'},'dialRecallMeTimeout':{'type':Sequelize[_0xbbb7('0x15')](0x5)['UNSIGNED'],'validate':{'min':0x1},'defaultValue':0x1e,'comment':_0xbbb7('0x41')},'dialRecallInQueue':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':0x0,'comment':_0xbbb7('0x42')},'dialOrderByScheduledAt':{'type':Sequelize[_0xbbb7('0x3')]('DESC',_0xbbb7('0x43')),'defaultValue':_0xbbb7('0x44')},'dialQueueProject2':{'type':Sequelize[_0xbbb7('0x2')],'comment':_0xbbb7('0x30')},'dialAgiAfterHangupClient':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'dialAgiAfterHangupAgent':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'dialRandomLastDigitCallerIdNumber':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'validate':{'min':0x0,'max':0xf},'defaultValue':0x0,'comment':_0xbbb7('0x45')},'dialCutDigit':{'type':Sequelize['INTEGER'](0x3)[_0xbbb7('0x26')],'validate':{'min':0x0,'max':0xf},'defaultValue':0x0,'comment':'Cut\x20Digit\x20(min:1,\x20max:15)'},'dialNoSuchNumberMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':'#NoSuchNumber\x20Retry\x20(min:1,\x20max:999)'},'dialNoSuchNumberRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':'NoSuchNumber\x20Retry\x20Frequency\x20Minutes\x20(min:1,\x20max:99999)'},'dialDropMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x46')},'dialDropRetryFrequency':{'type':Sequelize['INTEGER'](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x47')},'dialAbandonedMaxRetry':{'type':Sequelize['INTEGER'](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':'#Abandoned\x20Retry\x20(min:1,\x20max:999)'},'dialAbandonedRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x48')},'dialMachineMaxRetry':{'type':Sequelize['INTEGER'](0x3)[_0xbbb7('0x26')],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x49')},'dialMachineRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x4a')},'dialAgentRejectMaxRetry':{'type':Sequelize[_0xbbb7('0x15')](0x3)['UNSIGNED'],'defaultValue':0x3,'validate':{'min':0x1,'max':0x3e7},'comment':_0xbbb7('0x4b')},'dialAgentRejectRetryFrequency':{'type':Sequelize[_0xbbb7('0x15')](0x5)[_0xbbb7('0x26')],'validate':{'min':0x1,'max':0x1869f},'defaultValue':0x96,'comment':_0xbbb7('0x4c')},'mandatoryDispositionPauseId':{'type':Sequelize['INTEGER'],'allowNull':!![],'comment':_0xbbb7('0x4d')},'mandatoryDisposition':{'type':Sequelize['BOOLEAN'],'defaultValue':![],'comment':'Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','set':function(_0x2469f0){if(!_0x2469f0)this['setDataValue'](_0xbbb7('0x4e'),null);this[_0xbbb7('0xc')](_0xbbb7('0x4f'),_0x2469f0);}},'dialPredictiveIntervalMaxThreshold':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x14,'validate':{'min':0x1,'max':0x64}},'dialPredictiveIntervalMinThreshold':{'type':Sequelize[_0xbbb7('0x15')](0x3)['UNSIGNED'],'defaultValue':0xa,'validate':{'min':0x1,'max':0x64}},'dialPreviewAutoRecallMe':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':!![]},'callAdditionalPhoneAfterMin':{'type':Sequelize[_0xbbb7('0x15')](0x3)[_0xbbb7('0x26')],'defaultValue':0x4},'dialPreviewRecallmeReminder':{'type':Sequelize[_0xbbb7('0x1f')],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.controller.js b/server/api/voiceQueue/voiceQueue.controller.js new file mode 100644 index 0000000..3fee0b4 --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6f44=['role','user','inbound','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','outbound','findOne','hasOwnProperty','nolimit','VoiceQueueId','CmHopper','rows','getHopperHistories','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','Team','getTeams','teams','flatMap','Agents','penalty','transaction','TeamVoiceQueue','upsert','each','UserVoiceQueueRt','isNil','format','SIP/%s','voicePause','emit','userVoiceQueue:save','ids','User','select','field','tq.TeamId','from','team_has_voice_queues','user_has_teams','ut.UserId\x20=\x20?','sequelize','union','compact','removeTeams','isEmpty','removeAgents','userVoiceQueue:remove','addAgents','interface','online','push','all','isArray','getAgents','getMembers','getLists','YYYY-MM-DD\x20HH:mm:ss','addLists','dialCheckDuplicateType','always','into','cm_hopper','fromQuery','phone','scheduledAt','ListId','ContactId','CmListId','toString','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','VoiceQueueId\x20=\x20?','COALESCE(phone,\x27\x27)','cm_contacts','ListId\x20=\x20?','deletedAt\x20IS\x20NULL','insert','cm_hopper_additional_phones','CmHopperId','OrderBy','h.id','ci.OrderBy+1','cm_contact_has_items','join','h.ContactId=ci.CmContactId','PHONE','removeLists','getBlackLists','CmList','addBlackLists','spread','cm_hopper_black','NOW()','removeBlackLists','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','desk.js','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./voiceQueue.socket','status','offset','limit','undefined','count','set','Content-Range','json','apply','reject','save','update','then','destroy','get','VoiceQueues','QueueCampaigns','ignore','value','includes','type','name','error','send','index','map','VoiceQueue','key','model','query','filters','attributes','fields','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','catch','show','params','keys','rawAttributes','intersection','length','find','body','Unable\x20to\x20retrieve\x20the\x20current\x20user'];(function(_0x4a47fc,_0x25208f){var _0x30f1ee=function(_0x33ea17){while(--_0x33ea17){_0x4a47fc['push'](_0x4a47fc['shift']());}};_0x30f1ee(++_0x25208f);}(_0x6f44,0x1ea));var _0x46f4=function(_0x90cc54,_0x35c5ad){_0x90cc54=_0x90cc54-0x0;var _0x599dab=_0x6f44[_0x90cc54];return _0x599dab;};'use strict';var emlformat=require(_0x46f4('0x0'));var rimraf=require(_0x46f4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x46f4('0x2'));var rp=require(_0x46f4('0x3'));var moment=require(_0x46f4('0x4'));var BPromise=require(_0x46f4('0x5'));var Mustache=require(_0x46f4('0x6'));var util=require(_0x46f4('0x7'));var path=require(_0x46f4('0x8'));var sox=require(_0x46f4('0x9'));var csv=require(_0x46f4('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x46f4('0xb'));var _=require(_0x46f4('0xc'));var squel=require(_0x46f4('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x46f4('0xe'));var toCsv=require(_0x46f4('0xa'));var querystring=require('querystring');var Papa=require(_0x46f4('0xf'));var Redis=require('ioredis');var authService=require(_0x46f4('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x46f4('0x11'));var hardwareService=require(_0x46f4('0x12'));var logger=require(_0x46f4('0x13'))(_0x46f4('0x14'));var utils=require(_0x46f4('0x15'));var config=require(_0x46f4('0x16'));var licenseUtil=require(_0x46f4('0x17'));var db=require(_0x46f4('0x18'))['db'];config[_0x46f4('0x19')]=_[_0x46f4('0x1a')](config[_0x46f4('0x19')],{'host':_0x46f4('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x46f4('0x19')]));require(_0x46f4('0x1c'))['register'](socket);function respondWithStatusCode(_0x44a55b,_0xbe2e79){_0xbe2e79=_0xbe2e79||0xcc;return function(_0x1a1649){if(_0x1a1649){return _0x44a55b['sendStatus'](_0xbe2e79);}return _0x44a55b[_0x46f4('0x1d')](_0xbe2e79)['end']();};}function respondWithResult(_0x4e84ce,_0x45917e){_0x45917e=_0x45917e||0xc8;return function(_0xf082a9){if(_0xf082a9){return _0x4e84ce[_0x46f4('0x1d')](_0x45917e)['json'](_0xf082a9);}};}function respondWithFilteredResult(_0x5c191a,_0x5e237d){return function(_0x5d3471){if(_0x5d3471){var _0x26287f=typeof _0x5e237d[_0x46f4('0x1e')]==='undefined'&&typeof _0x5e237d[_0x46f4('0x1f')]===_0x46f4('0x20');var _0x2232d6=_0x5d3471[_0x46f4('0x21')];var _0x4b0650=_0x26287f?0x0:_0x5e237d[_0x46f4('0x1e')];var _0x390137=_0x26287f?_0x5d3471[_0x46f4('0x21')]:_0x5e237d[_0x46f4('0x1e')]+_0x5e237d[_0x46f4('0x1f')];var _0xdb9f25;if(_0x390137>=_0x2232d6){_0x390137=_0x2232d6;_0xdb9f25=0xc8;}else{_0xdb9f25=0xce;}_0x5c191a['status'](_0xdb9f25);return _0x5c191a[_0x46f4('0x22')](_0x46f4('0x23'),_0x4b0650+'-'+_0x390137+'/'+_0x2232d6)[_0x46f4('0x24')](_0x5d3471);}return null;};}function patchUpdates(_0x4ba21a){return function(_0x2d6ebc){try{jsonpatch[_0x46f4('0x25')](_0x2d6ebc,_0x4ba21a,!![]);}catch(_0x185ec2){return BPromise[_0x46f4('0x26')](_0x185ec2);}return _0x2d6ebc[_0x46f4('0x27')]();};}function saveUpdates(_0x41be5e,_0x204db6){return function(_0x58d27d){if(_0x58d27d){return _0x58d27d[_0x46f4('0x28')](_0x41be5e)[_0x46f4('0x29')](function(_0x2ad553){return _0x2ad553;});}return null;};}function removeEntity(_0x16cd7f,_0x197e55){return function(_0x59b5e2){if(_0x59b5e2){return _0x59b5e2[_0x46f4('0x2a')]()[_0x46f4('0x29')](function(){var _0xb23194=_0x59b5e2[_0x46f4('0x2b')]({'plain':!![]});var _0x57eb00=[{'name':_0x46f4('0x2c'),'value':'inbound','ignore':![]},{'name':_0x46f4('0x2d'),'value':'outbound','ignore':![]}];var _0x546d2b=_(_0x57eb00)['filter'](_0x46f4('0x2e'))['map'](_0x46f4('0x2f'))[_0x46f4('0x2f')]();if(_[_0x46f4('0x30')](_0x546d2b,_0xb23194[_0x46f4('0x31')])){return;}var _0x375da1=_['find'](_0x57eb00,[_0x46f4('0x2f'),_0xb23194[_0x46f4('0x31')]])[_0x46f4('0x32')];return db['UserProfileResource'][_0x46f4('0x2a')]({'where':{'type':_0x375da1,'resourceId':_0xb23194['id']}})[_0x46f4('0x29')](function(){return _0x59b5e2;});})[_0x46f4('0x29')](function(){_0x16cd7f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x1f781c,_0x1ae611){return function(_0x2afa3b){if(!_0x2afa3b){_0x1f781c['sendStatus'](0x194);}return _0x2afa3b;};}function handleError(_0x2bb1e3,_0x3a61c9){_0x3a61c9=_0x3a61c9||0x1f4;return function(_0x518128){logger[_0x46f4('0x33')](_0x518128['stack']);if(_0x518128[_0x46f4('0x32')]){delete _0x518128[_0x46f4('0x32')];}_0x2bb1e3[_0x46f4('0x1d')](_0x3a61c9)[_0x46f4('0x34')](_0x518128);};}exports[_0x46f4('0x35')]=function(_0x57c030,_0x43867b){var _0x213bcd={},_0x5d35d5={},_0xd1516a={'count':0x0,'rows':[]};var _0x5c952b=_[_0x46f4('0x36')](db[_0x46f4('0x37')]['rawAttributes'],function(_0xda13d4){return{'name':_0xda13d4['fieldName'],'type':_0xda13d4[_0x46f4('0x31')][_0x46f4('0x38')]};});_0x5d35d5[_0x46f4('0x39')]=_[_0x46f4('0x36')](_0x5c952b,'name');_0x5d35d5[_0x46f4('0x3a')]=_['keys'](_0x57c030['query']);_0x5d35d5[_0x46f4('0x3b')]=_['intersection'](_0x5d35d5['model'],_0x5d35d5[_0x46f4('0x3a')]);_0x213bcd[_0x46f4('0x3c')]=_['intersection'](_0x5d35d5[_0x46f4('0x39')],qs['fields'](_0x57c030[_0x46f4('0x3a')][_0x46f4('0x3d')]));_0x213bcd[_0x46f4('0x3c')]=_0x213bcd[_0x46f4('0x3c')]['length']?_0x213bcd[_0x46f4('0x3c')]:_0x5d35d5[_0x46f4('0x39')];if(!_0x57c030[_0x46f4('0x3a')]['hasOwnProperty']('nolimit')){_0x213bcd['limit']=qs[_0x46f4('0x1f')](_0x57c030[_0x46f4('0x3a')][_0x46f4('0x1f')]);_0x213bcd[_0x46f4('0x1e')]=qs['offset'](_0x57c030[_0x46f4('0x3a')][_0x46f4('0x1e')]);}_0x213bcd[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0x57c030[_0x46f4('0x3a')]['sort']);_0x213bcd[_0x46f4('0x40')]=qs[_0x46f4('0x3b')](_[_0x46f4('0x41')](_0x57c030[_0x46f4('0x3a')],_0x5d35d5[_0x46f4('0x3b')]),_0x5c952b);if(_0x57c030['query']['filter']){_0x213bcd['where']=_[_0x46f4('0x42')](_0x213bcd[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x5c952b,function(_0x5eb355){if(_0x5eb355[_0x46f4('0x31')]!==_0x46f4('0x43')){var _0x33aa3b={};_0x33aa3b[_0x5eb355[_0x46f4('0x32')]]={'$like':'%'+_0x57c030[_0x46f4('0x3a')][_0x46f4('0x44')]+'%'};return _0x33aa3b;}})});}_0x213bcd=_[_0x46f4('0x42')]({},_0x213bcd,_0x57c030[_0x46f4('0x45')]);var _0x543900={'where':_0x213bcd[_0x46f4('0x40')]};return db[_0x46f4('0x37')][_0x46f4('0x21')](_0x543900)[_0x46f4('0x29')](function(_0x596039){_0xd1516a[_0x46f4('0x21')]=_0x596039;if(_0x57c030[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x213bcd[_0x46f4('0x47')]=[{'all':!![]}];}return db[_0x46f4('0x37')][_0x46f4('0x48')](_0x213bcd);})['then'](function(_0x5e1cd3){_0xd1516a['rows']=_0x5e1cd3;return _0xd1516a;})[_0x46f4('0x29')](respondWithFilteredResult(_0x43867b,_0x213bcd))[_0x46f4('0x49')](handleError(_0x43867b,null));};exports[_0x46f4('0x4a')]=function(_0x19b357,_0x4369a4){var _0x379757={'raw':![],'where':{'id':_0x19b357[_0x46f4('0x4b')]['id']}},_0x2ca55d={};_0x2ca55d[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db[_0x46f4('0x37')][_0x46f4('0x4d')]);_0x2ca55d['query']=_[_0x46f4('0x4c')](_0x19b357[_0x46f4('0x3a')]);_0x2ca55d[_0x46f4('0x3b')]=_['intersection'](_0x2ca55d['model'],_0x2ca55d[_0x46f4('0x3a')]);_0x379757[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x2ca55d['model'],qs['fields'](_0x19b357[_0x46f4('0x3a')][_0x46f4('0x3d')]));_0x379757[_0x46f4('0x3c')]=_0x379757[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x379757[_0x46f4('0x3c')]:_0x2ca55d['model'];if(_0x19b357[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x379757[_0x46f4('0x47')]=[{'all':!![]}];}_0x379757=_['merge']({},_0x379757,_0x19b357[_0x46f4('0x45')]);return db[_0x46f4('0x37')][_0x46f4('0x50')](_0x379757)[_0x46f4('0x29')](handleEntityNotFound(_0x4369a4,null))['then'](respondWithResult(_0x4369a4,null))[_0x46f4('0x49')](handleError(_0x4369a4,null));};exports['create']=function(_0x2a9548,_0x3dfb7b){return db[_0x46f4('0x37')]['create'](_0x2a9548[_0x46f4('0x51')],{})[_0x46f4('0x29')](function(_0x51a464){var _0x1a2698=_0x2a9548['user']['get']({'plain':!![]});if(!_0x1a2698)throw new Error(_0x46f4('0x52'));if(_0x1a2698[_0x46f4('0x53')]===_0x46f4('0x54')){var _0x1e968a=_0x51a464['get']({'plain':!![]});var _0x5c0372=[{'name':'VoiceQueues','value':_0x46f4('0x55')},{'name':_0x46f4('0x2d'),'value':'outbound'}];var _0x9b1ef9=_[_0x46f4('0x50')](_0x5c0372,[_0x46f4('0x2f'),_0x1e968a[_0x46f4('0x31')]])['name'];return db[_0x46f4('0x56')]['find']({'where':{'name':_0x9b1ef9,'userProfileId':_0x1a2698[_0x46f4('0x57')]},'raw':!![]})[_0x46f4('0x29')](function(_0x289dde){if(_0x289dde&&_0x289dde[_0x46f4('0x58')]===0x0){return db[_0x46f4('0x59')][_0x46f4('0x5a')]({'name':_0x1e968a[_0x46f4('0x32')],'resourceId':_0x1e968a['id'],'type':_0x289dde[_0x46f4('0x32')],'sectionId':_0x289dde['id']},{})[_0x46f4('0x29')](function(){return _0x51a464;});}else{return _0x51a464;}})[_0x46f4('0x49')](function(_0x3f420b){logger[_0x46f4('0x33')](_0x46f4('0x5b'),_0x3f420b);throw _0x3f420b;});}return _0x51a464;})['then'](respondWithResult(_0x3dfb7b,0xc9))[_0x46f4('0x49')](handleError(_0x3dfb7b,null));};exports[_0x46f4('0x5c')]=function(_0x5538b9,_0x509f82){var _0x1d38f6={'where':{'id':_0x5538b9['params']['id']}},_0x32bf41={};_0x32bf41['model']=_[_0x46f4('0x4c')](db['VoiceQueue'][_0x46f4('0x4d')]);_0x1d38f6[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x32bf41[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x5538b9['query'][_0x46f4('0x3d')]));_0x1d38f6['attributes']=_0x1d38f6['attributes'][_0x46f4('0x4f')]?_0x1d38f6[_0x46f4('0x3c')]:_0x32bf41[_0x46f4('0x39')];if(_0x5538b9[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x1d38f6[_0x46f4('0x47')]=[{'all':!![]}];}_0x1d38f6=_['merge']({},_0x1d38f6,_0x5538b9[_0x46f4('0x45')]);return db[_0x46f4('0x37')][_0x46f4('0x50')](_0x1d38f6)[_0x46f4('0x29')](handleEntityNotFound(_0x509f82,null))[_0x46f4('0x29')](function(_0x115d77){if(_0x115d77){var _0x927caa=_0x115d77[_0x46f4('0x2b')]({'plain':!![]});_0x927caa=qs[_0x46f4('0x5d')](_0x927caa,['id',_0x46f4('0x5e'),_0x46f4('0x5f')]);_0x5538b9[_0x46f4('0x51')]=_[_0x46f4('0x5d')](_0x5538b9[_0x46f4('0x51')],['id',_0x46f4('0x5e'),_0x46f4('0x5f')]);return db[_0x46f4('0x37')][_0x46f4('0x5a')](_['merge'](_0x927caa,_0x5538b9[_0x46f4('0x51')]),{'include':_0x5538b9[_0x46f4('0x3a')][_0x46f4('0x46')]?[{'all':!![]}]:undefined})[_0x46f4('0x29')](function(_0x36ae73){var _0x5dee95=_0x5538b9[_0x46f4('0x54')][_0x46f4('0x2b')]({'plain':!![]});if(!_0x5dee95)throw new Error(_0x46f4('0x52'));if(_0x5dee95[_0x46f4('0x53')]===_0x46f4('0x54')){var _0x2a3a17=_0x36ae73[_0x46f4('0x2b')]({'plain':!![]});var _0x429f53=[{'name':_0x46f4('0x2c'),'value':_0x46f4('0x55')},{'name':_0x46f4('0x2d'),'value':_0x46f4('0x60')}];var _0x2b57df=_[_0x46f4('0x50')](_0x429f53,[_0x46f4('0x2f'),_0x2a3a17[_0x46f4('0x31')]])[_0x46f4('0x32')];return db[_0x46f4('0x56')][_0x46f4('0x50')]({'where':{'name':_0x2b57df,'userProfileId':_0x5dee95[_0x46f4('0x57')]},'raw':!![]})[_0x46f4('0x29')](function(_0x36a256){if(_0x36a256&&_0x36a256[_0x46f4('0x58')]===0x0){return db[_0x46f4('0x59')][_0x46f4('0x5a')]({'name':_0x2a3a17['name'],'resourceId':_0x2a3a17['id'],'type':_0x36a256[_0x46f4('0x32')],'sectionId':_0x36a256['id']},{})['then'](function(){return _0x36ae73;});}else{return _0x36ae73;}})[_0x46f4('0x49')](function(_0x3edcd3){logger[_0x46f4('0x33')](_0x46f4('0x5b'),_0x3edcd3);throw _0x3edcd3;});}return _0x36ae73;});}})[_0x46f4('0x29')](respondWithResult(_0x509f82,0xc9))[_0x46f4('0x49')](handleError(_0x509f82,null));};exports[_0x46f4('0x28')]=function(_0x2d804c,_0x576574){if(_0x2d804c[_0x46f4('0x51')]['id']){delete _0x2d804c[_0x46f4('0x51')]['id'];}return db['VoiceQueue'][_0x46f4('0x50')]({'where':{'id':_0x2d804c[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x576574,null))[_0x46f4('0x29')](saveUpdates(_0x2d804c[_0x46f4('0x51')],null))['then'](respondWithResult(_0x576574,null))[_0x46f4('0x49')](handleError(_0x576574,null));};exports['destroy']=function(_0x231d84,_0xa9b2aa){return db[_0x46f4('0x37')]['find']({'where':{'id':_0x231d84[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0xa9b2aa,null))[_0x46f4('0x29')](removeEntity(_0xa9b2aa,null))[_0x46f4('0x49')](handleError(_0xa9b2aa,null));};exports['getHoppers']=function(_0x35b090,_0xe91269,_0x30ddf0){var _0x318c28={'raw':![],'where':{}};var _0x433340={};var _0x42b31b={'count':0x0,'rows':[]};return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x35b090['params']['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0xe91269,null))[_0x46f4('0x29')](function(_0x5194d8){if(_0x5194d8){_0x433340[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db['CmHopper'][_0x46f4('0x4d')]);_0x433340['query']=_[_0x46f4('0x4c')](_0x35b090['query']);_0x433340[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x433340['model'],_0x433340['query']);_0x318c28[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x433340[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x35b090[_0x46f4('0x3a')][_0x46f4('0x3d')]));_0x318c28[_0x46f4('0x3c')]=_0x318c28['attributes'][_0x46f4('0x4f')]?_0x318c28[_0x46f4('0x3c')]:_0x433340[_0x46f4('0x39')];if(!_0x35b090[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x318c28['limit']=qs[_0x46f4('0x1f')](_0x35b090[_0x46f4('0x3a')]['limit']);_0x318c28[_0x46f4('0x1e')]=qs['offset'](_0x35b090[_0x46f4('0x3a')]['offset']);}_0x318c28[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0x35b090[_0x46f4('0x3a')]['sort']);_0x318c28[_0x46f4('0x40')]=qs[_0x46f4('0x3b')](_[_0x46f4('0x41')](_0x35b090[_0x46f4('0x3a')],_0x433340['filters']));_0x318c28[_0x46f4('0x40')][_0x46f4('0x64')]=_0x5194d8['id'];if(_0x35b090['query'][_0x46f4('0x44')]){_0x318c28[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x318c28[_0x46f4('0x40')],{'$or':_['map'](_0x318c28[_0x46f4('0x3c')],function(_0x3ec22f){var _0x48f5c2={};_0x48f5c2[_0x3ec22f]={'$like':'%'+_0x35b090[_0x46f4('0x3a')]['filter']+'%'};return _0x48f5c2;})});}_0x318c28=_[_0x46f4('0x42')]({},_0x318c28,_0x35b090[_0x46f4('0x45')]);return db[_0x46f4('0x65')]['count']({'where':_0x318c28[_0x46f4('0x40')]})[_0x46f4('0x29')](function(_0x5b9fb1){_0x42b31b[_0x46f4('0x21')]=_0x5b9fb1;if(_0x35b090[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x318c28[_0x46f4('0x47')]=[{'all':!![]}];}return db[_0x46f4('0x65')][_0x46f4('0x48')](_0x318c28);})[_0x46f4('0x29')](function(_0x31fb77){_0x42b31b[_0x46f4('0x66')]=_0x31fb77;return _0x42b31b;});}})[_0x46f4('0x29')](respondWithFilteredResult(_0xe91269,_0x318c28))['catch'](handleError(_0xe91269,null));};exports[_0x46f4('0x67')]=function(_0x6531c1,_0x42a2be,_0x513d58){var _0x2df7dc={'raw':!![],'where':{}};var _0x2f7ca8={};var _0x2acb74={'count':0x0,'rows':[]};return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x6531c1[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x42a2be,null))[_0x46f4('0x29')](function(_0x181690){if(_0x181690){_0x2f7ca8[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db[_0x46f4('0x68')][_0x46f4('0x4d')]);_0x2f7ca8['query']=_[_0x46f4('0x4c')](_0x6531c1['query']);_0x2f7ca8[_0x46f4('0x3b')]=_['intersection'](_0x2f7ca8[_0x46f4('0x39')],_0x2f7ca8[_0x46f4('0x3a')]);_0x2df7dc[_0x46f4('0x3c')]=_['intersection'](_0x2f7ca8[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x6531c1[_0x46f4('0x3a')]['fields']));_0x2df7dc['attributes']=_0x2df7dc[_0x46f4('0x3c')]['length']?_0x2df7dc[_0x46f4('0x3c')]:_0x2f7ca8[_0x46f4('0x39')];if(!_0x6531c1[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x2df7dc[_0x46f4('0x1f')]=qs['limit'](_0x6531c1['query'][_0x46f4('0x1f')]);_0x2df7dc[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x6531c1[_0x46f4('0x3a')][_0x46f4('0x1e')]);}_0x2df7dc['order']=qs[_0x46f4('0x3f')](_0x6531c1[_0x46f4('0x3a')][_0x46f4('0x3f')]);_0x2df7dc['where']=qs[_0x46f4('0x3b')](_['pick'](_0x6531c1['query'],_0x2f7ca8[_0x46f4('0x3b')]));_0x2df7dc[_0x46f4('0x40')][_0x46f4('0x64')]=_0x181690['id'];if(_0x6531c1[_0x46f4('0x3a')]['filter']){_0x2df7dc[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x2df7dc[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x2df7dc[_0x46f4('0x3c')],function(_0x577c48){var _0xa1d6bf={};_0xa1d6bf[_0x577c48]={'$like':'%'+_0x6531c1[_0x46f4('0x3a')][_0x46f4('0x44')]+'%'};return _0xa1d6bf;})});}_0x2df7dc=_['merge']({},_0x2df7dc,_0x6531c1[_0x46f4('0x45')]);return db[_0x46f4('0x68')]['count']({'where':_0x2df7dc[_0x46f4('0x40')]})[_0x46f4('0x29')](function(_0x121201){_0x2acb74['count']=_0x121201;if(_0x6531c1[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x2df7dc['include']=[{'all':!![]}];}return db[_0x46f4('0x68')][_0x46f4('0x48')](_0x2df7dc);})['then'](function(_0x3304d0){_0x2acb74[_0x46f4('0x66')]=_0x3304d0;return _0x2acb74;});}})[_0x46f4('0x29')](respondWithFilteredResult(_0x42a2be,_0x2df7dc))[_0x46f4('0x49')](handleError(_0x42a2be,null));};exports[_0x46f4('0x69')]=function(_0xfbb58a,_0x10ba2e,_0x206b66){var _0x254cce={'raw':!![],'where':{}};var _0x4121f4={};var _0x150ace={'count':0x0,'rows':[]};return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0xfbb58a['params']['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x10ba2e,null))['then'](function(_0x317f12){if(_0x317f12){_0x4121f4[_0x46f4('0x39')]=_['keys'](db['CmHopperFinal'][_0x46f4('0x4d')]);_0x4121f4[_0x46f4('0x3a')]=_[_0x46f4('0x4c')](_0xfbb58a[_0x46f4('0x3a')]);_0x4121f4[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x4121f4[_0x46f4('0x39')],_0x4121f4[_0x46f4('0x3a')]);_0x254cce[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x4121f4['model'],qs['fields'](_0xfbb58a['query'][_0x46f4('0x3d')]));_0x254cce[_0x46f4('0x3c')]=_0x254cce[_0x46f4('0x3c')]['length']?_0x254cce['attributes']:_0x4121f4[_0x46f4('0x39')];if(!_0xfbb58a['query'][_0x46f4('0x62')](_0x46f4('0x63'))){_0x254cce[_0x46f4('0x1f')]=qs[_0x46f4('0x1f')](_0xfbb58a[_0x46f4('0x3a')][_0x46f4('0x1f')]);_0x254cce[_0x46f4('0x1e')]=qs['offset'](_0xfbb58a[_0x46f4('0x3a')]['offset']);}_0x254cce[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0xfbb58a['query'][_0x46f4('0x3f')]);_0x254cce['where']=qs[_0x46f4('0x3b')](_['pick'](_0xfbb58a[_0x46f4('0x3a')],_0x4121f4[_0x46f4('0x3b')]));_0x254cce[_0x46f4('0x40')][_0x46f4('0x64')]=_0x317f12['id'];if(_0xfbb58a[_0x46f4('0x3a')]['filter']){_0x254cce['where']=_[_0x46f4('0x42')](_0x254cce[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x254cce[_0x46f4('0x3c')],function(_0x3eb2be){var _0x2b7cb8={};_0x2b7cb8[_0x3eb2be]={'$like':'%'+_0xfbb58a[_0x46f4('0x3a')][_0x46f4('0x44')]+'%'};return _0x2b7cb8;})});}_0x254cce=_['merge']({},_0x254cce,_0xfbb58a['options']);return db[_0x46f4('0x6a')]['count']({'where':_0x254cce[_0x46f4('0x40')]})[_0x46f4('0x29')](function(_0x13fc61){_0x150ace[_0x46f4('0x21')]=_0x13fc61;if(_0xfbb58a['query'][_0x46f4('0x46')]){_0x254cce[_0x46f4('0x47')]=[{'all':!![]}];}return db[_0x46f4('0x6a')][_0x46f4('0x48')](_0x254cce);})['then'](function(_0x467f35){_0x150ace[_0x46f4('0x66')]=_0x467f35;return _0x150ace;});}})[_0x46f4('0x29')](respondWithFilteredResult(_0x10ba2e,_0x254cce))['catch'](handleError(_0x10ba2e,null));};exports[_0x46f4('0x6b')]=function(_0x19e222,_0x400784,_0x26a2fd){var _0x14e48c={'raw':!![],'where':{}};var _0x1d7c36={};var _0x338cad={'count':0x0,'rows':[]};return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x19e222[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x400784,null))[_0x46f4('0x29')](function(_0x44d9ee){if(_0x44d9ee){_0x1d7c36[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db[_0x46f4('0x6c')][_0x46f4('0x4d')]);_0x1d7c36['query']=_[_0x46f4('0x4c')](_0x19e222[_0x46f4('0x3a')]);_0x1d7c36['filters']=_[_0x46f4('0x4e')](_0x1d7c36[_0x46f4('0x39')],_0x1d7c36[_0x46f4('0x3a')]);_0x14e48c[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x1d7c36[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x19e222[_0x46f4('0x3a')][_0x46f4('0x3d')]));_0x14e48c[_0x46f4('0x3c')]=_0x14e48c[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x14e48c[_0x46f4('0x3c')]:_0x1d7c36[_0x46f4('0x39')];if(!_0x19e222[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x14e48c[_0x46f4('0x1f')]=qs['limit'](_0x19e222[_0x46f4('0x3a')][_0x46f4('0x1f')]);_0x14e48c[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x19e222[_0x46f4('0x3a')][_0x46f4('0x1e')]);}_0x14e48c[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0x19e222['query'][_0x46f4('0x3f')]);_0x14e48c[_0x46f4('0x40')]=qs[_0x46f4('0x3b')](_[_0x46f4('0x41')](_0x19e222[_0x46f4('0x3a')],_0x1d7c36[_0x46f4('0x3b')]));_0x14e48c[_0x46f4('0x40')][_0x46f4('0x64')]=_0x44d9ee['id'];if(_0x19e222[_0x46f4('0x3a')][_0x46f4('0x44')]){_0x14e48c[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x14e48c[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x14e48c[_0x46f4('0x3c')],function(_0x56722e){var _0x2c16a8={};_0x2c16a8[_0x56722e]={'$like':'%'+_0x19e222['query'][_0x46f4('0x44')]+'%'};return _0x2c16a8;})});}_0x14e48c=_[_0x46f4('0x42')]({},_0x14e48c,_0x19e222[_0x46f4('0x45')]);return db[_0x46f4('0x6c')][_0x46f4('0x21')]({'where':_0x14e48c[_0x46f4('0x40')]})[_0x46f4('0x29')](function(_0x386ebf){_0x338cad[_0x46f4('0x21')]=_0x386ebf;if(_0x19e222[_0x46f4('0x3a')][_0x46f4('0x46')]){_0x14e48c[_0x46f4('0x47')]=[{'all':!![]}];}return db['CmHopperBlack'][_0x46f4('0x48')](_0x14e48c);})[_0x46f4('0x29')](function(_0x372d89){_0x338cad[_0x46f4('0x66')]=_0x372d89;return _0x338cad;});}})[_0x46f4('0x29')](respondWithFilteredResult(_0x400784,_0x14e48c))['catch'](handleError(_0x400784,null));};exports['getTeams']=function(_0x1268d9,_0x296541,_0x1654b6){var _0x14963e={};var _0x38d63b={};var _0x3584a6;var _0x2eaf43;return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x1268d9[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x296541,null))[_0x46f4('0x29')](function(_0x37270e){if(_0x37270e){_0x3584a6=_0x37270e;_0x38d63b[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db[_0x46f4('0x6d')]['rawAttributes']);_0x38d63b[_0x46f4('0x3a')]=_[_0x46f4('0x4c')](_0x1268d9['query']);_0x38d63b[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x38d63b[_0x46f4('0x39')],_0x38d63b[_0x46f4('0x3a')]);_0x14963e[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x38d63b[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x1268d9[_0x46f4('0x3a')][_0x46f4('0x3d')]));_0x14963e[_0x46f4('0x3c')]=_0x14963e[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x14963e[_0x46f4('0x3c')]:_0x38d63b[_0x46f4('0x39')];_0x14963e[_0x46f4('0x3e')]=qs['sort'](_0x1268d9['query']['sort']);_0x14963e[_0x46f4('0x40')]=qs[_0x46f4('0x3b')](_[_0x46f4('0x41')](_0x1268d9[_0x46f4('0x3a')],_0x38d63b[_0x46f4('0x3b')]));if(_0x1268d9[_0x46f4('0x3a')][_0x46f4('0x44')]){_0x14963e[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x14963e['where'],{'$or':_[_0x46f4('0x36')](_0x14963e['attributes'],function(_0x48cf8d){var _0x7c4d6f={};_0x7c4d6f[_0x48cf8d]={'$like':'%'+_0x1268d9[_0x46f4('0x3a')]['filter']+'%'};return _0x7c4d6f;})});}_0x14963e=_[_0x46f4('0x42')]({},_0x14963e,_0x1268d9['options']);return _0x3584a6[_0x46f4('0x6e')](_0x14963e);}})[_0x46f4('0x29')](function(_0x1e3cd4){if(_0x1e3cd4){_0x2eaf43=_0x1e3cd4[_0x46f4('0x4f')];if(!_0x1268d9['query'][_0x46f4('0x62')](_0x46f4('0x63'))){_0x14963e[_0x46f4('0x1f')]=qs['limit'](_0x1268d9[_0x46f4('0x3a')]['limit']);_0x14963e[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x1268d9['query'][_0x46f4('0x1e')]);}return _0x3584a6[_0x46f4('0x6e')](_0x14963e);}})[_0x46f4('0x29')](function(_0x2df23e){if(_0x2df23e){return _0x2df23e?{'count':_0x2eaf43,'rows':_0x2df23e}:null;}})[_0x46f4('0x29')](respondWithResult(_0x296541,null))[_0x46f4('0x49')](handleError(_0x296541,null));};exports['addTeams']=function(_0xd469df,_0x2398db,_0x1f8fa8){var _0x281cce=_0xd469df[_0x46f4('0x51')][_0x46f4('0x6f')];var _0x1dcf1b=_[_0x46f4('0x36')](_0x281cce,'id');return db[_0x46f4('0x6d')][_0x46f4('0x48')]({'where':{'id':_0x1dcf1b},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name','online','voicePause','interface'],'raw':!![]}]})['then'](function(_0x2fe2d2){if(_0x2fe2d2){var _0x328f55=_[_0x46f4('0x70')](_0x2fe2d2,function(_0x5df687){var _0x336d74=_0x5df687['get']({'plain':!![]});_0x336d74[_0x46f4('0x71')]['forEach'](function(_0x3f7812){_0x3f7812[_0x46f4('0x72')]=_[_0x46f4('0x50')](_0x281cce,{'id':_0x336d74['id']})[_0x46f4('0x72')];});return _0x336d74[_0x46f4('0x71')];});return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0xd469df[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](function(_0x2b4870){return db['sequelize'][_0x46f4('0x73')](function(_0x3d9492){return _0x2b4870['addTeams'](_0x1dcf1b,{'transaction':_0x3d9492})[_0x46f4('0x29')](function(){return BPromise['each'](_0x281cce,function(_0x4c0c59){return db[_0x46f4('0x74')][_0x46f4('0x75')]({'TeamId':_0x4c0c59['id'],'VoiceQueueId':_0xd469df[_0x46f4('0x4b')]['id'],'penalty':_0x4c0c59[_0x46f4('0x72')]},{'transaction':_0x3d9492});});})['then'](function(){return BPromise[_0x46f4('0x76')](_0x328f55,function(_0x2df6bf){return db['UserVoiceQueue']['findOrCreate']({'where':{'UserId':_0x2df6bf['id'],'VoiceQueueId':_0xd469df[_0x46f4('0x4b')]['id']},'defaults':{'penalty':_0x2df6bf[_0x46f4('0x72')]},'transaction':_0x3d9492});});})[_0x46f4('0x29')](function(){return BPromise[_0x46f4('0x76')](_[_0x46f4('0x44')](_0x328f55,{'online':!![]}),function(_0x426e10){return db[_0x46f4('0x77')][_0x46f4('0x75')]({'membername':_0x426e10[_0x46f4('0x32')],'UserId':_0x426e10['id'],'queue_name':_0x2b4870[_0x46f4('0x32')],'VoiceQueueId':_0x2b4870['id'],'interface':_[_0x46f4('0x78')](_0x426e10['interface'])?util[_0x46f4('0x79')](_0x46f4('0x7a'),_0x426e10[_0x46f4('0x32')]):_0x426e10['interface'],'paused':_0x426e10[_0x46f4('0x7b')]||![],'penalty':_0x426e10[_0x46f4('0x72')]},{'transaction':_0x3d9492});});})[_0x46f4('0x29')](function(){_0x328f55['forEach'](function(_0x5c8e84){socket[_0x46f4('0x7c')](_0x46f4('0x7d'),{'UserId':_0x5c8e84['id'],'VoiceQueueId':_0x2b4870['id']});});});});});}})[_0x46f4('0x29')](respondWithStatusCode(_0x2398db,null))[_0x46f4('0x49')](handleError(_0x2398db,null));};exports['removeTeams']=function(_0x5d9065,_0x4089d2,_0xa3380c){return db[_0x46f4('0x6d')][_0x46f4('0x48')]({'where':{'id':_0x5d9065[_0x46f4('0x3a')][_0x46f4('0x7e')]},'attributes':['id'],'include':[{'model':db[_0x46f4('0x7f')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4089d2,null))['then'](function(_0x41dbdc){var _0x5a17d5=_[_0x46f4('0x36')](_0x41dbdc,'id');var _0x5a9a7e=[];var _0x433243=[];var _0x12f8dd=squel[_0x46f4('0x80')]();_0x12f8dd[_0x46f4('0x81')](_0x46f4('0x82'))[_0x46f4('0x83')](_0x46f4('0x84'),'tq')['join'](_0x46f4('0x85'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where']('VoiceQueueId\x20=\x20?',_0x5d9065[_0x46f4('0x4b')]['id']);for(var _0x35b61b=0x0;_0x35b61b<_0x41dbdc['length'];_0x35b61b+=0x1){let _0x162d8f=_0x41dbdc[_0x35b61b];for(var _0x153597=0x0;_0x153597<_0x162d8f[_0x46f4('0x71')][_0x46f4('0x4f')];_0x153597+=0x1){let _0xd5909b=_0x162d8f[_0x46f4('0x71')][_0x153597];var _0x4a633a=_0x12f8dd['clone']();_0x4a633a[_0x46f4('0x40')](_0x46f4('0x86'),_0xd5909b['id']);_0x433243['push'](db[_0x46f4('0x87')][_0x46f4('0x3a')](_0x4a633a['toString'](),{'type':db[_0x46f4('0x87')]['QueryTypes']['SELECT']})[_0x46f4('0x29')](function(_0x2681ba){if(_0x2681ba['length']===0x1){return _0xd5909b['id'];}else{var _0x3dea0a=_['every'](_[_0x46f4('0x36')](_0x2681ba,'TeamId'),function(_0x528463){return _[_0x46f4('0x30')](_0x5a17d5,_0x528463);});if(_0x3dea0a){return _0xd5909b['id'];}}}));}}return BPromise['all'](_0x433243)['then'](function(_0x3291f5){_0x5a9a7e=_(_0x5a9a7e)[_0x46f4('0x88')](_0x3291f5)[_0x46f4('0x89')]()[_0x46f4('0x2f')]();return db['VoiceQueue']['find']({'where':{'id':_0x5d9065[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](function(_0x3b7786){return db[_0x46f4('0x87')][_0x46f4('0x73')](function(_0x2640af){return _0x3b7786[_0x46f4('0x8a')](_0x5d9065['query'][_0x46f4('0x7e')],{'transaction':_0x2640af})[_0x46f4('0x29')](function(){if(!_[_0x46f4('0x8b')](_0x5a9a7e)){return _0x3b7786[_0x46f4('0x8c')](_0x5a9a7e,{'transaction':_0x2640af})[_0x46f4('0x29')](function(){return db[_0x46f4('0x77')][_0x46f4('0x2a')]({'where':{'VoiceQueueId':_0x5d9065[_0x46f4('0x4b')]['id'],'UserId':_0x5a9a7e},'transaction':_0x2640af});});}})[_0x46f4('0x29')](function(){_0x5a9a7e['forEach'](function(_0x139c6e){socket[_0x46f4('0x7c')](_0x46f4('0x8d'),{'UserId':_0x139c6e,'VoiceQueueId':_0x3b7786['id']});});});});});});})[_0x46f4('0x29')](respondWithStatusCode(_0x4089d2,null))[_0x46f4('0x49')](handleError(_0x4089d2,null));};exports[_0x46f4('0x8e')]=function(_0x3b58e2,_0x340223,_0xc44bc2){var _0x16d319,_0x8d0cca;return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x3b58e2[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x340223,null))['then'](function(_0x497f8c){if(_0x497f8c){_0x8d0cca=_0x497f8c;return _0x497f8c[_0x46f4('0x8e')](_0x3b58e2['body'][_0x46f4('0x7e')],_['omit'](_0x3b58e2[_0x46f4('0x51')],[_0x46f4('0x7e'),'id'])||{})['spread'](function(_0x511c4b){for(var _0x339959=0x0;_0x339959<_0x3b58e2[_0x46f4('0x51')][_0x46f4('0x7e')][_0x46f4('0x4f')];_0x339959+=0x1){socket[_0x46f4('0x7c')](_0x46f4('0x7d'),{'UserId':Number(_0x3b58e2['body'][_0x46f4('0x7e')][_0x339959]),'VoiceQueueId':Number(_0x3b58e2[_0x46f4('0x4b')]['id'])});}return _0x511c4b;});}})[_0x46f4('0x29')](function(_0x31550a){_0x16d319=_0x31550a||[];if(_0x8d0cca){return db[_0x46f4('0x7f')]['findAll']({'where':{'id':_0x3b58e2[_0x46f4('0x51')][_0x46f4('0x7e')]},'attributes':['id',_0x46f4('0x32'),'online',_0x46f4('0x7b'),_0x46f4('0x8f')],'raw':!![]});}})[_0x46f4('0x29')](function(_0x37c458){if(!_['isEmpty'](_0x37c458)){var _0x444a7c=[];for(var _0x357c85=0x0;_0x357c85<_0x37c458[_0x46f4('0x4f')];_0x357c85++){if(_0x37c458[_0x357c85][_0x46f4('0x90')]){_0x444a7c[_0x46f4('0x91')](db[_0x46f4('0x77')]['upsert']({'membername':_0x37c458[_0x357c85][_0x46f4('0x32')],'UserId':_0x37c458[_0x357c85]['id'],'queue_name':_0x8d0cca[_0x46f4('0x32')],'VoiceQueueId':_0x8d0cca['id'],'interface':_['isNil'](_0x37c458[_0x357c85]['interface'])?util[_0x46f4('0x79')](_0x46f4('0x7a'),_0x37c458[_0x357c85][_0x46f4('0x32')]):_0x37c458[_0x357c85]['interface'],'paused':_0x37c458[_0x357c85]['voicePause']||![],'penalty':_0x3b58e2[_0x46f4('0x51')][_0x46f4('0x72')]||0x0}));}}return BPromise[_0x46f4('0x92')](_0x444a7c);}})[_0x46f4('0x29')](function(){return _0x16d319;})[_0x46f4('0x29')](respondWithResult(_0x340223,null))[_0x46f4('0x49')](handleError(_0x340223,null));};exports[_0x46f4('0x8c')]=function(_0x45a7d1,_0x3a8e48,_0x1340e0){return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x45a7d1[_0x46f4('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3a8e48,null))['then'](function(_0x4328f9){if(_0x4328f9){return _0x4328f9[_0x46f4('0x8c')](_0x45a7d1[_0x46f4('0x3a')][_0x46f4('0x7e')])[_0x46f4('0x29')](function(){if(_[_0x46f4('0x93')](_0x45a7d1[_0x46f4('0x3a')][_0x46f4('0x7e')])){for(var _0xfd104d=0x0;_0xfd104d<_0x45a7d1[_0x46f4('0x3a')][_0x46f4('0x7e')][_0x46f4('0x4f')];_0xfd104d+=0x1){socket[_0x46f4('0x7c')](_0x46f4('0x8d'),{'UserId':Number(_0x45a7d1[_0x46f4('0x3a')][_0x46f4('0x7e')][_0xfd104d]),'VoiceQueueId':Number(_0x45a7d1['params']['id'])});}}else{socket[_0x46f4('0x7c')](_0x46f4('0x8d'),{'UserId':Number(_0x45a7d1[_0x46f4('0x3a')][_0x46f4('0x7e')]),'VoiceQueueId':Number(_0x45a7d1[_0x46f4('0x4b')]['id'])});}});}})[_0x46f4('0x29')](function(_0x122d95){return db[_0x46f4('0x77')][_0x46f4('0x2a')]({'where':{'VoiceQueueId':_0x45a7d1[_0x46f4('0x4b')]['id'],'UserId':_0x45a7d1['query'][_0x46f4('0x7e')]}})[_0x46f4('0x29')](function(){return _0x122d95;});})[_0x46f4('0x29')](respondWithStatusCode(_0x3a8e48,null))[_0x46f4('0x49')](handleError(_0x3a8e48,null));};exports[_0x46f4('0x94')]=function(_0x5e6b3e,_0x4d9644,_0x92aab6){var _0x247eca={};var _0x232b9c={};var _0x412342;var _0x22dfab;return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x5e6b3e[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x4d9644,null))['then'](function(_0x87514c){if(_0x87514c){_0x412342=_0x87514c;_0x232b9c[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db['User'][_0x46f4('0x4d')]);_0x232b9c['query']=_['keys'](_0x5e6b3e['query']);_0x232b9c[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x232b9c[_0x46f4('0x39')],_0x232b9c['query']);_0x247eca[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x232b9c[_0x46f4('0x39')],qs[_0x46f4('0x3d')](_0x5e6b3e['query'][_0x46f4('0x3d')]));_0x247eca['attributes']=_0x247eca[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x247eca['attributes']:_0x232b9c['model'];_0x247eca[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0x5e6b3e[_0x46f4('0x3a')]['sort']);_0x247eca['where']=qs[_0x46f4('0x3b')](_[_0x46f4('0x41')](_0x5e6b3e['query'],_0x232b9c['filters']));if(_0x5e6b3e['query'][_0x46f4('0x44')]){_0x247eca[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x247eca[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x247eca['attributes'],function(_0x51cadf){var _0x5b5074={};_0x5b5074[_0x51cadf]={'$like':'%'+_0x5e6b3e['query'][_0x46f4('0x44')]+'%'};return _0x5b5074;})});}_0x247eca=_[_0x46f4('0x42')]({},_0x247eca,_0x5e6b3e[_0x46f4('0x45')]);return _0x412342[_0x46f4('0x94')](_0x247eca);}})[_0x46f4('0x29')](function(_0x271ae6){if(_0x271ae6){_0x22dfab=_0x271ae6['length'];if(!_0x5e6b3e[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x247eca[_0x46f4('0x1f')]=qs[_0x46f4('0x1f')](_0x5e6b3e[_0x46f4('0x3a')]['limit']);_0x247eca[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x5e6b3e[_0x46f4('0x3a')][_0x46f4('0x1e')]);}return _0x412342[_0x46f4('0x94')](_0x247eca);}})['then'](function(_0x2a6c74){if(_0x2a6c74){return _0x2a6c74?{'count':_0x22dfab,'rows':_0x2a6c74}:null;}})[_0x46f4('0x29')](respondWithResult(_0x4d9644,null))[_0x46f4('0x49')](handleError(_0x4d9644,null));};exports['getMembers']=function(_0x953370,_0x3c9d0e,_0x266c00){var _0x500634={};var _0x1bb92c={};var _0x41817b;var _0x1238c5;return db[_0x46f4('0x37')]['findOne']({'where':{'id':_0x953370[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x3c9d0e,null))[_0x46f4('0x29')](function(_0x27951c){if(_0x27951c){_0x41817b=_0x27951c;_0x1bb92c['model']=_['keys'](db[_0x46f4('0x77')]['rawAttributes']);_0x1bb92c[_0x46f4('0x3a')]=_[_0x46f4('0x4c')](_0x953370[_0x46f4('0x3a')]);_0x1bb92c[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x1bb92c['model'],_0x1bb92c[_0x46f4('0x3a')]);_0x500634[_0x46f4('0x3c')]=_['intersection'](_0x1bb92c[_0x46f4('0x39')],qs['fields'](_0x953370[_0x46f4('0x3a')]['fields']));_0x500634['attributes']=_0x500634[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x500634[_0x46f4('0x3c')]:_0x1bb92c[_0x46f4('0x39')];_0x500634['order']=qs[_0x46f4('0x3f')](_0x953370['query']['sort']);_0x500634['where']=qs['filters'](_[_0x46f4('0x41')](_0x953370[_0x46f4('0x3a')],_0x1bb92c['filters']));if(_0x953370[_0x46f4('0x3a')][_0x46f4('0x44')]){_0x500634['where']=_[_0x46f4('0x42')](_0x500634['where'],{'$or':_[_0x46f4('0x36')](_0x500634[_0x46f4('0x3c')],function(_0x3cf592){var _0x548fdb={};_0x548fdb[_0x3cf592]={'$like':'%'+_0x953370['query'][_0x46f4('0x44')]+'%'};return _0x548fdb;})});}_0x500634=_[_0x46f4('0x42')]({},_0x500634,_0x953370[_0x46f4('0x45')]);return _0x41817b[_0x46f4('0x95')](_0x500634);}})[_0x46f4('0x29')](function(_0x2481ed){if(_0x2481ed){_0x1238c5=_0x2481ed[_0x46f4('0x4f')];if(!_0x953370[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x500634[_0x46f4('0x1f')]=qs['limit'](_0x953370['query'][_0x46f4('0x1f')]);_0x500634[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x953370['query'][_0x46f4('0x1e')]);}return _0x41817b[_0x46f4('0x95')](_0x500634);}})['then'](function(_0x3cafa6){return _0x3cafa6?{'count':_0x1238c5,'rows':_0x3cafa6}:null;})['then'](respondWithResult(_0x3c9d0e,null))['catch'](handleError(_0x3c9d0e,null));};exports['getLists']=function(_0x321026,_0x2c273a,_0x242f56){var _0x7ba995={};var _0x1dbfdf={};var _0x5dd4bc;var _0xae878e;return db[_0x46f4('0x37')][_0x46f4('0x61')]({'where':{'id':_0x321026[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x2c273a,null))['then'](function(_0x527f57){if(_0x527f57){_0x5dd4bc=_0x527f57;_0x1dbfdf[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db['CmList']['rawAttributes']);_0x1dbfdf[_0x46f4('0x3a')]=_['keys'](_0x321026[_0x46f4('0x3a')]);_0x1dbfdf['filters']=_[_0x46f4('0x4e')](_0x1dbfdf[_0x46f4('0x39')],_0x1dbfdf[_0x46f4('0x3a')]);_0x7ba995[_0x46f4('0x3c')]=_[_0x46f4('0x4e')](_0x1dbfdf[_0x46f4('0x39')],qs['fields'](_0x321026[_0x46f4('0x3a')]['fields']));_0x7ba995[_0x46f4('0x3c')]=_0x7ba995[_0x46f4('0x3c')][_0x46f4('0x4f')]?_0x7ba995[_0x46f4('0x3c')]:_0x1dbfdf['model'];_0x7ba995[_0x46f4('0x3e')]=qs[_0x46f4('0x3f')](_0x321026[_0x46f4('0x3a')][_0x46f4('0x3f')]);_0x7ba995[_0x46f4('0x40')]=qs[_0x46f4('0x3b')](_['pick'](_0x321026[_0x46f4('0x3a')],_0x1dbfdf['filters']));if(_0x321026[_0x46f4('0x3a')][_0x46f4('0x44')]){_0x7ba995[_0x46f4('0x40')]=_[_0x46f4('0x42')](_0x7ba995[_0x46f4('0x40')],{'$or':_[_0x46f4('0x36')](_0x7ba995['attributes'],function(_0x339ed6){var _0x481f74={};_0x481f74[_0x339ed6]={'$like':'%'+_0x321026['query'][_0x46f4('0x44')]+'%'};return _0x481f74;})});}_0x7ba995=_[_0x46f4('0x42')]({},_0x7ba995,_0x321026[_0x46f4('0x45')]);return _0x5dd4bc[_0x46f4('0x96')](_0x7ba995);}})['then'](function(_0x498419){if(_0x498419){_0xae878e=_0x498419[_0x46f4('0x4f')];if(!_0x321026[_0x46f4('0x3a')][_0x46f4('0x62')]('nolimit')){_0x7ba995[_0x46f4('0x1f')]=qs[_0x46f4('0x1f')](_0x321026[_0x46f4('0x3a')]['limit']);_0x7ba995[_0x46f4('0x1e')]=qs[_0x46f4('0x1e')](_0x321026[_0x46f4('0x3a')][_0x46f4('0x1e')]);}return _0x5dd4bc[_0x46f4('0x96')](_0x7ba995);}})[_0x46f4('0x29')](function(_0x2b7c2e){if(_0x2b7c2e){return _0x2b7c2e?{'count':_0xae878e,'rows':_0x2b7c2e}:null;}})[_0x46f4('0x29')](respondWithResult(_0x2c273a,null))['catch'](handleError(_0x2c273a,null));};exports['addLists']=function(_0x8799e8,_0x3fadcb,_0x5eb13f){var _0x411936=moment()[_0x46f4('0x79')](_0x46f4('0x97'));var _0x4ca171,_0x5b2d1f;return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x8799e8[_0x46f4('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3fadcb,null))[_0x46f4('0x29')](function(_0x1b9a2f){if(_0x1b9a2f){_0x5b2d1f=_0x1b9a2f;return _0x1b9a2f[_0x46f4('0x98')](_0x8799e8['body'][_0x46f4('0x7e')],_[_0x46f4('0x5d')](_0x8799e8[_0x46f4('0x51')],[_0x46f4('0x7e'),'id'])||{});}return null;})['spread'](function(_0x217b1e){var _0x141d0b;_0x4ca171=_0x217b1e||[];var _0x15f13c=[];if(_0x217b1e){for(var _0x2f6599=0x0;_0x2f6599<_0x217b1e[_0x46f4('0x4f')];_0x2f6599+=0x1){var _0x3673ca=_0x217b1e[_0x2f6599][_0x46f4('0x2b')]({'plain':!![]});_0x5b2d1f[_0x46f4('0x99')]=_0x8799e8[_0x46f4('0x51')][_0x46f4('0x99')]?_0x8799e8[_0x46f4('0x51')][_0x46f4('0x99')]:_0x5b2d1f[_0x46f4('0x99')];switch(_0x5b2d1f[_0x46f4('0x99')]){case _0x46f4('0x9a'):_0x141d0b=squel['insert']()[_0x46f4('0x9b')](_0x46f4('0x9c'))[_0x46f4('0x9d')]([_0x46f4('0x9e'),_0x46f4('0x9f'),'ContactId',_0x46f4('0xa0'),_0x46f4('0x64'),'createdAt','updatedAt'],squel[_0x46f4('0x80')]()['field']('phone',_0x46f4('0x9e'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x9f'))[_0x46f4('0x81')]('id',_0x46f4('0xa1'))[_0x46f4('0x81')](_0x3673ca[_0x46f4('0xa2')][_0x46f4('0xa3')](),_0x46f4('0xa0'))[_0x46f4('0x81')](_0x8799e8[_0x46f4('0x4b')]['id']['toString'](),_0x46f4('0x64'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x5e'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x5f'))['from']('cm_contacts')[_0x46f4('0x40')]('deletedAt\x20IS\x20NULL')[_0x46f4('0x40')]('ListId\x20=\x20?',_0x3673ca['CmListId'][_0x46f4('0xa3')]())[_0x46f4('0x40')](_0x46f4('0xa4'))[_0x46f4('0x40')](_0x46f4('0xa5'),squel[_0x46f4('0x80')]()[_0x46f4('0x81')](_0x46f4('0xa6'))['from'](_0x46f4('0xa7'))['where'](_0x46f4('0xa8'),_0x8799e8['params']['id'][_0x46f4('0xa3')]()))['where'](_0x46f4('0xa5'),squel['select']()[_0x46f4('0x81')](_0x46f4('0xa9'))[_0x46f4('0x83')](_0x46f4('0x9c'))['where'](_0x46f4('0xa8'),_0x8799e8[_0x46f4('0x4b')]['id']['toString']())))[_0x46f4('0xa3')]();break;case'onlyIfOpen':_0x141d0b=squel['insert']()[_0x46f4('0x9b')](_0x46f4('0x9c'))[_0x46f4('0x9d')]([_0x46f4('0x9e'),'scheduledAt','ContactId',_0x46f4('0xa0'),_0x46f4('0x64'),'createdAt',_0x46f4('0x5f')],squel[_0x46f4('0x80')]()[_0x46f4('0x81')](_0x46f4('0x9e'),_0x46f4('0x9e'))['field']('\x27'+_0x411936+'\x27',_0x46f4('0x9f'))[_0x46f4('0x81')]('id',_0x46f4('0xa1'))[_0x46f4('0x81')](_0x3673ca[_0x46f4('0xa2')][_0x46f4('0xa3')](),_0x46f4('0xa0'))[_0x46f4('0x81')](_0x8799e8[_0x46f4('0x4b')]['id']['toString'](),'VoiceQueueId')[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x5e'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27','updatedAt')[_0x46f4('0x83')](_0x46f4('0xaa'))[_0x46f4('0x40')]('deletedAt\x20IS\x20NULL')[_0x46f4('0x40')](_0x46f4('0xab'),_0x3673ca[_0x46f4('0xa2')][_0x46f4('0xa3')]())[_0x46f4('0x40')](_0x46f4('0xa4'))[_0x46f4('0x40')](_0x46f4('0xa5'),squel[_0x46f4('0x80')]()['field'](_0x46f4('0xa9'))[_0x46f4('0x83')](_0x46f4('0x9c'))[_0x46f4('0x40')](_0x46f4('0xa8'),_0x8799e8[_0x46f4('0x4b')]['id'][_0x46f4('0xa3')]())))['toString']();break;default:_0x141d0b=squel['insert']()[_0x46f4('0x9b')](_0x46f4('0x9c'))[_0x46f4('0x9d')]([_0x46f4('0x9e'),_0x46f4('0x9f'),_0x46f4('0xa1'),_0x46f4('0xa0'),'VoiceQueueId',_0x46f4('0x5e'),_0x46f4('0x5f')],squel[_0x46f4('0x80')]()[_0x46f4('0x81')](_0x46f4('0x9e'),'phone')[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x9f'))['field']('id','ContactId')[_0x46f4('0x81')](_0x3673ca[_0x46f4('0xa2')][_0x46f4('0xa3')](),'ListId')[_0x46f4('0x81')](_0x8799e8[_0x46f4('0x4b')]['id']['toString'](),_0x46f4('0x64'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27','createdAt')[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x5f'))[_0x46f4('0x83')](_0x46f4('0xaa'))[_0x46f4('0x40')](_0x46f4('0xac'))['where']('ListId\x20=\x20?',_0x3673ca[_0x46f4('0xa2')][_0x46f4('0xa3')]())[_0x46f4('0x40')](_0x46f4('0xa4')))[_0x46f4('0xa3')]();}_0x15f13c[_0x46f4('0x91')](db[_0x46f4('0x87')][_0x46f4('0x3a')](_0x141d0b));}return BPromise[_0x46f4('0x92')](_0x15f13c);}})[_0x46f4('0x29')](function(){var _0x35df03=[];var _0x470b31=squel[_0x46f4('0xad')]()[_0x46f4('0x9b')](_0x46f4('0xae'))[_0x46f4('0x9d')]([_0x46f4('0xaf'),_0x46f4('0x9e'),_0x46f4('0xb0'),_0x46f4('0x5e'),'updatedAt'],squel[_0x46f4('0x80')]()[_0x46f4('0x81')](_0x46f4('0xb1'))[_0x46f4('0x81')]('ci.item')[_0x46f4('0x81')](_0x46f4('0xb2'))['field']('\x27'+_0x411936+'\x27',_0x46f4('0x5e'))[_0x46f4('0x81')]('\x27'+_0x411936+'\x27',_0x46f4('0x5f'))['from'](_0x46f4('0xb3'),'ci')[_0x46f4('0xb4')](_0x46f4('0x9c'),'h',_0x46f4('0xb5'))[_0x46f4('0x40')]('h.scheduledat=?',_0x411936)[_0x46f4('0x40')]('ci.ItemClass=?',_0x46f4('0xb6')))[_0x46f4('0xa3')]();_0x35df03['push'](db[_0x46f4('0x87')][_0x46f4('0x3a')](_0x470b31));return BPromise[_0x46f4('0x92')](_0x35df03);})[_0x46f4('0x29')](function(){return _0x4ca171;})[_0x46f4('0x29')](respondWithResult(_0x3fadcb,null))['catch'](handleError(_0x3fadcb,null));};exports[_0x46f4('0xb7')]=function(_0x4c95d,_0x5a6f70,_0x4f77e4){return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x4c95d[_0x46f4('0x4b')]['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x5a6f70,null))['then'](function(_0x329e85){if(_0x329e85){return _0x329e85[_0x46f4('0xb7')](_0x4c95d[_0x46f4('0x3a')][_0x46f4('0x7e')]);}})['then'](function(_0x253c9f){if(_0x253c9f){return db['CmHopper']['destroy']({'where':{'ListId':_0x4c95d[_0x46f4('0x3a')][_0x46f4('0x7e')],'VoiceQueueId':_0x4c95d[_0x46f4('0x4b')]['id']}})['then'](function(){return _0x253c9f;});}})[_0x46f4('0x29')](respondWithStatusCode(_0x5a6f70,null))[_0x46f4('0x49')](handleError(_0x5a6f70,null));};exports[_0x46f4('0xb8')]=function(_0xe50797,_0x3fb0d6,_0x561ea6){var _0x3135d5={};var _0x40bd8c={};var _0x4c2054;var _0x3f13f9;return db[_0x46f4('0x37')]['findOne']({'where':{'id':_0xe50797['params']['id']}})['then'](handleEntityNotFound(_0x3fb0d6,null))[_0x46f4('0x29')](function(_0x14dfa1){if(_0x14dfa1){_0x4c2054=_0x14dfa1;_0x40bd8c[_0x46f4('0x39')]=_[_0x46f4('0x4c')](db[_0x46f4('0xb9')][_0x46f4('0x4d')]);_0x40bd8c['query']=_[_0x46f4('0x4c')](_0xe50797['query']);_0x40bd8c[_0x46f4('0x3b')]=_[_0x46f4('0x4e')](_0x40bd8c['model'],_0x40bd8c[_0x46f4('0x3a')]);_0x3135d5['attributes']=_[_0x46f4('0x4e')](_0x40bd8c[_0x46f4('0x39')],qs['fields'](_0xe50797['query'][_0x46f4('0x3d')]));_0x3135d5[_0x46f4('0x3c')]=_0x3135d5[_0x46f4('0x3c')]['length']?_0x3135d5[_0x46f4('0x3c')]:_0x40bd8c[_0x46f4('0x39')];_0x3135d5['order']=qs['sort'](_0xe50797['query'][_0x46f4('0x3f')]);_0x3135d5[_0x46f4('0x40')]=qs['filters'](_[_0x46f4('0x41')](_0xe50797[_0x46f4('0x3a')],_0x40bd8c[_0x46f4('0x3b')]));if(_0xe50797[_0x46f4('0x3a')]['filter']){_0x3135d5['where']=_[_0x46f4('0x42')](_0x3135d5[_0x46f4('0x40')],{'$or':_['map'](_0x3135d5[_0x46f4('0x3c')],function(_0x4f5250){var _0x4ff46f={};_0x4ff46f[_0x4f5250]={'$like':'%'+_0xe50797[_0x46f4('0x3a')][_0x46f4('0x44')]+'%'};return _0x4ff46f;})});}_0x3135d5=_['merge']({},_0x3135d5,_0xe50797['options']);return _0x4c2054[_0x46f4('0xb8')](_0x3135d5);}})[_0x46f4('0x29')](function(_0x551ca7){if(_0x551ca7){_0x3f13f9=_0x551ca7['length'];if(!_0xe50797[_0x46f4('0x3a')][_0x46f4('0x62')](_0x46f4('0x63'))){_0x3135d5[_0x46f4('0x1f')]=qs['limit'](_0xe50797['query']['limit']);_0x3135d5[_0x46f4('0x1e')]=qs['offset'](_0xe50797[_0x46f4('0x3a')][_0x46f4('0x1e')]);}return _0x4c2054[_0x46f4('0xb8')](_0x3135d5);}})['then'](function(_0x127a97){if(_0x127a97){return _0x127a97?{'count':_0x3f13f9,'rows':_0x127a97}:null;}})[_0x46f4('0x29')](respondWithResult(_0x3fb0d6,null))[_0x46f4('0x49')](handleError(_0x3fb0d6,null));};exports['addBlackLists']=function(_0x232cf6,_0x462f25,_0x22ebb4){var _0x57a6ed,_0x6bb502;return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x232cf6['params']['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x462f25,null))[_0x46f4('0x29')](function(_0xf8d8d){if(_0xf8d8d){_0x6bb502=_0xf8d8d;return _0xf8d8d[_0x46f4('0xba')](_0x232cf6[_0x46f4('0x51')][_0x46f4('0x7e')],_[_0x46f4('0x5d')](_0x232cf6[_0x46f4('0x51')],[_0x46f4('0x7e'),'id'])||{});}return null;})[_0x46f4('0xbb')](function(_0x2a0096){var _0x2608a4;_0x57a6ed=_0x2a0096||[];var _0x406269=[];if(_0x2a0096){for(var _0x3d63ad=0x0;_0x3d63ad<_0x2a0096['length'];_0x3d63ad+=0x1){var _0x2525a2=_0x2a0096[_0x3d63ad][_0x46f4('0x2b')]({'plain':!![]});_0x2608a4=squel[_0x46f4('0xad')]()[_0x46f4('0x9b')](_0x46f4('0xbc'))[_0x46f4('0x9d')](['phone','ContactId',_0x46f4('0xa0'),_0x46f4('0x64'),_0x46f4('0x5e'),_0x46f4('0x5f')],squel['select']()[_0x46f4('0x81')](_0x46f4('0x9e'),_0x46f4('0x9e'))['field']('id','ContactId')[_0x46f4('0x81')](_0x2525a2[_0x46f4('0xa2')][_0x46f4('0xa3')](),_0x46f4('0xa0'))[_0x46f4('0x81')](_0x232cf6[_0x46f4('0x4b')]['id']['toString'](),_0x46f4('0x64'))['field']('NOW()',_0x46f4('0x5e'))[_0x46f4('0x81')](_0x46f4('0xbd'),_0x46f4('0x5f'))['from'](_0x46f4('0xaa'))[_0x46f4('0x40')](_0x46f4('0xac'))[_0x46f4('0x40')](_0x46f4('0xab'),_0x2525a2[_0x46f4('0xa2')][_0x46f4('0xa3')]())[_0x46f4('0x40')](_0x46f4('0xa4')))[_0x46f4('0xa3')]();_0x406269['push'](db[_0x46f4('0x87')][_0x46f4('0x3a')](_0x2608a4));}return BPromise['all'](_0x406269);}})[_0x46f4('0x29')](function(){return _0x57a6ed;})[_0x46f4('0x29')](respondWithResult(_0x462f25,null))['catch'](handleError(_0x462f25,null));};exports[_0x46f4('0xbe')]=function(_0x176f88,_0x232fad,_0x4f5871){return db[_0x46f4('0x37')][_0x46f4('0x50')]({'where':{'id':_0x176f88['params']['id']}})[_0x46f4('0x29')](handleEntityNotFound(_0x232fad,null))[_0x46f4('0x29')](function(_0x15bce9){if(_0x15bce9){return _0x15bce9['removeBlackLists'](_0x176f88[_0x46f4('0x3a')][_0x46f4('0x7e')]);}})[_0x46f4('0x29')](function(_0x49359c){if(_0x49359c){return db[_0x46f4('0x6c')]['destroy']({'where':{'ListId':_0x176f88[_0x46f4('0x3a')][_0x46f4('0x7e')],'VoiceQueueId':_0x176f88[_0x46f4('0x4b')]['id']}})['then'](function(){return _0x49359c;});}})['then'](respondWithStatusCode(_0x232fad,null))[_0x46f4('0x49')](handleError(_0x232fad,null));}; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.events.js b/server/api/voiceQueue/voiceQueue.events.js new file mode 100644 index 0000000..5719fad --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0360=['exports','events','../../mysqldb','VoiceQueue','setMaxListeners','remove','emit','hasOwnProperty'];(function(_0x47ea2b,_0x23ec13){var _0x214d98=function(_0x1b4caa){while(--_0x1b4caa){_0x47ea2b['push'](_0x47ea2b['shift']());}};_0x214d98(++_0x23ec13);}(_0x0360,0x139));var _0x0036=function(_0x21bea9,_0x40d301){_0x21bea9=_0x21bea9-0x0;var _0x487aa3=_0x0360[_0x21bea9];return _0x487aa3;};'use strict';var EventEmitter=require(_0x0036('0x0'));var VoiceQueue=require(_0x0036('0x1'))['db'][_0x0036('0x2')];var VoiceQueueEvents=new EventEmitter();VoiceQueueEvents[_0x0036('0x3')](0x0);var events={'afterCreate':'save','afterUpdate':'update','afterDestroy':_0x0036('0x4')};function emitEvent(_0x49a18d){return function(_0x5caa9b,_0x4a612f,_0x3c476c){VoiceQueueEvents[_0x0036('0x5')](_0x49a18d+':'+_0x5caa9b['id'],_0x5caa9b);VoiceQueueEvents[_0x0036('0x5')](_0x49a18d,_0x5caa9b);_0x3c476c(null);};}for(var e in events){if(events[_0x0036('0x6')](e)){var event=events[e];VoiceQueue['hook'](e,emitEvent(event));}}module[_0x0036('0x7')]=VoiceQueueEvents; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.model.js b/server/api/voiceQueue/voiceQueue.model.js new file mode 100644 index 0000000..e48cf74 --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x70e0=['voice_queues','lodash','util','../../config/logger','bluebird','request-promise','path','rimraf','./voiceQueue.attributes'];(function(_0x5d0207,_0xee695a){var _0x440b63=function(_0x1eb40e){while(--_0x1eb40e){_0x5d0207['push'](_0x5d0207['shift']());}};_0x440b63(++_0xee695a);}(_0x70e0,0x17b));var _0x070e=function(_0x488b95,_0x40db71){_0x488b95=_0x488b95-0x0;var _0x41e742=_0x70e0[_0x488b95];return _0x41e742;};'use strict';var _=require(_0x070e('0x0'));var util=require(_0x070e('0x1'));var logger=require(_0x070e('0x2'))('api');var moment=require('moment');var BPromise=require(_0x070e('0x3'));var rp=require(_0x070e('0x4'));var fs=require('fs');var path=require(_0x070e('0x5'));var rimraf=require(_0x070e('0x6'));var config=require('../../config/environment');var attributes=require(_0x070e('0x7'));module['exports']=function(_0x46fe68,_0x4b041d){return _0x46fe68['define']('VoiceQueue',attributes,{'tableName':_0x070e('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.rpc.js b/server/api/voiceQueue/voiceQueue.rpc.js new file mode 100644 index 0000000..9332e07 --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4e5a=['../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueue','VoiceQueue','findAll','options','raw','where','limit','include','model','attributes','map','find','ShowVoiceQueue','debug','lodash','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x43a5ee,_0x12ef80){var _0x4dcb0b=function(_0x1dc776){while(--_0x1dc776){_0x43a5ee['push'](_0x43a5ee['shift']());}};_0x4dcb0b(++_0x12ef80);}(_0x4e5a,0x1e7));var _0xa4e5=function(_0x160814,_0x57b5c6){_0x160814=_0x160814-0x0;var _0x427a69=_0x4e5a[_0x160814];return _0x427a69;};'use strict';var _=require(_0xa4e5('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa4e5('0x1'));var rs=require(_0xa4e5('0x2'));var fs=require('fs');var Redis=require(_0xa4e5('0x3'));var db=require(_0xa4e5('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa4e5('0x5'))(_0xa4e5('0x6'));var config=require(_0xa4e5('0x7'));var jayson=require(_0xa4e5('0x8'));var client=jayson['client'][_0xa4e5('0x9')]({'port':0x232a});config[_0xa4e5('0xa')]=_[_0xa4e5('0xb')](config[_0xa4e5('0xa')],{'host':_0xa4e5('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa4e5('0xa')]));require(_0xa4e5('0xd'))[_0xa4e5('0xe')](socket);function respondWithRpcPromise(_0x311e0a,_0x2bc7f2,_0x42ca60){return new BPromise(function(_0x3a2397,_0x13a10c){return client[_0xa4e5('0xf')](_0x311e0a,_0x42ca60)[_0xa4e5('0x10')](function(_0x48cd92){logger[_0xa4e5('0x11')](_0xa4e5('0x12'),_0x2bc7f2,_0xa4e5('0x13'));logger['debug'](_0xa4e5('0x14'),_0x2bc7f2,_0xa4e5('0x13'),JSON[_0xa4e5('0x15')](_0x48cd92));if(_0x48cd92['error']){if(_0x48cd92[_0xa4e5('0x16')][_0xa4e5('0x17')]===0x1f4){logger[_0xa4e5('0x16')](_0xa4e5('0x12'),_0x2bc7f2,_0x48cd92[_0xa4e5('0x16')][_0xa4e5('0x18')]);return _0x13a10c(_0x48cd92[_0xa4e5('0x16')]['message']);}logger[_0xa4e5('0x16')](_0xa4e5('0x12'),_0x2bc7f2,_0x48cd92[_0xa4e5('0x16')][_0xa4e5('0x18')]);return _0x3a2397(_0x48cd92[_0xa4e5('0x16')][_0xa4e5('0x18')]);}else{logger[_0xa4e5('0x11')](_0xa4e5('0x12'),_0x2bc7f2,'request\x20sent');_0x3a2397(_0x48cd92[_0xa4e5('0x19')][_0xa4e5('0x18')]);}})[_0xa4e5('0x1a')](function(_0x576138){logger[_0xa4e5('0x16')](_0xa4e5('0x12'),_0x2bc7f2,_0x576138);_0x13a10c(_0x576138);});});}exports[_0xa4e5('0x1b')]=function(_0x2041af){var _0x707c7=this;return new Promise(function(_0x4c30b2,_0x502478){return db[_0xa4e5('0x1c')][_0xa4e5('0x1d')]({'raw':_0x2041af[_0xa4e5('0x1e')]?_0x2041af['options'][_0xa4e5('0x1f')]===undefined?!![]:![]:!![],'where':_0x2041af['options']?_0x2041af[_0xa4e5('0x1e')][_0xa4e5('0x20')]||null:null,'attributes':_0x2041af[_0xa4e5('0x1e')]?_0x2041af[_0xa4e5('0x1e')]['attributes']||null:null,'limit':_0x2041af[_0xa4e5('0x1e')]?_0x2041af[_0xa4e5('0x1e')][_0xa4e5('0x21')]||null:null,'include':_0x2041af[_0xa4e5('0x1e')]?_0x2041af[_0xa4e5('0x1e')][_0xa4e5('0x22')]?_['map'](_0x2041af[_0xa4e5('0x1e')][_0xa4e5('0x22')],function(_0x9b1e69){return{'model':db[_0x9b1e69[_0xa4e5('0x23')]],'as':_0x9b1e69['as'],'attributes':_0x9b1e69[_0xa4e5('0x24')],'include':_0x9b1e69[_0xa4e5('0x22')]?_[_0xa4e5('0x25')](_0x9b1e69[_0xa4e5('0x22')],function(_0x4d4719){return{'model':db[_0x4d4719[_0xa4e5('0x23')]],'as':_0x4d4719['as'],'attributes':_0x4d4719[_0xa4e5('0x24')],'include':_0x4d4719[_0xa4e5('0x22')]?_[_0xa4e5('0x25')](_0x4d4719[_0xa4e5('0x22')],function(_0x4ce3e7){return{'model':db[_0x4ce3e7[_0xa4e5('0x23')]],'as':_0x4ce3e7['as'],'attributes':_0x4ce3e7[_0xa4e5('0x24')]};}):[]};}):[]};}):[]:[]})[_0xa4e5('0x10')](function(_0x213308){logger[_0xa4e5('0x11')](_0xa4e5('0x1b'),_0x2041af);logger['debug'](_0xa4e5('0x1b'),_0x2041af,JSON[_0xa4e5('0x15')](_0x213308));_0x4c30b2(_0x213308);})[_0xa4e5('0x1a')](function(_0x28859a){logger[_0xa4e5('0x16')](_0xa4e5('0x1b'),_0x28859a[_0xa4e5('0x18')],_0x2041af);_0x502478(_0x707c7['error'](0x1f4,_0x28859a[_0xa4e5('0x18')]));});});};exports['ShowVoiceQueue']=function(_0x166074){var _0x30ab57=this;return new Promise(function(_0xe596d4,_0x51ab72){return db[_0xa4e5('0x1c')][_0xa4e5('0x26')]({'raw':_0x166074[_0xa4e5('0x1e')]?_0x166074[_0xa4e5('0x1e')][_0xa4e5('0x1f')]===undefined?!![]:![]:!![],'where':_0x166074[_0xa4e5('0x1e')]?_0x166074[_0xa4e5('0x1e')][_0xa4e5('0x20')]||null:null,'attributes':_0x166074[_0xa4e5('0x1e')]?_0x166074[_0xa4e5('0x1e')][_0xa4e5('0x24')]||null:null,'include':_0x166074['options']?_0x166074['options']['include']?_[_0xa4e5('0x25')](_0x166074[_0xa4e5('0x1e')]['include'],function(_0x2c823a){return{'model':db[_0x2c823a['model']],'as':_0x2c823a['as'],'attributes':_0x2c823a[_0xa4e5('0x24')],'include':_0x2c823a[_0xa4e5('0x22')]?_[_0xa4e5('0x25')](_0x2c823a['include'],function(_0x313156){return{'model':db[_0x313156[_0xa4e5('0x23')]],'as':_0x313156['as'],'attributes':_0x313156['attributes'],'include':_0x313156['include']?_[_0xa4e5('0x25')](_0x313156[_0xa4e5('0x22')],function(_0x56aadc){return{'model':db[_0x56aadc[_0xa4e5('0x23')]],'as':_0x56aadc['as'],'attributes':_0x56aadc[_0xa4e5('0x24')]};}):[]};}):[]};}):[]:[]})[_0xa4e5('0x10')](function(_0x220b25){logger[_0xa4e5('0x11')](_0xa4e5('0x27'),_0x166074);logger[_0xa4e5('0x28')]('ShowVoiceQueue',_0x166074,JSON[_0xa4e5('0x15')](_0x220b25));_0xe596d4(_0x220b25);})[_0xa4e5('0x1a')](function(_0x10cca8){logger[_0xa4e5('0x16')](_0xa4e5('0x27'),_0x10cca8[_0xa4e5('0x18')],_0x166074);_0x51ab72(_0x30ab57[_0xa4e5('0x16')](0x1f4,_0x10cca8[_0xa4e5('0x18')]));});});}; \ No newline at end of file diff --git a/server/api/voiceQueue/voiceQueue.socket.js b/server/api/voiceQueue/voiceQueue.socket.js new file mode 100644 index 0000000..2da78e9 --- /dev/null +++ b/server/api/voiceQueue/voiceQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c4d=['save','remove','emit','removeListener','register','length','voiceQueue:'];(function(_0x19950b,_0x53d0d7){var _0x3c6b41=function(_0x3924ad){while(--_0x3924ad){_0x19950b['push'](_0x19950b['shift']());}};_0x3c6b41(++_0x53d0d7);}(_0x4c4d,0x1e3));var _0xd4c4=function(_0x162404,_0x3903c7){_0x162404=_0x162404-0x0;var _0x1d7869=_0x4c4d[_0x162404];return _0x1d7869;};'use strict';var VoiceQueueEvents=require('./voiceQueue.events');var events=[_0xd4c4('0x0'),_0xd4c4('0x1'),'update'];function createListener(_0x29cba5,_0x3b3462){return function(_0x362f17){_0x3b3462[_0xd4c4('0x2')](_0x29cba5,_0x362f17);};}function removeListener(_0x248992,_0x1fc186){return function(){VoiceQueueEvents[_0xd4c4('0x3')](_0x248992,_0x1fc186);};}exports[_0xd4c4('0x4')]=function(_0xd9811e){for(var _0x202ff1=0x0,_0x5d3325=events[_0xd4c4('0x5')];_0x202ff1<_0x5d3325;_0x202ff1++){var _0x25c82b=events[_0x202ff1];var _0x2ce6fd=createListener(_0xd4c4('0x6')+_0x25c82b,_0xd9811e);VoiceQueueEvents['on'](_0x25c82b,_0x2ce6fd);}}; \ No newline at end of file diff --git a/server/api/voiceQueueReport/index.js b/server/api/voiceQueueReport/index.js new file mode 100644 index 0000000..aab729e --- /dev/null +++ b/server/api/voiceQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2529=['/describe','describe','/index','get','/:id','post','create','put','update','delete','destroy','exports','path','connect-timeout','express','../../components/auth/service','../../components/interaction/service','./voiceQueueReport.controller','isAuthenticated','index'];(function(_0x4d5e1a,_0x267064){var _0x4b1085=function(_0x1dea8c){while(--_0x1dea8c){_0x4d5e1a['push'](_0x4d5e1a['shift']());}};_0x4b1085(++_0x267064);}(_0x2529,0x98));var _0x9252=function(_0x1bfc52,_0x3ad80a){_0x1bfc52=_0x1bfc52-0x0;var _0xf287d8=_0x2529[_0x1bfc52];return _0xf287d8;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x9252('0x0'));var timeout=require(_0x9252('0x1'));var express=require(_0x9252('0x2'));var router=express['Router']();var fs_extra=require('fs-extra');var auth=require(_0x9252('0x3'));var interaction=require(_0x9252('0x4'));var config=require('../../config/environment');var controller=require(_0x9252('0x5'));router['get']('/',auth[_0x9252('0x6')](),controller[_0x9252('0x7')]);router['get'](_0x9252('0x8'),auth[_0x9252('0x6')](),controller[_0x9252('0x9')]);router['get'](_0x9252('0xa'),auth[_0x9252('0x6')](),controller['getVoiceQueuesReport']);router[_0x9252('0xb')](_0x9252('0xc'),auth[_0x9252('0x6')](),controller['show']);router[_0x9252('0xd')]('/',auth[_0x9252('0x6')](),controller[_0x9252('0xe')]);router[_0x9252('0xf')]('/:id',auth[_0x9252('0x6')](),controller[_0x9252('0x10')]);router[_0x9252('0x11')]('/:id',auth[_0x9252('0x6')](),controller[_0x9252('0x12')]);module[_0x9252('0x13')]=router; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.attributes.js b/server/api/voiceQueueReport/voiceQueueReport.attributes.js new file mode 100644 index 0000000..a61de86 --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8543=['exports','STRING','DATE','getDataValue','queuecallerjoinAt','format','YYYY-MM-DD\x20HH:mm:ss','diff','seconds','queuecallerleaveAt','setDataValue','holdtime','INTEGER','BOOLEAN','COMPLETEDBYCALLER,\x20COMPLETEDBYAGENT,\x20FORWARDTRANFER,\x20BLINDTRANSFER,\x20ATTENDEDTRANSFER,\x20EXITWITHKEY,\x20TIMEOUT','FORWARD,\x20BLIND,\x20ATTENDED','moment'];(function(_0x3d5a58,_0x51c353){var _0x3b6ce4=function(_0x24c449){while(--_0x24c449){_0x3d5a58['push'](_0x3d5a58['shift']());}};_0x3b6ce4(++_0x51c353);}(_0x8543,0x10f));var _0x3854=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x8543[_0x53ccf2];return _0x5a2964;};'use strict';var Sequelize=require('sequelize');var moment=require(_0x3854('0x0'));module[_0x3854('0x1')]={'type':{'type':Sequelize[_0x3854('0x2')]},'uniqueid':{'type':Sequelize[_0x3854('0x2')]},'calleridnum':{'type':Sequelize['STRING']},'calleridname':{'type':Sequelize[_0x3854('0x2')]},'queue':{'type':Sequelize[_0x3854('0x2')]},'queuecallerjoinAt':{'type':Sequelize[_0x3854('0x3')]},'queuecallerleaveAt':{'type':Sequelize[_0x3854('0x3')],'set':function(_0x5b85e5){var _0x3f9d0e=moment(_0x5b85e5);var _0x1a24c3=moment(this[_0x3854('0x4')](_0x3854('0x5')))[_0x3854('0x6')](_0x3854('0x7'));var _0x21b431=_0x3f9d0e[_0x3854('0x8')](_0x1a24c3,_0x3854('0x9'));this['setDataValue'](_0x3854('0xa'),_0x5b85e5);this[_0x3854('0xb')](_0x3854('0xc'),_0x21b431||null);}},'position':{'type':Sequelize['INTEGER']},'count':{'type':Sequelize[_0x3854('0xd')]},'queuecallerabandon':{'type':Sequelize['BOOLEAN'],'defaultValue':![]},'queuecallerabandonAt':{'type':Sequelize[_0x3854('0x3')]},'queuecallercomplete':{'type':Sequelize[_0x3854('0xe')],'defaultValue':![]},'queuecallercompleteAt':{'type':Sequelize['DATE']},'queuecallerexit':{'type':Sequelize[_0x3854('0xe')],'defaultValue':![]},'queuecallerexitAt':{'type':Sequelize['DATE']},'queuecallerexitreason':{'type':Sequelize[_0x3854('0x2')],'comment':_0x3854('0xf')},'originalposition':{'type':Sequelize[_0x3854('0xd')]},'channel':{'type':Sequelize[_0x3854('0x2')]},'connectedlinenum':{'type':Sequelize[_0x3854('0x2')]},'connectedlinename':{'type':Sequelize[_0x3854('0x2')]},'accountcode':{'type':Sequelize[_0x3854('0x2')]},'context':{'type':Sequelize['STRING']},'exten':{'type':Sequelize[_0x3854('0x2')]},'priority':{'type':Sequelize[_0x3854('0x2')]},'holdtime':{'type':Sequelize['INTEGER']},'mohtime':{'type':Sequelize[_0x3854('0xd')],'defaultValue':0x0},'assigned':{'type':Sequelize[_0x3854('0xe')],'defaultValue':![]},'lastAssignedTo':{'type':Sequelize['STRING']},'transfer':{'type':Sequelize[_0x3854('0xe')],'defaultValue':![]},'transfertype':{'type':Sequelize[_0x3854('0x2')],'comment':_0x3854('0x10')},'transferexten':{'type':Sequelize[_0x3854('0x2')]},'transferuniqueid':{'type':Sequelize[_0x3854('0x2')]},'disposition':{'type':Sequelize[_0x3854('0x2')]},'secondDisposition':{'type':Sequelize[_0x3854('0x2')]},'thirdDisposition':{'type':Sequelize[_0x3854('0x2')]},'queuecallerenterreason':{'type':Sequelize[_0x3854('0xd')],'defaultValue':0x0},'note':{'type':Sequelize[_0x3854('0x2')]}}; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.controller.js b/server/api/voiceQueueReport/voiceQueueReport.controller.js new file mode 100644 index 0000000..fc22f73 --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x01fa=['redis','defaults','./voiceQueueReport.socket','register','sendStatus','end','json','offset','undefined','limit','count','status','set','Content-Range','apply','reject','update','then','destroy','error','name','index','VoiceQueueReport','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','findAll','show','params','length','find','create','body','catch','describe','getVoiceQueuesReport','include','rows','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb'];(function(_0x3d2949,_0x509812){var _0x49953f=function(_0x394418){while(--_0x394418){_0x3d2949['push'](_0x3d2949['shift']());}};_0x49953f(++_0x509812);}(_0x01fa,0x132));var _0xa01f=function(_0x2cfb58,_0x3d9412){_0x2cfb58=_0x2cfb58-0x0;var _0xd99951=_0x01fa[_0x2cfb58];return _0xd99951;};'use strict';var emlformat=require(_0xa01f('0x0'));var rimraf=require(_0xa01f('0x1'));var zipdir=require(_0xa01f('0x2'));var jsonpatch=require(_0xa01f('0x3'));var rp=require(_0xa01f('0x4'));var moment=require(_0xa01f('0x5'));var BPromise=require(_0xa01f('0x6'));var Mustache=require('mustache');var util=require(_0xa01f('0x7'));var path=require(_0xa01f('0x8'));var sox=require('sox');var csv=require(_0xa01f('0x9'));var ejs=require(_0xa01f('0xa'));var fs=require('fs');var fs_extra=require(_0xa01f('0xb'));var _=require(_0xa01f('0xc'));var squel=require(_0xa01f('0xd'));var crypto=require(_0xa01f('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xa01f('0xf'));var toCsv=require(_0xa01f('0x9'));var querystring=require(_0xa01f('0x10'));var Papa=require(_0xa01f('0x11'));var Redis=require('ioredis');var authService=require(_0xa01f('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa01f('0x13'));var logger=require(_0xa01f('0x14'))(_0xa01f('0x15'));var utils=require(_0xa01f('0x16'));var config=require(_0xa01f('0x17'));var licenseUtil=require(_0xa01f('0x18'));var db=require(_0xa01f('0x19'))['db'];config[_0xa01f('0x1a')]=_[_0xa01f('0x1b')](config[_0xa01f('0x1a')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa01f('0x1a')]));require(_0xa01f('0x1c'))[_0xa01f('0x1d')](socket);function respondWithStatusCode(_0x54fae1,_0x3384d8){_0x3384d8=_0x3384d8||0xcc;return function(_0x4e47e9){if(_0x4e47e9){return _0x54fae1[_0xa01f('0x1e')](_0x3384d8);}return _0x54fae1['status'](_0x3384d8)[_0xa01f('0x1f')]();};}function respondWithResult(_0x32bf5e,_0xfc5bd4){_0xfc5bd4=_0xfc5bd4||0xc8;return function(_0x135f3b){if(_0x135f3b){return _0x32bf5e['status'](_0xfc5bd4)[_0xa01f('0x20')](_0x135f3b);}};}function respondWithFilteredResult(_0xaa0fa0,_0x5ddcc2){return function(_0x5c4fe1){if(_0x5c4fe1){var _0xa5339c=typeof _0x5ddcc2[_0xa01f('0x21')]===_0xa01f('0x22')&&typeof _0x5ddcc2[_0xa01f('0x23')]==='undefined';var _0x163793=_0x5c4fe1['count'];var _0x4006fc=_0xa5339c?0x0:_0x5ddcc2['offset'];var _0x507bd7=_0xa5339c?_0x5c4fe1[_0xa01f('0x24')]:_0x5ddcc2[_0xa01f('0x21')]+_0x5ddcc2['limit'];var _0x3eb7ba;if(_0x507bd7>=_0x163793){_0x507bd7=_0x163793;_0x3eb7ba=0xc8;}else{_0x3eb7ba=0xce;}_0xaa0fa0[_0xa01f('0x25')](_0x3eb7ba);return _0xaa0fa0[_0xa01f('0x26')](_0xa01f('0x27'),_0x4006fc+'-'+_0x507bd7+'/'+_0x163793)['json'](_0x5c4fe1);}return null;};}function patchUpdates(_0x5b9ce8){return function(_0x408687){try{jsonpatch[_0xa01f('0x28')](_0x408687,_0x5b9ce8,!![]);}catch(_0x2fc91d){return BPromise[_0xa01f('0x29')](_0x2fc91d);}return _0x408687['save']();};}function saveUpdates(_0x4898ea,_0x5acb9a){return function(_0x10a454){if(_0x10a454){return _0x10a454[_0xa01f('0x2a')](_0x4898ea)[_0xa01f('0x2b')](function(_0x414b17){return _0x414b17;});}return null;};}function removeEntity(_0xb6b17e,_0x30ee11){return function(_0x543d61){if(_0x543d61){return _0x543d61[_0xa01f('0x2c')]()['then'](function(){_0xb6b17e[_0xa01f('0x25')](0xcc)[_0xa01f('0x1f')]();});}};}function handleEntityNotFound(_0x39048c,_0x4d87ad){return function(_0x217842){if(!_0x217842){_0x39048c[_0xa01f('0x1e')](0x194);}return _0x217842;};}function handleError(_0x71f9f5,_0x4b2616){_0x4b2616=_0x4b2616||0x1f4;return function(_0x3e7ccd){logger[_0xa01f('0x2d')](_0x3e7ccd['stack']);if(_0x3e7ccd[_0xa01f('0x2e')]){delete _0x3e7ccd[_0xa01f('0x2e')];}_0x71f9f5[_0xa01f('0x25')](_0x4b2616)['send'](_0x3e7ccd);};}exports[_0xa01f('0x2f')]=function(_0x117585,_0x444dc3){var _0x2f2bb4={},_0x412a4e={},_0x5d3146={'count':0x0,'rows':[]};var _0x433e7f=_['map'](db[_0xa01f('0x30')][_0xa01f('0x31')],function(_0xc32904){return{'name':_0xc32904['fieldName'],'type':_0xc32904[_0xa01f('0x32')][_0xa01f('0x33')]};});_0x412a4e[_0xa01f('0x34')]=_[_0xa01f('0x35')](_0x433e7f,'name');_0x412a4e[_0xa01f('0x36')]=_[_0xa01f('0x37')](_0x117585[_0xa01f('0x36')]);_0x412a4e[_0xa01f('0x38')]=_[_0xa01f('0x39')](_0x412a4e[_0xa01f('0x34')],_0x412a4e[_0xa01f('0x36')]);_0x2f2bb4[_0xa01f('0x3a')]=_[_0xa01f('0x39')](_0x412a4e['model'],qs[_0xa01f('0x3b')](_0x117585[_0xa01f('0x36')][_0xa01f('0x3b')]));_0x2f2bb4['attributes']=_0x2f2bb4[_0xa01f('0x3a')]['length']?_0x2f2bb4[_0xa01f('0x3a')]:_0x412a4e[_0xa01f('0x34')];if(!_0x117585['query'][_0xa01f('0x3c')](_0xa01f('0x3d'))){_0x2f2bb4['limit']=qs['limit'](_0x117585[_0xa01f('0x36')][_0xa01f('0x23')]);_0x2f2bb4[_0xa01f('0x21')]=qs[_0xa01f('0x21')](_0x117585[_0xa01f('0x36')][_0xa01f('0x21')]);}_0x2f2bb4[_0xa01f('0x3e')]=qs[_0xa01f('0x3f')](_0x117585[_0xa01f('0x36')][_0xa01f('0x3f')]);_0x2f2bb4['where']=qs[_0xa01f('0x38')](_[_0xa01f('0x40')](_0x117585[_0xa01f('0x36')],_0x412a4e['filters']),_0x433e7f);if(_0x117585[_0xa01f('0x36')][_0xa01f('0x41')]){_0x2f2bb4[_0xa01f('0x42')]=_[_0xa01f('0x43')](_0x2f2bb4[_0xa01f('0x42')],{'$or':_[_0xa01f('0x35')](_0x433e7f,function(_0x20ae8f){if(_0x20ae8f[_0xa01f('0x32')]!==_0xa01f('0x44')){var _0x1c03e4={};_0x1c03e4[_0x20ae8f[_0xa01f('0x2e')]]={'$like':'%'+_0x117585[_0xa01f('0x36')][_0xa01f('0x41')]+'%'};return _0x1c03e4;}})});}_0x2f2bb4=_[_0xa01f('0x43')]({},_0x2f2bb4,_0x117585[_0xa01f('0x45')]);var _0x1b43de={'where':_0x2f2bb4[_0xa01f('0x42')]};return db[_0xa01f('0x30')][_0xa01f('0x24')](_0x1b43de)[_0xa01f('0x2b')](function(_0x248e6f){_0x5d3146[_0xa01f('0x24')]=_0x248e6f;if(_0x117585[_0xa01f('0x36')][_0xa01f('0x46')]){_0x2f2bb4['include']=[{'all':!![]}];}return db['VoiceQueueReport'][_0xa01f('0x47')](_0x2f2bb4);})['then'](function(_0x10dc35){_0x5d3146['rows']=_0x10dc35;return _0x5d3146;})[_0xa01f('0x2b')](respondWithFilteredResult(_0x444dc3,_0x2f2bb4))['catch'](handleError(_0x444dc3,null));};exports[_0xa01f('0x48')]=function(_0x3d490c,_0x4a5e29){var _0x4dfc36={'raw':![],'where':{'id':_0x3d490c[_0xa01f('0x49')]['id']}},_0x1bd6b8={};_0x1bd6b8[_0xa01f('0x34')]=_[_0xa01f('0x37')](db[_0xa01f('0x30')][_0xa01f('0x31')]);_0x1bd6b8[_0xa01f('0x36')]=_[_0xa01f('0x37')](_0x3d490c[_0xa01f('0x36')]);_0x1bd6b8[_0xa01f('0x38')]=_[_0xa01f('0x39')](_0x1bd6b8[_0xa01f('0x34')],_0x1bd6b8[_0xa01f('0x36')]);_0x4dfc36[_0xa01f('0x3a')]=_[_0xa01f('0x39')](_0x1bd6b8[_0xa01f('0x34')],qs[_0xa01f('0x3b')](_0x3d490c[_0xa01f('0x36')]['fields']));_0x4dfc36[_0xa01f('0x3a')]=_0x4dfc36['attributes'][_0xa01f('0x4a')]?_0x4dfc36['attributes']:_0x1bd6b8[_0xa01f('0x34')];if(_0x3d490c[_0xa01f('0x36')][_0xa01f('0x46')]){_0x4dfc36['include']=[{'all':!![]}];}_0x4dfc36=_[_0xa01f('0x43')]({},_0x4dfc36,_0x3d490c[_0xa01f('0x45')]);return db[_0xa01f('0x30')][_0xa01f('0x4b')](_0x4dfc36)[_0xa01f('0x2b')](handleEntityNotFound(_0x4a5e29,null))[_0xa01f('0x2b')](respondWithResult(_0x4a5e29,null))['catch'](handleError(_0x4a5e29,null));};exports[_0xa01f('0x4c')]=function(_0x19b9b3,_0xbd5441){return db[_0xa01f('0x30')][_0xa01f('0x4c')](_0x19b9b3[_0xa01f('0x4d')],{})[_0xa01f('0x2b')](respondWithResult(_0xbd5441,0xc9))[_0xa01f('0x4e')](handleError(_0xbd5441,null));};exports['update']=function(_0x5d1a46,_0x473774){if(_0x5d1a46[_0xa01f('0x4d')]['id']){delete _0x5d1a46['body']['id'];}return db[_0xa01f('0x30')][_0xa01f('0x4b')]({'where':{'id':_0x5d1a46[_0xa01f('0x49')]['id']}})[_0xa01f('0x2b')](handleEntityNotFound(_0x473774,null))[_0xa01f('0x2b')](saveUpdates(_0x5d1a46[_0xa01f('0x4d')],null))['then'](respondWithResult(_0x473774,null))[_0xa01f('0x4e')](handleError(_0x473774,null));};exports['destroy']=function(_0x4a6c9d,_0x4f09a3){return db[_0xa01f('0x30')]['find']({'where':{'id':_0x4a6c9d[_0xa01f('0x49')]['id']}})[_0xa01f('0x2b')](handleEntityNotFound(_0x4f09a3,null))[_0xa01f('0x2b')](removeEntity(_0x4f09a3,null))['catch'](handleError(_0x4f09a3,null));};exports[_0xa01f('0x4f')]=function(_0x386a77,_0x490463){return db['VoiceQueueReport'][_0xa01f('0x4f')]()[_0xa01f('0x2b')](respondWithResult(_0x490463,null))['catch'](handleError(_0x490463,null));};exports[_0xa01f('0x50')]=function(_0x148c30,_0x5abd9c){var _0x195016={},_0xac1fee={},_0x14e093={'count':0x0,'rows':[]};_0xac1fee[_0xa01f('0x34')]=_[_0xa01f('0x37')](db[_0xa01f('0x30')][_0xa01f('0x31')]);_0xac1fee['query']=_['keys'](_0x148c30[_0xa01f('0x36')]);_0xac1fee['filters']=_[_0xa01f('0x39')](_0xac1fee[_0xa01f('0x34')],_0xac1fee['query']);_0x195016[_0xa01f('0x3a')]=_[_0xa01f('0x39')](_0xac1fee[_0xa01f('0x34')],qs[_0xa01f('0x3b')](_0x148c30[_0xa01f('0x36')]['fields']));_0x195016[_0xa01f('0x3a')]=_0x195016[_0xa01f('0x3a')][_0xa01f('0x4a')]?_0x195016[_0xa01f('0x3a')]:_0xac1fee[_0xa01f('0x34')];if(!_0x148c30[_0xa01f('0x36')][_0xa01f('0x3c')](_0xa01f('0x3d'))){_0x195016[_0xa01f('0x23')]=qs[_0xa01f('0x23')](_0x148c30[_0xa01f('0x36')][_0xa01f('0x23')]);_0x195016[_0xa01f('0x21')]=qs[_0xa01f('0x21')](_0x148c30['query'][_0xa01f('0x21')]);}_0x195016['order']=qs[_0xa01f('0x3f')](_0x148c30[_0xa01f('0x36')][_0xa01f('0x3f')]);_0x195016[_0xa01f('0x42')]=qs['filters'](_[_0xa01f('0x40')](_0x148c30[_0xa01f('0x36')],_0xac1fee['filters']));if(_0x148c30[_0xa01f('0x36')][_0xa01f('0x41')]){_0x195016[_0xa01f('0x42')]=_['merge'](_0x195016[_0xa01f('0x42')],{'$or':_[_0xa01f('0x35')](_0x195016[_0xa01f('0x3a')],function(_0x9cff4f){var _0x4caaf1={};_0x4caaf1[_0x9cff4f]={'$like':'%'+_0x148c30[_0xa01f('0x36')][_0xa01f('0x41')]+'%'};return _0x4caaf1;})});}_0x195016=_[_0xa01f('0x43')]({},_0x195016,_0x148c30[_0xa01f('0x45')]);var _0x4fe89a={'where':_0x195016[_0xa01f('0x42')]};return db['VoiceQueueReport'][_0xa01f('0x24')](_0x4fe89a)[_0xa01f('0x2b')](function(_0x5cedf4){_0x14e093['count']=_0x5cedf4;if(_0x148c30[_0xa01f('0x36')]['includeAll']){_0x195016[_0xa01f('0x51')]=[{'all':!![]}];}return db['VoiceQueueReport']['findAll'](_0x195016);})[_0xa01f('0x2b')](function(_0x1635cf){_0x14e093[_0xa01f('0x52')]=_0x1635cf;return _0x14e093;})['then'](respondWithFilteredResult(_0x5abd9c,_0x195016,_0xa01f('0x50')))[_0xa01f('0x4e')](handleError(_0x5abd9c,null,_0xa01f('0x50')));}; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.events.js b/server/api/voiceQueueReport/voiceQueueReport.events.js new file mode 100644 index 0000000..5dc0093 --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5cff=['hasOwnProperty','hook','events','../../mysqldb','setMaxListeners','save','emit'];(function(_0x181678,_0x5553ec){var _0xa17ff4=function(_0x5a44e1){while(--_0x5a44e1){_0x181678['push'](_0x181678['shift']());}};_0xa17ff4(++_0x5553ec);}(_0x5cff,0x87));var _0xf5cf=function(_0x337377,_0x241b24){_0x337377=_0x337377-0x0;var _0x1c1c32=_0x5cff[_0x337377];return _0x1c1c32;};'use strict';var EventEmitter=require(_0xf5cf('0x0'));var VoiceQueueReport=require(_0xf5cf('0x1'))['db']['VoiceQueueReport'];var VoiceQueueReportEvents=new EventEmitter();VoiceQueueReportEvents[_0xf5cf('0x2')](0x0);var events={'afterCreate':_0xf5cf('0x3'),'afterUpdate':'update','afterDestroy':'remove'};function emitEvent(_0x13c528){return function(_0x3a6058,_0x1875d1,_0x4f63b5){VoiceQueueReportEvents[_0xf5cf('0x4')](_0x13c528+':'+_0x3a6058['id'],_0x3a6058);VoiceQueueReportEvents[_0xf5cf('0x4')](_0x13c528,_0x3a6058);_0x4f63b5(null);};}for(var e in events){if(events[_0xf5cf('0x5')](e)){var event=events[e];VoiceQueueReport[_0xf5cf('0x6')](e,emitEvent(event));}}module['exports']=VoiceQueueReportEvents; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.model.js b/server/api/voiceQueueReport/voiceQueueReport.model.js new file mode 100644 index 0000000..c998c62 --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4983=['exports','VoiceQueueReport','report_queue','calleridnum','lodash','util','../../config/logger','api','moment','request-promise','rimraf','../../config/environment'];(function(_0x41db9c,_0x1d3bb4){var _0x3de4bf=function(_0x4f4776){while(--_0x4f4776){_0x41db9c['push'](_0x41db9c['shift']());}};_0x3de4bf(++_0x1d3bb4);}(_0x4983,0xb8));var _0x3498=function(_0x289b3d,_0x45d444){_0x289b3d=_0x289b3d-0x0;var _0x599c7a=_0x4983[_0x289b3d];return _0x599c7a;};'use strict';var _=require(_0x3498('0x0'));var util=require(_0x3498('0x1'));var logger=require(_0x3498('0x2'))(_0x3498('0x3'));var moment=require(_0x3498('0x4'));var BPromise=require('bluebird');var rp=require(_0x3498('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x3498('0x6'));var config=require(_0x3498('0x7'));var attributes=require('./voiceQueueReport.attributes');module[_0x3498('0x8')]=function(_0x162b54,_0x16d504){return _0x162b54['define'](_0x3498('0x9'),attributes,{'tableName':_0x3498('0xa'),'paranoid':![],'indexes':[{'fields':['uniqueid']},{'fields':[_0x3498('0xb')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.rpc.js b/server/api/voiceQueueReport/voiceQueueReport.rpc.js new file mode 100644 index 0000000..14ade4b --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd963=['client','http','redis','defaults','socket.io-emitter','./voiceQueueReport.socket','register','request','then','info','request\x20sent','debug','stringify','error','VoiceQueueReport,\x20%s,\x20%s','message','GetVoiceQueueReport','VoiceQueueReport','options','raw','where','attributes','map','include','model','body','CreateVoiceQueueReport','UpdateVoiceQueueReport','limit','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise'];(function(_0x134b6e,_0x21b5ca){var _0x2229a9=function(_0x3fd3f5){while(--_0x3fd3f5){_0x134b6e['push'](_0x134b6e['shift']());}};_0x2229a9(++_0x21b5ca);}(_0xd963,0x93));var _0x3d96=function(_0x592cea,_0x4e72f1){_0x592cea=_0x592cea-0x0;var _0x1e9cc6=_0xd963[_0x592cea];return _0x1e9cc6;};'use strict';var _=require(_0x3d96('0x0'));var util=require(_0x3d96('0x1'));var moment=require(_0x3d96('0x2'));var BPromise=require(_0x3d96('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3d96('0x4'))['db'];var utils=require(_0x3d96('0x5'));var logger=require('../../config/logger')(_0x3d96('0x6'));var config=require(_0x3d96('0x7'));var jayson=require(_0x3d96('0x8'));var client=jayson[_0x3d96('0x9')][_0x3d96('0xa')]({'port':0x232a});config[_0x3d96('0xb')]=_[_0x3d96('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x3d96('0xd'))(new Redis(config[_0x3d96('0xb')]));require(_0x3d96('0xe'))[_0x3d96('0xf')](socket);function respondWithRpcPromise(_0x50c813,_0x433cb3,_0x4a3341){return new BPromise(function(_0x9945ce,_0x29b4ff){return client[_0x3d96('0x10')](_0x50c813,_0x4a3341)[_0x3d96('0x11')](function(_0x620b40){logger[_0x3d96('0x12')]('VoiceQueueReport,\x20%s,\x20%s',_0x433cb3,_0x3d96('0x13'));logger[_0x3d96('0x14')]('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0x433cb3,_0x3d96('0x13'),JSON[_0x3d96('0x15')](_0x620b40));if(_0x620b40[_0x3d96('0x16')]){if(_0x620b40[_0x3d96('0x16')]['code']===0x1f4){logger['error'](_0x3d96('0x17'),_0x433cb3,_0x620b40[_0x3d96('0x16')][_0x3d96('0x18')]);return _0x29b4ff(_0x620b40[_0x3d96('0x16')]['message']);}logger[_0x3d96('0x16')](_0x3d96('0x17'),_0x433cb3,_0x620b40[_0x3d96('0x16')]['message']);return _0x9945ce(_0x620b40[_0x3d96('0x16')]['message']);}else{logger[_0x3d96('0x12')]('VoiceQueueReport,\x20%s,\x20%s',_0x433cb3,_0x3d96('0x13'));_0x9945ce(_0x620b40['result'][_0x3d96('0x18')]);}})['catch'](function(_0x50815b){logger['error'](_0x3d96('0x17'),_0x433cb3,_0x50815b);_0x29b4ff(_0x50815b);});});}exports[_0x3d96('0x19')]=function(_0x56e0e1){var _0x367768=this;return new Promise(function(_0x2cbba3,_0x376848){return db[_0x3d96('0x1a')]['findAll']({'raw':_0x56e0e1[_0x3d96('0x1b')]?_0x56e0e1[_0x3d96('0x1b')][_0x3d96('0x1c')]===undefined?!![]:![]:!![],'where':_0x56e0e1[_0x3d96('0x1b')]?_0x56e0e1[_0x3d96('0x1b')][_0x3d96('0x1d')]||null:null,'attributes':_0x56e0e1['options']?_0x56e0e1[_0x3d96('0x1b')][_0x3d96('0x1e')]||null:null,'limit':_0x56e0e1[_0x3d96('0x1b')]?_0x56e0e1[_0x3d96('0x1b')]['limit']||null:null,'include':_0x56e0e1[_0x3d96('0x1b')]?_0x56e0e1[_0x3d96('0x1b')]['include']?_[_0x3d96('0x1f')](_0x56e0e1[_0x3d96('0x1b')][_0x3d96('0x20')],function(_0x2ab2b0){return{'model':db[_0x2ab2b0['model']],'as':_0x2ab2b0['as'],'attributes':_0x2ab2b0['attributes'],'include':_0x2ab2b0['include']?_[_0x3d96('0x1f')](_0x2ab2b0['include'],function(_0x368eec){return{'model':db[_0x368eec[_0x3d96('0x21')]],'as':_0x368eec['as'],'attributes':_0x368eec['attributes'],'include':_0x368eec[_0x3d96('0x20')]?_[_0x3d96('0x1f')](_0x368eec[_0x3d96('0x20')],function(_0x2ff725){return{'model':db[_0x2ff725[_0x3d96('0x21')]],'as':_0x2ff725['as'],'attributes':_0x2ff725[_0x3d96('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x3d96('0x11')](function(_0x110d8f){logger[_0x3d96('0x12')](_0x3d96('0x19'),_0x56e0e1);logger[_0x3d96('0x14')](_0x3d96('0x19'),_0x56e0e1,JSON[_0x3d96('0x15')](_0x110d8f));_0x2cbba3(_0x110d8f);})['catch'](function(_0x133cb6){logger[_0x3d96('0x16')](_0x3d96('0x19'),_0x133cb6[_0x3d96('0x18')],_0x56e0e1);_0x376848(_0x367768[_0x3d96('0x16')](0x1f4,_0x133cb6[_0x3d96('0x18')]));});});};exports['CreateVoiceQueueReport']=function(_0x4a82c8){var _0x400829=this;return new Promise(function(_0xbf5b0b,_0xff22c8){return db[_0x3d96('0x1a')]['create'](_0x4a82c8[_0x3d96('0x22')],{'raw':_0x4a82c8[_0x3d96('0x1b')]?_0x4a82c8['options']['raw']===undefined?!![]:![]:!![]})[_0x3d96('0x11')](function(_0x5c9cf4){logger[_0x3d96('0x12')](_0x3d96('0x23'),_0x4a82c8);logger[_0x3d96('0x14')](_0x3d96('0x23'),_0x4a82c8,JSON[_0x3d96('0x15')](_0x5c9cf4));_0xbf5b0b(_0x5c9cf4);})['catch'](function(_0x15d7c5){logger[_0x3d96('0x16')]('CreateVoiceQueueReport',_0x15d7c5['message'],_0x4a82c8);_0xff22c8(_0x400829[_0x3d96('0x16')](0x1f4,_0x15d7c5[_0x3d96('0x18')]));});});};exports[_0x3d96('0x24')]=function(_0x5a925c){var _0x4c30e4=this;return new Promise(function(_0x4e041b,_0xf08fec){return db[_0x3d96('0x1a')]['update'](_0x5a925c['body'],{'raw':_0x5a925c[_0x3d96('0x1b')]?_0x5a925c[_0x3d96('0x1b')][_0x3d96('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5a925c[_0x3d96('0x1b')]?_0x5a925c[_0x3d96('0x1b')]['where']||null:null,'attributes':_0x5a925c['options']?_0x5a925c['options'][_0x3d96('0x1e')]||null:null,'limit':_0x5a925c['options']?_0x5a925c['options'][_0x3d96('0x25')]||null:null})[_0x3d96('0x11')](function(_0xfac65c){logger['info'](_0x3d96('0x24'),_0x5a925c);logger[_0x3d96('0x14')](_0x3d96('0x24'),_0x5a925c,JSON[_0x3d96('0x15')](_0xfac65c));_0x4e041b(_0xfac65c);})[_0x3d96('0x26')](function(_0x1eecc4){logger[_0x3d96('0x16')](_0x3d96('0x24'),_0x1eecc4[_0x3d96('0x18')],_0x5a925c);_0xf08fec(_0x4c30e4[_0x3d96('0x16')](0x1f4,_0x1eecc4['message']));});});}; \ No newline at end of file diff --git a/server/api/voiceQueueReport/voiceQueueReport.socket.js b/server/api/voiceQueueReport/voiceQueueReport.socket.js new file mode 100644 index 0000000..87cb518 --- /dev/null +++ b/server/api/voiceQueueReport/voiceQueueReport.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7bb8=['update','emit','removeListener','voiceQueueReport:','save','remove'];(function(_0x140c01,_0x1063b1){var _0x3ebcc0=function(_0x2dfd07){while(--_0x2dfd07){_0x140c01['push'](_0x140c01['shift']());}};_0x3ebcc0(++_0x1063b1);}(_0x7bb8,0xe8));var _0x87bb=function(_0x18030d,_0x31f551){_0x18030d=_0x18030d-0x0;var _0x261e56=_0x7bb8[_0x18030d];return _0x261e56;};'use strict';var VoiceQueueReportEvents=require('./voiceQueueReport.events');var events=[_0x87bb('0x0'),_0x87bb('0x1'),_0x87bb('0x2')];function createListener(_0x2a8157,_0x57cf25){return function(_0x26d1f5){_0x57cf25[_0x87bb('0x3')](_0x2a8157,_0x26d1f5);};}function removeListener(_0x5c03d3,_0xd7ed75){return function(){VoiceQueueReportEvents[_0x87bb('0x4')](_0x5c03d3,_0xd7ed75);};}exports['register']=function(_0x38b56d){for(var _0x46622e=0x0,_0x5e6e14=events['length'];_0x46622e<_0x5e6e14;_0x46622e++){var _0x317bba=events[_0x46622e];var _0x11d858=createListener(_0x87bb('0x5')+_0x317bba,_0x38b56d);VoiceQueueReportEvents['on'](_0x317bba,_0x11d858);}}; \ No newline at end of file diff --git a/server/api/voiceQueuesLog/index.js b/server/api/voiceQueuesLog/index.js new file mode 100644 index 0000000..6ab6264 --- /dev/null +++ b/server/api/voiceQueuesLog/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd200=['put','update','delete','destroy','exports','multer','util','path','connect-timeout','Router','fs-extra','../../components/interaction/service','./voiceQueuesLog.controller','get','isAuthenticated','index','/:id','show','post','create'];(function(_0x1d1ed7,_0x461116){var _0x52a28e=function(_0x463754){while(--_0x463754){_0x1d1ed7['push'](_0x1d1ed7['shift']());}};_0x52a28e(++_0x461116);}(_0xd200,0x7d));var _0x0d20=function(_0x3b0731,_0xcf9925){_0x3b0731=_0x3b0731-0x0;var _0x4204d7=_0xd200[_0x3b0731];return _0x4204d7;};'use strict';var multer=require(_0x0d20('0x0'));var util=require(_0x0d20('0x1'));var path=require(_0x0d20('0x2'));var timeout=require(_0x0d20('0x3'));var express=require('express');var router=express[_0x0d20('0x4')]();var fs_extra=require(_0x0d20('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x0d20('0x6'));var config=require('../../config/environment');var controller=require(_0x0d20('0x7'));router[_0x0d20('0x8')]('/',auth[_0x0d20('0x9')](),controller[_0x0d20('0xa')]);router[_0x0d20('0x8')](_0x0d20('0xb'),auth['isAuthenticated'](),controller[_0x0d20('0xc')]);router[_0x0d20('0xd')]('/',auth[_0x0d20('0x9')](),controller[_0x0d20('0xe')]);router[_0x0d20('0xf')](_0x0d20('0xb'),auth[_0x0d20('0x9')](),controller[_0x0d20('0x10')]);router[_0x0d20('0x11')](_0x0d20('0xb'),auth[_0x0d20('0x9')](),controller[_0x0d20('0x12')]);module[_0x0d20('0x13')]=router; \ No newline at end of file diff --git a/server/api/voiceQueuesLog/voiceQueuesLog.attributes.js b/server/api/voiceQueuesLog/voiceQueuesLog.attributes.js new file mode 100644 index 0000000..c6a26b9 --- /dev/null +++ b/server/api/voiceQueuesLog/voiceQueuesLog.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xec1a=['CURRENT_TIMESTAMP\x20ON\x20UPDATE\x20CURRENT_TIMESTAMP','sequelize','exports','STRING','DATE','literal'];(function(_0x40fb97,_0x56d0f1){var _0x3aaecc=function(_0x10c28a){while(--_0x10c28a){_0x40fb97['push'](_0x40fb97['shift']());}};_0x3aaecc(++_0x56d0f1);}(_0xec1a,0x18d));var _0xaec1=function(_0x1cac97,_0x14901b){_0x1cac97=_0x1cac97-0x0;var _0xc47a1=_0xec1a[_0x1cac97];return _0xc47a1;};'use strict';var Sequelize=require(_0xaec1('0x0'));var moment=require('moment');module[_0xaec1('0x1')]={'time':{'type':Sequelize[_0xaec1('0x2')]},'callid':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'queuename':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'agent':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'event':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data1':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data2':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data3':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data4':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'data5':{'type':Sequelize[_0xaec1('0x2')],'allowNull':![],'defaultValue':''},'dtm':{'type':Sequelize[_0xaec1('0x3')],'allowNull':![],'defaultValue':Sequelize[_0xaec1('0x4')](_0xaec1('0x5'))}}; \ No newline at end of file diff --git a/server/api/voiceQueuesLog/voiceQueuesLog.controller.js b/server/api/voiceQueuesLog/voiceQueuesLog.controller.js new file mode 100644 index 0000000..221c19f --- /dev/null +++ b/server/api/voiceQueuesLog/voiceQueuesLog.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0472=['show','rawAttributes','include','create','body','update','params','destroy','find','eml-format','zip-dir','fast-json-patch','moment','mustache','to-csv','ejs','fs-extra','squel','crypto','desk.js','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','undefined','limit','count','offset','set','apply','save','error','stack','name','send','index','map','fieldName','type','query','keys','filters','model','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VoiceQueuesLog','then','includeAll','findAll','catch'];(function(_0x48be61,_0x204c04){var _0x55fcd9=function(_0x5a9c6b){while(--_0x5a9c6b){_0x48be61['push'](_0x48be61['shift']());}};_0x55fcd9(++_0x204c04);}(_0x0472,0x1a1));var _0x2047=function(_0x517f19,_0x164202){_0x517f19=_0x517f19-0x0;var _0x5acce3=_0x0472[_0x517f19];return _0x5acce3;};'use strict';var emlformat=require(_0x2047('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x2047('0x1'));var jsonpatch=require(_0x2047('0x2'));var rp=require('request-promise');var moment=require(_0x2047('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x2047('0x4'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x2047('0x5'));var ejs=require(_0x2047('0x6'));var fs=require('fs');var fs_extra=require(_0x2047('0x7'));var _=require('lodash');var squel=require(_0x2047('0x8'));var crypto=require(_0x2047('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x2047('0xa'));var toCsv=require(_0x2047('0x5'));var querystring=require('querystring');var Papa=require(_0x2047('0xb'));var Redis=require('ioredis');var authService=require(_0x2047('0xc'));var qs=require('../../components/parsers/qs');var as=require(_0x2047('0xd'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x2047('0xe'))('api');var utils=require(_0x2047('0xf'));var config=require(_0x2047('0x10'));var licenseUtil=require(_0x2047('0x11'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x302032,_0x21f0d7){_0x21f0d7=_0x21f0d7||0xcc;return function(_0x2bced7){if(_0x2bced7){return _0x302032[_0x2047('0x12')](_0x21f0d7);}return _0x302032[_0x2047('0x13')](_0x21f0d7)[_0x2047('0x14')]();};}function respondWithResult(_0x91aa02,_0x9d1f4d){_0x9d1f4d=_0x9d1f4d||0xc8;return function(_0x5be194){if(_0x5be194){return _0x91aa02[_0x2047('0x13')](_0x9d1f4d)[_0x2047('0x15')](_0x5be194);}};}function respondWithFilteredResult(_0x40929e,_0x46d0aa){return function(_0x20a2e7){if(_0x20a2e7){var _0xe0848d=typeof _0x46d0aa['offset']===_0x2047('0x16')&&typeof _0x46d0aa[_0x2047('0x17')]==='undefined';var _0x4b8535=_0x20a2e7[_0x2047('0x18')];var _0x155292=_0xe0848d?0x0:_0x46d0aa[_0x2047('0x19')];var _0x2ca61a=_0xe0848d?_0x20a2e7[_0x2047('0x18')]:_0x46d0aa[_0x2047('0x19')]+_0x46d0aa[_0x2047('0x17')];var _0x4810f9;if(_0x2ca61a>=_0x4b8535){_0x2ca61a=_0x4b8535;_0x4810f9=0xc8;}else{_0x4810f9=0xce;}_0x40929e['status'](_0x4810f9);return _0x40929e[_0x2047('0x1a')]('Content-Range',_0x155292+'-'+_0x2ca61a+'/'+_0x4b8535)[_0x2047('0x15')](_0x20a2e7);}return null;};}function patchUpdates(_0x16d90e){return function(_0x22dc0d){try{jsonpatch[_0x2047('0x1b')](_0x22dc0d,_0x16d90e,!![]);}catch(_0x41def3){return BPromise['reject'](_0x41def3);}return _0x22dc0d[_0x2047('0x1c')]();};}function saveUpdates(_0x49f023,_0x33cee4){return function(_0x301105){if(_0x301105){return _0x301105['update'](_0x49f023)['then'](function(_0x318391){return _0x318391;});}return null;};}function removeEntity(_0x20bf28,_0x194a9b){return function(_0x400272){if(_0x400272){return _0x400272['destroy']()['then'](function(){_0x20bf28[_0x2047('0x13')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3bef7a,_0x45f59a){return function(_0x22b780){if(!_0x22b780){_0x3bef7a['sendStatus'](0x194);}return _0x22b780;};}function handleError(_0x46b32b,_0x2df27e){_0x2df27e=_0x2df27e||0x1f4;return function(_0x3e1244){logger[_0x2047('0x1d')](_0x3e1244[_0x2047('0x1e')]);if(_0x3e1244[_0x2047('0x1f')]){delete _0x3e1244[_0x2047('0x1f')];}_0x46b32b[_0x2047('0x13')](_0x2df27e)[_0x2047('0x20')](_0x3e1244);};}exports[_0x2047('0x21')]=function(_0x5e3e38,_0x3b06be){var _0x42113e={},_0x4d1f0b={},_0x53653c={'count':0x0,'rows':[]};var _0x20dc5a=_[_0x2047('0x22')](db['VoiceQueuesLog']['rawAttributes'],function(_0x10317f){return{'name':_0x10317f[_0x2047('0x23')],'type':_0x10317f[_0x2047('0x24')]['key']};});_0x4d1f0b['model']=_[_0x2047('0x22')](_0x20dc5a,_0x2047('0x1f'));_0x4d1f0b[_0x2047('0x25')]=_[_0x2047('0x26')](_0x5e3e38['query']);_0x4d1f0b[_0x2047('0x27')]=_['intersection'](_0x4d1f0b[_0x2047('0x28')],_0x4d1f0b['query']);_0x42113e[_0x2047('0x29')]=_[_0x2047('0x2a')](_0x4d1f0b[_0x2047('0x28')],qs[_0x2047('0x2b')](_0x5e3e38['query'][_0x2047('0x2b')]));_0x42113e[_0x2047('0x29')]=_0x42113e['attributes'][_0x2047('0x2c')]?_0x42113e[_0x2047('0x29')]:_0x4d1f0b['model'];if(!_0x5e3e38[_0x2047('0x25')]['hasOwnProperty'](_0x2047('0x2d'))){_0x42113e[_0x2047('0x17')]=qs[_0x2047('0x17')](_0x5e3e38['query'][_0x2047('0x17')]);_0x42113e[_0x2047('0x19')]=qs['offset'](_0x5e3e38[_0x2047('0x25')][_0x2047('0x19')]);}_0x42113e[_0x2047('0x2e')]=qs[_0x2047('0x2f')](_0x5e3e38['query'][_0x2047('0x2f')]);_0x42113e[_0x2047('0x30')]=qs[_0x2047('0x27')](_[_0x2047('0x31')](_0x5e3e38[_0x2047('0x25')],_0x4d1f0b[_0x2047('0x27')]),_0x20dc5a);if(_0x5e3e38[_0x2047('0x25')][_0x2047('0x32')]){_0x42113e[_0x2047('0x30')]=_[_0x2047('0x33')](_0x42113e[_0x2047('0x30')],{'$or':_[_0x2047('0x22')](_0x20dc5a,function(_0x2b870b){if(_0x2b870b[_0x2047('0x24')]!==_0x2047('0x34')){var _0x2422e2={};_0x2422e2[_0x2b870b[_0x2047('0x1f')]]={'$like':'%'+_0x5e3e38['query'][_0x2047('0x32')]+'%'};return _0x2422e2;}})});}_0x42113e=_[_0x2047('0x33')]({},_0x42113e,_0x5e3e38[_0x2047('0x35')]);var _0x387b97={'where':_0x42113e['where']};return db[_0x2047('0x36')][_0x2047('0x18')](_0x387b97)[_0x2047('0x37')](function(_0x2d77ba){_0x53653c[_0x2047('0x18')]=_0x2d77ba;if(_0x5e3e38[_0x2047('0x25')][_0x2047('0x38')]){_0x42113e['include']=[{'all':!![]}];}return db[_0x2047('0x36')][_0x2047('0x39')](_0x42113e);})['then'](function(_0x1c2639){_0x53653c['rows']=_0x1c2639;return _0x53653c;})[_0x2047('0x37')](respondWithFilteredResult(_0x3b06be,_0x42113e))[_0x2047('0x3a')](handleError(_0x3b06be,null));};exports[_0x2047('0x3b')]=function(_0x555c65,_0x21a1f7){var _0x2cbbaf={'raw':!![],'where':{'id':_0x555c65['params']['id']}},_0x110205={};_0x110205[_0x2047('0x28')]=_[_0x2047('0x26')](db['VoiceQueuesLog'][_0x2047('0x3c')]);_0x110205[_0x2047('0x25')]=_['keys'](_0x555c65[_0x2047('0x25')]);_0x110205[_0x2047('0x27')]=_[_0x2047('0x2a')](_0x110205[_0x2047('0x28')],_0x110205['query']);_0x2cbbaf[_0x2047('0x29')]=_['intersection'](_0x110205[_0x2047('0x28')],qs[_0x2047('0x2b')](_0x555c65['query'][_0x2047('0x2b')]));_0x2cbbaf['attributes']=_0x2cbbaf[_0x2047('0x29')][_0x2047('0x2c')]?_0x2cbbaf[_0x2047('0x29')]:_0x110205[_0x2047('0x28')];if(_0x555c65[_0x2047('0x25')][_0x2047('0x38')]){_0x2cbbaf[_0x2047('0x3d')]=[{'all':!![]}];}_0x2cbbaf=_[_0x2047('0x33')]({},_0x2cbbaf,_0x555c65[_0x2047('0x35')]);return db[_0x2047('0x36')]['find'](_0x2cbbaf)['then'](handleEntityNotFound(_0x21a1f7,null))[_0x2047('0x37')](respondWithResult(_0x21a1f7,null))['catch'](handleError(_0x21a1f7,null));};exports[_0x2047('0x3e')]=function(_0x3d9099,_0x325b00){return db[_0x2047('0x36')][_0x2047('0x3e')](_0x3d9099[_0x2047('0x3f')],{})['then'](respondWithResult(_0x325b00,0xc9))['catch'](handleError(_0x325b00,null));};exports[_0x2047('0x40')]=function(_0x2891f5,_0x2bdf3c){if(_0x2891f5[_0x2047('0x3f')]['id']){delete _0x2891f5[_0x2047('0x3f')]['id'];}return db[_0x2047('0x36')]['find']({'where':{'id':_0x2891f5[_0x2047('0x41')]['id']}})[_0x2047('0x37')](handleEntityNotFound(_0x2bdf3c,null))[_0x2047('0x37')](saveUpdates(_0x2891f5[_0x2047('0x3f')],null))[_0x2047('0x37')](respondWithResult(_0x2bdf3c,null))[_0x2047('0x3a')](handleError(_0x2bdf3c,null));};exports[_0x2047('0x42')]=function(_0x14030d,_0x4d0927){return db[_0x2047('0x36')][_0x2047('0x43')]({'where':{'id':_0x14030d['params']['id']}})[_0x2047('0x37')](handleEntityNotFound(_0x4d0927,null))[_0x2047('0x37')](removeEntity(_0x4d0927,null))[_0x2047('0x3a')](handleError(_0x4d0927,null));}; \ No newline at end of file diff --git a/server/api/voiceQueuesLog/voiceQueuesLog.model.js b/server/api/voiceQueuesLog/voiceQueuesLog.model.js new file mode 100644 index 0000000..a51a669 --- /dev/null +++ b/server/api/voiceQueuesLog/voiceQueuesLog.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcaa7=['dtm','lodash','util','api','moment','bluebird','request-promise','rimraf','./voiceQueuesLog.attributes','exports','define','VoiceQueuesLog','event_dtm','event'];(function(_0x1574a1,_0x22b83){var _0x53dd85=function(_0x451cd9){while(--_0x451cd9){_0x1574a1['push'](_0x1574a1['shift']());}};_0x53dd85(++_0x22b83);}(_0xcaa7,0x1a5));var _0x7caa=function(_0x1f2b9e,_0xa7c8de){_0x1f2b9e=_0x1f2b9e-0x0;var _0x1b4bca=_0xcaa7[_0x1f2b9e];return _0x1b4bca;};'use strict';var _=require(_0x7caa('0x0'));var util=require(_0x7caa('0x1'));var logger=require('../../config/logger')(_0x7caa('0x2'));var moment=require(_0x7caa('0x3'));var BPromise=require(_0x7caa('0x4'));var rp=require(_0x7caa('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0x7caa('0x6'));var config=require('../../config/environment');var attributes=require(_0x7caa('0x7'));module[_0x7caa('0x8')]=function(_0x3900ae,_0x6ab9f3){return _0x3900ae[_0x7caa('0x9')](_0x7caa('0xa'),attributes,{'tableName':'voice_queues_log','paranoid':![],'indexes':[{'name':_0x7caa('0xb'),'fields':[_0x7caa('0xc'),_0x7caa('0xd')]}],'timestamps':![]});}; \ No newline at end of file diff --git a/server/api/voiceQueuesLog/voiceQueuesLog.rpc.js b/server/api/voiceQueuesLog/voiceQueuesLog.rpc.js new file mode 100644 index 0000000..1b2460a --- /dev/null +++ b/server/api/voiceQueuesLog/voiceQueuesLog.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0ade=['../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','VoiceQueuesLog,\x20%s,\x20%s','request\x20sent','VoiceQueuesLog,\x20%s,\x20%s,\x20%s','stringify','error','result','message','catch','lodash','util','bluebird','randomstring','ioredis'];(function(_0x41ce34,_0x22932a){var _0x580c63=function(_0x46a806){while(--_0x46a806){_0x41ce34['push'](_0x41ce34['shift']());}};_0x580c63(++_0x22932a);}(_0x0ade,0xab));var _0xe0ad=function(_0x2b4d00,_0x57acd5){_0x2b4d00=_0x2b4d00-0x0;var _0x52a923=_0x0ade[_0x2b4d00];return _0x52a923;};'use strict';var _=require(_0xe0ad('0x0'));var util=require(_0xe0ad('0x1'));var moment=require('moment');var BPromise=require(_0xe0ad('0x2'));var rs=require(_0xe0ad('0x3'));var fs=require('fs');var Redis=require(_0xe0ad('0x4'));var db=require(_0xe0ad('0x5'))['db'];var utils=require(_0xe0ad('0x6'));var logger=require(_0xe0ad('0x7'))('rpc');var config=require(_0xe0ad('0x8'));var jayson=require(_0xe0ad('0x9'));var client=jayson[_0xe0ad('0xa')][_0xe0ad('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4426eb,_0x18828e,_0x5b21f7){return new BPromise(function(_0x448d,_0x1add4e){return client['request'](_0x4426eb,_0x5b21f7)[_0xe0ad('0xc')](function(_0x1bbe93){logger[_0xe0ad('0xd')](_0xe0ad('0xe'),_0x18828e,_0xe0ad('0xf'));logger['debug'](_0xe0ad('0x10'),_0x18828e,_0xe0ad('0xf'),JSON[_0xe0ad('0x11')](_0x1bbe93));if(_0x1bbe93['error']){if(_0x1bbe93['error']['code']===0x1f4){logger[_0xe0ad('0x12')]('VoiceQueuesLog,\x20%s,\x20%s',_0x18828e,_0x1bbe93[_0xe0ad('0x12')]['message']);return _0x1add4e(_0x1bbe93[_0xe0ad('0x12')]['message']);}logger[_0xe0ad('0x12')](_0xe0ad('0xe'),_0x18828e,_0x1bbe93[_0xe0ad('0x12')]['message']);return _0x448d(_0x1bbe93['error']['message']);}else{logger['info'](_0xe0ad('0xe'),_0x18828e,_0xe0ad('0xf'));_0x448d(_0x1bbe93[_0xe0ad('0x13')][_0xe0ad('0x14')]);}})[_0xe0ad('0x15')](function(_0x2f71a3){logger[_0xe0ad('0x12')](_0xe0ad('0xe'),_0x18828e,_0x2f71a3);_0x1add4e(_0x2f71a3);});});} \ No newline at end of file diff --git a/server/api/voiceRecording/index.js b/server/api/voiceRecording/index.js new file mode 100644 index 0000000..22272a0 --- /dev/null +++ b/server/api/voiceRecording/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc673=['multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','index','/describe','isAuthenticated','describe','show','/:id/download','/:id/downloads','/:id/transcribe','downloadTranscribe','post','create','runTranscribe','put','/:id','update','delete','destroy','exports'];(function(_0x2e0aa6,_0x4217cd){var _0x3efbe7=function(_0x3aa245){while(--_0x3aa245){_0x2e0aa6['push'](_0x2e0aa6['shift']());}};_0x3efbe7(++_0x4217cd);}(_0xc673,0x1b3));var _0x3c67=function(_0x26c7a1,_0x56544f){_0x26c7a1=_0x26c7a1-0x0;var _0x5e42db=_0xc673[_0x26c7a1];return _0x5e42db;};'use strict';var multer=require(_0x3c67('0x0'));var util=require(_0x3c67('0x1'));var path=require(_0x3c67('0x2'));var timeout=require(_0x3c67('0x3'));var express=require(_0x3c67('0x4'));var router=express[_0x3c67('0x5')]();var fs_extra=require(_0x3c67('0x6'));var auth=require(_0x3c67('0x7'));var interaction=require(_0x3c67('0x8'));var config=require(_0x3c67('0x9'));var controller=require('./voiceRecording.controller');router[_0x3c67('0xa')]('/',auth['isAuthenticated'](),controller[_0x3c67('0xb')]);router['get'](_0x3c67('0xc'),auth[_0x3c67('0xd')](),controller[_0x3c67('0xe')]);router['get']('/:id',auth['isAuthenticated'](),controller[_0x3c67('0xf')]);router['get'](_0x3c67('0x10'),auth[_0x3c67('0xd')](),controller['download']);router['get'](_0x3c67('0x11'),controller['downloads']);router[_0x3c67('0xa')](_0x3c67('0x12'),auth[_0x3c67('0xd')](),controller[_0x3c67('0x13')]);router[_0x3c67('0x14')]('/',auth[_0x3c67('0xd')](),controller[_0x3c67('0x15')]);router['post'](_0x3c67('0x12'),auth[_0x3c67('0xd')](),controller[_0x3c67('0x16')]);router[_0x3c67('0x17')](_0x3c67('0x18'),auth[_0x3c67('0xd')](),controller[_0x3c67('0x19')]);router[_0x3c67('0x1a')](_0x3c67('0x18'),auth['isAuthenticated'](),controller[_0x3c67('0x1b')]);module[_0x3c67('0x1c')]=router; \ No newline at end of file diff --git a/server/api/voiceRecording/voiceRecording.attributes.js b/server/api/voiceRecording/voiceRecording.attributes.js new file mode 100644 index 0000000..f94c04b --- /dev/null +++ b/server/api/voiceRecording/voiceRecording.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['DATE','updatedAt','toString','sequelize','moment','path','getDataValue','extname','value','STRING','setDataValue','channel','TEXT','NEW','FLOAT','BOOLEAN','format','MM-DD-YYYY\x20HH:mm'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0xa9e0,0x123));var _0x0a9e=function(_0x220dbb,_0x99328d){_0x220dbb=_0x220dbb-0x0;var _0x2b77de=_0xa9e0[_0x220dbb];return _0x2b77de;};'use strict';var Sequelize=require(_0x0a9e('0x0'));var moment=require(_0x0a9e('0x1'));var path=require(_0x0a9e('0x2'));module['exports']={'format':{'type':Sequelize['VIRTUAL'],'get':function(){return this[_0x0a9e('0x3')]('value')?path[_0x0a9e('0x4')](this[_0x0a9e('0x3')](_0x0a9e('0x5'))):undefined;}},'uniqueid':{'type':Sequelize[_0x0a9e('0x6')]},'channel':{'type':Sequelize[_0x0a9e('0x6')],'set':function(_0x57b080){if(_0x57b080){this[_0x0a9e('0x7')](_0x0a9e('0x8'),_0x57b080);this[_0x0a9e('0x7')]('membername',_0x57b080['split'](/\/|-/)[0x1]);}}},'membername':{'type':Sequelize[_0x0a9e('0x6')]},'calleridnum':{'type':Sequelize['STRING']},'calleridname':{'type':Sequelize['STRING']},'connectedlinenum':{'type':Sequelize[_0x0a9e('0x6')]},'connectedlinename':{'type':Sequelize[_0x0a9e('0x6')]},'accountcode':{'type':Sequelize[_0x0a9e('0x6')]},'context':{'type':Sequelize[_0x0a9e('0x6')]},'exten':{'type':Sequelize[_0x0a9e('0x6')]},'value':{'type':Sequelize[_0x0a9e('0x6')]},'type':{'type':Sequelize['STRING']},'rating':{'type':Sequelize['INTEGER'],'validate':{'max':0x5,'min':0x0}},'queue':{'type':Sequelize['STRING']},'userDisposition':{'type':Sequelize['STRING']},'userSecondDisposition':{'type':Sequelize[_0x0a9e('0x6')]},'userThirdDisposition':{'type':Sequelize[_0x0a9e('0x6')]},'location':{'type':Sequelize[_0x0a9e('0x9')]},'transcribeName':{'type':Sequelize[_0x0a9e('0x6')]},'transcribeStatus':{'type':Sequelize[_0x0a9e('0x6')],'defaultValue':_0x0a9e('0xa')},'fileUri':{'type':Sequelize['TEXT']},'fileText':{'type':Sequelize[_0x0a9e('0x9')]},'failureReason':{'type':Sequelize[_0x0a9e('0x9')]},'sentiment':{'type':Sequelize[_0x0a9e('0x6')]},'sPositive':{'type':Sequelize[_0x0a9e('0xb')]},'sNegative':{'type':Sequelize[_0x0a9e('0xb')]},'sNeutral':{'type':Sequelize[_0x0a9e('0xb')]},'sMixed':{'type':Sequelize['FLOAT']},'tempSentiment':{'type':Sequelize[_0x0a9e('0xc')],'defaultValue':![]},'createdAt':{'type':Sequelize['DATE'],'get':function(){return moment(this[_0x0a9e('0x3')]('createdAt'))[_0x0a9e('0xd')](_0x0a9e('0xe'))['toString']();}},'updatedAt':{'type':Sequelize[_0x0a9e('0xf')],'get':function(){return moment(this['getDataValue'](_0x0a9e('0x10')))[_0x0a9e('0xd')](_0x0a9e('0xe'))[_0x0a9e('0x11')]();}}}; \ No newline at end of file diff --git a/server/api/voiceRecording/voiceRecording.controller.js b/server/api/voiceRecording/voiceRecording.controller.js new file mode 100644 index 0000000..c0faeec --- /dev/null +++ b/server/api/voiceRecording/voiceRecording.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7439=['findOne','Voice\x20Recording\x20not\x20found','transcribe','transcribeAccountId','transcribeRegion','Transcribe\x20not\x20configured','sentimentRegion','language','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','Cloud\x20Provider\x20not\x20available','data2','Name','[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20not\x20available','NEW','data1','[RUNTRANSCRIPT][%d]\x20Transcript\x20action\x20already\x20requested','IN_PROGRESS','tempSentiment','runSentiment','writeFile','downloadTranscribe','fileText','root','/server/files/transcribes/transcribe_','.txt','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','aws-sdk','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','apply','reject','save','then','destroy','stack','name','send','index','map','VoiceRecording','rawAttributes','fieldName','type','key','model','format','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','include','findAll','catch','show','params','options','find','create','body','update','describe','download','../../components/encryptor','uniqueid','value','existsSync','decryptFile','secrets','Sequelize','ValidationError','filename','unlink','message','VoiceRecording\x20not\x20found','Not\x20found','sequelize','col','$and','push','%s.cypher','recording','isNil','Entity\x20not\x20found','cancellazione\x20fisica\x20documento\x20%s','info','File:\x20\x22','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','.cypher','createBucket','TranscribeService','startTranscriptionJob','[RUNTRANSCRIPT][%d]\x20Starting\x20voice\x20recording\x20upload\x20in\x20bucket\x20%s','basename','[RUNTRANSCRIPT][%d]\x20Voice\x20recording\x20uploaded\x20in\x20bucket\x20%s\x20(%s)','bucket','Bucket','location','Location','[RUNTRANSCRIPT][%d]\x20Transcription\x20job\x20%s\x20created','TranscriptionJob','TranscriptionJobName','transcribeName','transcribeStatus','TranscriptionJobStatus'];(function(_0x555879,_0x7e85fc){var _0xafff09=function(_0x3f65c0){while(--_0x3f65c0){_0x555879['push'](_0x555879['shift']());}};_0xafff09(++_0x7e85fc);}(_0x7439,0x1df));var _0x9743=function(_0x9aee93,_0x5d49be){_0x9aee93=_0x9aee93-0x0;var _0x8bcbbb=_0x7439[_0x9aee93];return _0x8bcbbb;};'use strict';var emlformat=require(_0x9743('0x0'));var rimraf=require(_0x9743('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x9743('0x2'));var rp=require(_0x9743('0x3'));var moment=require(_0x9743('0x4'));var BPromise=require(_0x9743('0x5'));var Mustache=require(_0x9743('0x6'));var util=require('util');var path=require(_0x9743('0x7'));var sox=require(_0x9743('0x8'));var csv=require('to-csv');var ejs=require(_0x9743('0x9'));var fs=require('fs');var fs_extra=require(_0x9743('0xa'));var _=require(_0x9743('0xb'));var squel=require(_0x9743('0xc'));var crypto=require('crypto');var jsforce=require(_0x9743('0xd'));var deskjs=require(_0x9743('0xe'));var toCsv=require(_0x9743('0xf'));var querystring=require(_0x9743('0x10'));var Papa=require(_0x9743('0x11'));var AWS=require(_0x9743('0x12'));var uuidv4=require('uuid/v4');var Redis=require(_0x9743('0x13'));var authService=require(_0x9743('0x14'));var qs=require(_0x9743('0x15'));var as=require(_0x9743('0x16'));var hardwareService=require(_0x9743('0x17'));var logger=require('../../config/logger')(_0x9743('0x18'));var utils=require(_0x9743('0x19'));var config=require(_0x9743('0x1a'));var licenseUtil=require(_0x9743('0x1b'));var db=require(_0x9743('0x1c'))['db'];function respondWithStatusCode(_0x5d7e3f,_0x10e791){_0x10e791=_0x10e791||0xcc;return function(_0x189f3e){if(_0x189f3e){return _0x5d7e3f[_0x9743('0x1d')](_0x10e791);}return _0x5d7e3f[_0x9743('0x1e')](_0x10e791)[_0x9743('0x1f')]();};}function respondWithResult(_0x4fc875,_0x26ae24){_0x26ae24=_0x26ae24||0xc8;return function(_0x3a5623){if(_0x3a5623){return _0x4fc875['status'](_0x26ae24)[_0x9743('0x20')](_0x3a5623);}};}function respondWithFilteredResult(_0x45024d,_0x5eda07){return function(_0x5e2977){if(_0x5e2977){var _0x27234c=typeof _0x5eda07[_0x9743('0x21')]==='undefined'&&typeof _0x5eda07[_0x9743('0x22')]===_0x9743('0x23');var _0x371c40=_0x5e2977[_0x9743('0x24')];var _0x5d1b00=_0x27234c?0x0:_0x5eda07[_0x9743('0x21')];var _0x42d1e6=_0x27234c?_0x5e2977['count']:_0x5eda07['offset']+_0x5eda07[_0x9743('0x22')];var _0x9ade60;if(_0x42d1e6>=_0x371c40){_0x42d1e6=_0x371c40;_0x9ade60=0xc8;}else{_0x9ade60=0xce;}_0x45024d[_0x9743('0x1e')](_0x9ade60);return _0x45024d[_0x9743('0x25')]('Content-Range',_0x5d1b00+'-'+_0x42d1e6+'/'+_0x371c40)[_0x9743('0x20')](_0x5e2977);}return null;};}function patchUpdates(_0x583cc6){return function(_0x425523){try{jsonpatch[_0x9743('0x26')](_0x425523,_0x583cc6,!![]);}catch(_0x5844d6){return BPromise[_0x9743('0x27')](_0x5844d6);}return _0x425523[_0x9743('0x28')]();};}function saveUpdates(_0x2cd681,_0x228d1a){return function(_0x10c143){if(_0x10c143){return _0x10c143['update'](_0x2cd681)[_0x9743('0x29')](function(_0x369c3d){return _0x369c3d;});}return null;};}function removeEntity(_0x5b3575,_0x546d42){return function(_0x2c6088){if(_0x2c6088){return _0x2c6088[_0x9743('0x2a')]()[_0x9743('0x29')](function(){_0x5b3575[_0x9743('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x9918af,_0x4c7ce4){return function(_0x36be9c){if(!_0x36be9c){_0x9918af[_0x9743('0x1d')](0x194);}return _0x36be9c;};}function handleError(_0x5fd04b,_0x3aa6e5){_0x3aa6e5=_0x3aa6e5||0x1f4;return function(_0x66468c){logger['error'](_0x66468c[_0x9743('0x2b')]);if(_0x66468c[_0x9743('0x2c')]){delete _0x66468c[_0x9743('0x2c')];}_0x5fd04b[_0x9743('0x1e')](_0x3aa6e5)[_0x9743('0x2d')](_0x66468c);};}exports[_0x9743('0x2e')]=function(_0x2b2ecc,_0x51c1e5){var _0x39b5f3={},_0x209d8d={},_0x55dfef={'count':0x0,'rows':[]};var _0x2f9ae1=_[_0x9743('0x2f')](db[_0x9743('0x30')][_0x9743('0x31')],function(_0x266c0c){return{'name':_0x266c0c[_0x9743('0x32')],'type':_0x266c0c[_0x9743('0x33')][_0x9743('0x34')]};});_0x209d8d[_0x9743('0x35')]=_['differenceBy'](_[_0x9743('0x2f')](_0x2f9ae1,_0x9743('0x2c')),[_0x9743('0x36')]);_0x209d8d[_0x9743('0x37')]=_[_0x9743('0x38')](_0x2b2ecc[_0x9743('0x37')]);_0x209d8d['filters']=_[_0x9743('0x39')](_0x209d8d[_0x9743('0x35')],_0x209d8d['query']);_0x39b5f3[_0x9743('0x3a')]=_['intersection'](_0x209d8d[_0x9743('0x35')],qs[_0x9743('0x3b')](_0x2b2ecc[_0x9743('0x37')][_0x9743('0x3b')]));_0x39b5f3[_0x9743('0x3a')]=_0x39b5f3['attributes'][_0x9743('0x3c')]?_0x39b5f3[_0x9743('0x3a')]:_0x209d8d[_0x9743('0x35')];if(!_0x2b2ecc['query'][_0x9743('0x3d')](_0x9743('0x3e'))){_0x39b5f3[_0x9743('0x22')]=qs[_0x9743('0x22')](_0x2b2ecc[_0x9743('0x37')][_0x9743('0x22')]);_0x39b5f3[_0x9743('0x21')]=qs[_0x9743('0x21')](_0x2b2ecc[_0x9743('0x37')]['offset']);}_0x39b5f3[_0x9743('0x3f')]=qs[_0x9743('0x40')](_0x2b2ecc[_0x9743('0x37')][_0x9743('0x40')]);_0x39b5f3[_0x9743('0x41')]=qs[_0x9743('0x42')](_[_0x9743('0x43')](_0x2b2ecc[_0x9743('0x37')],_0x209d8d[_0x9743('0x42')]),_0x2f9ae1);if(_0x2b2ecc[_0x9743('0x37')][_0x9743('0x44')]){_0x39b5f3[_0x9743('0x41')]=_[_0x9743('0x45')](_0x39b5f3[_0x9743('0x41')],{'$or':_[_0x9743('0x2f')](_0x2f9ae1,function(_0x374f8f){if(_0x374f8f[_0x9743('0x33')]!==_0x9743('0x46')){var _0x2feaf0={};_0x2feaf0[_0x374f8f[_0x9743('0x2c')]]={'$like':'%'+_0x2b2ecc['query'][_0x9743('0x44')]+'%'};return _0x2feaf0;}})});}_0x39b5f3=_[_0x9743('0x45')]({},_0x39b5f3,_0x2b2ecc['options']);var _0x568f6f={'where':_0x39b5f3[_0x9743('0x41')]};return db[_0x9743('0x30')][_0x9743('0x24')](_0x568f6f)['then'](function(_0x799b34){_0x55dfef[_0x9743('0x24')]=_0x799b34;if(_0x2b2ecc[_0x9743('0x37')]['includeAll']){_0x39b5f3[_0x9743('0x47')]=[{'all':!![]}];}return db[_0x9743('0x30')][_0x9743('0x48')](_0x39b5f3);})[_0x9743('0x29')](function(_0x137782){_0x55dfef['rows']=_0x137782;return _0x55dfef;})[_0x9743('0x29')](respondWithFilteredResult(_0x51c1e5,_0x39b5f3))[_0x9743('0x49')](handleError(_0x51c1e5,null));};exports[_0x9743('0x4a')]=function(_0x7ca18a,_0x28231b){var _0x804d84={'raw':![],'where':{'id':_0x7ca18a[_0x9743('0x4b')]['id']}},_0x523ac0={};_0x523ac0['model']=_[_0x9743('0x38')](db[_0x9743('0x30')][_0x9743('0x31')]);_0x523ac0[_0x9743('0x37')]=_['keys'](_0x7ca18a[_0x9743('0x37')]);_0x523ac0[_0x9743('0x42')]=_[_0x9743('0x39')](_0x523ac0['model'],_0x523ac0[_0x9743('0x37')]);_0x804d84[_0x9743('0x3a')]=_[_0x9743('0x39')](_0x523ac0[_0x9743('0x35')],qs[_0x9743('0x3b')](_0x7ca18a[_0x9743('0x37')]['fields']));_0x804d84[_0x9743('0x3a')]=_0x804d84['attributes'][_0x9743('0x3c')]?_0x804d84[_0x9743('0x3a')]:_0x523ac0['model'];if(_0x7ca18a[_0x9743('0x37')]['includeAll']){_0x804d84[_0x9743('0x47')]=[{'all':!![]}];}_0x804d84=_[_0x9743('0x45')]({},_0x804d84,_0x7ca18a[_0x9743('0x4c')]);return db['VoiceRecording'][_0x9743('0x4d')](_0x804d84)[_0x9743('0x29')](handleEntityNotFound(_0x28231b,null))[_0x9743('0x29')](respondWithResult(_0x28231b,null))['catch'](handleError(_0x28231b,null));};exports[_0x9743('0x4e')]=function(_0x156da1,_0x2dfa7b){return db[_0x9743('0x30')][_0x9743('0x4e')](_0x156da1[_0x9743('0x4f')],{})[_0x9743('0x29')](respondWithResult(_0x2dfa7b,0xc9))[_0x9743('0x49')](handleError(_0x2dfa7b,null));};exports[_0x9743('0x50')]=function(_0x48efcc,_0x1b8639){if(_0x48efcc[_0x9743('0x4f')]['id']){delete _0x48efcc['body']['id'];}return db[_0x9743('0x30')][_0x9743('0x4d')]({'where':{'id':_0x48efcc[_0x9743('0x4b')]['id']}})[_0x9743('0x29')](handleEntityNotFound(_0x1b8639,null))[_0x9743('0x29')](saveUpdates(_0x48efcc[_0x9743('0x4f')],null))[_0x9743('0x29')](respondWithResult(_0x1b8639,null))[_0x9743('0x49')](handleError(_0x1b8639,null));};exports[_0x9743('0x51')]=function(_0x392754,_0x10722b){return db[_0x9743('0x30')][_0x9743('0x51')]()[_0x9743('0x29')](respondWithResult(_0x10722b,null))[_0x9743('0x49')](handleError(_0x10722b,null));};exports[_0x9743('0x52')]=function(_0x5b26e2,_0x1d98b9,_0xff884b){var _0x28036d=require(_0x9743('0x53'));var _0x2b342d=![];var _0x184436={};if(_0x5b26e2[_0x9743('0x37')][_0x9743('0x33')]&&_0x5b26e2[_0x9743('0x37')][_0x9743('0x33')]==='uniqueid'){_0x184436[_0x9743('0x54')]=_0x5b26e2[_0x9743('0x4b')]['id'];}else{_0x184436['id']=_0x5b26e2[_0x9743('0x4b')]['id'];}return db['VoiceRecording'][_0x9743('0x4d')]({'where':_0x184436,'attributes':['id',_0x9743('0x55')],'raw':!![]})[_0x9743('0x29')](handleEntityNotFound(_0x1d98b9,null))[_0x9743('0x29')](function(_0x3208a1){if(_0x3208a1){var _0x597c75=_0x3208a1['value'];var _0x235a7b=util[_0x9743('0x36')]('%s.cypher',_0x597c75);if(fs[_0x9743('0x56')](_0x235a7b)){_0x2b342d=!![];return _0x28036d[_0x9743('0x57')](_0x235a7b,_0x597c75,config[_0x9743('0x58')]['recording'])[_0x9743('0x29')](function(){return _0x3208a1;});}return _0x3208a1;}})['then'](function(_0x459542){if(_0x459542){var _0x51acce=_0x459542[_0x9743('0x55')];if(!fs[_0x9743('0x56')](_0x51acce)){throw new db[(_0x9743('0x59'))][(_0x9743('0x5a'))]('VoiceRecording\x20not\x20found');}if(_0x459542[_0x9743('0x5b')]){return _0x1d98b9[_0x9743('0x52')](_0x51acce,_0x459542[_0x9743('0x5b')]+path['extname'](_0x51acce),function(){if(_0x2b342d){fs[_0x9743('0x5c')](_0x51acce);}});}else{return _0x1d98b9['download'](_0x51acce,function(_0x4a3e1f){if(_0x2b342d){fs[_0x9743('0x5c')](_0x51acce);}});}}})[_0x9743('0x49')](function(_0x439c81){if(_0x439c81[_0x9743('0x5d')]===_0x9743('0x5e')){_0x1d98b9[_0x9743('0x1e')](0x194)[_0x9743('0x2d')](_0x9743('0x5f'));}else{return handleError(_0x1d98b9,null);}});};exports['downloads']=function(_0x207a2a,_0x2aa360,_0x3afa76){var _0x3b967a=require('../../components/encryptor');var _0x51c300=![];var _0x4fe42e={'$and':[db['sequelize'][_0x9743('0x41')](db['sequelize']['fn']('MD5',db[_0x9743('0x60')][_0x9743('0x61')](_0x9743('0x54'))),_0x207a2a[_0x9743('0x37')]['token'])]};if(_0x207a2a[_0x9743('0x37')][_0x9743('0x33')]&&_0x207a2a[_0x9743('0x37')]['type']===_0x9743('0x54')){_0x4fe42e[_0x9743('0x62')][_0x9743('0x63')]({'uniqueid':_0x207a2a[_0x9743('0x4b')]['id']});}else{_0x4fe42e[_0x9743('0x62')][_0x9743('0x63')]({'id':_0x207a2a['params']['id']});}return db['VoiceRecording']['find']({'where':_0x4fe42e,'attributes':['id',_0x9743('0x55')],'raw':!![]})['then'](handleEntityNotFound(_0x2aa360,null))['then'](function(_0xbfddaa){if(_0xbfddaa){var _0x4336a0=util[_0x9743('0x36')](_0x9743('0x64'),_0xbfddaa[_0x9743('0x55')]);if(fs[_0x9743('0x56')](_0x4336a0)){_0x51c300=!![];return _0x3b967a[_0x9743('0x57')](_0x4336a0,_0xbfddaa[_0x9743('0x55')],config[_0x9743('0x58')][_0x9743('0x65')])[_0x9743('0x29')](function(){return _0xbfddaa;});}return _0xbfddaa;}})[_0x9743('0x29')](function(_0x4b10cc){if(_0x4b10cc){if(!fs['existsSync'](_0x4b10cc['value'])){throw new db[(_0x9743('0x59'))]['ValidationError'](_0x9743('0x5e'));}if(_0x4b10cc[_0x9743('0x5b')]){return _0x2aa360[_0x9743('0x52')](_0x4b10cc[_0x9743('0x55')],_0x4b10cc[_0x9743('0x5b')]+path['extname'](_0x4b10cc[_0x9743('0x55')]),function(){if(_0x51c300){fs[_0x9743('0x5c')](_0x4b10cc[_0x9743('0x55')]);}});}else{return _0x2aa360[_0x9743('0x52')](_0x4b10cc['value'],function(_0x733269){if(_0x51c300){fs[_0x9743('0x5c')](_0x4b10cc[_0x9743('0x55')]);}});}}})[_0x9743('0x49')](handleError(_0x2aa360,null));};exports['destroy']=function(_0x3c2942,_0x598758){return db[_0x9743('0x30')][_0x9743('0x4d')]({'where':{'id':_0x3c2942['params']['id']}})[_0x9743('0x29')](function(_0x5dec25){if(_[_0x9743('0x66')](_0x5dec25)){throw new ReferenceError(_0x9743('0x67'));}return _0x5dec25;})[_0x9743('0x29')](function(_0x4c7ea6){var _0x3a412a=_0x4c7ea6['value'];logger['info'](_0x9743('0x68'),_0x3a412a);if(!_[_0x9743('0x66')](_0x4c7ea6[_0x9743('0x55')])&&fs[_0x9743('0x56')](_0x3a412a)){logger[_0x9743('0x69')](_0x9743('0x6a')+_0x3a412a+_0x9743('0x6b'));fs['unlinkSync'](_0x3a412a);}_0x3a412a=_0x3a412a+_0x9743('0x6c');if(!_[_0x9743('0x66')](_0x4c7ea6[_0x9743('0x55')])&&fs[_0x9743('0x56')](_0x3a412a)){logger[_0x9743('0x69')]('File:\x20\x22'+_0x3a412a+_0x9743('0x6b'));fs['unlinkSync'](_0x3a412a);}return _0x4c7ea6;})[_0x9743('0x29')](function(_0x1f773b){if(!_0x1f773b)throw new InternalError();return _0x1f773b[_0x9743('0x2a')]();})[_0x9743('0x29')](function(){_0x598758['status'](0xcc)['end']();})[_0x9743('0x49')](handleError(_0x598758,null));};function getBucketslist(_0x35e465,_0x34e18d,_0x4ef33e){return new Promise(function(_0x41e2f6,_0x213c5c){var _0x44f930=new AWS['S3']({'accessKeyId':_0x34e18d,'secretAccessKey':_0x35e465,'region':_0x4ef33e});_0x44f930['listBuckets']({},function(_0xf13a76,_0x45ce67){if(_0xf13a76){return _0x213c5c(_0xf13a76);}else{return _0x41e2f6(_0x45ce67);}});});}function createBucket(_0x1a2020,_0x1ebc9e,_0x3401f8,_0x32d86b){return new Promise(function(_0x409c6e,_0x4bcbd4){var _0x53928a=new AWS['S3']({'accessKeyId':_0x1ebc9e,'secretAccessKey':_0x1a2020,'region':_0x3401f8});_0x53928a[_0x9743('0x6d')]({'Bucket':_0x32d86b},function(_0x184b42,_0x1d4c8e){if(_0x184b42){return _0x4bcbd4(_0x184b42);}else{return _0x409c6e(_0x1d4c8e);}});});}function uploadFile(_0x422261,_0xa7fbac,_0x314b3d,_0x11d019,_0x5ab17c,_0xfaf403){return new Promise(function(_0x42e8f2,_0x251849){var _0x29af68=new AWS['S3']({'accessKeyId':_0xa7fbac,'secretAccessKey':_0x422261,'region':_0x314b3d});_0x29af68['upload']({'Bucket':_0x11d019,'Key':_0x5ab17c,'Body':_0xfaf403},function(_0x376e73,_0x31b2ad){if(_0x376e73){return _0x251849(_0x376e73);}else{return _0x42e8f2(_0x31b2ad);}});});}function startTranscribe(_0x39193d,_0xa1160e,_0x45e803,_0x54aa0e,_0x16cc45,_0x42958e){return new Promise(function(_0x43b1b0,_0x175053){var _0x1ee3ee=new AWS[(_0x9743('0x6e'))]({'accessKeyId':_0xa1160e,'secretAccessKey':_0x39193d,'region':_0x45e803});_0x1ee3ee[_0x9743('0x6f')]({'TranscriptionJobName':_0x54aa0e,'LanguageCode':_0x16cc45,'Media':{'MediaFileUri':_0x42958e}},function(_0x52aefa,_0x46c78e){if(_0x52aefa){return _0x175053(_0x52aefa);}else{return _0x43b1b0(_0x46c78e);}});});}function transcribe(_0x3f66e9,_0x36c394,_0x25df40,_0x8c7690,_0x2b39a0,_0x21c646,_0x4f9d88){return new Promise(function(_0x15608c,_0x4d9a7d){var _0x359208={};logger['info'](util[_0x9743('0x36')](_0x9743('0x70'),_0x3f66e9,_0x2b39a0));return uploadFile(_0x36c394,_0x25df40,_0x8c7690,_0x2b39a0,path[_0x9743('0x71')](_0x21c646),fs['readFileSync'](_0x21c646))[_0x9743('0x29')](function(_0x184d53){logger['info'](util[_0x9743('0x36')](_0x9743('0x72'),_0x3f66e9,_0x2b39a0,_0x184d53['Location']));_0x359208[_0x9743('0x73')]=_0x184d53[_0x9743('0x74')];_0x359208[_0x9743('0x75')]=_0x184d53['Location'];logger[_0x9743('0x69')](util[_0x9743('0x36')]('[RUNTRANSCRIPT][%d]\x20Sending\x20transcribe\x20request',_0x3f66e9));return startTranscribe(_0x36c394,_0x25df40,_0x8c7690,uuidv4(),_0x4f9d88,_0x184d53[_0x9743('0x76')]);})[_0x9743('0x29')](function(_0x59ae1d){logger['info'](util['format'](_0x9743('0x77'),_0x3f66e9,_0x59ae1d[_0x9743('0x78')][_0x9743('0x79')]));_0x359208[_0x9743('0x7a')]=_0x59ae1d['TranscriptionJob'][_0x9743('0x79')];_0x359208[_0x9743('0x7b')]=_0x59ae1d[_0x9743('0x78')][_0x9743('0x7c')];return _0x15608c(_0x359208);})[_0x9743('0x49')](function(_0x21a0dd){return _0x4d9a7d(_0x21a0dd);});});}exports['runTranscribe']=function(_0x3ca281,_0x5ed9ba,_0x1f2801){var _0x1eecee;var _0x2a32f0;var _0x17735e;var _0x30c63d=require(_0x9743('0x53'));return db[_0x9743('0x30')][_0x9743('0x7d')]({'where':{'id':_0x3ca281['params']['id']}})[_0x9743('0x29')](function(_0x1ec60f){if(_0x1ec60f){var _0x227e44=util[_0x9743('0x36')]('%s.cypher',_0x1ec60f[_0x9743('0x55')]);if(fs[_0x9743('0x56')](_0x227e44)){cypher=!![];return _0x30c63d['decryptFile'](_0x227e44,_0x1ec60f[_0x9743('0x55')],config[_0x9743('0x58')]['recording'])[_0x9743('0x29')](function(){return _0x1ec60f;});}return _0x1ec60f;}})['then'](function(_0x4db8f3){if(!_0x4db8f3){throw new db[(_0x9743('0x59'))]['ValidationError'](_0x9743('0x7e'));}_0x2a32f0=_0x4db8f3;return db['Setting'][_0x9743('0x7d')]({'where':{'id':0x1}});})[_0x9743('0x29')](handleEntityNotFound(_0x5ed9ba,null))[_0x9743('0x29')](function(_0xf0d235){if(_0xf0d235){_0x1eecee=_0xf0d235;if(!_0x1eecee[_0x9743('0x7f')]||!_0x1eecee[_0x9743('0x80')]||!_0x1eecee[_0x9743('0x81')]||!_0x1eecee['language']||!_0x1eecee['bucket']){throw new db[(_0x9743('0x59'))][(_0x9743('0x5a'))](_0x9743('0x82'));}if(_0x3ca281[_0x9743('0x4f')]['runSentiment']&&(!_0x1eecee['sentiment']||!_0x1eecee['sentimentAccountId']||!_0x1eecee[_0x9743('0x83')]||!_0x1eecee[_0x9743('0x84')]||!_0x1eecee[_0x9743('0x73')])){throw new db[(_0x9743('0x59'))]['ValidationError'](_0x9743('0x85'));}return db[_0x9743('0x86')][_0x9743('0x7d')]({'where':{'id':_0x1eecee[_0x9743('0x80')]}});}})['then'](function(_0x387daa){if(!_0x387daa){throw new db[(_0x9743('0x59'))]['ValidationError'](_0x9743('0x87'));}if(!_0x387daa['data1']||!_0x387daa[_0x9743('0x88')]){throw new db[(_0x9743('0x59'))]['ValidationError']('Cloud\x20Provider\x20not\x20configured');}_0x17735e=_0x387daa;return getBucketslist(_0x17735e['data1'],_0x17735e['data2'],_0x1eecee['transcribeRegion']);})[_0x9743('0x29')](function(_0x39c936){if(_0x39c936&&_0x39c936['Buckets']){var _0x494bf9=_[_0x9743('0x4d')](_0x39c936['Buckets'],function(_0xe4819d){return _0xe4819d[_0x9743('0x89')]===_0x1eecee[_0x9743('0x73')];});if(!_0x494bf9){logger[_0x9743('0x69')](util[_0x9743('0x36')](_0x9743('0x8a'),_0x3ca281['params']['id'],_0x1eecee[_0x9743('0x73')]));return createBucket(_0x17735e['data1'],_0x17735e[_0x9743('0x88')],_0x1eecee['transcribeRegion'],_0x1eecee[_0x9743('0x73')]);}logger[_0x9743('0x69')](util['format']('[RUNTRANSCRIPT][%d]\x20Bucket\x20%s\x20available',_0x3ca281['params']['id'],_0x1eecee[_0x9743('0x73')]));return;}})[_0x9743('0x29')](function(_0x2db7b4){if(_0x2a32f0[_0x9743('0x7b')]===_0x9743('0x8b')){return transcribe(_0x3ca281[_0x9743('0x4b')]['id'],_0x17735e[_0x9743('0x8c')],_0x17735e[_0x9743('0x88')],_0x1eecee[_0x9743('0x81')],_0x1eecee[_0x9743('0x73')],_0x2a32f0[_0x9743('0x55')],_0x1eecee[_0x9743('0x84')]);}else{logger[_0x9743('0x69')](util['format'](_0x9743('0x8d'),_0x3ca281[_0x9743('0x4b')]['id']));return{'transcribeStatus':_0x9743('0x8e')};}})['then'](function(_0x1d0e18){if(_0x1d0e18){_0x1d0e18[_0x9743('0x8f')]=_0x3ca281[_0x9743('0x4f')][_0x9743('0x90')];return _0x2a32f0['updateAttributes'](_0x1d0e18);}})['then'](respondWithResult(_0x5ed9ba,null))[_0x9743('0x49')](handleError(_0x5ed9ba,null));};function writeFile(_0x37796d,_0x1bcc0b){return new Promise(function(_0x12a5f8,_0x19e17d){fs[_0x9743('0x91')](_0x1bcc0b,_0x37796d,function(_0x893f9a,_0x5747f0){if(_0x893f9a){return _0x19e17d(_0x893f9a);}else{return _0x12a5f8(_0x5747f0);}});});}exports[_0x9743('0x92')]=function(_0xbece87,_0x8a516c,_0x56382b){return db[_0x9743('0x30')]['findOne']({'where':{'id':_0xbece87['params']['id']}})[_0x9743('0x29')](handleEntityNotFound(_0x8a516c))['then'](function(_0xd9b822){if(_0xd9b822&&_0xd9b822[_0x9743('0x93')]){var _0x10bcba=_0xd9b822['fileText'];var _0x3747d3=config[_0x9743('0x94')]+_0x9743('0x95')+_0xd9b822['id']+_0x9743('0x96');if(fs[_0x9743('0x56')](_0x3747d3)){return _0x3747d3;}return writeFile(_0x10bcba,_0x3747d3)[_0x9743('0x29')](function(){return _0x3747d3;});}else{throw new db[(_0x9743('0x59'))][(_0x9743('0x5a'))]('Transcript\x20not\x20available');}})[_0x9743('0x29')](function(_0x5cf221){return _0x8a516c[_0x9743('0x52')](_0x5cf221);})[_0x9743('0x49')](handleError(_0x8a516c));}; \ No newline at end of file diff --git a/server/api/voiceRecording/voiceRecording.model.js b/server/api/voiceRecording/voiceRecording.model.js new file mode 100644 index 0000000..bdfc3eb --- /dev/null +++ b/server/api/voiceRecording/voiceRecording.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6d4a=['voice_recordings','uniqueid','transcribeStatus','./voiceRecording.attributes','define','VoiceRecording'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6d4a,0x117));var _0xa6d4=function(_0x52d11a,_0x5025e4){_0x52d11a=_0x52d11a-0x0;var _0xc7d962=_0x6d4a[_0x52d11a];return _0xc7d962;};'use strict';var attributes=require(_0xa6d4('0x0'));module['exports']=function(_0x1495eb,_0x9d594f){return _0x1495eb[_0xa6d4('0x1')](_0xa6d4('0x2'),attributes,{'tableName':_0xa6d4('0x3'),'paranoid':![],'indexes':[{'name':_0xa6d4('0x4'),'fields':[_0xa6d4('0x4')]},{'name':_0xa6d4('0x5'),'fields':[_0xa6d4('0x5')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceRecording/voiceRecording.rpc.js b/server/api/voiceRecording/voiceRecording.rpc.js new file mode 100644 index 0000000..4fcb7d8 --- /dev/null +++ b/server/api/voiceRecording/voiceRecording.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8aad=['VoiceRecording,\x20%s,\x20%s','request\x20sent','debug','VoiceRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','UpdateVoiceRecording','VoiceRecording','update','body','options','raw','where','attributes','then','CreateVoiceRecording','../../components/encryptor','Setting','findOne','callRecordingEncryption','existsSync','value','format','%s.cypher','secrets','recording','unlink','CreateVoiceRecording\x20file\x20encrypted','lodash','util','bluebird','ioredis','../../mysqldb','rpc','client','http','request','info'];(function(_0x20213,_0x1809ac){var _0xc797ea=function(_0x2a1943){while(--_0x2a1943){_0x20213['push'](_0x20213['shift']());}};_0xc797ea(++_0x1809ac);}(_0x8aad,0x146));var _0xd8aa=function(_0x308991,_0x4e4983){_0x308991=_0x308991-0x0;var _0x43c74b=_0x8aad[_0x308991];return _0x43c74b;};'use strict';var _=require(_0xd8aa('0x0'));var util=require(_0xd8aa('0x1'));var moment=require('moment');var BPromise=require(_0xd8aa('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xd8aa('0x3'));var db=require(_0xd8aa('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xd8aa('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xd8aa('0x6')][_0xd8aa('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x16ea12,_0x4a4b10,_0x2a559d){return new BPromise(function(_0x1da411,_0x2a23b5){return client[_0xd8aa('0x8')](_0x16ea12,_0x2a559d)['then'](function(_0x5de228){logger[_0xd8aa('0x9')](_0xd8aa('0xa'),_0x4a4b10,_0xd8aa('0xb'));logger[_0xd8aa('0xc')](_0xd8aa('0xd'),_0x4a4b10,'request\x20sent',JSON[_0xd8aa('0xe')](_0x5de228));if(_0x5de228[_0xd8aa('0xf')]){if(_0x5de228[_0xd8aa('0xf')][_0xd8aa('0x10')]===0x1f4){logger[_0xd8aa('0xf')](_0xd8aa('0xa'),_0x4a4b10,_0x5de228[_0xd8aa('0xf')][_0xd8aa('0x11')]);return _0x2a23b5(_0x5de228[_0xd8aa('0xf')][_0xd8aa('0x11')]);}logger['error']('VoiceRecording,\x20%s,\x20%s',_0x4a4b10,_0x5de228[_0xd8aa('0xf')][_0xd8aa('0x11')]);return _0x1da411(_0x5de228[_0xd8aa('0xf')]['message']);}else{logger[_0xd8aa('0x9')](_0xd8aa('0xa'),_0x4a4b10,_0xd8aa('0xb'));_0x1da411(_0x5de228[_0xd8aa('0x12')]['message']);}})[_0xd8aa('0x13')](function(_0xa9ba1b){logger['error'](_0xd8aa('0xa'),_0x4a4b10,_0xa9ba1b);_0x2a23b5(_0xa9ba1b);});});}exports[_0xd8aa('0x14')]=function(_0x32e2cd){var _0x3a29ca=this;return new Promise(function(_0x2d34ac,_0x4953be){return db[_0xd8aa('0x15')][_0xd8aa('0x16')](_0x32e2cd[_0xd8aa('0x17')],{'raw':_0x32e2cd[_0xd8aa('0x18')]?_0x32e2cd['options'][_0xd8aa('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x32e2cd[_0xd8aa('0x18')]?_0x32e2cd[_0xd8aa('0x18')][_0xd8aa('0x1a')]||null:null,'attributes':_0x32e2cd[_0xd8aa('0x18')]?_0x32e2cd['options'][_0xd8aa('0x1b')]||null:null,'limit':_0x32e2cd[_0xd8aa('0x18')]?_0x32e2cd[_0xd8aa('0x18')]['limit']||null:null})[_0xd8aa('0x1c')](function(_0x7a4ce7){logger[_0xd8aa('0x9')](_0xd8aa('0x14'),_0x32e2cd);logger[_0xd8aa('0xc')](_0xd8aa('0x14'),_0x32e2cd,JSON[_0xd8aa('0xe')](_0x7a4ce7));_0x2d34ac(_0x7a4ce7);})[_0xd8aa('0x13')](function(_0x375f64){logger[_0xd8aa('0xf')](_0xd8aa('0x14'),_0x375f64[_0xd8aa('0x11')],_0x32e2cd);_0x4953be(_0x3a29ca[_0xd8aa('0xf')](0x1f4,_0x375f64['message']));});});};exports[_0xd8aa('0x1d')]=function(_0x59eb3f){var _0xd4d204=this;return new Promise(function(_0x1f6ab2,_0x26cff3){var _0x3696fd=require(_0xd8aa('0x1e'));var _0x19edee;return db[_0xd8aa('0x1f')][_0xd8aa('0x20')]({'attributes':['id','callRecordingEncryption'],'where':{'id':0x1},'raw':!![]})[_0xd8aa('0x1c')](function(_0x34b792){_0x19edee=_0x34b792;return db[_0xd8aa('0x15')]['create'](_0x59eb3f[_0xd8aa('0x17')]);})['then'](function(_0x3052c6){if(_0x19edee[_0xd8aa('0x21')]&&fs[_0xd8aa('0x22')](_0x3052c6[_0xd8aa('0x23')])){var _0x44f783=util[_0xd8aa('0x24')](_0xd8aa('0x25'),_0x3052c6[_0xd8aa('0x23')]);return _0x3696fd['encryptFile'](_0x3052c6[_0xd8aa('0x23')],_0x44f783,config[_0xd8aa('0x26')][_0xd8aa('0x27')])[_0xd8aa('0x1c')](function(){fs[_0xd8aa('0x28')](_0x3052c6[_0xd8aa('0x23')]);logger[_0xd8aa('0x9')](_0xd8aa('0x29'));return _0x3052c6;});}return _0x3052c6;})['then'](function(_0x265217){logger[_0xd8aa('0x9')](_0xd8aa('0x1d'),_0x59eb3f);logger['debug'](_0xd8aa('0x1d'),_0x59eb3f,JSON[_0xd8aa('0xe')](_0x265217));_0x1f6ab2(_0x265217);})[_0xd8aa('0x13')](function(_0x45c216){logger[_0xd8aa('0xf')](_0xd8aa('0x1d'),_0x45c216[_0xd8aa('0x11')],_0x59eb3f);_0x26cff3(_0xd4d204[_0xd8aa('0xf')](0x1f4,_0x45c216[_0xd8aa('0x11')]));});});}; \ No newline at end of file diff --git a/server/api/voiceTransferReport/index.js b/server/api/voiceTransferReport/index.js new file mode 100644 index 0000000..b99a45f --- /dev/null +++ b/server/api/voiceTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37c0=['index','isAuthenticated','describe','/:id','put','update','delete','destroy','exports','express','Router','fs-extra','../../components/auth/service','../../config/environment','./voiceTransferReport.controller','get'];(function(_0x3bf83f,_0x181cac){var _0x22c4a9=function(_0xb3ff0d){while(--_0xb3ff0d){_0x3bf83f['push'](_0x3bf83f['shift']());}};_0x22c4a9(++_0x181cac);}(_0x37c0,0x1c9));var _0x037c=function(_0x4021de,_0x21c195){_0x4021de=_0x4021de-0x0;var _0x2bc644=_0x37c0[_0x4021de];return _0x2bc644;};'use strict';var multer=require('multer');var util=require('util');var path=require('path');var timeout=require('connect-timeout');var express=require(_0x037c('0x0'));var router=express[_0x037c('0x1')]();var fs_extra=require(_0x037c('0x2'));var auth=require(_0x037c('0x3'));var interaction=require('../../components/interaction/service');var config=require(_0x037c('0x4'));var controller=require(_0x037c('0x5'));router[_0x037c('0x6')]('/',auth['isAuthenticated'](),controller[_0x037c('0x7')]);router['get']('/describe',auth[_0x037c('0x8')](),controller[_0x037c('0x9')]);router[_0x037c('0x6')](_0x037c('0xa'),auth[_0x037c('0x8')](),controller['show']);router['post']('/',auth[_0x037c('0x8')](),controller['create']);router[_0x037c('0xb')](_0x037c('0xa'),auth['isAuthenticated'](),controller[_0x037c('0xc')]);router[_0x037c('0xd')]('/:id',auth['isAuthenticated'](),controller[_0x037c('0xe')]);module[_0x037c('0xf')]=router; \ No newline at end of file diff --git a/server/api/voiceTransferReport/voiceTransferReport.attributes.js b/server/api/voiceTransferReport/voiceTransferReport.attributes.js new file mode 100644 index 0000000..0391d85 --- /dev/null +++ b/server/api/voiceTransferReport/voiceTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa7b4=['attended','STRING','Yes','moment','exports','blind'];(function(_0x455293,_0x26be07){var _0x2739a3=function(_0x508823){while(--_0x508823){_0x455293['push'](_0x455293['shift']());}};_0x2739a3(++_0x26be07);}(_0xa7b4,0x8d));var _0x4a7b=function(_0x46f6c6,_0x5f337d){_0x46f6c6=_0x46f6c6-0x0;var _0x462bb8=_0xa7b4[_0x46f6c6];return _0x462bb8;};'use strict';var Sequelize=require('sequelize');var moment=require(_0x4a7b('0x0'));module[_0x4a7b('0x1')]={'type':{'type':Sequelize['ENUM'](_0x4a7b('0x2'),_0x4a7b('0x3'))},'result':{'type':Sequelize['STRING']},'transfererchannel':{'type':Sequelize['STRING']},'transferercalleridnum':{'type':Sequelize['STRING']},'transferercalleridname':{'type':Sequelize[_0x4a7b('0x4')]},'transfererconnectedlinenum':{'type':Sequelize[_0x4a7b('0x4')]},'transfererconnectedlinename':{'type':Sequelize['STRING']},'transfereraccountcode':{'type':Sequelize[_0x4a7b('0x4')]},'transferercontext':{'type':Sequelize[_0x4a7b('0x4')]},'transfererexten':{'type':Sequelize[_0x4a7b('0x4')]},'transfererlinkedid':{'type':Sequelize[_0x4a7b('0x4')]},'transfereechannel':{'type':Sequelize[_0x4a7b('0x4')]},'transfereecalleridnum':{'type':Sequelize[_0x4a7b('0x4')]},'transfereecalleridname':{'type':Sequelize[_0x4a7b('0x4')]},'transfereeconnectedlinenum':{'type':Sequelize[_0x4a7b('0x4')]},'transfereeconnectedlinename':{'type':Sequelize[_0x4a7b('0x4')]},'transfereeaccountcode':{'type':Sequelize[_0x4a7b('0x4')]},'transfereecontext':{'type':Sequelize[_0x4a7b('0x4')]},'transfereeexten':{'type':Sequelize[_0x4a7b('0x4')]},'transfereelinkedid':{'type':Sequelize[_0x4a7b('0x4')]},'isexternal':{'type':Sequelize['ENUM'](_0x4a7b('0x5'),'No')},'context':{'type':Sequelize['STRING']},'extension':{'type':Sequelize[_0x4a7b('0x4')]}}; \ No newline at end of file diff --git a/server/api/voiceTransferReport/voiceTransferReport.controller.js b/server/api/voiceTransferReport/voiceTransferReport.controller.js new file mode 100644 index 0000000..8f6b438 --- /dev/null +++ b/server/api/voiceTransferReport/voiceTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1c31=['status','end','offset','limit','undefined','count','set','Content-Range','json','apply','reject','save','update','then','destroy','name','map','VoiceTransferReport','fieldName','type','key','query','keys','filters','intersection','attributes','model','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','includeAll','rows','catch','show','params','fields','include','options','find','create','describe','eml-format','rimraf','zip-dir','moment','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus'];(function(_0x3947c9,_0x4d6c97){var _0x2e7871=function(_0x1236cc){while(--_0x1236cc){_0x3947c9['push'](_0x3947c9['shift']());}};_0x2e7871(++_0x4d6c97);}(_0x1c31,0x153));var _0x11c3=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x1c31[_0x19e35c];return _0x3e1fe8;};'use strict';var emlformat=require(_0x11c3('0x0'));var rimraf=require(_0x11c3('0x1'));var zipdir=require(_0x11c3('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x11c3('0x3'));var BPromise=require(_0x11c3('0x4'));var Mustache=require(_0x11c3('0x5'));var util=require('util');var path=require(_0x11c3('0x6'));var sox=require(_0x11c3('0x7'));var csv=require(_0x11c3('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x11c3('0x9'));var _=require(_0x11c3('0xa'));var squel=require(_0x11c3('0xb'));var crypto=require(_0x11c3('0xc'));var jsforce=require(_0x11c3('0xd'));var deskjs=require(_0x11c3('0xe'));var toCsv=require(_0x11c3('0x8'));var querystring=require(_0x11c3('0xf'));var Papa=require('papaparse');var Redis=require(_0x11c3('0x10'));var authService=require(_0x11c3('0x11'));var qs=require(_0x11c3('0x12'));var as=require(_0x11c3('0x13'));var hardwareService=require(_0x11c3('0x14'));var logger=require(_0x11c3('0x15'))(_0x11c3('0x16'));var utils=require('../../config/utils');var config=require(_0x11c3('0x17'));var licenseUtil=require(_0x11c3('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x46470d,_0x583885){_0x583885=_0x583885||0xcc;return function(_0x7b157f){if(_0x7b157f){return _0x46470d[_0x11c3('0x19')](_0x583885);}return _0x46470d[_0x11c3('0x1a')](_0x583885)[_0x11c3('0x1b')]();};}function respondWithResult(_0x5ec73f,_0x4c5371){_0x4c5371=_0x4c5371||0xc8;return function(_0x2e5c45){if(_0x2e5c45){return _0x5ec73f[_0x11c3('0x1a')](_0x4c5371)['json'](_0x2e5c45);}};}function respondWithFilteredResult(_0x14d4dc,_0x1f7de7){return function(_0x1ada43){if(_0x1ada43){var _0x121538=typeof _0x1f7de7[_0x11c3('0x1c')]==='undefined'&&typeof _0x1f7de7[_0x11c3('0x1d')]===_0x11c3('0x1e');var _0x4b9068=_0x1ada43[_0x11c3('0x1f')];var _0x4453e6=_0x121538?0x0:_0x1f7de7[_0x11c3('0x1c')];var _0x374f77=_0x121538?_0x1ada43[_0x11c3('0x1f')]:_0x1f7de7[_0x11c3('0x1c')]+_0x1f7de7['limit'];var _0x56549c;if(_0x374f77>=_0x4b9068){_0x374f77=_0x4b9068;_0x56549c=0xc8;}else{_0x56549c=0xce;}_0x14d4dc[_0x11c3('0x1a')](_0x56549c);return _0x14d4dc[_0x11c3('0x20')](_0x11c3('0x21'),_0x4453e6+'-'+_0x374f77+'/'+_0x4b9068)[_0x11c3('0x22')](_0x1ada43);}return null;};}function patchUpdates(_0x3f6022){return function(_0x3bee5a){try{jsonpatch[_0x11c3('0x23')](_0x3bee5a,_0x3f6022,!![]);}catch(_0xbb3d72){return BPromise[_0x11c3('0x24')](_0xbb3d72);}return _0x3bee5a[_0x11c3('0x25')]();};}function saveUpdates(_0x561842,_0x5e29ca){return function(_0x4b92ab){if(_0x4b92ab){return _0x4b92ab[_0x11c3('0x26')](_0x561842)[_0x11c3('0x27')](function(_0x3c2e7a){return _0x3c2e7a;});}return null;};}function removeEntity(_0xdc53b9,_0x4c035f){return function(_0x40b21b){if(_0x40b21b){return _0x40b21b[_0x11c3('0x28')]()[_0x11c3('0x27')](function(){_0xdc53b9[_0x11c3('0x1a')](0xcc)[_0x11c3('0x1b')]();});}};}function handleEntityNotFound(_0x5c6641,_0x1043e9){return function(_0x19b93d){if(!_0x19b93d){_0x5c6641[_0x11c3('0x19')](0x194);}return _0x19b93d;};}function handleError(_0x6e02f,_0x29bf00){_0x29bf00=_0x29bf00||0x1f4;return function(_0x316a81){logger['error'](_0x316a81['stack']);if(_0x316a81[_0x11c3('0x29')]){delete _0x316a81['name'];}_0x6e02f[_0x11c3('0x1a')](_0x29bf00)['send'](_0x316a81);};}exports['index']=function(_0xe96cc8,_0x2bf215){var _0x44be24={},_0x2e7dea={},_0x43c2a9={'count':0x0,'rows':[]};var _0x9a403d=_[_0x11c3('0x2a')](db[_0x11c3('0x2b')]['rawAttributes'],function(_0x23462b){return{'name':_0x23462b[_0x11c3('0x2c')],'type':_0x23462b[_0x11c3('0x2d')][_0x11c3('0x2e')]};});_0x2e7dea['model']=_['map'](_0x9a403d,_0x11c3('0x29'));_0x2e7dea[_0x11c3('0x2f')]=_[_0x11c3('0x30')](_0xe96cc8[_0x11c3('0x2f')]);_0x2e7dea[_0x11c3('0x31')]=_[_0x11c3('0x32')](_0x2e7dea['model'],_0x2e7dea[_0x11c3('0x2f')]);_0x44be24[_0x11c3('0x33')]=_[_0x11c3('0x32')](_0x2e7dea[_0x11c3('0x34')],qs['fields'](_0xe96cc8['query']['fields']));_0x44be24[_0x11c3('0x33')]=_0x44be24[_0x11c3('0x33')][_0x11c3('0x35')]?_0x44be24[_0x11c3('0x33')]:_0x2e7dea[_0x11c3('0x34')];if(!_0xe96cc8['query'][_0x11c3('0x36')](_0x11c3('0x37'))){_0x44be24[_0x11c3('0x1d')]=qs['limit'](_0xe96cc8[_0x11c3('0x2f')][_0x11c3('0x1d')]);_0x44be24[_0x11c3('0x1c')]=qs[_0x11c3('0x1c')](_0xe96cc8[_0x11c3('0x2f')][_0x11c3('0x1c')]);}_0x44be24[_0x11c3('0x38')]=qs[_0x11c3('0x39')](_0xe96cc8['query']['sort']);_0x44be24[_0x11c3('0x3a')]=qs[_0x11c3('0x31')](_[_0x11c3('0x3b')](_0xe96cc8[_0x11c3('0x2f')],_0x2e7dea[_0x11c3('0x31')]),_0x9a403d);if(_0xe96cc8[_0x11c3('0x2f')][_0x11c3('0x3c')]){_0x44be24[_0x11c3('0x3a')]=_[_0x11c3('0x3d')](_0x44be24[_0x11c3('0x3a')],{'$or':_['map'](_0x9a403d,function(_0x402353){if(_0x402353[_0x11c3('0x2d')]!=='VIRTUAL'){var _0x158d19={};_0x158d19[_0x402353[_0x11c3('0x29')]]={'$like':'%'+_0xe96cc8[_0x11c3('0x2f')][_0x11c3('0x3c')]+'%'};return _0x158d19;}})});}_0x44be24=_[_0x11c3('0x3d')]({},_0x44be24,_0xe96cc8['options']);var _0x5ad6ba={'where':_0x44be24[_0x11c3('0x3a')]};return db['VoiceTransferReport'][_0x11c3('0x1f')](_0x5ad6ba)[_0x11c3('0x27')](function(_0x4e54c3){_0x43c2a9[_0x11c3('0x1f')]=_0x4e54c3;if(_0xe96cc8[_0x11c3('0x2f')][_0x11c3('0x3e')]){_0x44be24['include']=[{'all':!![]}];}return db[_0x11c3('0x2b')]['findAll'](_0x44be24);})[_0x11c3('0x27')](function(_0x3aedc6){_0x43c2a9[_0x11c3('0x3f')]=_0x3aedc6;return _0x43c2a9;})['then'](respondWithFilteredResult(_0x2bf215,_0x44be24))[_0x11c3('0x40')](handleError(_0x2bf215,null));};exports[_0x11c3('0x41')]=function(_0x1bb4df,_0x5c2a90){var _0x173819={'raw':!![],'where':{'id':_0x1bb4df[_0x11c3('0x42')]['id']}},_0x278fca={};_0x278fca[_0x11c3('0x34')]=_[_0x11c3('0x30')](db[_0x11c3('0x2b')]['rawAttributes']);_0x278fca['query']=_[_0x11c3('0x30')](_0x1bb4df[_0x11c3('0x2f')]);_0x278fca[_0x11c3('0x31')]=_[_0x11c3('0x32')](_0x278fca[_0x11c3('0x34')],_0x278fca[_0x11c3('0x2f')]);_0x173819[_0x11c3('0x33')]=_['intersection'](_0x278fca['model'],qs[_0x11c3('0x43')](_0x1bb4df['query'][_0x11c3('0x43')]));_0x173819['attributes']=_0x173819[_0x11c3('0x33')][_0x11c3('0x35')]?_0x173819[_0x11c3('0x33')]:_0x278fca[_0x11c3('0x34')];if(_0x1bb4df[_0x11c3('0x2f')]['includeAll']){_0x173819[_0x11c3('0x44')]=[{'all':!![]}];}_0x173819=_[_0x11c3('0x3d')]({},_0x173819,_0x1bb4df[_0x11c3('0x45')]);return db['VoiceTransferReport'][_0x11c3('0x46')](_0x173819)[_0x11c3('0x27')](handleEntityNotFound(_0x5c2a90,null))['then'](respondWithResult(_0x5c2a90,null))[_0x11c3('0x40')](handleError(_0x5c2a90,null));};exports[_0x11c3('0x47')]=function(_0x33827e,_0x8c8aa0){return db[_0x11c3('0x2b')][_0x11c3('0x47')](_0x33827e['body'],{})[_0x11c3('0x27')](respondWithResult(_0x8c8aa0,0xc9))[_0x11c3('0x40')](handleError(_0x8c8aa0,null));};exports[_0x11c3('0x26')]=function(_0x1dd223,_0x35e0f0){if(_0x1dd223['body']['id']){delete _0x1dd223['body']['id'];}return db['VoiceTransferReport'][_0x11c3('0x46')]({'where':{'id':_0x1dd223[_0x11c3('0x42')]['id']}})[_0x11c3('0x27')](handleEntityNotFound(_0x35e0f0,null))[_0x11c3('0x27')](saveUpdates(_0x1dd223['body'],null))[_0x11c3('0x27')](respondWithResult(_0x35e0f0,null))[_0x11c3('0x40')](handleError(_0x35e0f0,null));};exports[_0x11c3('0x28')]=function(_0x134beb,_0x237064){return db[_0x11c3('0x2b')][_0x11c3('0x46')]({'where':{'id':_0x134beb[_0x11c3('0x42')]['id']}})[_0x11c3('0x27')](handleEntityNotFound(_0x237064,null))[_0x11c3('0x27')](removeEntity(_0x237064,null))[_0x11c3('0x40')](handleError(_0x237064,null));};exports[_0x11c3('0x48')]=function(_0xceeb92,_0x3437f2){return db['VoiceTransferReport']['describe']()[_0x11c3('0x27')](respondWithResult(_0x3437f2,null))[_0x11c3('0x40')](handleError(_0x3437f2,null));}; \ No newline at end of file diff --git a/server/api/voiceTransferReport/voiceTransferReport.model.js b/server/api/voiceTransferReport/voiceTransferReport.model.js new file mode 100644 index 0000000..b61834f --- /dev/null +++ b/server/api/voiceTransferReport/voiceTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x18ad=['moment','bluebird','request-promise','path','../../config/environment','exports','define','VoiceTransferReport','report_call_transfer','lodash','util','../../config/logger','api'];(function(_0xdf22cc,_0x3fceff){var _0x1094a7=function(_0x12a4d4){while(--_0x12a4d4){_0xdf22cc['push'](_0xdf22cc['shift']());}};_0x1094a7(++_0x3fceff);}(_0x18ad,0x1c3));var _0xd18a=function(_0x5534fe,_0x43c22e){_0x5534fe=_0x5534fe-0x0;var _0x3d1dc2=_0x18ad[_0x5534fe];return _0x3d1dc2;};'use strict';var _=require(_0xd18a('0x0'));var util=require(_0xd18a('0x1'));var logger=require(_0xd18a('0x2'))(_0xd18a('0x3'));var moment=require(_0xd18a('0x4'));var BPromise=require(_0xd18a('0x5'));var rp=require(_0xd18a('0x6'));var fs=require('fs');var path=require(_0xd18a('0x7'));var rimraf=require('rimraf');var config=require(_0xd18a('0x8'));var attributes=require('./voiceTransferReport.attributes');module[_0xd18a('0x9')]=function(_0x4ee8f0,_0x5757dc){return _0x4ee8f0[_0xd18a('0xa')](_0xd18a('0xb'),attributes,{'tableName':_0xd18a('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/voiceTransferReport/voiceTransferReport.rpc.js b/server/api/voiceTransferReport/voiceTransferReport.rpc.js new file mode 100644 index 0000000..9274bf7 --- /dev/null +++ b/server/api/voiceTransferReport/voiceTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdae2=['bluebird','randomstring','../../config/utils','../../config/environment','client','http','request','then','info','request\x20sent','debug','VoiceTransferReport,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceTransferReport,\x20%s,\x20%s','result','message','catch','body','options','raw','CreateVoiceTransferReport','lodash','util','moment'];(function(_0x253fc8,_0x2882fa){var _0x4b3bbd=function(_0x4075ab){while(--_0x4075ab){_0x253fc8['push'](_0x253fc8['shift']());}};_0x4b3bbd(++_0x2882fa);}(_0xdae2,0x1b7));var _0x2dae=function(_0x47aa64,_0xfb8a07){_0x47aa64=_0x47aa64-0x0;var _0x549c7a=_0xdae2[_0x47aa64];return _0x549c7a;};'use strict';var _=require(_0x2dae('0x0'));var util=require(_0x2dae('0x1'));var moment=require(_0x2dae('0x2'));var BPromise=require(_0x2dae('0x3'));var rs=require(_0x2dae('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x2dae('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x2dae('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x2dae('0x7')][_0x2dae('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x19c1e8,_0x2bc1db,_0x338769){return new BPromise(function(_0x538262,_0x5f5541){return client[_0x2dae('0x9')](_0x19c1e8,_0x338769)[_0x2dae('0xa')](function(_0x41e9ec){logger[_0x2dae('0xb')]('VoiceTransferReport,\x20%s,\x20%s',_0x2bc1db,_0x2dae('0xc'));logger[_0x2dae('0xd')](_0x2dae('0xe'),_0x2bc1db,_0x2dae('0xc'),JSON[_0x2dae('0xf')](_0x41e9ec));if(_0x41e9ec['error']){if(_0x41e9ec[_0x2dae('0x10')][_0x2dae('0x11')]===0x1f4){logger['error'](_0x2dae('0x12'),_0x2bc1db,_0x41e9ec['error']['message']);return _0x5f5541(_0x41e9ec['error']['message']);}logger[_0x2dae('0x10')](_0x2dae('0x12'),_0x2bc1db,_0x41e9ec[_0x2dae('0x10')]['message']);return _0x538262(_0x41e9ec[_0x2dae('0x10')]['message']);}else{logger['info']('VoiceTransferReport,\x20%s,\x20%s',_0x2bc1db,'request\x20sent');_0x538262(_0x41e9ec[_0x2dae('0x13')][_0x2dae('0x14')]);}})[_0x2dae('0x15')](function(_0x5ad083){logger[_0x2dae('0x10')](_0x2dae('0x12'),_0x2bc1db,_0x5ad083);_0x5f5541(_0x5ad083);});});}exports['CreateVoiceTransferReport']=function(_0x1ecb79){var _0x54fbb5=this;return new Promise(function(_0xaf81d1,_0x1dfc96){return db['VoiceTransferReport']['create'](_0x1ecb79[_0x2dae('0x16')],{'raw':_0x1ecb79[_0x2dae('0x17')]?_0x1ecb79[_0x2dae('0x17')][_0x2dae('0x18')]===undefined?!![]:![]:!![]})[_0x2dae('0xa')](function(_0x41c654){logger[_0x2dae('0xb')](_0x2dae('0x19'),_0x1ecb79);logger[_0x2dae('0xd')](_0x2dae('0x19'),_0x1ecb79,JSON['stringify'](_0x41c654));_0xaf81d1(_0x41c654);})[_0x2dae('0x15')](function(_0x54a251){logger[_0x2dae('0x10')](_0x2dae('0x19'),_0x54a251[_0x2dae('0x14')],_0x1ecb79);_0x1dfc96(_0x54fbb5['error'](0x1f4,_0x54a251['message']));});});}; \ No newline at end of file diff --git a/server/api/webbar/index.js b/server/api/webbar/index.js new file mode 100644 index 0000000..3a863d7 --- /dev/null +++ b/server/api/webbar/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe5b3=['transfer','Router','../../components/auth/service','./webbar.controller','post','/originate','isAuthenticated','isWebrtcLicence','originate','/hangup','hangup','answer','hold','/unhold','unhold','/calls','calls','/transfer'];(function(_0x2552e9,_0x4715e7){var _0x2428eb=function(_0x21d38b){while(--_0x21d38b){_0x2552e9['push'](_0x2552e9['shift']());}};_0x2428eb(++_0x4715e7);}(_0xe5b3,0x133));var _0x3e5b=function(_0x18f46a,_0x157938){_0x18f46a=_0x18f46a-0x0;var _0x3e786e=_0xe5b3[_0x18f46a];return _0x3e786e;};'use strict';var express=require('express');var router=express[_0x3e5b('0x0')]();var auth=require(_0x3e5b('0x1'));var controller=require(_0x3e5b('0x2'));router[_0x3e5b('0x3')](_0x3e5b('0x4'),auth[_0x3e5b('0x5')](),auth[_0x3e5b('0x6')](),controller[_0x3e5b('0x7')]);router[_0x3e5b('0x3')](_0x3e5b('0x8'),auth[_0x3e5b('0x5')](),auth['isWebrtcLicence'](),controller[_0x3e5b('0x9')]);router[_0x3e5b('0x3')]('/answer',auth[_0x3e5b('0x5')](),auth[_0x3e5b('0x6')](),controller[_0x3e5b('0xa')]);router[_0x3e5b('0x3')]('/hold',auth['isAuthenticated'](),auth[_0x3e5b('0x6')](),controller[_0x3e5b('0xb')]);router[_0x3e5b('0x3')](_0x3e5b('0xc'),auth[_0x3e5b('0x5')](),auth['isWebrtcLicence'](),controller[_0x3e5b('0xd')]);router['post'](_0x3e5b('0xe'),auth[_0x3e5b('0x5')](),auth[_0x3e5b('0x6')](),controller[_0x3e5b('0xf')]);router[_0x3e5b('0x3')](_0x3e5b('0x10'),auth[_0x3e5b('0x5')](),auth['isWebrtcLicence'](),controller[_0x3e5b('0x11')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/webbar/webbar.controller.js b/server/api/webbar/webbar.controller.js new file mode 100644 index 0000000..3f19ff8 --- /dev/null +++ b/server/api/webbar/webbar.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4bc3=['transfer\x20executed!','path','lodash','../../config/environment','util','jayson/promise','client','http','../../config/logger','webbarapi','ioredis','redis','validate','number','userId\x20is\x20required','string','callNumber\x20is\x20required','log','handleError:','stack','name','status','send','NotFound','error','code','message','result','catch','findOne','all','then','filter','rows','UserId','sessionId','length','\x20not\x20found!','originate\x20fired:','body','userId','callerId','info','entityFound:','user:%s','webbar:originate','json','originate\x20executed!','hangup','hangup\x20fired:','format','webbar:hangup','hangup\x20executed!','answer\x20fired:','answer\x20executed!','hold','hold\x20fired:','webbar:hold','hold\x20executed!','unhold','unhold\x20fired:','webbar:unhold','unhold\x20executed!','calls','calls\x20fired:','VoiceChannels','conference','conference\x20fired:','webbar:conference','conference\x20executed!','transfer\x20fired:','transferNumber','webbar:transfer'];(function(_0x3e00b7,_0x4a7b42){var _0x53fa95=function(_0xe2a798){while(--_0xe2a798){_0x3e00b7['push'](_0x3e00b7['shift']());}};_0x53fa95(++_0x4a7b42);}(_0x4bc3,0x16e));var _0x34bc=function(_0xc0a3d3,_0x2c8d00){_0xc0a3d3=_0xc0a3d3-0x0;var _0x3386e8=_0x4bc3[_0xc0a3d3];return _0x3386e8;};'use strict';var path=require(_0x34bc('0x0'));var fs=require('fs');var _=require(_0x34bc('0x1'));var db=require('../../mysqldb')['db'];var config=require(_0x34bc('0x2'));var util=require(_0x34bc('0x3'));var BPromise=require('bluebird');var jayson=require(_0x34bc('0x4'));var amiClient=jayson[_0x34bc('0x5')][_0x34bc('0x6')]({'port':0x232a});var logger=require(_0x34bc('0x7'))(_0x34bc('0x8'));var Redis=require(_0x34bc('0x9'));config[_0x34bc('0xa')]=_['defaults'](config[_0x34bc('0xa')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x34bc('0xa')]));var Schema=require(_0x34bc('0xb'));var originateValidation=new Schema({'userId':{'type':_0x34bc('0xc'),'required':[!![],_0x34bc('0xd')]},'callNumber':{'type':_0x34bc('0xe'),'required':[!![],_0x34bc('0xf')]},'callerId':{'type':'string'},'callbackUrl':{'type':'string'}});var hangupValidation=new Schema({'userId':{'type':_0x34bc('0xc'),'required':[!![],_0x34bc('0xd')]},'sessionId':{'type':_0x34bc('0xe'),'required':![]}});var answerValidation=new Schema({'userId':{'type':'number','required':[!![],_0x34bc('0xd')]},'sessionId':{'type':'string','required':![]}});var transferValidation=new Schema({'userId':{'type':_0x34bc('0xc'),'required':[!![],_0x34bc('0xd')]},'sessionId':{'type':_0x34bc('0xe'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':_0x34bc('0xe'),'required':[!![],'transferNumber\x20is\x20required']}});var holdValidation=new Schema({'userId':{'type':_0x34bc('0xc'),'required':[!![],_0x34bc('0xd')]},'sessionId':{'type':_0x34bc('0xe'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':'number','required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x34bc('0xe'),'required':![]}});var callsValidation=new Schema({'userId':{'type':'number','required':[!![],_0x34bc('0xd')]}});var conferenceValidation=new Schema({'userId':{'type':_0x34bc('0xc'),'required':[!![],_0x34bc('0xd')]}});function emit(_0x25da29,_0x2db2dd,_0x69542f){logger['info'](_0x25da29,_0x2db2dd,JSON['stringify'](_0x69542f));io['to'](_0x25da29)['emit'](_0x2db2dd,_0x69542f);}function handleError(_0x4205eb){return function(_0x3eaedf){console[_0x34bc('0x10')](_0x34bc('0x11'),_0x3eaedf,_0x3eaedf instanceof RangeError);logger['error'](_0x3eaedf[_0x34bc('0x12')]);if(_0x3eaedf instanceof RangeError){if(_0x3eaedf[_0x34bc('0x13')]){delete _0x3eaedf['name'];}_0x4205eb[_0x34bc('0x14')](0x194)[_0x34bc('0x15')](_0x3eaedf);}else{if(_0x3eaedf['name']){delete _0x3eaedf[_0x34bc('0x13')];}_0x4205eb[_0x34bc('0x14')](0x1f4)[_0x34bc('0x15')](_0x3eaedf);}};}function checkError(){return function(_0x120bd3){if(!_0x120bd3){throw new RangeError(_0x34bc('0x16'));}return _0x120bd3;};}function respondWithRpcPromise(_0x42c814,_0x48087e){return new BPromise(function(_0x40e128,_0x3c9939){var _0x38882c=amiClient;return _0x38882c['request'](_0x42c814,_0x48087e)['then'](function(_0x358d51){if(_0x358d51[_0x34bc('0x17')]){if(_0x358d51[_0x34bc('0x17')][_0x34bc('0x18')]===0x1f4){return _0x3c9939(_0x358d51[_0x34bc('0x17')][_0x34bc('0x19')]);}return _0x40e128(_0x358d51[_0x34bc('0x17')][_0x34bc('0x19')]);}else{_0x40e128(_0x358d51[_0x34bc('0x1a')]);}})[_0x34bc('0x1b')](function(_0x2de017){_0x3c9939(_0x2de017);});});}function getAgent(_0x1edcb0){return db['User'][_0x34bc('0x1c')]({'where':{'id':_0x1edcb0,'role':'agent'}})['then'](checkError());}function getAgentCheckSession(_0x3da96b,_0x5332c8){return new BPromise(function(_0x4082c3,_0x446b58){var _0x46fd76=respondWithRpcPromise('VoiceChannels');var _0x2e6d96=getAgent(_0x3da96b);Promise[_0x34bc('0x1d')]([_0x46fd76,_0x2e6d96])[_0x34bc('0x1e')](function(_0x1a83f7){var _0x2bb874=_0x1a83f7[0x0];var _0x33bf46=_0x1a83f7[0x1];var _0x520fd4=_[_0x34bc('0x1f')](_0x2bb874[_0x34bc('0x20')],function(_0x22aacc){return _0x22aacc[_0x34bc('0x21')]==_0x33bf46['id']&&_0x22aacc[_0x34bc('0x22')]==_0x5332c8;});if(_0x520fd4[_0x34bc('0x23')]==0x1){_0x4082c3(_0x33bf46);}else{_0x446b58(new RangeError('sessionId\x20'+_0x5332c8+_0x34bc('0x24')));}});});}exports['originate']=function(_0x530748,_0x42fd40){logger['info'](_0x34bc('0x25'),_0x530748[_0x34bc('0x26')]);var _0xb446f4=originateValidation[_0x34bc('0xb')](_0x530748[_0x34bc('0x26')]);if(_0xb446f4[_0x34bc('0x23')]>0x0){return _0x42fd40[_0x34bc('0x14')](0x190)['json'](_0xb446f4);}var _0xbd59f9=_0x530748[_0x34bc('0x26')][_0x34bc('0x27')];var _0x3224c7=_0x530748[_0x34bc('0x26')]['callNumber'];var _0x3bc739=_0x530748[_0x34bc('0x26')][_0x34bc('0x28')];var _0x493835=_0x530748[_0x34bc('0x26')]['callbackUrl'];return getAgent(_0xbd59f9)['then'](function(_0x39e630){logger[_0x34bc('0x29')](_0x34bc('0x2a'),_0x39e630[_0x34bc('0x13')]);emit(util['format'](_0x34bc('0x2b'),_0x39e630[_0x34bc('0x13')]),_0x34bc('0x2c'),{'callNumber':_0x3224c7,'callerId':_0x3bc739,'callbackUrl':_0x493835});return _0x42fd40['status'](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x2e')});})[_0x34bc('0x1b')](handleError(_0x42fd40));};exports[_0x34bc('0x2f')]=function(_0x53a43a,_0x2ac72b){logger[_0x34bc('0x29')](_0x34bc('0x30'),_0x53a43a['body']);var _0x246a86=hangupValidation[_0x34bc('0xb')](_0x53a43a[_0x34bc('0x26')]);if(_0x246a86[_0x34bc('0x23')]>0x0){return _0x2ac72b[_0x34bc('0x14')](0x190)['json'](_0x246a86);}var _0xca2aaf=_0x53a43a[_0x34bc('0x26')][_0x34bc('0x27')];var _0x174cfe=_0x53a43a[_0x34bc('0x26')]['sessionId'];return getAgent(_0xca2aaf)[_0x34bc('0x1e')](function(_0x50f1ee){logger[_0x34bc('0x29')](_0x34bc('0x2a'),_0x50f1ee[_0x34bc('0x13')]);emit(util[_0x34bc('0x31')]('user:%s',_0x50f1ee[_0x34bc('0x13')]),_0x34bc('0x32'),{'sessionId':_0x174cfe});return _0x2ac72b['status'](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x33')});})[_0x34bc('0x1b')](handleError(_0x2ac72b));};exports['answer']=function(_0x31afd3,_0xbf2127){logger[_0x34bc('0x29')](_0x34bc('0x34'),_0x31afd3[_0x34bc('0x26')]);var _0x20debf=answerValidation[_0x34bc('0xb')](_0x31afd3[_0x34bc('0x26')]);if(_0x20debf[_0x34bc('0x23')]>0x0){return _0xbf2127[_0x34bc('0x14')](0x190)[_0x34bc('0x2d')](_0x20debf);}var _0x570824=_0x31afd3['body'][_0x34bc('0x27')];var _0x1e1bf3=_0x31afd3[_0x34bc('0x26')][_0x34bc('0x22')];return getAgent(_0x570824)[_0x34bc('0x1e')](function(_0x2db155){logger['info'](_0x34bc('0x2a'),_0x2db155['name']);emit(util[_0x34bc('0x31')](_0x34bc('0x2b'),_0x2db155[_0x34bc('0x13')]),'webbar:answer',{'sessionId':_0x1e1bf3});return _0xbf2127[_0x34bc('0x14')](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x35')});})[_0x34bc('0x1b')](handleError(_0xbf2127));};exports[_0x34bc('0x36')]=function(_0x26924c,_0xba179d){logger[_0x34bc('0x29')](_0x34bc('0x37'),_0x26924c[_0x34bc('0x26')]);var _0x100c70=holdValidation[_0x34bc('0xb')](_0x26924c['body']);if(_0x100c70['length']>0x0){return _0xba179d[_0x34bc('0x14')](0x190)[_0x34bc('0x2d')](_0x100c70);}var _0x180a51=_0x26924c['body']['userId'];var _0x898cf8=_0x26924c[_0x34bc('0x26')][_0x34bc('0x22')];return getAgent(_0x180a51)['then'](function(_0x43bfb7){logger[_0x34bc('0x29')]('entityFound:',_0x43bfb7[_0x34bc('0x13')]);emit(util['format'](_0x34bc('0x2b'),_0x43bfb7['name']),_0x34bc('0x38'),{'sessionId':_0x898cf8});return _0xba179d[_0x34bc('0x14')](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x39')});})['catch'](handleError(_0xba179d));};exports[_0x34bc('0x3a')]=function(_0x2bbd0b,_0x103bd1){logger[_0x34bc('0x29')](_0x34bc('0x3b'),_0x2bbd0b[_0x34bc('0x26')]);var _0x18eadd=unholdValidation[_0x34bc('0xb')](_0x2bbd0b['body']);if(_0x18eadd['length']>0x0){return _0x103bd1['status'](0x190)[_0x34bc('0x2d')](_0x18eadd);}var _0x1ed088=_0x2bbd0b['body'][_0x34bc('0x27')];var _0xe7b515=_0x2bbd0b[_0x34bc('0x26')][_0x34bc('0x22')];return getAgent(_0x1ed088)[_0x34bc('0x1e')](function(_0x5c82c2){logger['info']('entityFound:',_0x5c82c2[_0x34bc('0x13')]);emit(util[_0x34bc('0x31')](_0x34bc('0x2b'),_0x5c82c2[_0x34bc('0x13')]),_0x34bc('0x3c'),{'sessionId':_0xe7b515});return _0x103bd1['status'](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x3d')});})[_0x34bc('0x1b')](handleError(_0x103bd1));};exports[_0x34bc('0x3e')]=function(_0x58e4c3,_0x1a2cf2){logger[_0x34bc('0x29')](_0x34bc('0x3f'),_0x1a2cf2[_0x34bc('0x26')]);var _0x279a83=callsValidation[_0x34bc('0xb')](_0x58e4c3[_0x34bc('0x26')]);if(_0x279a83[_0x34bc('0x23')]>0x0){return _0x1a2cf2[_0x34bc('0x14')](0x190)[_0x34bc('0x2d')](_0x279a83);}var _0x39c580=_0x58e4c3[_0x34bc('0x26')][_0x34bc('0x27')];var _0x592e81=respondWithRpcPromise(_0x34bc('0x40'));var _0x2cc1f5=getAgent(_0x39c580);return Promise[_0x34bc('0x1d')]([_0x592e81,_0x2cc1f5])[_0x34bc('0x1e')](function(_0x426df1){var _0x1b3704=_0x426df1[0x0];var _0x31cf3a=_0x426df1[0x1];var _0x43337d=_[_0x34bc('0x1f')](_0x1b3704[_0x34bc('0x20')],function(_0x11cd4c){return _0x11cd4c[_0x34bc('0x21')]==_0x31cf3a['id'];});return _0x1a2cf2[_0x34bc('0x14')](0xc8)[_0x34bc('0x2d')]({'count':_0x43337d['length'],'rows':_0x43337d});})[_0x34bc('0x1b')](handleError(_0x1a2cf2));};exports[_0x34bc('0x41')]=function(_0x36143f,_0x320d86){logger[_0x34bc('0x29')](_0x34bc('0x42'),_0x36143f[_0x34bc('0x26')]);var _0x36d2fb=conferenceValidation[_0x34bc('0xb')](_0x36143f[_0x34bc('0x26')]);if(_0x36d2fb['length']>0x0){return _0x320d86[_0x34bc('0x14')](0x190)[_0x34bc('0x2d')](_0x36d2fb);}var _0x51bbbd=_0x36143f['body'][_0x34bc('0x27')];return getAgent(_0x51bbbd)[_0x34bc('0x1e')](function(_0x9dd563){logger[_0x34bc('0x29')]('entityFound:',_0x9dd563[_0x34bc('0x13')]);emit(util[_0x34bc('0x31')](_0x34bc('0x2b'),_0x9dd563[_0x34bc('0x13')]),_0x34bc('0x43'));return _0x320d86[_0x34bc('0x14')](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x44')});})['catch'](handleError(_0x320d86));};exports['transfer']=function(_0x405abb,_0x1dd036){logger[_0x34bc('0x29')](_0x34bc('0x45'),_0x405abb[_0x34bc('0x26')]);var _0x3066d9=transferValidation[_0x34bc('0xb')](_0x405abb[_0x34bc('0x26')]);if(_0x3066d9[_0x34bc('0x23')]>0x0){return _0x1dd036[_0x34bc('0x14')](0x190)[_0x34bc('0x2d')](_0x3066d9);}var _0x2d0d2c=_0x405abb[_0x34bc('0x26')][_0x34bc('0x27')];var _0x4d7c67=_0x405abb[_0x34bc('0x26')][_0x34bc('0x22')];var _0xa4e120=_0x405abb['body'][_0x34bc('0x46')];return getAgent(_0x2d0d2c)[_0x34bc('0x1e')](function(_0x124945){logger[_0x34bc('0x29')]('entityFound:',_0x124945[_0x34bc('0x13')]);emit(util[_0x34bc('0x31')](_0x34bc('0x2b'),_0x124945[_0x34bc('0x13')]),_0x34bc('0x47'),{'sessionId':_0x4d7c67,'transferNumber':_0xa4e120});return _0x1dd036['status'](0xc8)[_0x34bc('0x2d')]({'error':![],'message':_0x34bc('0x48')});})[_0x34bc('0x1b')](handleError(_0x1dd036));}; \ No newline at end of file diff --git a/server/api/whatsappAccount/index.js b/server/api/whatsappAccount/index.js new file mode 100644 index 0000000..d96cb5f --- /dev/null +++ b/server/api/whatsappAccount/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x33af=['getAnswers','/:id/users','/:id/applications','post','create','addDisposition','addAgents','addApplications','/:id/notify','/:id/send','send','put','/:id','update','delete','destroy','removeDispositions','/:id/canned_answers','removeAnswers','removeAgents','util','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','./whatsappAccount.controller','get','index','/describe','isAuthenticated','describe','show','/:id/dispositions','getDispositions'];(function(_0x494c4f,_0x5c97f5){var _0x117f33=function(_0x277a46){while(--_0x277a46){_0x494c4f['push'](_0x494c4f['shift']());}};_0x117f33(++_0x5c97f5);}(_0x33af,0xec));var _0xf33a=function(_0x590b61,_0x4c4335){_0x590b61=_0x590b61-0x0;var _0x1a14dc=_0x33af[_0x590b61];return _0x1a14dc;};'use strict';var multer=require('multer');var util=require(_0xf33a('0x0'));var path=require('path');var timeout=require(_0xf33a('0x1'));var express=require(_0xf33a('0x2'));var router=express[_0xf33a('0x3')]();var fs_extra=require(_0xf33a('0x4'));var auth=require(_0xf33a('0x5'));var interaction=require(_0xf33a('0x6'));var config=require('../../config/environment');var controller=require(_0xf33a('0x7'));router[_0xf33a('0x8')]('/',auth['isAuthenticated'](),controller[_0xf33a('0x9')]);router[_0xf33a('0x8')](_0xf33a('0xa'),auth[_0xf33a('0xb')](),controller[_0xf33a('0xc')]);router[_0xf33a('0x8')]('/:id',auth[_0xf33a('0xb')](),controller[_0xf33a('0xd')]);router[_0xf33a('0x8')](_0xf33a('0xe'),auth[_0xf33a('0xb')](),controller[_0xf33a('0xf')]);router['get']('/:id/canned_answers',auth[_0xf33a('0xb')](),controller[_0xf33a('0x10')]);router[_0xf33a('0x8')](_0xf33a('0x11'),auth[_0xf33a('0xb')](),controller['getAgents']);router[_0xf33a('0x8')](_0xf33a('0x12'),auth['isAuthenticated'](),controller['getApplications']);router[_0xf33a('0x13')]('/',auth[_0xf33a('0xb')](),controller[_0xf33a('0x14')]);router[_0xf33a('0x13')](_0xf33a('0xe'),auth[_0xf33a('0xb')](),controller[_0xf33a('0x15')]);router[_0xf33a('0x13')]('/:id/canned_answers',auth[_0xf33a('0xb')](),controller['addAnswer']);router[_0xf33a('0x13')](_0xf33a('0x11'),auth['isAuthenticated'](),controller[_0xf33a('0x16')]);router[_0xf33a('0x13')]('/:id/applications',auth[_0xf33a('0xb')](),controller[_0xf33a('0x17')]);router[_0xf33a('0x13')](_0xf33a('0x18'),controller['notify']);router[_0xf33a('0x13')](_0xf33a('0x19'),auth[_0xf33a('0xb')](),controller[_0xf33a('0x1a')]);router[_0xf33a('0x1b')](_0xf33a('0x1c'),auth[_0xf33a('0xb')](),controller[_0xf33a('0x1d')]);router[_0xf33a('0x1e')](_0xf33a('0x1c'),auth['isAuthenticated'](),controller[_0xf33a('0x1f')]);router[_0xf33a('0x1e')](_0xf33a('0xe'),auth[_0xf33a('0xb')](),controller[_0xf33a('0x20')]);router['delete'](_0xf33a('0x21'),auth['isAuthenticated'](),controller[_0xf33a('0x22')]);router[_0xf33a('0x1e')](_0xf33a('0x11'),auth[_0xf33a('0xb')](),controller[_0xf33a('0x23')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.attributes.js b/server/api/whatsappAccount/whatsappAccount.attributes.js new file mode 100644 index 0000000..670fc8e --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x046b=['generate','ENUM','twilio','sinch','TEXT','BOOLEAN','INTEGER','Enabled/disables\x20mandatory\x20dispo\x20on\x20a\x20queue','setDataValue','mandatoryDispositionPauseId','mandatoryDisposition','sequelize','randomstring','exports','STRING','name'];(function(_0x4382bc,_0x231a2d){var _0x13c82a=function(_0x3723b0){while(--_0x3723b0){_0x4382bc['push'](_0x4382bc['shift']());}};_0x13c82a(++_0x231a2d);}(_0x046b,0x11b));var _0xb046=function(_0x51c699,_0x38d5f4){_0x51c699=_0x51c699-0x0;var _0x418e9f=_0x046b[_0x51c699];return _0x418e9f;};'use strict';var Sequelize=require(_0xb046('0x0'));var rs=require(_0xb046('0x1'));module[_0xb046('0x2')]={'name':{'type':Sequelize[_0xb046('0x3')],'unique':_0xb046('0x4'),'allowNull':![]},'key':{'type':Sequelize[_0xb046('0x3')],'allowNull':![]},'remote':{'type':Sequelize[_0xb046('0x3')],'allowNull':![]},'token':{'type':Sequelize['STRING'],'defaultValue':function(){return rs[_0xb046('0x5')]();}},'phone':{'type':Sequelize[_0xb046('0x3')]},'type':{'type':Sequelize[_0xb046('0x6')](_0xb046('0x7'),_0xb046('0x8'))},'accountSid':{'type':Sequelize[_0xb046('0x3')]},'baseUrl':{'type':Sequelize[_0xb046('0x3')]},'authToken':{'type':Sequelize['STRING']},'notificationTemplate':{'type':Sequelize[_0xb046('0x9')],'defaultValue':function(){return'Account:\x20{{account.name}}
{{#queue}}Queue:\x20{{queue.name}}
{{/queue}}From\x20:\x20{{from}}';}},'notificationSound':{'type':Sequelize[_0xb046('0xa')],'defaultValue':![]},'notificationShake':{'type':Sequelize[_0xb046('0xa')],'defaultValue':![]},'waitForTheAssignedAgent':{'type':Sequelize['INTEGER'],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0xa},'queueTransfer':{'type':Sequelize[_0xb046('0xa')],'defaultValue':![]},'queueTransferTimeout':{'type':Sequelize[_0xb046('0xb')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'agentTransfer':{'type':Sequelize[_0xb046('0xa')],'defaultValue':![]},'agentTransferTimeout':{'type':Sequelize[_0xb046('0xb')],'validate':{'min':0x1,'max':0x20c49b},'defaultValue':0x12c},'mandatoryDispositionPauseId':{'type':Sequelize[_0xb046('0xb')],'comment':'Status\x20to\x20put\x20when\x20mandatory\x20disposition\x20is\x20enabled'},'mandatoryDisposition':{'type':Sequelize[_0xb046('0xa')],'defaultValue':![],'comment':_0xb046('0xc'),'set':function(_0x3fe806){if(!_0x3fe806){this[_0xb046('0xd')](_0xb046('0xe'),null);}this[_0xb046('0xd')](_0xb046('0xf'),_0x3fe806);}},'description':{'type':Sequelize[_0xb046('0x3')]}}; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.controller.js b/server/api/whatsappAccount/whatsappAccount.controller.js new file mode 100644 index 0000000..0e561e8 --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xca97=['querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','redis','defaults','socket.io-emitter','register','jayson/promise','client','http','request','then','info','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','WhatsappAccount,\x20%s,\x20%s','message','result','catch','sendStatus','end','status','json','offset','limit','undefined','count','set','apply','reject','save','update','WhatsappAccounts','UserProfileResource','destroy','stack','name','send','index','Pause','mandatoryDispositionPause','map','WhatsappAccount','rawAttributes','fieldName','type','model','query','keys','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','includeAll','include','findAll','rows','filters','find','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','WhatsappAccountId','getDispositions','findOne','length','filter','Disposition','removeDispositions','addAnswer','CannedAnswer','getAnswers','removeAnswers','ids','addAgents','omit','emit','userWhatsappAccount:save','removeAgents','isArray','userWhatsappAccount:remove','User','getAgents','addApplications','sequelize','transaction','Transaction','READ_COMMITTED','bulkCreate','priority','finally','getApplications','WhatsappApplication','notify','whatsapp','Applications','account','sinch','statuses','state','read','WhatsappMessage','timestamp','message_id','applications','orderBy','asc','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','createdAt','updatedAt','difference','ListId','twilio','from','whatsapp:','Body','messageId','notifications','isNil','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','CmList','DESC','list','Contacts','WhatsappInteraction','spread','interaction','push','unmanaged','*,*,*,*','created','ContactId','AttachmentId','UserId','agent','waitForTheAssignedAgent','Start','startRouting','receiveMessage','entity\x20found','WhatsappAccount,\x20%s,\x20%s,\x20%s,\x20%s','Content-Type','text/xml','\x0a','body\x20is\x20mandatory\x20and\x20not\x20empty','to\x20is\x20mandatory','List','out','Messages','dataValues','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','ejs','lodash','squel','jsforce','to-csv'];(function(_0x47a349,_0x4699d9){var _0x18ab75=function(_0x210796){while(--_0x210796){_0x47a349['push'](_0x47a349['shift']());}};_0x18ab75(++_0x4699d9);}(_0xca97,0xb6));var _0x7ca9=function(_0x31e29a,_0x349c9b){_0x31e29a=_0x31e29a-0x0;var _0x32d892=_0xca97[_0x31e29a];return _0x32d892;};'use strict';var emlformat=require(_0x7ca9('0x0'));var rimraf=require(_0x7ca9('0x1'));var zipdir=require(_0x7ca9('0x2'));var jsonpatch=require(_0x7ca9('0x3'));var rp=require('request-promise');var moment=require(_0x7ca9('0x4'));var BPromise=require(_0x7ca9('0x5'));var Mustache=require(_0x7ca9('0x6'));var util=require(_0x7ca9('0x7'));var path=require('path');var sox=require(_0x7ca9('0x8'));var csv=require('to-csv');var ejs=require(_0x7ca9('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7ca9('0xa'));var squel=require(_0x7ca9('0xb'));var crypto=require('crypto');var jsforce=require(_0x7ca9('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x7ca9('0xd'));var querystring=require(_0x7ca9('0xe'));var Papa=require(_0x7ca9('0xf'));var Redis=require(_0x7ca9('0x10'));var authService=require(_0x7ca9('0x11'));var qs=require(_0x7ca9('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x7ca9('0x13'));var logger=require(_0x7ca9('0x14'))(_0x7ca9('0x15'));var utils=require(_0x7ca9('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x7ca9('0x17')]=_[_0x7ca9('0x18')](config[_0x7ca9('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0x7ca9('0x19'))(new Redis(config[_0x7ca9('0x17')]));require('./whatsappAccount.socket')[_0x7ca9('0x1a')](socket);var jayson=require(_0x7ca9('0x1b'));var client=jayson[_0x7ca9('0x1c')][_0x7ca9('0x1d')]({'port':0x232c});function respondWithRpcPromise(_0x15776d,_0x2a50e7,_0x1ff6b1,_0x47aa4c){return new BPromise(function(_0x2a94b0,_0x2116e9){var _0x109b6b=_0x47aa4c||client;return _0x109b6b[_0x7ca9('0x1e')](_0x15776d,_0x1ff6b1)[_0x7ca9('0x1f')](function(_0x46065f){logger[_0x7ca9('0x20')]('WhatsappAccount,\x20%s,\x20%s',_0x2a50e7,'request\x20sent');logger[_0x7ca9('0x21')](_0x7ca9('0x22'),_0x2a50e7,_0x7ca9('0x23'),JSON[_0x7ca9('0x24')](_0x46065f));if(_0x46065f[_0x7ca9('0x25')]){if(_0x46065f[_0x7ca9('0x25')][_0x7ca9('0x26')]===0x1f4){logger['error'](_0x7ca9('0x27'),_0x2a50e7,_0x46065f[_0x7ca9('0x25')]['message']);return _0x2116e9(_0x46065f[_0x7ca9('0x25')][_0x7ca9('0x28')]);}logger['error'](_0x7ca9('0x27'),_0x2a50e7,_0x46065f[_0x7ca9('0x25')][_0x7ca9('0x28')]);return _0x2a94b0(_0x46065f[_0x7ca9('0x25')][_0x7ca9('0x28')]);}else{logger[_0x7ca9('0x20')]('WhatsappAccount,\x20%s,\x20%s',_0x2a50e7,'request\x20sent');_0x2a94b0(_0x46065f[_0x7ca9('0x29')][_0x7ca9('0x28')]);}})[_0x7ca9('0x2a')](function(_0x1cc852){logger[_0x7ca9('0x25')]('WhatsappAccount,\x20%s,\x20%s',_0x2a50e7,_0x1cc852);_0x2116e9(_0x1cc852);});});}function respondWithStatusCode(_0x4bdbcb,_0x2204fa){_0x2204fa=_0x2204fa||0xcc;return function(_0x36c9a9){if(_0x36c9a9){return _0x4bdbcb[_0x7ca9('0x2b')](_0x2204fa);}return _0x4bdbcb['status'](_0x2204fa)[_0x7ca9('0x2c')]();};}function respondWithResult(_0x268691,_0x35ddff){_0x35ddff=_0x35ddff||0xc8;return function(_0x4ef040){if(_0x4ef040){return _0x268691[_0x7ca9('0x2d')](_0x35ddff)[_0x7ca9('0x2e')](_0x4ef040);}};}function respondWithFilteredResult(_0x46107f,_0xaa395c){return function(_0x175a55){if(_0x175a55){var _0x1ff4ac=typeof _0xaa395c[_0x7ca9('0x2f')]==='undefined'&&typeof _0xaa395c[_0x7ca9('0x30')]===_0x7ca9('0x31');var _0xfb1fb0=_0x175a55[_0x7ca9('0x32')];var _0x2ad130=_0x1ff4ac?0x0:_0xaa395c['offset'];var _0x5e6912=_0x1ff4ac?_0x175a55['count']:_0xaa395c['offset']+_0xaa395c[_0x7ca9('0x30')];var _0x394e7f;if(_0x5e6912>=_0xfb1fb0){_0x5e6912=_0xfb1fb0;_0x394e7f=0xc8;}else{_0x394e7f=0xce;}_0x46107f[_0x7ca9('0x2d')](_0x394e7f);return _0x46107f[_0x7ca9('0x33')]('Content-Range',_0x2ad130+'-'+_0x5e6912+'/'+_0xfb1fb0)[_0x7ca9('0x2e')](_0x175a55);}return null;};}function patchUpdates(_0x17361e){return function(_0x5b6a4a){try{jsonpatch[_0x7ca9('0x34')](_0x5b6a4a,_0x17361e,!![]);}catch(_0x5cb73f){return BPromise[_0x7ca9('0x35')](_0x5cb73f);}return _0x5b6a4a[_0x7ca9('0x36')]();};}function saveUpdates(_0x5080dc,_0x57d954){return function(_0x33c617){if(_0x33c617){return _0x33c617[_0x7ca9('0x37')](_0x5080dc)[_0x7ca9('0x1f')](function(_0x5cc1b1){return _0x5cc1b1;});}return null;};}function removeEntity(_0xd2b101,_0x396419){return function(_0x446785){if(_0x446785){return _0x446785['destroy']()['then'](function(){var _0x152279=_0x446785['get']({'plain':!![]});var _0x5b9b54=_0x7ca9('0x38');return db[_0x7ca9('0x39')][_0x7ca9('0x3a')]({'where':{'type':_0x5b9b54,'resourceId':_0x152279['id']}})[_0x7ca9('0x1f')](function(){return _0x446785;});})[_0x7ca9('0x1f')](function(){_0xd2b101[_0x7ca9('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x44cd60,_0x3f55cd){return function(_0x5077c9){if(!_0x5077c9){_0x44cd60[_0x7ca9('0x2b')](0x194);}return _0x5077c9;};}function handleError(_0x323208,_0x214974){_0x214974=_0x214974||0x1f4;return function(_0x31a162){logger['error'](_0x31a162[_0x7ca9('0x3b')]);if(_0x31a162[_0x7ca9('0x3c')]){delete _0x31a162[_0x7ca9('0x3c')];}_0x323208[_0x7ca9('0x2d')](_0x214974)[_0x7ca9('0x3d')](_0x31a162);};}exports[_0x7ca9('0x3e')]=function(_0x49b365,_0x148b88){var _0x45d151={'include':[{'model':db[_0x7ca9('0x3f')],'as':_0x7ca9('0x40')}]},_0x5c358a={},_0x32a13a={'count':0x0,'rows':[]};var _0x2cc1ff=_[_0x7ca9('0x41')](db[_0x7ca9('0x42')][_0x7ca9('0x43')],function(_0x1f77b3){return{'name':_0x1f77b3[_0x7ca9('0x44')],'type':_0x1f77b3[_0x7ca9('0x45')]['key']};});_0x5c358a[_0x7ca9('0x46')]=_[_0x7ca9('0x41')](_0x2cc1ff,_0x7ca9('0x3c'));_0x5c358a[_0x7ca9('0x47')]=_[_0x7ca9('0x48')](_0x49b365[_0x7ca9('0x47')]);_0x5c358a['filters']=_['intersection'](_0x5c358a[_0x7ca9('0x46')],_0x5c358a[_0x7ca9('0x47')]);_0x45d151[_0x7ca9('0x49')]=_[_0x7ca9('0x4a')](_0x5c358a[_0x7ca9('0x46')],qs[_0x7ca9('0x4b')](_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x4b')]));_0x45d151['attributes']=_0x45d151[_0x7ca9('0x49')]['length']?_0x45d151[_0x7ca9('0x49')]:_0x5c358a[_0x7ca9('0x46')];if(!_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x4c')](_0x7ca9('0x4d'))){_0x45d151[_0x7ca9('0x30')]=qs[_0x7ca9('0x30')](_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x30')]);_0x45d151['offset']=qs[_0x7ca9('0x2f')](_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x2f')]);}_0x45d151[_0x7ca9('0x4e')]=qs[_0x7ca9('0x4f')](_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x4f')]);_0x45d151[_0x7ca9('0x50')]=qs['filters'](_[_0x7ca9('0x51')](_0x49b365[_0x7ca9('0x47')],_0x5c358a['filters']),_0x2cc1ff);if(_0x49b365[_0x7ca9('0x47')]['filter']){_0x45d151[_0x7ca9('0x50')]=_[_0x7ca9('0x52')](_0x45d151['where'],{'$or':_[_0x7ca9('0x41')](_0x2cc1ff,function(_0x1b4f19){if(_0x1b4f19['type']!==_0x7ca9('0x53')){var _0x1e9e21={};_0x1e9e21[_0x1b4f19[_0x7ca9('0x3c')]]={'$like':'%'+_0x49b365[_0x7ca9('0x47')]['filter']+'%'};return _0x1e9e21;}})});}_0x45d151=_[_0x7ca9('0x52')]({},_0x45d151,_0x49b365[_0x7ca9('0x54')]);var _0x423dfb={'where':_0x45d151['where']};return db['WhatsappAccount'][_0x7ca9('0x32')](_0x423dfb)['then'](function(_0x2c76b4){_0x32a13a[_0x7ca9('0x32')]=_0x2c76b4;if(_0x49b365[_0x7ca9('0x47')][_0x7ca9('0x55')]){_0x45d151[_0x7ca9('0x56')]=[{'all':!![]}];}return db[_0x7ca9('0x42')][_0x7ca9('0x57')](_0x45d151);})[_0x7ca9('0x1f')](function(_0x59c03a){_0x32a13a[_0x7ca9('0x58')]=_0x59c03a;return _0x32a13a;})[_0x7ca9('0x1f')](respondWithFilteredResult(_0x148b88,_0x45d151))[_0x7ca9('0x2a')](handleError(_0x148b88,null));};exports['show']=function(_0x556d20,_0x2d7bd1){var _0x26b106={'raw':![],'where':{'id':_0x556d20['params']['id']},'include':[{'model':db[_0x7ca9('0x3f')],'as':'mandatoryDispositionPause'}]},_0x33ec40={};_0x33ec40[_0x7ca9('0x46')]=_[_0x7ca9('0x48')](db[_0x7ca9('0x42')][_0x7ca9('0x43')]);_0x33ec40[_0x7ca9('0x47')]=_[_0x7ca9('0x48')](_0x556d20[_0x7ca9('0x47')]);_0x33ec40[_0x7ca9('0x59')]=_[_0x7ca9('0x4a')](_0x33ec40['model'],_0x33ec40[_0x7ca9('0x47')]);_0x26b106[_0x7ca9('0x49')]=_[_0x7ca9('0x4a')](_0x33ec40[_0x7ca9('0x46')],qs[_0x7ca9('0x4b')](_0x556d20['query'][_0x7ca9('0x4b')]));_0x26b106[_0x7ca9('0x49')]=_0x26b106[_0x7ca9('0x49')]['length']?_0x26b106['attributes']:_0x33ec40[_0x7ca9('0x46')];if(_0x556d20[_0x7ca9('0x47')]['includeAll']){_0x26b106[_0x7ca9('0x56')]=[{'all':!![]}];}_0x26b106=_[_0x7ca9('0x52')]({},_0x26b106,_0x556d20[_0x7ca9('0x54')]);return db[_0x7ca9('0x42')][_0x7ca9('0x5a')](_0x26b106)[_0x7ca9('0x1f')](handleEntityNotFound(_0x2d7bd1,null))[_0x7ca9('0x1f')](respondWithResult(_0x2d7bd1,null))[_0x7ca9('0x2a')](handleError(_0x2d7bd1,null));};exports[_0x7ca9('0x5b')]=function(_0xdf7bc1,_0x1db66d){return db['WhatsappAccount'][_0x7ca9('0x5b')](_0xdf7bc1['body'],{})[_0x7ca9('0x1f')](function(_0x3f24d8){var _0x41f9a2=_0xdf7bc1['user'][_0x7ca9('0x5c')]({'plain':!![]});if(!_0x41f9a2)throw new Error(_0x7ca9('0x5d'));if(_0x41f9a2[_0x7ca9('0x5e')]===_0x7ca9('0x5f')){var _0x50ca53=_0x3f24d8[_0x7ca9('0x5c')]({'plain':!![]});var _0x381a6b=_0x7ca9('0x38');return db[_0x7ca9('0x60')][_0x7ca9('0x5a')]({'where':{'name':_0x381a6b,'userProfileId':_0x41f9a2['userProfileId']},'raw':!![]})[_0x7ca9('0x1f')](function(_0x5efc6b){if(_0x5efc6b&&_0x5efc6b[_0x7ca9('0x61')]===0x0){return db[_0x7ca9('0x39')]['create']({'name':_0x50ca53[_0x7ca9('0x3c')],'resourceId':_0x50ca53['id'],'type':_0x5efc6b['name'],'sectionId':_0x5efc6b['id']},{})['then'](function(){return _0x3f24d8;});}else{return _0x3f24d8;}})[_0x7ca9('0x2a')](function(_0x5b5491){logger[_0x7ca9('0x25')](_0x7ca9('0x62'),_0x5b5491);throw _0x5b5491;});}return _0x3f24d8;})[_0x7ca9('0x1f')](respondWithResult(_0x1db66d,0xc9))[_0x7ca9('0x2a')](handleError(_0x1db66d,null));};exports['update']=function(_0x5ef30e,_0x586f65){if(_0x5ef30e[_0x7ca9('0x63')]['id']){delete _0x5ef30e[_0x7ca9('0x63')]['id'];}return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x5ef30e[_0x7ca9('0x64')]['id']},'include':[{'model':db[_0x7ca9('0x3f')],'as':_0x7ca9('0x40')}]})[_0x7ca9('0x1f')](handleEntityNotFound(_0x586f65,null))[_0x7ca9('0x1f')](saveUpdates(_0x5ef30e[_0x7ca9('0x63')],null))[_0x7ca9('0x1f')](respondWithResult(_0x586f65,null))['catch'](handleError(_0x586f65,null));};exports[_0x7ca9('0x3a')]=function(_0x57466e,_0x1897e1){return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x57466e[_0x7ca9('0x64')]['id']}})['then'](handleEntityNotFound(_0x1897e1,null))[_0x7ca9('0x1f')](removeEntity(_0x1897e1,null))['catch'](handleError(_0x1897e1,null));};exports[_0x7ca9('0x65')]=function(_0x7d3e66,_0x247e87){return db['WhatsappAccount'][_0x7ca9('0x65')]()[_0x7ca9('0x1f')](respondWithResult(_0x247e87,null))[_0x7ca9('0x2a')](handleError(_0x247e87,null));};exports[_0x7ca9('0x66')]=function(_0x1192af,_0x21683a,_0x43b0a4){if(_0x1192af[_0x7ca9('0x63')]['id']){delete _0x1192af[_0x7ca9('0x63')]['id'];}return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x1192af[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x21683a,null))[_0x7ca9('0x1f')](function(_0x474453){if(_0x474453){_0x1192af[_0x7ca9('0x63')][_0x7ca9('0x67')]=_0x474453['id'];return db['Disposition'][_0x7ca9('0x5b')](_0x1192af['body']);}})[_0x7ca9('0x1f')](respondWithResult(_0x21683a,null))[_0x7ca9('0x2a')](handleError(_0x21683a,null));};exports[_0x7ca9('0x68')]=function(_0x181447,_0x5e0477,_0x149a76){var _0x584481={'raw':![],'where':{}};var _0xcab269={};var _0x1a89ca={'count':0x0,'rows':[]};return db['WhatsappAccount'][_0x7ca9('0x69')]({'where':{'id':_0x181447[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x5e0477,null))[_0x7ca9('0x1f')](function(_0x577215){if(_0x577215){_0xcab269[_0x7ca9('0x46')]=_[_0x7ca9('0x48')](db['Disposition'][_0x7ca9('0x43')]);_0xcab269['query']=_[_0x7ca9('0x48')](_0x181447['query']);_0xcab269[_0x7ca9('0x59')]=_[_0x7ca9('0x4a')](_0xcab269['model'],_0xcab269[_0x7ca9('0x47')]);_0x584481[_0x7ca9('0x49')]=_[_0x7ca9('0x4a')](_0xcab269[_0x7ca9('0x46')],qs['fields'](_0x181447[_0x7ca9('0x47')][_0x7ca9('0x4b')]));_0x584481[_0x7ca9('0x49')]=_0x584481[_0x7ca9('0x49')][_0x7ca9('0x6a')]?_0x584481[_0x7ca9('0x49')]:_0xcab269[_0x7ca9('0x46')];if(!_0x181447[_0x7ca9('0x47')][_0x7ca9('0x4c')](_0x7ca9('0x4d'))){_0x584481[_0x7ca9('0x30')]=qs['limit'](_0x181447[_0x7ca9('0x47')][_0x7ca9('0x30')]);_0x584481[_0x7ca9('0x2f')]=qs['offset'](_0x181447[_0x7ca9('0x47')][_0x7ca9('0x2f')]);}_0x584481[_0x7ca9('0x4e')]=qs[_0x7ca9('0x4f')](_0x181447[_0x7ca9('0x47')][_0x7ca9('0x4f')]);_0x584481['where']=qs[_0x7ca9('0x59')](_['pick'](_0x181447['query'],_0xcab269[_0x7ca9('0x59')]));_0x584481['where']['WhatsappAccountId']=_0x577215['id'];if(_0x181447[_0x7ca9('0x47')][_0x7ca9('0x6b')]){_0x584481[_0x7ca9('0x50')]=_[_0x7ca9('0x52')](_0x584481[_0x7ca9('0x50')],{'$or':_[_0x7ca9('0x41')](_0x584481[_0x7ca9('0x49')],function(_0x417640){var _0xfddd13={};_0xfddd13[_0x417640]={'$like':'%'+_0x181447[_0x7ca9('0x47')][_0x7ca9('0x6b')]+'%'};return _0xfddd13;})});}_0x584481=_[_0x7ca9('0x52')]({},_0x584481,_0x181447['options']);return db[_0x7ca9('0x6c')][_0x7ca9('0x32')]({'where':_0x584481[_0x7ca9('0x50')]})[_0x7ca9('0x1f')](function(_0x3d1ab4){_0x1a89ca[_0x7ca9('0x32')]=_0x3d1ab4;if(_0x181447[_0x7ca9('0x47')][_0x7ca9('0x55')]){_0x584481['include']=[{'all':!![]}];}return db[_0x7ca9('0x6c')][_0x7ca9('0x57')](_0x584481);})[_0x7ca9('0x1f')](function(_0x41f20b){_0x1a89ca[_0x7ca9('0x58')]=_0x41f20b;return _0x1a89ca;});}})[_0x7ca9('0x1f')](respondWithFilteredResult(_0x5e0477,_0x584481))[_0x7ca9('0x2a')](handleError(_0x5e0477,null));};exports[_0x7ca9('0x6d')]=function(_0x3fca75,_0x5260b1,_0x23b91c){return db[_0x7ca9('0x42')]['find']({'where':{'id':_0x3fca75['params']['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x5260b1,null))['then'](function(_0x3101f3){if(_0x3101f3){return _0x3101f3[_0x7ca9('0x6d')](_0x3fca75[_0x7ca9('0x47')]['ids']);}})[_0x7ca9('0x1f')](respondWithStatusCode(_0x5260b1,null))[_0x7ca9('0x2a')](handleError(_0x5260b1,null));};exports[_0x7ca9('0x6e')]=function(_0x599538,_0x51ac4d,_0x1e3aeb){if(_0x599538[_0x7ca9('0x63')]['id']){delete _0x599538[_0x7ca9('0x63')]['id'];}return db['WhatsappAccount'][_0x7ca9('0x5a')]({'where':{'id':_0x599538[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x51ac4d,null))[_0x7ca9('0x1f')](function(_0x59b90f){if(_0x59b90f){_0x599538[_0x7ca9('0x63')]['WhatsappAccountId']=_0x59b90f['id'];return db[_0x7ca9('0x6f')]['create'](_0x599538[_0x7ca9('0x63')]);}})[_0x7ca9('0x1f')](respondWithResult(_0x51ac4d,null))[_0x7ca9('0x2a')](handleError(_0x51ac4d,null));};exports[_0x7ca9('0x70')]=function(_0x333745,_0x360e01,_0x416b2a){var _0x3724c6={'raw':![],'where':{}};var _0x4bbb2c={};var _0x4b06f1={'count':0x0,'rows':[]};return db[_0x7ca9('0x42')][_0x7ca9('0x69')]({'where':{'id':_0x333745[_0x7ca9('0x64')]['id']}})['then'](handleEntityNotFound(_0x360e01,null))[_0x7ca9('0x1f')](function(_0x3726ab){if(_0x3726ab){_0x4bbb2c[_0x7ca9('0x46')]=_[_0x7ca9('0x48')](db[_0x7ca9('0x6f')]['rawAttributes']);_0x4bbb2c[_0x7ca9('0x47')]=_[_0x7ca9('0x48')](_0x333745[_0x7ca9('0x47')]);_0x4bbb2c[_0x7ca9('0x59')]=_['intersection'](_0x4bbb2c[_0x7ca9('0x46')],_0x4bbb2c[_0x7ca9('0x47')]);_0x3724c6[_0x7ca9('0x49')]=_[_0x7ca9('0x4a')](_0x4bbb2c['model'],qs[_0x7ca9('0x4b')](_0x333745[_0x7ca9('0x47')][_0x7ca9('0x4b')]));_0x3724c6[_0x7ca9('0x49')]=_0x3724c6['attributes'][_0x7ca9('0x6a')]?_0x3724c6[_0x7ca9('0x49')]:_0x4bbb2c[_0x7ca9('0x46')];if(!_0x333745[_0x7ca9('0x47')]['hasOwnProperty'](_0x7ca9('0x4d'))){_0x3724c6[_0x7ca9('0x30')]=qs[_0x7ca9('0x30')](_0x333745[_0x7ca9('0x47')][_0x7ca9('0x30')]);_0x3724c6[_0x7ca9('0x2f')]=qs[_0x7ca9('0x2f')](_0x333745['query'][_0x7ca9('0x2f')]);}_0x3724c6['order']=qs['sort'](_0x333745[_0x7ca9('0x47')][_0x7ca9('0x4f')]);_0x3724c6[_0x7ca9('0x50')]=qs['filters'](_['pick'](_0x333745[_0x7ca9('0x47')],_0x4bbb2c[_0x7ca9('0x59')]));_0x3724c6[_0x7ca9('0x50')][_0x7ca9('0x67')]=_0x3726ab['id'];if(_0x333745[_0x7ca9('0x47')][_0x7ca9('0x6b')]){_0x3724c6[_0x7ca9('0x50')]=_[_0x7ca9('0x52')](_0x3724c6[_0x7ca9('0x50')],{'$or':_[_0x7ca9('0x41')](_0x3724c6[_0x7ca9('0x49')],function(_0x5dc313){var _0x277bed={};_0x277bed[_0x5dc313]={'$like':'%'+_0x333745['query'][_0x7ca9('0x6b')]+'%'};return _0x277bed;})});}_0x3724c6=_['merge']({},_0x3724c6,_0x333745[_0x7ca9('0x54')]);return db['CannedAnswer'][_0x7ca9('0x32')]({'where':_0x3724c6['where']})[_0x7ca9('0x1f')](function(_0x144082){_0x4b06f1[_0x7ca9('0x32')]=_0x144082;if(_0x333745['query']['includeAll']){_0x3724c6[_0x7ca9('0x56')]=[{'all':!![]}];}return db[_0x7ca9('0x6f')]['findAll'](_0x3724c6);})[_0x7ca9('0x1f')](function(_0x285660){_0x4b06f1[_0x7ca9('0x58')]=_0x285660;return _0x4b06f1;});}})[_0x7ca9('0x1f')](respondWithFilteredResult(_0x360e01,_0x3724c6))[_0x7ca9('0x2a')](handleError(_0x360e01,null));};exports[_0x7ca9('0x71')]=function(_0x49df1d,_0x3f256c,_0x459328){return db['WhatsappAccount'][_0x7ca9('0x5a')]({'where':{'id':_0x49df1d[_0x7ca9('0x64')]['id']}})['then'](handleEntityNotFound(_0x3f256c,null))[_0x7ca9('0x1f')](function(_0x949007){if(_0x949007){return _0x949007['removeAnswers'](_0x49df1d[_0x7ca9('0x47')][_0x7ca9('0x72')]);}})[_0x7ca9('0x1f')](respondWithStatusCode(_0x3f256c,null))[_0x7ca9('0x2a')](handleError(_0x3f256c,null));};exports['addAgents']=function(_0x1275a4,_0x2ee2cd,_0x1a9646){return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x1275a4[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x2ee2cd,null))[_0x7ca9('0x1f')](function(_0x394e59){if(_0x394e59){return _0x394e59[_0x7ca9('0x73')](_0x1275a4['body'][_0x7ca9('0x72')],_[_0x7ca9('0x74')](_0x1275a4[_0x7ca9('0x63')],[_0x7ca9('0x72'),'id'])||{})['spread'](function(_0x21dbac){for(var _0x2c7a6f=0x0;_0x2c7a6f<_0x1275a4[_0x7ca9('0x63')][_0x7ca9('0x72')][_0x7ca9('0x6a')];_0x2c7a6f+=0x1){socket[_0x7ca9('0x75')](_0x7ca9('0x76'),{'UserId':Number(_0x1275a4['body'][_0x7ca9('0x72')][_0x2c7a6f]),'WhatsappAccountId':Number(_0x1275a4['params']['id'])});}return _0x21dbac;});}})[_0x7ca9('0x1f')](respondWithResult(_0x2ee2cd,null))[_0x7ca9('0x2a')](handleError(_0x2ee2cd,null));};exports[_0x7ca9('0x77')]=function(_0x19fd63,_0x26b3c7,_0x45dae3){return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x19fd63[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x26b3c7,null))[_0x7ca9('0x1f')](function(_0x4a14a0){if(_0x4a14a0){return _0x4a14a0[_0x7ca9('0x77')](_0x19fd63[_0x7ca9('0x47')][_0x7ca9('0x72')])['then'](function(){if(_[_0x7ca9('0x78')](_0x19fd63[_0x7ca9('0x47')][_0x7ca9('0x72')])){for(var _0x24ff1a=0x0;_0x24ff1a<_0x19fd63[_0x7ca9('0x47')][_0x7ca9('0x72')][_0x7ca9('0x6a')];_0x24ff1a+=0x1){socket[_0x7ca9('0x75')]('userWhatsappAccount:remove',{'UserId':Number(_0x19fd63['query']['ids'][_0x24ff1a]),'WhatsappAccountId':Number(_0x19fd63[_0x7ca9('0x64')]['id'])});}}else{socket[_0x7ca9('0x75')](_0x7ca9('0x79'),{'UserId':Number(_0x19fd63[_0x7ca9('0x47')][_0x7ca9('0x72')]),'WhatsappAccountId':Number(_0x19fd63[_0x7ca9('0x64')]['id'])});}});}})[_0x7ca9('0x1f')](respondWithStatusCode(_0x26b3c7,null))[_0x7ca9('0x2a')](handleError(_0x26b3c7,null));};exports['getAgents']=function(_0x132e07,_0x2e8af1,_0x36ac17){var _0x6fda05={};var _0x219ffe={};var _0x2f6375;var _0x444893;return db[_0x7ca9('0x42')]['findOne']({'where':{'id':_0x132e07[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x2e8af1,null))['then'](function(_0x590330){if(_0x590330){_0x2f6375=_0x590330;_0x219ffe[_0x7ca9('0x46')]=_[_0x7ca9('0x48')](db[_0x7ca9('0x7a')][_0x7ca9('0x43')]);_0x219ffe[_0x7ca9('0x47')]=_['keys'](_0x132e07[_0x7ca9('0x47')]);_0x219ffe['filters']=_[_0x7ca9('0x4a')](_0x219ffe[_0x7ca9('0x46')],_0x219ffe[_0x7ca9('0x47')]);_0x6fda05['attributes']=_['intersection'](_0x219ffe['model'],qs['fields'](_0x132e07['query'][_0x7ca9('0x4b')]));_0x6fda05['attributes']=_0x6fda05[_0x7ca9('0x49')]['length']?_0x6fda05[_0x7ca9('0x49')]:_0x219ffe[_0x7ca9('0x46')];_0x6fda05['order']=qs[_0x7ca9('0x4f')](_0x132e07[_0x7ca9('0x47')][_0x7ca9('0x4f')]);_0x6fda05[_0x7ca9('0x50')]=qs[_0x7ca9('0x59')](_[_0x7ca9('0x51')](_0x132e07[_0x7ca9('0x47')],_0x219ffe['filters']));if(_0x132e07[_0x7ca9('0x47')]['filter']){_0x6fda05[_0x7ca9('0x50')]=_['merge'](_0x6fda05[_0x7ca9('0x50')],{'$or':_[_0x7ca9('0x41')](_0x6fda05[_0x7ca9('0x49')],function(_0x566eb7){var _0x4b3db3={};_0x4b3db3[_0x566eb7]={'$like':'%'+_0x132e07[_0x7ca9('0x47')][_0x7ca9('0x6b')]+'%'};return _0x4b3db3;})});}_0x6fda05=_[_0x7ca9('0x52')]({},_0x6fda05,_0x132e07[_0x7ca9('0x54')]);return _0x2f6375[_0x7ca9('0x7b')](_0x6fda05);}})[_0x7ca9('0x1f')](function(_0x534ccd){if(_0x534ccd){_0x444893=_0x534ccd['length'];if(!_0x132e07[_0x7ca9('0x47')]['hasOwnProperty']('nolimit')){_0x6fda05[_0x7ca9('0x30')]=qs[_0x7ca9('0x30')](_0x132e07[_0x7ca9('0x47')][_0x7ca9('0x30')]);_0x6fda05[_0x7ca9('0x2f')]=qs[_0x7ca9('0x2f')](_0x132e07[_0x7ca9('0x47')]['offset']);}return _0x2f6375[_0x7ca9('0x7b')](_0x6fda05);}})[_0x7ca9('0x1f')](function(_0x2c9f86){if(_0x2c9f86){return _0x2c9f86?{'count':_0x444893,'rows':_0x2c9f86}:null;}})[_0x7ca9('0x1f')](respondWithResult(_0x2e8af1,null))[_0x7ca9('0x2a')](handleError(_0x2e8af1,null));};exports[_0x7ca9('0x7c')]=function(_0x49ac9a,_0x29df39){var _0xcec97c=_0x49ac9a[_0x7ca9('0x64')]['id'];var _0x155abb=_0x49ac9a[_0x7ca9('0x63')];var _0x56ffef=0xc8;var _0x3978ef=null;return db[_0x7ca9('0x7d')][_0x7ca9('0x7e')]({'isolationLevel':db[_0x7ca9('0x7d')][_0x7ca9('0x7f')]['ISOLATION_LEVELS'][_0x7ca9('0x80')]},function(_0x68a19b){return db[_0x7ca9('0x42')][_0x7ca9('0x69')]({'where':{'id':_0xcec97c},'transaction':_0x68a19b})[_0x7ca9('0x1f')](function(_0x543648){if(_0x543648){return db['WhatsappApplication'][_0x7ca9('0x3a')]({'where':{'WhatsappAccountId':_0xcec97c},'transaction':_0x68a19b})[_0x7ca9('0x1f')](function(){var _0x55b3ea=_['map'](_0x155abb,function(_0x550f9c){_0x550f9c['WhatsappAccountId']=_0xcec97c;return _0x550f9c;});return db['WhatsappApplication'][_0x7ca9('0x81')](_0x55b3ea,{'transaction':_0x68a19b});});}else{_0x56ffef=0x194;_0x3978ef=[];}});})[_0x7ca9('0x1f')](function(){if(_0x56ffef!==0x194){return db['WhatsappApplication']['findAndCountAll']({'where':{'WhatsappAccountId':_0xcec97c},'order':_0x7ca9('0x82')})['then'](function(_0xf1afc3){_0x3978ef=_0xf1afc3;});}})[_0x7ca9('0x2a')](function(_0x33f7f9){_0x56ffef=0x1f4;logger['error'](_0x33f7f9['stack']);if(_0x33f7f9[_0x7ca9('0x3c')]){delete _0x33f7f9['name'];}_0x3978ef=_0x33f7f9;})[_0x7ca9('0x83')](function(){if(_0x3978ef===null){_0x29df39['sendStatus'](_0x56ffef);}else{if(_0x56ffef===0x1f4){_0x29df39[_0x7ca9('0x2d')](_0x56ffef)['send'](_0x3978ef);}else{_0x29df39['status'](_0x56ffef)[_0x7ca9('0x2e')](_0x3978ef);}}});};exports[_0x7ca9('0x84')]=function(_0x13fa6a,_0x1a6a0a,_0x170660){var _0x4e4f6c={};var _0x3d6ff2={};var _0x305dc5;var _0x2cba1d;return db[_0x7ca9('0x42')]['findOne']({'where':{'id':_0x13fa6a[_0x7ca9('0x64')]['id']}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x1a6a0a,null))[_0x7ca9('0x1f')](function(_0x31de28){if(_0x31de28){_0x305dc5=_0x31de28;_0x3d6ff2[_0x7ca9('0x46')]=_[_0x7ca9('0x48')](db[_0x7ca9('0x85')][_0x7ca9('0x43')]);_0x3d6ff2[_0x7ca9('0x47')]=_['keys'](_0x13fa6a[_0x7ca9('0x47')]);_0x3d6ff2[_0x7ca9('0x59')]=_['intersection'](_0x3d6ff2[_0x7ca9('0x46')],_0x3d6ff2[_0x7ca9('0x47')]);_0x4e4f6c[_0x7ca9('0x49')]=_[_0x7ca9('0x4a')](_0x3d6ff2[_0x7ca9('0x46')],qs['fields'](_0x13fa6a[_0x7ca9('0x47')][_0x7ca9('0x4b')]));_0x4e4f6c[_0x7ca9('0x49')]=_0x4e4f6c[_0x7ca9('0x49')][_0x7ca9('0x6a')]?_0x4e4f6c[_0x7ca9('0x49')]:_0x3d6ff2['model'];_0x4e4f6c[_0x7ca9('0x4e')]=qs[_0x7ca9('0x4f')](_0x13fa6a['query'][_0x7ca9('0x4f')]);_0x4e4f6c[_0x7ca9('0x50')]=qs[_0x7ca9('0x59')](_[_0x7ca9('0x51')](_0x13fa6a[_0x7ca9('0x47')],_0x3d6ff2[_0x7ca9('0x59')]));if(_0x13fa6a[_0x7ca9('0x47')]['filter']){_0x4e4f6c[_0x7ca9('0x50')]=_[_0x7ca9('0x52')](_0x4e4f6c[_0x7ca9('0x50')],{'$or':_[_0x7ca9('0x41')](_0x4e4f6c[_0x7ca9('0x49')],function(_0xa85469){var _0x1bc87f={};_0x1bc87f[_0xa85469]={'$like':'%'+_0x13fa6a['query'][_0x7ca9('0x6b')]+'%'};return _0x1bc87f;})});}_0x4e4f6c=_[_0x7ca9('0x52')]({},_0x4e4f6c,_0x13fa6a[_0x7ca9('0x54')]);return _0x305dc5[_0x7ca9('0x84')](_0x4e4f6c);}})[_0x7ca9('0x1f')](function(_0x41dcbd){if(_0x41dcbd){_0x2cba1d=_0x41dcbd['length'];if(!_0x13fa6a[_0x7ca9('0x47')][_0x7ca9('0x4c')](_0x7ca9('0x4d'))){_0x4e4f6c[_0x7ca9('0x30')]=qs['limit'](_0x13fa6a['query'][_0x7ca9('0x30')]);_0x4e4f6c[_0x7ca9('0x2f')]=qs[_0x7ca9('0x2f')](_0x13fa6a[_0x7ca9('0x47')][_0x7ca9('0x2f')]);}return _0x305dc5[_0x7ca9('0x84')](_0x4e4f6c);}})['then'](function(_0x25efe7){if(_0x25efe7){return _0x25efe7?{'count':_0x2cba1d,'rows':_0x25efe7}:null;}})[_0x7ca9('0x1f')](respondWithResult(_0x1a6a0a,null))[_0x7ca9('0x2a')](handleError(_0x1a6a0a,null));};exports[_0x7ca9('0x86')]=function(_0x48c5bf,_0x299bb9,_0xa7920a){var _0x27f64f={'channel':_0x7ca9('0x87')};var _0x4ca522=[];var _0x321747=[];var _0x2d9948={};return db['WhatsappAccount'][_0x7ca9('0x5a')]({'where':{'id':_0x48c5bf[_0x7ca9('0x64')]['id']},'include':[{'model':db['WhatsappApplication'],'as':_0x7ca9('0x88')}]})[_0x7ca9('0x1f')](handleEntityNotFound(_0x299bb9,null))['then'](function(_0x49bf5c){_0x27f64f[_0x7ca9('0x89')]=_0x49bf5c;if(_0x27f64f['account']&&_0x27f64f['account'][_0x7ca9('0x45')]===_0x7ca9('0x8a')&&_0x48c5bf[_0x7ca9('0x63')]['statuses']){if(_0x48c5bf[_0x7ca9('0x63')]['statuses'][_0x7ca9('0x6a')]===0x0)return;if(_0x48c5bf[_0x7ca9('0x63')][_0x7ca9('0x8b')][0x0][_0x7ca9('0x8c')]!==_0x7ca9('0x8d'))return;return db[_0x7ca9('0x8e')][_0x7ca9('0x37')]({'read':!![],'readAt':_0x48c5bf['body'][_0x7ca9('0x8b')][0x0][_0x7ca9('0x8f')]},{'where':{'messageId':_0x48c5bf[_0x7ca9('0x63')][_0x7ca9('0x8b')][0x0][_0x7ca9('0x90')]},'individualHooks':!![]})[_0x7ca9('0x1f')](function(_0xc0fcdc){return _0x299bb9[_0x7ca9('0x2d')](0xc8)[_0x7ca9('0x2e')](_0xc0fcdc);});}_0x27f64f[_0x7ca9('0x91')]=_[_0x7ca9('0x92')](_0x49bf5c[_0x7ca9('0x88')],['priority'],[_0x7ca9('0x93')]);if(_0x27f64f[_0x7ca9('0x89')][_0x7ca9('0x88')]){delete _0x27f64f[_0x7ca9('0x89')][_0x7ca9('0x88')];}return db[_0x7ca9('0x94')][_0x7ca9('0x65')]()[_0x7ca9('0x1f')](function(_0x520982){if(!_0x520982){throw new db[(_0x7ca9('0x95'))][(_0x7ca9('0x96'))](_0x7ca9('0x97'));}_0x4ca522=_['difference'](_['keys'](_0x520982),[_0x7ca9('0x98'),_0x7ca9('0x99')]);_0x321747=_[_0x7ca9('0x9a')](_['keys'](_0x520982),[_0x7ca9('0x98'),'updatedAt','CompanyId',_0x7ca9('0x9b')]);_0x27f64f['body']={'mapKey':'mobile'};if(_0x27f64f[_0x7ca9('0x89')]&&_0x27f64f[_0x7ca9('0x89')][_0x7ca9('0x45')]===_0x7ca9('0x9c')){_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x9d')]=_0x48c5bf[_0x7ca9('0x63')]['From']['replace'](_0x7ca9('0x9e'),'');_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x63')]=_0x48c5bf['body'][_0x7ca9('0x9f')];_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xa0')]=_0x48c5bf[_0x7ca9('0x63')]['MessageSid'];}if(_0x27f64f[_0x7ca9('0x89')]&&_0x27f64f[_0x7ca9('0x89')][_0x7ca9('0x45')]==='sinch'){_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x9d')]=_0x48c5bf[_0x7ca9('0x63')][_0x7ca9('0xa1')][0x0]['from'];_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x63')]=_0x48c5bf[_0x7ca9('0x63')][_0x7ca9('0xa1')][0x0]['message'][_0x7ca9('0x63')];_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xa0')]=_0x48c5bf['body'][_0x7ca9('0xa1')][0x0][_0x7ca9('0x90')];}if(_0x27f64f[_0x7ca9('0x63')]['id']){delete _0x27f64f[_0x7ca9('0x63')]['id'];}if(_[_0x7ca9('0xa2')](_0x27f64f['body'][_0x7ca9('0x9d')])){throw new db['Sequelize'][(_0x7ca9('0x96'))]('from\x20is\x20mandatory');}if(_[_0x7ca9('0xa2')](_0x27f64f[_0x7ca9('0x63')]['body'])||_0x27f64f[_0x7ca9('0x63')]['body']===''){throw new db[(_0x7ca9('0x95'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x27f64f[_0x7ca9('0x63')]['mapKey'])){throw new db[(_0x7ca9('0x95'))][(_0x7ca9('0x96'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x321747);}if(!_[_0x7ca9('0xa3')](_0x321747,_0x27f64f[_0x7ca9('0x63')]['mapKey'])){throw new db[(_0x7ca9('0x95'))][(_0x7ca9('0x96'))](_0x7ca9('0xa4')+_0x321747);}_0x2d9948[_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xa5')]]=_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x9d')];return db[_0x7ca9('0xa6')]['find']({'where':{'id':_0x27f64f[_0x7ca9('0x89')]['ListId']},'include':[{'model':db[_0x7ca9('0x94')],'as':'Contacts','where':_0x2d9948,'limit':0x1,'order':[[_0x7ca9('0x99'),_0x7ca9('0xa7')]]}]});})[_0x7ca9('0x1f')](handleEntityNotFound(_0x299bb9,null))[_0x7ca9('0x1f')](function(_0x19ced8){if(_0x19ced8){_0x27f64f[_0x7ca9('0xa8')]=_[_0x7ca9('0x74')](_0x19ced8,[_0x7ca9('0xa9')]);if(_0x19ced8['Contacts'][_0x7ca9('0x6a')]){return _0x19ced8[_0x7ca9('0xa9')][0x0];}var _0x25bb33=_[_0x7ca9('0x18')](_0x27f64f[_0x7ca9('0x63')],{'firstName':_0x27f64f[_0x7ca9('0x63')]['from'],'ListId':_0x19ced8['id']});_0x25bb33[_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xa5')]]=_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0x9d')];return db[_0x7ca9('0x94')][_0x7ca9('0x5b')](_0x25bb33,{'fields':_0x4ca522,'raw':!![]});}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x299bb9,null))[_0x7ca9('0x1f')](function(_0x2c338e){if(_0x2c338e){_0x27f64f['contact']=_0x2c338e;var _0x2d615a={'ContactId':_0x2c338e['id'],'phone':_0x27f64f[_0x7ca9('0x63')]['from'],'WhatsappAccountId':_0x48c5bf[_0x7ca9('0x64')]['id']};var _0x3aae98={'ContactId':_0x2c338e['id'],'WhatsappAccountId':_0x48c5bf[_0x7ca9('0x64')]['id'],'closed':![]};return db[_0x7ca9('0xaa')]['find']({'where':_0x3aae98})[_0x7ca9('0x1f')](function(_0x35a44f){if(_0x35a44f){return[_0x35a44f,![]];}return db[_0x7ca9('0xaa')][_0x7ca9('0x5b')](_0x2d615a)[_0x7ca9('0x1f')](function(_0x22e105){return[_0x22e105,!![]];});});}})[_0x7ca9('0xab')](function(_0x27ada3,_0xd7e3c5){_0x27f64f[_0x7ca9('0xac')]=_0x27ada3[_0x7ca9('0x5c')]({'plain':!![]});_0x27f64f[_0x7ca9('0xac')]['created']=![];if(_0xd7e3c5){if(_0x27f64f[_0x7ca9('0x89')]['autoclose']){_0x27f64f[_0x7ca9('0x91')][_0x7ca9('0xad')]({'id':0x0,'priority':_0x27f64f[_0x7ca9('0x91')][_0x7ca9('0x6a')]+0x1,'app':'close','appdata':_0x7ca9('0xae'),'interval':_0x7ca9('0xaf')});}_0x27f64f['interaction'][_0x7ca9('0xb0')]=!![];}return db['WhatsappMessage'][_0x7ca9('0x5b')]({'phone':_0x27f64f[_0x7ca9('0x63')]['from'],'messageId':_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xa0')],'body':_0x27f64f['body']['body'],'WhatsappAccountId':_0x48c5bf['params']['id'],'WhatsappInteractionId':_0x27ada3['id'],'direction':'in','ContactId':_0x27ada3[_0x7ca9('0xb1')],'AttachmentId':_0x27f64f[_0x7ca9('0x63')][_0x7ca9('0xb2')]});})['then'](function(_0x12187d){_0x27f64f[_0x7ca9('0x28')]=_0x12187d;if(_0x27f64f[_0x7ca9('0xac')][_0x7ca9('0xb3')]){return db['User'][_0x7ca9('0x5a')]({'attributes':['id',_0x7ca9('0x3c')],'where':{'id':_0x27f64f[_0x7ca9('0xac')][_0x7ca9('0xb3')]}})[_0x7ca9('0x1f')](function(_0x2b9e33){if(_0x2b9e33){_0x27f64f[_0x7ca9('0x91')]['unshift']({'id':0x0,'priority':0x0,'app':_0x7ca9('0xb4'),'appdata':_0x2b9e33[_0x7ca9('0x3c')]+','+(_0x27f64f[_0x7ca9('0x89')][_0x7ca9('0xb5')]||0xa),'interval':_0x7ca9('0xaf')});}return respondWithRpcPromise(_0x7ca9('0xb6'),_0x7ca9('0xb7'),_0x27f64f);});}return respondWithRpcPromise(_0x7ca9('0xb6'),_0x7ca9('0xb7'),_0x27f64f);})[_0x7ca9('0x1f')](function(_0x3b14e2){if(_0x3b14e2){var _0x532139=0xc8;var _0x12e8e2=_0x7ca9('0xb8');logger[_0x7ca9('0x20')]('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0x12e8e2,_0x532139,_0x7ca9('0xb9'));logger['debug'](_0x7ca9('0xba'),_0x12e8e2,_0x532139,_0x7ca9('0xb9'),JSON[_0x7ca9('0x24')](_0x3b14e2));if(_0x27f64f[_0x7ca9('0x89')]['type']==='twilio'){return _0x299bb9['status'](_0x532139)['set'](_0x7ca9('0xbb'),_0x7ca9('0xbc'))['send'](_0x7ca9('0xbd'));}else{return _0x299bb9['status'](_0x532139)[_0x7ca9('0x2e')](_0x3b14e2);}}});})[_0x7ca9('0x2a')](handleError(_0x299bb9,null));};exports['send']=function(_0x2ea1eb,_0x56f826,_0x17ad83){var _0x46a012,_0x367c0b,_0x5a07c7;if(_['isNil'](_0x2ea1eb[_0x7ca9('0x63')]['body'])||_0x2ea1eb[_0x7ca9('0x63')][_0x7ca9('0x63')]===''){throw new db[(_0x7ca9('0x95'))][(_0x7ca9('0x96'))](_0x7ca9('0xbe'));}if(_['isNil'](_0x2ea1eb['body']['to'])){throw new db[(_0x7ca9('0x95'))]['ValidationError'](_0x7ca9('0xbf'));}_0x46a012=_0x2ea1eb[_0x7ca9('0x63')]['to'];return db[_0x7ca9('0x42')][_0x7ca9('0x5a')]({'where':{'id':_0x2ea1eb[_0x7ca9('0x64')]['id']},'include':[{'model':db[_0x7ca9('0xa6')],'as':_0x7ca9('0xc0'),'include':[{'model':db['CmContact'],'as':'Contacts','where':{'mobile':_0x46a012},'limit':0x1,'order':[[_0x7ca9('0x99'),_0x7ca9('0xa7')]]}]}]})[_0x7ca9('0x1f')](handleEntityNotFound(_0x56f826,null))[_0x7ca9('0x1f')](function(_0x641c3b){if(_0x641c3b&&_0x641c3b['List']){_0x367c0b=_0x641c3b[_0x7ca9('0x5c')]({'plain':!![]});if(_0x367c0b['List']&&_0x367c0b[_0x7ca9('0xc0')]['Contacts'][_0x7ca9('0x6a')]){return _0x367c0b[_0x7ca9('0xc0')][_0x7ca9('0xa9')][0x0];}return db['CmContact']['create'](_[_0x7ca9('0x18')](_0x2ea1eb['body'],{'firstName':_0x46a012,'mobile':_0x46a012,'phone':_0x46a012,'ListId':_0x367c0b[_0x7ca9('0x9b')]}));}})[_0x7ca9('0x1f')](handleEntityNotFound(_0x56f826,null))[_0x7ca9('0x1f')](function(_0x547d1e){if(_0x547d1e){_0x5a07c7=_0x547d1e;return db[_0x7ca9('0xaa')][_0x7ca9('0x5a')]({'where':{'ContactId':_0x5a07c7['id'],'closed':![],'WhatsappAccountId':_0x367c0b['id']}})[_0x7ca9('0x1f')](function(_0x4f914a){if(_0x4f914a){return[_0x4f914a,![]];}return db[_0x7ca9('0xaa')][_0x7ca9('0x5b')]({'UserId':_0x2ea1eb[_0x7ca9('0x5f')]['id'],'ContactId':_0x5a07c7['id'],'WhatsappAccountId':_0x367c0b['id'],'phone':_0x46a012,'firstMsgDirection':_0x7ca9('0xc1'),'Messages':[_[_0x7ca9('0x52')](_0x2ea1eb[_0x7ca9('0x63')],{'read':![],'body':_0x2ea1eb['body'][_0x7ca9('0x63')],'phone':_0x46a012,'WhatsappAccountId':_0x367c0b['id'],'UserId':_0x2ea1eb[_0x7ca9('0x5f')]['id'],'ContactId':_0x5a07c7['id']})]},{'include':[{'model':db[_0x7ca9('0x8e')],'as':_0x7ca9('0xc2')}]})[_0x7ca9('0x1f')](function(_0x404246){return[_0x404246,!![]];});});}})[_0x7ca9('0xab')](function(_0xf2c8a4,_0x3779ea){if(_0x3779ea){return _0xf2c8a4;}return db[_0x7ca9('0x8e')][_0x7ca9('0x5b')](_[_0x7ca9('0x52')](_0x2ea1eb[_0x7ca9('0x63')],{'read':![],'body':_0x2ea1eb[_0x7ca9('0x63')][_0x7ca9('0x63')],'phone':_0x46a012,'WhatsappAccountId':_0x367c0b['id'],'WhatsappInteractionId':_0xf2c8a4['id'],'UserId':_0x2ea1eb[_0x7ca9('0x5f')]['id'],'ContactId':_0x5a07c7['id']}))[_0x7ca9('0x1f')](function(_0x299413){_0xf2c8a4['dataValues'][_0x7ca9('0xc2')]=[];_0xf2c8a4['dataValues']['Messages']['push'](_0x299413[_0x7ca9('0xc3')]);return _0xf2c8a4;});})['then'](respondWithResult(_0x56f826,null))[_0x7ca9('0x2a')](handleError(_0x56f826,null));}; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.events.js b/server/api/whatsappAccount/whatsappAccount.events.js new file mode 100644 index 0000000..42e7245 --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x81a6=['hasOwnProperty','hook','exports','events','../../mysqldb','WhatsappAccount','setMaxListeners','save','update','emit'];(function(_0x27bb0b,_0x3003d6){var _0x58709a=function(_0x35a351){while(--_0x35a351){_0x27bb0b['push'](_0x27bb0b['shift']());}};_0x58709a(++_0x3003d6);}(_0x81a6,0x157));var _0x681a=function(_0xc0a3d3,_0x2c8d00){_0xc0a3d3=_0xc0a3d3-0x0;var _0x3386e8=_0x81a6[_0xc0a3d3];return _0x3386e8;};'use strict';var EventEmitter=require(_0x681a('0x0'));var WhatsappAccount=require(_0x681a('0x1'))['db'][_0x681a('0x2')];var WhatsappAccountEvents=new EventEmitter();WhatsappAccountEvents[_0x681a('0x3')](0x0);var events={'afterCreate':_0x681a('0x4'),'afterUpdate':_0x681a('0x5'),'afterDestroy':'remove'};function emitEvent(_0x1e22f1){return function(_0x3217ff,_0x39b464,_0x46c75b){WhatsappAccountEvents[_0x681a('0x6')](_0x1e22f1+':'+_0x3217ff['id'],_0x3217ff);WhatsappAccountEvents[_0x681a('0x6')](_0x1e22f1,_0x3217ff);_0x46c75b(null);};}for(var e in events){if(events[_0x681a('0x7')](e)){var event=events[e];WhatsappAccount[_0x681a('0x8')](e,emitEvent(event));}}module[_0x681a('0x9')]=WhatsappAccountEvents; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.model.js b/server/api/whatsappAccount/whatsappAccount.model.js new file mode 100644 index 0000000..ca527fc --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x262f=['request-promise','path','./whatsappAccount.attributes','whatsapp_accounts','lodash','../../config/logger','api','moment','bluebird'];(function(_0x582f6f,_0x39d0ce){var _0x6efd70=function(_0x412f4f){while(--_0x412f4f){_0x582f6f['push'](_0x582f6f['shift']());}};_0x6efd70(++_0x39d0ce);}(_0x262f,0x67));var _0xf262=function(_0x75f0e3,_0xf48e93){_0x75f0e3=_0x75f0e3-0x0;var _0x3d535b=_0x262f[_0x75f0e3];return _0x3d535b;};'use strict';var _=require(_0xf262('0x0'));var util=require('util');var logger=require(_0xf262('0x1'))(_0xf262('0x2'));var moment=require(_0xf262('0x3'));var BPromise=require(_0xf262('0x4'));var rp=require(_0xf262('0x5'));var fs=require('fs');var path=require(_0xf262('0x6'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0xf262('0x7'));module['exports']=function(_0x2e1631,_0x400709){return _0x2e1631['define']('WhatsappAccount',attributes,{'tableName':_0xf262('0x8'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.rpc.js b/server/api/whatsappAccount/whatsappAccount.rpc.js new file mode 100644 index 0000000..f4e9e75 --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5272=['debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','find','options','raw','where','include','map','model','attributes','ShowWhatsappAccount','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','request','then','info','WhatsappAccount,\x20%s,\x20%s'];(function(_0x41c9f2,_0x3dc2c0){var _0x2fb75d=function(_0xb78361){while(--_0xb78361){_0x41c9f2['push'](_0x41c9f2['shift']());}};_0x2fb75d(++_0x3dc2c0);}(_0x5272,0x14a));var _0x2527=function(_0x475927,_0x4b0be7){_0x475927=_0x475927-0x0;var _0x19e8f3=_0x5272[_0x475927];return _0x19e8f3;};'use strict';var _=require(_0x2527('0x0'));var util=require(_0x2527('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x2527('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2527('0x3'))['db'];var utils=require(_0x2527('0x4'));var logger=require(_0x2527('0x5'))(_0x2527('0x6'));var config=require(_0x2527('0x7'));var jayson=require(_0x2527('0x8'));var client=jayson[_0x2527('0x9')][_0x2527('0xa')]({'port':0x232a});config[_0x2527('0xb')]=_[_0x2527('0xc')](config[_0x2527('0xb')],{'host':_0x2527('0xd'),'port':0x18eb});var socket=require(_0x2527('0xe'))(new Redis(config['redis']));require(_0x2527('0xf'))[_0x2527('0x10')](socket);function respondWithRpcPromise(_0x194d35,_0xc3af22,_0x40732c){return new BPromise(function(_0x3b01f2,_0x42d07e){return client[_0x2527('0x11')](_0x194d35,_0x40732c)[_0x2527('0x12')](function(_0x1c2a50){logger[_0x2527('0x13')](_0x2527('0x14'),_0xc3af22,'request\x20sent');logger[_0x2527('0x15')](_0x2527('0x16'),_0xc3af22,_0x2527('0x17'),JSON[_0x2527('0x18')](_0x1c2a50));if(_0x1c2a50[_0x2527('0x19')]){if(_0x1c2a50['error'][_0x2527('0x1a')]===0x1f4){logger[_0x2527('0x19')](_0x2527('0x14'),_0xc3af22,_0x1c2a50[_0x2527('0x19')][_0x2527('0x1b')]);return _0x42d07e(_0x1c2a50[_0x2527('0x19')][_0x2527('0x1b')]);}logger[_0x2527('0x19')](_0x2527('0x14'),_0xc3af22,_0x1c2a50[_0x2527('0x19')][_0x2527('0x1b')]);return _0x3b01f2(_0x1c2a50[_0x2527('0x19')]['message']);}else{logger[_0x2527('0x13')](_0x2527('0x14'),_0xc3af22,_0x2527('0x17'));_0x3b01f2(_0x1c2a50[_0x2527('0x1c')][_0x2527('0x1b')]);}})[_0x2527('0x1d')](function(_0x372b4f){logger[_0x2527('0x19')]('WhatsappAccount,\x20%s,\x20%s',_0xc3af22,_0x372b4f);_0x42d07e(_0x372b4f);});});}exports['ShowWhatsappAccount']=function(_0x243959){var _0x2b6f74=this;return new Promise(function(_0xeba6e7,_0xbb70a1){return db['WhatsappAccount'][_0x2527('0x1e')]({'raw':_0x243959['options']?_0x243959[_0x2527('0x1f')][_0x2527('0x20')]===undefined?!![]:![]:!![],'where':_0x243959[_0x2527('0x1f')]?_0x243959[_0x2527('0x1f')][_0x2527('0x21')]||null:null,'attributes':_0x243959[_0x2527('0x1f')]?_0x243959[_0x2527('0x1f')]['attributes']||null:null,'include':_0x243959['options']?_0x243959[_0x2527('0x1f')][_0x2527('0x22')]?_[_0x2527('0x23')](_0x243959['options'][_0x2527('0x22')],function(_0x515a6e){return{'model':db[_0x515a6e[_0x2527('0x24')]],'as':_0x515a6e['as'],'attributes':_0x515a6e[_0x2527('0x25')],'include':_0x515a6e[_0x2527('0x22')]?_[_0x2527('0x23')](_0x515a6e[_0x2527('0x22')],function(_0x5af1d6){return{'model':db[_0x5af1d6['model']],'as':_0x5af1d6['as'],'attributes':_0x5af1d6['attributes'],'include':_0x5af1d6['include']?_[_0x2527('0x23')](_0x5af1d6[_0x2527('0x22')],function(_0x54b9f9){return{'model':db[_0x54b9f9['model']],'as':_0x54b9f9['as'],'attributes':_0x54b9f9['attributes']};}):[]};}):[]};}):[]:[]})[_0x2527('0x12')](function(_0x3a6858){logger[_0x2527('0x13')](_0x2527('0x26'),_0x243959);logger['debug'](_0x2527('0x26'),_0x243959,JSON[_0x2527('0x18')](_0x3a6858));_0xeba6e7(_0x3a6858);})[_0x2527('0x1d')](function(_0x21f7d6){logger['error']('ShowWhatsappAccount',_0x21f7d6[_0x2527('0x1b')],_0x243959);_0xbb70a1(_0x2b6f74[_0x2527('0x19')](0x1f4,_0x21f7d6[_0x2527('0x1b')]));});});}; \ No newline at end of file diff --git a/server/api/whatsappAccount/whatsappAccount.socket.js b/server/api/whatsappAccount/whatsappAccount.socket.js new file mode 100644 index 0000000..7a0e481 --- /dev/null +++ b/server/api/whatsappAccount/whatsappAccount.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6c57=['remove','update','removeListener','length','whatsappAccount:','./whatsappAccount.events','save'];(function(_0x318ab8,_0x151ef9){var _0x49886a=function(_0x1c3263){while(--_0x1c3263){_0x318ab8['push'](_0x318ab8['shift']());}};_0x49886a(++_0x151ef9);}(_0x6c57,0x140));var _0x76c5=function(_0x134c2e,_0x3573c4){_0x134c2e=_0x134c2e-0x0;var _0x2825db=_0x6c57[_0x134c2e];return _0x2825db;};'use strict';var WhatsappAccountEvents=require(_0x76c5('0x0'));var events=[_0x76c5('0x1'),_0x76c5('0x2'),_0x76c5('0x3')];function createListener(_0x40f2e8,_0x2d3743){return function(_0xbd912c){_0x2d3743['emit'](_0x40f2e8,_0xbd912c);};}function removeListener(_0x3f3672,_0x48f7dc){return function(){WhatsappAccountEvents[_0x76c5('0x4')](_0x3f3672,_0x48f7dc);};}exports['register']=function(_0x5ade1a){for(var _0x3fb969=0x0,_0x4452f8=events[_0x76c5('0x5')];_0x3fb969<_0x4452f8;_0x3fb969++){var _0x5c2a5d=events[_0x3fb969];var _0x563d9b=createListener(_0x76c5('0x6')+_0x5c2a5d,_0x5ade1a);WhatsappAccountEvents['on'](_0x5c2a5d,_0x563d9b);}}; \ No newline at end of file diff --git a/server/api/whatsappApplication/index.js b/server/api/whatsappApplication/index.js new file mode 100644 index 0000000..39f9be9 --- /dev/null +++ b/server/api/whatsappApplication/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7dc9=['./whatsappApplication.controller','isAuthenticated','index','/:id','show','post','create','destroy','exports','multer','util','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment'];(function(_0x4a9973,_0x5228c3){var _0x4695f0=function(_0x30c21f){while(--_0x30c21f){_0x4a9973['push'](_0x4a9973['shift']());}};_0x4695f0(++_0x5228c3);}(_0x7dc9,0x139));var _0x97dc=function(_0x292eb9,_0x4807f8){_0x292eb9=_0x292eb9-0x0;var _0x30f4af=_0x7dc9[_0x292eb9];return _0x30f4af;};'use strict';var multer=require(_0x97dc('0x0'));var util=require(_0x97dc('0x1'));var path=require(_0x97dc('0x2'));var timeout=require(_0x97dc('0x3'));var express=require(_0x97dc('0x4'));var router=express[_0x97dc('0x5')]();var fs_extra=require(_0x97dc('0x6'));var auth=require(_0x97dc('0x7'));var interaction=require(_0x97dc('0x8'));var config=require(_0x97dc('0x9'));var controller=require(_0x97dc('0xa'));router['get']('/',auth[_0x97dc('0xb')](),controller[_0x97dc('0xc')]);router['get'](_0x97dc('0xd'),auth[_0x97dc('0xb')](),controller[_0x97dc('0xe')]);router[_0x97dc('0xf')]('/',auth[_0x97dc('0xb')](),controller[_0x97dc('0x10')]);router['put'](_0x97dc('0xd'),auth['isAuthenticated'](),controller['update']);router['delete'](_0x97dc('0xd'),auth[_0x97dc('0xb')](),controller[_0x97dc('0x11')]);module[_0x97dc('0x12')]=router; \ No newline at end of file diff --git a/server/api/whatsappApplication/whatsappApplication.attributes.js b/server/api/whatsappApplication/whatsappApplication.attributes.js new file mode 100644 index 0000000..bc8d44b --- /dev/null +++ b/server/api/whatsappApplication/whatsappApplication.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x187b=['INTEGER','STRING','*,*,*,*','sequelize','exports'];(function(_0x40998b,_0x38b1c5){var _0xb33ab8=function(_0xbee60e){while(--_0xbee60e){_0x40998b['push'](_0x40998b['shift']());}};_0xb33ab8(++_0x38b1c5);}(_0x187b,0x12a));var _0xb187=function(_0x16a035,_0x2d520d){_0x16a035=_0x16a035-0x0;var _0x32749a=_0x187b[_0x16a035];return _0x32749a;};'use strict';var Sequelize=require(_0xb187('0x0'));module[_0xb187('0x1')]={'priority':{'type':Sequelize[_0xb187('0x2')],'allowNull':![]},'app':{'type':Sequelize[_0xb187('0x3')],'allowNull':![],'defaultValue':'noop'},'appdata':{'type':Sequelize['TEXT']()},'description':{'type':Sequelize[_0xb187('0x3')]},'interval':{'type':Sequelize[_0xb187('0x3')],'defaultValue':_0xb187('0x4')}}; \ No newline at end of file diff --git a/server/api/whatsappApplication/whatsappApplication.controller.js b/server/api/whatsappApplication/whatsappApplication.controller.js new file mode 100644 index 0000000..f5d66f5 --- /dev/null +++ b/server/api/whatsappApplication/whatsappApplication.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1bb4=['sendStatus','status','offset','undefined','count','set','Content-Range','json','apply','reject','save','update','then','destroy','end','error','stack','name','send','index','map','WhatsappApplication','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','show','params','options','catch','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','sox','ejs','fs-extra','lodash','crypto','jsforce','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb'];(function(_0x527dc5,_0x1de7e7){var _0x216de9=function(_0xde9c52){while(--_0xde9c52){_0x527dc5['push'](_0x527dc5['shift']());}};_0x216de9(++_0x1de7e7);}(_0x1bb4,0x1c7));var _0x41bb=function(_0x4e406f,_0x526785){_0x4e406f=_0x4e406f-0x0;var _0x456590=_0x1bb4[_0x4e406f];return _0x456590;};'use strict';var emlformat=require(_0x41bb('0x0'));var rimraf=require(_0x41bb('0x1'));var zipdir=require(_0x41bb('0x2'));var jsonpatch=require(_0x41bb('0x3'));var rp=require(_0x41bb('0x4'));var moment=require('moment');var BPromise=require(_0x41bb('0x5'));var Mustache=require('mustache');var util=require(_0x41bb('0x6'));var path=require('path');var sox=require(_0x41bb('0x7'));var csv=require('to-csv');var ejs=require(_0x41bb('0x8'));var fs=require('fs');var fs_extra=require(_0x41bb('0x9'));var _=require(_0x41bb('0xa'));var squel=require('squel');var crypto=require(_0x41bb('0xb'));var jsforce=require(_0x41bb('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x41bb('0xd'));var querystring=require(_0x41bb('0xe'));var Papa=require(_0x41bb('0xf'));var Redis=require('ioredis');var authService=require(_0x41bb('0x10'));var qs=require(_0x41bb('0x11'));var as=require(_0x41bb('0x12'));var hardwareService=require(_0x41bb('0x13'));var logger=require(_0x41bb('0x14'))('api');var utils=require(_0x41bb('0x15'));var config=require(_0x41bb('0x16'));var licenseUtil=require(_0x41bb('0x17'));var db=require(_0x41bb('0x18'))['db'];function respondWithStatusCode(_0x28c08a,_0x233473){_0x233473=_0x233473||0xcc;return function(_0x1f4b78){if(_0x1f4b78){return _0x28c08a[_0x41bb('0x19')](_0x233473);}return _0x28c08a['status'](_0x233473)['end']();};}function respondWithResult(_0x4bfeae,_0x43fd1f){_0x43fd1f=_0x43fd1f||0xc8;return function(_0x46a7ec){if(_0x46a7ec){return _0x4bfeae[_0x41bb('0x1a')](_0x43fd1f)['json'](_0x46a7ec);}};}function respondWithFilteredResult(_0x514d8f,_0x18bf70){return function(_0xa66c46){if(_0xa66c46){var _0xfa8f14=typeof _0x18bf70[_0x41bb('0x1b')]===_0x41bb('0x1c')&&typeof _0x18bf70['limit']===_0x41bb('0x1c');var _0x5a8de5=_0xa66c46[_0x41bb('0x1d')];var _0x3fa4a4=_0xfa8f14?0x0:_0x18bf70['offset'];var _0xc202d0=_0xfa8f14?_0xa66c46[_0x41bb('0x1d')]:_0x18bf70['offset']+_0x18bf70['limit'];var _0x3755d7;if(_0xc202d0>=_0x5a8de5){_0xc202d0=_0x5a8de5;_0x3755d7=0xc8;}else{_0x3755d7=0xce;}_0x514d8f['status'](_0x3755d7);return _0x514d8f[_0x41bb('0x1e')](_0x41bb('0x1f'),_0x3fa4a4+'-'+_0xc202d0+'/'+_0x5a8de5)[_0x41bb('0x20')](_0xa66c46);}return null;};}function patchUpdates(_0x2be518){return function(_0x2765e7){try{jsonpatch[_0x41bb('0x21')](_0x2765e7,_0x2be518,!![]);}catch(_0x44d02d){return BPromise[_0x41bb('0x22')](_0x44d02d);}return _0x2765e7[_0x41bb('0x23')]();};}function saveUpdates(_0x407480,_0x5bd58f){return function(_0x29b356){if(_0x29b356){return _0x29b356[_0x41bb('0x24')](_0x407480)[_0x41bb('0x25')](function(_0x177209){return _0x177209;});}return null;};}function removeEntity(_0x54ec2a,_0x4d065e){return function(_0x1a43ad){if(_0x1a43ad){return _0x1a43ad[_0x41bb('0x26')]()[_0x41bb('0x25')](function(){_0x54ec2a['status'](0xcc)[_0x41bb('0x27')]();});}};}function handleEntityNotFound(_0x19bd28,_0x592239){return function(_0x310f09){if(!_0x310f09){_0x19bd28[_0x41bb('0x19')](0x194);}return _0x310f09;};}function handleError(_0x20ebe6,_0x2fba16){_0x2fba16=_0x2fba16||0x1f4;return function(_0x440d33){logger[_0x41bb('0x28')](_0x440d33[_0x41bb('0x29')]);if(_0x440d33[_0x41bb('0x2a')]){delete _0x440d33[_0x41bb('0x2a')];}_0x20ebe6[_0x41bb('0x1a')](_0x2fba16)[_0x41bb('0x2b')](_0x440d33);};}exports[_0x41bb('0x2c')]=function(_0x430131,_0x16b1f6){var _0x148ea5={},_0x4645c8={},_0x501f78={'count':0x0,'rows':[]};var _0x32af99=_[_0x41bb('0x2d')](db[_0x41bb('0x2e')][_0x41bb('0x2f')],function(_0x3a3d23){return{'name':_0x3a3d23[_0x41bb('0x30')],'type':_0x3a3d23[_0x41bb('0x31')][_0x41bb('0x32')]};});_0x4645c8[_0x41bb('0x33')]=_[_0x41bb('0x2d')](_0x32af99,_0x41bb('0x2a'));_0x4645c8[_0x41bb('0x34')]=_[_0x41bb('0x35')](_0x430131[_0x41bb('0x34')]);_0x4645c8[_0x41bb('0x36')]=_[_0x41bb('0x37')](_0x4645c8['model'],_0x4645c8[_0x41bb('0x34')]);_0x148ea5[_0x41bb('0x38')]=_[_0x41bb('0x37')](_0x4645c8[_0x41bb('0x33')],qs[_0x41bb('0x39')](_0x430131[_0x41bb('0x34')][_0x41bb('0x39')]));_0x148ea5['attributes']=_0x148ea5['attributes'][_0x41bb('0x3a')]?_0x148ea5[_0x41bb('0x38')]:_0x4645c8[_0x41bb('0x33')];if(!_0x430131[_0x41bb('0x34')][_0x41bb('0x3b')](_0x41bb('0x3c'))){_0x148ea5[_0x41bb('0x3d')]=qs[_0x41bb('0x3d')](_0x430131['query']['limit']);_0x148ea5['offset']=qs[_0x41bb('0x1b')](_0x430131[_0x41bb('0x34')][_0x41bb('0x1b')]);}_0x148ea5[_0x41bb('0x3e')]=qs[_0x41bb('0x3f')](_0x430131['query'][_0x41bb('0x3f')]);_0x148ea5[_0x41bb('0x40')]=qs[_0x41bb('0x36')](_[_0x41bb('0x41')](_0x430131[_0x41bb('0x34')],_0x4645c8[_0x41bb('0x36')]),_0x32af99);if(_0x430131[_0x41bb('0x34')][_0x41bb('0x42')]){_0x148ea5[_0x41bb('0x40')]=_[_0x41bb('0x43')](_0x148ea5['where'],{'$or':_['map'](_0x32af99,function(_0x5f22eb){if(_0x5f22eb[_0x41bb('0x31')]!==_0x41bb('0x44')){var _0x3ac009={};_0x3ac009[_0x5f22eb[_0x41bb('0x2a')]]={'$like':'%'+_0x430131['query'][_0x41bb('0x42')]+'%'};return _0x3ac009;}})});}_0x148ea5=_[_0x41bb('0x43')]({},_0x148ea5,_0x430131['options']);var _0x4df15e={'where':_0x148ea5[_0x41bb('0x40')]};return db[_0x41bb('0x2e')]['count'](_0x4df15e)[_0x41bb('0x25')](function(_0x4aa5dc){_0x501f78[_0x41bb('0x1d')]=_0x4aa5dc;if(_0x430131[_0x41bb('0x34')][_0x41bb('0x45')]){_0x148ea5[_0x41bb('0x46')]=[{'all':!![]}];}return db[_0x41bb('0x2e')][_0x41bb('0x47')](_0x148ea5);})[_0x41bb('0x25')](function(_0x4e0c7d){_0x501f78[_0x41bb('0x48')]=_0x4e0c7d;return _0x501f78;})[_0x41bb('0x25')](respondWithFilteredResult(_0x16b1f6,_0x148ea5))['catch'](handleError(_0x16b1f6,null));};exports[_0x41bb('0x49')]=function(_0x14a908,_0x6a5364){var _0x59ed00={'raw':!![],'where':{'id':_0x14a908[_0x41bb('0x4a')]['id']}},_0x2deafc={};_0x2deafc[_0x41bb('0x33')]=_['keys'](db[_0x41bb('0x2e')][_0x41bb('0x2f')]);_0x2deafc[_0x41bb('0x34')]=_[_0x41bb('0x35')](_0x14a908[_0x41bb('0x34')]);_0x2deafc[_0x41bb('0x36')]=_[_0x41bb('0x37')](_0x2deafc[_0x41bb('0x33')],_0x2deafc['query']);_0x59ed00[_0x41bb('0x38')]=_[_0x41bb('0x37')](_0x2deafc[_0x41bb('0x33')],qs['fields'](_0x14a908[_0x41bb('0x34')][_0x41bb('0x39')]));_0x59ed00[_0x41bb('0x38')]=_0x59ed00[_0x41bb('0x38')][_0x41bb('0x3a')]?_0x59ed00[_0x41bb('0x38')]:_0x2deafc['model'];if(_0x14a908['query']['includeAll']){_0x59ed00[_0x41bb('0x46')]=[{'all':!![]}];}_0x59ed00=_[_0x41bb('0x43')]({},_0x59ed00,_0x14a908[_0x41bb('0x4b')]);return db['WhatsappApplication']['find'](_0x59ed00)['then'](handleEntityNotFound(_0x6a5364,null))[_0x41bb('0x25')](respondWithResult(_0x6a5364,null))[_0x41bb('0x4c')](handleError(_0x6a5364,null));};exports[_0x41bb('0x4d')]=function(_0x239a67,_0x69292a){return db[_0x41bb('0x2e')]['create'](_0x239a67[_0x41bb('0x4e')],{})[_0x41bb('0x25')](respondWithResult(_0x69292a,0xc9))[_0x41bb('0x4c')](handleError(_0x69292a,null));};exports['update']=function(_0x590f8f,_0x5d2e2e){if(_0x590f8f[_0x41bb('0x4e')]['id']){delete _0x590f8f[_0x41bb('0x4e')]['id'];}return db[_0x41bb('0x2e')][_0x41bb('0x4f')]({'where':{'id':_0x590f8f[_0x41bb('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5d2e2e,null))[_0x41bb('0x25')](saveUpdates(_0x590f8f[_0x41bb('0x4e')],null))['then'](respondWithResult(_0x5d2e2e,null))[_0x41bb('0x4c')](handleError(_0x5d2e2e,null));};exports[_0x41bb('0x26')]=function(_0x45ef28,_0x57cd4c){return db[_0x41bb('0x2e')]['find']({'where':{'id':_0x45ef28[_0x41bb('0x4a')]['id']}})['then'](handleEntityNotFound(_0x57cd4c,null))[_0x41bb('0x25')](removeEntity(_0x57cd4c,null))[_0x41bb('0x4c')](handleError(_0x57cd4c,null));}; \ No newline at end of file diff --git a/server/api/whatsappApplication/whatsappApplication.model.js b/server/api/whatsappApplication/whatsappApplication.model.js new file mode 100644 index 0000000..8f43ec1 --- /dev/null +++ b/server/api/whatsappApplication/whatsappApplication.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4bc3=['utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','request-promise','path','rimraf','../../config/environment','./whatsappApplication.attributes','exports','define'];(function(_0x59eacf,_0x56ec4a){var _0x5d74f2=function(_0x5476ed){while(--_0x5476ed){_0x59eacf['push'](_0x59eacf['shift']());}};_0x5d74f2(++_0x56ec4a);}(_0x4bc3,0x16e));var _0x34bc=function(_0x46698a,_0x8de1e4){_0x46698a=_0x46698a-0x0;var _0x356db0=_0x4bc3[_0x46698a];return _0x356db0;};'use strict';var _=require(_0x34bc('0x0'));var util=require(_0x34bc('0x1'));var logger=require('../../config/logger')(_0x34bc('0x2'));var moment=require(_0x34bc('0x3'));var BPromise=require('bluebird');var rp=require(_0x34bc('0x4'));var fs=require('fs');var path=require(_0x34bc('0x5'));var rimraf=require(_0x34bc('0x6'));var config=require(_0x34bc('0x7'));var attributes=require(_0x34bc('0x8'));module[_0x34bc('0x9')]=function(_0x2cc9c2,_0x4c63a1){return _0x2cc9c2[_0x34bc('0xa')]('WhatsappApplication',attributes,{'tableName':'whatsapp_applications','paranoid':![],'indexes':[],'timestamps':!![],'charset':_0x34bc('0xb'),'collate':_0x34bc('0xc')});}; \ No newline at end of file diff --git a/server/api/whatsappApplication/whatsappApplication.rpc.js b/server/api/whatsappApplication/whatsappApplication.rpc.js new file mode 100644 index 0000000..520e3b7 --- /dev/null +++ b/server/api/whatsappApplication/whatsappApplication.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c4e=['result','catch','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','request','info','WhatsappApplication,\x20%s,\x20%s','request\x20sent','debug','WhatsappApplication,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x565ac0,_0x559e8b){var _0x54d5c1=function(_0x19a345){while(--_0x19a345){_0x565ac0['push'](_0x565ac0['shift']());}};_0x54d5c1(++_0x559e8b);}(_0x4c4e,0x152));var _0xe4c4=function(_0x4957b6,_0x2ebb38){_0x4957b6=_0x4957b6-0x0;var _0x52f3ad=_0x4c4e[_0x4957b6];return _0x52f3ad;};'use strict';var _=require(_0xe4c4('0x0'));var util=require('util');var moment=require(_0xe4c4('0x1'));var BPromise=require(_0xe4c4('0x2'));var rs=require(_0xe4c4('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe4c4('0x4'))['db'];var utils=require(_0xe4c4('0x5'));var logger=require(_0xe4c4('0x6'))('rpc');var config=require(_0xe4c4('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xe4c4('0x8')][_0xe4c4('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x262b64,_0xad105,_0x22085a){return new BPromise(function(_0x329d29,_0x28a42e){return client[_0xe4c4('0xa')](_0x262b64,_0x22085a)['then'](function(_0x589b2e){logger[_0xe4c4('0xb')](_0xe4c4('0xc'),_0xad105,_0xe4c4('0xd'));logger[_0xe4c4('0xe')](_0xe4c4('0xf'),_0xad105,_0xe4c4('0xd'),JSON['stringify'](_0x589b2e));if(_0x589b2e[_0xe4c4('0x10')]){if(_0x589b2e[_0xe4c4('0x10')][_0xe4c4('0x11')]===0x1f4){logger[_0xe4c4('0x10')]('WhatsappApplication,\x20%s,\x20%s',_0xad105,_0x589b2e[_0xe4c4('0x10')][_0xe4c4('0x12')]);return _0x28a42e(_0x589b2e['error'][_0xe4c4('0x12')]);}logger[_0xe4c4('0x10')]('WhatsappApplication,\x20%s,\x20%s',_0xad105,_0x589b2e[_0xe4c4('0x10')][_0xe4c4('0x12')]);return _0x329d29(_0x589b2e['error'][_0xe4c4('0x12')]);}else{logger[_0xe4c4('0xb')](_0xe4c4('0xc'),_0xad105,_0xe4c4('0xd'));_0x329d29(_0x589b2e[_0xe4c4('0x13')][_0xe4c4('0x12')]);}})[_0xe4c4('0x14')](function(_0x1038cb){logger[_0xe4c4('0x10')](_0xe4c4('0xc'),_0xad105,_0x1038cb);_0x28a42e(_0x1038cb);});});} \ No newline at end of file diff --git a/server/api/whatsappInteraction/index.js b/server/api/whatsappInteraction/index.js new file mode 100644 index 0000000..6fef14e --- /dev/null +++ b/server/api/whatsappInteraction/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1b20=['getMessages','/:id/download','download','post','addMessage','/:id/tags','tracked','whatsapp','whatsappinteraction:addtags','put','/:id','update','delete','destroy','removeTags','util','path','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./whatsappInteraction.controller','get','isAuthenticated','index','/describe','show','/:id/messages'];(function(_0x408d9d,_0x5eb151){var _0x36546c=function(_0x2ddb21){while(--_0x2ddb21){_0x408d9d['push'](_0x408d9d['shift']());}};_0x36546c(++_0x5eb151);}(_0x1b20,0x66));var _0x01b2=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0x1b20[_0x17d9e3];return _0x14192d;};'use strict';var multer=require('multer');var util=require(_0x01b2('0x0'));var path=require(_0x01b2('0x1'));var timeout=require('connect-timeout');var express=require('express');var router=express[_0x01b2('0x2')]();var fs_extra=require(_0x01b2('0x3'));var auth=require(_0x01b2('0x4'));var interaction=require(_0x01b2('0x5'));var config=require(_0x01b2('0x6'));var controller=require(_0x01b2('0x7'));router[_0x01b2('0x8')]('/',auth[_0x01b2('0x9')](),controller[_0x01b2('0xa')]);router[_0x01b2('0x8')](_0x01b2('0xb'),auth[_0x01b2('0x9')](),controller['describe']);router[_0x01b2('0x8')]('/:id',auth[_0x01b2('0x9')](),controller[_0x01b2('0xc')]);router[_0x01b2('0x8')](_0x01b2('0xd'),auth[_0x01b2('0x9')](),controller[_0x01b2('0xe')]);router[_0x01b2('0x8')](_0x01b2('0xf'),auth['isAuthenticated'](),controller[_0x01b2('0x10')]);router['post']('/',auth[_0x01b2('0x9')](),controller['create']);router[_0x01b2('0x11')](_0x01b2('0xd'),auth[_0x01b2('0x9')](),controller[_0x01b2('0x12')]);router['post'](_0x01b2('0x13'),auth[_0x01b2('0x9')](),interaction[_0x01b2('0x14')](_0x01b2('0x15'),_0x01b2('0x16')),controller['addTags']);router[_0x01b2('0x17')](_0x01b2('0x18'),auth[_0x01b2('0x9')](),interaction[_0x01b2('0x14')]('whatsapp','whatsappinteraction:update'),controller[_0x01b2('0x19')]);router[_0x01b2('0x1a')]('/:id',auth[_0x01b2('0x9')](),interaction[_0x01b2('0x14')](_0x01b2('0x15'),'whatsappinteraction:destroy'),controller[_0x01b2('0x1b')]);router[_0x01b2('0x1a')](_0x01b2('0x13'),auth[_0x01b2('0x9')](),controller[_0x01b2('0x1c')]);module['exports']=router; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.attributes.js b/server/api/whatsappInteraction/whatsappInteraction.attributes.js new file mode 100644 index 0000000..073202f --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x29d4=['DATE','STRING','ENUM','out','sequelize','exports','BOOLEAN'];(function(_0x341098,_0x525fe5){var _0x4a39fc=function(_0x82bbdb){while(--_0x82bbdb){_0x341098['push'](_0x341098['shift']());}};_0x4a39fc(++_0x525fe5);}(_0x29d4,0x1a1));var _0x429d=function(_0x33032e,_0x31411a){_0x33032e=_0x33032e-0x0;var _0x13316b=_0x29d4[_0x33032e];return _0x13316b;};'use strict';var Sequelize=require(_0x429d('0x0'));var moment=require('moment');module[_0x429d('0x1')]={'closed':{'type':Sequelize[_0x429d('0x2')],'defaultValue':![]},'closedAt':{'type':Sequelize[_0x429d('0x3')]},'disposition':{'type':Sequelize[_0x429d('0x4')]},'secondDisposition':{'type':Sequelize[_0x429d('0x4')]},'thirdDisposition':{'type':Sequelize['STRING']},'note':{'type':Sequelize[_0x429d('0x4')]},'phone':{'type':Sequelize[_0x429d('0x4')]},'read1stAt':{'type':Sequelize[_0x429d('0x3')]},'firstMsgDirection':{'type':Sequelize[_0x429d('0x5')]('in',_0x429d('0x6')),'defaultValue':'in','allowNull':![]},'lastMsgAt':{'type':Sequelize[_0x429d('0x3')]},'lastMsgDirection':{'type':Sequelize[_0x429d('0x5')]('in',_0x429d('0x6')),'defaultValue':'in','allowNull':![]},'autoreplyExecuted':{'type':Sequelize['BOOLEAN'],'defaultValue':![]}}; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.controller.js b/server/api/whatsappInteraction/whatsappInteraction.controller.js new file mode 100644 index 0000000..2e34385 --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8294=['error','name','send','WhatsappInteraction','key','getOptions','query','user','catch','params','model','keys','filters','intersection','attributes','fields','length','include','merge','options','create','body','update','find','describe','addMessage','WhatsappMessage','ids','findOne','rawAttributes','nolimit','order','sort','where','pick','filter','map','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','findAll','rows','addTags','spread','Tag','color','emit','whatsappInteractionTags:save','removeTags','download','unix','toString','join','server','files','tmp','root','attachments','transcript-%d-%s.zip','push','User','fullname','CmContact','Contact','firstName','Attachment','Messages','createdAt','read','Account','Owner','get','N.A.','closed','closedAt','disposition','basename','createReadStream','pipe','createWriteStream','direction','System','lastName','out','secret','value','renderFile','views','downloadInteraction.ejs','transcript-','.pdf','log','unlinkSync','rimraf','zip-dir','bluebird','ejs','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','redis','defaults','socket.io-emitter','register','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','then','destroy','end'];(function(_0x12d2d7,_0x253ea8){var _0x1defcb=function(_0x4d42e4){while(--_0x4d42e4){_0x12d2d7['push'](_0x12d2d7['shift']());}};_0x1defcb(++_0x253ea8);}(_0x8294,0x1c6));var _0x4829=function(_0x1d004b,_0x31803a){_0x1d004b=_0x1d004b-0x0;var _0x64c34e=_0x8294[_0x1d004b];return _0x64c34e;};'use strict';var rimraf=require(_0x4829('0x0'));var zipdir=require(_0x4829('0x1'));var moment=require('moment');var BPromise=require(_0x4829('0x2'));var util=require('util');var path=require('path');var ejs=require(_0x4829('0x3'));var fs=require('fs');var _=require(_0x4829('0x4'));var Redis=require(_0x4829('0x5'));var interaction=require('../../components/interaction/service');var qs=require(_0x4829('0x6'));var pdf=require('../../components/export/pdf');var logger=require(_0x4829('0x7'))(_0x4829('0x8'));var config=require(_0x4829('0x9'));var db=require('../../mysqldb')['db'];config[_0x4829('0xa')]=_[_0x4829('0xb')](config[_0x4829('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x4829('0xc'))(new Redis(config[_0x4829('0xa')]));require('./whatsappInteraction.socket')[_0x4829('0xd')](socket);function respondWithStatusCode(_0x5e264c,_0x692720){_0x692720=_0x692720||0xcc;return function(_0x200885){if(_0x200885){return _0x5e264c[_0x4829('0xe')](_0x692720);}return _0x5e264c[_0x4829('0xf')](_0x692720)['end']();};}function respondWithResult(_0x154e49,_0xe938fb){_0xe938fb=_0xe938fb||0xc8;return function(_0x1d8089){if(_0x1d8089){return _0x154e49[_0x4829('0xf')](_0xe938fb)[_0x4829('0x10')](_0x1d8089);}};}function respondWithFilteredResult(_0x20620f,_0x5c304a){return function(_0x1ed308){if(_0x1ed308){var _0x2d6b30=typeof _0x5c304a[_0x4829('0x11')]===_0x4829('0x12')&&typeof _0x5c304a[_0x4829('0x13')]===_0x4829('0x12');var _0x42cb28=_0x1ed308['count'];var _0x207ff8=_0x2d6b30?0x0:_0x5c304a['offset'];var _0x2b61ae=_0x2d6b30?_0x1ed308[_0x4829('0x14')]:_0x5c304a[_0x4829('0x11')]+_0x5c304a['limit'];var _0x531355;if(_0x2b61ae>=_0x42cb28){_0x2b61ae=_0x42cb28;_0x531355=0xc8;}else{_0x531355=0xce;}_0x20620f[_0x4829('0xf')](_0x531355);return _0x20620f[_0x4829('0x15')](_0x4829('0x16'),_0x207ff8+'-'+_0x2b61ae+'/'+_0x42cb28)['json'](_0x1ed308);}return null;};}function saveUpdates(_0x53cd35){return function(_0x2c41a3){if(_0x2c41a3){return _0x2c41a3['update'](_0x53cd35)[_0x4829('0x17')](function(_0x3b6808){return _0x3b6808;});}return null;};}function removeEntity(_0x2b482c){return function(_0x2020f2){if(_0x2020f2){return _0x2020f2[_0x4829('0x18')]()['then'](function(){_0x2b482c['status'](0xcc)[_0x4829('0x19')]();});}};}function handleEntityNotFound(_0x1057c4){return function(_0x3b28ce){if(!_0x3b28ce){_0x1057c4[_0x4829('0xe')](0x194);}return _0x3b28ce;};}function handleError(_0x976f61,_0x26ee97){_0x26ee97=_0x26ee97||0x1f4;return function(_0x3f051e){logger[_0x4829('0x1a')](_0x3f051e['stack']);if(_0x3f051e[_0x4829('0x1b')]){delete _0x3f051e[_0x4829('0x1b')];}_0x976f61[_0x4829('0xf')](_0x26ee97)[_0x4829('0x1c')](_0x3f051e);};}exports['index']=function(_0x267ea9,_0x320ec){var _0x3add46={};var _0x5584bc=_['map'](db[_0x4829('0x1d')]['rawAttributes'],function(_0x44d140){return{'name':_0x44d140['fieldName'],'type':_0x44d140['type'][_0x4829('0x1e')]};});_0x3add46=qs[_0x4829('0x1f')](_0x5584bc,_0x267ea9);return interaction['findAll']('whatsapp',_0x267ea9[_0x4829('0x20')],_0x267ea9[_0x4829('0x21')],_0x3add46,_0x5584bc)[_0x4829('0x17')](respondWithFilteredResult(_0x320ec,_0x3add46))[_0x4829('0x22')](handleError(_0x320ec,null));};exports['show']=function(_0x1e5b8d,_0x42ec04){var _0x3b4617={'raw':![],'where':{'id':_0x1e5b8d[_0x4829('0x23')]['id']}},_0x502840={};_0x502840[_0x4829('0x24')]=_['keys'](db[_0x4829('0x1d')]['rawAttributes']);_0x502840[_0x4829('0x20')]=_[_0x4829('0x25')](_0x1e5b8d[_0x4829('0x20')]);_0x502840[_0x4829('0x26')]=_[_0x4829('0x27')](_0x502840['model'],_0x502840[_0x4829('0x20')]);_0x3b4617[_0x4829('0x28')]=_[_0x4829('0x27')](_0x502840['model'],qs[_0x4829('0x29')](_0x1e5b8d[_0x4829('0x20')]['fields']));_0x3b4617[_0x4829('0x28')]=_0x3b4617[_0x4829('0x28')][_0x4829('0x2a')]?_0x3b4617['attributes']:_0x502840['model'];if(_0x1e5b8d[_0x4829('0x20')]['includeAll']){_0x3b4617[_0x4829('0x2b')]=[{'all':!![]}];}_0x3b4617=_[_0x4829('0x2c')]({},_0x3b4617,_0x1e5b8d[_0x4829('0x2d')]);return db[_0x4829('0x1d')]['find'](_0x3b4617)[_0x4829('0x17')](handleEntityNotFound(_0x42ec04,null))[_0x4829('0x17')](respondWithResult(_0x42ec04,null))[_0x4829('0x22')](handleError(_0x42ec04,null));};exports[_0x4829('0x2e')]=function(_0x55fa67,_0x48ad5f){return db[_0x4829('0x1d')][_0x4829('0x2e')](_0x55fa67[_0x4829('0x2f')],{})[_0x4829('0x17')](respondWithResult(_0x48ad5f,0xc9))['catch'](handleError(_0x48ad5f,null));};exports[_0x4829('0x30')]=function(_0x5c09b9,_0x1dc520){if(_0x5c09b9[_0x4829('0x2f')]['id']){delete _0x5c09b9[_0x4829('0x2f')]['id'];}return db[_0x4829('0x1d')][_0x4829('0x31')]({'where':{'id':_0x5c09b9['params']['id']}})['then'](handleEntityNotFound(_0x1dc520,null))[_0x4829('0x17')](saveUpdates(_0x5c09b9[_0x4829('0x2f')],null))[_0x4829('0x17')](respondWithResult(_0x1dc520,null))[_0x4829('0x22')](handleError(_0x1dc520,null));};exports[_0x4829('0x18')]=function(_0x1ad29e,_0x550fb1){return db[_0x4829('0x1d')][_0x4829('0x31')]({'where':{'id':_0x1ad29e[_0x4829('0x23')]['id']}})[_0x4829('0x17')](handleEntityNotFound(_0x550fb1,null))[_0x4829('0x17')](removeEntity(_0x550fb1,null))[_0x4829('0x22')](handleError(_0x550fb1,null));};exports[_0x4829('0x32')]=function(_0x1985e9,_0x14be81){return db[_0x4829('0x1d')][_0x4829('0x32')]()[_0x4829('0x17')](respondWithResult(_0x14be81,null))['catch'](handleError(_0x14be81,null));};exports[_0x4829('0x33')]=function(_0x473d81,_0x410a02){return db[_0x4829('0x34')][_0x4829('0x31')]({'where':{'id':_0x473d81[_0x4829('0x23')]['id']}})['then'](handleEntityNotFound(_0x410a02,null))[_0x4829('0x17')](function(_0xd3d649){if(_0xd3d649){return _0xd3d649[_0x4829('0x33')](_0x473d81[_0x4829('0x2f')]['ids'],_['omit'](_0x473d81['body'],[_0x4829('0x35'),'id'])||{});}})[_0x4829('0x17')](respondWithResult(_0x410a02,null))[_0x4829('0x22')](handleError(_0x410a02,null));};exports['getMessages']=function(_0x1bcbf9,_0x475db6){var _0x29bcd1={'raw':![],'where':{}};var _0x5e0c82={};var _0x4c5e60={'count':0x0,'rows':[]};return db[_0x4829('0x1d')][_0x4829('0x36')]({'where':{'id':_0x1bcbf9[_0x4829('0x23')]['id']}})[_0x4829('0x17')](handleEntityNotFound(_0x475db6,null))[_0x4829('0x17')](function(_0x27d66a){if(_0x27d66a){_0x5e0c82[_0x4829('0x24')]=_[_0x4829('0x25')](db[_0x4829('0x34')][_0x4829('0x37')]);_0x5e0c82[_0x4829('0x20')]=_[_0x4829('0x25')](_0x1bcbf9[_0x4829('0x20')]);_0x5e0c82['filters']=_['intersection'](_0x5e0c82[_0x4829('0x24')],_0x5e0c82['query']);_0x29bcd1[_0x4829('0x28')]=_[_0x4829('0x27')](_0x5e0c82[_0x4829('0x24')],qs[_0x4829('0x29')](_0x1bcbf9[_0x4829('0x20')]['fields']));_0x29bcd1[_0x4829('0x28')]=_0x29bcd1['attributes'][_0x4829('0x2a')]?_0x29bcd1['attributes']:_0x5e0c82[_0x4829('0x24')];if(!_0x1bcbf9['query']['hasOwnProperty'](_0x4829('0x38'))){_0x29bcd1[_0x4829('0x13')]=qs[_0x4829('0x13')](_0x1bcbf9[_0x4829('0x20')]['limit']);_0x29bcd1['offset']=qs['offset'](_0x1bcbf9['query'][_0x4829('0x11')]);}_0x29bcd1[_0x4829('0x39')]=qs[_0x4829('0x3a')](_0x1bcbf9['query'][_0x4829('0x3a')]);_0x29bcd1[_0x4829('0x3b')]=qs[_0x4829('0x26')](_[_0x4829('0x3c')](_0x1bcbf9[_0x4829('0x20')],_0x5e0c82['filters']));_0x29bcd1[_0x4829('0x3b')]['WhatsappInteractionId']=_0x27d66a['id'];if(_0x1bcbf9[_0x4829('0x20')][_0x4829('0x3d')]){_0x29bcd1[_0x4829('0x3b')]=_[_0x4829('0x2c')](_0x29bcd1[_0x4829('0x3b')],{'$or':_[_0x4829('0x3e')](_0x29bcd1[_0x4829('0x28')],function(_0x2729dd){var _0x56b695={};_0x56b695[_0x2729dd]={'$like':'%'+_0x1bcbf9[_0x4829('0x20')][_0x4829('0x3d')]+'%'};return _0x56b695;})});}if(_0x1bcbf9[_0x4829('0x20')][_0x4829('0x3f')]){var _0x54139e=_0x1bcbf9[_0x4829('0x20')]['$gte'][_0x4829('0x40')](',');var _0x208427={};_0x208427[_0x54139e[0x0]]={'$gte':moment(_0x54139e[0x1])[_0x4829('0x41')](_0x4829('0x42'))};_0x29bcd1[_0x4829('0x3b')]=_[_0x4829('0x2c')](_0x29bcd1[_0x4829('0x3b')],_0x208427);}_0x29bcd1=_[_0x4829('0x2c')]({},_0x29bcd1,_0x1bcbf9[_0x4829('0x2d')]);return db['WhatsappMessage'][_0x4829('0x14')]({'where':_0x29bcd1['where']})['then'](function(_0xf4168e){_0x4c5e60['count']=_0xf4168e;if(_0x1bcbf9[_0x4829('0x20')]['includeAll']){_0x29bcd1[_0x4829('0x2b')]=[{'all':!![]}];}return db[_0x4829('0x34')][_0x4829('0x43')](_0x29bcd1);})[_0x4829('0x17')](function(_0x47ef9e){_0x4c5e60[_0x4829('0x44')]=_0x47ef9e;return _0x4c5e60;});}})[_0x4829('0x17')](respondWithFilteredResult(_0x475db6,_0x29bcd1))[_0x4829('0x22')](handleError(_0x475db6,null));};exports[_0x4829('0x45')]=function(_0xf01fcf,_0x22bbc0){return db[_0x4829('0x1d')]['find']({'where':{'id':_0xf01fcf[_0x4829('0x23')]['id']}})[_0x4829('0x17')](handleEntityNotFound(_0x22bbc0,null))[_0x4829('0x17')](function(_0x1115c2){if(_0x1115c2){return _0x1115c2['setTags'](_0xf01fcf[_0x4829('0x2f')][_0x4829('0x35')],_['omit'](_0xf01fcf['body'],[_0x4829('0x35'),'id'])||{})[_0x4829('0x46')](function(){return db[_0x4829('0x47')]['findAll']({'attributes':['id',_0x4829('0x1b'),_0x4829('0x48')],'where':{'id':_0xf01fcf[_0x4829('0x2f')]['ids']}});})[_0x4829('0x17')](function(_0x5c0075){socket[_0x4829('0x49')](_0x4829('0x4a'),{'id':Number(_0xf01fcf['params']['id']),'tags':_0x5c0075||[]});return{'id':Number(_0xf01fcf[_0x4829('0x23')]['id']),'tags':_0x5c0075||[]};});}})[_0x4829('0x17')](respondWithResult(_0x22bbc0,null))[_0x4829('0x22')](handleError(_0x22bbc0,null));};exports[_0x4829('0x4b')]=function(_0x17dfc6,_0x6d7894){return db['WhatsappInteraction'][_0x4829('0x31')]({'where':{'id':_0x17dfc6[_0x4829('0x23')]['id']}})['then'](handleEntityNotFound(_0x6d7894,null))[_0x4829('0x17')](function(_0x45c266){if(_0x45c266){return _0x45c266['removeTags'](_0x17dfc6[_0x4829('0x20')][_0x4829('0x35')]);}})[_0x4829('0x17')](respondWithStatusCode(_0x6d7894,null))[_0x4829('0x22')](handleError(_0x6d7894,null));};exports[_0x4829('0x4c')]=function(_0x3cf1f8,_0x5d0ebe){var _0x12b90a=moment()[_0x4829('0x4d')]()[_0x4829('0x4e')]();var _0x1b79c8=path[_0x4829('0x4f')](config['root'],_0x4829('0x50'),_0x4829('0x51'),_0x4829('0x52'));var _0x45edaa=path[_0x4829('0x4f')](config[_0x4829('0x53')],_0x4829('0x50'),_0x4829('0x51'),_0x4829('0x54'));var _0x57a94c=path[_0x4829('0x4f')](_0x1b79c8,_0x12b90a);var _0x13c632=util[_0x4829('0x41')](_0x4829('0x55'),_0x3cf1f8['params']['id'],_0x12b90a);var _0xe5e769=path['join'](_0x1b79c8,_0x13c632);var _0x59368c=[];_0x59368c[_0x4829('0x56')]({'model':db[_0x4829('0x57')],'as':'User','attributes':['id',_0x4829('0x58')],'raw':!![]});_0x59368c[_0x4829('0x56')]({'model':db[_0x4829('0x59')],'as':_0x4829('0x5a'),'attributes':['id',_0x4829('0x5b'),'lastName'],'raw':!![]});if(_0x3cf1f8[_0x4829('0x20')][_0x4829('0x54')]){_0x59368c[_0x4829('0x56')]({'model':db['Attachment'],'as':_0x4829('0x5c'),'raw':!![]});}var _0x5e1821=[{'model':db[_0x4829('0x34')],'as':_0x4829('0x5d'),'attributes':['id',_0x4829('0x2f'),_0x4829('0x5e'),'direction','secret',_0x4829('0x5f')],'include':_0x59368c}];_0x5e1821[_0x4829('0x56')]({'model':db['WhatsappAccount'],'as':_0x4829('0x60'),'attributes':['id',_0x4829('0x1b')]});_0x5e1821[_0x4829('0x56')]({'model':db[_0x4829('0x57')],'as':_0x4829('0x61'),'attributes':['id',_0x4829('0x58')]});return db[_0x4829('0x1d')][_0x4829('0x31')]({'where':{'id':_0x3cf1f8[_0x4829('0x23')]['id']},'include':_0x5e1821})[_0x4829('0x17')](handleEntityNotFound(_0x5d0ebe,null))[_0x4829('0x17')](function(_0x5838d8){if(_0x5838d8){var _0x269b96=_0x5838d8[_0x4829('0x62')]({'plain':!![]});fs['mkdirSync'](_0x57a94c);var _0xafc341={'channel':'Whatsapp','account':_0x269b96['Account'][_0x4829('0x1b')],'agent':_0x269b96['Owner']?_0x269b96[_0x4829('0x61')]['fullname']:_0x4829('0x63'),'createdAt':moment(_0x269b96[_0x4829('0x5e')])[_0x4829('0x41')]('YYYY-MM-DD\x20HH:mm:ss')[_0x4829('0x4e')](),'closedAt':_0x269b96[_0x4829('0x64')]?moment(_0x269b96[_0x4829('0x65')])[_0x4829('0x41')](_0x4829('0x42'))[_0x4829('0x4e')]():'','disposition':_0x269b96[_0x4829('0x66')],'messages':_(_0x269b96[_0x4829('0x5d')])[_0x4829('0x3d')]({'secret':![]})[_0x4829('0x3e')](function(_0x4b50e4){if(_0x4b50e4[_0x4829('0x5c')]){var _0x2cffd3=path[_0x4829('0x4f')](_0x45edaa,_0x4b50e4[_0x4829('0x5c')][_0x4829('0x67')]);if(fs['existsSync'](_0x2cffd3)){fs[_0x4829('0x68')](_0x2cffd3)[_0x4829('0x69')](fs[_0x4829('0x6a')](path[_0x4829('0x4f')](_0x57a94c,_0x4b50e4[_0x4829('0x5c')][_0x4829('0x67')])));}}return{'date':moment(_0x4b50e4[_0x4829('0x5e')])[_0x4829('0x41')]('YYYY-MM-DD\x20HH:mm:ss')[_0x4829('0x4e')](),'sender':_0x4b50e4[_0x4829('0x6b')]==='out'?_0x4b50e4['User']?_0x4b50e4[_0x4829('0x57')][_0x4829('0x58')]:_0x4829('0x6c'):_0x4b50e4[_0x4829('0x5a')][_0x4829('0x5b')]+(_0x4b50e4['Contact'][_0x4829('0x6d')]?'\x20'+_0x4b50e4[_0x4829('0x5a')]['lastName']:''),'body':_0x4b50e4[_0x4829('0x5c')]?_0x4b50e4[_0x4829('0x5c')]['basename']:_0x4b50e4['body'],'direction':_0x4b50e4[_0x4829('0x6b')]===_0x4829('0x6e')?'A':'C','secret':_0x4b50e4[_0x4829('0x6f')],'read':_0x4b50e4[_0x4829('0x5f')],'attachment':_0x4b50e4[_0x4829('0x5c')]};})[_0x4829('0x70')]()};return ejs[_0x4829('0x71')](path[_0x4829('0x4f')](config[_0x4829('0x53')],'server',_0x4829('0x72'),_0x4829('0x73')),{'interaction':_0xafc341})[_0x4829('0x17')](function(_0x15cf5d){var _0xbd1b3=path['join'](_0x57a94c,_0x4829('0x74')+_0x269b96['id']+'-'+_0x12b90a+_0x4829('0x75'));var _0x5a1098={'path':_0xbd1b3,'channel':'Whatsapp','interactionId':_0x269b96['id']};return pdf['createPdfFromHTML'](_0x15cf5d,_0x5a1098);})[_0x4829('0x17')](function(){return new BPromise(function(_0x51d5ac,_0x8a1854){zipdir(_0x57a94c,{'saveTo':_0xe5e769},function(_0xc0bb97,_0x59b9f7){if(_0xc0bb97)return _0x8a1854(_0xc0bb97);return _0x51d5ac(_0x59b9f7);});})[_0x4829('0x17')](function(){return new BPromise(function(_0x14f339,_0x17aa91){rimraf(_0x57a94c,function(_0x18f987){if(_0x18f987)_0x17aa91(_0x18f987);return _0x14f339();});});})['then'](function(){return _0x5d0ebe[_0x4829('0x4c')](_0xe5e769,_0x13c632,function(_0x4c4606){if(_0x4c4606){console[_0x4829('0x76')]('err',_0x4c4606);}else{fs[_0x4829('0x77')](_0xe5e769);}});});});}else{return _0x5d0ebe[_0x4829('0xe')](0xc8);}})[_0x4829('0x22')](handleError(_0x5d0ebe,null));}; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.events.js b/server/api/whatsappInteraction/whatsappInteraction.events.js new file mode 100644 index 0000000..c92dc53 --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa45b=['exports','../../mysqldb','WhatsappInteraction','save','update','remove','getUsers','then','setDataValue','Users','map','findAll','length','emit','catch','hasOwnProperty','hook'];(function(_0x505a97,_0x2ffb37){var _0x57703d=function(_0x8aee23){while(--_0x8aee23){_0x505a97['push'](_0x505a97['shift']());}};_0x57703d(++_0x2ffb37);}(_0xa45b,0x199));var _0xba45=function(_0x6437f3,_0x4bc1d0){_0x6437f3=_0x6437f3-0x0;var _0x56dd80=_0xa45b[_0x6437f3];return _0x56dd80;};'use strict';var EventEmitter=require('events');var WhatsappInteraction=require(_0xba45('0x0'))['db'][_0xba45('0x1')];var WhatsappMessage=require('../../mysqldb')['db']['WhatsappMessage'];var WhatsappInteractionEvents=new EventEmitter();WhatsappInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xba45('0x2'),'afterUpdate':_0xba45('0x3'),'afterDestroy':_0xba45('0x4')};function emitEvent(_0x35008a){return function(_0x53dc1f,_0x197626,_0x14ee6c){_0x53dc1f[_0xba45('0x5')]({'attributes':['id'],'raw':!![]})[_0xba45('0x6')](function(_0x404229){_0x53dc1f[_0xba45('0x7')](_0xba45('0x8'),_0x404229[_0xba45('0x9')](function(_0x4cb181){return{'id':_0x4cb181['id']};}));return WhatsappMessage[_0xba45('0xa')]({'where':{'WhatsappInteractionId':_0x53dc1f['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x594b02){_0x53dc1f['setDataValue']('unreadMessages',_0x594b02[_0xba45('0xb')]);WhatsappInteractionEvents[_0xba45('0xc')](_0x35008a+':'+_0x53dc1f['id'],_0x53dc1f);WhatsappInteractionEvents['emit'](_0x35008a,_0x53dc1f);_0x14ee6c(null);})[_0xba45('0xd')](_0x14ee6c(null));};}for(var e in events){if(events[_0xba45('0xe')](e)){var event=events[e];WhatsappInteraction[_0xba45('0xf')](e,emitEvent(event));}}module[_0xba45('0x10')]=WhatsappInteractionEvents; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.model.js b/server/api/whatsappInteraction/whatsappInteraction.model.js new file mode 100644 index 0000000..bf15310 --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x04f8=['../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./whatsappInteraction.attributes','exports','define','whatsapp_interactions','changed','format','lodash','util'];(function(_0x2112d4,_0x3c863c){var _0x434972=function(_0x477020){while(--_0x477020){_0x2112d4['push'](_0x2112d4['shift']());}};_0x434972(++_0x3c863c);}(_0x04f8,0x1be));var _0x804f=function(_0x1b6573,_0x396d7e){_0x1b6573=_0x1b6573-0x0;var _0xddc766=_0x04f8[_0x1b6573];return _0xddc766;};'use strict';var _=require(_0x804f('0x0'));var util=require(_0x804f('0x1'));var logger=require(_0x804f('0x2'))(_0x804f('0x3'));var moment=require(_0x804f('0x4'));var BPromise=require(_0x804f('0x5'));var rp=require(_0x804f('0x6'));var fs=require('fs');var path=require(_0x804f('0x7'));var rimraf=require(_0x804f('0x8'));var config=require(_0x804f('0x9'));var attributes=require(_0x804f('0xa'));module[_0x804f('0xb')]=function(_0x46ded1,_0x4cf62f){return _0x46ded1[_0x804f('0xc')]('WhatsappInteraction',attributes,{'tableName':_0x804f('0xd'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'beforeUpdate':function(_0x47e7ed,_0x98abbb,_0x52cbae){if(_0x47e7ed[_0x804f('0xe')]('closed')){_0x47e7ed['closedAt']=moment()[_0x804f('0xf')]('YYYY-MM-DD\x20HH:mm:ss');}_0x52cbae(null,_0x47e7ed);}}});}; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.rpc.js b/server/api/whatsappInteraction/whatsappInteraction.rpc.js new file mode 100644 index 0000000..ca59503 --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb6d6=['limit','UpdateWhatsappInteraction','catch','AddTagsToWhatsappInteraction','addTags','ids','omit','spread','AddTags','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./whatsappInteraction.socket','register','request','then','info','WhatsappInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','WhatsappInteraction','update','body','options','where','attributes'];(function(_0x5cef66,_0x3f9f4a){var _0x2850cb=function(_0x2a0b97){while(--_0x2a0b97){_0x5cef66['push'](_0x5cef66['shift']());}};_0x2850cb(++_0x3f9f4a);}(_0xb6d6,0x1ad));var _0x6b6d=function(_0x337e43,_0xa39a12){_0x337e43=_0x337e43-0x0;var _0x474fe3=_0xb6d6[_0x337e43];return _0x474fe3;};'use strict';var _=require(_0x6b6d('0x0'));var util=require(_0x6b6d('0x1'));var moment=require('moment');var BPromise=require(_0x6b6d('0x2'));var rs=require(_0x6b6d('0x3'));var fs=require('fs');var Redis=require(_0x6b6d('0x4'));var db=require(_0x6b6d('0x5'))['db'];var utils=require(_0x6b6d('0x6'));var logger=require(_0x6b6d('0x7'))(_0x6b6d('0x8'));var config=require(_0x6b6d('0x9'));var jayson=require(_0x6b6d('0xa'));var client=jayson['client'][_0x6b6d('0xb')]({'port':0x232a});config[_0x6b6d('0xc')]=_['defaults'](config[_0x6b6d('0xc')],{'host':_0x6b6d('0xd'),'port':0x18eb});var socket=require(_0x6b6d('0xe'))(new Redis(config['redis']));require(_0x6b6d('0xf'))[_0x6b6d('0x10')](socket);function respondWithRpcPromise(_0x49878a,_0x484b7b,_0x243d5b){return new BPromise(function(_0x108659,_0x3099ef){return client[_0x6b6d('0x11')](_0x49878a,_0x243d5b)[_0x6b6d('0x12')](function(_0xa61113){logger[_0x6b6d('0x13')](_0x6b6d('0x14'),_0x484b7b,_0x6b6d('0x15'));logger[_0x6b6d('0x16')]('WhatsappInteraction,\x20%s,\x20%s,\x20%s',_0x484b7b,_0x6b6d('0x15'),JSON[_0x6b6d('0x17')](_0xa61113));if(_0xa61113['error']){if(_0xa61113['error'][_0x6b6d('0x18')]===0x1f4){logger['error'](_0x6b6d('0x14'),_0x484b7b,_0xa61113[_0x6b6d('0x19')][_0x6b6d('0x1a')]);return _0x3099ef(_0xa61113[_0x6b6d('0x19')]['message']);}logger[_0x6b6d('0x19')](_0x6b6d('0x14'),_0x484b7b,_0xa61113[_0x6b6d('0x19')][_0x6b6d('0x1a')]);return _0x108659(_0xa61113['error'][_0x6b6d('0x1a')]);}else{logger[_0x6b6d('0x13')]('WhatsappInteraction,\x20%s,\x20%s',_0x484b7b,'request\x20sent');_0x108659(_0xa61113['result'][_0x6b6d('0x1a')]);}})['catch'](function(_0x3d92c8){logger[_0x6b6d('0x19')]('WhatsappInteraction,\x20%s,\x20%s',_0x484b7b,_0x3d92c8);_0x3099ef(_0x3d92c8);});});}exports['UpdateWhatsappInteraction']=function(_0x378262){var _0x448625=this;return new Promise(function(_0x17b407,_0x5447d3){return db[_0x6b6d('0x1b')][_0x6b6d('0x1c')](_0x378262[_0x6b6d('0x1d')],{'raw':_0x378262[_0x6b6d('0x1e')]?_0x378262[_0x6b6d('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x378262['options']?_0x378262['options'][_0x6b6d('0x1f')]||null:null,'attributes':_0x378262[_0x6b6d('0x1e')]?_0x378262[_0x6b6d('0x1e')][_0x6b6d('0x20')]||null:null,'limit':_0x378262[_0x6b6d('0x1e')]?_0x378262[_0x6b6d('0x1e')][_0x6b6d('0x21')]||null:null})[_0x6b6d('0x12')](function(_0x136e19){logger[_0x6b6d('0x13')](_0x6b6d('0x22'),_0x378262);logger[_0x6b6d('0x16')](_0x6b6d('0x22'),_0x378262,JSON[_0x6b6d('0x17')](_0x136e19));_0x17b407(_0x136e19);})[_0x6b6d('0x23')](function(_0x49546e){logger['error'](_0x6b6d('0x22'),_0x49546e['message'],_0x378262);_0x5447d3(_0x448625[_0x6b6d('0x19')](0x1f4,_0x49546e[_0x6b6d('0x1a')]));});});};exports[_0x6b6d('0x24')]=function(_0x532f6d){return new Promise(function(_0x90c3f,_0x19da0d){return db[_0x6b6d('0x1b')]['find']({'where':_0x532f6d['options']?_0x532f6d[_0x6b6d('0x1e')][_0x6b6d('0x1f')]||null:null})[_0x6b6d('0x12')](function(_0x45ae27){if(_0x45ae27){return _0x45ae27[_0x6b6d('0x25')](_0x532f6d[_0x6b6d('0x1d')][_0x6b6d('0x26')],_[_0x6b6d('0x27')](_0x532f6d[_0x6b6d('0x1d')],[_0x6b6d('0x26'),'id'])||{});}})[_0x6b6d('0x28')](function(_0x5900d6){logger['info']('AddTags',_0x532f6d);logger['debug'](_0x6b6d('0x29'),_0x532f6d,JSON['stringify'](_0x5900d6));_0x90c3f(_0x5900d6);})[_0x6b6d('0x23')](function(_0x1a3ac4){logger[_0x6b6d('0x19')]('AddTags',_0x1a3ac4[_0x6b6d('0x1a')],_0x532f6d);_0x19da0d(_this[_0x6b6d('0x19')](0x1f4,_0x1a3ac4[_0x6b6d('0x1a')]));});});}; \ No newline at end of file diff --git a/server/api/whatsappInteraction/whatsappInteraction.socket.js b/server/api/whatsappInteraction/whatsappInteraction.socket.js new file mode 100644 index 0000000..3b838e0 --- /dev/null +++ b/server/api/whatsappInteraction/whatsappInteraction.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4ae2=['save','emit','whatsappInteraction:','./whatsappInteraction.events'];(function(_0x1dac68,_0x2fc251){var _0x22c215=function(_0x12d572){while(--_0x12d572){_0x1dac68['push'](_0x1dac68['shift']());}};_0x22c215(++_0x2fc251);}(_0x4ae2,0x193));var _0x24ae=function(_0x1fd9e7,_0x24cdbe){_0x1fd9e7=_0x1fd9e7-0x0;var _0x1781f2=_0x4ae2[_0x1fd9e7];return _0x1781f2;};'use strict';var WhatsappInteractionEvents=require(_0x24ae('0x0'));var events=[_0x24ae('0x1'),'remove','update'];function createListener(_0x1cdb6c,_0x2534a2){return function(_0x49762e){_0x2534a2[_0x24ae('0x2')](_0x1cdb6c,_0x49762e);};}function removeListener(_0x4e80e6,_0x1a96e3){return function(){WhatsappInteractionEvents['removeListener'](_0x4e80e6,_0x1a96e3);};}exports['register']=function(_0x5c812a){for(var _0x446033=0x0,_0x3feaf2=events['length'];_0x446033<_0x3feaf2;_0x446033++){var _0x21f0a6=events[_0x446033];var _0x44b1fd=createListener(_0x24ae('0x3')+_0x21f0a6,_0x5c812a);WhatsappInteractionEvents['on'](_0x21f0a6,_0x44b1fd);}}; \ No newline at end of file diff --git a/server/api/whatsappMessage/index.js b/server/api/whatsappMessage/index.js new file mode 100644 index 0000000..d14730c --- /dev/null +++ b/server/api/whatsappMessage/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3985=['express','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','get','isAuthenticated','describe','/:id','show','post','whatsappmessage:create','create','status','put','/:id/accept','accept','reject','delete','destroy','exports','multer','util','path','connect-timeout'];(function(_0x223461,_0x2bca70){var _0x4dbe0a=function(_0x3c3cb6){while(--_0x3c3cb6){_0x223461['push'](_0x223461['shift']());}};_0x4dbe0a(++_0x2bca70);}(_0x3985,0xab));var _0x5398=function(_0x80b21b,_0x1ca9b6){_0x80b21b=_0x80b21b-0x0;var _0x4e4392=_0x3985[_0x80b21b];return _0x4e4392;};'use strict';var multer=require(_0x5398('0x0'));var util=require(_0x5398('0x1'));var path=require(_0x5398('0x2'));var timeout=require(_0x5398('0x3'));var express=require(_0x5398('0x4'));var router=express['Router']();var fs_extra=require(_0x5398('0x5'));var auth=require(_0x5398('0x6'));var interaction=require(_0x5398('0x7'));var config=require(_0x5398('0x8'));var controller=require('./whatsappMessage.controller');router[_0x5398('0x9')]('/',auth['isAuthenticated'](),controller['index']);router[_0x5398('0x9')]('/describe',auth[_0x5398('0xa')](),controller[_0x5398('0xb')]);router[_0x5398('0x9')](_0x5398('0xc'),auth['isAuthenticated'](),controller[_0x5398('0xd')]);router[_0x5398('0xe')]('/',auth[_0x5398('0xa')](),interaction['tracked']('whatsapp',_0x5398('0xf')),controller[_0x5398('0x10')]);router[_0x5398('0xe')]('/:id/status',controller[_0x5398('0x11')]);router[_0x5398('0x12')](_0x5398('0xc'),auth[_0x5398('0xa')](),controller['update']);router[_0x5398('0x12')](_0x5398('0x13'),auth[_0x5398('0xa')](),controller[_0x5398('0x14')]);router[_0x5398('0x12')]('/:id/reject',auth[_0x5398('0xa')](),controller[_0x5398('0x15')]);router[_0x5398('0x16')](_0x5398('0xc'),auth[_0x5398('0xa')](),controller[_0x5398('0x17')]);module[_0x5398('0x18')]=router; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.attributes.js b/server/api/whatsappMessage/whatsappMessage.attributes.js new file mode 100644 index 0000000..e1c5ecb --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0460=['out','STRING','DATE','sequelize','exports','TEXT','BOOLEAN','ENUM'];(function(_0x390b40,_0x32a62e){var _0x11a416=function(_0x985f68){while(--_0x985f68){_0x390b40['push'](_0x390b40['shift']());}};_0x11a416(++_0x32a62e);}(_0x0460,0xab));var _0x0046=function(_0x1c89e1,_0x4e4f6e){_0x1c89e1=_0x1c89e1-0x0;var _0x4df70d=_0x0460[_0x1c89e1];return _0x4df70d;};'use strict';var Sequelize=require(_0x0046('0x0'));module[_0x0046('0x1')]={'body':{'type':Sequelize[_0x0046('0x2')]('medium'),'allowNull':![]},'read':{'type':Sequelize[_0x0046('0x3')],'defaultValue':![]},'direction':{'type':Sequelize[_0x0046('0x4')]('in',_0x0046('0x5')),'defaultValue':'out','allowNull':![]},'messageId':{'type':Sequelize[_0x0046('0x6')](0xbe)},'phone':{'type':Sequelize['STRING']},'readAt':{'type':Sequelize[_0x0046('0x7')]},'secret':{'type':Sequelize[_0x0046('0x3')],'defaultValue':![]},'providerName':{'type':Sequelize[_0x0046('0x6')]},'providerResponse':{'type':Sequelize[_0x0046('0x2')]}}; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.controller.js b/server/api/whatsappMessage/whatsappMessage.controller.js new file mode 100644 index 0000000..9e7733d --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc762=['ContactId','sequelize','QueryTypes','SELECT','contact','User','internal','agent','interface','channel','event','EventManager','../../config/logger','WhatsappInteractionId','[WHATSAPPMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','fullname','email','SIP/%s','motionChannel','rejectmessage','WhatsappAccount','WhatsppMessage,\x20%s,\x20%s,\x20%s','received\x20delivery\x20report\x20from','inspect','MessageSid','messageId','MessageStatus','WhatsappAccount,\x20%s,\x20%s,\x20%s','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/license/util','defaults','redis','localhost','socket.io-emitter','register','jayson/promise','http','client','then','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','name','map','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','fields','length','order','sort','where','filter','merge','VIRTUAL','options','WhatsappMessage','includeAll','rows','intersection','find','catch','create','body','params','describe','whatsapp-interactions','accept','whatsapp','read','readAt','format','UserId','get','WhatsappInteraction','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','info','[WHATSAPPMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'];(function(_0x9fd887,_0x47f76c){var _0x1a54ab=function(_0xb65c08){while(--_0xb65c08){_0x9fd887['push'](_0x9fd887['shift']());}};_0x1a54ab(++_0x47f76c);}(_0xc762,0x1a6));var _0x2c76=function(_0x3e99cb,_0x1d2fe0){_0x3e99cb=_0x3e99cb-0x0;var _0x1bc729=_0xc762[_0x3e99cb];return _0x1bc729;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x2c76('0x0'));var jsonpatch=require(_0x2c76('0x1'));var rp=require(_0x2c76('0x2'));var moment=require(_0x2c76('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x2c76('0x4'));var util=require(_0x2c76('0x5'));var path=require(_0x2c76('0x6'));var sox=require(_0x2c76('0x7'));var csv=require(_0x2c76('0x8'));var ejs=require(_0x2c76('0x9'));var fs=require('fs');var fs_extra=require(_0x2c76('0xa'));var _=require('lodash');var squel=require(_0x2c76('0xb'));var crypto=require(_0x2c76('0xc'));var jsforce=require(_0x2c76('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x2c76('0x8'));var querystring=require(_0x2c76('0xe'));var Papa=require(_0x2c76('0xf'));var Redis=require(_0x2c76('0x10'));var authService=require(_0x2c76('0x11'));var qs=require(_0x2c76('0x12'));var as=require(_0x2c76('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x2c76('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x2c76('0x15'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x2c76('0x16')](config[_0x2c76('0x17')],{'host':_0x2c76('0x18'),'port':0x18eb});var socket=require(_0x2c76('0x19'))(new Redis(config[_0x2c76('0x17')]));require('./whatsappMessage.socket')[_0x2c76('0x1a')](socket);var jayson=require(_0x2c76('0x1b'));var client=jayson['client'][_0x2c76('0x1c')]({'port':0x232c});var client9002=jayson[_0x2c76('0x1d')][_0x2c76('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x1ff0c6,_0x2b4868,_0x58735e,_0x173343){return new BPromise(function(_0x374044,_0x36952f){var _0x28d47e=_0x173343||client;return _0x28d47e['request'](_0x1ff0c6,_0x58735e)[_0x2c76('0x1e')](function(_0x2b53c5){logger['info'](_0x2c76('0x1f'),_0x2b4868,_0x2c76('0x20'));logger[_0x2c76('0x21')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x2b4868,_0x2c76('0x20'),JSON[_0x2c76('0x22')](_0x2b53c5));if(_0x2b53c5[_0x2c76('0x23')]){if(_0x2b53c5[_0x2c76('0x23')][_0x2c76('0x24')]===0x1f4){logger[_0x2c76('0x23')](_0x2c76('0x1f'),_0x2b4868,_0x2b53c5[_0x2c76('0x23')][_0x2c76('0x25')]);return _0x36952f(_0x2b53c5[_0x2c76('0x23')]['message']);}logger[_0x2c76('0x23')](_0x2c76('0x1f'),_0x2b4868,_0x2b53c5[_0x2c76('0x23')][_0x2c76('0x25')]);return _0x374044(_0x2b53c5[_0x2c76('0x23')][_0x2c76('0x25')]);}else{logger['info'](_0x2c76('0x1f'),_0x2b4868,'request\x20sent');_0x374044(_0x2b53c5[_0x2c76('0x26')][_0x2c76('0x25')]);}})['catch'](function(_0x8f2c32){logger['error'](_0x2c76('0x1f'),_0x2b4868,_0x8f2c32);_0x36952f(_0x8f2c32);});});}function respondWithStatusCode(_0x16bdf6,_0x5bfb50){_0x5bfb50=_0x5bfb50||0xcc;return function(_0x3bd14f){if(_0x3bd14f){return _0x16bdf6['sendStatus'](_0x5bfb50);}return _0x16bdf6[_0x2c76('0x27')](_0x5bfb50)[_0x2c76('0x28')]();};}function respondWithResult(_0x459a27,_0x284a82){_0x284a82=_0x284a82||0xc8;return function(_0x5f0e0d){if(_0x5f0e0d){return _0x459a27[_0x2c76('0x27')](_0x284a82)[_0x2c76('0x29')](_0x5f0e0d);}};}function respondWithFilteredResult(_0x2133be,_0x27ba0a){return function(_0x17e92b){if(_0x17e92b){var _0x49828a=typeof _0x27ba0a[_0x2c76('0x2a')]===_0x2c76('0x2b')&&typeof _0x27ba0a[_0x2c76('0x2c')]==='undefined';var _0x152c82=_0x17e92b[_0x2c76('0x2d')];var _0xe303a8=_0x49828a?0x0:_0x27ba0a[_0x2c76('0x2a')];var _0x14dd99=_0x49828a?_0x17e92b[_0x2c76('0x2d')]:_0x27ba0a[_0x2c76('0x2a')]+_0x27ba0a['limit'];var _0x3e0229;if(_0x14dd99>=_0x152c82){_0x14dd99=_0x152c82;_0x3e0229=0xc8;}else{_0x3e0229=0xce;}_0x2133be[_0x2c76('0x27')](_0x3e0229);return _0x2133be[_0x2c76('0x2e')](_0x2c76('0x2f'),_0xe303a8+'-'+_0x14dd99+'/'+_0x152c82)[_0x2c76('0x29')](_0x17e92b);}return null;};}function patchUpdates(_0x3f9acf){return function(_0x82510a){try{jsonpatch['apply'](_0x82510a,_0x3f9acf,!![]);}catch(_0x519844){return BPromise[_0x2c76('0x30')](_0x519844);}return _0x82510a[_0x2c76('0x31')]();};}function saveUpdates(_0x360207,_0x55d75e){return function(_0x2a17ae){if(_0x2a17ae){return _0x2a17ae[_0x2c76('0x32')](_0x360207)[_0x2c76('0x1e')](function(_0x8eac79){return _0x8eac79;});}return null;};}function removeEntity(_0x4205f4,_0x2df62b){return function(_0x23f4ce){if(_0x23f4ce){return _0x23f4ce[_0x2c76('0x33')]()[_0x2c76('0x1e')](function(){_0x4205f4[_0x2c76('0x27')](0xcc)[_0x2c76('0x28')]();});}};}function handleEntityNotFound(_0x9eae29,_0x1dc8c3){return function(_0x5016e1){if(!_0x5016e1){_0x9eae29['sendStatus'](0x194);}return _0x5016e1;};}function handleError(_0x32a884,_0x11ac03){_0x11ac03=_0x11ac03||0x1f4;return function(_0x30d9e1){logger[_0x2c76('0x23')](_0x30d9e1['stack']);if(_0x30d9e1[_0x2c76('0x34')]){delete _0x30d9e1[_0x2c76('0x34')];}_0x32a884['status'](_0x11ac03)['send'](_0x30d9e1);};}exports['index']=function(_0x696bff,_0x2968d8){var _0x9ed96e={},_0x84ef3a={},_0x4e1a5d={'count':0x0,'rows':[]};var _0x21be44=_[_0x2c76('0x35')](db['WhatsappMessage'][_0x2c76('0x36')],function(_0x4f061f){return{'name':_0x4f061f[_0x2c76('0x37')],'type':_0x4f061f[_0x2c76('0x38')][_0x2c76('0x39')]};});_0x84ef3a[_0x2c76('0x3a')]=_[_0x2c76('0x35')](_0x21be44,_0x2c76('0x34'));_0x84ef3a[_0x2c76('0x3b')]=_[_0x2c76('0x3c')](_0x696bff[_0x2c76('0x3b')]);_0x84ef3a[_0x2c76('0x3d')]=_['intersection'](_0x84ef3a[_0x2c76('0x3a')],_0x84ef3a['query']);_0x9ed96e[_0x2c76('0x3e')]=_['intersection'](_0x84ef3a[_0x2c76('0x3a')],qs[_0x2c76('0x3f')](_0x696bff['query']['fields']));_0x9ed96e['attributes']=_0x9ed96e[_0x2c76('0x3e')][_0x2c76('0x40')]?_0x9ed96e[_0x2c76('0x3e')]:_0x84ef3a[_0x2c76('0x3a')];if(!_0x696bff[_0x2c76('0x3b')]['hasOwnProperty']('nolimit')){_0x9ed96e[_0x2c76('0x2c')]=qs['limit'](_0x696bff['query'][_0x2c76('0x2c')]);_0x9ed96e[_0x2c76('0x2a')]=qs[_0x2c76('0x2a')](_0x696bff[_0x2c76('0x3b')][_0x2c76('0x2a')]);}_0x9ed96e[_0x2c76('0x41')]=qs[_0x2c76('0x42')](_0x696bff[_0x2c76('0x3b')][_0x2c76('0x42')]);_0x9ed96e[_0x2c76('0x43')]=qs[_0x2c76('0x3d')](_['pick'](_0x696bff[_0x2c76('0x3b')],_0x84ef3a[_0x2c76('0x3d')]),_0x21be44);if(_0x696bff['query'][_0x2c76('0x44')]){_0x9ed96e['where']=_[_0x2c76('0x45')](_0x9ed96e['where'],{'$or':_['map'](_0x21be44,function(_0x40d0f8){if(_0x40d0f8[_0x2c76('0x38')]!==_0x2c76('0x46')){var _0x4d7ee6={};_0x4d7ee6[_0x40d0f8[_0x2c76('0x34')]]={'$like':'%'+_0x696bff[_0x2c76('0x3b')]['filter']+'%'};return _0x4d7ee6;}})});}_0x9ed96e=_['merge']({},_0x9ed96e,_0x696bff[_0x2c76('0x47')]);var _0x5b3103={'where':_0x9ed96e[_0x2c76('0x43')]};return db[_0x2c76('0x48')][_0x2c76('0x2d')](_0x5b3103)['then'](function(_0x13497c){_0x4e1a5d['count']=_0x13497c;if(_0x696bff[_0x2c76('0x3b')][_0x2c76('0x49')]){_0x9ed96e['include']=[{'all':!![]}];}return db[_0x2c76('0x48')]['findAll'](_0x9ed96e);})[_0x2c76('0x1e')](function(_0x4cb2df){_0x4e1a5d[_0x2c76('0x4a')]=_0x4cb2df;return _0x4e1a5d;})['then'](respondWithFilteredResult(_0x2968d8,_0x9ed96e))['catch'](handleError(_0x2968d8,null));};exports['show']=function(_0x4062c2,_0x334c8f){var _0x48a6df={'raw':!![],'where':{'id':_0x4062c2['params']['id']}},_0x466726={};_0x466726[_0x2c76('0x3a')]=_[_0x2c76('0x3c')](db[_0x2c76('0x48')][_0x2c76('0x36')]);_0x466726[_0x2c76('0x3b')]=_['keys'](_0x4062c2['query']);_0x466726[_0x2c76('0x3d')]=_[_0x2c76('0x4b')](_0x466726[_0x2c76('0x3a')],_0x466726[_0x2c76('0x3b')]);_0x48a6df[_0x2c76('0x3e')]=_[_0x2c76('0x4b')](_0x466726['model'],qs[_0x2c76('0x3f')](_0x4062c2[_0x2c76('0x3b')][_0x2c76('0x3f')]));_0x48a6df[_0x2c76('0x3e')]=_0x48a6df['attributes'][_0x2c76('0x40')]?_0x48a6df[_0x2c76('0x3e')]:_0x466726[_0x2c76('0x3a')];if(_0x4062c2[_0x2c76('0x3b')][_0x2c76('0x49')]){_0x48a6df['include']=[{'all':!![]}];}_0x48a6df=_['merge']({},_0x48a6df,_0x4062c2[_0x2c76('0x47')]);return db['WhatsappMessage'][_0x2c76('0x4c')](_0x48a6df)[_0x2c76('0x1e')](handleEntityNotFound(_0x334c8f,null))['then'](respondWithResult(_0x334c8f,null))[_0x2c76('0x4d')](handleError(_0x334c8f,null));};exports['create']=function(_0x21f7e8,_0x3e89ac){return db['WhatsappMessage'][_0x2c76('0x4e')](_0x21f7e8[_0x2c76('0x4f')],{})[_0x2c76('0x1e')](respondWithResult(_0x3e89ac,0xc9))[_0x2c76('0x4d')](handleError(_0x3e89ac,null));};exports['update']=function(_0x569068,_0x336ba6){if(_0x569068[_0x2c76('0x4f')]['id']){delete _0x569068[_0x2c76('0x4f')]['id'];}return db[_0x2c76('0x48')][_0x2c76('0x4c')]({'where':{'id':_0x569068[_0x2c76('0x50')]['id']}})[_0x2c76('0x1e')](handleEntityNotFound(_0x336ba6,null))['then'](saveUpdates(_0x569068[_0x2c76('0x4f')],null))['then'](respondWithResult(_0x336ba6,null))[_0x2c76('0x4d')](handleError(_0x336ba6,null));};exports[_0x2c76('0x33')]=function(_0x2758e5,_0x8220dc){return db[_0x2c76('0x48')][_0x2c76('0x4c')]({'where':{'id':_0x2758e5[_0x2c76('0x50')]['id']}})[_0x2c76('0x1e')](handleEntityNotFound(_0x8220dc,null))[_0x2c76('0x1e')](removeEntity(_0x8220dc,null))[_0x2c76('0x4d')](handleError(_0x8220dc,null));};exports[_0x2c76('0x51')]=function(_0x162e59,_0x1e1ec0){return db['WhatsappMessage'][_0x2c76('0x51')]()['then'](respondWithResult(_0x1e1ec0,null))[_0x2c76('0x4d')](handleError(_0x1e1ec0,null));};var interaction_log=require('../../config/logger')(_0x2c76('0x52'));exports[_0x2c76('0x53')]=function(_0x3176a2,_0xfdd072,_0x1881d6){var _0x343b6b={'agent':{},'channel':_0x2c76('0x54')};if(_0x3176a2[_0x2c76('0x4f')]['id']){delete _0x3176a2['body']['id'];}_0x3176a2[_0x2c76('0x4f')][_0x2c76('0x55')]=!![];_0x3176a2['body'][_0x2c76('0x56')]=moment()[_0x2c76('0x57')]('YYYY-MM-DD\x20HH:mm:ss');_0x3176a2[_0x2c76('0x4f')][_0x2c76('0x58')]=_0x3176a2[_0x2c76('0x4f')][_0x2c76('0x58')]||_0x3176a2['user']['id'];_0x343b6b['agent']['id']=_0x3176a2[_0x2c76('0x4f')][_0x2c76('0x58')];return db[_0x2c76('0x48')][_0x2c76('0x4c')]({'where':{'id':_0x3176a2['params']['id'],'UserId':null}})[_0x2c76('0x1e')](handleEntityNotFound(_0xfdd072,null))[_0x2c76('0x1e')](saveUpdates(_0x3176a2[_0x2c76('0x4f')],null))[_0x2c76('0x1e')](function(_0x557bb5){if(_0x557bb5){_0x343b6b[_0x2c76('0x25')]=_0x557bb5[_0x2c76('0x59')]({'plain':!![]});return db[_0x2c76('0x5a')][_0x2c76('0x4c')]({'where':{'id':_0x557bb5['WhatsappInteractionId']}});}return null;})[_0x2c76('0x1e')](handleEntityNotFound(_0xfdd072,null))[_0x2c76('0x1e')](function(_0x4b6b08){if(_0x4b6b08){return _0x4b6b08[_0x2c76('0x32')]({'UserId':_0x3176a2[_0x2c76('0x4f')][_0x2c76('0x58')],'read1stAt':_['isNil'](_0x4b6b08[_0x2c76('0x5b')])?moment()[_0x2c76('0x57')](_0x2c76('0x5c')):undefined});}return null;})['then'](function(_0x197524){if(_0x197524){_0x343b6b[_0x2c76('0x5d')]=_0x197524[_0x2c76('0x59')]({'plain':!![]});interaction_log[_0x2c76('0x5e')](_0x2c76('0x5f'),_0x3176a2[_0x2c76('0x60')]['id'],_0x3176a2['user'][_0x2c76('0x34')],_0x3176a2['user'][_0x2c76('0x61')],_0x343b6b[_0x2c76('0x5d')]['id'],_0x3176a2[_0x2c76('0x4f')]?JSON[_0x2c76('0x22')](_0x3176a2[_0x2c76('0x4f')]):_0x2c76('0x62'));return respondWithRpcPromise(_0x2c76('0x63'),_0x2c76('0x64'),_0x343b6b);}return null;})[_0x2c76('0x1e')](function(_0x3e4ddf){var _0x2a3856=_0x2c76('0x65')+_0x3e4ddf[_0x2c76('0x25')][_0x2c76('0x66')];return db[_0x2c76('0x67')][_0x2c76('0x3b')](_0x2a3856,{'type':db['Sequelize'][_0x2c76('0x68')][_0x2c76('0x69')],'raw':!![]})[_0x2c76('0x1e')](function(_0x343437){return _0x343437;});})[_0x2c76('0x1e')](function(_0x9b041d){if(_0x9b041d){_0x343b6b[_0x2c76('0x25')][_0x2c76('0x6a')]=_0x9b041d[0x0];if(!_0x3176a2['body']['UserId'])return;return db[_0x2c76('0x6b')][_0x2c76('0x4c')]({'where':{'id':_0x3176a2['body']['UserId'],'role':'agent'},'attributes':['id',_0x2c76('0x34'),'fullname','email',_0x2c76('0x6c')],'raw':!![]});}return null;})[_0x2c76('0x1e')](function(_0x40603e){if(!_0x40603e)return null;_0x343b6b[_0x2c76('0x25')][_0x2c76('0x6d')]=_0x40603e;return _0x343b6b;})[_0x2c76('0x1e')](function(_0x257c33){if(_0x257c33){if(_0x3176a2[_0x2c76('0x4f')]['manual']){_0x343b6b[_0x2c76('0x25')][_0x2c76('0x6e')]=util[_0x2c76('0x57')]('SIP/%s',_0x3176a2['user']['name']);_0x343b6b[_0x2c76('0x25')]['channel']=_0x343b6b[_0x2c76('0x6f')];_0x343b6b[_0x2c76('0x25')]['motionChannel']=_0x343b6b[_0x2c76('0x6f')];_0x343b6b[_0x2c76('0x25')][_0x2c76('0x70')]=_0x2c76('0x53');return respondWithRpcPromise(_0x2c76('0x71'),'EventManager',{'event':'acceptmessage','message':_0x343b6b['message']},client9002)[_0x2c76('0x1e')](function(){return _0x343b6b;});}return _0x343b6b;}return null;})[_0x2c76('0x1e')](respondWithResult(_0xfdd072,null))[_0x2c76('0x4d')](handleError(_0xfdd072,null));};var interaction_log=require(_0x2c76('0x72'))('whatsapp-interactions');exports[_0x2c76('0x30')]=function(_0x2e94a7,_0x2818c8,_0x33ff0c){var _0x2827ab={'agent':{},'channel':'whatsapp'};if(_0x2e94a7[_0x2c76('0x4f')]['id']){delete _0x2e94a7[_0x2c76('0x4f')]['id'];}_0x2e94a7['body'][_0x2c76('0x58')]=_0x2e94a7['body']['UserId']||_0x2e94a7[_0x2c76('0x60')]['id'];_0x2827ab['agent']['id']=_0x2e94a7[_0x2c76('0x4f')][_0x2c76('0x58')];return db['WhatsappMessage'][_0x2c76('0x4c')]({'where':{'id':_0x2e94a7[_0x2c76('0x50')]['id'],'UserId':null}})[_0x2c76('0x1e')](handleEntityNotFound(_0x2818c8,null))[_0x2c76('0x1e')](function(_0x435b18){if(_0x435b18){_0x2827ab[_0x2c76('0x25')]=_0x435b18[_0x2c76('0x59')]({'plain':!![]});return db[_0x2c76('0x5a')][_0x2c76('0x4c')]({'where':{'id':_0x435b18[_0x2c76('0x73')]}});}return null;})['then'](handleEntityNotFound(_0x2818c8,null))['then'](function(_0x563fb7){if(_0x563fb7){_0x2827ab[_0x2c76('0x5d')]=_0x563fb7[_0x2c76('0x59')]({'plain':!![]});interaction_log[_0x2c76('0x5e')](_0x2c76('0x74'),_0x2e94a7[_0x2c76('0x60')]['id'],_0x2e94a7[_0x2c76('0x60')][_0x2c76('0x34')],_0x2e94a7['user'][_0x2c76('0x61')],_0x2827ab['interaction']['id'],_0x2e94a7['body']?JSON[_0x2c76('0x22')](_0x2e94a7['body']):_0x2c76('0x62'));return respondWithRpcPromise(_0x2c76('0x75'),'rejectMessage',_0x2827ab);}return null;})['then'](function(_0x29aaf3){var _0x3e1a5e=_0x2c76('0x65')+_0x29aaf3[_0x2c76('0x25')][_0x2c76('0x66')];return db[_0x2c76('0x67')][_0x2c76('0x3b')](_0x3e1a5e,{'type':db['Sequelize']['QueryTypes']['SELECT'],'raw':!![]})[_0x2c76('0x1e')](function(_0x28254e){return _0x28254e;});})['then'](function(_0x3ff255){if(_0x3ff255){_0x2827ab['message'][_0x2c76('0x6a')]=_0x3ff255[0x0];if(!_0x2e94a7[_0x2c76('0x4f')][_0x2c76('0x58')])return;return db[_0x2c76('0x6b')][_0x2c76('0x4c')]({'where':{'id':_0x2e94a7[_0x2c76('0x4f')][_0x2c76('0x58')],'role':'agent'},'attributes':['id',_0x2c76('0x34'),_0x2c76('0x76'),_0x2c76('0x77'),'internal'],'raw':!![]});}return null;})['then'](function(_0x26f146){if(!_0x26f146)return null;_0x2827ab['message'][_0x2c76('0x6d')]=_0x26f146;return _0x2827ab;})['then'](function(_0x2b774c){if(_0x2b774c){_0x2b774c['message'][_0x2c76('0x6e')]=util[_0x2c76('0x57')](_0x2c76('0x78'),_0x2e94a7['user'][_0x2c76('0x34')]);_0x2b774c[_0x2c76('0x25')][_0x2c76('0x6f')]=_0x2827ab['channel'];_0x2b774c[_0x2c76('0x25')][_0x2c76('0x79')]=_0x2827ab['channel'];_0x2b774c[_0x2c76('0x25')][_0x2c76('0x70')]=_0x2c76('0x30');respondWithRpcPromise(_0x2c76('0x71'),_0x2c76('0x71'),{'event':_0x2c76('0x7a'),'message':_0x2b774c[_0x2c76('0x25')]},client9002);return _0x2827ab;}return null;})[_0x2c76('0x1e')](respondWithResult(_0x2818c8,null))[_0x2c76('0x4d')](handleError(_0x2818c8,null));};exports[_0x2c76('0x27')]=function(_0x473418,_0x235a8d,_0x2cbe3e){if(_0x473418[_0x2c76('0x4f')]['id']){delete _0x473418[_0x2c76('0x4f')]['id'];}var _0x5ae0ab;return db[_0x2c76('0x48')]['find']({'where':{'id':_0x473418[_0x2c76('0x50')]['id']}})[_0x2c76('0x1e')](handleEntityNotFound(_0x235a8d,null))[_0x2c76('0x1e')](function(_0x4cbd9f){if(_0x4cbd9f){_0x5ae0ab=_0x4cbd9f;return db[_0x2c76('0x7b')][_0x2c76('0x4c')]({'where':{'id':_0x4cbd9f['WhatsappAccountId']}});}})['then'](handleEntityNotFound(_0x235a8d,null))[_0x2c76('0x1e')](function(_0x37b41a){if(_0x37b41a){logger[_0x2c76('0x21')](_0x2c76('0x7c'),_0x2c76('0x27'),_0x2c76('0x7d'),_0x37b41a[_0x2c76('0x38')],util[_0x2c76('0x7e')](_0x473418[_0x2c76('0x4f')],{'showHidden':![],'depth':null}));switch(_0x37b41a[_0x2c76('0x38')]){case'twilio':if(_0x473418[_0x2c76('0x4f')][_0x2c76('0x7f')]&&_0x473418[_0x2c76('0x4f')][_0x2c76('0x7f')]===_0x5ae0ab[_0x2c76('0x80')]&&_0x473418[_0x2c76('0x4f')][_0x2c76('0x81')]&&_0x473418['body'][_0x2c76('0x81')]===_0x2c76('0x55')){return _0x5ae0ab[_0x2c76('0x32')]({'read':!![]});}else{logger['error'](_0x2c76('0x82'),_0x2c76('0x27'),'twilio',util[_0x2c76('0x7e')](_0x473418[_0x2c76('0x4f')],{'showHidden':![],'depth':null}));}break;}return _0x5ae0ab;}})[_0x2c76('0x1e')](respondWithResult(_0x235a8d,null))[_0x2c76('0x4d')](handleError(_0x235a8d,null));}; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.events.js b/server/api/whatsappMessage/whatsappMessage.events.js new file mode 100644 index 0000000..044756d --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7980=['events','../../mysqldb','WhatsappMessage','setMaxListeners','save','remove','emit','hook','exports'];(function(_0xb2f404,_0x406b79){var _0x3ca35f=function(_0x2de0da){while(--_0x2de0da){_0xb2f404['push'](_0xb2f404['shift']());}};_0x3ca35f(++_0x406b79);}(_0x7980,0xab));var _0x0798=function(_0x2d953a,_0x4d762c){_0x2d953a=_0x2d953a-0x0;var _0x8e49c5=_0x7980[_0x2d953a];return _0x8e49c5;};'use strict';var EventEmitter=require(_0x0798('0x0'));var WhatsappMessage=require(_0x0798('0x1'))['db'][_0x0798('0x2')];var WhatsappMessageEvents=new EventEmitter();WhatsappMessageEvents[_0x0798('0x3')](0x0);var events={'afterCreate':_0x0798('0x4'),'afterUpdate':'update','afterDestroy':_0x0798('0x5')};function emitEvent(_0x31597d){return function(_0xecc24f,_0x1637db,_0x1a1fe7){WhatsappMessageEvents['emit'](_0x31597d+':'+_0xecc24f['id'],_0xecc24f);WhatsappMessageEvents[_0x0798('0x6')](_0x31597d,_0xecc24f);_0x1a1fe7(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappMessage[_0x0798('0x7')](e,emitEvent(event));}}module[_0x0798('0x8')]=WhatsappMessageEvents; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.model.js b/server/api/whatsappMessage/whatsappMessage.model.js new file mode 100644 index 0000000..dad020e --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc3b2=['models','get','direction','toLowerCase','out','UserId','WhatsappInteraction','WhatsappInteractionId','then','createdAt','catch','error','secret','WhatsappAccount','find','WhatsappAccountId','type','twilio','authToken','phone','accountSid','create','whatsapp:','remote','/api/whatsapp/messages/','/status?token=','token','sid','afterCreate','inspect','WhatsappMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','sinch','baseUrl','/whatsapp/v1/','/messages/','POST','application/json','statuses','message_id','update','err','finally','utf8mb4_unicode_ci','lodash','../../config/logger','bluebird','request-promise','node-fetch','path','rimraf','../../config/environment','./whatsappMessage.attributes','define','WhatsappMessage','whatsapp_messages','messageId','body','FULLTEXT'];(function(_0x431309,_0xa6a419){var _0x240caa=function(_0x6aab6f){while(--_0x6aab6f){_0x431309['push'](_0x431309['shift']());}};_0x240caa(++_0xa6a419);}(_0xc3b2,0x67));var _0x2c3b=function(_0x52e854,_0x4cef54){_0x52e854=_0x52e854-0x0;var _0x5a8410=_0xc3b2[_0x52e854];return _0x5a8410;};'use strict';var _=require(_0x2c3b('0x0'));var util=require('util');var logger=require(_0x2c3b('0x1'))('api');var moment=require('moment');var BPromise=require(_0x2c3b('0x2'));var rp=require(_0x2c3b('0x3'));var fetch=require(_0x2c3b('0x4'));var fs=require('fs');var path=require(_0x2c3b('0x5'));var rimraf=require(_0x2c3b('0x6'));var config=require(_0x2c3b('0x7'));var attributes=require(_0x2c3b('0x8'));module['exports']=function(_0xf71a8d,_0x3675e6){return _0xf71a8d[_0x2c3b('0x9')](_0x2c3b('0xa'),attributes,{'tableName':_0x2c3b('0xb'),'paranoid':![],'indexes':[{'name':_0x2c3b('0xc'),'fields':[_0x2c3b('0xc')]},{'name':'fti_whatsapp_messages','fields':[_0x2c3b('0xd')],'type':_0x2c3b('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0xbf8480,_0x1ebb78,_0x5f41bb){var _0x1bf997=_0xf71a8d[_0x2c3b('0xf')];var _0x444b59=_0xbf8480[_0x2c3b('0x10')]({'plain':!![]});if(_0x444b59[_0x2c3b('0x11')]['toLowerCase']()==='in'||_0x444b59[_0x2c3b('0x11')][_0x2c3b('0x12')]()===_0x2c3b('0x13')&&!_0x444b59['secret']&&!_['isNil'](_0x444b59[_0x2c3b('0x14')])){_0x1bf997[_0x2c3b('0x15')]['findOne']({'where':{'id':_0x444b59[_0x2c3b('0x16')]}})[_0x2c3b('0x17')](function(_0x3bae14){if(_0x3bae14){_0x3bae14['update']({'lastMsgAt':_0x444b59[_0x2c3b('0x18')],'lastMsgDirection':_0x444b59[_0x2c3b('0x11')][_0x2c3b('0x12')]()});}})[_0x2c3b('0x19')](function(_0x40ffcf){console[_0x2c3b('0x1a')](_0x40ffcf);});}if(_0x444b59[_0x2c3b('0x11')]===_0x2c3b('0x13')&&!_0x444b59[_0x2c3b('0x1b')]){var _0x205e62;_0x1bf997[_0x2c3b('0x1c')][_0x2c3b('0x1d')]({'where':{'id':_0x444b59[_0x2c3b('0x1e')]},'raw':!![]})['then'](function(_0x2d96d3){_0x205e62=_0x2d96d3;if(_0x205e62&&_0x205e62[_0x2c3b('0x1f')]){switch(_0x205e62[_0x2c3b('0x1f')]){case _0x2c3b('0x20'):var _0x482d4c=require(_0x2c3b('0x20'));if(_0x205e62['accountSid']&&_0x205e62[_0x2c3b('0x21')]&&_0x205e62[_0x2c3b('0x22')]){var _0x126193=new _0x482d4c(_0x205e62[_0x2c3b('0x23')],_0x205e62[_0x2c3b('0x21')]);_0x126193['messages'][_0x2c3b('0x24')]({'body':_0x444b59[_0x2c3b('0xd')],'to':'whatsapp:'+_0x444b59[_0x2c3b('0x22')],'from':_0x2c3b('0x25')+_0x205e62[_0x2c3b('0x22')],'statusCallback':_0x205e62[_0x2c3b('0x26')]+_0x2c3b('0x27')+_0x444b59['id']+_0x2c3b('0x28')+_0x205e62[_0x2c3b('0x29')]})['then'](function(_0x577fca){if(_0x577fca[_0x2c3b('0x2a')]){return _0xbf8480['update']({'messageId':_0x577fca[_0x2c3b('0x2a')]});}})[_0x2c3b('0x19')](function(_0x2f1567){logger['error']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x2c3b('0x2b'),_0x2c3b('0x20'),util[_0x2c3b('0x2c')](_0x2f1567,{'showHidden':![],'depth':null}));});}else{logger[_0x2c3b('0x1a')](_0x2c3b('0x2d'),_0x2c3b('0x2b'),_0x2c3b('0x20'),_0x2c3b('0x2e'));}break;case _0x2c3b('0x2f'):var _0x586da4=_0x205e62[_0x2c3b('0x23')];var _0x184256=_0x205e62[_0x2c3b('0x21')];var _0x403a50=_0x205e62[_0x2c3b('0x30')]+_0x2c3b('0x31')+_0x586da4+_0x2c3b('0x32');var _0x2e19c8={'to':[_0x444b59[_0x2c3b('0x22')]],'message':{'type':'text','text':_0x444b59['body']}};var _0xb3ee69={'method':_0x2c3b('0x33'),'uri':_0x403a50,'headers':{'Authorization':'Bearer\x20'+_0x184256,'Content-Type':_0x2c3b('0x34')},'body':_0x2e19c8,'json':!![]};rp(_0xb3ee69)[_0x2c3b('0x17')](function(_0xe8819){if(_0xe8819[_0x2c3b('0x35')][0x0][_0x2c3b('0x36')]){return _0xbf8480[_0x2c3b('0x37')]({'messageId':_0xe8819[_0x2c3b('0x35')][0x0]['message_id']});}})[_0x2c3b('0x19')](function(_0x2c2604){logger[_0x2c3b('0x38')]('WhatsappMessage,\x20%s',_0x2c2604);});break;}}})[_0x2c3b('0x39')](function(){_0x5f41bb();});}else{_0x5f41bb();}}},'charset':'utf8mb4','collate':_0x2c3b('0x3a')});}; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.rpc.js b/server/api/whatsappMessage/whatsappMessage.rpc.js new file mode 100644 index 0000000..dc6655a --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xec0c=['lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./whatsappMessage.socket','request','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','error','code','message','result','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','then','debug','stringify','catch'];(function(_0xcc6a3f,_0xe32370){var _0x45990f=function(_0x9b56c9){while(--_0x9b56c9){_0xcc6a3f['push'](_0xcc6a3f['shift']());}};_0x45990f(++_0xe32370);}(_0xec0c,0x118));var _0xcec0=function(_0x39a92a,_0x4bf484){_0x39a92a=_0x39a92a-0x0;var _0x3a700a=_0xec0c[_0x39a92a];return _0x3a700a;};'use strict';var _=require(_0xcec0('0x0'));var util=require(_0xcec0('0x1'));var moment=require(_0xcec0('0x2'));var BPromise=require('bluebird');var rs=require(_0xcec0('0x3'));var fs=require('fs');var Redis=require(_0xcec0('0x4'));var db=require(_0xcec0('0x5'))['db'];var utils=require(_0xcec0('0x6'));var logger=require(_0xcec0('0x7'))(_0xcec0('0x8'));var config=require(_0xcec0('0x9'));var jayson=require(_0xcec0('0xa'));var client=jayson[_0xcec0('0xb')][_0xcec0('0xc')]({'port':0x232a});config[_0xcec0('0xd')]=_[_0xcec0('0xe')](config[_0xcec0('0xd')],{'host':_0xcec0('0xf'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcec0('0xd')]));require(_0xcec0('0x10'))['register'](socket);function respondWithRpcPromise(_0x56f002,_0x2fc003,_0x3aba17){return new BPromise(function(_0x54cca2,_0xb9f4b9){return client[_0xcec0('0x11')](_0x56f002,_0x3aba17)['then'](function(_0x27419f){logger[_0xcec0('0x12')](_0xcec0('0x13'),_0x2fc003,_0xcec0('0x14'));logger['debug']('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x2fc003,_0xcec0('0x14'),JSON['stringify'](_0x27419f));if(_0x27419f[_0xcec0('0x15')]){if(_0x27419f[_0xcec0('0x15')][_0xcec0('0x16')]===0x1f4){logger[_0xcec0('0x15')](_0xcec0('0x13'),_0x2fc003,_0x27419f[_0xcec0('0x15')][_0xcec0('0x17')]);return _0xb9f4b9(_0x27419f['error'][_0xcec0('0x17')]);}logger[_0xcec0('0x15')](_0xcec0('0x13'),_0x2fc003,_0x27419f[_0xcec0('0x15')][_0xcec0('0x17')]);return _0x54cca2(_0x27419f[_0xcec0('0x15')]['message']);}else{logger[_0xcec0('0x12')](_0xcec0('0x13'),_0x2fc003,_0xcec0('0x14'));_0x54cca2(_0x27419f[_0xcec0('0x18')][_0xcec0('0x17')]);}})['catch'](function(_0x3f340d){logger[_0xcec0('0x15')](_0xcec0('0x13'),_0x2fc003,_0x3f340d);_0xb9f4b9(_0x3f340d);});});}exports[_0xcec0('0x19')]=function(_0x19a170){var _0x572745=this;return new Promise(function(_0x20aa87,_0x9d3504){return db[_0xcec0('0x1a')][_0xcec0('0x1b')](_0x19a170[_0xcec0('0x1c')],{'raw':_0x19a170[_0xcec0('0x1d')]?_0x19a170['options'][_0xcec0('0x1e')]===undefined?!![]:![]:!![]})[_0xcec0('0x1f')](function(_0x805aa2){logger[_0xcec0('0x12')]('CreateWhatsappMessage',_0x19a170);logger[_0xcec0('0x20')](_0xcec0('0x19'),_0x19a170,JSON[_0xcec0('0x21')](_0x805aa2));_0x20aa87(_0x805aa2);})[_0xcec0('0x22')](function(_0x3ecb2e){logger[_0xcec0('0x15')](_0xcec0('0x19'),_0x3ecb2e[_0xcec0('0x17')],_0x19a170);_0x9d3504(_0x572745['error'](0x1f4,_0x3ecb2e[_0xcec0('0x17')]));});});}; \ No newline at end of file diff --git a/server/api/whatsappMessage/whatsappMessage.socket.js b/server/api/whatsappMessage/whatsappMessage.socket.js new file mode 100644 index 0000000..2ab1326 --- /dev/null +++ b/server/api/whatsappMessage/whatsappMessage.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x415c=['update','removeListener','register','length','./whatsappMessage.events','save','remove'];(function(_0x4bf979,_0x13d7a7){var _0x5570f7=function(_0x30afe6){while(--_0x30afe6){_0x4bf979['push'](_0x4bf979['shift']());}};_0x5570f7(++_0x13d7a7);}(_0x415c,0x1af));var _0xc415=function(_0x2a8fae,_0x54fd0d){_0x2a8fae=_0x2a8fae-0x0;var _0x29a1fa=_0x415c[_0x2a8fae];return _0x29a1fa;};'use strict';var WhatsappMessageEvents=require(_0xc415('0x0'));var events=[_0xc415('0x1'),_0xc415('0x2'),_0xc415('0x3')];function createListener(_0x4d9fa4,_0x2ba8d3){return function(_0x3c4aa5){_0x2ba8d3['emit'](_0x4d9fa4,_0x3c4aa5);};}function removeListener(_0x4c59d6,_0x225cb2){return function(){WhatsappMessageEvents[_0xc415('0x4')](_0x4c59d6,_0x225cb2);};}exports[_0xc415('0x5')]=function(_0x5e3b99){for(var _0x540f93=0x0,_0x46b1fb=events[_0xc415('0x6')];_0x540f93<_0x46b1fb;_0x540f93++){var _0x10af2b=events[_0x540f93];var _0x508447=createListener('whatsappMessage:'+_0x10af2b,_0x5e3b99);WhatsappMessageEvents['on'](_0x10af2b,_0x508447);}}; \ No newline at end of file diff --git a/server/api/whatsappQueue/index.js b/server/api/whatsappQueue/index.js new file mode 100644 index 0000000..cc52e87 --- /dev/null +++ b/server/api/whatsappQueue/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc833=['isAuthenticated','index','describe','get','/:id','show','/:id/members','getMembers','/:id/teams','getTeams','/:id/users','post','addTeams','addAgents','put','update','delete','destroy','removeTeams','removeAgents','exports','util','path','connect-timeout','express','Router','fs-extra','../../components/interaction/service','./whatsappQueue.controller'];(function(_0x513a0a,_0x6dfd40){var _0x22f507=function(_0x2efacb){while(--_0x2efacb){_0x513a0a['push'](_0x513a0a['shift']());}};_0x22f507(++_0x6dfd40);}(_0xc833,0xfd));var _0x3c83=function(_0x56823e,_0x460ae2){_0x56823e=_0x56823e-0x0;var _0x5524a8=_0xc833[_0x56823e];return _0x5524a8;};'use strict';var multer=require('multer');var util=require(_0x3c83('0x0'));var path=require(_0x3c83('0x1'));var timeout=require(_0x3c83('0x2'));var express=require(_0x3c83('0x3'));var router=express[_0x3c83('0x4')]();var fs_extra=require(_0x3c83('0x5'));var auth=require('../../components/auth/service');var interaction=require(_0x3c83('0x6'));var config=require('../../config/environment');var controller=require(_0x3c83('0x7'));router['get']('/',auth[_0x3c83('0x8')](),controller[_0x3c83('0x9')]);router['get']('/describe',auth[_0x3c83('0x8')](),controller[_0x3c83('0xa')]);router[_0x3c83('0xb')](_0x3c83('0xc'),auth[_0x3c83('0x8')](),controller[_0x3c83('0xd')]);router[_0x3c83('0xb')](_0x3c83('0xe'),auth[_0x3c83('0x8')](),controller[_0x3c83('0xf')]);router['get'](_0x3c83('0x10'),auth[_0x3c83('0x8')](),controller[_0x3c83('0x11')]);router[_0x3c83('0xb')](_0x3c83('0x12'),auth[_0x3c83('0x8')](),controller['getAgents']);router[_0x3c83('0x13')]('/',auth['isAuthenticated'](),controller['create']);router[_0x3c83('0x13')](_0x3c83('0x10'),auth[_0x3c83('0x8')](),controller[_0x3c83('0x14')]);router[_0x3c83('0x13')](_0x3c83('0x12'),auth[_0x3c83('0x8')](),controller[_0x3c83('0x15')]);router[_0x3c83('0x16')]('/:id',auth['isAuthenticated'](),controller[_0x3c83('0x17')]);router[_0x3c83('0x18')](_0x3c83('0xc'),auth[_0x3c83('0x8')](),controller[_0x3c83('0x19')]);router[_0x3c83('0x18')]('/:id/teams',auth['isAuthenticated'](),controller[_0x3c83('0x1a')]);router[_0x3c83('0x18')](_0x3c83('0x12'),auth[_0x3c83('0x8')](),controller[_0x3c83('0x1b')]);module[_0x3c83('0x1c')]=router; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.attributes.js b/server/api/whatsappQueue/whatsappQueue.attributes.js new file mode 100644 index 0000000..145bfaa --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xca2b=['STRING','name','INTEGER','ENUM','rrmemory','beepall','sequelize','exports'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0xca2b,0x156));var _0xbca2=function(_0x2be8c2,_0x14a4b5){_0x2be8c2=_0x2be8c2-0x0;var _0x97f531=_0xca2b[_0x2be8c2];return _0x97f531;};'use strict';var Sequelize=require(_0xbca2('0x0'));module[_0xbca2('0x1')]={'name':{'type':Sequelize[_0xbca2('0x2')],'unique':_0xbca2('0x3'),'validate':{'notEmpty':!![],'is':/^[A-Za-z0-9\.\_]+$/i}},'timeout':{'type':Sequelize[_0xbca2('0x4')],'validate':{'min':0x1,'max':0x20c49b}},'strategy':{'type':Sequelize[_0xbca2('0x5')](_0xbca2('0x6'),_0xbca2('0x7'),'roundrobin')},'description':{'type':Sequelize[_0xbca2('0x2')]}}; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.controller.js b/server/api/whatsappQueue/whatsappQueue.controller.js new file mode 100644 index 0000000..ddee5d6 --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4baa=['findAll','rows','catch','show','params','intersection','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','nolimit','WhatsappQueueId','UserWhatsappQueue','User','findAndCountAll','UserId','agent','updatedAt','createdAt','format','SIP','whatsappPause','Team','getTeams','addTeams','ids','voicePause','interface','flatMap','Agents','sequelize','transaction','each','findOrCreate','forEach','userWhatsappQueue:save','removeTeams','select','field','team_has_whatsapp_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','WhatsappQueueId\x20=\x20?','clone','push','toString','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','addAgents','omit','spread','emit','userWhatsappQueue:remove','getAgents','rimraf','request-promise','moment','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./whatsappQueue.socket','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','update','then','destroy','get','WhatsappQueues','UserProfileResource','end','error','stack','name','send','index','map','WhatsappQueue','rawAttributes','type','key','model','query','keys','filters','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll'];(function(_0x2b36d9,_0x42faf0){var _0x7a8c90=function(_0x4dfba6){while(--_0x4dfba6){_0x2b36d9['push'](_0x2b36d9['shift']());}};_0x7a8c90(++_0x42faf0);}(_0x4baa,0xd5));var _0xa4ba=function(_0x3a23f1,_0x401962){_0x3a23f1=_0x3a23f1-0x0;var _0x484219=_0x4baa[_0x3a23f1];return _0x484219;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa4ba('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xa4ba('0x1'));var moment=require(_0xa4ba('0x2'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xa4ba('0x3'));var sox=require(_0xa4ba('0x4'));var csv=require(_0xa4ba('0x5'));var ejs=require(_0xa4ba('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa4ba('0x7'));var squel=require(_0xa4ba('0x8'));var crypto=require(_0xa4ba('0x9'));var jsforce=require(_0xa4ba('0xa'));var deskjs=require(_0xa4ba('0xb'));var toCsv=require('to-csv');var querystring=require(_0xa4ba('0xc'));var Papa=require(_0xa4ba('0xd'));var Redis=require(_0xa4ba('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xa4ba('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa4ba('0x10'));var logger=require(_0xa4ba('0x11'))('api');var utils=require(_0xa4ba('0x12'));var config=require(_0xa4ba('0x13'));var licenseUtil=require(_0xa4ba('0x14'));var db=require(_0xa4ba('0x15'))['db'];config[_0xa4ba('0x16')]=_[_0xa4ba('0x17')](config[_0xa4ba('0x16')],{'host':_0xa4ba('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa4ba('0x16')]));require(_0xa4ba('0x19'))['register'](socket);function respondWithStatusCode(_0x2475c0,_0x1a4a94){_0x1a4a94=_0x1a4a94||0xcc;return function(_0x32b387){if(_0x32b387){return _0x2475c0[_0xa4ba('0x1a')](_0x1a4a94);}return _0x2475c0[_0xa4ba('0x1b')](_0x1a4a94)['end']();};}function respondWithResult(_0x55d54e,_0x2a81d6){_0x2a81d6=_0x2a81d6||0xc8;return function(_0x2ba393){if(_0x2ba393){return _0x55d54e[_0xa4ba('0x1b')](_0x2a81d6)[_0xa4ba('0x1c')](_0x2ba393);}};}function respondWithFilteredResult(_0xbd608d,_0xe5e189){return function(_0x1c437f){if(_0x1c437f){var _0xe14f19=typeof _0xe5e189[_0xa4ba('0x1d')]===_0xa4ba('0x1e')&&typeof _0xe5e189['limit']==='undefined';var _0x435d2e=_0x1c437f[_0xa4ba('0x1f')];var _0x4a430a=_0xe14f19?0x0:_0xe5e189[_0xa4ba('0x1d')];var _0x580533=_0xe14f19?_0x1c437f[_0xa4ba('0x1f')]:_0xe5e189[_0xa4ba('0x1d')]+_0xe5e189[_0xa4ba('0x20')];var _0x5d88ae;if(_0x580533>=_0x435d2e){_0x580533=_0x435d2e;_0x5d88ae=0xc8;}else{_0x5d88ae=0xce;}_0xbd608d[_0xa4ba('0x1b')](_0x5d88ae);return _0xbd608d[_0xa4ba('0x21')](_0xa4ba('0x22'),_0x4a430a+'-'+_0x580533+'/'+_0x435d2e)['json'](_0x1c437f);}return null;};}function patchUpdates(_0x400d28){return function(_0x26bf2e){try{jsonpatch[_0xa4ba('0x23')](_0x26bf2e,_0x400d28,!![]);}catch(_0x486274){return BPromise[_0xa4ba('0x24')](_0x486274);}return _0x26bf2e['save']();};}function saveUpdates(_0xf9d44f,_0x5921a6){return function(_0x3cd2a0){if(_0x3cd2a0){return _0x3cd2a0[_0xa4ba('0x25')](_0xf9d44f)[_0xa4ba('0x26')](function(_0x2ceee1){return _0x2ceee1;});}return null;};}function removeEntity(_0x1c735a,_0x42dbd3){return function(_0x28d37e){if(_0x28d37e){return _0x28d37e[_0xa4ba('0x27')]()['then'](function(){var _0x181b13=_0x28d37e[_0xa4ba('0x28')]({'plain':!![]});var _0x54d09e=_0xa4ba('0x29');return db[_0xa4ba('0x2a')][_0xa4ba('0x27')]({'where':{'type':_0x54d09e,'resourceId':_0x181b13['id']}})[_0xa4ba('0x26')](function(){return _0x28d37e;});})[_0xa4ba('0x26')](function(){_0x1c735a[_0xa4ba('0x1b')](0xcc)[_0xa4ba('0x2b')]();});}};}function handleEntityNotFound(_0x426102,_0x38578e){return function(_0x3d9465){if(!_0x3d9465){_0x426102[_0xa4ba('0x1a')](0x194);}return _0x3d9465;};}function handleError(_0x5511e3,_0x152c5e){_0x152c5e=_0x152c5e||0x1f4;return function(_0x5a7e9a){logger[_0xa4ba('0x2c')](_0x5a7e9a[_0xa4ba('0x2d')]);if(_0x5a7e9a[_0xa4ba('0x2e')]){delete _0x5a7e9a['name'];}_0x5511e3[_0xa4ba('0x1b')](_0x152c5e)[_0xa4ba('0x2f')](_0x5a7e9a);};}exports[_0xa4ba('0x30')]=function(_0x242985,_0x57fe7f){var _0x50aa55={},_0x4061c9={},_0x2a2254={'count':0x0,'rows':[]};var _0x1c7917=_[_0xa4ba('0x31')](db[_0xa4ba('0x32')][_0xa4ba('0x33')],function(_0x1daece){return{'name':_0x1daece['fieldName'],'type':_0x1daece[_0xa4ba('0x34')][_0xa4ba('0x35')]};});_0x4061c9[_0xa4ba('0x36')]=_[_0xa4ba('0x31')](_0x1c7917,'name');_0x4061c9[_0xa4ba('0x37')]=_[_0xa4ba('0x38')](_0x242985['query']);_0x4061c9[_0xa4ba('0x39')]=_['intersection'](_0x4061c9['model'],_0x4061c9[_0xa4ba('0x37')]);_0x50aa55[_0xa4ba('0x3a')]=_['intersection'](_0x4061c9[_0xa4ba('0x36')],qs[_0xa4ba('0x3b')](_0x242985[_0xa4ba('0x37')][_0xa4ba('0x3b')]));_0x50aa55[_0xa4ba('0x3a')]=_0x50aa55[_0xa4ba('0x3a')][_0xa4ba('0x3c')]?_0x50aa55[_0xa4ba('0x3a')]:_0x4061c9[_0xa4ba('0x36')];if(!_0x242985[_0xa4ba('0x37')][_0xa4ba('0x3d')]('nolimit')){_0x50aa55[_0xa4ba('0x20')]=qs[_0xa4ba('0x20')](_0x242985['query'][_0xa4ba('0x20')]);_0x50aa55[_0xa4ba('0x1d')]=qs[_0xa4ba('0x1d')](_0x242985['query']['offset']);}_0x50aa55[_0xa4ba('0x3e')]=qs['sort'](_0x242985[_0xa4ba('0x37')][_0xa4ba('0x3f')]);_0x50aa55[_0xa4ba('0x40')]=qs[_0xa4ba('0x39')](_[_0xa4ba('0x41')](_0x242985[_0xa4ba('0x37')],_0x4061c9['filters']),_0x1c7917);if(_0x242985['query'][_0xa4ba('0x42')]){_0x50aa55[_0xa4ba('0x40')]=_[_0xa4ba('0x43')](_0x50aa55[_0xa4ba('0x40')],{'$or':_[_0xa4ba('0x31')](_0x1c7917,function(_0x5394a9){if(_0x5394a9[_0xa4ba('0x34')]!==_0xa4ba('0x44')){var _0x3e3af9={};_0x3e3af9[_0x5394a9['name']]={'$like':'%'+_0x242985[_0xa4ba('0x37')][_0xa4ba('0x42')]+'%'};return _0x3e3af9;}})});}_0x50aa55=_['merge']({},_0x50aa55,_0x242985[_0xa4ba('0x45')]);var _0x2a5450={'where':_0x50aa55['where']};return db[_0xa4ba('0x32')][_0xa4ba('0x1f')](_0x2a5450)[_0xa4ba('0x26')](function(_0x147f93){_0x2a2254[_0xa4ba('0x1f')]=_0x147f93;if(_0x242985[_0xa4ba('0x37')][_0xa4ba('0x46')]){_0x50aa55['include']=[{'all':!![]}];}return db[_0xa4ba('0x32')][_0xa4ba('0x47')](_0x50aa55);})['then'](function(_0x4afe64){_0x2a2254[_0xa4ba('0x48')]=_0x4afe64;return _0x2a2254;})[_0xa4ba('0x26')](respondWithFilteredResult(_0x57fe7f,_0x50aa55))[_0xa4ba('0x49')](handleError(_0x57fe7f,null));};exports[_0xa4ba('0x4a')]=function(_0x3db0fb,_0x4a1f19){var _0x4a605e={'raw':!![],'where':{'id':_0x3db0fb[_0xa4ba('0x4b')]['id']}},_0x2ae635={};_0x2ae635[_0xa4ba('0x36')]=_[_0xa4ba('0x38')](db[_0xa4ba('0x32')][_0xa4ba('0x33')]);_0x2ae635[_0xa4ba('0x37')]=_[_0xa4ba('0x38')](_0x3db0fb['query']);_0x2ae635[_0xa4ba('0x39')]=_[_0xa4ba('0x4c')](_0x2ae635[_0xa4ba('0x36')],_0x2ae635[_0xa4ba('0x37')]);_0x4a605e[_0xa4ba('0x3a')]=_[_0xa4ba('0x4c')](_0x2ae635[_0xa4ba('0x36')],qs[_0xa4ba('0x3b')](_0x3db0fb['query'][_0xa4ba('0x3b')]));_0x4a605e[_0xa4ba('0x3a')]=_0x4a605e[_0xa4ba('0x3a')][_0xa4ba('0x3c')]?_0x4a605e[_0xa4ba('0x3a')]:_0x2ae635[_0xa4ba('0x36')];if(_0x3db0fb['query'][_0xa4ba('0x46')]){_0x4a605e[_0xa4ba('0x4d')]=[{'all':!![]}];}_0x4a605e=_[_0xa4ba('0x43')]({},_0x4a605e,_0x3db0fb[_0xa4ba('0x45')]);return db[_0xa4ba('0x32')]['find'](_0x4a605e)['then'](handleEntityNotFound(_0x4a1f19,null))['then'](respondWithResult(_0x4a1f19,null))[_0xa4ba('0x49')](handleError(_0x4a1f19,null));};exports[_0xa4ba('0x4e')]=function(_0x2e968e,_0x4edaa5){return db['WhatsappQueue']['create'](_0x2e968e[_0xa4ba('0x4f')],{})[_0xa4ba('0x26')](function(_0x414d70){var _0x478ae8=_0x2e968e[_0xa4ba('0x50')]['get']({'plain':!![]});if(!_0x478ae8)throw new Error(_0xa4ba('0x51'));if(_0x478ae8[_0xa4ba('0x52')]==='user'){var _0x57a40e=_0x414d70[_0xa4ba('0x28')]({'plain':!![]});var _0x2daec5=_0xa4ba('0x29');return db[_0xa4ba('0x53')][_0xa4ba('0x54')]({'where':{'name':_0x2daec5,'userProfileId':_0x478ae8[_0xa4ba('0x55')]},'raw':!![]})[_0xa4ba('0x26')](function(_0x9ce572){if(_0x9ce572&&_0x9ce572[_0xa4ba('0x56')]===0x0){return db[_0xa4ba('0x2a')][_0xa4ba('0x4e')]({'name':_0x57a40e[_0xa4ba('0x2e')],'resourceId':_0x57a40e['id'],'type':_0x9ce572[_0xa4ba('0x2e')],'sectionId':_0x9ce572['id']},{})[_0xa4ba('0x26')](function(){return _0x414d70;});}else{return _0x414d70;}})[_0xa4ba('0x49')](function(_0x1589b6){logger[_0xa4ba('0x2c')](_0xa4ba('0x57'),_0x1589b6);throw _0x1589b6;});}return _0x414d70;})['then'](respondWithResult(_0x4edaa5,0xc9))[_0xa4ba('0x49')](handleError(_0x4edaa5,null));};exports['update']=function(_0x4c9f95,_0x3e771e){if(_0x4c9f95[_0xa4ba('0x4f')]['id']){delete _0x4c9f95[_0xa4ba('0x4f')]['id'];}return db['WhatsappQueue'][_0xa4ba('0x54')]({'where':{'id':_0x4c9f95['params']['id']}})['then'](handleEntityNotFound(_0x3e771e,null))[_0xa4ba('0x26')](saveUpdates(_0x4c9f95[_0xa4ba('0x4f')],null))[_0xa4ba('0x26')](respondWithResult(_0x3e771e,null))['catch'](handleError(_0x3e771e,null));};exports[_0xa4ba('0x27')]=function(_0x27fc38,_0x2c5dc2){return db[_0xa4ba('0x32')][_0xa4ba('0x54')]({'where':{'id':_0x27fc38[_0xa4ba('0x4b')]['id']}})['then'](handleEntityNotFound(_0x2c5dc2,null))[_0xa4ba('0x26')](removeEntity(_0x2c5dc2,null))['catch'](handleError(_0x2c5dc2,null));};exports[_0xa4ba('0x58')]=function(_0x3c6329,_0x41814e){return db[_0xa4ba('0x32')][_0xa4ba('0x58')]()[_0xa4ba('0x26')](respondWithResult(_0x41814e,null))[_0xa4ba('0x49')](handleError(_0x41814e,null));};exports['getMembers']=function(_0x46d623,_0x2bc78f,_0x1ff193){var _0x52d5dc={'raw':!![],'where':{}},_0xa88e80={},_0x2b2311;return db[_0xa4ba('0x32')][_0xa4ba('0x59')]({'where':{'id':_0x46d623[_0xa4ba('0x4b')]['id']}})[_0xa4ba('0x26')](handleEntityNotFound(_0x2bc78f,null))['then'](function(_0xb14407){if(_0xb14407){_0x2b2311=_0xb14407['get']({'plain':!![]});_0xa88e80['model']=_[_0xa4ba('0x38')](db['UserWhatsappQueue'][_0xa4ba('0x33')]);_0xa88e80[_0xa4ba('0x37')]=_[_0xa4ba('0x38')](_0x46d623[_0xa4ba('0x37')]);_0xa88e80[_0xa4ba('0x39')]=_[_0xa4ba('0x4c')](_0xa88e80['model'],_0xa88e80[_0xa4ba('0x37')]);_0x52d5dc[_0xa4ba('0x3a')]=_[_0xa4ba('0x4c')](_0xa88e80[_0xa4ba('0x36')],qs[_0xa4ba('0x3b')](_0x46d623[_0xa4ba('0x37')][_0xa4ba('0x3b')]));_0x52d5dc[_0xa4ba('0x3a')]=_0x52d5dc[_0xa4ba('0x3a')][_0xa4ba('0x3c')]?_0x52d5dc[_0xa4ba('0x3a')]:_0xa88e80['model'];if(!_0x46d623['query']['hasOwnProperty'](_0xa4ba('0x5a'))){_0x52d5dc[_0xa4ba('0x20')]=qs['limit'](_0x46d623[_0xa4ba('0x37')][_0xa4ba('0x20')]);_0x52d5dc[_0xa4ba('0x1d')]=qs['offset'](_0x46d623[_0xa4ba('0x37')][_0xa4ba('0x1d')]);}_0x52d5dc['order']=qs[_0xa4ba('0x3f')](_0x46d623[_0xa4ba('0x37')]['sort']);_0x52d5dc[_0xa4ba('0x40')]=qs[_0xa4ba('0x39')](_[_0xa4ba('0x41')](_0x46d623['query'],_0xa88e80[_0xa4ba('0x39')]));_0x52d5dc[_0xa4ba('0x40')][_0xa4ba('0x5b')]=_0xb14407['id'];if(_0x46d623['query'][_0xa4ba('0x42')]){_0x52d5dc['where']=_[_0xa4ba('0x43')](_0x52d5dc[_0xa4ba('0x40')],{'$or':_[_0xa4ba('0x31')](_0x52d5dc[_0xa4ba('0x3a')],function(_0x4b0031){var _0x8b7f2c={};_0x8b7f2c[_0x4b0031]={'$like':'%'+_0x46d623['query'][_0xa4ba('0x42')]+'%'};return _0x8b7f2c;})});}_0x52d5dc=_['merge']({},_0x52d5dc,_0x46d623[_0xa4ba('0x45')]);return db[_0xa4ba('0x5c')][_0xa4ba('0x47')](_0x52d5dc);}})[_0xa4ba('0x26')](function(_0x2be995){if(_0x2be995){return db[_0xa4ba('0x5d')][_0xa4ba('0x5e')]({'where':{'id':_[_0xa4ba('0x31')](_0x2be995,_0xa4ba('0x5f')),'role':_0xa4ba('0x60')},'attributes':['id',_0xa4ba('0x2e'),'whatsappPause',_0xa4ba('0x61'),_0xa4ba('0x62')]});}})['then'](function(_0x1f1e47){if(_0x1f1e47){return{'count':_0x1f1e47['count'],'rows':_[_0xa4ba('0x31')](_0x1f1e47['rows'],function(_0xa9bf2b){return{'membername':_0xa9bf2b[_0xa4ba('0x2e')],'UserId':_0xa9bf2b['id'],'queue_name':_0x2b2311[_0xa4ba('0x2e')],'WhatsappQueueId':_0x2b2311['id'],'interface':util[_0xa4ba('0x63')]('%s/%s',_0xa4ba('0x64'),_0xa9bf2b[_0xa4ba('0x2e')]),'penalty':0x0,'paused':_0xa9bf2b[_0xa4ba('0x65')],'createdAt':_0xa9bf2b[_0xa4ba('0x62')],'updatedAt':_0xa9bf2b[_0xa4ba('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xa4ba('0x26')](respondWithFilteredResult(_0x2bc78f,_0x52d5dc))['catch'](handleError(_0x2bc78f,null));};exports['getTeams']=function(_0x2ae481,_0x3f18db,_0x48778c){var _0x5a583b={};var _0x20c674={};var _0x5eb189;var _0x4c7d44;return db[_0xa4ba('0x32')]['findOne']({'where':{'id':_0x2ae481[_0xa4ba('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3f18db,null))['then'](function(_0x42bdaf){if(_0x42bdaf){_0x5eb189=_0x42bdaf;_0x20c674['model']=_['keys'](db[_0xa4ba('0x66')][_0xa4ba('0x33')]);_0x20c674['query']=_[_0xa4ba('0x38')](_0x2ae481[_0xa4ba('0x37')]);_0x20c674[_0xa4ba('0x39')]=_[_0xa4ba('0x4c')](_0x20c674[_0xa4ba('0x36')],_0x20c674[_0xa4ba('0x37')]);_0x5a583b[_0xa4ba('0x3a')]=_[_0xa4ba('0x4c')](_0x20c674[_0xa4ba('0x36')],qs[_0xa4ba('0x3b')](_0x2ae481['query'][_0xa4ba('0x3b')]));_0x5a583b['attributes']=_0x5a583b[_0xa4ba('0x3a')][_0xa4ba('0x3c')]?_0x5a583b['attributes']:_0x20c674[_0xa4ba('0x36')];_0x5a583b[_0xa4ba('0x3e')]=qs[_0xa4ba('0x3f')](_0x2ae481[_0xa4ba('0x37')][_0xa4ba('0x3f')]);_0x5a583b[_0xa4ba('0x40')]=qs[_0xa4ba('0x39')](_[_0xa4ba('0x41')](_0x2ae481['query'],_0x20c674[_0xa4ba('0x39')]));if(_0x2ae481[_0xa4ba('0x37')][_0xa4ba('0x42')]){_0x5a583b['where']=_['merge'](_0x5a583b[_0xa4ba('0x40')],{'$or':_[_0xa4ba('0x31')](_0x5a583b[_0xa4ba('0x3a')],function(_0x24ecda){var _0x6484c6={};_0x6484c6[_0x24ecda]={'$like':'%'+_0x2ae481['query'][_0xa4ba('0x42')]+'%'};return _0x6484c6;})});}_0x5a583b=_[_0xa4ba('0x43')]({},_0x5a583b,_0x2ae481[_0xa4ba('0x45')]);return _0x5eb189[_0xa4ba('0x67')](_0x5a583b);}})['then'](function(_0x13f683){if(_0x13f683){_0x4c7d44=_0x13f683[_0xa4ba('0x3c')];if(!_0x2ae481['query'][_0xa4ba('0x3d')]('nolimit')){_0x5a583b[_0xa4ba('0x20')]=qs['limit'](_0x2ae481[_0xa4ba('0x37')][_0xa4ba('0x20')]);_0x5a583b[_0xa4ba('0x1d')]=qs[_0xa4ba('0x1d')](_0x2ae481[_0xa4ba('0x37')][_0xa4ba('0x1d')]);}return _0x5eb189[_0xa4ba('0x67')](_0x5a583b);}})[_0xa4ba('0x26')](function(_0x51a6c9){if(_0x51a6c9){return _0x51a6c9?{'count':_0x4c7d44,'rows':_0x51a6c9}:null;}})[_0xa4ba('0x26')](respondWithResult(_0x3f18db,null))[_0xa4ba('0x49')](handleError(_0x3f18db,null));};exports[_0xa4ba('0x68')]=function(_0x55d31e,_0x808c65,_0x55d042){var _0x232c26=_0x55d31e[_0xa4ba('0x4f')][_0xa4ba('0x69')];return db[_0xa4ba('0x66')][_0xa4ba('0x47')]({'where':{'id':_0x232c26},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0xa4ba('0x2e'),'online',_0xa4ba('0x6a'),_0xa4ba('0x6b')],'raw':!![]}]})[_0xa4ba('0x26')](function(_0x47b6f3){if(_0x47b6f3){var _0x26dd8a=_[_0xa4ba('0x6c')](_0x47b6f3,function(_0x40267e){var _0x20ee22=_0x40267e[_0xa4ba('0x28')]({'plain':!![]});return _0x20ee22[_0xa4ba('0x6d')];});return db['WhatsappQueue'][_0xa4ba('0x54')]({'where':{'id':_0x55d31e[_0xa4ba('0x4b')]['id']}})['then'](function(_0x311c8b){return db[_0xa4ba('0x6e')][_0xa4ba('0x6f')](function(_0x6d25a9){return _0x311c8b[_0xa4ba('0x68')](_0x232c26,{'transaction':_0x6d25a9})['then'](function(){return BPromise[_0xa4ba('0x70')](_0x26dd8a,function(_0x47d903){return db[_0xa4ba('0x5c')][_0xa4ba('0x71')]({'where':{'UserId':_0x47d903['id'],'WhatsappQueueId':_0x55d31e['params']['id']},'transaction':_0x6d25a9});});})[_0xa4ba('0x26')](function(){_0x26dd8a[_0xa4ba('0x72')](function(_0x1bf807){socket['emit'](_0xa4ba('0x73'),{'UserId':_0x1bf807['id'],'WhatsappQueueId':_0x311c8b['id']});});});});});}})[_0xa4ba('0x26')](respondWithStatusCode(_0x808c65,null))['catch'](handleError(_0x808c65,null));};exports[_0xa4ba('0x74')]=function(_0x448601,_0x3417b3,_0x5817fa){return db[_0xa4ba('0x66')][_0xa4ba('0x47')]({'where':{'id':_0x448601[_0xa4ba('0x37')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0xa4ba('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xa4ba('0x26')](handleEntityNotFound(_0x3417b3,null))['then'](function(_0x13c11e){var _0x336118=_[_0xa4ba('0x31')](_0x13c11e,'id');var _0x2b8a95=[];var _0x1b6a68=[];var _0x5838d9=squel[_0xa4ba('0x75')]();_0x5838d9[_0xa4ba('0x76')]('tq.TeamId')['from'](_0xa4ba('0x77'),'tq')[_0xa4ba('0x78')](_0xa4ba('0x79'),'ut',_0xa4ba('0x7a'))[_0xa4ba('0x40')](_0xa4ba('0x7b'),_0x448601[_0xa4ba('0x4b')]['id']);for(var _0x48f58c=0x0;_0x48f58c<_0x13c11e[_0xa4ba('0x3c')];_0x48f58c+=0x1){let _0x13e4c7=_0x13c11e[_0x48f58c];for(var _0x4fb5a6=0x0;_0x4fb5a6<_0x13e4c7[_0xa4ba('0x6d')][_0xa4ba('0x3c')];_0x4fb5a6+=0x1){let _0x4f1411=_0x13e4c7[_0xa4ba('0x6d')][_0x4fb5a6];var _0x84f99b=_0x5838d9[_0xa4ba('0x7c')]();_0x84f99b[_0xa4ba('0x40')]('ut.UserId\x20=\x20?',_0x4f1411['id']);_0x1b6a68[_0xa4ba('0x7d')](db[_0xa4ba('0x6e')][_0xa4ba('0x37')](_0x84f99b[_0xa4ba('0x7e')](),{'type':db['sequelize']['QueryTypes'][_0xa4ba('0x7f')]})[_0xa4ba('0x26')](function(_0x41d633){if(_0x41d633[_0xa4ba('0x3c')]===0x1){return _0x4f1411['id'];}else{var _0xfea1b0=_[_0xa4ba('0x80')](_[_0xa4ba('0x31')](_0x41d633,_0xa4ba('0x81')),function(_0x3c3f56){return _[_0xa4ba('0x82')](_0x336118,_0x3c3f56);});if(_0xfea1b0){return _0x4f1411['id'];}}}));}}return BPromise[_0xa4ba('0x83')](_0x1b6a68)['then'](function(_0x495d7e){_0x2b8a95=_(_0x2b8a95)[_0xa4ba('0x84')](_0x495d7e)[_0xa4ba('0x85')]()[_0xa4ba('0x86')]();return db[_0xa4ba('0x32')][_0xa4ba('0x54')]({'where':{'id':_0x448601[_0xa4ba('0x4b')]['id']}})[_0xa4ba('0x26')](function(_0x577825){return db[_0xa4ba('0x6e')][_0xa4ba('0x6f')](function(_0x4e86c4){return _0x577825[_0xa4ba('0x74')](_0x448601[_0xa4ba('0x37')]['ids'],{'transaction':_0x4e86c4})['then'](function(){if(!_['isEmpty'](_0x2b8a95)){return _0x577825[_0xa4ba('0x87')](_0x2b8a95,{'transaction':_0x4e86c4});}})['then'](function(){_0x2b8a95[_0xa4ba('0x72')](function(_0x4c7131){socket['emit']('userWhatsappQueue:remove',{'UserId':_0x4c7131,'WhatsappQueueId':_0x577825['id']});});});});});});})[_0xa4ba('0x26')](respondWithStatusCode(_0x3417b3,null))[_0xa4ba('0x49')](handleError(_0x3417b3,null));};exports[_0xa4ba('0x88')]=function(_0xe5ab38,_0x7dc6fd,_0x57aeeb){return db['WhatsappQueue'][_0xa4ba('0x54')]({'where':{'id':_0xe5ab38['params']['id']}})[_0xa4ba('0x26')](handleEntityNotFound(_0x7dc6fd,null))[_0xa4ba('0x26')](function(_0xd2ee0c){if(_0xd2ee0c){return _0xd2ee0c['addAgents'](_0xe5ab38['body'][_0xa4ba('0x69')],_[_0xa4ba('0x89')](_0xe5ab38[_0xa4ba('0x4f')],['ids','id'])||{})[_0xa4ba('0x8a')](function(_0x44015f){for(var _0x25304a=0x0;_0x25304a<_0xe5ab38['body'][_0xa4ba('0x69')][_0xa4ba('0x3c')];_0x25304a+=0x1){socket[_0xa4ba('0x8b')](_0xa4ba('0x73'),{'UserId':Number(_0xe5ab38[_0xa4ba('0x4f')][_0xa4ba('0x69')][_0x25304a]),'WhatsappQueueId':Number(_0xe5ab38[_0xa4ba('0x4b')]['id'])});}return _0x44015f;});}})[_0xa4ba('0x26')](respondWithResult(_0x7dc6fd,null))[_0xa4ba('0x49')](handleError(_0x7dc6fd,null));};exports[_0xa4ba('0x87')]=function(_0x83c440,_0x41b82a,_0x527cbe){return db['WhatsappQueue'][_0xa4ba('0x54')]({'where':{'id':_0x83c440[_0xa4ba('0x4b')]['id']}})[_0xa4ba('0x26')](handleEntityNotFound(_0x41b82a,null))[_0xa4ba('0x26')](function(_0x35b954){if(_0x35b954){return _0x35b954[_0xa4ba('0x87')](_0x83c440[_0xa4ba('0x37')][_0xa4ba('0x69')])[_0xa4ba('0x26')](function(){if(_['isArray'](_0x83c440[_0xa4ba('0x37')][_0xa4ba('0x69')])){for(var _0x20f6a1=0x0;_0x20f6a1<_0x83c440[_0xa4ba('0x37')][_0xa4ba('0x69')][_0xa4ba('0x3c')];_0x20f6a1+=0x1){socket[_0xa4ba('0x8b')]('userWhatsappQueue:remove',{'UserId':Number(_0x83c440[_0xa4ba('0x37')][_0xa4ba('0x69')][_0x20f6a1]),'WhatsappQueueId':Number(_0x83c440[_0xa4ba('0x4b')]['id'])});}}else{socket[_0xa4ba('0x8b')](_0xa4ba('0x8c'),{'UserId':Number(_0x83c440['query'][_0xa4ba('0x69')]),'WhatsappQueueId':Number(_0x83c440[_0xa4ba('0x4b')]['id'])});}});}})[_0xa4ba('0x26')](respondWithStatusCode(_0x41b82a,null))[_0xa4ba('0x49')](handleError(_0x41b82a,null));};exports[_0xa4ba('0x8d')]=function(_0x1c2584,_0x242dff,_0xcaf719){var _0x1f67d0={};var _0x4399cf={};var _0x3f0848;var _0x47a84a;return db[_0xa4ba('0x32')][_0xa4ba('0x59')]({'where':{'id':_0x1c2584[_0xa4ba('0x4b')]['id']}})[_0xa4ba('0x26')](handleEntityNotFound(_0x242dff,null))[_0xa4ba('0x26')](function(_0x3a1d7d){if(_0x3a1d7d){_0x3f0848=_0x3a1d7d;_0x4399cf[_0xa4ba('0x36')]=_[_0xa4ba('0x38')](db['User'][_0xa4ba('0x33')]);_0x4399cf[_0xa4ba('0x37')]=_[_0xa4ba('0x38')](_0x1c2584[_0xa4ba('0x37')]);_0x4399cf[_0xa4ba('0x39')]=_['intersection'](_0x4399cf[_0xa4ba('0x36')],_0x4399cf[_0xa4ba('0x37')]);_0x1f67d0[_0xa4ba('0x3a')]=_[_0xa4ba('0x4c')](_0x4399cf[_0xa4ba('0x36')],qs['fields'](_0x1c2584['query'][_0xa4ba('0x3b')]));_0x1f67d0[_0xa4ba('0x3a')]=_0x1f67d0[_0xa4ba('0x3a')][_0xa4ba('0x3c')]?_0x1f67d0['attributes']:_0x4399cf[_0xa4ba('0x36')];_0x1f67d0['order']=qs[_0xa4ba('0x3f')](_0x1c2584[_0xa4ba('0x37')]['sort']);_0x1f67d0[_0xa4ba('0x40')]=qs[_0xa4ba('0x39')](_[_0xa4ba('0x41')](_0x1c2584[_0xa4ba('0x37')],_0x4399cf['filters']));if(_0x1c2584['query'][_0xa4ba('0x42')]){_0x1f67d0['where']=_[_0xa4ba('0x43')](_0x1f67d0[_0xa4ba('0x40')],{'$or':_[_0xa4ba('0x31')](_0x1f67d0[_0xa4ba('0x3a')],function(_0x6a1333){var _0x184c24={};_0x184c24[_0x6a1333]={'$like':'%'+_0x1c2584['query'][_0xa4ba('0x42')]+'%'};return _0x184c24;})});}_0x1f67d0=_['merge']({},_0x1f67d0,_0x1c2584[_0xa4ba('0x45')]);return _0x3f0848[_0xa4ba('0x8d')](_0x1f67d0);}})[_0xa4ba('0x26')](function(_0x25191c){if(_0x25191c){_0x47a84a=_0x25191c[_0xa4ba('0x3c')];if(!_0x1c2584['query'][_0xa4ba('0x3d')](_0xa4ba('0x5a'))){_0x1f67d0[_0xa4ba('0x20')]=qs[_0xa4ba('0x20')](_0x1c2584[_0xa4ba('0x37')][_0xa4ba('0x20')]);_0x1f67d0[_0xa4ba('0x1d')]=qs[_0xa4ba('0x1d')](_0x1c2584[_0xa4ba('0x37')]['offset']);}return _0x3f0848[_0xa4ba('0x8d')](_0x1f67d0);}})[_0xa4ba('0x26')](function(_0x496d9a){if(_0x496d9a){return _0x496d9a?{'count':_0x47a84a,'rows':_0x496d9a}:null;}})[_0xa4ba('0x26')](respondWithResult(_0x242dff,null))[_0xa4ba('0x49')](handleError(_0x242dff,null));}; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.events.js b/server/api/whatsappQueue/whatsappQueue.events.js new file mode 100644 index 0000000..5b50023 --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb21a=['../../mysqldb','WhatsappQueue','setMaxListeners','save','remove','emit','hook','exports','events'];(function(_0x4a9520,_0x4e67b2){var _0x27d098=function(_0x3e367c){while(--_0x3e367c){_0x4a9520['push'](_0x4a9520['shift']());}};_0x27d098(++_0x4e67b2);}(_0xb21a,0x1ca));var _0xab21=function(_0x4db352,_0x3d638){_0x4db352=_0x4db352-0x0;var _0x54ff7e=_0xb21a[_0x4db352];return _0x54ff7e;};'use strict';var EventEmitter=require(_0xab21('0x0'));var WhatsappQueue=require(_0xab21('0x1'))['db'][_0xab21('0x2')];var WhatsappQueueEvents=new EventEmitter();WhatsappQueueEvents[_0xab21('0x3')](0x0);var events={'afterCreate':_0xab21('0x4'),'afterUpdate':'update','afterDestroy':_0xab21('0x5')};function emitEvent(_0x31f16c){return function(_0x599ead,_0x26cc79,_0x2691ff){WhatsappQueueEvents[_0xab21('0x6')](_0x31f16c+':'+_0x599ead['id'],_0x599ead);WhatsappQueueEvents[_0xab21('0x6')](_0x31f16c,_0x599ead);_0x2691ff(null);};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];WhatsappQueue[_0xab21('0x7')](e,emitEvent(event));}}module[_0xab21('0x8')]=WhatsappQueueEvents; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.model.js b/server/api/whatsappQueue/whatsappQueue.model.js new file mode 100644 index 0000000..8b9f935 --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0d04=['rimraf','./whatsappQueue.attributes','exports','define','WhatsappQueue','whatsapp_queues','lodash','util','../../config/logger','api','moment','request-promise','path'];(function(_0x16b9ed,_0x56517a){var _0x66b1f8=function(_0x1c883){while(--_0x1c883){_0x16b9ed['push'](_0x16b9ed['shift']());}};_0x66b1f8(++_0x56517a);}(_0x0d04,0x18c));var _0x40d0=function(_0x417b1a,_0x3cfce5){_0x417b1a=_0x417b1a-0x0;var _0x1e41af=_0x0d04[_0x417b1a];return _0x1e41af;};'use strict';var _=require(_0x40d0('0x0'));var util=require(_0x40d0('0x1'));var logger=require(_0x40d0('0x2'))(_0x40d0('0x3'));var moment=require(_0x40d0('0x4'));var BPromise=require('bluebird');var rp=require(_0x40d0('0x5'));var fs=require('fs');var path=require(_0x40d0('0x6'));var rimraf=require(_0x40d0('0x7'));var config=require('../../config/environment');var attributes=require(_0x40d0('0x8'));module[_0x40d0('0x9')]=function(_0x3e54fa,_0x491546){return _0x3e54fa[_0x40d0('0xa')](_0x40d0('0xb'),attributes,{'tableName':_0x40d0('0xc'),'paranoid':![],'indexes':[],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.rpc.js b/server/api/whatsappQueue/whatsappQueue.rpc.js new file mode 100644 index 0000000..bd21b43 --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xca00=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./whatsappQueue.socket','register','info','WhatsappQueue,\x20%s,\x20%s','debug','WhatsappQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','GetWhatsappQueue','WhatsappQueue','findAll','options','where','attributes','limit','include','model','map','then','ShowWhatsappQueue','raw','lodash','util','moment','ioredis'];(function(_0x81324,_0x2927ef){var _0x9811c6=function(_0x100955){while(--_0x100955){_0x81324['push'](_0x81324['shift']());}};_0x9811c6(++_0x2927ef);}(_0xca00,0xe6));var _0x0ca0=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xca00[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0x0ca0('0x0'));var util=require(_0x0ca0('0x1'));var moment=require(_0x0ca0('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0ca0('0x3'));var db=require(_0x0ca0('0x4'))['db'];var utils=require(_0x0ca0('0x5'));var logger=require(_0x0ca0('0x6'))(_0x0ca0('0x7'));var config=require(_0x0ca0('0x8'));var jayson=require(_0x0ca0('0x9'));var client=jayson[_0x0ca0('0xa')][_0x0ca0('0xb')]({'port':0x232a});config[_0x0ca0('0xc')]=_['defaults'](config['redis'],{'host':_0x0ca0('0xd'),'port':0x18eb});var socket=require(_0x0ca0('0xe'))(new Redis(config[_0x0ca0('0xc')]));require(_0x0ca0('0xf'))[_0x0ca0('0x10')](socket);function respondWithRpcPromise(_0x43cba4,_0xe602ee,_0x54f319){return new BPromise(function(_0x16eee7,_0x2b63bc){return client['request'](_0x43cba4,_0x54f319)['then'](function(_0x508f7c){logger[_0x0ca0('0x11')](_0x0ca0('0x12'),_0xe602ee,'request\x20sent');logger[_0x0ca0('0x13')](_0x0ca0('0x14'),_0xe602ee,_0x0ca0('0x15'),JSON['stringify'](_0x508f7c));if(_0x508f7c['error']){if(_0x508f7c[_0x0ca0('0x16')]['code']===0x1f4){logger[_0x0ca0('0x16')](_0x0ca0('0x12'),_0xe602ee,_0x508f7c['error'][_0x0ca0('0x17')]);return _0x2b63bc(_0x508f7c[_0x0ca0('0x16')][_0x0ca0('0x17')]);}logger[_0x0ca0('0x16')]('WhatsappQueue,\x20%s,\x20%s',_0xe602ee,_0x508f7c['error'][_0x0ca0('0x17')]);return _0x16eee7(_0x508f7c[_0x0ca0('0x16')][_0x0ca0('0x17')]);}else{logger['info']('WhatsappQueue,\x20%s,\x20%s',_0xe602ee,_0x0ca0('0x15'));_0x16eee7(_0x508f7c[_0x0ca0('0x18')][_0x0ca0('0x17')]);}})[_0x0ca0('0x19')](function(_0x1f2469){logger[_0x0ca0('0x16')](_0x0ca0('0x12'),_0xe602ee,_0x1f2469);_0x2b63bc(_0x1f2469);});});}exports[_0x0ca0('0x1a')]=function(_0x171854){var _0x324d4f=this;return new Promise(function(_0x2dd020,_0x1bcf29){return db[_0x0ca0('0x1b')][_0x0ca0('0x1c')]({'raw':_0x171854[_0x0ca0('0x1d')]?_0x171854[_0x0ca0('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x171854[_0x0ca0('0x1d')]?_0x171854[_0x0ca0('0x1d')][_0x0ca0('0x1e')]||null:null,'attributes':_0x171854['options']?_0x171854[_0x0ca0('0x1d')][_0x0ca0('0x1f')]||null:null,'limit':_0x171854[_0x0ca0('0x1d')]?_0x171854[_0x0ca0('0x1d')][_0x0ca0('0x20')]||null:null,'include':_0x171854['options']?_0x171854[_0x0ca0('0x1d')][_0x0ca0('0x21')]?_['map'](_0x171854[_0x0ca0('0x1d')][_0x0ca0('0x21')],function(_0x1565c8){return{'model':db[_0x1565c8[_0x0ca0('0x22')]],'as':_0x1565c8['as'],'attributes':_0x1565c8[_0x0ca0('0x1f')],'include':_0x1565c8[_0x0ca0('0x21')]?_[_0x0ca0('0x23')](_0x1565c8[_0x0ca0('0x21')],function(_0x3c8e11){return{'model':db[_0x3c8e11['model']],'as':_0x3c8e11['as'],'attributes':_0x3c8e11['attributes'],'include':_0x3c8e11[_0x0ca0('0x21')]?_[_0x0ca0('0x23')](_0x3c8e11[_0x0ca0('0x21')],function(_0x138749){return{'model':db[_0x138749[_0x0ca0('0x22')]],'as':_0x138749['as'],'attributes':_0x138749[_0x0ca0('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x0ca0('0x24')](function(_0x50be16){logger[_0x0ca0('0x11')]('GetWhatsappQueue',_0x171854);logger['debug'](_0x0ca0('0x1a'),_0x171854,JSON['stringify'](_0x50be16));_0x2dd020(_0x50be16);})[_0x0ca0('0x19')](function(_0x28f421){logger[_0x0ca0('0x16')](_0x0ca0('0x1a'),_0x28f421[_0x0ca0('0x17')],_0x171854);_0x1bcf29(_0x324d4f['error'](0x1f4,_0x28f421[_0x0ca0('0x17')]));});});};exports[_0x0ca0('0x25')]=function(_0x43bd3f){var _0x562307=this;return new Promise(function(_0x25b1e6,_0x2d13a7){return db['WhatsappQueue']['find']({'raw':_0x43bd3f[_0x0ca0('0x1d')]?_0x43bd3f[_0x0ca0('0x1d')][_0x0ca0('0x26')]===undefined?!![]:![]:!![],'where':_0x43bd3f[_0x0ca0('0x1d')]?_0x43bd3f[_0x0ca0('0x1d')][_0x0ca0('0x1e')]||null:null,'attributes':_0x43bd3f[_0x0ca0('0x1d')]?_0x43bd3f['options'][_0x0ca0('0x1f')]||null:null,'include':_0x43bd3f[_0x0ca0('0x1d')]?_0x43bd3f[_0x0ca0('0x1d')][_0x0ca0('0x21')]?_[_0x0ca0('0x23')](_0x43bd3f[_0x0ca0('0x1d')]['include'],function(_0x48aa32){return{'model':db[_0x48aa32['model']],'as':_0x48aa32['as'],'attributes':_0x48aa32['attributes'],'include':_0x48aa32[_0x0ca0('0x21')]?_[_0x0ca0('0x23')](_0x48aa32[_0x0ca0('0x21')],function(_0x54896e){return{'model':db[_0x54896e[_0x0ca0('0x22')]],'as':_0x54896e['as'],'attributes':_0x54896e[_0x0ca0('0x1f')],'include':_0x54896e[_0x0ca0('0x21')]?_[_0x0ca0('0x23')](_0x54896e[_0x0ca0('0x21')],function(_0x37e341){return{'model':db[_0x37e341[_0x0ca0('0x22')]],'as':_0x37e341['as'],'attributes':_0x37e341[_0x0ca0('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x0ca0('0x24')](function(_0x4c8b81){logger['info'](_0x0ca0('0x25'),_0x43bd3f);logger[_0x0ca0('0x13')](_0x0ca0('0x25'),_0x43bd3f,JSON['stringify'](_0x4c8b81));_0x25b1e6(_0x4c8b81);})[_0x0ca0('0x19')](function(_0x4af046){logger['error'](_0x0ca0('0x25'),_0x4af046[_0x0ca0('0x17')],_0x43bd3f);_0x2d13a7(_0x562307['error'](0x1f4,_0x4af046[_0x0ca0('0x17')]));});});}; \ No newline at end of file diff --git a/server/api/whatsappQueue/whatsappQueue.socket.js b/server/api/whatsappQueue/whatsappQueue.socket.js new file mode 100644 index 0000000..3044edf --- /dev/null +++ b/server/api/whatsappQueue/whatsappQueue.socket.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2182=['remove','update','emit','register','length','save'];(function(_0x4c4180,_0x4e1bca){var _0x391ee8=function(_0x5277a4){while(--_0x5277a4){_0x4c4180['push'](_0x4c4180['shift']());}};_0x391ee8(++_0x4e1bca);}(_0x2182,0x167));var _0x2218=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0x2182[_0x167cc1];return _0x10bc4b;};'use strict';var WhatsappQueueEvents=require('./whatsappQueue.events');var events=[_0x2218('0x0'),_0x2218('0x1'),_0x2218('0x2')];function createListener(_0x479709,_0x29d103){return function(_0x33a885){_0x29d103[_0x2218('0x3')](_0x479709,_0x33a885);};}function removeListener(_0xa46ab8,_0x4babce){return function(){WhatsappQueueEvents['removeListener'](_0xa46ab8,_0x4babce);};}exports[_0x2218('0x4')]=function(_0x2f30f7){for(var _0x3445b6=0x0,_0x5ebece=events[_0x2218('0x5')];_0x3445b6<_0x5ebece;_0x3445b6++){var _0x241ce8=events[_0x3445b6];var _0x2888f9=createListener('whatsappQueue:'+_0x241ce8,_0x2f30f7);WhatsappQueueEvents['on'](_0x241ce8,_0x2888f9);}}; \ No newline at end of file diff --git a/server/api/whatsappQueueReport/index.js b/server/api/whatsappQueueReport/index.js new file mode 100644 index 0000000..1d8c619 --- /dev/null +++ b/server/api/whatsappQueueReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0223=['fs-extra','../../components/auth/service','../../components/interaction/service','./whatsappQueueReport.controller','isAuthenticated','index','get','/describe','/:id','show','post','create','delete','destroy','exports','util','path','connect-timeout','Router'];(function(_0x3a186f,_0x1fd391){var _0xcd4e18=function(_0x1133b3){while(--_0x1133b3){_0x3a186f['push'](_0x3a186f['shift']());}};_0xcd4e18(++_0x1fd391);}(_0x0223,0x81));var _0x3022=function(_0x4fde83,_0x2d9011){_0x4fde83=_0x4fde83-0x0;var _0x3b33e3=_0x0223[_0x4fde83];return _0x3b33e3;};'use strict';var multer=require('multer');var util=require(_0x3022('0x0'));var path=require(_0x3022('0x1'));var timeout=require(_0x3022('0x2'));var express=require('express');var router=express[_0x3022('0x3')]();var fs_extra=require(_0x3022('0x4'));var auth=require(_0x3022('0x5'));var interaction=require(_0x3022('0x6'));var config=require('../../config/environment');var controller=require(_0x3022('0x7'));router['get']('/',auth[_0x3022('0x8')](),controller[_0x3022('0x9')]);router[_0x3022('0xa')](_0x3022('0xb'),auth[_0x3022('0x8')](),controller['describe']);router[_0x3022('0xa')](_0x3022('0xc'),auth[_0x3022('0x8')](),controller[_0x3022('0xd')]);router[_0x3022('0xe')]('/',auth[_0x3022('0x8')](),controller[_0x3022('0xf')]);router['put']('/:id',auth[_0x3022('0x8')](),controller['update']);router[_0x3022('0x10')](_0x3022('0xc'),auth[_0x3022('0x8')](),controller[_0x3022('0x11')]);module[_0x3022('0x12')]=router; \ No newline at end of file diff --git a/server/api/whatsappQueueReport/whatsappQueueReport.attributes.js b/server/api/whatsappQueueReport/whatsappQueueReport.attributes.js new file mode 100644 index 0000000..6d44b20 --- /dev/null +++ b/server/api/whatsappQueueReport/whatsappQueueReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['STRING','DATE','sequelize','exports'];(function(_0x4720dd,_0x396da7){var _0x19bf8b=function(_0x25a78e){while(--_0x25a78e){_0x4720dd['push'](_0x4720dd['shift']());}};_0x19bf8b(++_0x396da7);}(_0x7a54,0x106));var _0x47a5=function(_0x133e53,_0xf8eac2){_0x133e53=_0x133e53-0x0;var _0x5988c4=_0x7a54[_0x133e53];return _0x5988c4;};'use strict';var Sequelize=require(_0x47a5('0x0'));module[_0x47a5('0x1')]={'uniqueid':{'type':Sequelize[_0x47a5('0x2')],'allowNull':![]},'from':{'type':Sequelize['STRING']},'joinAt':{'type':Sequelize[_0x47a5('0x3')]},'leaveAt':{'type':Sequelize[_0x47a5('0x3')]},'acceptAt':{'type':Sequelize['DATE']},'exitAt':{'type':Sequelize[_0x47a5('0x3')]},'reason':{'type':Sequelize[_0x47a5('0x2')]}}; \ No newline at end of file diff --git a/server/api/whatsappQueueReport/whatsappQueueReport.controller.js b/server/api/whatsappQueueReport/whatsappQueueReport.controller.js new file mode 100644 index 0000000..102d6e3 --- /dev/null +++ b/server/api/whatsappQueueReport/whatsappQueueReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2547=['order','where','pick','filter','merge','VIRTUAL','options','WhatsappQueueReport','includeAll','include','rows','catch','params','find','create','body','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','name','send','index','map','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x2547,0x1cd));var _0x7254=function(_0x15fc43,_0x19a45){_0x15fc43=_0x15fc43-0x0;var _0x57318a=_0x2547[_0x15fc43];return _0x57318a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7254('0x0'));var zipdir=require(_0x7254('0x1'));var jsonpatch=require(_0x7254('0x2'));var rp=require(_0x7254('0x3'));var moment=require(_0x7254('0x4'));var BPromise=require(_0x7254('0x5'));var Mustache=require(_0x7254('0x6'));var util=require(_0x7254('0x7'));var path=require('path');var sox=require(_0x7254('0x8'));var csv=require(_0x7254('0x9'));var ejs=require(_0x7254('0xa'));var fs=require('fs');var fs_extra=require(_0x7254('0xb'));var _=require('lodash');var squel=require(_0x7254('0xc'));var crypto=require(_0x7254('0xd'));var jsforce=require(_0x7254('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x7254('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x7254('0xf'));var qs=require(_0x7254('0x10'));var as=require(_0x7254('0x11'));var hardwareService=require(_0x7254('0x12'));var logger=require(_0x7254('0x13'))(_0x7254('0x14'));var utils=require('../../config/utils');var config=require(_0x7254('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x7254('0x16'))['db'];function respondWithStatusCode(_0x53fc4f,_0x16c08e){_0x16c08e=_0x16c08e||0xcc;return function(_0x2bfff8){if(_0x2bfff8){return _0x53fc4f[_0x7254('0x17')](_0x16c08e);}return _0x53fc4f[_0x7254('0x18')](_0x16c08e)[_0x7254('0x19')]();};}function respondWithResult(_0x395a8a,_0x124192){_0x124192=_0x124192||0xc8;return function(_0x21cecc){if(_0x21cecc){return _0x395a8a[_0x7254('0x18')](_0x124192)[_0x7254('0x1a')](_0x21cecc);}};}function respondWithFilteredResult(_0x38a99c,_0x1ee5cb){return function(_0x163c8c){if(_0x163c8c){var _0x535065=typeof _0x1ee5cb[_0x7254('0x1b')]===_0x7254('0x1c')&&typeof _0x1ee5cb[_0x7254('0x1d')]===_0x7254('0x1c');var _0x3b5f06=_0x163c8c[_0x7254('0x1e')];var _0x2737e0=_0x535065?0x0:_0x1ee5cb['offset'];var _0x1f48f6=_0x535065?_0x163c8c[_0x7254('0x1e')]:_0x1ee5cb[_0x7254('0x1b')]+_0x1ee5cb[_0x7254('0x1d')];var _0x2a1ddc;if(_0x1f48f6>=_0x3b5f06){_0x1f48f6=_0x3b5f06;_0x2a1ddc=0xc8;}else{_0x2a1ddc=0xce;}_0x38a99c[_0x7254('0x18')](_0x2a1ddc);return _0x38a99c[_0x7254('0x1f')](_0x7254('0x20'),_0x2737e0+'-'+_0x1f48f6+'/'+_0x3b5f06)[_0x7254('0x1a')](_0x163c8c);}return null;};}function patchUpdates(_0x3b6cb6){return function(_0x2594b8){try{jsonpatch[_0x7254('0x21')](_0x2594b8,_0x3b6cb6,!![]);}catch(_0xc617b6){return BPromise[_0x7254('0x22')](_0xc617b6);}return _0x2594b8[_0x7254('0x23')]();};}function saveUpdates(_0x95ceaa,_0x2bb2fe){return function(_0x46c0a2){if(_0x46c0a2){return _0x46c0a2[_0x7254('0x24')](_0x95ceaa)[_0x7254('0x25')](function(_0x1be69b){return _0x1be69b;});}return null;};}function removeEntity(_0x50c34b,_0x493bfd){return function(_0x136ea3){if(_0x136ea3){return _0x136ea3[_0x7254('0x26')]()[_0x7254('0x25')](function(){_0x50c34b[_0x7254('0x18')](0xcc)[_0x7254('0x19')]();});}};}function handleEntityNotFound(_0x36b5d5,_0x133aee){return function(_0x5d6df5){if(!_0x5d6df5){_0x36b5d5[_0x7254('0x17')](0x194);}return _0x5d6df5;};}function handleError(_0x21a579,_0x2b4f46){_0x2b4f46=_0x2b4f46||0x1f4;return function(_0x494cdb){logger[_0x7254('0x27')](_0x494cdb['stack']);if(_0x494cdb[_0x7254('0x28')]){delete _0x494cdb[_0x7254('0x28')];}_0x21a579['status'](_0x2b4f46)[_0x7254('0x29')](_0x494cdb);};}exports[_0x7254('0x2a')]=function(_0x4f684c,_0x14cbea){var _0x6c4927={},_0x37cb5c={},_0xb9198b={'count':0x0,'rows':[]};var _0x43bf02=_[_0x7254('0x2b')](db['WhatsappQueueReport'][_0x7254('0x2c')],function(_0x2dba3f){return{'name':_0x2dba3f['fieldName'],'type':_0x2dba3f[_0x7254('0x2d')][_0x7254('0x2e')]};});_0x37cb5c[_0x7254('0x2f')]=_['map'](_0x43bf02,_0x7254('0x28'));_0x37cb5c[_0x7254('0x30')]=_[_0x7254('0x31')](_0x4f684c[_0x7254('0x30')]);_0x37cb5c[_0x7254('0x32')]=_[_0x7254('0x33')](_0x37cb5c[_0x7254('0x2f')],_0x37cb5c['query']);_0x6c4927[_0x7254('0x34')]=_['intersection'](_0x37cb5c['model'],qs[_0x7254('0x35')](_0x4f684c[_0x7254('0x30')][_0x7254('0x35')]));_0x6c4927[_0x7254('0x34')]=_0x6c4927[_0x7254('0x34')][_0x7254('0x36')]?_0x6c4927[_0x7254('0x34')]:_0x37cb5c[_0x7254('0x2f')];if(!_0x4f684c[_0x7254('0x30')][_0x7254('0x37')](_0x7254('0x38'))){_0x6c4927[_0x7254('0x1d')]=qs[_0x7254('0x1d')](_0x4f684c[_0x7254('0x30')]['limit']);_0x6c4927[_0x7254('0x1b')]=qs[_0x7254('0x1b')](_0x4f684c[_0x7254('0x30')][_0x7254('0x1b')]);}_0x6c4927[_0x7254('0x39')]=qs['sort'](_0x4f684c[_0x7254('0x30')]['sort']);_0x6c4927[_0x7254('0x3a')]=qs[_0x7254('0x32')](_[_0x7254('0x3b')](_0x4f684c[_0x7254('0x30')],_0x37cb5c[_0x7254('0x32')]),_0x43bf02);if(_0x4f684c['query'][_0x7254('0x3c')]){_0x6c4927['where']=_[_0x7254('0x3d')](_0x6c4927[_0x7254('0x3a')],{'$or':_['map'](_0x43bf02,function(_0x1485a0){if(_0x1485a0[_0x7254('0x2d')]!==_0x7254('0x3e')){var _0x9273ee={};_0x9273ee[_0x1485a0[_0x7254('0x28')]]={'$like':'%'+_0x4f684c[_0x7254('0x30')]['filter']+'%'};return _0x9273ee;}})});}_0x6c4927=_[_0x7254('0x3d')]({},_0x6c4927,_0x4f684c[_0x7254('0x3f')]);var _0x105b8c={'where':_0x6c4927['where']};return db[_0x7254('0x40')][_0x7254('0x1e')](_0x105b8c)[_0x7254('0x25')](function(_0x4824d5){_0xb9198b[_0x7254('0x1e')]=_0x4824d5;if(_0x4f684c[_0x7254('0x30')][_0x7254('0x41')]){_0x6c4927[_0x7254('0x42')]=[{'all':!![]}];}return db[_0x7254('0x40')]['findAll'](_0x6c4927);})['then'](function(_0x25004f){_0xb9198b[_0x7254('0x43')]=_0x25004f;return _0xb9198b;})[_0x7254('0x25')](respondWithFilteredResult(_0x14cbea,_0x6c4927))[_0x7254('0x44')](handleError(_0x14cbea,null));};exports['show']=function(_0x53a7a7,_0x29821a){var _0x565cd8={'raw':!![],'where':{'id':_0x53a7a7[_0x7254('0x45')]['id']}},_0x2ae22e={};_0x2ae22e[_0x7254('0x2f')]=_[_0x7254('0x31')](db['WhatsappQueueReport']['rawAttributes']);_0x2ae22e[_0x7254('0x30')]=_[_0x7254('0x31')](_0x53a7a7[_0x7254('0x30')]);_0x2ae22e[_0x7254('0x32')]=_[_0x7254('0x33')](_0x2ae22e['model'],_0x2ae22e['query']);_0x565cd8[_0x7254('0x34')]=_[_0x7254('0x33')](_0x2ae22e[_0x7254('0x2f')],qs['fields'](_0x53a7a7[_0x7254('0x30')][_0x7254('0x35')]));_0x565cd8['attributes']=_0x565cd8[_0x7254('0x34')][_0x7254('0x36')]?_0x565cd8[_0x7254('0x34')]:_0x2ae22e[_0x7254('0x2f')];if(_0x53a7a7['query'][_0x7254('0x41')]){_0x565cd8[_0x7254('0x42')]=[{'all':!![]}];}_0x565cd8=_['merge']({},_0x565cd8,_0x53a7a7[_0x7254('0x3f')]);return db[_0x7254('0x40')][_0x7254('0x46')](_0x565cd8)['then'](handleEntityNotFound(_0x29821a,null))[_0x7254('0x25')](respondWithResult(_0x29821a,null))[_0x7254('0x44')](handleError(_0x29821a,null));};exports['create']=function(_0x5f101e,_0x10b32f){return db['WhatsappQueueReport'][_0x7254('0x47')](_0x5f101e[_0x7254('0x48')],{})['then'](respondWithResult(_0x10b32f,0xc9))['catch'](handleError(_0x10b32f,null));};exports[_0x7254('0x24')]=function(_0xc40bc5,_0x38bcd5){if(_0xc40bc5[_0x7254('0x48')]['id']){delete _0xc40bc5[_0x7254('0x48')]['id'];}return db[_0x7254('0x40')]['find']({'where':{'id':_0xc40bc5[_0x7254('0x45')]['id']}})['then'](handleEntityNotFound(_0x38bcd5,null))[_0x7254('0x25')](saveUpdates(_0xc40bc5[_0x7254('0x48')],null))[_0x7254('0x25')](respondWithResult(_0x38bcd5,null))['catch'](handleError(_0x38bcd5,null));};exports[_0x7254('0x26')]=function(_0x1c1a0e,_0x252758){return db['WhatsappQueueReport'][_0x7254('0x46')]({'where':{'id':_0x1c1a0e[_0x7254('0x45')]['id']}})[_0x7254('0x25')](handleEntityNotFound(_0x252758,null))[_0x7254('0x25')](removeEntity(_0x252758,null))[_0x7254('0x44')](handleError(_0x252758,null));};exports['describe']=function(_0x5e66c6,_0x24c532){return db[_0x7254('0x40')][_0x7254('0x49')]()[_0x7254('0x25')](respondWithResult(_0x24c532,null))[_0x7254('0x44')](handleError(_0x24c532,null));}; \ No newline at end of file diff --git a/server/api/whatsappQueueReport/whatsappQueueReport.model.js b/server/api/whatsappQueueReport/whatsappQueueReport.model.js new file mode 100644 index 0000000..309e3a9 --- /dev/null +++ b/server/api/whatsappQueueReport/whatsappQueueReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd179=['lodash','util','api','bluebird','request-promise','path','../../config/environment','exports','define','report_whatsapp_queue','uniqueid'];(function(_0x5c1329,_0x44d752){var _0x282631=function(_0x92755d){while(--_0x92755d){_0x5c1329['push'](_0x5c1329['shift']());}};_0x282631(++_0x44d752);}(_0xd179,0x8f));var _0x9d17=function(_0x34843e,_0x4c4224){_0x34843e=_0x34843e-0x0;var _0x598f7f=_0xd179[_0x34843e];return _0x598f7f;};'use strict';var _=require(_0x9d17('0x0'));var util=require(_0x9d17('0x1'));var logger=require('../../config/logger')(_0x9d17('0x2'));var moment=require('moment');var BPromise=require(_0x9d17('0x3'));var rp=require(_0x9d17('0x4'));var fs=require('fs');var path=require(_0x9d17('0x5'));var rimraf=require('rimraf');var config=require(_0x9d17('0x6'));var attributes=require('./whatsappQueueReport.attributes');module[_0x9d17('0x7')]=function(_0x15ee64,_0x432b0b){return _0x15ee64[_0x9d17('0x8')]('WhatsappQueueReport',attributes,{'tableName':_0x9d17('0x9'),'paranoid':![],'indexes':[{'name':_0x9d17('0xa'),'fields':[_0x9d17('0xa')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/whatsappQueueReport/whatsappQueueReport.rpc.js b/server/api/whatsappQueueReport/whatsappQueueReport.rpc.js new file mode 100644 index 0000000..791237e --- /dev/null +++ b/server/api/whatsappQueueReport/whatsappQueueReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x63d9=['update','raw','where','limit','UpdateWhatsappQueueReport','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','then','info','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','WhatsappQueueReport,\x20%s,\x20%s','result','CreateWhatsappQueueReport','create','body','options','WhatsappQueueReport'];(function(_0x3e5147,_0x33eef9){var _0x18c779=function(_0x2a143c){while(--_0x2a143c){_0x3e5147['push'](_0x3e5147['shift']());}};_0x18c779(++_0x33eef9);}(_0x63d9,0x19e));var _0x963d=function(_0x305e72,_0x1f2c2a){_0x305e72=_0x305e72-0x0;var _0x18dcf9=_0x63d9[_0x305e72];return _0x18dcf9;};'use strict';var _=require(_0x963d('0x0'));var util=require('util');var moment=require(_0x963d('0x1'));var BPromise=require(_0x963d('0x2'));var rs=require(_0x963d('0x3'));var fs=require('fs');var Redis=require(_0x963d('0x4'));var db=require(_0x963d('0x5'))['db'];var utils=require(_0x963d('0x6'));var logger=require(_0x963d('0x7'))(_0x963d('0x8'));var config=require(_0x963d('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x963d('0xa')][_0x963d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x273297,_0x375c4c,_0x12a1bf){return new BPromise(function(_0x5efe74,_0x59b448){return client['request'](_0x273297,_0x12a1bf)[_0x963d('0xc')](function(_0x54bfbd){logger[_0x963d('0xd')]('WhatsappQueueReport,\x20%s,\x20%s',_0x375c4c,_0x963d('0xe'));logger[_0x963d('0xf')](_0x963d('0x10'),_0x375c4c,'request\x20sent',JSON[_0x963d('0x11')](_0x54bfbd));if(_0x54bfbd[_0x963d('0x12')]){if(_0x54bfbd[_0x963d('0x12')][_0x963d('0x13')]===0x1f4){logger[_0x963d('0x12')]('WhatsappQueueReport,\x20%s,\x20%s',_0x375c4c,_0x54bfbd[_0x963d('0x12')][_0x963d('0x14')]);return _0x59b448(_0x54bfbd['error'][_0x963d('0x14')]);}logger[_0x963d('0x12')](_0x963d('0x15'),_0x375c4c,_0x54bfbd[_0x963d('0x12')][_0x963d('0x14')]);return _0x5efe74(_0x54bfbd[_0x963d('0x12')][_0x963d('0x14')]);}else{logger[_0x963d('0xd')]('WhatsappQueueReport,\x20%s,\x20%s',_0x375c4c,_0x963d('0xe'));_0x5efe74(_0x54bfbd[_0x963d('0x16')][_0x963d('0x14')]);}})['catch'](function(_0x36339c){logger[_0x963d('0x12')]('WhatsappQueueReport,\x20%s,\x20%s',_0x375c4c,_0x36339c);_0x59b448(_0x36339c);});});}exports[_0x963d('0x17')]=function(_0x4e0278){var _0x5b522c=this;return new Promise(function(_0x532ab6,_0x5683f4){return db['WhatsappQueueReport'][_0x963d('0x18')](_0x4e0278[_0x963d('0x19')],{'raw':_0x4e0278[_0x963d('0x1a')]?_0x4e0278[_0x963d('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x963d('0xc')](function(_0x32d870){logger['info'](_0x963d('0x17'),_0x4e0278);logger[_0x963d('0xf')](_0x963d('0x17'),_0x4e0278,JSON[_0x963d('0x11')](_0x32d870));_0x532ab6(_0x32d870);})['catch'](function(_0x91cd4e){logger[_0x963d('0x12')]('CreateWhatsappQueueReport',_0x91cd4e[_0x963d('0x14')],_0x4e0278);_0x5683f4(_0x5b522c['error'](0x1f4,_0x91cd4e[_0x963d('0x14')]));});});};exports['UpdateWhatsappQueueReport']=function(_0x3503b7){var _0x232c8a=this;return new Promise(function(_0xce2d21,_0x3cc319){return db[_0x963d('0x1b')][_0x963d('0x1c')](_0x3503b7[_0x963d('0x19')],{'raw':_0x3503b7[_0x963d('0x1a')]?_0x3503b7[_0x963d('0x1a')][_0x963d('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3503b7[_0x963d('0x1a')]?_0x3503b7[_0x963d('0x1a')][_0x963d('0x1e')]||null:null,'attributes':_0x3503b7[_0x963d('0x1a')]?_0x3503b7[_0x963d('0x1a')]['attributes']||null:null,'limit':_0x3503b7[_0x963d('0x1a')]?_0x3503b7[_0x963d('0x1a')][_0x963d('0x1f')]||null:null})[_0x963d('0xc')](function(_0x532153){logger[_0x963d('0xd')](_0x963d('0x20'),_0x3503b7);logger[_0x963d('0xf')](_0x963d('0x20'),_0x3503b7,JSON[_0x963d('0x11')](_0x532153));_0xce2d21(_0x532153);})[_0x963d('0x21')](function(_0x5c4c5c){logger['error'](_0x963d('0x20'),_0x5c4c5c[_0x963d('0x14')],_0x3503b7);_0x3cc319(_0x232c8a[_0x963d('0x12')](0x1f4,_0x5c4c5c[_0x963d('0x14')]));});});}; \ No newline at end of file diff --git a/server/api/whatsappTransferReport/index.js b/server/api/whatsappTransferReport/index.js new file mode 100644 index 0000000..1df67c5 --- /dev/null +++ b/server/api/whatsappTransferReport/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2c72=['/:id','show','put','update','delete','exports','path','connect-timeout','express','Router','fs-extra','../../components/auth/service','../../components/interaction/service','../../config/environment','./whatsappTransferReport.controller','get','isAuthenticated','index','/describe','describe'];(function(_0x28db55,_0x498814){var _0x12e1d6=function(_0x572bb1){while(--_0x572bb1){_0x28db55['push'](_0x28db55['shift']());}};_0x12e1d6(++_0x498814);}(_0x2c72,0x132));var _0x22c7=function(_0x52a6f1,_0x5e3372){_0x52a6f1=_0x52a6f1-0x0;var _0xacda44=_0x2c72[_0x52a6f1];return _0xacda44;};'use strict';var multer=require('multer');var util=require('util');var path=require(_0x22c7('0x0'));var timeout=require(_0x22c7('0x1'));var express=require(_0x22c7('0x2'));var router=express[_0x22c7('0x3')]();var fs_extra=require(_0x22c7('0x4'));var auth=require(_0x22c7('0x5'));var interaction=require(_0x22c7('0x6'));var config=require(_0x22c7('0x7'));var controller=require(_0x22c7('0x8'));router[_0x22c7('0x9')]('/',auth[_0x22c7('0xa')](),controller[_0x22c7('0xb')]);router[_0x22c7('0x9')](_0x22c7('0xc'),auth[_0x22c7('0xa')](),controller[_0x22c7('0xd')]);router[_0x22c7('0x9')](_0x22c7('0xe'),auth[_0x22c7('0xa')](),controller[_0x22c7('0xf')]);router['post']('/',auth[_0x22c7('0xa')](),controller['create']);router[_0x22c7('0x10')]('/:id',auth[_0x22c7('0xa')](),controller[_0x22c7('0x11')]);router[_0x22c7('0x12')](_0x22c7('0xe'),auth[_0x22c7('0xa')](),controller['destroy']);module[_0x22c7('0x13')]=router; \ No newline at end of file diff --git a/server/api/whatsappTransferReport/whatsappTransferReport.attributes.js b/server/api/whatsappTransferReport/whatsappTransferReport.attributes.js new file mode 100644 index 0000000..7668e66 --- /dev/null +++ b/server/api/whatsappTransferReport/whatsappTransferReport.attributes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa866=['DATE','sequelize','exports','STRING','ENUM','account','queue'];(function(_0x4345be,_0x1e1dd6){var _0xf851a1=function(_0x2d5ec6){while(--_0x2d5ec6){_0x4345be['push'](_0x4345be['shift']());}};_0xf851a1(++_0x1e1dd6);}(_0xa866,0x6a));var _0x6a86=function(_0x3c5561,_0x29fde6){_0x3c5561=_0x3c5561-0x0;var _0x5b2af5=_0xa866[_0x3c5561];return _0x5b2af5;};'use strict';var Sequelize=require(_0x6a86('0x0'));module[_0x6a86('0x1')]={'uniqueid':{'type':Sequelize[_0x6a86('0x2')],'allowNull':![]},'type':{'type':Sequelize[_0x6a86('0x3')](_0x6a86('0x4'),'agent',_0x6a86('0x5')),'allowNull':![]},'transferredAt':{'type':Sequelize[_0x6a86('0x6')]}}; \ No newline at end of file diff --git a/server/api/whatsappTransferReport/whatsappTransferReport.controller.js b/server/api/whatsappTransferReport/whatsappTransferReport.controller.js new file mode 100644 index 0000000..cdec905 --- /dev/null +++ b/server/api/whatsappTransferReport/whatsappTransferReport.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x64cd=['where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','intersection','length','find','create','body','describe','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','error','name','index','map','WhatsappTransferReport','rawAttributes','type','key','query','keys','filters','model','attributes','fields','nolimit','order','sort'];(function(_0x4ce637,_0x463346){var _0x2e9cba=function(_0x11f3d1){while(--_0x11f3d1){_0x4ce637['push'](_0x4ce637['shift']());}};_0x2e9cba(++_0x463346);}(_0x64cd,0x194));var _0xd64c=function(_0x48e86c,_0x9f034d){_0x48e86c=_0x48e86c-0x0;var _0x54fa11=_0x64cd[_0x48e86c];return _0x54fa11;};'use strict';var emlformat=require(_0xd64c('0x0'));var rimraf=require(_0xd64c('0x1'));var zipdir=require(_0xd64c('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd64c('0x3'));var moment=require('moment');var BPromise=require(_0xd64c('0x4'));var Mustache=require(_0xd64c('0x5'));var util=require(_0xd64c('0x6'));var path=require(_0xd64c('0x7'));var sox=require(_0xd64c('0x8'));var csv=require('to-csv');var ejs=require(_0xd64c('0x9'));var fs=require('fs');var fs_extra=require(_0xd64c('0xa'));var _=require(_0xd64c('0xb'));var squel=require(_0xd64c('0xc'));var crypto=require('crypto');var jsforce=require(_0xd64c('0xd'));var deskjs=require(_0xd64c('0xe'));var toCsv=require('to-csv');var querystring=require(_0xd64c('0xf'));var Papa=require('papaparse');var Redis=require(_0xd64c('0x10'));var authService=require(_0xd64c('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xd64c('0x12'));var hardwareService=require(_0xd64c('0x13'));var logger=require(_0xd64c('0x14'))(_0xd64c('0x15'));var utils=require(_0xd64c('0x16'));var config=require(_0xd64c('0x17'));var licenseUtil=require(_0xd64c('0x18'));var db=require(_0xd64c('0x19'))['db'];function respondWithStatusCode(_0x319908,_0x103979){_0x103979=_0x103979||0xcc;return function(_0x48345e){if(_0x48345e){return _0x319908[_0xd64c('0x1a')](_0x103979);}return _0x319908['status'](_0x103979)[_0xd64c('0x1b')]();};}function respondWithResult(_0x3b14b0,_0x2dd345){_0x2dd345=_0x2dd345||0xc8;return function(_0x3dc136){if(_0x3dc136){return _0x3b14b0[_0xd64c('0x1c')](_0x2dd345)[_0xd64c('0x1d')](_0x3dc136);}};}function respondWithFilteredResult(_0x386c3d,_0x338f3e){return function(_0x5ee4f1){if(_0x5ee4f1){var _0x5a9ba2=typeof _0x338f3e[_0xd64c('0x1e')]===_0xd64c('0x1f')&&typeof _0x338f3e[_0xd64c('0x20')]===_0xd64c('0x1f');var _0x12a5d1=_0x5ee4f1[_0xd64c('0x21')];var _0x35b26c=_0x5a9ba2?0x0:_0x338f3e[_0xd64c('0x1e')];var _0x12d925=_0x5a9ba2?_0x5ee4f1[_0xd64c('0x21')]:_0x338f3e['offset']+_0x338f3e[_0xd64c('0x20')];var _0x444bb0;if(_0x12d925>=_0x12a5d1){_0x12d925=_0x12a5d1;_0x444bb0=0xc8;}else{_0x444bb0=0xce;}_0x386c3d['status'](_0x444bb0);return _0x386c3d[_0xd64c('0x22')](_0xd64c('0x23'),_0x35b26c+'-'+_0x12d925+'/'+_0x12a5d1)['json'](_0x5ee4f1);}return null;};}function patchUpdates(_0x333f0b){return function(_0x5c8274){try{jsonpatch[_0xd64c('0x24')](_0x5c8274,_0x333f0b,!![]);}catch(_0x27187b){return BPromise[_0xd64c('0x25')](_0x27187b);}return _0x5c8274['save']();};}function saveUpdates(_0x2a0e42,_0xbab4d9){return function(_0x2b9587){if(_0x2b9587){return _0x2b9587[_0xd64c('0x26')](_0x2a0e42)[_0xd64c('0x27')](function(_0x5873d4){return _0x5873d4;});}return null;};}function removeEntity(_0x4e491e,_0x203729){return function(_0x1d5c71){if(_0x1d5c71){return _0x1d5c71[_0xd64c('0x28')]()[_0xd64c('0x27')](function(){_0x4e491e[_0xd64c('0x1c')](0xcc)[_0xd64c('0x1b')]();});}};}function handleEntityNotFound(_0x24961a,_0x166385){return function(_0x3af946){if(!_0x3af946){_0x24961a['sendStatus'](0x194);}return _0x3af946;};}function handleError(_0x4e1d06,_0x5965ec){_0x5965ec=_0x5965ec||0x1f4;return function(_0x22bb01){logger[_0xd64c('0x29')](_0x22bb01['stack']);if(_0x22bb01[_0xd64c('0x2a')]){delete _0x22bb01[_0xd64c('0x2a')];}_0x4e1d06[_0xd64c('0x1c')](_0x5965ec)['send'](_0x22bb01);};}exports[_0xd64c('0x2b')]=function(_0x28f512,_0x291bc2){var _0x61b320={},_0x5b9340={},_0x21ba65={'count':0x0,'rows':[]};var _0x5adfea=_[_0xd64c('0x2c')](db[_0xd64c('0x2d')][_0xd64c('0x2e')],function(_0x13c820){return{'name':_0x13c820['fieldName'],'type':_0x13c820[_0xd64c('0x2f')][_0xd64c('0x30')]};});_0x5b9340['model']=_[_0xd64c('0x2c')](_0x5adfea,_0xd64c('0x2a'));_0x5b9340[_0xd64c('0x31')]=_[_0xd64c('0x32')](_0x28f512[_0xd64c('0x31')]);_0x5b9340[_0xd64c('0x33')]=_['intersection'](_0x5b9340[_0xd64c('0x34')],_0x5b9340[_0xd64c('0x31')]);_0x61b320[_0xd64c('0x35')]=_['intersection'](_0x5b9340[_0xd64c('0x34')],qs[_0xd64c('0x36')](_0x28f512[_0xd64c('0x31')][_0xd64c('0x36')]));_0x61b320['attributes']=_0x61b320[_0xd64c('0x35')]['length']?_0x61b320[_0xd64c('0x35')]:_0x5b9340[_0xd64c('0x34')];if(!_0x28f512['query']['hasOwnProperty'](_0xd64c('0x37'))){_0x61b320[_0xd64c('0x20')]=qs[_0xd64c('0x20')](_0x28f512[_0xd64c('0x31')][_0xd64c('0x20')]);_0x61b320['offset']=qs[_0xd64c('0x1e')](_0x28f512['query'][_0xd64c('0x1e')]);}_0x61b320[_0xd64c('0x38')]=qs[_0xd64c('0x39')](_0x28f512[_0xd64c('0x31')][_0xd64c('0x39')]);_0x61b320[_0xd64c('0x3a')]=qs[_0xd64c('0x33')](_[_0xd64c('0x3b')](_0x28f512[_0xd64c('0x31')],_0x5b9340['filters']),_0x5adfea);if(_0x28f512[_0xd64c('0x31')][_0xd64c('0x3c')]){_0x61b320[_0xd64c('0x3a')]=_[_0xd64c('0x3d')](_0x61b320[_0xd64c('0x3a')],{'$or':_['map'](_0x5adfea,function(_0x249f03){if(_0x249f03['type']!==_0xd64c('0x3e')){var _0x49e13e={};_0x49e13e[_0x249f03[_0xd64c('0x2a')]]={'$like':'%'+_0x28f512[_0xd64c('0x31')][_0xd64c('0x3c')]+'%'};return _0x49e13e;}})});}_0x61b320=_[_0xd64c('0x3d')]({},_0x61b320,_0x28f512[_0xd64c('0x3f')]);var _0x18a47f={'where':_0x61b320[_0xd64c('0x3a')]};return db[_0xd64c('0x2d')][_0xd64c('0x21')](_0x18a47f)['then'](function(_0xa961a6){_0x21ba65[_0xd64c('0x21')]=_0xa961a6;if(_0x28f512['query'][_0xd64c('0x40')]){_0x61b320[_0xd64c('0x41')]=[{'all':!![]}];}return db[_0xd64c('0x2d')][_0xd64c('0x42')](_0x61b320);})[_0xd64c('0x27')](function(_0x18f5f6){_0x21ba65[_0xd64c('0x43')]=_0x18f5f6;return _0x21ba65;})[_0xd64c('0x27')](respondWithFilteredResult(_0x291bc2,_0x61b320))[_0xd64c('0x44')](handleError(_0x291bc2,null));};exports[_0xd64c('0x45')]=function(_0x1584af,_0x56b1ab){var _0x523f6c={'raw':!![],'where':{'id':_0x1584af[_0xd64c('0x46')]['id']}},_0x207b9d={};_0x207b9d[_0xd64c('0x34')]=_[_0xd64c('0x32')](db['WhatsappTransferReport'][_0xd64c('0x2e')]);_0x207b9d['query']=_[_0xd64c('0x32')](_0x1584af[_0xd64c('0x31')]);_0x207b9d[_0xd64c('0x33')]=_[_0xd64c('0x47')](_0x207b9d[_0xd64c('0x34')],_0x207b9d['query']);_0x523f6c['attributes']=_[_0xd64c('0x47')](_0x207b9d[_0xd64c('0x34')],qs[_0xd64c('0x36')](_0x1584af[_0xd64c('0x31')][_0xd64c('0x36')]));_0x523f6c['attributes']=_0x523f6c[_0xd64c('0x35')][_0xd64c('0x48')]?_0x523f6c['attributes']:_0x207b9d[_0xd64c('0x34')];if(_0x1584af[_0xd64c('0x31')][_0xd64c('0x40')]){_0x523f6c[_0xd64c('0x41')]=[{'all':!![]}];}_0x523f6c=_['merge']({},_0x523f6c,_0x1584af[_0xd64c('0x3f')]);return db[_0xd64c('0x2d')][_0xd64c('0x49')](_0x523f6c)[_0xd64c('0x27')](handleEntityNotFound(_0x56b1ab,null))['then'](respondWithResult(_0x56b1ab,null))[_0xd64c('0x44')](handleError(_0x56b1ab,null));};exports[_0xd64c('0x4a')]=function(_0x965e2e,_0x40ac78){return db[_0xd64c('0x2d')][_0xd64c('0x4a')](_0x965e2e[_0xd64c('0x4b')],{})[_0xd64c('0x27')](respondWithResult(_0x40ac78,0xc9))[_0xd64c('0x44')](handleError(_0x40ac78,null));};exports[_0xd64c('0x26')]=function(_0x19c2ba,_0x1ae56f){if(_0x19c2ba[_0xd64c('0x4b')]['id']){delete _0x19c2ba['body']['id'];}return db[_0xd64c('0x2d')][_0xd64c('0x49')]({'where':{'id':_0x19c2ba[_0xd64c('0x46')]['id']}})[_0xd64c('0x27')](handleEntityNotFound(_0x1ae56f,null))[_0xd64c('0x27')](saveUpdates(_0x19c2ba[_0xd64c('0x4b')],null))[_0xd64c('0x27')](respondWithResult(_0x1ae56f,null))['catch'](handleError(_0x1ae56f,null));};exports[_0xd64c('0x28')]=function(_0x417701,_0x585c95){return db[_0xd64c('0x2d')]['find']({'where':{'id':_0x417701[_0xd64c('0x46')]['id']}})[_0xd64c('0x27')](handleEntityNotFound(_0x585c95,null))['then'](removeEntity(_0x585c95,null))[_0xd64c('0x44')](handleError(_0x585c95,null));};exports[_0xd64c('0x4c')]=function(_0x557d41,_0x2d7eb1){return db[_0xd64c('0x2d')][_0xd64c('0x4c')]()[_0xd64c('0x27')](respondWithResult(_0x2d7eb1,null))['catch'](handleError(_0x2d7eb1,null));}; \ No newline at end of file diff --git a/server/api/whatsappTransferReport/whatsappTransferReport.model.js b/server/api/whatsappTransferReport/whatsappTransferReport.model.js new file mode 100644 index 0000000..2bac978 --- /dev/null +++ b/server/api/whatsappTransferReport/whatsappTransferReport.model.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x81ee=['path','rimraf','../../config/environment','./whatsappTransferReport.attributes','exports','define','WhatsappTransferReport','report_whatsapp_transfer','uniqueid','lodash','util','../../config/logger','request-promise'];(function(_0x2c602e,_0x1d26f5){var _0x1a2650=function(_0x2370d1){while(--_0x2370d1){_0x2c602e['push'](_0x2c602e['shift']());}};_0x1a2650(++_0x1d26f5);}(_0x81ee,0x18f));var _0xe81e=function(_0x2e4926,_0x5cb287){_0x2e4926=_0x2e4926-0x0;var _0x136495=_0x81ee[_0x2e4926];return _0x136495;};'use strict';var _=require(_0xe81e('0x0'));var util=require(_0xe81e('0x1'));var logger=require(_0xe81e('0x2'))('api');var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xe81e('0x3'));var fs=require('fs');var path=require(_0xe81e('0x4'));var rimraf=require(_0xe81e('0x5'));var config=require(_0xe81e('0x6'));var attributes=require(_0xe81e('0x7'));module[_0xe81e('0x8')]=function(_0x5f1405,_0x406517){return _0x5f1405[_0xe81e('0x9')](_0xe81e('0xa'),attributes,{'tableName':_0xe81e('0xb'),'paranoid':![],'indexes':[{'name':'uniqueid','fields':[_0xe81e('0xc')]}],'timestamps':!![]});}; \ No newline at end of file diff --git a/server/api/whatsappTransferReport/whatsappTransferReport.rpc.js b/server/api/whatsappTransferReport/whatsappTransferReport.rpc.js new file mode 100644 index 0000000..c4031d4 --- /dev/null +++ b/server/api/whatsappTransferReport/whatsappTransferReport.rpc.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x96d3=['stringify','error','code','message','result','catch','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','request','then','info','WhatsappTransferReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappTransferReport,\x20%s,\x20%s,\x20%s'];(function(_0x21eee5,_0x23fdbe){var _0x2ab31e=function(_0x34dcfb){while(--_0x34dcfb){_0x21eee5['push'](_0x21eee5['shift']());}};_0x2ab31e(++_0x23fdbe);}(_0x96d3,0xa7));var _0x396d=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0x96d3[_0x167cc1];return _0x10bc4b;};'use strict';var _=require('lodash');var util=require(_0x396d('0x0'));var moment=require(_0x396d('0x1'));var BPromise=require('bluebird');var rs=require(_0x396d('0x2'));var fs=require('fs');var Redis=require(_0x396d('0x3'));var db=require(_0x396d('0x4'))['db'];var utils=require(_0x396d('0x5'));var logger=require('../../config/logger')(_0x396d('0x6'));var config=require('../../config/environment');var jayson=require(_0x396d('0x7'));var client=jayson[_0x396d('0x8')][_0x396d('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xabb588,_0x49074f,_0x4b6f7c){return new BPromise(function(_0x3fc777,_0x29d8b0){return client[_0x396d('0xa')](_0xabb588,_0x4b6f7c)[_0x396d('0xb')](function(_0xa96448){logger[_0x396d('0xc')](_0x396d('0xd'),_0x49074f,_0x396d('0xe'));logger[_0x396d('0xf')](_0x396d('0x10'),_0x49074f,_0x396d('0xe'),JSON[_0x396d('0x11')](_0xa96448));if(_0xa96448[_0x396d('0x12')]){if(_0xa96448[_0x396d('0x12')][_0x396d('0x13')]===0x1f4){logger[_0x396d('0x12')]('WhatsappTransferReport,\x20%s,\x20%s',_0x49074f,_0xa96448[_0x396d('0x12')][_0x396d('0x14')]);return _0x29d8b0(_0xa96448['error']['message']);}logger['error'](_0x396d('0xd'),_0x49074f,_0xa96448[_0x396d('0x12')][_0x396d('0x14')]);return _0x3fc777(_0xa96448['error'][_0x396d('0x14')]);}else{logger[_0x396d('0xc')](_0x396d('0xd'),_0x49074f,_0x396d('0xe'));_0x3fc777(_0xa96448[_0x396d('0x15')][_0x396d('0x14')]);}})[_0x396d('0x16')](function(_0xcf5db6){logger[_0x396d('0x12')](_0x396d('0xd'),_0x49074f,_0xcf5db6);_0x29d8b0(_0xcf5db6);});});} \ No newline at end of file diff --git a/server/app.js b/server/app.js new file mode 100644 index 0000000..f990666 --- /dev/null +++ b/server/app.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0e17=['\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','online','join','Offline\x20apps:','status','None','log','App\x20Ready!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./mysqldb','./config/seedDB','./config/license','./rpc','./config/environment','./config/logger','app','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','sync','then','seedDB','default','listen','info','start','filter','exitCode','number','length'];(function(_0x5d80de,_0x2cf15d){var _0x1c7556=function(_0x5bd806){while(--_0x5bd806){_0x5d80de['push'](_0x5d80de['shift']());}};_0x1c7556(++_0x2cf15d);}(_0x0e17,0xd6));var _0x70e1=function(_0x27f981,_0x9517ef){_0x27f981=_0x27f981-0x0;var _0x574d9f=_0x0e17[_0x27f981];return _0x574d9f;};'use strict';var _=require(_0x70e1('0x0'));var db=require(_0x70e1('0x1'))['db'];var seedDb=require(_0x70e1('0x2'));var checkLicense=require(_0x70e1('0x3'));var rpc=require(_0x70e1('0x4'));var config=require(_0x70e1('0x5'));var logger=require(_0x70e1('0x6'))(_0x70e1('0x7'));var pm2=require(_0x70e1('0x8'));var pm2Config=require(_0x70e1('0x9'));var schedule=require(_0x70e1('0xa'));var chat=require(_0x70e1('0xb'));var whatsapp=require('./config/schedule/whatsapp');var transcribe=require(_0x70e1('0xc'));var provider=require(_0x70e1('0xd'));function main(){return db[_0x70e1('0xe')][_0x70e1('0xf')]()[_0x70e1('0x10')](function(){if(config[_0x70e1('0x11')]){return seedDb['default']();}})['then'](function(){return checkLicense[_0x70e1('0x12')]();})['then'](function(){return rpc[_0x70e1('0x13')]();})[_0x70e1('0x10')](function(_0x556483){logger[_0x70e1('0x14')](_0x556483);return chat[_0x70e1('0x15')]();})['then'](function(){return whatsapp[_0x70e1('0x15')]();})['then'](function(){return schedule[_0x70e1('0x15')]();})['then'](function(){return transcribe[_0x70e1('0x15')]();})[_0x70e1('0x10')](function(){return provider[_0x70e1('0x15')]();})[_0x70e1('0x10')](function(_0x2949db){logger[_0x70e1('0x14')](_0x2949db);return pm2[_0x70e1('0x15')](pm2Config);})[_0x70e1('0x10')](function(_0xf824e){var _0x385fc7=_0xf824e[_0x70e1('0x16')](function(_0x491c9c){return typeof _0x491c9c[_0x70e1('0x17')]===_0x70e1('0x18')&&_0x491c9c[_0x70e1('0x17')]>=0x0;});if(_0x385fc7[_0x70e1('0x19')]>0x0){throw new Error(_0x385fc7[_0x70e1('0x19')]+_0x70e1('0x1a')+_[_0x70e1('0x1b')](_0x385fc7,function(_0x178441){return'\x22'+_0x178441[_0x70e1('0x1c')][_0x70e1('0x1d')]+'\x22';}));}logger[_0x70e1('0x14')]('Online\x20apps:',_['map'](_[_0x70e1('0x16')](_0xf824e,{'status':_0x70e1('0x1e')}),_0x70e1('0x1d'))[_0x70e1('0x1f')]());logger[_0x70e1('0x14')](_0x70e1('0x20'),_[_0x70e1('0x1b')](_[_0x70e1('0x16')](_0xf824e,function(_0xdb1503){return _0xdb1503[_0x70e1('0x21')]!==_0x70e1('0x1e');}),_0x70e1('0x1d'))[_0x70e1('0x1f')]()||_0x70e1('0x22'));console[_0x70e1('0x23')](_0x70e1('0x24'));})['catch'](function(_0x34f89d){console['log']('Server\x20failed\x20to\x20start\x20due\x20to\x20error!',_0x34f89d);logger[_0x70e1('0x25')](_0x70e1('0x26'),_0x34f89d);process[_0x70e1('0x27')](0x1);});}main(); \ No newline at end of file diff --git a/server/components/auth/service.js b/server/components/auth/service.js new file mode 100644 index 0000000..0b5dd23 --- /dev/null +++ b/server/components/auth/service.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9bde=['whatsappAutoanswerDelay','isChatInteractionAuthorized','use','user','ChatInteraction','params','closed','disposition','then','status','unmanaged','Forbidden.','catch','isAuthenticated','headers','authorization','startsWith','User','find','authenticate','pass','json','Bearer','Unknown\x20authorization\x20format','query','apikey','getUuid','sub','Setting','findOne','blockDuration','apiKeyNonce','nonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','disabled','blocked','blockedAt','add','minutes','Invalid\x20API\x20access\x20key','User\x20not\x20found.','User\x20object\x20not\x20found.','canUpdate','getLicense','Forbidden','isWebrtcLicence','webrtc','signToken','setTokenCookie','It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.','motion.token','redirect','send','isNil','generateApiKey','regenerateApiKey','apiKeyIat','Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one','validatePasswordPattern','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','decryptString','split','toLowerCase','format','The\x20password\x20must\x20be\x20different\x20from\x20the\x20previous\x20%d\x20passwords.\x20Please\x20choose\x20another\x20one.','The\x20password\x20must\x20be\x20different\x20from\x20the\x20last\x20one.\x20Please\x20choose\x20another\x20one.','updatePasswordsHistory','length','unshift','encryptString','join','sign','secret','payload','options','promisify','verify','randomBytes','toString','hex','floor','now','HS512','../../config/environment','../../config/license/util','lodash','jsonwebtoken','express-jwt','composable-middleware','basic-auth','crypto','bluebird','moment','secrets','session','role','fullname','name','internal','email','userpic','permissions','chatPause','mailPause','faxPause','openchannelPause','pauseType','showWebBar','lastLoginAt','crudPermissions','passwordResetAt','alias','phoneBarAutoAnswer','phoneBarEnableRecording','phoneBarEnableDtmfTone','phoneBarEnableSettings','phoneBarExpires','phoneBarPrefixRequired','phoneBarRemoteControl','phoneBarRemoteControlPort','interface','userProfileId','privacyEnabled','wssPort','downloadVoiceRecordings','downloadOmnichannelInteractions','downloadAttachments','selectRecallMeCampaign','chatAutoanswerDelay','emailAutoanswerDelay','smsAutoanswer','smsAutoanswerDelay','openchannelAutoanswer','openchannelAutoanswerDelay','faxAutoanswer','faxAutoanswerDelay'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x9bde,0xe1));var _0xe9bd=function(_0x26ef6f,_0x431f07){_0x26ef6f=_0x26ef6f-0x0;var _0x279352=_0x9bde[_0x26ef6f];return _0x279352;};'use strict';var db=require('../../mysqldb')['db'];var config=require(_0xe9bd('0x0'));var hardwareConf=require('../../config/license/hardware');var licenseUtil=require(_0xe9bd('0x1'));var encryptor=require('../encryptor');var _=require(_0xe9bd('0x2'));var jwt=require(_0xe9bd('0x3'));var expressJwt=require(_0xe9bd('0x4'));var compose=require(_0xe9bd('0x5'));var basicAuth=require(_0xe9bd('0x6'));var crypto=require(_0xe9bd('0x7'));var BPromise=require(_0xe9bd('0x8'));var util=require('util');var moment=require(_0xe9bd('0x9'));var validateJwt=expressJwt({'secret':config[_0xe9bd('0xa')][_0xe9bd('0xb')]});var userAttributes=['id',_0xe9bd('0xc'),_0xe9bd('0xd'),_0xe9bd('0xe'),_0xe9bd('0xf'),_0xe9bd('0x10'),_0xe9bd('0x11'),_0xe9bd('0x12'),'md5secret','voicePause',_0xe9bd('0x13'),_0xe9bd('0x14'),_0xe9bd('0x15'),'smsPause',_0xe9bd('0x16'),_0xe9bd('0x17'),_0xe9bd('0x18'),_0xe9bd('0x19'),'lastPauseAt',_0xe9bd('0x1a'),'allowmessenger',_0xe9bd('0x1b'),_0xe9bd('0x1c'),_0xe9bd('0x1d'),'phoneBarAutoAnswerDelay','phoneBarDnd',_0xe9bd('0x1e'),_0xe9bd('0x1f'),_0xe9bd('0x20'),_0xe9bd('0x21'),_0xe9bd('0x22'),_0xe9bd('0x23'),_0xe9bd('0x24'),'hotdesk',_0xe9bd('0x25'),_0xe9bd('0x26'),_0xe9bd('0x27'),'settingsEnabled',_0xe9bd('0x28'),_0xe9bd('0x29'),_0xe9bd('0x2a'),_0xe9bd('0x2b'),'ignorePauseForPreviewCalls',_0xe9bd('0x2c'),'chatAutoanswer',_0xe9bd('0x2d'),'emailAutoanswer',_0xe9bd('0x2e'),_0xe9bd('0x2f'),_0xe9bd('0x30'),_0xe9bd('0x31'),_0xe9bd('0x32'),_0xe9bd('0x33'),_0xe9bd('0x34'),'whatsappAutoanswer',_0xe9bd('0x35')];exports[_0xe9bd('0x36')]=function(){return this['isAuthenticated'](!![])[_0xe9bd('0x37')](function(_0x505c23,_0x238ab1,_0x1b9cc9){if(_0x505c23[_0xe9bd('0x38')]){_0x1b9cc9();}else{return db[_0xe9bd('0x39')]['findOne']({'where':{'id':_0x505c23[_0xe9bd('0x3a')]['id']},'attributes':['id',_0xe9bd('0x3b'),_0xe9bd('0x3c')],'raw':!![]})[_0xe9bd('0x3d')](function(_0x2641be){if(_0x2641be&&_0x2641be[_0xe9bd('0x3b')]){return _0x238ab1[_0xe9bd('0x3e')](_0x2641be[_0xe9bd('0x3c')]===_0xe9bd('0x3f')?0x195:0x193)['json']({'message':_0x2641be[_0xe9bd('0x3c')]===_0xe9bd('0x3f')?'Unmanaged.':_0xe9bd('0x40')});}else{_0x1b9cc9();}})[_0xe9bd('0x41')](function(_0x119672){_0x1b9cc9(_0x119672);});}});};exports[_0xe9bd('0x42')]=function isAuthenticated(_0x141b95){return compose()[_0xe9bd('0x37')](function(_0x519f48,_0x5b7f1d,_0x1de54c){var _0x56e409;if(_0x519f48[_0xe9bd('0x43')][_0xe9bd('0x44')]){if(_[_0xe9bd('0x45')](_0x519f48[_0xe9bd('0x43')][_0xe9bd('0x44')],'Basic')){var _0x4b7bc2=basicAuth(_0x519f48);db[_0xe9bd('0x46')][_0xe9bd('0x47')]({'where':{'name':_0x4b7bc2[_0xe9bd('0xe')]}})[_0xe9bd('0x3d')](function(_0xe2436){if(!_0xe2436||!_0xe2436[_0xe9bd('0x48')](_0x4b7bc2[_0xe9bd('0x49')])){return _0x5b7f1d[_0xe9bd('0x3e')](0x191)[_0xe9bd('0x4a')]({'message':'Wrong\x20credentials.'});}_0x519f48[_0xe9bd('0x38')]={'id':_0xe2436['id']};_0x1de54c();})[_0xe9bd('0x41')](function(_0x390a43){_0x1de54c(_0x390a43);});}else if(_['startsWith'](_0x519f48['headers'][_0xe9bd('0x44')],_0xe9bd('0x4b'))){validateJwt(_0x519f48,_0x5b7f1d,_0x1de54c);}else{if(_0x141b95){_0x1de54c();}else{return _0x5b7f1d[_0xe9bd('0x3e')](0x193)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x4c')});}}}else if(_0x519f48[_0xe9bd('0x4d')][_0xe9bd('0x4e')]){try{var _0x1c6173={'audience':hardwareConf[_0xe9bd('0x4f')](),'issuer':hardwareConf[_0xe9bd('0x4f')]()};verifyJwt(_0x519f48[_0xe9bd('0x4d')][_0xe9bd('0x4e')],_0x1c6173)[_0xe9bd('0x3d')](function(_0x199477){return db[_0xe9bd('0x46')][_0xe9bd('0x47')]({'where':{'id':_0x199477[_0xe9bd('0x50')]}})[_0xe9bd('0x3d')](function(_0x4c689d){_0x56e409=_0x4c689d;return db[_0xe9bd('0x51')][_0xe9bd('0x52')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0xe9bd('0x53')],'raw':!![]});})[_0xe9bd('0x3d')](function(_0x4c7d47){if(!_0x56e409||!_['isEqual'](_0x56e409[_0xe9bd('0x54')],_0x199477[_0xe9bd('0x55')])){return _0x5b7f1d['status'](0x191)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x56')});}if(_0x56e409[_0xe9bd('0x57')]){return _0x5b7f1d['status'](0x191)[_0xe9bd('0x4a')]({'message':'Invalid\x20API\x20access\x20key'});}if(_0x56e409[_0xe9bd('0x58')]){if(_0x4c7d47[_0xe9bd('0x53')]>0x0){if(moment(_0x56e409[_0xe9bd('0x59')])[_0xe9bd('0x5a')](_0x4c7d47['blockDuration'],_0xe9bd('0x5b'))>moment()){return _0x5b7f1d[_0xe9bd('0x3e')](0x191)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x5c')});}}else{return _0x5b7f1d[_0xe9bd('0x3e')](0x191)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x5c')});}}_0x519f48[_0xe9bd('0x38')]={'id':_0x56e409['id']};_0x1de54c();});})[_0xe9bd('0x41')](function(){return _0x5b7f1d[_0xe9bd('0x3e')](0x191)['json']({'message':'Invalid\x20API\x20access\x20key'});});}catch(_0xcf9a0c){_0x1de54c(_0xcf9a0c);}}else if(_0x141b95){_0x1de54c();}else{return _0x5b7f1d['status'](0x193)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x4c')});}})[_0xe9bd('0x37')](function(_0x480797,_0x1ba613,_0x2923cf){if(_0x480797[_0xe9bd('0x38')]){db['User'][_0xe9bd('0x47')]({'where':{'id':_0x480797[_0xe9bd('0x38')]['id']},'attributes':userAttributes})[_0xe9bd('0x3d')](function(_0x388132){if(!_0x388132){return _0x1ba613[_0xe9bd('0x3e')](0x194)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x5d')});}_0x480797[_0xe9bd('0x38')]=_0x388132;_0x2923cf();})[_0xe9bd('0x41')](function(_0x300e07){_0x2923cf(_0x300e07);});}else if(_0x141b95){_0x2923cf();}else{return _0x1ba613[_0xe9bd('0x3e')](0x194)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x5e')});}});};exports[_0xe9bd('0x5f')]=function canUpdate(){return compose()[_0xe9bd('0x37')](function(_0x5b70d3,_0x5a86fd,_0x283e67){return licenseUtil[_0xe9bd('0x60')]()[_0xe9bd('0x3d')](function(_0x58828b){if(_0x58828b['update']){_0x283e67();}else{return _0x5a86fd[_0xe9bd('0x3e')](0x193)[_0xe9bd('0x4a')]({'message':_0xe9bd('0x61')});}})[_0xe9bd('0x41')](function(_0x39fb61){_0x283e67(_0x39fb61);});});};exports[_0xe9bd('0x62')]=function isWebrtcLicence(){return compose()[_0xe9bd('0x37')](function(_0x512899,_0x1e45fc,_0x4cc146){return licenseUtil[_0xe9bd('0x60')]()[_0xe9bd('0x3d')](function(_0x33ba69){if(_0x33ba69[_0xe9bd('0x63')]){_0x4cc146();}else{return _0x1e45fc[_0xe9bd('0x3e')](0x193)['json']({'message':_0xe9bd('0x61')});}})[_0xe9bd('0x41')](function(_0xe14fa4){_0x4cc146(_0xe14fa4);});});};exports['isMiddleware']=function(_0xff4e14,_0x476f23,_0x34f787){_0xff4e14['isMiddleware']=!![];return _0x34f787();};exports[_0xe9bd('0x64')]=function signToken(_0x27e7b0){return signJwt(_0x27e7b0);};exports[_0xe9bd('0x65')]=function(_0x10ec29,_0x1ee09c){if(!_0x10ec29['user']){return _0x1ee09c[_0xe9bd('0x3e')](0x194)['json']({'message':_0xe9bd('0x66')});}var _0x239be9={'payload':{'id':_0x10ec29[_0xe9bd('0x38')]['id'],'role':_0x10ec29[_0xe9bd('0x38')][_0xe9bd('0xc')]},'options':{'expiresIn':0x15180}};return signJwt(_0x239be9)['then'](function(_0x15d1d0){_0x1ee09c['cookie'](_0xe9bd('0x67'),_0x15d1d0);_0x1ee09c[_0xe9bd('0x68')]('/dashboards/general');})['catch'](function(_0x1ce539){return _0x1ee09c['status'](0x1f4)[_0xe9bd('0x69')](_0x1ce539);});};exports['retrieveApiKey']=function(_0x26b25a){if(_[_0xe9bd('0x6a')](_0x26b25a['apiKeyNonce'])||_[_0xe9bd('0x6a')](_0x26b25a['apiKeyIat'])){return null;}else{return createJwt(_0x26b25a);}};exports[_0xe9bd('0x6b')]=function(_0x2d9a94){_0x2d9a94[_0xe9bd('0x54')]=generateNonce();_0x2d9a94['apiKeyIat']=generateIssuedAt();return createJwt(_0x2d9a94);};exports[_0xe9bd('0x6c')]=function(_0x1d703f,_0x45b69e){var _0x232a36=_0x1d703f['query']['apikey'];if(_0x232a36){var _0x441f89={'nonce':_0x45b69e['apiKeyNonce'],'iat':_0x45b69e[_0xe9bd('0x6d')],'audience':hardwareConf[_0xe9bd('0x4f')](),'issuer':hardwareConf[_0xe9bd('0x4f')]()};return verifyJwt(_0x232a36,_0x441f89)[_0xe9bd('0x3d')](function(){return generateApiKey(_0x45b69e);});}else{throw{'message':_0xe9bd('0x6e')};}};exports[_0xe9bd('0x6f')]=function(_0x373057){var _0x3381ee=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x3381ee[_0xe9bd('0x70')](_0x373057))throw new db[(_0xe9bd('0x71'))][(_0xe9bd('0x72'))](_0xe9bd('0x73'));return;};exports['validatePasswordHistory']=function(_0x596a7d,_0x566dd8,_0x10e685){var _0x5a516e=encryptor[_0xe9bd('0x74')](_0x566dd8)[_0xe9bd('0x75')](',');for(var _0x90db01=0x0;_0x90db01<_0x10e685;_0x90db01++){if(!_0x5a516e[_0x90db01])break;if(_0x596a7d[_0xe9bd('0x76')]()===_0x5a516e[_0x90db01][_0xe9bd('0x76')]()){var _0xaf6ffd=util[_0xe9bd('0x77')](_0xe9bd('0x78'),_0x10e685);if(_0x10e685===0x1){_0xaf6ffd=_0xe9bd('0x79');}throw new db['Sequelize'][(_0xe9bd('0x72'))](_0xaf6ffd);}}return;};exports[_0xe9bd('0x7a')]=function(_0x3d3e74,_0x3f848d){var _0x4d58c1=_0x3f848d?encryptor[_0xe9bd('0x74')](_0x3f848d)[_0xe9bd('0x75')](','):[];if(_0x4d58c1[_0xe9bd('0x7b')]===0x5){_0x4d58c1['splice'](-0x1,0x1);}_0x4d58c1[_0xe9bd('0x7c')](_0x3d3e74);return encryptor[_0xe9bd('0x7d')](_0x4d58c1[_0xe9bd('0x7e')](','));};function signJwt(_0xfe82f7){var _0x4ee26a=BPromise['promisify'](jwt[_0xe9bd('0x7f')],{'context':jwt});var _0x188891=_0xfe82f7[_0xe9bd('0x80')]||config[_0xe9bd('0xa')]['session'];return new BPromise(function(_0x49add9,_0x305efa){_0x4ee26a(_0xfe82f7[_0xe9bd('0x81')],_0x188891,_0xfe82f7[_0xe9bd('0x82')])[_0xe9bd('0x3d')](function(_0x1fd2b5){_0x49add9(_0x1fd2b5);})[_0xe9bd('0x41')](function(_0x4870f8){_0x305efa(_0x4870f8);});});}function verifyJwt(_0x179c8d,_0x5681ab,_0x27e07c){var _0x28dd03=BPromise[_0xe9bd('0x83')](jwt[_0xe9bd('0x84')],{'context':jwt});var _0x5bc1f8=_0x27e07c||config[_0xe9bd('0xa')][_0xe9bd('0xb')];return new BPromise(function(_0x3b0190,_0x4f35c4){_0x28dd03(_0x179c8d,_0x5bc1f8,_0x5681ab)[_0xe9bd('0x3d')](function(_0x1a9d0c){_0x3b0190(_0x1a9d0c);})[_0xe9bd('0x41')](function(_0x3e3e05){_0x4f35c4(_0x3e3e05);});});}function generateNonce(){return crypto[_0xe9bd('0x85')](0x10)[_0xe9bd('0x86')](_0xe9bd('0x87'));}function generateIssuedAt(){return Math[_0xe9bd('0x88')](Date[_0xe9bd('0x89')]()/0x3e8)[_0xe9bd('0x86')]();}function createJwt(_0x14c599){var _0x37d07a={'payload':{'iat':_0x14c599['apiKeyIat'],'nonce':_0x14c599[_0xe9bd('0x54')]},'options':{'algorithm':_0xe9bd('0x8a'),'subject':_0x14c599['id']['toString'](),'issuer':hardwareConf[_0xe9bd('0x4f')](),'audience':hardwareConf[_0xe9bd('0x4f')]()}};return signJwt(_0x37d07a)['then'](function(_0x561165){return{'iat':_0x14c599[_0xe9bd('0x6d')],'nonce':_0x14c599[_0xe9bd('0x54')],'token':_0x561165};});} \ No newline at end of file diff --git a/server/components/contacts/index.js b/server/components/contacts/index.js new file mode 100644 index 0000000..3d949b9 --- /dev/null +++ b/server/components/contacts/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0b0e=['tags','skip','tag','count','getFilteredContacts','catch','CmContact','keys','cf_','map','findOne','all','length','type','lodash','../../mysqldb','skipContactsQuery','resolve','getContactsSubquery','then','search','parseAdvancedSearchFilter','parseQueryParameters','where','default','fields','filter','user','clause'];(function(_0x3a3c80,_0x3b403a){var _0x29d920=function(_0x519764){while(--_0x519764){_0x3a3c80['push'](_0x3a3c80['shift']());}};_0x29d920(++_0x3b403a);}(_0x0b0e,0x187));var _0xe0b0=function(_0x1ad07b,_0x551d55){_0x1ad07b=_0x1ad07b-0x0;var _0x2c447f=_0x0b0e[_0x1ad07b];return _0x2c447f;};'use strict';var _=require(_0xe0b0('0x0'));var sqlUtils=require('./sql-utils');var db=require(_0xe0b0('0x1'))['db'];exports['findAll']=function(_0x7e5a8a,_0xdf715e,_0x3b5e2b,_0x25153a){var _0x28040c={'count':0x0,'rows':[]};var _0x38a058=sqlUtils[_0xe0b0('0x2')](_0xdf715e,_0x7e5a8a);if(_0x38a058){return Promise[_0xe0b0('0x3')](_0x28040c);}var _0x30e20d=sqlUtils[_0xe0b0('0x4')]();var _0x219b1c={};var _0x5cf9cc=![];var _0x50be7f=![];return Promise[_0xe0b0('0x3')]()[_0xe0b0('0x5')](function(){if(_0x7e5a8a[_0xe0b0('0x6')]){return sqlUtils[_0xe0b0('0x7')](_0x7e5a8a['search'],_0x25153a);}else{return sqlUtils[_0xe0b0('0x8')](_0x7e5a8a,_0x25153a);}})[_0xe0b0('0x5')](function(_0x553d4f){_0x30e20d[_0xe0b0('0x9')](_0x553d4f[_0xe0b0('0xa')]);_0x30e20d['where'](_0x553d4f[_0xe0b0('0xb')]);_0x30e20d[_0xe0b0('0x9')](_0x553d4f[_0xe0b0('0xc')]);_0x30e20d['where'](_0x553d4f[_0xe0b0('0xd')][_0xe0b0('0xe')]);_0x219b1c=_0x553d4f[_0xe0b0('0xf')];_0x50be7f=_0x553d4f[_0xe0b0('0xd')][_0xe0b0('0x10')];return sqlUtils['checkListsRestrictions'](_0xdf715e,_0x7e5a8a,_0x50be7f);})[_0xe0b0('0x5')](function(_0x154de6){_0x30e20d[_0xe0b0('0x9')](_0x154de6);var _0x24babd=_0x7e5a8a[_0xe0b0('0x6')]?_0x219b1c['ids']:_0x7e5a8a[_0xe0b0('0x11')];_0x5cf9cc=_0x24babd?!![]:![];return sqlUtils['countFilteredContacts'](_0x30e20d,_0x24babd);})[_0xe0b0('0x5')](function(_0xadee6e){_0x28040c['count']=_0xadee6e;if(_0x28040c[_0xe0b0('0x12')]===0x0){return;}return sqlUtils['buildContactsQuery'](_0x30e20d,_0x7e5a8a[_0xe0b0('0xb')],_0x3b5e2b,_0x5cf9cc,_0x219b1c[_0xe0b0('0xe')],_0x50be7f);})['then'](function(_0x54a3eb){if(!_0x54a3eb){return[];}return sqlUtils[_0xe0b0('0x13')](_0x54a3eb,_0x7e5a8a,_0x3b5e2b);})['then'](function(_0x4df8da){_0x28040c['rows']=_0x4df8da;return _0x28040c;})[_0xe0b0('0x14')](function(_0x50fa4a){throw _0x50fa4a;});};exports['describe']=function(){var _0x10cde1={};var _0x59dff5=[];return db[_0xe0b0('0x15')]['describe']()[_0xe0b0('0x5')](function(_0x1cd7c4){_0x10cde1=_0x1cd7c4;var _0x3e10b3=Object[_0xe0b0('0x16')](_0x10cde1)[_0xe0b0('0xc')](function(_0x58b804){return _['startsWith'](_0x58b804,_0xe0b0('0x17'))?_0x58b804:undefined;});var _0x5512bb=_0x3e10b3[_0xe0b0('0x18')](function(_0x31b5f8){return db['CmCustomField'][_0xe0b0('0x19')]({'where':{'id':_0x31b5f8['slice'](0x3)},'raw':!![]});});return Promise[_0xe0b0('0x1a')](_0x5512bb);})['then'](function(_0x28586d){for(var _0x576352=0x0;_0x576352<_0x28586d[_0xe0b0('0x1b')];_0x576352++){if(_0x28586d[_0x576352]){var _0x4de537=_0xe0b0('0x17')+_0x28586d[_0x576352]['id'];_0x10cde1[_0x4de537]['fieldType']=_0x28586d[_0x576352][_0xe0b0('0x1c')];}}_0x59dff5=_['map'](Object[_0xe0b0('0x16')](_0x10cde1),function(_0x3c3bc2){return{'name':_0x3c3bc2,'type':_0x10cde1[_0x3c3bc2][_0xe0b0('0x1c')]};});return _0x59dff5;})[_0xe0b0('0x14')](function(_0x3ec2){throw _0x3ec2;});}; \ No newline at end of file diff --git a/server/components/contacts/sql-utils.js b/server/components/contacts/sql-utils.js new file mode 100644 index 0000000..57f137f --- /dev/null +++ b/server/components/contacts/sql-utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7bf9=['text','value','end','Tag','map','tags','clause','ids','user','skip','compact','Contact','ListId','c.ListId\x20IN\x20?','concat','and','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','resolve','then','fields','tag','filter','role','getLists','c.ListId\x20IS\x20NULL','c.id','limit','subqry.id','offset','having','order','DESC','subqry.','findAll','QueryTypes','SELECT','CmContact','sequelize','Tags','clone','COUNT(*)','group','getSelectedTags','isEmpty','query','toString','exports','squel','../parsers/qs','../interaction/utils','../../mysqldb','agent','search','autocomplete','true','select','from','cm_contacts','c.deletedAt\x20IS\x20NULL','subqry','left_join','cm_user_has_contacts','.id','cm_contact_has_tags','ct.CmContactId\x20=\x20','tools_tags','t.id\x20=\x20ct.TagId','firstName','phone','fax','CompanyId','createdAt','updatedAt','deletedAt','TagIds','push','forEach','GROUP_CONCAT(DISTINCT\x20t.id)','field','expr','replace','split','length','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','isNumeric','c.id\x20LIKE\x20?','c.phone\x20LIKE\x20?','c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','parseSearch','conditions','name','dateOfBirth','fieldType','datetime','castTo','DATE','buildExpression','type','default'];(function(_0x566876,_0x4dbd73){var _0x5abe45=function(_0x2aca50){while(--_0x2aca50){_0x566876['push'](_0x566876['shift']());}};_0x5abe45(++_0x4dbd73);}(_0x7bf9,0x100));var _0x97bf=function(_0x3abd17,_0xde01c3){_0x3abd17=_0x3abd17-0x0;var _0x3e1006=_0x7bf9[_0x3abd17];return _0x3e1006;};'use strict';var _=require('lodash');var squel=require(_0x97bf('0x0'));var as=require('../parsers/advancedSearch');var qs=require(_0x97bf('0x1'));var utils=require(_0x97bf('0x2'));var db=require(_0x97bf('0x3'))['db'];function skipContactsQuery(_0x201726,_0x2482b1){var _0x5a160d=![];if(_0x201726['role']===_0x97bf('0x4')&&!_0x2482b1[_0x97bf('0x5')]&&!_0x2482b1['ListId']&&_0x2482b1[_0x97bf('0x6')]!==_0x97bf('0x7')){_0x5a160d=!![];}return _0x5a160d;}function getContactsSubquery(){return squel[_0x97bf('0x8')]()[_0x97bf('0x9')](_0x97bf('0xa'),'c')['where'](_0x97bf('0xb'));}function applyJoinClauses(_0x347dc5,_0x43af07){var _0x3abe3c=_0x43af07?'c':_0x97bf('0xc');_0x347dc5[_0x97bf('0xd')](_0x97bf('0xe'),'uc','uc.CmContactId\x20=\x20'+_0x3abe3c+_0x97bf('0xf'))[_0x97bf('0xd')](_0x97bf('0x10'),'ct',_0x97bf('0x11')+_0x3abe3c+_0x97bf('0xf'))[_0x97bf('0xd')](_0x97bf('0x12'),'t',_0x97bf('0x13'));return _0x347dc5;}function addFieldsToQuery(_0x20a011,_0x25dbe2,_0x2bb0a4,_0x3361ff,_0x26bd21){var _0x415409=_0x26bd21?'c':_0x97bf('0xc');if(!_0x25dbe2){_0x25dbe2=['id',_0x97bf('0x14'),'lastName',_0x97bf('0x15'),'mobile',_0x97bf('0x16'),'email','ListId',_0x97bf('0x17'),_0x97bf('0x18'),_0x97bf('0x19'),_0x97bf('0x1a'),_0x97bf('0x1b')];}else if(!_0x25dbe2['includes']('id')){_0x25dbe2[_0x97bf('0x1c')]('id');}var _0x2401f9=_0x2bb0a4&&_0x26bd21||!_0x2bb0a4&&!_0x26bd21;if(_0x3361ff){_0x2401f9=_0x3361ff&&_0x26bd21||!_0x3361ff&&!_0x26bd21;}_0x25dbe2[_0x97bf('0x1d')](function(_0x17b409){if(_0x17b409===_0x97bf('0x1b')){if(_0x2401f9){_0x20a011['field'](_0x97bf('0x1e'),_0x17b409);}else if(_0x2bb0a4||_0x3361ff){_0x20a011[_0x97bf('0x1f')](_0x415409+'.'+_0x17b409);}}else{_0x20a011[_0x97bf('0x1f')](_0x415409+'.'+_0x17b409);}});return _0x20a011;}function getSqlClauses(){var _0x26d362={'default':squel[_0x97bf('0x20')](),'fields':squel[_0x97bf('0x20')](),'filter':squel[_0x97bf('0x20')](),'tags':{'clause':squel[_0x97bf('0x20')](),'ids':null},'user':{'clause':squel[_0x97bf('0x20')](),'skip':![]}};return _0x26d362;}function parseTagParameter(_0x26f6a9){var _0x28f344=squel[_0x97bf('0x20')]();if(_0x26f6a9){var _0x2e38f4=utils['getSelectedTags'](_0x26f6a9);_0x2e38f4[_0x97bf('0x1d')](function(_0x2ce570){_0x28f344['or']('CONCAT(\x27,\x27,\x20subqry.TagIds,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x2ce570+',%');});}return _0x28f344;}function parseSearchFilter(_0x59303e){var _0x23752d=squel['expr']();if(_0x59303e){var _0x4c9326=_0x59303e[_0x97bf('0x21')]('\x5c','\x5c\x5c')[_0x97bf('0x21')](/'/g,'\x27\x27');if(_0x4c9326[_0x97bf('0x22')]('\x20')[_0x97bf('0x23')]>0x1){_0x23752d['or'](_0x97bf('0x24'),qs[_0x97bf('0x25')](_0x4c9326),null);}else{if(qs[_0x97bf('0x26')](_0x4c9326)){_0x23752d['or'](_0x97bf('0x27'),_0x4c9326+'%');_0x23752d['or'](_0x97bf('0x28'),_0x4c9326+'%');_0x23752d['or'](_0x97bf('0x29'),_0x4c9326+'%');_0x23752d['or'](_0x97bf('0x2a'),_0x4c9326+'%');}else if(qs[_0x97bf('0x2b')](_0x4c9326)){_0x23752d['or'](_0x97bf('0x2c'),_0x4c9326+'%');}else{_0x23752d['or']('c.firstName\x20LIKE\x20?','%'+_0x4c9326+'%');_0x23752d['or']('c.lastName\x20LIKE\x20?','%'+_0x4c9326+'%');_0x23752d['or'](_0x97bf('0x2c'),'%'+_0x4c9326+'%');}}}return _0x23752d;}function parseAdvancedSearchFilter(_0x475cce,_0x21e13d){var _0x483b3a=getSqlClauses();var _0x4bc161=as[_0x97bf('0x2d')](_0x475cce);var _0x3bef9d=_0x4bc161['sqlOperator'];for(var _0x5ef9ce=0x0;_0x5ef9ce<_0x4bc161['conditions'][_0x97bf('0x23')];_0x5ef9ce++){var _0x7fce3d=_0x4bc161[_0x97bf('0x2e')][_0x5ef9ce];var _0x44b98b='c';var _0x1fee58=_['find'](_0x21e13d,[_0x97bf('0x2f'),_0x7fce3d[_0x97bf('0x1f')]]);if(_0x1fee58){if(_0x7fce3d[_0x97bf('0x1f')]===_0x97bf('0x30')||_0x1fee58[_0x97bf('0x31')]===_0x97bf('0x32')){_0x7fce3d[_0x97bf('0x33')]=_0x97bf('0x34');}var _0x1d64e9=as[_0x97bf('0x35')](_0x44b98b,_0x1fee58[_0x97bf('0x36')],_0x7fce3d);_0x483b3a[_0x97bf('0x37')][_0x3bef9d](_0x1d64e9[_0x97bf('0x38')],_0x1d64e9[_0x97bf('0x39')]['start'],_0x1d64e9['value'][_0x97bf('0x3a')]);}else{if(_0x7fce3d[_0x97bf('0x1f')]===_0x97bf('0x3b')){var _0x413d0e=_0x7fce3d['value'][_0x97bf('0x22')](',')[_0x97bf('0x3c')](function(_0x4f25cd){return Number(_0x4f25cd);});var _0x2d4c12=parseTagParameter(_0x413d0e);_0x483b3a[_0x97bf('0x3d')][_0x97bf('0x3e')]['and'](_0x2d4c12);_0x483b3a[_0x97bf('0x3d')][_0x97bf('0x3f')]=_0x413d0e;}else if(_0x7fce3d['field']==='User'){_0x483b3a[_0x97bf('0x40')]['clause']['and']('uc.UserId\x20=\x20?',_0x7fce3d['value']);_0x483b3a[_0x97bf('0x40')][_0x97bf('0x41')]=!![];}}}return _0x483b3a;}function parseModelFields(_0x874b20,_0x54a345){var _0x40340a=squel[_0x97bf('0x20')]();var _0x2d8ba8=_(_0x874b20)['keys']()['map'](function(_0x23b53a){return _['some'](_0x54a345,[_0x97bf('0x2f'),_0x23b53a])?_0x23b53a:undefined;})[_0x97bf('0x42')]()['value']();if(_0x874b20[_0x97bf('0x43')]){_0x2d8ba8[_0x97bf('0x1c')](_0x97bf('0x43'));}if(_0x2d8ba8['length']>0x0){_0x2d8ba8['forEach'](function(_0x41abf2){if(_0x41abf2===_0x97bf('0x44')){_0x40340a['and'](_0x97bf('0x45'),[][_0x97bf('0x46')](_0x874b20[_0x41abf2]));}else if(_0x41abf2==='Contact'){var _0x40cd23='%'+_0x874b20[_0x41abf2]+'%';_0x40340a[_0x97bf('0x47')](_0x97bf('0x48'),_0x40cd23);}else{_0x40340a[_0x97bf('0x47')]('c.'+_0x41abf2+_0x97bf('0x49'),_0x874b20[_0x41abf2]);}});}return _0x40340a;}function parseQueryParameters(_0x67a217,_0x1f9a71){var _0x4285db=getSqlClauses();return Promise[_0x97bf('0x4a')]()[_0x97bf('0x4b')](function(){return parseModelFields(_0x67a217,_0x1f9a71);})[_0x97bf('0x4b')](function(_0x1f72dc){_0x4285db[_0x97bf('0x4c')][_0x97bf('0x47')](_0x1f72dc);return parseTagParameter(_0x67a217[_0x97bf('0x4d')]);})[_0x97bf('0x4b')](function(_0x1d3ecd){_0x4285db['tags'][_0x97bf('0x3e')]['and'](_0x1d3ecd);return parseSearchFilter(_0x67a217['filter']);})['then'](function(_0x53b7f6){_0x4285db[_0x97bf('0x4e')]=_0x53b7f6;return _0x4285db;});}function checkListsRestrictions(_0x3aab0a,_0x495392,_0x2051f1){var _0x163b69=squel[_0x97bf('0x20')]();return Promise['resolve']()[_0x97bf('0x4b')](function(){if(_0x495392['search']&&_0x3aab0a[_0x97bf('0x4f')]===_0x97bf('0x4')&&!_0x2051f1){return _0x3aab0a[_0x97bf('0x50')]({'attributes':['id'],'raw':!![]});}})['then'](function(_0x304f7e){if(_0x304f7e){if(_0x304f7e[_0x97bf('0x23')]===0x0){_0x163b69['and'](_0x97bf('0x51'));}else{_0x163b69[_0x97bf('0x47')](_0x97bf('0x45'),_['map'](_0x304f7e,'id'));}}})[_0x97bf('0x4b')](function(){return _0x163b69;});}function buildContactsQuery(_0x4b373f,_0x2b8364,_0x124054,_0x26d30e,_0x5d911a,_0x28c6fa){if(_0x2b8364){_0x2b8364=_0x124054['attributes'];}_0x4b373f=addFieldsToQuery(_0x4b373f,_0x2b8364,_0x26d30e,_0x28c6fa,!![]);var _0x198a75=squel[_0x97bf('0x8')]();_0x198a75=addFieldsToQuery(_0x198a75,_0x2b8364,_0x26d30e,_0x28c6fa,![]);if(_0x26d30e||_0x28c6fa){_0x4b373f=applyJoinClauses(_0x4b373f,!![]);_0x4b373f['group'](_0x97bf('0x52'));if(_0x124054[_0x97bf('0x53')]){_0x198a75['limit'](_0x124054[_0x97bf('0x53')]);}if(_0x124054['offset']){_0x198a75['offset'](_0x124054['offset']);}}else{_0x198a75=applyJoinClauses(_0x198a75,![]);_0x198a75['group'](_0x97bf('0x54'));if(_0x124054[_0x97bf('0x53')]){_0x4b373f[_0x97bf('0x53')](_0x124054[_0x97bf('0x53')]);}if(_0x124054['offset']){_0x4b373f['offset'](_0x124054[_0x97bf('0x55')]);}}_0x198a75[_0x97bf('0x56')](_0x5d911a);if(_0x124054[_0x97bf('0x57')]){_0x124054['order'][_0x97bf('0x1d')](function(_0x116a3f){_0x4b373f[_0x97bf('0x57')]('c.'+_0x116a3f[0x0],_0x116a3f[0x1]===_0x97bf('0x58')?![]:!![]);_0x198a75[_0x97bf('0x57')](_0x97bf('0x59')+_0x116a3f[0x0],_0x116a3f[0x1]==='DESC'?![]:!![]);});}_0x198a75['from'](_0x4b373f,_0x97bf('0xc'));return _0x198a75;}function getFilteredContacts(_0x36af27){var _0x447a3e=[];return db[_0x97bf('0x3b')][_0x97bf('0x5a')]({'attributes':['id',_0x97bf('0x2f'),'color'],'raw':!![]})['then'](function(_0x3eb607){_0x447a3e=_['keyBy'](_0x3eb607,'id');var _0x109d74={'type':db['Sequelize'][_0x97bf('0x5b')][_0x97bf('0x5c')],'model':db[_0x97bf('0x5d')],'mapToModel':!![],'nest':!![],'raw':!![]};return db[_0x97bf('0x5e')]['query'](_0x36af27['toString'](),_0x109d74);})[_0x97bf('0x4b')](function(_0x3b7a47){_0x3b7a47[_0x97bf('0x1d')](function(_0x2f3ee1){if(_0x2f3ee1[_0x97bf('0x1b')]){_0x2f3ee1[_0x97bf('0x5f')]=[];_0x2f3ee1['TagIds']['split'](',')[_0x97bf('0x1d')](function(_0x46b6e6){_0x2f3ee1[_0x97bf('0x5f')][_0x97bf('0x1c')](_0x447a3e[_0x46b6e6]);});}delete _0x2f3ee1[_0x97bf('0x1b')];});return _0x3b7a47;});}function countFilteredContacts(_0x399064,_0x1a98b2){var _0x21c906=_0x399064[_0x97bf('0x60')]();_0x21c906[_0x97bf('0x1f')](_0x97bf('0x61'));_0x21c906=applyJoinClauses(_0x21c906,!![]);_0x399064[_0x97bf('0x62')](_0x97bf('0x52'));var _0x2ca71f=utils[_0x97bf('0x63')](_0x1a98b2);if(!_[_0x97bf('0x64')](_0x2ca71f)){_0x21c906['where']('t.id\x20IN\x20?',_0x2ca71f);}var _0x145d07={'type':db['Sequelize'][_0x97bf('0x5b')][_0x97bf('0x5c')],'raw':!![]};return db[_0x97bf('0x5e')][_0x97bf('0x65')](_0x21c906[_0x97bf('0x66')](),_0x145d07)[_0x97bf('0x4b')](function(_0x2d00c2){return _0x2d00c2[0x0][_0x97bf('0x61')];});}module[_0x97bf('0x67')]={'buildContactsQuery':buildContactsQuery,'checkListsRestrictions':checkListsRestrictions,'countFilteredContacts':countFilteredContacts,'getContactsSubquery':getContactsSubquery,'getFilteredContacts':getFilteredContacts,'parseAdvancedSearchFilter':parseAdvancedSearchFilter,'parseQueryParameters':parseQueryParameters,'skipContactsQuery':skipContactsQuery}; \ No newline at end of file diff --git a/server/components/encryptor/index.js b/server/components/encryptor/index.js new file mode 100644 index 0000000..08d64f5 --- /dev/null +++ b/server/components/encryptor/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb807=['base64','decryptString','crypto','lodash','../../config/logger','app','secrets','session','aes-256-ctr','aes192','encrypt','algorithm','join','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','test','filter','indexOf','encryptFile','createReadStream','createWriteStream','createCipher','data','binary','write','end','final','close','unlink','decryptFile','createDecipher','update','encryptString','secret','utf8'];(function(_0x25680f,_0x49646a){var _0x135948=function(_0x4b6ebe){while(--_0x4b6ebe){_0x25680f['push'](_0x25680f['shift']());}};_0x135948(++_0x49646a);}(_0xb807,0x1bc));var _0x7b80=function(_0x3de8a2,_0x1c8615){_0x3de8a2=_0x3de8a2-0x0;var _0x267573=_0xb807[_0x3de8a2];return _0x267573;};'use strict';var crypto=require(_0x7b80('0x0'));var fs=require('fs');var BPromise=require('bluebird');var _=require(_0x7b80('0x1'));var config=require('../../config/environment');var logger=require(_0x7b80('0x2'))(_0x7b80('0x3'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0x7b80('0x4')][_0x7b80('0x5')],'algorithm':_0x7b80('0x6')};const fileOptions={'algorithm':_0x7b80('0x7')};if(config[_0x7b80('0x8')]&&config[_0x7b80('0x8')][_0x7b80('0x9')]){var isSupported=isAlgorithmSupported(config[_0x7b80('0x8')][_0x7b80('0x9')]);if(isSupported){fileOptions[_0x7b80('0x9')]=config[_0x7b80('0x8')][_0x7b80('0x9')];}else{var supportedAlgorithms=getSupportedCiphers()[_0x7b80('0xa')](',\x20');logger['error'](config[_0x7b80('0x8')][_0x7b80('0x9')],_0x7b80('0xb'),supportedAlgorithms);}}function isASupportedCipher(_0x1781a7){return AES_SUPPORTED_RX[_0x7b80('0xc')](_0x1781a7);}function getSupportedCiphers(){return crypto['getCiphers']()[_0x7b80('0xd')](isASupportedCipher);}function isAlgorithmSupported(_0xdaa294){return getSupportedCiphers()[_0x7b80('0xe')](_0xdaa294)>-0x1;}function combineOptions(_0x4ee208){var _0x5a0e6a={};for(var _0x2ba638 in fileOptions){if(fileOptions['hasOwnProperty'](_0x2ba638)){_0x5a0e6a[_0x2ba638]=fileOptions[_0x2ba638];}}if(_0x4ee208){for(var _0x557ca9 in _0x4ee208){if(_0x4ee208['hasOwnProperty'](_0x557ca9)){_0x5a0e6a[_0x557ca9]=_0x4ee208[_0x557ca9];}}}return _0x5a0e6a;}exports[_0x7b80('0xf')]=function(_0x591386,_0x29295f,_0x40ff8a,_0x17e7fa){return new BPromise(function(_0x50ae23,_0x5cf2ab){_0x17e7fa=combineOptions(_0x17e7fa);var _0x55cb11=new Buffer(_0x40ff8a);var _0x38b118=fs[_0x7b80('0x10')](_0x591386);var _0x3ca82d=fs[_0x7b80('0x11')](_0x29295f);var _0x4280c6=crypto[_0x7b80('0x12')](_0x17e7fa[_0x7b80('0x9')],_0x55cb11);_0x38b118['on'](_0x7b80('0x13'),function(_0x365da0){var _0x27f924=new Buffer(_0x4280c6['update'](_0x365da0),_0x7b80('0x14'));_0x3ca82d[_0x7b80('0x15')](_0x27f924);});_0x38b118['on'](_0x7b80('0x16'),function(){try{var _0x683431=new Buffer(_0x4280c6[_0x7b80('0x17')]('binary'),_0x7b80('0x14'));_0x3ca82d['write'](_0x683431);_0x3ca82d[_0x7b80('0x16')]();_0x3ca82d['on'](_0x7b80('0x18'),function(){return _0x50ae23(_0x29295f);});}catch(_0x5268c4){fs[_0x7b80('0x19')](_0x29295f);return _0x5cf2ab(_0x5268c4);}});});};exports[_0x7b80('0x1a')]=function(_0xf31925,_0x350abc,_0x4e602c,_0x3c77f5){return new BPromise(function(_0x3ccf7f,_0x1d6505){_0x3c77f5=combineOptions(_0x3c77f5);var _0x5b5eb3=new Buffer(_0x4e602c);var _0x4e5bb3=fs[_0x7b80('0x10')](_0xf31925);var _0x359f0b=fs[_0x7b80('0x11')](_0x350abc);var _0x3c0598=crypto[_0x7b80('0x1b')](_0x3c77f5[_0x7b80('0x9')],_0x5b5eb3);_0x4e5bb3['on'](_0x7b80('0x13'),function(_0x55f5d9){var _0x2f1e6f=new Buffer(_0x3c0598[_0x7b80('0x1c')](_0x55f5d9),_0x7b80('0x14'));_0x359f0b[_0x7b80('0x15')](_0x2f1e6f);});_0x4e5bb3['on']('end',function(){try{var _0x3415b0=new Buffer(_0x3c0598[_0x7b80('0x17')](_0x7b80('0x14')),_0x7b80('0x14'));_0x359f0b[_0x7b80('0x15')](_0x3415b0);_0x359f0b[_0x7b80('0x16')]();_0x359f0b['on']('close',function(){return _0x3ccf7f(_0x350abc);});}catch(_0x5c6de9){fs[_0x7b80('0x19')](_0x350abc);return _0x1d6505(_0x5c6de9);}});});};exports[_0x7b80('0x1d')]=function(_0x243f15,_0x5aa07c,_0x1715b6){var _0x2fb3eb=_0x1715b6||stringOptions[_0x7b80('0x9')];var _0x2f40f5=_0x5aa07c||stringOptions[_0x7b80('0x1e')];var _0x48792f=crypto[_0x7b80('0x12')](_0x2fb3eb,_0x2f40f5);var _0x449a75=_0x48792f[_0x7b80('0x1c')](_0x243f15,_0x7b80('0x1f'),_0x7b80('0x20'));_0x449a75+=_0x48792f[_0x7b80('0x17')](_0x7b80('0x20'));return _0x449a75;};exports[_0x7b80('0x21')]=function(_0x4e8a42,_0x1bd9c7,_0x49e3f1){var _0x142720=_0x49e3f1||stringOptions[_0x7b80('0x9')];var _0x1fd23f=_0x1bd9c7||stringOptions[_0x7b80('0x1e')];var _0x387792=crypto[_0x7b80('0x1b')](_0x142720,_0x1fd23f);var _0x2db423=_0x387792[_0x7b80('0x1c')](_0x4e8a42,'base64',_0x7b80('0x1f'));_0x2db423+=_0x387792[_0x7b80('0x17')](_0x7b80('0x1f'));return _0x2db423;}; \ No newline at end of file diff --git a/server/components/export/csv.js b/server/components/export/csv.js new file mode 100644 index 0000000..bb65ae6 --- /dev/null +++ b/server/components/export/csv.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8821=['writeFileSync','zip','zip\x20finished','CSV','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Failed','finally','exit','util','path','lodash','to-csv','bluebird','zip-dir','rimraf','../../mysqldb','dbH','analytics','argv','savename','AnalyticExtractedReport','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','find','split','splitSizeCsv','then','sequelize','query','QueryTypes','SELECT','num','length','isInteger','forEach','push','%s\x20limit\x20%d\x20OFFSET\x20%d','basename','join','mkdirSync','%s%d.%s','csv','%s.%s'];(function(_0x269a48,_0x88b5d5){var _0x4d849a=function(_0x5d532c){while(--_0x5d532c){_0x269a48['push'](_0x269a48['shift']());}};_0x4d849a(++_0x88b5d5);}(_0x8821,0xc1));var _0x1882=function(_0x11309c,_0xe18a74){_0x11309c=_0x11309c-0x0;var _0x3fea9c=_0x8821[_0x11309c];return _0x3fea9c;};'use strict';var util=require(_0x1882('0x0'));var path=require(_0x1882('0x1'));var _=require(_0x1882('0x2'));var csv=require(_0x1882('0x3'));var fs=require('fs');var BPromise=require(_0x1882('0x4'));var zipdir=require(_0x1882('0x5'));var rimraf=require(_0x1882('0x6'));var db=require(_0x1882('0x7'))['db'];var dbH=require(_0x1882('0x7'))[_0x1882('0x8')];var logger=require('../../config/logger')(_0x1882('0x9'));var EXTRACTED_REPORT_ID=Number(process[_0x1882('0xa')][0x2]);var QUERY=process[_0x1882('0xa')][0x3];var PATH=process[_0x1882('0xa')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x341deb,_0xce9204){var _0x1df330={'status':_0x341deb};var _0x39cded={'where':{'id':EXTRACTED_REPORT_ID}};if(_0xce9204){_0x1df330[_0x1882('0xb')]=_0xce9204;}return db[_0x1882('0xc')][_0x1882('0xd')](_0x1df330,_0x39cded);}function main(){var _0x559e28=0x1388;var _0x39b505;logger[_0x1882('0xe')](util[_0x1882('0xf')](_0x1882('0x10'),EXTRACTED_REPORT_ID,'CSV'));return db['Setting'][_0x1882('0x11')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x1882('0x12'),_0x1882('0x13')]})[_0x1882('0x14')](function(_0x43d9bc){if(_0x43d9bc){_0x39b505=_0x43d9bc;_0x559e28=_0x39b505[_0x1882('0x13')]||0x1388;}})[_0x1882('0x14')](function(){return dbH[_0x1882('0x15')][_0x1882('0x16')](util['format']('SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t',QUERY),{'type':dbH[_0x1882('0x15')][_0x1882('0x17')][_0x1882('0x18')]});})[_0x1882('0x14')](function(_0x1ccd77){if(!_0x1ccd77[0x0][_0x1882('0x19')]){return analyticExtractedReport('Empty');}var _0x31c3e3=[];var _0xed86cb=0x0;if(_0x39b505['split']){if(_0x1ccd77&&_0x1ccd77[_0x1882('0x1a')]){var _0x5f4967=_['range'](_0x1ccd77[0x0][_0x1882('0x19')]/_0x559e28);var _0x421aae=Number[_0x1882('0x1b')](_0x1ccd77[0x0][_0x1882('0x19')]/_0x559e28)?_0x1ccd77[0x0]['num']%_0x559e28:0x0;_0x5f4967[_0x1882('0x1c')](function(_0x34b2ef){if(_0x34b2ef>0x0){_0xed86cb+=_0x559e28;}_0x31c3e3[_0x1882('0x1d')](dbH[_0x1882('0x15')][_0x1882('0x16')](util[_0x1882('0xf')](_0x1882('0x1e'),QUERY,_0x559e28,_0xed86cb),{'type':dbH[_0x1882('0x15')]['QueryTypes']['SELECT']}));});if(_0x421aae>0x0){_0xed86cb+=_0x559e28;_0x31c3e3[_0x1882('0x1d')](dbH[_0x1882('0x15')]['query'](util[_0x1882('0xf')](_0x1882('0x1e'),QUERY,_0x421aae,_0xed86cb),{'type':dbH[_0x1882('0x15')][_0x1882('0x17')][_0x1882('0x18')]}));}}}else{_0x31c3e3[_0x1882('0x1d')](dbH[_0x1882('0x15')][_0x1882('0x16')](QUERY,{'type':dbH[_0x1882('0x15')][_0x1882('0x17')]['SELECT']}));}var _0xf7949c=path['dirname'](PATH);var _0xc9be91=path[_0x1882('0x1f')](PATH,'.csv');var _0x58f617=_0x39b505[_0x1882('0x12')]&&_0x31c3e3[_0x1882('0x1a')]>0x1;var _0x625196=[];if(!fs['existsSync'](path[_0x1882('0x20')](_0xf7949c,_0xc9be91))&&_0x58f617){fs[_0x1882('0x21')](path[_0x1882('0x20')](_0xf7949c,_0xc9be91));}return BPromise['each'](_0x31c3e3,function(_0x22e56f){_0x625196['push'](_0x22e56f);})[_0x1882('0x14')](function(){for(var _0x42185e=0x0;_0x42185e<_0x625196[_0x1882('0x1a')];_0x42185e+=0x1){var _0x18eb85;var _0x46a971=_0x625196[_0x42185e];if(_0x58f617){_0x18eb85=path['join'](_0xf7949c,_0xc9be91,util[_0x1882('0xf')](_0x1882('0x22'),_0xc9be91,_0x42185e,_0x1882('0x23')));}else{_0x18eb85=path[_0x1882('0x20')](_0xf7949c,util[_0x1882('0xf')](_0x1882('0x24'),_0xc9be91,_0x1882('0x23')));}fs[_0x1882('0x25')](_0x18eb85,csv(_0x46a971));}})[_0x1882('0x14')](function(){if(_0x58f617){return new Promise(function(_0x35f499){zipdir(path[_0x1882('0x20')](_0xf7949c,_0xc9be91),{'saveTo':path['join'](_0xf7949c,util[_0x1882('0xf')](_0x1882('0x24'),_0xc9be91,_0x1882('0x26')))},function(_0x3a6951,_0x37f8e2){rimraf(path[_0x1882('0x20')](_0xf7949c,_0xc9be91),function(){});_0x35f499(_0x1882('0x27'));});});}})[_0x1882('0x14')](function(){logger[_0x1882('0xe')](util[_0x1882('0xf')]('Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed',EXTRACTED_REPORT_ID,_0x1882('0x28')));return analyticExtractedReport('Completed',_0x58f617?util[_0x1882('0xf')](_0x1882('0x24'),_0xc9be91,_0x58f617?_0x1882('0x26'):'csv'):null);});})[_0x1882('0x29')](function(_0x5365f8){logger[_0x1882('0xe')](util['format'](_0x1882('0x2a'),EXTRACTED_REPORT_ID,'CSV'),util['inspect'](_0x5365f8,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x1882('0x2b'));})[_0x1882('0x2c')](function(){process[_0x1882('0x2d')](EXIT_CODE);});}main(); \ No newline at end of file diff --git a/server/components/export/fonts/arial-bold-italic.ttf b/server/components/export/fonts/arial-bold-italic.ttf new file mode 100644 index 0000000..00968d2 Binary files /dev/null and b/server/components/export/fonts/arial-bold-italic.ttf differ diff --git a/server/components/export/fonts/arial-bold.ttf b/server/components/export/fonts/arial-bold.ttf new file mode 100644 index 0000000..d0d857e Binary files /dev/null and b/server/components/export/fonts/arial-bold.ttf differ diff --git a/server/components/export/fonts/arial-italic.ttf b/server/components/export/fonts/arial-italic.ttf new file mode 100644 index 0000000..5b05d35 Binary files /dev/null and b/server/components/export/fonts/arial-italic.ttf differ diff --git a/server/components/export/fonts/arial-regular.ttf b/server/components/export/fonts/arial-regular.ttf new file mode 100644 index 0000000..51a18bc Binary files /dev/null and b/server/components/export/fonts/arial-regular.ttf differ diff --git a/server/components/export/pdf.js b/server/components/export/pdf.js new file mode 100644 index 0000000..736d1fb --- /dev/null +++ b/server/components/export/pdf.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x356c=['push','format','name','startDate','endDate','header','pageBreak','landscape','footer','Arial','right','num','Empty','Setting','find','split','then','splitSizePdf','range','isInteger','forEach','sequelize','%s\x20limit\x20%d\x20OFFSET\x20%d','QueryTypes','SELECT','query','dirname','basename','.pdf','existsSync','join','flatten','createPdfKitDocument','%s%d.%s','pdf','%s.%s','zip','zip\x20finished','info','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','PDF','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','AnalyticExtractedReport','findOne','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','exit','/fonts/arial-regular.ttf','/fonts/arial-italic.ttf','/fonts/arial-bold-italic.ttf','%s\x20#%d','channel','interactionId','YYYY-MM-DD','center','\x09\x09XCALLY\x20Motion\x20-\x20%s\x09\x09\x09\x09%d/%d\x09\x09\x09\x09%s','pipe','finish','error','end','createPdfFromHTML','lodash','util','path','moment','pdfmake/src/printer','zip-dir','rimraf','jsdom','JSDOM','window','bluebird','../../mysqldb','dbH','../../config/logger','analytics','argv','MMMM\x20Do\x20YYYY,\x20h:mm:ss\x20a','update','map','tableHeader','pick','toString','length','auto','body','concat','chunk','keys'];(function(_0x4ff2a7,_0x264a62){var _0x36d0ea=function(_0x8b54bf){while(--_0x8b54bf){_0x4ff2a7['push'](_0x4ff2a7['shift']());}};_0x36d0ea(++_0x264a62);}(_0x356c,0x150));var _0xc356=function(_0x29efef,_0x3d8270){_0x29efef=_0x29efef-0x0;var _0x418e36=_0x356c[_0x29efef];return _0x418e36;};'use strict';var _=require(_0xc356('0x0'));var fs=require('fs');var util=require(_0xc356('0x1'));var path=require(_0xc356('0x2'));var moment=require(_0xc356('0x3'));var htmlToPdfmake=require('html-to-pdfmake');var PdfPrinter=require(_0xc356('0x4'));var zipdir=require(_0xc356('0x5'));var rimraf=require(_0xc356('0x6'));var JSDOM=require(_0xc356('0x7'))[_0xc356('0x8')];var window=new JSDOM('')[_0xc356('0x9')];var BPromise=require(_0xc356('0xa'));var db=require(_0xc356('0xb'))['db'];var dbH=require(_0xc356('0xb'))[_0xc356('0xc')];var logger=require(_0xc356('0xd'))(_0xc356('0xe'));var EXTRACTED_REPORT_ID=Number(process[_0xc356('0xf')][0x2]);var QUERY=process[_0xc356('0xf')][0x3];var PATH=process[_0xc356('0xf')][0x4];var NAME=process['argv'][0x5];var FORMAT=_0xc356('0x10');var EXTRACTED_REPORT;var EXIT_CODE=0x0;function analyticExtractedReport(_0x56519a,_0x5caaef){var _0x312fb6={'status':_0x56519a};var _0x127605={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x5caaef){_0x312fb6['savename']=_0x5caaef;}return db['AnalyticExtractedReport'][_0xc356('0x11')](_0x312fb6,_0x127605);}function getHeaders(_0x305242){return _[_0xc356('0x12')](_0x305242,function(_0x1c7565){return{'text':_0x1c7565,'style':_0xc356('0x13')};});}function getRows(_0x139fe2,_0xb44371){return _[_0xc356('0x12')](_0xb44371,function(_0x1dd8f9){return _(_0x1dd8f9)[_0xc356('0x14')](_0x139fe2)[_0xc356('0x12')](function(_0x4f28ca){return _0x4f28ca?_[_0xc356('0x15')](_0x4f28ca):'';})['value']();});}function createTable(_0x3cbdef,_0x1b4576){var _0x560e18={'widths':_['fill'](Array(_0x3cbdef[_0xc356('0x16')]),0x91),'heights':function(_0x267190){return _0x267190===0x0?_0xc356('0x17'):0x32;},'dontBreakRows':!![],'headerRows':0x1,'body':[]};var _0x5444e9=getHeaders(_0x3cbdef);_0x560e18['body']['push'](_0x5444e9);var _0x1d03ca=getRows(_0x3cbdef,_0x1b4576);_0x560e18[_0xc356('0x18')]=_0x560e18[_0xc356('0x18')][_0xc356('0x19')](_0x1d03ca);return _0x560e18;}function createTables(_0x322db9){var _0x367c44=[];var _0x3d396b=_[_0xc356('0x1a')](Object[_0xc356('0x1b')](_0x322db9[0x0]),0x5);_0x3d396b['forEach'](function(_0x385ad1){_0x367c44[_0xc356('0x1c')](createTable(_0x385ad1,_0x322db9));});return _0x367c44;}function getPDFDocDefinition(_0x2f380e){var _0xed52a4=util[_0xc356('0x1d')]('Name:\x20%s\x0aReport:\x20%s\x0aFrom:\x20%s\x20To:\x20%s',NAME,EXTRACTED_REPORT[_0xc356('0x1e')],moment(EXTRACTED_REPORT[_0xc356('0x1f')])['format'](FORMAT),moment(EXTRACTED_REPORT[_0xc356('0x20')])['format'](FORMAT));var _0x26cbf5=[];for(var _0x2b9fc9=0x0;_0x2b9fc9<_0x2f380e[_0xc356('0x16')];_0x2b9fc9++){var _0x48f9c1=[];if(_0x2b9fc9===0x0){_0x48f9c1['push']({'text':_0xed52a4,'style':_0xc356('0x21')});}var _0x31de0b={'table':_0x2f380e[_0x2b9fc9]};if(_0x2b9fc9>0x0){_0x31de0b[_0xc356('0x22')]='before';_0x31de0b['margin']=[0x0,0x46,0x0,0x0];}_0x48f9c1[_0xc356('0x1c')](_0x31de0b);_0x26cbf5[_0xc356('0x1c')](_0x48f9c1);}return{'pageSize':'A4','pageOrientation':_0xc356('0x23'),'content':_0x26cbf5,'footer':function(_0x3c20c5,_0x5d3751){return{'text':_0x3c20c5['toString']()+'\x20/\x20'+_0x5d3751,'style':_0xc356('0x24')};},'defaultStyle':{'font':_0xc356('0x25')},'styles':{'header':{'fontSize':0x12,'bold':!![],'margin':[0x0,0x0,0x0,0xa]},'tableHeader':{'bold':!![],'fontSize':0xd,'color':'black'},'footer':{'alignment':_0xc356('0x26'),'margin':[0x0,0x0,0x28,0x0]}}};}function extractReport(_0xcefa5){var _0x311fb1=0x1388;var _0x59cfd6;if(!_0xcefa5[0x0][_0xc356('0x27')]){return analyticExtractedReport(_0xc356('0x28'));}return db[_0xc356('0x29')][_0xc356('0x2a')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xc356('0x2b'),'splitSizePdf']})[_0xc356('0x2c')](function(_0x2e08e5){if(_0x2e08e5){_0x59cfd6=_0x2e08e5;_0x311fb1=_0x59cfd6[_0xc356('0x2d')]||0x3e8;}})[_0xc356('0x2c')](function(){var _0x5e43c4=[];var _0x66a9c0=0x0;if(_0x59cfd6[_0xc356('0x2b')]){if(_0xcefa5&&_0xcefa5[_0xc356('0x16')]){var _0x348168=_[_0xc356('0x2e')](_0xcefa5[0x0]['num']/_0x311fb1);var _0x33a0a2=Number[_0xc356('0x2f')](_0xcefa5[0x0]['num']/_0x311fb1)?_0xcefa5[0x0][_0xc356('0x27')]%_0x311fb1:0x0;_0x348168[_0xc356('0x30')](function(_0x265eea){if(_0x265eea>0x0){_0x66a9c0+=_0x311fb1;}_0x5e43c4[_0xc356('0x1c')](dbH[_0xc356('0x31')]['query'](util[_0xc356('0x1d')](_0xc356('0x32'),QUERY,_0x311fb1,_0x66a9c0),{'type':dbH['sequelize'][_0xc356('0x33')][_0xc356('0x34')]}));});if(_0x33a0a2>0x0){_0x66a9c0+=_0x311fb1;_0x5e43c4['push'](dbH['sequelize'][_0xc356('0x35')](util[_0xc356('0x1d')]('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x33a0a2,_0x66a9c0),{'type':dbH[_0xc356('0x31')]['QueryTypes'][_0xc356('0x34')]}));}}}else{_0x5e43c4[_0xc356('0x1c')](dbH[_0xc356('0x31')][_0xc356('0x35')](QUERY,{'type':dbH[_0xc356('0x31')][_0xc356('0x33')][_0xc356('0x34')]}));}var _0x50a381=path[_0xc356('0x36')](PATH);var _0x546ea0=path[_0xc356('0x37')](PATH,_0xc356('0x38'));var _0x963884=_0x59cfd6[_0xc356('0x2b')]&&_0x5e43c4[_0xc356('0x16')]>0x1;var _0x4c62cd=[];if(!fs[_0xc356('0x39')](path[_0xc356('0x3a')](_0x50a381,_0x546ea0))&&_0x963884){fs['mkdirSync'](path[_0xc356('0x3a')](_0x50a381,_0x546ea0));}return BPromise['each'](_0x5e43c4,function(_0xb1326e){_0x4c62cd[_0xc356('0x1c')](_0xb1326e);})[_0xc356('0x2c')](function(){var _0xf27700=[];for(var _0x18f999=0x0;_0x18f999<_0x4c62cd[_0xc356('0x16')];_0x18f999+=0x1){var _0x48cef1=_0x4c62cd[_0x18f999];var _0x4b1f8d=createTables(_[_0xc356('0x3b')](_0x48cef1));var _0x1fce9d;var _0x2a6ba9=getPDFDocDefinition(_0x4b1f8d);var _0x5782dc=getPDFPrinter();var _0x1e46cc=_0x5782dc[_0xc356('0x3c')](_0x2a6ba9);if(_0x963884){_0x1fce9d=path[_0xc356('0x3a')](_0x50a381,_0x546ea0,util[_0xc356('0x1d')](_0xc356('0x3d'),_0x546ea0,_0x18f999,_0xc356('0x3e')));}else{_0x1fce9d=path[_0xc356('0x3a')](_0x50a381,util['format'](_0xc356('0x3f'),_0x546ea0,_0xc356('0x3e')));}_0xf27700['push'](writePDFDocument(_0x1e46cc,_0x1fce9d));}return Promise['all'](_0xf27700);})['then'](function(){if(_0x963884){return new Promise(function(_0x3a360f){zipdir(path['join'](_0x50a381,_0x546ea0),{'saveTo':path[_0xc356('0x3a')](_0x50a381,util['format'](_0xc356('0x3f'),_0x546ea0,_0xc356('0x40')))},function(){rimraf(path[_0xc356('0x3a')](_0x50a381,_0x546ea0),function(){});_0x3a360f(_0xc356('0x41'));});});}})[_0xc356('0x2c')](function(){if(!_0x963884)return;rimraf(path[_0xc356('0x3a')](_0x50a381,_0x546ea0),function(){});})[_0xc356('0x2c')](function(){logger[_0xc356('0x42')](util['format'](_0xc356('0x43'),EXTRACTED_REPORT_ID,_0xc356('0x44')));return analyticExtractedReport('Completed',_0x963884?util[_0xc356('0x1d')]('%s.%s',_0x546ea0,_0x963884?_0xc356('0x40'):_0xc356('0x3e')):null);});});}function main(){if(!EXTRACTED_REPORT_ID)return;logger[_0xc356('0x42')](util[_0xc356('0x1d')](_0xc356('0x45'),EXTRACTED_REPORT_ID,'PDF'));return db[_0xc356('0x46')][_0xc356('0x47')]({'where':{'id':EXTRACTED_REPORT_ID}})[_0xc356('0x2c')](function(_0x5a740b){EXTRACTED_REPORT=_0x5a740b;return dbH[_0xc356('0x31')][_0xc356('0x35')](util[_0xc356('0x1d')](_0xc356('0x48'),QUERY),{'type':dbH[_0xc356('0x31')][_0xc356('0x33')][_0xc356('0x34')]});})['then'](extractReport)[_0xc356('0x49')](function(_0x1dc71f){logger[_0xc356('0x42')](util[_0xc356('0x1d')](_0xc356('0x4a'),EXTRACTED_REPORT_ID,_0xc356('0x44')),util[_0xc356('0x4b')](_0x1dc71f,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport('Failed');})['finally'](function(){process[_0xc356('0x4c')](EXIT_CODE);});}main();function getPDFPrinter(){var _0x147904=new PdfPrinter({'Arial':{'normal':__dirname+_0xc356('0x4d'),'bold':__dirname+'/fonts/arial-bold.ttf','italics':__dirname+_0xc356('0x4e'),'bolditalics':__dirname+_0xc356('0x4f')}});return _0x147904;}function getPDFDocDefinitionFromHTML(_0x27ef3d,_0x2458b2){var _0x50d67e=util[_0xc356('0x1d')](_0xc356('0x50'),_0x2458b2[_0xc356('0x51')],_0x2458b2[_0xc356('0x52')]);var _0x5c007f=moment()[_0xc356('0x1d')](_0xc356('0x53'))[_0xc356('0x15')]();var _0x1288b5=htmlToPdfmake(_0x27ef3d,{'window':window,'tableAutoSize':!![]});return{'content':[_0x1288b5],'defaultStyle':{'font':'Arial'},'styles':{'header':{'fontSize':0x12,'bold':!![],'alignment':_0xc356('0x54'),'margin':[0xa,0xa,0xa,0xa]},'footer':{'fontSize':0x9,'alignment':_0xc356('0x54'),'margin':[0xa,0x14,0xa,0xa]},'textblock':{'fontSize':0xb},'textfield':{'bold':!![]},'messageContainer':{'fontSize':0xa},'messageInfo':{'bold':!![]},'interactionData':{'alignment':_0xc356('0x54')}},'header':function(){return[{'text':'Interaction\x20Transcript','style':_0xc356('0x21')}];},'footer':function(_0x68d6f8,_0x49f485){return[{'text':util[_0xc356('0x1d')](_0xc356('0x55'),_0x50d67e,_0x68d6f8,_0x49f485,_0x5c007f),'style':_0xc356('0x24')}];}};}function writePDFDocument(_0x3af424,_0x59a467){return new Promise(function(_0x54d5b2,_0xb6e41e){var _0x3e1c93=_0x3af424[_0xc356('0x56')](fs['createWriteStream'](_0x59a467));_0x3e1c93['on']('finish',function(){_0x54d5b2(_0xc356('0x57'));});_0x3e1c93['on'](_0xc356('0x58'),function(_0x1c0ded){_0xb6e41e(_0x1c0ded);});_0x3af424[_0xc356('0x59')]();});}exports[_0xc356('0x5a')]=function(_0x1d2d75,_0x4054af){var _0x283cee=getPDFPrinter();var _0x177c05=getPDFDocDefinitionFromHTML(_0x1d2d75,_0x4054af);var _0x69b9c1=_0x283cee[_0xc356('0x3c')](_0x177c05);return writePDFDocument(_0x69b9c1,_0x4054af[_0xc356('0x2')])[_0xc356('0x49')](function(_0x4012cd){throw _0x4012cd;});}; \ No newline at end of file diff --git a/server/components/export/xlsx.js b/server/components/export/xlsx.js new file mode 100644 index 0000000..ffad105 --- /dev/null +++ b/server/components/export/xlsx.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3353=['AnalyticExtractedReport','update','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','split','splitSizeXlsx','then','sequelize','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT','num','Empty','length','isInteger','push','query','%s\x20limit\x20%d\x20OFFSET\x20%d','.xlsx','join','mkdirSync','%s%d.%s','xlsx','%s.%s','writeFileSync','binary','zip','info','XLSX','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','finally','path','lodash','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename'];(function(_0x454dc1,_0x441e0e){var _0x12a656=function(_0x18e19d){while(--_0x18e19d){_0x454dc1['push'](_0x454dc1['shift']());}};_0x12a656(++_0x441e0e);}(_0x3353,0x1ef));var _0x3335=function(_0x579321,_0x5f2ca7){_0x579321=_0x579321-0x0;var _0x12e520=_0x3353[_0x579321];return _0x12e520;};'use strict';var util=require('util');var path=require(_0x3335('0x0'));var _=require(_0x3335('0x1'));var fs=require('fs');var json2xls=require('json2xls');var BPromise=require(_0x3335('0x2'));var zipdir=require(_0x3335('0x3'));var rimraf=require(_0x3335('0x4'));var db=require(_0x3335('0x5'))['db'];var dbH=require(_0x3335('0x5'))[_0x3335('0x6')];var logger=require(_0x3335('0x7'))(_0x3335('0x8'));var EXTRACTED_REPORT_ID=Number(process[_0x3335('0x9')][0x2]);var QUERY=process[_0x3335('0x9')][0x3];var PATH=process[_0x3335('0x9')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x3c6941,_0x4f4320){var _0x4c5534={'status':_0x3c6941};var _0x2c3f27={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x4f4320){_0x4c5534[_0x3335('0xa')]=_0x4f4320;}return db[_0x3335('0xb')][_0x3335('0xc')](_0x4c5534,_0x2c3f27);}function main(){var _0x337d98=0x1388;var _0x1afd05;logger['info'](util[_0x3335('0xd')](_0x3335('0xe'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0x3335('0xf')]['find']({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x3335('0x10'),_0x3335('0x11')]})[_0x3335('0x12')](function(_0x66e23){if(_0x66e23){_0x1afd05=_0x66e23;_0x337d98=_0x1afd05[_0x3335('0x11')]||0x1388;}})[_0x3335('0x12')](function(){return dbH[_0x3335('0x13')]['query'](util[_0x3335('0xd')](_0x3335('0x14'),QUERY),{'type':dbH['sequelize'][_0x3335('0x15')][_0x3335('0x16')]});})[_0x3335('0x12')](function(_0x4bd6e8){if(!_0x4bd6e8[0x0][_0x3335('0x17')]){return analyticExtractedReport(_0x3335('0x18'));}var _0xf05e45=[];var _0x467125=0x0;if(_0x1afd05[_0x3335('0x10')]){if(_0x4bd6e8&&_0x4bd6e8[_0x3335('0x19')]){var _0x31faa1=_['range'](_0x4bd6e8[0x0][_0x3335('0x17')]/_0x337d98);var _0x41fd25=Number[_0x3335('0x1a')](_0x4bd6e8[0x0][_0x3335('0x17')]/_0x337d98)?_0x4bd6e8[0x0][_0x3335('0x17')]%_0x337d98:0x0;_0x31faa1['forEach'](function(_0x106a47){if(_0x106a47>0x0){_0x467125+=_0x337d98;}_0xf05e45[_0x3335('0x1b')](dbH[_0x3335('0x13')][_0x3335('0x1c')](util['format'](_0x3335('0x1d'),QUERY,_0x337d98,_0x467125),{'type':dbH[_0x3335('0x13')][_0x3335('0x15')][_0x3335('0x16')]}));});if(_0x41fd25>0x0){_0x467125+=_0x337d98;_0xf05e45[_0x3335('0x1b')](dbH[_0x3335('0x13')][_0x3335('0x1c')](util['format'](_0x3335('0x1d'),QUERY,_0x41fd25,_0x467125),{'type':dbH[_0x3335('0x13')]['QueryTypes'][_0x3335('0x16')]}));}}}else{_0xf05e45['push'](dbH[_0x3335('0x13')]['query'](QUERY,{'type':dbH[_0x3335('0x13')][_0x3335('0x15')][_0x3335('0x16')]}));}var _0xf8fea9=path['dirname'](PATH);var _0x275410=path['basename'](PATH,_0x3335('0x1e'));var _0x29cd17=_0x1afd05['split']&&_0xf05e45[_0x3335('0x19')]>0x1;var _0x4bdefe=[];if(!fs['existsSync'](path[_0x3335('0x1f')](_0xf8fea9,_0x275410))&&_0x29cd17){fs[_0x3335('0x20')](path[_0x3335('0x1f')](_0xf8fea9,_0x275410));}return BPromise['each'](_0xf05e45,function(_0x2eb7f5){_0x4bdefe[_0x3335('0x1b')](_0x2eb7f5);})[_0x3335('0x12')](function(){for(var _0x254c2f=0x0;_0x254c2f<_0x4bdefe[_0x3335('0x19')];_0x254c2f+=0x1){var _0x3e245d;var _0x1dc7d3=_0x4bdefe[_0x254c2f];if(_0x29cd17){_0x3e245d=path[_0x3335('0x1f')](_0xf8fea9,_0x275410,util[_0x3335('0xd')](_0x3335('0x21'),_0x275410,_0x254c2f,_0x3335('0x22')));}else{_0x3e245d=path[_0x3335('0x1f')](_0xf8fea9,util[_0x3335('0xd')](_0x3335('0x23'),_0x275410,_0x3335('0x22')));}fs[_0x3335('0x24')](_0x3e245d,json2xls(_0x1dc7d3),_0x3335('0x25'));}})[_0x3335('0x12')](function(){if(_0x29cd17){return new Promise(function(_0x180fc7){zipdir(path[_0x3335('0x1f')](_0xf8fea9,_0x275410),{'saveTo':path[_0x3335('0x1f')](_0xf8fea9,util[_0x3335('0xd')](_0x3335('0x23'),_0x275410,_0x3335('0x26')))},function(_0x5dd82f,_0xfb866b){rimraf(path[_0x3335('0x1f')](_0xf8fea9,_0x275410),function(){});_0x180fc7('zip\x20finished');});});}})[_0x3335('0x12')](function(){logger[_0x3335('0x27')](util[_0x3335('0xd')]('Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed',EXTRACTED_REPORT_ID,_0x3335('0x28')));return analyticExtractedReport('Completed',_0x29cd17?util[_0x3335('0xd')](_0x3335('0x23'),_0x275410,_0x29cd17?_0x3335('0x26'):_0x3335('0x22')):null);});})[_0x3335('0x29')](function(_0x43e5de){logger[_0x3335('0x27')](util[_0x3335('0xd')](_0x3335('0x2a'),EXTRACTED_REPORT_ID,_0x3335('0x28')),util[_0x3335('0x2b')](_0x43e5de,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x3335('0x2c'));})[_0x3335('0x2d')](function(){process['exit'](EXIT_CODE);});}main(); \ No newline at end of file diff --git a/server/components/extensions/rewrite.js b/server/components/extensions/rewrite.js new file mode 100644 index 0000000..c3ae38e --- /dev/null +++ b/server/components/extensions/rewrite.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbccd=['map','exten','filter','queue','playback','hasOwnProperty','extensions','extension','find','push','Set','format','CDR(type)=%s','type','context','priority','VoiceExtensionId','inbound','CDR(routeid)=','outbound','CDR(destination)=','${EXTEN:','cutdigits','${EXTEN}','ExecIf','CDR(prefix)=${EXTEN:0:','outboundrouteid=','recordingFormat','none','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','length','toLowerCase','createdAt','updatedAt','interval','IntervalId','intervals','tag','CDR(tag)=','callerID','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)=','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','answer','indexOf','app','appType','custom','XCALLY-MOTION-PROGRESS=1','splice','GotoIfTime',',${EXTEN},','last','concat','models','bulkCreate','sortBy','catch','rewrite','lodash','util','then','VoiceExtension','findAll','uniq'];(function(_0x5df2ff,_0x48300e){var _0x594f25=function(_0x1f5788){while(--_0x1f5788){_0x5df2ff['push'](_0x5df2ff['shift']());}};_0x594f25(++_0x48300e);}(_0xbccd,0x144));var _0xdbcc=function(_0x2b7764,_0x2606f1){_0x2b7764=_0x2b7764-0x0;var _0x848dcb=_0xbccd[_0x2b7764];return _0x848dcb;};'use strict';var _=require(_0xdbcc('0x0'));var util=require(_0xdbcc('0x1'));function rewrite(_0x4635a1,_0x2e0e66){var _0x229477=this;return _0x4635a1['models']['Interval']['findAll']({'raw':!![]})[_0xdbcc('0x2')](function(_0x46bcd4){_0x229477['intervals']=_0x46bcd4;return _0x4635a1['models'][_0xdbcc('0x3')]['findAll']({'where':{'IntervalId':_0x2e0e66['IntervalId']},'raw':!![]});})['then'](function(_0x44eeef){return _0x4635a1['models'][_0xdbcc('0x3')][_0xdbcc('0x4')]({'where':{'exten':{'$in':_[_0xdbcc('0x5')](_[_0xdbcc('0x6')](_0x44eeef,_0xdbcc('0x7')))}},'order':[{'raw':'CAST(priority\x20AS\x20UNSIGNED)'}],'raw':!![]});})[_0xdbcc('0x2')](function(_0x55473b){var _0x36761f=_[_0xdbcc('0x8')](_0x55473b,{'priority':'1'});var _0x30742c=_[_0xdbcc('0x8')](_0x55473b,{'isApp':0x1});var _0x1a67b5=_['groupBy'](_0x30742c,_0xdbcc('0x7'));var _0x4c4d82=[_0xdbcc('0x9'),_0xdbcc('0xa')];var _0x2413d4=[];var _0x1d4a8b=[];for(var _0x3830e8 in _0x1a67b5){if(_0x1a67b5[_0xdbcc('0xb')](_0x3830e8)){_0x229477['priority']=0x2;_0x229477[_0xdbcc('0xc')]=[];_0x229477[_0xdbcc('0xd')]=_[_0xdbcc('0xe')](_0x36761f,{'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')]});_0x229477['extensions'][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0]['type'],'app':_0xdbcc('0x10'),'appdata':util[_0xdbcc('0x11')](_0xdbcc('0x12'),_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')]),'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});if(_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')]===_0xdbcc('0x17')){_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0]['type'],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x18')+_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')],'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});}else if(_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')]===_0xdbcc('0x19')){if(_0x229477[_0xdbcc('0xd')]){_0x229477['extensions'][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x1a')+(_0x229477[_0xdbcc('0xd')]['cutdigits']?_0xdbcc('0x1b')+_0x229477[_0xdbcc('0xd')][_0xdbcc('0x1c')]+'}':_0xdbcc('0x1d')),'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0]['exten'],'priority':_0x229477['priority']++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});}_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':'CDR(routeid)='+_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')],'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0]['exten'],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});var _0x325c27=_0x229477[_0xdbcc('0x15')]++;_0x229477[_0xdbcc('0xc')]['push']({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x1e'),'appdata':'$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto('+(_0x325c27+0x2)+'):Goto('+(_0x325c27+0x1)+')','context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x325c27,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});if(_0x229477[_0xdbcc('0xd')]){_0x229477['extensions']['push']({'type':_0x1a67b5[_0x3830e8][0x0]['type'],'app':_0xdbcc('0x10'),'appdata':_0x229477[_0xdbcc('0xd')]['cutdigits']?_0xdbcc('0x1f')+_0x229477[_0xdbcc('0xd')][_0xdbcc('0x1c')]+'}':'CDR(prefix)=noprefix','context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477['priority']++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});}_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x20')+_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId'],'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});if(_0x229477[_0xdbcc('0xd')]&&_0x229477['extension'][_0xdbcc('0xb')](_0xdbcc('0x21'))&&_0x229477[_0xdbcc('0xd')][_0xdbcc('0x21')]!==_0xdbcc('0x22')){_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':'Set','appdata':_0xdbcc('0x23'),'context':_0x1a67b5[_0x3830e8][0x0]['context'],'exten':_0x1a67b5[_0x3830e8][0x0]['exten'],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':'Set','appdata':'_XCALLY_MIXMONITOR_FORMAT='+_0x229477['extension'][_0xdbcc('0x21')]||'wav','context':_0x1a67b5[_0x3830e8][0x0]['context'],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477['priority']++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});}}_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x24'),'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0]['exten'],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});_0x229477[_0xdbcc('0xc')]['push']({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x25'),'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':'MONITOR_OPTIONS=ab','context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'exten':_0x1a67b5[_0x3830e8][0x0]['exten'],'priority':_0x229477[_0xdbcc('0x15')]++,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});for(var _0x4195c3=0x0,_0x5c738a=0x0;_0x4195c3<_0x1a67b5[_0x3830e8][_0xdbcc('0x26')];_0x4195c3+=0x1,_0x5c738a=0x0){var _0x43c565=_0x1a67b5[_0x3830e8][_0x4195c3];if(_0x43c565[_0xdbcc('0x13')]){_0x43c565[_0xdbcc('0x13')]=_0x43c565[_0xdbcc('0x13')][_0xdbcc('0x27')]();}var _0x1423d9=[];var _0x41d653=[];delete _0x43c565['id'];delete _0x43c565[_0xdbcc('0x28')];delete _0x43c565[_0xdbcc('0x29')];var _0x4a6085=_0x43c565['interval']!=='*,*,*,*'?[_0x43c565[_0xdbcc('0x2a')]]:_0x43c565[_0xdbcc('0x2b')]?_['map'](_['filter'](_0x229477[_0xdbcc('0x2c')],{'IntervalId':_0x43c565[_0xdbcc('0x2b')]}),_0xdbcc('0x2a')):[];if(_0x43c565[_0xdbcc('0xb')]('tag')){if(_0x43c565['tag']&&_0x43c565[_0xdbcc('0x2d')]!=='--'){_0x1423d9[_0xdbcc('0xf')]({'type':_0x43c565[_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x2e')+_0x43c565[_0xdbcc('0x2d')],'context':_0x43c565[_0xdbcc('0x14')],'exten':_0x43c565[_0xdbcc('0x7')],'priority':_0x4a6085['length']+_0x229477[_0xdbcc('0x15')]+_0x5c738a++,'VoiceExtensionId':_0x43c565[_0xdbcc('0x16')]});}}if(_0x43c565[_0xdbcc('0x13')]==='outbound'&&_0x43c565['hasOwnProperty'](_0xdbcc('0x2f'))){if(_0x43c565[_0xdbcc('0x2f')]){_0x1423d9['push']({'type':_0x43c565[_0xdbcc('0x13')],'app':_0xdbcc('0x1e'),'appdata':_0xdbcc('0x30')+_0x43c565[_0xdbcc('0x2f')]+')','context':_0x43c565[_0xdbcc('0x14')],'exten':_0x43c565[_0xdbcc('0x7')],'priority':_0x4a6085[_0xdbcc('0x26')]+_0x229477[_0xdbcc('0x15')]+_0x5c738a++,'VoiceExtensionId':_0x43c565[_0xdbcc('0x16')]});}else{_0x1423d9[_0xdbcc('0xf')]({'type':_0x43c565[_0xdbcc('0x13')],'app':_0xdbcc('0x1e'),'appdata':_0xdbcc('0x31'),'context':_0x43c565[_0xdbcc('0x14')],'exten':_0x43c565[_0xdbcc('0x7')],'priority':_0x4a6085['length']+_0x229477[_0xdbcc('0x15')]+_0x5c738a++,'VoiceExtensionId':_0x43c565['VoiceExtensionId']});}}if(_0x43c565[_0xdbcc('0xb')](_0xdbcc('0x32'))){if(_0x4c4d82[_0xdbcc('0x33')](_0x43c565[_0xdbcc('0x34')][_0xdbcc('0x27')]())>=0x0&&_0x43c565[_0xdbcc('0x35')]!==_0xdbcc('0x36')){if(_0x43c565[_0xdbcc('0x32')]){_0x1423d9['push']({'type':_0x43c565['type'],'app':_0xdbcc('0x1e'),'appdata':'$[${XCALLY-MOTION-ANSWER}=0]?Answer','context':_0x43c565[_0xdbcc('0x14')],'exten':_0x43c565['exten'],'priority':_0x4a6085[_0xdbcc('0x26')]+_0x229477[_0xdbcc('0x15')]+_0x5c738a++,'VoiceExtensionId':_0x43c565['VoiceExtensionId']});_0x1423d9[_0xdbcc('0xf')]({'type':_0x43c565[_0xdbcc('0x13')],'app':_0xdbcc('0x10'),'appdata':'XCALLY-MOTION-ANSWER=1','context':_0x43c565['context'],'exten':_0x43c565[_0xdbcc('0x7')],'priority':_0x4a6085[_0xdbcc('0x26')]+_0x229477[_0xdbcc('0x15')]+_0x5c738a++,'VoiceExtensionId':_0x43c565['VoiceExtensionId']});}else{_0x1423d9['push']({'type':_0x43c565[_0xdbcc('0x13')],'app':_0xdbcc('0x1e'),'appdata':'$[${XCALLY-MOTION-PROGRESS}=0]?Progress','context':_0x43c565[_0xdbcc('0x14')],'exten':_0x43c565[_0xdbcc('0x7')],'priority':_0x4a6085[_0xdbcc('0x26')]+_0x229477['priority']+_0x5c738a++,'VoiceExtensionId':_0x43c565['VoiceExtensionId']});_0x1423d9[_0xdbcc('0xf')]({'type':_0x43c565['type'],'app':_0xdbcc('0x10'),'appdata':_0xdbcc('0x37'),'context':_0x43c565['context'],'exten':_0x43c565['exten'],'priority':_0x4a6085['length']+_0x229477['priority']+_0x5c738a++,'VoiceExtensionId':_0x43c565[_0xdbcc('0x16')]});}}}for(var _0x215365=0x0;_0x215365<_0x4a6085[_0xdbcc('0x26')];_0x215365+=0x1){var _0x2d58a3=_0x229477[_0xdbcc('0x15')]+_0x4a6085[_0xdbcc('0x26')];var _0x4f211e=_0x215365===_0x4a6085[_0xdbcc('0x26')]-0x1?_0x229477[_0xdbcc('0x15')]+_0x1423d9[_0xdbcc('0x26')]+_0x41d653['length']+0x2:_0x229477[_0xdbcc('0x15')]+_0x215365+0x1;_0x1423d9[_0xdbcc('0x38')](_0x215365,0x0,{'type':_0x43c565['type'],'app':_0xdbcc('0x39'),'appdata':_0x4a6085[_0x215365]+'?'+_0x43c565['context']+',${EXTEN},'+_0x2d58a3+':'+_0x43c565[_0xdbcc('0x14')]+_0xdbcc('0x3a')+_0x4f211e,'exten':_0x43c565[_0xdbcc('0x7')],'context':_0x43c565[_0xdbcc('0x14')],'priority':_0x229477[_0xdbcc('0x15')]+_0x215365,'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]});}_0x43c565['priority']=_0x1423d9['length']?_[_0xdbcc('0x3b')](_0x1423d9)['priority']+0x1:_0x229477[_0xdbcc('0x15')];_0x229477[_0xdbcc('0x15')]=(_0x41d653['length']?_[_0xdbcc('0x3b')](_0x41d653)[_0xdbcc('0x15')]:_0x43c565[_0xdbcc('0x15')])+0x1;_0x229477[_0xdbcc('0xc')]=_[_0xdbcc('0x3c')](_0x229477[_0xdbcc('0xc')],_0x1423d9,[_0x43c565],_0x41d653);}_0x229477[_0xdbcc('0xc')][_0xdbcc('0xf')]({'type':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x13')],'app':'Hangup','exten':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x7')],'context':_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x14')],'priority':_0x229477[_0xdbcc('0x15')],'VoiceExtensionId':_0x1a67b5[_0x3830e8][0x0]['VoiceExtensionId']});_0x2413d4[_0xdbcc('0xf')](_0x1a67b5[_0x3830e8][0x0][_0xdbcc('0x16')]);_0x1d4a8b=_[_0xdbcc('0x3c')](_0x1d4a8b,_0x229477[_0xdbcc('0xc')]);}}return _0x4635a1['transaction'](function(_0x48c2c8){return _0x4635a1['models']['VoiceExtension']['destroy']({'where':{'VoiceExtensionId':{'$in':_0x2413d4}},'transaction':_0x48c2c8})[_0xdbcc('0x2')](function(_0x48f101){return _0x4635a1[_0xdbcc('0x3d')][_0xdbcc('0x3')][_0xdbcc('0x3e')](_[_0xdbcc('0x3f')](_0x1d4a8b,_0xdbcc('0x15')),{'transaction':_0x48c2c8});});});})[_0xdbcc('0x40')](function(_0x434727){console['error'](_0x434727);});}exports[_0xdbcc('0x41')]=rewrite; \ No newline at end of file diff --git a/server/components/import/cm/csv.js b/server/components/import/cm/csv.js new file mode 100644 index 0000000..d3f32b9 --- /dev/null +++ b/server/components/import/cm/csv.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x794e=['squel','papaparse','ioredis','../../../mysqldb','../../../config/environment','../../../config/logger','redis','defaults','localhost','socket.io-emitter','../../../api/cmContact/cmContact.socket','argv','undefined','null','Missing\x20filepath\x20parameter!','Missing\x20binding\x20parameters!','zipObject','split','Missing\x20ListId\x20parameter!','Missing\x20socket_timestamp\x20parameter!','error','contact','test','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','errors','length','map','hasOwnProperty','data','firstName','firstName\x20not\x20specified!','phone','phone\x20not\x20specified!','birthDate','YYYY-MM-DD','isValid','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','email','ListId','CompanyId','find','duplicate','Duplicate\x20Contact','then','push','catch','Error\x20while\x20creating\x20contact:\x20','message','stringify','inspect','into','cm_hopper','fromQuery','ContactId','updatedAt','select','field','NOW()','scheduledAt','toString','createdAt','from','where','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','\x20=\x20?','insert','cm_contacts','str','calleridnum','id\x20IN\x20?','cm_hopper_black','VoiceQueue','findAll','outbound','CmList','Lists','dialCheckDuplicateType','always','sequelize','query','VoiceQueueId','onlyIfOpen','all','BlackLists','get','CampaignId','cmContact,\x20%s,\x20%s','generalCheckHopper','Error\x20processing\x20rows\x20block:','finally','contact:csv_','resume','Unable\x20to\x20delete\x20temp\x20file:','exit','SIGINT','resolve','createReadStream','parse','pause','info','CSV\x20parsed\x20correctly!','CSV\x20parse\x20error','util','lodash'];(function(_0x5af673,_0x4b6254){var _0x42f51b=function(_0x4afad4){while(--_0x4afad4){_0x5af673['push'](_0x5af673['shift']());}};_0x42f51b(++_0x4b6254);}(_0x794e,0x69));var _0xe794=function(_0x39d544,_0x35c14f){_0x39d544=_0x39d544-0x0;var _0x5a5ff2=_0x794e[_0x39d544];return _0x5a5ff2;};'use strict';var BPromise=require('bluebird');var util=require(_0xe794('0x0'));var _=require(_0xe794('0x1'));var fs=require('fs');var squel=require(_0xe794('0x2'));var Papa=require(_0xe794('0x3'));var Redis=require(_0xe794('0x4'));var db=require(_0xe794('0x5'))['db'];var config=require(_0xe794('0x6'));var logger=require(_0xe794('0x7'))('api');config[_0xe794('0x8')]=_[_0xe794('0x9')](config[_0xe794('0x8')],{'host':_0xe794('0xa'),'port':0x18eb});var socket=require(_0xe794('0xb'))(new Redis(config[_0xe794('0x8')]));require(_0xe794('0xc'))['register'](socket);try{if(!process[_0xe794('0xd')][0x2]||process[_0xe794('0xd')][0x2]===_0xe794('0xe')||process[_0xe794('0xd')][0x2]===_0xe794('0xf')){throw new Error(_0xe794('0x10'));}var FILEPATH=process['argv'][0x2];if(!process[_0xe794('0xd')][0x3]||process['argv'][0x3]===_0xe794('0xe')||process[_0xe794('0xd')][0x3]===_0xe794('0xf')||!process[_0xe794('0xd')][0x4]||process['argv'][0x4]===_0xe794('0xe')||process[_0xe794('0xd')][0x4]===_0xe794('0xf')){throw new Error(_0xe794('0x11'));}var FIELDS=_[_0xe794('0x12')](process[_0xe794('0xd')][0x3]['split'](','),process[_0xe794('0xd')][0x4][_0xe794('0x13')](','));if(!process[_0xe794('0xd')][0x5]||process[_0xe794('0xd')][0x5]===_0xe794('0xe')||process[_0xe794('0xd')][0x5]===_0xe794('0xf')){throw new Error(_0xe794('0x14'));}var LISTID=process[_0xe794('0xd')][0x5];var COMPANYID=process[_0xe794('0xd')][0x6]&&process[_0xe794('0xd')][0x6]!==_0xe794('0xe')&&process[_0xe794('0xd')][0x6]!==_0xe794('0xf')?process[_0xe794('0xd')][0x6]:null;var DUPLICATES=process[_0xe794('0xd')][0x7]&&process[_0xe794('0xd')][0x7]!=='undefined'&&process[_0xe794('0xd')][0x7]!==_0xe794('0xf')?process[_0xe794('0xd')][0x7]:null;if(!process[_0xe794('0xd')][0x8]||process['argv'][0x8]==='undefined'||process[_0xe794('0xd')][0x8]===_0xe794('0xf')){throw new Error(_0xe794('0x15'));}var SOCKET_TIMESTAMP=process['argv'][0x8];}catch(_0x33af8b){logger[_0xe794('0x16')](_0x33af8b);endCsv();}var total=0x0;var pTotal=0x0;var success=0x0;var errors=0x0;var duplicates=0x0;var rows=[];var hopperContacts='';var promises=[];var index=0x0;var alreadyInvalid=![];function handleCheckRowError(_0x295d68,_0x4d3989,_0x26a48f,_0x1e5cfe){var _0x194a1d={'message':_0x4d3989};_0x194a1d[_0x295d68]=!![];if(_0x26a48f){_0x194a1d[_0xe794('0x17')]=_0x26a48f;}if(_0x1e5cfe){_0x194a1d['index']=_0x1e5cfe;}return _0x194a1d;}function isEmail(_0x3a6ce2){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0xe794('0x18')](_0x3a6ce2);}function checkRow(_0x2bad67,_0x3f76b0,_0x3ea9a5){return new BPromise(function(_0x33bd41,_0xa0f3e2){if(_['isNil'](_0x2bad67)){return _0xa0f3e2(handleCheckRowError(_0xe794('0x16'),_0xe794('0x19'),null,_0x3ea9a5));}if(_0x2bad67[_0xe794('0x1a')]&&_0x2bad67[_0xe794('0x1a')][_0xe794('0x1b')]){var _0x53a4f2=_[_0xe794('0x1c')](_0x2bad67['errors'],'message')['join'](';');return _0xa0f3e2(handleCheckRowError(_0xe794('0x16'),_0x53a4f2,null,_0x3ea9a5));}var _0x1142fc={};for(var _0x5f2dfb in FIELDS){if(FIELDS[_0xe794('0x1d')](_0x5f2dfb)&&FIELDS[_0x5f2dfb]){_0x1142fc[_0x5f2dfb]=_0x2bad67['data'][0x0][FIELDS[_0x5f2dfb]]||_0x2bad67[_0xe794('0x1e')][0x0]['\ufeff'+FIELDS[_0x5f2dfb]];}}if(!_0x1142fc[_0xe794('0x1f')]){return _0xa0f3e2(handleCheckRowError('error',_0xe794('0x20'),null,_0x3ea9a5));}if(!_0x1142fc[_0xe794('0x21')]){return _0xa0f3e2(handleCheckRowError(_0xe794('0x16'),_0xe794('0x22'),null,_0x3ea9a5));}if(_0x1142fc['birthDate']){var _0x1a201b=moment(_0x1142fc[_0xe794('0x23')],_0xe794('0x24'));if(!_0x1a201b[_0xe794('0x25')]()){return _0xa0f3e2(handleCheckRowError(_0xe794('0x16'),_0xe794('0x26'),null,_0x3ea9a5));}}if(_0x1142fc[_0xe794('0x27')]){if(!isEmail(_0x1142fc[_0xe794('0x27')])){return _0xa0f3e2(handleCheckRowError(_0xe794('0x16'),'email\x20format\x20is\x20not\x20valid!',null,_0x3ea9a5));}}_0x1142fc[_0xe794('0x28')]=LISTID;_0x1142fc[_0xe794('0x29')]=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0xe794('0x1b')]&&_0x3f76b0){var _0x2cc614={};for(var _0x368b35=0x0,_0x397c00=DUPLICATES['length'];_0x368b35<_0x397c00;_0x368b35+=0x1){_0x2cc614[DUPLICATES[_0x368b35]]=_0x1142fc[DUPLICATES[_0x368b35]];}var _0x34e7a5=_[_0xe794('0x2a')](_0x3f76b0,_0x2cc614);if(_0x34e7a5){return _0xa0f3e2(handleCheckRowError(_0xe794('0x2b'),_0xe794('0x2c'),_0x34e7a5,_0x3ea9a5));}}return db['CmContact']['create'](_0x1142fc,{'raw':!![],'hooks':![],'fields':_['keys'](_0x1142fc)})[_0xe794('0x2d')](function(_0x17676d){if(DUPLICATES&&DUPLICATES[_0xe794('0x1b')]&&_0x3f76b0){_0x3f76b0[_0xe794('0x2e')](_['pick'](_0x1142fc,DUPLICATES));}hopperContacts+=(hopperContacts?',':'')+_0x17676d['id'];return _0x33bd41();})[_0xe794('0x2f')](function(_0xa48cf9){return _0xa0f3e2(handleCheckRowError('error',_0xe794('0x30')+(_0xa48cf9[_0xe794('0x31')]||JSON[_0xe794('0x32')](_0xa48cf9)),null,_0x3ea9a5));});});}function checkHopper(){function _0x586769(){return function(_0x59f9c7){logger[_0xe794('0x16')]('cmContact','checkHopper',util[_0xe794('0x33')](_0x59f9c7,{'showHidden':![],'depth':null}));};}var _0x83d76f=function(_0x3639c7,_0x335ba9){var _0x18dfa0=squel['insert']()[_0xe794('0x34')](_0xe794('0x35'))[_0xe794('0x36')]([_0xe794('0x21'),'scheduledAt',_0xe794('0x37'),'ListId',_0x335ba9,'createdAt',_0xe794('0x38')],squel[_0xe794('0x39')]()[_0xe794('0x3a')]('phone','phone')['field'](_0xe794('0x3b'),_0xe794('0x3c'))[_0xe794('0x3a')]('id',_0xe794('0x37'))[_0xe794('0x3a')](LISTID[_0xe794('0x3d')](),_0xe794('0x28'))[_0xe794('0x3a')](_0x3639c7['id'][_0xe794('0x3d')](),_0x335ba9)['field'](_0xe794('0x3b'),_0xe794('0x3e'))[_0xe794('0x3a')](_0xe794('0x3b'),'updatedAt')[_0xe794('0x3f')]('cm_contacts')[_0xe794('0x40')](_0xe794('0x41'))[_0xe794('0x40')](_0xe794('0x42'),LISTID[_0xe794('0x3d')]())[_0xe794('0x40')](_0xe794('0x43'))[_0xe794('0x40')](_0xe794('0x44'),squel['select']()[_0xe794('0x3a')](_0xe794('0x21'))[_0xe794('0x3f')](_0xe794('0x35'))[_0xe794('0x40')](_0x335ba9+_0xe794('0x45'),_0x3639c7['id'][_0xe794('0x3d')]())))[_0xe794('0x3d')]();return _0x18dfa0;};var _0x4fde78=function(_0x52161b,_0x1ca1a2){var _0x255a48=squel[_0xe794('0x46')]()['into'](_0xe794('0x35'))['fromQuery']([_0xe794('0x21'),_0xe794('0x3c'),_0xe794('0x37'),'ListId',_0x1ca1a2,'createdAt','updatedAt'],squel[_0xe794('0x39')]()[_0xe794('0x3a')](_0xe794('0x21'),_0xe794('0x21'))[_0xe794('0x3a')](_0xe794('0x3b'),_0xe794('0x3c'))[_0xe794('0x3a')]('id',_0xe794('0x37'))['field'](LISTID[_0xe794('0x3d')](),_0xe794('0x28'))[_0xe794('0x3a')](_0x52161b['id'][_0xe794('0x3d')](),_0x1ca1a2)[_0xe794('0x3a')](_0xe794('0x3b'),_0xe794('0x3e'))[_0xe794('0x3a')]('NOW()','updatedAt')[_0xe794('0x3f')](_0xe794('0x47'))[_0xe794('0x40')](_0xe794('0x41'))[_0xe794('0x40')](_0xe794('0x42'),LISTID[_0xe794('0x3d')]())[_0xe794('0x40')]('id\x20IN\x20?',squel[_0xe794('0x48')](hopperContacts))[_0xe794('0x40')]('phone\x20IS\x20NOT\x20NULL')[_0xe794('0x40')](_0xe794('0x44'),squel[_0xe794('0x39')]()[_0xe794('0x3a')](_0xe794('0x49'))[_0xe794('0x3f')]('cm_hopper_final')[_0xe794('0x40')](_0x1ca1a2+'\x20=\x20?',_0x52161b['id'][_0xe794('0x3d')]()))[_0xe794('0x40')](_0xe794('0x44'),squel[_0xe794('0x39')]()[_0xe794('0x3a')](_0xe794('0x21'))['from']('cm_hopper')[_0xe794('0x40')](_0x1ca1a2+_0xe794('0x45'),_0x52161b['id']['toString']())))[_0xe794('0x3d')]();return _0x255a48;};function _0x292175(_0x2288cb,_0x4899c7){var _0x238f14=squel[_0xe794('0x46')]()[_0xe794('0x34')](_0xe794('0x35'))[_0xe794('0x36')]([_0xe794('0x21'),_0xe794('0x3c'),_0xe794('0x37'),_0xe794('0x28'),_0x4899c7,_0xe794('0x3e'),_0xe794('0x38')],squel[_0xe794('0x39')]()[_0xe794('0x3a')]('phone',_0xe794('0x21'))[_0xe794('0x3a')]('NOW()',_0xe794('0x3c'))[_0xe794('0x3a')]('id',_0xe794('0x37'))[_0xe794('0x3a')](LISTID[_0xe794('0x3d')](),'ListId')[_0xe794('0x3a')](_0x2288cb['id'][_0xe794('0x3d')](),_0x4899c7)[_0xe794('0x3a')](_0xe794('0x3b'),_0xe794('0x3e'))[_0xe794('0x3a')]('NOW()',_0xe794('0x38'))[_0xe794('0x3f')]('cm_contacts')[_0xe794('0x40')](_0xe794('0x41'))[_0xe794('0x40')]('ListId\x20=\x20?',LISTID[_0xe794('0x3d')]())[_0xe794('0x40')](_0xe794('0x4a'),squel['str'](hopperContacts))[_0xe794('0x40')](_0xe794('0x43')))[_0xe794('0x3d')]();return _0x238f14;}function _0x1140ba(_0x3c11ed,_0x2d5eed){var _0x28918c=squel[_0xe794('0x46')]()[_0xe794('0x34')](_0xe794('0x4b'))[_0xe794('0x36')]([_0xe794('0x21'),_0xe794('0x37'),'ListId',_0x2d5eed,_0xe794('0x3e'),_0xe794('0x38')],squel[_0xe794('0x39')]()[_0xe794('0x3a')](_0xe794('0x21'),'phone')['field']('id',_0xe794('0x37'))[_0xe794('0x3a')](LISTID[_0xe794('0x3d')](),_0xe794('0x28'))[_0xe794('0x3a')](_0x3c11ed['id'][_0xe794('0x3d')](),_0x2d5eed)['field'](_0xe794('0x3b'),_0xe794('0x3e'))[_0xe794('0x3a')]('NOW()','updatedAt')[_0xe794('0x3f')](_0xe794('0x47'))[_0xe794('0x40')](_0xe794('0x41'))['where'](_0xe794('0x42'),LISTID['toString']())[_0xe794('0x40')]('id\x20IN\x20?',squel['str'](hopperContacts))['where'](_0xe794('0x43')))['toString']();return _0x28918c;}return db[_0xe794('0x4c')][_0xe794('0x4d')]({'where':{'type':_0xe794('0x4e')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db[_0xe794('0x4f')],'as':_0xe794('0x50'),'where':{'id':LISTID}}]})[_0xe794('0x2d')](function(_0x1d2b07){var _0x38180a=[];if(_0x1d2b07){var _0x57fec9;for(var _0x266f09=0x0,_0x757ca7;_0x266f09<_0x1d2b07[_0xe794('0x1b')];_0x266f09+=0x1){_0x757ca7=_0x1d2b07[_0x266f09]['get']({'plain':!![]});switch(_0x757ca7[_0xe794('0x51')]){case _0xe794('0x52'):_0x38180a[_0xe794('0x2e')](db[_0xe794('0x53')][_0xe794('0x54')](_0x4fde78(_0x757ca7,_0xe794('0x55')))[_0xe794('0x2d')](function(){})[_0xe794('0x2f')](_0x586769()));break;case _0xe794('0x56'):_0x38180a[_0xe794('0x2e')](db[_0xe794('0x53')][_0xe794('0x54')](_0x83d76f(_0x757ca7,_0xe794('0x55')))[_0xe794('0x2d')](function(){})[_0xe794('0x2f')](_0x586769()));break;default:_0x38180a[_0xe794('0x2e')](db['sequelize'][_0xe794('0x54')](_0x292175(_0x757ca7,'VoiceQueueId'))[_0xe794('0x2d')](function(){})[_0xe794('0x2f')](_0x586769()));}}}return _0x38180a;})[_0xe794('0x57')]()['then'](function(){return db[_0xe794('0x4c')][_0xe794('0x4d')]({'where':{'type':_0xe794('0x4e')},'attributes':['id'],'include':[{'model':db['CmList'],'as':_0xe794('0x58'),'where':{'id':LISTID}}]})[_0xe794('0x2d')](function(_0x1264d3){var _0x182393=[];if(_0x1264d3){var _0x5b9175;for(var _0x4e7a39=0x0,_0x80f4cf;_0x4e7a39<_0x1264d3[_0xe794('0x1b')];_0x4e7a39+=0x1){_0x80f4cf=_0x1264d3[_0x4e7a39][_0xe794('0x59')]({'plain':!![]});_0x182393[_0xe794('0x2e')](db[_0xe794('0x53')][_0xe794('0x54')](_0x1140ba(_0x80f4cf,_0xe794('0x55')))['then'](function(){})[_0xe794('0x2f')](_0x586769()));}}return _0x182393;})[_0xe794('0x57')]();})[_0xe794('0x2d')](function(){return db['Campaign'][_0xe794('0x4d')]({'attributes':['id',_0xe794('0x51')],'include':[{'model':db[_0xe794('0x4f')],'as':_0xe794('0x50'),'where':{'id':LISTID}}]})[_0xe794('0x2d')](function(_0x2bf16a){var _0x33b1ef=[];if(_0x2bf16a){for(var _0xa3edbc=0x0,_0x31d41e;_0xa3edbc<_0x2bf16a[_0xe794('0x1b')];_0xa3edbc+=0x1){_0x31d41e=_0x2bf16a[_0xa3edbc][_0xe794('0x59')]({'plain':!![]});switch(_0x31d41e['dialCheckDuplicateType']){case'always':_0x33b1ef[_0xe794('0x2e')](db['sequelize'][_0xe794('0x54')](_0x4fde78(_0x31d41e,_0xe794('0x5a')))[_0xe794('0x2d')](function(){})[_0xe794('0x2f')](_0x586769()));break;case _0xe794('0x56'):_0x33b1ef[_0xe794('0x2e')](db[_0xe794('0x53')][_0xe794('0x54')](_0x83d76f(_0x31d41e,_0xe794('0x5a')))['then'](function(){})[_0xe794('0x2f')](_0x586769()));break;default:_0x33b1ef[_0xe794('0x2e')](db[_0xe794('0x53')]['query'](_0x292175(_0x31d41e,_0xe794('0x5a')))[_0xe794('0x2d')](function(){})['catch'](_0x586769()));}}}return _0x33b1ef;})[_0xe794('0x57')]();})['then'](function(){return db['Campaign'][_0xe794('0x4d')]({'attributes':['id'],'include':[{'model':db['CmList'],'as':'BlackLists','where':{'id':LISTID}}]})[_0xe794('0x2d')](function(_0x4eb90b){var _0x4d2a82=[];if(_0x4eb90b){for(var _0x2fd8f2=0x0,_0xfb019b;_0x2fd8f2<_0x4eb90b[_0xe794('0x1b')];_0x2fd8f2+=0x1){_0xfb019b=_0x4eb90b[_0x2fd8f2][_0xe794('0x59')]({'plain':!![]});_0x4d2a82[_0xe794('0x2e')](db[_0xe794('0x53')]['query'](_0x1140ba(_0xfb019b,_0xe794('0x5a')))[_0xe794('0x2d')](function(){})[_0xe794('0x2f')](_0x586769()));}}return _0x4d2a82;})[_0xe794('0x57')]();})[_0xe794('0x2f')](function(_0x179c86){logger[_0xe794('0x16')](_0xe794('0x5b'),_0xe794('0x5c'),_0x179c86['message']);});}var processPromises=function(_0x410cde){return BPromise[_0xe794('0x57')](promises)['then'](function(_0x3d5e34){})['catch'](function(_0x266561){logger[_0xe794('0x16')](_0xe794('0x5d'),JSON[_0xe794('0x32')](_0x266561));})[_0xe794('0x5e')](function(){socket['emit'](_0xe794('0x5f')+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});promises=[];success=0x0;errors=0x0;duplicates=0x0;rows=[];if(_0x410cde){return _0x410cde[_0xe794('0x60')]();}});};var endCsv=function(){return BPromise['resolve']()[_0xe794('0x2d')](function(){if(hopperContacts){return checkHopper();}})[_0xe794('0x2d')](function(){socket['emit'](_0xe794('0x5f')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs['unlinkSync'](FILEPATH);}catch(_0x4ae71a){logger['error'](_0xe794('0x61'),JSON[_0xe794('0x32')](_0x4ae71a));}finally{process[_0xe794('0x62')](0x0);}});};process['on'](_0xe794('0x63'),function(){logger['info']('CSV\x20import\x20process\x20stopped!');endCsv();});function main(){return BPromise[_0xe794('0x64')]()[_0xe794('0x2d')](function(){if(DUPLICATES){DUPLICATES=DUPLICATES[_0xe794('0x13')](',');return db['CmContact'][_0xe794('0x4d')]({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});}})[_0xe794('0x2d')](function(_0x6a0da3){var _0x4857ea=fs[_0xe794('0x65')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0xe794('0x66')](_0x4857ea,{'header':!![],'skipEmptyLines':!![],'step':function(_0x2bb2cc,_0x4825ec){total+=0x1;var _0x8ce762=total;promises[_0xe794('0x2e')](checkRow(_0x2bb2cc,_0x6a0da3,_0x8ce762)['then'](function(){success+=0x1;})[_0xe794('0x2f')](function(_0xd63c13){if(_0xd63c13[_0xe794('0x16')]){errors+=0x1;delete _0xd63c13[_0xe794('0x16')];}else if(_0xd63c13[_0xe794('0x2b')]){duplicates+=0x1;delete _0xd63c13[_0xe794('0x2b')];}rows[_0xe794('0x2e')](_0xd63c13);}));if(total%0xc8===0x0){_0x4825ec[_0xe794('0x67')]();return processPromises(_0x4825ec);}},'complete':function(){return processPromises()[_0xe794('0x2d')](function(){logger[_0xe794('0x68')](_0xe794('0x69'));endCsv();});},'error':function(_0x1c51ab,_0x4dd2d5){logger[_0xe794('0x68')](_0xe794('0x6a'),JSON[_0xe794('0x32')](_0x1c51ab));endCsv();}});})[_0xe794('0x2f')](function(_0x3287de){logger[_0xe794('0x16')]('Error\x20executing\x20contact\x20csv\x20import:',JSON['stringify'](_0x3287de));});}main(); \ No newline at end of file diff --git a/server/components/import/cm/csv2.js b/server/components/import/cm/csv2.js new file mode 100644 index 0000000..7e1f534 --- /dev/null +++ b/server/components/import/cm/csv2.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb8f0=['uncaughtException','path','lodash','util','bluebird','moment','squel','ioredis','../../../mysqldb','../../../config/environment','../../../config/environment/shared','../../../config/logger','import','defaults','redis','localhost','format','YYYY-MM-DD\x20HH:mm:ss','test','select','field','from','join','where','\x20=\x20','CmContact','findAll','AdditionalPhones','then','length','push','all','split','isNil','filter','CmContactHasItem','update','updated','create','cm_contacts.phone','cm_contacts.scheduledat','cm_contacts.ListId','cm_contacts.createdAt','cm_contacts.updatedAt','cm_contacts.priority','cm_contacts.UserId','insert','into','fromQuery','phone','scheduledat','createdAt','updatedAt','recallme','fields','cm_contacts','cm_contacts.ListId\x20=\x20','.id\x20=\x20','.CmListId\x20=\x20?','cm_contacts.createdAt\x20=\x20?','cm_contacts.phone\x20NOT\x20IN\x20(?)','cm_hopper','\x22always\x22','\x22onlyIfOpen\x22','cm_hopper_black','ContactId','ListId','priority','UserId','cm_contacts.id','.CmListId','ListId\x20=\x20?','toString','cm_contact_has_items.item','cm_contact_has_items.createdAt','cm_hopper_additional_phones','CmHopperId','OrderBy','cm_contacts.id\x20=\x20cm_hopper.ContactId','cm_contact_has_items','concat','keys','CompanyId',')\x20NOT\x20IN\x20?','MIN(id)','min_id','group','info','Received\x20SIGINT','error','message','exit','errors','code','catch','campaigns.id','campaigns.dialTimezone','campaigns','campaigns_has_cm_lists','campaigns.id\x20=\x20campaigns_has_cm_lists.CampaignId','sequelize','spread','voice_queues.id','voice_queues.dialTimezone','voice_queues_has_cm_lists','voice_queues.id\x20=\x20voice_queues_has_cm_lists.VoiceQueueId','voice_queues_has_cm_lists.CmListId=','query','timezones','dialTimezone','utcOffset','set','stringify','send','binding','socket_timestamp','server/files/tmp','.csv','includes','header','ContactItemType','name','_description','parse','createReadStream','data','rows','find','hasOwnProperty','trim','isValid','scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)','isNaN','isNumber','agent\x20not\x20exists','email','email\x20wrong\x20format','dateOfBirth','YYYY-MM-DD','dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)','\x20not\x20specified','replace','itemTypeId','description','SystemRow','appendFileSync','Abort\x20parser','abort','SystemError','step','duplicates','cm_contacts_','CREATE\x20TABLE\x20','\x20LIKE\x20cm_contacts;','campaigns_','voice_queues_','(id\x20int,dialTimezone\x20varchar(255),offset\x20int);','each','LOAD\x20DATA\x20LOCAL\x20INFILE\x20\x27%s\x27\x20INTO\x20TABLE\x20%s\x20CHARACTER\x20SET\x20UTF8\x20FIELDS\x20TERMINATED\x20BY\x20\x27,\x27\x20ENCLOSED\x20BY\x20\x27\x22\x27\x20LINES\x20TERMINATED\x20BY\x20\x27\x0a\x27\x20IGNORE\x201\x20ROWS\x20(%s)\x20SET\x20id\x20=\x20NULL,\x20ListId\x20=\x20%s,\x20CompanyId\x20=\x20%s,\x20createdAt\x20=\x20\x27%s\x27,\x20updatedAt\x20=\x20\x27%s\x27',',\x20scheduledAt\x20=\x20NOW()','DROP\x20TABLE\x20','contactId','contactTypeId','orderBy','voice_queues','VoiceQueueId','voice_queues_has_cm_blacklists','CampaignId','campaigns_has_cm_blacklists','finish','affectedRows','emit','unlink','complete','argv','arguments\x20\x20\x20','file\x20doesn\x27t\x20exists','binding\x20doesn\x27t\x20exists','phone\x20is\x20mandatory','firstName\x20is\x20mandatory','No\x20agent\x20available','SIGINT'];(function(_0x1e1e0a,_0x23d3f1){var _0x5ab3d6=function(_0x50674b){while(--_0x50674b){_0x1e1e0a['push'](_0x1e1e0a['shift']());}};_0x5ab3d6(++_0x23d3f1);}(_0xb8f0,0x16d));var _0x0b8f=function(_0x5c9a6a,_0x4a5804){_0x5c9a6a=_0x5c9a6a-0x0;var _0x115fef=_0xb8f0[_0x5c9a6a];return _0x115fef;};'use strict';var fs=require('fs');var path=require(_0x0b8f('0x0'));var _=require(_0x0b8f('0x1'));var Papa=require('papaparse');var util=require(_0x0b8f('0x2'));var BPromise=require(_0x0b8f('0x3'));var moment=require(_0x0b8f('0x4'));var squel=require(_0x0b8f('0x5'));var Redis=require(_0x0b8f('0x6'));var db=require(_0x0b8f('0x7'))['db'];var config=require(_0x0b8f('0x8'));var shared=require(_0x0b8f('0x9'));var logger=require(_0x0b8f('0xa'))(_0x0b8f('0xb'));config['redis']=_[_0x0b8f('0xc')](config[_0x0b8f('0xd')],{'host':_0x0b8f('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0b8f('0xd')]));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var promisesAdditionalPhones=[];var orderBy=0x0;var stopped=![];var NOW=moment()[_0x0b8f('0xf')]('YYYY-MM-DD\x20HH:mm:ss');var contactItemTypes=[];var phoneDescriptions=[];var hasAdditionalPhones=![];var tmp_voice_queues;var tmp_campaigns;var tzOffset=0x0;var hasTZ;var NOW=moment()['format'](_0x0b8f('0x10'));function isEmail(_0x4d1823){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0x0b8f('0x11')](_0x4d1823);}function selectNotIn(_0x947b0,_0x4116d8,_0x3a5d9d,_0x49f5bd,_0xa7321b){return squel[_0x0b8f('0x12')]()[_0x0b8f('0x13')]('phone')[_0x0b8f('0x14')](_0x49f5bd)[_0x0b8f('0x15')](_0x4116d8,null,_0x4116d8+'.id\x20=\x20'+_0x49f5bd+'.'+_0x3a5d9d)[_0x0b8f('0x16')](_0x49f5bd+'.'+_0x3a5d9d+_0x0b8f('0x17')+_0x947b0+'.'+_0x3a5d9d)[_0x0b8f('0x16')](_0x4116d8+'.dialCheckDuplicateType\x20IN\x20('+_0xa7321b['join']()+')');}function handleAdditionalPhones(){return new Promise(function(_0x5746f6,_0x23bd6f){promisesAdditionalPhones=[];return db[_0x0b8f('0x18')][_0x0b8f('0x19')]({'raw':!![],'attributes':['id',_0x0b8f('0x1a')],'where':{'createdAt':NOW,'AdditionalPhones':{'$ne':null}}})[_0x0b8f('0x1b')](function(_0x496522){if(_0x496522!==null){var _0x5327bd=[];for(var _0x326c9f=0x0;_0x326c9f<_0x496522[_0x0b8f('0x1c')];_0x326c9f++){var _0x3b5f0f=_0x496522[_0x326c9f];_0x5327bd[_0x0b8f('0x1d')](insertAdditionalPhones(_0x3b5f0f));}}Promise[_0x0b8f('0x1e')](_0x5327bd)['then'](function(){_0x5746f6({'val':0x1});});});});}function insertAdditionalPhones(_0x4e3180){return new Promise(function(_0x2eb80b,_0x26fb76){var _0xfe4a7c=_0x4e3180[_0x0b8f('0x1a')];var _0x1053e0=_0xfe4a7c[_0x0b8f('0x1f')](';');var _0x4158a4=[];orderBy=0x0;for(var _0x4b89a1=0x0;_0x4b89a1<_0x1053e0[_0x0b8f('0x1c')];_0x4b89a1++){_0x4158a4['push'](splitAdditionalPhone(_0x4e3180['id'],_0x1053e0[_0x4b89a1]));}Promise[_0x0b8f('0x1e')](_0x4158a4)['then'](function(){_0x2eb80b({'val':_0x1053e0[_0x0b8f('0x1c')]});});});}function splitAdditionalPhone(_0x3a7ca1,_0x1f3b98){return new Promise(function(_0x147c2d,_0x31365b){var _0x52952d=_0x1f3b98[_0x0b8f('0x1f')](':');var _0x12acb9=_0x52952d[0x0];var _0x4c07c6=_0x52952d[0x1];if(!_[_0x0b8f('0x20')](_0x4c07c6)){var _0x25ef26=_0x4c07c6[_0x0b8f('0x1f')]('|');var _0x274781=[];for(var _0x2f72f1=0x0;_0x2f72f1<_0x25ef26[_0x0b8f('0x1c')];_0x2f72f1++){if(_0x25ef26[_0x2f72f1]!==''){var _0x3e7347=_[_0x0b8f('0x21')](promisesAdditionalPhones,{'contactId':_0x3a7ca1,'phone':_0x25ef26[_0x2f72f1]});if(_0x3e7347['length']==0x0){orderBy++;promisesAdditionalPhones[_0x0b8f('0x1d')]({'contactId':_0x3a7ca1,'contactTypeId':_0x12acb9,'phone':_0x25ef26[_0x2f72f1],'orderBy':orderBy});}}}_0x147c2d({'ok':0x1});}else _0x147c2d({'res':0x0});});}function createAdditionalPhone(_0x1f39ba,_0x2537e1,_0x22cee4,_0x57752c){var _0x2ecf33='';var _0x3c8f15='';var _0x4333ad=_0x22cee4[_0x0b8f('0x1f')]('§');_0x2ecf33=_0x4333ad[0x0];if(_0x4333ad[_0x0b8f('0x1c')]==0x2)_0x3c8f15=_0x4333ad[0x1];return new Promise(function(_0x5f119a,_0x14f801){return db[_0x0b8f('0x22')]['findOne']({'where':{'CmContactId':_0x1f39ba,'item':_0x2ecf33}})['then'](function(_0x2665e1){if(_0x2665e1){return db['CmContactHasItem'][_0x0b8f('0x23')]({'ItemTypeId':_0x2537e1,'description':_0x3c8f15,'OrderBy':_0x57752c},{'where':{'CmContactId':_0x1f39ba,'item':_0x2ecf33}})[_0x0b8f('0x1b')](function(_0x2ebb7e){_0x5f119a({'res':_0x0b8f('0x24')});});}else{return db[_0x0b8f('0x22')][_0x0b8f('0x25')]({'CmContactId':_0x1f39ba,'item':_0x2ecf33,'description':_0x3c8f15,'ItemTypeId':_0x2537e1,'OrderBy':_0x57752c,'ItemClass':'PHONE'})[_0x0b8f('0x1b')](function(_0x3f733a){_0x5f119a({'res':'inserted'});});}});});}function insertCmHopper(_0x45f2b4,_0x21011c,_0x28e301,_0x57f86f,_0xa868ce){var _0x5027e1=[_0x0b8f('0x26'),_0x0b8f('0x27'),'cm_contacts.id',_0x0b8f('0x28'),_0x21011c+'.'+_0x57f86f,_0x0b8f('0x29'),_0x0b8f('0x2a'),_0x0b8f('0x2b'),_0x0b8f('0x2c'),'\x22'+_0xa868ce+'\x22'];return squel[_0x0b8f('0x2d')]()[_0x0b8f('0x2e')]('cm_hopper')[_0x0b8f('0x2f')]([_0x0b8f('0x30'),_0x0b8f('0x31'),'ContactId','ListId',_0x57f86f,_0x0b8f('0x32'),_0x0b8f('0x33'),'priority','UserId',_0x0b8f('0x34')],squel['select']()[_0x0b8f('0x35')](_0x5027e1)['from'](_0x21011c)[_0x0b8f('0x15')](_0x0b8f('0x36'),null,_0x0b8f('0x37')+_0x21011c+'.CmListId')[_0x0b8f('0x15')](_0x28e301,null,_0x28e301+_0x0b8f('0x38')+_0x21011c+'.'+_0x57f86f)['where'](_0x21011c+_0x0b8f('0x39'),_0x45f2b4)[_0x0b8f('0x16')](_0x0b8f('0x3a'),NOW)[_0x0b8f('0x16')](_0x0b8f('0x3b'),selectNotIn(_0x21011c,_0x28e301,_0x57f86f,_0x0b8f('0x3c'),[_0x0b8f('0x3d'),_0x0b8f('0x3e')]))[_0x0b8f('0x16')](_0x0b8f('0x3b'),selectNotIn(_0x21011c,_0x28e301,_0x57f86f,_0x0b8f('0x3c'),[_0x0b8f('0x3d')])))['toString']();}function insertCmHopperBlack(_0x329013,_0x494adb,_0x100330,_0xe716c4){var _0x5f2e29=[_0x0b8f('0x26'),'cm_contacts.id','cm_contacts.ListId',_0x494adb+'.'+_0xe716c4,_0x0b8f('0x29'),'cm_contacts.updatedAt'];return squel[_0x0b8f('0x2d')]()['into'](_0x0b8f('0x3f'))[_0x0b8f('0x2f')]([_0x0b8f('0x30'),_0x0b8f('0x40'),'ListId',_0xe716c4,'createdAt',_0x0b8f('0x33')],squel['select']()[_0x0b8f('0x35')](_0x5f2e29)[_0x0b8f('0x14')](_0x494adb)[_0x0b8f('0x15')](_0x0b8f('0x36'),null,_0x0b8f('0x37')+_0x494adb+'.CmListId')[_0x0b8f('0x15')](_0x100330,null,_0x100330+'.id\x20=\x20'+_0x494adb+'.'+_0xe716c4)['where'](_0x494adb+_0x0b8f('0x39'),_0x329013)[_0x0b8f('0x16')](_0x0b8f('0x3a'),NOW)[_0x0b8f('0x16')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',squel[_0x0b8f('0x12')]()[_0x0b8f('0x13')]('phone')[_0x0b8f('0x14')](_0x0b8f('0x3f'))[_0x0b8f('0x16')]('ListId\x20=\x20?',_0x329013)['where'](_0xe716c4+'\x20=\x20'+_0x494adb+'.'+_0xe716c4)))['toString']();}function insertTzCmHopper(_0x4398cc,_0x3abc2a,_0x4d8072,_0x2487ae,_0x340a32,_0x1f0a69){var _0x54bd04=['cm_contacts.phone','date_add(cm_contacts.scheduledat,interval\x20'+_0x1f0a69+'.offset-cm_contacts.utcOffset\x20minute)','cm_contacts.id',_0x0b8f('0x28'),_0x3abc2a+'.'+_0x2487ae,'cm_contacts.createdAt',_0x0b8f('0x2a'),'cm_contacts.priority',_0x0b8f('0x2c'),'\x22'+_0x340a32+'\x22'];var _0x1b7b5a=squel[_0x0b8f('0x2d')]()['into'](_0x0b8f('0x3c'))[_0x0b8f('0x2f')](['phone',_0x0b8f('0x31'),'ContactId',_0x0b8f('0x41'),_0x2487ae,_0x0b8f('0x32'),_0x0b8f('0x33'),_0x0b8f('0x42'),_0x0b8f('0x43'),'recallme'],squel[_0x0b8f('0x12')]()[_0x0b8f('0x35')](_0x54bd04)[_0x0b8f('0x14')](_0x3abc2a)[_0x0b8f('0x15')](_0x0b8f('0x36'),null,'cm_contacts.ListId\x20=\x20'+_0x3abc2a+'.CmListId')[_0x0b8f('0x15')](_0x4d8072,null,_0x4d8072+'.id\x20=\x20'+_0x3abc2a+'.'+_0x2487ae)[_0x0b8f('0x15')](_0x1f0a69,null,_0x1f0a69+_0x0b8f('0x38')+_0x3abc2a+'.'+_0x2487ae)[_0x0b8f('0x16')](_0x3abc2a+_0x0b8f('0x39'),_0x4398cc)['where'](_0x0b8f('0x3a'),NOW)['where']('cm_contacts.phone\x20NOT\x20IN\x20(?)',selectNotIn(_0x3abc2a,_0x4d8072,_0x2487ae,_0x0b8f('0x3c'),[_0x0b8f('0x3d'),_0x0b8f('0x3e')]))['where'](_0x0b8f('0x3b'),selectNotIn(_0x3abc2a,_0x4d8072,_0x2487ae,_0x0b8f('0x3c'),[_0x0b8f('0x3d')])))['toString']();return _0x1b7b5a;}function insertTzCmHopperBlack(_0x111d16,_0x750f38,_0x33f395,_0x1b2744){var _0x39e143=[_0x0b8f('0x26'),_0x0b8f('0x44'),_0x0b8f('0x28'),_0x750f38+'.'+_0x1b2744,_0x0b8f('0x29'),_0x0b8f('0x2a')];return squel[_0x0b8f('0x2d')]()[_0x0b8f('0x2e')](_0x0b8f('0x3f'))['fromQuery']([_0x0b8f('0x30'),_0x0b8f('0x40'),_0x0b8f('0x41'),_0x1b2744,_0x0b8f('0x32'),_0x0b8f('0x33')],squel['select']()[_0x0b8f('0x35')](_0x39e143)[_0x0b8f('0x14')](_0x750f38)[_0x0b8f('0x15')](_0x0b8f('0x36'),null,_0x0b8f('0x37')+_0x750f38+_0x0b8f('0x45'))[_0x0b8f('0x15')](_0x33f395,null,_0x33f395+_0x0b8f('0x38')+_0x750f38+'.'+_0x1b2744)[_0x0b8f('0x16')](_0x750f38+'.CmListId\x20=\x20?',_0x111d16)[_0x0b8f('0x16')](_0x0b8f('0x3a'),NOW)[_0x0b8f('0x16')]('cm_contacts.phone\x20NOT\x20IN\x20(?)',squel[_0x0b8f('0x12')]()[_0x0b8f('0x13')]('phone')[_0x0b8f('0x14')]('cm_hopper_black')['where'](_0x0b8f('0x46'),_0x111d16)['where'](_0x1b2744+'\x20=\x20'+_0x750f38+'.'+_0x1b2744)))[_0x0b8f('0x47')]();}function insertCmHopperAdditionalPhones(_0x262ae5){var _0x34e848=['cm_hopper.id',_0x0b8f('0x48'),'cm_contact_has_items.OrderBy',_0x0b8f('0x49'),'cm_contact_has_items.updatedAt'];return squel[_0x0b8f('0x2d')]()[_0x0b8f('0x2e')](_0x0b8f('0x4a'))[_0x0b8f('0x2f')]([_0x0b8f('0x4b'),'phone',_0x0b8f('0x4c'),_0x0b8f('0x32'),_0x0b8f('0x33')],squel[_0x0b8f('0x12')]()[_0x0b8f('0x35')](_0x34e848)[_0x0b8f('0x14')](_0x0b8f('0x3c'))['join'](_0x0b8f('0x36'),null,_0x0b8f('0x4d'))[_0x0b8f('0x15')](_0x0b8f('0x4e'),null,'cm_contacts.id\x20=\x20cm_contact_has_items.CmContactId')[_0x0b8f('0x16')]('cm_hopper.ListId\x20=\x20?',_0x262ae5)['where'](_0x0b8f('0x3a'),NOW))[_0x0b8f('0x47')]();}function insertCmContact(_0x177b7d,_0x5f02bf,_0x1e446a,_0x10beed){var _0x10a0b6=_[_0x0b8f('0x4f')](_[_0x0b8f('0x50')](_0x10beed),[_0x0b8f('0x41'),_0x0b8f('0x51'),_0x0b8f('0x32'),'updatedAt']);return squel['insert']()[_0x0b8f('0x2e')](_0x0b8f('0x36'))[_0x0b8f('0x2f')](_0x10a0b6,squel[_0x0b8f('0x12')]()[_0x0b8f('0x35')](_0x10a0b6)[_0x0b8f('0x14')](_0x5f02bf)[_0x0b8f('0x16')]('('+_0x1e446a[_0x0b8f('0x15')](',')+_0x0b8f('0x52'),squel[_0x0b8f('0x12')]()[_0x0b8f('0x35')](_0x1e446a)[_0x0b8f('0x14')](_0x0b8f('0x36'))[_0x0b8f('0x16')](_0x0b8f('0x46'),_0x177b7d)[_0x0b8f('0x16')]('deletedAt\x20IS\x20NULL'))[_0x0b8f('0x16')]('id\x20IN\x20?',squel[_0x0b8f('0x12')]()[_0x0b8f('0x13')](_0x0b8f('0x53'),_0x0b8f('0x54'))['from'](_0x5f02bf)[_0x0b8f('0x55')](_0x1e446a[_0x0b8f('0x15')](','))))[_0x0b8f('0x47')]();}function handleStop(){logger[_0x0b8f('0x56')](_0x0b8f('0x57'));stopped=!![];}function handleUncaughtException(_0x47245b){logger[_0x0b8f('0x58')](_0x47245b[_0x0b8f('0x59')]);process[_0x0b8f('0x5a')](0x1);}function handleError(_0x43eace,_0x5c07e9){stats[_0x0b8f('0x5b')][_0x0b8f('0x1d')]({'name':_0x5c07e9[_0x0b8f('0x5c')],'message':_0x5c07e9[_0x0b8f('0x59')],'row':_0x43eace});}function handleQuery(_0x4a3d41){logger[_0x0b8f('0x56')](_0x4a3d41);return db['sequelize']['query'](_0x4a3d41)['spread'](function(_0x128f93){results['push'](_0x128f93);})[_0x0b8f('0x5d')](function(_0x425d82){logger['error'](_0x425d82['message']);});}function updateTzCampaigns(_0x44653e){return new Promise(function(_0x1cf76b,_0x36d527){var _0x3aab01=squel[_0x0b8f('0x12')]()['fields']([_0x0b8f('0x5e'),_0x0b8f('0x5f')])[_0x0b8f('0x14')](_0x0b8f('0x60'))['join'](_0x0b8f('0x61'),null,_0x0b8f('0x62'))[_0x0b8f('0x16')]('campaigns_has_cm_lists.CmListId='+_0x44653e);db[_0x0b8f('0x63')]['query'](_0x3aab01['toString']())[_0x0b8f('0x64')](function(_0x250af0){var _0x3bbce4=[];for(var _0x32c113=0x0;_0x32c113<_0x250af0[_0x0b8f('0x1c')];_0x32c113++){_0x3bbce4['push'](getTimezoneData(_0x250af0[_0x32c113],tmp_campaigns));}BPromise[_0x0b8f('0x1e')](_0x3bbce4)['then'](function(){_0x1cf76b({'val':0x1});});})['catch'](function(_0x99f3a){logger[_0x0b8f('0x58')](_0x99f3a[_0x0b8f('0x59')]);_0x1cf76b({'val':0x0});});});}function updateTzVoiceQueues(_0x3e34c7){return new Promise(function(_0xb0a673,_0x80c7be){var _0x7ebd9e=squel['select']()[_0x0b8f('0x35')]([_0x0b8f('0x65'),_0x0b8f('0x66')])[_0x0b8f('0x14')]('voice_queues')[_0x0b8f('0x15')](_0x0b8f('0x67'),null,_0x0b8f('0x68'))[_0x0b8f('0x16')](_0x0b8f('0x69')+_0x3e34c7);db[_0x0b8f('0x63')][_0x0b8f('0x6a')](_0x7ebd9e['toString']())[_0x0b8f('0x64')](function(_0xf2a9e1){var _0x5cb232=[];for(var _0x1d58c8=0x0;_0x1d58c8<_0xf2a9e1[_0x0b8f('0x1c')];_0x1d58c8++){_0x5cb232[_0x0b8f('0x1d')](getTimezoneData(_0xf2a9e1[_0x1d58c8],tmp_voice_queues));}BPromise[_0x0b8f('0x1e')](_0x5cb232)[_0x0b8f('0x1b')](function(){_0xb0a673({'val':0x1});});})['catch'](function(_0x59a063){logger[_0x0b8f('0x58')](_0x59a063[_0x0b8f('0x59')]);_0xb0a673({'val':0x0});});});}function getTimezoneData(_0x12d388,_0x22c3b1){return new Promise(function(_0x273e26,_0x77bdfa){var _0x160b24=shared[_0x0b8f('0x6b')];var _0xb6e2c8=_0x160b24[_0x12d388[_0x0b8f('0x6c')]];if(_['isNil'](_0xb6e2c8)){_0x273e26({'ret':0x1});}else{var _0x4071fc=_0xb6e2c8[_0x0b8f('0x6d')];var _0x4665cc=squel[_0x0b8f('0x2d')]()[_0x0b8f('0x2e')](_0x22c3b1)[_0x0b8f('0x6e')]('id',_0x12d388['id'])[_0x0b8f('0x6e')]('offset',_0x4071fc)[_0x0b8f('0x6e')](_0x0b8f('0x6c'),_0x12d388[_0x0b8f('0x6c')])['toString']();return db[_0x0b8f('0x63')][_0x0b8f('0x6a')](_0x4665cc)[_0x0b8f('0x64')](function(_0x3b5901){_0x273e26({'ret':0x1});})[_0x0b8f('0x5d')](function(_0x3a21c7){logger[_0x0b8f('0x58')](_0x3a21c7[_0x0b8f('0x59')]);_0x77bdfa({'ret':0x1});});}});}function handleTZQuery(_0x564baf){logger[_0x0b8f('0x56')](_0x564baf);return db['sequelize'][_0x0b8f('0x6a')](_0x564baf)[_0x0b8f('0x64')](function(_0x27dcd5){})[_0x0b8f('0x5d')](function(_0x57da1d){logger['error'](_0x57da1d[_0x0b8f('0x59')]);});}function main(_0x5bf0f4,_0x1b095a,_0x26689b,_0x50f7df){logger[_0x0b8f('0x56')]('main',_0x5bf0f4,JSON[_0x0b8f('0x6f')](_0x1b095a));process[_0x0b8f('0x70')]('start');var _0x8f5512=_0x1b095a[_0x0b8f('0x71')];var _0x27cf85=_['clone'](_0x8f5512);var _0x4ba93e=_0x1b095a[_0x0b8f('0x72')];var _0x163eb1=path[_0x0b8f('0x15')](config['root'],_0x0b8f('0x73'),_0x4ba93e+_0x0b8f('0x74'));hasTZ=_[_0x0b8f('0x50')](_0x8f5512)[_0x0b8f('0x75')](_0x0b8f('0x6c'));var _0x17b60f=_[_0x0b8f('0x50')](_0x8f5512)[_0x0b8f('0x15')]();logger[_0x0b8f('0x56')](_0x0b8f('0x76'),_0x17b60f);db[_0x0b8f('0x77')][_0x0b8f('0x19')]({'raw':!![],'attributes':['id',_0x0b8f('0x78')]})[_0x0b8f('0x1b')](function(_0x7a7cd0){for(var _0x4ca244=0x0;_0x4ca244<_0x7a7cd0[_0x0b8f('0x1c')];_0x4ca244++){if(_0x7a7cd0[_0x4ca244][_0x0b8f('0x78')]in _0x8f5512){contactItemTypes[_0x0b8f('0x1d')](_0x7a7cd0[_0x4ca244]);delete _0x27cf85[_0x7a7cd0[_0x4ca244][_0x0b8f('0x78')]];hasAdditionalPhones=!![];}for(var _0x16760c in _0x8f5512){if(_0x7a7cd0[_0x4ca244][_0x0b8f('0x78')]+_0x0b8f('0x79')===_0x16760c){phoneDescriptions['push']({'itemTypeId':_0x7a7cd0[_0x4ca244]['id'],'description':_0x16760c});delete _0x27cf85[_0x16760c];}}}if(hasAdditionalPhones)_0x27cf85[_0x0b8f('0x1a')]='';var _0x52fabb=_['keys'](_0x27cf85)[_0x0b8f('0x15')]();logger['info']('header',_0x52fabb);fs['writeFileSync'](_0x163eb1,_0x52fabb+'\x0a');Papa[_0x0b8f('0x7a')](fs[_0x0b8f('0x7b')](_0x5bf0f4),{'header':!![],'skipEmptyLines':!![],'step':function(_0x592c5b,_0x565612){try{for(var _0x20a6af=0x0,_0x5e681a=[];_0x20a6af<_0x592c5b[_0x0b8f('0x7c')][_0x0b8f('0x1c')];_0x20a6af++){stats[_0x0b8f('0x7d')]+=0x1;if(_0x592c5b[_0x0b8f('0x5b')][_0x20a6af]){handleError(_0x592c5b[_0x0b8f('0x7c')][_0x20a6af],_0x592c5b['errors'][_0x20a6af]);}else{var _0xe8a9f5=[];var _0x582504=[];var _0x3c398c={};for(var _0x21e85a in _0x8f5512){let _0x437e08=contactItemTypes[_0x0b8f('0x7e')](_0x570bb8=>_0x570bb8['name']===_0x21e85a);let _0xdc4bd0=contactItemTypes[_0x0b8f('0x7e')](_0x3e188a=>_0x3e188a[_0x0b8f('0x78')]+_0x0b8f('0x79')===_0x21e85a);if(_[_0x0b8f('0x20')](_0x437e08)&&_[_0x0b8f('0x20')](_0xdc4bd0)){if(_0x8f5512[_0x0b8f('0x7f')](_0x21e85a)){if(_0x592c5b['data'][_0x20a6af][_0x8f5512[_0x21e85a]]){var _0x3aa43e=_[_0x0b8f('0x80')](_0x592c5b['data'][_0x20a6af][_0x8f5512[_0x21e85a]]['replace'](/"/g,'\x27'));switch(_0x21e85a){case _0x0b8f('0x31'):var _0xaed7b5=moment(_0x3aa43e,_0x0b8f('0x10'),!![]);if(_0xaed7b5[_0x0b8f('0x81')]()){_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');}else{_0xe8a9f5[_0x0b8f('0x1d')](_0x0b8f('0x82'));}break;case _0x0b8f('0x42'):var _0xe6e7d3=parseInt(_0x3aa43e);_0x3aa43e=_[_0x0b8f('0x83')](_0xe6e7d3)||_0xe6e7d3<0x0||_0xe6e7d3>0x4?_0x50f7df?0x3:0x2:_0xe6e7d3;_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');break;case _0x0b8f('0x43'):var _0xd088de=parseInt(_0x3aa43e);if(_[_0x0b8f('0x84')](_0xd088de)&&_[_0x0b8f('0x75')](_0x26689b,_0xd088de)){_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0xd088de+'\x22');}else{_0xe8a9f5[_0x0b8f('0x1d')](_0x0b8f('0x85'));}break;case _0x0b8f('0x86'):if(isEmail(_0x3aa43e)){_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');}else{_0xe8a9f5[_0x0b8f('0x1d')](_0x0b8f('0x87'));}break;case _0x0b8f('0x88'):var _0x2b04e9=moment(_0x3aa43e,_0x0b8f('0x89'),!![]);if(_0x2b04e9[_0x0b8f('0x81')]()){_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');}else{_0xe8a9f5[_0x0b8f('0x1d')](_0x0b8f('0x8a'));}break;case _0x0b8f('0x6c'):var _0xb671d5=shared[_0x0b8f('0x6b')];var _0x4a936b=_0xb671d5[_0x3aa43e];if(!_[_0x0b8f('0x20')](_0x4a936b)){var _0x517217=_0x4a936b[_0x0b8f('0x6d')];_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x517217+'\x22');}break;default:_0x5e681a[_0x0b8f('0x1d')]('\x22'+_0x3aa43e+'\x22');}}else{switch(_0x21e85a){case'firstName':case _0x0b8f('0x30'):_0xe8a9f5['push'](_0x21e85a+_0x0b8f('0x8b'));break;default:_0x5e681a['push']('\x22\x22');}}}}else{var _0x575251='';if(!_[_0x0b8f('0x20')](_0x437e08)){if(!_0x3c398c[_0x0b8f('0x7f')](_0x437e08['id'])){if(!_[_0x0b8f('0x20')](_0x592c5b['data'][_0x20a6af][_0x8f5512[_0x21e85a]])){var _0x3aa43e=_[_0x0b8f('0x80')](_0x592c5b[_0x0b8f('0x7c')][_0x20a6af][_0x8f5512[_0x21e85a]][_0x0b8f('0x8c')](/"/g,'\x27'));var _0x52890d=phoneDescriptions[_0x0b8f('0x7e')](_0x7abde=>_0x7abde[_0x0b8f('0x8d')]===_0x437e08['id']);if(!_[_0x0b8f('0x20')](_0x52890d)){var _0x223a1c=_[_0x0b8f('0x80')](_0x592c5b[_0x0b8f('0x7c')][_0x20a6af][_0x8f5512[_0x52890d[_0x0b8f('0x8e')]]][_0x0b8f('0x8c')](/"/g,'\x27'));if(!_[_0x0b8f('0x20')](_0x223a1c))_0x3aa43e=_0x3aa43e+'§'+_0x223a1c;}if(_0x575251=='')_0x575251=_0x3aa43e;else _0x575251+='|'+_0x3aa43e;}_0x582504[_0x0b8f('0x1d')](_0x437e08['id']+':'+_0x575251);_0x3c398c[_0x437e08['id']]=0x1;}}}}if(hasAdditionalPhones){_0x5e681a['push']('\x22'+_0x582504[_0x0b8f('0x15')](';')+'\x22');}if(_0xe8a9f5[_0x0b8f('0x1c')]){handleError(_0x592c5b[_0x0b8f('0x7c')][_0x20a6af],{'code':_0x0b8f('0x8f'),'message':_0xe8a9f5[_0x0b8f('0x15')]()});}else{fs[_0x0b8f('0x90')](_0x163eb1,_0x5e681a[_0x0b8f('0x15')]()+'\x0a');}_0x5e681a=[];}if(!(stats[_0x0b8f('0x7d')]%0xc8)){socket['emit']('contact:import:'+_0x4ba93e,stats);stats[_0x0b8f('0x5b')]=[];}}if(stopped){logger[_0x0b8f('0x56')](_0x0b8f('0x91'));_0x565612[_0x0b8f('0x92')]();}}catch(_0x31ee1d){handleError(_0x592c5b[_0x0b8f('0x7c')][_0x20a6af],{'code':_0x0b8f('0x93'),'message':_0x31ee1d[_0x0b8f('0x59')]});logger[_0x0b8f('0x58')](_0x0b8f('0x94'),_0x31ee1d[_0x0b8f('0x59')]);}},'complete':function(){try{var _0x553d62=[];var _0x30b5f1=[];var _0x2afa48='cm_contacts';if(_0x1b095a['duplicates']&&_0x1b095a[_0x0b8f('0x95')]['length']){_0x2afa48=_0x0b8f('0x96')+_0x4ba93e;_0x553d62['push'](_0x0b8f('0x97')+_0x2afa48+_0x0b8f('0x98'));}tmp_campaigns=_0x0b8f('0x99')+_0x4ba93e;tmp_voice_queues=_0x0b8f('0x9a')+_0x4ba93e;_0x30b5f1['push'](_0x0b8f('0x97')+tmp_campaigns+_0x0b8f('0x9b'));_0x30b5f1[_0x0b8f('0x1d')]('CREATE\x20TABLE\x20'+tmp_voice_queues+_0x0b8f('0x9b'));BPromise[_0x0b8f('0x9c')](_0x30b5f1,handleTZQuery)[_0x0b8f('0x1b')](function(_0x16b41a){updateTzCampaigns(_0x1b095a[_0x0b8f('0x41')])[_0x0b8f('0x1b')](function(_0x49ddef){updateTzVoiceQueues(_0x1b095a[_0x0b8f('0x41')])[_0x0b8f('0x1b')](function(_0x5be9cb){if(hasTZ)_0x52fabb=_0x52fabb['replace'](_0x0b8f('0x6c'),'dialTimezone,utcOffset');var _0x2f2d4d=util['format'](_0x0b8f('0x9d'),_0x163eb1,_0x2afa48,_0x52fabb,_0x1b095a[_0x0b8f('0x41')],_0x1b095a[_0x0b8f('0x51')]||null,NOW,NOW);if(_[_0x0b8f('0x20')](_0x8f5512['scheduledat'])){_0x2f2d4d+=_0x0b8f('0x9e');}_0x553d62[_0x0b8f('0x1d')](_0x2f2d4d);if(_0x1b095a[_0x0b8f('0x95')]&&_0x1b095a[_0x0b8f('0x95')][_0x0b8f('0x1c')]){_0x553d62['push'](insertCmContact(_0x1b095a['ListId'],_0x2afa48,_0x1b095a['duplicates'],_0x8f5512));_0x553d62['push'](_0x0b8f('0x9f')+_0x2afa48+';');}BPromise[_0x0b8f('0x9c')](_0x553d62,handleQuery)[_0x0b8f('0x1b')](function(_0x25997a){BPromise[_0x0b8f('0x1e')]([handleAdditionalPhones()])[_0x0b8f('0x1b')](function(){_0x553d62=[];for(var _0x3ff80a=0x0;_0x3ff80a\x20\x20','server/files/tmp','existsSync','file\x20doesn\x27t\x20exists','ListId\x20is\x20mandatory','body\x20id\x20mandatory','map','No\x20agent\x20available','uncaughtException','path','util','bluebird','moment','squel','../../../mysqldb','../../../config/logger','redis','defaults','socket.io-emitter','format','YYYY-MM-DD\x20HH:mm:ss','YYYYMMDDHHmmss','select','field','phone','from','join','.id\x20=\x20','where','\x20=\x20','.dialCheckDuplicateType\x20IN\x20(','sequelize','query','select\x20*\x20from\x20','length','isNil','AdditionalPhones','all','then','catch','error','message','split','push','filter','CmContactHasItem','findOne','update','updated','PHONE','inserted','CmContact','cm_contacts.scheduledat','cm_contacts.id','cm_contacts.ListId','cm_contacts.createdAt','cm_contacts.updatedAt','cm_contacts.priority','cm_contacts.UserId','insert','into','cm_hopper','ContactId','ListId','createdAt','priority','UserId','recallme','fields','cm_contacts','cm_contacts.ListId\x20=\x20','.CmListId\x20=\x20?','cm_contacts.createdAt\x20=\x20?','cm_contacts.phone\x20NOT\x20IN\x20(?)','\x22always\x22','\x22onlyIfOpen\x22','cm_contacts.phone','cm_hopper_black','fromQuery','ListId\x20=\x20?','\x20=\x20?','cm_contact_has_items.item','cm_contact_has_items.OrderBy','cm_contact_has_items.updatedAt','cm_hopper_additional_phones','OrderBy','updatedAt','cm_contacts.id\x20=\x20cm_hopper.ContactId','cm_contacts.id\x20=\x20cm_contact_has_items.CmContactId','cm_hopper.ListId\x20=\x20?','toString','keys',')\x20NOT\x20IN\x20?','MIN(id)','min_id','info','errors','code','spread','start','binding','clone','socket_timestamp','root','.csv','body','ContactItemType','findAll','name','_description','header','writeFileSync','createReadStream','data','rows','find','trim','replace','isValid','scheduledat\x20wrong\x20format\x20(YYYY-MM-DD\x20HH:mm:ss)','isNaN','isNumber','includes','agent\x20not\x20exists','email','email\x20wrong\x20format','dateOfBirth','YYYY-MM-DD','firstName','\x20not\x20specified','hasOwnProperty','itemTypeId','SystemRow','appendFileSync','emit','contact:import:','Abort\x20parser','abort','SystemError','CREATE\x20TABLE\x20','\x20LIKE\x20cm_contacts;','CIS\x20len','LOAD\x20DATA\x20LOCAL\x20INFILE\x20\x27%s\x27\x20INTO\x20TABLE\x20%s\x20CHARACTER\x20SET\x20UTF8\x20FIELDS\x20TERMINATED\x20BY\x20\x27,\x27\x20ENCLOSED\x20BY\x20\x27\x22\x27\x20LINES\x20TERMINATED\x20BY\x20\x27\x0a\x27\x20IGNORE\x201\x20ROWS\x20(%s)\x20SET\x20ListId\x20=\x20%s,\x20CompanyId\x20=\x20%s,\x20createdAt\x20=\x20\x27%s\x27,\x20updatedAt\x20=\x20\x27%s\x27','CompanyId',',\x20scheduledAt\x20=\x20NOW()','contact','contactTypeId','orderBy','each','affectedRows'];(function(_0x4af038,_0x354822){var _0x5a12f4=function(_0xe71ae1){while(--_0xe71ae1){_0x4af038['push'](_0x4af038['shift']());}};_0x5a12f4(++_0x354822);}(_0x86dc,0x13e));var _0xc86d=function(_0x12e211,_0x28da09){_0x12e211=_0x12e211-0x0;var _0xef2553=_0x86dc[_0x12e211];return _0xef2553;};'use strict';var fs=require('fs');var path=require(_0xc86d('0x0'));var _=require('lodash');var Papa=require('papaparse');var util=require(_0xc86d('0x1'));var BPromise=require(_0xc86d('0x2'));var moment=require(_0xc86d('0x3'));var squel=require(_0xc86d('0x4'));var Redis=require('ioredis');var db=require(_0xc86d('0x5'))['db'];var config=require('../../../config/environment');var logger=require(_0xc86d('0x6'))('import');config[_0xc86d('0x7')]=_[_0xc86d('0x8')](config[_0xc86d('0x7')],{'host':'localhost','port':0x18eb});var socket=require(_0xc86d('0x9'))(new Redis(config['redis']));var stats={'finish':![],'errors':[],'rows':0x0,'affectedRows':0x0};var results=[];var promisesAdditionalPhones=[];var promisesContact=[];var orderBy=0x0;var updatedRows=0x0;var stopped=![];var NOW=moment()[_0xc86d('0xa')](_0xc86d('0xb'));var tempTableName='cm_contacts_temp_'+moment()['format'](_0xc86d('0xc'));var contactItemTypes=[];var phoneDescriptions=[];var hasAdditionalPhones=![];function isEmail(_0x47086a){return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/['test'](_0x47086a);}function selectNotIn(_0x2963c9,_0x332344,_0x41b7dd,_0x44e5dc,_0x1aebff){return squel[_0xc86d('0xd')]()[_0xc86d('0xe')](_0xc86d('0xf'))[_0xc86d('0x10')](_0x44e5dc)[_0xc86d('0x11')](_0x332344,null,_0x332344+_0xc86d('0x12')+_0x44e5dc+'.'+_0x41b7dd)[_0xc86d('0x13')](_0x44e5dc+'.'+_0x41b7dd+_0xc86d('0x14')+_0x2963c9+'.'+_0x41b7dd)[_0xc86d('0x13')](_0x332344+_0xc86d('0x15')+_0x1aebff[_0xc86d('0x11')]()+')');}function handleAdditionalPhones(){return new Promise(function(_0x176ce1,_0x313c16){promisesAdditionalPhones=[];promisesContact=[];return db[_0xc86d('0x16')][_0xc86d('0x17')](_0xc86d('0x18')+tempTableName)['spread'](function(_0x4fb8e7){if(_0x4fb8e7!==null){var _0x49af1f=[];for(var _0x3a253c=0x0;_0x3a253c<_0x4fb8e7[_0xc86d('0x19')];_0x3a253c++){var _0x17f576=_0x4fb8e7[_0x3a253c];if(!_[_0xc86d('0x1a')](_0x17f576[_0xc86d('0xf')])){if(!_[_0xc86d('0x1a')](_0x17f576[_0xc86d('0x1b')]))_0x49af1f['push'](insertAdditionalPhones(_0x17f576));promisesContact['push']({'contact':_0x17f576});}}}Promise[_0xc86d('0x1c')](_0x49af1f)[_0xc86d('0x1d')](function(){_0x176ce1({'val':0x1});});})[_0xc86d('0x1e')](function(_0x56f510){logger[_0xc86d('0x1f')](_0x56f510[_0xc86d('0x20')]);});});}function insertAdditionalPhones(_0x4f1efc){return new Promise(function(_0x4eb0e5,_0x330c70){var _0x210043=_0x4f1efc['AdditionalPhones'];if(_[_0xc86d('0x1a')](_0x210043))_0x330c70({'val':0x0});else{var _0x1adaaa=_0x210043[_0xc86d('0x21')](';');var _0x27ebd8=[];orderBy=0x0;for(var _0x57d804=0x0;_0x57d804<_0x1adaaa[_0xc86d('0x19')];_0x57d804++){_0x27ebd8[_0xc86d('0x22')](splitAdditionalPhone(_0x4f1efc['id'],_0x1adaaa[_0x57d804]));}Promise[_0xc86d('0x1c')](_0x27ebd8)[_0xc86d('0x1d')](function(){_0x4eb0e5({'val':_0x1adaaa[_0xc86d('0x19')]});});}});}function splitAdditionalPhone(_0x56278d,_0x38fb11){return new Promise(function(_0x419afa,_0x41de64){var _0xd59e7b=_0x38fb11[_0xc86d('0x21')](':');var _0x5347f7=_0xd59e7b[0x0];var _0x1458fe=_0xd59e7b[0x1];if(_0x1458fe!==''){var _0x54303e=_0x1458fe['split']('|');var _0x533cce=[];for(var _0x2782b8=0x0;_0x2782b8<_0x54303e[_0xc86d('0x19')];_0x2782b8++){if(_0x54303e[_0x2782b8]!==''){var _0x273c5a=_[_0xc86d('0x23')](promisesAdditionalPhones,{'contactId':_0x56278d,'phone':_0x54303e[_0x2782b8]});if(_0x273c5a[_0xc86d('0x19')]==0x0){orderBy++;promisesAdditionalPhones[_0xc86d('0x22')]({'contactId':_0x56278d,'contactTypeId':_0x5347f7,'phone':_0x54303e[_0x2782b8],'orderBy':orderBy});}}}_0x419afa({'ok':0x1});}else _0x419afa({'res':0x0});});}function createAdditionalPhone(_0x2fabc0,_0x2a35b3,_0x4db581,_0x397a55){var _0x2bce7b='';var _0x581a9e='';var _0x5cf11a=_0x4db581[_0xc86d('0x21')]('§');_0x2bce7b=_0x5cf11a[0x0];if(_0x5cf11a[_0xc86d('0x19')]==0x2)_0x581a9e=_0x5cf11a[0x1];return new Promise(function(_0x54a9f6,_0x271b23){return db[_0xc86d('0x24')][_0xc86d('0x25')]({'where':{'CmContactId':_0x2fabc0,'item':_0x2bce7b}})[_0xc86d('0x1d')](function(_0x5a4ef1){if(_0x5a4ef1){return db['CmContactHasItem'][_0xc86d('0x26')]({'ItemTypeId':_0x2a35b3,'description':_0x581a9e,'OrderBy':_0x397a55},{'where':{'CmContactId':_0x2fabc0,'item':_0x2bce7b}})[_0xc86d('0x1d')](function(_0x18e468){_0x54a9f6({'res':_0xc86d('0x27')});});}else{return db[_0xc86d('0x24')]['create']({'CmContactId':_0x2fabc0,'item':_0x2bce7b,'ItemTypeId':_0x2a35b3,'description':_0x581a9e,'OrderBy':_0x397a55,'ItemClass':_0xc86d('0x28')})['then'](function(_0xc539d0){_0x54a9f6({'res':_0xc86d('0x29')});});}});});}function updateContact(_0x1f01f7){return new Promise(function(_0x21377a,_0x3a469d){var _0x1d7fe8=_0x1f01f7['id'];delete _0x1f01f7['id'];return db[_0xc86d('0x2a')][_0xc86d('0x26')](_0x1f01f7,{'where':{'id':_0x1d7fe8}})[_0xc86d('0x1d')](function(_0x4e51bd){updatedRows+=0x1;return db['CmHopper']['update']({'phone':_0x1f01f7['phone']},{'where':{'ContactId':_0x1d7fe8}})['then'](function(_0x514cf0){_0x21377a({'ret':'OK'});});});});}function insertCmHopper(_0x412dd7,_0x44f4fa,_0x3fa1dd,_0x118007,_0x2cba68){var _0x225a25=['cm_contacts.phone',_0xc86d('0x2b'),_0xc86d('0x2c'),_0xc86d('0x2d'),_0x44f4fa+'.'+_0x118007,_0xc86d('0x2e'),_0xc86d('0x2f'),_0xc86d('0x30'),_0xc86d('0x31'),'\x22'+_0x2cba68+'\x22'];return squel[_0xc86d('0x32')]()[_0xc86d('0x33')](_0xc86d('0x34'))['fromQuery']([_0xc86d('0xf'),'scheduledat',_0xc86d('0x35'),_0xc86d('0x36'),_0x118007,_0xc86d('0x37'),'updatedAt',_0xc86d('0x38'),_0xc86d('0x39'),_0xc86d('0x3a')],squel['select']()[_0xc86d('0x3b')](_0x225a25)[_0xc86d('0x10')](_0x44f4fa)[_0xc86d('0x11')](_0xc86d('0x3c'),null,_0xc86d('0x3d')+_0x44f4fa+'.CmListId')[_0xc86d('0x11')](_0x3fa1dd,null,_0x3fa1dd+_0xc86d('0x12')+_0x44f4fa+'.'+_0x118007)[_0xc86d('0x13')](_0x44f4fa+_0xc86d('0x3e'),_0x412dd7)[_0xc86d('0x13')](_0xc86d('0x3f'),NOW)['where'](_0xc86d('0x40'),selectNotIn(_0x44f4fa,_0x3fa1dd,_0x118007,'cm_hopper',[_0xc86d('0x41'),_0xc86d('0x42')]))[_0xc86d('0x13')](_0xc86d('0x40'),selectNotIn(_0x44f4fa,_0x3fa1dd,_0x118007,'cm_hopper',['\x22always\x22'])))['toString']();}function insertCmHopperBlack(_0x9841ff,_0x1a583b,_0x172f7b,_0x2c3f3d){var _0x549023=[_0xc86d('0x43'),_0xc86d('0x2c'),_0xc86d('0x2d'),_0x1a583b+'.'+_0x2c3f3d,_0xc86d('0x2e'),_0xc86d('0x2f')];return squel['insert']()[_0xc86d('0x33')](_0xc86d('0x44'))[_0xc86d('0x45')]([_0xc86d('0xf'),'ContactId',_0xc86d('0x36'),_0x2c3f3d,'createdAt','updatedAt'],squel[_0xc86d('0xd')]()['fields'](_0x549023)[_0xc86d('0x10')](_0x1a583b)[_0xc86d('0x11')](_0xc86d('0x3c'),null,_0xc86d('0x3d')+_0x1a583b+'.CmListId')[_0xc86d('0x11')](_0x172f7b,null,_0x172f7b+_0xc86d('0x12')+_0x1a583b+'.'+_0x2c3f3d)[_0xc86d('0x13')](_0x1a583b+'.CmListId\x20=\x20?',_0x9841ff)['where'](_0xc86d('0x3f'),NOW)['where'](_0xc86d('0x40'),squel[_0xc86d('0xd')]()[_0xc86d('0xe')]('phone')['from'](_0xc86d('0x44'))[_0xc86d('0x13')](_0xc86d('0x46'),_0x9841ff)['where'](_0x2c3f3d+_0xc86d('0x47'),_0x1a583b+'.'+_0x2c3f3d)))['toString']();}function insertCmHopperAdditionalPhones(_0x280298){var _0x2e9fc3=['cm_hopper.id',_0xc86d('0x48'),_0xc86d('0x49'),'cm_contact_has_items.createdAt',_0xc86d('0x4a')];return squel['insert']()[_0xc86d('0x33')](_0xc86d('0x4b'))[_0xc86d('0x45')](['CmHopperId','phone',_0xc86d('0x4c'),_0xc86d('0x37'),_0xc86d('0x4d')],squel[_0xc86d('0xd')]()['fields'](_0x2e9fc3)[_0xc86d('0x10')](_0xc86d('0x34'))[_0xc86d('0x11')](_0xc86d('0x3c'),null,_0xc86d('0x4e'))[_0xc86d('0x11')]('cm_contact_has_items',null,_0xc86d('0x4f'))[_0xc86d('0x13')](_0xc86d('0x50'),_0x280298)[_0xc86d('0x13')](_0xc86d('0x3f'),NOW))[_0xc86d('0x51')]();}function insertCmContact(_0x1c9b8a,_0x19ada6,_0x5b6fdb,_0x4f57f7){var _0x345c35=_['concat'](_[_0xc86d('0x52')](_0x4f57f7),[_0xc86d('0x36'),'CompanyId',_0xc86d('0x37'),_0xc86d('0x4d')]);return squel[_0xc86d('0x32')]()[_0xc86d('0x33')](_0xc86d('0x3c'))[_0xc86d('0x45')](_0x345c35,squel[_0xc86d('0xd')]()[_0xc86d('0x3b')](_0x345c35)['from'](_0x19ada6)[_0xc86d('0x13')]('('+_0x5b6fdb[_0xc86d('0x11')](',')+_0xc86d('0x53'),squel[_0xc86d('0xd')]()['fields'](_0x5b6fdb)[_0xc86d('0x10')]('cm_contacts')[_0xc86d('0x13')](_0xc86d('0x46'),_0x1c9b8a))[_0xc86d('0x13')]('id\x20IN\x20?',squel[_0xc86d('0xd')]()[_0xc86d('0xe')](_0xc86d('0x54'),_0xc86d('0x55'))['from'](_0x19ada6)['group'](_0x5b6fdb[_0xc86d('0x11')](','))))['toString']();}function handleStop(){logger[_0xc86d('0x56')]('Received\x20SIGINT');stopped=!![];}function handleUncaughtException(_0x41b5ce){logger[_0xc86d('0x1f')](_0x41b5ce[_0xc86d('0x20')]);process['exit'](0x1);}function handleError(_0x48895c,_0x4f0d12){stats[_0xc86d('0x57')][_0xc86d('0x22')]({'name':_0x4f0d12[_0xc86d('0x58')],'message':_0x4f0d12[_0xc86d('0x20')],'row':_0x48895c});}function handleQuery(_0x7a5d0c){logger[_0xc86d('0x56')](_0x7a5d0c);return db['sequelize']['query'](_0x7a5d0c)[_0xc86d('0x59')](function(_0x6f90f0){results[_0xc86d('0x22')](_0x6f90f0);})[_0xc86d('0x1e')](function(_0x379b99){logger[_0xc86d('0x1f')](_0x379b99[_0xc86d('0x20')]);});}function main(_0xb8425b,_0x4719bc,_0x4be771,_0x17ef2a){logger[_0xc86d('0x56')]('main',_0xb8425b,JSON['stringify'](_0x4719bc));process['send'](_0xc86d('0x5a'));var _0x1d92d8=_0x4719bc[_0xc86d('0x5b')];var _0x1c96ca=_[_0xc86d('0x5c')](_0x1d92d8);var _0x2ce87b=_0x4719bc[_0xc86d('0x5d')];var _0xf99be1=path['join'](config[_0xc86d('0x5e')],'server/files/tmp',_0x2ce87b+_0xc86d('0x5f'));logger[_0xc86d('0x56')](_0xc86d('0x60'),_0x4719bc);db[_0xc86d('0x61')][_0xc86d('0x62')]({'raw':!![],'attributes':['id',_0xc86d('0x63')]})[_0xc86d('0x1d')](function(_0x28e54c){for(var _0x475ff8=0x0;_0x475ff8<_0x28e54c[_0xc86d('0x19')];_0x475ff8++){if(_0x28e54c[_0x475ff8][_0xc86d('0x63')]in _0x1d92d8){contactItemTypes[_0xc86d('0x22')](_0x28e54c[_0x475ff8]);delete _0x1c96ca[_0x28e54c[_0x475ff8]['name']];hasAdditionalPhones=!![];}for(var _0x25e122 in _0x1d92d8){if(_0x28e54c[_0x475ff8][_0xc86d('0x63')]+_0xc86d('0x64')===_0x25e122){phoneDescriptions[_0xc86d('0x22')]({'itemTypeId':_0x28e54c[_0x475ff8]['id'],'description':_0x25e122});delete _0x1c96ca[_0x25e122];}}}if(hasAdditionalPhones)_0x1c96ca[_0xc86d('0x1b')]='';var _0x34741d=_['keys'](_0x1c96ca)['join']();logger[_0xc86d('0x56')](_0xc86d('0x65'),_0x34741d);fs[_0xc86d('0x66')](_0xf99be1,_0x34741d+'\x0a');Papa['parse'](fs[_0xc86d('0x67')](_0xb8425b),{'header':!![],'skipEmptyLines':!![],'step':function(_0x2172c3,_0x542d27){try{for(var _0x5005a4=0x0,_0x129ba9=[];_0x5005a4<_0x2172c3[_0xc86d('0x68')][_0xc86d('0x19')];_0x5005a4++){stats[_0xc86d('0x69')]+=0x1;if(_0x2172c3[_0xc86d('0x57')][_0x5005a4]){handleError(_0x2172c3[_0xc86d('0x68')][_0x5005a4],_0x2172c3[_0xc86d('0x57')][_0x5005a4]);}else{var _0x3cd23d=[];var _0x1b5ea7=[];var _0xd550a3={};for(var _0x34b080 in _0x1d92d8){let _0x296736=contactItemTypes[_0xc86d('0x6a')](_0x160cb1=>_0x160cb1[_0xc86d('0x63')]===_0x34b080);let _0x21babf=contactItemTypes[_0xc86d('0x6a')](_0x32149b=>_0x32149b['name']+_0xc86d('0x64')===_0x34b080);if(_[_0xc86d('0x1a')](_0x296736)&&_['isNil'](_0x21babf)){if(_0x1d92d8['hasOwnProperty'](_0x34b080)){if(_0x2172c3[_0xc86d('0x68')][_0x5005a4][_0x1d92d8[_0x34b080]]){var _0xce0099=_[_0xc86d('0x6b')](_0x2172c3[_0xc86d('0x68')][_0x5005a4][_0x1d92d8[_0x34b080]][_0xc86d('0x6c')](/"/g,'\x27'));switch(_0x34b080){case'scheduledat':var _0x2b3fd3=moment(_0xce0099,_0xc86d('0xb'),!![]);if(_0x2b3fd3[_0xc86d('0x6d')]()){_0x129ba9[_0xc86d('0x22')]('\x22'+_0xce0099+'\x22');}else{_0x3cd23d[_0xc86d('0x22')](_0xc86d('0x6e'));}break;case _0xc86d('0x38'):var _0x526e22=parseInt(_0xce0099);_0xce0099=_[_0xc86d('0x6f')](_0x526e22)||_0x526e22<0x0||_0x526e22>0x4?_0x17ef2a?0x3:0x2:_0x526e22;_0x129ba9[_0xc86d('0x22')]('\x22'+_0xce0099+'\x22');break;case _0xc86d('0x39'):var _0x48224e=parseInt(_0xce0099);if(_[_0xc86d('0x70')](_0x48224e)&&_[_0xc86d('0x71')](_0x4be771,_0x48224e)){_0x129ba9[_0xc86d('0x22')]('\x22'+_0x48224e+'\x22');}else{_0x3cd23d[_0xc86d('0x22')](_0xc86d('0x72'));}break;case _0xc86d('0x73'):if(isEmail(_0xce0099)){_0x129ba9[_0xc86d('0x22')]('\x22'+_0xce0099+'\x22');}else{_0x3cd23d[_0xc86d('0x22')](_0xc86d('0x74'));}break;case _0xc86d('0x75'):var _0x13c6a5=moment(_0xce0099,_0xc86d('0x76'),!![]);if(_0x13c6a5[_0xc86d('0x6d')]()){_0x129ba9[_0xc86d('0x22')]('\x22'+_0xce0099+'\x22');}else{_0x3cd23d[_0xc86d('0x22')]('dateOfBirth\x20wrong\x20format\x20(YYYY-MM-DD)');}break;default:_0x129ba9[_0xc86d('0x22')]('\x22'+_0xce0099+'\x22');}}else{switch(_0x34b080){case _0xc86d('0x77'):case _0xc86d('0xf'):_0x3cd23d['push'](_0x34b080+_0xc86d('0x78'));break;default:_0x129ba9[_0xc86d('0x22')]('\x22\x22');}}}}else{var _0xee93da='';if(!_[_0xc86d('0x1a')](_0x296736)){if(!_0xd550a3[_0xc86d('0x79')](_0x296736['id'])){for(var _0x90a73f=0x0;_0x90a73f<_0x1d92d8[_0x34b080]['length'];_0x90a73f++){var _0xce0099=_[_0xc86d('0x6b')](_0x2172c3['data'][_0x5005a4][_0x1d92d8[_0x34b080][_0x90a73f]][_0xc86d('0x6c')](/"/g,'\x27'));var _0x1cb58c=phoneDescriptions[_0xc86d('0x6a')](_0x5a34c5=>_0x5a34c5[_0xc86d('0x7a')]===_0x296736['id']);if(!_[_0xc86d('0x1a')](_0x1cb58c)){var _0x306e0a=_[_0xc86d('0x6b')](_0x2172c3[_0xc86d('0x68')][_0x5005a4][_0x1d92d8[_0x1cb58c['description']][0x0]]['replace'](/"/g,'\x27'));if(!_[_0xc86d('0x1a')](_0x306e0a))_0xce0099=_0xce0099+'§'+_0x306e0a;}if(_0xee93da=='')_0xee93da=_0xce0099;else _0xee93da+='|'+_0xce0099;}_0x1b5ea7['push'](_0x296736['id']+':'+_0xee93da);_0xd550a3[_0x296736['id']]=0x1;}}}}if(hasAdditionalPhones){_0x129ba9['push']('\x22'+_0x1b5ea7[_0xc86d('0x11')](';')+'\x22');}if(_0x3cd23d['length']){handleError(_0x2172c3[_0xc86d('0x68')][_0x5005a4],{'code':_0xc86d('0x7b'),'message':_0x3cd23d[_0xc86d('0x11')]()});}else{fs[_0xc86d('0x7c')](_0xf99be1,_0x129ba9[_0xc86d('0x11')]()+'\x0a');}_0x129ba9=[];}if(!(stats[_0xc86d('0x69')]%0xc8)){socket[_0xc86d('0x7d')](_0xc86d('0x7e')+_0x2ce87b,stats);stats[_0xc86d('0x57')]=[];}}if(stopped){logger[_0xc86d('0x56')](_0xc86d('0x7f'));_0x542d27[_0xc86d('0x80')]();}}catch(_0x44adc8){handleError(_0x2172c3['data'][_0x5005a4],{'code':_0xc86d('0x81'),'message':_0x44adc8[_0xc86d('0x20')]});logger['error']('step',_0x44adc8['message']);}},'complete':function(){try{var _0x2789ad=[];var _0x294128=tempTableName;_0x2789ad[_0xc86d('0x22')](_0xc86d('0x82')+_0x294128+_0xc86d('0x83'));logger[_0xc86d('0x56')](_0xc86d('0x84'),contactItemTypes['length']);var _0xeea1a8=util[_0xc86d('0xa')](_0xc86d('0x85'),_0xf99be1,_0x294128,_0x34741d,_0x4719bc['ListId'],_0x4719bc[_0xc86d('0x86')]||null,NOW,NOW);if(_[_0xc86d('0x1a')](_0x1d92d8['scheduledat'])){_0xeea1a8+=_0xc86d('0x87');}_0x2789ad[_0xc86d('0x22')](_0xeea1a8);BPromise['each'](_0x2789ad,handleQuery)[_0xc86d('0x1d')](function(_0x54998e){BPromise[_0xc86d('0x1c')]([handleAdditionalPhones()])[_0xc86d('0x1d')](function(){_0x2789ad=[];for(var _0x449c2f=0x0;_0x449c2f\x20\x27\x27\x20THEN\x20i.from\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','contactName','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','i.*','c.firstName','Contact.firstName','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','limit','offset','Setting','enableEmailPreview','clone','COUNT(*)'];(function(_0x5d4607,_0x6b5e7b){var _0x5e4a86=function(_0x46891a){while(--_0x46891a){_0x5d4607['push'](_0x5d4607['shift']());}};_0x5e4a86(++_0x6b5e7b);}(_0x153f,0x15b));var _0xf153=function(_0x4cef9c,_0x19508f){_0x4cef9c=_0x4cef9c-0x0;var _0x52d2cf=_0x153f[_0x4cef9c];return _0x52d2cf;};'use strict';var _=require(_0xf153('0x0'));var squel=require(_0xf153('0x1'));var as=require(_0xf153('0x2'));var qs=require(_0xf153('0x3'));var updateInteraction=require(_0xf153('0x4'))[_0xf153('0x5')];var utils=require(_0xf153('0x6'));var db=require('../../mysqldb')['db'];function skipInteractionsQuery(_0x364e65,_0x5c49c7,_0x1f9ead){var _0x2fcb1a=![];var _0x342a45=utils[_0xf153('0x7')](_0x364e65);if(_0x5c49c7[_0xf153('0x8')]==='agent'&&!_0x1f9ead[_0xf153('0x9')]&&!_0x1f9ead[_0x342a45]){_0x2fcb1a=!![];}return _0x2fcb1a;}function getTagsQuery(){return squel[_0xf153('0xa')]()[_0xf153('0xb')]('id')[_0xf153('0xb')](_0xf153('0xc'))[_0xf153('0xb')](_0xf153('0xd'))[_0xf153('0xe')](_0xf153('0xf'));}function getUsersQuery(_0xeaccb0,_0x5c8ae9){var _0x2b76eb=utils[_0xf153('0x10')](_0xeaccb0);var _0x2bea70='user_has_'+_0xeaccb0+_0xf153('0x11');var _0x292f89=squel[_0xf153('0xa')]()[_0xf153('0xb')](_0xf153('0x12'))[_0xf153('0xb')](_0xf153('0x13'))[_0xf153('0xb')](_0xf153('0x14')+_0x2b76eb)['from'](_0x2bea70,'ui')[_0xf153('0x15')](_0xf153('0x16'),'u',_0xf153('0x17'));if(_0x5c8ae9[_0xf153('0x18')]>0x0){_0x292f89[_0xf153('0x19')](_0xf153('0x14')+_0x2b76eb+_0xf153('0x1a'),_[_0xf153('0x1b')](_0x5c8ae9,'id'));}return _0x292f89;}function getInteractionsQuery(_0x47fbfe){var _0x35f4e8=utils['getInteractionsTables'](_0x47fbfe);var _0x37093a=utils[_0xf153('0x7')](_0x47fbfe);var _0x138dbe=utils[_0xf153('0x10')](_0x47fbfe);return squel['select']()[_0xf153('0xe')](_0x35f4e8[_0xf153('0x1c')],'i')[_0xf153('0x15')](_0xf153('0x1d'),'c',_0xf153('0x1e'))[_0xf153('0x15')](_0xf153('0x16'),'o',_0xf153('0x1f'))[_0xf153('0x15')](_0x35f4e8[_0xf153('0x20')],'a',_0xf153('0x21')+_0x37093a)[_0xf153('0x15')](_0x35f4e8['messages'],'me',_0xf153('0x22')+_0x138dbe+_0xf153('0x23'))[_0xf153('0x15')](_0x35f4e8[_0xf153('0x24')],'it',_0xf153('0x25')+_0x138dbe+_0xf153('0x23'))[_0xf153('0x15')](_0xf153('0xf'),'t',_0xf153('0x26'));}function getSqlClauses(){var _0x38190c={'body':squel[_0xf153('0x27')](),'contact':squel[_0xf153('0x27')](),'default':squel[_0xf153('0x27')](),'fields':squel[_0xf153('0x27')](),'filter':squel[_0xf153('0x27')](),'read':squel[_0xf153('0x27')](),'tags':{'clause':squel[_0xf153('0x27')](),'ids':null},'user':squel[_0xf153('0x27')]()};return _0x38190c;}function parseTagParameter(_0x23acc3){var _0x17f7a4=squel['expr']();if(_0x23acc3){var _0x6d62ef=utils[_0xf153('0x28')](_0x23acc3);_0x6d62ef['forEach'](function(_0x16cdcd){_0x17f7a4['or'](_0xf153('0x29'),'%,'+_0x16cdcd+',%');});}return _0x17f7a4;}function parseReadParameter(_0x4e45f9){var _0x17305d='';if(_0x4e45f9){_0x17305d=_0xf153('0x2a');if(_0x4e45f9==='1'){_0x17305d=_0x17305d[_0xf153('0x2b')](_0xf153('0x2c'),'=');}else{_0x17305d=_0x17305d[_0xf153('0x2b')](_0xf153('0x2c'),'>');}}return _0x17305d;}function parseSearchFilter(_0x441436,_0x3b5f4f){var _0x19a568=squel[_0xf153('0x27')]();if(_0x3b5f4f){var _0x13b541=_0x3b5f4f[_0xf153('0x2b')]('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(qs[_0xf153('0x2d')](_0x13b541)){_0x19a568['or'](_0xf153('0x2e'),_0x13b541+'%');if([_0xf153('0x2f'),_0xf153('0x30')]['includes'](_0x441436)){_0x19a568['or']('i.phone\x20LIKE\x20?',_0x13b541+'%');}else if(_0x441436===_0xf153('0x31')){_0x19a568['or']('i.fax\x20LIKE\x20?',_0x13b541+'%');}else if(_0x441436==='openchannel'){_0x19a568['or'](_0xf153('0x32'),_0x13b541+'%');}}else if(_0x441436==='mail'&&qs[_0xf153('0x33')](_0x13b541)){_0x19a568['or']('c.email\x20LIKE\x20?',_0x13b541+'%');}else{if(_0x441436===_0xf153('0x34')){_0x19a568['or'](_0xf153('0x35'),qs['getFullTextValue'](_0x13b541))['or'](_0xf153('0x36'),qs[_0xf153('0x37')](_0x13b541));}else{if(_0x441436!==_0xf153('0x31')){_0x19a568['or'](_0xf153('0x38'),qs[_0xf153('0x37')](_0x13b541));}_0x19a568['or'](_0xf153('0x39'),_0x13b541+'%');}}}return _0x19a568;}function parseAdvancedSearchFilter(_0x4ab69c,_0x23c293){var _0x5c333b=getSqlClauses();var _0x40834b=as[_0xf153('0x3a')](_0x4ab69c);var _0x9b3f4c=_0x40834b[_0xf153('0x3b')];for(var _0x274bcc=0x0;_0x274bcc<_0x40834b[_0xf153('0x3c')]['length'];_0x274bcc++){var _0x1b4bc1=_0x40834b[_0xf153('0x3c')][_0x274bcc];var _0x332809='i';var _0x4e0634=_[_0xf153('0x3d')](_0x23c293,[_0xf153('0xc'),_0x1b4bc1[_0xf153('0xb')]]);if(_0x4e0634){var _0x254692=as[_0xf153('0x3e')](_0x332809,_0x4e0634[_0xf153('0x3f')],_0x1b4bc1);_0x5c333b['default'][_0x9b3f4c](_0x254692[_0xf153('0x40')],_0x254692[_0xf153('0x41')]['start'],_0x254692[_0xf153('0x41')][_0xf153('0x42')]);}else{switch(_0x1b4bc1[_0xf153('0xb')]){case _0xf153('0x43'):var _0x103b91=parseReadParameter(_0x1b4bc1[_0xf153('0x41')]);_0x5c333b[_0xf153('0x44')]['and'](_0x103b91);break;case _0xf153('0x45'):if(_0x1b4bc1[_0xf153('0x46')]===_0xf153('0x47')){if(_0x1b4bc1[_0xf153('0x41')][_0xf153('0x48')]('\x20')[_0xf153('0x18')]>0x1){_0x5c333b['contact'][_0x9b3f4c]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0xf153('0x37')](_0x1b4bc1['value']),null);}else{var _0x46dd09='%'+_0x1b4bc1[_0xf153('0x41')]+'%';_0x5c333b[_0xf153('0x49')][_0x9b3f4c](_0xf153('0x4a'),_0x46dd09,_0x46dd09,_0x46dd09);}}else{_0x4e0634=_[_0xf153('0x3d')](_0x23c293,[_0xf153('0xc'),'ContactId']);_0x1b4bc1['field']=_0xf153('0x4b');_0x254692=as[_0xf153('0x3e')](_0x332809,_0x4e0634['type'],_0x1b4bc1);_0x5c333b[_0xf153('0x49')][_0x9b3f4c](_0x254692[_0xf153('0x40')],_0x254692[_0xf153('0x41')][_0xf153('0x4c')],_0x254692[_0xf153('0x41')][_0xf153('0x42')]);}break;case _0xf153('0x4d'):var _0x17fb17=_0x1b4bc1[_0xf153('0x41')][_0xf153('0x48')](',')[_0xf153('0x1b')](function(_0x46e279){return Number(_0x46e279);});var _0x59228a=parseTagParameter(_0x17fb17);_0x5c333b[_0xf153('0x4e')][_0xf153('0x4f')][_0xf153('0x50')](_0x59228a);_0x5c333b['tags'][_0xf153('0x51')]=_0x17fb17;break;case _0xf153('0x52'):if(_0x1b4bc1['operator']===_0xf153('0x47')){_0x5c333b['user'][_0x9b3f4c](_0xf153('0x53'),'%'+_0x1b4bc1[_0xf153('0x41')]+'%',null);}else{_0x4e0634=_[_0xf153('0x3d')](_0x23c293,['name',_0xf153('0x54')]);_0x1b4bc1[_0xf153('0xb')]=_0xf153('0x54');_0x254692=as[_0xf153('0x3e')](_0x332809,_0x4e0634[_0xf153('0x3f')],_0x1b4bc1);_0x5c333b['user'][_0x9b3f4c](_0x254692[_0xf153('0x40')],_0x254692[_0xf153('0x41')]['start'],_0x254692[_0xf153('0x41')][_0xf153('0x42')]);}break;case _0xf153('0x55'):case'plainBody':_0x254692=as[_0xf153('0x3e')]('me',null,_0x1b4bc1);_0x5c333b[_0xf153('0x55')][_0x9b3f4c](_0x254692[_0xf153('0x40')],_0x254692[_0xf153('0x41')][_0xf153('0x4c')],_0x254692[_0xf153('0x41')][_0xf153('0x42')]);break;}}}return _0x5c333b;}function parseModelFields(_0x33e48,_0x3b91ed,_0x5b33a5){var _0x5c1444=utils['getAccountFK'](_0x33e48);var _0x5987f0=squel['expr']();var _0x43e608=_(_0x3b91ed)[_0xf153('0x56')]()['map'](function(_0x424b7a){return _[_0xf153('0x57')](_0x5b33a5,['name',_0x424b7a])?_0x424b7a:undefined;})[_0xf153('0x58')]()[_0xf153('0x41')]();if(_0x43e608[_0xf153('0x18')]>0x0){_0x43e608[_0xf153('0x59')](function(_0x3964db){if(_0x3964db===_0x5c1444){_0x5987f0[_0xf153('0x50')]('i.'+_0x5c1444+'\x20IN\x20?',[][_0xf153('0x5a')](_0x3b91ed[_0x3964db]));}else if(_0x3964db===_0xf153('0x5b')){var _0x4dca55=JSON['parse'](_0x3b91ed[_0x3964db])[_0xf153('0x5c')];var _0x8cbb80=JSON[_0xf153('0x5d')](_0x3b91ed[_0x3964db])[_0xf153('0x5e')];_0x5987f0[_0xf153('0x50')](_0xf153('0x5f'),_0x4dca55,_0x8cbb80);}else{if(_0x3b91ed[_0x3964db]==='null'){_0x5987f0[_0xf153('0x50')]('i.'+_0x3964db+'\x20IS\x20NULL');}else{_0x5987f0[_0xf153('0x50')]('i.'+_0x3964db+_0xf153('0x60'),_0x3b91ed[_0x3964db]);}}});}return _0x5987f0;}function parseQueryParameters(_0x454fff,_0x5cc697,_0x35912e){var _0x3a4166=getSqlClauses();return Promise[_0xf153('0x61')]()[_0xf153('0x62')](function(){return parseModelFields(_0x454fff,_0x5cc697,_0x35912e);})[_0xf153('0x62')](function(_0x18d0ce){_0x3a4166[_0xf153('0x63')]['and'](_0x18d0ce);return parseReadParameter(_0x5cc697[_0xf153('0x44')]);})[_0xf153('0x62')](function(_0x546114){_0x3a4166['read'][_0xf153('0x50')](_0x546114);return parseTagParameter(_0x5cc697[_0xf153('0x64')]);})[_0xf153('0x62')](function(_0x2d96eb){_0x3a4166[_0xf153('0x4e')][_0xf153('0x4f')][_0xf153('0x50')](_0x2d96eb);return parseSearchFilter(_0x454fff,_0x5cc697[_0xf153('0x65')]);})['then'](function(_0x308b5f){_0x3a4166[_0xf153('0x65')]=_0x308b5f;return _0x3a4166;});}function checkAccountsRestrictions(_0x5a0cd8,_0x3b112e,_0x3e160a){var _0x2e95f4=utils[_0xf153('0x7')](_0x5a0cd8);var _0x1f2830=_0xf153('0x66')+_[_0xf153('0x67')](_0x5a0cd8)+(_0x5a0cd8===_0xf153('0x68')?_0xf153('0x69'):_0xf153('0x6a'));var _0xca7bec=squel['expr']();return Promise[_0xf153('0x61')]()[_0xf153('0x62')](function(){if(_0x3e160a['search']&&_0x3b112e[_0xf153('0x8')]===_0xf153('0x6b')){return _0x3b112e[_0x1f2830]({'attributes':['id'],'raw':!![]});}})[_0xf153('0x62')](function(_0x147d3a){if(_0x147d3a){if(_0x147d3a[_0xf153('0x18')]===0x0){_0xca7bec[_0xf153('0x50')]('i.'+_0x2e95f4+_0xf153('0x6c'));}else{_0xca7bec['and']('i.'+_0x2e95f4+_0xf153('0x1a'),_[_0xf153('0x1b')](_0x147d3a,'id'));}}else if(!_0x3e160a[_0x2e95f4]){_0xca7bec[_0xf153('0x50')]('i.'+_0x2e95f4+_0xf153('0x6d'));}})[_0xf153('0x62')](function(){return _0xca7bec;});}function getClosedOrderClause(_0x2755b7,_0x19ec0b){var _0x2db5b7='';var _0x437083=['i.thirdDisposition',_0xf153('0x6e'),_0xf153('0x6f')];if(_0x2755b7==='mail'){_0x437083[_0xf153('0x70')]('i.substatus');}if(_0x19ec0b[_0xf153('0x71')]==='0'&&_0x2755b7===_0xf153('0x34')){_0x2db5b7='i.substatus';}else{if(_0x19ec0b[_0xf153('0x71')]==='1'){_0x437083['shift']();}_0x2db5b7=_0xf153('0x72')+_0x437083[_0xf153('0x73')](',\x20')+')';}return _0x2db5b7;}function getFilteredInteractions(_0x1ff298,_0x1c2e33,_0x4ad773,_0x42cd70){var _0xc0095d=utils['getInteractionFK'](_0x1ff298);var _0x43d10b=_[_0xf153('0x67')](_0x1ff298)+_0xf153('0x74');var _0x362e41=[];var _0x1e19f4=getTagsQuery();var _0x55f7c1={'type':db[_0xf153('0x75')]['QueryTypes'][_0xf153('0x76')],'raw':!![]};var _0x38a7c4=[];var _0x5907f8=[];return db['sequelize'][_0xf153('0x77')](_0x1e19f4[_0xf153('0x78')](),_0x55f7c1)['then'](function(_0x4775b1){_0x362e41=_[_0xf153('0x79')](_0x4775b1,'id');_0x55f7c1=_[_0xf153('0x7a')](_0x55f7c1,{'model':db[_0x43d10b],'mapToModel':!![],'nest':!![]});if(_0x4ad773['fields']){_0x42cd70[_0xf153('0x7b')][_0xf153('0x59')](function(_0x3b87e7){_0x1c2e33[_0xf153('0xb')]('i.'+_0x3b87e7);});}else{_0x1c2e33[_0xf153('0xb')](_0xf153('0x7c'),_0xf153('0x43'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x7d'),_0xf153('0x7e'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x7f'),_0xf153('0x80'));if(_0x1ff298===_0xf153('0x34')){_0x1c2e33[_0xf153('0xb')](_0xf153('0x81'),'Account.email');_0x1c2e33[_0xf153('0xb')]('CASE\x20WHEN\x20i.to\x20IS\x20NOT\x20NULL\x20AND\x20i.to\x20<>\x20\x27\x27\x20AND\x20i.to\x20NOT\x20LIKE\x20CONCAT(\x27%\x27,\x20a.email,\x20\x27%\x27)\x20THEN\x20TRIM(SUBSTRING_INDEX(i.to,\x20\x27<\x27,\x201))\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','contactName');_0x1c2e33[_0xf153('0xb')]('i.id');_0x1c2e33[_0xf153('0xb')](_0xf153('0x82'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x83'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x84'));_0x1c2e33['field'](_0xf153('0x85'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x86'));_0x1c2e33['field']('i.lastMsgAt');_0x1c2e33[_0xf153('0xb')](_0xf153('0x87'));_0x1c2e33[_0xf153('0xb')]('i.subject');_0x1c2e33[_0xf153('0xb')]('i.disposition');_0x1c2e33['field'](_0xf153('0x6e'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x88'));_0x1c2e33['field'](_0xf153('0x89'));_0x1c2e33[_0xf153('0xb')]('i.to');_0x1c2e33[_0xf153('0xb')](_0xf153('0x8a'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x8b'));_0x1c2e33[_0xf153('0xb')]('i.UserId');}else if(_0x1ff298===_0xf153('0x8c')){_0x1c2e33[_0xf153('0xb')](_0xf153('0x8d'),_0xf153('0x8e'));}else{_0x1c2e33[_0xf153('0xb')](_0xf153('0x8f'),_0xf153('0x8e'));}if(_0x1ff298!=='mail'){_0x1c2e33[_0xf153('0xb')](_0xf153('0x90'));}_0x1c2e33[_0xf153('0xb')](_0xf153('0x91'),_0xf153('0x92'));_0x1c2e33[_0xf153('0xb')]('c.lastName',_0xf153('0x93'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x94'),_0xf153('0x95'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x96'),_0xf153('0x97'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x98'),_0xf153('0x99'));_0x1c2e33['field']('c.fax','Contact.fax');_0x1c2e33['field'](_0xf153('0x9a'),_0xf153('0x9b'));_0x1c2e33[_0xf153('0xb')](_0xf153('0x9c'),_0xf153('0x9d'));_0x1c2e33['field'](_0xf153('0x9e'),_0xf153('0x9f'));}if(_0x42cd70[_0xf153('0xa0')]){_0x1c2e33[_0xf153('0xa0')](_0x42cd70['limit']);}if(_0x42cd70[_0xf153('0xa1')]){_0x1c2e33[_0xf153('0xa1')](_0x42cd70[_0xf153('0xa1')]);}return db['sequelize'][_0xf153('0x77')](_0x1c2e33['toString'](),_0x55f7c1);})[_0xf153('0x62')](function(_0x25ab76){_0x38a7c4=_0x25ab76;var _0x2651ff=getUsersQuery(_0x1ff298,_0x38a7c4);return db['sequelize']['query'](_0x2651ff['toString'](),_0x55f7c1);})[_0xf153('0x62')](function(_0x45f965){_0x5907f8=_['groupBy'](_0x45f965,_0xc0095d);if(_0x1ff298==='mail'){return db[_0xf153('0xa2')]['findOne']({'attributes':[_0xf153('0xa3')],'raw':!![]});}})['then'](function(_0xb3632c){var _0x2d007a=_0xb3632c?_0xb3632c[_0xf153('0xa3')]:undefined;var _0x3a1bf2=_0x38a7c4[_0xf153('0x1b')](function(_0x3bb664){return updateInteraction(_0x3bb664,_0x362e41,_0x5907f8,_0x2d007a);});return Promise['all'](_0x3a1bf2);});}function countFilteredInteractions(_0x174546,_0x33cd1a){var _0x56473b=_0x174546[_0xf153('0xa4')]();_0x56473b[_0xf153('0xb')](_0xf153('0xa5'));_0x56473b[_0xf153('0xb')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0xf153('0x43'));var _0x19534a=utils['getSelectedTags'](_0x33cd1a);if(!_[_0xf153('0xa6')](_0x19534a)){_0x56473b[_0xf153('0x19')](_0xf153('0xa7'),_0x19534a);}var _0x11d650={'type':db['Sequelize'][_0xf153('0xa8')][_0xf153('0x76')],'raw':!![]};return db[_0xf153('0xa9')][_0xf153('0x77')](_0x56473b[_0xf153('0x78')](),_0x11d650);}module[_0xf153('0xaa')]={'checkAccountsRestrictions':checkAccountsRestrictions,'countFilteredInteractions':countFilteredInteractions,'getClosedOrderClause':getClosedOrderClause,'getFilteredInteractions':getFilteredInteractions,'getInteractionsQuery':getInteractionsQuery,'parseAdvancedSearchFilter':parseAdvancedSearchFilter,'parseQueryParameters':parseQueryParameters,'skipInteractionsQuery':skipInteractionsQuery}; \ No newline at end of file diff --git a/server/components/interaction/update-interaction.js b/server/components/interaction/update-interaction.js new file mode 100644 index 0000000..9b2b554 --- /dev/null +++ b/server/components/interaction/update-interaction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaee5=['answered','unmanaged','abandoned','total','closed','disposition','UserId','MailMessage','findOne','out','-id','plainBody','lastMsgText','trimStart','catch','updateInteraction','then','Users','TagIds','../../mysqldb','map','fullname','split','waiting','talking'];(function(_0x5105e8,_0x44a2e0){var _0x53bbf5=function(_0x29dfb8){while(--_0x29dfb8){_0x5105e8['push'](_0x5105e8['shift']());}};_0x53bbf5(++_0x44a2e0);}(_0xaee5,0xa9));var _0x5aee=function(_0xbc1ed5,_0x5473a1){_0xbc1ed5=_0xbc1ed5-0x0;var _0x4cb7e4=_0xaee5[_0xbc1ed5];return _0x4cb7e4;};'use strict';var _=require('lodash');var db=require(_0x5aee('0x0'))['db'];function getInteractionUsers(_0x207cd8,_0x402145){return new Promise(function(_0x344bcf,_0xe2081c){try{var _0x155111=[];if(_0x402145[_0x207cd8]){_0x155111=_0x402145[_0x207cd8][_0x5aee('0x1')](function(_0x434e7d){return{'id':_0x434e7d['id'],'fullname':_0x434e7d[_0x5aee('0x2')]};});}return _0x344bcf(_0x155111);}catch(_0x12df4c){_0xe2081c(_0x12df4c);}});}function getInteractionTags(_0x8d2231,_0x104503){var _0x5ddb6f=[];if(_0x8d2231){_0x8d2231[_0x5aee('0x3')](',')['forEach'](function(_0x5c90cb){_0x5ddb6f['push'](_0x104503[_0x5c90cb]);});}return _0x5ddb6f;}function updateWaitingCounter(_0x28c567){if(_0x28c567[_0x5aee('0x4')]){_0x28c567[_0x5aee('0x4')]-=0x1;}}function updateInteractionCounters(_0x59d3b0){_0x59d3b0[_0x5aee('0x4')]=0x0;_0x59d3b0[_0x5aee('0x5')]=0x0;_0x59d3b0[_0x5aee('0x6')]=0x0;_0x59d3b0[_0x5aee('0x7')]=0x0;_0x59d3b0[_0x5aee('0x8')]=0x0;_0x59d3b0[_0x5aee('0x9')]=0x0;if(_0x59d3b0[_0x5aee('0xa')]){if(_0x59d3b0[_0x5aee('0xb')]===_0x5aee('0x8')){_0x59d3b0[_0x5aee('0x8')]+=0x1;updateWaitingCounter(_0x59d3b0);}if(_0x59d3b0[_0x5aee('0xc')]){_0x59d3b0[_0x5aee('0x6')]+=0x1;if(_0x59d3b0[_0x5aee('0x5')]){_0x59d3b0[_0x5aee('0x5')]-=0x1;}}else{if(_0x59d3b0[_0x5aee('0xb')]){_0x59d3b0['unmanaged']+=0x1;updateWaitingCounter(_0x59d3b0);}}}else{if(!_0x59d3b0[_0x5aee('0xc')]){_0x59d3b0[_0x5aee('0x4')]+=0x1;}if(_0x59d3b0[_0x5aee('0xc')]){_0x59d3b0['talking']+=0x1;updateWaitingCounter(_0x59d3b0);}}_0x59d3b0[_0x5aee('0x9')]+=0x1;return _0x59d3b0;}function getLastMessageText(_0x423ebb){return db[_0x5aee('0xd')][_0x5aee('0xe')]({'where':{'$and':[{'MailInteractionId':_0x423ebb['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0x5aee('0xf')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':['plainBody'],'order':_0x5aee('0x10'),'raw':!![]})['then'](function(_0x4c543c){if(_0x4c543c&&_0x4c543c[_0x5aee('0x11')]){_0x423ebb[_0x5aee('0x12')]=_[_0x5aee('0x13')](_0x4c543c[_0x5aee('0x11')]);}return _0x423ebb;})[_0x5aee('0x14')](function(_0x1639d2){throw _0x1639d2;});}exports[_0x5aee('0x15')]=function(_0x3fe883,_0x59196a,_0x231284,_0x579eaa){return new Promise(function(_0x309b9d,_0x12c941){return getInteractionUsers(_0x3fe883['id'],_0x231284)[_0x5aee('0x16')](function(_0x385ca2){_0x3fe883[_0x5aee('0x17')]=_0x385ca2;return getInteractionTags(_0x3fe883[_0x5aee('0x18')],_0x59196a);})[_0x5aee('0x16')](function(_0x3f7649){_0x3fe883['Tags']=_0x3f7649;delete _0x3fe883[_0x5aee('0x18')];return updateInteractionCounters(_0x3fe883);})[_0x5aee('0x16')](function(_0x42ac3c){if(_0x579eaa){return getLastMessageText(_0x42ac3c);}else{return _0x42ac3c;}})[_0x5aee('0x16')](function(_0x4d5a9c){_0x309b9d(_0x4d5a9c);})[_0x5aee('0x14')](function(_0x3b86e1){_0x12c941(_0x3b86e1);});});}; \ No newline at end of file diff --git a/server/components/interaction/utils.js b/server/components/interaction/utils.js new file mode 100644 index 0000000..9f38ac2 --- /dev/null +++ b/server/components/interaction/utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8df8=['[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','null','findOne','then','catch','error','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','whatsapp-interactions','chat','Website','Account','capitalize','InteractionId','upperFirst','unknown','websites','accounts','_interactions','_interaction_has_tags','_messages','isArray','toLowerCase'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x8df8,0xbd));var _0x88df=function(_0x55a0bf,_0x3f1235){_0x55a0bf=_0x55a0bf-0x0;var _0x20dfec=_0x8df8[_0x55a0bf];return _0x20dfec;};'use strict';var _=require(_0x88df('0x0'));var db=require(_0x88df('0x1'))['db'];var loggers={'openchannel':require(_0x88df('0x2'))(_0x88df('0x3')),'mail':require(_0x88df('0x2'))(_0x88df('0x4')),'fax':require('../../config/logger')(_0x88df('0x5')),'sms':require(_0x88df('0x2'))('sms-interactions'),'chat':require(_0x88df('0x2'))('chat-interactions'),'whatsapp':require(_0x88df('0x2'))(_0x88df('0x6'))};function getAccountFK(_0x175328){return _['capitalize'](_0x175328)+(_0x175328===_0x88df('0x7')?_0x88df('0x8'):_0x88df('0x9'))+'Id';}function getInteractionFK(_0x3a2903){return _[_0x88df('0xa')](_0x3a2903)+_0x88df('0xb');}function getInteractionId(_0x5e803b,_0x36c67f,_0x1db1a5){if(_0x5e803b&&_0x5e803b[_[_0x88df('0xc')](_0x1db1a5)+_0x88df('0xb')]){return _0x5e803b[_[_0x88df('0xc')](_0x1db1a5)+_0x88df('0xb')];}else if(_0x5e803b&&_0x5e803b['id']){return _0x5e803b['id'];}else if(_0x36c67f&&_0x36c67f['id']){return _0x36c67f['id'];}else{return _0x88df('0xd');}}function getInteractionsTables(_0xb56358){return{'accounts':_0xb56358+'_'+(_0xb56358==='chat'?_0x88df('0xe'):_0x88df('0xf')),'interactions':_0xb56358+_0x88df('0x10'),'interactionsTags':_0xb56358+_0x88df('0x11'),'messages':_0xb56358+_0x88df('0x12'),'userInteractions':'user_has_'+_0xb56358+_0x88df('0x10')};}function getSelectedTags(_0xce383f){var _0x248a0e=[];if(_0xce383f){_0x248a0e=Array[_0x88df('0x13')](_0xce383f)?_0xce383f:[_0xce383f];}return _0x248a0e;}function log(_0x5a3ff5,_0x334fef,_0x1e633b,_0x1926da,_0x350720,_0x58919c){loggers[_0x350720[_0x88df('0x14')]()][_0x5a3ff5](_0x88df('0x15'),_0x58919c[_0x88df('0x16')](),_0x334fef?_0x334fef['id']:null,_0x334fef?_0x334fef[_0x88df('0x17')]:null,_0x334fef?_0x334fef[_0x88df('0x18')]:null,getInteractionId(_0x1e633b,_0x1926da,_0x350720),_0x1e633b?JSON['stringify'](_0x1e633b):_0x88df('0x19'));}function updateUser(_0x5684ed,_0x341956,_0x145afe,_0x5e30a2,_0x3603b6){db[_[_0x88df('0xc')](_0x5e30a2)+'Interaction'][_0x88df('0x1a')]({'where':{'id':getInteractionId(_0x341956,_0x145afe,_0x5e30a2)}})['then'](function(_0x3c5c9c){if(_0x3c5c9c){return _0x3c5c9c['update']({'UserId':_0x5684ed?_0x5684ed['id']:null});}})[_0x88df('0x1b')](function(_0x381583){if(_0x381583){log('info',_0x5684ed,_0x341956,_0x145afe,_0x5e30a2,_0x3603b6);}})[_0x88df('0x1c')](function(){log(_0x88df('0x1d'),_0x5684ed,_0x341956,_0x145afe,_0x5e30a2,_0x3603b6);});}module['exports']={'getAccountFK':getAccountFK,'getInteractionFK':getInteractionFK,'getInteractionsTables':getInteractionsTables,'getSelectedTags':getSelectedTags,'updateUser':updateUser}; \ No newline at end of file diff --git a/server/components/license/service.js b/server/components/license/service.js new file mode 100644 index 0000000..7c1a7a5 --- /dev/null +++ b/server/components/license/service.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x280b=['catch','users','User','admin','user','isUserLimit','crypto','util','composable-middleware','../../config/environment','license','data1','split','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0x280b,0xd8));var _0xb280=function(_0x2f5ac5,_0x1ee939){_0x2f5ac5=_0x2f5ac5-0x0;var _0x37c9a8=_0x280b[_0x2f5ac5];return _0x37c9a8;};'use strict';var crypto=require(_0xb280('0x0'));var util=require(_0xb280('0x1'));var compose=require(_0xb280('0x2'));var db=require('../../mysqldb')['db'];var config=require(_0xb280('0x3'));function getValueFromLicense(_0x2370fc,_0xe7c5f9){if(_0x2370fc&&_0xe7c5f9){if(_0xe7c5f9['data1']&&_0xe7c5f9[_0xb280('0x4')]){var _0xb5e7ba=_0xe7c5f9[_0xb280('0x5')];var _0x149565=_0xe7c5f9['license'];var _0x334cb8=_0xb5e7ba[_0xb280('0x6')]('-')[0x4];var _0xca6773=_0xb5e7ba['split']('-')[0x0];var _0x5eb558=crypto['createDecipher'](_0xb280('0x7'),util[_0xb280('0x8')](_0xb280('0x9'),_0x334cb8,_0xb5e7ba,_0xca6773));var _0x33a3b2=_0x5eb558[_0xb280('0xa')](_0x149565,_0xb280('0xb'),_0xb280('0xc'));_0x33a3b2+=_0x5eb558[_0xb280('0xd')]('utf8');var _0x41a90d=JSON[_0xb280('0xe')](_0x33a3b2);return _0x41a90d[_0xb280('0xf')](_0x2370fc)?_0x41a90d[_0x2370fc]:null;}}return null;}function isLimit(_0x35a91f,_0x5c1aa8,_0x413900,_0x512b3a){var _0x7842b8=_0x5c1aa8;return compose()[_0xb280('0x10')](function(_0x320a0d,_0x53bf91,_0x2acbaf){return db[_0xb280('0x11')][_0xb280('0x12')]({'where':{'id':0x1},'raw':!![]})[_0xb280('0x13')](function(_0x428625){var _0x3a49bc=getValueFromLicense(_0x35a91f,_0x428625);return _0x3a49bc?_0x3a49bc:_0x7842b8;})[_0xb280('0x13')](function(_0x504759){_0x7842b8=_0x504759;return _0x413900[_0xb280('0x14')](_0x512b3a);})['then'](function(_0x357688){if(_0x357688>=_0x7842b8){return _0x53bf91[_0xb280('0x15')](0x193)[_0xb280('0x16')]({'message':util[_0xb280('0x8')](_0xb280('0x17'),_0x35a91f)});}_0x2acbaf();})[_0xb280('0x18')](function(_0x30bcb2){_0x2acbaf(_0x30bcb2);});});}function isUserLimit(){return isLimit(_0xb280('0x19'),0x1,db[_0xb280('0x1a')],{'where':{'$or':[{'role':_0xb280('0x1b')},{'role':_0xb280('0x1c')}]}});}exports[_0xb280('0x1d')]=isUserLimit; \ No newline at end of file diff --git a/server/components/parsers/advancedSearch.js b/server/components/parsers/advancedSearch.js new file mode 100644 index 0000000..fed5507 --- /dev/null +++ b/server/components/parsers/advancedSearch.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf4f6=['value','includes','$gt','$lte','add','days','format','castTo','text','CAST(','field','\x20AS\x20','$notIn','\x20OR\x20','\x20IS\x20NULL)','$in','IN\x20?','NOT\x20IN\x20?','=\x20?','$ne','<>\x20?','$substring','$startsWith','$endsWith','LIKE\x20?','$lt','<=\x20?','$gte','>=\x20?','$between','BETWEEN\x20?\x20AND\x20?','start','utcOffset','hours','lodash','parseSearch','sqlOperator','startsWith','and','replace','[$and]','[$or]','split','length','shift','match','forEach','filter','indexOf','map','push','buildExpression','DATE','$eq','operator'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xf4f6,0xfe));var _0x6f4f=function(_0x51020b,_0x38c2c7){_0x51020b=_0x51020b-0x0;var _0x371e47=_0xf4f6[_0x51020b];return _0x371e47;};'use strict';var _=require(_0x6f4f('0x0'));var moment=require('moment');exports[_0x6f4f('0x1')]=function(_0x26c117){var _0x5c5629={'conditions':[]};_0x5c5629[_0x6f4f('0x2')]=_[_0x6f4f('0x3')](_0x26c117,'[$or]')?'or':_0x6f4f('0x4');var _0x28b6f4=_0x26c117[_0x6f4f('0x5')](_0x6f4f('0x6'),'')[_0x6f4f('0x5')](_0x6f4f('0x7'),'')[_0x6f4f('0x8')]('||');for(var _0x3b0343=0x0;_0x3b0343<_0x28b6f4[_0x6f4f('0x9')];_0x3b0343++){var _0x489be2=_0x28b6f4[_0x3b0343][_0x6f4f('0x8')](':=');var _0x3b5027=_0x489be2[0x0];var _0x2c923f=_0x489be2['slice'](0x1);_0x2c923f['forEach'](function(_0x225e18){var _0x1b8369=_0x225e18[_0x6f4f('0x8')]('[')[_0x6f4f('0xa')]();var _0x49b8fe=_0x225e18[_0x6f4f('0xb')](/\[(.*?)\]/g);_0x49b8fe[_0x6f4f('0xc')](function(_0xa0d11a){var _0x29db70=_0xa0d11a[_0x6f4f('0x8')]('[')[_0x6f4f('0xd')](function(_0x3c44e9){return _0x3c44e9[_0x6f4f('0xe')](']')>-0x1;})[_0x6f4f('0xf')](function(_0x412cc1){return _0x412cc1['split'](']')[0x0];})[0x0];_0x5c5629['conditions'][_0x6f4f('0x10')]({'field':_0x3b5027,'operator':_0x1b8369,'value':_0x29db70});});});}return _0x5c5629;};exports[_0x6f4f('0x11')]=function(_0x4f324c,_0x4d4bbb,_0x41e7ea){var _0xa43581={};if(_0x4d4bbb===_0x6f4f('0x12')){if(_0x41e7ea['operator']===_0x6f4f('0x13')){_0x41e7ea[_0x6f4f('0x14')]='$between';_0x41e7ea[_0x6f4f('0x15')]+=','+_0x41e7ea[_0x6f4f('0x15')];}else if(_[_0x6f4f('0x16')]([_0x6f4f('0x17'),_0x6f4f('0x18')],_0x41e7ea['operator'])){_0x41e7ea[_0x6f4f('0x15')]=moment(_0x41e7ea[_0x6f4f('0x15')])[_0x6f4f('0x19')](0x1,_0x6f4f('0x1a'))[_0x6f4f('0x1b')]('YYYY-MM-DD');}}if(_0x41e7ea[_0x6f4f('0x1c')]){_0x4d4bbb=_0x41e7ea[_0x6f4f('0x1c')];_0xa43581[_0x6f4f('0x1d')]=_0x6f4f('0x1e')+_0x4f324c+'.'+_0x41e7ea[_0x6f4f('0x1f')]+_0x6f4f('0x20')+_0x41e7ea['castTo']+')\x20'+parseOperator(_0x41e7ea[_0x6f4f('0x14')]);}else{_0xa43581[_0x6f4f('0x1d')]=_0x4f324c+'.'+_0x41e7ea[_0x6f4f('0x1f')]+'\x20'+parseOperator(_0x41e7ea['operator']);}if(_[_0x6f4f('0x16')](['$ne',_0x6f4f('0x21')],_0x41e7ea[_0x6f4f('0x14')]))_0xa43581[_0x6f4f('0x1d')]='('+_0xa43581['text']+_0x6f4f('0x22')+_0x4f324c+'.'+_0x41e7ea['field']+_0x6f4f('0x23');_0xa43581[_0x6f4f('0x15')]=parseValue(_0x4d4bbb,_0x41e7ea[_0x6f4f('0x14')],_0x41e7ea[_0x6f4f('0x15')]);return _0xa43581;};function parseOperator(_0x44c37d){var _0x2be3fd;switch(_0x44c37d){case _0x6f4f('0x24'):_0x2be3fd=_0x6f4f('0x25');break;case _0x6f4f('0x21'):_0x2be3fd=_0x6f4f('0x26');break;case _0x6f4f('0x13'):_0x2be3fd=_0x6f4f('0x27');break;case _0x6f4f('0x28'):_0x2be3fd=_0x6f4f('0x29');break;case _0x6f4f('0x2a'):case _0x6f4f('0x2b'):case _0x6f4f('0x2c'):_0x2be3fd=_0x6f4f('0x2d');break;case _0x6f4f('0x2e'):_0x2be3fd='<\x20?';break;case _0x6f4f('0x17'):_0x2be3fd='>\x20?';break;case _0x6f4f('0x18'):_0x2be3fd=_0x6f4f('0x2f');break;case _0x6f4f('0x30'):_0x2be3fd=_0x6f4f('0x31');break;case _0x6f4f('0x32'):_0x2be3fd=_0x6f4f('0x33');break;}return _0x2be3fd;}function parseValue(_0x525dea,_0x4002e7,_0x1e09b0){var _0x1a0726={'start':undefined,'end':undefined};switch(_0x4002e7){case _0x6f4f('0x24'):case _0x6f4f('0x21'):_0x1a0726['start']=_0x1e09b0[_0x6f4f('0x8')](',');break;case _0x6f4f('0x2a'):_0x1a0726[_0x6f4f('0x34')]='%'+_0x1e09b0+'%';break;case _0x6f4f('0x2b'):_0x1a0726[_0x6f4f('0x34')]=_0x1e09b0+'%';break;case _0x6f4f('0x2c'):_0x1a0726['start']='%'+_0x1e09b0;break;case _0x6f4f('0x32'):var _0x53f09c=_0x1e09b0[_0x6f4f('0x8')](',');var _0x1e09b0=_0x53f09c['shift']();var _0x3493f5=_0x53f09c['pop']();if(_0x525dea==='DATE'){_0x1e09b0=moment(_0x1e09b0)['utcOffset'](0x0,!![])[_0x6f4f('0x1b')]();_0x3493f5=moment(_0x3493f5)[_0x6f4f('0x35')](0x0,!![])[_0x6f4f('0x19')](0x17,_0x6f4f('0x36'))[_0x6f4f('0x19')](0x3b,'minutes')[_0x6f4f('0x19')](0x3b,'seconds')['format']();}_0x1a0726={'start':_0x1e09b0,'end':_0x3493f5};break;default:_0x1a0726[_0x6f4f('0x34')]=_0x1e09b0;break;}return _0x1a0726;} \ No newline at end of file diff --git a/server/components/parsers/qs.js b/server/components/parsers/qs.js new file mode 100644 index 0000000..b62ecbd --- /dev/null +++ b/server/components/parsers/qs.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2d17=['indexOf','unsigned','substr','priority','cast','col','length','omit','unset','match','^[+]?[0-9]*$','isEmail','forEach','replace','join','getOptions','query','$id','model','name','keys','intersection','attributes','hasOwnProperty','offset','order','where','pick','filter','object','columns','merge','VIRTUAL','lower','lodash','sequelize','parse','includes','fields','split','filters','isEmpty','forOwn','find','type','DATE','isPlainObject','$gte','format','YYYY-MM-DD','utc','$lte','subtract','uniqueid','isArray','limit','sort','map'];(function(_0x359345,_0x4f2e67){var _0x27de8d=function(_0x4b060d){while(--_0x4b060d){_0x359345['push'](_0x359345['shift']());}};_0x27de8d(++_0x4f2e67);}(_0x2d17,0x17e));var _0x72d1=function(_0x10dfb8,_0x5ab2e4){_0x10dfb8=_0x10dfb8-0x0;var _0x3ca55c=_0x2d17[_0x10dfb8];return _0x3ca55c;};'use strict';var _=require(_0x72d1('0x0'));var sequelize=require(_0x72d1('0x1'));var moment=require('moment');var LIMIT_VALUE=0xfa;function hasSequelizeOperator(_0x12f23c){var _0x4727f9=['ne'];try{var _0x531f4e=JSON[_0x72d1('0x2')](_0x12f23c);var _0x38fec7=Object['keys'](_0x531f4e)[0x0];return _0x4727f9[_0x72d1('0x3')](_0x38fec7);}catch(_0x4dfee1){return![];}}function getOperatorValue(_0x39150f){var _0x50f551=JSON[_0x72d1('0x2')](_0x39150f);var _0x239d1f=Object['keys'](_0x50f551)[0x0];var _0x477264=_0x50f551[_0x239d1f];return{['$'+_0x239d1f]:_0x477264};}exports[_0x72d1('0x4')]=function(_0x19e248){var _0x4e7f3e=null;if(_0x19e248){_0x4e7f3e=_0x19e248[_0x72d1('0x5')](',');}return _0x4e7f3e;};exports[_0x72d1('0x6')]=function(_0x283775,_0x593c91){var _0x1d7520={};if(!_[_0x72d1('0x7')](_0x283775)){_[_0x72d1('0x8')](_0x283775,function(_0x14a41e,_0x3cb9c2){try{if(_0x593c91){var _0x3916f2=_[_0x72d1('0x9')](_0x593c91,{'name':_0x3cb9c2})||{};if(hasSequelizeOperator(_0x14a41e)){_0x1d7520[_0x3cb9c2]=getOperatorValue(_0x14a41e);}else if(_0x3916f2[_0x72d1('0xa')]===_0x72d1('0xb')&&_[_0x72d1('0xc')](_0x14a41e)){var _0x5ad4df=JSON[_0x72d1('0x2')](_0x14a41e);var _0x37017c={'$gte':moment(moment(_0x5ad4df[_0x72d1('0xd')])[_0x72d1('0xe')](_0x72d1('0xf')))[_0x72d1('0x10')]()[_0x72d1('0xe')](),'$lte':moment(moment(_0x5ad4df[_0x72d1('0x11')])[_0x72d1('0xe')](_0x72d1('0xf')))[_0x72d1('0x10')]()[_0x72d1('0x12')](0x1,'s')[_0x72d1('0xe')]()};_0x1d7520[_0x3cb9c2]=_0x37017c;}else if(_0x3916f2['name']===_0x72d1('0x13')){_0x1d7520[_0x3cb9c2]=_0x14a41e;}else{_0x1d7520[_0x3cb9c2]=_['isArray'](_0x14a41e)?_0x14a41e:JSON[_0x72d1('0x2')](_0x14a41e);}}else{_0x1d7520[_0x3cb9c2]=_[_0x72d1('0x14')](_0x14a41e)?_0x14a41e:JSON['parse'](_0x14a41e);}}catch(_0x1061b7){_0x1d7520[_0x3cb9c2]=_0x14a41e[_0x72d1('0x5')](',');}});}return _0x1d7520;};exports[_0x72d1('0x15')]=function(_0x49caf4){_0x49caf4=parseInt(_0x49caf4,0xa);if(!_0x49caf4||_0x49caf4<0x0){_0x49caf4=LIMIT_VALUE;}return _0x49caf4;};exports['offset']=function(_0x313d7b){_0x313d7b=parseInt(_0x313d7b,0xa);if(!_0x313d7b||_0x313d7b<0x0){_0x313d7b=0x0;}return _0x313d7b;};exports[_0x72d1('0x16')]=function(_0x2233cb){var _0x1865c1,_0x8d6890=null;if(_0x2233cb){_0x1865c1=_0x2233cb[_0x72d1('0x5')](',');_0x8d6890=_[_0x72d1('0x17')](_0x1865c1,function(_0x5c7982){if(_0x5c7982[_0x72d1('0x18')]('-')===0x0){return[_0x5c7982==='priority'?sequelize['cast'](sequelize['col']('priority'),_0x72d1('0x19')):_0x5c7982[_0x72d1('0x1a')](0x1),'DESC'];}else{return[_0x5c7982===_0x72d1('0x1b')?sequelize[_0x72d1('0x1c')](sequelize[_0x72d1('0x1d')](_0x72d1('0x1b')),_0x72d1('0x19')):_0x5c7982,'ASC'];}});}return _0x8d6890;};exports['omit']=function(_0x188eca,_0x36bc65){if(_[_0x72d1('0x7')](_0x188eca)){return _0x188eca;}if(_[_0x72d1('0x14')](_0x188eca)){for(var _0xdf6a69=0x0;_0xdf6a69<_0x188eca[_0x72d1('0x1e')];_0xdf6a69+=0x1){_0x188eca[_0xdf6a69]=this[_0x72d1('0x1f')](_0x188eca[_0xdf6a69],_0x36bc65);}return _0x188eca;}if(!_['isObject'](_0x188eca)){return _0x188eca;}if(_['isString'](_0x36bc65)){_0x36bc65=[_0x36bc65];}if(!_[_0x72d1('0x14')](_0x36bc65)){return _0x188eca;}for(var _0x482cb8=0x0;_0x482cb8<_0x36bc65[_0x72d1('0x1e')];_0x482cb8+=0x1){_[_0x72d1('0x20')](_0x188eca,_0x36bc65[_0x482cb8]);}for(var _0x2c113d in _0x188eca){if(_0x188eca['hasOwnProperty'](_0x2c113d)){_0x188eca[_0x2c113d]=this[_0x72d1('0x1f')](_0x188eca[_0x2c113d],_0x36bc65);}}return _0x188eca;};exports['isNumeric']=function(_0x707cd0){return _0x707cd0[_0x72d1('0x21')](RegExp(_0x72d1('0x22')))?!![]:![];};exports[_0x72d1('0x23')]=function(_0x51242b){return _0x51242b[_0x72d1('0x21')](/^\S+@\S+$/)?!![]:![];};exports['getFullTextValue']=function(_0x42c03c){var _0x32dc5e=[];_0x42c03c['split'](/[ ,]+/)[_0x72d1('0x24')](function(_0x358b0c){_0x358b0c=_0x358b0c[_0x72d1('0x25')](/([^:]")"+/g,'$1');_0x358b0c='+'+_0x358b0c+'*';var _0x11ea2f=/[ `!@#$%^&*()_\-?~]/;if(_0x358b0c[_0x72d1('0x21')](_0x11ea2f))_0x358b0c='\x22'+_0x358b0c+'\x22';_0x32dc5e['push'](_0x358b0c);});return _0x32dc5e[_0x72d1('0x26')]('\x20');};exports[_0x72d1('0x27')]=function(_0x9efc2f,_0x482033,_0x244f4a){var _0x14669a={},_0x4a2909={};if(_0x482033[_0x72d1('0x28')][_0x72d1('0x29')]){_0x482033[_0x72d1('0x28')]['id']=_0x482033['query'][_0x72d1('0x29')];delete _0x482033['query'][_0x72d1('0x29')];}_0x14669a[_0x72d1('0x2a')]=_[_0x72d1('0x17')](_0x9efc2f,_0x72d1('0x2b'));_0x14669a[_0x72d1('0x28')]=_[_0x72d1('0x2c')](_0x482033[_0x72d1('0x28')]);_0x14669a[_0x72d1('0x6')]=_[_0x72d1('0x2d')](_0x14669a[_0x72d1('0x2a')],_0x14669a[_0x72d1('0x28')]);_0x4a2909['attributes']=_[_0x72d1('0x2d')](_0x14669a[_0x72d1('0x2a')],this[_0x72d1('0x4')](_0x482033[_0x72d1('0x28')]['fields']));_0x4a2909[_0x72d1('0x2e')]=_0x4a2909[_0x72d1('0x2e')][_0x72d1('0x1e')]?_0x4a2909['attributes']:_0x14669a[_0x72d1('0x2a')];if(!_0x482033[_0x72d1('0x28')][_0x72d1('0x2f')]('nolimit')){_0x4a2909[_0x72d1('0x15')]=this[_0x72d1('0x15')](_0x482033[_0x72d1('0x28')]['limit']);_0x4a2909[_0x72d1('0x30')]=this[_0x72d1('0x30')](_0x482033[_0x72d1('0x28')][_0x72d1('0x30')]);}_0x4a2909[_0x72d1('0x31')]=this[_0x72d1('0x16')](_0x482033[_0x72d1('0x28')]['sort']);_0x4a2909[_0x72d1('0x32')]=this[_0x72d1('0x6')](_[_0x72d1('0x33')](_0x482033[_0x72d1('0x28')],_0x14669a[_0x72d1('0x6')]),_0x9efc2f);if(_0x482033[_0x72d1('0x28')][_0x72d1('0x34')]){var _0x1d4fdf=_0x9efc2f;var _0x55438b=_0x482033[_0x72d1('0x28')][_0x72d1('0x34')];if(typeof _0x55438b===_0x72d1('0x35')){_0x1d4fdf=_[_0x72d1('0x34')](_0x9efc2f,function(_0x45870b){return _[_0x72d1('0x3')](_0x55438b[_0x72d1('0x36')],_0x45870b[_0x72d1('0x2b')]);});_0x55438b=_0x55438b['value'];}_0x4a2909['where']=_[_0x72d1('0x37')](_0x4a2909[_0x72d1('0x32')],{'$or':_[_0x72d1('0x17')](_0x1d4fdf,function(_0x21d361){if(_0x21d361['type']!==_0x72d1('0x38')){if(_0x244f4a){return sequelize[_0x72d1('0x32')](sequelize['fn']('lower',sequelize[_0x72d1('0x1d')](_0x21d361['name'])),{'$like':sequelize['fn'](_0x72d1('0x39'),'%'+_0x482033[_0x72d1('0x28')]['filter']+'%')});}else{var _0x37c69a={};_0x37c69a[_0x21d361['name']]={'$like':'%'+_0x482033['query']['filter']+'%'};return _0x37c69a;}}})});}_0x4a2909=_[_0x72d1('0x37')]({},_0x4a2909,_0x482033['options']);return _0x4a2909;}; \ No newline at end of file diff --git a/server/components/realtime/agents.js b/server/components/realtime/agents.js new file mode 100644 index 0000000..6424906 --- /dev/null +++ b/server/components/realtime/agents.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x87f3=['lodash','jayson/promise','client','http','chatPause','smsPause','voicePause','whatsappPause','filter','length','unknown','unavailable','ringing','isNil','voiceStatus','idle','pause','chatStatus','faxStatus','openchannelStatus','smsStatus','whatsappStatus','then','error','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(AMI)','Agents','Unable\x20to\x20retrieve\x20RPC\x20agents\x20(Routing)','result','merge','*pause','busy','getAgentStatus','isArray','Queue','findOne','getAgents','flatten','map','uniq','value','getAgentIdsByStatus','resolve','includes','findAll','name','fullname','mailPause','pauseType','globalStatus','catch','getSortedAgentsIdsByStatus','split','fields','order','startsWith','DESC','ASC','getUpdatedSortOptions','internal','indexOf','validateSortParameter','sort','toLowerCase','sortAgentsByStatus','userpic','online','lastLoginAt','lastPauseAt','address','chatCapacity','openchannelCapacity','mailCapacity','smsCapacity','whatsappCapacity','mailCurrentCapacity','smsCurrentCapacity','whatsappCurrentCapacity','faxCurrentCapacity','mailStatus','chatStatusTime','openchannelStatusTime','whatsappStatusTime','faxStatusTime','voiceStatusTime','queue','destconnectedlinenum','screenrecording','phoneBarEnableScreenRecordingByAgent','phoneBarEnableAutomaticScreenRecording','routealias','pick','filterAgentAttributes'];(function(_0xb1a876,_0x5d29d3){var _0x2a0e27=function(_0x6fb612){while(--_0x6fb612){_0xb1a876['push'](_0xb1a876['shift']());}};_0x2a0e27(++_0x5d29d3);}(_0x87f3,0xb8));var _0x387f=function(_0x4eec9b,_0x4aea09){_0x4eec9b=_0x4eec9b-0x0;var _0x2e3849=_0x87f3[_0x4eec9b];return _0x2e3849;};'use strict';var _=require(_0x387f('0x0'));var jayson=require(_0x387f('0x1'));var db=require('../../mysqldb')['db'];var amiClient=jayson[_0x387f('0x2')]['http']({'port':0x232a});var routingClient=jayson[_0x387f('0x2')][_0x387f('0x3')]({'port':0x232c});function isAgentPaused(_0x59be2c,_0x7d1240){var _0x49d129=[_0x59be2c[_0x387f('0x4')],_0x59be2c['faxPause'],_0x59be2c['mailPause'],_0x59be2c['openchannelPause'],_0x59be2c[_0x387f('0x5')],_0x59be2c[_0x387f('0x6')],_0x59be2c[_0x387f('0x7')]];if(!_0x7d1240)return _['every'](_0x49d129);var _0xb0e1fe=_[_0x387f('0x8')](_0x49d129);return _0xb0e1fe[_0x387f('0x9')]>0x0&&_0xb0e1fe[_0x387f('0x9')]<_0x49d129['length']?!![]:![];}function isIdle(_0x3d9e7a){return _0x3d9e7a==='idle'||_0x3d9e7a===_0x387f('0xa')||_0x3d9e7a===_0x387f('0xb')||_0x3d9e7a===_0x387f('0xc')||_[_0x387f('0xd')](_0x3d9e7a);}function isAgentIdle(_0x2e3b4f){if(_0x2e3b4f[_0x387f('0xe')]!==_0x387f('0xf')&&_0x2e3b4f[_0x387f('0x6')]){_0x2e3b4f[_0x387f('0xe')]=_0x387f('0x10');return![];}return _['every']([_0x2e3b4f[_0x387f('0x11')],_0x2e3b4f[_0x387f('0x12')],_0x2e3b4f['mailStatus'],_0x2e3b4f[_0x387f('0x13')],_0x2e3b4f[_0x387f('0x14')],_0x2e3b4f['voiceStatus'],_0x2e3b4f[_0x387f('0x15')]],isIdle);}function getRealtimeAgents(){return amiClient['request']('Agents',{})[_0x387f('0x16')](function(_0x416770){if(_0x416770[_0x387f('0x17')]){throw new Error(_0x387f('0x18'));}var _0x185c0d=_0x416770['result'];return routingClient['request'](_0x387f('0x19'),{})['then'](function(_0x4638ba){if(_0x4638ba[_0x387f('0x17')]){throw new Error(_0x387f('0x1a'));}var _0x2d5f1d=_0x4638ba[_0x387f('0x1b')];return _[_0x387f('0x1c')]({},_0x185c0d,_0x2d5f1d);});})['catch'](function(_0x3093d3){throw _0x3093d3;});}exports['getRealtimeAgents']=getRealtimeAgents;function getAgentStatus(_0x5e0e47){var _0x3f8040=_0x387f('0xa');if(isAgentPaused(_0x5e0e47))_0x3f8040=_0x387f('0x10');else if(isAgentPaused(_0x5e0e47,!![]))_0x3f8040=_0x387f('0x1d');else if(isAgentIdle(_0x5e0e47))_0x3f8040=_0x387f('0xf');else _0x3f8040=_0x387f('0x1e');return _0x3f8040;}exports[_0x387f('0x1f')]=getAgentStatus;function getAgentIdsByQueues(_0x1c0dd0,_0x2b33a2){var _0x351943=_[_0x387f('0x20')](_0x1c0dd0)?_0x1c0dd0:[_0x1c0dd0];var _0x5aec3c=_['startCase'](_0x2b33a2)+_0x387f('0x21');var _0x2d4d04=_['map'](_0x351943,function(_0x2bc326){return db[_0x5aec3c][_0x387f('0x22')]({'where':{'id':_0x2bc326}})[_0x387f('0x16')](function(_0x4e4892){if(!_0x4e4892)return[];return _0x4e4892[_0x387f('0x23')]({'attributes':['id'],'raw':!![]});});});return Promise['all'](_0x2d4d04)['then'](function(_0x2167f9){var _0x22165b=_(_0x2167f9)[_0x387f('0x24')]()[_0x387f('0x25')]('id')[_0x387f('0x26')]()[_0x387f('0x27')]();return _0x22165b;});}exports['getAgentIdsByQueues']=getAgentIdsByQueues;function getAgentIdsByStatus(_0x3cbc50,_0x154460,_0x2af508){try{if(_0x154460['length']>0x0){_0x3cbc50=_0x3cbc50[_0x387f('0x8')](function(_0x4ed11c){return _0x154460['includes'](_0x4ed11c['id']);});}var _0xed497a=_0x3cbc50[_0x387f('0x8')](function(_0x1e481b){var _0x5bbe4f=_0x387f('0x1e');if(isAgentIdle(_0x1e481b)){_0x5bbe4f=_0x387f('0xf');}return _0x5bbe4f===_0x2af508;});return _['map'](_0xed497a,'id');}catch(_0xe7d8f3){throw _0xe7d8f3;}}exports[_0x387f('0x28')]=getAgentIdsByStatus;function getSortedAgentsIdsByStatus(_0x27c599,_0x524a33,_0x217063){return Promise[_0x387f('0x29')]()['then'](function(){if(_0x524a33['length']>0x0){_0x27c599=_0x27c599[_0x387f('0x8')](function(_0x28de64){return _0x524a33[_0x387f('0x2a')](_0x28de64['id']);});}return _0x27c599;})['then'](function(){return db['User'][_0x387f('0x2b')]({'attributes':['id',_0x387f('0x2c'),_0x387f('0x2d'),_0x387f('0x4'),'faxPause',_0x387f('0x2e'),'openchannelPause',_0x387f('0x5'),_0x387f('0x6'),_0x387f('0x7'),_0x387f('0x2f')],'where':{'id':{'$in':_['map'](_0x27c599,'id')}},'raw':!![]});})['then'](function(_0x347af0){return _0x347af0[_0x387f('0x25')](function(_0x143ff4){var _0x39fbf7=_['find'](_0x27c599,['id',_0x143ff4['id']]);var _0x10f7e1=filterAgentAttributes(_0x39fbf7);_[_0x387f('0x1c')](_0x143ff4,_0x10f7e1);_0x143ff4[_0x387f('0x30')]=getAgentStatus(_0x143ff4);return _0x143ff4;});})[_0x387f('0x16')](function(_0x51109a){var _0x37927b=sortAgentsByStatus(_0x51109a,_0x217063);return _['map'](_0x37927b,'id');})[_0x387f('0x31')](function(_0x2b53cb){throw _0x2b53cb;});}exports[_0x387f('0x32')]=getSortedAgentsIdsByStatus;function getUpdatedSortOptions(_0x1976db){var _0x52a714={'fields':[],'order':null};var _0x3f3402=_0x1976db[_0x387f('0x33')](',');_0x52a714[_0x387f('0x34')]=_[_0x387f('0x8')](_0x3f3402,function(_0x5301e5){if(!_0x5301e5[_0x387f('0x2a')]('globalStatus')){return!![];}_0x52a714[_0x387f('0x35')]=_[_0x387f('0x36')](_0x5301e5,'-')?_0x387f('0x37'):_0x387f('0x38');return![];});return _0x52a714;}exports[_0x387f('0x39')]=getUpdatedSortOptions;function validateSortParameter(_0x5d7c83){if(_0x5d7c83[_0x387f('0x2a')](_0x387f('0x2d'))&&!_0x5d7c83['includes'](_0x387f('0x3a'))){var _0x467dc7=_0x5d7c83['substring'](0x0,_0x5d7c83[_0x387f('0x3b')](_0x387f('0x2d')));_0x5d7c83+=','+_0x467dc7+_0x387f('0x3a');}return _0x5d7c83;}exports[_0x387f('0x3c')]=validateSortParameter;function sortAgentsByStatus(_0x136333,_0x5ce394){var _0x37a117=_0x136333[_0x387f('0x3d')](function(_0x586a54,_0x273270){if(_0x586a54[_0x387f('0x30')]===_0x273270[_0x387f('0x30')]){if(_0x586a54[_0x387f('0x30')]===_0x387f('0x10')){if(_0x5ce394===_0x387f('0x37')){return(_0x586a54[_0x387f('0x2f')]||'')<(_0x273270['pauseType']||'')||_0x586a54['fullname']['toLowerCase']()>_0x273270[_0x387f('0x2d')]['toLowerCase']()?0x1:-0x1;}else{return(_0x586a54[_0x387f('0x2f')]||'')<(_0x273270[_0x387f('0x2f')]||'')||_0x586a54[_0x387f('0x2d')][_0x387f('0x3e')]()>_0x273270[_0x387f('0x2d')]['toLowerCase']()?-0x1:0x1;}}else{if(_0x5ce394==='DESC'){return _0x586a54[_0x387f('0x2d')][_0x387f('0x3e')]()<_0x273270[_0x387f('0x2d')][_0x387f('0x3e')]()?0x1:-0x1;}else{return _0x586a54[_0x387f('0x2d')][_0x387f('0x3e')]()<_0x273270['fullname'][_0x387f('0x3e')]()?-0x1:0x1;}}}else{if(_0x5ce394==='DESC'){return _0x586a54[_0x387f('0x30')]<_0x273270['globalStatus']?0x1:-0x1;}else{return _0x586a54['globalStatus']<_0x273270[_0x387f('0x30')]?-0x1:0x1;}}});return _0x37a117;}exports[_0x387f('0x3f')]=sortAgentsByStatus;function filterAgentAttributes(_0xa59612){var _0x46d372=[_0x387f('0x40'),_0x387f('0x41'),_0x387f('0x42'),_0x387f('0x43'),_0x387f('0x2f'),_0x387f('0x43'),_0x387f('0x3a'),_0x387f('0x44'),'chatPause','openchannelPause',_0x387f('0x2e'),'smsPause',_0x387f('0x7'),'faxPause','voicePause',_0x387f('0x45'),_0x387f('0x46'),_0x387f('0x47'),_0x387f('0x48'),_0x387f('0x49'),'faxCapacity','chatCurrentCapacity','openchannelCurrentCapacity',_0x387f('0x4a'),_0x387f('0x4b'),_0x387f('0x4c'),_0x387f('0x4d'),'chatStatus',_0x387f('0x13'),_0x387f('0x4e'),_0x387f('0x14'),_0x387f('0x15'),'faxStatus',_0x387f('0xe'),_0x387f('0x4f'),_0x387f('0x50'),'mailStatusTime','smsStatusTime',_0x387f('0x51'),_0x387f('0x52'),_0x387f('0x53'),_0x387f('0x54'),_0x387f('0x55'),_0x387f('0x56'),_0x387f('0x57'),_0x387f('0x58'),_0x387f('0x59')];var _0x4c608c=[_0x387f('0x4'),'openchannelPause','mailPause',_0x387f('0x5'),_0x387f('0x7'),'faxPause',_0x387f('0x6'),_0x387f('0x41')];var _0x39e596=_(_0xa59612)['omit'](_0x4c608c)[_0x387f('0x5a')](_0x46d372)[_0x387f('0x27')]();return _0x39e596;}exports[_0x387f('0x5b')]=filterAgentAttributes; \ No newline at end of file diff --git a/server/components/realtime/queues.js b/server/components/realtime/queues.js new file mode 100644 index 0000000..1a9ab71 --- /dev/null +++ b/server/components/realtime/queues.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe082=['Trunk','startPredictive','erlangCalls','erlangCallToSecond','erlangBusyFactor','dialPredictiveInterval','dialPredictiveIntervalMinThreshold','predictiveIntervalTotalCalls','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','startCase','Queues','then','error','Unable\x20to\x20retrieve\x20RPC\x20%s\x20queues','result','catch','inbound','concat','outbound','get','loggedIn','voice','find','merge','initializeQueues','jayson/promise','util','client','http','available','paused','busy','inUse','loggedInDb','onHold','ringInUse','talking','unavailable','unknown','pTalking','originated','message','statusMessage','dialActive','dialMethod'];(function(_0x334b4d,_0x5c6c01){var _0x1662a6=function(_0x377511){while(--_0x377511){_0x334b4d['push'](_0x334b4d['shift']());}};_0x1662a6(++_0x5c6c01);}(_0xe082,0x143));var _0x2e08=function(_0x307d86,_0x9264f2){_0x307d86=_0x307d86-0x0;var _0x361745=_0xe082[_0x307d86];return _0x361745;};'use strict';var _=require('lodash');var jayson=require(_0x2e08('0x0'));var util=require(_0x2e08('0x1'));var amiClient=jayson[_0x2e08('0x2')][_0x2e08('0x3')]({'port':0x232a});var routingClient=jayson[_0x2e08('0x2')][_0x2e08('0x3')]({'port':0x232c});var DEFAULT_QUEUE_ATTRIBUTES=[_0x2e08('0x4'),'loggedIn',_0x2e08('0x5'),'waiting'];var VOICE_QUEUE_ATTRIBUTES=[_0x2e08('0x6'),_0x2e08('0x7'),'invalid',_0x2e08('0x8'),'notInUse',_0x2e08('0x9'),'ringing',_0x2e08('0xa'),_0x2e08('0xb'),_0x2e08('0xc'),_0x2e08('0xd')];var OUTBOUND_QUEUE_ATTRIBUTES=[_0x2e08('0xe'),_0x2e08('0xf'),_0x2e08('0x10'),_0x2e08('0x11'),_0x2e08('0x12'),_0x2e08('0x13'),_0x2e08('0x14'),_0x2e08('0x15'),'startProgressive',_0x2e08('0x16'),_0x2e08('0x17'),'erlangAbandonmentRate',_0x2e08('0x18'),_0x2e08('0x19'),'dialPredictiveIntervalMaxThreshold',_0x2e08('0x1a'),'predictiveIntervalAvailable',_0x2e08('0x1b'),_0x2e08('0x1c'),_0x2e08('0x1d'),_0x2e08('0x1e'),_0x2e08('0x1f'),_0x2e08('0x20')];function getRealtimeQueues(_0x59b451,_0x4d9486){var _0x24b905=_0x4d9486==='voice'?amiClient:routingClient;return _0x24b905['request'](_[_0x2e08('0x21')](_0x4d9486)+_0x2e08('0x22'),_0x59b451)[_0x2e08('0x23')](function(_0x35ee2c){if(_0x35ee2c[_0x2e08('0x24')])throw new Error(util['format'](_0x2e08('0x25'),_0x4d9486));return _0x35ee2c[_0x2e08('0x26')];})[_0x2e08('0x27')](function(_0x24c3ce){throw _0x24c3ce;});}exports['getRealtimeQueues']=getRealtimeQueues;function initializeQueues(_0x2281f2,_0x48e4d2,_0x907362,_0x577f88){var _0x70e962=DEFAULT_QUEUE_ATTRIBUTES;if(_0x907362==='voice'){if(_0x577f88===_0x2e08('0x28')){_0x70e962=_0x70e962[_0x2e08('0x29')](VOICE_QUEUE_ATTRIBUTES);}else if(_0x577f88===_0x2e08('0x2a')){_0x70e962=_0x70e962[_0x2e08('0x29')](VOICE_QUEUE_ATTRIBUTES,OUTBOUND_QUEUE_ATTRIBUTES);}}return _0x2281f2['map'](function(_0x1de401){var _0x4323eb=_0x1de401[_0x2e08('0x2b')]({'plain':!![]});_0x4323eb[_0x2e08('0x5')]=0x0;_0x4323eb['loggedInDb']=0x0;_0x4323eb[_0x2e08('0x2c')]=0x0;_0x4323eb[_0x2e08('0x4')]=0x0;_0x4323eb['waiting']=0x0;if(_0x907362===_0x2e08('0x2d')){_0x4323eb[_0x2e08('0xb')]=0x0;_0x4323eb['busy']=0x0;if(_0x577f88===_0x2e08('0x2a')){_0x4323eb['pTalking']=0x0;_0x4323eb['originated']=0x0;}}var _0x4316a7=_[_0x2e08('0x2e')](_0x48e4d2,['id',_0x4323eb['id']]);if(_0x4316a7){_[_0x2e08('0x2f')](_0x4323eb,_['pick'](_0x4316a7,_0x70e962));}return _0x4323eb;});}exports[_0x2e08('0x30')]=initializeQueues; \ No newline at end of file diff --git a/server/config/environment/development.js b/server/config/environment/development.js new file mode 100644 index 0000000..d5e896a --- /dev/null +++ b/server/config/environment/development.js @@ -0,0 +1,90 @@ +'use strict'; + +var jstz = require('jstz'); +var timezone = jstz.determine(); + +// Development specific configuration +// ================================== +module.exports = { + + // Sequelize connection opions + sequelize: { + database: 'motion2', + username: 'xcall', + password: 'xC@LL1234', + options: { + host: '127.0.0.1', + port: 3306, + dialect: 'mysql', + dialectOptions: { + charset: 'utf8mb4' + }, + logging: false, + timezone: timezone.name(), + define: { + charset: 'utf8', + collate: 'utf8_general_ci' + } + } + }, + sequelizeHistory: { + database: 'motion2', + username: 'xcall', + password: 'xC@LL1234', + options: { + host: '127.0.0.1', + port: 3306, + dialect: 'mysql', + dialectOptions: { + charset: 'utf8mb4' + }, + logging: false, + timezone: timezone.name(), + define: { + charset: 'utf8', + collate: 'utf8_general_ci' + } + } + }, + asterisk: { + ip: '127.0.0.1', + port: '5038', + username: 'xcall', + password: 'xcall1234' + }, + redis: { + host: 'localhost', + port: '6379' + }, + rpc: { + port: process.env.RPCPORT || 9001, + ip: process.env.RPCIP || '127.0.0.1', + }, + agi: { + port: process.env.AGIPORT || 4573, + ip: process.env.AGIIP || '127.0.0.1', + }, + // Seed database on startup + seedDB: true, + google: { + clientID: process.env.GOOGLE_ID || 'id', + clientSecret: process.env.GOOGLE_SECRET || 'secret', + callbackURL: (process.env.DOMAIN || 'http://localhost:9000') + '/api/auth/google/callback' + }, + secrets: { + session: 'xcally-motion-session-secret', + recording: 'xcally-motion-recording-secret' + }, + xdr: { + disabled: true, + local: false + }, + encrypt: { + algorithm: 'aes192' + }, + activedirectory: { + baseDN: process.env.AD_BASEDN || '', + url: process.env.AD_URL, + domain: process.env.AD_DOMAIN + } +}; \ No newline at end of file diff --git a/server/config/environment/index.js b/server/config/environment/index.js new file mode 100644 index 0000000..6ad2e34 --- /dev/null +++ b/server/config/environment/index.js @@ -0,0 +1,49 @@ +'use strict'; +/*eslint no-process-env:0*/ +var path = require('path'); +var _ = require('lodash'); + +/*function requiredProcessEnv(name) { + if(!process.env[name]) { + throw new Error('You must set the ' + name + ' environment variable'); + } + return process.env[name]; +}*/ + +// All configurations will extend these options +// ============================================ +var all = { + env: process.env.NODE_ENV, + + // Root path of server + root: path.normalize(__dirname + '/../../..'), + + // Browser-sync port + browserSyncPort: process.env.BROWSER_SYNC_PORT || 3000, + + port: process.env.PORT || 9000, + + ip: process.env.IP || '127.0.0.1', + + // Should we populate the DB with sample data? + seedDB: false, + + // Secret for session, you will want to change this and make it an environment variable + secrets: { + session: 'xcally-motion-session-secret', + recording: 'xcally-motion-recording-secret' + }, + + encrypt: { + algorithm: 'aes192' + }, + // Possible values ["SILLY", "DEBUG", "VERBOSE", "HTTP", "INFO", "WARN", "ERROR"] + debugLevel: 'INFO' +}; + +// Export the config object based on the NODE_ENV +// ============================================== +module.exports = _.merge( + all, + require('./shared'), + require('./' + (process.env.NODE_ENV || 'development') + '.js') || {}); \ No newline at end of file diff --git a/server/config/environment/shared.js b/server/config/environment/shared.js new file mode 100644 index 0000000..a86a5f7 --- /dev/null +++ b/server/config/environment/shared.js @@ -0,0 +1,2793 @@ +'use strict'; + +exports = module.exports = { + // List of user roles + userRoles: ['guest', 'user', 'admin'], + timezones: { + 'Europe/Andorra': { + name: 'Europe/Andorra', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'AD' + ] + }, + 'Asia/Dubai': { + name: 'Asia/Dubai', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'AE', + 'OM' + ] + }, + 'Asia/Kabul': { + name: 'Asia/Kabul', + utcOffset: 270, + offsetStr: '+04:30', + countries: [ + 'AF' + ] + }, + 'Europe/Tirane': { + name: 'Europe/Tirane', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'AL' + ] + }, + 'Asia/Yerevan': { + name: 'Asia/Yerevan', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'AM' + ] + }, + 'Antarctica/Rothera': { + name: 'Antarctica/Rothera', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Palmer': { + name: 'Antarctica/Palmer', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Mawson': { + name: 'Antarctica/Mawson', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Davis': { + name: 'Antarctica/Davis', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Casey': { + name: 'Antarctica/Casey', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Vostok': { + name: 'Antarctica/Vostok', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/DumontDUrville': { + name: 'Antarctica/DumontDUrville', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Syowa': { + name: 'Antarctica/Syowa', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'AQ' + ] + }, + 'Antarctica/Troll': { + name: 'Antarctica/Troll', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'AQ' + ] + }, + 'America/Argentina/Buenos_Aires': { + name: 'America/Argentina/Buenos_Aires', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Cordoba': { + name: 'America/Argentina/Cordoba', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Salta': { + name: 'America/Argentina/Salta', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Jujuy': { + name: 'America/Argentina/Jujuy', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Tucuman': { + name: 'America/Argentina/Tucuman', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Catamarca': { + name: 'America/Argentina/Catamarca', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/La_Rioja': { + name: 'America/Argentina/La_Rioja', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/San_Juan': { + name: 'America/Argentina/San_Juan', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Mendoza': { + name: 'America/Argentina/Mendoza', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/San_Luis': { + name: 'America/Argentina/San_Luis', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Rio_Gallegos': { + name: 'America/Argentina/Rio_Gallegos', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'America/Argentina/Ushuaia': { + name: 'America/Argentina/Ushuaia', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'AR' + ] + }, + 'Pacific/Pago_Pago': { + name: 'Pacific/Pago_Pago', + utcOffset: -660, + offsetStr: '-11:00', + countries: [ + 'AS', + 'UM' + ] + }, + 'Europe/Vienna': { + name: 'Europe/Vienna', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'AT' + ] + }, + 'Australia/Lord_Howe': { + name: 'Australia/Lord_Howe', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Antarctica/Macquarie': { + name: 'Antarctica/Macquarie', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Australia/Hobart': { + name: 'Australia/Hobart', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Australia/Currie': { + name: 'Australia/Currie', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Australia/Melbourne': { + name: 'Australia/Melbourne', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Australia/Sydney': { + name: 'Australia/Sydney', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'AU' + ] + }, + 'Australia/Broken_Hill': { + name: 'Australia/Broken_Hill', + utcOffset: 630, + offsetStr: '+10:30', + countries: [ + 'AU' + ] + }, + 'Australia/Brisbane': { + name: 'Australia/Brisbane', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'AU' + ] + }, + 'Australia/Lindeman': { + name: 'Australia/Lindeman', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'AU' + ] + }, + 'Australia/Adelaide': { + name: 'Australia/Adelaide', + utcOffset: 630, + offsetStr: '+10:30', + countries: [ + 'AU' + ] + }, + 'Australia/Darwin': { + name: 'Australia/Darwin', + utcOffset: 570, + offsetStr: '+09:30', + countries: [ + 'AU' + ] + }, + 'Australia/Perth': { + name: 'Australia/Perth', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'AU' + ] + }, + 'Australia/Eucla': { + name: 'Australia/Eucla', + utcOffset: 525, + offsetStr: '+08:45', + countries: [ + 'AU' + ] + }, + 'Asia/Baku': { + name: 'Asia/Baku', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'AZ' + ] + }, + 'America/Barbados': { + name: 'America/Barbados', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BB' + ] + }, + 'Asia/Dhaka': { + name: 'Asia/Dhaka', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'BD' + ] + }, + 'Europe/Brussels': { + name: 'Europe/Brussels', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'BE' + ] + }, + 'Europe/Sofia': { + name: 'Europe/Sofia', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'BG' + ] + }, + 'Atlantic/Bermuda': { + name: 'Atlantic/Bermuda', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BM' + ] + }, + 'Asia/Brunei': { + name: 'Asia/Brunei', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'BN' + ] + }, + 'America/La_Paz': { + name: 'America/La_Paz', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BO' + ] + }, + 'America/Noronha': { + name: 'America/Noronha', + utcOffset: -120, + offsetStr: '-02:00', + countries: [ + 'BR' + ] + }, + 'America/Belem': { + name: 'America/Belem', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Fortaleza': { + name: 'America/Fortaleza', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Recife': { + name: 'America/Recife', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Araguaina': { + name: 'America/Araguaina', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Maceio': { + name: 'America/Maceio', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Bahia': { + name: 'America/Bahia', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Sao_Paulo': { + name: 'America/Sao_Paulo', + utcOffset: -120, + offsetStr: '-02:00', + countries: [ + 'BR' + ] + }, + 'America/Campo_Grande': { + name: 'America/Campo_Grande', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Cuiaba': { + name: 'America/Cuiaba', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Santarem': { + name: 'America/Santarem', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'BR' + ] + }, + 'America/Porto_Velho': { + name: 'America/Porto_Velho', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BR' + ] + }, + 'America/Boa_Vista': { + name: 'America/Boa_Vista', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BR' + ] + }, + 'America/Manaus': { + name: 'America/Manaus', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'BR' + ] + }, + 'America/Eirunepe': { + name: 'America/Eirunepe', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'BR' + ] + }, + 'America/Rio_Branco': { + name: 'America/Rio_Branco', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'BR' + ] + }, + 'America/Nassau': { + name: 'America/Nassau', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'BS' + ] + }, + 'Asia/Thimphu': { + name: 'Asia/Thimphu', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'BT' + ] + }, + 'Europe/Minsk': { + name: 'Europe/Minsk', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'BY' + ] + }, + 'America/Belize': { + name: 'America/Belize', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'BZ' + ] + }, + 'America/St_Johns': { + name: 'America/St_Johns', + utcOffset: -210, + offsetStr: '-03:30', + countries: [ + 'CA' + ] + }, + 'America/Halifax': { + name: 'America/Halifax', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CA' + ] + }, + 'America/Glace_Bay': { + name: 'America/Glace_Bay', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CA' + ] + }, + 'America/Moncton': { + name: 'America/Moncton', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CA' + ] + }, + 'America/Goose_Bay': { + name: 'America/Goose_Bay', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CA' + ] + }, + 'America/Blanc-Sablon': { + name: 'America/Blanc-Sablon', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CA' + ] + }, + 'America/Toronto': { + name: 'America/Toronto', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Nipigon': { + name: 'America/Nipigon', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Thunder_Bay': { + name: 'America/Thunder_Bay', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Iqaluit': { + name: 'America/Iqaluit', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Pangnirtung': { + name: 'America/Pangnirtung', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Resolute': { + name: 'America/Resolute', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Atikokan': { + name: 'America/Atikokan', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CA' + ] + }, + 'America/Rankin_Inlet': { + name: 'America/Rankin_Inlet', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Winnipeg': { + name: 'America/Winnipeg', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Rainy_River': { + name: 'America/Rainy_River', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Regina': { + name: 'America/Regina', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Swift_Current': { + name: 'America/Swift_Current', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CA' + ] + }, + 'America/Edmonton': { + name: 'America/Edmonton', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Cambridge_Bay': { + name: 'America/Cambridge_Bay', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Yellowknife': { + name: 'America/Yellowknife', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Inuvik': { + name: 'America/Inuvik', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Creston': { + name: 'America/Creston', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Dawson_Creek': { + name: 'America/Dawson_Creek', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Fort_Nelson': { + name: 'America/Fort_Nelson', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'CA' + ] + }, + 'America/Vancouver': { + name: 'America/Vancouver', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'CA' + ] + }, + 'America/Whitehorse': { + name: 'America/Whitehorse', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'CA' + ] + }, + 'America/Dawson': { + name: 'America/Dawson', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'CA' + ] + }, + 'Indian/Cocos': { + name: 'Indian/Cocos', + utcOffset: 390, + offsetStr: '+06:30', + countries: [ + 'CC' + ] + }, + 'Europe/Zurich': { + name: 'Europe/Zurich', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'CH', + 'DE', + 'LI' + ] + }, + 'Africa/Abidjan': { + name: 'Africa/Abidjan', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'CI', + 'BF', + 'GM', + 'GN', + 'ML', + 'MR', + 'SH', + 'SL', + 'SN', + 'ST', + 'TG' + ] + }, + 'Pacific/Rarotonga': { + name: 'Pacific/Rarotonga', + utcOffset: -600, + offsetStr: '-10:00', + countries: [ + 'CK' + ] + }, + 'America/Santiago': { + name: 'America/Santiago', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'CL' + ] + }, + 'Pacific/Easter': { + name: 'Pacific/Easter', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CL' + ] + }, + 'Asia/Shanghai': { + name: 'Asia/Shanghai', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'CN' + ] + }, + 'Asia/Urumqi': { + name: 'Asia/Urumqi', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'CN' + ] + }, + 'America/Bogota': { + name: 'America/Bogota', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CO' + ] + }, + 'America/Costa_Rica': { + name: 'America/Costa_Rica', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'CR' + ] + }, + 'America/Havana': { + name: 'America/Havana', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'CU' + ] + }, + 'Atlantic/Cape_Verde': { + name: 'Atlantic/Cape_Verde', + utcOffset: -60, + offsetStr: '-01:00', + countries: [ + 'CV' + ] + }, + 'America/Curacao': { + name: 'America/Curacao', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'CW', + 'AW', + 'BQ', + 'SX' + ] + }, + 'Indian/Christmas': { + name: 'Indian/Christmas', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'CX' + ] + }, + 'Asia/Nicosia': { + name: 'Asia/Nicosia', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'CY' + ] + }, + 'Europe/Prague': { + name: 'Europe/Prague', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'CZ', + 'SK' + ] + }, + 'Europe/Berlin': { + name: 'Europe/Berlin', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'DE' + ] + }, + 'Europe/Copenhagen': { + name: 'Europe/Copenhagen', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'DK' + ] + }, + 'America/Santo_Domingo': { + name: 'America/Santo_Domingo', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'DO' + ] + }, + 'Africa/Algiers': { + name: 'Africa/Algiers', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'DZ' + ] + }, + 'America/Guayaquil': { + name: 'America/Guayaquil', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'EC' + ] + }, + 'Pacific/Galapagos': { + name: 'Pacific/Galapagos', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'EC' + ] + }, + 'Europe/Tallinn': { + name: 'Europe/Tallinn', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'EE' + ] + }, + 'Africa/Cairo': { + name: 'Africa/Cairo', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'EG' + ] + }, + 'Africa/El_Aaiun': { + name: 'Africa/El_Aaiun', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'EH' + ] + }, + 'Europe/Madrid': { + name: 'Europe/Madrid', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'ES' + ] + }, + 'Africa/Ceuta': { + name: 'Africa/Ceuta', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'ES' + ] + }, + 'Atlantic/Canary': { + name: 'Atlantic/Canary', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'ES' + ] + }, + 'Europe/Helsinki': { + name: 'Europe/Helsinki', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'FI', + 'AX' + ] + }, + 'Pacific/Fiji': { + name: 'Pacific/Fiji', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'FJ' + ] + }, + 'Atlantic/Stanley': { + name: 'Atlantic/Stanley', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'FK' + ] + }, + 'Pacific/Chuuk': { + name: 'Pacific/Chuuk', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'FM' + ] + }, + 'Pacific/Pohnpei': { + name: 'Pacific/Pohnpei', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'FM' + ] + }, + 'Pacific/Kosrae': { + name: 'Pacific/Kosrae', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'FM' + ] + }, + 'Atlantic/Faroe': { + name: 'Atlantic/Faroe', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'FO' + ] + }, + 'Europe/Paris': { + name: 'Europe/Paris', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'FR' + ] + }, + 'Europe/London': { + name: 'Europe/London', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'GB', + 'GG', + 'IM', + 'JE' + ] + }, + 'Asia/Tbilisi': { + name: 'Asia/Tbilisi', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'GE' + ] + }, + 'America/Cayenne': { + name: 'America/Cayenne', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'GF' + ] + }, + 'Africa/Accra': { + name: 'Africa/Accra', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'GH' + ] + }, + 'Europe/Gibraltar': { + name: 'Europe/Gibraltar', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'GI' + ] + }, + 'America/Godthab': { + name: 'America/Godthab', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'GL' + ] + }, + 'America/Danmarkshavn': { + name: 'America/Danmarkshavn', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'GL' + ] + }, + 'America/Scoresbysund': { + name: 'America/Scoresbysund', + utcOffset: -60, + offsetStr: '-01:00', + countries: [ + 'GL' + ] + }, + 'America/Thule': { + name: 'America/Thule', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'GL' + ] + }, + 'Europe/Athens': { + name: 'Europe/Athens', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'GR' + ] + }, + 'Atlantic/South_Georgia': { + name: 'Atlantic/South_Georgia', + utcOffset: -120, + offsetStr: '-02:00', + countries: [ + 'GS' + ] + }, + 'America/Guatemala': { + name: 'America/Guatemala', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'GT' + ] + }, + 'Pacific/Guam': { + name: 'Pacific/Guam', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'GU', + 'MP' + ] + }, + 'Africa/Bissau': { + name: 'Africa/Bissau', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'GW' + ] + }, + 'America/Guyana': { + name: 'America/Guyana', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'GY' + ] + }, + 'Asia/Hong_Kong': { + name: 'Asia/Hong_Kong', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'HK' + ] + }, + 'America/Tegucigalpa': { + name: 'America/Tegucigalpa', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'HN' + ] + }, + 'America/Port-au-Prince': { + name: 'America/Port-au-Prince', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'HT' + ] + }, + 'Europe/Budapest': { + name: 'Europe/Budapest', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'HU' + ] + }, + 'Asia/Jakarta': { + name: 'Asia/Jakarta', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'ID' + ] + }, + 'Asia/Pontianak': { + name: 'Asia/Pontianak', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'ID' + ] + }, + 'Asia/Makassar': { + name: 'Asia/Makassar', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'ID' + ] + }, + 'Asia/Jayapura': { + name: 'Asia/Jayapura', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'ID' + ] + }, + 'Europe/Dublin': { + name: 'Europe/Dublin', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'IE' + ] + }, + 'Asia/Jerusalem': { + name: 'Asia/Jerusalem', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'IL' + ] + }, + 'Asia/Kolkata': { + name: 'Asia/Kolkata', + utcOffset: 330, + offsetStr: '+05:30', + countries: [ + 'IN' + ] + }, + 'Indian/Chagos': { + name: 'Indian/Chagos', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'IO' + ] + }, + 'Asia/Baghdad': { + name: 'Asia/Baghdad', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'IQ' + ] + }, + 'Asia/Tehran': { + name: 'Asia/Tehran', + utcOffset: 210, + offsetStr: '+03:30', + countries: [ + 'IR' + ] + }, + 'Atlantic/Reykjavik': { + name: 'Atlantic/Reykjavik', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'IS' + ] + }, + 'Europe/Rome': { + name: 'Europe/Rome', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'IT', + 'SM', + 'VA' + ] + }, + 'America/Jamaica': { + name: 'America/Jamaica', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'JM' + ] + }, + 'Asia/Amman': { + name: 'Asia/Amman', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'JO' + ] + }, + 'Asia/Tokyo': { + name: 'Asia/Tokyo', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'JP' + ] + }, + 'Africa/Nairobi': { + name: 'Africa/Nairobi', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'KE', + 'DJ', + 'ER', + 'ET', + 'KM', + 'MG', + 'SO', + 'TZ', + 'UG', + 'YT' + ] + }, + 'Asia/Bishkek': { + name: 'Asia/Bishkek', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'KG' + ] + }, + 'Pacific/Tarawa': { + name: 'Pacific/Tarawa', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'KI' + ] + }, + 'Pacific/Enderbury': { + name: 'Pacific/Enderbury', + utcOffset: 780, + offsetStr: '+13:00', + countries: [ + 'KI' + ] + }, + 'Pacific/Kiritimati': { + name: 'Pacific/Kiritimati', + utcOffset: 840, + offsetStr: '+14:00', + countries: [ + 'KI' + ] + }, + 'Asia/Pyongyang': { + name: 'Asia/Pyongyang', + utcOffset: 510, + offsetStr: '+08:30', + countries: [ + 'KP' + ] + }, + 'Asia/Seoul': { + name: 'Asia/Seoul', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'KR' + ] + }, + 'America/Cayman': { + name: 'America/Cayman', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'KY' + ] + }, + 'Asia/Almaty': { + name: 'Asia/Almaty', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'KZ' + ] + }, + 'Asia/Qyzylorda': { + name: 'Asia/Qyzylorda', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'KZ' + ] + }, + 'Asia/Aqtobe': { + name: 'Asia/Aqtobe', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'KZ' + ] + }, + 'Asia/Aqtau': { + name: 'Asia/Aqtau', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'KZ' + ] + }, + 'Asia/Oral': { + name: 'Asia/Oral', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'KZ' + ] + }, + 'Asia/Beirut': { + name: 'Asia/Beirut', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'LB' + ] + }, + 'Asia/Colombo': { + name: 'Asia/Colombo', + utcOffset: 330, + offsetStr: '+05:30', + countries: [ + 'LK' + ] + }, + 'Africa/Monrovia': { + name: 'Africa/Monrovia', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'LR' + ] + }, + 'Europe/Vilnius': { + name: 'Europe/Vilnius', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'LT' + ] + }, + 'Europe/Luxembourg': { + name: 'Europe/Luxembourg', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'LU' + ] + }, + 'Europe/Riga': { + name: 'Europe/Riga', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'LV' + ] + }, + 'Africa/Tripoli': { + name: 'Africa/Tripoli', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'LY' + ] + }, + 'Africa/Casablanca': { + name: 'Africa/Casablanca', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'MA' + ] + }, + 'Europe/Monaco': { + name: 'Europe/Monaco', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'MC' + ] + }, + 'Europe/Chisinau': { + name: 'Europe/Chisinau', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'MD' + ] + }, + 'Pacific/Majuro': { + name: 'Pacific/Majuro', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'MH' + ] + }, + 'Pacific/Kwajalein': { + name: 'Pacific/Kwajalein', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'MH' + ] + }, + 'Asia/Rangoon': { + name: 'Asia/Rangoon', + utcOffset: 390, + offsetStr: '+06:30', + countries: [ + 'MM' + ] + }, + 'Asia/Ulaanbaatar': { + name: 'Asia/Ulaanbaatar', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'MN' + ] + }, + 'Asia/Hovd': { + name: 'Asia/Hovd', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'MN' + ] + }, + 'Asia/Choibalsan': { + name: 'Asia/Choibalsan', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'MN' + ] + }, + 'Asia/Macau': { + name: 'Asia/Macau', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'MO' + ] + }, + 'America/Martinique': { + name: 'America/Martinique', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'MQ' + ] + }, + 'Europe/Malta': { + name: 'Europe/Malta', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'MT' + ] + }, + 'Indian/Mauritius': { + name: 'Indian/Mauritius', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'MU' + ] + }, + 'Indian/Maldives': { + name: 'Indian/Maldives', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'MV' + ] + }, + 'America/Mexico_City': { + name: 'America/Mexico_City', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'MX' + ] + }, + 'America/Cancun': { + name: 'America/Cancun', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'MX' + ] + }, + 'America/Merida': { + name: 'America/Merida', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'MX' + ] + }, + 'America/Monterrey': { + name: 'America/Monterrey', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'MX' + ] + }, + 'America/Matamoros': { + name: 'America/Matamoros', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'MX' + ] + }, + 'America/Mazatlan': { + name: 'America/Mazatlan', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'MX' + ] + }, + 'America/Chihuahua': { + name: 'America/Chihuahua', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'MX' + ] + }, + 'America/Ojinaga': { + name: 'America/Ojinaga', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'MX' + ] + }, + 'America/Hermosillo': { + name: 'America/Hermosillo', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'MX' + ] + }, + 'America/Tijuana': { + name: 'America/Tijuana', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'MX' + ] + }, + 'America/Santa_Isabel': { + name: 'America/Santa_Isabel', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'MX' + ] + }, + 'America/Bahia_Banderas': { + name: 'America/Bahia_Banderas', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'MX' + ] + }, + 'Asia/Kuala_Lumpur': { + name: 'Asia/Kuala_Lumpur', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'MY' + ] + }, + 'Asia/Kuching': { + name: 'Asia/Kuching', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'MY' + ] + }, + 'Africa/Maputo': { + name: 'Africa/Maputo', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'MZ', + 'BI', + 'BW', + 'CD', + 'MW', + 'RW', + 'ZM', + 'ZW' + ] + }, + 'Africa/Windhoek': { + name: 'Africa/Windhoek', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'NA' + ] + }, + 'Pacific/Noumea': { + name: 'Pacific/Noumea', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'NC' + ] + }, + 'Pacific/Norfolk': { + name: 'Pacific/Norfolk', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'NF' + ] + }, + 'Africa/Lagos': { + name: 'Africa/Lagos', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'NG', + 'AO', + 'BJ', + 'CD', + 'CF', + 'CG', + 'CM', + 'GA', + 'GQ', + 'NE' + ] + }, + 'America/Managua': { + name: 'America/Managua', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'NI' + ] + }, + 'Europe/Amsterdam': { + name: 'Europe/Amsterdam', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'NL' + ] + }, + 'Europe/Oslo': { + name: 'Europe/Oslo', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'NO', + 'SJ' + ] + }, + 'Asia/Kathmandu': { + name: 'Asia/Kathmandu', + utcOffset: 345, + offsetStr: '+05:45', + countries: [ + 'NP' + ] + }, + 'Pacific/Nauru': { + name: 'Pacific/Nauru', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'NR' + ] + }, + 'Pacific/Niue': { + name: 'Pacific/Niue', + utcOffset: -660, + offsetStr: '-11:00', + countries: [ + 'NU' + ] + }, + 'Pacific/Auckland': { + name: 'Pacific/Auckland', + utcOffset: 780, + offsetStr: '+13:00', + countries: [ + 'NZ', + 'AQ' + ] + }, + 'Pacific/Chatham': { + name: 'Pacific/Chatham', + utcOffset: 825, + offsetStr: '+13:45', + countries: [ + 'NZ' + ] + }, + 'America/Panama': { + name: 'America/Panama', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'PA' + ] + }, + 'America/Lima': { + name: 'America/Lima', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'PE' + ] + }, + 'Pacific/Tahiti': { + name: 'Pacific/Tahiti', + utcOffset: -600, + offsetStr: '-10:00', + countries: [ + 'PF' + ] + }, + 'Pacific/Marquesas': { + name: 'Pacific/Marquesas', + utcOffset: -570, + offsetStr: '-09:30', + countries: [ + 'PF' + ] + }, + 'Pacific/Gambier': { + name: 'Pacific/Gambier', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'PF' + ] + }, + 'Pacific/Port_Moresby': { + name: 'Pacific/Port_Moresby', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'PG' + ] + }, + 'Pacific/Bougainville': { + name: 'Pacific/Bougainville', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'PG' + ] + }, + 'Asia/Manila': { + name: 'Asia/Manila', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'PH' + ] + }, + 'Asia/Karachi': { + name: 'Asia/Karachi', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'PK' + ] + }, + 'Europe/Warsaw': { + name: 'Europe/Warsaw', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'PL' + ] + }, + 'America/Miquelon': { + name: 'America/Miquelon', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'PM' + ] + }, + 'Pacific/Pitcairn': { + name: 'Pacific/Pitcairn', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'PN' + ] + }, + 'America/Puerto_Rico': { + name: 'America/Puerto_Rico', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'PR' + ] + }, + 'Asia/Gaza': { + name: 'Asia/Gaza', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'PS' + ] + }, + 'Asia/Hebron': { + name: 'Asia/Hebron', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'PS' + ] + }, + 'Europe/Lisbon': { + name: 'Europe/Lisbon', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'PT' + ] + }, + 'Atlantic/Madeira': { + name: 'Atlantic/Madeira', + utcOffset: 0, + offsetStr: '+00:00', + countries: [ + 'PT' + ] + }, + 'Atlantic/Azores': { + name: 'Atlantic/Azores', + utcOffset: -60, + offsetStr: '-01:00', + countries: [ + 'PT' + ] + }, + 'Pacific/Palau': { + name: 'Pacific/Palau', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'PW' + ] + }, + 'America/Asuncion': { + name: 'America/Asuncion', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'PY' + ] + }, + 'Asia/Qatar': { + name: 'Asia/Qatar', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'QA', + 'BH' + ] + }, + 'Indian/Reunion': { + name: 'Indian/Reunion', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'RE', + 'TF' + ] + }, + 'Europe/Bucharest': { + name: 'Europe/Bucharest', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'RO' + ] + }, + 'Europe/Belgrade': { + name: 'Europe/Belgrade', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'RS', + 'BA', + 'HR', + 'ME', + 'MK', + 'SI' + ] + }, + 'Europe/Kaliningrad': { + name: 'Europe/Kaliningrad', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'RU' + ] + }, + 'Europe/Moscow': { + name: 'Europe/Moscow', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'RU' + ] + }, + 'Europe/Simferopol': { + name: 'Europe/Simferopol', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'RU' + ] + }, + 'Europe/Volgograd': { + name: 'Europe/Volgograd', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'RU' + ] + }, + 'Europe/Samara': { + name: 'Europe/Samara', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'RU' + ] + }, + 'Asia/Yekaterinburg': { + name: 'Asia/Yekaterinburg', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'RU' + ] + }, + 'Asia/Omsk': { + name: 'Asia/Omsk', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'RU' + ] + }, + 'Asia/Novosibirsk': { + name: 'Asia/Novosibirsk', + utcOffset: 360, + offsetStr: '+06:00', + countries: [ + 'RU' + ] + }, + 'Asia/Novokuznetsk': { + name: 'Asia/Novokuznetsk', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'RU' + ] + }, + 'Asia/Krasnoyarsk': { + name: 'Asia/Krasnoyarsk', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'RU' + ] + }, + 'Asia/Irkutsk': { + name: 'Asia/Irkutsk', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'RU' + ] + }, + 'Asia/Chita': { + name: 'Asia/Chita', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'RU' + ] + }, + 'Asia/Yakutsk': { + name: 'Asia/Yakutsk', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'RU' + ] + }, + 'Asia/Khandyga': { + name: 'Asia/Khandyga', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'RU' + ] + }, + 'Asia/Vladivostok': { + name: 'Asia/Vladivostok', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'RU' + ] + }, + 'Asia/Sakhalin': { + name: 'Asia/Sakhalin', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'RU' + ] + }, + 'Asia/Ust-Nera': { + name: 'Asia/Ust-Nera', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'RU' + ] + }, + 'Asia/Magadan': { + name: 'Asia/Magadan', + utcOffset: 600, + offsetStr: '+10:00', + countries: [ + 'RU' + ] + }, + 'Asia/Srednekolymsk': { + name: 'Asia/Srednekolymsk', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'RU' + ] + }, + 'Asia/Kamchatka': { + name: 'Asia/Kamchatka', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'RU' + ] + }, + 'Asia/Anadyr': { + name: 'Asia/Anadyr', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'RU' + ] + }, + 'Asia/Riyadh': { + name: 'Asia/Riyadh', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'SA', + 'KW', + 'YE' + ] + }, + 'Pacific/Guadalcanal': { + name: 'Pacific/Guadalcanal', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'SB' + ] + }, + 'Indian/Mahe': { + name: 'Indian/Mahe', + utcOffset: 240, + offsetStr: '+04:00', + countries: [ + 'SC' + ] + }, + 'Africa/Khartoum': { + name: 'Africa/Khartoum', + utcOffset: 180, + offsetStr: '+03:00', + countries: [ + 'SD', + 'SS' + ] + }, + 'Europe/Stockholm': { + name: 'Europe/Stockholm', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'SE' + ] + }, + 'Asia/Singapore': { + name: 'Asia/Singapore', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'SG' + ] + }, + 'America/Paramaribo': { + name: 'America/Paramaribo', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'SR' + ] + }, + 'America/El_Salvador': { + name: 'America/El_Salvador', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'SV' + ] + }, + 'Asia/Damascus': { + name: 'Asia/Damascus', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'SY' + ] + }, + 'America/Grand_Turk': { + name: 'America/Grand_Turk', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'TC' + ] + }, + 'Africa/Ndjamena': { + name: 'Africa/Ndjamena', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'TD' + ] + }, + 'Indian/Kerguelen': { + name: 'Indian/Kerguelen', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'TF' + ] + }, + 'Asia/Bangkok': { + name: 'Asia/Bangkok', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'TH', + 'KH', + 'LA', + 'VN' + ] + }, + 'Asia/Dushanbe': { + name: 'Asia/Dushanbe', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'TJ' + ] + }, + 'Pacific/Fakaofo': { + name: 'Pacific/Fakaofo', + utcOffset: 780, + offsetStr: '+13:00', + countries: [ + 'TK' + ] + }, + 'Asia/Dili': { + name: 'Asia/Dili', + utcOffset: 540, + offsetStr: '+09:00', + countries: [ + 'TL' + ] + }, + 'Asia/Ashgabat': { + name: 'Asia/Ashgabat', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'TM' + ] + }, + 'Africa/Tunis': { + name: 'Africa/Tunis', + utcOffset: 60, + offsetStr: '+01:00', + countries: [ + 'TN' + ] + }, + 'Pacific/Tongatapu': { + name: 'Pacific/Tongatapu', + utcOffset: 780, + offsetStr: '+13:00', + countries: [ + 'TO' + ] + }, + 'Europe/Istanbul': { + name: 'Europe/Istanbul', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'TR' + ] + }, + 'America/Port_of_Spain': { + name: 'America/Port_of_Spain', + utcOffset: -240, + offsetStr: '-04:00', + countries: [ + 'TT', + 'AG', + 'AI', + 'BL', + 'DM', + 'GD', + 'GP', + 'KN', + 'LC', + 'MF', + 'MS', + 'VC', + 'VG', + 'VI' + ] + }, + 'Pacific/Funafuti': { + name: 'Pacific/Funafuti', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'TV' + ] + }, + 'Asia/Taipei': { + name: 'Asia/Taipei', + utcOffset: 480, + offsetStr: '+08:00', + countries: [ + 'TW' + ] + }, + 'Europe/Kiev': { + name: 'Europe/Kiev', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'UA' + ] + }, + 'Europe/Uzhgorod': { + name: 'Europe/Uzhgorod', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'UA' + ] + }, + 'Europe/Zaporozhye': { + name: 'Europe/Zaporozhye', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'UA' + ] + }, + 'Pacific/Wake': { + name: 'Pacific/Wake', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'UM' + ] + }, + 'America/New_York': { + name: 'America/New_York', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Detroit': { + name: 'America/Detroit', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Kentucky/Louisville': { + name: 'America/Kentucky/Louisville', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Kentucky/Monticello': { + name: 'America/Kentucky/Monticello', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Indianapolis': { + name: 'America/Indiana/Indianapolis', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Vincennes': { + name: 'America/Indiana/Vincennes', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Winamac': { + name: 'America/Indiana/Winamac', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Marengo': { + name: 'America/Indiana/Marengo', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Petersburg': { + name: 'America/Indiana/Petersburg', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Vevay': { + name: 'America/Indiana/Vevay', + utcOffset: -300, + offsetStr: '-05:00', + countries: [ + 'US' + ] + }, + 'America/Chicago': { + name: 'America/Chicago', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Tell_City': { + name: 'America/Indiana/Tell_City', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/Indiana/Knox': { + name: 'America/Indiana/Knox', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/Menominee': { + name: 'America/Menominee', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/North_Dakota/Center': { + name: 'America/North_Dakota/Center', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/North_Dakota/New_Salem': { + name: 'America/North_Dakota/New_Salem', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/North_Dakota/Beulah': { + name: 'America/North_Dakota/Beulah', + utcOffset: -360, + offsetStr: '-06:00', + countries: [ + 'US' + ] + }, + 'America/Denver': { + name: 'America/Denver', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'US' + ] + }, + 'America/Boise': { + name: 'America/Boise', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'US' + ] + }, + 'America/Phoenix': { + name: 'America/Phoenix', + utcOffset: -420, + offsetStr: '-07:00', + countries: [ + 'US' + ] + }, + 'America/Los_Angeles': { + name: 'America/Los_Angeles', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'US' + ] + }, + 'America/Metlakatla': { + name: 'America/Metlakatla', + utcOffset: -480, + offsetStr: '-08:00', + countries: [ + 'US' + ] + }, + 'America/Anchorage': { + name: 'America/Anchorage', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'US' + ] + }, + 'America/Juneau': { + name: 'America/Juneau', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'US' + ] + }, + 'America/Sitka': { + name: 'America/Sitka', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'US' + ] + }, + 'America/Yakutat': { + name: 'America/Yakutat', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'US' + ] + }, + 'America/Nome': { + name: 'America/Nome', + utcOffset: -540, + offsetStr: '-09:00', + countries: [ + 'US' + ] + }, + 'America/Adak': { + name: 'America/Adak', + utcOffset: -600, + offsetStr: '-10:00', + countries: [ + 'US' + ] + }, + 'Pacific/Honolulu': { + name: 'Pacific/Honolulu', + utcOffset: -600, + offsetStr: '-10:00', + countries: [ + 'US', + 'UM' + ] + }, + 'America/Montevideo': { + name: 'America/Montevideo', + utcOffset: -180, + offsetStr: '-03:00', + countries: [ + 'UY' + ] + }, + 'Asia/Samarkand': { + name: 'Asia/Samarkand', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'UZ' + ] + }, + 'Asia/Tashkent': { + name: 'Asia/Tashkent', + utcOffset: 300, + offsetStr: '+05:00', + countries: [ + 'UZ' + ] + }, + 'America/Caracas': { + name: 'America/Caracas', + utcOffset: -270, + offsetStr: '-04:30', + countries: [ + 'VE' + ] + }, + 'Asia/Ho_Chi_Minh': { + name: 'Asia/Ho_Chi_Minh', + utcOffset: 420, + offsetStr: '+07:00', + countries: [ + 'VN' + ] + }, + 'Pacific/Efate': { + name: 'Pacific/Efate', + utcOffset: 660, + offsetStr: '+11:00', + countries: [ + 'VU' + ] + }, + 'Pacific/Wallis': { + name: 'Pacific/Wallis', + utcOffset: 720, + offsetStr: '+12:00', + countries: [ + 'WF' + ] + }, + 'Pacific/Apia': { + name: 'Pacific/Apia', + utcOffset: 840, + offsetStr: '+14:00', + countries: [ + 'WS' + ] + }, + 'Africa/Johannesburg': { + name: 'Africa/Johannesburg', + utcOffset: 120, + offsetStr: '+02:00', + countries: [ + 'ZA', + 'LS', + 'SZ' + ] + } + } +}; \ No newline at end of file diff --git a/server/config/express.js b/server/config/express.js new file mode 100644 index 0000000..9c4446d --- /dev/null +++ b/server/config/express.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['get','production','set','appPath','public','join','root','client','use','toISOString','split','static','views','/server/views','engine','html','ejs','urlencoded','50mb','json','initialize','express','method-override','cookie-parser','passport','./environment','default'];(function(_0x5e2489,_0x2fd8be){var _0xa87596=function(_0x3b348d){while(--_0x3b348d){_0x5e2489['push'](_0x5e2489['shift']());}};_0xa87596(++_0x2fd8be);}(_0xa9e0,0x123));var _0x0a9e=function(_0x1b349a,_0x22222c){_0x1b349a=_0x1b349a-0x0;var _0x5d1f7c=_0xa9e0[_0x1b349a];return _0x5d1f7c;};'use strict';var express=require(_0x0a9e('0x0'));var methodOverride=require(_0x0a9e('0x1'));var cookieParser=require(_0x0a9e('0x2'));var errorHandler=require('errorhandler');var path=require('path');var passport=require(_0x0a9e('0x3'));var cors=require('cors');var config=require(_0x0a9e('0x4'));exports[_0x0a9e('0x5')]=function(_0x2ab90b){var _0x991246=_0x2ab90b[_0x0a9e('0x6')]('env');if(_0x991246===_0x0a9e('0x7')){_0x2ab90b[_0x0a9e('0x8')](_0x0a9e('0x9'),path['join'](config['root'],_0x0a9e('0xa')));}if(_0x991246==='development'||_0x991246==='test'){_0x2ab90b[_0x0a9e('0x8')](_0x0a9e('0x9'),path[_0x0a9e('0xb')](config[_0x0a9e('0xc')],_0x0a9e('0xd')));_0x2ab90b[_0x0a9e('0xe')](errorHandler());}_0x2ab90b['set']('json\x20replacer',function(_0x527cdd,_0x4cfe67){if(this[_0x527cdd]instanceof Date){_0x4cfe67=this[_0x527cdd][_0x0a9e('0xf')]()[_0x0a9e('0x10')]('.')[0x0]+'Z';}return _0x4cfe67;});_0x2ab90b[_0x0a9e('0xe')](express[_0x0a9e('0x11')](_0x2ab90b[_0x0a9e('0x6')](_0x0a9e('0x9'))));_0x2ab90b['set'](_0x0a9e('0x12'),config[_0x0a9e('0xc')]+_0x0a9e('0x13'));_0x2ab90b[_0x0a9e('0x14')](_0x0a9e('0x15'),require(_0x0a9e('0x16'))['renderFile']);_0x2ab90b[_0x0a9e('0x8')]('view\x20engine',_0x0a9e('0x15'));_0x2ab90b['use'](express[_0x0a9e('0x17')]({'limit':_0x0a9e('0x18'),'extended':!![]}));_0x2ab90b['use'](express[_0x0a9e('0x19')]({'limit':'50mb'}));_0x2ab90b[_0x0a9e('0xe')](cors());_0x2ab90b[_0x0a9e('0xe')](methodOverride());_0x2ab90b[_0x0a9e('0xe')](cookieParser());_0x2ab90b[_0x0a9e('0xe')](passport[_0x0a9e('0x1a')]());}; \ No newline at end of file diff --git a/server/config/license/hardware.js b/server/config/license/hardware.js new file mode 100644 index 0000000..154677c --- /dev/null +++ b/server/config/license/hardware.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4cef=['filter','IPv4','internal','head','mac','00:00:00:00:00:00','address','127.0.0.1','getFirstInterface','cpus','map','model','createHash','md5','update','hex','getUuid','licenseToken','test','win32','utf8','replace','hostname','macAddress','ipAddress','digest','substring','crypto','bimedia-machine-uuid','execSync','../environment','orderBy','length'];(function(_0x1abb09,_0x18ee91){var _0xea1c07=function(_0x38f42c){while(--_0x38f42c){_0x1abb09['push'](_0x1abb09['shift']());}};_0xea1c07(++_0x18ee91);}(_0x4cef,0x165));var _0xf4ce=function(_0x5b0a4a,_0x11a985){_0x5b0a4a=_0x5b0a4a-0x0;var _0x2ce5c6=_0x4cef[_0x5b0a4a];return _0x2ce5c6;};'use strict';var _=require('lodash');var os=require('os');var crypto=require(_0xf4ce('0x0'));var machine=require(_0xf4ce('0x1'));var exec=require('child_process')[_0xf4ce('0x2')];var config=require(_0xf4ce('0x3'));function getInterfaces(){var _0x2ed3e7=[];var _0xe2ad63=os['networkInterfaces']();var _0x154f81=_[_0xf4ce('0x4')](_['keys'](_0xe2ad63));for(var _0x209553=0x0;_0x209553<_0x154f81[_0xf4ce('0x5')];_0x209553++){var _0x705ae=_0xe2ad63[_0x154f81[_0x209553]][_0xf4ce('0x6')](function(_0x66c549){return _0x66c549['family']===_0xf4ce('0x7')&&_0x66c549[_0xf4ce('0x8')]===![];});_0x2ed3e7=_0x2ed3e7['concat'](_0x705ae);}return _0x2ed3e7;}function getFirstInterface(){var _0x50b496=_[_0xf4ce('0x9')](getInterfaces());return{'macAddress':_0x50b496&&_0x50b496['mac']?_0x50b496[_0xf4ce('0xa')]:_0xf4ce('0xb'),'ipAddress':_0x50b496&&_0x50b496['address']?_0x50b496[_0xf4ce('0xc')]:_0xf4ce('0xd')};}exports[_0xf4ce('0xe')]=getFirstInterface;function getCPUhash(){var _0x2ef959=_[_0xf4ce('0x4')](os[_0xf4ce('0xf')]()[_0xf4ce('0x10')](function(_0x3f7118){return _0x3f7118[_0xf4ce('0x11')];}))['join'](':');return crypto[_0xf4ce('0x12')](_0xf4ce('0x13'))[_0xf4ce('0x14')](_0x2ef959)['digest'](_0xf4ce('0x15'));}exports[_0xf4ce('0x16')]=function(){var _0x5178b4=os['platform']();var _0x523dfa=/[0-9a-f-]{36}/;if(config[_0xf4ce('0x17')]&&_0x523dfa[_0xf4ce('0x18')](config[_0xf4ce('0x17')])){return config[_0xf4ce('0x17')];}else if(_0x5178b4===_0xf4ce('0x19')){return exec('dmidecode\x20--string\x20system-uuid',{'encoding':_0xf4ce('0x1a')})[_0xf4ce('0x1b')]('\x0d\x0a','');}else{var _0x13343e=getFirstInterface();var _0x185338=getCPUhash();var _0x54c370=_0x185338+'|'+os[_0xf4ce('0x1c')]()+'|'+_0x13343e[_0xf4ce('0x1d')]+'|'+_0x13343e[_0xf4ce('0x1e')];var _0x481160=crypto[_0xf4ce('0x12')](_0xf4ce('0x13'))[_0xf4ce('0x14')](_0x54c370)[_0xf4ce('0x1f')](_0xf4ce('0x15'));return _0x481160[_0xf4ce('0x20')](0x0,0x8)+'-'+_0x481160['substring'](0x8,0xc)+'-'+_0x481160[_0xf4ce('0x20')](0xc,0x10)+'-'+_0x481160[_0xf4ce('0x20')](0x10,0x14)+'-'+_0x481160['substring'](0x14);}}; \ No newline at end of file diff --git a/server/config/license/index.js b/server/config/license/index.js new file mode 100644 index 0000000..1ac73c7 --- /dev/null +++ b/server/config/license/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x60cd=['get','data1','data2','then','active','license','info','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','diff','decryptString','days','DEMO\x20START\x20AT\x20%s','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','error','finally','getUuid','License','findOrCreate','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','message','bluebird','version','./hardware','../logger','format','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','catch'];(function(_0x5216c1,_0x4559ba){var _0x37fb01=function(_0x194c3c){while(--_0x194c3c){_0x5216c1['push'](_0x5216c1['shift']());}};_0x37fb01(++_0x4559ba);}(_0x60cd,0xe0));var _0xd60c=function(_0xade468,_0xa07081){_0xade468=_0xade468-0x0;var _0x54a9dc=_0x60cd[_0xade468];return _0x54a9dc;};'use strict';var util=require('util');var moment=require('moment');var rp=require('request-promise');var BPromise=require(_0xd60c('0x0'));var pkginfo=require('pkginfo')(module,_0xd60c('0x1'));var db=require('../../mysqldb')['db'];var encryptor=require('../../components/encryptor');var hardware=require(_0xd60c('0x2'));var logger=require(_0xd60c('0x3'))('license');var HOST='https://www.xcallymotion.com';var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x642791){return new BPromise(function(_0x28a205,_0x58dbdb){var _0x545824=util[_0xd60c('0x4')](_0xd60c('0x5'),HOST,_0x642791,module[_0xd60c('0x6')]['version']);if(oldToken){_0x545824=util[_0xd60c('0x4')](_0xd60c('0x7'),HOST,_0x642791,module[_0xd60c('0x6')][_0xd60c('0x1')],oldToken);}var _0x20a2fe={'uri':_0x545824,'method':_0xd60c('0x8'),'timeout':0xea60,'json':!![]};return rp(_0x20a2fe)['then'](function(_0xa17420){_0x28a205(_0xa17420);})[_0xd60c('0x9')](function(_0x57c048){_0x58dbdb(_0x57c048);});});}function manageLicense(_0x3223d4,_0x343a8e){var _0xca684e=_0x343a8e[_0xd60c('0xa')]({'plain':!![]});if(!isOldTokenSent&&_0xca684e[_0xd60c('0xb')]!==_0x3223d4&&!_0xca684e[_0xd60c('0xc')]){oldToken=_0xca684e[_0xd60c('0xb')];}httpRequest(_0x3223d4)[_0xd60c('0xd')](function(_0x601259){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x601259[_0xd60c('0xe')]){isOldTokenSent=![];if(!_0xca684e[_0xd60c('0xf')]&&_0xca684e[_0xd60c('0xf')]!=_0x601259['license']||_0xca684e[_0xd60c('0xf')]&&_0xca684e[_0xd60c('0xc')]){logger[_0xd60c('0x10')]('THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED');}if(_0xca684e[_0xd60c('0xf')]&&!_0xca684e[_0xd60c('0xc')]&&_0xca684e[_0xd60c('0xf')]!=_0x601259[_0xd60c('0xf')]){logger['info'](_0xd60c('0x11'));}if(_0xca684e[_0xd60c('0xf')]&&!_0xca684e[_0xd60c('0xc')]&&_0xca684e['license']==_0x601259[_0xd60c('0xf')]){return _0x343a8e;}return _0x343a8e[_0xd60c('0x12')]({'data1':_0x3223d4,'data2':null,'license':_0x601259['license']});}else{if(_0x601259['license']||_0xca684e[_0xd60c('0xf')]){if(!_0xca684e[_0xd60c('0xc')]){if(_0xca684e[_0xd60c('0xb')]==_0x3223d4){GRAY_PERIOD_REASON=_0xd60c('0x13');logger[_0xd60c('0x10')](_0xd60c('0x14'));}else{GRAY_PERIOD_REASON=_0xd60c('0x15');logger[_0xd60c('0x10')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0xca684e['data1'],_0x3223d4);}logger[_0xd60c('0x10')](_0xd60c('0x16'),GRAY_PERIOD_REASON[_0xd60c('0x17')](),moment()['format'](_0xd60c('0x18')));return _0x343a8e[_0xd60c('0x12')]({'data2':encryptor[_0xd60c('0x19')](moment()['format'](_0xd60c('0x18')))});}else{if(moment()[_0xd60c('0x1a')](encryptor[_0xd60c('0x1b')](_0xca684e[_0xd60c('0xc')]),_0xd60c('0x1c'))>DAYS){logger[_0xd60c('0x10')](_0xd60c('0x1d'),moment()[_0xd60c('0x4')](_0xd60c('0x18')));isOldTokenSent=![];return _0x343a8e[_0xd60c('0x12')]({'data1':_0x3223d4,'data2':null,'license':null});}}}else{if(_0xca684e[_0xd60c('0xb')]!=_0x3223d4){logger[_0xd60c('0x10')](_0xd60c('0x1e'),_0xca684e[_0xd60c('0xb')],_0x3223d4);return _0x343a8e[_0xd60c('0x12')]({'data1':_0x3223d4,'data2':null,'license':null});}}}return _0x343a8e;})[_0xd60c('0xd')](function(_0x234184){_0x343a8e=_0x234184;})['catch'](function(_0x26e1f4){logger[_0xd60c('0x1f')](_0x26e1f4['message']);})[_0xd60c('0x20')](function(){setTimeout(function(){manageLicense(hardware[_0xd60c('0x21')](),_0x343a8e);},TIME);});}function defaultLicense(){var _0x3f424c=hardware[_0xd60c('0x21')]();if(_0x3f424c){return db[_0xd60c('0x22')][_0xd60c('0x23')]({'where':{'id':0x1},'defaults':{'data1':_0x3f424c}})[_0xd60c('0x24')](function(_0x5f06cb,_0x19037b){logger[_0xd60c('0x10')](_0xd60c('0x25'),_0x3f424c);manageLicense(_0x3f424c,_0x5f06cb);})[_0xd60c('0x9')](function(_0x53390e){logger[_0xd60c('0x1f')](_0x53390e[_0xd60c('0x26')]);});}}exports['default']=defaultLicense; \ No newline at end of file diff --git a/server/config/license/util.js b/server/config/license/util.js new file mode 100644 index 0000000..d3b841c --- /dev/null +++ b/server/config/license/util.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3147=['forEach','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','moment','bluebird','./hardware','Demo\x20license','getUuid','2027-01-01T00:00:00.000Z','Breaking\x20license','License','find','defaults','then','catch','uuid','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','data2','split','decryptString','format','%s:%s:%s','parse','demo','machineUuid','gray','add','days','grayReason','message','User','findAll','role','sequelize','COUNT','col','count','admin','user','telephone','users','telephones'];(function(_0x2b871b,_0x2ced5d){var _0x36918b=function(_0x101552){while(--_0x101552){_0x2b871b['push'](_0x2b871b['shift']());}};_0x36918b(++_0x2ced5d);}(_0x3147,0xc9));var _0x7314=function(_0xb80b68,_0x1180b1){_0xb80b68=_0xb80b68-0x0;var _0x173d69=_0x3147[_0xb80b68];return _0x173d69;};'use strict';var util=require(_0x7314('0x0'));var _=require(_0x7314('0x1'));var moment=require(_0x7314('0x2'));var BPromise=require(_0x7314('0x3'));var hardware=require(_0x7314('0x4'));var encryptor=require('../../components/encryptor');var db=require('../../mysqldb')['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':'2027-01-01T00:00:00.000Z','chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x7314('0x5'),'machineUuid':hardware[_0x7314('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x7314('0x7'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x7314('0x8'),'machineUuid':hardware[_0x7314('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x7abbf2){return new BPromise(function(_0x37dfb9,_0x147cec){return db[_0x7314('0x9')][_0x7314('0xa')](_[_0x7314('0xb')](_0x7abbf2,{'raw':!![],'where':{'id':0x1}}))[_0x7314('0xc')](function(_0x1bfac4){return checkLicense(_0x1bfac4,null);})['then'](function(_0x363aaa){_0x37dfb9(_0x363aaa);return;})[_0x7314('0xd')](function(_0x379481){_0x147cec(_0x379481);});});}function checkLicense(_0x2208f0,_0x4c040e){if(!_0x2208f0){demoLicense[_0x7314('0xe')]=_0x2208f0[_0x7314('0xf')];return demoLicense;}try{var _0x33681a=_0x4c040e||_0x2208f0[_0x7314('0x10')];if(_[_0x7314('0x11')](_0x33681a)){throw new Error(_0x7314('0x12'));}var _0x1e7011=_0x2208f0[_0x7314('0xf')];var _0x39a06e=_0x2208f0[_0x7314('0x13')];var _0x437a08=_0x1e7011[_0x7314('0x14')]('-')[0x4];var _0x17b4fe=_0x1e7011[_0x7314('0x14')]('-')[0x0];var _0x2ddfc5=encryptor[_0x7314('0x15')](_0x33681a,util[_0x7314('0x16')](_0x7314('0x17'),_0x437a08,_0x1e7011,_0x17b4fe));var _0x1b9096=JSON[_0x7314('0x18')](_0x2ddfc5);_0x1b9096[_0x7314('0x19')]=![];_0x1b9096[_0x7314('0xe')]=_0x1e7011;_0x1b9096[_0x7314('0x1a')]=hardware[_0x7314('0x6')]();if(_0x39a06e){var _0x24884c=encryptor[_0x7314('0x15')](_0x39a06e);_0x1b9096[_0x7314('0x1b')]=_0x24884c;_0x1b9096['deadline']=moment(_0x24884c)[_0x7314('0x1c')](0x7,_0x7314('0x1d'))['format']();_0x1b9096[_0x7314('0x1e')]=_0x1b9096[_0x7314('0xe')]!=_0x1b9096['machineUuid']?'changed':'disabled';}return _0x1b9096;}catch(_0x1874e2){breakingLicense[_0x7314('0xe')]=_0x2208f0[_0x7314('0xf')];breakingLicense[_0x7314('0x1f')]=_0x1874e2[_0x7314('0x1f')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x42f900,_0x24093e){getLicense()['then'](function(_0x4e3f6e){return db[_0x7314('0x20')][_0x7314('0x21')]({'attributes':[_0x7314('0x22'),[db[_0x7314('0x23')]['fn'](_0x7314('0x24'),db[_0x7314('0x23')][_0x7314('0x25')](_0x7314('0x22'))),_0x7314('0x26')]],'group':_0x7314('0x22'),'where':{'role':{'$or':[_0x7314('0x27'),_0x7314('0x28'),_0x7314('0x29')]}},'raw':!![]})['then'](function(_0x2e9b41){var _0x12f09e={'user':_0x4e3f6e[_0x7314('0x2a')]||0x0,'telephone':_0x4e3f6e[_0x7314('0x2b')]||0x0};_0x2e9b41[_0x7314('0x2c')](function(_0x5a476c){var _0x2959e9=_0x5a476c['role']===_0x7314('0x27')?'user':_0x5a476c['role'];_0x12f09e[_0x2959e9]-=_0x5a476c[_0x7314('0x26')];if(_0x12f09e[_0x2959e9]<0x0)_0x12f09e[_0x2959e9]=0x0;});_0x42f900(_0x12f09e);return;});})[_0x7314('0xd')](function(_0x162e5b){_0x24093e(_0x162e5b);});});}function checkUserLimits(_0x150c1e){return new BPromise(function(_0x20d6ab,_0x57e691){getLimits()['then'](function(_0x11b2d8){var _0x45a8f9=_['pick'](_[_0x7314('0x2d')](_0x150c1e,'role'),[_0x7314('0x27'),_0x7314('0x28'),'telephone']);var _0x752d5e=(_0x45a8f9[_0x7314('0x27')]||0x0)+(_0x45a8f9['user']||0x0);var _0x38958f=_0x45a8f9['telephone']||0x0;if(_0x752d5e>_0x11b2d8['user'])return _0x57e691(_0x7314('0x2e'));if(_0x38958f>_0x11b2d8[_0x7314('0x29')])return _0x57e691(_0x7314('0x2f'));return _0x20d6ab();})[_0x7314('0xd')](function(_0x1f46e6){_0x57e691(_0x1f46e6);});});}module[_0x7314('0x30')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense}; \ No newline at end of file diff --git a/server/config/local.env.js b/server/config/local.env.js new file mode 100644 index 0000000..ba56432 --- /dev/null +++ b/server/config/local.env.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x25e7=['exports','http://localhost:9000','myappanuglar-secret','app-id','secret'];(function(_0x4ff09b,_0x53f67d){var _0x3f5c2e=function(_0x124592){while(--_0x124592){_0x4ff09b['push'](_0x4ff09b['shift']());}};_0x3f5c2e(++_0x53f67d);}(_0x25e7,0x1d6));var _0x725e=function(_0x5c620a,_0x200a52){_0x5c620a=_0x5c620a-0x0;var _0x5e6424=_0x25e7[_0x5c620a];return _0x5e6424;};'use strict';module[_0x725e('0x0')]={'DOMAIN':_0x725e('0x1'),'SESSION_SECRET':_0x725e('0x2'),'GOOGLE_ID':_0x725e('0x3'),'GOOGLE_SECRET':_0x725e('0x4'),'DEBUG':''}; \ No newline at end of file diff --git a/server/config/logger.js b/server/config/logger.js new file mode 100644 index 0000000..3e69a58 --- /dev/null +++ b/server/config/logger.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x64ca=['fileLogger','../utils/loggers'];(function(_0x458bf4,_0x42cf71){var _0x1ec4b9=function(_0x37e63a){while(--_0x37e63a){_0x458bf4['push'](_0x458bf4['shift']());}};_0x1ec4b9(++_0x42cf71);}(_0x64ca,0xc7));var _0xa64c=function(_0x2f5ac5,_0x1ee939){_0x2f5ac5=_0x2f5ac5-0x0;var _0x37c9a8=_0x64ca[_0x2f5ac5];return _0x37c9a8;};'use strict';var fileLogger=require(_0xa64c('0x0'))[_0xa64c('0x1')];module['exports']=fileLogger; \ No newline at end of file diff --git a/server/config/pm2/config.js b/server/config/pm2/config.js new file mode 100644 index 0000000..c334964 --- /dev/null +++ b/server/config/pm2/config.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9569=['agi','../../services/agi/index.js','../../services/email/index.js','xdr','../../services/xdr/index.js','exports','path','express','join','../../services/express/index.js'];(function(_0x241424,_0x25eb5d){var _0x3da798=function(_0x415153){while(--_0x415153){_0x241424['push'](_0x241424['shift']());}};_0x3da798(++_0x25eb5d);}(_0x9569,0xb0));var _0x9956=function(_0x4b3084,_0x35dad4){_0x4b3084=_0x4b3084-0x0;var _0x149475=_0x9569[_0x4b3084];return _0x149475;};'use strict';var path=require(_0x9956('0x0'));var os=require('os');var config={'apps':[{'name':_0x9956('0x1'),'script':path[_0x9956('0x2')](__dirname,_0x9956('0x3'))},{'name':'ami','script':path[_0x9956('0x2')](__dirname,'../../services/ami/index.js')},{'name':_0x9956('0x4'),'script':path[_0x9956('0x2')](__dirname,_0x9956('0x5'))},{'name':'email','script':path[_0x9956('0x2')](__dirname,_0x9956('0x6'))},{'name':'routing','script':path[_0x9956('0x2')](__dirname,'../../services/routing/index.js')},{'name':_0x9956('0x7'),'script':path[_0x9956('0x2')](__dirname,_0x9956('0x8'))}]};module[_0x9956('0x9')]=config; \ No newline at end of file diff --git a/server/config/pm2/index.js b/server/config/pm2/index.js new file mode 100644 index 0000000..25c7634 --- /dev/null +++ b/server/config/pm2/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x064a=['dump','saved','pm2','bluebird','./config','connect','connected','start','then','disconnect','stop','restart','list','describe','delete'];(function(_0x2de10c,_0x14a21e){var _0x9635ef=function(_0x368193){while(--_0x368193){_0x2de10c['push'](_0x2de10c['shift']());}};_0x9635ef(++_0x14a21e);}(_0x064a,0xf2));var _0xa064=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x064a[_0x14add3];return _0x4a174f;};'use strict';var pm2=require(_0xa064('0x0'));var BPromise=require(_0xa064('0x1'));var config=require(_0xa064('0x2'));function connect(){return new BPromise(function(_0x1c3668,_0x483b52){return pm2[_0xa064('0x3')](function(_0x29501a){if(_0x29501a){return _0x483b52(_0x29501a);}return _0x1c3668(_0xa064('0x4'));});});};exports[_0xa064('0x5')]=function(_0x550b09){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x12d008,_0x745469){return pm2[_0xa064('0x5')](_0x550b09,function(_0x3856dc,_0x26b440){if(_0x3856dc){return _0x745469(_0x3856dc);}pm2[_0xa064('0x7')]();return _0x12d008(_0x26b440);});});});};exports['stop']=function(_0x31e0f5){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x41bf49,_0x214570){return pm2[_0xa064('0x8')](_0x31e0f5,function(_0x1a810e,_0x3fe676){if(_0x1a810e){return _0x214570(_0x1a810e);}pm2['disconnect']();return _0x41bf49(_0x3fe676);});});});};exports[_0xa064('0x9')]=function(_0x14ba60){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x38e4f1,_0x150cca){return pm2[_0xa064('0x9')](_0x14ba60,function(_0x138b45,_0x5467eb){if(_0x138b45){return _0x150cca(_0x138b45);}pm2['disconnect']();return _0x38e4f1(_0x5467eb);});});});};exports[_0xa064('0xa')]=function(){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x1f3ff9,_0x249cfb){return pm2[_0xa064('0xa')](function(_0x16a9ce,_0x100f74){if(_0x16a9ce){return _0x249cfb(_0x16a9ce);}pm2[_0xa064('0x7')]();return _0x1f3ff9(_0x100f74);});});});};exports[_0xa064('0xb')]=function(_0x702d60){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x35c58f,_0x245a0e){return pm2[_0xa064('0xb')](_0x702d60,function(_0x384556,_0x450e1e){if(_0x384556){return _0x245a0e(_0x384556);}pm2['disconnect']();return _0x35c58f(_0x450e1e);});});});};exports['delete']=function(_0x158d07){return connect()['then'](function(){return new BPromise(function(_0x577b8d,_0x3bf889){return pm2[_0xa064('0xc')](_0x158d07,function(_0x38d95b,_0x249412){if(_0x38d95b){return _0x3bf889(_0x38d95b);}pm2[_0xa064('0x7')]();return _0x577b8d(_0x249412);});});});};exports[_0xa064('0xd')]=function(){return connect()[_0xa064('0x6')](function(){return new BPromise(function(_0x1f833b,_0x22f6dc){return pm2[_0xa064('0xd')](function(_0x43a7a0){if(_0x43a7a0){return _0x22f6dc(_0x43a7a0);}return _0x1f833b(_0xa064('0xe'));});});});}; \ No newline at end of file diff --git a/server/config/schedule/chat.js b/server/config/schedule/chat.js new file mode 100644 index 0000000..3b3e394 --- /dev/null +++ b/server/config/schedule/chat.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xaaa6=['catch','error','[CHAT]\x20Error\x20closing\x20interactions','inspect','lodash','moment','ioredis','../../config/environment','../../mysqldb','../logger','schedule','redis','defaults','socket.io-emitter','Setting','find','then','ChatInteraction','lastMsgAt','chatTimeout','minutes','length','map','join','update','system','format','YYYY-MM-DD\x20HH:mm:ss','info','[CHAT]\x20Sending\x20updates\x20for\x20interactions:','emit','chatInteraction:update'];(function(_0x28aee1,_0x45880b){var _0x12b081=function(_0x115d6d){while(--_0x115d6d){_0x28aee1['push'](_0x28aee1['shift']());}};_0x12b081(++_0x45880b);}(_0xaaa6,0xe4));var _0x6aaa=function(_0x4af7e3,_0x34f989){_0x4af7e3=_0x4af7e3-0x0;var _0x9c8095=_0xaaa6[_0x4af7e3];return _0x9c8095;};'use strict';var _=require(_0x6aaa('0x0'));var moment=require(_0x6aaa('0x1'));var Redis=require(_0x6aaa('0x2'));var util=require('util');var config=require(_0x6aaa('0x3'));var db=require(_0x6aaa('0x4'))['db'];var logger=require(_0x6aaa('0x5'))(_0x6aaa('0x6'));config[_0x6aaa('0x7')]=_[_0x6aaa('0x8')](config[_0x6aaa('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x6aaa('0x9'))(new Redis(config[_0x6aaa('0x7')]));function closeInteractions(){var _0x59aa36=0x0;var _0x3bcbff=[];return db[_0x6aaa('0xa')][_0x6aaa('0xb')]({'raw':!![],'attributes':['id','chatTimeout'],'where':{'id':0x1}})[_0x6aaa('0xc')](function(_0x2f3a8e){_0x59aa36=_0x2f3a8e['chatTimeout'];if(_0x59aa36){return db[_0x6aaa('0xd')]['findAll']({'raw':!![],'attributes':['id',_0x6aaa('0xe')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()['subtract'](_0x2f3a8e[_0x6aaa('0xf')],_0x6aaa('0x10'))}}});}else{return[];}})[_0x6aaa('0xc')](function(_0x218152){if(_0x218152&&_0x218152[_0x6aaa('0x11')]){_0x3bcbff=_[_0x6aaa('0x12')](_0x218152||[],'id');logger['info']('[CHAT]\x20Interactions\x20to\x20close:',_0x3bcbff[_0x6aaa('0x13')]());return db['ChatInteraction'][_0x6aaa('0x14')]({'closeReason':_0x6aaa('0x15'),'disposition':'timeout','closed':!![],'closedAt':moment()[_0x6aaa('0x16')](_0x6aaa('0x17'))},{'where':{'id':_0x3bcbff}});}})[_0x6aaa('0xc')](function(){if(_0x3bcbff&&_0x3bcbff['length']){logger[_0x6aaa('0x18')](_0x6aaa('0x19'),_0x3bcbff['join']());for(var _0x20dbf4=0x0;_0x20dbf4<_0x3bcbff[_0x6aaa('0x11')];_0x20dbf4++){io[_0x6aaa('0x1a')](_0x6aaa('0x1b'),{'id':_0x3bcbff[_0x20dbf4],'closed':!![]});}}})[_0x6aaa('0x1c')](function(_0x51eb23){logger[_0x6aaa('0x1d')](_0x6aaa('0x1e'),_0x51eb23?util[_0x6aaa('0x1f')](_0x51eb23,{'showHidden':![],'depth':null}):'');});}exports['start']=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();}; \ No newline at end of file diff --git a/server/config/schedule/cloud-provider.js b/server/config/schedule/cloud-provider.js new file mode 100644 index 0000000..b881637 --- /dev/null +++ b/server/config/schedule/cloud-provider.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3896=['../../api/cloudProvider/cloudProvider.oauth.js','exports'];(function(_0xa1e3e3,_0x29fe0e){var _0xc980e9=function(_0x1f5adc){while(--_0x1f5adc){_0xa1e3e3['push'](_0xa1e3e3['shift']());}};_0xc980e9(++_0x29fe0e);}(_0x3896,0x1ae));var _0x6389=function(_0x5d7c19,_0x46b3ec){_0x5d7c19=_0x5d7c19-0x0;var _0x46108a=_0x3896[_0x5d7c19];return _0x46108a;};'use strict';function start(){var _0x1027ad=require(_0x6389('0x0'));return _0x1027ad['startAllRefreshIntervals']();}module[_0x6389('0x1')]={'intervals':{},'start':start}; \ No newline at end of file diff --git a/server/config/schedule/index.js b/server/config/schedule/index.js new file mode 100644 index 0000000..1e2bd76 --- /dev/null +++ b/server/config/schedule/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x34e7=['jayson/promise','../logger','schedule','../../mysqldb','../../api/analyticCustomReport/analyticCustomReport.controller','../../api/analyticDefaultReport/analyticDefaultReport.controller','client','http','info','Try\x20to\x20send\x20a\x20mail\x20to','email','MailAccount','getSmtpOptions','format','\x22%s\x22\x20<%s>','name','Smtp','bcc','subtractUnit','savename','%s.%s','basename','extname','zip','join','existsSync','status','Sent','message','attachments','text','stringify','Report\x20empty\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20this\x20email.\x0a\x0a','sendIfEmpty','empty\x20file,\x20email\x20not\x20sent','request','SendMail','error','email\x20sent','catch','error\x20mail','data','isNil','subtractNumber\x20null\x20or\x20undefined','subtractUnit\x20null\x20or\x20undefined','subtract','YYYY-MM-DD\x20HH:mm:ss','output','DefaultReportId','exec\x20defaul\x20report\x20id:%s','runReport','then','CustomReportId','exec\x20custom\x20report\x20id:%s','no\x20report\x20id','Schedule','findAll','MailServerOut','CloudProvider','keys','jobs','map','toString','keyBy','difference','intersection','length','stop','deleteJob','delete\x20cron','toRun','index','my\x20id','resolve','run\x20job','cron','active','isBetween','startAt','add','stop\x20cron','exists','endAt','update','run','start','path','lodash','moment'];(function(_0x410b00,_0x95f65c){var _0x4e5b0b=function(_0x1194d8){while(--_0x1194d8){_0x410b00['push'](_0x410b00['shift']());}};_0x4e5b0b(++_0x95f65c);}(_0x34e7,0x161));var _0x734e=function(_0x29c3b9,_0x4adaf7){_0x29c3b9=_0x29c3b9-0x0;var _0x637286=_0x34e7[_0x29c3b9];return _0x637286;};'use strict';var fs=require('fs');var util=require('util');var path=require(_0x734e('0x0'));var _=require(_0x734e('0x1'));var moment=require(_0x734e('0x2'));var CronJobManager=require('cron-job-manager');var jayson=require(_0x734e('0x3'));var BPromise=require('bluebird');var logger=require(_0x734e('0x4'))(_0x734e('0x5'));var db=require(_0x734e('0x6'))['db'];var analyticCustomReportController=require(_0x734e('0x7'));var analyticDefaultReportController=require(_0x734e('0x8'));var client=jayson[_0x734e('0x9')][_0x734e('0xa')]({'port':0x232b});var manager=new CronJobManager();function handleSendEmail(_0x1f70d4,_0x391832){return function(){logger[_0x734e('0xb')](_0x734e('0xc'),_0x1f70d4[_0x734e('0xd')]);var _0x15e358=!![];var _0x179916=_0x1f70d4[_0x734e('0xe')][_0x734e('0xf')]();var _0xc13952={'account':_0x179916,'message':{'from':util[_0x734e('0x10')](_0x734e('0x11'),_0x1f70d4['MailAccount'][_0x734e('0x12')],_0x1f70d4[_0x734e('0xe')][_0x734e('0xd')]||_0x1f70d4['MailAccount'][_0x734e('0x13')]['user']),'to':_0x1f70d4[_0x734e('0xd')],'cc':_0x1f70d4['cc'],'bcc':_0x1f70d4[_0x734e('0x14')],'subject':util[_0x734e('0x10')]('Report\x20%s\x20last\x20%s\x20%s',_0x391832[_0x734e('0x12')],_0x1f70d4['subtractNumber'],_0x1f70d4[_0x734e('0x15')])}};var _0x3d039a=path['join'](__dirname,'../../files/reports');var _0x680225=_0x391832[_0x734e('0x16')];var _0x267985=util[_0x734e('0x10')](_0x734e('0x17'),path[_0x734e('0x18')](_0x391832['savename'],path[_0x734e('0x19')](_0x391832[_0x734e('0x16')])),_0x734e('0x1a'));var _0xf9a691=path[_0x734e('0x1b')](_0x3d039a,_0x680225);var _0x4e268e=path[_0x734e('0x1b')](_0x3d039a,_0x267985);if(fs[_0x734e('0x1c')](_0xf9a691)){_0x391832[_0x734e('0x1d')]=_0x734e('0x1e');_0xc13952[_0x734e('0x1f')][_0x734e('0x20')]=[{'filename':_0x680225,'path':_0xf9a691}];_0xc13952['message'][_0x734e('0x21')]=util['format']('Info\x20report:\x0a%s\x0aPlease\x20see\x20the\x20attachments\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20it.\x0a\x0a',JSON[_0x734e('0x22')](_0x391832,null,0x2));}else if(fs[_0x734e('0x1c')](_0x4e268e)){_0x391832[_0x734e('0x1d')]=_0x734e('0x1e');_0xc13952['message']['attachments']=[{'filename':_0x267985,'path':_0x4e268e}];}else{_0xc13952[_0x734e('0x1f')][_0x734e('0x21')]=_0x734e('0x23');if(!_0x1f70d4[_0x734e('0x24')]){_0x15e358=![];logger[_0x734e('0xb')](_0x734e('0x25'));}}if(_0x15e358){return client[_0x734e('0x26')](_0x734e('0x27'),_0xc13952)['then'](function(_0x3f353a){if(_0x3f353a[_0x734e('0x28')]){return logger[_0x734e('0x28')]('error\x20mail',JSON[_0x734e('0x22')](_0x3f353a));}return logger[_0x734e('0xb')](_0x734e('0x29'));})[_0x734e('0x2a')](function(_0x4591b7){return logger[_0x734e('0x28')](_0x734e('0x2b'),JSON[_0x734e('0x22')](_0x4591b7));});}};}function handleError(){return function(_0x31831b){return logger[_0x734e('0x28')](JSON[_0x734e('0x22')](_0x31831b));};}function handleResult(_0x546d30){return function(_0x526443){logger['info'](_0x734e('0x2c'),JSON[_0x734e('0x22')](_0x526443));if(_0x546d30[_0x734e('0xe')]&&_0x546d30[_0x734e('0xe')][_0x734e('0x13')]&&!_[_0x734e('0x2d')](_0x546d30[_0x734e('0xd')])){setTimeout(handleSendEmail(_0x546d30,_0x526443),0x3c*0x3e8);}};}function handleJob(_0x4ff583){return function(){try{if(_['isNil'](_0x4ff583['subtractNumber'])){return logger[_0x734e('0xb')](_0x734e('0x2e'));}if(_[_0x734e('0x2d')](_0x4ff583[_0x734e('0x15')])){return logger['info'](_0x734e('0x2f'));}var _0xa0e6d8={'startDate':moment()[_0x734e('0x30')](_0x4ff583['subtractNumber'],_0x4ff583[_0x734e('0x15')])[_0x734e('0x10')]('YYYY-MM-DD\x20HH:mm:ss'),'endDate':moment()['format'](_0x734e('0x31')),'type':'scheduled','output':_0x4ff583[_0x734e('0x32')],'name':_0x4ff583['name']};if(!_[_0x734e('0x2d')](_0x4ff583[_0x734e('0x33')])){logger[_0x734e('0xb')](_0x734e('0x34'),_0x4ff583[_0x734e('0x33')]);return analyticDefaultReportController[_0x734e('0x35')]({'id':_0x4ff583[_0x734e('0x33')]},_0xa0e6d8)[_0x734e('0x36')](handleResult(_0x4ff583))[_0x734e('0x2a')](handleError());}if(!_[_0x734e('0x2d')](_0x4ff583[_0x734e('0x37')])){logger[_0x734e('0xb')](_0x734e('0x38'),_0x4ff583[_0x734e('0x37')]);return analyticCustomReportController[_0x734e('0x35')]({'id':_0x4ff583[_0x734e('0x37')]},_0xa0e6d8)['then'](handleResult(_0x4ff583))[_0x734e('0x2a')](handleError());}}catch(_0x3f3713){logger[_0x734e('0x28')](JSON[_0x734e('0x22')](_0x3f3713));}return logger[_0x734e('0xb')](_0x734e('0x39'));};}function getJobs(_0x416ee3){var _0x450ffe={};if(_0x416ee3){_0x450ffe['id']=_0x416ee3;}return db[_0x734e('0x3a')][_0x734e('0x3b')]({'where':_0x450ffe,'include':[{'model':db[_0x734e('0xe')],'attributes':['id',_0x734e('0x12'),_0x734e('0xd')],'include':[{'model':db[_0x734e('0x3c')],'as':_0x734e('0x13'),'include':[{'model':db[_0x734e('0x3d')],'as':_0x734e('0x3d')}]}]}]})['then'](function(_0x577e3d){var _0x4e8e79=_[_0x734e('0x3e')](manager[_0x734e('0x3f')]);var _0x63e80a=_[_0x734e('0x40')](_0x577e3d,function(_0x3e33d9){return _0x3e33d9['id'][_0x734e('0x41')]();});var _0x25c4a5=_[_0x734e('0x42')](_0x577e3d,function(_0x3a9242){return _0x3a9242['id'][_0x734e('0x41')]();});var _0x30f2d1=_0x416ee3?_0x63e80a:_[_0x734e('0x43')](_0x63e80a,_0x4e8e79);var _0x1252bc=_[_0x734e('0x44')](_0x63e80a,_0x4e8e79);var _0x40d5ec=_['difference'](_0x4e8e79,_0x63e80a);var _0x213590;var _0x793d58;for(_0x213590=0x0;_0x213590<_0x40d5ec[_0x734e('0x45')]&&!_0x416ee3;_0x213590+=0x1){_0x793d58=_0x40d5ec[_0x213590][_0x734e('0x41')]();if(manager['exists'](_0x793d58)){manager[_0x734e('0x46')](_0x793d58);manager[_0x734e('0x47')](_0x793d58);logger[_0x734e('0xb')](_0x734e('0x48'),_0x793d58);}}logger[_0x734e('0xb')](_0x734e('0x49'),JSON[_0x734e('0x22')](_0x30f2d1));for(_0x213590=0x0;_0x213590<_0x30f2d1[_0x734e('0x45')];_0x213590+=0x1){_0x793d58=_0x30f2d1[_0x213590][_0x734e('0x41')]();logger['info'](_0x734e('0x4a'),_0x793d58);if(_0x416ee3){logger[_0x734e('0xb')](_0x734e('0x4b'),_0x416ee3);logger[_0x734e('0xb')](JSON[_0x734e('0x22')](_0x25c4a5[_0x793d58]));BPromise[_0x734e('0x4c')]()['then'](handleJob(_0x25c4a5[_0x793d58]));logger['info'](_0x734e('0x4d'),_0x25c4a5[_0x793d58][_0x734e('0x12')],_0x25c4a5[_0x793d58][_0x734e('0x4e')]);}else if(_0x25c4a5[_0x793d58][_0x734e('0x4e')]&&_0x25c4a5[_0x793d58][_0x734e('0x4f')]&&moment()[_0x734e('0x50')](_0x25c4a5[_0x793d58][_0x734e('0x51')],_0x25c4a5[_0x793d58]['endAt'])){manager[_0x734e('0x52')](_0x793d58,_0x25c4a5[_0x793d58][_0x734e('0x4e')],handleJob(_0x25c4a5[_0x793d58]));manager['start'](_0x793d58);logger['info']('add\x20cron',_0x25c4a5[_0x793d58][_0x734e('0x12')],_0x25c4a5[_0x793d58]['cron']);}else if(manager['exists'](_0x793d58)){manager[_0x734e('0x46')](_0x793d58);manager['deleteJob'](_0x793d58);logger[_0x734e('0xb')](_0x734e('0x53'),_0x25c4a5[_0x793d58][_0x734e('0x12')],_0x25c4a5[_0x793d58][_0x734e('0x4e')]);}}for(_0x213590=0x0,_0x793d58;_0x213590<_0x1252bc[_0x734e('0x45')]&&!_0x416ee3;_0x213590+=0x1){_0x793d58=_0x1252bc[_0x213590]['toString']();if(manager[_0x734e('0x54')](_0x793d58)){if(_0x25c4a5[_0x793d58][_0x734e('0x4e')]&&_0x25c4a5[_0x793d58][_0x734e('0x4f')]&&moment()[_0x734e('0x50')](_0x25c4a5[_0x793d58]['startAt'],_0x25c4a5[_0x793d58][_0x734e('0x55')])){manager[_0x734e('0x56')](_0x793d58,_0x25c4a5[_0x793d58][_0x734e('0x4e')],handleJob(_0x25c4a5[_0x793d58]));logger[_0x734e('0xb')]('update\x20cron',_0x25c4a5[_0x793d58]['name'],_0x25c4a5[_0x793d58][_0x734e('0x4e')]);}else{manager['stop'](_0x793d58);manager[_0x734e('0x47')](_0x793d58);logger[_0x734e('0xb')]('stop\x20cron',_0x25c4a5[_0x793d58][_0x734e('0x12')],_0x25c4a5[_0x793d58][_0x734e('0x4e')]);}}}})[_0x734e('0x2a')](function(_0x1ae09e){logger[_0x734e('0x28')](JSON[_0x734e('0x22')](_0x1ae09e));});}exports[_0x734e('0x57')]=function(_0xcc2064){return getJobs(_0xcc2064);};exports[_0x734e('0x58')]=function(){setInterval(function(){return getJobs();},0x3c*0x3e8);return getJobs();}; \ No newline at end of file diff --git a/server/config/schedule/transcribe.js b/server/config/schedule/transcribe.js new file mode 100644 index 0000000..6e1c522 --- /dev/null +++ b/server/config/schedule/transcribe.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x36ee=['[RECORDING:%d]\x20Error\x20running\x20Transcribe\x20&\x20Sentiment\x20Analysis','VoiceRecording','findAll','IN_PROGRESS','No\x20transcribe\x20job\x20to\x20check','Setting','transcribeAccountId','Transcribe\x20not\x20configured','all','catch','error','inspect','start','request-promise','bluebird','../../mysqldb','../../config/logger','transcribe','TranscribeService','Comprehend','detectSentiment','substring','format','data1','data2','transcribeRegion','transcribeName','then','info','[RECORDING:%d]\x20Status\x20of\x20transcript\x20job\x20(%s):\x20%s','TranscriptionJobStatus','fileText','TranscriptionJob','Transcript','TranscriptFileUri','[RECORDING:%d]\x20Get\x20transcript','[RECORDING:%d]\x20Transcript\x20downloaded','results','transcripts','length','transcript','update','[RECORDING:%d]\x20Voice\x20Recording\x20entry\x20updated','Sequelize','Sentiment\x20Analysis\x20not\x20requested','sentimentAccountId','ValidationError','Sentiment\x20Analysis\x20not\x20configured','CloudProvider','findOne','Cloud\x20Provider\x20not\x20available','Cloud\x20Provider\x20not\x20configured','[RECORDING:%d]\x20Requesting\x20sentiment\x20analysis','sentimentRegion','Sentiment','SentimentScore','Positive','Mixed','Neutral','FAILED','FailureReason','[RECORDING:%d]\x20Transcript\x20Job\x20status\x20not\x20managed','resolve','tempSentiment','sentiment','language','bucket','Transcript\x20not\x20available','[RECORDING:%d]\x20Sentiment\x20Analysis\x20available','Negative','COMPLETED','name','SequelizeValidationError'];(function(_0x4f1777,_0x2e2e38){var _0x42ba61=function(_0x34c899){while(--_0x34c899){_0x4f1777['push'](_0x4f1777['shift']());}};_0x42ba61(++_0x2e2e38);}(_0x36ee,0xe8));var _0xe36e=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x36ee[_0x501510];return _0x1e6ee5;};var _=require('lodash');var AWS=require('aws-sdk');var rp=require(_0xe36e('0x0'));var util=require('util');var BPromise=require(_0xe36e('0x1'));var db=require(_0xe36e('0x2'))['db'];var logger=require(_0xe36e('0x3'))(_0xe36e('0x4'));function getTranscriptionJob(_0x567a84,_0x1118af,_0x29e692,_0x3f29e1){return new Promise(function(_0x25a07d,_0x190404){var _0x21be0b=new AWS[(_0xe36e('0x5'))]({'accessKeyId':_0x1118af,'secretAccessKey':_0x567a84,'region':_0x29e692});_0x21be0b['getTranscriptionJob']({'TranscriptionJobName':_0x3f29e1},function(_0x74b4b7,_0x4aebdd){if(_0x74b4b7){return _0x190404(_0x74b4b7);}else{return _0x25a07d(_0x4aebdd);}});});}function sentiment(_0x2236e9,_0x123c16,_0x46f239,_0x47ce3a,_0xf119e4){return new Promise(function(_0x48981b,_0x2e968d){var _0x2133cf=new AWS[(_0xe36e('0x6'))]({'accessKeyId':_0x123c16,'secretAccessKey':_0x2236e9,'region':_0x46f239});_0x2133cf[_0xe36e('0x7')]({'Text':_0x47ce3a,'LanguageCode':_0xf119e4[_0xe36e('0x8')](0x0,0x2)},function(_0x1f7233,_0x3f6d7f){if(_0x1f7233){return _0x2e968d(_0x1f7233);}else{return _0x48981b(_0x3f6d7f);}});});}function checkTranscribeJob(_0x265473,_0x4fbdb2,_0x32981d){var _0x27841e;return new BPromise(function(_0x23abfb,_0x1fdea2){logger['info'](util[_0xe36e('0x9')]('[RECORDING:%d]\x20Get\x20status\x20for\x20transcript\x20job\x20(%s)',_0x265473['id'],_0x265473['transcribeName']));return getTranscriptionJob(_0x32981d[_0xe36e('0xa')],_0x32981d[_0xe36e('0xb')],_0x4fbdb2[_0xe36e('0xc')],_0x265473[_0xe36e('0xd')])[_0xe36e('0xe')](function(_0x924cd5){logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x10'),_0x265473['id'],_0x265473[_0xe36e('0xd')],_0x924cd5['TranscriptionJob'][_0xe36e('0x11')]));if(!_0x265473[_0xe36e('0x12')]){switch(_0x924cd5['TranscriptionJob'][_0xe36e('0x11')]){case'COMPLETED':var _0x471400={'transcribeStatus':_0x924cd5[_0xe36e('0x13')]['TranscriptionJobStatus'],'fileUri':_0x924cd5[_0xe36e('0x13')][_0xe36e('0x14')][_0xe36e('0x15')]};logger['info'](util[_0xe36e('0x9')](_0xe36e('0x16'),_0x265473['id']));return rp({'uri':_0x924cd5[_0xe36e('0x13')][_0xe36e('0x14')][_0xe36e('0x15')],'json':!![]})[_0xe36e('0xe')](function(_0x4f438a){logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x17'),_0x265473['id']));if(_0x4f438a&&_0x4f438a[_0xe36e('0x18')]&&_0x4f438a[_0xe36e('0x18')]['transcripts']&&_0x4f438a['results'][_0xe36e('0x19')][_0xe36e('0x1a')]){_0x471400[_0xe36e('0x12')]='';for(var _0xb32195=0x0;_0xb32195<_0x4f438a[_0xe36e('0x18')][_0xe36e('0x19')][_0xe36e('0x1a')];_0xb32195++){_0x471400['fileText']+=_0x4f438a[_0xe36e('0x18')][_0xe36e('0x19')][_0xb32195][_0xe36e('0x1b')]+'';}}return _0x265473[_0xe36e('0x1c')](_0x471400);})['then'](function(){logger[_0xe36e('0xf')](util['format'](_0xe36e('0x1d'),_0x265473['id']));if(!_0x265473['tempSentiment']){throw new db[(_0xe36e('0x1e'))]['ValidationError'](_0xe36e('0x1f'));}if(!_0x4fbdb2['sentiment']||!_0x4fbdb2[_0xe36e('0x20')]||!_0x4fbdb2['sentimentRegion']||!_0x4fbdb2['language']||!_0x4fbdb2['bucket']){throw new db['Sequelize'][(_0xe36e('0x21'))](_0xe36e('0x22'));}if(!_0x471400['fileText']){throw new Error('Transcript\x20not\x20available');}if(_0x4fbdb2[_0xe36e('0x20')]===_0x32981d['id']){return _0x32981d;}else{return db[_0xe36e('0x23')][_0xe36e('0x24')]({'where':{'id':_settings[_0xe36e('0x20')]}});}})[_0xe36e('0xe')](function(_0x4759b4){if(!_0x4759b4){throw new db['Sequelize'][(_0xe36e('0x21'))](_0xe36e('0x25'));}if(!_0x4759b4['data1']||!_0x4759b4[_0xe36e('0xb')]){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))](_0xe36e('0x26'));}_0x27841e=_0x4759b4;logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x27'),_0x265473['id']));return sentiment(_0x27841e[_0xe36e('0xa')],_0x27841e[_0xe36e('0xb')],_0x4fbdb2[_0xe36e('0x28')],_0x471400[_0xe36e('0x12')],_0x4fbdb2['language']);})[_0xe36e('0xe')](function(_0x59231e){logger['info'](util[_0xe36e('0x9')]('[RECORDING:%d]\x20Sentiment\x20Analysis\x20available',_0x265473['id']));return _0x265473[_0xe36e('0x1c')]({'sentiment':_0x59231e[_0xe36e('0x29')],'sPositive':_0x59231e[_0xe36e('0x2a')][_0xe36e('0x2b')],'sNegative':_0x59231e['SentimentScore']['Negative'],'sMixed':_0x59231e[_0xe36e('0x2a')][_0xe36e('0x2c')],'sNeutral':_0x59231e[_0xe36e('0x2a')][_0xe36e('0x2d')]});})['then'](function(){logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x1d'),_0x265473['id']));_0x23abfb();});case'FAILED':return _0x265473[_0xe36e('0x1c')]({'transcribeStatus':_0xe36e('0x2e'),'failureReason':_0x924cd5['TranscriptionJob'][_0xe36e('0x2f')]})[_0xe36e('0xe')](function(){logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x1d'),_0x265473['id']));_0x23abfb();});default:logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x30'),_0x265473['id']));break;}}else{return BPromise[_0xe36e('0x31')]()[_0xe36e('0xe')](function(){if(!_0x265473[_0xe36e('0x32')]){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))]('Sentiment\x20Analysis\x20not\x20requested');}if(!_0x4fbdb2[_0xe36e('0x33')]||!_0x4fbdb2[_0xe36e('0x20')]||!_0x4fbdb2[_0xe36e('0x28')]||!_0x4fbdb2[_0xe36e('0x34')]||!_0x4fbdb2[_0xe36e('0x35')]){throw new db['Sequelize']['ValidationError'](_0xe36e('0x22'));}if(!_0x265473[_0xe36e('0x12')]){throw new Error(_0xe36e('0x36'));}if(_0x4fbdb2[_0xe36e('0x20')]===_0x32981d['id']){return _0x32981d;}else{return db[_0xe36e('0x23')][_0xe36e('0x24')]({'where':{'id':_settings[_0xe36e('0x20')]}});}})[_0xe36e('0xe')](function(_0x48066c){if(!_0x48066c){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))]('Cloud\x20Provider\x20not\x20available');}if(!_0x48066c[_0xe36e('0xa')]||!_0x48066c['data2']){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))](_0xe36e('0x26'));}_0x27841e=_0x48066c;logger[_0xe36e('0xf')](util[_0xe36e('0x9')]('[RECORDING:%d]\x20Requesting\x20sentiment\x20analysis',_0x265473['id']));return sentiment(_0x27841e[_0xe36e('0xa')],_0x27841e[_0xe36e('0xb')],_0x4fbdb2[_0xe36e('0x28')],_0x265473[_0xe36e('0x12')],_0x4fbdb2[_0xe36e('0x34')]);})[_0xe36e('0xe')](function(_0x569809){logger[_0xe36e('0xf')](util[_0xe36e('0x9')](_0xe36e('0x37'),_0x265473['id']));return _0x265473[_0xe36e('0x1c')]({'sentiment':_0x569809[_0xe36e('0x29')],'sPositive':_0x569809['SentimentScore'][_0xe36e('0x2b')],'sNegative':_0x569809[_0xe36e('0x2a')][_0xe36e('0x38')],'sMixed':_0x569809[_0xe36e('0x2a')][_0xe36e('0x2c')],'sNeutral':_0x569809[_0xe36e('0x2a')][_0xe36e('0x2d')],'transcribeStatus':_0xe36e('0x39')});})[_0xe36e('0xe')](function(){logger['info'](util['format'](_0xe36e('0x1d'),_0x265473['id']));_0x23abfb();});}})['catch'](function(_0x1f697f){if(_0x1f697f){if(!_0x1f697f[_0xe36e('0x3a')]||_0x1f697f[_0xe36e('0x3a')]!==_0xe36e('0x3b')){logger['error'](util[_0xe36e('0x9')](_0xe36e('0x3c'),_0x265473['id']),util['inspect'](_0x1f697f,{'showHidden':![],'depth':null}));}}_0x23abfb();});});}function checkTranscribe(){var _0x125e62;var _0x40634a;var _0x2c26e6;return db[_0xe36e('0x3d')][_0xe36e('0x3e')]({'where':{'transcribeStatus':_0xe36e('0x3f')}})[_0xe36e('0xe')](function(_0xaf917c){if(!_0xaf917c||!_0xaf917c[_0xe36e('0x1a')]){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))](_0xe36e('0x40'));}_0x125e62=_0xaf917c;return db[_0xe36e('0x41')][_0xe36e('0x24')]({'where':{'id':0x1}});})[_0xe36e('0xe')](function(_0x5678d3){if(!_0x5678d3){throw new db[(_0xe36e('0x1e'))]['ValidationError']('Settings\x20not\x20available');}_0x40634a=_0x5678d3;if(!_0x40634a[_0xe36e('0x4')]||!_0x40634a[_0xe36e('0x42')]||!_0x40634a['transcribeRegion']||!_0x40634a[_0xe36e('0x34')]||!_0x40634a[_0xe36e('0x35')]){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))](_0xe36e('0x43'));}return db[_0xe36e('0x23')][_0xe36e('0x24')]({'where':{'id':_0x40634a[_0xe36e('0x42')]}});})[_0xe36e('0xe')](function(_0x55d190){if(!_0x55d190){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))]('Cloud\x20Provider\x20not\x20available');}if(!_0x55d190[_0xe36e('0xa')]||!_0x55d190[_0xe36e('0xb')]){throw new db[(_0xe36e('0x1e'))][(_0xe36e('0x21'))](_0xe36e('0x26'));}_0x2c26e6=_0x55d190;var _0x53758e=[];_0x125e62['forEach'](function(_0x56f5b6){_0x53758e['push'](checkTranscribeJob(_0x56f5b6,_0x40634a,_0x2c26e6));});return BPromise[_0xe36e('0x44')](_0x53758e);})[_0xe36e('0x45')](function(_0x283365){if(_0x283365){if(!_0x283365[_0xe36e('0x3a')]||_0x283365[_0xe36e('0x3a')]!==_0xe36e('0x3b')){logger[_0xe36e('0x46')](util[_0xe36e('0x47')](_0x283365,{'showHidden':![],'depth':null}));}}});}exports[_0xe36e('0x48')]=function(){setInterval(function(){return checkTranscribe();},0x3c*0x3e8);return checkTranscribe();}; \ No newline at end of file diff --git a/server/config/schedule/whatsapp.js b/server/config/schedule/whatsapp.js new file mode 100644 index 0000000..8f6690f --- /dev/null +++ b/server/config/schedule/whatsapp.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf8fb=['error','[WHATSAPP]\x20Error\x20closing\x20interactions','inspect','start','lodash','ioredis','util','../../config/environment','../../mysqldb','../logger','redis','defaults','localhost','socket.io-emitter','findAll','lastMsgAt','subtract','hours','then','length','map','info','[WHATSAPP]\x20Interactions\x20to\x20close:','join','WhatsappInteraction','timeout','format','YYYY-MM-DD\x20HH:mm:ss','[WHATSAPP]\x20Sending\x20updates\x20for\x20interactions:','emit','whatsappInteraction:update','catch'];(function(_0x5e42a7,_0x3eba35){var _0x36d21b=function(_0x567f0a){while(--_0x567f0a){_0x5e42a7['push'](_0x5e42a7['shift']());}};_0x36d21b(++_0x3eba35);}(_0xf8fb,0x184));var _0xbf8f=function(_0x5d6456,_0x58ecc7){_0x5d6456=_0x5d6456-0x0;var _0x4d66c1=_0xf8fb[_0x5d6456];return _0x4d66c1;};'use strict';var _=require(_0xbf8f('0x0'));var moment=require('moment');var Redis=require(_0xbf8f('0x1'));var util=require(_0xbf8f('0x2'));var config=require(_0xbf8f('0x3'));var db=require(_0xbf8f('0x4'))['db'];var logger=require(_0xbf8f('0x5'))('schedule');config[_0xbf8f('0x6')]=_[_0xbf8f('0x7')](config[_0xbf8f('0x6')],{'host':_0xbf8f('0x8'),'port':0x18eb});var io=require(_0xbf8f('0x9'))(new Redis(config[_0xbf8f('0x6')]));function closeInteractions(){var _0x36a720=[];return db['WhatsappInteraction'][_0xbf8f('0xa')]({'raw':!![],'attributes':['id',_0xbf8f('0xb')],'where':{'closed':![],'lastMsgDirection':'in','lastMsgAt':{'$lt':moment()[_0xbf8f('0xc')](0x18,_0xbf8f('0xd'))}}})[_0xbf8f('0xe')](function(_0x440729){if(_0x440729&&_0x440729[_0xbf8f('0xf')]){_0x36a720=_[_0xbf8f('0x10')](_0x440729||[],'id');logger[_0xbf8f('0x11')](_0xbf8f('0x12'),_0x36a720[_0xbf8f('0x13')]());return db[_0xbf8f('0x14')]['update']({'closeReason':'system','disposition':_0xbf8f('0x15'),'closed':!![],'closedAt':moment()[_0xbf8f('0x16')](_0xbf8f('0x17'))},{'where':{'id':_0x36a720}});}})[_0xbf8f('0xe')](function(){if(_0x36a720&&_0x36a720[_0xbf8f('0xf')]){logger['info'](_0xbf8f('0x18'),_0x36a720['join']());for(var _0xf812ee=0x0;_0xf812ee<_0x36a720[_0xbf8f('0xf')];_0xf812ee++){io[_0xbf8f('0x19')](_0xbf8f('0x1a'),{'id':_0x36a720[_0xf812ee],'closed':!![]});}}})[_0xbf8f('0x1b')](function(_0x1f6e44){logger[_0xbf8f('0x1c')](_0xbf8f('0x1d'),_0x1f6e44?util[_0xbf8f('0x1e')](_0x1f6e44,{'showHidden':![],'depth':null}):'');});}exports[_0xbf8f('0x1f')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();}; \ No newline at end of file diff --git a/server/config/seedContact.js b/server/config/seedContact.js new file mode 100644 index 0000000..548367b --- /dev/null +++ b/server/config/seedContact.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5787=['Biondo','innocenzo.biondo','@xcally.com','now','CmContact','destroy','then','bulkCreate','log','finished\x20populating','contacts1','CmHopper','hopper1','hopper2','util','../mysqldb','push','Innocenzo'];(function(_0x3b632f,_0x453380){var _0x10e788=function(_0x2228a4){while(--_0x2228a4){_0x3b632f['push'](_0x3b632f['shift']());}};_0x10e788(++_0x453380);}(_0x5787,0xb0));var _0x7578=function(_0x5b6bc6,_0x25d088){_0x5b6bc6=_0x5b6bc6-0x0;var _0x41fcc5=_0x5787[_0x5b6bc6];return _0x41fcc5;};'use strict';var util=require(_0x7578('0x0'));var db=require(_0x7578('0x1'))['db'];var contacts=[];var hopper=[];var contacts2=[];var hopper2=[];for(var i=0x1;i<=0x4b0;i+=0x1){contacts[_0x7578('0x2')]({'id':i,'firstName':_0x7578('0x3')+i,'lastName':_0x7578('0x4')+i,'phone':0xf879fb460+i,'email':_0x7578('0x5')+i+_0x7578('0x6')});}for(var i=0x1;i<=0x4b0;i+=0x1){hopper[_0x7578('0x2')]({'id':i,'active':![],'scheduledat':Date[_0x7578('0x7')](),'countbusyretry':0x0,'countcongestionretry':0x0,'countnoanswerretry':0x0,'ContactId':i,'ListId':0x1,'UserId':0x1,'VoiceQueueId':0x3fd,'createdAt':Date['now'](),'updatedAt':Date['now']()});}for(var i=0x4b1;i<=0x960;i+=0x1){contacts2[_0x7578('0x2')]({'id':i,'firstName':_0x7578('0x3')+i,'lastName':'Biondo'+i,'phone':0xf879fb460+i,'email':_0x7578('0x5')+i+_0x7578('0x6')});}for(var i=0x4b1;i<=0x960;i+=0x1){hopper2[_0x7578('0x2')]({'id':i,'active':![],'scheduledat':Date[_0x7578('0x7')](),'countbusyretry':0x0,'countcongestionretry':0x0,'countnoanswerretry':0x0,'ContactId':i,'ListId':0x1,'UserId':0x1,'VoiceQueueId':0x3fd,'createdAt':Date[_0x7578('0x7')](),'updatedAt':Date[_0x7578('0x7')]()});}db[_0x7578('0x8')][_0x7578('0x9')]({'where':{}})[_0x7578('0xa')](function(){return db[_0x7578('0x8')][_0x7578('0xb')](contacts);})['then'](function(){console[_0x7578('0xc')](_0x7578('0xd'),_0x7578('0xe'));return db[_0x7578('0xf')][_0x7578('0x9')]({'where':{}});})[_0x7578('0xa')](function(){return db[_0x7578('0xf')][_0x7578('0xb')](hopper);})[_0x7578('0xa')](function(){console[_0x7578('0xc')](_0x7578('0xd'),_0x7578('0x10'));return db['CmContact'][_0x7578('0xb')](contacts2);})[_0x7578('0xa')](function(){console[_0x7578('0xc')]('finished\x20populating','contacts2');return db[_0x7578('0xf')][_0x7578('0xb')](hopper2);})[_0x7578('0xa')](function(){console[_0x7578('0xc')](_0x7578('0xd'),_0x7578('0x11'));})['catch'](function(_0xe2b191){console[_0x7578('0xc')](_0xe2b191);}); \ No newline at end of file diff --git a/server/config/seedDB/analyticReports.js b/server/config/seedDB/analyticReports.js new file mode 100644 index 0000000..6eb548d --- /dev/null +++ b/server/config/seedDB/analyticReports.js @@ -0,0 +1,67 @@ +'use strict'; +var util = require('util'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var report = require('./report'); + +exports.createDefault = function() { + // Remove default report + return db.AnalyticDefaultReport + .destroy({ + where: {} + }) + .then(function() { + return db.AnalyticDefaultReport.bulkCreate(report.default('motion'), { + ignoreDuplicates: true, + individualHooks: true + }); + }) + .then(function(entities) { + var fields = report.fields(); + for (var i = 0; i < entities.length; i += 1) { + if (fields[entities[i].id]) { + for (var j = 0; j < fields[entities[i].id].length; j += 1) { + fields[entities[i].id][j].DefaultReportId = fields[entities[i].id][j].ReportId; + delete fields[entities[i].id][j].ReportId; + //db.AnalyticFieldReport.create(fields[entities[i].id][j]); + } + db.AnalyticFieldReport.bulkCreate(fields[entities[i].id]); + } + } + }) + .then(function() { + logger.info('Analytic Default Reports have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Analytic Default Report', err.message); + }); +}; + +exports.createCustom = function() { + return db.AnalyticCustomReport + .bulkCreate(report.default('custom'), { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function(entities) { + var fields = report.fields(); + for (var i = 0; i < entities.length; i += 1) { + if (fields[entities[i].id]) { + for (var j = 0; j < fields[entities[i].id].length; j += 1) { + fields[entities[i].id][j].CustomReportId = fields[entities[i].id][j].ReportId; + delete fields[entities[i].id][j].ReportId; + // db.AnalyticFieldReport.create(fields[entities[i].id][j]); + } + db.AnalyticFieldReport.bulkCreate(fields[entities[i].id]); + } + } + }) + .then(function() { + logger.info('Analytic Custom Reports have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Analytic Custom Report'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/analyticTreeReports.js b/server/config/seedDB/analyticTreeReports.js new file mode 100644 index 0000000..3049118 --- /dev/null +++ b/server/config/seedDB/analyticTreeReports.js @@ -0,0 +1,50 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var tree = require('./tree'); + +exports.createDefault = function() { + return db.AnalyticTreeReport + .findOrCreate({ + where: { + id: 1 + }, + defaults: { + id: 1, + tree: JSON.stringify(tree.motion) + } + }) + .spread(function(entity, created) { + if (!created) { + return entity.update({ + tree: JSON.stringify(tree.motion) + }); + } + return entity; + }) + .then(function() { + logger.info('Analytic Tree Default Reports have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Analytic Tree Default Report'); + }); +}; + +exports.createCustom = function() { + return db.AnalyticTreeReport + .bulkCreate([{ + id: 2, + tree: JSON.stringify(tree.custom) + }], { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Analytic Tree Custom Reports have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Analytic Tree Custom Report'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/chanspy.js b/server/config/seedDB/chanspy.js new file mode 100644 index 0000000..df77f4e --- /dev/null +++ b/server/config/seedDB/chanspy.js @@ -0,0 +1,44 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var chanSpy = [{ + id: 1, + name: 'Listen&TalkOne', + prefix: 'spy1', + options: ['b', 'w', 'E', 'S'], + description: 'The supervisor can listen and talk to the agent. The customer will not listen to the supervisor voice', +}, { + id: 2, + name: 'OnlyListen', + prefix: 'spy2', + options: ['b', 'o', 'E', 'S'], + description: 'The supervisor can only listen the agent channel (neither the agent nor the customer will listen to the supervisor voice)', +}, { + id: 3, + name: 'Listen&TalkBoth', + prefix: 'spy3', + options: ['B', 'w', 'E', 'S'], + description: 'The supervisor can listen and talk both to the agent and to the customer, like a pure 3 way conference room', +}, { + id: 4, + name: 'OnlyListenBoth', + prefix: 'spy4', + options: ['B', 'o', 'E', 'S'], + description: 'The supervisor can just listen to the phone call', +}]; + +exports.create = function() { + return db.VoiceChanSpy + .bulkCreate(chanSpy, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('ChanSpy have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create ChanSpy'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/companies.js b/server/config/seedDB/companies.js new file mode 100644 index 0000000..2256913 --- /dev/null +++ b/server/config/seedDB/companies.js @@ -0,0 +1,35 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var companies = [{ + id: 1, + name: 'Xenialab', + type: 'srl', + vat: '09668910012', + phone: '+3901119886500', + fax: '+390110960070', + website: 'www.xcallymotion.com', + email: 'info@xcally.com', + emailDomain: 'xcally.com', + street: 'Corso Vittorio Emanuele II, 111', + postalCode: '10128', + city: 'Turin', + country: 'Italy', + description: 'company auto generated' +}]; + +exports.create = function() { + return db.CmCompany + .bulkCreate(companies, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Companies have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Companies'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/contacts.js b/server/config/seedDB/contacts.js new file mode 100644 index 0000000..220dbcf --- /dev/null +++ b/server/config/seedDB/contacts.js @@ -0,0 +1,59 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var tags = require('./tags'); + +// See tags file +var tags = tags.getNames(); +var getRandomTag = function() { + var length = tags.length - 1; + return [tags[Math.floor(Math.random() * length) + 1]]; +}; + +var contacts = [{ + id: 1, + firstName: 'Mario', + lastName: 'Rossi', + phone: '123', + email: 'mario.rossi@xcally.com', + ListId: 1, + CompanyId: 1, + tags: getRandomTag(), + description: 'contact auto generated' +}, { + id: 2, + firstName: 'Giuseppe', + lastName: 'Verdi', + phone: '456', + email: 'giuseppe.verdi@xcally.com', + ListId: 1, + CompanyId: 1, + tags: getRandomTag(), + description: 'contact auto generated' +}, { + id: 3, + firstName: 'Andrea', + lastName: 'Bianco', + phone: '789', + email: 'andrea.bianco@xcally.com', + ListId: 2, + CompanyId: 1, + tags: getRandomTag(), + description: 'contact auto generated' +}]; + +exports.create = function() { + return db.CmContact + .bulkCreate(contacts, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Contacts have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Contacts'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/dispositions.js b/server/config/seedDB/dispositions.js new file mode 100644 index 0000000..31ed254 --- /dev/null +++ b/server/config/seedDB/dispositions.js @@ -0,0 +1,32 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var dispositions = [{ + name: 'Fax' +}, { + name: 'Answer Machine' +}, { + name: 'Interested' +}, { + name: 'Not Interested' +}, { + name: 'Sold' +}, { + name: 'Special' +}]; + +exports.create = function() { + return db.Disposition + .bulkCreate(dispositions, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Dispositions have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Companies'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/index.js b/server/config/seedDB/index.js new file mode 100644 index 0000000..cc7d663 --- /dev/null +++ b/server/config/seedDB/index.js @@ -0,0 +1,70 @@ +/** + * Populate DB with sample data on server start + * to disable, edit config/environment/index.js, and set `seedDB: false` + */ + +'use strict'; + +var BPromise = require('bluebird'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var defaultSeed = function() { + return db.Setting + .findOrCreate({ + where: { + id: 1 + }, + defaults: { + firstSetup: true + } + }) + .spread(function(settings, created) { + + if (created) { + // NOTE: Run only first installation + logger.info('Settings have been created'); + + require('./analyticTreeReports').createCustom(); + require('./analyticReports').createCustom(); + require('./migrations').create(); + require('./intervals').create(); + require('./userProfiles').create(); + require('./users').create(); + require('./teams').create(); + require('./trunks').create(); + require('./voiceQueues').create(); + require('./chanspy').create(); + require('./voiceMusicOnHold').create(); + require('./variables').create(); + require('./pauses').create(); + require('./tags').create(); + require('./companies').create(); + require('./sounds').create(); + require('./squareOdbc').create(); + require('./squareProjects').create(); + require('./jscriptyProjects').create(); + require('./voiceExtensions').create(); + require('./mailSubstatuses').create(); + require('./dispositions').create(); + return require('./lists').create() + .then(function() { + return require('./contacts').create(); + }); + } + }) + .then(function() { + // NOTE: Run always + require('./voiceContexts').create(); + require('./voiceExtensions').createAlways(); + require('./mailAccounts').create(); + require('./analyticTreeReports').createDefault(); + require('./analyticReports').createDefault(); + }) + .catch(function(err) { + logger.error(JSON.stringify(err)); + }); +}; + +exports.default = defaultSeed; \ No newline at end of file diff --git a/server/config/seedDB/intervals.js b/server/config/seedDB/intervals.js new file mode 100644 index 0000000..806fdbd --- /dev/null +++ b/server/config/seedDB/intervals.js @@ -0,0 +1,69 @@ +'use strict'; + +var _ = require('lodash'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var subIntervals = { + 'WorkingTime': [{ + name: 'Morning', + interval: '09:00-13:00,mon-fri,*,*' + }, { + name: 'Afternoon', + interval: '14:00-18:00,mon-fri,*,*' + }], + 'Holidays': [{ + name: 'Christmas', + interval: '*,*,25,dec' + }, { + name: 'NewYear', + interval: '*,*,1,jan' + }, { + name: 'Valentines', + interval: '*,*,14,feb' + }, { + name: 'Halloween', + interval: '*,*,31,oct' + }] +}; + +var intervals = [{ + id: 1, + name: 'WorkingTime', + description: 'working time auto generated' +}, { + id: 2, + name: 'Holidays', + description: 'working time auto generated' +}]; + +exports.create = function() { + return db.Interval + .bulkCreate(intervals, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function(entities) { + for (var i = 0; i < entities.length; i += 1) { + if (subIntervals[entities[i].name]) { + for (var j = 0; j < subIntervals[entities[i].name].length; j += 1) { + + subIntervals[entities[i].name][j] = _.defaults(subIntervals[entities[i].name][j], { + description: entities[i].description, + IntervalId: entities[i].id + }); + + db.Interval.create(subIntervals[entities[i].name][j]); + } + } + + } + }) + .then(function() { + logger.info('Intervals have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Intevals'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/jscripty/customerSatisfation.json b/server/config/seedDB/jscripty/customerSatisfation.json new file mode 100644 index 0000000..b4eb055 --- /dev/null +++ b/server/config/seedDB/jscripty/customerSatisfation.json @@ -0,0 +1,476 @@ +{ + "pages": [ + { + "id": "25b2038c54fe1a72774647dbbeccc557", + "number": 1, + "name": "Introduction", + "description": null, + "pageFlow": { "nextPage": true, "label": "mwForm.pageFlow.goToNextPage" }, + "elements": [ + { + "id": "f731c14bb078ca1f5c1f00b2500f13ab", + "orderNo": 1, + "type": "question", + "question": { + "id": "652b65e0e5b078e1d1381b6b3a3ad2bd", + "text": "How long it is since you are using xCALLY?", + "type": "radio", + "required": true, + "offeredAnswers": [ + { + "id": "f3457c416661f1d6b71ed4141ee00530", + "orderNo": 1, + "value": "One month (Demo version)", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "365bafc9fc19c835f772a7c2acd38882", + "orderNo": 2, + "value": "Less than 6 months", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "c0d26ab74b369c6608237de9c2ed90b6", + "orderNo": 3, + "value": "Between 6 months - 1 year", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "354b52df5354eca27018b347e9a9d962", + "orderNo": 4, + "value": "Between 1 year - 2 years", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "b934ff6bcb0911a60114653489f19b93", + "orderNo": 5, + "value": "More than 2 years", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "b30240d2e6f3418f9b26c2fe03682933", + "orderNo": 6, + "value": "We don't use it anymore", + "pageFlow": { + "page": { + "id": "9b52dfb6e7f3fecdf786e4ce5f29d149", + "number": 5 + }, + "label": "mwForm.pageFlow.goToPage" + } + } + ], + "pageFlowModifier": true + } + } + ], + "namedPage": true, + "isFirst": true, + "isLast": false + }, + { + "id": "dabd2a6334f17f5221933742ba2f31f9", + "number": 2, + "name": null, + "description": null, + "pageFlow": { "nextPage": true, "label": "mwForm.pageFlow.goToNextPage" }, + "elements": [ + { + "id": "ac72a77463aa846d99e38952b0db9c23", + "orderNo": 1, + "type": "question", + "question": { + "id": "a79c23cda72d60e9e14d1f652905a525", + "text": "How many Agents in your Contact Center are using xCALLY?", + "type": "radio", + "required": true, + "offeredAnswers": [ + { + "id": "e230b9a031b9b7e79ebd66e07b8a6fb8", + "orderNo": 1, + "value": "Less than 20", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "cefdabfc82a62e8b31f1826f25af9e03", + "orderNo": 2, + "value": "Between 20 - 50 Agents", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "9d57d3fece117eae0be6960a6b412b75", + "orderNo": 3, + "value": "Between 50 - 150 Agents", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "b9feebe68db5c13c834e0f142cb71fb8", + "orderNo": 4, + "value": "Between 150 - 300 Agents", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "15819a8e1677a24c157b150573f5eefa", + "orderNo": 5, + "value": "More than 300 Agents", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ] + } + }, + { + "id": "2670401c278e69f233552826a415bcf6", + "orderNo": 2, + "type": "question", + "question": { + "id": "a16aff0dfe356ccd998fb6025759de2a", + "text": "What kind of calls do you manage in your Contact Center?", + "type": "radio", + "required": true, + "offeredAnswers": [ + { + "id": "fcd91cc71dd50c171d52f452d352292b", + "orderNo": 1, + "value": "Only inbound", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "cbc6afbc84fbf8b3f5009578e5cd40de", + "orderNo": 2, + "value": "Mostly inbound", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "7ca573f2be2d946224403083bce1bf89", + "orderNo": 3, + "value": "Both inbound and outbound", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "51ec57f9b511e3d8a304c0c46495174d", + "orderNo": 4, + "value": "Mostly outbound", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "52651dea4bf51d54bdeb56dec892f09b", + "orderNo": 5, + "value": "Only outbound", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ] + } + }, + { + "id": "c793e0d4543e663554a55514e2981de0", + "orderNo": 3, + "type": "question", + "question": { + "id": "7c656fb101c5d110978c50c06d1cae69", + "text": "Which of the following channels do you use in your Contact Center?", + "type": "checkbox", + "required": true, + "offeredAnswers": [ + { + "id": "e858f6d4692beca5f9b000363bd0b0d2", + "orderNo": 1, + "value": "Phone calls", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "5472cee835b67c74df453bdf64aca9b4", + "orderNo": 2, + "value": "E-Mail", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "eb38c0e572e9ec848fb35f69355b973d", + "orderNo": 3, + "value": "Chat", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "9f67af37e549f93e388e9ddfeb0bcfcf", + "orderNo": 4, + "value": "Fax", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "3093eeac4219df32a68347deed6bed21", + "orderNo": 5, + "value": "SMS", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "112f774dc8b2fe2f114cf5a93e818fc3", + "orderNo": 6, + "value": "Social", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ], + "pageFlowModifier": false, + "otherAnswer": true + } + } + ], + "namedPage": false + }, + { + "id": "46f60945788ece4084460324c60781ba", + "number": 3, + "name": "Software Installation & Update", + "description": null, + "pageFlow": { "nextPage": true, "label": "mwForm.pageFlow.goToNextPage" }, + "elements": [ + { + "id": "28a8d8b1ba8600f68f0ab9c623bdc971", + "orderNo": 1, + "type": "paragraph", + "paragraph": { + "id": "1951cb18ce8eb56d740651bbca74f4ca", + "html": "Please insert a number between 1 and 5 where:\n1=Not at all easy\n5=Extremely easy" + } + }, + { + "id": "785910fa586964beec53a57224d939f6", + "orderNo": 2, + "type": "question", + "question": { + "id": "4b49749e0415aac8f01f28f90fb13a86", + "text": "How easy are the xCALLY Installation Procedures?", + "type": "number", + "required": true, + "pageFlowModifier": false, + "min": 1, + "max": 5 + } + }, + { + "id": "bedca4f334f22b3802640eb483504c9b", + "orderNo": 3, + "type": "question", + "question": { + "id": "2127a022af8bbbb58fca261417b91bd7", + "text": "How easy are the xCALLY Update Procedures?", + "type": "number", + "required": true, + "pageFlowModifier": false, + "min": 1, + "max": 5 + } + }, + { + "id": "cd852a90b6a43804942999e5831b4a49", + "orderNo": 4, + "type": "question", + "question": { + "id": "16be11cba3a9602c4f29b8760b17e654", + "text": "Notes or suggestions about the installation & update procedure", + "type": "textarea", + "required": true, + "pageFlowModifier": false + } + } + ], + "namedPage": true, + "isFirst": false, + "isLast": false + }, + { + "id": "9d0f47a3c42ce21b915c28bfb41ad846", + "number": 4, + "name": "Modules and functionalities", + "description": null, + "pageFlow": { "nextPage": true, "label": "mwForm.pageFlow.goToNextPage" }, + "elements": [ + { + "id": "5d03d9bbe15a2cf9ab86765a12a09738", + "orderNo": 1, + "type": "question", + "question": { + "id": "4fa5442caf2c5147fa05650c0abe51ec", + "text": "How easy is to configure the following xCALLY Modules?", + "type": "radio", + "required": true, + "offeredAnswers": [ + { + "id": "89cbfcc88fa2e1d46b582368bd01353d", + "orderNo": 1, + "value": "Not at all easy", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "70c4409e42828f9661584cbf78eec9f8", + "orderNo": 2, + "value": "Slightly easy", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "6375221b958a98ca81d1e92c78ecb35d", + "orderNo": 3, + "value": "Moderately easy", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "7892ba12ef10deed546d3c4bca5dfe4e", + "orderNo": 4, + "value": "Very easy", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "a426c3d52defe247762748417da73106", + "orderNo": 5, + "value": "Extremely easy", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ] + } + }, + { + "id": "257b36eec82264fae5dcbd132016fa72", + "orderNo": 2, + "type": "question", + "question": { + "id": "f18af40b3c48a69b5ee753ef641db31e", + "text": "How many hours you spent to perform a basic XCALLY configuration?", + "type": "range", + "required": true, + "pageFlowModifier": false, + "min": 1, + "max": 8 + } + } + ], + "namedPage": true, + "isFirst": false, + "isLast": true + }, + { + "id": "9b52dfb6e7f3fecdf786e4ce5f29d149", + "number": 5, + "name": "May we known something more about you?", + "description": null, + "pageFlow": { "nextPage": true, "label": "mwForm.pageFlow.goToNextPage" }, + "elements": [ + { + "id": "01b95d724f79040bb094ba2a6e9c38bf", + "orderNo": 1, + "type": "question", + "question": { + "id": "c6571665c1e1b959edf0d02c80da1002", + "text": "Your Name", + "type": "text", + "required": true, + "pageFlowModifier": false + } + }, + { + "id": "d2b5f0d31cbf5b7fe43b2a62a5f02c18", + "orderNo": 2, + "type": "question", + "question": { + "id": "8b9964d0c0f7b724ba3dc87bcb01e930", + "text": "Your E-Mail address", + "type": "email", + "required": true, + "pageFlowModifier": false + } + }, + { + "id": "bd7604840dd6ccf8083acc83b5495744", + "orderNo": 3, + "type": "question", + "question": { + "id": "97fcfa4c89afc8803458d90ddbaace93", + "text": "Your Company website", + "type": "url", + "required": true, + "pageFlowModifier": false + } + } + ], + "namedPage": true + } + ], + "name": "XCALLY Customer Satisfaction", + "description": "The XCALLY customer satisfaction help us to improve our services and make our customers very very happy! :-)", + "confirmationMessage": "Thanks for your time!" +} diff --git a/server/config/seedDB/jscriptyProjects.js b/server/config/seedDB/jscriptyProjects.js new file mode 100644 index 0000000..9222288 --- /dev/null +++ b/server/config/seedDB/jscriptyProjects.js @@ -0,0 +1,34 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var getJson = function(filename) { + return fs.readFileSync(path.join(__dirname, 'jscripty', filename + '.json'), { + encoding: 'utf-8' + }); +}; + +var jscriptyProjects = [{ + id: 1, + name: 'CustomerSatisfaction', + description: 'Customer Satisfaction auto generated', + formData: getJson('customerSatisfation') +}]; + +exports.create = function() { + return db.JscriptyProject + .bulkCreate(jscriptyProjects, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Jscripty Projects have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Jscripty Projects'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/lists.js b/server/config/seedDB/lists.js new file mode 100644 index 0000000..2da3940 --- /dev/null +++ b/server/config/seedDB/lists.js @@ -0,0 +1,32 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var lists = [{ + id: 1, + name: 'Public List', + description: 'public list auto generated' +}, { + id: 2, + name: 'Black List', + description: 'black list auto generated' +}, { + id: 3, + name: 'Callback List', + description: 'Callback list auto generated' +}]; + +exports.create = function() { + return db.CmList + .bulkCreate(lists, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Lists have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Lists'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/mailAccounts.js b/server/config/seedDB/mailAccounts.js new file mode 100644 index 0000000..9f132f4 --- /dev/null +++ b/server/config/seedDB/mailAccounts.js @@ -0,0 +1,73 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +exports.create = function() { + var account; + return db.MailAccount + .findOrCreate({ + where: { + service: true + }, + defaults: { + name: 'Service Mail', + key: 'SERV', + email: 'email@xcally.com', + service: true, + description: 'service motion account auto generated', + active: false, + ListId: 1 + } + }) + .spread(function(entity, created) { + if (created) { + logger.info('service motion account auto generated'); + } + + account = entity; + + return db.MailServerOut.findOrCreate({ + where: { + MailAccountId: account.id + }, + defaults: { + host: '127.0.0.1', + user: 'username', + pass: 'password', + port: 25, + secure: false, + authentication: false, + MailAccountId: account.id, + description: 'service motion smtp auto generated' + } + }); + }) + .spread(function(entity, created) { + if (created) { + logger.info('service motion smtp auto generated'); + } + + return db.MailServerIn.findOrCreate({ + where: { + MailAccountId: account.id + }, + defaults: { + host: '127.0.0.1', + user: 'username', + password: 'password', + port: 993, + MailAccountId: account.id, + description: 'service motion imap auto generated' + } + }); + }) + .spread(function(entity, created) { + if (created) { + logger.info('service motion imap auto generated'); + } + }) + .catch(function(err) { + logger.error('Can\'t create Mail Accounts'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/mailSubstatuses.js b/server/config/seedDB/mailSubstatuses.js new file mode 100644 index 0000000..8e8ba66 --- /dev/null +++ b/server/config/seedDB/mailSubstatuses.js @@ -0,0 +1,26 @@ +'use strict'; + +var _ = require('lodash'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var items = [{ + id: 1, + name: 'pending', + description: 'Pending status for mail interaction' +}]; + +exports.create = function() { + return db.MailSubstatus + .bulkCreate(items, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Substatues have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create MailSubstatuses'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/migrations.js b/server/config/seedDB/migrations.js new file mode 100644 index 0000000..5a20ff3 --- /dev/null +++ b/server/config/seedDB/migrations.js @@ -0,0 +1,19 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var pkginfo = require('pkginfo')(module, 'version'); + +exports.create = function() { + return db.Migration + .create({ + version: module.exports.version + '.js' + }) + .then(function() { + logger.info('Version have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Version'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/pauses.js b/server/config/seedDB/pauses.js new file mode 100644 index 0000000..f857c65 --- /dev/null +++ b/server/config/seedDB/pauses.js @@ -0,0 +1,28 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var pauses = [{ + id: 1, + name: 'BACKOFFICE', + description: 'backoffice pause auto generated' +}, { + id: 2, + name: 'AFTERCALL', + description: 'aftercall pause auto generated' +}]; + +exports.create = function() { + return db.Pause + .bulkCreate(pauses, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Pauses have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Pauses'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/report/default.js b/server/config/seedDB/report/default.js new file mode 100644 index 0000000..369f5eb --- /dev/null +++ b/server/config/seedDB/report/default.js @@ -0,0 +1,543 @@ +'use strict'; + +module.exports = function(prefix) { + return [{ + id: 1, + name: 'Details', + description: 'Detailed queues report', + parent: prefix + '_voice_queues', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 2, + name: 'Calls Result', + description: 'Simple queue calls overview', + parent: prefix + '_voice_queues', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 3, + name: 'Details', + description: 'Detailed report about answered queue calls', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 4, + name: 'Calls by Agent', + description: 'Agent calls timer Handle time= talk time + ACW time', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 5, + name: 'Calls by Queue', + description: 'Queue timer Handle Time= Talk Time + AVG TIme', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 6, + name: 'Answer Time by Queue', + description: 'Queues answer time performance', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 7, + name: 'Disconnection Cause', + description: 'Summary of the calls disconnection causes', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 8, + name: 'Answer Time by Hour', + description: 'Answer time by hour', + parent: prefix + '_voice_queues_answered', + table: 'report_agent', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"agentcomplete","value":"1","required":true}]}}' + }, { + id: 9, + name: 'Details', + description: 'Detailed report about the unanswered calls', + parent: prefix + '_voice_queues_unanswered', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"queuecallercomplete","value":"0","required":true}]}}' + }, { + id: 10, + name: 'Unanswered by Queue', + description: 'Unanswered calls summary by queue', + parent: prefix + '_voice_queues_unanswered', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"queuecallercomplete","value":"0","required":true}]}}' + }, { + id: 11, + name: 'Unmanaged calls', + description: 'Unmanaged calls summary', + parent: prefix + '_voice_queues_unanswered', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"queuecallerexit","value":"1","required":true}]}}' + }, { + id: 12, + name: 'Abandon Time by Queue', + description: 'Abandon time performance by queue', + parent: prefix + '_voice_queues_unanswered', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"queuecallerabandon","value":"1","required":true}]}}' + }, { + id: 13, + name: 'Calls by Date', + description: 'Queue calls summary by date', + parent: prefix + '_voice_queues_distribution', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 14, + name: 'Calls by Hour', + description: 'Calls distribution by hour', + parent: prefix + '_voice_queues_distribution', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 15, + name: 'Calls by Day', + description: 'Calls distribution by day of the month', + parent: prefix + '_voice_queues_distribution', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 16, + name: 'Calls by Weekday', + description: 'Calls distribution by day of the week', + parent: prefix + '_voice_queues_distribution', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 17, + name: 'Summary', + description: 'Calls distribution by queue', + parent: prefix + '_voice_queues', + table: 'report_queue', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 18, + name: 'Details', + description: 'Calls detail (cdr)', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 19, + name: 'Outbound', + description: 'Manual outbound calls detailed report', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'outbound\'","required":true}]}}' + }, { + id: 20, + name: 'Calls by Type', + description: 'Summary report of the calls type', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 21, + name: 'Outbound Calls Disposition', + description: 'Outbound calls grouped by disposition', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'outbound\'","required":true}]}}' + }, { + id: 22, + name: 'Outbound Calls by Agent', + description: 'Summary of outbound calls grouped by agent', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'outbound\'","required":true}]}}' + }, { + id: 23, + name: 'Outbound Calls by Date', + description: 'Summary of outbound calls grouped by date', + parent: prefix + '_voice_calls', + table: 'report_call', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'outbound\'","required":true}]}}' + }, { + id: 24, + name: 'Login Time', + description: 'Agent\'s login time', + parent: prefix + '_agents', + table: 'report_member', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'LOGIN\'","required":true},{"condition":"=","field":"channel","value":"\'voice\'","required":true}]}}' + }, { + id: 25, + name: 'Activities Summary', + description: 'Agent\'s activities report', + parent: prefix + '_voice_agents', + table: 'report_member', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"channel","value":"\'voice\'","required":true}]}}' + }, { + id: 26, + name: 'Pause Details', + description: 'Agents status details', + parent: prefix + '_voice_agents', + table: 'report_member', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"channel","value":"\'voice\'","required":true},{"condition":"=","field":"type","value":"\'PAUSE\'","required":true}]}}' + }, { + id: 27, + name: 'Details', + description: 'Agent\'s status detail', + parent: prefix + '_voice_agents', + table: 'report_member', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"channel","value":"\'voice\'","required":true}]}}' + }, { + id: 28, + name: 'Pause Time', + description: 'Agent\'s pause time', + parent: prefix + '_voice_agents', + table: 'report_member', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"type","value":"\'PAUSE\'","required":true},{"condition":"=","field":"channel","value":"\'voice\'","required":true}]}}' + }, { + id: 29, + name: 'Summary', + description: 'CallySquare Summary', + parent: prefix + '_voice_callysquare', + table: 'report_square', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 30, + name: 'Blocks', + description: 'CallySquare Blocks Detail', + parent: prefix + '_voice_callysquare', + table: 'report_square_details', + conditions: '{"group":{"operator":"AND","rules":[]}}' + }, { + id: 31, + name: 'Rating by Agent', + description: 'Records rating by agent', + parent: prefix + '_voice_recordings', + table: 'voice_recordings', + conditions: '{"group":{"operator":"AND","rules":[{"condition":">","field":"rating","value":"0","required":true}]}}' + }, { + id: 32, + name: 'Rating by Queue', + description: 'Records rating by queue', + parent: prefix + '_voice_recordings', + table: 'voice_recordings', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"IS NOT NULL","field":"queue","value":"","required":false},{"condition":">","field":"rating","value":"0","required":true}]}}' + }, { + id: 33, + name: 'Details', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"}]}}' + }, { + id: 34, + name: 'Calls Summary', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_history', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"}]}}' + }, { + id: 35, + name: 'Campaign Calls', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"}]}}' + }, { + id: 36, + name: 'List Penetration Rate', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"}]}}' + }, { + id: 37, + name: 'Agent Calls', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"},{"condition":"=","field":"state","value":"4"}]}}' + }, { + id: 38, + name: 'Disposition Rate', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"},{"condition":"IS NOT NULL","field":"disposition","value":""},{"condition":"=","field":"state","value":"4"}]}}' + }, { + id: 39, + name: 'Agent Disposition Rate', + description: '', + parent: prefix + '_bull_queue_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'queue\'"},{"condition":"IS NOT NULL","field":"disposition","value":""},{"condition":"=","field":"state","value":"4"}]}}' + }, { + id: 40, + name: 'Details', + description: '', + parent: prefix + '_bull_ivr_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'ivr\'"}]}}' + }, { + id: 41, + name: 'Calls Summary', + description: '', + parent: prefix + '_bull_ivr_campaigns', + table: 'cm_hopper_history', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'ivr\'"}]}}' + }, { + id: 42, + name: 'Campaign Calls', + description: '', + parent: prefix + '_bull_ivr_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'ivr\'"}]}}' + }, { + id: 43, + name: 'List Penetration Rate', + description: '', + parent: prefix + '_bull_ivr_campaigns', + table: 'cm_hopper_final', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"campaigntype","value":"\'ivr\'"}]}}' + }, { + id: 44, + name: 'Website Summary', + description: 'Chat interactions by website', + parent: prefix + '_chat', + table: 'chat_interactions', + joins: '[{"parentKey":"ChatWebsiteId","foreignTable":"chat_websites","foreignKey":"id","type":"join"}]' + }, { + id: 45, + name: 'Website Times', + description: 'Chat interaction times by website', + parent: prefix + '_chat', + table: 'chat_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"chat_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"IS NULL","field":"chat_interactions.disposition","value":""},{"group":{"operator":"AND","rules":[{"condition":"!=","field":"chat_interactions.disposition","value":"\'abandoned\'"},{"condition":"!=","field":"chat_interactions.disposition","value":"\'unmanaged\'"}]}}]}}]}}', + joins: '[{"parentKey":"ChatWebsiteId","foreignTable":"chat_websites","foreignKey":"id","type":"join"}]' + }, { + id: 46, + name: 'Chat By Agent', + description: 'Chat interactions by agent', + parent: prefix + '_chat', + table: 'chat_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"chat_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 47, + name: 'Chat By Date', + description: 'Chat interactions by date', + parent: prefix + '_chat', + table: 'chat_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"chat_interactions.closed","value":"1"}]}}' + }, { + id: 48, + name: 'Chat By Queue', + description: 'Chat interactions by queue', + parent: prefix + '_chat', + table: 'report_chat_queue', + joins: '[{"parentKey":"ChatQueueId","foreignTable":"chat_queues","foreignKey":"id","type":"join"}]' + }, { + id: 49, + name: 'Email Account Summary', + description: 'Email interactions by account', + parent: prefix + '_mail', + table: 'mail_interactions', + joins: '[{"parentKey":"MailAccountId","foreignTable":"mail_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 50, + name: 'Email Account Times', + description: 'Email interaction times by account', + parent: prefix + '_mail', + table: 'mail_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"mail_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"!=","field":"mail_interactions.disposition","value":"\'unmanaged\'"},{"condition":"IS NULL","field":"mail_interactions.disposition","value":""}]}}]}}', + joins: '[{"parentKey":"MailAccountId","foreignTable":"mail_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 51, + name: 'Email By Agent', + description: 'Email interactions by agent', + parent: prefix + '_mail', + table: 'mail_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"mail_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 52, + name: 'Email By Date', + description: 'Email interactions by date', + parent: prefix + '_mail', + table: 'mail_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"mail_interactions.closed","value":"1"}]}}' + }, { + id: 53, + name: 'Email By Queue', + description: 'Email interactions by queue', + parent: prefix + '_mail', + table: 'report_mail_queue', + joins: '[{"parentKey":"MailQueueId","foreignTable":"mail_queues","foreignKey":"id","type":"join"}]' + }, { + id: 54, + name: 'Openchannel Account Summary', + description: 'Openchannel interactions by account', + parent: prefix + '_openchannel', + table: 'openchannel_interactions', + joins: '[{"parentKey":"OpenchannelAccountId","foreignTable":"openchannel_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 55, + name: 'Openchannel Account Times', + description: 'Openchannel interaction times by account', + parent: prefix + '_openchannel', + table: 'openchannel_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"openchannel_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"!=","field":"openchannel_interactions.disposition","value":"\'unmanaged\'"},{"condition":"IS NULL","field":"openchannel_interactions.disposition","value":""}]}}]}}', + joins: '[{"parentKey":"OpenchannelAccountId","foreignTable":"openchannel_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 56, + name: 'Openchannel By Agent', + description: 'Openchannel interactions by agent', + parent: prefix + '_openchannel', + table: 'openchannel_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"openchannel_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 57, + name: 'Openchannel By Date', + description: 'Openchannel interactions by date', + parent: prefix + '_openchannel', + table: 'openchannel_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"openchannel_interactions.closed","value":"1"}]}}' + }, { + id: 58, + name: 'Openchannel By Queue', + description: 'Openchannel interactions by queue', + parent: prefix + '_openchannel', + table: 'report_openchannel_queue', + joins: '[{"parentKey":"OpenchannelQueueId","foreignTable":"openchannel_queues","foreignKey":"id","type":"join"}]' + }, { + id: 59, + name: 'Sms Account Summary', + description: 'Sms interactions by account', + parent: prefix + '_sms', + table: 'sms_interactions', + joins: '[{"parentKey":"SmsAccountId","foreignTable":"sms_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 60, + name: 'Sms Account Times', + description: 'Sms interaction times by account', + parent: prefix + '_sms', + table: 'sms_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"sms_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"!=","field":"sms_interactions.disposition","value":"\'unmanaged\'"},{"condition":"IS NULL","field":"sms_interactions.disposition","value":""}]}}]}}', + joins: '[{"parentKey":"SmsAccountId","foreignTable":"sms_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 61, + name: 'Sms By Agent', + description: 'Sms interactions by agent', + parent: prefix + '_sms', + table: 'sms_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"sms_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 62, + name: 'Sms By Date', + description: 'Sms interactions by date', + parent: prefix + '_sms', + table: 'sms_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"sms_interactions.closed","value":"1"}]}}' + }, { + id: 63, + name: 'Sms By Queue', + description: 'Sms interactions by queue', + parent: prefix + '_sms', + table: 'report_sms_queue', + joins: '[{"parentKey":"SmsQueueId","foreignTable":"sms_queues","foreignKey":"id","type":"join"}]' + }, { + id: 64, + name: 'Fax Account Summary', + description: 'Fax interactions by account', + parent: prefix + '_fax', + table: 'fax_interactions', + joins: '[{"parentKey":"FaxAccountId","foreignTable":"fax_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 65, + name: 'Fax Account Times', + description: 'Fax interaction times by account', + parent: prefix + '_fax', + table: 'fax_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"fax_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"!=","field":"fax_interactions.disposition","value":"\'unmanaged\'"},{"condition":"IS NULL","field":"fax_interactions.disposition","value":""}]}}]}}', + joins: '[{"parentKey":"FaxAccountId","foreignTable":"fax_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 66, + name: 'Fax By Agent', + description: 'Fax interactions by agent', + parent: prefix + '_fax', + table: 'fax_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"fax_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 67, + name: 'Fax By Date', + description: 'Fax interactions by date', + parent: prefix + '_fax', + table: 'fax_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"fax_interactions.closed","value":"1"}]}}' + }, { + id: 68, + name: 'Fax By Queue', + description: 'Fax interactions by queue', + parent: prefix + '_fax', + table: 'report_fax_queue', + joins: '[{"parentKey":"FaxQueueId","foreignTable":"fax_queues","foreignKey":"id","type":"join"}]' + }, { + id: 69, + name: 'WhatsApp Account Summary', + description: 'WhatsApp interactions by account', + parent: prefix + '_whatsapp', + table: 'whatsapp_interactions', + joins: '[{"parentKey":"WhatsappAccountId","foreignTable":"whatsapp_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 70, + name: 'WhatsApp Account Times', + description: 'WhatsApp interaction times by account', + parent: prefix + '_whatsapp', + table: 'whatsapp_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"whatsapp_interactions.closed","value":"1"},{"group":{"operator":"OR","rules":[{"condition":"!=","field":"whatsapp_interactions.disposition","value":"\'unmanaged\'"},{"condition":"IS NULL","field":"whatsapp_interactions.disposition","value":""}]}}]}}', + joins: '[{"parentKey":"WhatsappAccountId","foreignTable":"whatsapp_accounts","foreignKey":"id","type":"join"}]' + }, { + id: 71, + name: 'WhatsApp By Agent', + description: 'WhatsApp interactions by agent', + parent: prefix + '_whatsapp', + table: 'whatsapp_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"whatsapp_interactions.closed","value":"1"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 72, + name: 'WhatsApp By Date', + description: 'WhatsApp interactions by date', + parent: prefix + '_whatsapp', + table: 'whatsapp_interactions', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"=","field":"whatsapp_interactions.closed","value":"1"}]}}' + }, { + id: 73, + name: 'WhatsApp By Queue', + description: 'WhatsApp interactions by queue', + parent: prefix + '_whatsapp', + table: 'report_whatsapp_queue', + joins: '[{"parentKey":"WhatsappQueueId","foreignTable":"whatsapp_queues","foreignKey":"id","type":"join"}]' + }, { + id: 74, + name: 'Sentiment by Agent', + description: 'Sentiment by agent', + parent: prefix + '_voice_recordings', + table: 'voice_recordings', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"IS NOT NULL","field":"voice_recordings.sentiment","value":"NULL"}]}}', + joins: '[{"parentKey":"UserId","foreignTable":"users","foreignKey":"id","type":"join"}]' + }, { + id: 75, + name: 'Sentiment Summary', + description: 'Sentiment Summary', + parent: prefix + '_voice_recordings', + table: 'voice_recordings', + conditions: '{"group":{"operator":"AND","rules":[{"condition":"IS NOT NULL","field":"voice_recordings.sentiment","value":""}]}}' + }]; +}; \ No newline at end of file diff --git a/server/config/seedDB/report/fields.js b/server/config/seedDB/report/fields.js new file mode 100644 index 0000000..6085e19 --- /dev/null +++ b/server/config/seedDB/report/fields.js @@ -0,0 +1,2353 @@ +'use strict'; + +var _ = require('lodash'); + +module.exports = function() { + var fields = [{ + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 1 + }, { + field: 'calleridnum', + alias: 'CallerIdNum', + ReportId: 1 + }, { + field: 'calleridname', + alias: 'CallerIdName', + ReportId: 1 + }, { + field: 'queue', + alias: 'Queue', + ReportId: 1 + }, { + field: 'queuecallerjoinAt', + alias: 'QueueJoinAt', + ReportId: 1 + }, { + field: 'queuecallerleaveAt', + alias: 'QueueLeaveAt', + ReportId: 1 + }, { + field: 'queuecallerabandon', + alias: 'QueueAbandon', + ReportId: 1 + }, { + field: 'queuecallerabandonAt', + alias: 'QueueAbandonAt', + ReportId: 1 + }, { + field: 'queuecallercomplete', + alias: 'Complete', + ReportId: 1 + }, { + field: 'queuecallercompleteAt', + alias: 'CompleteAt', + ReportId: 1 + }, { + field: 'queuecallerexit', + alias: 'QueueExit', + ReportId: 1 + }, { + field: 'queuecallerexitAt', + alias: 'QueueExitAt', + ReportId: 1 + }, { + field: 'queuecallerexitreason', + alias: 'QueueExitReason', + ReportId: 1 + }, { + field: 'exten', + alias: 'DID', + ReportId: 1 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'TalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 1 + }, { + field: 'UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'AbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 1 + }, { + field: 'IF(queuecallercomplete=1,holdtime,null)', + alias: 'AnswerTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 1 + }, { + field: 'calleridnum', + alias: 'CallerID', + ReportId: 2 + }, { + field: 'queue', + alias: 'Queue', + ReportId: 2 + }, { + field: 'queuecallerjoinAt', + alias: 'StartTime', + ReportId: 2 + }, { + field: 'CASE WHEN queuecallercomplete=1 THEN queuecallercompleteAt ELSE queuecallerLeaveAt END', + alias: 'EndTime', + custom: 1, + ReportId: 2 + }, { + field: 'holdtime', + alias: 'HoldTime', + format: 'SEC_TO_TIME', + ReportId: 2 + }, { + field: 'CASE WHEN queuecallercomplete=1 THEN \'YES\' ELSE \'NO\' END', + alias: 'Answered', + custom: 1, + ReportId: 2 + }, { + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 3 + }, { + field: 'calleridnum', + alias: 'CallerIdNum', + ReportId: 3 + }, { + field: 'calleridname', + alias: 'CallerIdName', + ReportId: 3 + }, { + field: 'queue', + alias: 'Queue', + ReportId: 3 + }, { + field: 'membername', + alias: 'Agent', + ReportId: 3 + }, { + field: 'agentcalledAt', + alias: 'AgentCalledAt', + ReportId: 3 + }, { + field: 'agentconnectAt', + alias: 'AgentConnectAt', + ReportId: 3 + }, { + field: 'agentcompleteAt', + alias: 'AgentCompleteAt', + ReportId: 3 + }, { + field: 'holdtime', + alias: 'AnswerTime', + ReportId: 3 + }, { + field: 'talktime', + alias: 'TalkTime', + ReportId: 3 + }, { + field: 'agentacw', + alias: 'AgentACW', + ReportId: 3 + }, { + field: 'acwtime', + alias: 'AgentACWTime', + ReportId: 3 + }, { + field: 'agentcomplete', + alias: 'AgentComplete', + ReportId: 3 + }, { + field: 'reason', + alias: 'HangupReason', + ReportId: 3 + }, { + field: 'lastevent', + alias: 'LastEvent', + ReportId: 3 + }, { + field: 'exten', + alias: 'DID', + ReportId: 3 + }, { + field: 'membername', + alias: 'Agent', + groupBy: 1, + ReportId: 4 + }, { + field: 'agentcomplete', + alias: 'Completed', + function: 'SUM', + ReportId: 4 + }, { + field: 'talktime', + alias: 'TotTalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 4 + }, { + field: 'acwtime', + alias: 'TotACWTime', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 4 + }, { + field: 'talktime + acwtime', + alias: 'TotHandleTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 4 + }, { + field: 'ROUND(AVG(talktime))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 4 + }, { + field: 'ROUND(AVG(acwtime))', + alias: 'AvgACWTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 4 + }, { + field: 'ROUND(SUM(talktime + acwtime)/COUNT(agentcomplete))', + alias: 'AvgHandleTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 4 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 5 + }, { + field: 'agentcomplete', + alias: 'Completed', + function: 'SUM', + ReportId: 5 + }, { + field: 'talktime', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 5 + }, { + field: 'holdtime', + alias: 'Tot HoldTime', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 5 + }, { + field: 'acwtime', + alias: 'Tot ACWTime', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 5 + }, { + field: 'talktime + acwtime', + alias: 'Tot Handle Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 5 + }, { + field: 'ROUND(AVG(talktime))', + alias: 'Avg TalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 5 + }, { + field: 'ROUND(AVG(holdtime))', + alias: 'Avg HoldTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 5 + }, { + field: 'ROUND(AVG(acwtime))', + alias: 'Avg ACWTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 5 + }, { + field: 'ROUND(SUM(talktime + acwtime)/COUNT(agentcomplete))', + alias: 'Avg Handle Time', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 5 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 6 + }, { + field: 'agentcomplete', + alias: 'Tot Answered', + function: 'SUM', + ReportId: 6 + }, { + field: 'COUNT(IF(holdtime<10,1,NULL))', + alias: 'Answered <10s', + custom: 1, + ReportId: 6 + }, { + field: 'ROUND(COUNT(IF(holdtime<10,1,NULL)) / SUM(agentcomplete) *100,1)', + alias: 'Answer Rate <10s', + custom: 1, + ReportId: 6 + }, { + field: 'COUNT(IF(holdtime >=10 AND holdtime <20,1,NULL))', + alias: 'Answered 10-20s', + custom: 1, + ReportId: 6 + }, { + field: 'ROUND(COUNT(IF(holdtime >=10 AND holdtime <20,1,NULL)) / SUM(agentcomplete) *100,1)', + alias: 'Answer Rate 10-20s', + custom: 1, + ReportId: 6 + }, { + field: 'COUNT(IF(holdtime >=20 AND holdtime <30,1,NULL))', + alias: 'Answered 20-30s', + custom: 1, + ReportId: 6 + }, { + field: 'ROUND(COUNT(IF(holdtime >=20 AND holdtime <30,1,NULL)) / SUM(agentcomplete) *100,1)', + alias: 'Answer Rate 20-30s', + custom: 1, + ReportId: 6 + }, { + field: 'COUNT(IF(holdtime >=30,1,NULL))', + alias: 'Answered >30s', + custom: 1, + ReportId: 6 + }, { + field: 'ROUND(COUNT(IF(holdtime >=30,1,NULL)) / SUM(agentcomplete) *100,1)', + alias: 'Answer Rate >30s', + custom: 1, + ReportId: 6 + }, { + field: 'reason', + alias: 'Reason', + groupBy: 1, + ReportId: 7 + }, { + field: 'uniqueid', + alias: 'Calls', + function: 'COUNT', + ReportId: 7 + }, { + field: 'agentconnectAt', + alias: 'Hour', + format: 'HOUR', + groupBy: 1, + ReportId: 8 + }, { + field: 'agentcomplete', + alias: 'Tot Answered', + function: 'SUM', + ReportId: 8 + }, { + field: 'COUNT(IF(holdtime<10,1,NULL))', + alias: 'Answered <10s', + custom: 1, + ReportId: 8 + }, { + field: 'COUNT(IF(holdtime >=10 AND holdtime <20,1,NULL))', + alias: 'Answered 10-20s', + custom: 1, + ReportId: 8 + }, { + field: 'COUNT(IF(holdtime >=20 AND holdtime <30,1,NULL))', + alias: 'Answered 20-30s', + custom: 1, + ReportId: 8 + }, { + field: 'COUNT(IF(holdtime >=30,1,NULL))', + alias: 'Answered >30s', + custom: 1, + ReportId: 8 + }, { + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 9 + }, { + field: 'calleridnum', + alias: 'CallerIdNum', + ReportId: 9 + }, { + field: 'queue', + alias: 'Queue', + ReportId: 9 + }, { + field: 'queuecallerjoinAt', + alias: 'JoinAt', + ReportId: 9 + }, { + field: 'queuecallerleaveAt', + alias: 'LeaveAt', + ReportId: 9 + }, { + field: 'queuecallerabandon', + alias: 'Abandon', + ReportId: 9 + }, { + field: 'queuecallerabandonAt', + alias: 'AbandonAt', + ReportId: 9 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + ReportId: 9 + }, { + field: 'queuecallerexitAt', + alias: 'UnmanagedAt', + ReportId: 9 + }, { + field: 'queuecallerexitreason', + alias: 'UnmanagedReason', + ReportId: 9 + }, { + field: 'position', + alias: 'QueuePosition', + ReportId: 9 + }, { + field: 'exten', + alias: 'DID', + ReportId: 9 + }, { + field: 'UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'Abandon Time', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 9 + }, { + field: 'UNIX_TIMESTAMP(queuecallerExitAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'Unmanaged HoldTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 9 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 10 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + ReportId: 10 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + ReportId: 10 + }, { + field: 'UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'Tot AbandonTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 10 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 10 + }, { + field: 'UNIX_TIMESTAMP(queuecallerExitAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'Tot Unmanaged Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 10 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerExitAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'Avg Unmanaged TIme', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 10 + }, { + field: 'queuecallerexitreason', + alias: 'Reason', + groupBy: 1, + ReportId: 11 + }, { + field: 'queuecallerexit', + alias: 'Calls', + function: 'SUM', + ReportId: 11 + }, { + field: 'UNIX_TIMESTAMP(queuecallerExitAt)-UNIX_TIMESTAMP(queuecallerjoinAt)', + alias: 'Tot Unmanaged Time', + function: 'SUM', + custom: 1, + ReportId: 11 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 12 + }, { + field: 'queuecallerabandon', + alias: 'Tot Abandoned', + function: 'SUM', + ReportId: 12 + }, { + field: 'COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <10,1,NULL))', + alias: 'Abandoned<10s', + custom: 1, + ReportId: 12 + }, { + field: 'ROUND(COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <10,1,NULL)) / SUM(queuecallerabandon) *100,1)', + alias: 'Abandoned Rate<10s', + custom: 1, + ReportId: 12 + }, { + field: 'COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=10 AND UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <60,1,NULL))', + alias: 'Abandoned 10-60s', + custom: 1, + ReportId: 12 + }, { + field: 'ROUND(COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=10 AND UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <60,1,NULL)) / SUM(queuecallerabandon) *100,1)', + alias: 'Abandoned Rate 10-60s', + custom: 1, + ReportId: 12 + }, { + field: 'COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=60 AND UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <120,1,NULL))', + alias: 'Abandoned 60-120s', + custom: 1, + ReportId: 12 + }, { + field: 'ROUND(COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=60 AND UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) <120,1,NULL)) / SUM(queuecallerabandon) *100,1)', + alias: 'Abandoned Rate 60-120s', + custom: 1, + ReportId: 12 + }, { + field: 'COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=120,1,NULL))', + alias: 'Abandoned>120s', + custom: 1, + ReportId: 12 + }, { + field: 'ROUND(COUNT(IF(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt) >=120,1,NULL)) / SUM(queuecallerabandon) *100,1)', + alias: 'Abandoned Rate>120s', + custom: 1, + ReportId: 12 + }, { + field: 'queuecallerjoinat', + alias: 'Date', + format: 'DATE', + groupBy: 1, + custom: 1, + ReportId: 13 + }, { + field: 'uniqueid', + alias: 'Offered', + function: 'COUNT DISTINCT', + ReportId: 13 + }, { + field: 'queuecallercomplete', + alias: 'Completed', + function: 'SUM', + ReportId: 13 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + custom: 1, + ReportId: 13 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + custom: 1, + ReportId: 13 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 13 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 13 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 13 + }, { + field: 'queuecallerjoinat', + alias: 'Hour', + format: 'HOUR', + groupBy: 1, + custom: 1, + ReportId: 14 + }, { + field: 'uniqueid', + alias: 'Offered', + function: 'COUNT DISTINCT', + ReportId: 14 + }, { + field: 'queuecallercomplete', + alias: 'Answered', + function: 'SUM', + ReportId: 14 + }, { + field: 'ROUND(SUM(queuecallercomplete)/COUNT(DISTINCT uniqueid)*100,1)', + alias: 'Answer Rate', + custom: 1, + ReportId: 14 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + ReportId: 14 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + ReportId: 14 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 14 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 14 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 14 + }, { + field: 'DAY(queuecallerjoinat)', + alias: 'Day', + groupBy: 1, + custom: 1, + ReportId: 15 + }, { + field: 'uniqueid', + alias: 'Offered', + function: 'COUNT DISTINCT', + ReportId: 15 + }, { + field: 'queuecallercomplete', + alias: 'Answered', + function: 'SUM', + ReportId: 15 + }, { + field: 'ROUND(SUM(queuecallercomplete)/COUNT(DISTINCT uniqueid)*100,1)', + alias: 'Answer Rate', + custom: 1, + ReportId: 15 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + ReportId: 15 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + ReportId: 15 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 15 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 15 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 15 + }, { + field: 'DAYNAME(queuecallerjoinat)', + alias: 'DayOfWeek', + groupBy: 1, + custom: 1, + ReportId: 16 + }, { + field: 'uniqueid', + alias: 'Offered', + function: 'COUNT DISTINCT', + ReportId: 16 + }, { + field: 'queuecallercomplete', + alias: 'Answered', + function: 'SUM', + ReportId: 16 + }, { + field: 'ROUND(SUM(queuecallercomplete)/COUNT(DISTINCT uniqueid)*100,1)', + alias: 'Answer Rate', + custom: 1, + ReportId: 16 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + orderBy: 'ASC', + ReportId: 16 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + ReportId: 16 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 16 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 16 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 16 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 17 + }, { + field: 'uniqueid', + alias: 'Offered', + function: 'COUNT DISTINCT', + ReportId: 17 + }, { + field: 'queuecallercomplete', + alias: 'Answered', + function: 'SUM', + ReportId: 17 + }, { + field: 'ROUND(SUM(queuecallercomplete)/COUNT(DISTINCT uniqueid)*100,1)', + alias: 'Answer Rate', + custom: 1, + ReportId: 17 + }, { + field: 'queuecallerabandon', + alias: 'Abandoned', + function: 'SUM', + ReportId: 17 + }, { + field: 'queuecallerexit', + alias: 'Unmanaged', + function: 'SUM', + ReportId: 17 + }, { + field: 'UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)', + alias: 'Tot TalkTime', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 17 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallercompleteAt)-UNIX_TIMESTAMP(queuecallerleaveAt)))', + alias: 'AvgTalkTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 17 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(queuecallerAbandonAt)-UNIX_TIMESTAMP(queuecallerjoinAt)))', + alias: 'AvgAbandonTime', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 17 + }, { + field: 'uniqueid', + alias: 'UniqueID', + ReportId: 18 + }, { + field: 'type', + alias: 'Type', + ReportId: 18 + }, { + field: 'tag', + alias: 'Tag', + ReportId: 18 + }, { + field: 'source', + alias: 'Source', + ReportId: 18 + }, { + field: 'destination', + alias: 'Destination', + ReportId: 18 + }, { + field: 'callerid', + alias: 'CallerID', + ReportId: 18 + }, { + field: 'destinationchannel', + alias: 'DestChannel', + ReportId: 18 + }, { + field: 'lastapplication', + alias: 'LastApp', + ReportId: 18 + }, { + field: 'lastdata', + alias: 'LastData', + ReportId: 18 + }, { + field: 'starttime', + alias: 'StartTime', + ReportId: 18 + }, { + field: 'answertime', + alias: 'AnswerTime', + ReportId: 18 + }, { + field: 'endtime', + alias: 'EndTime', + ReportId: 18 + }, { + field: 'duration', + alias: 'Duration', + ReportId: 18 + }, { + field: 'disposition', + alias: 'Disposition', + ReportId: 18 + }, { + field: 'uniqueid', + alias: 'UniqueID', + ReportId: 19 + }, { + field: 'accountcode', + alias: 'AgentExtension', + ReportId: 19 + }, { + field: 'source', + alias: 'Source', + ReportId: 19 + }, { + field: 'destination', + alias: 'Destination', + ReportId: 19 + }, { + field: 'callerid', + alias: 'CallerId', + ReportId: 19 + }, { + field: 'starttime', + alias: 'StartTime', + ReportId: 19 + }, { + field: 'answertime', + alias: 'AnswerTime', + ReportId: 19 + }, { + field: 'endtime', + alias: 'EndTime', + ReportId: 19 + }, { + field: 'duration', + alias: 'Duration', + format: 'SEC_TO_TIME', + ReportId: 19 + }, { + field: 'billableseconds', + alias: 'Billsec', + format: 'SEC_TO_TIME', + ReportId: 19 + }, { + field: 'disposition', + alias: 'Disposition', + ReportId: 19 + }, { + field: 'tag', + alias: 'Tag', + ReportId: 19 + }, { + field: 'type', + alias: 'Type', + groupBy: 1, + ReportId: 20 + }, { + field: 'uniqueid', + alias: 'Calls', + function: 'COUNT', + ReportId: 20 + }, { + field: 'duration', + alias: 'Tot Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 20 + }, { + field: 'ROUND(AVG(duration))', + alias: 'Avg Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 20 + }, { + field: 'disposition', + alias: 'Disposition', + groupBy: 1, + ReportId: 21 + }, { + field: 'uniqueid', + alias: 'Calls', + function: 'COUNT', + ReportId: 21 + }, { + field: 'duration', + alias: 'Tot Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 21 + }, { + field: 'ROUND(AVG(duration))', + alias: 'Avg Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 21 + }, { + field: 'SUBSTRING_INDEX(channel, "-", 1)', + alias: 'Agent', + groupBy: 1, + custom: 1, + ReportId: 22 + }, { + field: 'uniqueid', + alias: 'Calls', + function: 'COUNT', + ReportId: 22 + }, { + field: 'duration', + alias: 'Tot Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 22 + }, { + field: 'ROUND(AVG(duration))', + alias: 'Avg Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 22 + }, { + field: 'starttime', + alias: 'Date', + format: 'DATE', + groupBy: 1, + ReportId: 23 + }, { + field: 'uniqueid', + alias: 'Calls', + function: 'COUNT', + ReportId: 23 + }, { + field: 'duration', + alias: 'Tot Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + ReportId: 23 + }, { + field: 'ROUND(AVG(duration))', + alias: 'Avg Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 23 + }, { + field: 'membername', + alias: 'Agent', + groupBy: 1, + orderBy: 'ASC', + ReportId: 24 + }, { + field: 'UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt)', + alias: 'Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 24 + }, { + field: 'membername', + alias: 'Agent', + groupBy: 1, + ReportId: 25 + }, { + field: 'CASE WHEN type=\'LOGIN\' THEN UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt) END', + alias: 'Login Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 25 + }, { + field: 'CASE WHEN type=\'TALKING\' THEN UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt) END', + alias: 'Talk Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 25 + }, { + field: 'CASE WHEN type=\'PAUSE\' THEN UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt) END', + alias: 'Pause Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 25 + }, { + field: 'membername', + alias: 'Agent', + ReportId: 26 + }, { + field: 'enterAt', + alias: 'EnterAt', + ReportId: 26 + }, { + field: 'exitAt', + alias: 'ExitAt', + ReportId: 26 + }, { + field: 'data1', + alias: 'Pause', + ReportId: 26 + }, { + field: 'duration', + alias: 'Duration', + format: 'SEC_TO_TIME', + ReportId: 26 + }, { + field: 'membername', + alias: 'Agent', + ReportId: 27 + }, { + field: 'interface', + alias: 'Interface', + ReportId: 27 + }, { + field: 'type', + alias: 'Event', + ReportId: 27 + }, { + field: 'data1', + alias: 'Type', + ReportId: 27 + }, { + field: 'enterAt', + alias: 'EnterAt', + ReportId: 27 + }, { + field: 'exitAt', + alias: 'ExitAt', + ReportId: 27 + }, { + field: 'UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt)', + alias: 'Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 27 + }, { + field: 'membername', + alias: 'Agent', + groupBy: 1, + orderBy: 'ASC', + ReportId: 28 + }, { + field: 'data1', + alias: 'PauseType', + groupBy: 1, + orderBy: 'ASC', + ReportId: 28 + }, { + field: 'UNIX_TIMESTAMP(exitAt)-UNIX_TIMESTAMP(enterAt)', + alias: 'Duration', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 28 + }, { + field: 'project_name', + alias: 'Project Name', + ReportId: 29 + }, { + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 29 + }, { + field: 'callerid', + alias: 'CallerId', + ReportId: 29 + }, { + field: 'dnid', + alias: 'DID', + ReportId: 29 + }, { + field: 'joinAt', + alias: 'Start Time', + orderBy: 'ASC', + ReportId: 29 + }, { + field: 'leaveAt', + alias: 'End Time', + ReportId: 29 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Duration', + format: 'SEC_TO_TIME', + custom: 1, + ReportId: 29 + }, { + field: 'uniqueid', + alias: 'Unique Id', + ReportId: 30 + }, { + field: 'project_name', + alias: 'Project Name', + ReportId: 30 + }, { + field: 'callerid', + alias: 'Caller Id', + ReportId: 30 + }, { + field: 'node', + alias: 'Block', + ReportId: 30 + }, { + field: 'data', + alias: 'Data', + ReportId: 30 + }, { + field: 'connectedlinename', + alias: 'Agent', + groupBy: 1, + ReportId: 31 + }, { + field: 'uniqueid', + alias: 'Recorded Calls', + function: 'COUNT', + ReportId: 31 + }, { + field: 'rating', + alias: 'Total Rating', + function: 'SUM', + ReportId: 31 + }, { + field: 'rating', + alias: 'Avg Rating', + function: 'AVG', + ReportId: 31 + }, { + field: 'queue', + alias: 'Queue', + groupBy: 1, + ReportId: 32 + }, { + field: 'uniqueid', + alias: 'Rated Calls', + function: 'COUNT', + ReportId: 32 + }, { + field: 'rating', + alias: 'Total Rating', + function: 'SUM', + ReportId: 32 + }, { + field: 'rating', + alias: 'Avg Rating', + function: 'AVG', + ReportId: 32 + }, { + field: 'campaign', + alias: 'Campaign Name', + ReportId: 33 + }, { + field: 'calleridnum', + alias: 'CallerIdNum', + ReportId: 33 + }, { + field: 'starttime', + alias: 'LastCallAt', + orderBy: 'DESC', + ReportId: 33 + }, { + field: 'statedesc', + alias: 'State', + ReportId: 33 + }, { + field: 'countglobal', + alias: 'Global Count', + ReportId: 33 + }, { + field: 'dropreason', + alias: 'Drop Reason', + ReportId: 33 + }, { + field: 'blacklist', + alias: 'BlackList', + ReportId: 33 + }, { + field: 'membername', + alias: 'Agent', + ReportId: 33 + }, { + field: 'talktime', + alias: 'Talk Time', + ReportId: 33 + }, { + field: 'disposition', + alias: 'Disposition', + ReportId: 33 + }, { + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 33 + }, { + field: 'statedesc', + alias: 'State', + groupBy: true, + orderBy: 'ASC', + ReportId: 34 + }, { + field: 'id', + alias: 'Calls', + function: 'COUNT', + ReportId: 34 + }, { + field: 'ROUND(count(id)*100/(SELECT COUNT(*) FROM cm_hopper_history WHERE campaigntype=\'queue\'),2)', + alias: 'Calls (%)', + custom: true, + ReportId: 34 + }, { + field: 'campaign', + alias: 'Campaign Name', + orderBy: 'ASC', + groupBy: true, + ReportId: 35 + }, { + field: 'statedesc', + alias: 'State', + groupBy: true, + ReportId: 35 + }, { + field: 'id', + alias: 'Total Calls', + function: 'COUNT', + ReportId: 35 + }, { + field: 'ListId', + groupBy: true, + orderBy: 'ASC', + ReportId: 36 + }, { + field: 'id', + alias: 'Contacts', + function: 'COUNT', + ReportId: 36 + }, { + field: 'SUM(IF(state=4,1,0))', + alias: 'Managed', + custom: true, + ReportId: 36 + }, { + field: 'ROUND(SUM(IF(state=4,1,0))/COUNT(*)*100,1)', + alias: 'Penetration Rate', + custom: true, + ReportId: 36 + }, { + field: 'membername', + alias: 'Agent', + groupBy: true, + orderBy: 'ASC', + ReportId: 37 + }, { + field: 'id', + alias: 'Calls', + function: 'COUNT', + ReportId: 37 + }, { + field: 'SEC_TO_TIME(AVG(talktime))', + alias: 'AVG Talk Time', + custom: true, + ReportId: 37 + }, { + field: 'disposition', + alias: 'Disposition', + groupBy: true, + ReportId: 38 + }, { + field: 'id', + alias: 'Total', + function: 'COUNT', + ReportId: 38 + }, { + field: 'ROUND(COUNT(id)*100/(SELECT COUNT(*) FROM cm_hopper_final WHERE state=4 and campaigntype=\'queue\'),2)', + alias: 'Total (%)', + custom: true, + ReportId: 38 + }, { + field: 'membername', + alias: 'Agent', + groupBy: true, + ReportId: 39 + }, { + field: 'disposition', + alias: 'Disposition', + groupBy: true, + ReportId: 39 + }, { + field: 'id', + alias: 'Total', + function: 'COUNT', + ReportId: 39 + }, { + field: 'ROUND(COUNT(id)*100/(SELECT COUNT(*) FROM cm_hopper_final WHERE state=4 and campaigntype=\'queue\'),2)', + alias: 'Total (%)', + custom: true, + ReportId: 39 + }, { + field: 'campaign', + alias: 'Campaign Name', + ReportId: 40 + }, { + field: 'calleridnum', + alias: 'CallerIdNum', + ReportId: 40 + }, { + field: 'starttime', + alias: 'LastCallAt', + orderBy: 'DESC', + ReportId: 40 + }, { + field: 'statedesc', + alias: 'State', + ReportId: 40 + }, { + field: 'countglobal', + alias: 'Global Count', + ReportId: 40 + }, { + field: 'dropreason', + alias: 'Drop Reason', + ReportId: 40 + }, { + field: 'blacklist', + alias: 'BlackList', + ReportId: 40 + }, { + field: 'talktime', + alias: 'Talk Time', + ReportId: 40 + }, { + field: 'uniqueid', + alias: 'UniqueId', + ReportId: 40 + }, { + field: 'statedesc', + alias: 'State', + groupBy: true, + orderBy: 'ASC', + ReportId: 41 + }, { + field: 'id', + alias: 'Calls', + function: 'COUNT', + ReportId: 41 + }, { + field: 'ROUND(count(id)*100/(SELECT COUNT(*) FROM cm_hopper_history WHERE campaigntype=\'ivr\'),2)', + alias: 'Calls (%)', + custom: true, + ReportId: 41 + }, { + field: 'campaign', + alias: 'Campaign Name', + orderBy: 'ASC', + groupBy: true, + ReportId: 42 + }, { + field: 'statedesc', + alias: 'State', + groupBy: true, + ReportId: 42 + }, { + field: 'id', + alias: 'Total Calls', + function: 'COUNT', + ReportId: 42 + }, { + field: 'ListId', + groupBy: true, + orderBy: 'ASC', + ReportId: 43 + }, { + field: 'id', + alias: 'Contacts', + function: 'COUNT', + ReportId: 43 + }, { + field: 'SUM(IF(state=4,1,0))', + alias: 'Managed', + custom: true, + ReportId: 43 + }, { + field: 'ROUND(SUM(IF(state=4,1,0))/COUNT(*)*100,1)', + alias: 'Penetration Rate', + custom: true, + ReportId: 43 + }, { + field: 'chat_websites.name', + alias: 'Web Site', + groupBy: true, + ReportId: 44 + }, { + field: 'chat_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 44 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 44 + }, { + field: 'COUNT(IF(closed=1 && ((disposition !=\'unmanaged\' && disposition !=\'abandoned\') || disposition IS NULL),1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 44 + }, { + field: 'COUNT(IF(closed=1 && disposition =\'unmanaged\',1,NULL))', + alias: 'Unmanaged', + custom: true, + ReportId: 44 + }, { + field: 'COUNT(IF(closed=1 && disposition =\'abandoned\',1,NULL))', + alias: 'Abandoned', + custom: true, + ReportId: 44 + }, { + field: 'chat_websites.name', + alias: 'Web Site', + groupBy: true, + ReportId: 45 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(chat_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 45 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(chat_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 45 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 46 + }, { + field: 'chat_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 46 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(chat_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 46 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(chat_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 46 + }, { + field: 'chat_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 47 + }, { + field: 'chat_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 47 + }, { + field: 'COUNT(IF(closed=1 && ((disposition !=\'unmanaged\' && disposition !=\'abandoned\') || disposition IS NULL),1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 47 + }, { + field: 'ROUND(COUNT(IF(closed=1 && ((disposition !=\'unmanaged\' && disposition !=\'abandoned\') || disposition IS NULL),1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 47 + }, { + field: 'COUNT(IF(closed=1 && disposition =\'unmanaged\',1,NULL))', + alias: 'Unmanaged', + custom: true, + ReportId: 47 + }, { + field: 'ROUND(COUNT(IF(closed=1 && disposition=\'unmanaged\',1,NULL))/COUNT(id) *100,1)', + alias: 'Unmanaged (%)', + custom: true, + ReportId: 47 + }, { + field: 'COUNT(IF(closed=1 && disposition =\'abandoned\',1,NULL))', + alias: 'Abandoned', + custom: true, + ReportId: 47 + }, { + field: 'ROUND(COUNT(IF(closed=1 && disposition=\'abandoned\',1,NULL))/COUNT(id) *100,1)', + alias: 'Abandoned (%)', + custom: true, + ReportId: 47 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 47 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 47 + }, { + field: 'chat_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 48 + }, { + field: 'report_chat_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 48 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 48 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 48 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 48 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 48 + }, { + field: 'mail_accounts.name', + alias: 'Email Account', + groupBy: true, + ReportId: 49 + }, { + field: 'mail_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 49 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 49 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 49 + }, { + field: 'mail_accounts.name', + alias: 'Email Account', + groupBy: true, + ReportId: 50 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(mail_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 50 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(mail_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 50 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 51 + }, { + field: 'mail_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 51 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(mail_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 51 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(mail_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 51 + }, { + field: 'mail_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 52 + }, { + field: 'mail_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 52 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 52 + }, { + field: 'ROUND(COUNT(IF(closed=1,1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 52 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 52 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 52 + }, { + field: 'mail_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 53 + }, { + field: 'report_mail_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 53 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 53 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 53 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 53 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 53 + }, { + field: 'openchannel_accounts.name', + alias: 'Openchannel Account', + groupBy: true, + ReportId: 54 + }, { + field: 'openchannel_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 54 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 54 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 54 + }, { + field: 'openchannel_accounts.name', + alias: 'Openchannel Account', + groupBy: true, + ReportId: 55 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(openchannel_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 55 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(openchannel_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 55 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 56 + }, { + field: 'openchannel_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 56 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(openchannel_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 56 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(openchannel_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 56 + }, { + field: 'openchannel_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 57 + }, { + field: 'openchannel_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 57 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 57 + }, { + field: 'ROUND(COUNT(IF(closed=1,1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 57 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 57 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 57 + }, { + field: 'openchannel_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 58 + }, { + field: 'report_openchannel_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 58 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 58 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 58 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 58 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 58 + }, { + field: 'sms_accounts.name', + alias: 'Sms Account', + groupBy: true, + ReportId: 59 + }, { + field: 'sms_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 59 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 59 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 59 + }, { + field: 'sms_accounts.name', + alias: 'Sms Account', + groupBy: true, + ReportId: 60 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(sms_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 60 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(sms_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 60 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 61 + }, { + field: 'sms_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 61 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(sms_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 61 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(sms_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 61 + }, { + field: 'sms_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 62 + }, { + field: 'sms_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 62 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 62 + }, { + field: 'ROUND(COUNT(IF(closed=1,1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 62 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 62 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 62 + }, { + field: 'sms_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 63 + }, { + field: 'report_sms_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 63 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 63 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 63 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 63 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 63 + }, { + field: 'fax_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 68 + }, { + field: 'report_fax_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 68 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 68 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 68 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 68 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 68 + }, { + field: 'fax_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 67 + }, { + field: 'fax_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 67 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 67 + }, { + field: 'ROUND(COUNT(IF(closed=1,1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 67 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 67 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 67 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 66 + }, { + field: 'fax_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 66 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(fax_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 66 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(fax_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 66 + }, { + field: 'fax_accounts.name', + alias: 'Fax Account', + groupBy: true, + ReportId: 65 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(fax_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 65 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(fax_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 65 + }, { + field: 'fax_accounts.name', + alias: 'Fax Account', + groupBy: true, + ReportId: 64 + }, { + field: 'fax_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 64 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 64 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 64 + }, { + field: 'voice_recordings.UserId', + alias: 'UserId', + groupBy: true, + custom: false, + ReportId: 74 + }, { + field: 'users.fullname', + alias: 'Full Name', + groupBy: false, + custom: false, + ReportId: 74 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'POSITIVE\',1,NULL))', + alias: 'POSITIVE', + groupBy: false, + custom: true, + ReportId: 74 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'NEGATIVE\',1,NULL))', + alias: 'NEGATIVE', + groupBy: false, + custom: true, + ReportId: 74 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'NEUTRAL\',1,NULL))', + alias: 'NEUTRAL', + groupBy: false, + custom: true, + ReportId: 74 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'MIXED\',1,NULL))', + alias: 'MIXED', + groupBy: false, + custom: true, + ReportId: 74 + }, { + field: 'voice_recordings.sentiment', + alias: 'TOT', + function: 'COUNT', + groupBy: false, + custom: false, + ReportId: 74 + }, { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'POSITIVE\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Positive(%)', + groupBy: false, + custom: true, + ReportId: 74 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'NEGATIVE\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Negative(%)', + groupBy: false, + custom: true, + ReportId: 74 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'NEUTRAL\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Neutral(%)', + groupBy: false, + custom: true, + ReportId: 74 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'MIXED\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Mixed(%)', + groupBy: false, + custom: true, + ReportId: 74 + }, { + field: 'voice_recordings.sentiment', + alias: 'Sentiment TOT', + function: 'COUNT', + groupBy: false, + custom: false, + ReportId: 75 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'POSITIVE\',1,NULL))', + alias: 'POSITIVE', + groupBy: false, + custom: true, + ReportId: 75 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'NEGATIVE\',1,NULL))', + alias: 'NEGATIVE', + groupBy: false, + custom: true, + ReportId: 75 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'NEUTRAL\',1,NULL))', + alias: 'NEUTRAL', + groupBy: false, + custom: true, + ReportId: 75 + }, { + field: 'COUNT (IF(voice_recordings.sentiment = \'MIXED\',1,NULL))', + alias: 'MIXED', + groupBy: false, + custom: true, + ReportId: 75 + }, { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'POSITIVE\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Positive(%)', + groupBy: false, + custom: true, + ReportId: 75 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'NEGATIVE\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Negative(%)', + groupBy: false, + custom: true, + ReportId: 75 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'NEUTRAL\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Neutral(%)', + groupBy: false, + custom: true, + ReportId: 75 + }, + { + field: 'CONCAT(ROUND(( (SELECT COUNT(IF(voice_recordings.sentiment = \'MIXED\',1,NULL)))*100/ COUNT (voice_recordings.sentiment)),2),\'%\')', + alias: 'Mixed(%)', + groupBy: false, + custom: true, + ReportId: 75 + }, { + field: 'whatsapp_accounts.name', + alias: 'Whatsapp Account', + groupBy: true, + ReportId: 69 + }, { + field: 'whatsapp_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 69 + }, { + field: 'COUNT(IF(closed=0,1,NULL))', + alias: 'Open', + custom: true, + ReportId: 69 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Closed', + custom: true, + ReportId: 69 + }, { + field: 'whatsapp_accounts.name', + alias: 'Whatsapp Account', + groupBy: true, + ReportId: 70 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(whatsapp_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 70 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(whatsapp_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 70 + }, { + field: 'users.fullname', + alias: 'Agent', + groupBy: true, + ReportId: 71 + }, { + field: 'whatsapp_interactions.closed', + alias: 'Closed', + function: 'SUM', + ReportId: 71 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(whatsapp_interactions.createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 71 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(whatsapp_interactions.createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 71 + }, { + field: 'whatsapp_interactions.createdAt', + alias: 'Date', + format: 'DATE', + groupBy: true, + custom: true, + ReportId: 72 + }, { + field: 'whatsapp_interactions.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 72 + }, { + field: 'COUNT(IF(closed=1,1,NULL))', + alias: 'Completed', + custom: true, + ReportId: 72 + }, { + field: 'ROUND(COUNT(IF(closed=1,1,NULL))/COUNT(id) *100,1)', + alias: 'Completed (%)', + custom: true, + ReportId: 72 + }, { + field: 'UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)', + alias: 'Interaction Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 72 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(closedAt)-UNIX_TIMESTAMP(createdAt)))', + alias: 'AVG Interaction Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 72 + }, { + field: 'whatsapp_queues.name', + alias: 'Queue', + groupBy: true, + ReportId: 73 + }, { + field: 'report_whatsapp_queue.id', + alias: 'Interactions', + function: 'COUNT', + ReportId: 73 + }, { + field: 'COUNT(IF(reason=\'accepted\',1,NULL))', + alias: 'Accepted', + custom: true, + ReportId: 73 + }, { + field: 'COUNT(IF(reason=\'timeout\',1,NULL))', + alias: 'Timeout', + custom: true, + ReportId: 73 + }, { + field: 'UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)', + alias: 'Hold Time', + function: 'SUM', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 73 + }, { + field: 'ROUND(AVG(UNIX_TIMESTAMP(leaveAt)-UNIX_TIMESTAMP(joinAt)))', + alias: 'AVG Hold Time', + format: 'SEC_TO_TIME', + custom: true, + ReportId: 73 + } + ]; + + return _.groupBy(fields, 'ReportId'); +}; \ No newline at end of file diff --git a/server/config/seedDB/report/index.js b/server/config/seedDB/report/index.js new file mode 100644 index 0000000..07ba9c1 --- /dev/null +++ b/server/config/seedDB/report/index.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = { + default: require('./default'), + fields: require('./fields') +}; \ No newline at end of file diff --git a/server/config/seedDB/sounds.js b/server/config/seedDB/sounds.js new file mode 100644 index 0000000..698457b --- /dev/null +++ b/server/config/seedDB/sounds.js @@ -0,0 +1,118 @@ +'use strict'; + +var _ = require('lodash'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var sounds = [{ + id: 1, + name: 'Welcome Message', + save_name: 'welcome-acme', + display_name: 'Welcome Message', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 2, + name: 'Order Message', + save_name: 'order-number', + display_name: 'Order Message', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 3, + name: 'Order Shipped', + save_name: 'order-shipped', + display_name: 'Order Shipped', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 4, + name: 'Order Elaborated', + save_name: 'order-elaborated', + display_name: 'Order Elaborated', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 5, + name: 'Call Rating Message', + save_name: 'rate-call', + display_name: 'Call Rating Message', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 6, + name: 'Thank You', + save_name: 'thanx', + display_name: 'Thank You', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 7, + name: 'Agent Login', + save_name: 'agentmanagement-login', + display_name: 'Agent Login', + original_format: 'mp3', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 8, + name: 'Agent Logout', + save_name: 'agentmanagement-logout', + display_name: 'Agent Logout', + original_format: 'mp3', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 9, + name: 'Agent Menu', + save_name: 'agentmanagement-menu', + display_name: 'Agent Menu', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 10, + name: 'Agent Pause', + save_name: 'agentmanagement-pause', + display_name: 'Agent Pause', + original_format: 'mp3', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 11, + name: 'Agent End Pause', + save_name: 'agentmanagement-unpause', + display_name: 'Agent End Pause', + original_format: 'mp3', + converted_format: 'wav', + description: 'auto generated sound' +}, { + id: 12, + name: 'Agent Action Failure', + save_name: 'agentmanagement-action-failure', + display_name: 'Agent Action Failure', + original_format: 'wav', + converted_format: 'wav', + description: 'auto generated sound' +}]; + +exports.create = function() { + return db.Sound + .bulkCreate(sounds, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Sounds have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Sounds'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/squareOdbc.js b/server/config/seedDB/squareOdbc.js new file mode 100644 index 0000000..24d0a25 --- /dev/null +++ b/server/config/seedDB/squareOdbc.js @@ -0,0 +1,25 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var odbc = [{ + id: 1, + name: 'xcally-motion-database', + dsn: 'DRIVER=MySQL;SERVER=127.0.0.1;UID=xcall;PWD=xC@LL1234;DATABASE=motion2', + description: 'xcally motion db auto generated' +}]; + +exports.create = function() { + return db.SquareOdbc + .bulkCreate(odbc, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('ODBC have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create ODBC'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/squareProjects.js b/server/config/seedDB/squareProjects.js new file mode 100644 index 0000000..0de0077 --- /dev/null +++ b/server/config/seedDB/squareProjects.js @@ -0,0 +1,59 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var getXml = function(filename) { + return fs.readFileSync(path.join(__dirname, 'xml', filename + '.xml'), { + encoding: 'utf-8' + }); +}; + +var squareProjects = [{ + id: 1, + name: 'AutoAttendant', + description: 'Basic IVR sample auto generated', + preproduction: getXml('AutoAttendant'), + production: getXml('AutoAttendant') +}, { + id: 2, + name: 'CSI', + description: 'Customer Satisfaction IVR sample auto generated', + preproduction: getXml('CSI'), + production: getXml('CSI') +}, { + id: 3, + name: 'Orders', + description: 'Order DB IVR sample auto generated', + preproduction: getXml('Orders'), + production: getXml('Orders') +}, { + id: 4, + name: 'Survey', + description: 'Survey IVR sample auto generated', + preproduction: getXml('Survey'), + production: getXml('Survey') +}, { + id: 5, + name: 'AgentManagement', + description: 'Agent Management sample auto generated', + preproduction: getXml('AgentManagement'), + production: getXml('AgentManagement') +}]; + +exports.create = function() { + return db.SquareProject + .bulkCreate(squareProjects, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Square Projects have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Square Projects'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/tags.js b/server/config/seedDB/tags.js new file mode 100644 index 0000000..47258e8 --- /dev/null +++ b/server/config/seedDB/tags.js @@ -0,0 +1,46 @@ +'use strict'; + +var _ = require('lodash'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var tags = [{ + id: 1, + name: 'forums', + description: 'tag forums auto generated' +}, { + id: 2, + name: 'defective', + description: 'tag defective auto generated' +}, { + id: 3, + name: 'faq', + description: 'tag faq auto generated' +}, { + id: 4, + name: 'installation', + description: 'tag installation auto generated' +}, { + id: 5, + name: 'about_sales', + description: 'tag about_sales auto generated' +}]; + +exports.create = function() { + return db.Tag + .bulkCreate(tags, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Tags have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Tags'); + }); +}; + +exports.getNames = function() { + return _.map(tags, 'name'); +}; \ No newline at end of file diff --git a/server/config/seedDB/teams.js b/server/config/seedDB/teams.js new file mode 100644 index 0000000..4dcad73 --- /dev/null +++ b/server/config/seedDB/teams.js @@ -0,0 +1,29 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var teams = [{ + id: 1, + name: 'Demo Team', + description: 'demo team auto generated' +}]; + +exports.create = function() { + return db.Team + .bulkCreate(teams, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function(entities) { + for (var i = 0; i < entities.length; i += 1) { + entities[i].addAgents([2, 3]); + } + }) + .then(function() { + logger.info('Teams have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Teams'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/tree/index.js b/server/config/seedDB/tree/index.js new file mode 100644 index 0000000..6731138 --- /dev/null +++ b/server/config/seedDB/tree/index.js @@ -0,0 +1,128 @@ +'use strict'; + +/* Expected format of the node (there are no required fields) +{ + id : "string" // will be autogenerated if omitted + text : "string" // node text + icon : "string" // string for custom + state : { + opened : boolean // is the node open + disabled : boolean // is the node disabled + selected : boolean // is the node selected + }, + children : [] // array of strings or objects +} +*/ + +var getQueuesChildren = function(prefix) { + prefix += '_'; + return [{ + id: prefix + 'answered', + text: 'Answered' + }, { + id: prefix + 'unanswered', + text: 'Unanswered' + }, { + id: prefix + 'distribution', + text: 'Distribution' + }]; +}; + +var getVoiceChildren = function(prefix) { + prefix += '_'; + return [{ + id: prefix + 'queues', + text: 'Queues', + icon: 'icon s20 icon-stackoverflow', + children: getQueuesChildren(prefix + 'queues') + }, { + id: prefix + 'calls', + text: 'Calls', + icon: 'icon s20 icon-phone-dots' + }, { + id: prefix + 'agents', + text: 'Agents', + icon: 'icon s20 icon-account-multiple' + }, { + id: prefix + 'callysquare', + text: 'Cally Square', + icon: 'icon s20 icon-sitemap' + }, { + id: prefix + 'recordings', + text: 'Recordings', + icon: 'icon s20 icon-microphone' + }]; +}; + +var getBullChildren = function(prefix) { + prefix += '_'; + return [{ + id: prefix + 'queue_campaigns', + text: 'Queue Campaigns', + icon: 'icon s20 icon-stackoverflow' + }, { + id: prefix + 'ivr_campaigns', + text: 'IVR Campaigns', + icon: 'icon s20 icon-sitemap' + }]; +}; + + +var getMotionChildren = function(prefix) { + prefix += '_'; + return [{ + id: prefix + 'voice', + text: 'Voice', + icon: 'icon s20 icon-phone-log', + children: getVoiceChildren(prefix + 'voice') + }, { + id: prefix + 'bull', + text: 'Motion Bull', + icon: 'icon s20 icon-fire', + children: getBullChildren(prefix + 'bull') + }, { + id: prefix + 'chat', + text: 'Chat', + icon: 'icon s20 icon-hangouts' + }, { + id: prefix + 'mail', + text: 'Email', + icon: 'icon s20 icon-email' + }, { + id: prefix + 'openchannel', + text: 'Openchannel', + icon: 'icon s20 icon-google-earth' + }, { + id: prefix + 'sms', + text: 'Sms', + icon: 'icon s20 icon-message-text' + }, { + id: prefix + 'fax', + text: 'Fax', + icon: 'icon s20 icon-deskphone' + }, { + id: prefix + 'whatsapp', + text: 'WhatsApp Connector', + icon: 'icon s20 icon-whatsapp' + }, { + id: prefix + 'agents', + text: 'Agents', + icon: 'icon s20 icon-account-multiple' + }]; +}; + +var getTree = function(custom) { + return [{ + id: custom ? 'custom' : 'motion', + text: (custom ? 'Custom' : 'Motion') + ' Reports', + icon: 'icon s20 ' + (custom ? 'icon-laptop-chromebook' : 'icon-cloud'), + state: { + opened: true, + selected: true + }, + children: getMotionChildren(custom ? 'custom' : 'motion') + }]; +}; + +exports.motion = getTree(false); +exports.custom = getTree(true); \ No newline at end of file diff --git a/server/config/seedDB/trunks.js b/server/config/seedDB/trunks.js new file mode 100644 index 0000000..0007141 --- /dev/null +++ b/server/config/seedDB/trunks.js @@ -0,0 +1,26 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var trunks = [{ + id: 1, + name: 'demo', + secret: '55xcally55', + defaultuser: 'demo', + description: 'trunk demo auto generated' +}]; + +exports.create = function() { + return db.Trunk + .bulkCreate(trunks, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Trunks have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Trunks'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/userProfiles.js b/server/config/seedDB/userProfiles.js new file mode 100644 index 0000000..d51efa6 --- /dev/null +++ b/server/config/seedDB/userProfiles.js @@ -0,0 +1,25 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var userProfiles = [{ + id: 1, + name: 'Default', + crudPermissions: ['r', 'e', 'd'], + description: 'Auto generated User Profile' +}]; + +exports.create = function() { + return db.UserProfile + .bulkCreate(userProfiles, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('User Profiles have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create User Profiles'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/users.js b/server/config/seedDB/users.js new file mode 100644 index 0000000..2cbd239 --- /dev/null +++ b/server/config/seedDB/users.js @@ -0,0 +1,49 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var users = [{ + id: 1, + role: 'admin', + name: 'admin', + password: 'password', + fullname: 'Administrator', + email: 'admin@xcally.com', + internal: 1000, + description: 'user auto generated' +}, { + id: 2, + role: 'agent', + name: 'john.doe', + email: 'john.doe@xcally.com', + password: 'shuttle55', + fullname: 'John Doe', + internal: 1001, + permissions: '101,102,103,113,110,104,105,106,107,108,109,100,111,114'.split(','), + description: 'agent auto generated' +}, { + id: 3, + role: 'agent', + name: 'jane.miller', + email: 'jane.miller@xcally.com', + password: 'shuttle55', + fullname: 'Jane Miller', + internal: 1002, + permissions: '101,102,103,113,110,104,105,106,107,108,109,100,111,114'.split(','), + description: 'agent auto generated' +}]; + +exports.create = function() { + return db.User + .bulkCreate(users, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Users have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Users'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/variables.js b/server/config/seedDB/variables.js new file mode 100644 index 0000000..20b57fe --- /dev/null +++ b/server/config/seedDB/variables.js @@ -0,0 +1,108 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var variables = [{ + id: 1, + name: 'CHOICE', + description: 'variable for menu auto generated' +}, { + id: 2, + name: 'ORDERNUM', + description: 'variable for order auto generated' +}, { + id: 3, + name: 'DBRESULT', + description: 'variable for db query result auto generated' +}, { + id: 4, + name: 'RATE', + description: 'variable for rate call auto generated' +}, { + id: 5, + name: 'CALLERID(dnid)', + description: 'variable dialed number identifier auto generated' +}, { + id: 6, + name: 'CALLERID(name)', + description: 'variable name of the caller auto generated' +}, { + id: 7, + name: 'CALLERID(num)', + description: 'variable number of the caller auto generated' +}, { + id: 8, + name: 'CHANNEL(language)', + description: 'variable select a natural language file when available auto generated' +}, { + id: 9, + name: 'COUNTER', + description: 'variable auto generated' +}, { + id: 10, + name: 'EMAIL', + description: 'variable auto generated' +}, { + id: 11, + name: 'EXTRAVAR', + description: 'variable useful for agent popup auto generated' +}, { + id: 12, + name: 'FIRSTNAME', + description: 'variable auto generated' +}, { + id: 13, + name: 'LASTNAME', + description: 'variable auto generated' +}, { + id: 14, + name: 'INPUT', + description: 'variable auto generated' +}, { + id: 15, + name: 'OPTION', + description: 'variable auto generated' +}, { + id: 16, + name: 'ORDER', + description: 'variable auto generated' +}, { + id: 17, + name: 'PHONE', + description: 'variable auto generated' +}, { + id: 18, + name: 'RESULT', + description: 'variable auto generated' +}, { + id: 19, + name: 'UNIQUEID', + description: 'variable current call unique identifier auto generated' +}, { + id: 20, + name: 'VAR1', + description: 'generic variable auto generated' +}, { + id: 21, + name: 'VAR2', + description: 'generic variable auto generated' +}, { + id: 22, + name: 'VAR3', + description: 'generic variable auto generated' +}]; + +exports.create = function() { + return db.Variable + .bulkCreate(variables, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Variables have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Variables'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/voiceContexts.js b/server/config/seedDB/voiceContexts.js new file mode 100644 index 0000000..023bd4a --- /dev/null +++ b/server/config/seedDB/voiceContexts.js @@ -0,0 +1,51 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var voiceContexts = [{ + name: 'from-sip', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}, { + name: 'from-voip-provider', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}, { + name: 'inbound-fax', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}, { + name: 'outbound-fax', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}, { + name: 'from-voicemail', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}, { + name: 'xcally-mixmonitor-context', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true +}]; + + +exports.create = function() { + voiceContexts.forEach(function(element) { + db.VoiceContext + .findOrCreate({ + where: { + name: element.name + }, + defaults: element + }) + .spread(function(entity, created) { + if (created) { + logger.info('Context ' + element.name + ' have been created'); + } + }) + .catch(function(err) { + logger.error('Can\'t create ' + element.name + ' context'); + }); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/voiceExtensions.js b/server/config/seedDB/voiceExtensions.js new file mode 100644 index 0000000..1d115d9 --- /dev/null +++ b/server/config/seedDB/voiceExtensions.js @@ -0,0 +1,444 @@ +'use strict'; + +var _ = require('lodash'); + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); +var DBPromise = require('bluebird'); + +var applications = { + '600': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'Answer' + }, { + app: 'Playback', + appdata: 'demo-echotest', + isApp: true + }, { + app: 'Echo', + isApp: true + }, { + app: 'Playback', + appdata: 'demo-echodone', + isApp: true + }, { + app: 'Hangup' + }], + '6000': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'Answer' + }, { + app: 'Queue', + appdata: 'Support,xX,,,300,,,,,', + appType: 'queue', + isApp: true + }, { + app: 'Hangup' + }], + '6001': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'Answer' + }, { + app: 'Queue', + appdata: 'Sales,xX,,,300,,,,,', + appType: 'queue', + isApp: true + }, { + app: 'Hangup' + }], + '6666': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'AGI', + appdata: 'agi://127.0.0.1/square,AutoAttendant', + appType: 'agi', + isApp: true + }, { + app: 'Hangup' + }], + '6667': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'AGI', + appdata: 'agi://127.0.0.1/square,Orders', + appType: 'agi', + isApp: true + }, { + app: 'Hangup' + }], + '6668': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'AGI', + appdata: 'agi://127.0.0.1/square,CSI', + appType: 'agi', + isApp: true + }, { + app: 'Hangup' + }], + '6669': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'AGI', + appdata: 'agi://127.0.0.1/square,Survey', + appType: 'agi', + isApp: true + }, { + app: 'Hangup' + }], + '6670': [{ + app: 'Set', + appdata: 'CDR(type)=internal' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'AGI', + appdata: 'agi://127.0.0.1/square,AgentManagement', + appType: 'agi', + isApp: true + }, { + app: 'Hangup' + }], + 'xcally-motion-dialer': [{ + app: 'Set', + appdata: 'CDR(type)=dialer' + }, { + app: 'Set', + appdata: 'CALLERID(all)=${XMD-CALLERID}' + }, { + app: 'GotoIf', + appdata: '$["${XMD-AMD}" != "NONE" ]?5:11' + }, { + app: 'Answer', + appdata: '' + }, { + app: 'Background', + appdata: 'silence/1' + }, { + app: 'AMD', + appdata: '${XMD-AMDINITIALSILENCE},${XMD-AMDGREETING},${XMD-AMDAFTERGREETINGSILENCE},${XMD-AMDTOTALANALYSISTIME},${XMD-AMDMINWORDLENGTH},${XMD-AMDBETWEENWORDSSILENCE},${XMD-AMDMAXIMUMNUMBEROFWORDS},${XMD-AMDSILENCETHRESHOLD},${XMD-AMDMAXIMUMWORDLENGTH}' + }, { + app: 'GotoIf', + appdata: '$["${AMDSTATUS}" == "HUMAN" ]?11:9' + }, { + app: 'GotoIf', + appdata: '$["${AMDSTATUS}" == "NOTSURE" ]?11:10' + }, { + app: 'GotoIf', + appdata: '$["${AMDSTATUS}" == "MACHINE" ]?14:11' + }, { + app: 'Execif', + appdata: '$["${XMD-AGI}" != "NONE" ]?AGI(${XMD-AGI})' + }, { + app: 'Execif', + appdata: '$["${XMD-QUEUE}" != "NONE" ]?QUEUE(${XMD-QUEUE})' + }, { + app: 'Execif', + appdata: '$["${XMD-AGIAFTER}" != "NONE" ]?AGI(${XMD-AGIAFTER})' + }, { + app: 'Hangup' + }], + 'xcally-motion-fax': [{ + app: 'Set', + appdata: 'CDR(type)=outbound-fax' + }, { + app: 'Wait', + appdata: '6' + }, { + app: 'Set', + appdata: 'FAXOPT(ecm)=${XMF-ECM}' + }, { + app: 'Set', + appdata: 'FAXOPT(headerinfo)=${XMF-HEADERINFO}' + }, { + app: 'Set', + appdata: 'FAXOPT(localstationid)=${XMF-LOCALSTATIONID}' + }, { + app: 'Set', + appdata: 'FAXOPT(maxrate)=${XMF-MAXRATE}' + }, { + app: 'Set', + appdata: 'FAXOPT(minrate)=${XMF-MINRATE}' + }, { + app: 'Set', + appdata: 'FAXOPT(modem)=${XMF-MODEM}' + }, { + app: 'Set', + appdata: 'FAXOPT(t38timeout)=${XMF-T38TIMEOUT}' + }, { + app: 'SendFax', + appdata: '${XMF-PATH},d' + }], + 'xcally-motion-preview': [{ + app: 'Set', + appdata: 'CDR(type)=dialer' + }, { + app: 'Set', + appdata: 'CALLERID(all)=${XMD-CALLERID}' + }, { + app: 'Execif', + appdata: '$["${XMD-AGI}" != "NONE" ]?AGI(${XMD-AGI})' + }, { + app: 'Dial', + appdata: '${XMD-DIALCHANNEL},${XMD-DIALTIMEOUT},${XMD-DIALOPTIONS},${XMD-DIALURL}' + }, { + app: 'Execif', + appdata: '$["${XMD-AGIAFTER}" != "NONE" ]?AGI(${XMD-AGIAFTER})' + }, { + app: 'Hangup' + }], + '_.': [{ + app: 'Set', + appdata: 'CDR(type)=outbound' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'Set', + appdata: 'XCALLY-MOTION-ANSWER=0' + }, { + app: 'Set', + appdata: 'XCALLY-MOTION-PROGRESS=0' + }, { + app: 'Set', + appdata: 'MONITOR_OPTIONS=ab' + }, { + app: 'Set', + outboundrouteid: true + }, { + app: 'Set', + appdata: '_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}' + }, { + app: 'Set', + appdata: '_XCALLY_MIXMONITOR_FORMAT=wav' + }, { + app: 'Playback', + appdata: 'demo-congrats', + appType: 'custom', + isApp: true + }, { + app: 'Hangup' + }], + '_X.': [{ + app: 'Set', + appdata: 'CDR(type)=inbound' + }, { + app: 'NoOp', + appdata: 'No alias set' + }, { + app: 'Answer' + }, { + app: 'Playback', + appdata: 'demo-congrats', + isApp: true + }, { + app: 'Hangup' + }], + 'h': [{ + app: 'Hangup' + }], + 'failed': [{ + app: 'Hangup' + }], +}; + +var voiceExtensions = [{ + type: 'internal', + context: 'from-sip', + exten: '600', + description: 'echo test demo auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6000', + description: 'forward to Support queue auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6001', + description: 'forward to Sales queue auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6666', + description: 'forward to Auto Attendant IVR auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6667', + description: 'forward to Orders IVR auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6668', + description: 'forward to CSI IVR auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6669', + description: 'forward to Survey IVR auto generated' +}, { + type: 'internal', + context: 'from-sip', + exten: '6670', + description: 'forward to Agent Management IVR auto generated' +}, { + type: 'system', + context: 'from-sip', + exten: 'xcally-motion-dialer', + description: 'dialer extensions auto generated' +}, { + type: 'system', + context: 'from-sip', + exten: 'xcally-motion-fax', + description: 'fax extensions auto generated' +}, { + type: 'system', + context: 'from-sip', + exten: 'xcally-motion-preview', + description: 'dialer extensions auto generated' +}, { + type: 'outbound', + context: 'from-sip', + exten: '_.', + description: 'demo outbound calls auto generated' +}, { + type: 'inbound', + context: 'from-voip-provider', + exten: '_X.', + description: 'catch all inbound calls auto generated' +}, { + type: 'system', + context: 'from-sip', + exten: 'h', + description: 'catch hangup event auto generated' +}, { + type: 'system', + context: 'from-sip', + exten: 'failed', + description: 'catch failed event auto generated' +}]; + +var applicationsAlways = { + 's': [{ + app: 'MixMonitor', + appdata: '${XCALLY_MIXMONITOR_UNIQUEID}.${XCALLY_MIXMONITOR_FORMAT},ab' + }, { + app: 'Return' + }], + '_[x][c][a][l][l][y][Q][u][e][u][e][E][x][t][e][n][s][i][o][n].': [{ + app: 'Progress' + }, + { + app: 'Set', + appdata: 'CDR(type)=internal' + }, + { + app: 'Queue', + appdata: '${EXTEN:20},xX' + } + ] +}; + +var voiceExtensionsAlways = [{ + type: 'system', + context: 'xcally-mixmonitor-context', + exten: 's' +}, { + type: 'system', + context: 'from-sip', + exten: '_[x][c][a][l][l][y][Q][u][e][u][e][E][x][t][e][n][s][i][o][n].' +}]; + +function createExtensions(voiceExtensions, applications) { + return db.VoiceExtension + .bulkCreate(voiceExtensions, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function(entities) { + for (var i = 0; i < entities.length; i += 1) { + if (applications[entities[i].exten]) { + for (var j = 0; j < applications[entities[i].exten].length; j += 1) { + + // NOTE: only for outbound route with outboundrouteid + if (applications[entities[i].exten][j].outboundrouteid) { + applications[entities[i].exten][j].appdata = 'outboundrouteid=' + entities[i].id; + delete applications[entities[i].exten][j].outboundrouteid; + } + + applications[entities[i].exten][j] = _.defaults(applications[entities[i].exten][j], { + isApp: false, + appType: 'custom', + type: entities[i].type, + context: entities[i].context, + exten: entities[i].exten, + priority: parseInt(entities[i].priority, 10) + 1 + j, + description: entities[i].description, + VoiceExtensionId: entities[i].id + }); + + db.VoiceExtension.create(applications[entities[i].exten][j]); + } + } + + } + }) + .then(function() { + logger.info('Voice Extensions have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Voice Extensions', err); + }); +} + +exports.create = function() { + createExtensions(voiceExtensions, applications); +}; + +exports.createAlways = function() { + return db.VoiceExtension + .destroy({ + where: { + $or: voiceExtensionsAlways + } + }) + .then(function() { + createExtensions(voiceExtensionsAlways, applicationsAlways); + }) + .catch(function(err) { + logger.error('Can\'t create Voice Extensions', err); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/voiceMusicOnHold.js b/server/config/seedDB/voiceMusicOnHold.js new file mode 100644 index 0000000..2dbb2ad --- /dev/null +++ b/server/config/seedDB/voiceMusicOnHold.js @@ -0,0 +1,47 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var voiceMusicOnHold = [{ + id: 1, + name: 'default', + directory: '/var/lib/asterisk/moh/', + mode: 'files', + sort: 'random', + format: 'wav', + defaultEntry: true, + description: 'default moh auto generated' +}, { + id: 2, + name: 'noice', + directory: '/var/opt/motion2/server/files/moh/noice/', + mode: 'files', + sort: 'random', + format: 'wav', + defaultEntry: true, + description: 'noice moh auto generated' +}, { + id: 3, + name: 'wait', + directory: '/var/opt/motion2/server/files/moh/wait/', + mode: 'files', + sort: 'random', + format: 'wav', + defaultEntry: true, + description: 'wait moh auto generated' +}]; + +exports.create = function() { + return db.VoiceMusicOnHold + .bulkCreate(voiceMusicOnHold, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function() { + logger.info('Music on hold have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Music on hold'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/voiceQueues.js b/server/config/seedDB/voiceQueues.js new file mode 100644 index 0000000..c1991c2 --- /dev/null +++ b/server/config/seedDB/voiceQueues.js @@ -0,0 +1,98 @@ +'use strict'; + +var db = require('../../mysqldb').db; +var logger = require('../logger')('app'); + +var voiceQueues = [{ + id: 1, + type: 'inbound', + name: 'Support', + strategy: 'ringall', + musiconhold: 'wait', + description: 'inbound voice queue auto generated' +}, { + id: 2, + type: 'inbound', + name: 'Sales', + strategy: 'ringall', + musiconhold: 'wait', + description: 'inbound voice queue auto generated' +}, { + id: 3, + type: 'outbound', + name: 'Survey', + strategy: 'rrmemory', + TrunkId: 1, + IntervalId: 1, + musiconhold: 'noice', + description: 'outbound voice queue campaign auto generated' +}, { + id: 4, + type: 'outbound', + name: 'Telemarketing', + strategy: 'rrmemory', + TrunkId: 1, + IntervalId: 1, + musiconhold: 'noice', + description: 'outbound voice queue campaign auto generated' +}, { + id: 5, + type: 'outbound', + name: 'CallbackCampaign', + strategy: 'rrmemory', + TrunkId: 1, + IntervalId: 1, + musiconhold: 'noice', + description: 'outbound voice queue campaign auto generated' +}]; + +exports.create = function() { + return db.VoiceQueue + .bulkCreate(voiceQueues, { + ignoreDuplicates: true, + individualHooks: true + }) + .then(function(entities) { + for (var i = 0; i < entities.length; i += 1) { + // add agents on all queues + entities[i].addAgents([2, 3], { + ignoreDuplicates: true, + individualHooks: true + }); + + // add agents on all queues + entities[i].addTeams([1], { + ignoreDuplicates: true, + individualHooks: true + }); + + if (entities[i].type === 'outbound' && entities[i].id !== 5) { + // add lists only for outbound queue + entities[i].addLists([1], { + ignoreDuplicates: true, + individualHooks: true + }); + // add black lists only for outbound queue + entities[i].addBlackLists([2], { + ignoreDuplicates: true, + individualHooks: true + }); + } + + if (entities[i].id === 5) { + // add lists only for outbound queue + entities[i].addLists([3], { + ignoreDuplicates: true, + individualHooks: true + }); + } + } + return entities; + }) + .then(function() { + logger.info('Voice Queues have been created'); + }) + .catch(function(err) { + logger.error('Can\'t create Voice Queues'); + }); +}; \ No newline at end of file diff --git a/server/config/seedDB/xml/AgentManagement.xml b/server/config/seedDB/xml/AgentManagement.xml new file mode 100644 index 0000000..4145ec5 --- /dev/null +++ b/server/config/seedDB/xml/AgentManagement.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/config/seedDB/xml/AutoAttendant.xml b/server/config/seedDB/xml/AutoAttendant.xml new file mode 100644 index 0000000..c22b142 --- /dev/null +++ b/server/config/seedDB/xml/AutoAttendant.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/config/seedDB/xml/CSI.xml b/server/config/seedDB/xml/CSI.xml new file mode 100644 index 0000000..5f33a96 --- /dev/null +++ b/server/config/seedDB/xml/CSI.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/config/seedDB/xml/Orders.xml b/server/config/seedDB/xml/Orders.xml new file mode 100644 index 0000000..91fff6f --- /dev/null +++ b/server/config/seedDB/xml/Orders.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/config/seedDB/xml/Survey.xml b/server/config/seedDB/xml/Survey.xml new file mode 100644 index 0000000..c58f340 --- /dev/null +++ b/server/config/seedDB/xml/Survey.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/config/seedUsers.js b/server/config/seedUsers.js new file mode 100644 index 0000000..65f9636 --- /dev/null +++ b/server/config/seedUsers.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd70b=['../mysqldb','push','format','%s%s','agent','%s%s@xcally.com','password','udp','wss','all','ulaw','yes','/etc/pki/tls/certs/motion.crt','/etc/pki/tls/private/motion.key','actpass','\x22%s\x22\x20<%s>','User','bulkCreate','add\x20user','catch','log','util'];(function(_0x586042,_0x335fbf){var _0x3cccab=function(_0x2aa2d9){while(--_0x2aa2d9){_0x586042['push'](_0x586042['shift']());}};_0x3cccab(++_0x335fbf);}(_0xd70b,0xdb));var _0xbd70=function(_0x2d2ca2,_0x51873f){_0x2d2ca2=_0x2d2ca2-0x0;var _0x48489d=_0xd70b[_0x2d2ca2];return _0x48489d;};'use strict';var util=require(_0xbd70('0x0'));var db=require(_0xbd70('0x1'))['db'];var users=[];for(var i=0x1;i<=0xc8;i+=0x1){users[_0xbd70('0x2')]({'name':util[_0xbd70('0x3')](_0xbd70('0x4'),_0xbd70('0x5'),i),'fullname':util[_0xbd70('0x3')](_0xbd70('0x4'),'agent',i),'email':util[_0xbd70('0x3')](_0xbd70('0x6'),_0xbd70('0x5'),i),'role':_0xbd70('0x5'),'password':_0xbd70('0x7'),'internal':0xfa0+i,'type':'friend','transport':[_0xbd70('0x8'),'ws',_0xbd70('0x9')],'disallow':[_0xbd70('0xa')],'allow':[_0xbd70('0xb')],'defaultuser':util[_0xbd70('0x3')]('%s%s',_0xbd70('0x5'),i),'encryption':_0xbd70('0xc'),'avpf':_0xbd70('0xc'),'force_avp':_0xbd70('0xc'),'icesupport':_0xbd70('0xc'),'dtlsenable':_0xbd70('0xc'),'dtlsverify':'no','dtlscertfile':_0xbd70('0xd'),'dtlsprivatekey':_0xbd70('0xe'),'dtlssetup':_0xbd70('0xf'),'callerid':util[_0xbd70('0x3')](_0xbd70('0x10'),util[_0xbd70('0x3')](_0xbd70('0x4'),'agent',i),0xfa0+i)});}db[_0xbd70('0x11')][_0xbd70('0x12')](users)['then'](function(){console['log'](_0xbd70('0x13'));})[_0xbd70('0x14')](function(_0x1b936a){console[_0xbd70('0x15')](_0x1b936a);}); \ No newline at end of file diff --git a/server/config/socketio.js b/server/config/socketio.js new file mode 100644 index 0000000..8c76f64 --- /dev/null +++ b/server/config/socketio.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb1ad=['findOne','then','ChatQueues','FaxQueues','SmsQueues','MailQueues','OpenchannelQueues','WhatsappQueues','findAll','Telephones','Trunks','IvrCampaigns','resourceId','where','Campaign','format','%s:queue:%s','Agents','length','user:%s','query','find','userProfileId','handshake','ChatInteraction','ChatInteractions','FaxInteraction','FaxInteractions','SmsInteraction','SmsInteractions','OpenchannelInteraction','OpenchannelInteractions','WhatsappInteractions','admin','voice:outbound','hasOwnProperty','include','VoiceQueue','push','FaxQueue','MailQueue','OpenchannelQueue','WhatsappQueue','user','VoiceQueues','SmsQueue','Trunk','getVoiceQueues','getChatQueues','getSmsQueues','getMailQueues','getOpenchannelQueues','getWhatsappQueues','all','voice','chat','fax','mail','openchannel','whatsapp','telephone:%s','campaign:%s:%s','map','emit','user_has_chat_interactions:remove','leave','MailInteractions','removeMailInteractions','user_has_mail_interactions:remove','user_has_fax_interactions:remove','removeSmsInteractions','removeOpenchannelInteractions','user_has_openchannel_interactions:remove','removeWhatsappInteractions','user_has_whatsapp_interactions:remove','catch','join','default','request','connection','remoteAddress','remotePort','connectedAt','log','SocketIO\x20','nsp','address','CONNECTED','lodash','util','bluebird','../mysqldb','./environment','name','User','role','agent','telephone','type','ivr'];(function(_0x3f9a54,_0x3b3c36){var _0x2b1780=function(_0x4bdf57){while(--_0x4bdf57){_0x3f9a54['push'](_0x3f9a54['shift']());}};_0x2b1780(++_0x3b3c36);}(_0xb1ad,0x184));var _0xdb1a=function(_0x297fd3,_0x115406){_0x297fd3=_0x297fd3-0x0;var _0x2af381=_0xb1ad[_0x297fd3];return _0x2af381;};'use strict';var _=require(_0xdb1a('0x0'));var util=require(_0xdb1a('0x1'));var BPromise=require(_0xdb1a('0x2'));var db=require(_0xdb1a('0x3'))['db'];var config=require(_0xdb1a('0x4'));var queryQueues={'attributes':['id',_0xdb1a('0x5')],'include':[{'as':'Agents','model':db[_0xdb1a('0x6')],'attributes':['id',_0xdb1a('0x5'),_0xdb1a('0x7')],'raw':!![],'where':{'role':_0xdb1a('0x8')},'required':![]}]};var queryTelephones={'raw':!![],'attributes':['id',_0xdb1a('0x5')],'where':{'role':_0xdb1a('0x9')}};var queryTrunks={'raw':!![],'attributes':['id',_0xdb1a('0x5')]};var queryAgents={'raw':!![],'attributes':['id',_0xdb1a('0x5')],'where':{'role':_0xdb1a('0x8')}};var queryCampaigns={'raw':!![],'attributes':['id',_0xdb1a('0x5'),_0xdb1a('0xa')],'where':{'type':_0xdb1a('0xb')}};function getAssociatedResources(_0xf62df9,_0x174303,_0x122af8){return db['UserProfileSection'][_0xdb1a('0xc')]({'where':{'name':_0xf62df9,'userProfileId':_0x174303},'raw':!![]})[_0xdb1a('0xd')](function(_0x5a36cf){if(_0x5a36cf){if(_0x5a36cf['autoAssociation']){switch(_0xf62df9){case'VoiceQueues':case _0xdb1a('0xe'):case _0xdb1a('0xf'):case _0xdb1a('0x10'):case _0xdb1a('0x11'):case _0xdb1a('0x12'):case _0xdb1a('0x13'):return db[_0x122af8][_0xdb1a('0x14')](queryQueues);case _0xdb1a('0x15'):return db[_0x122af8][_0xdb1a('0x14')](queryTelephones);case _0xdb1a('0x16'):return db[_0x122af8][_0xdb1a('0x14')](queryTrunks);case _0xdb1a('0x17'):return db[_0x122af8][_0xdb1a('0x14')](queryCampaigns);}}else{return db['UserProfileResource'][_0xdb1a('0x14')]({'attributes':[_0xdb1a('0x18')],'where':{'sectionId':_0x5a36cf['id']},'raw':!![]})[_0xdb1a('0xd')](function(_0x4bdec7){if(_0x4bdec7){var _0x28dfe9={'where':{'id':_['map'](_0x4bdec7,_0xdb1a('0x18'))},'raw':!![]};switch(_0x122af8){case _0xdb1a('0x6'):_0x28dfe9[_0xdb1a('0x19')]['role']=_0xdb1a('0x9');break;case _0xdb1a('0x1a'):_0x28dfe9[_0xdb1a('0x19')]['type']=_0xdb1a('0xb');break;}return db[_0x122af8][_0xdb1a('0x14')](_0x28dfe9);}else{return[];}});}}else{return[];}})[_0xdb1a('0xd')](function(_0x15fc44){return _0x15fc44;});}function joinOrLeaveQueues(_0x37e10c,_0x2882e2,_0x572ee2,_0xde9106){_0x37e10c[_0x2882e2](util[_0xdb1a('0x1b')](_0xdb1a('0x1c'),_0x572ee2,_0xde9106[_0xdb1a('0x5')]));if(_0xde9106[_0xdb1a('0x1d')]){for(var _0x400397=0x0;_0x400397<_0xde9106[_0xdb1a('0x1d')][_0xdb1a('0x1e')];_0x400397+=0x1){_0x37e10c[_0x2882e2](util[_0xdb1a('0x1b')](_0xdb1a('0x1f'),_0xde9106['Agents'][_0x400397][_0xdb1a('0x5')]));}}}function joinOrLeave(_0x4de659,_0x28ccfe,_0x2cc1aa){var _0x3d07fc;if(_0x4de659['handshake'][_0xdb1a('0x20')]['id']){db['User'][_0xdb1a('0x21')]({'attributes':['id',_0xdb1a('0x5'),_0xdb1a('0x7'),_0xdb1a('0x22')],'where':{'id':_0x4de659[_0xdb1a('0x23')][_0xdb1a('0x20')]['id']},'include':[{'model':db[_0xdb1a('0x24')],'as':_0xdb1a('0x25'),'attributes':['id'],'raw':!![]},{'model':db['MailInteraction'],'as':'MailInteractions','attributes':['id'],'raw':!![]},{'model':db[_0xdb1a('0x26')],'as':_0xdb1a('0x27'),'attributes':['id'],'raw':!![]},{'model':db[_0xdb1a('0x28')],'as':_0xdb1a('0x29'),'attributes':['id'],'raw':!![]},{'model':db[_0xdb1a('0x2a')],'as':_0xdb1a('0x2b'),'attributes':['id'],'raw':!![]},{'model':db['WhatsappInteraction'],'as':_0xdb1a('0x2c'),'attributes':['id'],'raw':!![]}]})['then'](function(_0x5a67c4){if(_0x5a67c4){_0x3d07fc=_0x5a67c4;_0x4de659[_0x28ccfe](util[_0xdb1a('0x1b')]('user:%s',_0x5a67c4['name']));var _0x3a860d=[];switch(_0x5a67c4[_0xdb1a('0x7')]){case _0xdb1a('0x2d'):_0x4de659[_0x28ccfe]('voice:inbound');_0x4de659[_0x28ccfe](_0xdb1a('0x2e'));if(queryQueues[_0xdb1a('0x2f')](_0xdb1a('0x30'))){delete queryQueues[_0xdb1a('0x30')];}_0x3a860d['push'](db[_0xdb1a('0x31')][_0xdb1a('0x14')](queryQueues));_0x3a860d[_0xdb1a('0x32')](db['ChatQueue'][_0xdb1a('0x14')](queryQueues));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x33')][_0xdb1a('0x14')](queryQueues));_0x3a860d['push'](db['SmsQueue']['findAll'](queryQueues));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x34')]['findAll'](queryQueues));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x35')][_0xdb1a('0x14')](queryQueues));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x36')]['findAll'](queryQueues));_0x3a860d['push'](db['User'][_0xdb1a('0x14')](queryTelephones));_0x3a860d['push'](db['Trunk'][_0xdb1a('0x14')](queryTrunks));_0x3a860d[_0xdb1a('0x32')](db['Campaign'][_0xdb1a('0x14')](queryCampaigns));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x6')][_0xdb1a('0x14')](queryAgents));break;case _0xdb1a('0x37'):_0x4de659[_0x28ccfe]('voice:inbound');_0x4de659[_0x28ccfe]('voice:outbound');_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x38'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x31')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0xe'),_0x5a67c4[_0xdb1a('0x22')],'ChatQueue'));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources('FaxQueues',_0x5a67c4['userProfileId'],'FaxQueue'));_0x3a860d['push'](getAssociatedResources(_0xdb1a('0x10'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x39')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x11'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x34')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x12'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x35')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x13'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x36')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources('Telephones',_0x5a67c4['userProfileId'],_0xdb1a('0x6')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x16'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x3a')));_0x3a860d[_0xdb1a('0x32')](getAssociatedResources(_0xdb1a('0x17'),_0x5a67c4[_0xdb1a('0x22')],_0xdb1a('0x1a')));_0x3a860d[_0xdb1a('0x32')](db[_0xdb1a('0x6')][_0xdb1a('0x14')](queryAgents));break;case _0xdb1a('0x8'):_0x4de659[_0x28ccfe]('voice:inbound');_0x4de659[_0x28ccfe](_0xdb1a('0x2e'));_0x3a860d[_0xdb1a('0x32')](_0x5a67c4[_0xdb1a('0x3b')]({'attributes':['id',_0xdb1a('0x5')]}));_0x3a860d[_0xdb1a('0x32')](_0x5a67c4[_0xdb1a('0x3c')]({'attributes':['id',_0xdb1a('0x5')]}));_0x3a860d['push'](_0x5a67c4['getFaxQueues']({'attributes':['id','name']}));_0x3a860d[_0xdb1a('0x32')](_0x5a67c4[_0xdb1a('0x3d')]({'attributes':['id','name']}));_0x3a860d[_0xdb1a('0x32')](_0x5a67c4[_0xdb1a('0x3e')]({'attributes':['id','name']}));_0x3a860d['push'](_0x5a67c4[_0xdb1a('0x3f')]({'attributes':['id',_0xdb1a('0x5')]}));_0x3a860d['push'](_0x5a67c4[_0xdb1a('0x40')]({'attributes':['id',_0xdb1a('0x5')]}));break;}return BPromise[_0xdb1a('0x41')](_0x3a860d);}})['then'](function(_0x1e1e04){if(_0x1e1e04&&_0x1e1e04[_0xdb1a('0x1e')]){for(var _0x3fe575=0x0;_0x3fe575<_0x1e1e04[_0xdb1a('0x1e')];_0x3fe575+=0x1){for(var _0x57f3f7=0x0;_0x57f3f7<_0x1e1e04[_0x3fe575][_0xdb1a('0x1e')];_0x57f3f7+=0x1){switch(_0x3fe575){case 0x0:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x42'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x1:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x43'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x2:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x44'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x3:joinOrLeaveQueues(_0x4de659,_0x28ccfe,'sms',_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x4:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x45'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x5:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x46'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x6:joinOrLeaveQueues(_0x4de659,_0x28ccfe,_0xdb1a('0x47'),_0x1e1e04[_0x3fe575][_0x57f3f7]);break;case 0x7:if(_0x3d07fc[_0xdb1a('0x7')]!==_0xdb1a('0x8'))_0x4de659[_0x28ccfe](util[_0xdb1a('0x1b')](_0xdb1a('0x48'),_0x1e1e04[_0x3fe575][_0x57f3f7][_0xdb1a('0x5')]));break;case 0x8:if(_0x3d07fc[_0xdb1a('0x7')]!==_0xdb1a('0x8'))_0x4de659[_0x28ccfe](util['format']('trunk:%s',_0x1e1e04[_0x3fe575][_0x57f3f7]['name']));break;case 0x9:if(_0x3d07fc[_0xdb1a('0x7')]!==_0xdb1a('0x8'))_0x4de659[_0x28ccfe](util[_0xdb1a('0x1b')](_0xdb1a('0x49'),_0x1e1e04[_0x3fe575][_0x57f3f7][_0xdb1a('0xa')],_0x1e1e04[_0x3fe575][_0x57f3f7][_0xdb1a('0x5')]));break;case 0xa:_0x4de659[_0x28ccfe](util[_0xdb1a('0x1b')]('user:%s',_0x1e1e04[_0x3fe575][_0x57f3f7]['name']));break;}}}}})['then'](function(){if(_0x28ccfe==='leave'){var _0xfa239=_[_0xdb1a('0x4a')](_0x3d07fc['ChatInteractions'],'id');return _0x3d07fc['removeChatInteractions'](_0xfa239)['then'](function(){for(var _0xe13eb0=0x0;_0xe13eb0<_0xfa239[_0xdb1a('0x1e')];_0xe13eb0+=0x1){_0x2cc1aa[_0xdb1a('0x4b')](_0xdb1a('0x4c'),{'ChatInteractionId':Number(_0xfa239[_0xe13eb0]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0xd')](function(){if(_0x28ccfe===_0xdb1a('0x4d')){var _0x4adb49=_[_0xdb1a('0x4a')](_0x3d07fc[_0xdb1a('0x4e')],'id');return _0x3d07fc[_0xdb1a('0x4f')](_0x4adb49)[_0xdb1a('0xd')](function(){for(var _0x314ed2=0x0;_0x314ed2<_0x4adb49[_0xdb1a('0x1e')];_0x314ed2+=0x1){_0x2cc1aa[_0xdb1a('0x4b')](_0xdb1a('0x50'),{'MailInteractionId':Number(_0x4adb49[_0x314ed2]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0xd')](function(){if(_0x28ccfe==='leave'){var _0x2d09fc=_[_0xdb1a('0x4a')](_0x3d07fc[_0xdb1a('0x27')],'id');return _0x3d07fc['removeFaxInteractions'](_0x2d09fc)[_0xdb1a('0xd')](function(){for(var _0x388781=0x0;_0x388781<_0x2d09fc[_0xdb1a('0x1e')];_0x388781+=0x1){_0x2cc1aa[_0xdb1a('0x4b')](_0xdb1a('0x51'),{'FaxInteractionId':Number(_0x2d09fc[_0x388781]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0xd')](function(){if(_0x28ccfe===_0xdb1a('0x4d')){var _0x588f84=_[_0xdb1a('0x4a')](_0x3d07fc['SmsInteractions'],'id');return _0x3d07fc[_0xdb1a('0x52')](_0x588f84)['then'](function(){for(var _0xff852a=0x0;_0xff852a<_0x588f84['length'];_0xff852a+=0x1){_0x2cc1aa[_0xdb1a('0x4b')]('user_has_sms_interactions:remove',{'SmsInteractionId':Number(_0x588f84[_0xff852a]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0xd')](function(){if(_0x28ccfe===_0xdb1a('0x4d')){var _0x2305c2=_[_0xdb1a('0x4a')](_0x3d07fc[_0xdb1a('0x2b')],'id');return _0x3d07fc[_0xdb1a('0x53')](_0x2305c2)[_0xdb1a('0xd')](function(){for(var _0x3620e1=0x0;_0x3620e1<_0x2305c2[_0xdb1a('0x1e')];_0x3620e1+=0x1){_0x2cc1aa['emit'](_0xdb1a('0x54'),{'OpenchannelInteractionId':Number(_0x2305c2[_0x3620e1]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0xd')](function(){if(_0x28ccfe===_0xdb1a('0x4d')){var _0x43d3a2=_[_0xdb1a('0x4a')](_0x3d07fc[_0xdb1a('0x2c')],'id');return _0x3d07fc[_0xdb1a('0x55')](_0x43d3a2)[_0xdb1a('0xd')](function(){for(var _0x5a6556=0x0;_0x5a6556<_0x43d3a2[_0xdb1a('0x1e')];_0x5a6556+=0x1){_0x2cc1aa[_0xdb1a('0x4b')](_0xdb1a('0x56'),{'WhatsappInteractionId':Number(_0x43d3a2[_0x5a6556]),'UserId':Number(_0x3d07fc['id'])});}});}})[_0xdb1a('0x57')](function(_0x54b0ea){_0x4de659['log'](_0x54b0ea);});}}function onDisconnect(_0x39ac9a,_0x2b0616){joinOrLeave(_0x39ac9a,_0xdb1a('0x4d'),_0x2b0616);}function onConnect(_0x47d76e){joinOrLeave(_0x47d76e,_0xdb1a('0x58'));}exports[_0xdb1a('0x59')]=function(_0x429bc4){_0x429bc4['on']('connection',function(_0xa0aac4){_0xa0aac4['setMaxListeners'](0x0);_0xa0aac4['address']=_0xa0aac4[_0xdb1a('0x5a')][_0xdb1a('0x5b')][_0xdb1a('0x5c')]+':'+_0xa0aac4[_0xdb1a('0x5a')][_0xdb1a('0x5b')][_0xdb1a('0x5d')];_0xa0aac4[_0xdb1a('0x5e')]=new Date();_0xa0aac4[_0xdb1a('0x5f')]=function(_0x3f620b){console[_0xdb1a('0x5f')](_0xdb1a('0x60')+_0xa0aac4[_0xdb1a('0x61')]['name']+'['+_0xa0aac4[_0xdb1a('0x62')]+']',_0x3f620b);};_0xa0aac4['on']('disconnect',function(){onDisconnect(_0xa0aac4,_0x429bc4);_0xa0aac4[_0xdb1a('0x5f')]('DISCONNECTED');});onConnect(_0xa0aac4);_0xa0aac4[_0xdb1a('0x5f')](_0xdb1a('0x63'));});}; \ No newline at end of file diff --git a/server/config/triggers/index.js b/server/config/triggers/index.js new file mode 100644 index 0000000..a08cb27 --- /dev/null +++ b/server/config/triggers/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3160=['code','catch','get','channel','motionChannel','event','direction','ContactId','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','query','Sequelize','QueryTypes','SELECT','contact','UserId','undefined','interface','format','agent','incomingmessage','outgoingmessage','AfterCreateMessage','offlineMessage','opened','resolve','sequelize','SIP/%s','name','AfterCreate','changed','closed','substatus','User','find','fullname','email','default','hasOwnProperty','model','hook','callback','toLowerCase','condition','util','../../mysqldb','triggers','client','http','Chat','ChatInteraction','afterCreate','newinteraction','afterUpdate','ChatMessage','newmessage','SmsInteraction','Sms','SmsMessage','Whatsapp','WhatsappInteraction','closedinteraction','WhatsappMessage','Fax','FaxMessage','Mail','MailInteraction','MailMessage','Openchannel','OpenchannelInteraction','then','info','Trigger,\x20%s','EventManager','error'];(function(_0x1d1779,_0x284147){var _0x2377e9=function(_0x299f6f){while(--_0x299f6f){_0x1d1779['push'](_0x1d1779['shift']());}};_0x2377e9(++_0x284147);}(_0x3160,0x109));var _0x0316=function(_0xddb0dd,_0x37f9b7){_0xddb0dd=_0xddb0dd-0x0;var _0x38150b=_0x3160[_0xddb0dd];return _0x38150b;};'use strict';var util=require(_0x0316('0x0'));var db=require(_0x0316('0x1'))['db'];var jayson=require('jayson/promise');var logger=require('../logger')(_0x0316('0x2'));var client=jayson[_0x0316('0x3')][_0x0316('0x4')]({'port':0x232a});var triggers=[{'channel':_0x0316('0x5'),'model':_0x0316('0x6'),'event':_0x0316('0x7'),'condition':_0x0316('0x8'),'callback':afterCreate},{'channel':'Chat','model':_0x0316('0x6'),'event':_0x0316('0x9'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0x0316('0x5'),'model':_0x0316('0xa'),'event':'afterCreate','condition':_0x0316('0xb'),'callback':afterCreateMessage},{'channel':_0x0316('0x5'),'model':'ChatOfflineMessage','event':'afterCreate','condition':_0x0316('0xb'),'callback':afterCreateOfflineMessage},{'channel':'Sms','model':_0x0316('0xc'),'event':_0x0316('0x7'),'condition':_0x0316('0x8'),'callback':afterCreate},{'channel':_0x0316('0xd'),'model':_0x0316('0xc'),'event':_0x0316('0x9'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0x0316('0xd'),'model':_0x0316('0xe'),'event':_0x0316('0x7'),'condition':_0x0316('0xb'),'callback':afterCreateMessage},{'channel':_0x0316('0xf'),'model':_0x0316('0x10'),'event':_0x0316('0x7'),'condition':_0x0316('0x8'),'callback':afterCreate},{'channel':_0x0316('0xf'),'model':_0x0316('0x10'),'event':'afterUpdate','condition':_0x0316('0x11'),'callback':afterUpdate},{'channel':'Whatsapp','model':_0x0316('0x12'),'event':_0x0316('0x7'),'condition':_0x0316('0xb'),'callback':afterCreateMessage},{'channel':_0x0316('0x13'),'model':'FaxInteraction','event':_0x0316('0x7'),'condition':'newinteraction','callback':afterCreate},{'channel':_0x0316('0x13'),'model':'FaxInteraction','event':_0x0316('0x9'),'condition':_0x0316('0x11'),'callback':afterUpdate},{'channel':_0x0316('0x13'),'model':_0x0316('0x14'),'event':_0x0316('0x7'),'condition':_0x0316('0xb'),'callback':afterCreateMessage},{'channel':_0x0316('0x15'),'model':_0x0316('0x16'),'event':'afterCreate','condition':_0x0316('0x8'),'callback':afterCreate},{'channel':_0x0316('0x15'),'model':_0x0316('0x16'),'event':_0x0316('0x9'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0x0316('0x15'),'model':_0x0316('0x17'),'event':'afterCreate','condition':_0x0316('0xb'),'callback':afterCreateMessage},{'channel':_0x0316('0x18'),'model':_0x0316('0x19'),'event':_0x0316('0x7'),'condition':'newinteraction','callback':afterCreate},{'channel':_0x0316('0x18'),'model':_0x0316('0x19'),'event':_0x0316('0x9'),'condition':'closedinteraction','callback':afterUpdate},{'channel':_0x0316('0x18'),'model':'OpenchannelMessage','event':_0x0316('0x7'),'condition':_0x0316('0xb'),'callback':afterCreateMessage}];function request(_0x43354c){return client['request']('EventManager',_0x43354c)[_0x0316('0x1a')](function(_0x261382){logger[_0x0316('0x1b')](_0x0316('0x1c'),_0x0316('0x1d'),_0x261382);if(_0x261382[_0x0316('0x1e')]){if(_0x261382[_0x0316('0x1e')][_0x0316('0x1f')]===0x1f4){logger['error'](_0x0316('0x1c'),_0x0316('0x1d'),_0x261382[_0x0316('0x1e')]);}}})[_0x0316('0x20')](function(_0x5b7f4d){logger['error'](_0x0316('0x1c'),'EventManager',_0x5b7f4d);});}function afterCreateMessage(_0x27cc5c){return function(_0x2664ee){_0x2664ee=_0x2664ee[_0x0316('0x21')]({'plain':!![]});_0x2664ee[_0x0316('0x22')]=_0x27cc5c;_0x2664ee[_0x0316('0x23')]=_0x27cc5c;_0x2664ee[_0x0316('0x24')]=_0x2664ee[_0x0316('0x25')];Promise['resolve']()[_0x0316('0x1a')](function(){if(typeof _0x2664ee[_0x0316('0x26')]==='undefined')return null;var _0x1cfa2d=_0x0316('0x27')+_0x2664ee['ContactId'];return db['sequelize'][_0x0316('0x28')](_0x1cfa2d,{'type':db[_0x0316('0x29')][_0x0316('0x2a')][_0x0316('0x2b')],'raw':!![]});})[_0x0316('0x1a')](function(_0x42be7a){if(_0x42be7a){_0x2664ee[_0x0316('0x2c')]=_0x42be7a[0x0];}if(typeof _0x2664ee[_0x0316('0x2d')]===_0x0316('0x2e'))return;return getAgent(_0x2664ee[_0x0316('0x2d')]);})[_0x0316('0x1a')](function(_0x4ee125){if(_0x4ee125){_0x2664ee[_0x0316('0x2f')]=util[_0x0316('0x30')]('SIP/%s',_0x4ee125['name']);_0x2664ee[_0x0316('0x31')]=_0x4ee125;_0x2664ee[_0x0316('0x22')]=_0x27cc5c;return request({'event':_0x0316('0x32'),'message':_0x2664ee});}else{return request({'event':_0x0316('0x33'),'message':_0x2664ee});}})['catch'](function(_0x3dafba){logger[_0x0316('0x1e')](_0x0316('0x1c'),_0x0316('0x34'),_0x3dafba);});};}function afterCreateOfflineMessage(_0x4c2f7b){return function(_0x5b2c74){_0x5b2c74=_0x5b2c74['get']({'plain':!![]});_0x5b2c74['channel']=_0x4c2f7b;_0x5b2c74[_0x0316('0x23')]=_0x4c2f7b;_0x5b2c74['event']=_0x0316('0x35');return request({'event':_0x5b2c74['event'],'message':_0x5b2c74});};}function afterCreate(_0x424595,_0x51ce9a){return function(_0x57e330){_0x57e330=_0x57e330[_0x0316('0x21')]({'plain':!![]});_0x57e330['channel']=_0x424595;_0x57e330[_0x0316('0x23')]=_0x424595;_0x57e330[_0x0316('0x24')]=_0x0316('0x36');Promise[_0x0316('0x37')]()[_0x0316('0x1a')](function(){var _0x29462a=_0x0316('0x27')+_0x57e330[_0x0316('0x26')];return db[_0x0316('0x38')][_0x0316('0x28')](_0x29462a,{'type':db['Sequelize'][_0x0316('0x2a')]['SELECT'],'raw':!![]});})[_0x0316('0x1a')](function(_0x15aa7f){if(_0x15aa7f){_0x57e330['contact']=_0x15aa7f[0x0];}if(typeof _0x57e330[_0x0316('0x2d')]===_0x0316('0x2e'))return;return getAgent(_0x57e330[_0x0316('0x2d')]);})[_0x0316('0x1a')](function(_0x4e80f2){if(_0x4e80f2){_0x57e330['interface']=util[_0x0316('0x30')](_0x0316('0x39'),_0x4e80f2[_0x0316('0x3a')]);_0x57e330[_0x0316('0x31')]=_0x4e80f2;}return request({'event':_0x51ce9a,'message':_0x57e330});})[_0x0316('0x20')](function(_0x323cfe){logger[_0x0316('0x1e')](_0x0316('0x1c'),_0x0316('0x3b'),_0x323cfe);});};}function afterUpdate(_0xcb692d){return function(_0x1a22fc){var _0x42fac9=_0x1a22fc[_0x0316('0x3c')](_0x0316('0x3d'))&&_0x1a22fc[_0x0316('0x3d')];var _0x4e1f29=_0x1a22fc['changed']('substatus');if(_0x42fac9||_0x4e1f29){var _0xf1d888=_0x42fac9?_0x0316('0x11'):_0x0316('0x3e');var _0x5a3685=_0x1a22fc[_0x0316('0x21')]({'plain':!![]});_0x5a3685[_0x0316('0x22')]=_0xcb692d;_0x5a3685[_0x0316('0x23')]=_0xcb692d;_0x5a3685['event']=_0x42fac9?'closed':_0x0316('0x3e');var _0x4f4a82='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x5a3685['ContactId'];return db['sequelize']['query'](_0x4f4a82,{'type':db[_0x0316('0x29')][_0x0316('0x2a')][_0x0316('0x2b')],'raw':!![]})[_0x0316('0x1a')](function(_0x5829ad){if(_0x5829ad){_0x5a3685[_0x0316('0x2c')]=_0x5829ad[0x0];}if(typeof _0x5a3685[_0x0316('0x2d')]==='undefined')return;return getAgent(_0x5a3685[_0x0316('0x2d')]);})[_0x0316('0x1a')](function(_0x198360){if(_0x198360){_0x5a3685[_0x0316('0x2f')]=util[_0x0316('0x30')]('SIP/%s',_0x198360[_0x0316('0x3a')]);_0x5a3685[_0x0316('0x31')]=_0x198360;}return request({'event':_0xf1d888,'message':_0x5a3685});})[_0x0316('0x20')](function(_0x1603f2){logger['error'](_0x0316('0x1c'),'AfterUpdate',_0x1603f2);});}};}function getAgent(_0x3285b4){return db[_0x0316('0x3f')][_0x0316('0x40')]({'where':{'id':_0x3285b4},'attributes':['id','name',_0x0316('0x41'),_0x0316('0x42'),'internal'],'raw':!![]})['then'](function(_0x1ccdf1){return _0x1ccdf1;});}exports[_0x0316('0x43')]=function(){for(var _0x907e7=0x0;_0x907e7=_0x39d8c6[_0xde0d('0x16')]){throw Error(_0xde0d('0x17'));}_0x33f3f7(_0x165271);})[_0xde0d('0x18')](function(_0xe0c00e){_0x41da9c(_0xe0c00e);});});}; \ No newline at end of file diff --git a/server/errors/api.js b/server/errors/api.js new file mode 100644 index 0000000..1cd471e --- /dev/null +++ b/server/errors/api.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xac4a=['Bad\x20Request','Not\x20Found','OutOfInterval','error','name','send','exports','util','../config/logger','api','message','Error','inherits'];(function(_0x38ab90,_0x17ea77){var _0xff571f=function(_0x4f0990){while(--_0x4f0990){_0x38ab90['push'](_0x38ab90['shift']());}};_0xff571f(++_0x17ea77);}(_0xac4a,0x13f));var _0xaac4=function(_0x3e18c7,_0x5734fe){_0x3e18c7=_0x3e18c7-0x0;var _0x229d91=_0xac4a[_0x3e18c7];return _0x229d91;};'use strict';var util=require(_0xaac4('0x0'));var logger=require(_0xaac4('0x1'))(_0xaac4('0x2'));var APIError=function(_0x132fc3,_0x38f4f4){this[_0xaac4('0x3')]=_0x132fc3||'Internal\x20Server\x20Error';this['name']=_0x38f4f4||_0xaac4('0x4');util[_0xaac4('0x5')](APIError,Error);};var APIBadRequestError=function(_0x32d34c){this['message']=_0x32d34c||_0xaac4('0x6');this['name']=_0xaac4('0x6');util['inherits'](APIBadRequestError,APIError);};var APINotFoundError=function(_0x1e4283){this[_0xaac4('0x3')]=_0x1e4283||'Entity\x20not\x20found';this['name']=_0xaac4('0x7');util['inherits'](APINotFoundError,APIError);};function getStatusCode(_0x452573){switch(_0x452573){case'Bad\x20Request':return 0x190;case'Forbidden',_0xaac4('0x8'):return 0x193;case _0xaac4('0x7'):return 0x194;default:return 0x1f4;}}function handleError(_0x38d1d0){return function(_0x5f393e){logger[_0xaac4('0x9')](_0x5f393e['stack']);var _0x508e14=getStatusCode(_0x5f393e[_0xaac4('0xa')]);if(_0x5f393e[_0xaac4('0xa')])delete _0x5f393e[_0xaac4('0xa')];return _0x38d1d0['status'](_0x508e14)[_0xaac4('0xb')](_0x5f393e);};}module[_0xaac4('0xc')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError}; \ No newline at end of file diff --git a/server/errors/index.js b/server/errors/index.js new file mode 100644 index 0000000..cbae4d6 --- /dev/null +++ b/server/errors/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x13e6=['status','render','send','exports'];(function(_0x5ddb1c,_0x5ea4df){var _0x354adc=function(_0x2dfb1f){while(--_0x2dfb1f){_0x5ddb1c['push'](_0x5ddb1c['shift']());}};_0x354adc(++_0x5ea4df);}(_0x13e6,0x1a3));var _0x613e=function(_0x318d9f,_0x10b237){_0x318d9f=_0x318d9f-0x0;var _0x2b5422=_0x13e6[_0x318d9f];return _0x2b5422;};'use strict';module[_0x613e('0x0')][0x194]=function pageNotFound(_0x4d60b8,_0x41b5f2){var _0x20c52c='404';var _0x495a3d=0x194;var _0x460f25={'status':_0x495a3d};_0x41b5f2[_0x613e('0x1')](_0x460f25[_0x613e('0x1')]);_0x41b5f2[_0x613e('0x2')](_0x20c52c,{},function(_0x515ca2,_0x9367ef){if(_0x515ca2){return _0x41b5f2[_0x613e('0x1')](_0x460f25['status'])['json'](_0x460f25);}_0x41b5f2[_0x613e('0x3')](_0x9367ef);});}; \ No newline at end of file diff --git a/server/files/attachments/README.md b/server/files/attachments/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/chat/iframe.ejs b/server/files/chat/iframe.ejs new file mode 100644 index 0000000..220645c --- /dev/null +++ b/server/files/chat/iframe.ejs @@ -0,0 +1,390 @@ +(function() { + 'use strict'; + const chatWebsiteAddressOrigin = '{{{chatWebsiteAddressOrigin}}}' + if(chatWebsiteAddressOrigin !== window.location.origin){ + alert(`The current location does not match ${chatWebsiteAddressOrigin}. Please check your website domain in the current XCALLY Chat Website settings.`) + } + else + { + // Init all URLs + const remoteURL = new URL('{{{remote}}}') + const chatOrigin = remoteURL.origin + const chatPath = '/snippet/' + const chatStylesPath = chatPath + 'styles/' + const chatVersion = '{{{chatVersion}}}' + + // Style setttings + const divColor = '<%=div_color%>' + const textColor = '<%=text_color%>' + const buttonColor = '<%=button_color%>' + const backgroungColor = '<%=background_color%>' + let alignment = "<%=alignment%>"; + let verticalAlignment = "<%=verticalAlignment%>"; + + // iframe URL settings + const iframeId = 'motion-chat-iframe' + const iframeSrcURL = new URL(chatPath, chatOrigin) + const iframeSearchParams = new URLSearchParams('{{{query}}}') + iframeSearchParams.append('version', chatVersion) + iframeSearchParams.append('location', btoa(window.location.host)) + iframeSrcURL.search = iframeSearchParams + + // Style URL settings + const linkURL = new URL(chatStylesPath + 'mobile.css', chatOrigin) + linkURL.search = new URLSearchParams({ version: chatVersion }) + const linkMobile = document.createElement('link'); + linkMobile.type = "text/css"; + linkMobile.rel='stylesheet'; + linkMobile.href = linkURL.toString() + + // Iframe localstorage whitelisting + const allowedOrigins = [chatOrigin] + + function remoteLocalStorageEventHandler(event){ + if (allowedOrigins.includes(event.origin)) { + const { action, key, value } = event.data + const localStorage = window.localStorage + switch(action){ + case 'setItem': + { + localStorage.setItem(key, JSON.stringify(value)) + event.source.postMessage( + { + action: 'setItemResult', + key + }, event.origin) + } + break + case 'getItem': + { + let item = localStorage.getItem(key) + if(item){ + try { + item = JSON.parse(item) + } catch (error) { + console.error('Cannot read data from localstorage', error) + } + } + event.source.postMessage( + { + action: 'getItemResult', + key, + item + }, event.origin) + } + break + case 'removeItem': + { + localStorage.removeItem(key) + event.source.postMessage( + { + action: 'removeItemResult', + key + }, event.origin) + } + break + default: + typeof action === 'string' && console.debug('Unsupported action', action) + break; + } + } + } + + // DOM Manipulation + let iframe = document.createElement('iframe'); + // Attributes + iframe['id'] = iframeId; + iframe['src'] = iframeSrcURL.toString() + + let iframe_status = false; + + document.documentElement.style.setProperty('--xc-ws-div-color', divColor); + document.documentElement.style.setProperty('--xc-ws-text-color', textColor); + document.documentElement.style.setProperty('--xc-ws-button-color', buttonColor); + document.documentElement.style.setProperty('--xc-ws-background-color', backgroungColor); + + document.head.appendChild(linkMobile); + + <% if (alignment == 'bottom_right') { -%> // Bottom, right + iframe.className = 'motion-chat-iframe-bottom_right'; + verticalAlignment = 0; + document.body.appendChild(iframe); + + <% } else if (alignment == 'right') { -%> // Right + iframe.className = 'motion-chat-iframe-right'; + iframe.style['top'] = verticalAlignment+'%'; + let iframe_h = topIframe_calc(); + topIframe_set(iframe_h); + let div_tab = document.createElement('div'); + div_tab['id'] = 'motion-chat-iframe-tab'; + div_tab.className = 'motion-chat-div-right'; + let tab_status=0; + + <% } else if (alignment == 'left') { -%> // Left + iframe.className = 'motion-chat-iframe-left'; + iframe.style['top'] = verticalAlignment+'%'; + let iframe_h = topIframe_calc(); + topIframe_set(iframe_h); + let div_tab = document.createElement('div'); + div_tab.className = 'motion-chat-div-left'; + div_tab['id'] ='motion-chat-iframe-tab'; + let tab_status=0; + + <% } -%> + + <% if (alignment == 'right') { -%> // Right + topChat_set(iframe_h, verticalAlignment); + document.body.appendChild(div_tab); + let html = '
<
<%=labelText%>'; + div_tab.innerHTML = html; + + div_tab.style.backgroundColor = divColor; + document.getElementById("chat_tab_text").style.color = textColor; + document.getElementById("chat_tab_arrow").style.color = divColor + document.getElementById("chat_tab_arrow").style.backgroundColor = textColor; + document.getElementById("motion-chat-iframe-tab").style.display = "flex"; + + function appendLink(){ + if(iframe_status == false){ + document.body.appendChild(iframe); + iframe_status=true; + } + } + + function expandChatRight(){ + appendLink() + div_tab.style.right = '295px'; + iframe.style.right = '0px'; + document.getElementById("chat_tab_arrow").innerHTML = " > "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"show"}, '*'); + } + + function collapseChatRight(){ + appendLink() + div_tab.style.right = '0px'; + iframe.style.right = '-312px'; + document.getElementById("chat_tab_arrow").innerHTML = " < "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"hide"}, '*'); + } + + function toggleChatExpandedRight(){ + if(tab_status % 2 === 0) { + expandChatRight() + } + else { + collapseChatRight() + } + tab_status++; + } + + document.getElementById("motion-chat-iframe-tab").addEventListener("click", toggleChatExpandedRight); + <% } else if (alignment == 'left') { -%> + topChat_set(iframe_h, verticalAlignment); + document.body.appendChild(div_tab); + let html='
>
<%=labelText%>'; + div_tab.innerHTML=html; + + div_tab.style.backgroundColor = divColor; + document.getElementById("chat_tab_text").style.color = textColor; + document.getElementById("chat_tab_arrow").style.color = divColor; + document.getElementById("chat_tab_arrow").style.backgroundColor = textColor; + document.getElementById("motion-chat-iframe-tab").style.display="flex"; + + function appendLink(){ + if(iframe_status == false){ + document.body.appendChild(iframe); + iframe_status=true; + } + } + + function expandChatLeft(){ + appendLink() + div_tab.style.left = '295px'; + iframe.style.left = '0px'; + document.getElementById("chat_tab_arrow").innerHTML = " < "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"show"}, '*'); + } + + function collapseChatLeft(){ + appendLink() + div_tab.style.left = '0px'; + iframe.style.left = '-312px'; + document.getElementById("chat_tab_arrow").innerHTML = " > "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"hide"}, '*'); + } + + function toggleChatExpandedLeft(){ + if(tab_status % 2 === 0) { + expandChatLeft() + } + else { + collapseChatLeft() + } + tab_status++; + } + + document.getElementById("motion-chat-iframe-tab").addEventListener("click", toggleChatExpandedLeft); + + <% } -%> + + // START Events management + window.addEventListener('message', function(evt) { + remoteLocalStorageEventHandler(evt) + switch (evt.data.cmd) { + case 'show': + <% if (alignment == 'bottom_right') { -%> // Bottom, right + iframe.style.top = 'auto'; + iframe.style.bottom = '0px'; + <% } else if (alignment == 'right') { -%> // Right + iframe.style.right = '0px'; + div_tab.style.right = '295px'; + <% } else if (alignment == 'left') { -%> // Left + iframe.style.left = '0px'; + div_tab.style.left = '295px'; + // Left + <% } -%> break; + case 'hide': + <% if (alignment == 'bottom_right') { -%> // Bottom, right + iframe.style.top = 'calc(100% - 50px)'; + <% } else if (alignment == 'right') { -%> // Right + iframe.style.right = '-312px'; + div_tab.style['right'] = '0px'; + <% } else if (alignment == 'left') { -%> // Left + iframe.style.left = '-312px'; + div_tab.style.left = '0px'; + <% } -%> break; + case "init": + <% if (alignment == 'right' || alignment == 'left') { -%> // Bottom, right + div_tab.style.backgroundColor = textColor; + document.getElementById("chat_tab_text").style.color = textColor; + document.getElementById("chat_tab_arrow").style.color = textColor; + document.getElementById("chat_tab_arrow").style.backgroundColor = textColor; + document.getElementById("motion-chat-iframe-tab").style.display = "flex"; + <% } -%> break; + case "offline": + <% if (alignment == 'right' || alignment == 'left') { -%> // Bottom, right + document.getElementById("motion-chat-iframe-tab").style.display = "none"; + <% } -%> break; + default: + } + + }, false); + // END Events management + + // START Proactive action management + <% proactiveActions.forEach(function(action, index) { -%> + <% if (action.type == 'timeout') { -%> + setTimeout(function() { + <% if (alignment == 'right') { -%> + expandChatRight(); + tab_status++; + <% } else if (alignment == 'left') { -%> + expandChatLeft(); + tab_status++; + <% } else { -%> + iframe.style.bottom = '0px'; + iframe.contentWindow?.postMessage({ + evt: 'show' + }, '*'); + <% } -%> + }, <%- action.timeout %> * 1000); + <% } -%> + <% if (action.type == 'mouseOver') { -%> + let elements<%- index %> = document.querySelectorAll("<%- action.selector %>"); + for (let i = 0; i < elements<%- index %>.length; i++) { + elements<%- index %>[i].onmouseover = function() { + <% if (alignment == 'right') { -%> + expandChatRight(); + tab_status++; + <% } else if (alignment == 'left') { -%> + expandChatLeft(); + tab_status++; + <% } else { -%> + iframe.style.bottom = '0px'; + iframe.contentWindow?.postMessage({ + evt: 'show' + }, '*'); + <% } -%> + } + } + <% } -%> <% }); -%> + // END Proactive action management + + + if (window.DeviceOrientationEvent) { + window.addEventListener('orientationchange', function() { + if (alignment == 'right'){ + document.getElementById("chat_tab_arrow").innerHTML = " < "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"hide"}, '*'); + tab_status = 0; + iframe_h = topIframe_calc(); + topIframe_set(iframe_h); + if(typeof div_tab != "undefined") topChat_set(iframe_h, verticalAlignment); + } + else if (alignment == 'left'){ + document.getElementById("chat_tab_arrow").innerHTML = " > "; + let iframeEl = document.getElementById('motion-chat-iframe'); + iframeEl.contentWindow?.postMessage({"evt":"hide"}, '*'); + tab_status = 0; + iframe_h = topIframe_calc(); + topIframe_set(iframe_h); + if(typeof div_tab != "undefined") topChat_set(iframe_h, verticalAlignment); + } }, false); + } + + window.addEventListener("resize", function(event) { + let iframe_h = topIframe_calc(); + topIframe_set(iframe_h); + if(typeof div_tab != "undefined") topChat_set(iframe_h, verticalAlignment); + }); + + function topIframe_calc(){ + let height_iframe + let heightD = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); + let iframeT = ((heightD/100)*verticalAlignment) + 450; + if (heightD < iframeT) { + height_iframe = 450 - (iframeT - heightD); + } + else { height_iframe = 450; } + return height_iframe; + } + + function topIframe_set(height_iframe){ + if( height_iframe > 340){ + iframe.style['height'] = height_iframe +'px'; + if (alignment == "right" || alignment == "left" ) + { iframe.style['top'] = verticalAlignment + "%"; } + else{ iframe.style['bottom'] = "0%"; } + + } + else { + iframe.style['height'] = '340px'; + if (alignment == "right" || alignment == "left" ) + { iframe.style['top'] = "calc(100% - 340px)"; } + else{ iframe.style['bottom'] = "0%"; } + + } + } + + function topChat_set(height_iframe, verticalAlignment){ + + if( height_iframe > 340){ + div_tab.style['top'] = "calc("+ verticalAlignment +"% + " + (height_iframe - 100) + "px)"; + } + else { + div_tab.style['top'] = "auto"; + div_tab.style['bottom'] = "0px"; + } + } + + // hide chat + <% if (hideWhenOffline && intervalId != null) { -%> // hide template + document.getElementById("motion-chat-iframe-tab").style.display = "none"; + <% } -%> + } +}()); \ No newline at end of file diff --git a/server/files/chat/upload/README.md b/server/files/chat/upload/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/conf/README.md b/server/files/conf/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/images/README.md b/server/files/images/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/images/avatars/README.md b/server/files/images/avatars/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/images/avatars/customer_avatar.png b/server/files/images/avatars/customer_avatar.png new file mode 100644 index 0000000..a83b87c Binary files /dev/null and b/server/files/images/avatars/customer_avatar.png differ diff --git a/server/files/images/avatars/default_avatar.png b/server/files/images/avatars/default_avatar.png new file mode 100644 index 0000000..1a4c242 Binary files /dev/null and b/server/files/images/avatars/default_avatar.png differ diff --git a/server/files/images/avatars/system_avatar.png b/server/files/images/avatars/system_avatar.png new file mode 100644 index 0000000..98f057e Binary files /dev/null and b/server/files/images/avatars/system_avatar.png differ diff --git a/server/files/images/logos/README.md b/server/files/images/logos/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/images/logos/default_favicon.ico b/server/files/images/logos/default_favicon.ico new file mode 100644 index 0000000..e596f84 Binary files /dev/null and b/server/files/images/logos/default_favicon.ico differ diff --git a/server/files/images/logos/default_loginlogo.svg b/server/files/images/logos/default_loginlogo.svg new file mode 100644 index 0000000..60b1eb2 --- /dev/null +++ b/server/files/images/logos/default_loginlogo.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/files/images/logos/default_logo.svg b/server/files/images/logos/default_logo.svg new file mode 100644 index 0000000..31574d0 --- /dev/null +++ b/server/files/images/logos/default_logo.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + diff --git a/server/files/images/logos/default_preferred.png b/server/files/images/logos/default_preferred.png new file mode 100644 index 0000000..80c9b33 Binary files /dev/null and b/server/files/images/logos/default_preferred.png differ diff --git a/server/files/images/logos/default_profile.png b/server/files/images/logos/default_profile.png new file mode 100644 index 0000000..9b96eee Binary files /dev/null and b/server/files/images/logos/default_profile.png differ diff --git a/server/files/moh/README.md b/server/files/moh/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/moh/noice/noice.wav b/server/files/moh/noice/noice.wav new file mode 100644 index 0000000..c38ad4e Binary files /dev/null and b/server/files/moh/noice/noice.wav differ diff --git a/server/files/moh/wait/wait.wav b/server/files/moh/wait/wait.wav new file mode 100644 index 0000000..07c6f87 Binary files /dev/null and b/server/files/moh/wait/wait.wav differ diff --git a/server/files/plugins/README.md b/server/files/plugins/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/recordings/README.md b/server/files/recordings/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/reports/README.md b/server/files/reports/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/screen_recordings/README.md b/server/files/screen_recordings/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/sounds/README.md b/server/files/sounds/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/sounds/converted/README.md b/server/files/sounds/converted/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/sounds/converted/agentmanagement-action-failure.wav b/server/files/sounds/converted/agentmanagement-action-failure.wav new file mode 100644 index 0000000..aedcb88 Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-action-failure.wav differ diff --git a/server/files/sounds/converted/agentmanagement-login.wav b/server/files/sounds/converted/agentmanagement-login.wav new file mode 100644 index 0000000..d17b40d Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-login.wav differ diff --git a/server/files/sounds/converted/agentmanagement-logout.wav b/server/files/sounds/converted/agentmanagement-logout.wav new file mode 100644 index 0000000..2cf8c29 Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-logout.wav differ diff --git a/server/files/sounds/converted/agentmanagement-menu.wav b/server/files/sounds/converted/agentmanagement-menu.wav new file mode 100644 index 0000000..1f8f5be Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-menu.wav differ diff --git a/server/files/sounds/converted/agentmanagement-pause.wav b/server/files/sounds/converted/agentmanagement-pause.wav new file mode 100644 index 0000000..895fb65 Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-pause.wav differ diff --git a/server/files/sounds/converted/agentmanagement-unpause.wav b/server/files/sounds/converted/agentmanagement-unpause.wav new file mode 100644 index 0000000..fa23193 Binary files /dev/null and b/server/files/sounds/converted/agentmanagement-unpause.wav differ diff --git a/server/files/sounds/converted/order-elaborated.wav b/server/files/sounds/converted/order-elaborated.wav new file mode 100644 index 0000000..f02a863 Binary files /dev/null and b/server/files/sounds/converted/order-elaborated.wav differ diff --git a/server/files/sounds/converted/order-number.wav b/server/files/sounds/converted/order-number.wav new file mode 100644 index 0000000..91a8290 Binary files /dev/null and b/server/files/sounds/converted/order-number.wav differ diff --git a/server/files/sounds/converted/order-shipped.wav b/server/files/sounds/converted/order-shipped.wav new file mode 100644 index 0000000..d88744d Binary files /dev/null and b/server/files/sounds/converted/order-shipped.wav differ diff --git a/server/files/sounds/converted/rate-call.wav b/server/files/sounds/converted/rate-call.wav new file mode 100644 index 0000000..5949011 Binary files /dev/null and b/server/files/sounds/converted/rate-call.wav differ diff --git a/server/files/sounds/converted/thanx.wav b/server/files/sounds/converted/thanx.wav new file mode 100644 index 0000000..68f91b6 Binary files /dev/null and b/server/files/sounds/converted/thanx.wav differ diff --git a/server/files/sounds/converted/welcome-acme.wav b/server/files/sounds/converted/welcome-acme.wav new file mode 100644 index 0000000..e5b8b9a Binary files /dev/null and b/server/files/sounds/converted/welcome-acme.wav differ diff --git a/server/files/sounds/original/README.md b/server/files/sounds/original/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/sounds/original/agentmanagement-action-failure.wav b/server/files/sounds/original/agentmanagement-action-failure.wav new file mode 100644 index 0000000..aedcb88 Binary files /dev/null and b/server/files/sounds/original/agentmanagement-action-failure.wav differ diff --git a/server/files/sounds/original/agentmanagement-login.mp3 b/server/files/sounds/original/agentmanagement-login.mp3 new file mode 100644 index 0000000..01a24b7 Binary files /dev/null and b/server/files/sounds/original/agentmanagement-login.mp3 differ diff --git a/server/files/sounds/original/agentmanagement-logout.mp3 b/server/files/sounds/original/agentmanagement-logout.mp3 new file mode 100644 index 0000000..41c7843 Binary files /dev/null and b/server/files/sounds/original/agentmanagement-logout.mp3 differ diff --git a/server/files/sounds/original/agentmanagement-menu.wav b/server/files/sounds/original/agentmanagement-menu.wav new file mode 100644 index 0000000..1f8f5be Binary files /dev/null and b/server/files/sounds/original/agentmanagement-menu.wav differ diff --git a/server/files/sounds/original/agentmanagement-pause.mp3 b/server/files/sounds/original/agentmanagement-pause.mp3 new file mode 100644 index 0000000..9a44123 Binary files /dev/null and b/server/files/sounds/original/agentmanagement-pause.mp3 differ diff --git a/server/files/sounds/original/agentmanagement-unpause.mp3 b/server/files/sounds/original/agentmanagement-unpause.mp3 new file mode 100644 index 0000000..99d03ed Binary files /dev/null and b/server/files/sounds/original/agentmanagement-unpause.mp3 differ diff --git a/server/files/sounds/original/order-elaborated.wav b/server/files/sounds/original/order-elaborated.wav new file mode 100644 index 0000000..f02a863 Binary files /dev/null and b/server/files/sounds/original/order-elaborated.wav differ diff --git a/server/files/sounds/original/order-number.wav b/server/files/sounds/original/order-number.wav new file mode 100644 index 0000000..91a8290 Binary files /dev/null and b/server/files/sounds/original/order-number.wav differ diff --git a/server/files/sounds/original/order-shipped.wav b/server/files/sounds/original/order-shipped.wav new file mode 100644 index 0000000..d88744d Binary files /dev/null and b/server/files/sounds/original/order-shipped.wav differ diff --git a/server/files/sounds/original/rate-call.wav b/server/files/sounds/original/rate-call.wav new file mode 100644 index 0000000..5949011 Binary files /dev/null and b/server/files/sounds/original/rate-call.wav differ diff --git a/server/files/sounds/original/thanx.wav b/server/files/sounds/original/thanx.wav new file mode 100644 index 0000000..68f91b6 Binary files /dev/null and b/server/files/sounds/original/thanx.wav differ diff --git a/server/files/sounds/original/welcome-acme.wav b/server/files/sounds/original/welcome-acme.wav new file mode 100644 index 0000000..e5b8b9a Binary files /dev/null and b/server/files/sounds/original/welcome-acme.wav differ diff --git a/server/files/templates/chatOfflineMessage.ejs b/server/files/templates/chatOfflineMessage.ejs new file mode 100644 index 0000000..80cbf5b --- /dev/null +++ b/server/files/templates/chatOfflineMessage.ejs @@ -0,0 +1,16 @@ + + + + + + +

+ <%- bodyTitle %> +

+ <% body.forEach(function(data) { -%> + + <%= data[0] %>: <%= data[1] %> +
+ <% }); -%> + + \ No newline at end of file diff --git a/server/files/templates/context.ejs b/server/files/templates/context.ejs new file mode 100644 index 0000000..c69d531 --- /dev/null +++ b/server/files/templates/context.ejs @@ -0,0 +1,5 @@ +<% contexts.forEach(function(context) { -%> +[<%- context.name %>] +include => <%- context.name %>-custom +switch => Realtime +<% }); %> diff --git a/server/files/templates/network.ejs b/server/files/templates/network.ejs new file mode 100644 index 0000000..a4bd2ce --- /dev/null +++ b/server/files/templates/network.ejs @@ -0,0 +1,3 @@ +<% networks.forEach(function(network) { -%> +<%- network.type.toLowerCase() %> = <%- network.value %> +<% }); %> diff --git a/server/files/templates/registry.ejs b/server/files/templates/registry.ejs new file mode 100644 index 0000000..33c1342 --- /dev/null +++ b/server/files/templates/registry.ejs @@ -0,0 +1,5 @@ +<% trunks.forEach(function(trunk) { -%> +<% if (trunk.active && trunk.registry) { -%> +register => <%- trunk.registry %> +<% } -%> +<% }); %> diff --git a/server/files/templates/stun_multiple.ejs b/server/files/templates/stun_multiple.ejs new file mode 100644 index 0000000..594a229 --- /dev/null +++ b/server/files/templates/stun_multiple.ejs @@ -0,0 +1,8 @@ +; STUN server list + +<% networks.forEach(function(network) { -%> +<% if (network.value) { -%> +stunaddr=<%- network.value %> +<% } -%> +;------------------------------------------- +<% }); %> diff --git a/server/files/templates/trunk.ejs b/server/files/templates/trunk.ejs new file mode 100644 index 0000000..337b56f --- /dev/null +++ b/server/files/templates/trunk.ejs @@ -0,0 +1,30 @@ +<% trunks.forEach(function(trunk) { -%> +<% if (trunk.active) { -%> +[<%- trunk.name %>] +<% for (var key in trunk) { -%> +<% if (trunk[key]) { -%> +<% switch(key) { +case 'allow': -%> +<% trunk[key].split(';').forEach(function(codec) { -%> +allow=<%- codec %> +<% }); -%> +<% break; -%> +<% case 'id': +case 'active': +case 'createdAt': +case 'updatedAt': +case 'registry': +case 'status': +case 'otherFields': +break; -%> +<% default: -%> +<%- key %>=<%- trunk[key] %> +<% } -%> +<% } -%> +<% } -%> +<% if (trunk.otherFields) { -%> +<%- trunk.otherFields %> +<% } -%> +<% } -%> + +<% }); %> diff --git a/server/files/templates/turn_multiple.ejs b/server/files/templates/turn_multiple.ejs new file mode 100644 index 0000000..67ef834 --- /dev/null +++ b/server/files/templates/turn_multiple.ejs @@ -0,0 +1,14 @@ +; TURN server list + +<% networks.forEach(function(network) { -%> +<% if (network.value) { -%> +turnaddr=<%- network.value %> +<% } -%> +<% if (network.username) { -%> +turnusername=<%- network.username %> +<% } -%> +<% if (network.password) { -%> +turnpassword=<%- network.password %> +<% } -%> +;------------------------------------------- +<% }); %> \ No newline at end of file diff --git a/server/files/tmp/README.md b/server/files/tmp/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/files/transcribes/README.md b/server/files/transcribes/README.md new file mode 100644 index 0000000..e69de29 diff --git a/server/migrations/2.0.12.js b/server/migrations/2.0.12.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.12.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.13.js b/server/migrations/2.0.13.js new file mode 100644 index 0000000..89b9a84 --- /dev/null +++ b/server/migrations/2.0.13.js @@ -0,0 +1,70 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + migration.addColumn('cm_hopper_final', 'deletedat', { + type: Sequelize.DATE + }); + migration.addColumn('users', 'phoneBarRingInUse', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('cm_hopper_final', 'deleted', { + type: Sequelize.STRING, + defaultValue: null + }); + migration.renameColumn('cm_hopper_final', 'reschedule', 'rescheduled'); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface, Sequelize); + migration.removeColumn('users', 'phoneBarRingInUse'); + migration.removeColumn('cm_hopper_final', 'deletedat'); + migration.removeColumn('cm_hopper_final', 'deleted'); + migration.renameColumn('cm_hopper_final', 'rescheduled', 'reschedule'); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.14.js b/server/migrations/2.0.14.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.14.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.15.js b/server/migrations/2.0.15.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.15.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.16.js b/server/migrations/2.0.16.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.16.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.17.js b/server/migrations/2.0.17.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.17.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.18.js b/server/migrations/2.0.18.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.18.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.19.js b/server/migrations/2.0.19.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.19.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.20.js b/server/migrations/2.0.20.js new file mode 100644 index 0000000..668a157 --- /dev/null +++ b/server/migrations/2.0.20.js @@ -0,0 +1,70 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +Migration.prototype.dropTable = function(table) { + return this.queryInterface + .dropTable(table) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.dropTable('jscripty_projects'); + migration.dropTable('report_jscripty_inputs'); + migration.dropTable('report_jscripty_questions'); + migration.dropTable('report_jscripty_sessions'); + }, + + down: function(queryInterface, Sequelize) { + + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.21.js b/server/migrations/2.0.21.js new file mode 100644 index 0000000..600583d --- /dev/null +++ b/server/migrations/2.0.21.js @@ -0,0 +1,81 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +Migration.prototype.dropTable = function(table) { + return this.queryInterface + .dropTable(table) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.dropTable('jscripty_projects', { + force: true + }); + + migration.dropTable('report_jscripty_inputs', { + force: true + }); + + migration.dropTable('report_jscripty_questions', { + force: true + }); + + migration.dropTable('report_jscripty_sessions', { + force: true + }); + }, + + down: function(queryInterface, Sequelize) { + + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.22.js b/server/migrations/2.0.22.js new file mode 100644 index 0000000..6892d1b --- /dev/null +++ b/server/migrations/2.0.22.js @@ -0,0 +1,78 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +Migration.prototype.dropTable = function(table) { + return this.queryInterface + .dropTable(table) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.dropTable('report_jscripty_answers', { + force: true + }); + + migration.dropTable('report_jscripty_questions', { + force: true + }); + + migration.dropTable('report_jscripty_sessions', { + force: true + }); + + }, + + down: function(queryInterface, Sequelize) { + + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.23.js b/server/migrations/2.0.23.js new file mode 100644 index 0000000..26f02f4 --- /dev/null +++ b/server/migrations/2.0.23.js @@ -0,0 +1,97 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +Migration.prototype.dropTable = function(table) { + return this.queryInterface + .dropTable(table) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.addColumn('int_salesforce_accounts', 'type', { + type: Sequelize.ENUM('integrationTab', 'newTab'), + defaultValue: 'integrationTab' + }); + + migration.addColumn('int_zendesk_accounts', 'type', { + type: Sequelize.ENUM('integrationTab', 'newTab'), + defaultValue: 'integrationTab' + }); + + migration.dropTable('user_has_openchannel_rooms', { + force: true + }); + + migration.dropTable('openchannel_messages', { + force: true + }); + + migration.dropTable('openchannel_rooms', { + force: true + }); + + migration.dropTable('openchannel_applications', { + force: true + }); + + migration.dropTable('openchannel_accounts', { + force: true + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + migration.removeColumn('int_salesforce_accounts', 'type'); + migration.removeColumn('int_zendesk_accounts', 'type'); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.24.js b/server/migrations/2.0.24.js new file mode 100644 index 0000000..de48944 --- /dev/null +++ b/server/migrations/2.0.24.js @@ -0,0 +1,69 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.removeColumn = function(table, column) { + return this.queryInterface + .removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + return this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +Migration.prototype.dropTable = function(table) { + return this.queryInterface + .dropTable(table) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.dropTable('tools_schedules', { + force: true + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.25.js b/server/migrations/2.0.25.js new file mode 100644 index 0000000..a9f3c66 --- /dev/null +++ b/server/migrations/2.0.25.js @@ -0,0 +1,76 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.insertExtension = function(query) { + return this.queryInterface.sequelize.query(query) + .then(function(res) { + logger.info('Insert new row in voice_extensions'); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + return this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.insertExtension("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `appType`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'failed', '1', 'NoOp', 'system', 'catch failed event auto generated', 'custom', NOW(), NOW());"); + migration.insertExtension("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `appType`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'failed', '2', 'Hangup', 'system', 'catch failed event auto generated', 'custom', NOW(), NOW());"); + migration.changeColumn('users', 'allow', { + type: Sequelize.STRING, + defaultValue: 'ulaw;gsm' + }); + + migration.changeColumn('tools_trunks', 'allow', { + type: Sequelize.STRING, + defaultValue: 'ulaw;gsm;alaw' + }); + + migration.addColumn('voice_queues', 'dialPrefix', { + type: Sequelize.STRING, + defaultValue: null + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.26.js b/server/migrations/2.0.26.js new file mode 100644 index 0000000..96330f7 --- /dev/null +++ b/server/migrations/2.0.26.js @@ -0,0 +1,92 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; +}; + +Migration.prototype.changeColumn = function(table, column, type) { + return this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + return this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + + migration.changeColumn('tools_trunks', 'sendrpid', { + type: Sequelize.ENUM('yes', 'no', 'pai'), + defaultValue: 'no' + }); + + migration.addColumn('mail_servers_out', 'authentication', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.changeColumn('voice_queues', 'timeout', { + type: Sequelize.INTEGER(11), + defaultValue: 15 + }); + + migration.changeColumn('voice_queues', 'retry', { + type: Sequelize.INTEGER(11), + defaultValue: 2 + }); + + migration.changeColumn('users', 'allow', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: 'ulaw;alaw;gsm' + }); + + migration.changeColumn('tools_trunks', 'allow', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: 'ulaw;alaw;gsm' + }); + + migration.addColumn('voice_queues', 'dialCheckDuplicateType', { + type: Sequelize.ENUM('always', 'never', 'onlyIfOpen'), + defaultValue: 'always' + }); + + migration.addColumn('campaigns', 'dialCheckDuplicateType', { + type: Sequelize.ENUM('always', 'never', 'onlyIfOpen'), + defaultValue: 'always' + }); + + migration.addColumn('mail_accounts', 'email', { + type: Sequelize.STRING + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.27.js b/server/migrations/2.0.27.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.27.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.28.js b/server/migrations/2.0.28.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.28.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.29.js b/server/migrations/2.0.29.js new file mode 100644 index 0000000..e9eed3f --- /dev/null +++ b/server/migrations/2.0.29.js @@ -0,0 +1,380 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START CHAT + migration.dropTable('user_has_chat_rooms'); + migration.dropTable('chat_enquiries'); + migration.dropTable('chat_messages'); + migration.dropTable('chat_proactive_actions'); + migration.dropTable('chat_dispositions'); + migration.dropTable('chat_applications'); + migration.dropTable('user_has_chat_interactions'); + migration.dropTable('chat_interactions'); + migration.dropTable('team_has_chat_queues'); + migration.dropTable('user_has_chat_queues'); + migration.dropTable('chat_queues'); + migration.dropTable('chat_websites'); + // END CHAT + + // START OPENCHANNEL + migration.dropTable('openchannel_messages'); + migration.dropTable('user_has_openchannel_interactions'); + migration.dropTable('openchannel_interactions'); + // END OPENCHANNEL + + migration.addIndex('cm_hopper', ['phone'], 'phone'); + + migration.addIndex('cm_hopper_final', ['calleridnum'], 'calleridnum'); + + migration.addColumn('users', 'phoneBarUnconditionalNumber', { + type: Sequelize.STRING + }); + + migration.addColumn('users', 'phoneBarNoReplyNumber', { + type: Sequelize.STRING + }); + + migration.addColumn('users', 'phoneBarBusyNumber', { + type: Sequelize.STRING + }); + + migration.addColumn('users', 'phoneBarUnconditional', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'phoneBarNoReply', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'phoneBarBusy', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'phoneBarDnd', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.changeColumn('campaigns', 'dialQueueTimeout', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 3, + validate: { + min: 1, + max: 999 + }, + comment: 'Queue Timeout Seconds (min:1, max:999)' + }); + + migration.addColumn('voice_queues', 'dialAMDActive', { + type: Sequelize.BOOLEAN, + defaultValue: 0, + comment: 'Active/Disactive AMD' + }); + + migration.addColumn('voice_queues', 'dialAMDInitialSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 2500, + comment: '#AMD Initial Silence' + }); + + migration.addColumn('voice_queues', 'dialAMDGreeting', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 1500, + comment: '#AMD Greeting' + }); + + migration.addColumn('voice_queues', 'dialAMDAfterGreetingSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 800, + comment: '#AMD After Greeting Silence' + }); + + migration.addColumn('voice_queues', 'dialAMDTotalAnalysisTime', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 5000, + comment: '#AMD Total Analysis Time' + }); + + migration.addColumn('voice_queues', 'dialAMDMinWordLength', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 100, + comment: '#AMD Min Word Length' + }); + + migration.addColumn('voice_queues', 'dialAMDBetweenWordsSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 50, + comment: '#AMD Between Words Silence' + }); + + migration.addColumn('voice_queues', 'dialAMDMaximumNumberOfWords', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 3, + comment: '#AMD Maximum Number Of Words' + }); + + migration.addColumn('voice_queues', 'dialAMDSilenceThreshold', { + type: Sequelize.INTEGER(5).UNSIGNED, + validate: { + min: 0, + max: 32767 + }, + defaultValue: 256, + comment: '#AMD Silence Threshold (min:0, max:32767)' + }); + + migration.addColumn('voice_queues', 'dialAMDMaximumWordLength', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 5000, + comment: '#AMD Maximum Word Length' + }); + + + migration.addColumn('campaigns', 'dialAMDActive', { + type: Sequelize.BOOLEAN, + defaultValue: 0, + comment: 'Active/Disactive AMD' + }); + + migration.addColumn('campaigns', 'dialAMDInitialSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 2500, + comment: '#AMD Initial Silence' + }); + + migration.addColumn('campaigns', 'dialAMDGreeting', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 1500, + comment: '#AMD Greeting' + }); + + migration.addColumn('campaigns', 'dialAMDAfterGreetingSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 800, + comment: '#AMD After Greeting Silence' + }); + + migration.addColumn('campaigns', 'dialAMDTotalAnalysisTime', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 5000, + comment: '#AMD Total Analysis Time' + }); + + migration.addColumn('campaigns', 'dialAMDMinWordLength', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 100, + comment: '#AMD Min Word Length' + }); + + migration.addColumn('campaigns', 'dialAMDBetweenWordsSilence', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 50, + comment: '#AMD Between Words Silence' + }); + + migration.addColumn('campaigns', 'dialAMDMaximumNumberOfWords', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 3, + comment: '#AMD Maximum Number Of Words' + }); + + migration.addColumn('campaigns', 'dialAMDSilenceThreshold', { + type: Sequelize.INTEGER(5).UNSIGNED, + validate: { + min: 0, + max: 32767 + }, + defaultValue: 256, + comment: '#AMD Silence Threshold (min:0, max:32767)' + }); + + migration.addColumn('campaigns', 'dialAMDMaximumWordLength', { + type: Sequelize.INTEGER(9).UNSIGNED, + validate: { + min: 0 + }, + defaultValue: 5000, + comment: '#AMD Maximum Word Length' + }); + + migration.query("DELETE FROM `voice_extensions` WHERE exten = 'xcally-motion-dialer';"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '1', 'NoOp', '', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '2', 'set', 'CDR(type)=dialer', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '3', 'set', 'CALLERID(all)=${XMD-CALLERID}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '4', 'gotoif', '$[\"${XMD-AMD}\" != \"NONE\" ]?5:9', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '5', 'amd', '${XMD-AMDINITIALSILENCE},${XMD-AMDGREETING},${XMD-AMDAFTERGREETINGSILENCE},${XMD-AMDTOTALANALYSISTIME},${XMD-AMDMINWORDLENGTH},${XMD-AMDBETWEENWORDSSILENCE},${XMD-AMDMAXIMUMNUMBEROFWORDS},${XMD-AMDSILENCETHRESHOLD},${XMD-AMDMAXIMUMWORDLENGTH}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '6', 'gotoif', '$[\"${AMDSTATUS}\" == \"HUMAN\" ]?9:7', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`,`createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '7', 'gotoif', '$[\"${AMDSTATUS}\" == \"NOTSURE\" ]?9:8', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`,`createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '8', 'gotoif', '$[\"${AMDSTATUS}\" == \"MACHINE\" ]?11:9', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '9', 'execif', '$[\"${XMD-AGI}\" != \"NONE\" ]?AGI(${XMD-AGI})', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '10', 'execif', '$[\"${XMD-QUEUE}\" != \"NONE\" ]?QUEUE(${XMD-QUEUE})', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '11', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.30.js b/server/migrations/2.0.30.js new file mode 100644 index 0000000..1d69e33 --- /dev/null +++ b/server/migrations/2.0.30.js @@ -0,0 +1,141 @@ +'use strict'; +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START CHAT + migration.dropTable('user_has_chat_rooms'); + migration.dropTable('chat_enquiries'); + migration.dropTable('chat_messages'); + migration.dropTable('chat_proactive_actions'); + migration.dropTable('chat_dispositions'); + migration.dropTable('chat_applications'); + migration.dropTable('user_has_chat_interactions'); + migration.dropTable('chat_interactions'); + migration.dropTable('team_has_chat_queues'); + migration.dropTable('user_has_chat_queues'); + migration.dropTable('chat_queues'); + migration.dropTable('chat_visitors'); + migration.dropTable('chat_websites_fields'); + migration.dropTable('chat_websites'); + // END CHAT + + migration.changeColumn('voice_queues', 'dialQueueTimeout', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 3, + validate: { + min: 1, + max: 999 + }, + comment: 'Queue Timeout Seconds (min:1, max:999)' + }); + // START FINAL + migration.final(resolve); + // END FINAL + + }); + + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.31.js b/server/migrations/2.0.31.js new file mode 100644 index 0000000..bddb9b9 --- /dev/null +++ b/server/migrations/2.0.31.js @@ -0,0 +1,194 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SMS + migration.dropTable('sms_messages'); + migration.dropTable('sms_dispositions'); + migration.dropTable('sms_applications'); + migration.dropTable('user_has_sms_interactions'); + migration.dropTable('sms_interactions'); + migration.dropTable('team_has_sms_queues'); + migration.dropTable('user_has_sms_queues'); + migration.dropTable('sms_queues'); + migration.dropTable('sms_accounts'); + // END SMS + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'facebook', { + type: Sequelize.STRING + }); + + migration.addColumn('cm_contacts', 'twitter', { + type: Sequelize.STRING + }); + // END CM CONTACTS + + // START CHAT WEBSITES + migration.query('ALTER TABLE chat_websites DROP FOREIGN KEY chat_websites_ibfk_2'); + migration.query('ALTER TABLE chat_websites DROP COLUMN OfflineTemplateId'); + migration.addColumn('chat_websites', 'timezone', { + type: Sequelize.STRING + }); + migration.addColumn('chat_websites', 'token', { + type: Sequelize.STRING + }); + migration.addColumn('chat_websites', 'IntervalId', { + type: Sequelize.INTEGER(11) + }); + migration.query('ALTER TABLE chat_websites ADD CONSTRAINT chat_websites_ibfk_2 FOREIGN KEY (IntervalId) REFERENCES tools_intervals(id) ON UPDATE CASCADE ON DELETE SET NULL'); + // END CHAT WEBSITES + + // START TRANSFER + migration.addColumn('report_queue', 'transfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('report_queue', 'transfertype', { + type: Sequelize.STRING, + comment: 'FORWARD, BLIND, ATTENDED' + }); + migration.addColumn('report_queue', 'transferexten', { + type: Sequelize.STRING + }); + migration.addColumn('report_queue', 'transferuniqueid', { + type: Sequelize.STRING + }); + // END TRANSFER + + //START JSCRIPTY + migration.addColumn('report_jscripty_answers', 'questionId', { + type: Sequelize.STRING + }); + migration.addColumn('report_jscripty_questions', 'questionId', { + type: Sequelize.STRING + }); + //END JSCRIPTY + + // START USER PHONEBAR + migration.addColumn('users', 'phoneBarUnansweredCallBadge', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END USER PHONEBAR + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '1', 'NoOp', '', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '2', 'set', 'CDR(type)=dialer', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '3', 'set', 'CALLERID(all)=${XMD-CALLERID}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '4', 'dial', '${XMD-DIALCHANNEL},${XMD-DIALTIMEOUT},${XMD-DIALOPTIONS},${XMD-DIALURL}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '5', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + // END EXTENSION DIALER + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.32.js b/server/migrations/2.0.32.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.32.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.33.js b/server/migrations/2.0.33.js new file mode 100644 index 0000000..5379c35 --- /dev/null +++ b/server/migrations/2.0.33.js @@ -0,0 +1,243 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'agentAlias', { + type: Sequelize.STRING, + defaultValue: 'Agent' + }); + migration.addColumn('chat_websites', 'mapKeyOffline', { + type: Sequelize.STRING, + defaultValue: 'email' + }); + migration.addColumn('chat_websites', 'sitepic', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_websites', 'closingMessage', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_websites', 'closingMessageButton', { + type: Sequelize.STRING, + defaultValue: 'Send' + }); + migration.addColumn('chat_websites', 'enableRating', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'ratingType', { + type: Sequelize.ENUM('star', 'thumb'), + defaultValue: 'star' + }); + migration.addColumn('chat_websites', 'ratingStarsNumber', { + type: Sequelize.INTEGER, + defaultValue: 5 + }); + migration.addColumn('chat_interactions', 'ratingValue', { + type: Sequelize.INTEGER + }); + migration.addColumn('chat_interactions', 'ratingMessage', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_interactions', 'pathTranscript', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_interactions', 'mailTranscript', { + type: Sequelize.STRING + }); + migration.addColumn('chat_websites', 'forwardTranscript', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'forwardOffline', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'forwardOfflineAddress', { + type: Sequelize.STRING, + validate: { + isEmail: true + } + }); + migration.changeColumn('chat_websites', 'color', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#9f946a' + }); + migration.changeColumn('chat_websites', 'color_button', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#9f946a' + }); + // END CHATWEBSITE + + // START FAX + migration.dropTable('fax_attachments'); + migration.dropTable('user_has_fax_rooms'); + migration.dropTable('fax_rooms'); + migration.dropTable('fax_messages'); + migration.dropTable('fax_dispositions'); + migration.dropTable('fax_applications'); + migration.dropTable('user_has_fax_interactions'); + migration.dropTable('fax_interactions'); + migration.dropTable('team_has_fax_queues'); + migration.dropTable('user_has_fax_queues'); + migration.dropTable('fax_queues'); + migration.removeColumn('fax_accounts', 'fidelity'); + migration.removeColumn('fax_accounts', 'timeout'); + migration.removeColumn('fax_accounts', 'acceptUrl'); + migration.removeColumn('fax_accounts', 'rejectUrl'); + migration.removeColumn('fax_accounts', 'acceptMethod'); + migration.removeColumn('fax_accounts', 'rejectMethod'); + migration.removeColumn('fax_accounts', 'actions'); + migration.removeColumn('fax_accounts', 'closeUrl'); + migration.removeColumn('fax_accounts', 'closeMethod'); + // END FAX + + //START USER_HAS_CHAT_QUEUES + migration.removeColumn('user_has_chat_queues', 'assigned'); + migration.removeColumn('user_has_chat_queues', 'queue'); + //END USER_HAS_CHAT_QUEUES + + //START USER_HAS_OPENCHANNEL_QUEUES + migration.removeColumn('user_has_openchannel_queues', 'assigned'); + migration.removeColumn('user_has_openchannel_queues', 'queue'); + //END USER_HAS_OPENCHANNEL_QUEUES + + //START Priority + migration.addColumn('cm_hopper', 'priority', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 2 + }); + migration.addIndex('cm_hopper', ['priority'], 'priority'); + //END Priority + + //START sms_messages + migration.dropTable('sms_messages'); + //START sms_messages + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.34.js b/server/migrations/2.0.34.js new file mode 100644 index 0000000..64da570 --- /dev/null +++ b/server/migrations/2.0.34.js @@ -0,0 +1,412 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'key', { + type: Sequelize.STRING, + allowNull: false + }); + migration.addColumn('chat_websites', 'forwardTranscriptMessage', { + type: Sequelize.STRING + }); + migration.addColumn('chat_websites', 'skipMessageButton', { + type: Sequelize.STRING, + defaultValue: 'Skip' + }); + migration.addColumn('chat_websites', 'enableFeedback', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'enableCustomerWriting', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'conditionAgreement', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'waitingTitle', { + type: Sequelize.STRING, + defaultValue: 'All of our agents are busy at this time. Your chat is very important to us.' + }); + migration.addColumn('chat_websites', 'waitingMessage', { + type: Sequelize.STRING, + defaultValue: 'Please hold and we will answer your request as soon as possible.' + }); + migration.addColumn('chat_websites', 'autoclose', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('chat_websites', 'unmanagedMessage', { + type: Sequelize.STRING, + defaultValue: 'Your request has not been processed.' + }); + migration.addColumn('chat_websites', 'enableUnmanagedNote', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('chat_websites', 'sendUnmanaged', { + type: Sequelize.STRING, + defaultValue: 'Send' + }); + migration.addColumn('chat_websites', 'skipUnmanaged', { + type: Sequelize.STRING, + defaultValue: 'Skip' + }); + migration.changeColumn('chat_websites', 'closingMessage', { + type: Sequelize.STRING, + defaultValue: 'Thanks you for your time!' + }); + // END CHATWEBSITE + + // START CHATINTERACTION + migration.addColumn('chat_interactions', 'browserName', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'browserVersion', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'osName', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'osVersion', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'deviceModel', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'deviceVendor', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'deviceType', { + type: Sequelize.STRING + }); + // END CHATINTERACTION + + // START CHATMESSAGES + migration.addColumn('chat_messages', 'AttachmentId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE `chat_messages` \ + ADD CONSTRAINT `chat_messages_ibfk_5` \ + FOREIGN KEY (`AttachmentId`) \ + REFERENCES attachments(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + // END CHATMESSAGES + + // START RECALLME + migration.addColumn('voice_queues', 'dialRecallMeTimeout', { + type: Sequelize.INTEGER(5).UNSIGNED, + defaultValue: 30 + }); + migration.addColumn('voice_queues', 'dialRecallInQueue', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('cm_hopper', 'recallme', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('cm_hopper_final', 'recallme', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('cm_hopper_history', 'recallme', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // STOP RECALLME + + // START RECORDINGS + migration.addColumn('voice_recordings', 'userDisposition', { + type: Sequelize.STRING + }); + // STOP RECORDINGS + + // START EMAIL + migration.dropTable('user_has_mail_rooms'); + + migration.query('ALTER TABLE mail_rooms DROP FOREIGN KEY mail_rooms_ibfk_1'); + migration.query('ALTER TABLE mail_rooms DROP COLUMN MailAccountId'); + migration.dropTable('mail_rooms'); + + migration.query('ALTER TABLE analytics_extracted_reports DROP FOREIGN KEY analytics_extracted_reports_ibfk_1'); + migration.query('ALTER TABLE mail_messages DROP COLUMN MailMessageId'); + + migration.query('ALTER TABLE mail_messages DROP FOREIGN KEY mail_messages_ibfk_1'); + migration.query('ALTER TABLE mail_messages DROP COLUMN MailRoomId'); + migration.query('ALTER TABLE mail_messages DROP FOREIGN KEY mail_messages_ibfk_2'); + migration.query('ALTER TABLE mail_messages DROP COLUMN UserId'); + migration.dropTable('mail_messages'); + + migration.dropTable('mail_attachments'); + migration.dropTable('mail_dispositions'); + migration.dropTable('mail_applications'); + migration.dropTable('user_has_mail_interactions'); + migration.dropTable('mail_interactions'); + migration.dropTable('team_has_mail_queues'); + migration.dropTable('user_has_mail_queues'); + migration.dropTable('mail_queues'); + + migration.removeColumn('mail_accounts', 'fidelity'); + migration.removeColumn('mail_accounts', 'timeout'); + migration.removeColumn('mail_accounts', 'whiteLabel'); + migration.removeColumn('mail_accounts', 'acceptUrl'); + migration.removeColumn('mail_accounts', 'rejectUrl'); + migration.removeColumn('mail_accounts', 'acceptMethod'); + migration.removeColumn('mail_accounts', 'rejectMethod'); + migration.removeColumn('mail_accounts', 'actions'); + migration.removeColumn('mail_accounts', 'closeUrl'); + migration.removeColumn('mail_accounts', 'closeMethod'); + migration.removeColumn('mail_accounts', 'signature'); + migration.removeColumn('mail_accounts', 'custom'); + + migration.addColumn('mail_accounts', 'active', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.removeColumn('mail_servers_out', 'state'); + + migration.dropTable('mail_servers_in'); + + migration.query("CREATE TABLE `mail_interactions` ( \ + `id` int(11) NOT NULL AUTO_INCREMENT, \ + `closed` tinyint(1) DEFAULT '0', \ + `closedAt` datetime DEFAULT NULL, \ + `disposition` varchar(255) DEFAULT NULL, \ + `note` varchar(255) DEFAULT NULL, \ + `inReplyTo` varchar(190) DEFAULT NULL, \ + `to` varchar(255) DEFAULT NULL, \ + `cc` longtext, \ + `subject` text, \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `UserId` int(11) DEFAULT NULL, \ + `MailAccountId` int(11) DEFAULT NULL, \ + `ContactId` int(11) DEFAULT NULL, \ + PRIMARY KEY (`id`), \ + KEY `UserId` (`UserId`), \ + KEY `MailAccountId` (`MailAccountId`), \ + KEY `ContactId` (`ContactId`), \ + CONSTRAINT `mail_interactions_ibfk_1` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, \ + CONSTRAINT `mail_interactions_ibfk_2` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, \ + CONSTRAINT `mail_interactions_ibfk_3` FOREIGN KEY (`ContactId`) REFERENCES `cm_contacts` (`id`) ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + migration.query("CREATE TABLE `mail_messages` ( \ + `id` int(11) NOT NULL AUTO_INCREMENT, \ + `body` longtext COLLATE utf8mb4_unicode_ci NOT NULL, \ + `read` tinyint(1) DEFAULT '0', \ + `direction` enum('in','out') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'out', \ + `messageId` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL, \ + `from` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, \ + `to` longtext COLLATE utf8mb4_unicode_ci, \ + `cc` longtext COLLATE utf8mb4_unicode_ci, \ + `bcc` longtext COLLATE utf8mb4_unicode_ci, \ + `subject` text COLLATE utf8mb4_unicode_ci, \ + `sentAt` datetime DEFAULT NULL, \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `MailAccountId` int(11) DEFAULT NULL, \ + `MailInteractionId` int(11) DEFAULT NULL, \ + `UserId` int(11) DEFAULT NULL, \ + `ContactId` int(11) DEFAULT NULL, \ + PRIMARY KEY (`id`), \ + KEY `MailAccountId` (`MailAccountId`), \ + KEY `MailInteractionId` (`MailInteractionId`), \ + KEY `UserId` (`UserId`), \ + KEY `ContactId` (`ContactId`), \ + KEY `messageId` (`messageId`), \ + CONSTRAINT `mail_messages_ibfk_1` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, \ + CONSTRAINT `mail_messages_ibfk_2` FOREIGN KEY (`MailInteractionId`) REFERENCES `mail_interactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `mail_messages_ibfk_3` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, \ + CONSTRAINT `mail_messages_ibfk_4` FOREIGN KEY (`ContactId`) REFERENCES `cm_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); + // STOP EMAIL + + // START ATTACHMENTS + migration.query('CREATE TABLE `attachments` ( \ + `id` int(11) NOT NULL AUTO_INCREMENT, \ + `name` varchar(255) DEFAULT NULL, \ + `basename` varchar(255) DEFAULT NULL, \ + `type` varchar(255) DEFAULT NULL, \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `MailMessageId` int(11) DEFAULT NULL, \ + PRIMARY KEY (`id`), \ + KEY `MailMessageId` (`MailMessageId`), \ + CONSTRAINT `attachments_ibfk_1` FOREIGN KEY (`MailMessageId`) REFERENCES `mail_messages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;'); + + migration.dropTable('fax_attachments'); + // END ATTACHMENTS + + // START SMS ACCOUNT + migration.addColumn('sms_accounts', 'phone', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'accountSid', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'authToken', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'key', { + type: Sequelize.STRING, + allowNull: false + }); + // END SMS ACCOUNT + + // START COLLATE CHANGE + migration.query('ALTER TABLE users CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;'); + // migration.query('ALTER TABLE voice_extensions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;'); + //END COLLATE CHANGE + + //START OPENCHANNEL + migration.addColumn('openchannel_accounts', 'key', { + type: Sequelize.STRING, + allowNull: false + }); + //END OPENCHANNEL + + //START FAX + migration.addColumn('fax_accounts', 'key', { + type: Sequelize.STRING, + allowNull: false + }); + //END FAX + + //START MAIL + migration.addColumn('mail_accounts', 'key', { + type: Sequelize.STRING, + allowNull: false + }); + //END MAIL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.35.js b/server/migrations/2.0.35.js new file mode 100644 index 0000000..49b46d4 --- /dev/null +++ b/server/migrations/2.0.35.js @@ -0,0 +1,326 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START REPORT + migration.addColumn('analytics_custom_reports', 'joins', { + type: Sequelize.TEXT + }); + + migration.addColumn('analytics_default_reports', 'joins', { + type: Sequelize.TEXT + }); + // END REPORT + + // START CHAT MESSAGES + migration.query('ALTER TABLE `chat_messages` \ + ADD CONSTRAINT `chat_messages_ibfk_5` \ + FOREIGN KEY (`AttachmentId`) \ + REFERENCES attachments(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + // END CHAT MESSAGES + + // START CHAT WEBSITE + migration.addColumn('chat_websites', 'offline_chat_button', { + type: Sequelize.STRING, + defaultValue: 'Send' + }); + migration.addColumn('chat_websites', 'enableCustomerAttachment', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT WEBSITE + + // START CHAT INTERACTION + migration.addColumn('chat_interactions', 'referer', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'customerIp', { + type: Sequelize.STRING + }); + migration.addColumn('chat_interactions', 'ratingType', { + type: Sequelize.ENUM('star', 'thumb'), + defaultValue: 'star' + }); + migration.query('ALTER TABLE chat_interactions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); + // END CHAT INTERACTION + + // START EMAIL + migration.addColumn('mail_messages', 'body', { + type: Sequelize.TEXT('long'), + allowNull: false + }); + migration.addColumn('mail_messages', 'read', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('mail_messages', 'direction', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'out', + allowNull: false + }); + migration.changeColumn('mail_messages', 'messageId', { + type: Sequelize.STRING(190) + }); + migration.removeColumn('mail_messages', 'inReplyTo'); + migration.changeColumn('mail_messages', 'to', { + type: Sequelize.TEXT('long') + }); + migration.changeColumn('mail_messages', 'cc', { + type: Sequelize.TEXT('long') + }); + migration.changeColumn('mail_messages', 'bcc', { + type: Sequelize.TEXT('long') + }); + migration.changeColumn('mail_messages', 'subject', { + type: Sequelize.TEXT + }); + migration.addColumn('mail_messages', 'sentAt', { + type: Sequelize.DATE + }); + migration.addColumn('mail_messages', 'attach', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.removeColumn('mail_messages', 'fromId'); + migration.removeColumn('mail_messages', 'attachment'); + migration.removeColumn('mail_messages', 'text'); + migration.removeColumn('mail_messages', 'html'); + migration.removeColumn('mail_messages', 'reason'); + migration.removeColumn('mail_messages', 'auto'); + migration.removeColumn('mail_messages', 'status'); + migration.removeColumn('mail_messages', 'retry'); + migration.removeColumn('mail_messages', 'voiceSource'); + migration.removeColumn('mail_messages', 'userName'); + migration.removeColumn('mail_messages', 'userFullname'); + migration.removeColumn('mail_messages', 'accountId'); + migration.removeColumn('mail_messages', 'accountName'); + migration.removeColumn('mail_messages', 'MailInteractionId'); + + migration.addColumn('mail_messages', 'MailAccountId', { + type: Sequelize.INTEGER, + }); + migration.query('ALTER TABLE `mail_messages` \ + ADD CONSTRAINT `mail_messages_ibfk_1` \ + FOREIGN KEY (`MailAccountId`) \ + REFERENCES mail_accounts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + + migration.addColumn('mail_messages', 'MailInteractionId', { + type: Sequelize.INTEGER, + }); + migration.query('ALTER TABLE `mail_messages` \ + ADD CONSTRAINT `mail_messages_ibfk_2` \ + FOREIGN KEY (`MailInteractionId`) \ + REFERENCES mail_interactions(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + migration.addColumn('mail_messages', 'UserId', { + type: Sequelize.INTEGER, + }); + migration.query('ALTER TABLE `mail_messages` \ + ADD CONSTRAINT `mail_messages_ibfk_3` \ + FOREIGN KEY (`UserId`) \ + REFERENCES users(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + + migration.addColumn('mail_messages', 'ContactId', { + type: Sequelize.INTEGER, + }); + migration.query('ALTER TABLE `mail_messages` \ + ADD CONSTRAINT `mail_messages_ibfk_4` \ + FOREIGN KEY (`ContactId`) \ + REFERENCES cm_contacts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + migration.query('ALTER TABLE mail_messages CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); + + migration.addColumn('mail_interactions', 'attach', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('mail_accounts', 'signature', { + type: Sequelize.TEXT + }); + // END MAIL + + // START TEMPLATE + migration.removeColumn('tools_templates', 'subject'); + // END TEMPLATE + + // START USER + migration.addColumn('users', 'phoneBarEnableDtmfTone', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'phoneBarAutoAnswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END USER + + // START REPORT QUEUE MULTICHANNEL + migration.dropTable('report_openchannel'); + migration.dropTable('report_openchannel_session'); + migration.dropTable('report_chat'); + migration.dropTable('report_chat_session'); + migration.dropTable('report_fax'); + migration.dropTable('report_fax_session'); + migration.dropTable('report_mail'); + migration.dropTable('report_mail_session'); + migration.dropTable('report_sms'); + migration.dropTable('report_sms_session'); + // END REPORT QUEUE MULTICHANNEL + + // START EDIT HOPPER + migration.addColumn('cm_hopper_history', 'editedat', { + type: Sequelize.DATE + }); + migration.addColumn('cm_hopper_history', 'edited', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END EDIT HOPPER + + // START EDIT VOICE QUEUE / CAMPAIGN + migration.addColumn('voice_queues', 'dialOrderByScheduledAt', { + type: Sequelize.ENUM('DESC', 'ASC'), + defaultValue: 'DESC' + }); + migration.addColumn('campaigns', 'dialOrderByScheduledAt', { + type: Sequelize.ENUM('DESC', 'ASC'), + defaultValue: 'DESC' + }); + // END EDIT VOICE QUEUE + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.36.js b/server/migrations/2.0.36.js new file mode 100644 index 0000000..efdd6e4 --- /dev/null +++ b/server/migrations/2.0.36.js @@ -0,0 +1,140 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + //START OPENCHANNEL MESSAGES + migration.addColumn('openchannel_messages', 'AttachmentId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE `openchannel_messages` \ + ADD CONSTRAINT `openchannel_messages_ibfk_5` \ + FOREIGN KEY (`AttachmentId`) \ + REFERENCES attachments(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + //END OPENCHANNEL MESSAGES + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.37.js b/server/migrations/2.0.37.js new file mode 100644 index 0000000..eb00133 --- /dev/null +++ b/server/migrations/2.0.37.js @@ -0,0 +1,149 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + //START JSCRIPTY + migration.addColumn('jscripty_projects', 'enableUncompleteSave', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('report_jscripty_sessions', 'completed', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.query('UPDATE report_jscripty_sessions SET completed = true'); + //END JSCRIPTY + + //START SMS + migration.addColumn('sms_interactions', 'phone', { + type: Sequelize.STRING + }); + migration.addColumn('sms_messages', 'phone', { + type: Sequelize.STRING + }); + //END SMS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.38.js b/server/migrations/2.0.38.js new file mode 100644 index 0000000..1acfdb3 --- /dev/null +++ b/server/migrations/2.0.38.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); +var exec = require('child_process').exec; +var cmd = 'chown motion:asterisk /var/opt/motion2/server/files/attachments'; +var ls = 'ls -la /var/opt/motion2/server/files'; + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START SMS + migration.addColumn('sms_accounts', 'remote', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'token', { + type: Sequelize.STRING + }); + migration.addColumn('sms_messages', 'messageId', { + type: Sequelize.STRING + }); + // END SMS + + // START FAX + + exec(cmd, function(err, stdout, stderr) { + logger.info('Exec chmod', ' Error :', JSON.stringify(err), stdout, stderr); + exec(ls, function(err, stdout, stderr) { + logger.info('Ls :', ' Error :', JSON.stringify(err), stdout, stderr); + }); + }); + + migration.dropTable('fax_applications'); + + migration.addColumn('fax_messages', 'AttachmentId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE `fax_messages` \ + ADD CONSTRAINT `fax_messages_ibfk_5` \ + FOREIGN KEY (`AttachmentId`) \ + REFERENCES attachments(`id`) \ + ON UPDATE CASCADE \ + ON DELETE SET NULL'); + + migration.addColumn('tools_trunks', 't38pt_udptl', { + type: Sequelize.STRING, + defaultValue: 'no' + }); + // END FAX + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.39.js b/server/migrations/2.0.39.js new file mode 100644 index 0000000..ed00d6a --- /dev/null +++ b/server/migrations/2.0.39.js @@ -0,0 +1,236 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); +var ejs = require('ejs'); +var fs = require('fs'); +var path = require('path'); +var exec = require('child_process').exec; + +var config = require('../config/environment'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.checkVoiceContexts = function() { + var _this = this; + var VoiceContext = _this.queryInterface.sequelize.import(path.join(config.root, 'server/api/voiceContext/voiceContext.model')); + this.sequence.enqueue(function() { + return VoiceContext.findOrCreate({ + where: { + name: 'xcally-mixmonitor-context' + }, + defaults: { + name: 'xcally-mixmonitor-context', + description: 'default entry context (DO NOT DELETE)', + defaultEntry: true + } + }) + .spread(function(entity, created) { + return VoiceContext + .findAll({ + raw: true + }); + }) + .then(function(contexts) { + var templateContext = fs.readFileSync(path.join(config.root, 'server/files/templates/context.ejs'), 'utf8'); + + var contextsFile = ejs.render(templateContext, { + contexts: contexts || [] + }); + + fs.writeFileSync('/etc/asterisk/extensions_xcally_contexts.conf', contextsFile); + + exec('asterisk -rx "reload chan_sip.so"', function(err, stdout, stderr) { + logger.info('Exec chmod', ' Error :', JSON.stringify(err), stdout, stderr); + }); + + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + // START SETTINGS + migration.addColumn('settings', 'defaultPageTitle', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('settings', 'pageTitle', { + type: Sequelize.STRING + }); + // END SETTINGS + + // START VOICECONTEXT + migration.checkVoiceContexts(); + // END VOICECONTEXT + + // START SALESFORCE CONF + migration.addColumn('int_salesforce_configurations', 'moduleSearch', { + type: Sequelize.ENUM('contact_lead', 'contact', 'lead'), + defaultValue: 'contact_lead' + }); + migration.addColumn('int_salesforce_configurations', 'moduleCreate', { + type: Sequelize.ENUM('nothing', 'contact', 'lead'), + defaultValue: 'lead' + }); + // END SALESFORCE CONF + + // START FAX + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '1', 'NoOp', '', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '2', 'Set', 'CDR(type)=outbound-fax', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '3', 'Wait', '6', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '4', 'Set', 'FAXOPT(ecm)=${XMF-ECM}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '5', 'Set', 'FAXOPT(headerinfo)=${XMF-HEADERINFO}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '6', 'Set', 'FAXOPT(localstationid)=${XMF-LOCALSTATIONID}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '7', 'Set', 'FAXOPT(maxrate)=${XMF-MAXRATE}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '8', 'Set', 'FAXOPT(minrate)=${XMF-MINRATE}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '9', 'Set', 'FAXOPT(modem)=${XMF-MODEM}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '10', 'Set', 'FAXOPT(t38timeout)=${XMF-T38TIMEOUT}', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-fax', '11', 'SendFax', '${XMF-PATH},d', 'system', 'Fax extensions auto generated', NOW(), NOW());"); + + exec('chmod 775 /var/opt/motion2/server/files/attachments', function(err, stdout, stderr) { + logger.info('Exec chmod', ' Error :', JSON.stringify(err), stdout, stderr); + exec('ls -la /var/opt/motion2/server/files', function(err, stdout, stderr) { + logger.info('Ls :', ' Error :', JSON.stringify(err), stdout, stderr); + }); + }); + // END FAX + + // START CONTACT + migration.addColumn('cm_contacts', 'deletedAt', { + type: Sequelize.DATE, + defaultValue: null + }); + // END CONTACT + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.40.js b/server/migrations/2.0.40.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.40.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.41.js b/server/migrations/2.0.41.js new file mode 100644 index 0000000..557ad72 --- /dev/null +++ b/server/migrations/2.0.41.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); +var exec = require('child_process').exec; +var cmd = 'chown motion:asterisk /var/opt/motion2/server/files/attachments'; +var ls = 'ls -la /var/opt/motion2/server/files'; + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START DESK ACCOUNTS + migration.addColumn('int_desk_accounts', 'serverUrl', { + type: Sequelize.STRING + }); + // END DESK ACCOUNTS + + // START CHAT INTERACTIONS + migration.addColumn('chat_interactions', 'formData', { + type: Sequelize.TEXT('long') + }); + // END CHAT INTERACTIONS + + // START CHAT MESSAGES + migration.addColumn('chat_messages', 'secret', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT MESSAGES + + // START CHAT WEBSITES + migration.addColumn('chat_websites', 'agentAvatar', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_websites', 'showAgentAvatar', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT WEBSITES + + //START CUSTOM FIELDS + migration.changeColumn('cm_custom_fields', 'values', { + type: Sequelize.TEXT('long') + }); + //END CUSTOM FIELDS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.42.js b/server/migrations/2.0.42.js new file mode 100644 index 0000000..260d26a --- /dev/null +++ b/server/migrations/2.0.42.js @@ -0,0 +1,192 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); +var path = require('path'); +var config = require('../config/environment'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.getCustomFields = function() { + var _this = this; + var CmCustomField = _this.queryInterface.sequelize.import(path.join(config.root, 'server/api/cmCustomField/cmCustomField.model')); + return CmCustomField.findAll({ + where: { + type: { + $notIn: ['number', 'switch'] + } + }, + attributes: ['id'] + }) + .then(function(entities) { + return entities; + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); +}; + + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START TOOLS TAGS + migration.addColumn('tools_tags', 'color', { + type: Sequelize.STRING, + defaultValue: '#0091EA' + }); + // END TOOLS TAGS + + // START OPENCHANNEL MESSAGES + migration.addColumn('openchannel_messages', 'secret', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END OPENCHANNEL MESSAGES + + //START CONTACTS + migration.getCustomFields() + .then(function(entities) { + if (entities) { + for (var i = 0, length = entities.length; i < length; i++) { + migration.changeColumn('cm_contacts', 'cf_' + entities[i].id, { + type: Sequelize.TEXT + }); + } + } + }); + //END CONTACTS + + // START FAX + migration.addColumn('fax_messages', 'failMessage', { + type: Sequelize.TEXT + }); + + // END FAX + + // START USER + migration.addColumn('users', 'extensionMonitor', { + type: Sequelize.STRING, + defaultValue: '' + }); + + // END USER + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.43.js b/server/migrations/2.0.43.js new file mode 100644 index 0000000..4c2d1d1 --- /dev/null +++ b/server/migrations/2.0.43.js @@ -0,0 +1,135 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START MAIL MESSAGES + migration.addColumn('mail_messages', 'secret', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END MAIL MESSAGES + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.44.js b/server/migrations/2.0.44.js new file mode 100644 index 0000000..09546ae --- /dev/null +++ b/server/migrations/2.0.44.js @@ -0,0 +1,247 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'closingQuestion', { + type: Sequelize.STRING, + defaultValue: 'Do you want to close the interaction?' + }); + // END CHATWEBSITE + + // START CHAT INTERACTIONS + migration.addColumn('chat_interactions', 'read1stAt', { + type: Sequelize.DATE + }); + // END CHAT INTERACTIONS + + // START CHAT MESSAGES + migration.addColumn('chat_messages', 'readAt', { + type: Sequelize.DATE + }); + // END CHAT MESSAGES + + // START FAX INTERACTIONS + migration.addColumn('fax_interactions', 'read1stAt', { + type: Sequelize.DATE + }); + // END FAX INTERACTIONS + + // START FAX MESSAGES + migration.addColumn('fax_messages', 'readAt', { + type: Sequelize.DATE + }); + // END FAX MESSAGES + + // START OPENCHANNEL INTERACTIONS + migration.addColumn('openchannel_interactions', 'read1stAt', { + type: Sequelize.DATE + }); + migration.addColumn('openchannel_interactions', 'threadId', { + type: Sequelize.STRING + }); + migration.addColumn('openchannel_interactions', 'externalUrl', { + type: Sequelize.STRING + }); + // END OPENCHANNEL INTERACTIONS + + // START OPENCHANNEL MESSAGES + migration.addColumn('openchannel_messages', 'readAt', { + type: Sequelize.DATE + }); + // END OPENCHANNEL MESSAGES + + // START MAIL INTERACTIONS + migration.addColumn('mail_interactions', 'read1stAt', { + type: Sequelize.DATE + }); + migration.addColumn('mail_interactions', 'substatus', { + type: Sequelize.STRING(60) + }); + migration.addColumn('mail_interactions', 'substatusAt', { + type: Sequelize.DATE + }); + // END MAIL INTERACTIONS + + // START MAIL MESSAGES + migration.addColumn('mail_messages', 'readAt', { + type: Sequelize.DATE + }); + // END MAIL MESSAGES + + // START SMS INTERACTIONS + migration.addColumn('sms_interactions', 'read1stAt', { + type: Sequelize.DATE + }); + // END SMS INTERACTIONS + + // START SMS MESSAGES + migration.addColumn('sms_messages', 'readAt', { + type: Sequelize.DATE + }); + // END SMS MESSAGES + + // START DISPOSITIONS + migration.changeColumn('chat_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.changeColumn('fax_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.changeColumn('openchannel_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.changeColumn('sms_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.changeColumn('voice_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.query('ALTER TABLE chat_dispositions add UNIQUE INDEX nameAndAccount (name, ChatAccountId)'); + migration.query('ALTER TABLE fax_dispositions add UNIQUE INDEX nameAndAccount (name, FaxAccountId)'); + migration.query('ALTER TABLE openchannel_dispositions add UNIQUE INDEX nameAndAccount (name, OpenchannelAccountId)'); + migration.query('ALTER TABLE sms_dispositions add UNIQUE INDEX nameAndAccount (name, SmsAccountId)'); + migration.query('ALTER TABLE voice_dispositions add UNIQUE INDEX nameAndAccount (name, ListId)'); + migration.changeColumn('mail_dispositions', 'name', { + type: Sequelize.STRING, + unique: 'nameAndAccount', + allowNull: false + }); + migration.query('ALTER TABLE mail_dispositions DROP INDEX name'); + migration.query('ALTER TABLE mail_dispositions add UNIQUE INDEX nameAndAccount (name, MailAccountId)'); + // END DISPOSITIONS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.45.js b/server/migrations/2.0.45.js new file mode 100644 index 0000000..c8d1ee2 --- /dev/null +++ b/server/migrations/2.0.45.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + up: function(queryInterface, Sequelize) { + + }, + down: function(queryInterface, Sequelize) {} +}; \ No newline at end of file diff --git a/server/migrations/2.0.46.js b/server/migrations/2.0.46.js new file mode 100644 index 0000000..411f55f --- /dev/null +++ b/server/migrations/2.0.46.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START USER + migration.changeColumn('users', 'showWebBar', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END USER + + // START USER + // UPDATE AGENT COLUMN PERMISSION + migration.query("UPDATE users SET permissions='101,102,103,104,105,106,107,108,109,100' WHERE role='agent' AND (permissions IS NULL OR permissions = '')"); + + migration.addColumn('users', 'crudPermissions', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + //END USER + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'noteTitle', { + type: Sequelize.STRING, + defaultValue: 'Note' + }); + + migration.addColumn('chat_websites', 'placeholderMessage', { + type: Sequelize.STRING, + defaultValue: 'Type a message' + }); + // END CHATWEBSITE + + // START Fax Interaction + migration.addColumn('fax_interactions', 'fax', { + type: Sequelize.STRING + }); + migration.query("UPDATE fax_interactions as t1 JOIN cm_contacts AS t2 ON t1.ContactId = t2.id SET t1.fax = t2.fax"); + + // END Fax Interaction + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.47.js b/server/migrations/2.0.47.js new file mode 100644 index 0000000..0e7884d --- /dev/null +++ b/server/migrations/2.0.47.js @@ -0,0 +1,176 @@ +'use strict'; + +var BPromise = require('bluebird'); + +var logger = require('../config/logger')('migration'); +var util = require('util'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + var migration = new Migration(queryInterface); + + // START DASHBOARD + migration.query("DELETE FROM dashboards"); + + migration.removeColumn('dashboards', 'interval'); + + + migration.changeColumn('dashboard_items', 'type', { + type: Sequelize.STRING(20), + allowNull: false, + validate: { + len: [1, 20] + } + }); + migration.removeColumn('dashboard_items', 'query'); + migration.removeColumn('dashboard_items', 'data'); + + migration.addColumn('dashboard_items', 'title', { + type: Sequelize.STRING(20), + validate: { + len: [0, 20] + } + }); + + migration.addColumn('dashboard_items', 'attrs', { + type: Sequelize.TEXT('long') + }); + // END DASHBOARD + + // START SMS MESSAGES + migration.addColumn('sms_messages', 'secret', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END SMS MESSAGES + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'formSubmitSuccessMessage', { + type: Sequelize.STRING, + defaultValue: 'Form properly submitted' + }); + + migration.addColumn('chat_websites', 'formSubmitFailureMessage', { + type: Sequelize.STRING, + defaultValue: 'Form submission error' + }); + // END CHATWEBSITE + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.48.js b/server/migrations/2.0.48.js new file mode 100644 index 0000000..a6106d8 --- /dev/null +++ b/server/migrations/2.0.48.js @@ -0,0 +1,211 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'turnaddr', { + type: Sequelize.STRING + }); + migration.addColumn('settings', 'turnusername', { + type: Sequelize.STRING + }); + migration.addColumn('settings', 'turnpassword', { + type: Sequelize.STRING + }); + // END SETTINGS + + // START USERS + migration.addColumn('users', 'rtcp_mux', { + type: Sequelize.ENUM('yes', 'no'), + defaultValue: 'no' + }); + + migration.query('UPDATE users SET rtcp_mux=\'yes\' WHERE showWebBar=2'); + // END USERS + + // START SMS INTERACTIONS + migration.addColumn('sms_interactions', 'firstMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + + // Update the firstMsgDirection column with correct value (direction of the first message for each interactions) + migration.query("UPDATE sms_interactions t1, (SELECT SmsInteractionId, MIN(id) AS messageid, ANY_VALUE(direction) AS direction FROM sms_messages WHERE SmsInteractionId IS NOT NULL GROUP BY SmsInteractionId) t2 SET t1.firstMsgDirection = t2.direction WHERE t1.id = t2.SmsInteractionId;"); + // END SMS INTERACTIONS + + // START MAIL INTERACTIONS + migration.addColumn('mail_interactions', 'firstMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + + // Update the firstMsgDirection column with correct value (direction of the first message for each interactions) + migration.query("UPDATE mail_interactions t1, (SELECT MailInteractionId, MIN(id) AS messageid, ANY_VALUE(direction) AS direction FROM mail_messages WHERE MailInteractionId IS NOT NULL GROUP BY MailInteractionId) t2 SET t1.firstMsgDirection = t2.direction WHERE t1.id = t2.MailInteractionId;"); + // END MAIL INTERACTIONS + + // START FAX INTERACTIONS + migration.addColumn('fax_interactions', 'firstMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + + // Update the firstMsgDirection column with correct value (direction of the first message for each interactions) + migration.query("UPDATE fax_interactions t1, (SELECT FaxInteractionId, MIN(id) AS messageid, ANY_VALUE(direction) AS direction FROM fax_messages WHERE FaxInteractionId IS NOT NULL GROUP BY FaxInteractionId) t2 SET t1.firstMsgDirection = t2.direction WHERE t1.id = t2.FaxInteractionId;"); + // END FAX INTERACTIONS + + // START rtp.conf + try { + fs.writeFileSync('/etc/asterisk/stun_xcally.conf', '; STUN server list\n', { + encoding: 'utf8' + }); + fs.writeFileSync('/etc/asterisk/turn_xcally.conf', '; TURN server list\n', { + encoding: 'utf8' + }); + + var lines = fs.readFileSync('/etc/asterisk/rtp.conf', { + encoding: 'utf8' + }); + + lines = _.replace(lines, '[ice_host_candidates]', '#include "stun_xcally.conf"\n#include "turn_xcally.conf"\n[ice_host_candidates]'); + + fs.writeFileSync('/etc/asterisk/rtp.conf', lines, { + encoding: 'utf8' + }); + fs.appendFileSync('/etc/asterisk/res_stun_monitor.conf', '#include "stun_xcally.conf"', { + encoding: 'utf8' + }); + } catch (err) { + logger.info(JSON.stringify(err)); + } + // END rtp.conf + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.49.js b/server/migrations/2.0.49.js new file mode 100644 index 0000000..16a38af --- /dev/null +++ b/server/migrations/2.0.49.js @@ -0,0 +1,210 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SMS + migration.addColumn('sms_accounts', 'smsMethod', { + type: Sequelize.ENUM('basic', 'classic', 'classic+') + }); + migration.addColumn('sms_accounts', 'username', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'password', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'senderString', { + type: Sequelize.STRING + }); + migration.addColumn('sms_accounts', 'deliveryReport', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END SMS + + // START USERS + migration.addColumn('users', 'allowmessenger', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('users', 'phoneBarOutboundProxy', { + type: Sequelize.STRING + }); + //END USERS + + // START CHATWEBSITE + migration.addColumn('chat_websites', 'offlineMessageSubject', { + type: Sequelize.STRING, + defaultValue: 'New offline message from websiteName' + }); + + migration.addColumn('chat_websites', 'offlineMessageBody', { + type: Sequelize.STRING, + defaultValue: 'You received a new offline message from websiteName. Here you can find the details of the request:' + }); + // END CHATWEBSITE + + // START AGI AFTER + migration.addColumn('voice_queues', 'dialQueueProject2', { + type: Sequelize.STRING + }); + + migration.addColumn('voice_queues', 'dialAgiAfterHangupClient', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('voice_queues', 'dialAgiAfterHangupAgent', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-dialer' AND `priority`= 11"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '11', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '12', 'Hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 4"); + + migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 5"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '4', 'Execif', '$[\"${XMD-AGI}\" != \"NONE\" ]?AGI(${XMD-AGI})', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '5', 'dial', '${XMD-DIALCHANNEL},${XMD-DIALTIMEOUT},${XMD-DIALOPTIONS},${XMD-DIALURL}', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '6', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.addColumn('cm_hopper_final', 'agiafterat', { + type: Sequelize.DATE + }); + + // END AGI AFTER + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.50.js b/server/migrations/2.0.50.js new file mode 100644 index 0000000..5a08644 --- /dev/null +++ b/server/migrations/2.0.50.js @@ -0,0 +1,154 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SMS + migration.changeColumn('sms_messages', 'messageId', { + type: Sequelize.STRING(190), + }); + + migration.addIndex('sms_messages', ['messageId'], 'messageId'); + // END SMS + + // START BOOKED PROGRESSIVE + migration.changeColumn('voice_queues', 'dialMethod', { + type: Sequelize.ENUM('preview', 'progressive', 'power', 'predictive', 'booked'), + defaultValue: 'progressive' + }); + // END BOOKED PROGRESSIVE + + // START AGI AFTER PREVIEW + migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 6"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '6', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '7', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + // END AGI AFTER PREVIEW + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.51.js b/server/migrations/2.0.51.js new file mode 100644 index 0000000..0be8b1a --- /dev/null +++ b/server/migrations/2.0.51.js @@ -0,0 +1,276 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + //START CHAT INTERNAL MESSAGES + migration.addColumn('chat_internal_messages', 'ChatInternalMessageId', { + type: Sequelize.INTEGER + }); + migration.addColumn('chat_internal_messages', 'ChatGroupId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE `chat_internal_messages` \ + ADD CONSTRAINT `chat_internal_messages_ibfk_3` \ + FOREIGN KEY (`ChatGroupId`) \ + REFERENCES chat_groups(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + //END CHAT INTERNAL MESSAGES + + // START CHAT INTERACTIONS + migration.addColumn('chat_interactions', 'lastMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + migration.addColumn('chat_interactions', 'lastMsgAt', { + type: Sequelize.DATE + }); + // END CHAT INTERACTIONS + + // START MAIL INTERACTIONS + migration.addColumn('mail_interactions', 'lastMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + migration.addColumn('mail_interactions', 'lastMsgAt', { + type: Sequelize.DATE + }); + // END MAIL INTERACTIONS + + // START SMS INTERACTIONS + migration.addColumn('sms_interactions', 'lastMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + migration.addColumn('sms_interactions', 'lastMsgAt', { + type: Sequelize.DATE + }); + // END SMS INTERACTIONS + + // START OPENCHANNEL INTERACTIONS + migration.addColumn('openchannel_interactions', 'lastMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + migration.addColumn('openchannel_interactions', 'lastMsgAt', { + type: Sequelize.DATE + }); + // END OPENCHANNEL INTERACTIONS + + // START FAX INTERACTIONS + migration.addColumn('fax_interactions', 'lastMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + migration.addColumn('fax_interactions', 'lastMsgAt', { + type: Sequelize.DATE + }); + // END FAX INTERACTIONS + + var channels = ['Chat', 'Mail', 'Sms', 'Openchannel']; + for (var i = 0; i < channels.length; i++) { + migration.query('UPDATE ' + channels[i].toLowerCase() + '_interactions t1, (SELECT ' + channels[i] + 'InteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \ + FROM ' + channels[i].toLowerCase() + '_messages \ + WHERE ' + channels[i] + 'InteractionId IS NOT NULL AND (direction=\'in\' OR (direction=\'out\' AND secret=0 AND UserId IS NOT NULL)) \ + GROUP BY ' + channels[i] + 'InteractionId) t2 SET t1.lastMsgDirection = t2.direction, t1.lastMsgAt = t2.createdAt WHERE t1.id = t2.' + channels[i] + 'InteractionId;'); + } + + migration.query('UPDATE fax_interactions t1, (SELECT FaxInteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \ + FROM fax_messages \ + WHERE FaxInteractionId IS NOT NULL \ + GROUP BY FaxInteractionId) t2 SET t1.lastMsgDirection = t2.direction, t1.lastMsgAt = t2.createdAt WHERE t1.id = t2.FaxInteractionId;'); + + // START SMS + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel') + }); + // END SMS + + // START VOICECALLREPORT + migration.addColumn('report_call', 'note', { + type: Sequelize.STRING + }); + // END VOICECALLREPORT + + // START CM + migration.addIndex('cm_contacts', ['phone'], 'phone'); + migration.addIndex('cm_hopper_final', ['uniqueid'], 'uniqueid'); + migration.addIndex('cm_hopper_history', ['uniqueid'], 'uniqueid'); + // END CM + + //START VOICERECORDINGS + migration.addIndex('voice_recordings', ['uniqueid'], 'uniqueid'); + //END VOICERECORDINGS + + //START REPORTMEMBER + migration.addIndex('report_member', ['membername', 'interface'], 'membername_interface'); + //END REPORTMEMBER + + //START USERS + migration.query('UPDATE users SET permissions=\'101,102,103,110,104,105,106,107,108,109,100\' WHERE permissions=\'101,102,103,104,105,106,107,108,109,100\''); + //END USERS + + // START DIALER + migration.query("DELETE FROM `voice_extensions` WHERE exten = 'xcally-motion-dialer';"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '1', 'NoOp', '', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '2', 'set', 'CDR(type)=dialer', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '3', 'set', 'CALLERID(all)=${XMD-CALLERID}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '4', 'gotoif', '$[\"${XMD-AMD}\" != \"NONE\" ]?5:11', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '5', 'answer', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '6', 'background', 'silence/1', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '7', 'amd', '${XMD-AMDINITIALSILENCE},${XMD-AMDGREETING},${XMD-AMDAFTERGREETINGSILENCE},${XMD-AMDTOTALANALYSISTIME},${XMD-AMDMINWORDLENGTH},${XMD-AMDBETWEENWORDSSILENCE},${XMD-AMDMAXIMUMNUMBEROFWORDS},${XMD-AMDSILENCETHRESHOLD},${XMD-AMDMAXIMUMWORDLENGTH}', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '8', 'gotoif', '$[\"${AMDSTATUS}\" == \"HUMAN\" ]?11:9', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`,`createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '9', 'gotoif', '$[\"${AMDSTATUS}\" == \"NOTSURE\" ]?11:10', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`,`createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '10', 'gotoif', '$[\"${AMDSTATUS}\" == \"MACHINE\" ]?14:11', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '11', 'execif', '$[\"${XMD-AGI}\" != \"NONE\" ]?AGI(${XMD-AGI})', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '12', 'execif', '$[\"${XMD-QUEUE}\" != \"NONE\" ]?QUEUE(${XMD-QUEUE})', 'system', 'Dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '13', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + + migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '14', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());"); + //END DIALER + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.52.js b/server/migrations/2.0.52.js new file mode 100644 index 0000000..19face4 --- /dev/null +++ b/server/migrations/2.0.52.js @@ -0,0 +1,243 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + //START SETTINGS + migration.addColumn('settings', 'callRecordingEncryption', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('settings', 'passwordExpiresDays', { + type: Sequelize.INTEGER(11), + defaultValue: 90 + }); + migration.query('UPDATE settings SET securePassword=false WHERE id=1'); + //END SETTINGS + + //START CANNED ANSWERS + migration.addColumn('tools_canned_answers', 'MailAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('tools_canned_answers', 'FaxAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('tools_canned_answers', 'SmsAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('tools_canned_answers', 'OpenchannelAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('tools_canned_answers', 'ChatWebsiteId', { + type: Sequelize.INTEGER + }); + + migration.query('ALTER TABLE `tools_canned_answers` \ + ADD CONSTRAINT `tools_canned_answers_ibfk_1` \ + FOREIGN KEY (`MailAccountId`) \ + REFERENCES mail_accounts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + migration.query('ALTER TABLE `tools_canned_answers` \ + ADD CONSTRAINT `tools_canned_answers_ibfk_2` \ + FOREIGN KEY (`FaxAccountId`) \ + REFERENCES fax_accounts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + migration.query('ALTER TABLE `tools_canned_answers` \ + ADD CONSTRAINT `tools_canned_answers_ibfk_3` \ + FOREIGN KEY (`SmsAccountId`) \ + REFERENCES sms_accounts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + migration.query('ALTER TABLE `tools_canned_answers` \ + ADD CONSTRAINT `tools_canned_answers_ibfk_4` \ + FOREIGN KEY (`OpenchannelAccountId`) \ + REFERENCES openchannel_accounts(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + migration.query('ALTER TABLE `tools_canned_answers` \ + ADD CONSTRAINT `tools_canned_answers_ibfk_5` \ + FOREIGN KEY (`ChatWebsiteId`) \ + REFERENCES chat_websites(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + //START CANNED ANSWERS + + //START USERS + migration.addColumn('users', 'passwordResetAt', { + type: Sequelize.DATE, + defaultValue: null + }); + migration.query('UPDATE users SET passwordResetAt=NOW()'); + //END USERS + + //START USERS + migration.addColumn('report_dial', 'duration', { + type: Sequelize.INTEGER + }); + migration.addColumn('report_dial', 'holdtime', { + type: Sequelize.INTEGER + }); + migration.addColumn('report_dial', 'billableseconds', { + type: Sequelize.INTEGER + }); + //END USERS + + // START SMS + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend') + }); + // END SMS + + //START CUSTOM DASHBOARDS + migration.addColumn('dashboard_items', 'background', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#ffffff', + validate: { + notEmpty: true + } + }); + + migration.addColumn('dashboard_items', 'foreground', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#2196f3', + validate: { + notEmpty: true + } + }); + + migration.addColumn('dashboard_items', 'link', { + type: Sequelize.STRING + }); + //END CUSTOM DASHBOARDS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.53.js b/server/migrations/2.0.53.js new file mode 100644 index 0000000..12e9a27 --- /dev/null +++ b/server/migrations/2.0.53.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START CONTACTS + migration.changeColumn('cm_contacts', 'description', { + type: Sequelize.TEXT + }); + // END CONTACTS + + // START SMS + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo') + }); + // END SMS + + // START EXTRACTED REPORTS + migration.changeColumn('analytics_extracted_reports', 'output', { + type: Sequelize.ENUM('csv', 'pdf', 'xls', 'xlsx'), + allowNull: false, + defaultValue: 'csv' + }); + migration.query('UPDATE analytics_extracted_reports SET output=\'xlsx\' WHERE output=\'xls\''); + migration.changeColumn('analytics_extracted_reports', 'output', { + type: Sequelize.ENUM('csv', 'pdf', 'xlsx'), + allowNull: false, + defaultValue: 'csv' + }); + // END EXTRACTED REPORTS + + // START USERS + migration.query('UPDATE users SET insecure=NULL WHERE insecure=\'port,invite\''); + migration.changeColumn('users', 'insecure', { + type: Sequelize.STRING, + allowNull: true + }); + // END USERS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.54.js b/server/migrations/2.0.54.js new file mode 100644 index 0000000..bcb52c7 --- /dev/null +++ b/server/migrations/2.0.54.js @@ -0,0 +1,209 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START CHAT WEBSITES + migration.addColumn('chat_websites', 'textColor', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#ffffff', + validate: { + notEmpty: true + } + }); + migration.addColumn('chat_websites', 'fontSize', { + type: Sequelize.INTEGER, + defaultValue: 15 + }); + migration.addColumn('chat_websites', 'timezone', { + type: Sequelize.STRING + }); + // END CHAT WEBSITES + + // START USERS + migration.query('UPDATE users SET nat=\'force_rport,comedia\' WHERE nat IS NULL'); + migration.query('UPDATE users SET transport=\'udp\' WHERE avpf IS NULL AND transport IS NULL'); + migration.query('UPDATE users SET transport=\'wss\' WHERE avpf IS NOT NULL'); + // STOP USERS + + // START SCHEDULED REPORTS + migration.changeColumn('tools_schedules', 'output', { + type: Sequelize.ENUM('csv', 'pdf', 'xls', 'xlsx'), + allowNull: false, + defaultValue: 'csv' + }); + migration.query('UPDATE tools_schedules SET output=\'xlsx\' WHERE output=\'xls\''); + migration.changeColumn('tools_schedules', 'output', { + type: Sequelize.ENUM('csv', 'pdf', 'xlsx'), + allowNull: false, + defaultValue: 'csv' + }); + // END SCHEDULED REPORTS + + // START MAIL ACCOUNT + migration.addColumn('mail_accounts', 'markAsUnread', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('mail_accounts', 'fontFamily', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: 'Arial,Helvetica,sans-serif' + }); + + migration.addColumn('mail_accounts', 'fontSize', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 13, + validate: { + min: 8, + max: 72 + } + }); + + migration.renameColumn('mail_accounts', 'signature', 'template'); + // END MAIL ACCOUNT + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.55.js b/server/migrations/2.0.55.js new file mode 100644 index 0000000..81ff2e3 --- /dev/null +++ b/server/migrations/2.0.55.js @@ -0,0 +1,166 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SMS ACCOUNT + migration.addColumn('sms_accounts', 'authId', { + type: Sequelize.STRING + }); + // END SMS ACCOUNT + + // START MAIL SUBSTATUS + migration.query('CREATE TABLE `mail_substatuses` ( \ + `id` int(11) NOT NULL AUTO_INCREMENT, \ + `name` varchar(255) NOT NULL, \ + `description` varchar(255) DEFAULT NULL, \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + PRIMARY KEY (`id`), \ + UNIQUE KEY `name` (`name`) \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO `mail_substatuses` (`name`, `description`, `createdAt`, `updatedAt`) VALUES (\'pending\', \'Pending status for mail interaction\', NOW(), NOW());'); + // END MAIL SUBSTATUS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.56.js b/server/migrations/2.0.56.js new file mode 100644 index 0000000..b8ea415 --- /dev/null +++ b/server/migrations/2.0.56.js @@ -0,0 +1,240 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START BOOKED + migration.changeColumn('voice_queues', 'strategy', { + type: Sequelize.ENUM('roundrobin', 'ringall', 'leastrecent', 'fewestcalls', 'random', 'rrmemory', 'linear', 'wrandom', 'rrordered'), + allowNull: false, + defaultValue: 'ringall' + }); + // END BOOKED + + // START EXTRACTED REPORT + migration.addColumn('analytics_extracted_reports', 'basename', { + type: Sequelize.STRING, + allowNull: false + }); + // END EXTRACTED REPORT + + // START MAIL ACCOUNT + migration.addColumn('mail_accounts', 'notificationTemplate', { + type: Sequelize.TEXT + }); + migration.addColumn('mail_accounts', 'notificationSound', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('mail_accounts', 'notificationShake', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END MAIL ACCOUNT + + // START CHAT ACCOUNT + migration.addColumn('chat_websites', 'notificationTemplate', { + type: Sequelize.TEXT + }); + migration.addColumn('chat_websites', 'notificationSound', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('chat_websites', 'notificationShake', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT ACCOUNT + + // START FAX ACCOUNT + migration.addColumn('fax_accounts', 'notificationTemplate', { + type: Sequelize.TEXT + }); + migration.addColumn('fax_accounts', 'notificationSound', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('fax_accounts', 'notificationShake', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END FAX ACCOUNT + + // START SMS ACCOUNT + migration.addColumn('sms_accounts', 'notificationTemplate', { + type: Sequelize.TEXT + }); + migration.addColumn('sms_accounts', 'notificationSound', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('sms_accounts', 'notificationShake', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END SMS ACCOUNT + + // START OPENCHANNEL ACCOUNT + migration.addColumn('openchannel_accounts', 'notificationTemplate', { + type: Sequelize.TEXT + }); + migration.addColumn('openchannel_accounts', 'notificationSound', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('openchannel_accounts', 'notificationShake', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END OPENCHANNEL ACCOUNT + + // START ACCOUNTS UPDATE + migration.query('UPDATE chat_websites SET notificationTemplate=\'Account: {{account.name}}
{{#queue}}Queue: {{queue.name}}
{{/queue}}From : {{from}}\''); + migration.query('UPDATE mail_accounts SET notificationTemplate=\'Account: {{account.name}}
{{#queue}}Queue: {{queue.name}}
{{/queue}}From : {{from}}
Subject : {{message.subject}}\''); + migration.query('UPDATE sms_accounts SET notificationTemplate=\'Account: {{account.name}}
{{#queue}}Queue: {{queue.name}}
{{/queue}}From : {{from}}\''); + migration.query('UPDATE fax_accounts SET notificationTemplate=\'Account: {{account.name}}
{{#queue}}Queue: {{queue.name}}
{{/queue}}From : {{from}}\''); + migration.query('UPDATE openchannel_accounts SET notificationTemplate=\'Account: {{account.name}}
{{#queue}}Queue: {{queue.name}}
{{/queue}}From : {{from}}\''); + // END ACCOUNTS UPDATE + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.57.js b/server/migrations/2.0.57.js new file mode 100644 index 0000000..d4f2f20 --- /dev/null +++ b/server/migrations/2.0.57.js @@ -0,0 +1,168 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START CHAT ACCOUNT + migration.addColumn('chat_websites', 'hideWhenOffline', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT ACCOUNT + + // START VOICE QUEUES + migration.changeColumn('voice_queues', 'periodic_announce', { + type: Sequelize.TEXT + }); + // END VOICE QUEUES + + //START USERS + migration.query('UPDATE users SET permissions=\'101,102,103,110,104,105,106,107,108,109,100,111\' WHERE permissions=\'101,102,103,110,104,105,106,107,108,109,100\''); + //END USERS + + //START ABANDON + migration.query('UPDATE report_queue SET lastAssignedTo=NULL WHERE lastAssignedTo=""'); + //END ABANDON + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.58.js b/server/migrations/2.0.58.js new file mode 100644 index 0000000..a494984 --- /dev/null +++ b/server/migrations/2.0.58.js @@ -0,0 +1,181 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var path = require('path'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START VOICEMAIL + migration.query('ALTER TABLE `voice_voicemail_messages` \ + ADD CONSTRAINT `voice_voicemail_messages_ibfk_1` \ + FOREIGN KEY (`mailboxuser`) \ + REFERENCES voice_voicemail(`mailbox`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + // END VOICEMAIL + + // START REPORT QUEUE + migration.addIndex('report_queue', ['queue'], 'queue'); + migration.addIndex('report_queue', ['queuecallerexitreason'], 'queuecallerexitreason'); + migration.addColumn('report_queue', 'disposition', { + type: Sequelize.STRING + }); + // END REPORT QUEUE + + // START CALLYSQUARE + migration.query("INSERT INTO `square_projects` (`name`, `description`, `notes`, `preproduction`, `production`, `createdAt`, `updatedAt`) VALUES ('AgentManagement', 'Agent Management sample auto generated', NULL, X'3C6D7847726170684D6F64656C20677269643D223122206775696465733D22312220746F6F6C746970733D22312220636F6E6E6563743D22312220666F6C643D22312220706167653D22302220706167655363616C653D223122207061676557696474683D223832362220706167654865696768743D2231313639223E0A20203C726F6F743E0A202020203C6D7843656C6C2069643D2230222F3E0A202020203C6D7843656C6C2069643D22312220706172656E743D2230222F3E0A202020203C7374617274206C6162656C3D2253746172742220616E737765723D22796573222069643D2239223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F656E7472792F73746172745F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D2234302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F73746172743E0A202020203C6D656E75206C6162656C3D224D656E75222066696C655F69643D222220726573706F6E73653D2235222064696769743D2231222072657472793D223122207661726961626C655F69643D2230222069643D223136223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F6D656E755F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223137302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6D656E753E0A202020203C6C6F67696E206C6162656C3D224C6F67696E222066696E6442793D22696E7465726E616C222069643D223339223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F6C6F67696E5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D223132222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6C6F67696E3E0A202020203C7061757365206C6162656C3D225061757365222066696E6442793D22696E7465726E616C222070617573655F69643D22222069643D223430223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F70617573655F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22333434222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F70617573653E0A202020203C756E7061757365206C6162656C3D22556E7061757365222066696E6442793D22696E7465726E616C222069643D223431223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F756E70617573655F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22343634222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F756E70617573653E0A202020203C6C6F676F7574206C6162656C3D224C6F676F7574222066696E6442793D22696E7465726E616C222069643D223432223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F6C6F676F75745F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22313332222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6C6F676F75743E0A202020203C6D7843656C6C2069643D223433222076616C75653D22312220706172656E743D22312220736F757263653D22313622207461726765743D2233392220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223231302220793D22313432222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223434222076616C75653D22322220706172656E743D22312220736F757263653D22313622207461726765743D2234322220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223435222076616C75653D22332220706172656E743D22312220736F757263653D22313622207461726765743D2234302220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223436222076616C75653D22342220706172656E743D22312220736F757263653D22313622207461726765743D2234312220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223231302220793D22343134222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2234372220706172656E743D22312220736F757263653D223922207461726765743D2231362220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223438223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223435302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C6D7843656C6C2069643D223530222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343222207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223531222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343022207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C68616E677570206C6162656C3D2248616E677570222069643D223533223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F63616C6C5F6D616E6167656D656E742F68616E6775705F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223735302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F68616E6775703E0A202020203C6D7843656C6C2069643D2235342220706172656E743D22312220736F757263653D22343822207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223535222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22333922207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223439302220793D22313730222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223536222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343122207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223439302220793D22333930222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223537223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22313332222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223538223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D223132222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223539223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22333434222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223630223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22343634222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C6D7843656C6C2069643D223631222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22333922207461726765743D2235382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223632222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343222207461726765743D2235372220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223633222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343022207461726765743D2235392220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223634222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343122207461726765743D2236302220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236352220706172656E743D22312220736F757263653D22353822207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236362220706172656E743D22312220736F757263653D22353722207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236372220706172656E743D22312220736F757263653D22353922207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236382220706172656E743D22312220736F757263653D22363022207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A20203C2F726F6F743E0A3C2F6D7847726170684D6F64656C3E', X'3C6D7847726170684D6F64656C20677269643D223122206775696465733D22312220746F6F6C746970733D22312220636F6E6E6563743D22312220666F6C643D22312220706167653D22302220706167655363616C653D223122207061676557696474683D223832362220706167654865696768743D2231313639223E0A20203C726F6F743E0A202020203C6D7843656C6C2069643D2230222F3E0A202020203C6D7843656C6C2069643D22312220706172656E743D2230222F3E0A202020203C7374617274206C6162656C3D2253746172742220616E737765723D22796573222069643D2239223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F656E7472792F73746172745F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D2234302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F73746172743E0A202020203C6D656E75206C6162656C3D224D656E75222066696C655F69643D222220726573706F6E73653D2235222064696769743D2231222072657472793D223122207661726961626C655F69643D2230222069643D223136223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F6D656E755F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223137302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6D656E753E0A202020203C6C6F67696E206C6162656C3D224C6F67696E222066696E6442793D22696E7465726E616C222069643D223339223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F6C6F67696E5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D223132222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6C6F67696E3E0A202020203C7061757365206C6162656C3D225061757365222066696E6442793D22696E7465726E616C222070617573655F69643D22222069643D223430223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F70617573655F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22333434222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F70617573653E0A202020203C756E7061757365206C6162656C3D22556E7061757365222066696E6442793D22696E7465726E616C222069643D223431223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F756E70617573655F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22343634222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F756E70617573653E0A202020203C6C6F676F7574206C6162656C3D224C6F676F7574222066696E6442793D22696E7465726E616C222069643D223432223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F6167656E745F6D616E6167656D656E742F6C6F676F75745F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223332302220793D22313332222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F6C6F676F75743E0A202020203C6D7843656C6C2069643D223433222076616C75653D22312220706172656E743D22312220736F757263653D22313622207461726765743D2233392220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223231302220793D22313432222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223434222076616C75653D22322220706172656E743D22312220736F757263653D22313622207461726765743D2234322220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223435222076616C75653D22332220706172656E743D22312220736F757263653D22313622207461726765743D2234302220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223436222076616C75653D22342220706172656E743D22312220736F757263653D22313622207461726765743D2234312220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223231302220793D22343134222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2234372220706172656E743D22312220736F757263653D223922207461726765743D2231362220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223438223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223435302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C6D7843656C6C2069643D223530222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343222207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223531222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343022207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C68616E677570206C6162656C3D2248616E677570222069643D223533223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F63616C6C5F6D616E6167656D656E742F68616E6775705F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223735302220793D22323338222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F68616E6775703E0A202020203C6D7843656C6C2069643D2235342220706172656E743D22312220736F757263653D22343822207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223535222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22333922207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223439302220793D22313730222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223536222076616C75653D226661696C7572652220706172656E743D22312220736F757263653D22343122207461726765743D2234382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279223E0A20202020202020203C41727261792061733D22706F696E7473223E0A202020202020202020203C6D78506F696E7420783D223439302220793D22333930222F3E0A20202020202020203C2F41727261793E0A2020202020203C2F6D7847656F6D657472793E0A202020203C2F6D7843656C6C3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223537223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22313332222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223538223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D223132222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223539223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22333434222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C706C61796261636B206C6162656C3D22506C61796261636B222066696C655F69643D2222206F7074733D22222069643D223630223E0A2020202020203C6D7843656C6C207374796C653D22696D6167653B68746D6C3D313B6C6162656C4261636B67726F756E64436F6C6F723D236666666666663B696D6167653D2F6173736574732F706C7567696E732F7371756172652F7374656E63696C732F706C61796261636B2F706C61796261636B5F313238783132382E706E672220706172656E743D223122207665727465783D2231223E0A20202020202020203C6D7847656F6D6574727920783D223630302220793D22343634222077696474683D22383022206865696768743D223830222061733D2267656F6D65747279222F3E0A2020202020203C2F6D7843656C6C3E0A202020203C2F706C61796261636B3E0A202020203C6D7843656C6C2069643D223631222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22333922207461726765743D2235382220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223632222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343222207461726765743D2235372220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223633222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343022207461726765743D2235392220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D223634222076616C75653D22737563636573732220706172656E743D22312220736F757263653D22343122207461726765743D2236302220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236352220706172656E743D22312220736F757263653D22353822207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236362220706172656E743D22312220736F757263653D22353722207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236372220706172656E743D22312220736F757263653D22353922207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A202020203C6D7843656C6C2069643D2236382220706172656E743D22312220736F757263653D22363022207461726765743D2235332220656467653D2231223E0A2020202020203C6D7847656F6D657472792072656C61746976653D2231222061733D2267656F6D65747279222F3E0A202020203C2F6D7843656C6C3E0A20203C2F726F6F743E0A3C2F6D7847726170684D6F64656C3E', '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent Login', 'agentmanagement-login', 'Agent Login', 'auto generated sound', 'mp3', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent Logout', 'agentmanagement-logout', 'Agent Logout', 'auto generated sound', 'mp3', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent Menu', 'agentmanagement-menu', 'Agent Menu', 'auto generated sound', 'wav', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent Pause', 'agentmanagement-pause', 'Agent Pause', 'auto generated sound', 'mp3', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent End Pause', 'agentmanagement-unpause', 'Agent End Pause', 'auto generated sound', 'mp3', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + + migration.query("INSERT INTO `tools_sounds` (`name`, `save_name`, `display_name`, `description`, `original_format`, `original_duration`, `original_sampleCount`, `original_channelCount`, `original_bitRate`, `original_sampleRate`, `converted_format`, `converted_duration`, `converted_sampleCount`, `converted_channelCount`, `converted_bitRate`, `converted_sampleRate`, `createdAt`, `updatedAt`) VALUES ('Agent Action Failure', 'agentmanagement-action-failure', 'Agent Action Failure', 'auto generated sound', 'wav', NULL, NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, '2018-05-24 11:44:53', '2018-05-24 11:44:53');"); + // END CALLYSQUARE + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.59.js b/server/migrations/2.0.59.js new file mode 100644 index 0000000..4849a76 --- /dev/null +++ b/server/migrations/2.0.59.js @@ -0,0 +1,244 @@ +'use strict'; + +var BPromise = require('bluebird'); +var fs = require('fs'); +var path = require('path'); +var util = require('util'); +var _ = require('lodash'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function(res) { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function(res) { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function(res) { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function(res) { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function(res) { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function(res) { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + var _this = this; + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve, reject) { + + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'phoneBarAutoUpdater', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + migration.addColumn('settings', 'phoneBarAutoUpdaterUrl', { + type: Sequelize.STRING, + defaultValue: 'https://www.xcally.com/bar/phonebar/autoupdater.xml' + }); + // END SETTINGS + + // START PREFIX + migration.addColumn('campaigns', 'dialPrefix', { + type: Sequelize.STRING + }); + // END PREFIX + + // START CM LIST + migration.addColumn('cm_lists', 'dialPrefix', { + type: Sequelize.STRING + }); + // END CM LIST + + // START USER + migration.addColumn('users', 'alias', { + type: Sequelize.STRING + }); + // END USER + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'skype', { + type: Sequelize.STRING + }); + migration.addColumn('cm_contacts', 'UserId', { + type: Sequelize.INTEGER + }); + migration.addColumn('cm_contacts', 'priority', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 2, + validate: { + min: 0, + max: 4 + } + }); + migration.addColumn('cm_contacts', 'scheduledat', { + type: Sequelize.DATE, + defaultValue: Sequelize.NOW + }); + // END CM CONTACTS + + // START MAIL INTERACTION + migration.addColumn('mail_interactions', 'openedBy', { + type: Sequelize.STRING, + defaultValue: '' + }); + // END MAIL INTERACTION + + // START CHAT INTERACTION + migration.addColumn('chat_interactions', 'openedBy', { + type: Sequelize.STRING, + defaultValue: '' + }); + // END CHAT INTERACTION + + // START SMS INTERACTION + migration.addColumn('sms_interactions', 'openedBy', { + type: Sequelize.STRING, + defaultValue: '' + }); + // END SMS INTERACTION + + // START OPENCHANNEL INTERACTION + migration.addColumn('openchannel_interactions', 'openedBy', { + type: Sequelize.STRING, + defaultValue: '' + }); + // END OPENCHANNEL INTERACTION + + // START FAX INTERACTION + migration.addColumn('fax_interactions', 'openedBy', { + type: Sequelize.STRING, + defaultValue: '' + }); + // END FAX INTERACTION + + // START VOICEMAIL + migration.query('DELETE FROM `voice_voicemail_messages` WHERE `mailboxuser` NOT IN (SELECT `mailbox` FROM `voice_voicemail`)'); + + migration.query('ALTER TABLE `voice_voicemail_messages` \ + ADD CONSTRAINT `voice_voicemail_messages_ibfk_1` \ + FOREIGN KEY (`mailboxuser`) \ + REFERENCES voice_voicemail(`mailbox`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + // END VOICEMAIL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.60.js b/server/migrations/2.0.60.js new file mode 100644 index 0000000..b321901 --- /dev/null +++ b/server/migrations/2.0.60.js @@ -0,0 +1,240 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START CHAT WEBSITES + migration.addColumn('chat_websites', 'agentIdentifier', { + type: Sequelize.STRING, + defaultValue: 'website_alias' + }); + + migration.addColumn('chat_websites', 'waitForTheAssignedAgent', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 10 + }); + // END CHAT WEBSITES + + // START chat_interactions + migration.removeColumn('chat_interactions', 'openedBy'); + // END chat_interactions + + // START mail_interactions + migration.removeColumn('mail_interactions', 'openedBy'); + + migration.addColumn('mail_interactions', 'lastMsgBody', { + type: Sequelize.TEXT('long') + }); + // END mail_interactions + + // START sms_interactions + migration.removeColumn('sms_interactions', 'openedBy'); + // END sms_interactions + + // START fax_interactions + migration.removeColumn('fax_interactions', 'openedBy'); + // END fax_interactions + + // START openchannel_interactions + migration.removeColumn('openchannel_interactions', 'openedBy'); + // END openchannel_interactions + + // START OPENCHANNEL INTERACTION + migration.addColumn('openchannel_interactions', 'from', { + type: Sequelize.STRING + }); + // END OPENCHANNEL INTERACTION + + // START MAIL ACCOUNT + migration.addColumn('mail_accounts', 'waitForTheAssignedAgent', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 10 + }); + // END MAIL ACCOUNT + + // START OPENCHANNEL ACCOUNT + migration.addColumn('openchannel_accounts', 'waitForTheAssignedAgent', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 10 + }); + // END OPENCHANNEL ACCOUNT + + // START OPENCHANNEL ACCOUNT + migration.addColumn('fax_accounts', 'waitForTheAssignedAgent', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 10 + }); + // END OPENCHANNEL ACCOUNT + + // START SMS ACCOUNT + migration.addColumn('sms_accounts', 'waitForTheAssignedAgent', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 10 + }); + // END SMS ACCOUNT + + // START USERS + migration.addColumn('users', 'phoneBarEnableJaws', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + //END USERS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.61.js b/server/migrations/2.0.61.js new file mode 100644 index 0000000..5aaa180 --- /dev/null +++ b/server/migrations/2.0.61.js @@ -0,0 +1,143 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.62.js b/server/migrations/2.0.62.js new file mode 100644 index 0000000..59ad495 --- /dev/null +++ b/server/migrations/2.0.62.js @@ -0,0 +1,176 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START CUSTOM REPORTS + migration.addColumn('tools_schedules', 'sendIfEmpty', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END CUSTOM REPORTS + + // START CM CONTACTS + migration.changeColumn('cm_contacts', 'phone', { + type: Sequelize.STRING, + allowNull: true + }); + // END CM CONTACTS + + // START SETTINGS + migration.addColumn('settings', 'enableEmailPreview', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END SETTINGS + + // START CHAT WEBSITE + migration.addColumn('chat_websites', 'alignment', { + type: Sequelize.STRING, + defaultValue: 'bottom_right' + }); + + migration.addColumn('chat_websites', 'verticalAlignment', { + type: Sequelize.INTEGER, + defaultValue: 30 + }); + // END CHAT WEBSITE + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.63.js b/server/migrations/2.0.63.js new file mode 100644 index 0000000..528245a --- /dev/null +++ b/server/migrations/2.0.63.js @@ -0,0 +1,253 @@ +'use strict'; + +var BPromise = require('bluebird'); +var rs = require('randomstring'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START CHAT WEBSITE + migration.addColumn('chat_websites', 'messagesAlignment', { + type: Sequelize.STRING, + defaultValue: 'alternate' + }); + + migration.addColumn('chat_websites', 'defaultTitle', { + type: Sequelize.STRING + }); + + migration.addColumn('chat_websites', 'customerAvatar', { + type: Sequelize.TEXT + }); + + migration.addColumn('chat_websites', 'showCustomerAvatar', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END CHAT WEBSITE + + //START TAG APPLICATION + + migration.addColumn('chat_applications', 'TagId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `chat_applications` \ + ADD CONSTRAINT `chat_applications_ibfk_5` \ + FOREIGN KEY (`TagId`) \ + REFERENCES tools_tags(`id`) \ + ON UPDATE CASCADE' + ); + + migration.addColumn('fax_applications', 'TagId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `fax_applications` \ + ADD CONSTRAINT `fax_applications_ibfk_5` \ + FOREIGN KEY (`TagId`) \ + REFERENCES tools_tags(`id`) \ + ON UPDATE CASCADE' + ); + + migration.addColumn('mail_applications', 'TagId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `mail_applications` \ + ADD CONSTRAINT `mail_applications_ibfk_5` \ + FOREIGN KEY (`TagId`) \ + REFERENCES tools_tags(`id`) \ + ON UPDATE CASCADE' + ); + + migration.addColumn('openchannel_applications', 'TagId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `openchannel_applications` \ + ADD CONSTRAINT `openchannel_applications_ibfk_5` \ + FOREIGN KEY (`TagId`) \ + REFERENCES tools_tags(`id`) \ + ON UPDATE CASCADE' + ); + + migration.addColumn('sms_applications', 'TagId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `sms_applications` \ + ADD CONSTRAINT `sms_applications_ibfk_5` \ + FOREIGN KEY (`TagId`) \ + REFERENCES tools_tags(`id`) \ + ON UPDATE CASCADE' + ); + + //END TAG APPLICATION + + //START REPORT_DIAL + migration.query('ALTER TABLE report_dial CHANGE `hodltime` `holdtime` INT(11) DEFAULT NULL'); + //END REPORT_DIAL + + //START OPENCHANNEL TOKEN + migration.addColumn('openchannel_accounts', 'token', { + type: Sequelize.STRING + }); + //END OPENCHANNEL TOKEN + + // START VOICE QUEUE LOG + migration.addColumn('voice_queues_log', 'data', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '' + }); + // END VOICE QUEUE LOG + + // START CUSTOM DASHBOARD WIDGET + migration.changeColumn('dashboard_items', 'title', { + type: Sequelize.STRING, + allowNull: false + }); + // END CUSTOM DASHBOARD WIDGET + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.64.js b/server/migrations/2.0.64.js new file mode 100644 index 0000000..3452849 --- /dev/null +++ b/server/migrations/2.0.64.js @@ -0,0 +1,188 @@ +'use strict'; + +var BPromise = require('bluebird'); +var rs = require('randomstring'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function(res) { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START USERS + migration.addColumn('users', 'phoneBarEnableVideoRecording', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + //END USERS + + // START REPORT CALL + migration.changeColumn('report_call', 'lastdata', { + type: Sequelize.TEXT + }); + // END REPORT CALL + + // START CHAT WEBSITE + migration.addColumn('chat_websites', 'customerAlias', { + type: Sequelize.STRING, + defaultValue: 'Me' + }); + // END CHAT WEBSITE + + // START analytics_report_fields + migration.changeColumn('analytics_report_fields', 'field', { + type: Sequelize.TEXT, + allowNull: false + }); + // END analytics_report_fields + + // START report_call + migration.removeIndex('report_call', 'uniqueid'); + // END report_call + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.65.js b/server/migrations/2.0.65.js new file mode 100644 index 0000000..237f33a --- /dev/null +++ b/server/migrations/2.0.65.js @@ -0,0 +1,235 @@ +'use strict'; + +var BPromise = require('bluebird'); +var rs = require('randomstring'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START VOICEQUEUE + migration.addColumn('voice_queues', 'dialRandomLastDigitCallerIdNumber', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 0 + }); + migration.addColumn('voice_queues', 'dialCutDigit', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 0 + }); + // END VOICEQUEUE + + // START IVR CAMPAIGN + migration.addColumn('campaigns', 'dialRandomLastDigitCallerIdNumber', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 0 + }); + migration.addColumn('campaigns', 'dialCutDigit', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 0 + }); + // END IVR CAMPAIGN + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'teams', { + type: Sequelize.STRING + }); + // END CM CONTACTS + + // START cm_contact_has_tags + migration.query('CREATE TABLE `cm_contact_has_tags` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `CmContactId` int(11) NOT NULL, \ + `TagId` int(11) NOT NULL, \ + PRIMARY KEY (`CmContactId`,`TagId`), \ + KEY `TagId` (`TagId`), \ + CONSTRAINT `cm_contact_has_tags_ibfk_1` FOREIGN KEY (`CmContactId`) REFERENCES `cm_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `cm_contact_has_tags_ibfk_2` FOREIGN KEY (`TagId`) REFERENCES `tools_tags` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + // END cm_contact_has_tags + + migration.query('CREATE TABLE `tmp_tools_tags` (\ + `id` int(11) NOT NULL AUTO_INCREMENT, \ + `name` varchar(255) NOT NULL, \ + `color` varchar(255) DEFAULT \'#0091EA\', \ + `description` varchar(255) DEFAULT NULL, \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET=utf8;'); + migration.query('CREATE TABLE ints(i int(11) DEFAULT NULL,UNIQUE KEY i_UNIQUE (i)) ENGINE=InnoDB DEFAULT CHARSET=utf8'); + migration.query('INSERT INTO ints(i) VALUES (0)'); + migration.query('INSERT INTO ints(i) VALUES (1)'); + migration.query('INSERT INTO ints(i) VALUES (2)'); + migration.query('INSERT INTO ints(i) VALUES (3)'); + migration.query('INSERT INTO ints(i) VALUES (4)'); + migration.query('INSERT INTO ints(i) VALUES (5)'); + migration.query('INSERT INTO ints(i) VALUES (6)'); + migration.query('INSERT INTO ints(i) VALUES (7)'); + migration.query('INSERT INTO ints(i) VALUES (8)'); + migration.query('INSERT INTO ints(i) VALUES (9)'); + migration.query('ALTER TABLE tmp_tools_tags ADD COLUMN contact_id INT NULL'); + + migration.query('INSERT INTO tmp_tools_tags( name, createdAt, updatedAt, contact_id)\ + SELECT splitted_tags, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP() , id \ + FROM ( \ + SELECT DISTINCT cm.id, cm.tags, TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(cm.tags, \';\', i+1),\';\',-1)) splitted_tags\ + FROM ints i, cm_contacts cm \ + WHERE cm.tags REGEXP \'(.*;){1}\'\ + ORDER BY id) a\ + WHERE a.tags IS NOT NULL and splitted_tags <> \'\';'); + + migration.query('INSERT INTO cm_contact_has_tags(createdAt, updatedAt, `CmContactId`, `TagId`) \ + SELECT NOW(), NOW(), tmt.contact_id, tt.id \ + FROM tmp_tools_tags tmt \ + JOIN tools_tags tt \ + ON tmt.name = tt.name;'); + // END cm_contact_has_tags + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.66.js b/server/migrations/2.0.66.js new file mode 100644 index 0000000..ca4ecd7 --- /dev/null +++ b/server/migrations/2.0.66.js @@ -0,0 +1,246 @@ +'use strict'; + +var BPromise = require('bluebird'); +var rs = require('randomstring'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START analytics_report_fields + migration.changeColumn('analytics_report_fields', 'field', { + type: Sequelize.TEXT + }); + // END analytics_report_fields + + // START tools_schedules + migration.addColumn('tools_schedules', 'cc', { + type: Sequelize.TEXT + }); + + migration.addColumn('tools_schedules', 'bcc', { + type: Sequelize.TEXT + }); + + migration.addColumn('settings', 'split', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('settings', 'splitSizeCsv', { + type: Sequelize.INTEGER, + defaultValue: 5000 + }); + + migration.addColumn('settings', 'splitSizePdf', { + type: Sequelize.INTEGER, + defaultValue: 1000 + }); + + migration.addColumn('settings', 'splitSizeXlsx', { + type: Sequelize.INTEGER, + defaultValue: 5000 + }); + // END tools_schedules + + // START mail_accounts + migration.addColumn('mail_accounts', 'queueTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('mail_accounts', 'queueTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + + migration.addColumn('mail_accounts', 'agentTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('mail_accounts', 'agentTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + // END mail_accounts + + // START users + migration.addColumn('users', 'phoneBarPrefixRequired', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END users + + // START mail_interactions + migration.changeColumn('mail_interactions', 'subject', { + type: Sequelize.TEXT('') + ' CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci' + }); + + migration.changeColumn('mail_interactions', 'lastMsgBody', { + type: Sequelize.TEXT('long') + ' CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci' + }); + // END mail_interactions + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'viber', { + type: Sequelize.STRING + }); + // END CM CONTACTS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.67.js b/server/migrations/2.0.67.js new file mode 100644 index 0000000..9b22627 --- /dev/null +++ b/server/migrations/2.0.67.js @@ -0,0 +1,298 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + var toolsDispositionsQuery = 'CREATE TABLE `tools_dispositions` (\ + `id` int(11) NOT NULL AUTO_INCREMENT,\ + `name` varchar(255) NOT NULL,\ + `createdAt` datetime NOT NULL,\ + `updatedAt` datetime NOT NULL,\ + `MailAccountId` int(11) DEFAULT NULL,\ + `FaxAccountId` int(11) DEFAULT NULL,\ + `SmsAccountId` int(11) DEFAULT NULL,\ + `OpenchannelAccountId` int(11) DEFAULT NULL,\ + `ChatWebsiteId` int(11) DEFAULT NULL,\ + `ListId` int(11) DEFAULT NULL,\ + PRIMARY KEY (`id`),\ + UNIQUE KEY `name_voice` (`name`,`ListId`),\ + UNIQUE KEY `name_chat` (`name`,`ChatWebsiteId`),\ + UNIQUE KEY `name_mail` (`name`,`MailAccountId`),\ + UNIQUE KEY `name_sms` (`name`,`SmsAccountId`),\ + UNIQUE KEY `name_fax` (`name`,`FaxAccountId`),\ + UNIQUE KEY `name_openchannel` (`name`,`OpenchannelAccountId`),\ + KEY `MailAccountId` (`MailAccountId`),\ + KEY `FaxAccountId` (`FaxAccountId`),\ + KEY `SmsAccountId` (`SmsAccountId`),\ + KEY `OpenchannelAccountId` (`OpenchannelAccountId`),\ + KEY `ChatWebsiteId` (`ChatWebsiteId`),\ + KEY `ListId` (`ListId`),\ + CONSTRAINT `tools_dispositions_ibfk_1` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\ + CONSTRAINT `tools_dispositions_ibfk_2` FOREIGN KEY (`FaxAccountId`) REFERENCES `fax_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\ + CONSTRAINT `tools_dispositions_ibfk_3` FOREIGN KEY (`SmsAccountId`) REFERENCES `sms_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\ + CONSTRAINT `tools_dispositions_ibfk_4` FOREIGN KEY (`OpenchannelAccountId`) REFERENCES `openchannel_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\ + CONSTRAINT `tools_dispositions_ibfk_5` FOREIGN KEY (`ChatWebsiteId`) REFERENCES `chat_websites` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\ + CONSTRAINT `tools_dispositions_ibfk_6` FOREIGN KEY (`ListId`) REFERENCES `cm_lists` (`id`) ON DELETE SET NULL ON UPDATE CASCADE\ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;' + + // START tools_dispositions + migration.query(toolsDispositionsQuery); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `ChatWebsiteId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `ChatWebsiteId` FROM chat_dispositions;'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `MailAccountId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `MailAccountId` FROM mail_dispositions;'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `FaxAccountId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `FaxAccountId` FROM fax_dispositions;'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `SmsAccountId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `SmsAccountId` FROM sms_dispositions;'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `OpenchannelAccountId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `OpenchannelAccountId` FROM openchannel_dispositions;'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`, `ListId`) \ + SELECT `name`, `createdAt`, `updatedAt`, `ListId` FROM voice_dispositions;'); + // END tools_dispositions + + // START user_has_chat_websites + migration.query('CREATE TABLE `user_has_chat_websites` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `ChatWebsiteId` int(11) NOT NULL, \ + `UserId` int(11) NOT NULL, \ + PRIMARY KEY (`ChatWebsiteId`,`UserId`), \ + KEY `UserId` (`UserId`), \ + CONSTRAINT `user_has_chat_websites_ibfk_1` FOREIGN KEY (`ChatWebsiteId`) REFERENCES `chat_websites` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `user_has_chat_websites_ibfk_2` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO user_has_chat_websites (`UserId`, `ChatWebsiteId`, `createdAt`, `updatedAt`) \ + SELECT u.id as `UserId`, a.id as `ChatWebsiteId`, NOW() as `createdAt`, NOW() as `updatedAt` \ + FROM users as u, chat_websites as a \ + ORDER BY u.id, a.id;'); + // END user_has_chat_websites + + // START user_has_mail_accounts + migration.query('CREATE TABLE `user_has_mail_accounts` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `MailAccountId` int(11) NOT NULL, \ + `UserId` int(11) NOT NULL, \ + PRIMARY KEY (`MailAccountId`,`UserId`), \ + KEY `UserId` (`UserId`), \ + CONSTRAINT `user_has_mail_accounts_ibfk_1` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `user_has_mail_accounts_ibfk_2` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO user_has_mail_accounts (`UserId`, `MailAccountId`, `createdAt`, `updatedAt`) \ + SELECT u.id as `UserId`, a.id as `MailAccountId`, NOW() as `createdAt`, NOW() as `updatedAt` \ + FROM users as u, mail_accounts as a \ + ORDER BY u.id, a.id;'); + // END user_has_mail_accounts + + // START user_has_fax_accounts + migration.query('CREATE TABLE `user_has_fax_accounts` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `FaxAccountId` int(11) NOT NULL, \ + `UserId` int(11) NOT NULL, \ + PRIMARY KEY (`FaxAccountId`,`UserId`), \ + KEY `UserId` (`UserId`), \ + CONSTRAINT `user_has_fax_accounts_ibfk_1` FOREIGN KEY (`FaxAccountId`) REFERENCES `fax_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `user_has_fax_accounts_ibfk_2` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO user_has_fax_accounts (`UserId`, `FaxAccountId`, `createdAt`, `updatedAt`) \ + SELECT u.id as `UserId`, a.id as `FaxAccountId`, NOW() as `createdAt`, NOW() as `updatedAt` \ + FROM users as u, fax_accounts as a \ + ORDER BY u.id, a.id;'); + // END user_has_fax_accounts + + // START user_has_sms_accounts + migration.query('CREATE TABLE `user_has_sms_accounts` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `SmsAccountId` int(11) NOT NULL, \ + `UserId` int(11) NOT NULL, \ + PRIMARY KEY (`SmsAccountId`,`UserId`), \ + KEY `UserId` (`UserId`), \ + CONSTRAINT `user_has_sms_accounts_ibfk_1` FOREIGN KEY (`SmsAccountId`) REFERENCES `sms_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `user_has_sms_accounts_ibfk_2` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO user_has_sms_accounts (`UserId`, `SmsAccountId`, `createdAt`, `updatedAt`) \ + SELECT u.id as `UserId`, a.id as `SmsAccountId`, NOW() as `createdAt`, NOW() as `updatedAt` \ + FROM users as u, sms_accounts as a \ + ORDER BY u.id, a.id;'); + // END user_has_sms_accounts + + // START user_has_openchannel_accounts + migration.query('CREATE TABLE `user_has_openchannel_accounts` ( \ + `createdAt` datetime NOT NULL, \ + `updatedAt` datetime NOT NULL, \ + `OpenchannelAccountId` int(11) NOT NULL, \ + `UserId` int(11) NOT NULL, \ + PRIMARY KEY (`OpenchannelAccountId`,`UserId`), \ + KEY `UserId` (`UserId`), \ + CONSTRAINT `user_has_openchannel_accounts_ibfk_1` FOREIGN KEY (`OpenchannelAccountId`) REFERENCES `openchannel_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, \ + CONSTRAINT `user_has_openchannel_accounts_ibfk_2` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE \ + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + migration.query('INSERT INTO user_has_openchannel_accounts (`UserId`, `OpenchannelAccountId`, `createdAt`, `updatedAt`) \ + SELECT u.id as `UserId`, a.id as `OpenchannelAccountId`, NOW() as `createdAt`, NOW() as `updatedAt` \ + FROM users as u, openchannel_accounts as a \ + ORDER BY u.id, a.id;'); + // END user_has_openchannel_accounts + + // START mail_messages + migration.addColumn('mail_messages', 'originTo', { + type: Sequelize.TEXT('long') + }); + + migration.addColumn('mail_messages', 'originCc', { + type: Sequelize.TEXT('long') + }); + // START mail_messages + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.68.js b/server/migrations/2.0.68.js new file mode 100644 index 0000000..7942445 --- /dev/null +++ b/server/migrations/2.0.68.js @@ -0,0 +1,183 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Fax\', NOW(), NOW())'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Answer Machine\', NOW(), NOW())'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Interested\', NOW(), NOW())'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Not Interested\', NOW(), NOW())'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Sold\', NOW(), NOW())'); + migration.query('INSERT INTO tools_dispositions (`name`, `createdAt`, `updatedAt`) VALUES (\'Special\', NOW(), NOW())'); + + // START openchannel_accounts + migration.addColumn('openchannel_accounts', 'mapKey', { + type: Sequelize.STRING + }); + // END openchannel_accounts + + // START chat_interactions + migration.addColumn('chat_interactions', 'closeReason', { + type: Sequelize.STRING + }); + // END chat_interactions + + // START SETTINGS + migration.addColumn('settings', 'messagesAlignment', { + type: Sequelize.STRING + }); + + migration.query('UPDATE settings SET messagesAlignment=\'alternate\''); + // END SETTINGS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.69.js b/server/migrations/2.0.69.js new file mode 100644 index 0000000..a564b29 --- /dev/null +++ b/server/migrations/2.0.69.js @@ -0,0 +1,242 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START report_jscripty_answers + migration.changeColumn('report_jscripty_answers', 'answer', { + type: Sequelize.TEXT('long') + }); + // END report_jscripty_answers + + // START report_jscripty_questions + migration.changeColumn('report_jscripty_questions', 'answer', { + type: Sequelize.TEXT('long') + }); + // END report_jscripty_questions + + // START tools_sounds + migration.query( + 'UPDATE tools_sounds S1 JOIN \ + (SELECT name FROM tools_sounds GROUP BY name HAVING COUNT(id) > 1) S2 \ + ON S1.name = S2.name \ + SET S1.name = CONCAT(S1.name, \'_\', LOWER(LPAD(CONV(FLOOR(RAND()*POW(36,6)), 10, 36), 6, 0)))' + ); + + migration.changeColumn('tools_sounds', 'name', { + type: Sequelize.STRING, + unique: true, + allowNull: false + }); + // END tools_sounds + // START chat_websites + migration.addColumn('chat_websites', 'messageFontSize', { + type: Sequelize.INTEGER, + defaultValue: 12 + }); + + migration.addColumn('chat_websites', 'backgroundColor', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#fafafa', + validate: { + notEmpty: true + } + }); + // END chat_websites + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'line', { + type: Sequelize.STRING + }); + // END CM CONTACTS + + // START voice_prefixes + migration.query('DELETE FROM `voice_prefixes`'); + migration.query('DELETE FROM `user_has_voice_prefixes`'); + migration.removeIndex('voice_prefixes', 'prefix'); + migration.removeColumn('voice_prefixes', 'prefix'); + migration.addColumn('voice_prefixes', 'callerIdAll', { + type: Sequelize.STRING + }); + migration.addColumn('voice_prefixes', 'VoiceExtensionId', { + type: Sequelize.INTEGER + }); + // END voice_prefixes + + // START voice_extensions + migration.addColumn('voice_extensions', 'VoicePrefixId', { + type: Sequelize.INTEGER + }); + + migration.query( + 'ALTER TABLE `voice_extensions` \ + ADD CONSTRAINT `voice_extensions_ibfk_7` \ + FOREIGN KEY (`VoicePrefixId`) \ + REFERENCES voice_prefixes(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE' + ); + + migration.query( + 'update voice_extensions set app = \'ExecIf\', appdata = CONCAT(\'$[${LEN(${PREFIX-CALLERIDALL})} > 0]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(\', appdata, \')\') where appdata LIKE CONCAT(\'CALLERID(all)\', \'%\') and type = \'outbound\'' + ); + // END voice_extensions + + // START REPORT CALL + migration.addColumn('report_call', 'prefix', { + type: Sequelize.STRING + }); + // END REPORT CALL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.70.js b/server/migrations/2.0.70.js new file mode 100644 index 0000000..179679c --- /dev/null +++ b/server/migrations/2.0.70.js @@ -0,0 +1,174 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START report_queue + migration.addColumn('report_queue', 'mohtime', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // + + // START report_queue + migration.addColumn('report_call', 'mohtime', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // + + // START int_vtiger_accounts + migration.query('ALTER TABLE int_vtiger_accounts ENCRYPTION=\'Y\';'); + // END int_vtiger_accounts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.71.js b/server/migrations/2.0.71.js new file mode 100644 index 0000000..a859d75 --- /dev/null +++ b/server/migrations/2.0.71.js @@ -0,0 +1,300 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + //START CHAT_WEBSITE + migration.addColumn('chat_websites', 'queueTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'enableCustomerCheckmarks', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'queueTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + migration.addColumn('chat_websites', 'agentTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'agentTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + migration.addColumn('chat_websites', 'systemAlias', { + type: Sequelize.STRING, + defaultValue: 'System' + }); + migration.addColumn('chat_websites', 'systemAvatar', { + type: Sequelize.TEXT + }); + //END CHAT_WEBSITE + + //START FAX_ACCOUNT + migration.addColumn('fax_accounts', 'queueTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('fax_accounts', 'queueTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + migration.addColumn('fax_accounts', 'agentTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('fax_accounts', 'agentTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + //END FAX_ACCOUNT + + //START OPENCHANNEL_ACCOUNT + migration.addColumn('openchannel_accounts', 'queueTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('openchannel_accounts', 'queueTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + migration.addColumn('openchannel_accounts', 'agentTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('openchannel_accounts', 'agentTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + //END OPENCHANNEL_ACCOUNT + + //START SMS_ACCOUNT + migration.addColumn('sms_accounts', 'queueTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('sms_accounts', 'queueTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + migration.addColumn('sms_accounts', 'agentTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('sms_accounts', 'agentTransferTimeout', { + type: Sequelize.INTEGER, + validate: { + min: 1, + max: 2147483 + }, + defaultValue: 300 + }); + //END SMS_ACCOUNT + + // START SETTINGS + migration.addColumn('settings', 'chatTimeout', { + type: Sequelize.INTEGER, + defaultValue: 30 + }); + migration.query('UPDATE settings SET chatTimeout = 0;'); + migration.addColumn('settings', 'phoneBarRememberMeEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END SETTINGS + + // START LICENSE + migration.addColumn('license', 'chatLicenseExceeded', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END LICENSE + + // START TOOLS_ACTIONS + migration.addColumn('tools_actions', 'data7', { + type: Sequelize.TEXT + }); + // END TOOLS_ACTIONS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.72.js b/server/migrations/2.0.72.js new file mode 100644 index 0000000..7f0458e --- /dev/null +++ b/server/migrations/2.0.72.js @@ -0,0 +1,166 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START user_has_voice_queues_rt + migration.query('DELETE FROM user_has_voice_queues_rt WHERE UserId NOT IN (SELECT id FROM users WHERE role = \'agent\')'); + // END user_has_voice_queues_rt + + //START REPORT_SQUARE + migration.addIndex('report_square', ['uniqueid', 'project_name'], 'uid_pname'); + + migration.addIndex('report_square', ['leaveAt'], 'leaveAt'); + //END REPORT_SQUARE + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.73.js b/server/migrations/2.0.73.js new file mode 100644 index 0000000..2a011a9 --- /dev/null +++ b/server/migrations/2.0.73.js @@ -0,0 +1,189 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START report_call + migration.addColumn('report_call', 'routeid', { + type: Sequelize.INTEGER + }); + // END report_call + + // START cm_hopper_final + migration.addColumn('cm_hopper_final', 'originatecalleridnum', { + type: Sequelize.STRING + }); + migration.addColumn('cm_hopper_final', 'originatecalleridname', { + type: Sequelize.STRING + }); + // END cm_hopper_final + + // START cm_hopper_history + migration.addColumn('cm_hopper_history', 'originatecalleridnum', { + type: Sequelize.STRING + }); + migration.addColumn('cm_hopper_history', 'originatecalleridname', { + type: Sequelize.STRING + }); + // END cm_hopper_history + + // START CM CONTACTS + migration.addColumn('cm_contacts', 'wechat', { + type: Sequelize.STRING + }); + migration.addColumn('cm_contacts', 'fb_data', { + type: Sequelize.STRING + }); + // END CM CONTACTS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.74.js b/server/migrations/2.0.74.js new file mode 100644 index 0000000..5dc32dd --- /dev/null +++ b/server/migrations/2.0.74.js @@ -0,0 +1,156 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.75.js b/server/migrations/2.0.75.js new file mode 100644 index 0000000..5dc32dd --- /dev/null +++ b/server/migrations/2.0.75.js @@ -0,0 +1,156 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.76.js b/server/migrations/2.0.76.js new file mode 100644 index 0000000..0a4b9c2 --- /dev/null +++ b/server/migrations/2.0.76.js @@ -0,0 +1,176 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START sessions + migration.query('TRUNCATE sessions'); + // END sessions + + // START report__transfer + migration.query('ALTER TABLE report_chat_transfer ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE report_mail_transfer ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE report_fax_transfer ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE report_openchannel_transfer ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE report_sms_transfer ENCRYPTION=\'Y\';'); + // END report__transfer + + // START USERS + migration.addColumn('users', 'hotdesk', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END USERS + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.77.js b/server/migrations/2.0.77.js new file mode 100644 index 0000000..a68e351 --- /dev/null +++ b/server/migrations/2.0.77.js @@ -0,0 +1,177 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START REPORT SQUARE + migration.addColumn('report_square', 'bot', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END REPORT SQUARE + + // START REPORT SQUARE + migration.addColumn('users', 'interface', { + type: Sequelize.STRING, + defaultValue: null + }); + // END REPORT SQUARE + + // START USERS + migration.addColumn('users', 'privacyEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END USERS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.78.js b/server/migrations/2.0.78.js new file mode 100644 index 0000000..d6909a2 --- /dev/null +++ b/server/migrations/2.0.78.js @@ -0,0 +1,160 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START square_messages + migration.query('ALTER TABLE square_messages ENCRYPTION=\'Y\';'); + // END square_messages + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.79.js b/server/migrations/2.0.79.js new file mode 100644 index 0000000..f75604e --- /dev/null +++ b/server/migrations/2.0.79.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START dashboard_items + migration.query( + 'UPDATE dashboard_items SET attrs = REPLACE(attrs,\'[{"name":"attrReport"\',\'[{"name":"attrReport","type":"custom"\') WHERE type = \'web-report\' AND attrs NOT LIKE \'%type%\'' + ); + // END dashboard_items + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.80.js b/server/migrations/2.0.80.js new file mode 100644 index 0000000..8ce1296 --- /dev/null +++ b/server/migrations/2.0.80.js @@ -0,0 +1,176 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'preferred', { + type: Sequelize.STRING + }); + + migration.addColumn('settings', 'defaultPreferred', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END SETTINGS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.81.js b/server/migrations/2.0.81.js new file mode 100644 index 0000000..fd8d9a9 --- /dev/null +++ b/server/migrations/2.0.81.js @@ -0,0 +1,199 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START sms_accounts + migration.changeColumn( + 'sms_accounts', + 'smsMethod', { + type: Sequelize.ENUM('basic', 'classic', 'classic+', 'SI', 'TI', 'GP') + } + ); + migration.query( + 'UPDATE sms_accounts \ + SET smsMethod = \'SI\' WHERE smsMethod = \'basic\'' + ); + migration.query( + 'UPDATE sms_accounts \ + SET smsMethod = \'TI\' WHERE smsMethod = \'classic\'' + ); + migration.query( + 'UPDATE sms_accounts \ + SET smsMethod = \'GP\' WHERE smsMethod = \'classic+\'' + ); + migration.changeColumn( + 'sms_accounts', + 'smsMethod', { + type: Sequelize.ENUM('SI', 'TI', 'GP') + } + ); + // END sms_accounts + + // START CM_CONTACTS + migration.addColumn('cm_contacts', 'telegram', { + type: Sequelize.STRING + }); + // END CM_CONTACTS + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.82.js b/server/migrations/2.0.82.js new file mode 100644 index 0000000..6a1536c --- /dev/null +++ b/server/migrations/2.0.82.js @@ -0,0 +1,175 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SMSACCOUNT + migration.addColumn('sms_accounts', 'apiKey', { + type: Sequelize.STRING + }); + + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo', 'clickatell', 'csc') + }); + // END SMSACCOUNT + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.83.js b/server/migrations/2.0.83.js new file mode 100644 index 0000000..c40cfde --- /dev/null +++ b/server/migrations/2.0.83.js @@ -0,0 +1,195 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START CM_HOPPER + migration.addColumn('cm_hopper', 'OwnerId', { + type: Sequelize.INTEGER(11) + }); + migration.query('ALTER TABLE cm_hopper ADD CONSTRAINT cm_hopper_ibfk_6 FOREIGN KEY (OwnerId) REFERENCES users(id) ON UPDATE CASCADE ON DELETE SET NULL'); + // END CM_HOPPER + + // START CM_CONTACTS + migration.addColumn('cm_contacts', 'fb_data', { + type: Sequelize.STRING + }); + // START CM_CONTACTS + + // START sms_accounts + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo', 'clickatell', 'csc', 'infobip') + }); + + migration.addColumn('sms_accounts', 'baseUrl', { + type: Sequelize.STRING + }); + // END sms_accounts + + // START report_queue + migration.addColumn('report_queue', 'queuecallerenterreason', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END report_queue + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.0.84.js b/server/migrations/2.0.84.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.0.84.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.1.0.js b/server/migrations/2.1.0.js new file mode 100644 index 0000000..ce77612 --- /dev/null +++ b/server/migrations/2.1.0.js @@ -0,0 +1,776 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize.query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info(util.inspect(err, { + showHidden: false, + depth: null + })); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START EXTRACTED REPORTS + migration.addColumn('analytics_extracted_reports', 'reportId', { + type: Sequelize.INTEGER + }); + + migration.addColumn('analytics_extracted_reports', 'reportType', { + type: Sequelize.STRING + }); + // END EXTRACTED REPORTS + + // START USERS + migration.addColumn('users', 'userProfileId', { + type: Sequelize.INTEGER + }); + // END USERS + + // START VOICEMAILS + migration.removeColumn('voice_voicemail', 'name'); + // END VOICEMAILS + + // START USER_PROFILES + migration.query('CREATE TABLE `user_profiles` (' + + ' `id` int(11) NOT NULL AUTO_INCREMENT,' + + ' `name` varchar(255) NOT NULL,' + + ' `crudPermissions` varchar(255) NOT NULL DEFAULT \'r\',' + + ' `description` varchar(255) DEFAULT NULL,' + + ' `createdAt` datetime NOT NULL,' + + ' `updatedAt` datetime NOT NULL,' + + ' PRIMARY KEY (`id`),' + + ' UNIQUE KEY `name` (`name`)' + + ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + + migration.query('INSERT INTO `user_profiles` (`name`, `crudPermissions`, `description`, `createdAt`, `updatedAt`)' + + 'VALUES (\'Default\', \'red\', NULL, NOW(), NOW());'); + + migration.query('ALTER TABLE `users` ' + + 'ADD CONSTRAINT `users_ibfk_1` ' + + 'FOREIGN KEY (`userProfileId`) ' + + 'REFERENCES user_profiles(`id`) ' + + 'ON UPDATE CASCADE'); + + migration.query('CREATE TABLE `user_profile_has_sections` (' + + ' `id` int(11) NOT NULL AUTO_INCREMENT,' + + ' `name` varchar(255) NOT NULL,' + + ' `category` varchar(255) NOT NULL,' + + ' `sectionId` int(11) NOT NULL,' + + ' `enabled` tinyint(1) DEFAULT NULL,' + + ' `autoAssociation` tinyint(1) DEFAULT NULL,' + + ' `crudPermissions` varchar(255) DEFAULT NULL,' + + ' `createdAt` datetime NOT NULL,' + + ' `updatedAt` datetime NOT NULL,' + + ' `userProfileId` int(11) DEFAULT NULL,' + + ' PRIMARY KEY (`id`),' + + ' KEY `userProfileId` (`userProfileId`),' + + ' KEY `compositeIndex` (`sectionId`,`userProfileId`),' + + ' CONSTRAINT `user_profile_has_sections_ibfk_1` FOREIGN KEY (`userProfileId`) REFERENCES `user_profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE' + + ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + + migration.query('CREATE TABLE `user_profile_has_resources` (' + + ' `id` int(11) NOT NULL AUTO_INCREMENT,' + + ' `name` varchar(255) NOT NULL,' + + ' `resourceId` int(11) NOT NULL,' + + ' `type` varchar(255) NOT NULL,' + + ' `createdAt` datetime NOT NULL,' + + ' `updatedAt` datetime NOT NULL,' + + ' `sectionId` int(11) DEFAULT NULL,' + + ' PRIMARY KEY (`id`),' + + ' KEY `sectionId` (`sectionId`),' + + ' KEY `compositeIndex` (`resourceId`,`sectionId`),' + + ' CONSTRAINT `user_profile_has_resources_ibfk_1` FOREIGN KEY (`sectionId`) REFERENCES `user_profile_has_sections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE' + + ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + + migration.query('CREATE TABLE tally (' + + ' n INT NOT NULL AUTO_INCREMENT PRIMARY KEY' + + ');'); + + migration.query('INSERT INTO tally (n)' + + 'SELECT NULL FROM' + + '(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a' + + ',(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b' + + ',(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) c' + + ',(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) d' + + ',(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) e' + + ';'); + + migration.query('CREATE TABLE tmpPermissions' + + ' (' + + ' userIds varchar(255) not null,' + + ' permissions text not null,' + + ' profileId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpPermissions' + + ' SELECT id, permissions, null' + + ' FROM users' + + ' WHERE role = \'user\' and permissions is not null and permissions <> \'\'' + + ' ORDER BY id;'); + + migration.query('CREATE TABLE tmpNormalizedSections' + + ' (' + + ' sectionId int(11) not null,' + + ' userId text,' + + ' resourceId text' + + ' );'); + + migration.query('INSERT INTO tmpNormalizedSections' + + ' SELECT DISTINCT permission, userId, 0' + + ' FROM (SELECT' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(p.permissions, \',\', tally.n), \',\', -1) permission,' + + ' p.userIds userId' + + ' FROM tally INNER JOIN tmpPermissions p ON CHAR_LENGTH(p.permissions) - CHAR_LENGTH(REPLACE(p.permissions, \',\', \'\')) >= tally.n-1' + + ' ORDER BY n) AS split;'); + + migration.query('CREATE TABLE tmpNormalizedPermissions' + + ' (' + + ' permissions text not null,' + + ' userId int(11) not null' + + ' );'); + + migration.query('INSERT INTO tmpNormalizedPermissions' + + ' SELECT GROUP_CONCAT(sectionId ORDER BY sectionId), userId' + + ' FROM tmpNormalizedSections' + + ' GROUP BY userId;'); + + migration.query('UPDATE users u, tmpNormalizedPermissions t' + + ' SET u.permissions = t.permissions' + + ' WHERE u.id = t.userId;'); + + migration.query('TRUNCATE TABLE tmpPermissions;'); + + migration.query('INSERT INTO tmpPermissions' + + ' SELECT GROUP_CONCAT(id), permissions, null' + + ' FROM users' + + ' WHERE role = \'user\' and permissions is not null and permissions <> \'\'' + + ' GROUP BY permissions' + + ' ORDER BY GROUP_CONCAT(id);'); + + migration.query('CREATE TABLE tmpNormalizedUsers' + + ' (' + + ' sectionId int(11) not null,' + + ' userId text,' + + ' resourceId text' + + ' );'); + + migration.query('INSERT INTO tmpNormalizedUsers' + + ' SELECT permission, userId, 0' + + ' FROM (SELECT' + + ' s.sectionId permission,' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(s.userId, \',\', t.n), \',\', -1) userId' + + ' FROM tally t INNER JOIN tmpNormalizedSections s ON CHAR_LENGTH(s.userId) - CHAR_LENGTH(REPLACE(s.userId, \',\', \'\')) >= t.n-1' + + ' ORDER BY n) AS split;'); + + + migration.query('CREATE TABLE tmpExtractedResources (' + + ' sectionId int(11) not null,' + + ' resourceId int(11),' + + ' userId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.VoiceQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_voice_queues u ON u.UserId = x.userId' + + ' INNER JOIN voice_queues q ON u.VoiceQueueId = q.id' + + ' WHERE x.sectionId = 401 AND q.type = \'inbound\';'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.ChatQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_chat_queues u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 501;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.ChatWebsiteId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_chat_websites u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 502;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.MailQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_mail_queues u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 601;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.MailAccountId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_mail_accounts u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 602;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.SmsQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_sms_queues u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 701;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.SmsAccountId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_sms_accounts u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 702;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.OpenchannelQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_openchannel_queues u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 801;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.OpenchannelAccountId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_openchannel_accounts u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 802;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.FaxQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_fax_queues u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 901;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.FaxAccountId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_fax_accounts u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 902;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.SquareProjectId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_square_projects u ON u.UserId = x.userId' + + ' WHERE x.sectionId = 1103;'); + + migration.query('INSERT INTO tmpExtractedResources' + + ' SELECT x.sectionId, u.VoiceQueueId, x.userId' + + ' FROM tmpNormalizedUsers x' + + ' INNER JOIN user_has_voice_queues u ON u.UserId = x.userId' + + ' INNER JOIN voice_queues q ON u.VoiceQueueId = q.id' + + ' WHERE x.sectionId = 1501 AND q.type = \'outbound\';'); + + migration.query('CREATE TABLE tmpGroupedPermissions' + + ' (' + + ' userId text not null,' + + ' permissions text not null' + + ' );'); + + migration.query('INSERT INTO tmpGroupedPermissions' + + ' SELECT userId, permissions' + + ' FROM (SELECT' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(t.userIds, \',\', tally.n), \',\', -1) userId,' + + ' t.permissions permissions' + + ' FROM tally INNER JOIN tmpPermissions t ON CHAR_LENGTH(t.userIds) - CHAR_LENGTH(REPLACE(t.userIds, \',\', \'\')) >= tally.n-1' + + ' ORDER BY n) AS split;'); + + migration.query('CREATE TABLE tmpSharedProfiles' + + ' (' + + ' userIds varchar(255) not null,' + + ' permissions text not null,' + + ' profileId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpSharedProfiles' + + ' SELECT GROUP_CONCAT(userId), permissions, null' + + ' FROM tmpGroupedPermissions' + + ' WHERE userId NOT IN (SELECT split.userId' + + ' FROM (SELECT' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(r.userIds, \',\', t.n), \',\', -1) userId' + + ' FROM tally t' + + ' INNER JOIN tmpPermissions r on CHAR_LENGTH(r.userIds) - CHAR_LENGTH(REPLACE(r.userIds, \',\', \'\')) >= t.n-1' + + ' WHERE POSITION(\',\' in r.userIds) > 0' + + ' ORDER BY n) AS split' + + ' WHERE split.userId IN (SELECT * FROM' + + ' (SELECT GROUP_CONCAT(userId ORDER BY userId ASC) AS users' + + ' FROM tmpNormalizedUsers' + + ' GROUP BY resourceId, sectionId' + + ' ORDER BY users) b' + + ' WHERE position(\',\' in b.users) = 0))' + + ' GROUP BY permissions' + + ' ORDER BY GROUP_CONCAT(userId);'); + + migration.query('CREATE TABLE tmpSingleProfiles' + + ' (' + + ' userId text not null,' + + ' permissions text not null,' + + ' profileId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpSingleProfiles' + + ' SELECT userId, permissions, null' + + ' FROM tmpGroupedPermissions' + + ' WHERE userId IN (SELECT split.userId' + + ' FROM (select SUBSTRING_INDEX(SUBSTRING_INDEX(r.userIds, \',\', t.n), \',\', -1) userId' + + ' FROM tally t INNER JOIN tmpPermissions r ON CHAR_LENGTH(r.userIds) - CHAR_LENGTH(REPLACE(r.userIds, \',\', \'\')) >= t.n-1' + + ' WHERE POSITION(\',\' in r.userIds) > 0' + + ' ORDER BY n) as split' + + ' WHERE split.userId IN (SELECT * FROM' + + ' (SELECT GROUP_CONCAT(userId ORDER BY userId ASC) as users' + + ' FROM tmpNormalizedUsers' + + ' GROUP BY resourceId, sectionId' + + ' ORDER BY users) b' + + ' WHERE position(\',\' in b.users) = 0))' + + ' ORDER BY userId;'); + + migration.query('CREATE TABLE tmpFinalProfiles' + + ' (' + + ' userId text not null,' + + ' permissions text not null,' + + ' profileId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpFinalProfiles' + + ' SELECT * FROM tmpSharedProfiles' + + ' UNION' + + ' SELECT * FROM tmpSingleProfiles;'); + + migration.query('INSERT INTO user_profiles (name, crudPermissions, createdAt, updatedAt)' + + ' SELECT CONCAT(\'Profile_\', (SELECT (@cnt := @cnt + 1) AS rowNumber' + + ' FROM tmpFinalProfiles t' + + ' CROSS JOIN (SELECT @cnt := 0) as dummy LIMIT 1)), \'red\', now(), now()' + + ' FROM tmpFinalProfiles;'); + + migration.query('UPDATE tmpFinalProfiles' + + ' SET profileId = (SELECT (@cnt := @cnt + 1) AS rowNumber' + + ' FROM user_profiles u' + + ' CROSS JOIN (SELECT @cnt := 1) as dummy LIMIT 1)'); + // migration.query('UPDATE tmpFinalProfiles' + + // ' SET profileId = (@firstId := ifnull(@firstId, 1) + 1);'); + + migration.query('CREATE TABLE tmpSections' + + ' (' + + ' name varchar(255) not null,' + + ' category varchar(255) not null,' + + ' sectionId int(11) not null,' + + ' enabled tinyint not null,' + + ' autoAssociation tinyint not null,' + + ' userProfileId int(11) not null,' + + ' insertedId int(11),' + + ' userId text' + + ' );'); + + migration.query('INSERT INTO tmpSections' + + ' SELECT \'\', \'\', permission, 1, 0, profileId, null, userId' + + ' FROM (SELECT' + + ' fp.profileId profileId,' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(fp.permissions, \',\', tally.n), \',\', -1) permission,' + + ' SUBSTRING_INDEX(fp.userId, \',\', 1) userId' + + ' FROM tally' + + ' INNER JOIN tmpFinalProfiles fp ON CHAR_LENGTH(fp.permissions) - CHAR_LENGTH(REPLACE(fp.permissions, \',\', \'\')) >= tally.n-1' + + ' ORDER BY n) AS split;'); + + migration.query('UPDATE tmpSections' + + ' SET' + + ' name = (SELECT' + + ' CASE' + + ' WHEN sectionId = 100 THEN \'Dashboards\'' + + ' WHEN sectionId = 101 THEN \'DELETE\'' + + ' WHEN sectionId = 200 THEN \'DELETE\'' + + ' WHEN sectionId = 201 THEN \'DELETE\'' + + ' WHEN sectionId = 202 THEN \'Agents\'' + + ' WHEN sectionId = 203 THEN \'Telephones\'' + + ' WHEN sectionId = 204 THEN \'Teams\'' + + ' WHEN sectionId = 300 THEN \'DELETE\'' + + ' WHEN sectionId = 301 THEN \'Lists\'' + + ' WHEN sectionId = 302 THEN \'Companies\'' + + ' WHEN sectionId = 303 THEN \'Contacts\'' + + ' WHEN sectionId = 304 THEN \'GlobalCustomFields\'' + + ' WHEN sectionId = 400 THEN \'DELETE\'' + + ' WHEN sectionId = 401 THEN \'VoiceQueues\'' + + ' WHEN sectionId = 402 THEN \'InboundRoutes\'' + + ' WHEN sectionId = 403 THEN \'OutboundRoutes\'' + + ' WHEN sectionId = 404 THEN \'InternalRoutes\'' + + ' WHEN sectionId = 405 THEN \'Contexts\'' + + ' WHEN sectionId = 406 THEN \'Voicemails\'' + + ' WHEN sectionId = 407 THEN \'MusicOnHolds\'' + + ' WHEN sectionId = 408 THEN \'VoiceRecordings\'' + + ' WHEN sectionId = 409 THEN \'ChanSpies\'' + + ' WHEN sectionId = 410 THEN \'VoicePrefixes\'' + + ' WHEN sectionId = 411 THEN \'Realtime\'' + + ' WHEN sectionId = 500 THEN \'DELETE\'' + + ' WHEN sectionId = 501 THEN \'ChatQueues\'' + + ' WHEN sectionId = 502 THEN \'ChatWebsites\'' + + ' WHEN sectionId = 510 THEN \'Realtime\'' + + ' WHEN sectionId = 600 THEN \'DELETE\'' + + ' WHEN sectionId = 601 THEN \'MailQueues\'' + + ' WHEN sectionId = 602 THEN \'MailAccounts\'' + + ' WHEN sectionId = 603 THEN \'MailSubstatuses\'' + + ' WHEN sectionId = 610 THEN \'Realtime\'' + + ' WHEN sectionId = 700 THEN \'DELETE\'' + + ' WHEN sectionId = 701 THEN \'SmsQueues\'' + + ' WHEN sectionId = 702 THEN \'SmsAccounts\'' + + ' WHEN sectionId = 710 THEN \'Realtime\'' + + ' WHEN sectionId = 800 THEN \'DELETE\'' + + ' WHEN sectionId = 801 THEN \'OpenchannelQueues\'' + + ' WHEN sectionId = 802 THEN \'OpenchannelAccounts\'' + + ' WHEN sectionId = 810 THEN \'Realtime\'' + + ' WHEN sectionId = 900 THEN \'DELETE\'' + + ' WHEN sectionId = 901 THEN \'FaxQueues\'' + + ' WHEN sectionId = 902 THEN \'FaxAccounts\'' + + ' WHEN sectionId = 910 THEN \'Realtime\'' + + ' WHEN sectionId = 1000 THEN \'DELETE\'' + + ' WHEN sectionId = 1001 THEN \'CannedAnswers\'' + + ' WHEN sectionId = 1002 THEN \'Dispositions\'' + + ' WHEN sectionId = 1003 THEN \'CustomDashboards\'' + + ' WHEN sectionId = 1004 THEN \'Intervals\'' + + ' WHEN sectionId = 1005 THEN \'Pauses\'' + + ' WHEN sectionId = 1006 THEN \'Scheduler\'' + + ' WHEN sectionId = 1007 THEN \'Sounds\'' + + ' WHEN sectionId = 1008 THEN \'Tags\'' + + ' WHEN sectionId = 1009 THEN \'Templates\'' + + ' WHEN sectionId = 1010 THEN \'Triggers\'' + + ' WHEN sectionId = 1011 THEN \'Trunks\'' + + ' WHEN sectionId = 1012 THEN \'Variables\'' + + ' WHEN sectionId = 1100 THEN \'DELETE\'' + + ' WHEN sectionId = 1101 THEN \'ODBC\'' + + ' WHEN sectionId = 1102 THEN \'SquareRecordings\'' + + ' WHEN sectionId = 1103 THEN \'SquareProjects\'' + + ' WHEN sectionId = 1200 THEN \'DELETE\'' + + ' WHEN sectionId = 1201 THEN \'Metrics\'' + + ' WHEN sectionId = 1202 THEN \'ExtractedReports\'' + + ' WHEN sectionId = 1203 THEN \'Reports\'' + + ' WHEN sectionId = 1300 THEN \'DELETE\'' + + ' WHEN sectionId = 1301 THEN \'ZendeskAccounts\'' + + ' WHEN sectionId = 1302 THEN \'SalesforceAccounts\'' + + ' WHEN sectionId = 1303 THEN \'FreshdeskAccounts\'' + + ' WHEN sectionId = 1305 THEN \'SugarcrmAccounts\'' + + ' WHEN sectionId = 1306 THEN \'DeskAccounts\'' + + ' WHEN sectionId = 1307 THEN \'ZohoAccounts\'' + + ' WHEN sectionId = 1308 THEN \'VtigerAccounts\'' + + ' WHEN sectionId = 1400 THEN \'Settings\'' + + ' WHEN sectionId in (1401, 1402, 1403, 1404, 1405, 1406, 1407) THEN \'DELETE\'' + + ' WHEN sectionId = 1500 THEN \'DELETE\'' + + ' WHEN sectionId = 1501 THEN \'QueueCampaigns\'' + + ' WHEN sectionId = 1502 THEN \'IvrCampaigns\'' + + ' WHEN sectionId = 1510 THEN \'Realtime\'' + + ' WHEN sectionId = 1600 THEN \'Help\'' + + ' WHEN sectionId = 1601 THEN \'DELETE\'' + + ' WHEN sectionId = 1700 THEN \'DELETE\'' + + ' WHEN sectionId = 1701 THEN \'Projects\'' + + ' WHEN sectionId between 88889 AND 99999 THEN \'Plugins\'' + + ' WHEN sectionId >= 100000 THEN \'CustomDashboards\'' + + ' ELSE \'\'' + + ' END' + + ' ),' + + ' category = (SELECT' + + ' CASE' + + ' WHEN sectionId = 100 THEN \'Dashboards\'' + + ' WHEN sectionId >= 100000 THEN \'Tools\'' + + ' WHEN sectionId in (202, 203, 204) THEN \'Staff\'' + + ' WHEN sectionId in (301, 302, 303, 304) THEN \'ContactManager\'' + + ' WHEN sectionId in (401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411) THEN \'Voice\'' + + ' WHEN sectionId in (501, 502, 510) THEN \'Chat\'' + + ' WHEN sectionId in (601, 602, 603, 610) THEN \'Mail\'' + + ' WHEN sectionId in (701, 702, 710) THEN \'Sms\'' + + ' WHEN sectionId in (801, 802, 810) THEN \'Openchannel\'' + + ' WHEN sectionId in (901, 902, 910) THEN \'Fax\'' + + ' WHEN sectionId in (1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012) THEN \'Tools\'' + + ' WHEN sectionId in (1101, 1102, 1103) THEN \'CallySquare\'' + + ' WHEN sectionId in (1201, 1202, 1203) THEN \'Analytics\'' + + ' WHEN sectionId in (1301, 1302, 1303, 1305, 1306, 1307, 1308) THEN \'Integrations\'' + + ' WHEN sectionId = 1400 THEN \'Settings\'' + + ' WHEN sectionId in (1501, 1502, 1510) THEN \'MotionDialer\'' + + ' WHEN sectionId = 1600 THEN \'Help\'' + + ' WHEN sectionId = 1701 THEN \'jscripty\'' + + ' WHEN sectionId between 88889 AND 99999 THEN \'AppZone\'' + + ' ELSE \'\'' + + ' END' + + ' );'); + + migration.query('DELETE FROM tmpSections' + + ' WHERE name = \'DELETE\';'); + + migration.query('CREATE TABLE tmpCustomResources' + + ' (' + + ' name varchar(255) not null,' + + ' category varchar(255) not null,' + + ' sectionId int(11) not null,' + + ' enabled tinyint not null,' + + ' autoAssociation tinyint not null,' + + ' userProfileId int(11) not null,' + + ' insertedId int(11),' + + ' userId text' + + ' );'); + + migration.query('INSERT INTO tmpCustomResources' + + ' SELECT *' + + ' FROM tmpSections' + + ' WHERE name in (\'Plugins\', \'CustomDashboards\');'); + + migration.query('DELETE t1 FROM tmpSections t1, tmpCustomResources t2' + + ' WHERE t1.name = t2.name AND t1.userProfileId = t2.userProfileId AND t1.sectionId > t2.sectionId;'); + + migration.query('UPDATE tmpSections' + + ' SET sectionId = 1801 WHERE sectionId between 88889 AND 99999;'); + + migration.query('UPDATE tmpSections' + + ' SET sectionId = 1003 WHERE sectionId >= 100000;'); + + migration.query('UPDATE tmpSections' + + ' SET autoAssociation = 1 WHERE sectionId = 100;'); + + migration.query('UPDATE tmpCustomResources' + + ' SET insertedId = (SELECT' + + ' CASE' + + ' WHEN name = \'Plugins\' THEN (sectionId - 88888)' + + ' WHEN name = \'CustomDashboards\' THEN (sectionId - 99999)' + + ' END' + + ' );'); + + migration.query('INSERT INTO user_profile_has_sections (name, category, sectionId, enabled, autoAssociation, crudPermissions, createdAt, updatedAt, userProfileId)' + + ' SELECT name, category, sectionId, enabled, autoAssociation, \'red\', now(), now(), userProfileId' + + ' FROM tmpSections;'); + + migration.query('UPDATE tmpSections s' + + ' SET insertedId = (SELECT id' + + ' FROM user_profile_has_sections x' + + ' WHERE s.userProfileId = x.userProfileId AND s.sectionId = x.sectionId);'); + + migration.query('UPDATE tmpCustomResources r, tmpSections s' + + ' SET r.sectionId = s.insertedId' + + ' WHERE r.name = s.name AND r.userProfileId = s.userProfileId;'); + + migration.query('CREATE TABLE tmpResources' + + ' (' + + ' resourceId text,' + + ' type varchar(255) not null,' + + ' insertedSectionId int(11) not null,' + + ' sectionId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpResources' + + ' SELECT cr.resourceId, name, s.insertedId, s.sectionId' + + ' FROM tmpSections s' + + ' INNER JOIN tmpExtractedResources cr ON cr.userId = s.userId AND cr.sectionId = s.sectionId AND cr.resourceId IS NOT NULL;'); + + migration.query('CREATE TABLE tmpNormalizedResources' + + ' (' + + ' name varchar(255) not null,' + + ' resourceId int(11) not null,' + + ' type varchar(255) not null,' + + ' insertedSectionId int(11) not null,' + + ' sectionId int(11)' + + ' );'); + + migration.query('INSERT INTO tmpNormalizedResources' + + ' SELECT \'\', resourceId, type, insertedSectionId, sectionId' + + ' FROM (SELECT' + + ' SUBSTRING_INDEX(SUBSTRING_INDEX(r.resourceId, \',\', tally.n), \',\', -1) resourceId,' + + ' r.type type,' + + ' r.insertedSectionId insertedSectionId,' + + ' r.sectionId sectionId' + + ' FROM tally' + + ' INNER JOIN tmpResources r ON CHAR_LENGTH(r.resourceId) - CHAR_LENGTH(REPLACE(r.resourceId, \',\', \'\')) >= tally.n-1' + + ' ORDER BY n) AS split;'); + + migration.query('INSERT INTO tmpNormalizedResources' + + ' SELECT \'\', insertedId, name, sectionId, null' + + ' FROM tmpCustomResources;'); + + migration.query('UPDATE tmpNormalizedResources x' + + ' SET name = (SELECT' + + ' CASE' + + ' WHEN x.sectionId = 401 THEN COALESCE((SELECT name FROM voice_queues WHERE id = x.resourceId AND type = \'inbound\'),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 501 THEN COALESCE((SELECT name FROM chat_queues WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 502 THEN COALESCE((SELECT name FROM chat_websites WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 601 THEN COALESCE((SELECT name FROM mail_queues WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 602 THEN COALESCE((SELECT name FROM mail_accounts WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 701 THEN COALESCE((SELECT name FROM sms_queues WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 702 THEN COALESCE((SELECT name FROM sms_accounts WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 801 THEN COALESCE((SELECT name FROM openchannel_queues WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 802 THEN COALESCE((SELECT name FROM openchannel_accounts WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 901 THEN COALESCE((SELECT name FROM fax_queues WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 902 THEN COALESCE((SELECT name FROM fax_accounts WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 1103 THEN COALESCE((SELECT name FROM square_projects WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.sectionId = 1501 THEN COALESCE((SELECT name FROM voice_queues WHERE id = x.resourceId AND type = \'outbound\'),\'DELETE_MIGRATION\')' + + ' WHEN x.type = \'Plugins\' THEN COALESCE((SELECT name FROM plugins WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' WHEN x.type = \'CustomDashboards\' THEN COALESCE((SELECT name FROM dashboards WHERE id = x.resourceId),\'DELETE_MIGRATION\')' + + ' END' + + ' );'); + + migration.query('DELETE FROM tmpNormalizedResources' + + ' WHERE name = \'DELETE_MIGRATION\';'); + + migration.query('INSERT INTO user_profile_has_resources (name, resourceId, type, createdAt, updatedAt, sectionId)' + + ' SELECT name, resourceId, type, now(), now(), insertedSectionId' + + ' FROM tmpNormalizedResources;'); + + migration.query('UPDATE users u, tmpFinalProfiles f' + + ' SET u.userProfileId = f.profileId' + + ' WHERE u.id = f.userId;'); + + migration.query('UPDATE users u' + + ' SET u.userProfileId = 1' + + ' WHERE userProfileId is null AND role = \'user\';'); + + migration.query(' DROP TABLE IF EXISTS tally;'); + + migration.query('DROP TABLE IF EXISTS tmpPermissions;'); + + migration.query('DROP TABLE IF EXISTS tmpNormalizedSections;'); + + migration.query('DROP TABLE IF EXISTS tmpNormalizedUsers;'); + + migration.query('DROP TABLE IF EXISTS tmpExtractedResources;'); + + migration.query('DROP TABLE IF EXISTS tmpGroupedPermissions;'); + + migration.query('DROP TABLE IF EXISTS tmpSharedProfiles;'); + + migration.query('DROP TABLE IF EXISTS tmpSingleProfiles;'); + + migration.query('DROP TABLE IF EXISTS tmpFinalProfiles;'); + + migration.query('DROP TABLE IF EXISTS tmpSections;'); + + migration.query('DROP TABLE IF EXISTS tmpCustomResources;'); + + migration.query('DROP TABLE IF EXISTS tmpResources;'); + + migration.query('DROP TABLE IF EXISTS tmpNormalizedResources;'); + // END USER_PROFILES + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.0.js b/server/migrations/2.2.0.js new file mode 100644 index 0000000..6ffa03b --- /dev/null +++ b/server/migrations/2.2.0.js @@ -0,0 +1,178 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SMSACCOUNT + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo', 'clickatell', 'csc', 'infobip', 'intelepeer') + }); + // END SMSACCOUNT + + //START users + migration.changeColumn('users', 'phoneBarListenPort', { + type: Sequelize.INTEGER(5), + defaultValue: 5160 + }); + //END users + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.1.js b/server/migrations/2.2.1.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.2.1.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.2.js b/server/migrations/2.2.2.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.2.2.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.3.js b/server/migrations/2.2.3.js new file mode 100644 index 0000000..9d868ba --- /dev/null +++ b/server/migrations/2.2.3.js @@ -0,0 +1,175 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START EMAIL + migration.changeColumn('mail_interactions', 'inReplyTo', { + type: Sequelize.STRING(510) + }); + + migration.changeColumn('mail_messages', 'messageId', { + type: Sequelize.STRING(510) + }); + // END EMAIL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.4.js b/server/migrations/2.2.4.js new file mode 100644 index 0000000..6c6c812 --- /dev/null +++ b/server/migrations/2.2.4.js @@ -0,0 +1,175 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START INTEGRATIONS + migration.query('ALTER TABLE int_desk_fields add UNIQUE INDEX desk_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_freshdesk_fields add UNIQUE INDEX desk_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_salesforce_fields add UNIQUE INDEX salesforce_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_sugarcrm_fields add UNIQUE INDEX sugarcrm_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_vtiger_fields add UNIQUE INDEX vtiger_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_zendesk_fields add UNIQUE INDEX zendesk_unique_index (idField, FieldId)'); + migration.query('ALTER TABLE int_zoho_fields add UNIQUE INDEX zoho_unique_index (idField, FieldId)'); + // END INTEGRATIONS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.5.js b/server/migrations/2.2.5.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.2.5.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.2.6.js b/server/migrations/2.2.6.js new file mode 100644 index 0000000..f4df1d0 --- /dev/null +++ b/server/migrations/2.2.6.js @@ -0,0 +1,270 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + //START mail_interactions + migration.query('ALTER TABLE mail_interactions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); + //END mail_interactions + + // START analytics_custom_reports + migration.query('UPDATE analytics_custom_reports SET joins = REPLACE(joins,\'"type":"outer_join"\',\'"type":"left_join"\') WHERE joins LIKE \'%"type":"outer_join"%\''); + // END analytics_custom_reports + + // START square_projects + migration.query('UPDATE square_projects SET preproduction = REPLACE(preproduction,\'labelBackgroundColor=#ffffff;\',\'\')'); + migration.query('UPDATE square_projects SET production = REPLACE(production,\'labelBackgroundColor=#ffffff;\',\'\')'); + // END square_projects + + // START mandatoryDisposition + migration.addColumn('voice_queues', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('voice_queues', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE voice_queues \ + ADD CONSTRAINT `voice_queues_ibfk_4` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + migration.addColumn('chat_websites', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('chat_websites', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE chat_websites \ + ADD CONSTRAINT `chat_websites_ibfk_3` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + + migration.addColumn('fax_accounts', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('fax_accounts', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE fax_accounts \ + ADD CONSTRAINT `fax_accounts_ibfk_3` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + + migration.addColumn('mail_accounts', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('mail_accounts', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE mail_accounts \ + ADD CONSTRAINT `mail_accounts_ibfk_3` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + + migration.addColumn('openchannel_accounts', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('openchannel_accounts', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE openchannel_accounts \ + ADD CONSTRAINT `openchannel_accounts_ibfk_2` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + + migration.addColumn('sms_accounts', 'mandatoryDisposition', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('sms_accounts', 'mandatoryDispositionPauseId', { + type: Sequelize.INTEGER + }); + migration.query('ALTER TABLE sms_accounts \ + ADD CONSTRAINT `sms_accounts_ibfk_2` \ + FOREIGN KEY (`mandatoryDispositionPauseId`) \ + REFERENCES tools_pauses(`id`) \ + ON UPDATE CASCADE \ + ON DELETE CASCADE'); + + + // END mandatoryDisposition + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.0.js b/server/migrations/2.3.0.js new file mode 100644 index 0000000..423083b --- /dev/null +++ b/server/migrations/2.3.0.js @@ -0,0 +1,178 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START users + migration.addColumn('users', 'apiKeyNonce', { + type: Sequelize.STRING + }); + migration.addColumn('users', 'apiKeyIat', { + type: Sequelize.STRING + }); + // END users + + // START report_call + migration.addIndex('report_call', ['uniqueid'], 'uniqueid'); + // END report_call + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.1.js b/server/migrations/2.3.1.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.1.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.10.js b/server/migrations/2.3.10.js new file mode 100644 index 0000000..5cec167 --- /dev/null +++ b/server/migrations/2.3.10.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START REPORT CALL + migration.addColumn('report_call', 'sipcallid', { + type: Sequelize.STRING + }); + // END REPORT CALL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.2.js b/server/migrations/2.3.2.js new file mode 100644 index 0000000..fae7032 --- /dev/null +++ b/server/migrations/2.3.2.js @@ -0,0 +1,180 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START int_dynamics365_accounts + migration.query('ALTER TABLE int_dynamics365_accounts ENCRYPTION=\'Y\';'); + // END int_dynamics365_accounts + + // START int_servicenow_accounts + migration.query('ALTER TABLE int_servicenow_accounts ENCRYPTION=\'Y\';'); + // END int_servicenow_accounts + + // START SETTINGS + migration.addColumn('settings', 'rtlSupport', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END SETTINGS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.3.js b/server/migrations/2.3.3.js new file mode 100644 index 0000000..f632149 --- /dev/null +++ b/server/migrations/2.3.3.js @@ -0,0 +1,199 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + //START tools_canned_answers + migration.query('ALTER TABLE tools_canned_answers CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); + //END tools_canned_answers + + //START chat_applications + migration.changeColumn('chat_applications', 'appdata', { + type: Sequelize.TEXT() + }); + //END chat_applications + + //START fax_applications + migration.changeColumn('fax_applications', 'appdata', { + type: Sequelize.TEXT() + }); + //END fax_applications + + //START mail_applications + migration.changeColumn('mail_applications', 'appdata', { + type: Sequelize.TEXT() + }); + //END mail_applications + + //START openchannel_applications + migration.changeColumn('openchannel_applications', 'appdata', { + type: Sequelize.TEXT() + }); + //END openchannel_applications + + //START sms_applications + migration.changeColumn('sms_applications', 'appdata', { + type: Sequelize.TEXT() + }); + //END sms_applications + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.4.js b/server/migrations/2.3.4.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.4.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.5.js b/server/migrations/2.3.5.js new file mode 100644 index 0000000..ed7ec65 --- /dev/null +++ b/server/migrations/2.3.5.js @@ -0,0 +1,166 @@ +"use strict"; + +var BPromise = require("bluebird"); +var util = require("util"); + +var logger = require("../config/logger")("migration"); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info("Changed column %s in table %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info("Added column %s to %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info("table dropped %s", table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info("removeIndex %s %s", table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info("query %s", sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info("Removed column %s from %s", column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info("Renamed column from %s to %s on %s", oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.6.js b/server/migrations/2.3.6.js new file mode 100644 index 0000000..ed7ec65 --- /dev/null +++ b/server/migrations/2.3.6.js @@ -0,0 +1,166 @@ +"use strict"; + +var BPromise = require("bluebird"); +var util = require("util"); + +var logger = require("../config/logger")("migration"); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info("Changed column %s in table %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info("Added column %s to %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info("table dropped %s", table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info("removeIndex %s %s", table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info("query %s", sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info("Removed column %s from %s", column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info("Renamed column from %s to %s on %s", oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.7.js b/server/migrations/2.3.7.js new file mode 100644 index 0000000..69f7bcf --- /dev/null +++ b/server/migrations/2.3.7.js @@ -0,0 +1,198 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START REPORT AGENT + migration.addColumn('report_agent', 'transfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('report_agent', 'transfertype', { + type: Sequelize.STRING, + comment: 'FORWARD, BLIND, ATTENDED' + }); + migration.addColumn('report_agent', 'transferexten', { + type: Sequelize.STRING + }); + migration.addColumn('report_agent', 'transferuniqueid', { + type: Sequelize.STRING + }); + migration.addColumn('report_agent', 'agententerreason', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END REPORT AGENT + + // START REPORT CALL + migration.addColumn('report_call', 'systemanswertime', { + type: Sequelize.DATE + }); + // END REPORT CALL + // START int_salesforce_configurations + migration.addColumn('int_salesforce_configurations', 'ticketType', { + type: Sequelize.ENUM('Task', 'Case'), + defaultValue: 'Task' + }); + // END int_salesforce_configurations + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.8.js b/server/migrations/2.3.8.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.8.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.9.js b/server/migrations/2.3.9.js new file mode 100644 index 0000000..ed7ec65 --- /dev/null +++ b/server/migrations/2.3.9.js @@ -0,0 +1,166 @@ +"use strict"; + +var BPromise = require("bluebird"); +var util = require("util"); + +var logger = require("../config/logger")("migration"); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info("Changed column %s in table %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info("Added column %s to %s", column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info("table dropped %s", table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info("removeIndex %s %s", table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info("query %s", sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info("Removed column %s from %s", column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info("Renamed column from %s to %s on %s", oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.91.js b/server/migrations/2.3.91.js new file mode 100644 index 0000000..5cec167 --- /dev/null +++ b/server/migrations/2.3.91.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START REPORT CALL + migration.addColumn('report_call', 'sipcallid', { + type: Sequelize.STRING + }); + // END REPORT CALL + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.92.js b/server/migrations/2.3.92.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.92.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.93.js b/server/migrations/2.3.93.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.93.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.94.js b/server/migrations/2.3.94.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.94.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.95.js b/server/migrations/2.3.95.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.95.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.96.js b/server/migrations/2.3.96.js new file mode 100644 index 0000000..b237a64 --- /dev/null +++ b/server/migrations/2.3.96.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'defaultScreenRecordingPath', { + type: Sequelize.STRING + }); + // END SETTINGS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.97.js b/server/migrations/2.3.97.js new file mode 100644 index 0000000..dc6c0e5 --- /dev/null +++ b/server/migrations/2.3.97.js @@ -0,0 +1,184 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START voice_queues + migration.addColumn('voice_queues', 'dialPredictiveIntervalMaxThreshold', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 20 + }); + migration.addColumn('voice_queues', 'dialPredictiveIntervalMinThreshold', { + type: Sequelize.INTEGER(3).UNSIGNED, + defaultValue: 10 + }); + // END voice_queues + + // START MIGRATIONS + migration.query('ALTER TABLE migrations DROP PRIMARY KEY'); + migration.query('ALTER TABLE migrations MODIFY COLUMN version varchar(255) NOT NULL UNIQUE'); + migration.query('ALTER TABLE migrations ADD COLUMN id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST'); + migration.query('ALTER TABLE migrations ADD COLUMN createdAt datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER version'); + migration.query('ALTER TABLE migrations ADD COLUMN updatedAt datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER createdAt'); + // END MIGRATIONS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.3.98.js b/server/migrations/2.3.98.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.3.98.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.0.js b/server/migrations/2.4.0.js new file mode 100644 index 0000000..24ee6eb --- /dev/null +++ b/server/migrations/2.4.0.js @@ -0,0 +1,244 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START USERS + migration.renameColumn('users', 'phoneBarEnableVideoRecording', 'phoneBarEnableScreenRecordingByAgent'); + + migration.addColumn('users', 'phoneBarEnableAutomaticScreenRecording', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'screenrecording', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + //END USERS + + // START chat_messages + migration.addIndex("chat_messages", ["body"], { + indexName: "fti_chat_messages", + indicesType: "FULLTEXT" + }); + // END chat_messages + + // START mail_interactions + migration.addIndex("mail_interactions", ["subject", "to"], { + indexName: "fti_mail_interactions", + indicesType: "FULLTEXT" + }); + + migration.addColumn("mail_interactions", "lastMsgText", { + type: Sequelize.TEXT("tiny"), + after: "lastMsgBody" + }); + // END mail_interactions + + // START mail_messages + migration.addColumn("mail_messages", "plainBody", { + type: Sequelize.TEXT("medium"), + after: "body" + }); + + migration.addIndex("mail_messages", ["plainBody", "subject"], { + indexName: "fti_mail_messages", + indicesType: "FULLTEXT" + }); + // END mail_messages + + // START openchannel_messages + migration.addIndex("openchannel_messages", ["body"], { + indexName: "fti_openchannel_messages", + indicesType: "FULLTEXT" + }); + // END openchannel_messages + + // START sms_messages + migration.addIndex("sms_messages", ["body"], { + indexName: "fti_sms_messages", + indicesType: "FULLTEXT" + }); + // END sms_messages + // START chat_applications + migration.query('ALTER TABLE chat_applications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + // END chat_applications + + // START fax_applications + migration.query('ALTER TABLE fax_applications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + // END fax_applications + + // START mail_applications + migration.query('ALTER TABLE mail_applications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + // END mail_applications + + // START openchannel_applications + migration.query('ALTER TABLE openchannel_applications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + // END openchannel_applications + + // START sms_applications + migration.query('ALTER TABLE sms_applications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + // END sms_applications + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.1.js b/server/migrations/2.4.1.js new file mode 100644 index 0000000..fa87841 --- /dev/null +++ b/server/migrations/2.4.1.js @@ -0,0 +1,166 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.10.js b/server/migrations/2.4.10.js new file mode 100644 index 0000000..873abc1 --- /dev/null +++ b/server/migrations/2.4.10.js @@ -0,0 +1,184 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + //START chat_interactions + migration.changeColumn('chat_interactions', 'referer', { + type: Sequelize.TEXT + }); + //END chat_applications + + // START SETTINGS + migration.addColumn('settings', 'favicon', { + type: Sequelize.STRING + }); + + migration.addColumn('settings', 'defaultFavicon', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END SETTINGS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.11.js b/server/migrations/2.4.11.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.11.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.12.js b/server/migrations/2.4.12.js new file mode 100644 index 0000000..f54e0e9 --- /dev/null +++ b/server/migrations/2.4.12.js @@ -0,0 +1,178 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'loginMailFrequency', { + type: Sequelize.INTEGER, + defaultValue: 10 + }); + // END SETTINGS + + // START tools_actions + migration.query('UPDATE tools_actions SET tools_actions.data5 = "5" WHERE tools_actions.action = "urlForward"'); + // END tools_actions + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.13.js b/server/migrations/2.4.13.js new file mode 100644 index 0000000..819d394 --- /dev/null +++ b/server/migrations/2.4.13.js @@ -0,0 +1,174 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START JSCRIPTY_PROJECTS + migration.addColumn('jscripty_projects', 'sendUnpauseOnSubmit', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END JSCRIPTY_PROJECTS + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.14.js b/server/migrations/2.4.14.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.14.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.15.js b/server/migrations/2.4.15.js new file mode 100644 index 0000000..ff27fea --- /dev/null +++ b/server/migrations/2.4.15.js @@ -0,0 +1,171 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START sms_accounts + migration.query('UPDATE sms_accounts SET baseUrl = "https://sms.csc.lv" WHERE type = "csc"'); + // END sms_accounts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.16.js b/server/migrations/2.4.16.js new file mode 100644 index 0000000..9892855 --- /dev/null +++ b/server/migrations/2.4.16.js @@ -0,0 +1,174 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START cm_contacts + migration.addIndex("cm_contacts", ["firstName", "lastName", "phone", "mobile", "fax", "email"], { + indexName: "fti_cm_contacts", + indicesType: "FULLTEXT" + }); + // END cm_contacts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.17.js b/server/migrations/2.4.17.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.17.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.18.js b/server/migrations/2.4.18.js new file mode 100644 index 0000000..8cad27c --- /dev/null +++ b/server/migrations/2.4.18.js @@ -0,0 +1,173 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + + // START voice_queues + migration.query('UPDATE voice_queues SET joinempty = "yes" WHERE joinempty = \'\' or joinempty IS NULL'); + migration.query('UPDATE voice_queues SET leavewhenempty = "no" WHERE leavewhenempty = \'\' or leavewhenempty IS NULL'); + // END voice_queues + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.19.js b/server/migrations/2.4.19.js new file mode 100644 index 0000000..381850a --- /dev/null +++ b/server/migrations/2.4.19.js @@ -0,0 +1,203 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + //START int_zoho_configurations + migration.addColumn('int_zoho_configurations', 'moduleSearch', { + type: Sequelize.ENUM('contact_lead', 'contact', 'lead'), + defaultValue: 'contact_lead' + }); + + migration.changeColumn('int_zoho_configurations', 'moduleCreate', { + type: Sequelize.ENUM('Leads', 'Contacts', 'nothing', 'contact', 'lead') + }); + + migration.query('UPDATE int_zoho_configurations SET moduleCreate = \'contact\' WHERE moduleCreate = \'Contacts\''); + + migration.query('UPDATE int_zoho_configurations SET moduleCreate = \'lead\' WHERE moduleCreate = \'Leads\''); + + migration.changeColumn('int_zoho_configurations', 'moduleCreate', { + type: Sequelize.ENUM('nothing', 'contact', 'lead'), + defaultValue: 'lead' + }); + //END int_zoho_configurations + + + + // START network + migration.addColumn('network', 'username', { + type: Sequelize.STRING + }); + migration.addColumn('network', 'password', { + type: Sequelize.STRING + }); + migration.changeColumn('network', 'type', { + type: Sequelize.ENUM('localnet', 'externip', 'stun', 'turn') + }); + migration.query("INSERT INTO network (type,value, createdAt, updatedAt) SELECT 'stun', stunaddr, current_timestamp(), current_timestamp() from settings WHERE stunaddr<>''"); + migration.query("INSERT INTO network (type,value,username,password, createdAt, updatedAt) SELECT 'turn', turnaddr, turnusername, turnpassword, current_timestamp(), current_timestamp() from settings WHERE turnaddr<>''"); + // END network + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.2.js b/server/migrations/2.4.2.js new file mode 100644 index 0000000..2f7ce8e --- /dev/null +++ b/server/migrations/2.4.2.js @@ -0,0 +1,201 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SETTINGS + migration.addColumn('settings', 'allowedLoginAttempts', { + type: Sequelize.INTEGER, + defaultValue: 5 + }); + migration.addColumn('settings', 'blockDuration', { + type: Sequelize.INTEGER, + defaultValue: 10 + }); + migration.query('UPDATE settings SET allowedLoginAttempts = 0, blockDuration = 0;'); + // END SETTINGS + + // START USERS + migration.addColumn('users', 'blocked', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'loginAttempts', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('users', 'blockedAt', { + type: Sequelize.DATE, + defaultValue: null + }); + migration.addColumn('users', 'disabled', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END USERS + + // START screen_recordings + migration.query('ALTER TABLE screen_recordings ENCRYPTION=\'Y\';'); + // END screen_recordings + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.20.js b/server/migrations/2.4.20.js new file mode 100644 index 0000000..e2f26ce --- /dev/null +++ b/server/migrations/2.4.20.js @@ -0,0 +1,176 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'googleSsoEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.query('UPDATE settings SET googleSsoEnabled = 1'); + // END settings + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.21.js b/server/migrations/2.4.21.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.21.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.3.js b/server/migrations/2.4.3.js new file mode 100644 index 0000000..fa87841 --- /dev/null +++ b/server/migrations/2.4.3.js @@ -0,0 +1,166 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.4.js b/server/migrations/2.4.4.js new file mode 100644 index 0000000..9b32164 --- /dev/null +++ b/server/migrations/2.4.4.js @@ -0,0 +1,191 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START int_zoho_accounts + migration.removeColumn('int_zoho_accounts', 'authToken'); + + migration.addColumn('int_zoho_accounts', 'zone', { + type: Sequelize.STRING, + defaultValue: 'EU' + }); + + migration.addColumn('int_zoho_accounts', 'clientId', { + type: Sequelize.STRING + }); + + migration.addColumn('int_zoho_accounts', 'clientSecret', { + type: Sequelize.STRING + }); + + migration.addColumn('int_zoho_accounts', 'code', { + type: Sequelize.STRING + }); + + migration.addColumn('int_zoho_accounts', 'refreshToken', { + type: Sequelize.STRING + }); + // END int_zoho_accounts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.5.js b/server/migrations/2.4.5.js new file mode 100644 index 0000000..fa87841 --- /dev/null +++ b/server/migrations/2.4.5.js @@ -0,0 +1,166 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.6.js b/server/migrations/2.4.6.js new file mode 100644 index 0000000..18de8a3 --- /dev/null +++ b/server/migrations/2.4.6.js @@ -0,0 +1,168 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.7.js b/server/migrations/2.4.7.js new file mode 100644 index 0000000..f74dee8 --- /dev/null +++ b/server/migrations/2.4.7.js @@ -0,0 +1,192 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START int_zoho_configurations + migration.addColumn('int_zoho_configurations', 'moduleCreate', { + type: Sequelize.ENUM('Leads', 'Contacts'), + defaultValue: 'Leads' + }); + // END int_zoho_configurations + + //START chat_interactions + migration.addColumn('chat_interactions', 'customerPort', { + type: Sequelize.STRING + }); + // END chat_interactions + + //START chat_websites + migration.addColumn('chat_websites', 'enableSendButton', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('chat_websites', 'feedbackTitle', { + type: Sequelize.STRING, + defaultValue: "Feedback" + }); + // END chat_websites + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.8.js b/server/migrations/2.4.8.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.8.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.4.9.js b/server/migrations/2.4.9.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.4.9.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.0.js b/server/migrations/2.5.0.js new file mode 100644 index 0000000..7746ad2 --- /dev/null +++ b/server/migrations/2.5.0.js @@ -0,0 +1,314 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START whatsapp + migration.query('CREATE TABLE `whatsapp_accounts` (' + + ' `id` int(11) NOT NULL AUTO_INCREMENT,' + + ' `name` varchar(255) NOT NULL,' + + ' `key` varchar(255) NOT NULL,' + + ' `remote` varchar(255) NOT NULL,' + + ' `token` varchar(255) DEFAULT NULL,' + + ' `phone` varchar(255) DEFAULT NULL,' + + ' `type` enum(\'twilio\') DEFAULT NULL,' + + ' `accountSid` varchar(255) DEFAULT NULL,' + + ' `authToken` varchar(255) DEFAULT NULL,' + + ' `notificationTemplate` text,' + + ' `notificationSound` tinyint(1) DEFAULT \'0\',' + + ' `notificationShake` tinyint(1) DEFAULT \'0\',' + + ' `waitForTheAssignedAgent` int(11) DEFAULT \'10\',' + + ' `queueTransfer` tinyint(1) DEFAULT \'0\',' + + ' `queueTransferTimeout` int(11) DEFAULT \'300\',' + + ' `agentTransfer` tinyint(1) DEFAULT \'0\',' + + ' `agentTransferTimeout` int(11) DEFAULT \'300\',' + + ' `mandatoryDispositionPauseId` int(11) DEFAULT NULL,' + + ' `mandatoryDisposition` tinyint(1) DEFAULT \'0\',' + + ' `description` varchar(255) DEFAULT NULL,' + + ' `createdAt` datetime NOT NULL,' + + ' `updatedAt` datetime NOT NULL,' + + ' `ListId` int(11) DEFAULT NULL,' + + ' PRIMARY KEY (`id`),' + + ' UNIQUE KEY `name` (`name`),' + + ' KEY `mandatoryDispositionPauseId` (`mandatoryDispositionPauseId`),' + + ' KEY `ListId` (`ListId`),' + + ' CONSTRAINT `whatsapp_accounts_ibfk_1` FOREIGN KEY (`mandatoryDispositionPauseId`) REFERENCES `tools_pauses` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,' + + ' CONSTRAINT `whatsapp_accounts_ibfk_2` FOREIGN KEY (`ListId`) REFERENCES `cm_lists` (`id`) ON DELETE SET NULL ON UPDATE CASCADE' + + ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + + migration.addColumn('tools_dispositions', 'WhatsappAccountId', { + type: Sequelize.INTEGER + }); + + migration.addColumn('tools_canned_answers', 'WhatsappAccountId', { + type: Sequelize.INTEGER + }); + + migration.addColumn('users', 'whatsappPause', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'whatsappCapacity', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.query('ALTER TABLE tools_dispositions ADD CONSTRAINT `tools_dispositions_ibfk_7` FOREIGN KEY (`WhatsappAccountId`) REFERENCES `whatsapp_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + migration.query('ALTER TABLE tools_dispositions ADD CONSTRAINT `name_whatsapp` UNIQUE KEY (`name`,`WhatsappAccountId`)'); + migration.query('ALTER TABLE tools_canned_answers ADD CONSTRAINT `tools_canned_answers_ibfk_6` FOREIGN KEY (`WhatsappAccountId`) REFERENCES `whatsapp_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + + migration.query('UPDATE users SET permissions=\'101,102,103,113,110,104,105,106,107,108,109,100,111,114\' WHERE role=\'agent\' AND permissions=\'101,102,103,110,104,105,106,107,108,109,100,111\''); + // END whatsapp + + // START chat_interactions + migration.addColumn('chat_interactions', 'vidaooSessionId', { + type: Sequelize.TEXT + }); + + // START chat_websites + migration.addColumn('chat_websites', 'vidaooEscalation', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('chat_websites', 'vidaooApiKey', { + type: Sequelize.STRING + }); + // END chat_websites + + // START voice_recordings + migration.addColumn('voice_recordings', 'location', { + type: Sequelize.TEXT + }); + migration.addColumn('voice_recordings', 'transcribeName', { + type: Sequelize.STRING + }); + migration.addColumn('voice_recordings', 'transcribeStatus', { + type: Sequelize.STRING, + defaultValue: 'NEW' + }); + migration.addColumn('voice_recordings', 'fileUri', { + type: Sequelize.TEXT + }); + migration.addColumn('voice_recordings', 'fileText', { + type: Sequelize.TEXT + }); + migration.addColumn('voice_recordings', 'failureReason', { + type: Sequelize.TEXT + }); + migration.addColumn('voice_recordings', 'sentiment', { + type: Sequelize.STRING + }); + migration.addColumn('voice_recordings', 'sPositive', { + type: Sequelize.FLOAT + }); + migration.addColumn('voice_recordings', 'sNegative', { + type: Sequelize.FLOAT + }); + migration.addColumn('voice_recordings', 'sNeutral', { + type: Sequelize.FLOAT + }); + migration.addColumn('voice_recordings', 'sMixed', { + type: Sequelize.FLOAT + }); + migration.addColumn('voice_recordings', 'tempSentiment', { + type: Sequelize.BOOLEAN + }); + // END voice_recordings + + // START settings + migration.addColumn('settings', 'transcribe', { + type: Sequelize.BOOLEAN + }); + migration.addColumn('settings', 'automaticTranscribe', { + type: Sequelize.BOOLEAN + }); + migration.addColumn('settings', 'transcribeAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('settings', 'transcribeRegion', { + type: Sequelize.STRING + }); + migration.addColumn('settings', 'sentiment', { + type: Sequelize.BOOLEAN + }); + migration.addColumn('settings', 'automaticSentiment', { + type: Sequelize.BOOLEAN + }); + migration.addColumn('settings', 'sentimentAccountId', { + type: Sequelize.INTEGER + }); + migration.addColumn('settings', 'sentimentRegion', { + type: Sequelize.STRING + }); + migration.addColumn('settings', 'language', { + type: Sequelize.STRING + }); + migration.addColumn('settings', 'bucket', { + type: Sequelize.STRING + }); + // END settings + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.1.js b/server/migrations/2.5.1.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.5.1.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.10.js b/server/migrations/2.5.10.js new file mode 100644 index 0000000..eead711 --- /dev/null +++ b/server/migrations/2.5.10.js @@ -0,0 +1,177 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START square_projects + migration.addColumn('square_projects', 'savedAt', { + type: Sequelize.DATE + }); + + migration.addColumn('square_projects', 'publishedAt', { + type: Sequelize.DATE + }); + // END square_projects + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.11.js b/server/migrations/2.5.11.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.5.11.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.12.js b/server/migrations/2.5.12.js new file mode 100644 index 0000000..0f7efe0 --- /dev/null +++ b/server/migrations/2.5.12.js @@ -0,0 +1,221 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + //START integration + migration.query("UPDATE int_desk_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_dynamics365_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_freshdesk_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_freshsales_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_salesforce_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_servicenow_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_sugarcrm_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_vtiger_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_zendesk_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + migration.query("UPDATE int_zoho_accounts SET serverUrl='https://YOUR-MOTION-IPADDRESS' WHERE serverUrl IS NULL OR serverUrl = ''"); + + migration.changeColumn('int_desk_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_dynamics365_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_freshdesk_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_freshsales_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_salesforce_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_servicenow_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_sugarcrm_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_vtiger_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_zendesk_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + migration.changeColumn('int_zoho_accounts', 'serverUrl', { + type: Sequelize.STRING, + allowNull: false + }); + //END integration + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.13.js b/server/migrations/2.5.13.js new file mode 100644 index 0000000..01e22ec --- /dev/null +++ b/server/migrations/2.5.13.js @@ -0,0 +1,168 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.14.js b/server/migrations/2.5.14.js new file mode 100644 index 0000000..4c36724 --- /dev/null +++ b/server/migrations/2.5.14.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.15.js b/server/migrations/2.5.15.js new file mode 100644 index 0000000..4d03ae5 --- /dev/null +++ b/server/migrations/2.5.15.js @@ -0,0 +1,177 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + //START jscripty + migration.changeColumn('report_jscripty_questions', 'question', { + type: Sequelize.TEXT + }); + + migration.changeColumn('report_jscripty_answers', 'question', { + type: Sequelize.TEXT + }); + //END jscripty + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.16.js b/server/migrations/2.5.16.js new file mode 100644 index 0000000..084dda0 --- /dev/null +++ b/server/migrations/2.5.16.js @@ -0,0 +1,179 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START SMSACCOUNT + migration.addColumn('sms_accounts', 'applicationId', { + type: Sequelize.STRING + }); + + migration.addColumn('sms_accounts', 'accountId', { + type: Sequelize.STRING + }); + + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo', 'clickatell', 'csc', 'bandwidth') + }); + // END SMSACCOUNT + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.17.js b/server/migrations/2.5.17.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.17.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.18.js b/server/migrations/2.5.18.js new file mode 100644 index 0000000..6dd7db6 --- /dev/null +++ b/server/migrations/2.5.18.js @@ -0,0 +1,198 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'chatInteractionsReloadTimeout', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('settings', 'mailInteractionsReloadTimeout', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('settings', 'openchannelInteractionsReloadTimeout', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('settings', 'smsInteractionsReloadTimeout', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('settings', 'whatsappInteractionsReloadTimeout', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + // END settings + + // START mail_applications + migration.query('UPDATE mail_applications SET appdata = REPLACE(appdata, \'0,\', \'0,1\') WHERE appdata LIKE \'0,%\' AND app = \'autoreply\';'); + + migration.query('UPDATE mail_applications SET appdata = REPLACE(appdata, \'1,\', \'1,1\') WHERE appdata LIKE \'1,%\' AND app = \'autoreply\';'); + // END mail_applications + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.19.js b/server/migrations/2.5.19.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.19.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.2.js b/server/migrations/2.5.2.js new file mode 100644 index 0000000..af4a0b1 --- /dev/null +++ b/server/migrations/2.5.2.js @@ -0,0 +1,343 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START whatsapp + migration.query('ALTER TABLE whatsapp_accounts ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE whatsapp_interactions ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE whatsapp_messages ENCRYPTION=\'Y\';'); + migration.query('ALTER TABLE report_whatsapp_queue ENCRYPTION=\'Y\';'); + // END whatsapp + + // START cloud_providers + migration.query('ALTER TABLE cloud_providers ENCRYPTION=\'Y\';'); + // END cloud_providers + + // START voice_extensions + migration.query('ALTER TABLE voice_extensions DROP FOREIGN KEY voice_extensions_ibfk_7'); + migration.query('ALTER TABLE voice_extensions DROP INDEX voice_extensions_ibfk_7'); + migration.query('ALTER TABLE voice_extensions ADD CONSTRAINT voice_extensions_ibfk_7 FOREIGN KEY (VoicePrefixId) REFERENCES voice_prefixes(id) ON UPDATE CASCADE ON DELETE CASCADE'); + // END voice_extensions + + //START voice_queues + migration.addColumn('voice_queues', 'dialNoSuchNumberMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('voice_queues', 'dialNoSuchNumberRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + + migration.addColumn('voice_queues', 'dialDropMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('voice_queues', 'dialDropRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + + migration.addColumn('voice_queues', 'dialAbandonedMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('voice_queues', 'dialAbandonedRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + + migration.addColumn('voice_queues', 'dialMachineMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('voice_queues', 'dialMachineRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + + migration.addColumn('voice_queues', 'dialAgentRejectMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('voice_queues', 'dialAgentRejectRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + //END voice_queues + + //START campaigns + migration.addColumn('campaigns', 'dialNoSuchNumberMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('campaigns', 'dialNoSuchNumberRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + migration.addColumn('campaigns', 'dialDropMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('campaigns', 'dialDropRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + migration.addColumn('campaigns', 'dialAbandonedMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('campaigns', 'dialAbandonedRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + migration.addColumn('campaigns', 'dialMachineMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('campaigns', 'dialMachineRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + migration.addColumn('campaigns', 'dialAgentRejectMaxRetry', { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + migration.addColumn('campaigns', 'dialAgentRejectRetryFrequency', { + type: Sequelize.INTEGER, + defaultValue: 150 + }); + //END campaigns + + //START cm_hopper + migration.addColumn('cm_hopper', 'countnosuchnumberretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper', 'countdropretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper', 'countabandonedretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper', 'countmachineretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper', 'countagentrejectretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + //END cm_hopper + + //START cm_hopper_final + migration.addColumn('cm_hopper_final', 'countnosuchnumberretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_final', 'countdropretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_final', 'countabandonedretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_final', 'countmachineretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_final', 'countagentrejectretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + //END cm_hopper_final + + //START cm_hopper_history + migration.addColumn('cm_hopper_history', 'countnosuchnumberretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_history', 'countdropretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_history', 'countabandonedretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_history', 'countmachineretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper_history', 'countagentrejectretry', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + //END cm_hopper_history + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.20.js b/server/migrations/2.5.20.js new file mode 100644 index 0000000..1a383d8 --- /dev/null +++ b/server/migrations/2.5.20.js @@ -0,0 +1,179 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'searchOnEnterKey', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END settings + + // START DASHBOARD_ITEM + migration.addColumn('dashboard_items', 'titleFontSize', { + type: Sequelize.INTEGER, + defaultValue: 12 + }); + // END DASHBOARD_ITEM + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.21.js b/server/migrations/2.5.21.js new file mode 100644 index 0000000..1d6125d --- /dev/null +++ b/server/migrations/2.5.21.js @@ -0,0 +1,169 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START team_has_voice_queues + migration.query('ALTER TABLE team_has_voice_queues ADD COLUMN penalty SMALLINT(3) UNSIGNED DEFAULT 0 FIRST;'); + // END team_has_voice_queues + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.22.js b/server/migrations/2.5.22.js new file mode 100644 index 0000000..ca470b0 --- /dev/null +++ b/server/migrations/2.5.22.js @@ -0,0 +1,202 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START chat_websites + migration.addColumn('chat_websites', 'openNewInteraction', { + type: Sequelize.BOOLEAN, + defaultValue: false, + allowNull: true + }); + + migration.addColumn('chat_websites', 'MailAccountId', { + type: Sequelize.INTEGER + }); + + migration.query('ALTER TABLE chat_websites ADD CONSTRAINT `chat_websites_ibfk_4` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + // END chat_websites + + // START mail_messages + migration.addColumn('mail_messages', 'ChatWebsiteId', { + type: Sequelize.INTEGER + }); + + migration.addColumn('mail_messages', 'originChannel', { + type: Sequelize.ENUM('Email', 'Chat'), + defaultValue: 'Email', + allowNull: true + }); + + migration.addColumn('mail_messages', 'ChatOfflineMessageId', { + type: Sequelize.INTEGER + }); + + migration.query('ALTER TABLE mail_messages ADD CONSTRAINT `mail_messages_ibfk_5` FOREIGN KEY (`ChatWebsiteId`) REFERENCES `chat_websites` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + migration.query('ALTER TABLE mail_messages ADD CONSTRAINT `mail_messages_ibfk_6` FOREIGN KEY (`ChatOfflineMessageId`) REFERENCES `chat_offline_messages` (`id`) ON DELETE SET NULL ON UPDATE CASCADE'); + // END mail_messages + + // START voice_voicemail_messages + migration.query('ALTER TABLE voice_voicemail_messages MODIFY stamp timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;'); + // END voice_voicemail_messages + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.23.js b/server/migrations/2.5.23.js new file mode 100644 index 0000000..298f17f --- /dev/null +++ b/server/migrations/2.5.23.js @@ -0,0 +1,253 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START user_profiles + migration.addColumn('user_profiles', 'privacyEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: false, + after: 'description' + }); + // END user_profiles + + // START settings + migration.addColumn('settings', 'privacyPolicyNumber', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 0 + }); + + migration.addColumn('settings', 'privacyPolicyEmail', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 0 + }); + + migration.addColumn('settings', 'privacyPolicyName', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 0 + }); + // END settings + + // START integration fields + migration.changeColumn('int_desk_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_dynamics365_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_freshdesk_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_freshsales_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_salesforce_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_servicenow_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_sugarcrm_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_vtiger_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_zendesk_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + + migration.changeColumn('int_zoho_fields', 'type', { + type: Sequelize.ENUM('string', 'variable', 'customVariable', 'keyValue', 'picklist') + }); + // END integration fields + + // START int_salesforce_configurations + migration.addColumn('int_salesforce_configurations', 'leadId', { + type: Sequelize.STRING + }); + + migration.query("ALTER TABLE int_salesforce_configurations MODIFY moduleSearch ENUM('contact_lead','contact','lead','account_contact_lead','account')"); + migration.query("ALTER TABLE int_salesforce_configurations MODIFY moduleCreate ENUM('nothing','contact','lead','account')"); + + migration.addColumn('int_salesforce_configurations', 'additionalSearchAccount', { + type: Sequelize.STRING + }); + + migration.addColumn('int_salesforce_configurations', 'additionalSearchContact', { + type: Sequelize.STRING + }); + + migration.addColumn('int_salesforce_configurations', 'additionalSearchLead', { + type: Sequelize.STRING + }); + // END int_salesforce_configurations + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.24.js b/server/migrations/2.5.24.js new file mode 100644 index 0000000..630cece --- /dev/null +++ b/server/migrations/2.5.24.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + migration.query('ALTER TABLE mail_servers_in DROP INDEX username'); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.25.js b/server/migrations/2.5.25.js new file mode 100644 index 0000000..c3dbba8 --- /dev/null +++ b/server/migrations/2.5.25.js @@ -0,0 +1,172 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'stopRecordingOnTransfer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END settings + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.26.js b/server/migrations/2.5.26.js new file mode 100644 index 0000000..f93a9c2 --- /dev/null +++ b/server/migrations/2.5.26.js @@ -0,0 +1,179 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START attachments + migration.addColumn('attachments', 'ChatOfflineMessageId', { + type: Sequelize.INTEGER + }); + + migration.query('ALTER TABLE `attachments` ADD CONSTRAINT `attachments_ibfk_2` FOREIGN KEY (`ChatOfflineMessageId`) REFERENCES `chat_offline_messages` (`id`) ON UPDATE CASCADE ON DELETE CASCADE'); + // END attachments + + // START CHAT_WEBSITES + migration.addColumn('chat_websites', 'subjectOffline', { + type: Sequelize.TEXT + }); + // END CHAT_WEBSITES + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.27.js b/server/migrations/2.5.27.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.27.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.28.js b/server/migrations/2.5.28.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.28.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.29.js b/server/migrations/2.5.29.js new file mode 100644 index 0000000..dd75706 --- /dev/null +++ b/server/migrations/2.5.29.js @@ -0,0 +1,172 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START users + migration.addColumn('users', 'wssPort', { + type: Sequelize.INTEGER(5).UNSIGNED, + defaultValue: 8089 + }); + // END users + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.3.js b/server/migrations/2.5.3.js new file mode 100644 index 0000000..3b6261d --- /dev/null +++ b/server/migrations/2.5.3.js @@ -0,0 +1,187 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START chat_websites + migration.changeColumn('chat_websites', 'color', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#011F6A', + validate: { + notEmpty: true + } + }); + + migration.changeColumn('chat_websites', 'color_button', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#011F6A', + validate: { + notEmpty: true + } + }); + // END chat_websites + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.30.js b/server/migrations/2.5.30.js new file mode 100644 index 0000000..c466915 --- /dev/null +++ b/server/migrations/2.5.30.js @@ -0,0 +1,223 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START users + migration.changeColumn('users', 'previousPasswords', { + type: Sequelize.TEXT + }); + + migration.addColumn('users', 'downloadAttachments', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('users', 'downloadOmnichannelInteractions', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('users', 'downloadVoiceRecordings', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END users + + // START user_profiles + migration.addColumn('user_profiles', 'downloadAttachments', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadCallySquareRecordings', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadContactManagerLists', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadJscriptySessions', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadOmnichannelInteractions', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadScreenRecordings', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('user_profiles', 'downloadVoiceRecordings', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END user_profiles + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.31.js b/server/migrations/2.5.31.js new file mode 100644 index 0000000..4d49c15 --- /dev/null +++ b/server/migrations/2.5.31.js @@ -0,0 +1,182 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + //STAR chat_websites + migration.addColumn('chat_websites', 'vidaooTopic', { + type: Sequelize.STRING, + defaultValue: 'Generated by XCALLY Motion' + }); + + migration.addColumn('chat_websites', 'vidaooNote', { + type: Sequelize.STRING, + defaultValue: 'Meeting generated for interaction #{{interaction.id}} by {{agent.name}}' + }); + + migration.addColumn('chat_websites', 'vidaooMetadata', { + type: Sequelize.TEXT, + defaultValue: null + }); + //END chat_websites + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.32.js b/server/migrations/2.5.32.js new file mode 100644 index 0000000..211dddc --- /dev/null +++ b/server/migrations/2.5.32.js @@ -0,0 +1,192 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + //STAR *_interactions + migration.addColumn('mail_interactions', 'autoreplyExecuted', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('chat_interactions', 'autoreplyExecuted', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('openchannel_interactions', 'autoreplyExecuted', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('sms_interactions', 'autoreplyExecuted', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('whatsapp_interactions', 'autoreplyExecuted', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + //END *_interactions + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.33.js b/server/migrations/2.5.33.js new file mode 100644 index 0000000..b385309 --- /dev/null +++ b/server/migrations/2.5.33.js @@ -0,0 +1,189 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START voice_extensions + migration.addColumn('voice_extensions', 'alias', { + type: Sequelize.STRING, + allowNull: true + }); + // END voice_extensions + + //START cm_list + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_6`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_6` FOREIGN KEY (`ListId`) REFERENCES `cm_lists`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_5`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_5` FOREIGN KEY (`ChatWebsiteId`) REFERENCES `chat_websites`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_4`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_4` FOREIGN KEY (`OpenchannelAccountId`) REFERENCES `openchannel_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_3`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_3` FOREIGN KEY (`SmsAccountId`) REFERENCES `sms_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_2`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_2` FOREIGN KEY (`FaxAccountId`) REFERENCES `fax_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_1`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_1` FOREIGN KEY (`MailAccountId`) REFERENCES `mail_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + migration.query('ALTER TABLE `tools_dispositions` DROP FOREIGN KEY `tools_dispositions_ibfk_7`'); + migration.query('ALTER TABLE `tools_dispositions` ADD CONSTRAINT `tools_dispositions_ibfk_7` FOREIGN KEY (`WhatsappAccountId`) REFERENCES `whatsapp_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + //END cm_list + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.34.js b/server/migrations/2.5.34.js new file mode 100644 index 0000000..f7d42ec --- /dev/null +++ b/server/migrations/2.5.34.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.35.js b/server/migrations/2.5.35.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.35.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.36.js b/server/migrations/2.5.36.js new file mode 100644 index 0000000..e3fb3ea --- /dev/null +++ b/server/migrations/2.5.36.js @@ -0,0 +1,184 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START users + migration.addColumn('users', 'ignorePauseForPreviewCalls', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('users', 'selectRecallMeCampaign', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END users + + // START voice_queues + migration.addColumn('voice_queues', 'dialPreviewAutoRecallMe', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END voice_queues + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.37.js b/server/migrations/2.5.37.js new file mode 100644 index 0000000..08493a4 --- /dev/null +++ b/server/migrations/2.5.37.js @@ -0,0 +1,187 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'viewHelpSection', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('settings', 'secureCookieEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END settings + + // START whatsapp_accounts + migration.addColumn('whatsapp_accounts', 'baseUrl', { + type: Sequelize.STRING + }); + + migration.changeColumn('whatsapp_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'sinch') + }); + // END whatsapp_accounts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.38.js b/server/migrations/2.5.38.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.38.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.39.js b/server/migrations/2.5.39.js new file mode 100644 index 0000000..4262900 --- /dev/null +++ b/server/migrations/2.5.39.js @@ -0,0 +1,193 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START CHAT WEBSITE + migration.addColumn('chat_websites', 'labelText', { + type: Sequelize.STRING, + defaultValue: 'CHAT' + }); + // END CHAT WEBSITE + + // START settings + migration.addColumn('settings', 'adSsoEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END settings + + // START users + migration.addColumn('users', 'adSsoEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + // END users + + // START int_dynamics365_configurations + migration.addColumn('int_dynamics365_configurations', 'moduleCreate', { + type: Sequelize.ENUM('contact', 'nothing'), + defaultValue: 'contact' + }); + // END int_dynamics365_configurations + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.4.js b/server/migrations/2.5.4.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.5.4.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.40.js b/server/migrations/2.5.40.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.40.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.41.js b/server/migrations/2.5.41.js new file mode 100644 index 0000000..6639582 --- /dev/null +++ b/server/migrations/2.5.41.js @@ -0,0 +1,297 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START settings + migration.addColumn('settings', 'limitTabs', { + type: Sequelize.INTEGER, + defaultValue: 20 + }); + + migration.addColumn('settings', 'disabledCookie', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('settings', 'previewRecallmeReminderInterval', { + type: Sequelize.INTEGER, + defaultValue: 5 + }); + // END settings + + // START cm_hopper + migration.addColumn('cm_hopper', 'recallmeNotifiedDate', { + type: Sequelize.DATE, + allowNull: true + }); + // END cm_hopper + + // START voice_queues + migration.addColumn('voice_queues', 'dialPreviewRecallmeReminder', { + type: Sequelize.BOOLEAN, + default: false + }); + // END voice_queues + + // START cloud_providers + migration.changeColumn('cloud_providers', 'service', { + type: Sequelize.ENUM('AmazonAWS', 'Google', 'MicrosoftAzure') + }); + + migration.addColumn('cloud_providers', 'type', { + type: Sequelize.ENUM('Outlook365', 'Dynamics365'), + after: 'service' + }); + + migration.addColumn('cloud_providers', 'data3', { + type: Sequelize.STRING, + after: 'data2' + }); + + migration.addColumn('cloud_providers', 'data4', { + type: Sequelize.STRING, + after: 'data3' + }); + + migration.addColumn('cloud_providers', 'data5', { + type: Sequelize.TEXT, + after: 'data4' + }); + + migration.addColumn('cloud_providers', 'data6', { + type: Sequelize.TEXT, + after: 'data5' + }); + + migration.addColumn('cloud_providers', 'data7', { + type: Sequelize.TEXT, + after: 'data6' + }); + // END cloud_providers + + // START mail_accounts + migration.addColumn('mail_accounts', 'provider', { + type: Sequelize.ENUM('gmail', 'hotmail', 'yahoo', 'outlook365'), + after: 'name', + defaultValue: null + }); + // END mail_accounts + + // START mail_servers_in + migration.query('UPDATE mail_servers_in SET host = \'imap.gmail.com\' WHERE service = \'gmail\' AND host IS NULL'); + migration.query('UPDATE mail_servers_in SET port = 993 WHERE service = \'gmail\' AND port IS NULL'); + + migration.query('UPDATE mail_servers_in SET host = \'imap-mail.outlook.com\' WHERE service = \'hotmail\' AND host IS NULL'); + migration.query('UPDATE mail_servers_in SET port = 993 WHERE service = \'hotmail\' AND port IS NULL'); + + migration.query('UPDATE mail_servers_in SET host = \'imap.mail.yahoo.com\' WHERE service = \'yahoo\' AND host IS NULL'); + migration.query('UPDATE mail_servers_in SET port = 993 WHERE service = \'yahoo\' AND port IS NULL'); + + migration.query('UPDATE mail_servers_in SET host = \'outlook.office365.com\' WHERE service = \'outlook365\' AND host IS NULL'); + migration.query('UPDATE mail_servers_in SET port = 993 WHERE service = \'outlook365\' AND port IS NULL'); + + migration.addColumn('mail_servers_in', 'modernAuthentication', { + type: Sequelize.BOOLEAN, + defaultValue: false, + after: 'authentication' + }); + + migration.addColumn('mail_servers_in', 'CloudProviderId', { + type: Sequelize.INTEGER + }); + + migration.addIndex('mail_servers_in', ['CloudProviderId'], 'CloudProviderId'); + + migration.query('ALTER TABLE `mail_servers_in` ADD CONSTRAINT `mail_servers_in_ibfk_2` FOREIGN KEY (`CloudProviderId`) REFERENCES `cloud_providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE'); + // END mail_servers_in + + // START mail_servers_out + migration.query('UPDATE mail_servers_out SET host = \'smtp.gmail.com\' WHERE service = \'gmail\' AND host IS NULL'); + migration.query('UPDATE mail_servers_out SET port = 465 WHERE service = \'gmail\' AND port IS NULL AND secure = 0'); + migration.query('UPDATE mail_servers_out SET port = 587 WHERE service = \'gmail\' AND port IS NULL AND secure = 1'); + + migration.query('UPDATE mail_servers_out SET host = \'smtp-mail.outlook.com\' WHERE service = \'hotmail\' AND host IS NULL'); + migration.query('UPDATE mail_servers_out SET port = 587 WHERE service = \'hotmail\' AND port IS NULL'); + + migration.query('UPDATE mail_servers_out SET host = \'smtp.mail.yahoo.com\' WHERE service = \'yahoo\' AND host IS NULL'); + migration.query('UPDATE mail_servers_out SET port = 465 WHERE service = \'yahoo\' AND port IS NULL'); + + migration.query('UPDATE mail_servers_out SET host = \'smtp.office365.com\' WHERE service = \'outlook365\' AND host IS NULL'); + migration.query('UPDATE mail_servers_out SET port = 587 WHERE service = \'outlook365\' AND port IS NULL'); + + migration.addColumn('mail_servers_out', 'modernAuthentication', { + type: Sequelize.BOOLEAN, + defaultValue: false, + after: 'authentication' + }); + + migration.addColumn('mail_servers_out', 'CloudProviderId', { + type: Sequelize.INTEGER + }); + + migration.addIndex('mail_servers_out', ['CloudProviderId'], 'CloudProviderId'); + + migration.query('ALTER TABLE `mail_servers_out` ADD CONSTRAINT `mail_servers_out_ibfk_2` FOREIGN KEY (`CloudProviderId`) REFERENCES `cloud_providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE'); + // END mail_servers_out + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.42.js b/server/migrations/2.5.42.js new file mode 100644 index 0000000..0bcfee4 --- /dev/null +++ b/server/migrations/2.5.42.js @@ -0,0 +1,172 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START chat_offline_messages + migration.addColumn("chat_offline_messages", "plainBody", { + type: Sequelize.TEXT("medium"), + after: "body" + }); + // END chat_offline_messages + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.43.js b/server/migrations/2.5.43.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.43.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.44.js b/server/migrations/2.5.44.js new file mode 100644 index 0000000..27ec7ad --- /dev/null +++ b/server/migrations/2.5.44.js @@ -0,0 +1,219 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START user settings + migration.query('CREATE TABLE `user_settings` (' + + ' `id` int(11) NOT NULL AUTO_INCREMENT,' + + ' `clientSideLoggingLevel` enum(\'error\',\'warning\',\'info\',\'debug\') NOT NULL DEFAULT \'error\',' + + ' `clientSideLoggingEnabled` tinyint(1) DEFAULT \'0\',' + + ' `clientSideLoggingScopes` text,' + + ' `clientSideLoggingEnabledSince` datetime DEFAULT NULL,' + + ' `createdAt` datetime NOT NULL,' + + ' `updatedAt` datetime NOT NULL,' + + ' `UserId` int(11) DEFAULT NULL,' + + ' PRIMARY KEY (`id`),' + + ' UNIQUE KEY `UserId` (`UserId`),' + + ' CONSTRAINT `user_settings_ibfk_1` FOREIGN KEY (`UserId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE' + + ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'); + + migration.query( + "INSERT INTO `user_settings`(clientSideLoggingLevel, clientSideLoggingEnabled, clientSideLoggingEnabledSince, createdAt , updatedAt , UserId) SELECT 'error', false, NULL, NOW(), NOW(), id FROM `users`" + ); + // END user settings + + //START timezone + migration.addColumn('cm_contacts', 'dialTimezone', { + type: Sequelize.STRING + }); + migration.addColumn('cm_contacts', 'utcOffset', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + migration.addColumn('cm_hopper', 'dialTimezone', { + type: Sequelize.STRING + }); + migration.addColumn('cm_hopper_history', 'dialTimezone', { + type: Sequelize.STRING + }); + //END timezone + + // START int_dynamics365_accounts + migration.addColumn('int_dynamics365_accounts', 'CloudProviderId', { + type: Sequelize.INTEGER + }); + + migration.addIndex('int_dynamics365_accounts', ['CloudProviderId'], 'CloudProviderId'); + + migration.query('ALTER TABLE `int_dynamics365_accounts` ADD CONSTRAINT `int_dynamics365_accounts_ibfk_2` FOREIGN KEY (`CloudProviderId`) REFERENCES `cloud_providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE'); + + migration.addColumn('int_dynamics365_accounts', 'modernAuthentication', { + type: Sequelize.BOOLEAN, + defaultValue: true, + after: 'description' + }); + + migration.query('UPDATE int_dynamics365_accounts SET modernAuthentication = 0'); + // END int_dynamics365_accounts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.45.js b/server/migrations/2.5.45.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.45.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.46.js b/server/migrations/2.5.46.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.46.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.47.js b/server/migrations/2.5.47.js new file mode 100644 index 0000000..22df2f1 --- /dev/null +++ b/server/migrations/2.5.47.js @@ -0,0 +1,165 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.48.js b/server/migrations/2.5.48.js new file mode 100644 index 0000000..32039a5 --- /dev/null +++ b/server/migrations/2.5.48.js @@ -0,0 +1,237 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START mail_servers_out + migration.query( + 'UPDATE `mail_servers_out` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'smtp.office365.com', T1.port = 587, T1.secure = 0, T1.service = NULL" + + " WHERE T2.provider = 'outlook365'" + ); + + migration.query( + 'UPDATE `mail_servers_out` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'smtp-mail.outlook.com', T1.port = 587, T1.secure = 0, T1.service = NULL" + + " WHERE T2.provider = 'hotmail'" + ); + + migration.query( + 'UPDATE `mail_servers_out` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'smtp.mail.yahoo.com', T1.port = 587, T1.secure = 0, T1.service = NULL" + + " WHERE T2.provider = 'yahoo'" + ); + + migration.query( + 'UPDATE `mail_servers_out` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'smtp.gmail.com', T1.port = 587, T1.secure = 0, T1.service = NULL" + + " WHERE T2.provider = 'gmail'" + ); + // END mail_servers_out + + // START mail_servers_in + migration.query( + 'UPDATE `mail_servers_in` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = '127.0.0.1', T1.port = 993, T1.user = 'username', T1.password = 'password'" + + " WHERE T2.service = 1" + ); + + migration.query( + 'UPDATE `mail_servers_in` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'outlook.office365.com', T1.port = 993, T1.service = NULL" + + " WHERE T2.provider = 'outlook365' AND T2.service = 0" + ); + + migration.query( + 'UPDATE `mail_servers_in` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'imap-mail.outlook.com', T1.port = 993, T1.service = NULL" + + " WHERE T2.provider = 'hotmail' AND T2.service = 0" + ); + + migration.query( + 'UPDATE `mail_servers_in` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'imap.mail.yahoo.com', T1.port = 993, T1.service = NULL" + + " WHERE T2.provider = 'yahoo' AND T2.service = 0" + ); + + migration.query( + 'UPDATE `mail_servers_in` T1' + + ' JOIN `mail_accounts` T2 ON (T1.MailAccountId = T2.id)' + + " SET T1.host = 'imap.gmail.com', T1.port = 993, T1.service = NULL" + + " WHERE T2.provider = 'gmail' AND T2.service = 0" + ); + // END mail_servers_in + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.5.49.js b/server/migrations/2.5.49.js new file mode 100644 index 0000000..293edbf --- /dev/null +++ b/server/migrations/2.5.49.js @@ -0,0 +1,224 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + migration.addColumn('users', 'chatAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'chatAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('users', 'emailAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'emailAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('users', 'smsAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'smsAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('users', 'openchannelAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'openchannelAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('users', 'faxAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'faxAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + migration.addColumn('users', 'whatsappAutoanswer', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + migration.addColumn('users', 'whatsappAutoanswerDelay', { + type: Sequelize.INTEGER, + defaultValue: 0 + }); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.5.5.js b/server/migrations/2.5.5.js new file mode 100644 index 0000000..1ff9442 --- /dev/null +++ b/server/migrations/2.5.5.js @@ -0,0 +1,355 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START tools_actions + migration.query("UPDATE tools_actions SET data3 = 'phone' WHERE action = 'contactManager' AND data3 = '0'"); + migration.query("UPDATE tools_actions SET data4 = NULL WHERE action = 'contactManager' AND data2 = '0' AND data4 = '0'"); + migration.query("UPDATE tools_actions SET data4 = 'phone' WHERE action = 'contactManager' AND data4 = '0'"); + // END tools_actions + + // START settings + migration.addColumn('settings', 'enforcePasswordHistory', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + + migration.addColumn('settings', 'passwordHistoryLimit', { + type: Sequelize.INTEGER(2).UNSIGNED, + defaultValue: 3, + validate: { + min: 1, + max: 5 + } + }); + // END settings + + // START users + migration.addColumn('users', 'previousPasswords', { + type: Sequelize.STRING, + after: 'passwordResetAt' + }); + + migration.addColumn('users', 'settingsEnabled', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // END users + + // START cm_custom_fields + migration.addColumn('cm_custom_fields', 'clickToAction', { + type: Sequelize.BOOLEAN, + defaultValue: false + }); + + migration.addColumn('cm_custom_fields', 'actionType', { + type: Sequelize.ENUM('voice'), + allowNull: false, + defaultValue: 'voice' + }); + // END cm_custom_fields + + // START tools_disposition + migration.addColumn('tools_dispositions', 'level', { + type: Sequelize.ENUM('first', 'second', 'third'), + allowNull: false, + defaultValue: 'first', + after: "name" + }); + + migration.addColumn('tools_dispositions', 'description', { + type: Sequelize.STRING, + after: "level" + }); + + migration.addColumn('tools_dispositions', 'ParentId', { + type: Sequelize.INTEGER, + after: "updatedAt" + }); + + migration.query('ALTER TABLE tools_dispositions ADD CONSTRAINT `tools_dispositions_ibfk_8` FOREIGN KEY (`ParentId`) REFERENCES `tools_dispositions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); + // END tools_disposition + + // START report_call + migration.addColumn('report_call', 'userSecondDisposition', { + type: Sequelize.STRING, + after: "userDisposition" + }); + + migration.addColumn('report_call', 'userThirdDisposition', { + type: Sequelize.STRING, + after: "userSecondDisposition" + }); + // END report_call + + // START report_queue + migration.addColumn('report_queue', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('report_queue', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END report_queue + + // START voice_recordings + migration.addColumn('voice_recordings', 'userSecondDisposition', { + type: Sequelize.STRING, + after: "userDisposition" + }); + + migration.addColumn('voice_recordings', 'userThirdDisposition', { + type: Sequelize.STRING, + after: "userSecondDisposition" + }); + // END voice_recordings + + // START chat_interactions + migration.addColumn('chat_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('chat_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END chat_interactions + + // START fax_interactions + migration.addColumn('fax_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('fax_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END fax_interactions + + // START mail_interactions + migration.addColumn('mail_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('mail_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END mail_interactions + + // START openchannel_interactions + migration.addColumn('openchannel_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('openchannel_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END openchannel_interactions + + // START sms_interactions + migration.addColumn('sms_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('sms_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END sms_interactions + + // START whatsapp_interactions + migration.addColumn('whatsapp_interactions', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('whatsapp_interactions', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END whatsapp_interactions + + // START cm_hopper_final + migration.addColumn('cm_hopper_final', 'secondDisposition', { + type: Sequelize.STRING, + after: "disposition" + }); + + migration.addColumn('cm_hopper_final', 'thirdDisposition', { + type: Sequelize.STRING, + after: "secondDisposition" + }); + // END cm_hopper_final + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.50.js b/server/migrations/2.5.50.js new file mode 100644 index 0000000..1f96159 --- /dev/null +++ b/server/migrations/2.5.50.js @@ -0,0 +1,185 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + + // START chat_websites + migration.addColumn('chat_websites', 'textButtonColor', { + type: Sequelize.STRING, + allowNull: false, + defaultValue: '#ffffff', + validate: { + notEmpty: true + } + }); + + migration.query('UPDATE chat_websites SET textButtonColor=textColor'); + // STOP chat_websites + + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.5.6.js b/server/migrations/2.5.6.js new file mode 100644 index 0000000..35096ff --- /dev/null +++ b/server/migrations/2.5.6.js @@ -0,0 +1,174 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START cm_contacts + migration.addIndex("cm_contacts", ["firstName", "lastName", "phone", "mobile", "fax", "email"], { + indexName: "fti_cm_contacts", + indicesType: "FULLTEXT" + }); + // END cm_contacts + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.7.js b/server/migrations/2.5.7.js new file mode 100644 index 0000000..93422ad --- /dev/null +++ b/server/migrations/2.5.7.js @@ -0,0 +1,209 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + //START dialogflow + migration.addColumn('chat_messages', 'providerName', { + type: Sequelize.STRING + }); + + migration.addColumn('chat_messages', 'providerResponse', { + type: Sequelize.TEXT + }); + + migration.addColumn('openchannel_messages', 'providerName', { + type: Sequelize.STRING + }); + + migration.addColumn('openchannel_messages', 'providerResponse', { + type: Sequelize.TEXT + }); + + migration.addColumn('sms_messages', 'providerName', { + type: Sequelize.STRING + }); + + migration.addColumn('sms_messages', 'providerResponse', { + type: Sequelize.TEXT + }); + + migration.addColumn('whatsapp_messages', 'providerName', { + type: Sequelize.STRING + }); + + migration.addColumn('whatsapp_messages', 'providerResponse', { + type: Sequelize.TEXT + }); + + migration.addColumn('square_messages', 'providerName', { + type: Sequelize.STRING + }); + + migration.addColumn('square_messages', 'providerResponse', { + type: Sequelize.TEXT + }); + //END dialogflow + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.8.js b/server/migrations/2.5.8.js new file mode 100644 index 0000000..ee05d10 --- /dev/null +++ b/server/migrations/2.5.8.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.5.9.js b/server/migrations/2.5.9.js new file mode 100644 index 0000000..4c36724 --- /dev/null +++ b/server/migrations/2.5.9.js @@ -0,0 +1,167 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, options) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: options.indexName, + indicesType: options.indicesType + }) + .then(function() { + logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + } +}; \ No newline at end of file diff --git a/server/migrations/2.6.0.js b/server/migrations/2.6.0.js new file mode 100644 index 0000000..75b29b4 --- /dev/null +++ b/server/migrations/2.6.0.js @@ -0,0 +1,249 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START tools_contact_item_types + migration.query( + "CREATE TABLE `tools_contact_item_types` (" + + " `id` INT AUTO_INCREMENT NOT NULL," + + " `name` varchar(255) NOT NULL," + + " `OrderBy` INT NULL," + + " `rgbBackgroundColor` varchar(20) NULL," + + " `createdAt` datetime NOT NULL," + + " `updatedAt` datetime NOT NULL," + + " UNIQUE INDEX `item_type_id` (id) " + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" + ); + // END tools_contact_item_types + + // START cm_contact_has_items + migration.query( + "CREATE TABLE `cm_contact_has_items` (" + + " `CmContactId` INT NOT NULL," + + " `item` varchar(255) NOT NULL," + + " `ItemTypeId` INT NULL," + + " `ItemClass` VARCHAR(20) NOT NULL," + + " `OrderBy` INT NULL," + + " `description` varchar(255) DEFAULT NULL," + + " `createdAt` datetime NOT NULL," + + " `updatedAt` datetime NOT NULL," + + " UNIQUE INDEX `contact_item` (CmContactId,item), " + + " CONSTRAINT `cm_contact_has_items_ibfk_1` FOREIGN KEY (`CmContactId`) REFERENCES `cm_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, " + + " CONSTRAINT `cm_contact_has_items_ibfk_2` FOREIGN KEY (`ItemTypeId`) REFERENCES `tools_contact_item_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" + ); + // END cm_contact_has_items + + // START cm_hopper_additional_phones + migration.query( + "CREATE TABLE `cm_hopper_additional_phones` (" + + " `id` INT AUTO_INCREMENT NOT NULL," + + " `CmHopperId` INT NOT NULL," + + " `phone` varchar(255) NOT NULL," + + " `OrderBy` INT NULL default 0," + + " `scheduledat` datetime NULL," + + " `countbusyretry` INT NULL default 0," + + " `countcongestionretry` INT NULL default 0," + + " `countnoanswerretry` INT NULL default 0," + + " `countnosuchnumberretry` INT NULL default 0," + + " `countdropretry` INT NULL default 0," + + " `countabandonedretry` INT NULL default 0," + + " `countmachineretry` INT NULL default 0," + + " `countagentrejectretry` INT NULL default 0," + + " `createdAt` datetime NOT NULL," + + " `updatedAt` datetime NOT NULL," + + " UNIQUE INDEX `hopper_additional_phone_id` (id), " + + " INDEX `cm_hopper_phone_item` (CmHopperId), " + + " CONSTRAINT `cm_hopper_phone_item1` FOREIGN KEY (`CmHopperId`) REFERENCES `cm_hopper` (`id`) ON DELETE CASCADE ON UPDATE CASCADE " + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" + ); + // END cm_hopper_additional_phones + + // START cm_hopper + migration.addColumn("cm_hopper", "OrderBy", { + type: Sequelize.INTEGER, + allowNull: true, + defaultValue: 0 + }); + // END cm_hopper + + // START cm_contacts + migration.addColumn("cm_contacts", "AdditionalPhones", { + type: Sequelize.STRING, + allowNull: true + }); + // START cm_contacts + + // START voice_queues + migration.addColumn("voice_queues", "callAdditionalPhoneAfterMin", { + type: Sequelize.INTEGER, + defaultValue: 3 + }); + // END voice_queues + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.1.js b/server/migrations/2.6.1.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.1.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.10.js b/server/migrations/2.6.10.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.10.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.11.js b/server/migrations/2.6.11.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.11.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.2.js b/server/migrations/2.6.2.js new file mode 100644 index 0000000..9d3dde7 --- /dev/null +++ b/server/migrations/2.6.2.js @@ -0,0 +1,177 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START int_dynamics365_configurations + migration.addColumn('int_dynamics365_configurations', 'additionalSearchContact', { + type: Sequelize.STRING, + allowNull: true + }); + // END int_dynamics365_configurations + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.3.js b/server/migrations/2.6.3.js new file mode 100644 index 0000000..ad3e05e --- /dev/null +++ b/server/migrations/2.6.3.js @@ -0,0 +1,187 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START openchannel_interactions + migration.addColumn('openchannel_interactions', 'firstMsgDirection', { + type: Sequelize.ENUM('in', 'out'), + defaultValue: 'in', + allowNull: false + }); + + // Update the firstMsgDirection column with correct value (direction of the first message for each interactions) + migration.query("UPDATE openchannel_interactions t1, (SELECT OpenchannelInteractionId, MIN(id) AS messageid, ANY_VALUE(direction) AS direction FROM openchannel_messages WHERE OpenchannelInteractionId IS NOT NULL GROUP BY OpenchannelInteractionId) t2 SET t1.firstMsgDirection = t2.direction WHERE t1.id = t2.OpenchannelInteractionId;"); + // END openchannel_interactions + + // START SMSACCOUNT + migration.changeColumn('sms_accounts', 'type', { + type: Sequelize.ENUM('twilio', 'skebby', 'connectel', 'clicksend', 'plivo', 'clickatell', 'csc', 'bandwidth', 'infobip', 'intelepeer') + }); + // END SMSACCOUNT + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.4.js b/server/migrations/2.6.4.js new file mode 100644 index 0000000..54829f7 --- /dev/null +++ b/server/migrations/2.6.4.js @@ -0,0 +1,177 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START int_dynamics365_configurations + migration.addColumn('int_dynamics365_configurations', 'openNewTab', { + type: Sequelize.BOOLEAN, + defaultValue: true + }); + // STOP int_dynamics365_configurations + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.5.js b/server/migrations/2.6.5.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.5.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.6.js b/server/migrations/2.6.6.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.6.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.7.js b/server/migrations/2.6.7.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.7.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.8.js b/server/migrations/2.6.8.js new file mode 100644 index 0000000..99a8015 --- /dev/null +++ b/server/migrations/2.6.8.js @@ -0,0 +1,170 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/migrations/2.6.9.js b/server/migrations/2.6.9.js new file mode 100644 index 0000000..86d932d --- /dev/null +++ b/server/migrations/2.6.9.js @@ -0,0 +1,183 @@ +'use strict'; + +var BPromise = require('bluebird'); +var util = require('util'); + +var logger = require('../config/logger')('migration'); + +var Sequence = function() {}; + +Sequence.prototype.enqueue = function(fn) { + this.tail = this.tail ? this.tail.finally(fn) : fn(); +}; + +var Migration = function(queryInterface) { + this.queryInterface = queryInterface; + this.sequence = new Sequence(); +}; + +Migration.prototype.changeColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .changeColumn(table, column, type) + .then(function() { + logger.info('Changed column %s in table %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addColumn = function(table, column, type) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addColumn(table, column, type) + .then(function() { + logger.info('Added column %s to %s', column, table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.dropTable = function(table) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .dropTable(table, { + force: true, + }) + .then(function() { + logger.info('table dropped %s', table); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.addIndex = function(table, column, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .addIndex(table, column, { + indexName: indexName, + }) + .then(function() { + logger.info('addIndex %s %s %s', table, column.join(','), indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeIndex = function(table, indexName) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeIndex(table, indexName) + .then(function() { + logger.info('removeIndex %s %s', table, indexName); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.query = function(sql) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface.sequelize + .query(sql) + .then(function() { + logger.info('query %s', sql); + }) + .catch(function(err) { + logger.info(JSON.stringify(err)); + }); + }); +}; + +Migration.prototype.removeColumn = function(table, column) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .removeColumn(table, column) + .then(function() { + logger.info('Removed column %s from %s', column, table); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { + var _this = this; + this.sequence.enqueue(function() { + return _this.queryInterface + .renameColumn(table, oldColumn, newColumn) + .then(function() { + logger.info( + 'Renamed column from %s to %s on %s', + oldColumn, + newColumn, + table + ); + }) + .catch(function(err) { + logger.info( + util.inspect(err, { + showHidden: false, + depth: null, + }) + ); + }); + }); +}; + +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { + return resolve(); + }); +}; + +module.exports = { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { + var migration = new Migration(queryInterface); + + // START voice_queues_log + migration.changeColumn('voice_queues_log', 'dtm', { + type: Sequelize.DATE, + defaultValue: queryInterface.sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), + }); + // END voice_queues_log + + // START report_queue + migration.addColumn('report_queue', 'note', { + type: Sequelize.STRING + }); + // END report_queue + + // START FINAL + migration.final(resolve); + // END FINAL + }); + }, + + down: function(queryInterface, Sequelize) { + // var migration = new Migration(queryInterface); + }, +}; \ No newline at end of file diff --git a/server/mysqldb/index.js b/server/mysqldb/index.js new file mode 100644 index 0000000..fbf9816 --- /dev/null +++ b/server/mysqldb/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x727b=['SquareReport','SquareDetailsReport','../api/squareReportDetail/squareReportDetail.model','../api/jscriptyProject/jscriptyProject.model','Setting','../api/setting/setting.model','SquareOdbc','../api/squareOdbc/squareOdbc.model','SquareProject','../api/squareProject/squareProject.model','SquareMessage','../api/squareMessage/squareMessage.model','Team','License','../api/license/license.model','Campaign','../api/campaign/campaign.model','Migration','Attachment','../api/attachment/attachment.model','Plugin','../api/plugin/plugin.model','MailTransferReport','../api/mailTransferReport/mailTransferReport.model','ChatTransferReport','../api/chatTransferReport/chatTransferReport.model','../api/faxTransferReport/faxTransferReport.model','OpenchannelTransferReport','../api/smsTransferReport/smsTransferReport.model','CmList','VoicePrefix','../api/userProfileSection/userProfileSection.model','UserProfileResource','../api/userProfileResource/userProfileResource.model','UserNotification','../api/userNotification/userNotification.model','WhatsappApplication','../api/whatsappApplication/whatsappApplication.model','WhatsappInteraction','../api/whatsappInteraction/whatsappInteraction.model','WhatsappMessage','../api/whatsappQueueReport/whatsappQueueReport.model','WhatsappTransferReport','../api/whatsappTransferReport/whatsappTransferReport.model','CloudProvider','TeamVoiceQueue','../api/teamVoiceQueue/teamVoiceQueue.model','TeamVoicePrefix','../api/teamVoicePrefix/teamVoicePrefix.model','../api/userVoicePrefix/userVoicePrefix.model','UserSetting','../api/user-setting/user-setting.model','hasOne','cascade','userSetting','hasMany','Recordings','UserId','HopperFinals','HopperHistory','ChatInteractions','FaxInteractions','MailInteractions','UserNotifications','UserProfile','userProfileId','belongsToMany','chat_group_has_users','CmContact','Contacts','user_has_mail_interactions','SmsInteractions','user_has_sms_interactions','OpenchannelInteractions','user_has_openchannel_interactions','WhatsappInteractions','user_has_whatsapp_interactions','VoiceQueues','MailQueue','MailQueues','ChatQueues','UserChatQueue','FaxQueues','OpenchannelQueues','WhatsappQueue','ChatWebsites','FaxAccounts','MailAccounts','user_has_mail_accounts','OpenchannelAccounts','user_has_openchannel_accounts','user_has_sms_accounts','WhatsappAccounts','user_has_whatsapp_accounts','SpiedAgents','ChanSpyId','Applications','Sounds','moh_has_sounds','Members','VoiceQueueId','Hoppers','CmHopperBlack','HopperBlacks','JscriptySessions','belongsTo','TrunkId','TrunkBackup','TrunkBackupId','IntervalId','Lists','Teams','BlackLists','voice_queues_has_cm_blacklists','VoiceMailMessage','mailboxuser','mailbox','QueueCalls','uniqueid','AgentReports','Contact','MailAccountId','CloudProviderId','restrict','Imap','Smtp','Dispositions','Answers','MailMessage','Messages','List','ListId','TemplateId','mandatoryDispositionPause','mandatoryDispositionPauseId','Agents','team_has_mail_queues','MailInteractionId','Account','Owner','mail_interaction_has_tags','ThroughTags','Users','Attachments','Interaction','ChatWebsiteId','ChatOfflineMessageId','TagId','ContactId','Items','FaxAccountId','Interactions','Exntensions','FaxInteractionId','fax_interaction_has_tags','Tags','user_has_fax_interactions','AttachmentId','team_has_fax_queues','FaxQueueReport','SmsAccountId','SmsInteractionId','sms_interaction_has_tags','SmsQueueId','team_has_sms_queues','OpenchannelAccountId','OpenchannelQueueId','OpenchannelInteractionId','openchannel_interaction_has_tags','team_has_openchannel_queues','ProactiveActions','user_has_chat_websites','OpenchannelQueueReport','Agent','Queue','ChatQueueId','Website','ChatInteractionId','chat_interaction_has_tags','user_has_chat_interactions','team_has_chat_queues','ChatGroupId','CompanyId','CmContactHasItem','Phones','CmContactId','Company','cm_user_has_contacts','cm_contact_has_tags','AdditionalPhones','CmHopperId','OwnerId','AutomationAllId','Automation','Any','OneAny','ParentId','Extensions','MailApplications','ChatApplications','FaxApplications','SmsApplications','Schedule','AnalyticDefaultReport','AnalyticCustomReport','CustomReportId','whatsapp_interaction_has_tags','ItemType','ItemTypeId','Hopper','AllConditions','AllCondition','TriggerAllId','AnyCondition','TriggerAnyId','Actions','AnalyticFieldReport','Fields','DefaultReportId','MetricId','SalesforceAccount','Configurations','Subjects','SubjectId','SalesforceField','Descriptions','DescriptionId','AccountId','Description','Field','VariableId','SugarcrmConfiguration','SugarcrmField','FieldId','Subject','ZohoField','ZendeskAccount','int_zendesk_configuration_has_tags','int_freshdesk_configuration_has_tags','VtigerConfiguration','ServicenowConfiguration','ServicenowField','FreshsalesAccount','FromId','SessionId','JscriptyProject','ProjectId','user_has_teams','SmsQueues','team_has_whatsapp_queues','WhatsappQueues','CampaignId','HopperHistories','SquareProjectId','campaigns_has_cm_lists','campaigns_has_cm_blacklists','FromMailAccountId','FromAccount','FromUserId','ToAgent','ToMailQueueId','ToQueue','ToMailAccountId','ToAccount','FromChatWebsiteId','FromAgent','ToUserId','ToChatQueueId','ToChatWebsiteId','FaxTransferReport','FromFaxAccountId','ToFaxQueueId','ToFaxAccountId','FromOpenchannelAccountId','ToOpenchannelQueueId','SmsTransferReport','ToSmsQueueId','ToSmsAccountId','CmCustomField','CustomFields','Queues','cm_user_has_lists','UserProfileSection','sectionId','WhatsappAccount','WhatsappAccountId','WhatsappInteractionId','WhatsappQueueReport','FromWhatsappAccountId','ToWhatsappAccountId','ToQueueId','WhatsappQueueId','user','sequelize','jstz','motion2','xcall','xC@LL1234','127.0.0.1','mysql','utf8','sequelizeHistory','defaultsDeep','utf8mb4','utf8_general_ci','database','username','options','password','User','../api/user/user.model','VoiceChanSpy','import','../api/voiceChanSpy/voiceChanSpy.model','VoiceContext','../api/voiceContext/voiceContext.model','VoiceExtension','../api/voiceExtension/voiceExtension.model','VoiceMusicOnHold','../api/voiceMusicOnHold/voiceMusicOnHold.model','VoiceQueue','../api/voiceQueue/voiceQueue.model','VoiceRecording','../api/voiceRecording/voiceRecording.model','ScreenRecording','VoiceMail','../api/voiceMail/voiceMail.model','../api/voiceMailMessage/voiceMailMessage.model','VoiceCallReport','../api/voiceCallReport/voiceCallReport.model','../api/voiceDialReport/voiceDialReport.model','VoiceAgentReport','../api/voiceAgentReport/voiceAgentReport.model','VoiceQueueReport','../api/voiceQueueReport/voiceQueueReport.model','MemberReport','../api/memberReport/memberReport.model','Trunk','VoiceTransferReport','../api/voiceTransferReport/voiceTransferReport.model','UserVoiceQueueRt','../api/userVoiceQueueRt/userVoiceQueueRt.model','UserVoiceQueue','../api/userVoiceQueue/userVoiceQueue.model','../api/userChatQueue/userChatQueue.model','UserMailQueue','../api/userMailQueue/userMailQueue.model','UserFaxQueue','../api/userFaxQueue/userFaxQueue.model','UserSmsQueue','UserOpenchannelQueue','../api/userOpenchannelQueue/userOpenchannelQueue.model','UserWhatsappQueue','../api/userWhatsappQueue/userWhatsappQueue.model','MailServerIn','MailServerOut','MailAccount','../api/mailAccount/mailAccount.model','../api/mailQueue/mailQueue.model','MailSubstatus','../api/mailSubstatus/mailSubstatus.model','MailInteraction','../api/mailInteraction/mailInteraction.model','../api/mailMessage/mailMessage.model','MailApplication','../api/mailApplication/mailApplication.model','MailQueueReport','../api/mailQueueReport/mailQueueReport.model','Dashboard','DashboardItem','../api/dashboardItem/dashboardItem.model','FaxAccount','../api/faxAccount/faxAccount.model','FaxApplication','../api/faxApplication/faxApplication.model','FaxInteraction','../api/faxInteraction/faxInteraction.model','FaxMessage','../api/faxMessage/faxMessage.model','FaxQueue','../api/faxQueue/faxQueue.model','../api/faxQueueReport/faxQueueReport.model','SmsAccount','SmsApplication','../api/smsApplication/smsApplication.model','SmsInteraction','../api/smsInteraction/smsInteraction.model','SmsMessage','../api/smsMessage/smsMessage.model','SmsQueue','../api/smsQueue/smsQueue.model','OpenchannelAccount','../api/openchannelAccount/openchannelAccount.model','OpenchannelApplication','../api/openchannelApplication/openchannelApplication.model','OpenchannelInteraction','../api/openchannelInteraction/openchannelInteraction.model','OpenchannelMessage','../api/openchannelMessage/openchannelMessage.model','OpenchannelQueue','ChatWebsite','../api/chatWebsite/chatWebsite.model','../api/openchannelQueueReport/openchannelQueueReport.model','ChatApplication','../api/chatApplication/chatApplication.model','ChatInteraction','../api/chatInteraction/chatInteraction.model','ChatMessage','../api/chatMessage/chatMessage.model','ChatOfflineMessage','../api/chatOfflineMessage/chatOfflineMessage.model','ChatQueue','../api/chatQueue/chatQueue.model','ChatGroup','ChatProactiveAction','CmCompany','../api/cmCompany/cmCompany.model','../api/cmContact/cmContact.model','CmHopper','../api/cmHopper/cmHopper.model','../api/cmHopperBlack/cmHopperBlack.model','CmHopperFinal','../api/cmHopperFinal/cmHopperFinal.model','CmHopperHistory','../api/cmHopperHistory/cmHopperHistory.model','ReportAgentPreview','../api/reportAgentPreview/reportAgentPreview.model','../api/cmCustomField/cmCustomField.model','Action','CannedAnswer','../api/cannedAnswer/cannedAnswer.model','Disposition','../api/disposition/disposition.model','Condition','Interval','../api/interval/interval.model','Pause','../api/pause/pause.model','Cdr','../api/voiceQueuesLog/voiceQueuesLog.model','../api/schedule/schedule.model','Sound','../api/sound/sound.model','Tag','ContactItemType','../api/contactItemType/contactItemType.model','../api/cmContactHasItem/cmContactHasItem.model','CmHopperAdditionalPhone','../api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.model','../api/template/template.model','Trigger','../api/trigger/trigger.model','Variable','../api/variable/variable.model','Integration','../api/integration/integration.model','../api/analyticCustomReport/analyticCustomReport.model','../api/analyticDefaultReport/analyticDefaultReport.model','../api/analyticExtractedReport/analyticExtractedReport.model','AnalyticMetric','../api/analyticFieldReport/analyticFieldReport.model','AnalyticTreeReport','SalesforceConfiguration','../api/intSalesforceField/intSalesforceField.model','SugarcrmAccount','../api/intSugarcrmConfiguration/intSugarcrmConfiguration.model','../api/intSugarcrmField/intSugarcrmField.model','DeskAccount','../api/intDeskAccount/intDeskAccount.model','DeskConfiguration','../api/intDeskConfiguration/intDeskConfiguration.model','DeskField','../api/intDeskField/intDeskField.model','ZohoAccount','ZohoConfiguration','../api/intZohoConfiguration/intZohoConfiguration.model','../api/intZohoField/intZohoField.model','../api/intZendeskAccount/intZendeskAccount.model','ZendeskConfiguration','../api/intZendeskConfiguration/intZendeskConfiguration.model','ZendeskField','../api/intZendeskField/intZendeskField.model','FreshdeskAccount','../api/intFreshdeskAccount/intFreshdeskAccount.model','FreshdeskConfiguration','FreshdeskField','../api/intFreshdeskField/intFreshdeskField.model','VtigerAccount','../api/intVtigerAccount/intVtigerAccount.model','../api/intVtigerConfiguration/intVtigerConfiguration.model','VtigerField','../api/intVtigerField/intVtigerField.model','ServicenowAccount','../api/intServicenowAccount/intServicenowAccount.model','../api/intServicenowConfiguration/intServicenowConfiguration.model','../api/intServicenowField/intServicenowField.model','Dynamics365Account','../api/intDynamics365Account/intDynamics365Account.model','Dynamics365Configuration','../api/intDynamics365Configuration/intDynamics365Configuration.model','Dynamics365Field','../api/intFreshsalesAccount/intFreshsalesAccount.model','FreshsalesConfiguration','../api/intFreshsalesConfiguration/intFreshsalesConfiguration.model','FreshsalesField','../api/intFreshsalesField/intFreshsalesField.model','Network','../api/network/network.model','ChatQueueReport','../api/chatQueueReport/chatQueueReport.model','ChatInternalMessage','../api/chatInternalMessage/chatInternalMessage.model','JscriptyAnswerReport','../api/jscriptyAnswerReport/jscriptyAnswerReport.model','JscriptyQuestionReport','../api/jscriptyQuestionReport/jscriptyQuestionReport.model','JscriptySessionReport','../api/jscriptySessionReport/jscriptySessionReport.model','SmsQueueReport','../api/smsQueueReport/smsQueueReport.model'];(function(_0x42e4aa,_0x2a2f6e){var _0x7b27d3=function(_0x2aa0a8){while(--_0x2aa0a8){_0x42e4aa['push'](_0x42e4aa['shift']());}};_0x7b27d3(++_0x2a2f6e);}(_0x727b,0x125));var _0xb727=function(_0x3dfb4a,_0x4c216a){_0x3dfb4a=_0x3dfb4a-0x0;var _0x144c5f=_0x727b[_0x3dfb4a];return _0x144c5f;};'use strict';var config=require('../config/environment');var Sequelize=require(_0xb727('0x0'));var _=require('lodash');var jstz=require(_0xb727('0x1'));var timezone=jstz['determine']();config[_0xb727('0x0')]=_['defaultsDeep'](config['sequelize'],{'database':_0xb727('0x2'),'username':_0xb727('0x3'),'password':_0xb727('0x4'),'options':{'host':_0xb727('0x5'),'port':0xcea,'dialect':_0xb727('0x6'),'dialectOptions':{'charset':'utf8mb4'},'logging':![],'timezone':timezone['name'](),'define':{'charset':_0xb727('0x7'),'collate':'utf8_general_ci'}}});config[_0xb727('0x8')]=_[_0xb727('0x9')](config['sequelizeHistory'],{'database':_0xb727('0x2'),'username':_0xb727('0x3'),'password':_0xb727('0x4'),'options':{'host':_0xb727('0x5'),'port':0xcea,'dialect':_0xb727('0x6'),'dialectOptions':{'charset':_0xb727('0xa')},'logging':![],'timezone':timezone['name'](),'define':{'charset':_0xb727('0x7'),'collate':_0xb727('0xb')}}});var db={'Sequelize':Sequelize,'sequelize':new Sequelize(config['sequelize'][_0xb727('0xc')],config['sequelize'][_0xb727('0xd')],config[_0xb727('0x0')]['password'],config[_0xb727('0x0')][_0xb727('0xe')])};var dbH={'Sequelize':Sequelize,'sequelize':new Sequelize(config[_0xb727('0x8')][_0xb727('0xc')],config[_0xb727('0x8')][_0xb727('0xd')],config['sequelizeHistory'][_0xb727('0xf')],config['sequelizeHistory']['options'])};db[_0xb727('0x10')]=db[_0xb727('0x0')]['import'](_0xb727('0x11'));db[_0xb727('0x12')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x14'));db[_0xb727('0x15')]=db[_0xb727('0x0')]['import'](_0xb727('0x16'));db[_0xb727('0x17')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x18'));db[_0xb727('0x19')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x1a'));db[_0xb727('0x1b')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x1c'));db[_0xb727('0x1d')]=db[_0xb727('0x0')]['import'](_0xb727('0x1e'));db[_0xb727('0x1f')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/screenRecording/screenRecording.model');db[_0xb727('0x20')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x21'));db['VoiceMailMessage']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x22'));db[_0xb727('0x23')]=db['sequelize']['import'](_0xb727('0x24'));db['VoiceDialReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x25'));db[_0xb727('0x26')]=db[_0xb727('0x0')]['import'](_0xb727('0x27'));db[_0xb727('0x28')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x29'));db[_0xb727('0x2a')]=db['sequelize']['import'](_0xb727('0x2b'));db[_0xb727('0x2c')]=db['sequelize'][_0xb727('0x13')]('../api/trunk/trunk.model');db[_0xb727('0x2d')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x2e'));db[_0xb727('0x2f')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x30'));db[_0xb727('0x31')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x32'));db['UserChatQueue']=db['sequelize'][_0xb727('0x13')](_0xb727('0x33'));db[_0xb727('0x34')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x35'));db[_0xb727('0x36')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x37'));db[_0xb727('0x38')]=db[_0xb727('0x0')]['import']('../api/userSmsQueue/userSmsQueue.model');db[_0xb727('0x39')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x3a'));db[_0xb727('0x3b')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x3c'));db[_0xb727('0x3d')]=db[_0xb727('0x0')]['import']('../api/mailServerIn/mailServerIn.model');db[_0xb727('0x3e')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/mailServerOut/mailServerOut.model');db[_0xb727('0x3f')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x40'));db['MailQueue']=db['sequelize'][_0xb727('0x13')](_0xb727('0x41'));db[_0xb727('0x42')]=db['sequelize']['import'](_0xb727('0x43'));db[_0xb727('0x44')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x45'));db['MailMessage']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x46'));db[_0xb727('0x47')]=db['sequelize']['import'](_0xb727('0x48'));db[_0xb727('0x49')]=db['sequelize']['import'](_0xb727('0x4a'));db[_0xb727('0x4b')]=db['sequelize'][_0xb727('0x13')]('../api/dashboard/dashboard.model');db[_0xb727('0x4c')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x4d'));db[_0xb727('0x4e')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x4f'));db[_0xb727('0x50')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x51'));db[_0xb727('0x52')]=db[_0xb727('0x0')]['import'](_0xb727('0x53'));db[_0xb727('0x54')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x55'));db[_0xb727('0x56')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x57'));db['FaxQueueReport']=db[_0xb727('0x0')]['import'](_0xb727('0x58'));db[_0xb727('0x59')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/smsAccount/smsAccount.model');db[_0xb727('0x5a')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x5b'));db[_0xb727('0x5c')]=db[_0xb727('0x0')]['import'](_0xb727('0x5d'));db[_0xb727('0x5e')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x5f'));db[_0xb727('0x60')]=db[_0xb727('0x0')]['import'](_0xb727('0x61'));db[_0xb727('0x62')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x63'));db[_0xb727('0x64')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x65'));db[_0xb727('0x66')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x67'));db[_0xb727('0x68')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x69'));db[_0xb727('0x6a')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/openchannelQueue/openchannelQueue.model');db[_0xb727('0x6b')]=db[_0xb727('0x0')]['import'](_0xb727('0x6c'));db['OpenchannelQueueReport']=db[_0xb727('0x0')]['import'](_0xb727('0x6d'));db[_0xb727('0x6e')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x6f'));db[_0xb727('0x70')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x71'));db[_0xb727('0x72')]=db[_0xb727('0x0')]['import'](_0xb727('0x73'));db[_0xb727('0x74')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x75'));db[_0xb727('0x76')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x77'));db[_0xb727('0x78')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/chatGroup/chatGroup.model');db[_0xb727('0x79')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/chatProactiveAction/chatProactiveAction.model');db[_0xb727('0x7a')]=db[_0xb727('0x0')]['import'](_0xb727('0x7b'));db['CmContact']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x7c'));db[_0xb727('0x7d')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x7e'));db['CmHopperBlack']=db[_0xb727('0x0')]['import'](_0xb727('0x7f'));db[_0xb727('0x80')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x81'));db[_0xb727('0x82')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x83'));db[_0xb727('0x84')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x85'));db['CmCustomField']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x86'));db[_0xb727('0x87')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/action/action.model');db['Automation']=db['sequelize']['import']('../api/automation/automation.model');db[_0xb727('0x88')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x89'));db[_0xb727('0x8a')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x8b'));db[_0xb727('0x8c')]=db['sequelize']['import']('../api/condition/condition.model');db[_0xb727('0x8d')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x8e'));db[_0xb727('0x8f')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x90'));db[_0xb727('0x91')]=db['sequelize']['import']('../api/cdr/cdr.model');db['VoiceQueuesLog']=db['sequelize'][_0xb727('0x13')](_0xb727('0x92'));db['Schedule']=db['sequelize']['import'](_0xb727('0x93'));db[_0xb727('0x94')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x95'));db[_0xb727('0x96')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/tag/tag.model');db[_0xb727('0x97')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x98'));db['CmContactHasItem']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x99'));db[_0xb727('0x9a')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x9b'));db['Template']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x9c'));db[_0xb727('0x9d')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x9e'));db[_0xb727('0x9f')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xa0'));db[_0xb727('0xa1')]=db['sequelize'][_0xb727('0x13')](_0xb727('0xa2'));db['IntegrationReport']=db[_0xb727('0x0')]['import']('../api/integrationReport/integrationReport.model');db['AnalyticCustomReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xa3'));db['AnalyticDefaultReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xa4'));db['AnalyticExtractedReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xa5'));db[_0xb727('0xa6')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/analyticMetric/analyticMetric.model');db['AnalyticFieldReport']=db['sequelize'][_0xb727('0x13')](_0xb727('0xa7'));db[_0xb727('0xa8')]=db[_0xb727('0x0')]['import']('../api/analyticTreeReport/analyticTreeReport.model');db['SalesforceAccount']=db[_0xb727('0x0')][_0xb727('0x13')]('../api/intSalesforceAccount/intSalesforceAccount.model');db[_0xb727('0xa9')]=db[_0xb727('0x0')]['import']('../api/intSalesforceConfiguration/intSalesforceConfiguration.model');db['SalesforceField']=db['sequelize'][_0xb727('0x13')](_0xb727('0xaa'));db[_0xb727('0xab')]=db[_0xb727('0x0')]['import']('../api/intSugarcrmAccount/intSugarcrmAccount.model');db['SugarcrmConfiguration']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xac'));db['SugarcrmField']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xad'));db[_0xb727('0xae')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xaf'));db[_0xb727('0xb0')]=db['sequelize'][_0xb727('0x13')](_0xb727('0xb1'));db[_0xb727('0xb2')]=db[_0xb727('0x0')]['import'](_0xb727('0xb3'));db[_0xb727('0xb4')]=db[_0xb727('0x0')]['import']('../api/intZohoAccount/intZohoAccount.model');db[_0xb727('0xb5')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xb6'));db['ZohoField']=db['sequelize'][_0xb727('0x13')](_0xb727('0xb7'));db['ZendeskAccount']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xb8'));db[_0xb727('0xb9')]=db['sequelize']['import'](_0xb727('0xba'));db[_0xb727('0xbb')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xbc'));db[_0xb727('0xbd')]=db['sequelize'][_0xb727('0x13')](_0xb727('0xbe'));db[_0xb727('0xbf')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/intFreshdeskConfiguration/intFreshdeskConfiguration.model');db[_0xb727('0xc0')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xc1'));db[_0xb727('0xc2')]=db['sequelize'][_0xb727('0x13')](_0xb727('0xc3'));db['VtigerConfiguration']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xc4'));db[_0xb727('0xc5')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xc6'));db[_0xb727('0xc7')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xc8'));db['ServicenowConfiguration']=db['sequelize']['import'](_0xb727('0xc9'));db['ServicenowField']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xca'));db[_0xb727('0xcb')]=db['sequelize']['import'](_0xb727('0xcc'));db[_0xb727('0xcd')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xce'));db[_0xb727('0xcf')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/intDynamics365Field/intDynamics365Field.model');db['FreshsalesAccount']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xd0'));db[_0xb727('0xd1')]=db[_0xb727('0x0')]['import'](_0xb727('0xd2'));db[_0xb727('0xd3')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xd4'));db['Integration']=db['sequelize'][_0xb727('0x13')](_0xb727('0xa2'));db[_0xb727('0xd5')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xd6'));db[_0xb727('0xd7')]=db['sequelize']['import'](_0xb727('0xd8'));db[_0xb727('0xd9')]=db['sequelize']['import'](_0xb727('0xda'));db[_0xb727('0xdb')]=db[_0xb727('0x0')]['import'](_0xb727('0xdc'));db[_0xb727('0xdd')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xde'));db[_0xb727('0xdf')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xe0'));db[_0xb727('0xe1')]=db[_0xb727('0x0')]['import'](_0xb727('0xe2'));db[_0xb727('0xe3')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/squareReport/squareReport.model');db[_0xb727('0xe4')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xe5'));db['JscriptyProject']=db['sequelize']['import'](_0xb727('0xe6'));db[_0xb727('0xe7')]=db['sequelize']['import'](_0xb727('0xe8'));db[_0xb727('0xe9')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xea'));db[_0xb727('0xeb')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xec'));db['SquareRecording']=db['sequelize']['import']('../api/squareRecording/squareRecording.model');db[_0xb727('0xed')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xee'));db[_0xb727('0xef')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/team/team.model');db[_0xb727('0xf0')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xf1'));db[_0xb727('0xf2')]=db[_0xb727('0x0')]['import'](_0xb727('0xf3'));db[_0xb727('0xf4')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/migration/migration.model');db[_0xb727('0xf5')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xf6'));db[_0xb727('0xf7')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xf8'));db[_0xb727('0xf9')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xfa'));db[_0xb727('0xfb')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xfc'));db['FaxTransferReport']=db['sequelize'][_0xb727('0x13')](_0xb727('0xfd'));db[_0xb727('0xfe')]=db[_0xb727('0x0')]['import']('../api/openchannelTransferReport/openchannelTransferReport.model');db['SmsTransferReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0xff'));db[_0xb727('0x100')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/cmList/cmList.model');db[_0xb727('0x101')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/voicePrefix/voicePrefix.model');db['UserProfile']=db[_0xb727('0x0')][_0xb727('0x13')]('../api/userProfile/userProfile.model');db['UserProfileSection']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x102'));db[_0xb727('0x103')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x104'));db[_0xb727('0x105')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x106'));db['WhatsappAccount']=db[_0xb727('0x0')][_0xb727('0x13')]('../api/whatsappAccount/whatsappAccount.model');db[_0xb727('0x107')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x108'));db[_0xb727('0x109')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x10a'));db[_0xb727('0x10b')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/whatsappMessage/whatsappMessage.model');db['WhatsappQueueReport']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x10c'));db[_0xb727('0x10d')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x10e'));db['WhatsappQueue']=db[_0xb727('0x0')][_0xb727('0x13')]('../api/whatsappQueue/whatsappQueue.model');db[_0xb727('0x10f')]=db[_0xb727('0x0')][_0xb727('0x13')]('../api/cloudProvider/cloudProvider.model');db[_0xb727('0x110')]=db[_0xb727('0x0')]['import'](_0xb727('0x111'));db[_0xb727('0x112')]=db['sequelize'][_0xb727('0x13')](_0xb727('0x113'));db['UserVoicePrefix']=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x114'));db[_0xb727('0x115')]=db[_0xb727('0x0')][_0xb727('0x13')](_0xb727('0x116'));db[_0xb727('0x10')][_0xb727('0x117')](db['VoiceMail'],{'as':_0xb727('0x20'),'onDelete':_0xb727('0x118'),'foreignKey':'UserId'});db['User'][_0xb727('0x117')](db[_0xb727('0x115')],{'as':_0xb727('0x119'),'onDelete':_0xb727('0x118'),'foreignKey':'UserId'});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x1d')],{'as':_0xb727('0x11b'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x2f')],{'as':'VoiceQueuesRt','foreignKey':'UserId'});db['User']['hasMany'](db[_0xb727('0x17')],{'as':'Extensions','onDelete':_0xb727('0x118'),'hooks':!![]});db[_0xb727('0x10')]['hasMany'](db[_0xb727('0x80')],{'as':_0xb727('0x11d'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')]['hasMany'](db[_0xb727('0x82')],{'as':_0xb727('0x11e'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x84')],{'as':'ReportAgentPreview','foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x66')],{'as':'OpenchannelInteractions','foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')]['hasMany'](db[_0xb727('0x70')],{'as':_0xb727('0x11f'),'foreignKey':_0xb727('0x11c')});db['User'][_0xb727('0x11a')](db['SmsInteraction'],{'as':'SmsInteractions','foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x52')],{'as':_0xb727('0x120'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db[_0xb727('0x44')],{'as':_0xb727('0x121'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')][_0xb727('0x11a')](db['WhatsappInteraction'],{'as':'WhatsappInteractions','foreignKey':_0xb727('0x11c')});db[_0xb727('0x10')]['hasMany'](db['UserNotification'],{'as':_0xb727('0x122'),'foreignKey':'SenderId'});db[_0xb727('0x10')]['belongsTo'](db[_0xb727('0x123')],{'as':_0xb727('0x123'),'foreignKey':_0xb727('0x124')});db['User'][_0xb727('0x125')](db[_0xb727('0x78')],{'as':'Groups','through':_0xb727('0x126')});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x127')],{'as':_0xb727('0x128'),'through':'cm_user_has_contacts'});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x100')],{'as':'Lists','through':'cm_user_has_lists'});db['User'][_0xb727('0x125')](db[_0xb727('0xef')],{'through':'user_has_teams'});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x44')],{'as':_0xb727('0x121'),'through':_0xb727('0x129')});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x70')],{'as':_0xb727('0x11f'),'through':'user_has_chat_interactions'});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x52')],{'as':_0xb727('0x120'),'through':'user_has_fax_interactions'});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x5c')],{'as':_0xb727('0x12a'),'through':_0xb727('0x12b')});db['User'][_0xb727('0x125')](db['OpenchannelInteraction'],{'as':_0xb727('0x12c'),'through':_0xb727('0x12d')});db['User'][_0xb727('0x125')](db[_0xb727('0x109')],{'as':_0xb727('0x12e'),'through':_0xb727('0x12f')});db[_0xb727('0x10')]['belongsToMany'](db[_0xb727('0x1b')],{'as':_0xb727('0x130'),'through':'UserVoiceQueue','required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x101')],{'as':'VoicePrefixes','through':'UserVoicePrefix','required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x131')],{'as':_0xb727('0x132'),'through':_0xb727('0x34'),'required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x76')],{'as':_0xb727('0x133'),'through':_0xb727('0x134'),'required':![],'hooks':!![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x56')],{'as':_0xb727('0x135'),'through':_0xb727('0x36'),'required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x60')],{'as':'SmsQueues','through':_0xb727('0x38'),'required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x6a')],{'as':_0xb727('0x136'),'through':_0xb727('0x39'),'required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x137')],{'as':'WhatsappQueues','through':_0xb727('0x3b'),'required':![]});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x100')],{'through':'cm_user_has_lists'});db[_0xb727('0x10')][_0xb727('0x125')](db['ChatWebsite'],{'as':_0xb727('0x138'),'through':'user_has_chat_websites'});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x4e')],{'as':_0xb727('0x139'),'through':'user_has_fax_accounts'});db['User'][_0xb727('0x125')](db['MailAccount'],{'as':_0xb727('0x13a'),'through':_0xb727('0x13b')});db[_0xb727('0x10')][_0xb727('0x125')](db[_0xb727('0x62')],{'as':_0xb727('0x13c'),'through':_0xb727('0x13d')});db[_0xb727('0x10')]['belongsToMany'](db[_0xb727('0x59')],{'as':'SmsAccounts','through':_0xb727('0x13e')});db['User'][_0xb727('0x125')](db['WhatsappAccount'],{'as':_0xb727('0x13f'),'through':_0xb727('0x140')});db[_0xb727('0x12')]['hasMany'](db[_0xb727('0x17')],{'as':_0xb727('0x141'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x142')});db[_0xb727('0x15')][_0xb727('0x11a')](db[_0xb727('0x17')],{'onDelete':'cascade'});db[_0xb727('0x17')][_0xb727('0x11a')](db[_0xb727('0x17')],{'as':_0xb727('0x143'),'onDelete':_0xb727('0x118')});db[_0xb727('0x19')]['belongsToMany'](db['Sound'],{'as':_0xb727('0x144'),'through':_0xb727('0x145')});db[_0xb727('0x1b')]['hasMany'](db['UserVoiceQueueRt'],{'as':_0xb727('0x146'),'foreignKey':_0xb727('0x147')});db['VoiceQueue'][_0xb727('0x11a')](db[_0xb727('0x7d')],{'as':_0xb727('0x148'),'foreignKey':'VoiceQueueId'});db[_0xb727('0x1b')]['hasMany'](db[_0xb727('0x80')],{'as':_0xb727('0x11d'),'foreignKey':_0xb727('0x147')});db[_0xb727('0x1b')][_0xb727('0x11a')](db[_0xb727('0x82')],{'as':'HopperHistories','foreignKey':_0xb727('0x147')});db[_0xb727('0x1b')][_0xb727('0x11a')](db[_0xb727('0x84')],{'as':_0xb727('0x84'),'foreignKey':_0xb727('0x147')});db[_0xb727('0x1b')][_0xb727('0x11a')](db[_0xb727('0x149')],{'as':_0xb727('0x14a'),'foreignKey':_0xb727('0x147')});db['VoiceQueue']['hasMany'](db[_0xb727('0xdf')],{'as':_0xb727('0x14b'),'foreignKey':'VoiceQueueId'});db[_0xb727('0x1b')][_0xb727('0x14c')](db[_0xb727('0x2c')],{'as':_0xb727('0x2c'),'foreignKey':_0xb727('0x14d')});db[_0xb727('0x1b')][_0xb727('0x14c')](db[_0xb727('0x2c')],{'as':_0xb727('0x14e'),'foreignKey':_0xb727('0x14f')});db[_0xb727('0x1b')][_0xb727('0x14c')](db[_0xb727('0x8d')],{'as':_0xb727('0x8d'),'foreignKey':_0xb727('0x150')});db[_0xb727('0x1b')][_0xb727('0x14c')](db[_0xb727('0x8f')],{'as':'mandatoryDispositionPause','foreignKey':'mandatoryDispositionPauseId'});db[_0xb727('0x1b')][_0xb727('0x125')](db[_0xb727('0x100')],{'as':_0xb727('0x151'),'through':'voice_queues_has_cm_lists'});db[_0xb727('0x1b')][_0xb727('0x125')](db['User'],{'as':'Agents','through':_0xb727('0x31')});db[_0xb727('0x1b')][_0xb727('0x125')](db[_0xb727('0xef')],{'as':_0xb727('0x152'),'through':'TeamVoiceQueue'});db[_0xb727('0x1b')][_0xb727('0x125')](db[_0xb727('0x100')],{'as':_0xb727('0x153'),'through':_0xb727('0x154')});db[_0xb727('0x1d')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x10'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x1f')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':'User','foreignKey':_0xb727('0x11c')});db[_0xb727('0x20')][_0xb727('0x11a')](db[_0xb727('0x155')],{'as':'Messages','onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x156'),'sourceKey':_0xb727('0x157')});db['VoiceMailMessage']['belongsTo'](db[_0xb727('0x20')],{'foreignKey':_0xb727('0x156'),'targetKey':'mailbox'});db[_0xb727('0x23')][_0xb727('0x11a')](db[_0xb727('0x28')],{'as':_0xb727('0x158'),'foreignKey':_0xb727('0x159'),'constraints':![]});db[_0xb727('0x23')]['hasMany'](db[_0xb727('0x26')],{'as':_0xb727('0x15a'),'foreignKey':'uniqueid','constraints':![]});db[_0xb727('0x23')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x10'),'foreignKey':_0xb727('0x11c')});db['VoiceCallReport']['belongsTo'](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':'ContactId'});db[_0xb727('0x3d')][_0xb727('0x14c')](db['MailAccount'],{'as':_0xb727('0x3f'),'foreignKey':_0xb727('0x15c')});db['MailServerIn'][_0xb727('0x14c')](db[_0xb727('0x10f')],{'as':_0xb727('0x10f'),'foreignKey':_0xb727('0x15d'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x3e')][_0xb727('0x14c')](db[_0xb727('0x3f')],{'as':_0xb727('0x3f'),'foreignKey':_0xb727('0x15c')});db[_0xb727('0x3e')][_0xb727('0x14c')](db[_0xb727('0x10f')],{'as':_0xb727('0x10f'),'foreignKey':_0xb727('0x15d'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x3f')]['hasOne'](db['MailServerIn'],{'as':_0xb727('0x15f'),'onDelete':'cascade'});db[_0xb727('0x3f')][_0xb727('0x117')](db[_0xb727('0x3e')],{'as':_0xb727('0x160'),'onDelete':'cascade'});db[_0xb727('0x3f')][_0xb727('0x11a')](db['Disposition'],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x15c'),'onDelete':'cascade'});db['MailAccount']['hasMany'](db[_0xb727('0x88')],{'as':_0xb727('0x162'),'foreignKey':_0xb727('0x15c')});db[_0xb727('0x3f')][_0xb727('0x11a')](db[_0xb727('0x163')],{'as':_0xb727('0x164'),'foreignKey':_0xb727('0x15c')});db[_0xb727('0x3f')][_0xb727('0x11a')](db[_0xb727('0x44')],{'as':'Interactions'});db[_0xb727('0x3f')][_0xb727('0x11a')](db[_0xb727('0x47')],{'as':'Applications'});db[_0xb727('0x3f')][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x3f')]['belongsTo'](db['Template'],{'as':'Template','foreignKey':_0xb727('0x167')});db[_0xb727('0x3f')]['belongsTo'](db[_0xb727('0x8f')],{'as':_0xb727('0x168'),'foreignKey':_0xb727('0x169')});db[_0xb727('0x3f')]['belongsToMany'](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x13b')});db['MailQueue']['belongsToMany'](db[_0xb727('0x10')],{'as':'Agents','through':'UserMailQueue'});db[_0xb727('0x131')]['belongsToMany'](db[_0xb727('0xef')],{'through':_0xb727('0x16b'),'as':_0xb727('0x152')});db[_0xb727('0x44')][_0xb727('0x11a')](db[_0xb727('0x163')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x16c')});db[_0xb727('0x44')]['belongsTo'](db['MailAccount'],{'as':_0xb727('0x16d'),'foreignKey':'MailAccountId'});db['MailInteraction'][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':'Contact','foreignKey':'ContactId'});db[_0xb727('0x44')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x16e'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x44')]['belongsToMany'](db[_0xb727('0x96')],{'through':_0xb727('0x16f'),'as':'Tags'});db[_0xb727('0x44')][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x16f'),'as':_0xb727('0x170')});db[_0xb727('0x44')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x171'),'through':_0xb727('0x129'),'foreignKey':_0xb727('0x16c')});db['MailMessage'][_0xb727('0x11a')](db['Attachment'],{'as':_0xb727('0x172'),'onDelete':'cascade'});db[_0xb727('0x163')]['belongsTo'](db[_0xb727('0x10')],{'as':_0xb727('0x10')});db[_0xb727('0x163')][_0xb727('0x14c')](db['CmContact'],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x15b')});db[_0xb727('0x163')][_0xb727('0x14c')](db['MailInteraction'],{'as':_0xb727('0x173'),'foreignKey':'MailInteractionId'});db[_0xb727('0x163')][_0xb727('0x14c')](db['MailAccount'],{'as':_0xb727('0x16d'),'foreignKey':'MailAccountId'});db[_0xb727('0x163')][_0xb727('0x14c')](db[_0xb727('0x6b')],{'as':_0xb727('0x6b'),'foreignKey':_0xb727('0x174')});db['MailMessage'][_0xb727('0x14c')](db[_0xb727('0x74')],{'as':_0xb727('0x74'),'foreignKey':_0xb727('0x175')});db[_0xb727('0x47')]['belongsTo'](db['User'],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x47')]['belongsTo'](db[_0xb727('0x131')],{'onDelete':'restrict'});db[_0xb727('0x47')][_0xb727('0x14c')](db[_0xb727('0x3f')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x47')][_0xb727('0x14c')](db['Interval'],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x150')});db['MailApplication'][_0xb727('0x14c')](db['Tag'],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x49')]['belongsTo'](db[_0xb727('0x3f')],{});db[_0xb727('0x49')][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db['MailQueueReport'][_0xb727('0x14c')](db['CmContact'],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db['MailQueueReport'][_0xb727('0x14c')](db[_0xb727('0x44')],{});db['MailQueueReport'][_0xb727('0x14c')](db[_0xb727('0x163')],{});db[_0xb727('0x49')][_0xb727('0x14c')](db[_0xb727('0x10')],{});db[_0xb727('0x49')][_0xb727('0x14c')](db[_0xb727('0x131')],{});db[_0xb727('0x4b')][_0xb727('0x11a')](db['DashboardItem'],{'as':_0xb727('0x178'),'onDelete':_0xb727('0x118')});db[_0xb727('0x4e')][_0xb727('0x11a')](db['Disposition'],{'as':'Dispositions','foreignKey':_0xb727('0x179'),'onDelete':_0xb727('0x118')});db[_0xb727('0x4e')][_0xb727('0x11a')](db[_0xb727('0x88')],{'as':'Answers','foreignKey':_0xb727('0x179')});db['FaxAccount'][_0xb727('0x11a')](db[_0xb727('0x52')],{'as':_0xb727('0x17a')});db['FaxAccount'][_0xb727('0x11a')](db[_0xb727('0x50')],{'as':'Applications'});db['FaxAccount'][_0xb727('0x11a')](db['VoiceExtension'],{'as':_0xb727('0x17b'),'onDelete':'cascade'});db['FaxAccount'][_0xb727('0x11a')](db[_0xb727('0x54')],{'as':_0xb727('0x164')});db[_0xb727('0x4e')][_0xb727('0x14c')](db[_0xb727('0x2c')],{'as':_0xb727('0x2c')});db[_0xb727('0x4e')]['belongsTo'](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x4e')]['belongsTo'](db[_0xb727('0x8f')],{'as':_0xb727('0x168'),'foreignKey':_0xb727('0x169')});db[_0xb727('0x4e')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':'Agents','through':'user_has_fax_accounts'});db[_0xb727('0x50')][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x50')][_0xb727('0x14c')](db[_0xb727('0x56')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x50')][_0xb727('0x14c')](db[_0xb727('0x4e')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x50')][_0xb727('0x14c')](db[_0xb727('0x96')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x52')][_0xb727('0x11a')](db[_0xb727('0x54')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x17c')});db[_0xb727('0x52')][_0xb727('0x14c')](db[_0xb727('0x4e')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x179')});db[_0xb727('0x52')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x52')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x16e'),'foreignKey':'UserId'});db[_0xb727('0x52')][_0xb727('0x125')](db['Tag'],{'through':_0xb727('0x17d'),'as':_0xb727('0x17e')});db['FaxInteraction']['belongsToMany'](db['Tag'],{'through':_0xb727('0x17d'),'as':_0xb727('0x170')});db[_0xb727('0x52')]['belongsToMany'](db[_0xb727('0x10')],{'as':_0xb727('0x171'),'through':_0xb727('0x17f'),'foreignKey':_0xb727('0x17c')});db[_0xb727('0x54')][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x10')});db[_0xb727('0x54')][_0xb727('0x14c')](db[_0xb727('0x52')],{'as':_0xb727('0x173'),'foreignKey':_0xb727('0x17c')});db[_0xb727('0x54')][_0xb727('0x14c')](db[_0xb727('0x127')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x15b')});db['FaxMessage']['belongsTo'](db['Attachment'],{'as':_0xb727('0xf5'),'foreignKey':_0xb727('0x180')});db['FaxMessage'][_0xb727('0x14c')](db[_0xb727('0x4e')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x179')});db[_0xb727('0x56')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x36')});db[_0xb727('0x56')][_0xb727('0x125')](db['Team'],{'through':_0xb727('0x181'),'as':'Teams'});db['FaxQueueReport']['belongsTo'](db[_0xb727('0x4e')],{});db[_0xb727('0x182')]['belongsTo'](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x182')]['belongsTo'](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x182')]['belongsTo'](db['FaxInteraction'],{});db[_0xb727('0x182')][_0xb727('0x14c')](db[_0xb727('0x54')],{});db['FaxQueueReport'][_0xb727('0x14c')](db['User'],{});db['FaxQueueReport'][_0xb727('0x14c')](db[_0xb727('0x56')],{});db[_0xb727('0x59')][_0xb727('0x11a')](db[_0xb727('0x8a')],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x183'),'onDelete':_0xb727('0x118')});db[_0xb727('0x59')][_0xb727('0x11a')](db['CannedAnswer'],{'as':'Answers','foreignKey':_0xb727('0x183')});db[_0xb727('0x59')][_0xb727('0x11a')](db[_0xb727('0x5e')],{'as':_0xb727('0x164'),'foreignKey':'SmsAccountId'});db['SmsAccount'][_0xb727('0x11a')](db[_0xb727('0x5c')],{'as':_0xb727('0x17a')});db['SmsAccount'][_0xb727('0x11a')](db[_0xb727('0x5a')],{'as':_0xb727('0x143')});db[_0xb727('0x59')][_0xb727('0x14c')](db['CmList'],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x59')][_0xb727('0x14c')](db[_0xb727('0x8f')],{'as':_0xb727('0x168'),'foreignKey':_0xb727('0x169')});db['SmsAccount'][_0xb727('0x125')](db[_0xb727('0x10')],{'as':'Agents','through':_0xb727('0x13e')});db[_0xb727('0x5a')][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x5a')][_0xb727('0x14c')](db['SmsQueue'],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x5a')][_0xb727('0x14c')](db[_0xb727('0x59')],{'onDelete':_0xb727('0x15e')});db['SmsApplication'][_0xb727('0x14c')](db['Interval'],{'onDelete':_0xb727('0x15e'),'foreignKey':'IntervalId'});db[_0xb727('0x5a')][_0xb727('0x14c')](db[_0xb727('0x96')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x5c')]['hasMany'](db[_0xb727('0x5e')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x184')});db[_0xb727('0x5c')]['belongsTo'](db[_0xb727('0x59')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x183')});db[_0xb727('0x5c')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x5c')][_0xb727('0x14c')](db['User'],{'as':'Owner','foreignKey':_0xb727('0x11c')});db[_0xb727('0x5c')]['belongsToMany'](db['Tag'],{'through':'sms_interaction_has_tags','as':'Tags'});db['SmsInteraction'][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x185'),'as':_0xb727('0x170')});db[_0xb727('0x5c')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x171'),'through':_0xb727('0x12b'),'foreignKey':_0xb727('0x184')});db['SmsMessage'][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x10')});db['SmsMessage']['belongsTo'](db[_0xb727('0x127')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x15b')});db[_0xb727('0x5e')][_0xb727('0x14c')](db['SmsInteraction'],{'onDelete':_0xb727('0x118'),'as':'Interaction','foreignKey':'SmsInteractionId'});db[_0xb727('0x5e')][_0xb727('0x14c')](db[_0xb727('0x59')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x183')});db[_0xb727('0x60')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x38'),'foreignKey':_0xb727('0x186')});db['SmsQueue'][_0xb727('0x125')](db[_0xb727('0xef')],{'through':_0xb727('0x187'),'as':'Teams'});db[_0xb727('0x62')][_0xb727('0x11a')](db[_0xb727('0x8a')],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x188'),'onDelete':'cascade'});db[_0xb727('0x62')][_0xb727('0x11a')](db['CannedAnswer'],{'as':_0xb727('0x162'),'foreignKey':_0xb727('0x188')});db[_0xb727('0x62')][_0xb727('0x11a')](db[_0xb727('0x66')],{'as':'Interactions','foreignKey':_0xb727('0x188')});db[_0xb727('0x62')][_0xb727('0x11a')](db[_0xb727('0x68')],{'as':'Messages','foreignKey':_0xb727('0x188')});db[_0xb727('0x62')][_0xb727('0x11a')](db[_0xb727('0x64')],{'as':_0xb727('0x143'),'foreignKey':'OpenchannelAccountId'});db[_0xb727('0x62')][_0xb727('0x14c')](db['CmList'],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x62')][_0xb727('0x14c')](db[_0xb727('0x8f')],{'as':_0xb727('0x168'),'foreignKey':_0xb727('0x169')});db['OpenchannelAccount']['belongsToMany'](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x13d')});db['OpenchannelApplication'][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x64')][_0xb727('0x14c')](db[_0xb727('0x6a')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x189')});db[_0xb727('0x64')][_0xb727('0x14c')](db[_0xb727('0x62')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x188')});db[_0xb727('0x64')][_0xb727('0x14c')](db[_0xb727('0x8d')],{'onDelete':_0xb727('0x15e'),'foreignKey':'IntervalId'});db['OpenchannelApplication'][_0xb727('0x14c')](db[_0xb727('0x96')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x66')]['hasMany'](db[_0xb727('0x68')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x18a')});db[_0xb727('0x66')][_0xb727('0x14c')](db[_0xb727('0x62')],{'as':_0xb727('0x16d'),'foreignKey':'OpenchannelAccountId'});db[_0xb727('0x66')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':'Contact','foreignKey':'ContactId'});db[_0xb727('0x66')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x16e'),'foreignKey':_0xb727('0x11c')});db[_0xb727('0x66')][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x18b'),'as':'Tags'});db['OpenchannelInteraction'][_0xb727('0x125')](db[_0xb727('0x96')],{'through':'openchannel_interaction_has_tags','as':_0xb727('0x170')});db[_0xb727('0x66')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':'Users','through':'user_has_openchannel_interactions','foreignKey':_0xb727('0x18a')});db[_0xb727('0x68')][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x10')});db['OpenchannelMessage'][_0xb727('0x14c')](db[_0xb727('0x127')],{'onDelete':_0xb727('0x118'),'as':'Contact'});db[_0xb727('0x68')][_0xb727('0x14c')](db[_0xb727('0x66')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x173'),'foreignKey':_0xb727('0x18a')});db[_0xb727('0x68')][_0xb727('0x14c')](db[_0xb727('0xf5')],{'as':_0xb727('0xf5'),'foreignKey':_0xb727('0x180')});db[_0xb727('0x68')][_0xb727('0x14c')](db[_0xb727('0x62')],{'as':'Account','foreignKey':'OpenchannelAccountId'});db['OpenchannelQueue']['belongsToMany'](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x39'),'foreignKey':_0xb727('0x189')});db[_0xb727('0x6a')][_0xb727('0x125')](db[_0xb727('0xef')],{'through':_0xb727('0x18c'),'as':_0xb727('0x152')});db[_0xb727('0x6b')][_0xb727('0x11a')](db[_0xb727('0x8a')],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x174'),'onDelete':_0xb727('0x118')});db[_0xb727('0x6b')]['hasMany'](db[_0xb727('0x88')],{'as':_0xb727('0x162'),'foreignKey':'ChatWebsiteId'});db['ChatWebsite'][_0xb727('0x11a')](db['ChatProactiveAction'],{'as':_0xb727('0x18d')});db[_0xb727('0x6b')][_0xb727('0x11a')](db[_0xb727('0x70')],{'as':_0xb727('0x17a')});db[_0xb727('0x6b')][_0xb727('0x11a')](db[_0xb727('0x6e')],{'as':_0xb727('0x143')});db['ChatWebsite'][_0xb727('0x11a')](db[_0xb727('0x72')],{'as':_0xb727('0x164')});db[_0xb727('0x6b')]['belongsTo'](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x6b')]['belongsTo'](db[_0xb727('0x8d')],{'as':_0xb727('0x8d'),'foreignKey':_0xb727('0x150')});db[_0xb727('0x6b')][_0xb727('0x14c')](db[_0xb727('0x3f')],{'as':_0xb727('0x3f'),'foreignKey':'MailAccountId'});db[_0xb727('0x6b')][_0xb727('0x14c')](db[_0xb727('0x8f')],{'as':_0xb727('0x168'),'foreignKey':'mandatoryDispositionPauseId'});db[_0xb727('0x6b')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x18e')});db[_0xb727('0x18f')][_0xb727('0x14c')](db[_0xb727('0x62')],{});db['OpenchannelQueueReport'][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0x18f')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x18f')][_0xb727('0x14c')](db[_0xb727('0x66')],{});db[_0xb727('0x18f')]['belongsTo'](db['OpenchannelMessage'],{});db[_0xb727('0x18f')][_0xb727('0x14c')](db[_0xb727('0x10')],{});db[_0xb727('0x18f')][_0xb727('0x14c')](db[_0xb727('0x6a')],{});db[_0xb727('0x6e')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x190'),'foreignKey':_0xb727('0x11c'),'onDelete':_0xb727('0x15e')});db['ChatApplication'][_0xb727('0x14c')](db[_0xb727('0x76')],{'as':_0xb727('0x191'),'foreignKey':_0xb727('0x192'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x6e')][_0xb727('0x14c')](db[_0xb727('0x6b')],{'as':_0xb727('0x193'),'foreignKey':_0xb727('0x174'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x6e')][_0xb727('0x14c')](db[_0xb727('0x96')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x70')][_0xb727('0x11a')](db[_0xb727('0x72')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x194')});db[_0xb727('0x70')][_0xb727('0x14c')](db[_0xb727('0x6b')],{'as':'Account','foreignKey':_0xb727('0x174')});db[_0xb727('0x70')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x70')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x16e'),'foreignKey':_0xb727('0x11c')});db['ChatInteraction'][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x195'),'as':_0xb727('0x17e')});db[_0xb727('0x70')][_0xb727('0x125')](db['Tag'],{'through':_0xb727('0x195'),'as':'ThroughTags'});db[_0xb727('0x70')][_0xb727('0x125')](db['User'],{'as':_0xb727('0x171'),'through':_0xb727('0x196'),'foreignKey':_0xb727('0x194')});db['ChatMessage'][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':'cascade','as':_0xb727('0x10')});db[_0xb727('0x72')][_0xb727('0x14c')](db['CmContact'],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x72')][_0xb727('0x14c')](db[_0xb727('0x70')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x173'),'foreignKey':_0xb727('0x194')});db[_0xb727('0x72')][_0xb727('0x14c')](db['Attachment'],{'as':_0xb727('0xf5'),'foreignKey':_0xb727('0x180')});db[_0xb727('0x72')][_0xb727('0x14c')](db['ChatWebsite'],{'as':'Account','foreignKey':'ChatWebsiteId'});db[_0xb727('0x74')]['hasMany'](db[_0xb727('0xf5')],{'as':_0xb727('0x172'),'foreignKey':_0xb727('0x175'),'onDelete':_0xb727('0x118'),'hooks':!![]});db[_0xb727('0x74')][_0xb727('0x14c')](db[_0xb727('0x127')],{'onDelete':_0xb727('0x118'),'as':'Contact','foreignKey':_0xb727('0x177')});db['ChatOfflineMessage'][_0xb727('0x14c')](db[_0xb727('0x6b')],{'as':'Account','foreignKey':_0xb727('0x174')});db['ChatQueue'][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':'UserChatQueue','hooks':!![]});db[_0xb727('0x76')][_0xb727('0x125')](db[_0xb727('0xef')],{'through':_0xb727('0x197'),'as':_0xb727('0x152')});db[_0xb727('0x78')][_0xb727('0x11a')](db[_0xb727('0xd9')],{'as':_0xb727('0x164'),'foreignKey':_0xb727('0x198'),'onDelete':_0xb727('0x118')});db[_0xb727('0x78')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x146'),'through':_0xb727('0x126')});db['ChatProactiveAction'][_0xb727('0x14c')](db['ChatWebsite'],{'as':_0xb727('0x193'),'foreignKey':'ChatWebsiteId'});db[_0xb727('0x7a')][_0xb727('0x11a')](db['CmContact'],{'as':_0xb727('0x128'),'foreignKey':_0xb727('0x199')});db['CmContact'][_0xb727('0x11a')](db[_0xb727('0x19a')],{'as':_0xb727('0x19b'),'foreignKey':_0xb727('0x19c')});db[_0xb727('0x127')][_0xb727('0x11a')](db[_0xb727('0x7d')],{'as':_0xb727('0x148'),'foreignKey':'ContactId'});db[_0xb727('0x127')]['hasMany'](db[_0xb727('0x80')],{'as':'HopperFinals','foreignKey':_0xb727('0x177')});db['CmContact'][_0xb727('0x11a')](db[_0xb727('0x82')],{'as':'HopperHistories','foreignKey':_0xb727('0x177')});db[_0xb727('0x127')][_0xb727('0x11a')](db[_0xb727('0x84')],{'as':_0xb727('0x84'),'foreignKey':_0xb727('0x177')});db[_0xb727('0x127')][_0xb727('0x11a')](db[_0xb727('0xdf')],{'as':_0xb727('0x14b'),'foreignKey':'ContactId'});db[_0xb727('0x127')][_0xb727('0x11a')](db[_0xb727('0x66')],{'as':_0xb727('0x12c'),'foreignKey':_0xb727('0x177'),'onDelete':'restrict'});db[_0xb727('0x127')][_0xb727('0x11a')](db[_0xb727('0x70')],{'as':_0xb727('0x11f'),'foreignKey':_0xb727('0x177'),'onDelete':'restrict'});db['CmContact'][_0xb727('0x11a')](db[_0xb727('0x5c')],{'as':_0xb727('0x12a'),'foreignKey':'ContactId','onDelete':_0xb727('0x15e')});db[_0xb727('0x127')]['hasMany'](db[_0xb727('0x52')],{'as':_0xb727('0x120'),'foreignKey':_0xb727('0x177'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x127')][_0xb727('0x11a')](db['MailInteraction'],{'as':_0xb727('0x121'),'foreignKey':_0xb727('0x177'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x127')]['belongsTo'](db[_0xb727('0x7a')],{'as':_0xb727('0x19d'),'foreignKey':_0xb727('0x199')});db['CmContact'][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166'),'onDelete':_0xb727('0x118')});db[_0xb727('0x127')]['belongsToMany'](db[_0xb727('0x10')],{'as':_0xb727('0x171'),'through':_0xb727('0x19e')});db['CmContact'][_0xb727('0x125')](db[_0xb727('0x96')],{'as':_0xb727('0x17e'),'through':'cm_contact_has_tags'});db[_0xb727('0x127')][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x19f'),'as':_0xb727('0x170')});db[_0xb727('0x7d')][_0xb727('0x11a')](db[_0xb727('0x9a')],{'as':_0xb727('0x1a0'),'foreignKey':_0xb727('0x1a1')});db[_0xb727('0x7d')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177'),'onDelete':_0xb727('0x118')});db[_0xb727('0x7d')][_0xb727('0x14c')](db['CmList'],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166'),'onDelete':_0xb727('0x118')});db[_0xb727('0x7d')]['belongsTo'](db['User'],{'as':_0xb727('0x190'),'foreignKey':'UserId'});db[_0xb727('0x7d')][_0xb727('0x14c')](db[_0xb727('0x1b')],{'as':_0xb727('0x191'),'foreignKey':'VoiceQueueId','onDelete':_0xb727('0x118')});db[_0xb727('0x7d')][_0xb727('0x14c')](db[_0xb727('0xf2')],{'as':_0xb727('0xf2'),'foreignKey':'CampaignId','onDelete':'cascade'});db[_0xb727('0x7d')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':_0xb727('0x16e'),'foreignKey':_0xb727('0x1a2')});db[_0xb727('0x149')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177'),'onDelete':'cascade'});db[_0xb727('0x149')]['belongsTo'](db[_0xb727('0x100')],{'as':'List','foreignKey':'ListId','onDelete':_0xb727('0x118')});db[_0xb727('0x149')][_0xb727('0x14c')](db[_0xb727('0x1b')],{'as':_0xb727('0x191'),'foreignKey':'VoiceQueueId','onDelete':'cascade'});db[_0xb727('0x149')][_0xb727('0x14c')](db[_0xb727('0xf2')],{'as':_0xb727('0xf2'),'foreignKey':'CampaignId','onDelete':'cascade'});db['Automation'][_0xb727('0x11a')](db[_0xb727('0x8c')],{'as':{'plural':'All','singular':'OneAll'},'foreignKey':_0xb727('0x1a3'),'onDelete':'cascade','hooks':!![]});db[_0xb727('0x1a4')][_0xb727('0x11a')](db[_0xb727('0x8c')],{'as':{'plural':_0xb727('0x1a5'),'singular':_0xb727('0x1a6')},'foreignKey':'AutomationAnyId','onDelete':_0xb727('0x118'),'hooks':!![]});db[_0xb727('0x1a4')][_0xb727('0x11a')](db['Action'],{'as':'Actions','foreignKey':'AutomationId','onDelete':'cascade','hooks':!![]});db['Disposition']['hasMany'](db['Disposition'],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x1a7'),'onDelete':_0xb727('0x118')});db[_0xb727('0x8d')][_0xb727('0x11a')](db[_0xb727('0x8d')],{'as':'Intervals','foreignKey':_0xb727('0x150'),'onDelete':_0xb727('0x118'),'hooks':!![],'required':![]});db[_0xb727('0x8d')][_0xb727('0x11a')](db[_0xb727('0x17')],{'as':_0xb727('0x1a8'),'foreignKey':'IntervalId','onDelete':'restrict'});db[_0xb727('0x8d')]['hasMany'](db['MailApplication'],{'as':_0xb727('0x1a9'),'foreignKey':'IntervalId'});db['Interval'][_0xb727('0x11a')](db['ChatApplication'],{'as':_0xb727('0x1aa'),'foreignKey':_0xb727('0x150')});db[_0xb727('0x8d')][_0xb727('0x11a')](db[_0xb727('0x50')],{'as':_0xb727('0x1ab'),'foreignKey':_0xb727('0x150')});db[_0xb727('0x8d')][_0xb727('0x11a')](db[_0xb727('0x5a')],{'as':_0xb727('0x1ac'),'foreignKey':_0xb727('0x150')});db['Schedule'][_0xb727('0x14c')](db[_0xb727('0x3f')],{});db[_0xb727('0x1ad')][_0xb727('0x14c')](db[_0xb727('0x1ae')],{'foreignKey':'DefaultReportId'});db['Schedule'][_0xb727('0x14c')](db[_0xb727('0x1af')],{'foreignKey':_0xb727('0x1b0')});db[_0xb727('0x94')][_0xb727('0x125')](db[_0xb727('0x19')],{'as':'Mohs','through':_0xb727('0x145'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x96')][_0xb727('0x125')](db[_0xb727('0x127')],{'through':_0xb727('0x19f')});db[_0xb727('0x96')]['belongsToMany'](db[_0xb727('0x70')],{'through':_0xb727('0x195')});db[_0xb727('0x96')][_0xb727('0x125')](db['MailInteraction'],{'through':'mail_interaction_has_tags'});db[_0xb727('0x96')]['belongsToMany'](db[_0xb727('0x5c')],{'through':_0xb727('0x185')});db[_0xb727('0x96')][_0xb727('0x125')](db['FaxInteraction'],{'through':_0xb727('0x17d')});db[_0xb727('0x96')][_0xb727('0x125')](db[_0xb727('0x66')],{'through':'openchannel_interaction_has_tags'});db[_0xb727('0x96')][_0xb727('0x125')](db['WhatsappInteraction'],{'through':_0xb727('0x1b1')});db['CmContactHasItem'][_0xb727('0x14c')](db[_0xb727('0x97')],{'as':_0xb727('0x1b2'),'foreignKey':_0xb727('0x1b3')});db[_0xb727('0x9a')][_0xb727('0x14c')](db['CmHopper'],{'as':_0xb727('0x1b4'),'foreignKey':_0xb727('0x1a1')});db[_0xb727('0x19a')]['belongsTo'](db['CmContact'],{'as':_0xb727('0x15b'),'foreignKey':'CmContactId'});db['Trigger'][_0xb727('0x11a')](db[_0xb727('0x8c')],{'as':{'plural':_0xb727('0x1b5'),'singular':_0xb727('0x1b6')},'foreignKey':_0xb727('0x1b7'),'onDelete':_0xb727('0x118'),'hooks':!![]});db['Trigger'][_0xb727('0x11a')](db['Condition'],{'as':{'plural':'AnyConditions','singular':_0xb727('0x1b8')},'foreignKey':_0xb727('0x1b9'),'onDelete':_0xb727('0x118'),'hooks':!![]});db[_0xb727('0x9d')][_0xb727('0x11a')](db[_0xb727('0x87')],{'as':_0xb727('0x1ba'),'foreignKey':'TriggerId','onDelete':_0xb727('0x118'),'hooks':!![]});db[_0xb727('0x1af')][_0xb727('0x11a')](db[_0xb727('0x1bb')],{'as':_0xb727('0x1bc'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1b0'),'hooks':!![]});db[_0xb727('0x1ae')][_0xb727('0x11a')](db[_0xb727('0x1bb')],{'as':'Fields','onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1bd')});db[_0xb727('0xa6')][_0xb727('0x11a')](db['AnalyticFieldReport'],{'as':_0xb727('0x1bc'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1be')});db[_0xb727('0x1bb')]['belongsTo'](db[_0xb727('0xa6')],{'foreignKey':_0xb727('0x1be')});db[_0xb727('0x1bf')][_0xb727('0x11a')](db[_0xb727('0xa9')],{'as':_0xb727('0x1c0'),'onDelete':'cascade','foreignKey':'AccountId'});db[_0xb727('0xa9')][_0xb727('0x11a')](db['SalesforceField'],{'as':_0xb727('0x1c1'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c2')});db['SalesforceConfiguration'][_0xb727('0x11a')](db[_0xb727('0x1c3')],{'as':_0xb727('0x1c4'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0xa9')][_0xb727('0x11a')](db[_0xb727('0x1c3')],{'as':_0xb727('0x1bc'),'onDelete':_0xb727('0x118'),'foreignKey':'FieldId'});db['SalesforceConfiguration']['belongsTo'](db['SalesforceAccount'],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1c3')][_0xb727('0x11a')](db[_0xb727('0x1c3')],{'as':'Subject','foreignKey':'SubjectId'});db[_0xb727('0x1c3')]['hasMany'](db[_0xb727('0x1c3')],{'as':_0xb727('0x1c7'),'foreignKey':'DescriptionId'});db[_0xb727('0x1c3')][_0xb727('0x11a')](db[_0xb727('0x1c3')],{'as':_0xb727('0x1c8'),'foreignKey':'FieldId'});db[_0xb727('0x1c3')][_0xb727('0x14c')](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db[_0xb727('0xab')][_0xb727('0x11a')](db[_0xb727('0x1ca')],{'as':'Configurations','onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1ca')][_0xb727('0x11a')](db['SugarcrmField'],{'as':'Subjects','onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c2')});db[_0xb727('0x1ca')][_0xb727('0x11a')](db[_0xb727('0x1cb')],{'as':_0xb727('0x1c4'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c5')});db['SugarcrmConfiguration'][_0xb727('0x11a')](db['SugarcrmField'],{'as':_0xb727('0x1bc'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1cc')});db['SugarcrmConfiguration']['belongsTo'](db[_0xb727('0xab')],{'as':_0xb727('0x16d'),'foreignKey':'AccountId'});db[_0xb727('0x1cb')]['hasMany'](db[_0xb727('0x1cb')],{'as':_0xb727('0x1cd'),'foreignKey':_0xb727('0x1c2')});db[_0xb727('0x1cb')][_0xb727('0x11a')](db[_0xb727('0x1cb')],{'as':_0xb727('0x1c7'),'foreignKey':'DescriptionId'});db[_0xb727('0x1cb')][_0xb727('0x11a')](db[_0xb727('0x1cb')],{'as':_0xb727('0x1c8'),'foreignKey':_0xb727('0x1cc')});db[_0xb727('0x1cb')]['belongsTo'](db[_0xb727('0x9f')],{'as':'Variable','foreignKey':_0xb727('0x1c9')});db[_0xb727('0xae')][_0xb727('0x11a')](db[_0xb727('0xb0')],{'as':_0xb727('0x1c0'),'onDelete':'cascade','foreignKey':_0xb727('0x1c6')});db[_0xb727('0xb0')]['hasMany'](db[_0xb727('0xb2')],{'as':_0xb727('0x1c1'),'onDelete':'cascade','foreignKey':_0xb727('0x1c2')});db[_0xb727('0xb0')][_0xb727('0x11a')](db[_0xb727('0xb2')],{'as':'Descriptions','onDelete':_0xb727('0x118'),'foreignKey':'DescriptionId'});db['DeskConfiguration']['hasMany'](db[_0xb727('0xb2')],{'as':'Fields','onDelete':'cascade','foreignKey':'FieldId'});db['DeskConfiguration'][_0xb727('0x14c')](db[_0xb727('0xae')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x1c6')});db['DeskConfiguration']['belongsToMany'](db[_0xb727('0x96')],{'through':'int_desk_configuration_has_tags'});db[_0xb727('0xb2')][_0xb727('0x11a')](db[_0xb727('0xb2')],{'as':_0xb727('0x1cd'),'foreignKey':'SubjectId'});db[_0xb727('0xb2')][_0xb727('0x11a')](db['DeskField'],{'as':'Description','foreignKey':_0xb727('0x1c5')});db[_0xb727('0xb2')][_0xb727('0x11a')](db['DeskField'],{'as':_0xb727('0x1c8'),'foreignKey':_0xb727('0x1cc')});db[_0xb727('0xb2')]['belongsTo'](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db[_0xb727('0xb4')][_0xb727('0x11a')](db['ZohoConfiguration'],{'as':_0xb727('0x1c0'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c6')});db['ZohoConfiguration']['hasMany'](db['ZohoField'],{'as':_0xb727('0x1c1'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c2')});db['ZohoConfiguration'][_0xb727('0x11a')](db['ZohoField'],{'as':'Descriptions','onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c5')});db['ZohoConfiguration'][_0xb727('0x11a')](db['ZohoField'],{'as':_0xb727('0x1bc'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1cc')});db[_0xb727('0xb5')][_0xb727('0x14c')](db[_0xb727('0xb4')],{'as':'Account','foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1ce')][_0xb727('0x11a')](db['ZohoField'],{'as':_0xb727('0x1cd'),'foreignKey':_0xb727('0x1c2')});db[_0xb727('0x1ce')]['hasMany'](db[_0xb727('0x1ce')],{'as':_0xb727('0x1c7'),'foreignKey':'DescriptionId'});db[_0xb727('0x1ce')][_0xb727('0x11a')](db[_0xb727('0x1ce')],{'as':_0xb727('0x1c8'),'foreignKey':'FieldId'});db[_0xb727('0x1ce')][_0xb727('0x14c')](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db[_0xb727('0x1cf')][_0xb727('0x11a')](db[_0xb727('0xb9')],{'as':_0xb727('0x1c0'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0xb9')]['hasMany'](db[_0xb727('0xbb')],{'as':_0xb727('0x1c1'),'foreignKey':'SubjectId'});db[_0xb727('0xb9')][_0xb727('0x11a')](db[_0xb727('0xbb')],{'as':_0xb727('0x1c4'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0xb9')][_0xb727('0x11a')](db[_0xb727('0xbb')],{'as':_0xb727('0x1bc'),'foreignKey':_0xb727('0x1cc')});db['ZendeskConfiguration']['belongsTo'](db['ZendeskAccount'],{'as':'Account','foreignKey':_0xb727('0x1c6')});db[_0xb727('0xb9')][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x1d0')});db[_0xb727('0xbb')][_0xb727('0x11a')](db[_0xb727('0xbb')],{'as':_0xb727('0x1cd'),'foreignKey':_0xb727('0x1c2')});db['ZendeskField'][_0xb727('0x11a')](db[_0xb727('0xbb')],{'as':_0xb727('0x1c7'),'foreignKey':'DescriptionId'});db[_0xb727('0xbb')][_0xb727('0x11a')](db[_0xb727('0xbb')],{'as':'Field','foreignKey':_0xb727('0x1cc')});db[_0xb727('0xbb')]['belongsTo'](db['Variable'],{'as':_0xb727('0x9f'),'foreignKey':'VariableId'});db[_0xb727('0xbd')][_0xb727('0x11a')](db[_0xb727('0xbf')],{'as':_0xb727('0x1c0'),'onDelete':'cascade','foreignKey':_0xb727('0x1c6')});db['FreshdeskConfiguration']['hasMany'](db[_0xb727('0xc0')],{'as':_0xb727('0x1c1'),'onDelete':_0xb727('0x118'),'foreignKey':'SubjectId'});db[_0xb727('0xbf')]['hasMany'](db[_0xb727('0xc0')],{'as':_0xb727('0x1c4'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0xbf')][_0xb727('0x11a')](db[_0xb727('0xc0')],{'as':_0xb727('0x1bc'),'onDelete':'cascade','foreignKey':_0xb727('0x1cc')});db[_0xb727('0xbf')][_0xb727('0x14c')](db['FreshdeskAccount'],{'as':'Account','foreignKey':_0xb727('0x1c6')});db[_0xb727('0xbf')][_0xb727('0x125')](db['Tag'],{'through':_0xb727('0x1d1')});db['FreshdeskField'][_0xb727('0x11a')](db[_0xb727('0xc0')],{'as':_0xb727('0x1cd'),'foreignKey':'SubjectId'});db[_0xb727('0xc0')][_0xb727('0x11a')](db[_0xb727('0xc0')],{'as':_0xb727('0x1c7'),'foreignKey':'DescriptionId'});db[_0xb727('0xc0')]['hasMany'](db[_0xb727('0xc0')],{'as':_0xb727('0x1c8'),'foreignKey':'FieldId'});db[_0xb727('0xc0')]['belongsTo'](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db[_0xb727('0xc2')][_0xb727('0x11a')](db['VtigerConfiguration'],{'as':_0xb727('0x1c0'),'onDelete':'cascade','foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1d2')][_0xb727('0x11a')](db[_0xb727('0xc5')],{'as':'Subjects','foreignKey':_0xb727('0x1c2')});db['VtigerConfiguration'][_0xb727('0x11a')](db[_0xb727('0xc5')],{'as':'Descriptions','foreignKey':_0xb727('0x1c5')});db[_0xb727('0x1d2')][_0xb727('0x11a')](db['VtigerField'],{'as':_0xb727('0x1bc'),'foreignKey':_0xb727('0x1cc')});db['VtigerConfiguration'][_0xb727('0x14c')](db[_0xb727('0xc2')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0xc5')][_0xb727('0x11a')](db[_0xb727('0xc5')],{'as':'Subject','foreignKey':_0xb727('0x1c2')});db['VtigerField'][_0xb727('0x11a')](db['VtigerField'],{'as':_0xb727('0x1c7'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0xc5')]['hasMany'](db[_0xb727('0xc5')],{'as':_0xb727('0x1c8'),'foreignKey':_0xb727('0x1cc')});db[_0xb727('0xc5')][_0xb727('0x14c')](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db['ServicenowAccount']['hasMany'](db[_0xb727('0x1d3')],{'as':_0xb727('0x1c0'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1d3')][_0xb727('0x11a')](db[_0xb727('0x1d4')],{'as':_0xb727('0x1c1'),'foreignKey':_0xb727('0x1c2')});db[_0xb727('0x1d3')][_0xb727('0x11a')](db['ServicenowField'],{'as':_0xb727('0x1c4'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0x1d3')][_0xb727('0x11a')](db[_0xb727('0x1d4')],{'as':_0xb727('0x1bc'),'foreignKey':_0xb727('0x1cc')});db['ServicenowConfiguration'][_0xb727('0x14c')](db['ServicenowAccount'],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x1c6')});db[_0xb727('0x1d4')][_0xb727('0x11a')](db['ServicenowField'],{'as':'Subject','foreignKey':_0xb727('0x1c2')});db['ServicenowField'][_0xb727('0x11a')](db[_0xb727('0x1d4')],{'as':_0xb727('0x1c7'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0x1d4')]['hasMany'](db[_0xb727('0x1d4')],{'as':'Field','foreignKey':_0xb727('0x1cc')});db['ServicenowField'][_0xb727('0x14c')](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':'VariableId'});db[_0xb727('0xcb')][_0xb727('0x11a')](db[_0xb727('0xcd')],{'as':_0xb727('0x1c0'),'onDelete':_0xb727('0x118'),'foreignKey':'AccountId'});db[_0xb727('0xcb')][_0xb727('0x14c')](db[_0xb727('0x10f')],{'as':_0xb727('0x10f'),'foreignKey':_0xb727('0x15d')});db[_0xb727('0xcd')]['hasMany'](db[_0xb727('0xcf')],{'as':_0xb727('0x1c1'),'onDelete':'cascade','foreignKey':_0xb727('0x1c2')});db[_0xb727('0xcd')][_0xb727('0x11a')](db[_0xb727('0xcf')],{'as':'Descriptions','onDelete':'cascade','foreignKey':_0xb727('0x1c5')});db[_0xb727('0xcd')][_0xb727('0x11a')](db[_0xb727('0xcf')],{'as':'Fields','onDelete':'cascade','foreignKey':_0xb727('0x1cc')});db['Dynamics365Configuration'][_0xb727('0x14c')](db[_0xb727('0xcb')],{'as':'Account','foreignKey':'AccountId'});db['Dynamics365Field'][_0xb727('0x11a')](db[_0xb727('0xcf')],{'as':_0xb727('0x1cd'),'foreignKey':'SubjectId'});db[_0xb727('0xcf')]['hasMany'](db[_0xb727('0xcf')],{'as':'Description','foreignKey':'DescriptionId'});db[_0xb727('0xcf')]['hasMany'](db[_0xb727('0xcf')],{'as':'Field','foreignKey':_0xb727('0x1cc')});db[_0xb727('0xcf')][_0xb727('0x14c')](db[_0xb727('0x9f')],{'as':_0xb727('0x9f'),'foreignKey':_0xb727('0x1c9')});db[_0xb727('0x1d5')][_0xb727('0x11a')](db['FreshsalesConfiguration'],{'as':_0xb727('0x1c0'),'onDelete':_0xb727('0x118'),'foreignKey':'AccountId'});db['FreshsalesConfiguration'][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':_0xb727('0x1c1'),'foreignKey':'SubjectId'});db[_0xb727('0xd1')][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':'Descriptions','foreignKey':_0xb727('0x1c5')});db[_0xb727('0xd1')][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':'Fields','foreignKey':_0xb727('0x1cc')});db['FreshsalesConfiguration'][_0xb727('0x14c')](db['FreshsalesAccount'],{'as':_0xb727('0x16d'),'foreignKey':'AccountId'});db[_0xb727('0xd3')][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':'Subject','foreignKey':_0xb727('0x1c2')});db[_0xb727('0xd3')][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':_0xb727('0x1c7'),'foreignKey':_0xb727('0x1c5')});db[_0xb727('0xd3')][_0xb727('0x11a')](db[_0xb727('0xd3')],{'as':'Field','foreignKey':'FieldId'});db[_0xb727('0xd3')][_0xb727('0x14c')](db['Variable'],{'as':'Variable','foreignKey':'VariableId'});db[_0xb727('0xd7')][_0xb727('0x14c')](db[_0xb727('0x6b')],{});db[_0xb727('0xd7')][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':'List','foreignKey':_0xb727('0x166')});db[_0xb727('0xd7')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':'Contact','foreignKey':_0xb727('0x177')});db['ChatQueueReport'][_0xb727('0x14c')](db[_0xb727('0x70')],{});db['ChatQueueReport'][_0xb727('0x14c')](db['ChatMessage'],{});db[_0xb727('0xd7')][_0xb727('0x14c')](db[_0xb727('0x10')],{});db[_0xb727('0xd7')][_0xb727('0x14c')](db[_0xb727('0x76')],{});db[_0xb727('0xd9')]['belongsTo'](db['User'],{'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x1d6')});db[_0xb727('0xd9')]['belongsTo'](db[_0xb727('0x10')],{'onDelete':_0xb727('0x118'),'foreignKey':'ToId'});db[_0xb727('0xdf')][_0xb727('0x11a')](db['JscriptyQuestionReport'],{'foreignKey':'SessionId','onDelete':_0xb727('0x118')});db[_0xb727('0xdf')][_0xb727('0x11a')](db['JscriptyAnswerReport'],{'foreignKey':_0xb727('0x1d7'),'onDelete':_0xb727('0x118')});db[_0xb727('0xe1')]['belongsTo'](db['SmsAccount'],{});db[_0xb727('0xe1')]['belongsTo'](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':_0xb727('0x166')});db[_0xb727('0xe1')][_0xb727('0x14c')](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':_0xb727('0x177')});db[_0xb727('0xe1')][_0xb727('0x14c')](db['SmsInteraction'],{});db[_0xb727('0xe1')][_0xb727('0x14c')](db[_0xb727('0x5e')],{});db['SmsQueueReport'][_0xb727('0x14c')](db[_0xb727('0x10')],{});db[_0xb727('0xe1')][_0xb727('0x14c')](db[_0xb727('0x60')],{});db[_0xb727('0x1d8')][_0xb727('0x11a')](db['JscriptySessionReport'],{'foreignKey':_0xb727('0x1d9')});db[_0xb727('0x1d8')][_0xb727('0x11a')](db['JscriptyQuestionReport'],{'foreignKey':'ProjectId'});db[_0xb727('0x1d8')][_0xb727('0x11a')](db[_0xb727('0xdb')],{'foreignKey':_0xb727('0x1d9')});db[_0xb727('0xef')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':'Agents','through':_0xb727('0x1da')});db[_0xb727('0xef')][_0xb727('0x125')](db['VoiceQueue'],{'through':_0xb727('0x110'),'as':_0xb727('0x130')});db['Team'][_0xb727('0x125')](db[_0xb727('0x131')],{'through':_0xb727('0x16b'),'as':_0xb727('0x132')});db['Team']['belongsToMany'](db[_0xb727('0x76')],{'through':_0xb727('0x197'),'as':_0xb727('0x133')});db[_0xb727('0xef')][_0xb727('0x125')](db[_0xb727('0x56')],{'through':_0xb727('0x181'),'as':_0xb727('0x135')});db['Team'][_0xb727('0x125')](db['SmsQueue'],{'through':_0xb727('0x187'),'as':_0xb727('0x1db')});db['Team'][_0xb727('0x125')](db[_0xb727('0x6a')],{'through':_0xb727('0x18c'),'as':'OpenchannelQueues'});db[_0xb727('0xef')][_0xb727('0x125')](db[_0xb727('0x137')],{'through':_0xb727('0x1dc'),'as':_0xb727('0x1dd')});db[_0xb727('0xef')][_0xb727('0x125')](db[_0xb727('0x101')],{'through':_0xb727('0x112'),'as':'VoicePrefixes'});db[_0xb727('0xf2')]['hasMany'](db[_0xb727('0x7d')],{'as':_0xb727('0x148'),'foreignKey':_0xb727('0x1de')});db['Campaign'][_0xb727('0x11a')](db[_0xb727('0x80')],{'as':'HopperFinals','foreignKey':_0xb727('0x1de')});db['Campaign']['hasMany'](db[_0xb727('0x82')],{'as':_0xb727('0x1df'),'foreignKey':_0xb727('0x1de')});db['Campaign'][_0xb727('0x11a')](db[_0xb727('0x149')],{'as':_0xb727('0x14a'),'foreignKey':_0xb727('0x1de')});db[_0xb727('0xf2')][_0xb727('0x14c')](db[_0xb727('0x2c')],{'as':'Trunk','foreignKey':_0xb727('0x14d')});db[_0xb727('0xf2')]['belongsTo'](db[_0xb727('0x2c')],{'as':_0xb727('0x14e'),'foreignKey':_0xb727('0x14f')});db[_0xb727('0xf2')]['belongsTo'](db[_0xb727('0x8d')],{'as':'Interval','foreignKey':_0xb727('0x150')});db['Campaign'][_0xb727('0x14c')](db[_0xb727('0xeb')],{'as':_0xb727('0xeb'),'foreignKey':_0xb727('0x1e0')});db[_0xb727('0xf2')][_0xb727('0x125')](db['CmList'],{'as':_0xb727('0x151'),'through':_0xb727('0x1e1')});db[_0xb727('0xf2')][_0xb727('0x125')](db[_0xb727('0x100')],{'as':_0xb727('0x153'),'through':_0xb727('0x1e2')});db[_0xb727('0xf5')][_0xb727('0x14c')](db['ChatOfflineMessage'],{'as':_0xb727('0x74'),'foreignKey':'ChatOfflineMessageId'});db['MailTransferReport'][_0xb727('0x14c')](db[_0xb727('0x163')],{});db[_0xb727('0xf9')][_0xb727('0x14c')](db[_0xb727('0x44')],{});db['MailTransferReport']['belongsTo'](db[_0xb727('0x3f')],{'foreignKey':_0xb727('0x1e3'),'as':_0xb727('0x1e4')});db[_0xb727('0xf9')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1e5'),'as':'FromAgent'});db[_0xb727('0xf9')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':'ToUserId','as':_0xb727('0x1e6')});db[_0xb727('0xf9')][_0xb727('0x14c')](db[_0xb727('0x131')],{'foreignKey':_0xb727('0x1e7'),'as':_0xb727('0x1e8')});db[_0xb727('0xf9')]['belongsTo'](db[_0xb727('0x3f')],{'foreignKey':_0xb727('0x1e9'),'as':_0xb727('0x1ea')});db['ChatTransferReport'][_0xb727('0x14c')](db[_0xb727('0x72')],{});db[_0xb727('0xfb')][_0xb727('0x14c')](db[_0xb727('0x70')],{});db[_0xb727('0xfb')]['belongsTo'](db[_0xb727('0x6b')],{'foreignKey':_0xb727('0x1eb'),'as':_0xb727('0x1e4')});db[_0xb727('0xfb')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':'FromUserId','as':_0xb727('0x1ec')});db['ChatTransferReport'][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1ed'),'as':_0xb727('0x1e6')});db['ChatTransferReport']['belongsTo'](db[_0xb727('0x76')],{'foreignKey':_0xb727('0x1ee'),'as':_0xb727('0x1e8')});db['ChatTransferReport'][_0xb727('0x14c')](db['ChatWebsite'],{'foreignKey':_0xb727('0x1ef'),'as':_0xb727('0x1ea')});db[_0xb727('0x1f0')][_0xb727('0x14c')](db['FaxMessage'],{});db[_0xb727('0x1f0')][_0xb727('0x14c')](db['FaxInteraction'],{});db['FaxTransferReport']['belongsTo'](db[_0xb727('0x4e')],{'foreignKey':_0xb727('0x1f1'),'as':_0xb727('0x1e4')});db['FaxTransferReport'][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1e5'),'as':_0xb727('0x1ec')});db[_0xb727('0x1f0')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1ed'),'as':_0xb727('0x1e6')});db[_0xb727('0x1f0')][_0xb727('0x14c')](db[_0xb727('0x56')],{'foreignKey':_0xb727('0x1f2'),'as':'ToQueue'});db['FaxTransferReport'][_0xb727('0x14c')](db[_0xb727('0x4e')],{'foreignKey':_0xb727('0x1f3'),'as':_0xb727('0x1ea')});db[_0xb727('0xfe')][_0xb727('0x14c')](db[_0xb727('0x68')],{});db[_0xb727('0xfe')][_0xb727('0x14c')](db['OpenchannelInteraction'],{});db[_0xb727('0xfe')][_0xb727('0x14c')](db[_0xb727('0x62')],{'foreignKey':_0xb727('0x1f4'),'as':_0xb727('0x1e4')});db[_0xb727('0xfe')][_0xb727('0x14c')](db['User'],{'foreignKey':_0xb727('0x1e5'),'as':'FromAgent'});db[_0xb727('0xfe')][_0xb727('0x14c')](db['User'],{'foreignKey':'ToUserId','as':_0xb727('0x1e6')});db[_0xb727('0xfe')][_0xb727('0x14c')](db[_0xb727('0x6a')],{'foreignKey':_0xb727('0x1f5'),'as':_0xb727('0x1e8')});db[_0xb727('0xfe')][_0xb727('0x14c')](db['OpenchannelAccount'],{'foreignKey':'ToOpenchannelAccountId','as':_0xb727('0x1ea')});db[_0xb727('0x1f6')]['belongsTo'](db[_0xb727('0x5e')],{});db[_0xb727('0x1f6')]['belongsTo'](db[_0xb727('0x5c')],{});db[_0xb727('0x1f6')][_0xb727('0x14c')](db[_0xb727('0x59')],{'foreignKey':'FromSmsAccountId','as':_0xb727('0x1e4')});db[_0xb727('0x1f6')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1e5'),'as':_0xb727('0x1ec')});db[_0xb727('0x1f6')]['belongsTo'](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1ed'),'as':'ToAgent'});db['SmsTransferReport']['belongsTo'](db[_0xb727('0x60')],{'foreignKey':_0xb727('0x1f7'),'as':_0xb727('0x1e8')});db['SmsTransferReport'][_0xb727('0x14c')](db['SmsAccount'],{'foreignKey':_0xb727('0x1f8'),'as':_0xb727('0x1ea')});db[_0xb727('0x100')][_0xb727('0x11a')](db[_0xb727('0x8a')],{'as':_0xb727('0x161'),'foreignKey':_0xb727('0x166'),'onDelete':'cascade'});db['CmList'][_0xb727('0x11a')](db[_0xb727('0x1f9')],{'as':_0xb727('0x1fa'),'foreignKey':_0xb727('0x166')});db['CmList'][_0xb727('0x11a')](db[_0xb727('0x127')],{'as':_0xb727('0x128'),'onDelete':'cascade','foreignKey':'ListId'});db['CmList'][_0xb727('0x11a')](db[_0xb727('0x80')],{'as':_0xb727('0x11d'),'foreignKey':'ListId'});db['CmList'][_0xb727('0x11a')](db['CmHopperHistory'],{'as':_0xb727('0x11e'),'foreignKey':_0xb727('0x166')});db['CmList']['hasMany'](db['ReportAgentPreview'],{'as':_0xb727('0x84'),'foreignKey':'ListId'});db['CmList'][_0xb727('0x125')](db[_0xb727('0x1b')],{'as':_0xb727('0x1fb'),'through':'voice_queues_has_cm_lists'});db['CmList'][_0xb727('0x125')](db['User'],{'as':_0xb727('0x16a'),'through':_0xb727('0x1fc')});db[_0xb727('0x101')][_0xb727('0x11a')](db['VoiceExtension'],{'as':_0xb727('0x1a8'),'onDelete':_0xb727('0x118')});db[_0xb727('0x101')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':'UserVoicePrefix'});db[_0xb727('0x101')][_0xb727('0x125')](db[_0xb727('0xef')],{'through':_0xb727('0x112'),'as':'Teams'});db[_0xb727('0x123')][_0xb727('0x11a')](db['User'],{'as':_0xb727('0x171'),'foreignKey':_0xb727('0x124')});db[_0xb727('0x123')][_0xb727('0x11a')](db[_0xb727('0x1fd')],{'as':'UserProfileSections','foreignKey':_0xb727('0x124'),'onDelete':_0xb727('0x118')});db['UserProfileSection'][_0xb727('0x11a')](db['UserProfileResource'],{'as':'Resources','foreignKey':_0xb727('0x1fe'),'onDelete':'cascade'});db[_0xb727('0x1ff')][_0xb727('0x11a')](db['Disposition'],{'as':_0xb727('0x161'),'foreignKey':'WhatsappAccountId','onDelete':'cascade'});db[_0xb727('0x1ff')][_0xb727('0x11a')](db[_0xb727('0x88')],{'as':_0xb727('0x162'),'foreignKey':_0xb727('0x200')});db[_0xb727('0x1ff')][_0xb727('0x11a')](db[_0xb727('0x10b')],{'as':'Messages','foreignKey':_0xb727('0x200')});db[_0xb727('0x1ff')][_0xb727('0x11a')](db[_0xb727('0x109')],{'as':'Interactions'});db[_0xb727('0x1ff')][_0xb727('0x11a')](db[_0xb727('0x107')],{'as':_0xb727('0x143')});db[_0xb727('0x1ff')][_0xb727('0x14c')](db[_0xb727('0x100')],{'as':_0xb727('0x165'),'foreignKey':'ListId'});db[_0xb727('0x1ff')][_0xb727('0x14c')](db[_0xb727('0x8f')],{'as':'mandatoryDispositionPause','foreignKey':_0xb727('0x169')});db[_0xb727('0x1ff')][_0xb727('0x125')](db['User'],{'as':_0xb727('0x16a'),'through':_0xb727('0x140')});db['WhatsappApplication'][_0xb727('0x14c')](db[_0xb727('0x10')],{'onDelete':_0xb727('0x15e')});db['WhatsappApplication'][_0xb727('0x14c')](db['WhatsappQueue'],{'onDelete':_0xb727('0x15e')});db[_0xb727('0x107')][_0xb727('0x14c')](db[_0xb727('0x1ff')],{'onDelete':'restrict'});db['WhatsappApplication'][_0xb727('0x14c')](db[_0xb727('0x8d')],{'onDelete':'restrict','foreignKey':_0xb727('0x150')});db[_0xb727('0x107')]['belongsTo'](db[_0xb727('0x96')],{'onDelete':_0xb727('0x15e'),'foreignKey':_0xb727('0x176')});db[_0xb727('0x109')][_0xb727('0x11a')](db[_0xb727('0x10b')],{'as':_0xb727('0x164'),'onDelete':_0xb727('0x118'),'foreignKey':_0xb727('0x201')});db[_0xb727('0x109')][_0xb727('0x14c')](db['WhatsappAccount'],{'as':'Account','foreignKey':_0xb727('0x200')});db['WhatsappInteraction']['belongsTo'](db[_0xb727('0x127')],{'as':_0xb727('0x15b'),'foreignKey':'ContactId'});db[_0xb727('0x109')][_0xb727('0x14c')](db['User'],{'as':_0xb727('0x16e'),'foreignKey':_0xb727('0x11c')});db['WhatsappInteraction'][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x1b1'),'as':_0xb727('0x17e')});db[_0xb727('0x109')][_0xb727('0x125')](db[_0xb727('0x96')],{'through':_0xb727('0x1b1'),'as':_0xb727('0x170')});db['WhatsappInteraction'][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x171'),'through':_0xb727('0x12f'),'foreignKey':_0xb727('0x201')});db[_0xb727('0x10b')][_0xb727('0x14c')](db[_0xb727('0x10')],{'as':'User'});db[_0xb727('0x10b')][_0xb727('0x14c')](db[_0xb727('0x127')],{'onDelete':'cascade','as':'Contact'});db['WhatsappMessage']['belongsTo'](db[_0xb727('0x109')],{'onDelete':_0xb727('0x118'),'as':_0xb727('0x173'),'foreignKey':'WhatsappInteractionId'});db[_0xb727('0x10b')][_0xb727('0x14c')](db[_0xb727('0x1ff')],{'as':_0xb727('0x16d'),'foreignKey':_0xb727('0x200')});db[_0xb727('0x202')][_0xb727('0x14c')](db[_0xb727('0x1ff')],{});db[_0xb727('0x202')]['belongsTo'](db[_0xb727('0x100')],{'as':'List','foreignKey':_0xb727('0x166')});db[_0xb727('0x202')]['belongsTo'](db[_0xb727('0x127')],{'as':'Contact','foreignKey':_0xb727('0x177')});db[_0xb727('0x202')][_0xb727('0x14c')](db[_0xb727('0x109')],{});db[_0xb727('0x202')]['belongsTo'](db[_0xb727('0x137')],{});db['WhatsappQueueReport'][_0xb727('0x14c')](db[_0xb727('0x10b')],{});db[_0xb727('0x202')][_0xb727('0x14c')](db[_0xb727('0x10')],{});db['WhatsappTransferReport'][_0xb727('0x14c')](db[_0xb727('0x10b')],{});db['WhatsappTransferReport'][_0xb727('0x14c')](db[_0xb727('0x109')],{});db[_0xb727('0x10d')][_0xb727('0x14c')](db[_0xb727('0x1ff')],{'foreignKey':_0xb727('0x203'),'as':'FromAccount'});db[_0xb727('0x10d')]['belongsTo'](db[_0xb727('0x1ff')],{'foreignKey':_0xb727('0x204'),'as':'ToAccount'});db[_0xb727('0x10d')][_0xb727('0x14c')](db['WhatsappQueue'],{'foreignKey':_0xb727('0x205'),'as':_0xb727('0x1e8')});db[_0xb727('0x10d')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1e5'),'as':_0xb727('0x1ec')});db[_0xb727('0x10d')][_0xb727('0x14c')](db[_0xb727('0x10')],{'foreignKey':_0xb727('0x1ed'),'as':_0xb727('0x1e6')});db[_0xb727('0x137')][_0xb727('0x125')](db[_0xb727('0x10')],{'as':_0xb727('0x16a'),'through':_0xb727('0x3b'),'foreignKey':_0xb727('0x206')});db[_0xb727('0x137')]['belongsToMany'](db[_0xb727('0xef')],{'through':_0xb727('0x1dc'),'as':_0xb727('0x152')});db[_0xb727('0x115')]['belongsTo'](db[_0xb727('0x10')],{'as':_0xb727('0x207'),'foreignKey':_0xb727('0x11c'),'onDelete':_0xb727('0x118'),'hooks':!![]});db['CloudProvider']['hasOne'](db[_0xb727('0xcb')],{'as':_0xb727('0xcb'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x10f')][_0xb727('0x117')](db[_0xb727('0x3d')],{'as':_0xb727('0x15f'),'onDelete':_0xb727('0x15e')});db[_0xb727('0x10f')][_0xb727('0x117')](db[_0xb727('0x3e')],{'as':'Smtp','onDelete':_0xb727('0x15e')});module['exports']={'db':db,'dbH':dbH}; \ No newline at end of file diff --git a/server/routes.js b/server/routes.js new file mode 100644 index 0000000..4a19da6 --- /dev/null +++ b/server/routes.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcbda=['/api/license','/api/campaigns','/api/migrations','./api/migration','./api/attachment','./api/plugin','/api/mail/reports/transfer','./api/chatTransferReport','/api/fax/reports/transfer','./api/faxTransferReport','/api/openchannel/reports/transfer','./api/openchannelTransferReport','./api/smsTransferReport','/api/cm/lists','./api/voicePrefix','/api/userProfiles','./api/userProfile','/api/userProfile/sections','./api/userProfileSection','/api/userProfile/resources','./api/userProfileResource','/api/userNotifications','./api/userNotification','/api/whatsapp/accounts','./api/whatsappAccount','/api/whatsapp/applications','./api/whatsappApplication','/api/whatsapp/interactions','./api/whatsappInteraction','/api/whatsapp/messages','./api/whatsappQueueReport','/api/whatsapp/reports/transfer','./api/whatsappTransferReport','/api/whatsapp/queues','./api/whatsappQueue','./api/cloudProvider','/api/user-settings','./api/user-setting','/api/auth/local','./api/authLocal','/api/auth/google','./api/authGoogle','/api/auth/activedirectory','./api/authActiveDirectory','/api/jira','./api/jira','/api/rpc','./api/rpc','/api/version','./api/version','./api/pm2','./api/webbar','/api/logs','/apidoc','static','join','root','/demo','/snippet','3.1.0','/plugins','/:url(api|auth|components|app|bower_components|assets)/*','get','route','resolve','/index.html','./errors','./config/environment','./utils/client-side-logger','setupLoggers','./api/client-side-logs','then','use','/api/users','./api/user','/api/voice/chanspy','./api/voiceChanSpy','./api/voiceContext','/api/voice/extensions','./api/voiceExtension','/api/voice/mohs','./api/voiceMusicOnHold','/api/voice/queues','./api/voiceQueue','/api/voice/recordings','./api/voiceRecording','/api/screen/recordings','./api/screenRecording','/api/voice/mails','./api/voiceMail','/api/voice/mails/messages','./api/voiceMailMessage','/api/voice/calls/reports','./api/voiceCallReport','/api/voice/dials/reports','./api/voiceDialReport','/api/voice/agents/reports','./api/voiceAgentReport','/api/voice/queues/reports','/api/trunks','./api/trunk','/api/voice/transfers/reports','./api/voiceTransferReport','/api/mail/out_servers','./api/mailServerOut','/api/mail/accounts','./api/mailAccount','/api/mail/queues','./api/mailQueue','/api/mail/substatuses','./api/mailSubstatus','./api/mailInteraction','/api/mail/messages','./api/mailMessage','/api/mail/applications','./api/mailApplication','/api/mail/reports/queue','./api/mailQueueReport','/api/dashboards','/api/dashboards/items','/api/fax/accounts','/api/fax/applications','./api/faxApplication','/api/fax/interactions','./api/faxInteraction','/api/fax/messages','./api/faxQueue','/api/fax/reports/queue','./api/faxQueueReport','/api/sms/accounts','./api/smsAccount','/api/sms/applications','./api/smsApplication','/api/sms/interactions','./api/smsInteraction','/api/sms/messages','./api/smsMessage','/api/sms/queues','./api/smsQueue','/api/openchannel/accounts','./api/openchannelAccount','./api/openchannelInteraction','/api/openchannel/messages','./api/openchannelMessage','/api/openchannel/queues','./api/openchannelQueue','/api/chat/websites','./api/chatWebsite','/api/openchannel/reports/queue','./api/openchannelQueueReport','./api/chatApplication','/api/chat/interactions','./api/chatInteraction','./api/chatMessage','/api/chat/offline_messages','/api/chat/queues','./api/chatQueue','/api/chat/groups','./api/chatGroup','/api/chat/proactive_actions','/api/cm/companies','/api/cm/contacts','./api/cmContact','./api/cmHopper','/api/cm/hopper_final','./api/cmHopperFinal','/api/cm/hopper_history','./api/cmHopperHistory','/api/cm/custom_fields','./api/cmCustomField','/api/actions','./api/action','./api/automation','/api/canned_answers','./api/cannedAnswer','/api/dispositions','./api/disposition','/api/conditions','/api/intervals','./api/interval','/api/pauses','./api/pause','/api/cdr','./api/cdr','./api/voiceQueuesLog','./api/schedule','/api/sounds','./api/sound','/api/tags','./api/tag','./api/contactItemType','/api/cm_contact_has_items','/api/cm_hopper_additional_phones','./api/cmHopperAdditionalPhone','./api/template','/api/triggers','./api/trigger','/api/variables','/api/integrations','./api/integration','/api/integrations/reports','./api/integrationReport','/api/analytics/default_reports','/api/analytics/extracted_reports','./api/analyticExtractedReport','/api/analytics/metrics','./api/analyticMetric','/api/analytics/field_reports','./api/analyticFieldReport','/api/analytics/tree_reports','./api/analyticTreeReport','/api/integrations/salesforce/accounts','./api/intSalesforceAccount','/api/integrations/salesforce/configurations','/api/integrations/salesforce/fields','./api/intSugarcrmAccount','/api/integrations/sugarcrm/configurations','./api/intSugarcrmConfiguration','/api/integrations/sugarcrm/fields','./api/intSugarcrmField','/api/integrations/desk/accounts','./api/intDeskAccount','/api/integrations/desk/configurations','./api/intDeskConfiguration','/api/integrations/desk/fields','./api/intDeskField','./api/intZohoAccount','/api/integrations/zoho/configurations','./api/intZohoConfiguration','/api/integrations/zoho/fields','./api/intZohoField','/api/integrations/zendesk/accounts','/api/integrations/zendesk/fields','./api/intZendeskField','./api/intFreshdeskAccount','/api/integrations/freshdesk/configurations','./api/intFreshdeskConfiguration','/api/integrations/freshdesk/fields','./api/intFreshdeskField','/api/integrations/vtiger/accounts','./api/intVtigerAccount','./api/intVtigerConfiguration','/api/integrations/vtiger/fields','./api/intVtigerField','/api/integrations/servicenow/accounts','./api/intServicenowAccount','/api/integrations/servicenow/configurations','./api/intServicenowConfiguration','./api/intServicenowField','./api/intDynamics365Account','/api/integrations/dynamics365/configurations','./api/intDynamics365Configuration','./api/intDynamics365Field','/api/integrations/freshsales/accounts','./api/intFreshsalesAccount','/api/integrations/freshsales/configurations','./api/intFreshsalesConfiguration','/api/integrations/freshsales/fields','./api/intFreshsalesField','/api/networks','./api/network','/api/chat/reports/queue','./api/chatQueueReport','./api/chatInternalMessage','./api/jscriptyAnswerReport','/api/jscripty/questions/reports','./api/jscriptyQuestionReport','/api/jscripty/sessions/reports','./api/jscriptySessionReport','/api/sms/reports/queue','./api/smsQueueReport','./api/squareReport','/api/square/details/reports','./api/squareReportDetail','/api/jscripty/projects','./api/jscriptyProject','/api/settings','./api/setting','/api/square/odbc','/api/square/projects','./api/squareProject','/api/square/recordings','./api/squareRecording','/api/square/messages','./api/squareMessage','./api/team'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xcbda,0x160));var _0xacbd=function(_0x10afec,_0x8e39a9){_0x10afec=_0x10afec-0x0;var _0x515643=_0xcbda[_0x10afec];return _0x515643;};'use strict';var path=require('path');var express=require('express');var errors=require(_0xacbd('0x0'));var config=require(_0xacbd('0x1'));var setupLoggers=require(_0xacbd('0x2'))[_0xacbd('0x3')];var clientSideLogs=require(_0xacbd('0x4'));exports['default']=function(_0x4ef5fb){return setupLoggers(_0x4ef5fb)[_0xacbd('0x5')](function(){_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x7'),require(_0xacbd('0x8')));_0x4ef5fb['use'](_0xacbd('0x9'),require(_0xacbd('0xa')));_0x4ef5fb[_0xacbd('0x6')]('/api/voice/contexts',require(_0xacbd('0xb')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xc'),require(_0xacbd('0xd')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xe'),require(_0xacbd('0xf')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x10'),require(_0xacbd('0x11')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x12'),require(_0xacbd('0x13')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x14'),require(_0xacbd('0x15')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x16'),require(_0xacbd('0x17')));_0x4ef5fb['use'](_0xacbd('0x18'),require(_0xacbd('0x19')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x1a'),require(_0xacbd('0x1b')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x1c'),require(_0xacbd('0x1d')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x1e'),require(_0xacbd('0x1f')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x20'),require('./api/voiceQueueReport'));_0x4ef5fb[_0xacbd('0x6')]('/api/members/reports',require('./api/memberReport'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x21'),require(_0xacbd('0x22')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x23'),require(_0xacbd('0x24')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x25'),require(_0xacbd('0x26')));_0x4ef5fb['use'](_0xacbd('0x27'),require(_0xacbd('0x28')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x29'),require(_0xacbd('0x2a')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x2b'),require(_0xacbd('0x2c')));_0x4ef5fb[_0xacbd('0x6')]('/api/mail/interactions',require(_0xacbd('0x2d')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x2e'),require(_0xacbd('0x2f')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x30'),require(_0xacbd('0x31')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x32'),require(_0xacbd('0x33')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x34'),require('./api/dashboard'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x35'),require('./api/dashboardItem'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x36'),require('./api/faxAccount'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x37'),require(_0xacbd('0x38')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x39'),require(_0xacbd('0x3a')));_0x4ef5fb['use'](_0xacbd('0x3b'),require('./api/faxMessage'));_0x4ef5fb['use']('/api/fax/queues',require(_0xacbd('0x3c')));_0x4ef5fb['use'](_0xacbd('0x3d'),require(_0xacbd('0x3e')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x3f'),require(_0xacbd('0x40')));_0x4ef5fb['use'](_0xacbd('0x41'),require(_0xacbd('0x42')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x43'),require(_0xacbd('0x44')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x45'),require(_0xacbd('0x46')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x47'),require(_0xacbd('0x48')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x49'),require(_0xacbd('0x4a')));_0x4ef5fb[_0xacbd('0x6')]('/api/openchannel/applications',require('./api/openchannelApplication'));_0x4ef5fb[_0xacbd('0x6')]('/api/openchannel/interactions',require(_0xacbd('0x4b')));_0x4ef5fb['use'](_0xacbd('0x4c'),require(_0xacbd('0x4d')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x4e'),require(_0xacbd('0x4f')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x50'),require(_0xacbd('0x51')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x52'),require(_0xacbd('0x53')));_0x4ef5fb['use']('/api/chat/applications',require(_0xacbd('0x54')));_0x4ef5fb['use'](_0xacbd('0x55'),require(_0xacbd('0x56')));_0x4ef5fb[_0xacbd('0x6')]('/api/chat/messages',require(_0xacbd('0x57')));_0x4ef5fb['use'](_0xacbd('0x58'),require('./api/chatOfflineMessage'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x59'),require(_0xacbd('0x5a')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x5b'),require(_0xacbd('0x5c')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x5d'),require('./api/chatProactiveAction'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x5e'),require('./api/cmCompany'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x5f'),require(_0xacbd('0x60')));_0x4ef5fb[_0xacbd('0x6')]('/api/cm/hopper',require(_0xacbd('0x61')));_0x4ef5fb[_0xacbd('0x6')]('/api/cm/hopper_black',require('./api/cmHopperBlack'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x62'),require(_0xacbd('0x63')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x64'),require(_0xacbd('0x65')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x66'),require(_0xacbd('0x67')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x68'),require(_0xacbd('0x69')));_0x4ef5fb[_0xacbd('0x6')]('/api/automations',require(_0xacbd('0x6a')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x6b'),require(_0xacbd('0x6c')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x6d'),require(_0xacbd('0x6e')));_0x4ef5fb['use'](_0xacbd('0x6f'),require('./api/condition'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x70'),require(_0xacbd('0x71')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x72'),require(_0xacbd('0x73')));_0x4ef5fb['use'](_0xacbd('0x74'),require(_0xacbd('0x75')));_0x4ef5fb['use']('/api/voiceQueuesLog',require(_0xacbd('0x76')));_0x4ef5fb[_0xacbd('0x6')]('/api/schedules',require(_0xacbd('0x77')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x78'),require(_0xacbd('0x79')));_0x4ef5fb['use'](_0xacbd('0x7a'),require(_0xacbd('0x7b')));_0x4ef5fb[_0xacbd('0x6')]('/api/contact_item_types',require(_0xacbd('0x7c')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x7d'),require('./api/cmContactHasItem'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x7e'),require(_0xacbd('0x7f')));_0x4ef5fb[_0xacbd('0x6')]('/api/templates',require(_0xacbd('0x80')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x81'),require(_0xacbd('0x82')));_0x4ef5fb['use'](_0xacbd('0x83'),require('./api/variable'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x84'),require(_0xacbd('0x85')));_0x4ef5fb['use'](_0xacbd('0x86'),require(_0xacbd('0x87')));_0x4ef5fb[_0xacbd('0x6')]('/api/analytics/custom_reports',require('./api/analyticCustomReport'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x88'),require('./api/analyticDefaultReport'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x89'),require(_0xacbd('0x8a')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x8b'),require(_0xacbd('0x8c')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x8d'),require(_0xacbd('0x8e')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x8f'),require(_0xacbd('0x90')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x91'),require(_0xacbd('0x92')));_0x4ef5fb['use'](_0xacbd('0x93'),require('./api/intSalesforceConfiguration'));_0x4ef5fb['use'](_0xacbd('0x94'),require('./api/intSalesforceField'));_0x4ef5fb[_0xacbd('0x6')]('/api/integrations/sugarcrm/accounts',require(_0xacbd('0x95')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x96'),require(_0xacbd('0x97')));_0x4ef5fb['use'](_0xacbd('0x98'),require(_0xacbd('0x99')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x9a'),require(_0xacbd('0x9b')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x9c'),require(_0xacbd('0x9d')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x9e'),require(_0xacbd('0x9f')));_0x4ef5fb['use']('/api/integrations/zoho/accounts',require(_0xacbd('0xa0')));_0x4ef5fb['use'](_0xacbd('0xa1'),require(_0xacbd('0xa2')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xa3'),require(_0xacbd('0xa4')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xa5'),require('./api/intZendeskAccount'));_0x4ef5fb['use']('/api/integrations/zendesk/configurations',require('./api/intZendeskConfiguration'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xa6'),require(_0xacbd('0xa7')));_0x4ef5fb[_0xacbd('0x6')]('/api/integrations/freshdesk/accounts',require(_0xacbd('0xa8')));_0x4ef5fb['use'](_0xacbd('0xa9'),require(_0xacbd('0xaa')));_0x4ef5fb['use'](_0xacbd('0xab'),require(_0xacbd('0xac')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xad'),require(_0xacbd('0xae')));_0x4ef5fb['use']('/api/integrations/vtiger/configurations',require(_0xacbd('0xaf')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xb0'),require(_0xacbd('0xb1')));_0x4ef5fb['use'](_0xacbd('0xb2'),require(_0xacbd('0xb3')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xb4'),require(_0xacbd('0xb5')));_0x4ef5fb[_0xacbd('0x6')]('/api/integrations/servicenow/fields',require(_0xacbd('0xb6')));_0x4ef5fb[_0xacbd('0x6')]('/api/integrations/dynamics365/accounts',require(_0xacbd('0xb7')));_0x4ef5fb['use'](_0xacbd('0xb8'),require(_0xacbd('0xb9')));_0x4ef5fb[_0xacbd('0x6')]('/api/integrations/dynamics365/fields',require(_0xacbd('0xba')));_0x4ef5fb['use'](_0xacbd('0xbb'),require(_0xacbd('0xbc')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xbd'),require(_0xacbd('0xbe')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xbf'),require(_0xacbd('0xc0')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xc1'),require(_0xacbd('0xc2')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xc3'),require(_0xacbd('0xc4')));_0x4ef5fb[_0xacbd('0x6')]('/api/chat/internal/messages',require(_0xacbd('0xc5')));_0x4ef5fb[_0xacbd('0x6')]('/api/jscripty/answers/reports',require(_0xacbd('0xc6')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xc7'),require(_0xacbd('0xc8')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xc9'),require(_0xacbd('0xca')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xcb'),require(_0xacbd('0xcc')));_0x4ef5fb[_0xacbd('0x6')]('/api/square/reports',require(_0xacbd('0xcd')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xce'),require(_0xacbd('0xcf')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd0'),require(_0xacbd('0xd1')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd2'),require(_0xacbd('0xd3')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd4'),require('./api/squareOdbc'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd5'),require(_0xacbd('0xd6')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd7'),require(_0xacbd('0xd8')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xd9'),require(_0xacbd('0xda')));_0x4ef5fb[_0xacbd('0x6')]('/api/teams',require(_0xacbd('0xdb')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xdc'),require('./api/license'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xdd'),require('./api/campaign'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xde'),require(_0xacbd('0xdf')));_0x4ef5fb['use']('/api/attachments',require(_0xacbd('0xe0')));_0x4ef5fb[_0xacbd('0x6')]('/api/plugins',require(_0xacbd('0xe1')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xe2'),require('./api/mailTransferReport'));_0x4ef5fb[_0xacbd('0x6')]('/api/chat/reports/transfer',require(_0xacbd('0xe3')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xe4'),require(_0xacbd('0xe5')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xe6'),require(_0xacbd('0xe7')));_0x4ef5fb[_0xacbd('0x6')]('/api/sms/reports/transfer',require(_0xacbd('0xe8')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xe9'),require('./api/cmList'));_0x4ef5fb[_0xacbd('0x6')]('/api/voice/prefixes',require(_0xacbd('0xea')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xeb'),require(_0xacbd('0xec')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xed'),require(_0xacbd('0xee')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xef'),require(_0xacbd('0xf0')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xf1'),require(_0xacbd('0xf2')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xf3'),require(_0xacbd('0xf4')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xf5'),require(_0xacbd('0xf6')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xf7'),require(_0xacbd('0xf8')));_0x4ef5fb['use'](_0xacbd('0xf9'),require('./api/whatsappMessage'));_0x4ef5fb[_0xacbd('0x6')]('/api/whatsapp/reports/queue',require(_0xacbd('0xfa')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0xfb'),require(_0xacbd('0xfc')));_0x4ef5fb['use'](_0xacbd('0xfd'),require(_0xacbd('0xfe')));_0x4ef5fb[_0xacbd('0x6')]('/api/cloudProviders',require(_0xacbd('0xff')));_0x4ef5fb[_0xacbd('0x6')]('/api/realtime',require('./api/realtime'));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x100'),require(_0xacbd('0x101')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x102'),require(_0xacbd('0x103')));_0x4ef5fb['use'](_0xacbd('0x104'),require(_0xacbd('0x105')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x106'),require(_0xacbd('0x107')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x108'),require(_0xacbd('0x109')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x10a'),require(_0xacbd('0x10b')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x10c'),require(_0xacbd('0x10d')));_0x4ef5fb['use']('/api/system',require('./api/system'));_0x4ef5fb[_0xacbd('0x6')]('/api/pm2',require(_0xacbd('0x10e')));_0x4ef5fb[_0xacbd('0x6')]('/api/webbar',require(_0xacbd('0x10f')));_0x4ef5fb['use'](_0xacbd('0x110'),clientSideLogs);_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x111'),express[_0xacbd('0x112')](path[_0xacbd('0x113')](config[_0xacbd('0x114')],_0xacbd('0x111'))));_0x4ef5fb['use']('/www',express[_0xacbd('0x112')](path[_0xacbd('0x113')](config[_0xacbd('0x114')],'/www')));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x115'),express['static'](path[_0xacbd('0x113')](config[_0xacbd('0x114')],_0xacbd('0x115'))));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x116'),express[_0xacbd('0x112')](path['join'](config['root'],'snippet',_0xacbd('0x117'))));_0x4ef5fb[_0xacbd('0x6')](_0xacbd('0x118'),express[_0xacbd('0x112')](path['join'](config[_0xacbd('0x114')],'/server/files/plugins')));_0x4ef5fb['route'](_0xacbd('0x119'))[_0xacbd('0x11a')](errors[0x194]);_0x4ef5fb[_0xacbd('0x11b')]('/*')['get'](function(_0x133f8f,_0x2e954e){_0x2e954e['sendFile'](path[_0xacbd('0x11c')](_0x4ef5fb['get']('appPath')+_0xacbd('0x11d')));});return _0x4ef5fb;});}; \ No newline at end of file diff --git a/server/rpc/index.js b/server/rpc/index.js new file mode 100644 index 0000000..7bb90e7 --- /dev/null +++ b/server/rpc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x62ad=['../config/triggers','default','RPC\x20listening\x20on\x20','jayson/promise','lodash','../api/user/user.rpc','merge','../api/voiceExtension/voiceExtension.rpc','../api/voiceQueue/voiceQueue.rpc','../api/voiceCallReport/voiceCallReport.rpc','../api/voiceAgentReport/voiceAgentReport.rpc','../api/memberReport/memberReport.rpc','../api/trunk/trunk.rpc','../api/voiceTransferReport/voiceTransferReport.rpc','../api/userVoiceQueueRt/userVoiceQueueRt.rpc','../api/mailInteraction/mailInteraction.rpc','../api/mailMessage/mailMessage.rpc','../api/mailApplication/mailApplication.rpc','../api/mailQueueReport/mailQueueReport.rpc','../api/faxAccount/faxAccount.rpc','../api/faxApplication/faxApplication.rpc','../api/faxQueueReport/faxQueueReport.rpc','../api/smsAccount/smsAccount.rpc','../api/smsInteraction/smsInteraction.rpc','../api/smsMessage/smsMessage.rpc','../api/openchannelInteraction/openchannelInteraction.rpc','../api/openchannelMessage/openchannelMessage.rpc','../api/openchannelQueueReport/openchannelQueueReport.rpc','../api/chatMessage/chatMessage.rpc','../api/chatQueue/chatQueue.rpc','../api/cmHopper/cmHopper.rpc','../api/cmHopperBlack/cmHopperBlack.rpc','../api/cmHopperFinal/cmHopperFinal.rpc','../api/reportAgentPreview/reportAgentPreview.rpc','../api/pause/pause.rpc','../api/sound/sound.rpc','../api/cmHopperAdditionalPhone/cmHopperAdditionalPhone.rpc','../api/trigger/trigger.rpc','../api/intSalesforceAccount/intSalesforceAccount.rpc','../api/intSugarcrmAccount/intSugarcrmAccount.rpc','../api/intZohoAccount/intZohoAccount.rpc','../api/intVtigerAccount/intVtigerAccount.rpc','../api/intServicenowAccount/intServicenowAccount.rpc','../api/intDynamics365Account/intDynamics365Account.rpc','../api/intFreshsalesAccount/intFreshsalesAccount.rpc','../api/smsQueueReport/smsQueueReport.rpc','../api/squareReport/squareReport.rpc','../api/squareReportDetail/squareReportDetail.rpc','../api/setting/setting.rpc','../api/squareProject/squareProject.rpc','../api/squareRecording/squareRecording.rpc','../api/plugin/plugin.rpc','../api/whatsappAccount/whatsappAccount.rpc','../api/whatsappQueueReport/whatsappQueueReport.rpc','server','http','rpc','port','error','listen','log'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x62ad,0x134));var _0xd62a=function(_0x2c71b2,_0x2faa00){_0x2c71b2=_0x2c71b2-0x0;var _0x314e32=_0x62ad[_0x2c71b2];return _0x314e32;};'use strict';var jayson=require(_0xd62a('0x0'));var _=require(_0xd62a('0x1'));var config=require('../config/environment');exports['listen']=function(){return new Promise(function(_0x15dd6c,_0x34e5f2){var _0x50efae={};_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x2')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x4')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x5')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/voiceRecording/voiceRecording.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x6')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/voiceDialReport/voiceDialReport.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x7')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/voiceQueueReport/voiceQueueReport.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x8')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x9')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0xa')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0xb')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/mailServerIn/mailServerIn.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/mailAccount/mailAccount.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/mailQueue/mailQueue.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0xc')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0xd')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0xe')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0xf')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x10')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x11')));_0x50efae=_['merge'](_0x50efae,require('../api/faxInteraction/faxInteraction.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/faxMessage/faxMessage.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/faxQueue/faxQueue.rpc'));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x12')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x13')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x14')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x15')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/smsQueue/smsQueue.rpc'));_0x50efae=_['merge'](_0x50efae,require('../api/openchannelApplication/openchannelApplication.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x16')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x17')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/openchannelQueue/openchannelQueue.rpc'));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x18')));_0x50efae=_['merge'](_0x50efae,require('../api/chatInteraction/chatInteraction.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x19')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x1a')));_0x50efae=_['merge'](_0x50efae,require('../api/cmContact/cmContact.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x1b')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x1c')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x1d')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/cmHopperHistory/cmHopperHistory.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x1e')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/interval/interval.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x1f')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x20')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x21')));_0x50efae=_['merge'](_0x50efae,require('../api/template/template.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x22')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/variable/variable.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x23')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x24')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/intDeskAccount/intDeskAccount.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x25')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/intZendeskAccount/intZendeskAccount.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/intFreshdeskAccount/intFreshdeskAccount.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x26')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x27')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x28')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x29')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/chatQueueReport/chatQueueReport.rpc'));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x2a')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x2b')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x2c')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x2d')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/squareOdbc/squareOdbc.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x2e')));_0x50efae=_['merge'](_0x50efae,require(_0xd62a('0x2f')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/squareMessage/squareMessage.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/campaign/campaign.rpc'));_0x50efae=_['merge'](_0x50efae,require('../api/attachment/attachment.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x30')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x31')));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/whatsappInteraction/whatsappInteraction.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require('../api/whatsappMessage/whatsappMessage.rpc'));_0x50efae=_[_0xd62a('0x3')](_0x50efae,require(_0xd62a('0x32')));_0x50efae=_['merge'](_0x50efae,require('../api/whatsappQueue/whatsappQueue.rpc'));var _0x23ea91=jayson[_0xd62a('0x33')](_0x50efae)[_0xd62a('0x34')]();var _0x39a119=config[_0xd62a('0x35')][_0xd62a('0x36')]||config['port']+0x1;var _0x1bb815=config[_0xd62a('0x35')]['ip']||'localhost';_0x23ea91['on'](_0xd62a('0x37'),function(_0x321342){return _0x34e5f2(_0x321342);});_0x23ea91[_0xd62a('0x38')](_0x39a119,_0x1bb815,function(){console[_0xd62a('0x39')]('Express\x20RPC\x20server\x20listening\x20on\x20%s:%d!',_0x1bb815,_0x39a119);require(_0xd62a('0x3a'))[_0xd62a('0x3b')]();return _0x15dd6c(_0xd62a('0x3c')+_0x1bb815+':'+_0x39a119);});});}; \ No newline at end of file diff --git a/server/services/agi/channel.js b/server/services/agi/channel.js new file mode 100644 index 0000000..31ea8fa --- /dev/null +++ b/server/services/agi/channel.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9f9e=['HANGUP','isBoolean','isNumber','SET\x20VARIABLE\x20%s\x20\x22%s\x22','sayNumber','sayDigits','sayPhonetic','SAY\x20PHONETIC\x20\x22%s\x22\x20%s','continueAt','extension','getVariable','recordFile','wav','BEEP','RECORD\x20FILE\x20\x22%s\x22\x20\x22%s\x22\x20\x22%s\x22\x20%s\x20%s\x20%s','streamFile','STREAM\x20FILE\x20\x22%s\x22\x20\x22%s\x22','AGI','wait','WAIT','ID:%s\x20-\x20LABEL:\x20%s\x20-\x20MSG:\x20%s','label','util','events','EventEmitter','call','setEncoding','utf8','setTimeout','headers','emit','ready','line','toLowerCase','hangup','substring','520-Invalid','no\x20code','replace','indexOf','substr','startsWith','length','match','error','E_AGI_SOCKET_ERROR','close','E_AGI_SOCKET_CLOSE','timeout','E_AGI_SOCKET_TIMEOUT','pipe','command','function','destroy','inherits','prototype','sync','answer','sendRequest','ANSWER','getData','format','noop','NO\x20MESSAGE','exec','isArray','EXEC\x20%s\x20%s','join','setContext','SET\x20CONTEXT\x20%s','setExtension','SET\x20EXTENSION\x20%s','setPriority'];(function(_0x2154e7,_0x195446){var _0x462859=function(_0x295899){while(--_0x295899){_0x2154e7['push'](_0x2154e7['shift']());}};_0x462859(++_0x195446);}(_0x9f9e,0x183));var _0xe9f9=function(_0xc6be3a,_0x540e05){_0xc6be3a=_0xc6be3a-0x0;var _0x56a310=_0x9f9e[_0xc6be3a];return _0x56a310;};'use strict';var util=require(_0xe9f9('0x0'));var _=require('lodash');var EventEmitter=require(_0xe9f9('0x1'))[_0xe9f9('0x2')];var AGIReply=require('./reply');var AGIError=require('./error');function AGIChannel(_0x12de63){var _0x2eb0f2=this,_0x24430c=new AGIReply(),_0x5aedd3=![],_0x371dca={};EventEmitter[_0xe9f9('0x3')](_0x2eb0f2);_0x12de63[_0xe9f9('0x4')](_0xe9f9('0x5'));_0x12de63[_0xe9f9('0x6')](0x8*0x3c*0x3c*0x3e8);_0x24430c[_0xe9f9('0x4')]('utf8');_0x24430c['on'](_0xe9f9('0x7'),function(_0x34596d){for(var _0x975540 in _0x34596d){_0x2eb0f2[_0x975540]=_0x34596d[_0x975540];}_0x2eb0f2[_0xe9f9('0x8')](_0xe9f9('0x9'));});_0x24430c['on'](_0xe9f9('0xa'),function(_0x4eab89){if(_0x4eab89[_0xe9f9('0xb')]()=='hangup'){_0x2eb0f2['emit'](_0xe9f9('0xc'));return;}if(_0x4eab89[_0xe9f9('0xd')](0x0,0xb)==_0xe9f9('0xe')){_0x5aedd3=!![];}if(_0x5aedd3){_0x371dca['rx']+=_0x4eab89+'\x0a';if(_0x4eab89['search']('520\x20End\x20of\x20proper')!=-0x1){_0x5aedd3=![];}}else{_0x371dca['rx']=_0x4eab89;}if(_0x5aedd3){return;}if(typeof _0x371dca['cb']=='function'){var _0x1eee79=_0x371dca['rx'][_0xe9f9('0xd')](0x0,0x3),_0x8d616a=null,_0x5c25e9=null;_0x1eee79=parseInt(_0x1eee79);if(isNaN(_0x1eee79)){_0x371dca['cb'](null,{'code':0x1f4,'result':-0x1,'extra':_0xe9f9('0xf')});return;}if(_0x1eee79!=0xc8){_0x371dca['cb'](null,{'code':_0x1eee79,'result':-0x1,'extra':'KO'});return;}_0x8d616a=_0x371dca['rx'][_0xe9f9('0xd')](0x4)[_0xe9f9('0x10')]('result=','');if(_0x8d616a[_0xe9f9('0x11')]('\x20')!=-0x1){_0x8d616a=_0x8d616a[_0xe9f9('0x12')](0x0,_0x8d616a[_0xe9f9('0x11')]('\x20'));}if(_[_0xe9f9('0x13')](_0x8d616a,'-1')){_0x8d616a=parseInt(_0x8d616a);}_0x5c25e9=_0x371dca['rx']['split']('\x20');if(_0x5c25e9[_0xe9f9('0x14')]==0x3){_0x5c25e9=_0x5c25e9[0x2][_0xe9f9('0xd')](0x1,_0x5c25e9[0x2][_0xe9f9('0x14')]-0x1);}else if(_0x5c25e9[_0xe9f9('0x14')]>0x3){var _0x21676a=/\((.+)\)/;var _0x340e3e=_0x371dca['rx'][_0xe9f9('0x15')](_0x21676a);if(_0x340e3e){_0x5c25e9=_0x340e3e[0x1];}else{_0x5c25e9=null;}}else{_0x5c25e9=null;}_0x371dca['cb'](null,{'code':_0x1eee79,'result':_0x8d616a,'extra':_0x5c25e9});}});_0x12de63['on'](_0xe9f9('0x16'),function(_0xcf72f9){_0x2eb0f2[_0xe9f9('0x8')](_0xe9f9('0x16'),new AGIError(_0xe9f9('0x17'),_0xcf72f9['code']));});_0x12de63['on'](_0xe9f9('0x18'),function(){_0x2eb0f2[_0xe9f9('0x8')](_0xe9f9('0x18'),new AGIError(_0xe9f9('0x19')));});_0x12de63['on'](_0xe9f9('0x1a'),function(){_0x2eb0f2[_0xe9f9('0x8')](_0xe9f9('0x1a'),new AGIError(_0xe9f9('0x1b')));_0x12de63['destroy']();});_0x12de63[_0xe9f9('0x1c')](_0x24430c);this[_0xe9f9('0x1d')]=function(_0x4a2408,_0x21b20c){var _0x4a2408=_0x4a2408||'',_0x21b20c=typeof _0x21b20c==_0xe9f9('0x1e')?_0x21b20c:new Function();_0x371dca={'tx':_0x4a2408,'rx':'','cb':_0x21b20c};_0x12de63['write'](_0x4a2408+'\x0a');},this['close']=function(){_0x12de63[_0xe9f9('0x1f')]();};}util[_0xe9f9('0x20')](AGIChannel,EventEmitter);AGIChannel[_0xe9f9('0x21')]['sendRequest']=function(_0x19937e){return this['command'][_0xe9f9('0x22')](this,_0x19937e);};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x23')]=function(){return this[_0xe9f9('0x24')](_0xe9f9('0x25'));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x26')]=function(_0x4726fe,_0x3e87cb,_0x541372){_0x4726fe=_0x4726fe===undefined?'beep':_0x4726fe;_0x3e87cb=_0x3e87cb===undefined?'5':_0x3e87cb;_0x541372=_0x541372===undefined?'1':_0x541372;return this['sendRequest'](util[_0xe9f9('0x27')]('GET\x20DATA\x20\x22%s\x22\x20%s\x20%s',_0x4726fe,_0x3e87cb*0x3e8,_0x541372));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x28')]=function(_0x3776ad){_0x3776ad=_0x3776ad||_0xe9f9('0x29');return this[_0xe9f9('0x24')](util[_0xe9f9('0x27')]('VERBOSE\x20\x22%s\x22',_0x3776ad));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x2a')]=function(_0x2faa66,_0x46ce50){if(_[_0xe9f9('0x2b')](_0x46ce50)){return this[_0xe9f9('0x24')](util[_0xe9f9('0x27')](_0xe9f9('0x2c'),_0x2faa66,_0x46ce50[_0xe9f9('0x2d')](',')));}return this[_0xe9f9('0x24')](util[_0xe9f9('0x27')](_0xe9f9('0x2c'),_0x2faa66,_0x46ce50));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x2e')]=function(_0x403944){return this[_0xe9f9('0x24')](util['format'](_0xe9f9('0x2f'),_0x403944));};AGIChannel['prototype'][_0xe9f9('0x30')]=function(_0xcb108){return this['sendRequest'](util[_0xe9f9('0x27')](_0xe9f9('0x31'),_0xcb108));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x32')]=function(_0x13709b){return this[_0xe9f9('0x24')](util[_0xe9f9('0x27')]('SET\x20PRIORITY\x20%s',_0x13709b));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0xc')]=function(){return this[_0xe9f9('0x24')](_0xe9f9('0x33'));};AGIChannel[_0xe9f9('0x21')]['setVariable']=function(_0x291b2e,_0x314450){var _0x4caaf3=_[_0xe9f9('0x34')](_0x314450)||_[_0xe9f9('0x35')](_0x314450)?_0x314450['toString']():_0x314450;return this[_0xe9f9('0x24')](util['format'](_0xe9f9('0x36'),_0x291b2e,_0x4caaf3?_0x4caaf3['toString']()[_0xe9f9('0x10')](/(\r\n|\n|\r)/gm,'\x20'):''));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x37')]=function(_0xef9b1f,_0x12c9b2){return this['sendRequest'](util[_0xe9f9('0x27')]('SAY\x20NUMBER\x20%s\x20%s',_0xef9b1f,_0x12c9b2));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x38')]=function(_0xf11501,_0x39561e){return this['sendRequest'](util['format']('SAY\x20DIGITS\x20%s\x20%s',_0xf11501,_0x39561e));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x39')]=function(_0x5901ad,_0x1dcff2){return this['sendRequest'](util[_0xe9f9('0x27')](_0xe9f9('0x3a'),_0x5901ad,_0x1dcff2));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x3b')]=function(_0x48b227,_0x407044,_0x4bb76a){_0x407044=_0x407044||this[_0xe9f9('0x3c')];_0x4bb76a=_0x4bb76a||0x1;this[_0xe9f9('0x2e')](_0x48b227);this['setExtension'](_0x407044);this['setPriority'](_0x4bb76a);return this[_0xe9f9('0x28')](util[_0xe9f9('0x27')]('GOTO\x20%s\x20%s\x20%s',_0x48b227,_0x407044,_0x4bb76a));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x3d')]=function(_0x5d43fb){return this[_0xe9f9('0x24')](util['format']('GET\x20VARIABLE\x20\x22%s\x22',_0x5d43fb));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x3e')]=function(_0x5e9824,_0x48c816,_0xb864ce,_0x22cf2e,_0x3ed1e0,_0x121e40){_0x48c816=_0x48c816||_0xe9f9('0x3f');_0xb864ce=_0xb864ce||'';_0x22cf2e=_0x22cf2e===undefined?-0x1:_0x22cf2e==='-1'?-0x1:_0x22cf2e*0x3e8;_0x3ed1e0=_0x3ed1e0===undefined?'':'s='+_0x3ed1e0;_0x121e40=_0x121e40?_0xe9f9('0x40'):'';return this[_0xe9f9('0x24')](util[_0xe9f9('0x27')](_0xe9f9('0x41'),_0x5e9824,_0x48c816,_0xb864ce,_0x22cf2e,_0x121e40,_0x3ed1e0));};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x42')]=function(_0x387513,_0x7973ac){_0x7973ac=_0x7973ac||'';return this[_0xe9f9('0x24')](util['format'](_0xe9f9('0x43'),_0x387513,_0x7973ac));};AGIChannel['prototype']['agi']=function(_0x39518a){return this[_0xe9f9('0x2a')](_0xe9f9('0x44'),_0x39518a);};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x45')]=function(_0x554e0e){return this[_0xe9f9('0x2a')](_0xe9f9('0x46'),_0x554e0e);};AGIChannel[_0xe9f9('0x21')][_0xe9f9('0x16')]=function(_0x1c6402,_0x574711){this[_0xe9f9('0x28')](util[_0xe9f9('0x27')](_0xe9f9('0x47'),_0x1c6402['id'],_0x1c6402[_0xe9f9('0x48')],_0x574711));return{'code':0x1f4,'result':'-1','extra':''};};module['exports']=AGIChannel; \ No newline at end of file diff --git a/server/services/agi/error.js b/server/services/agi/error.js new file mode 100644 index 0000000..3025893 --- /dev/null +++ b/server/services/agi/error.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x28ea=['Missing\x20\x27ivr.entry\x27\x20menu.','push','format','apply','message','name','exports','util','Undefined\x20error.','Argument\x20\x27port\x27\x20missing\x20in\x20function\x20call.','Server\x20error.\x20Code:\x20%s.','Server\x20closed.','[LICENSE\x20VOICE]\x20Server\x20license\x20voice\x20disabled.','Socket\x20closed.','Socket\x20timeout.','Empty\x20command.','Missing\x20\x27ivr.agi_network_script\x27.'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x28ea,0x1e3));var _0xa28e=function(_0x2af3c0,_0x4a62c4){_0x2af3c0=_0x2af3c0-0x0;var _0x224762=_0x28ea[_0x2af3c0];return _0x224762;};'use strict';var util=require(_0xa28e('0x0'));var error={'E_AGI_UNDEFINED':_0xa28e('0x1'),'E_AGI_ARGUMENT_PORT':_0xa28e('0x2'),'E_AGI_SERVER_ERROR':_0xa28e('0x3'),'E_AGI_SERVER_CLOSE':_0xa28e('0x4'),'E_AGI_SERVER_MAXCONNECTION':'[LICENSE]\x20Server\x20max\x20connection.\x20Count:\x20%s.','E_AGI_SERVER_VOICE_DISABLED':_0xa28e('0x5'),'E_AGI_SOCKET_ERROR':'Socket\x20error.\x20Code:\x20%s.','E_AGI_SOCKET_CLOSE':_0xa28e('0x6'),'E_AGI_SOCKET_TIMEOUT':_0xa28e('0x7'),'E_AGI_COMMAND_EMPTY':_0xa28e('0x8'),'E_AGI_IVR_AGI_NETWORK_SCRIPT':_0xa28e('0x9'),'E_AGI_IVR_ENTRY':_0xa28e('0xa')};function AGIError(_0x47a953){var _0x47a953=_0x47a953||null,_0x309b9b=_0x309b9b||[],_0x3b1f32=0x1,_0xbfca40='';if(!error[_0x47a953]){_0x47a953='E_AGI_UNDEFINED';}_0x309b9b[_0xa28e('0xb')](error[_0x47a953]);while(arguments[_0x3b1f32]){_0x309b9b[_0xa28e('0xb')](arguments[_0x3b1f32]);_0x3b1f32++;}_0xbfca40=util[_0xa28e('0xc')][_0xa28e('0xd')](util,_0x309b9b);this[_0xa28e('0xe')]=_0xbfca40;this[_0xa28e('0xf')]=_0x47a953;}module[_0xa28e('0x10')]=AGIError; \ No newline at end of file diff --git a/server/services/agi/events.js b/server/services/agi/events.js new file mode 100644 index 0000000..8a5c4e6 --- /dev/null +++ b/server/services/agi/events.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x52f4=['error','E_AGI_SERVER_ERROR','message','parse','emit','projectUpdate','exports','lodash','EventEmitter','ioredis','./error','../../config/environment','redis','defaults','localhost','subscribe','agi'];(function(_0xa17335,_0x83bb89){var _0x5a4c84=function(_0x405acd){while(--_0x405acd){_0xa17335['push'](_0xa17335['shift']());}};_0x5a4c84(++_0x83bb89);}(_0x52f4,0xb1));var _0x452f=function(_0x149d1d,_0x2e15b9){_0x149d1d=_0x149d1d-0x0;var _0x56b77c=_0x52f4[_0x149d1d];return _0x56b77c;};'use strict';var _=require(_0x452f('0x0'));var EventEmitter=require('events')[_0x452f('0x1')];var Redis=require(_0x452f('0x2'));var AGIError=require(_0x452f('0x3'));var config=require(_0x452f('0x4'));config[_0x452f('0x5')]=_[_0x452f('0x6')](config[_0x452f('0x5')],{'host':_0x452f('0x7'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x452f('0x5')]);sub[_0x452f('0x8')](_0x452f('0x9'),function(_0x209127){if(_0x209127)return eventEmitter['emit'](_0x452f('0xa'),new AGIError(_0x452f('0xb'),_0x209127));});sub['on'](_0x452f('0xc'),function(_0x488b23,_0xc63685){if(_0x488b23!=='agi')return;try{var _0x2a48fd=JSON[_0x452f('0xd')](_0xc63685);eventEmitter[_0x452f('0xe')](_0x452f('0xf'),_0x2a48fd);}catch(_0x2e6428){eventEmitter[_0x452f('0xe')]('error',new AGIError(_0x452f('0xb'),_0x2e6428));}});module[_0x452f('0x10')]={'EventEmitter':eventEmitter}; \ No newline at end of file diff --git a/server/services/agi/graph/index.js b/server/services/agi/graph/index.js new file mode 100644 index 0000000..bdb0e48 --- /dev/null +++ b/server/services/agi/graph/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbd9b=['vertices','edges','numberOfEdges','prototype','addVertex','addEdge','size','getVertex','traverseBFS','info','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','agicommand','vswitch','target','default','invalid','max\x20retry\x20reach','condition\x20not\x20found','exports','lodash','../../../config/logger','agi','menu','getdigits'];(function(_0x1c1b5b,_0x26ef28){var _0x568db0=function(_0x16913a){while(--_0x16913a){_0x1c1b5b['push'](_0x1c1b5b['shift']());}};_0x568db0(++_0x26ef28);}(_0xbd9b,0x1d7));var _0xbbd9=function(_0x1dfb4a,_0x30f9ec){_0x1dfb4a=_0x1dfb4a-0x0;var _0x220ed6=_0xbd9b[_0x1dfb4a];return _0x220ed6;};'use strict';var _=require(_0xbbd9('0x0'));var logger=require(_0xbbd9('0x1'))(_0xbbd9('0x2'));var verticesWithRetry=[_0xbbd9('0x3'),_0xbbd9('0x4'),'getsecretdigits'];var Graph=function(){this[_0xbbd9('0x5')]={};this[_0xbbd9('0x6')]={};this[_0xbbd9('0x7')]=0x0;};Graph[_0xbbd9('0x8')][_0xbbd9('0x9')]=function(_0x59c434){this[_0xbbd9('0x5')][_0x59c434['id']]=_0x59c434;this[_0xbbd9('0x6')][_0x59c434['id']]=[];};Graph[_0xbbd9('0x8')][_0xbbd9('0xa')]=function(_0x338b7a,_0x35ffee,_0x57fca1){this[_0xbbd9('0x6')][_0x338b7a]['push']({'target':_0x35ffee,'condition':_0x57fca1});this['numberOfEdges']+=0x1;};Graph[_0xbbd9('0x8')][_0xbbd9('0xb')]=function(){return _['size'](this[_0xbbd9('0x5')]);};Graph[_0xbbd9('0x8')]['relations']=function(){return this[_0xbbd9('0x7')];};Graph['prototype'][_0xbbd9('0xc')]=function(_0x517de1){return this['vertices'][_0x517de1];};Graph[_0xbbd9('0x8')][_0xbbd9('0xd')]=function(_0x301ef2,_0x11e243){if(!this[_0xbbd9('0x5')][_0x301ef2]){return logger[_0xbbd9('0xe')]('no\x20vertex\x20found');}var _0x4591ea=_0x11e243(this['vertices'][_0x301ef2]);if(!_0x4591ea){return logger[_0xbbd9('0xe')](_0xbbd9('0xf'));}if(this[_0xbbd9('0x6')][_0x301ef2][_0xbbd9('0x10')]===0x0){return logger[_0xbbd9('0xe')](_0xbbd9('0x11'));}for(var _0x5a66e8=0x0,_0x2320a0=[],_0x666c47=![];_0x5a66e8\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','callerid','arg_1','dnid','uniqueid','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','calleridname','evtHangup','createSquareReport','then','indexOf','agi_','substring','debug','variables','stringify','close','timeout','hangup','find','handleNotFound','production','handleUnpublished','initialize','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','catch','[LICENSE]','finally','./server','connection','lodash','syncho','util','../../config/environment','../../config/logger','agi','../../config/license/util','./project','./events'];(function(_0x428407,_0x4406c3){var _0x5b590d=function(_0x54d987){while(--_0x54d987){_0x428407['push'](_0x428407['shift']());}};_0x5b590d(++_0x4406c3);}(_0x31a3,0xf3));var _0x331a=function(_0x4b54fb,_0x2150e4){_0x4b54fb=_0x4b54fb-0x0;var _0x375eb4=_0x31a3[_0x4b54fb];return _0x375eb4;};'use strict';var _=require(_0x331a('0x0'));var syncho=require(_0x331a('0x1'));var util=require(_0x331a('0x2'));var config=require(_0x331a('0x3'));var logger=require(_0x331a('0x4'))(_0x331a('0x5'));var utilLicense=require(_0x331a('0x6'));var rpc=require('./rpc');var Project=require(_0x331a('0x7'));var AGIEmitter=require(_0x331a('0x8'))[_0x331a('0x9')];var projects=[];config[_0x331a('0x5')]=_[_0x331a('0xa')](config[_0x331a('0x5')],{'ip':_0x331a('0xb'),'port':0x11dd});AGIEmitter['on'](_0x331a('0xc'),projectUpdateHandler);function connectionHandler(_0x3b6f09){process[_0x331a('0xd')](function(){syncho(function(){try{setChannelVariables(_0x3b6f09);agiHandler(_0x3b6f09);}catch(_0x3c10b3){logger[_0x331a('0xe')](_0x3c10b3[_0x331a('0xf')]);}});});}function projectUpdateHandler(_0x21aeb0){try{var _0x5a4380=_[_0x331a('0x10')](projects,['id',_0x21aeb0['id']]);if(_0x5a4380>-0x1){if(_0x21aeb0['deleted']===!![]){projects[_0x331a('0x11')](_0x5a4380,0x1);}else{projects[_0x5a4380]=_0x21aeb0;}}else{projects[_0x331a('0x12')](_0x21aeb0);}}catch(_0x5860fa){logger[_0x331a('0xe')](_0x5860fa[_0x331a('0xf')]);}}function listeningHandler(){console[_0x331a('0x13')]('Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!',config[_0x331a('0x5')][_0x331a('0x14')]);logger[_0x331a('0x15')](util[_0x331a('0x16')](_0x331a('0x17'),config[_0x331a('0x5')]['ip'],config[_0x331a('0x5')][_0x331a('0x14')]));}function errorHandler(_0x357597){if(_0x357597&&_0x357597['name']&&_0x357597[_0x331a('0x18')]){logger[_0x331a('0xe')](util['format'](_0x331a('0x19'),_0x357597[_0x331a('0x1a')],_0x357597[_0x331a('0x18')]));}else{logger['error'](util[_0x331a('0x16')](_0x331a('0x1b'),_0x357597[_0x331a('0xf')]));}}function closeHandler(){logger[_0x331a('0x15')](util['format'](_0x331a('0x1c'),this['arg_1'],this['calleridname'],this[_0x331a('0x1d')],this['dnid'],this['uniqueid']));try{createSquareReport(this);}catch(_0x38d812){logger[_0x331a('0xe')](_0x38d812[_0x331a('0xf')]);}}function timeoutHandler(){logger[_0x331a('0x15')](util[_0x331a('0x16')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0x331a('0x1e')],this['calleridname'],this[_0x331a('0x1d')],this[_0x331a('0x1f')],this[_0x331a('0x20')]));}function hangupHandler(){logger[_0x331a('0x15')](util[_0x331a('0x16')](_0x331a('0x21'),this[_0x331a('0x1e')],this[_0x331a('0x22')],this['callerid'],this[_0x331a('0x1f')],this[_0x331a('0x20')]));this[_0x331a('0x23')]=!![];}function createSquareReport(_0x22769b,_0x52b755){rpc[_0x331a('0x24')](_0x22769b)[_0x331a('0x25')](function(_0xfae693){if(_0x52b755){_0x52b755(null,_0xfae693);}})['catch'](function(_0xf63e70){if(_0x52b755){_0x52b755(null,_0xf63e70);}});}function setChannelVariables(_0x83a0dd){for(var _0x12a5c6 in _0x83a0dd){if(_0x83a0dd['hasOwnProperty'](_0x12a5c6)){if(_0x12a5c6[_0x331a('0x26')](_0x331a('0x27'))===0x0){_0x83a0dd[_0x12a5c6[_0x331a('0x28')](0x4)]=_0x83a0dd[_0x12a5c6];delete _0x83a0dd[_0x12a5c6];}}}}function agiHandler(_0x2978bf){logger[_0x331a('0x29')](_0x331a('0x2a'),JSON[_0x331a('0x2b')](_0x2978bf,null,0x2));logger[_0x331a('0x15')](util[_0x331a('0x16')]('[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x2978bf[_0x331a('0x1e')],_0x2978bf[_0x331a('0x22')],_0x2978bf[_0x331a('0x1d')],_0x2978bf[_0x331a('0x1f')],_0x2978bf[_0x331a('0x20')]));_0x2978bf['on']('error',errorHandler);_0x2978bf['on'](_0x331a('0x2c'),closeHandler);_0x2978bf['on'](_0x331a('0x2d'),timeoutHandler);_0x2978bf['evtHangup']=![];_0x2978bf['on'](_0x331a('0x2e'),hangupHandler);var _0x4fca5e=_[_0x331a('0x2f')](projects,[_0x331a('0x1a'),_0x2978bf[_0x331a('0x1e')]]);if(!_0x4fca5e)return Project[_0x331a('0x30')](_0x2978bf);if(!_0x4fca5e[_0x331a('0x31')])return Project[_0x331a('0x32')](_0x2978bf);return Project[_0x331a('0x33')](_0x4fca5e,_0x2978bf);}function main(){var _0xc1a178;return utilLicense[_0x331a('0x34')]()[_0x331a('0x25')](function(_0x3b0ad8){if(!_0x3b0ad8)return;if(_0x3b0ad8[_0x331a('0x35')]){if(_0x3b0ad8[_0x331a('0x36')]&&_0x3b0ad8[_0x331a('0x36')]>0x0){logger[_0x331a('0x15')](util[_0x331a('0x16')](_0x331a('0x37'),_0x3b0ad8[_0x331a('0x36')]));_0xc1a178=_0x3b0ad8[_0x331a('0x36')];}else{logger[_0x331a('0x15')](_0x331a('0x38'));}}else{logger[_0x331a('0x15')](_0x331a('0x39'));_0xc1a178=-0x1;}})['then'](function(){return Project['getAll']();})[_0x331a('0x25')](function(_0x1ac396){projects=_0x1ac396;return;})[_0x331a('0x3a')](function(_0xa4549b){logger[_0x331a('0xe')](_0x331a('0x3b'),_0xa4549b[_0x331a('0xf')]);})[_0x331a('0x3c')](function(){var _0x3e17a1=require(_0x331a('0x3d'))(config['agi'][_0x331a('0x14')],config[_0x331a('0x5')]['ip'],_0xc1a178);_0x3e17a1['on'](_0x331a('0xe'),errorHandler);_0x3e17a1['on']('listening',listeningHandler);_0x3e17a1['on'](_0x331a('0x3e'),connectionHandler);_0x3e17a1['on']('close',closeHandler);});}main(); \ No newline at end of file diff --git a/server/services/agi/mailRpc/index.js b/server/services/agi/mailRpc/index.js new file mode 100644 index 0000000..05ec2d1 --- /dev/null +++ b/server/services/agi/mailRpc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd9f4=['jayson/promise','client','request','then','error','result','catch','sendMailMessage','SendMail','bluebird'];(function(_0x3941df,_0x1492cb){var _0xe2da73=function(_0x1dcdf6){while(--_0x1dcdf6){_0x3941df['push'](_0x3941df['shift']());}};_0xe2da73(++_0x1492cb);}(_0xd9f4,0x1f3));var _0x4d9f=function(_0x1fafa5,_0x1aa281){_0x1fafa5=_0x1fafa5-0x0;var _0xcf08c9=_0xd9f4[_0x1fafa5];return _0xcf08c9;};'use strict';var BPromise=require(_0x4d9f('0x0'));var jayson=require(_0x4d9f('0x1'));var client=jayson[_0x4d9f('0x2')]['http']({'port':0x232b});function request(_0x5791ba,_0x31cdf5){return new BPromise(function(_0xce376e,_0x2583ef){return client[_0x4d9f('0x3')](_0x5791ba,_0x31cdf5)[_0x4d9f('0x4')](function(_0x1b3f10){if(_0x1b3f10[_0x4d9f('0x5')]){return _0x2583ef(_0x1b3f10[_0x4d9f('0x5')]['message']);}else{return _0xce376e(_0x1b3f10[_0x4d9f('0x6')]);}})[_0x4d9f('0x7')](function(_0x33f961){return _0x2583ef(_0x33f961);});});}exports[_0x4d9f('0x8')]=function(_0x136529,_0x14514c){return request(_0x4d9f('0x9'),{'account':_0x136529,'message':_0x14514c});}; \ No newline at end of file diff --git a/server/services/agi/project.js b/server/services/agi/project.js new file mode 100644 index 0000000..629bb74 --- /dev/null +++ b/server/services/agi/project.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x149e=['extension','priority','response','code','evtHangup','isUndefined','result','error','agicommand\x20not\x20found','finally','uniqueid','toString','[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s','continueAt','close','Project\x20%s\x20not\x20found','Project\x20%s\x20not\x20published','exports','lodash','util','../../config/logger','agi','./rpc','./mailRpc','./vertices','getSquareProjects','Unable\x20to\x20download\x20CallySquare\x20projects','stack','agicommand','hasOwnProperty','maxRetry','retry','omit','mxCell','isArray','length','source','addEdge','value','toJson','mxGraphModel','root','production','start','debug','stringify','joinAt','format','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','dnid','traverseBFS','clear','vertex','gotoc','info','gotoc\x20block\x20stop\x20traverse\x20BFS','context'];(function(_0x101320,_0x327215){var _0x10c830=function(_0xd6d1f7){while(--_0xd6d1f7){_0x101320['push'](_0x101320['shift']());}};_0x10c830(++_0x327215);}(_0x149e,0x107));var _0xe149=function(_0xc4dea8,_0x24930a){_0xc4dea8=_0xc4dea8-0x0;var _0x3d5675=_0x149e[_0xc4dea8];return _0x3d5675;};'use strict';var _=require(_0xe149('0x0'));var moment=require('moment');var parser=require('xml2json');var util=require(_0xe149('0x1'));var logger=require(_0xe149('0x2'))(_0xe149('0x3'));var rpc=require(_0xe149('0x4'));var mailRpc=require(_0xe149('0x5'));var Graph=require('./graph');var Vertices=require(_0xe149('0x6'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0xe149('0x7')]()['catch'](function(_0x48375a){logger['error'](_0xe149('0x8'),_0x48375a[_0xe149('0x9')]);return[];});}function addVertex(_0x410d49,_0x4bf15a,_0x26dfa6){_0x4bf15a[_0xe149('0xa')]=_0x26dfa6;if(_0x4bf15a[_0xe149('0xb')]('retry')){_0x4bf15a[_0xe149('0xc')]=parseInt(_0x4bf15a[_0xe149('0xd')],0xa);}_0x410d49['addVertex'](_[_0xe149('0xe')](_0x4bf15a,_0xe149('0xf')));}function initGraph(_0x1d32b5,_0x58352f){var _0x3f47cb=new Graph();for(var _0x4affe1 in _0x1d32b5){if(_0x1d32b5[_0xe149('0xb')](_0x4affe1)){if(_[_0xe149('0x10')](_0x1d32b5[_0x4affe1])){for(var _0x33ba55=0x0;_0x33ba55<_0x1d32b5[_0x4affe1][_0xe149('0x11')];_0x33ba55+=0x1){addVertex(_0x3f47cb,_0x1d32b5[_0x4affe1][_0x33ba55],_0x4affe1);}}else{addVertex(_0x3f47cb,_0x1d32b5[_0x4affe1],_0x4affe1);}}}for(var _0x1e2b1d=0x0;_0x1e2b1d<_0x58352f[_0xe149('0x11')];_0x1e2b1d+=0x1){if(_0x58352f[_0x1e2b1d][_0xe149('0x12')]&&_0x58352f[_0x1e2b1d]['target']){_0x3f47cb[_0xe149('0x13')](_0x58352f[_0x1e2b1d][_0xe149('0x12')],_0x58352f[_0x1e2b1d]['target'],_0x58352f[_0x1e2b1d][_0xe149('0x14')]);}}return _0x3f47cb;}function getRoot(_0x15e74b){return parser[_0xe149('0x15')](_0x15e74b,{'object':!![]})[_0xe149('0x16')][_0xe149('0x17')];}function inspect(_0x5b6a1b){return util['inspect'](_0x5b6a1b,{'showHidden':![],'depth':null});}function initialize(_0x56acb4,_0x17afce){var _0xd32175=getRoot(_0x56acb4[_0xe149('0x18')]);if(!_0xd32175||!_0xd32175[_0xe149('0x19')])return;var _0x241f30,_0x289c0c,_0x3a9424;logger[_0xe149('0x1a')](_0xe149('0x17'),JSON[_0xe149('0x1b')](_0xd32175,null,0x2));_0x17afce[_0xe149('0x1c')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x241f30=initGraph(_[_0xe149('0xe')](_0xd32175,_0xe149('0xf')),_0xd32175[_0xe149('0xf')]);_0x289c0c=new Vertices(_0x17afce,rpc,mailRpc);logger['info'](util[_0xe149('0x1d')](_0xe149('0x1e'),_0x17afce[_0xe149('0x1f')],_0x17afce[_0xe149('0x20')],_0x17afce[_0xe149('0x21')],_0x17afce[_0xe149('0x22')],_0x17afce['uniqueid']));_0x241f30[_0xe149('0x23')](_0xd32175[_0xe149('0x19')]['id'],function(_0x2800f9){try{_0x2800f9=_0x289c0c[_0xe149('0x24')](_0x2800f9);logger[_0xe149('0x1a')](_0xe149('0x25'),JSON['stringify'](_0x2800f9,null,0x2));if(_0x2800f9[_0xe149('0xa')]===_0xe149('0x26')){logger[_0xe149('0x27')](_0xe149('0x28'));_0x17afce[_0xe149('0x29')]=_0x2800f9['context']||_0x17afce[_0xe149('0x29')];_0x17afce[_0xe149('0x2a')]=_0x2800f9[_0xe149('0x2a')];_0x17afce[_0xe149('0x2b')]=_0x2800f9['priority']?_0x2800f9[_0xe149('0x2b')]-0x1:0x1;return null;}else if(_0x2800f9&&_0x289c0c[_0x2800f9['agicommand']]){_0x3a9424=_0x289c0c[_0x2800f9[_0xe149('0xa')]](_0x2800f9);logger[_0xe149('0x27')](_0xe149('0x2c'),JSON['stringify'](_0x3a9424,null,0x2));if(_0x3a9424&&_0x3a9424[_0xe149('0x2d')]===AGI_CODE_SUCCESS&&_0x3a9424['result']!==AGI_RESULT_ERROR&&!_0x17afce[_0xe149('0x2e')]){logger[_0xe149('0x1a')]('response',inspect(_0x3a9424));return _[_0xe149('0x2f')](_0x3a9424['result'])?null:_0x3a9424[_0xe149('0x30')]['toString']();}else{logger[_0xe149('0x31')]('response',inspect(_0x3a9424));return null;}}else{logger['error'](_0xe149('0x32'));return null;}}catch(_0x10242f){logger[_0xe149('0x31')](_0x10242f[_0xe149('0x9')]);return null;}});if(_0xd32175[_0xe149('0x33')]){logger['info'](util[_0xe149('0x1d')]('[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x17afce[_0xe149('0x1f')],_0x17afce[_0xe149('0x20')],_0x17afce[_0xe149('0x21')],_0x17afce[_0xe149('0x22')],_0x17afce[_0xe149('0x34')]));_0x241f30[_0xe149('0x23')](_0xd32175[_0xe149('0x33')]['id'],function(_0x1b6bb0){try{_0x1b6bb0=_0x289c0c[_0xe149('0x24')](_0x1b6bb0);logger[_0xe149('0x1a')](_0xe149('0x25'),JSON[_0xe149('0x1b')](_0x1b6bb0,null,0x2));if(_0x1b6bb0&&_0x289c0c[_0x1b6bb0[_0xe149('0xa')]]){_0x3a9424=_0x289c0c[_0x1b6bb0['agicommand']](_0x1b6bb0);if(_0x3a9424){logger['debug'](_0xe149('0x2c'),inspect(_0x3a9424));return _[_0xe149('0x2f')](_0x3a9424['result'])?null:_0x3a9424['result'][_0xe149('0x35')]();}else{logger[_0xe149('0x31')](_0xe149('0x2c'),inspect(_0x3a9424));return null;}}else{logger[_0xe149('0x31')](_0xe149('0x32'));return null;}}catch(_0x4fe416){logger[_0xe149('0x31')](_0x4fe416[_0xe149('0x9')]);return null;}});}logger[_0xe149('0x27')](util[_0xe149('0x1d')](_0xe149('0x36'),_0x17afce[_0xe149('0x1f')],_0x17afce['calleridname'],_0x17afce[_0xe149('0x21')],_0x17afce[_0xe149('0x22')],_0x17afce['uniqueid']));logger[_0xe149('0x27')](util[_0xe149('0x1d')](_0xe149('0x37'),_0x17afce['context'],_0x17afce['extension'],parseInt(_0x17afce[_0xe149('0x2b')],0xa)+0x1));_0x17afce[_0xe149('0x38')](_0x17afce['context'],_0x17afce[_0xe149('0x2a')],parseInt(_0x17afce['priority'],0xa)+0x1);_0x17afce[_0xe149('0x39')]();}function handleNotFound(_0x56d16e){logger['error'](util[_0xe149('0x1d')](_0xe149('0x3a'),_0x56d16e[_0xe149('0x1f')]));_0x56d16e[_0xe149('0x38')](_0x56d16e[_0xe149('0x29')],_0x56d16e[_0xe149('0x2a')],parseInt(_0x56d16e[_0xe149('0x2b')],0xa)+0x1);_0x56d16e['close']();}function handleUnpublished(_0x2a998a){logger[_0xe149('0x31')](util['format'](_0xe149('0x3b'),_0x2a998a[_0xe149('0x1f')]));_0x2a998a[_0xe149('0x38')](_0x2a998a[_0xe149('0x29')],_0x2a998a[_0xe149('0x2a')],parseInt(_0x2a998a[_0xe149('0x2b')],0xa)+0x1);_0x2a998a['close']();}module[_0xe149('0x3c')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize}; \ No newline at end of file diff --git a/server/services/agi/reply.js b/server/services/agi/reply.js new file mode 100644 index 0000000..3fed85e --- /dev/null +++ b/server/services/agi/reply.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe5ec=['Transform','call','prototype','_transform','\x0d\x0a\x0d\x0a','toString','_localBuffer','indexOf','substring','length','split','slice','trim','emit','headers','_inBody','line','exports','util'];(function(_0x1f5895,_0x4e0188){var _0x525e28=function(_0x6bd4dd){while(--_0x6bd4dd){_0x1f5895['push'](_0x1f5895['shift']());}};_0x525e28(++_0x4e0188);}(_0xe5ec,0x1b4));var _0xce5e=function(_0x7762d6,_0x1934b7){_0x7762d6=_0x7762d6-0x0;var _0x2627c3=_0xe5ec[_0x7762d6];return _0x2627c3;};'use strict';var util=require(_0xce5e('0x0'));var Transform=require('stream')[_0xce5e('0x1')];function AGIReply(_0x58542){Transform[_0xce5e('0x2')](this,_0x58542);this['_localBuffer']='';this['_inBody']=![];}util['inherits'](AGIReply,Transform);AGIReply[_0xce5e('0x3')][_0xce5e('0x4')]=function(_0xc9c505,_0xdb1d60,_0x10d862){var _0x538418='\x0a',_0x5f3abe=['\x0a\x0a',_0xce5e('0x5')],_0x2e3d2e=-0x1,_0xf570d8=-0x1,_0x29c26a='',_0x4633e4=0x0,_0x45cf19='',_0x36cdd6='';this['_localBuffer']+=_0xc9c505[_0xce5e('0x6')]();_0x45cf19=this[_0xce5e('0x7')];if(!this['_inBody']){_0x4633e4=0x0;while(_0x5f3abe[_0x4633e4]){while((_0xf570d8=_0x45cf19[_0xce5e('0x8')](_0x5f3abe[_0x4633e4]))!=-0x1){_0x29c26a=_0x5f3abe[_0x4633e4];_0x36cdd6=_0x45cf19[_0xce5e('0x9')](0x0,_0xf570d8);_0x45cf19=_0x45cf19[_0xce5e('0x9')](_0xf570d8+_0x29c26a[_0xce5e('0xa')]);var _0x2fd187=_0x36cdd6[_0xce5e('0xb')](_0x538418),_0x252b69=0x0,_0xcc395={},_0x72e2a9='',_0x1ffff0='',_0x110202=-0x1;while(_0x2fd187[_0x252b69]){_0x110202=_0x2fd187[_0x252b69][_0xce5e('0x8')](':');if(_0x110202!=-0x1){_0x72e2a9=_0x2fd187[_0x252b69][_0xce5e('0xc')](0x0,_0x110202)[_0xce5e('0xd')]();_0x1ffff0=_0x2fd187[_0x252b69][_0xce5e('0xc')](_0x110202+0x1)[_0xce5e('0xd')]();if(_0x72e2a9[_0xce5e('0xa')]>0x0){_0xcc395[_0x72e2a9]=_0x1ffff0;}}else{}_0x252b69++;}this[_0xce5e('0xe')](_0xce5e('0xf'),_0xcc395);this[_0xce5e('0x10')]=!![];}_0x4633e4++;}this[_0xce5e('0x7')]=_0x45cf19;}else{while((_0x2e3d2e=_0x45cf19[_0xce5e('0x8')](_0x538418))!=-0x1){_0x36cdd6=_0x45cf19[_0xce5e('0x9')](0x0,_0x2e3d2e);this['emit'](_0xce5e('0x11'),_0x36cdd6);_0x45cf19=_0x45cf19[_0xce5e('0x9')](_0x2e3d2e+_0x538418['length']);}this[_0xce5e('0x7')]=_0x45cf19;}_0x10d862();};module[_0xce5e('0x12')]=AGIReply; \ No newline at end of file diff --git a/server/services/agi/rpc/index.js b/server/services/agi/rpc/index.js new file mode 100644 index 0000000..b57198d --- /dev/null +++ b/server/services/agi/rpc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4c4e=['agentUnpause','UnpauseUser','lodash','jayson/promise','client','http','then','error','message','result','catch','getSquareProjects','GetSquareProjects','getSquareProject','ShowSquareProject','production','getMailAccountById','MailServerOut','Smtp','CloudProvider','email','getSquareProjectById','name','ShowVoiceQueue','getVariableById','ShowVariable','getSquareOdbcById','ShowSquareOdbc','dsn','getUserById','ShowUser','getContactByPhone','GetContactByPhone','getTrunkById','ShowTrunk','ShowSound','save_name','getIntervalById','ShowInterval','Interval','Intervals','getSmsAccountById','ShowSmsAccount','createSmsMessage','CreateSmsMessage','CreateSquareDetailsReport','merge','arg_2','format','createSquareMessage','createCmContact','ListId','CreateCmContact','getPauseById','agentLogin','LoginUser'];(function(_0xe01acf,_0x3a345a){var _0x2d218e=function(_0x1d03c1){while(--_0x1d03c1){_0xe01acf['push'](_0xe01acf['shift']());}};_0x2d218e(++_0x3a345a);}(_0x4c4e,0x152));var _0xe4c4=function(_0x5960c2,_0x55b471){_0x5960c2=_0x5960c2-0x0;var _0x288092=_0x4c4e[_0x5960c2];return _0x288092;};'use strict';var _=require(_0xe4c4('0x0'));var moment=require('moment');var jayson=require(_0xe4c4('0x1'));var client=jayson[_0xe4c4('0x2')][_0xe4c4('0x3')]({'port':0x2329});function request(_0x58c8f6,_0x1b6c91){return new Promise(function(_0x7d7655,_0x1a4483){return client['request'](_0x58c8f6,_0x1b6c91)[_0xe4c4('0x4')](function(_0x533a68){if(_0x533a68[_0xe4c4('0x5')]){return _0x1a4483(_0x533a68[_0xe4c4('0x5')][_0xe4c4('0x6')]);}else{return _0x7d7655(_0x533a68[_0xe4c4('0x7')]);}})[_0xe4c4('0x8')](function(_0x329d29){return _0x1a4483(_0x329d29);});});}exports[_0xe4c4('0x9')]=function(){return request(_0xe4c4('0xa'),{'options':{'raw':![],'attributes':['id','name','production']}});};exports[_0xe4c4('0xb')]=function(_0x6f2545){return request(_0xe4c4('0xc'),{'options':{'raw':![],'where':{'name':_0x6f2545},'attributes':[_0xe4c4('0xd')]}});};exports[_0xe4c4('0xe')]=function(_0x2f4d5f){return request('ShowMailAccount',{'options':{'raw':![],'where':{'id':_0x2f4d5f},'include':[{'model':_0xe4c4('0xf'),'as':_0xe4c4('0x10'),'include':[{'model':_0xe4c4('0x11'),'as':_0xe4c4('0x11')}]}],'attributes':['id','name',_0xe4c4('0x12')],'smtp':!![]}});};exports[_0xe4c4('0x13')]=function(_0x515056){return request(_0xe4c4('0xc'),{'options':{'where':{'id':_0x515056},'attributes':[_0xe4c4('0x14')]}});};exports['getVoiceQueueById']=function(_0x42ce9e){return request(_0xe4c4('0x15'),{'options':{'where':{'id':_0x42ce9e},'attributes':['name']}});};exports[_0xe4c4('0x16')]=function(_0x465c9b){return request(_0xe4c4('0x17'),{'options':{'where':{'id':_0x465c9b},'attributes':[_0xe4c4('0x14')]}});};exports[_0xe4c4('0x18')]=function(_0x882be2){return request(_0xe4c4('0x19'),{'options':{'where':{'id':_0x882be2},'attributes':[_0xe4c4('0x1a')]}});};exports[_0xe4c4('0x1b')]=function(_0x36b10c){return request(_0xe4c4('0x1c'),{'options':{'where':{'id':_0x36b10c},'attributes':[_0xe4c4('0x14')]}});};exports[_0xe4c4('0x1d')]=function(_0x43a9ce){return request(_0xe4c4('0x1e'),{'options':{'where':{'phone':_0x43a9ce['phone']},'attributes':['id']}});};exports[_0xe4c4('0x1f')]=function(_0x24f946){return request(_0xe4c4('0x20'),{'options':{'where':{'id':_0x24f946},'attributes':[_0xe4c4('0x14')]}});};exports['getSoundById']=function(_0x3d5856){return request(_0xe4c4('0x21'),{'options':{'where':{'id':_0x3d5856},'attributes':[_0xe4c4('0x22')]}});};exports[_0xe4c4('0x23')]=function(_0x2c5aea){return request(_0xe4c4('0x24'),{'options':{'raw':![],'where':{'id':_0x2c5aea},'include':[{'model':_0xe4c4('0x25'),'as':_0xe4c4('0x26')}]}});};exports[_0xe4c4('0x27')]=function(_0x1a7690){return request(_0xe4c4('0x28'),{'options':{'where':{'id':_0x1a7690},'attributes':['id',_0xe4c4('0x14')]}});};exports[_0xe4c4('0x29')]=function(_0x1db719){return request(_0xe4c4('0x2a'),{'body':_0x1db719});};exports['createSquareDetailsReport']=function(_0x49cadc){return request(_0xe4c4('0x2b'),{'body':_0x49cadc});};exports['createSquareReport']=function(_0xf6024d){return request('CreateSquareReport',{'body':_[_0xe4c4('0x2c')](_0xf6024d,{'project_name':_0xf6024d['arg_1'],'prev_project_name':_0xf6024d[_0xe4c4('0x2d')]||'','is_subproject':_0xf6024d['arg_2']?!![]:![],'leaveAt':moment()[_0xe4c4('0x2e')]('YYYY-MM-DD\x20HH:mm:ss')})});};exports['createSquareRecording']=function(_0x4cea1f){return request('CreateSquareRecording',{'body':_0x4cea1f});};exports[_0xe4c4('0x2f')]=function(_0x48cfe0){return request('CreateSquareMessage',{'body':_0x48cfe0});};exports[_0xe4c4('0x30')]=function(_0x11deab){return request('ShowCmHopper',{'options':{'raw':![],'where':{'phone':_0x11deab['phone'],'ListId':_0x11deab[_0xe4c4('0x31')]}}})[_0xe4c4('0x4')](function(_0x4aa6c1){if(_0x4aa6c1){return _0x4aa6c1;}return request(_0xe4c4('0x32'),{'body':_0x11deab});});};exports[_0xe4c4('0x33')]=function(_0x3f60fc){return request('ShowPause',{'options':{'where':{'id':_0x3f60fc},'attributes':['name']}});};exports[_0xe4c4('0x34')]=function(_0x2c5652,_0x12bde8){return request(_0xe4c4('0x35'),{'body':{'interface':_0x12bde8},'options':{'where':_0x2c5652}});};exports['agentPause']=function(_0x49c913,_0x1731c8,_0x2e4282){return request('PauseUser',{'body':{'type':_0x1731c8,'uniqueid':_0x2e4282},'options':{'where':_0x49c913}});};exports[_0xe4c4('0x36')]=function(_0x1ad3e6){return request(_0xe4c4('0x37'),{'body':{},'options':{'where':_0x1ad3e6}});};exports['agentLogout']=function(_0x137f40){return request('LogoutUser',{'body':{},'options':{'where':_0x137f40}});}; \ No newline at end of file diff --git a/server/services/agi/scripts/aws/index.js b/server/services/agi/scripts/aws/index.js new file mode 100644 index 0000000..e62f86d --- /dev/null +++ b/server/services/agi/scripts/aws/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8a5c=['./lex','exports'];(function(_0x3937cb,_0x9677b0){var _0x376a57=function(_0x1f20bd){while(--_0x1f20bd){_0x3937cb['push'](_0x3937cb['shift']());}};_0x376a57(++_0x9677b0);}(_0x8a5c,0x112));var _0xc8a5=function(_0x4399bd,_0x4468e9){_0x4399bd=_0x4399bd-0x0;var _0x29489a=_0x8a5c[_0x4399bd];return _0x29489a;};var polly=require('./polly');var lex=require(_0xc8a5('0x0'));module[_0xc8a5('0x1')]={'polly':polly,'lex':lex}; \ No newline at end of file diff --git a/server/services/agi/scripts/aws/lex/index.js b/server/services/agi/scripts/aws/lex/index.js new file mode 100644 index 0000000..17a9f7b --- /dev/null +++ b/server/services/agi/scripts/aws/lex/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6f7a=['./lib/api','exports'];(function(_0x3a68a8,_0x136d9f){var _0x451461=function(_0x3dde19){while(--_0x3dde19){_0x3a68a8['push'](_0x3a68a8['shift']());}};_0x451461(++_0x136d9f);}(_0x6f7a,0x1ae));var _0xa6f7=function(_0x1f3650,_0x2a809e){_0x1f3650=_0x1f3650-0x0;var _0x16111e=_0x6f7a[_0x1f3650];return _0x16111e;};'use strict';var lex=require(_0xa6f7('0x0'));module[_0xa6f7('0x1')]=function(_0x205e14,_0x982062,_0x4dd99d,_0x93614a,_0x407de3,_0x12ecb8){return lex(_0x205e14,_0x982062,_0x4dd99d,_0x93614a,_0x407de3,_0x12ecb8);}; \ No newline at end of file diff --git a/server/services/agi/scripts/aws/lex/lib/api.js b/server/services/agi/scripts/aws/lex/lib/api.js new file mode 100644 index 0000000..182eec4 --- /dev/null +++ b/server/services/agi/scripts/aws/lex/lib/api.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['LexRuntime','bluebird','aws-sdk','slots','hasOwnProperty'];(function(_0xef6438,_0x2ce72e){var _0x2ebd69=function(_0x2b9c6d){while(--_0x2b9c6d){_0xef6438['push'](_0xef6438['shift']());}};_0x2ebd69(++_0x2ce72e);}(_0xa9e0,0x123));var _0x0a9e=function(_0x3e112d,_0x2bb132){_0x3e112d=_0x3e112d-0x0;var _0x531c31=_0xa9e0[_0x3e112d];return _0x531c31;};'use strict';var BPromise=require(_0x0a9e('0x0'));var AWS=require(_0x0a9e('0x1'));function lexResult(_0x29929c,_0x5dd881){return new BPromise(function(_0x550fbc,_0x18d5c9){_0x29929c['postText'](_0x5dd881,function(_0x333808,_0x432180){if(_0x333808){_0x18d5c9(_0x333808);}if(_0x432180[_0x0a9e('0x2')]){for(const _0x991246 in _0x432180[_0x0a9e('0x2')]){if(_0x432180['slots'][_0x0a9e('0x3')](_0x991246)){var _0x441e3a=_0x432180[_0x0a9e('0x2')][_0x991246];_0x432180['slot_'+_0x991246]=_0x441e3a;}}}_0x550fbc(_0x432180);});});}module['exports']=function(_0xe42b77,_0x56465b,_0x52cace,_0x39753a,_0xf81284,_0x307b3e){var _0x3ab53f=new AWS[(_0x0a9e('0x4'))]({'accessKeyId':_0x56465b,'secretAccessKey':_0x52cace,'region':_0x39753a});var _0xbd1168={'botAlias':'$LATEST','botName':_0x307b3e,'inputText':_0xf81284,'userId':_0xe42b77};return lexResult(_0x3ab53f,_0xbd1168);}; \ No newline at end of file diff --git a/server/services/agi/scripts/aws/polly/index.js b/server/services/agi/scripts/aws/polly/index.js new file mode 100644 index 0000000..af4ae89 --- /dev/null +++ b/server/services/agi/scripts/aws/polly/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6afc=['./lib/api'];(function(_0x1a40df,_0x3cbeb7){var _0x1712ce=function(_0x32b6b5){while(--_0x32b6b5){_0x1a40df['push'](_0x1a40df['shift']());}};_0x1712ce(++_0x3cbeb7);}(_0x6afc,0x1e9));var _0xc6af=function(_0x18c6d5,_0x21cf58){_0x18c6d5=_0x18c6d5-0x0;var _0x235ee9=_0x6afc[_0x18c6d5];return _0x235ee9;};'use strict';var polly=require(_0xc6af('0x0'));module['exports']=function(_0x3d3a5a,_0x3d07b9,_0x458d02,_0x3cd7a9,_0xab52ea,_0x5bde49,_0x1123b6){return polly(_0x3d3a5a,_0x3d07b9,_0x458d02,_0x3cd7a9,_0xab52ea,_0x5bde49,_0x1123b6);}; \ No newline at end of file diff --git a/server/services/agi/scripts/aws/polly/lib/api.js b/server/services/agi/scripts/aws/polly/lib/api.js new file mode 100644 index 0000000..2cb9888 --- /dev/null +++ b/server/services/agi/scripts/aws/polly/lib/api.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3554=['bluebird','randomstring','synthesizeSpeech','AudioStream','writeFile','Polly','text','mp3','path'];(function(_0x59eefb,_0x2151ce){var _0x1a49e8=function(_0x5a758c){while(--_0x5a758c){_0x59eefb['push'](_0x59eefb['shift']());}};_0x1a49e8(++_0x2151ce);}(_0x3554,0x1ee));var _0x4355=function(_0x2edf63,_0x1f9dd8){_0x2edf63=_0x2edf63-0x0;var _0x20f865=_0x3554[_0x2edf63];return _0x20f865;};'use strict';var fs=require('fs');var path=require(_0x4355('0x0'));var BPromise=require(_0x4355('0x1'));var rs=require(_0x4355('0x2'));var AWS=require('aws-sdk');function pollyResult(_0x31c841,_0x9c851a,_0x1fd434){return new BPromise(function(_0x2b1f63,_0x29772c){_0x31c841[_0x4355('0x3')](_0x9c851a,function(_0x11a2de,_0x59ea96){if(_0x11a2de){_0x29772c(_0x11a2de);}else if(_0x59ea96){if(_0x59ea96[_0x4355('0x4')]instanceof Buffer){fs[_0x4355('0x5')](_0x1fd434,_0x59ea96['AudioStream'],function(_0x44e6df){if(_0x44e6df){_0x29772c(_0x44e6df);}else{_0x2b1f63();}});}else{_0x29772c(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x29772c(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module['exports']=function(_0x2319a2,_0x5019ff,_0x3322bf,_0x529153,_0x243fe0,_0x1f4572,_0x5a4455){var _0x57131e=new AWS[(_0x4355('0x6'))]({'accessKeyId':_0x2319a2,'secretAccessKey':_0x5019ff,'region':_0x3322bf});var _0x44d565={'Text':_0x243fe0,'TextType':_0x1f4572||_0x4355('0x7'),'OutputFormat':_0x4355('0x8'),'VoiceId':_0x529153};return pollyResult(_0x57131e,_0x44d565,_0x5a4455);}; \ No newline at end of file diff --git a/server/services/agi/scripts/google/asr/index.js b/server/services/agi/scripts/google/asr/index.js new file mode 100644 index 0000000..fd6ffa3 --- /dev/null +++ b/server/services/agi/scripts/google/asr/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3ed3=['exports'];(function(_0x4f7418,_0x1755cc){var _0x4afe7e=function(_0x5ae646){while(--_0x5ae646){_0x4f7418['push'](_0x4f7418['shift']());}};_0x4afe7e(++_0x1755cc);}(_0x3ed3,0x162));var _0x33ed=function(_0x3f6f3c,_0x323d8a){_0x3f6f3c=_0x3f6f3c-0x0;var _0x4b84bb=_0x3ed3[_0x3f6f3c];return _0x4b84bb;};'use strict';var asr=require('./lib/api');module[_0x33ed('0x0')]=function(_0x48ded1,_0xf3518c,_0x1f4c20,_0x154dfe){return asr(_0x48ded1,_0xf3518c,_0x1f4c20);}; \ No newline at end of file diff --git a/server/services/agi/scripts/google/asr/lib/api.js b/server/services/agi/scripts/google/asr/lib/api.js new file mode 100644 index 0000000..5271f7d --- /dev/null +++ b/server/services/agi/scripts/google/asr/lib/api.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x66fa=['length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','string'];(function(_0x38ce4c,_0xfdbe8c){var _0x5d4544=function(_0x503537){while(--_0x503537){_0x38ce4c['push'](_0x38ce4c['shift']());}};_0x5d4544(++_0xfdbe8c);}(_0x66fa,0x168));var _0xa66f=function(_0x5b1b1a,_0x296663){_0x5b1b1a=_0x5b1b1a-0x0;var _0x3a01e5=_0x66fa[_0x5b1b1a];return _0x3a01e5;};'use strict';var url=require(_0xa66f('0x0'));var BPromise=require(_0xa66f('0x1'));var fs=require('fs');var host=_0xa66f('0x2');module['exports']=function(_0x4a6840,_0x3dc747,_0x2325d7){return new BPromise(function(_0x3aaeff,_0x2e663b){var _0x2143e6;if(typeof _0x4a6840!==_0xa66f('0x3')||_0x4a6840[_0xa66f('0x4')]===0x0){return _0x2e663b(_0xa66f('0x5'));}if(typeof _0x3dc747!==_0xa66f('0x3')||_0x3dc747[_0xa66f('0x4')]===0x0){return _0x2e663b(_0xa66f('0x6'));}if(typeof _0x2325d7!=='undefined'&&(typeof _0x2325d7!==_0xa66f('0x3')||_0x2325d7['length']===0x0)){return _0x2e663b(_0xa66f('0x7'));}try{_0x2143e6=fs[_0xa66f('0x8')](_0x4a6840)['toString'](_0xa66f('0x9'));}catch(_0x32dc03){return _0x2e663b(_0x32dc03);}return _0x3aaeff({'method':_0xa66f('0xa'),'uri':host+_0xa66f('0xb')+_0x3dc747,'body':{'config':{'encoding':_0xa66f('0xc'),'sampleRateHertz':_0xa66f('0xd'),'languageCode':_0x2325d7},'audio':{'content':_0x2143e6}},'json':!![]});});}; \ No newline at end of file diff --git a/server/services/agi/scripts/google/index.js b/server/services/agi/scripts/google/index.js new file mode 100644 index 0000000..dbeb934 --- /dev/null +++ b/server/services/agi/scripts/google/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x993c=['exports','./asr'];(function(_0x278d83,_0x293390){var _0x2853d2=function(_0x4346f1){while(--_0x4346f1){_0x278d83['push'](_0x278d83['shift']());}};_0x2853d2(++_0x293390);}(_0x993c,0x16b));var _0xc993=function(_0x5e1b2d,_0x34cfb8){_0x5e1b2d=_0x5e1b2d-0x0;var _0x27dff8=_0x993c[_0x5e1b2d];return _0x27dff8;};var asr=require(_0xc993('0x0'));module[_0xc993('0x1')]={'asr':asr}; \ No newline at end of file diff --git a/server/services/agi/scripts/index.js b/server/services/agi/scripts/index.js new file mode 100644 index 0000000..2065c3d --- /dev/null +++ b/server/services/agi/scripts/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x85db=['status','code','metadata','endConversation','googleDialogflowV2','replace','SessionsClient','detectIntent','Dialogflow\x20V2\x20response:','queryResult','action','allRequiredParamsPresent','diagnosticInfo','fields','end_conversation','boolValue','intent','displayName','languageCode','queryText','responseId','intentDetectionConfidence','fulfillmentText','Tilde\x20ASR\x20confidence','polly','awsLex','lex','ispeechTTS','format','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','model=%s','freeform=3','nda','text','channelData','AudioFromTts','Data','dirName','apiai-promise','dialogflow','http','https','md5','path','querystring','request-promise','randomstring','url','parse','./aws','./google','./sestek','./tilde','../../../config/logger','agi','https://api.ispeech.org/api/rest','protocol','host','WHAT_EVER','get','statusCode','error','request\x20to\x20','statusMessage','\x20failed,\x20status\x20code\x20=\x20','createWriteStream','info','finish\x20download\x20file','pipe','end','https:','transcode','wav','start','resolve','generate','.wav','base64','then','unlink','chmodSync','split','https://texttospeech.googleapis.com/v1/','?key=','ssml','input','MP3','text:synthesize','tmp','.mp3','from','writeFile','777','googleTTS','https://translate.google.com/_/TranslateWebserverUi/data/batchexecute','utf8','POST','f.req=','jQ1olc','stringify','generic','parse\x20response\x20failed:\x0a','data','length','\x22\x20might\x20not\x20exist','writeFileSync','goggleTTS\x20path','googleASR','asr','results','map','alternatives','transcript','join','confidence','googleASR\x20transcription','googleASR\x20confidence','catch','message','result','source','resolvedQuery','actionIncomplete','fulfillment','speech','score'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x85db,0xa6));var _0xb85d=function(_0x344a3f,_0x579a22){_0x344a3f=_0x344a3f-0x0;var _0x264712=_0x85db[_0x344a3f];return _0x264712;};'use strict';var apiai=require(_0xb85d('0x0'));var BPromise=require('bluebird');var dialogflow=require(_0xb85d('0x1'));var fs=require('fs');var http=require(_0xb85d('0x2'));var https=require(_0xb85d('0x3'));var md5=require(_0xb85d('0x4'));var path=require(_0xb85d('0x5'));var querystring=require(_0xb85d('0x6'));var rp=require(_0xb85d('0x7'));var rs=require(_0xb85d('0x8'));var sox=require('sox');var tts=require('google-tts-api');var urlParse=require(_0xb85d('0x9'))[_0xb85d('0xa')];var util=require('util');var aws=require(_0xb85d('0xb'));var google=require(_0xb85d('0xc'));var sestek=require(_0xb85d('0xd'));var tilde=require(_0xb85d('0xe'));var logger=require(_0xb85d('0xf'))(_0xb85d('0x10'));var ISPEECH_API=_0xb85d('0x11');function downloadFile(_0x1cd8a4,_0x30c310){return new BPromise(function(_0x578b3d,_0xd640e1){var _0xbae064=urlParse(_0x1cd8a4);var _0x5f48aa=_0xbae064[_0xb85d('0x12')]==='https:'?https:http;var _0x22024b={'host':_0xbae064[_0xb85d('0x13')],'path':_0xbae064[_0xb85d('0x5')],'headers':{'user-agent':_0xb85d('0x14')}};_0x5f48aa[_0xb85d('0x15')](_0x22024b,function(_0x2ca120){if(_0x2ca120[_0xb85d('0x16')]!==0xc8){logger[_0xb85d('0x17')](_0xb85d('0x18')+_0x1cd8a4+'\x20failed,\x20status\x20code\x20=\x20'+_0x2ca120[_0xb85d('0x16')]+'\x20('+_0x2ca120[_0xb85d('0x19')]+')');_0xd640e1(new Error(_0xb85d('0x18')+_0x1cd8a4+_0xb85d('0x1a')+_0x2ca120[_0xb85d('0x16')]+'\x20('+_0x2ca120[_0xb85d('0x19')]+')'));return;}var _0x464548=fs[_0xb85d('0x1b')](_0x30c310);_0x464548['on']('finish',function(){logger[_0xb85d('0x1c')](_0xb85d('0x1d'));_0x464548['close'](_0x578b3d);});_0x464548['on'](_0xb85d('0x17'),function(_0x1bc67d){fs['unlink'](_0x30c310);logger[_0xb85d('0x17')]('download\x20error',_0x1bc67d);_0xd640e1(_0x1bc67d);});_0x2ca120[_0xb85d('0x1e')](_0x464548);})['on'](_0xb85d('0x17'),function(_0x281f3c){logger['error'](_0x281f3c);_0xd640e1(_0x281f3c);})[_0xb85d('0x1f')]();});}function uploadFile(_0x1158be){return new BPromise(function(_0x4acc61,_0xb4fe37){var _0x45204d=urlParse(_0x1158be);var _0x444a92=_0x45204d[_0xb85d('0x12')]===_0xb85d('0x20')?https:http;var _0x5e8b04={'host':_0x45204d['host'],'path':_0x45204d[_0xb85d('0x5')],'headers':{'user-agent':_0xb85d('0x14')}};_0x444a92[_0xb85d('0x15')](_0x5e8b04,function(_0x140d1a){if(_0x140d1a['statusCode']!==0xc8){_0xb4fe37(new Error(_0xb85d('0x18')+_0x1158be+_0xb85d('0x1a')+_0x140d1a['statusCode']+'\x20('+_0x140d1a[_0xb85d('0x19')]+')'));return;}var _0x1aaf4a='';_0x140d1a['on']('data',function(_0x8e7625){_0x1aaf4a+=_0x8e7625;});_0x140d1a['on'](_0xb85d('0x1f'),function(){_0x4acc61(_0x1aaf4a);});})['on'](_0xb85d('0x17'),function(_0x3425d4){_0xb4fe37(_0x3425d4);})['end']();});}function convertFile(_0x530665,_0x381812){return new BPromise(function(_0x5e50e3,_0x2751c0){var _0x3e94c4=sox[_0xb85d('0x21')](_0x530665,_0x381812,{'sampleRate':0x1f40,'format':_0xb85d('0x22'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x3e94c4['on'](_0xb85d('0x17'),function(_0x58e46b){logger['error']('error\x20convert',_0x58e46b);_0x2751c0(_0x58e46b);});_0x3e94c4['on'](_0xb85d('0x1f'),function(){logger[_0xb85d('0x1c')]('finish\x20to\x20convert');_0x5e50e3();});_0x3e94c4[_0xb85d('0x23')]();});}function base64Decode(_0x341d54,_0x32cae0){var _0x44a5be=path[_0xb85d('0x24')](__dirname,'tmp',rs[_0xb85d('0x25')](0x4)+_0xb85d('0x26'));fs['writeFileSync'](_0x44a5be,_0x341d54,_0xb85d('0x27'));return convertFile(_0x44a5be,_0x32cae0)[_0xb85d('0x28')](function(){try{fs[_0xb85d('0x29')](_0x44a5be);fs[_0xb85d('0x2a')](_0x32cae0,'777');}catch(_0x3bfec2){logger[_0xb85d('0x17')](_0x3bfec2);}return _0x32cae0[_0xb85d('0x2b')]('.')[0x0];});}function base64Encode(_0x5e480e){var _0x34210a=fs['readFileSync'](_0x5e480e);return new Buffer(_0x34210a)['toString']('base64');}exports['googleCloudTTS']=function(_0x572393,_0x25d89a,_0x3fec7e,_0x5201ca,_0x31a763,_0x206016){var _0x3de617,_0xb55e0a;var _0x13479f=_0xb85d('0x2c');var _0x13372a=_0xb85d('0x2d')+_0x572393;var _0x267c1f={};if(_0x25d89a===_0xb85d('0x2e')){_0x267c1f[_0xb85d('0x2f')]={'ssml':_0x3fec7e};}else{_0x267c1f[_0xb85d('0x2f')]={'text':_0x3fec7e};};_0x267c1f['voice']={'languageCode':_0x5201ca,'ssmlGender':_0x31a763};_0x267c1f['audioConfig']={'audioEncoding':_0xb85d('0x30'),'sampleRateHertz':0x1f40};var _0x46733f={'url':_0x13479f+_0xb85d('0x31')+_0x13372a,'method':'POST','json':!![],'body':_0x267c1f};return rp(_0x46733f)['then'](function(_0x611a5e){return new BPromise(function(_0x2f7df5,_0x5003ef){_0x3de617=path[_0xb85d('0x24')](__dirname,_0xb85d('0x32'),rs['generate'](0x4)+_0xb85d('0x33'));var _0x5e12bd=Buffer[_0xb85d('0x34')](_0x611a5e['audioContent'],'base64');return fs[_0xb85d('0x35')](_0x3de617,_0x5e12bd,function(_0x5325c0){_0x5003ef(_0x5325c0);},function(_0x4b4b15){fs[_0xb85d('0x2a')](_0x3de617,_0xb85d('0x36'));_0x2f7df5(_0x4b4b15);});});})[_0xb85d('0x28')](function(_0x44be19){_0xb55e0a=path[_0xb85d('0x24')](__dirname,'tmp',rs[_0xb85d('0x25')](0x4)+'.wav');return convertFile(_0x3de617,_0xb55e0a);})[_0xb85d('0x28')](function(){try{fs[_0xb85d('0x29')](_0x3de617);fs[_0xb85d('0x2a')](_0xb55e0a,'777');}catch(_0x2faebb){logger[_0xb85d('0x17')](_0x2faebb);}logger[_0xb85d('0x1c')]('googleCloudTTS\x20path',_0xb55e0a[_0xb85d('0x2b')]('.')[0x0]);return _0xb55e0a[_0xb85d('0x2b')]('.')[0x0];});};exports[_0xb85d('0x37')]=function(_0x5302e6,_0x5ade9a){var _0x15cba5=_0xb85d('0x38');var _0x129f74,_0x17fd15;var _0x15c50b;var _0x47a91d={'encoding':_0xb85d('0x39'),'method':_0xb85d('0x3a'),'timeout':0x2710,'url':_0x15cba5,'headers':{'Content-Type':'application/x-www-form-urlencoded'},'body':_0xb85d('0x3b')+encodeURIComponent(JSON['stringify']([[[_0xb85d('0x3c'),JSON[_0xb85d('0x3d')]([_0x5302e6,_0x5ade9a||'en',![],'null']),null,_0xb85d('0x3e')]]]))};return rp(_0x47a91d)[_0xb85d('0x28')](function(_0x17e9c9){try{_0x15c50b=eval(_0x17e9c9['slice'](0x5))[0x0][0x2];}catch(_0x1fe52c){throw new Error(_0xb85d('0x3f')+_0x17e9c9[_0xb85d('0x40')]);}if(!_0x15c50b){if(_0x5302e6[_0xb85d('0x41')]>0xc8){throw new Error('text\x20length\x20limit\x20reached');}else{throw new Error('lang\x20\x22'+_0x5ade9a+_0xb85d('0x42'));}}try{_0x15c50b=eval(_0x15c50b)[0x0];}catch(_0x12c4be){throw new Error(_0xb85d('0x3f')+res[_0xb85d('0x40')]);}const _0x4f9043=_0x15c50b;_0x129f74=path['resolve'](__dirname,_0xb85d('0x32'),rs[_0xb85d('0x25')](0x4)+'.mp3');fs[_0xb85d('0x43')](_0x129f74,_0x15c50b,{'encoding':_0xb85d('0x27')});_0x17fd15=path['resolve'](__dirname,'tmp',rs[_0xb85d('0x25')](0x4)+_0xb85d('0x26'));return convertFile(_0x129f74,_0x17fd15);})[_0xb85d('0x28')](function(){try{fs[_0xb85d('0x29')](_0x129f74);fs['chmodSync'](_0x17fd15,_0xb85d('0x36'));}catch(_0x282b58){logger[_0xb85d('0x17')](_0x282b58);}logger[_0xb85d('0x1c')](_0xb85d('0x44'),_0x17fd15[_0xb85d('0x2b')]('.')[0x0]);return _0x17fd15[_0xb85d('0x2b')]('.')[0x0];});};exports[_0xb85d('0x45')]=function(_0x272d92,_0x23d36e,_0x4161ec){return google[_0xb85d('0x46')](_0x272d92,_0x23d36e,_0x4161ec)[_0xb85d('0x28')](function(_0x2efc2e){logger[_0xb85d('0x1c')](_0x2efc2e['uri']);return rp(_0x2efc2e);})[_0xb85d('0x28')](function(_0x31d934){var _0x529d46='';var _0x113e09=0x0;try{fs[_0xb85d('0x29')](_0x272d92);}catch(_0x256bd1){logger[_0xb85d('0x17')](_0x256bd1);}if(_0x31d934&&_0x31d934[_0xb85d('0x47')]){_0x529d46=_0x31d934[_0xb85d('0x47')][_0xb85d('0x48')](function(_0x4e0d04){return _0x4e0d04&&_0x4e0d04[_0xb85d('0x49')][0x0]&&_0x4e0d04[_0xb85d('0x49')][0x0][_0xb85d('0x4a')]?_0x4e0d04[_0xb85d('0x49')][0x0][_0xb85d('0x4a')]:'';})[_0xb85d('0x4b')]('\x0a');_0x113e09=_0x31d934[_0xb85d('0x47')][_0xb85d('0x48')](function(_0x6cfd6f){return _0x6cfd6f&&_0x6cfd6f[_0xb85d('0x49')][0x0]&&_0x6cfd6f['alternatives'][0x0][_0xb85d('0x4c')]?_0x6cfd6f[_0xb85d('0x49')][0x0]['confidence']:0x0;})[_0xb85d('0x4b')]('\x0a');}logger['info'](_0xb85d('0x4d'),_0x529d46);logger[_0xb85d('0x1c')](_0xb85d('0x4e'),_0x113e09);return{'transcript':_0x529d46,'confidence':_0x113e09};})[_0xb85d('0x4f')](function(_0x4e8d9a){logger[_0xb85d('0x17')]('[%s]\x20%s:%s',_0x4e8d9a[_0xb85d('0x16')],_0x4e8d9a['name'],_0x4e8d9a[_0xb85d('0x50')]);});};exports['googleDialogflow']=function(_0x1ade5e,_0x222555,_0x132e05,_0xda200d){var _0x19e402=apiai(_0x222555,{'language':_0xda200d||'en'});return _0x19e402['textRequest'](_0x132e05,{'sessionId':md5(_0x1ade5e)})[_0xb85d('0x28')](function(_0x31b559){logger['info'](JSON[_0xb85d('0x3d')](_0x31b559));return{'source':_0x31b559[_0xb85d('0x51')][_0xb85d('0x52')],'resolvedQuery':_0x31b559[_0xb85d('0x51')][_0xb85d('0x53')],'action':_0x31b559[_0xb85d('0x51')]['action'],'actionIncomplete':_0x31b559[_0xb85d('0x51')][_0xb85d('0x54')],'speech':_0x31b559[_0xb85d('0x51')][_0xb85d('0x55')][_0xb85d('0x56')],'score':_0x31b559[_0xb85d('0x51')][_0xb85d('0x57')],'statusCode':_0x31b559[_0xb85d('0x58')][_0xb85d('0x59')],'endConversation':_0x31b559[_0xb85d('0x51')][_0xb85d('0x5a')][_0xb85d('0x5b')]||![],'isFallbackIntent':_0x31b559[_0xb85d('0x51')][_0xb85d('0x5a')]['isFallbackIntent']};});};exports[_0xb85d('0x5c')]=function(_0x5bf743,_0x200273,_0x3b5628,_0x4591ea,_0x3bd5be,_0x1a134c){var _0x48ac75=_0x4591ea[_0xb85d('0x5d')](/\\n/g,'\x0a');var _0x2389ee={'credentials':{'private_key':_0x48ac75,'client_email':_0x3b5628}};var _0x5e5af7=new dialogflow[(_0xb85d('0x5e'))](_0x2389ee);var _0x47c8d1=_0x5e5af7['sessionPath'](_0x200273,md5(_0x5bf743));var _0x34c794={'session':_0x47c8d1,'queryInput':{'text':{'text':_0x3bd5be,'languageCode':_0x1a134c}}};return _0x5e5af7[_0xb85d('0x5f')](_0x34c794)['then'](function(_0x19024f){if(_0x19024f&&_0x19024f[_0xb85d('0x41')]){logger[_0xb85d('0x1c')](_0xb85d('0x60'),JSON[_0xb85d('0x3d')](_0x19024f));var _0x93fd04=_0x19024f[0x0];if(_0x93fd04){var _0x7642bd={'action':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x62')],'allRequiredParamsPresent':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x63')],'endConversation':_0x93fd04['queryResult'][_0xb85d('0x64')]&&_0x93fd04[_0xb85d('0x61')][_0xb85d('0x64')]['fields']?_0x93fd04[_0xb85d('0x61')][_0xb85d('0x64')][_0xb85d('0x65')][_0xb85d('0x66')][_0xb85d('0x67')]:![],'fulfillmentText':_0x93fd04[_0xb85d('0x61')]['fulfillmentText'],'intentName':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x68')]['name'],'intentDisplayName':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x68')][_0xb85d('0x69')],'isFallbackIntent':_0x93fd04['queryResult'][_0xb85d('0x68')]['isFallback'],'languageCode':_0x93fd04['queryResult'][_0xb85d('0x6a')],'queryText':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x6b')],'responseId':_0x93fd04[_0xb85d('0x6c')],'score':_0x93fd04[_0xb85d('0x61')][_0xb85d('0x6d')],'speech':_0x93fd04['queryResult'][_0xb85d('0x6e')],'providerResponse':JSON[_0xb85d('0x3d')](_0x19024f)};return _0x7642bd;}}});};exports['tildeASR']=function(_0x325312,_0x19b970,_0x374b9f,_0x8c612f){return tilde[_0xb85d('0x46')](_0x325312,_0x19b970,_0x374b9f,_0x8c612f)[_0xb85d('0x28')](function(_0x15eb8d){try{fs[_0xb85d('0x29')](_0x325312);}catch(_0x4379f2){logger[_0xb85d('0x17')](_0x4379f2);}logger['info']('Tilde\x20ASR\x20transcription',_0x15eb8d[_0xb85d('0x4a')]);logger[_0xb85d('0x1c')](_0xb85d('0x6f'),_0x15eb8d[_0xb85d('0x4c')]);return _0x15eb8d;});};exports['awsPolly']=function(_0xcd75c7,_0x397a92,_0xb45583,_0x2428d1,_0x5a9a3c,_0x4dfd5d){var _0x34daf5=path[_0xb85d('0x24')](__dirname,_0xb85d('0x32'),rs[_0xb85d('0x25')](0x4)+_0xb85d('0x33'));var _0x3221a5;return aws[_0xb85d('0x70')](_0xcd75c7,_0x397a92,_0xb45583,_0x2428d1,_0x5a9a3c,_0x4dfd5d,_0x34daf5)[_0xb85d('0x28')](function(){_0x3221a5=path['resolve'](__dirname,_0xb85d('0x32'),rs[_0xb85d('0x25')](0x4)+'.wav');return convertFile(_0x34daf5,_0x3221a5);})[_0xb85d('0x28')](function(){try{fs[_0xb85d('0x29')](_0x34daf5);fs['chmodSync'](_0x3221a5,_0xb85d('0x36'));}catch(_0x4303ff){logger[_0xb85d('0x17')](_0x4303ff);}return _0x3221a5[_0xb85d('0x2b')]('.')[0x0];});};exports[_0xb85d('0x71')]=function(_0x251cf2,_0x46e3df,_0x4e5b94,_0x2ff5e8,_0x32b8d2,_0x10c1bd){return aws[_0xb85d('0x72')](_0x251cf2,_0x46e3df,_0x4e5b94,_0x2ff5e8,_0x32b8d2,_0x10c1bd)[_0xb85d('0x28')](function(_0x5bde9e){logger[_0xb85d('0x1c')](JSON[_0xb85d('0x3d')](_0x5bde9e));return _0x5bde9e;});};exports[_0xb85d('0x73')]=function(_0x44b704,_0x13be76,_0x4e538f,_0x3d4045){var _0x1cc93b=util[_0xb85d('0x74')](_0xb85d('0x75'),ISPEECH_API,_0x44b704,encodeURIComponent(_0x13be76),_0x4e538f,_0x3d4045);var _0x19fe8d=path[_0xb85d('0x24')](__dirname,_0xb85d('0x32'),rs[_0xb85d('0x25')](0x4)+_0xb85d('0x33'));var _0x537ddb;return downloadFile(_0x1cc93b,_0x19fe8d)[_0xb85d('0x28')](function(){_0x537ddb=path[_0xb85d('0x24')](__dirname,_0xb85d('0x32'),rs['generate'](0x4)+_0xb85d('0x26'));return convertFile(_0x19fe8d,_0x537ddb);})['then'](function(){try{fs['unlink'](_0x19fe8d);fs[_0xb85d('0x2a')](_0x537ddb,_0xb85d('0x36'));}catch(_0x12bf51){logger[_0xb85d('0x17')](_0x12bf51);}return _0x537ddb[_0xb85d('0x2b')]('.')[0x0];});};exports['ispeechASR']=function(_0x1f5126,_0x39f076,_0x3bb5a9,_0x1570a1){var _0x23561a=util['format'](_0xb85d('0x76'),ISPEECH_API,_0x39f076,_0x3bb5a9,base64Encode(_0x1f5126),_0x1570a1?util['format'](_0xb85d('0x77'),encodeURIComponent(_0x1570a1)):_0xb85d('0x78'));return uploadFile(_0x23561a)['then'](function(_0x2ccb96){return querystring['parse'](_0x2ccb96);});};exports['sestekNDA']=function(_0x21723c,_0x1ee83b){return sestek[_0xb85d('0x79')](_0x21723c,_0x1ee83b)[_0xb85d('0x28')](function(_0x54de66){logger[_0xb85d('0x1c')](JSON[_0xb85d('0x3d')](_0x54de66));var _0x49e68a={'speech':_0x54de66[_0xb85d('0x7a')],'action':_0x54de66[_0xb85d('0x7b')]?_0x54de66[_0xb85d('0x7b')]['CustomAction']:undefined,'actiondata':_0x54de66['channelData']?_0x54de66['channelData']['CustomActionData']:undefined};if(_0x54de66['channelData']&&_0x54de66[_0xb85d('0x7b')][_0xb85d('0x7c')]){return base64Decode(_0x54de66[_0xb85d('0x7b')][_0xb85d('0x7c')][_0xb85d('0x7d')],path[_0xb85d('0x24')](__dirname,_0xb85d('0x32'),rs[_0xb85d('0x25')](0x4)+_0xb85d('0x26')))[_0xb85d('0x28')](function(_0xaa5857){_0x49e68a['audiofile']=_0xaa5857;return _0x49e68a;});}return _0x49e68a;});};exports[_0xb85d('0x7e')]=function(){return __dirname;}; \ No newline at end of file diff --git a/server/services/agi/scripts/sestek/index.js b/server/services/agi/scripts/sestek/index.js new file mode 100644 index 0000000..240fb8d --- /dev/null +++ b/server/services/agi/scripts/sestek/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbf22=['exports'];(function(_0x2e7a9d,_0xd42e55){var _0x51ab1b=function(_0x1fad3a){while(--_0x1fad3a){_0x2e7a9d['push'](_0x2e7a9d['shift']());}};_0x51ab1b(++_0xd42e55);}(_0xbf22,0xc4));var _0x2bf2=function(_0x53d3fd,_0x9d9fb0){_0x53d3fd=_0x53d3fd-0x0;var _0x1f6f7e=_0xbf22[_0x53d3fd];return _0x1f6f7e;};var nda=require('./nda');module[_0x2bf2('0x0')]={'nda':nda}; \ No newline at end of file diff --git a/server/services/agi/scripts/sestek/nda/index.js b/server/services/agi/scripts/sestek/nda/index.js new file mode 100644 index 0000000..803a8a4 --- /dev/null +++ b/server/services/agi/scripts/sestek/nda/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xee4e=['then','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','message','uniqueid','calleridname','dnid','extension','Bearer\x20','access_token','project','body','ndagenerate_audio','channelData','AudioOutputSettings','CustomAction','custom_action','custom_action_data','CustomActionData','info','request-promise','url','../../../../../config/logger','exports','POST','resolve','ndauth_url','/token','username','password'];(function(_0x5aca71,_0x583dfa){var _0x375f79=function(_0x3b2d5e){while(--_0x3b2d5e){_0x5aca71['push'](_0x5aca71['shift']());}};_0x375f79(++_0x583dfa);}(_0xee4e,0x122));var _0xeee4=function(_0x122096,_0x60c295){_0x122096=_0x122096-0x0;var _0x3d1966=_0xee4e[_0x122096];return _0x3d1966;};'use strict';var rp=require(_0xeee4('0x0'));var url=require(_0xeee4('0x1'));var logger=require(_0xeee4('0x2'))('agi');module[_0xeee4('0x3')]=function(_0x827900,_0x33e574){var _0xea0952={'method':_0xeee4('0x4'),'uri':url[_0xeee4('0x5')](_0x33e574[_0xeee4('0x6')],_0xeee4('0x7')),'form':{'grant_type':'password','username':_0x33e574[_0xeee4('0x8')],'password':_0x33e574[_0xeee4('0x9')]},'json':!![]};return rp(_0xea0952)[_0xeee4('0xa')](function(_0x593262){var _0x25f0ed={'method':_0xeee4('0x4'),'uri':url[_0xeee4('0x5')](_0x33e574['ndassistant_url'],_0xeee4('0xb')),'body':{'type':_0x33e574[_0xeee4('0xc')]||_0xeee4('0xd'),'channelId':'Nda','conversation':{'id':_0x827900[_0xeee4('0xe')]},'from':{'id':_0x827900['callerid'],'name':_0x827900[_0xeee4('0xf')]},'recipient':{'id':_0x827900[_0xeee4('0x10')],'name':_0x827900[_0xeee4('0x11')]},'text':_0x33e574['text'],'channelData':{}},'headers':{'Authorization':_0xeee4('0x12')+_0x593262[_0xeee4('0x13')]},'json':!![]};if(_0x33e574[_0xeee4('0x14')]){_0x25f0ed[_0xeee4('0x15')]['channelData']['ProjectName']=_0x33e574[_0xeee4('0x14')];}if(_0x33e574[_0xeee4('0x16')]=='1'){_0x25f0ed[_0xeee4('0x15')][_0xeee4('0x17')][_0xeee4('0x18')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x33e574['custom_action']){_0x25f0ed[_0xeee4('0x15')][_0xeee4('0x17')][_0xeee4('0x19')]=_0x33e574[_0xeee4('0x1a')];if(_0x33e574[_0xeee4('0x1b')]){_0x25f0ed[_0xeee4('0x15')]['channelData'][_0xeee4('0x1c')]=_0x33e574['custom_action_data'];}}logger[_0xeee4('0x1d')](JSON['stringify'](_0x25f0ed));return rp(_0x25f0ed);});}; \ No newline at end of file diff --git a/server/services/agi/scripts/tilde/asr/index.js b/server/services/agi/scripts/tilde/asr/index.js new file mode 100644 index 0000000..0863ff7 --- /dev/null +++ b/server/services/agi/scripts/tilde/asr/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0c98=['./lib/api'];(function(_0x465c5e,_0x4b938e){var _0x55d352=function(_0x1889ee){while(--_0x1889ee){_0x465c5e['push'](_0x465c5e['shift']());}};_0x55d352(++_0x4b938e);}(_0x0c98,0x19e));var _0x80c9=function(_0x237a42,_0x4a98ca){_0x237a42=_0x237a42-0x0;var _0x3097e4=_0x0c98[_0x237a42];return _0x3097e4;};'use strict';var asr=require(_0x80c9('0x0'));module['exports']=function(_0x1e5b4f,_0x1ae5ca,_0x2d6f61,_0x4d51e6){return asr(_0x1e5b4f,_0x1ae5ca,_0x2d6f61,_0x4d51e6);}; \ No newline at end of file diff --git a/server/services/agi/scripts/tilde/asr/lib/api.js b/server/services/agi/scripts/tilde/asr/lib/api.js new file mode 100644 index 0000000..1809b13 --- /dev/null +++ b/server/services/agi/scripts/tilde/asr/lib/api.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x275f=['moment','crypto','exports','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','update','digest','info','Open\x20Tilde\x20ASR\x20socket','unix','send','stringify','createReadStream','data','EOS','error','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','likelihood','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','Not\x20available.\x20Max\x20load\x20limit\x20reached.','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','Tilde\x20ASR\x20parse\x20error','Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','isObject','open','message','close','bluebird'];(function(_0x1ebe5b,_0x22fbb5){var _0x3f47af=function(_0xa58097){while(--_0xa58097){_0x1ebe5b['push'](_0x1ebe5b['shift']());}};_0x3f47af(++_0x22fbb5);}(_0x275f,0x1bb));var _0xf275=function(_0x1488cd,_0x25a893){_0x1488cd=_0x1488cd-0x0;var _0x63fa13=_0x275f[_0x1488cd];return _0x63fa13;};'use strict';var BPromise=require(_0xf275('0x0'));var _=require('lodash');var fs=require('fs');var WebSocket=require('ws');var moment=require(_0xf275('0x1'));var crypto=require(_0xf275('0x2'));var logger=require('../../../../../../config/logger')('agi');module[_0xf275('0x3')]=function(_0x5f5c81,_0x240ad2,_0x3aef66,_0x18f7eb){return new BPromise(function(_0x58a9a2,_0x10e277){logger['info']('Tilde\x20URI',_0x18f7eb||_0xf275('0x4'));var _0x399f1f=new WebSocket(_0x18f7eb||_0xf275('0x4'),{'perMessageDeflate':![]});var _0x3ee0a1='';var _0x247caf='0';var _0x11943e='1';var _0x536b68=_0xf275('0x5');function _0x140cd1(_0x5d3dc8){var _0x42426b=crypto['createHash']('sha1');_0x42426b[_0xf275('0x6')](_0x5d3dc8);return _0x42426b[_0xf275('0x7')]('hex');}function _0x4b5334(){try{logger[_0xf275('0x8')](_0xf275('0x9'));var _0x2322da=moment()[_0xf275('0xa')]();var _0x318fda=_0x140cd1(_0x2322da+_0x240ad2+_0x3aef66);_0x399f1f[_0xf275('0xb')](JSON[_0xf275('0xc')]({'appID':_0x240ad2,'timestamp':_0x2322da,'appKey':_0x318fda}));var _0x1e8101=fs[_0xf275('0xd')](_0x5f5c81);_0x1e8101['on'](_0xf275('0xe'),function(_0x5a7dd1){_0x399f1f[_0xf275('0xb')](_0x5a7dd1);});_0x1e8101['on']('close',function(){_0x399f1f[_0xf275('0xb')](_0xf275('0xf'));});}catch(_0x1635e9){logger[_0xf275('0x10')]('Tilde\x20ASR\x20send\x20error',JSON[_0xf275('0xc')](_0x1635e9));_0x399f1f[_0xf275('0x11')]();}}function _0x209c44(_0x34f8ba){try{if(_0x34f8ba){var _0x26b2d5=JSON[_0xf275('0x12')](_0x34f8ba);switch(_0x26b2d5[_0xf275('0x13')]){case 0x0:if(_0x26b2d5[_0xf275('0x14')]){if(_0x26b2d5[_0xf275('0x14')][_0xf275('0x15')]){logger[_0xf275('0x8')](_0xf275('0x16'),JSON['stringify'](_0x26b2d5['result'][_0xf275('0x17')]));_0x3ee0a1=_0x26b2d5[_0xf275('0x14')][_0xf275('0x17')][0x0][_0xf275('0x18')];_0x247caf=_0x26b2d5[_0xf275('0x14')]['hypotheses'][0x0][_0xf275('0x19')];_0x11943e='0';_0x536b68='Success.';_0x399f1f[_0xf275('0x11')]();}}break;case 0x1:logger[_0xf275('0x8')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x11943e='1';_0x536b68=_0xf275('0x5');break;case 0x2:logger[_0xf275('0x8')](_0xf275('0x1a'));_0x11943e='2';_0x536b68=_0xf275('0x1a');break;case 0x9:logger[_0xf275('0x8')](_0xf275('0x1b'));_0x11943e='9';_0x536b68=_0xf275('0x1b');break;case 0xa:logger[_0xf275('0x8')]('Authentication\x20failed.');_0x11943e='10';_0x536b68='Authentication\x20failed.';break;case 0xb:logger[_0xf275('0x8')](_0xf275('0x1c'));_0x11943e='11';_0x536b68=_0xf275('0x1c');}}}catch(_0x4ad0a4){logger[_0xf275('0x10')](_0xf275('0x1d'),JSON[_0xf275('0xc')](_0x4ad0a4));_0x399f1f['terminate']();}}function _0x5d1dd4(){logger[_0xf275('0x8')](_0xf275('0x1e'));_0x58a9a2({'transcript':_0x3ee0a1,'confidence':_0x247caf,'status':_0x11943e,'status_message':_0x536b68});}function _0x30314e(_0x850be5){logger['error'](_0xf275('0x1f'));if(!_[_0xf275('0x20')](_0x850be5)){logger['error'](_[_0xf275('0x21')](_0x850be5)?JSON[_0xf275('0xc')](_0x850be5):_0x850be5);}}_0x399f1f['on'](_0xf275('0x22'),_0x4b5334);_0x399f1f['on'](_0xf275('0x23'),_0x209c44);_0x399f1f['on'](_0xf275('0x24'),_0x5d1dd4);_0x399f1f['on'](_0xf275('0x10'),_0x30314e);});}; \ No newline at end of file diff --git a/server/services/agi/scripts/tilde/index.js b/server/services/agi/scripts/tilde/index.js new file mode 100644 index 0000000..8e4d34d --- /dev/null +++ b/server/services/agi/scripts/tilde/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x561d=['exports'];(function(_0x572293,_0x4cc5bb){var _0x38fac3=function(_0x4e5a85){while(--_0x4e5a85){_0x572293['push'](_0x572293['shift']());}};_0x38fac3(++_0x4cc5bb);}(_0x561d,0x1e3));var _0xd561=function(_0x32e165,_0x3ff2f9){_0x32e165=_0x32e165-0x0;var _0x1c4867=_0x561d[_0x32e165];return _0x1c4867;};var asr=require('./asr');module[_0xd561('0x0')]={'asr':asr}; \ No newline at end of file diff --git a/server/services/agi/scripts/tmp/README.md b/server/services/agi/scripts/tmp/README.md new file mode 100644 index 0000000..b0e85a5 --- /dev/null +++ b/server/services/agi/scripts/tmp/README.md @@ -0,0 +1 @@ +temporary file generate from google and ispeech diff --git a/server/services/agi/server.js b/server/services/agi/server.js new file mode 100644 index 0000000..33b39e5 --- /dev/null +++ b/server/services/agi/server.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['ready','E_AGI_SERVER_ERROR','close','E_AGI_SERVER_CLOSE','inherits','exports','util','net','events','./channel','call','emit','createServer','listening','connection','getConnections','error','E_AGI_SERVER_VOICE_DISABLED','destroy'];(function(_0x500785,_0x15e5ff){var _0x1f8bcc=function(_0x406983){while(--_0x406983){_0x500785['push'](_0x500785['shift']());}};_0x1f8bcc(++_0x15e5ff);}(_0xa9e0,0x123));var _0x0a9e=function(_0x297fd3,_0x115406){_0x297fd3=_0x297fd3-0x0;var _0x2af381=_0xa9e0[_0x297fd3];return _0x2af381;};'use strict';var util=require(_0x0a9e('0x0'));var net=require(_0x0a9e('0x1'));var EventEmitter=require(_0x0a9e('0x2'))['EventEmitter'];var AGIError=require('./error');var AGIChannel=require(_0x0a9e('0x3'));var AGIServer=function(_0x4ce2f1,_0x333808,_0x432180){var _0x2ab90b=this;var _0x991246=null;var _0x981158=0x0;if(!_0x4ce2f1)_0x4ce2f1=0x11dd;if(!_0x333808)_0x333808='127.0.0.1';EventEmitter[_0x0a9e('0x4')](_0x2ab90b);function _0x441e3a(){if(!_0x4ce2f1){_0x2ab90b[_0x0a9e('0x5')]('error',new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0x991246=net[_0x0a9e('0x6')]();_0x991246['listen'](_0x4ce2f1,_0x333808);_0x991246['on']('listening',function(){_0x2ab90b[_0x0a9e('0x5')](_0x0a9e('0x7'));});_0x991246['on'](_0x0a9e('0x8'),function(_0x3ab53f){_0x991246[_0x0a9e('0x9')](function(_0xbd1168,_0x4a4c56){if(_0xbd1168){_0x2ab90b['emit']('error',new AGIError('E_AGI_SERVER_ERROR',_0xbd1168));}else if(_0x432180&&_0x432180<0x0){_0x2ab90b[_0x0a9e('0x5')](_0x0a9e('0xa'),new AGIError(_0x0a9e('0xb')));_0x3ab53f[_0x0a9e('0xc')]();}else if(_0x432180&&_0x432180>0x0&&_0x432180<_0x4a4c56){_0x981158+=0x1;_0x2ab90b[_0x0a9e('0x5')](_0x0a9e('0xa'),new AGIError('E_AGI_SERVER_MAXCONNECTION',_0x981158));_0x3ab53f[_0x0a9e('0xc')]();}else{var _0x239b12=new AGIChannel(_0x3ab53f);_0x239b12['on'](_0x0a9e('0xd'),function(){_0x2ab90b[_0x0a9e('0x5')](_0x0a9e('0x8'),_0x239b12);});}});});_0x991246['on'](_0x0a9e('0xa'),function(_0x52a03d){_0x2ab90b[_0x0a9e('0x5')]('error',new AGIError(_0x0a9e('0xe'),_0x52a03d['code']));});_0x991246['on'](_0x0a9e('0xf'),function(){_0x2ab90b[_0x0a9e('0x5')]('close',new AGIError(_0x0a9e('0x10')));});}process['nextTick'](function(){_0x441e3a();});};util[_0x0a9e('0x11')](AGIServer,EventEmitter);module[_0x0a9e('0x12')]=function(_0x106033,_0x205fd6,_0x31b1ca){return new AGIServer(_0x106033,_0x205fd6,_0x31b1ca);}; \ No newline at end of file diff --git a/server/services/agi/vertices.js b/server/services/agi/vertices.js new file mode 100644 index 0000000..0fc9059 --- /dev/null +++ b/server/services/agi/vertices.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9a86=['Answer','Skipped\x20Answer','subproject','project_id','no\x20subproject\x20selected','project\x20in\x20subproject\x20must\x20be\x20different\x20from\x20the\x20called\x20project','agi://%s/square,\x22%s\x22,\x22%s\x22','host','127.0.0.1','AGI','system','Enter\x20in\x20SYSTEM\x20(%s)\x20block','sh\x20command:\x20%s\x20result\x20on\x20variable:\x20%s','sh\x20command:\x20%s\x20result\x20no\x20stored','google_cloud_tts','Trying\x20Google\x20Cloud\x20TTS\x20%s','Google\x20Cloud\x20TTS\x20is\x20unreachable','tts','Enter\x20in\x20GOOGLETTS\x20(%s)\x20block','Google\x20TTS\x20%s\x20file\x20created','Google\x20TTS\x20is\x20unreachable','unpause','Enter\x20in\x20UNPAUSE\x20(%s)\x20block','voicemail','Enter\x20in\x20VOICEMAIL\x20(%s)\x20block','VOICEMAIL','mailbox','vswitch','Enter\x20in\x20SWITCH\x20(%s)\x20block','join','exports','util','lodash','odbc','randomstring','moment','mustache','request-promise','../../config/logger','agi','../../config/environment','../../config/environment/shared','./scripts','/var/opt/motion2/server/files','rawHeaders','rawBody','menu','getdigits','getsecretdigits','rpc','mailRpc','getVariableById','name','prototype','getVoiceQueue','getVoiceQueueById','getSquareProject','getSquareProjectById','then','catch','getSquareOdbc','dsn','getUser','getUserById','getTrunk','getTrunkById','getSound','getSoundById','getSoundPath','save_name','getMailAccountById','sendMailMessage','getIntervals','getIntervalById','IntervalId','interval','map','Intervals','format','open','error','info','ODBC\x20connection\x20successfully','query','Error\x20executing\x20query\x20%s','Query\x20executed\x20correctly\x20%s','close','Error\x20closing\x20connection\x20to\x20odbc\x20%s','getSmsAccount','getSmsAccountById','createSmsMessage','createSquareDetailsReport','channel','uniqueid','label','agicommand','createSquareRecording','callerid','calleridname','extension','accountcode','dnid','arg_1','createSquareMessage','createCmContact','isNil','random','isEmpty','lastName','phone','list_id','scheduledAt','callback','toString','callback_priority','getPauseById','agentPause','agentUnpause','agent','agentLogout','agentLogin','%s/%s@from-sip/n','LOCAL','shellCommand','exec','trim','replace','apiKey','google_cloud_tts_text_type','text','languageCode','ssmlGender','MALE','MP3','googleTTS','google_tts_language','restAPI','url','timeout','number','includes','method','toUpperCase','body','parse','An\x20incorrect\x20formatted\x20json\x20body\x20has\x20been\x20passed\x20to\x20the\x20function','headers','An\x20incorrect\x20formatted\x20json\x20headers\x20has\x20been\x20passed\x20to\x20the\x20function','computedVariables','sync','uri','render','stringify','An\x20incorrect\x20formatted\x20json\x20has\x20been\x20passed\x20to\x20the\x20function','statusCode','message','options','googleDialogflow','key','dialogflow_language','googleDialogflowV2','client_email','private_key','dialogflowV2_language','sestekNDA','ispeechTTS','speed','ispeechASR','ispeech_asr_language','en-US','model','awsPolly','aws_access_key_id','aws_secret_access_key','aws_polly_region','aws_polly_voice','awsLex','aws_lex_region','aws_bot_name','googleASR','appid','appsecret','clear','clone','hasOwnProperty','isString','replaceObjectAllVariables','replaceAllVariables','recursiveNodeIndex','isArray','length','saveRestApiResult','isPlainObject','%s.%s','setVariable','split','replaceAll','getVariable','extra','getAndSetVariable','result','The\x20\x22%s\x22\x20variable\x20value\x20is:\x20%s','isConfigured','maxRetry','retry','Enter\x20in\x20MRCPSynth\x20(%s)\x20block','noop','MRCPSynth','mrcprecog','Enter\x20in\x20MRCPRecog\x20(%s)\x20block','grammar','no\x20grammar\x20configured','MRCPRecog','MRCP_RECOG_CONFIDENCE','RECOG_INPUT()','MRCP_RECOG_TRANSCRIPT','RECOG_INSTANCE()','MRCP_RECOG_INSTANCE','Executed\x20command\x20MRCPRecog\x20%s','Enter\x20in\x20AGI\x20(%s)\x20block','command','args','Enter\x20in\x20ANSWER\x20(%s)\x20block','Wait\x20%s\x20seconds\x20before\x20answer','wait','answer','Enter\x20in\x20CALLBACK\x20(%s)\x20block','no\x20list\x20selected','delay','add','CALLBACK\x20added\x20phone:\x20%s\x20on\x20list:\x20%s\x20at\x20%s','custom_app','Enter\x20in\x20CUSTOM\x20APP\x20(%s)\x20block','application','Executed\x20command\x20%s\x20%s','lumenvoxtts','Enter\x20in\x20LUMENVOXTTS\x20(%s)\x20block','no\x20text\x20configured','Executed\x20command\x20MRCPSynth\x20%s','sestektts','Enter\x20in\x20SESTEKTTS\x20(%s)\x20block','lumenvoxasr','Enter\x20in\x20LUMENVOXASR\x20(%s)\x20block','RECOG_CONFIDENCE()','LUMENVOX_ASR_TRANSCRIPT','LUMENVOX_ASR_INSTANCE','sestekasr','SESTEK_ASR_CONFIDENCE','SESTEK_ASR_TRANSCRIPT','SESTEK_ASR_INSTANCE','database','Enter\x20in\x20DATABASE\x20(%s)\x20block','odbc_id','no\x20odbc\x20database\x20found','no\x20query\x20configured','getQueryOdbc','variable_id','forEach','keys','%s[%s][%s]','%s_ROWS_COUNT','variable\x20%s\x20set','dial','debug','sip_id','DIAL','opts','Executed\x20command\x20%s','dialogflow','Enter\x20in\x20DIALOGFLOW\x20(%s)\x20block','bot','Trying\x20Dialogflow:\x20%s','DIALOGFLOW_%s','speech','out','Dialogflow\x20Result\x20%s','Dialogflow\x20is\x20unreachable','Enter\x20in\x20DIALOGFLOW\x20V2\x20(%s)\x20block','dialogflowV2_project_id','no\x20client_email\x20configured','no\x20anguage\x20configured','Trying\x20DialogflowV2:\x20%s','providerResponse','dialogflowV2','DialogflowV2\x20Result\x20%s','DialogflowV2\x20is\x20unreachable','sesteknda','ndauth_url','no\x20ndauth\x20url\x20configured','no\x20username\x20configured','password','no\x20password\x20configured','ndassistant_url','Trying\x20SestekNDA:\x20%s','SESTEK_NDA_%s','audiofile','streamFile','.wav','SestekNDA\x20Result\x20%s','SestekNDA\x20is\x20unreachable','end','Enter\x20in\x20END\x20(%s)\x20block','Enter\x20in\x20EXTERNAL\x20DIAL\x20(%s)\x20block','trunk_id','no\x20trunk\x20found','trunk_name','no\x20trunk\x20selected','finally','Enter\x20in\x20FINALLY\x20(%s)\x20block','Enter\x20in\x20GETDIGITS\x20(%s)\x20block','no\x20file\x20audio\x20selected','file_id','no\x20file\x20audio\x20found','no\x20variable\x20selected\x20for\x20the\x20result','response','maxdigit','test','mindigit','no\x20variable\x20found','generate','first','substr','Enter\x20in\x20GETSECRETDIGITS\x20(%s)\x20block','goal','GOAL\x20%s','goalname','awspolly','no\x20valid\x20credentials\x20configured','Trying\x20aws\x20Polly\x20%s','aws\x20Polly\x20%s\x20file\x20created','unlink','aws\x20Polly\x20is\x20unreachable','awslex','Enter\x20in\x20Amazon\x20Lex\x20(%s)\x20block','no\x20bot\x20name\x20configured','amazonlex','Amazon\x20Lex\x20Result\x20%s','Amazon\x20Lex\x20is\x20unreachable','googleasr','Enter\x20in\x20GOOGLEASR\x20(%s)\x20block\x20%s','no\x20key\x20configured','wav','%s/recordings/%s','beep','NOBEEP','google\x20%s\x20file\x20created','GOOGLE_ASR_%s','GoogleASR\x20Result\x20%s','Enter\x20in\x20TILDEASR\x20(%s)\x20block','no\x20appid\x20configured','no\x20appsecret\x20configured','recordFile','tilde\x20%s\x20file\x20created','TILDE_ASR_%s','gotoc','Enter\x20in\x20GOTO\x20(%s)\x20block','continueAt','context','priority','no\x20condition\x20configured','condition','true','false','gotoiftime','Enter\x20in\x20GOTOIFTIME\x20(%s)\x20block','interval_id','no\x20interval\x20configured','IFTIME(%s?true:false)','IFTIME\x20%s\x20%s','ispeechasr','ispeech\x20%s\x20file\x20created','ISPEECH_ASR_%s','IspeechASR\x20Result\x20%s','ispeechtts','Trying\x20ispeech\x20TTS\x20%s','intKey','ispeech\x20TTS\x20is\x20unreachable','login','Enter\x20in\x20LOGIN\x20(%s)\x20block','findBy','FIND\x20AGENT\x20%s\x20BY\x20%s','AGENT\x20%s\x20FOUND\x20BY','success','AGENT\x20%s\x20NOT\x20FOUND\x20BY','logout','Enter\x20in\x20LOGOUT\x20(%s)\x20block','no\x20find\x20by\x20configured','failure','math','Enter\x20in\x20MATH\x20(%s)\x20block','operation','no\x20operation\x20configured','%s[%s]','variable\x20%s[key]\x20set','Enter\x20in\x20MENU\x20(%s)\x20block','Enter\x20in\x20NOOP\x20(%s)\x20block','pause','Enter\x20in\x20PAUSE\x20(%s)\x20block','getPause','pause_id','playback','PLAYBACK','queue','Enter\x20in\x20QUEUE\x20(%s)\x20block','queue_id','no\x20queue\x20selected','no\x20queue\x20found','indexOf','QUEUE','macro','gosub','record','recordingFormat','%s_%s','Recording\x20%s\x20%s\x20%s\x20%s','escape_digits','restapi','Enter\x20in\x20RESTAPI\x20(%s)\x20block','no\x20url\x20configured','Response:','inspect','no\x20variable\x20selected\x20for\x20the\x20response','200','%s_STATUS_MESSAGE','statusMessage','Unable\x20to\x20set\x20result\x20in\x20variable\x20%s','saydigits','Enter\x20in\x20SAYDIGITS\x20(%s)\x20block','sayDigits','digits','saynumber','Enter\x20in\x20SAYNUMBER\x20(%s)\x20block','sayNumber','Enter\x20in\x20SAYPHONETIC\x20(%s)\x20block','sendMail','Enter\x20in\x20SENDMAIL\x20(%s)\x20block','account_id','no\x20mail\x20account\x20configured','Smtp','no\x20mail\x20account\x20found','\x22%s\x22\x20<%s>','email','user','bcc','subject','sendMail\x20message','Trying\x20SendMail\x20with\x20account\x20%s','Mail\x20message\x20added\x20to\x20outgoing\x20process','sendFax','Enter\x20in\x20SENDFAX\x20(%s)\x20block','SENDFAX\x20block\x20not\x20implemented','sendSMS','sms_account_id','no\x20sms\x20account\x20configured','no\x20sms\x20account\x20found','sms_text','sendSMS\x20message','set','no\x20variable\x20selected','start','Enter\x20in\x20START\x20(%s)\x20block','yes'];(function(_0x560448,_0x2c1082){var _0x550276=function(_0x37e949){while(--_0x37e949){_0x560448['push'](_0x560448['shift']());}};_0x550276(++_0x2c1082);}(_0x9a86,0x1ed));var _0x69a8=function(_0x4c98b9,_0x1ad11b){_0x4c98b9=_0x4c98b9-0x0;var _0x3a257a=_0x9a86[_0x4c98b9];return _0x3a257a;};'use strict';var fs=require('fs');var util=require(_0x69a8('0x0'));var _=require(_0x69a8('0x1'));var sh=require('shelljs');var odbc=require(_0x69a8('0x2'))();var rs=require(_0x69a8('0x3'));var moment=require(_0x69a8('0x4'));var Mustache=require(_0x69a8('0x5'));var rp=require(_0x69a8('0x6'));var logger=require(_0x69a8('0x7'))(_0x69a8('0x8'));var config=require(_0x69a8('0x9'));var shared=require(_0x69a8('0xa'));var scripts=require(_0x69a8('0xb'));var FILES_PATH=_0x69a8('0xc');var recursiveMapAttributes=[_0x69a8('0xd'),_0x69a8('0xe')];var verticesWithRetry=[_0x69a8('0xf'),_0x69a8('0x10'),_0x69a8('0x11')];var AGIVertices=function(_0x54248e,_0x10a1e7,_0xaf3ed6){this['channel']=_0x54248e;this[_0x69a8('0x12')]=_0x10a1e7;this[_0x69a8('0x13')]=_0xaf3ed6;};AGIVertices['prototype']['getVariable']=function(_0x43c11e,_0xf7e885){this[_0x69a8('0x12')][_0x69a8('0x14')](_0x43c11e)['then'](function(_0x4e818b){_0xf7e885(null,_0x4e818b?_0x4e818b[_0x69a8('0x15')]:![]);})['catch'](function(_0x18f782){_0xf7e885(_0x18f782);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x17')]=function(_0x12b148,_0x272100){this['rpc'][_0x69a8('0x18')](_0x12b148)['then'](function(_0x381a2a){_0x272100(null,_0x381a2a?_0x381a2a[_0x69a8('0x15')]:![]);})['catch'](function(_0x33b701){_0x272100(_0x33b701);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x19')]=function(_0x35906f,_0x1d3ebf){this[_0x69a8('0x12')][_0x69a8('0x1a')](_0x35906f)[_0x69a8('0x1b')](function(_0x3c6252){_0x1d3ebf(null,_0x3c6252?_0x3c6252[_0x69a8('0x15')]:![]);})[_0x69a8('0x1c')](function(_0x5e123c){_0x1d3ebf(_0x5e123c);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1d')]=function(_0x237232,_0x4a769a){this[_0x69a8('0x12')]['getSquareOdbcById'](_0x237232)[_0x69a8('0x1b')](function(_0x2db796){_0x4a769a(null,_0x2db796?_0x2db796[_0x69a8('0x1e')]:![]);})[_0x69a8('0x1c')](function(_0x23df9e){_0x4a769a(_0x23df9e);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1f')]=function(_0x40a35d,_0x363fc0){this[_0x69a8('0x12')][_0x69a8('0x20')](_0x40a35d)[_0x69a8('0x1b')](function(_0x33e39c){_0x363fc0(null,_0x33e39c?_0x33e39c['name']:![]);})['catch'](function(_0x2381bf){_0x363fc0(_0x2381bf);});};AGIVertices['prototype'][_0x69a8('0x21')]=function(_0x115cdd,_0x45f1e9){this[_0x69a8('0x12')][_0x69a8('0x22')](_0x115cdd)[_0x69a8('0x1b')](function(_0x21412d){_0x45f1e9(null,_0x21412d?_0x21412d[_0x69a8('0x15')]:![]);})[_0x69a8('0x1c')](function(_0x1c9588){_0x45f1e9(_0x1c9588);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x23')]=function(_0x3d0754,_0xb61a04){var _0x2244c7=this;this[_0x69a8('0x12')][_0x69a8('0x24')](_0x3d0754)[_0x69a8('0x1b')](function(_0x3242ef){_0xb61a04(null,_0x3242ef?_0x2244c7[_0x69a8('0x25')](_0x3242ef[_0x69a8('0x26')]):![]);})['catch'](function(_0x24f1d1){_0xb61a04(_0x24f1d1);});};AGIVertices[_0x69a8('0x16')]['getMailAccount']=function(_0x2e7355,_0x5c8981){this[_0x69a8('0x12')][_0x69a8('0x27')](_0x2e7355)['then'](function(_0x51a25e){_0x5c8981(null,_0x51a25e?_0x51a25e:![]);})[_0x69a8('0x1c')](function(_0x2dbdb0){_0x5c8981(_0x2dbdb0);});};AGIVertices['prototype'][_0x69a8('0x28')]=function(_0x4fd0ee,_0x3fc8a9,_0x19a271){this['mailRpc']['sendMailMessage'](_0x4fd0ee,_0x3fc8a9)[_0x69a8('0x1b')](function(){_0x19a271(null);})[_0x69a8('0x1c')](function(_0x1561e3){_0x19a271(_0x1561e3);});};AGIVertices['prototype'][_0x69a8('0x29')]=function(_0x4c8279,_0x131fd9){this[_0x69a8('0x12')][_0x69a8('0x2a')](_0x4c8279)[_0x69a8('0x1b')](function(_0x5965c1){if(_0x5965c1){if(_0x5965c1[_0x69a8('0x2b')]){_0x131fd9(null,[_0x5965c1[_0x69a8('0x2c')]]);}else{_0x131fd9(null,_[_0x69a8('0x2d')](_0x5965c1[_0x69a8('0x2e')],_0x69a8('0x2c')));}}else{_0x131fd9(null,![]);}})['catch'](function(_0x5c3673){_0x131fd9(_0x5c3673);});};AGIVertices[_0x69a8('0x16')]['getSoundPath']=function(_0x51f130){return util[_0x69a8('0x2f')]('%s/sounds/converted/%s',FILES_PATH,_0x51f130);};AGIVertices[_0x69a8('0x16')]['getQueryOdbc']=function(_0x51a7ca,_0x1273be,_0x38037f){odbc[_0x69a8('0x30')](_0x51a7ca,function(_0x451310){if(_0x451310){logger[_0x69a8('0x31')]('Error\x20getting\x20ODBC\x20connection\x20%s',_0x451310);_0x38037f(_0x451310);}else{logger[_0x69a8('0x32')](_0x69a8('0x33'));odbc[_0x69a8('0x34')](_0x1273be,function(_0x3c30ce,_0x16744d){if(_0x3c30ce){logger[_0x69a8('0x32')](_0x69a8('0x35'),_0x1273be);_0x38037f(_0x3c30ce);}else{logger[_0x69a8('0x32')](_0x69a8('0x36'),_0x1273be);odbc[_0x69a8('0x37')](function(_0x5a80a8){if(_0x5a80a8){logger[_0x69a8('0x31')](_0x69a8('0x38'),_0x5a80a8);}_0x38037f(null,_0x16744d);});}});}});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x39')]=function(_0x54204c,_0x19d2f0){this['rpc'][_0x69a8('0x3a')](_0x54204c)['then'](function(_0x2559bf){_0x19d2f0(null,_0x2559bf?_0x2559bf:![]);})[_0x69a8('0x1c')](function(_0x36b2a1){_0x19d2f0(_0x36b2a1);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x3b')]=function(_0x412b42,_0x2269d6){this[_0x69a8('0x12')]['createSmsMessage'](_0x412b42)['then'](function(_0x279dac){_0x2269d6(null,_0x279dac);})[_0x69a8('0x1c')](function(_0x228739){_0x2269d6(_0x228739);});};AGIVertices['prototype'][_0x69a8('0x3c')]=function(_0x3e0da3,_0x5aed65,_0x39895a){this['rpc'][_0x69a8('0x3c')]({'uniqueid':this[_0x69a8('0x3d')][_0x69a8('0x3e')],'node':_0x3e0da3[_0x69a8('0x3f')],'application':_0x3e0da3[_0x69a8('0x40')],'data':_0x5aed65||null,'project_name':this[_0x69a8('0x3d')]['arg_1'],'callerid':this['channel']['callerid']})['then'](function(_0x16eba3){if(_0x39895a){_0x39895a(null,_0x16eba3);}})[_0x69a8('0x1c')](function(_0x403c40){if(_0x39895a){_0x39895a(_0x403c40);}});};AGIVertices[_0x69a8('0x16')]['createSquareRecording']=function(_0x2480ca,_0x5580d2,_0x34c461,_0x3c831e){this[_0x69a8('0x12')][_0x69a8('0x41')]({'uniqueid':this[_0x69a8('0x3d')][_0x69a8('0x3e')],'callerid':this[_0x69a8('0x3d')][_0x69a8('0x42')],'calleridname':this[_0x69a8('0x3d')][_0x69a8('0x43')],'context':this[_0x69a8('0x3d')]['context'],'extension':this[_0x69a8('0x3d')][_0x69a8('0x44')],'priority':this[_0x69a8('0x3d')]['priority'],'accountcode':this[_0x69a8('0x3d')][_0x69a8('0x45')],'dnid':this['channel'][_0x69a8('0x46')],'projectName':this[_0x69a8('0x3d')][_0x69a8('0x47')],'saveName':_0x5580d2,'filename':_0x2480ca['file']||_0x5580d2,'savePath':_0x34c461})[_0x69a8('0x1b')](function(_0x3512fd){_0x3c831e(null,_0x3512fd);})[_0x69a8('0x1c')](function(_0x243370){_0x3c831e(_0x243370);});};AGIVertices['prototype']['createSquareMessage']=function(_0x231213,_0x54bc76,_0x250c29,_0x54c2f0,_0x4e930f){this[_0x69a8('0x12')][_0x69a8('0x48')]({'uniqueid':this[_0x69a8('0x3d')][_0x69a8('0x3e')],'body':_0x231213,'direction':_0x54bc76,'providerName':_0x250c29,'providerResponse':_0x54c2f0})['then'](function(_0xfed272){if(_0x4e930f){_0x4e930f(null,_0xfed272);}})[_0x69a8('0x1c')](function(_0x36dd79){if(_0x4e930f){_0x4e930f(_0x36dd79);}});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x49')]=function(_0x4fb1f3,_0x270320){this[_0x69a8('0x12')][_0x69a8('0x49')]({'firstName':_['isEmpty'](_0x4fb1f3[_0x69a8('0x15')])||_[_0x69a8('0x4a')](_0x4fb1f3[_0x69a8('0x15')])?'callback_'+Math[_0x69a8('0x4b')]():_0x4fb1f3[_0x69a8('0x15')],'lastName':_[_0x69a8('0x4c')](_0x4fb1f3[_0x69a8('0x4d')])||_['isNil'](_0x4fb1f3[_0x69a8('0x4d')])?null:_0x4fb1f3[_0x69a8('0x4d')],'phone':_0x4fb1f3[_0x69a8('0x4e')],'ListId':_0x4fb1f3[_0x69a8('0x4f')],'scheduledat':_0x4fb1f3[_0x69a8('0x50')],'callbackUniqueid':this[_0x69a8('0x3d')][_0x69a8('0x3e')],'tags':_0x69a8('0x51'),'description':'Callback\x20scheduled\x20at\x20'+_0x4fb1f3['scheduledAt'][_0x69a8('0x52')](),'priority':_0x4fb1f3[_0x69a8('0x53')]})[_0x69a8('0x1b')](function(_0x4698ca){_0x270320(null,_0x4698ca);})[_0x69a8('0x1c')](function(_0x47c6cb){_0x270320(_0x47c6cb);});};AGIVertices['prototype']['getPause']=function(_0xce9ef0,_0x32542b){this[_0x69a8('0x12')][_0x69a8('0x54')](_0xce9ef0)[_0x69a8('0x1b')](function(_0x53dcbc){_0x32542b(null,_0x53dcbc?_0x53dcbc['name']:![]);})[_0x69a8('0x1c')](function(_0x286eea){_0x32542b(_0x286eea);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x55')]=function(_0x4f1bbc,_0x1d8dda,_0x9c7438){var _0x387703={'role':'agent'};_0x387703[_0x4f1bbc]=this[_0x69a8('0x3d')][_0x69a8('0x42')];this[_0x69a8('0x12')][_0x69a8('0x55')](_0x387703,_0x1d8dda,this[_0x69a8('0x3d')][_0x69a8('0x3e')])['then'](function(_0x116fd9){_0x9c7438(null,_[_0x69a8('0x4a')](_0x116fd9)?![]:!![]);})[_0x69a8('0x1c')](function(_0x3662de){logger[_0x69a8('0x31')](_0x3662de);_0x9c7438(null,![]);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x56')]=function(_0x347106,_0x40580f){var _0x3c26af={'role':_0x69a8('0x57')};_0x3c26af[_0x347106]=this[_0x69a8('0x3d')][_0x69a8('0x42')];this[_0x69a8('0x12')][_0x69a8('0x56')](_0x3c26af)[_0x69a8('0x1b')](function(_0x57b944){_0x40580f(null,_[_0x69a8('0x4a')](_0x57b944)?![]:!![]);})['catch'](function(_0x43d082){logger[_0x69a8('0x31')](_0x43d082);_0x40580f(null,![]);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x58')]=function(_0x517621,_0x31ff6f){var _0x4c1250={'role':'agent'};_0x4c1250[_0x517621]=this['channel'][_0x69a8('0x42')];this[_0x69a8('0x12')][_0x69a8('0x58')](_0x4c1250)[_0x69a8('0x1b')](function(_0x494ad6){_0x31ff6f(null,_[_0x69a8('0x4a')](_0x494ad6)?![]:!![]);})[_0x69a8('0x1c')](function(_0x2c210c){logger['error'](_0x2c210c);_0x31ff6f(null,![]);});};AGIVertices['prototype'][_0x69a8('0x59')]=function(_0x5cdca7,_0x4cc15a){var _0x2ed0bb={'role':_0x69a8('0x57')};_0x2ed0bb[_0x5cdca7]=this[_0x69a8('0x3d')][_0x69a8('0x42')];var _0x40880f=_0x5cdca7!='internal'?util[_0x69a8('0x2f')](_0x69a8('0x5a'),_0x69a8('0x5b'),this[_0x69a8('0x3d')]['callerid']):undefined;this[_0x69a8('0x12')][_0x69a8('0x59')](_0x2ed0bb,_0x40880f)['then'](function(_0x367ea1){_0x4cc15a(null,_['isNil'](_0x367ea1)?![]:!![]);})[_0x69a8('0x1c')](function(_0x2e292e){logger[_0x69a8('0x31')](_0x2e292e);_0x4cc15a(null,![]);});};AGIVertices['prototype'][_0x69a8('0x5c')]=function(_0x19df24,_0x44b7f3){sh[_0x69a8('0x5d')](_[_0x69a8('0x5e')](_0x19df24),function(_0x4c0f64,_0x38ecaf){var _0x57b807=_0x38ecaf[_0x69a8('0x5f')](/(\r\n|\n|\r)/gm,'');_0x44b7f3(null,_0x57b807);});};AGIVertices[_0x69a8('0x16')]['googleCloudTTS']=function(_0xe5023,_0x237dab){scripts['googleCloudTTS'](_0xe5023[_0x69a8('0x60')],_0xe5023[_0x69a8('0x61')]||_0x69a8('0x62'),_0xe5023[_0x69a8('0x62')],_0xe5023[_0x69a8('0x63')]||'en-US',_0xe5023[_0x69a8('0x64')]||_0x69a8('0x65'),_0xe5023['audioEncoding']||_0x69a8('0x66'))[_0x69a8('0x1b')](function(_0x456528){_0x237dab(null,_0x456528);})[_0x69a8('0x1c')](function(_0x4d4aad){_0x237dab(_0x4d4aad);});};AGIVertices['prototype'][_0x69a8('0x67')]=function(_0x2c8b1a,_0x562240){scripts['googleTTS'](_0x2c8b1a[_0x69a8('0x62')],_0x2c8b1a[_0x69a8('0x68')]||'en',0x1)['then'](function(_0x5d0bb5){_0x562240(null,_0x5d0bb5);})[_0x69a8('0x1c')](function(_0x228757){_0x562240(_0x228757);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x69')]=function(_0x402147,_0x4a0741){var _0x378e08={'uri':_0x402147[_0x69a8('0x6a')],'method':_0x402147['method'],'json':!![],'resolveWithFullResponse':!![],'strictSSL':![],'timeout':typeof parseInt(_0x402147[_0x69a8('0x6b')])===_0x69a8('0x6c')&&parseInt(_0x402147[_0x69a8('0x6b')])>=0x1?parseInt(_0x402147['timeout'])*0x3e8:0x5*0x3e8};if(_[_0x69a8('0x6d')](['POST','PUT'],_0x378e08[_0x69a8('0x6e')][_0x69a8('0x6f')]())){try{_0x378e08[_0x69a8('0x70')]=_0x402147[_0x69a8('0xe')]?JSON[_0x69a8('0x71')](_0x402147[_0x69a8('0xe')]):{};}catch(_0x185e11){logger[_0x69a8('0x31')](_0x69a8('0x72'),_0x185e11);}}try{_0x378e08[_0x69a8('0x73')]=_0x402147['rawHeaders']?JSON[_0x69a8('0x71')](_0x402147['rawHeaders']):{};}catch(_0x45d779){logger[_0x69a8('0x31')](_0x69a8('0x74'),_0x45d779);}if(_0x402147[_0x69a8('0x75')]){try{var _0x4d5be4=require(_0x402147[_0x69a8('0x75')])[_0x69a8('0x76')](this,_0x378e08);_0x378e08[_0x69a8('0x77')]=Mustache[_0x69a8('0x78')](_0x402147[_0x69a8('0x6a')],_0x4d5be4,{},['$$','$$']);if(_0x378e08[_0x69a8('0x73')]){_0x378e08[_0x69a8('0x73')]=JSON[_0x69a8('0x71')](Mustache[_0x69a8('0x78')](JSON[_0x69a8('0x79')](_0x378e08[_0x69a8('0x73')]),_0x4d5be4,{},['$$','$$']));}if(_0x378e08[_0x69a8('0x70')]){_0x378e08[_0x69a8('0x70')]=JSON[_0x69a8('0x71')](Mustache['render'](JSON[_0x69a8('0x79')](_0x378e08[_0x69a8('0x70')]),_0x4d5be4,{},['$$','$$']));}}catch(_0x583672){logger['error'](_0x69a8('0x7a'),_0x583672);}}rp(_0x378e08)['then'](function(_0x470e4a){var _0x259445={'statusCode':_0x470e4a[_0x69a8('0x7b')]||0xc8,'statusMessage':_0x470e4a['statusMessage']||'OK','headers':_0x470e4a[_0x69a8('0x73')]||{},'body':_0x470e4a[_0x69a8('0x70')]||{}};_0x4a0741(null,_0x259445);})[_0x69a8('0x1c')](function(_0x1993c9){var _0x51e957={'statusCode':_0x1993c9['statusCode']||0x1f4,'statusMessage':_0x1993c9[_0x69a8('0x7c')]||'500\x20-\x20Internal\x20Server\x20Error','headers':_0x1993c9[_0x69a8('0x7d')][_0x69a8('0x73')]||{},'body':_0x1993c9['options'][_0x69a8('0x70')]||{}};_0x4a0741(null,_0x51e957);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x7e')]=function(_0x3604f4,_0x1428d9){scripts['googleDialogflow'](this[_0x69a8('0x3d')][_0x69a8('0x3e')],_0x3604f4[_0x69a8('0x7f')],_0x3604f4['text'],_0x3604f4[_0x69a8('0x80')]||'en')[_0x69a8('0x1b')](function(_0x275513){_0x1428d9(null,_0x275513);})[_0x69a8('0x1c')](function(_0x2481ba){_0x1428d9(_0x2481ba);});};AGIVertices[_0x69a8('0x16')]['googleDialogflowV2']=function(_0x3f13b5,_0xb2add1){scripts[_0x69a8('0x81')](this[_0x69a8('0x3d')]['uniqueid'],_0x3f13b5['dialogflowV2_project_id'],_0x3f13b5[_0x69a8('0x82')],_0x3f13b5[_0x69a8('0x83')],_0x3f13b5[_0x69a8('0x62')],_0x3f13b5[_0x69a8('0x84')]||'en')[_0x69a8('0x1b')](function(_0x5888a3){_0xb2add1(null,_0x5888a3);})[_0x69a8('0x1c')](function(_0x384893){_0xb2add1(_0x384893);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x85')]=function(_0x1507a8,_0x546a8f){scripts[_0x69a8('0x85')](this[_0x69a8('0x3d')],_0x1507a8)[_0x69a8('0x1b')](function(_0x2498e9){_0x546a8f(null,_0x2498e9);})['catch'](function(_0x52bbf8){_0x546a8f(_0x52bbf8);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x86')]=function(_0x5d7665,_0x255af1){scripts['ispeechTTS'](_0x5d7665[_0x69a8('0x7f')],_0x5d7665[_0x69a8('0x62')],_0x5d7665['ispeech_tts_language']||'en-US',_0x5d7665[_0x69a8('0x87')])[_0x69a8('0x1b')](function(_0x255d6e){_0x255af1(null,_0x255d6e);})[_0x69a8('0x1c')](function(_0x508ec5){_0x255af1(_0x508ec5);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x88')]=function(_0x139b3d,_0x1c1c36,_0xfc314b){scripts[_0x69a8('0x88')](_0x1c1c36,_0x139b3d[_0x69a8('0x7f')],_0x139b3d[_0x69a8('0x89')]||_0x69a8('0x8a'),this['isConfigured'](_0x139b3d[_0x69a8('0x8b')])?_0x139b3d[_0x69a8('0x8b')]:undefined)[_0x69a8('0x1b')](function(_0x3b0d29){_0xfc314b(null,_0x3b0d29);})[_0x69a8('0x1c')](function(_0x98ddd8){_0xfc314b(_0x98ddd8);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x8c')]=function(_0x54edb2,_0x194831){scripts[_0x69a8('0x8c')](_0x54edb2[_0x69a8('0x8d')],_0x54edb2[_0x69a8('0x8e')],_0x54edb2[_0x69a8('0x8f')],_0x54edb2[_0x69a8('0x90')]||'Amy',_0x54edb2[_0x69a8('0x62')],_0x54edb2['aws_text_type']||_0x69a8('0x62'))[_0x69a8('0x1b')](function(_0x2fadbc){_0x194831(null,_0x2fadbc);})[_0x69a8('0x1c')](function(_0x5ab484){_0x194831(_0x5ab484);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x91')]=function(_0x27cc56,_0x1aaf84){scripts[_0x69a8('0x91')](this[_0x69a8('0x3d')][_0x69a8('0x3e')],_0x27cc56[_0x69a8('0x8d')],_0x27cc56[_0x69a8('0x8e')],_0x27cc56[_0x69a8('0x92')],_0x27cc56['text'],_0x27cc56[_0x69a8('0x93')])[_0x69a8('0x1b')](function(_0x38efb3){_0x1aaf84(null,_0x38efb3);})[_0x69a8('0x1c')](function(_0x1a5ce2){_0x1aaf84(_0x1a5ce2);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x94')]=function(_0x3af192,_0x1eb1e0,_0x2a6a37){scripts[_0x69a8('0x94')](_0x1eb1e0,_0x3af192['key'],_0x3af192['google_asr_language']||_0x69a8('0x8a'))['then'](function(_0x572a16){_0x2a6a37(null,_0x572a16);})[_0x69a8('0x1c')](function(_0x48223f){_0x2a6a37(_0x48223f);});};AGIVertices[_0x69a8('0x16')]['tildeASR']=function(_0x273d99,_0x44608c,_0x54cf48){scripts['tildeASR'](_0x44608c,_0x273d99[_0x69a8('0x95')],_0x273d99[_0x69a8('0x96')],_0x273d99['uri'])[_0x69a8('0x1b')](function(_0x49fd09){_0x54cf48(null,_0x49fd09);})[_0x69a8('0x1c')](function(_0x398309){_0x54cf48(_0x398309);});};AGIVertices[_0x69a8('0x16')][_0x69a8('0x97')]=function(_0x3e82e3){var _0x510aba=_[_0x69a8('0x6d')](verticesWithRetry,_0x3e82e3[_0x69a8('0x40')])?_0x3e82e3:_[_0x69a8('0x98')](_0x3e82e3);for(var _0xbf3c34 in _0x510aba){if(_0x510aba[_0x69a8('0x99')](_0xbf3c34)){if(_0x510aba[_0xbf3c34]&&_[_0x69a8('0x9a')](_0x510aba[_0xbf3c34])){if(_[_0x69a8('0x6d')](recursiveMapAttributes,_0xbf3c34)){_0x510aba[_0xbf3c34]=this[_0x69a8('0x9b')](_0x510aba[_0xbf3c34]);}else{_0x510aba[_0xbf3c34]=this[_0x69a8('0x9c')](_0x510aba[_0xbf3c34]);}}}}return _0x510aba;};AGIVertices[_0x69a8('0x16')][_0x69a8('0x9d')]=function(_0x284c31){for(var _0x2c990f in _0x284c31){if(_0x284c31[_0x69a8('0x99')](_0x2c990f)){if(_['isPlainObject'](_0x284c31[_0x2c990f])){this[_0x69a8('0x9d')](_0x284c31[_0x2c990f]);}else if(_[_0x69a8('0x9e')](_0x284c31[_0x2c990f])){for(var _0x16b4ec=0x0;_0x16b4ec<_0x284c31[_0x2c990f][_0x69a8('0x9f')];_0x16b4ec++){this[_0x69a8('0x9d')](_0x284c31[_0x2c990f][_0x16b4ec]);}}else if(_['isString'](_0x284c31[_0x2c990f])){_0x284c31[_0x2c990f]=this['replaceAllVariables'](_0x284c31[_0x2c990f]);}}}};AGIVertices[_0x69a8('0x16')][_0x69a8('0xa0')]=function(_0x3c2898,_0xde4fca){for(var _0x43b76a in _0x3c2898){if(_0x3c2898[_0x69a8('0x99')](_0x43b76a)){if(_[_0x69a8('0xa1')](_0x3c2898[_0x43b76a])){if(!_[_0x69a8('0x4c')](_0x3c2898[_0x43b76a])){this[_0x69a8('0xa0')](_0x3c2898[_0x43b76a],util[_0x69a8('0x2f')](_0x69a8('0xa2'),_0xde4fca,_0x43b76a));}}else if(_[_0x69a8('0x9e')](_0x3c2898[_0x43b76a])){for(var _0x3efb41=0x0;_0x3efb41<_0x3c2898[_0x43b76a][_0x69a8('0x9f')];_0x3efb41++){this[_0x69a8('0xa0')](_0x3c2898[_0x43b76a][_0x3efb41],util[_0x69a8('0x2f')](_0x69a8('0xa2'),_0xde4fca,_0x43b76a+'['+_0x3efb41+']'));}}else{if(!_[_0x69a8('0x4a')](_0x3c2898[_0x43b76a])){this[_0x69a8('0x3d')][_0x69a8('0xa3')](util['format']('%s.%s',_0xde4fca,_0x43b76a),_0x3c2898[_0x43b76a]);}}}}};AGIVertices['prototype']['replaceObjectAllVariables']=function(_0x4e72e6){try{var _0x274243=JSON['parse'](_0x4e72e6);this['recursiveNodeIndex'](_0x274243);return JSON[_0x69a8('0x79')](_0x274243);}catch(_0x563d9b){return this[_0x69a8('0x9c')](_0x4e72e6);}};AGIVertices['prototype'][_0x69a8('0x9c')]=function(_0x4bde38){var _0x44dc9d=_0x4bde38[_0x69a8('0xa4')]('{');for(var _0x429263=0x1;_0x429263<_0x44dc9d[_0x69a8('0x9f')];_0x429263+=0x1){var _0x2ab374=_0x44dc9d[_0x429263]['split']('}');if(_0x2ab374[_0x69a8('0x9f')]>0x1){_0x4bde38=_0x4bde38[_0x69a8('0xa5')]('{'+_0x2ab374[0x0]+'}',this[_0x69a8('0x3d')][_0x69a8('0xa6')](_0x2ab374[0x0])[_0x69a8('0xa7')]||_0x2ab374[0x0]);}}if(_0x44dc9d[_0x69a8('0x9f')]===0x1){return _0x4bde38[_0x69a8('0x52')]();}return this[_0x69a8('0x9c')](_0x4bde38);};AGIVertices[_0x69a8('0x16')][_0x69a8('0xa8')]=function(_0x4afa57,_0x1ea58a){var _0x2dee4d=this[_0x69a8('0x3d')][_0x69a8('0xa6')](_0x4afa57);if(_0x2dee4d[_0x69a8('0xa9')]===-0x1){return _0x2dee4d;}logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xaa'),_0x1ea58a,_0x2dee4d[_0x69a8('0xa7')]));return this['channel'][_0x69a8('0xa3')](_0x1ea58a,_0x2dee4d[_0x69a8('0xa7')]);};AGIVertices['prototype'][_0x69a8('0xab')]=function(_0x493cba){return _0x493cba&&_0x493cba!=='0'&&_0x493cba!=='-1'&&_0x493cba!=='';};AGIVertices[_0x69a8('0x16')][_0x69a8('0xac')]=function(_0x389915){this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x389915,'-');_0x389915[_0x69a8('0xad')]=_0x389915[_0x69a8('0xac')];return{'code':0xc8,'result':'-'};};AGIVertices[_0x69a8('0x16')]['mrcpsynth']=function(_0x7432b0){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xae'),_0x7432b0[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x7432b0[_0x69a8('0x62')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20text\x20configured');}var _0xd060a6='\x22'+_0x7432b0[_0x69a8('0x62')]+'\x22';if(this['isConfigured'](_0x7432b0[_0x69a8('0x7d')])){_0xd060a6+=','+_0x7432b0[_0x69a8('0x7d')];}var _0x4b32b8=this['channel'][_0x69a8('0x5d')](_0x69a8('0xb0'),_0xd060a6);if(_0x4b32b8[_0x69a8('0xa9')]===-0x1){return _0x4b32b8;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Executed\x20command\x20MRCPSynth\x20%s',_0xd060a6));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xb1')]=function(_0x2db5a6){logger[_0x69a8('0x32')](util['format'](_0x69a8('0xb2'),_0x2db5a6[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2db5a6[_0x69a8('0xb3')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xb4'));}var _0x4c471b=_0x2db5a6[_0x69a8('0xb3')];if(this[_0x69a8('0xab')](_0x2db5a6[_0x69a8('0x7d')])){_0x4c471b+=','+_0x2db5a6[_0x69a8('0x7d')];}var _0x322d28=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0xb5'),_0x4c471b);if(_0x322d28[_0x69a8('0xa9')]===-0x1){return _0x322d28;}var _0xe33197=this[_0x69a8('0xa8')]('RECOG_CONFIDENCE()',_0x69a8('0xb6'));if(_0xe33197[_0x69a8('0xa9')]===-0x1){return _0xe33197;}var _0x57d6b3=this['getAndSetVariable'](_0x69a8('0xb7'),_0x69a8('0xb8'));if(_0x57d6b3[_0x69a8('0xa9')]===-0x1){return _0x57d6b3;}var _0x219590=this[_0x69a8('0xa8')](_0x69a8('0xb9'),_0x69a8('0xba'));if(_0x219590[_0x69a8('0xa9')]===-0x1){return _0x219590;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0xbb'),_0x4c471b));};AGIVertices[_0x69a8('0x16')]['agi']=function(_0x2ce2b1){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xbc'),_0x2ce2b1[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')][_0x69a8('0x8')]([_0x2ce2b1[_0x69a8('0xbd')],_0x2ce2b1[_0x69a8('0xbe')]]);};AGIVertices[_0x69a8('0x16')]['answer']=function(_0x500601){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xbf'),_0x500601[_0x69a8('0x3f')]));if(this[_0x69a8('0xab')](_0x500601[_0x69a8('0x6b')])){logger[_0x69a8('0x32')](util['format'](_0x69a8('0xc0'),_0x500601[_0x69a8('0x6b')]));var _0xf348b4=this[_0x69a8('0x3d')][_0x69a8('0xc1')](_0x500601[_0x69a8('0x6b')]);if(_0xf348b4[_0x69a8('0xa9')]===-0x1){return _0xf348b4;}}return this[_0x69a8('0x3d')][_0x69a8('0xc2')]();};AGIVertices['prototype'][_0x69a8('0x51')]=function(_0x2d2005){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xc3'),_0x2d2005[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2d2005[_0x69a8('0x4f')])){return this['channel'][_0x69a8('0x31')](_0x2d2005,_0x69a8('0xc4'));}_0x2d2005[_0x69a8('0x50')]=moment();if(this[_0x69a8('0xab')](_0x2d2005[_0x69a8('0xc5')])){_0x2d2005[_0x69a8('0x50')]=moment()[_0x69a8('0xc6')](_0x2d2005['delay'],'minutes');}if(!this[_0x69a8('0xab')](_0x2d2005[_0x69a8('0x53')])){_0x2d2005[_0x69a8('0x53')]=0x2;}this[_0x69a8('0x49')][_0x69a8('0x76')](this,_0x2d2005);return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xc7'),_0x2d2005[_0x69a8('0x4e')],_0x2d2005[_0x69a8('0x4f')],_0x2d2005[_0x69a8('0x50')]));};AGIVertices['prototype'][_0x69a8('0xc8')]=function(_0x35d249){logger[_0x69a8('0x32')](util['format'](_0x69a8('0xc9'),_0x35d249[_0x69a8('0x3f')]));var _0x3bbf69=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x35d249[_0x69a8('0xca')],_0x35d249[_0x69a8('0x7d')]);if(_0x3bbf69['result']===-0x1){return _0x3bbf69;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xcb'),_0x35d249[_0x69a8('0xca')],_0x35d249[_0x69a8('0x7d')]));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xcc')]=function(_0x24344b){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xcd'),_0x24344b[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x24344b[_0x69a8('0x62')])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0xce'));}var _0x38382d='\x22'+_0x24344b['text']+'\x22';if(this['isConfigured'](_0x24344b['options'])){_0x38382d+=','+_0x24344b[_0x69a8('0x7d')];}var _0xd1c13d=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0xb0'),_0x38382d);if(_0xd1c13d[_0x69a8('0xa9')]===-0x1){return _0xd1c13d;}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xcf'),_0x38382d));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xd0')]=function(_0x4b45db){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xd1'),_0x4b45db[_0x69a8('0x3f')]));if(!this['isConfigured'](_0x4b45db[_0x69a8('0x62')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xce'));}var _0x13ee8d='\x22'+_0x4b45db[_0x69a8('0x62')]+'\x22';if(this[_0x69a8('0xab')](_0x4b45db[_0x69a8('0x7d')])){_0x13ee8d+=','+_0x4b45db[_0x69a8('0x7d')];}var _0xcd5a22=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0xb0'),_0x13ee8d);if(_0xcd5a22[_0x69a8('0xa9')]===-0x1){return _0xcd5a22;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xcf'),_0x13ee8d));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xd2')]=function(_0xb086e8){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xd3'),_0xb086e8[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0xb086e8[_0x69a8('0xb3')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xb4'));}var _0x5e9fd9=_0xb086e8[_0x69a8('0xb3')];if(this['isConfigured'](_0xb086e8[_0x69a8('0x7d')])){_0x5e9fd9+=','+_0xb086e8[_0x69a8('0x7d')];}var _0x36b6fe=this['channel'][_0x69a8('0x5d')](_0x69a8('0xb5'),_0x5e9fd9);if(_0x36b6fe[_0x69a8('0xa9')]===-0x1){return _0x36b6fe;}var _0x8edc61=this['getAndSetVariable'](_0x69a8('0xd4'),'LUMENVOX_ASR_CONFIDENCE');if(_0x8edc61['result']===-0x1){return _0x8edc61;}var _0x19272a=this['getAndSetVariable'](_0x69a8('0xb7'),_0x69a8('0xd5'));if(_0x19272a[_0x69a8('0xa9')]===-0x1){return _0x19272a;}var _0x3588a9=this[_0x69a8('0xa8')](_0x69a8('0xb9'),_0x69a8('0xd6'));if(_0x3588a9[_0x69a8('0xa9')]===-0x1){return _0x3588a9;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xbb'),_0x5e9fd9));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xd7')]=function(_0x77b3b9){logger[_0x69a8('0x32')](util['format']('Enter\x20in\x20SESTEKASR\x20(%s)\x20block',_0x77b3b9[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x77b3b9[_0x69a8('0xb3')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20grammar\x20configured');}var _0x21cbfa=_0x77b3b9[_0x69a8('0xb3')];if(this['isConfigured'](_0x77b3b9[_0x69a8('0x7d')])){_0x21cbfa+=','+_0x77b3b9[_0x69a8('0x7d')];}var _0x4ab209=this[_0x69a8('0x3d')][_0x69a8('0x5d')]('MRCPRecog',_0x21cbfa);if(_0x4ab209[_0x69a8('0xa9')]===-0x1){return _0x4ab209;}var _0x5de5a9=this['getAndSetVariable'](_0x69a8('0xd4'),_0x69a8('0xd8'));if(_0x5de5a9[_0x69a8('0xa9')]===-0x1){return _0x5de5a9;}var _0x5c990e=this[_0x69a8('0xa8')]('RECOG_INPUT()',_0x69a8('0xd9'));if(_0x5c990e['result']===-0x1){return _0x5c990e;}var _0x32b817=this[_0x69a8('0xa8')](_0x69a8('0xb9'),_0x69a8('0xda'));if(_0x32b817[_0x69a8('0xa9')]===-0x1){return _0x32b817;}return this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')]('Executed\x20command\x20MRCPRecog\x20%s',_0x21cbfa));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xdb')]=function(_0x222718){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0xdc'),_0x222718['label']));if(!this[_0x69a8('0xab')](_0x222718[_0x69a8('0xdd')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x222718,'no\x20database\x20selected');}var _0x1a2c82=this[_0x69a8('0x1d')]['sync'](this,_0x222718[_0x69a8('0xdd')]);if(!_0x1a2c82){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x222718,_0x69a8('0xde'));}if(!this[_0x69a8('0xab')](_0x222718[_0x69a8('0x34')])){return this['channel'][_0x69a8('0x31')](_0x222718,_0x69a8('0xdf'));}var _0x16dd63=_0x222718[_0x69a8('0x34')]['replace'](/(\r\n|\n|\r)/gm,'\x20');this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')]('query:\x20%s',_0x16dd63));var _0x457eea=this[_0x69a8('0xe0')][_0x69a8('0x76')](this,_0x1a2c82,_0x16dd63);this[_0x69a8('0x3c')]['sync'](this,_0x222718,_0x16dd63);if(!this[_0x69a8('0xab')](_0x222718[_0x69a8('0xe1')])){return this['channel'][_0x69a8('0xaf')]('no\x20variable\x20selected\x20for\x20the\x20result');}var _0x1feeb9=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x222718[_0x69a8('0xe1')]);if(!_0x1feeb9){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x222718,'no\x20variable\x20found');}var _0x4197ce=this;_0x457eea[_0x69a8('0xe2')](function(_0xc7aa1,_0x1eafcc){Object[_0x69a8('0xe3')](_0xc7aa1)['forEach'](function(_0x5c8784){_0x4197ce[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0xe4'),_0x1feeb9,_0x1eafcc,_0x5c8784),_0xc7aa1[_0x5c8784]);});});this[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0xe5'),_0x1feeb9),_0x457eea[_0x69a8('0x9f')]);return this[_0x69a8('0x3d')]['noop'](util['format'](_0x69a8('0xe6'),_0x1feeb9));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xe7')]=function(_0x5b3711){logger[_0x69a8('0xe8')](util[_0x69a8('0x2f')]('Enter\x20in\x20DIAL\x20(%s)\x20block',_0x5b3711[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x5b3711[_0x69a8('0xe9')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x5b3711,'no\x20user\x20selected');}var _0x1ee36a=this['getUser'][_0x69a8('0x76')](this,_0x5b3711[_0x69a8('0xe9')]);if(!_0x1ee36a){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x5b3711,'no\x20user\x20found');}var _0x53bb35=this[_0x69a8('0x3d')]['exec'](_0x69a8('0xea'),[util[_0x69a8('0x2f')]('SIP/%s',_0x1ee36a),_0x5b3711[_0x69a8('0x6b')],_0x5b3711[_0x69a8('0xeb')],_0x5b3711['url']]);if(_0x53bb35[_0x69a8('0xa9')]===-0x1){return _0x53bb35;}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xec'),_0x69a8('0xea')));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xed')]=function(_0x52194f){logger['info'](util['format'](_0x69a8('0xee'),_0x52194f[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x52194f[_0x69a8('0x7f')])){return this[_0x69a8('0x3d')]['noop']('no\x20key\x20configured');}if(!this[_0x69a8('0xab')](_0x52194f['text'])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20text\x20configured');}this[_0x69a8('0x3d')][_0x69a8('0xef')]=!![];this[_0x69a8('0x3c')](_0x52194f);this[_0x69a8('0x48')](_0x52194f[_0x69a8('0x62')],'in','','');this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xf0'),_0x52194f[_0x69a8('0x62')]));var _0x3b800a=this[_0x69a8('0x7e')]['sync'](this,_0x52194f);if(_0x3b800a){for(var _0x62a917 in _0x3b800a){if(_0x3b800a[_0x69a8('0x99')](_0x62a917)){this[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0xf1'),_0x62a917[_0x69a8('0x6f')]()),_0x3b800a[_0x62a917]);}}this[_0x69a8('0x48')](_0x3b800a[_0x69a8('0xf2')],_0x69a8('0xf3'),_0x69a8('0xed'),'');return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xf4'),_0x3b800a['speech']));}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x52194f,_0x69a8('0xf5'));};AGIVertices['prototype']['dialogflowV2']=function(_0x3788e0){logger[_0x69a8('0x32')](util['format'](_0x69a8('0xf6'),_0x3788e0[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x3788e0[_0x69a8('0xf7')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20project_id\x20configured');}if(!this[_0x69a8('0xab')](_0x3788e0[_0x69a8('0x82')])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0xf8'));}if(!this[_0x69a8('0xab')](_0x3788e0['private_key'])){return this[_0x69a8('0x3d')]['noop']('no\x20private_key\x20configured');}if(!this[_0x69a8('0xab')](_0x3788e0[_0x69a8('0x84')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xf9'));}if(!this[_0x69a8('0xab')](_0x3788e0[_0x69a8('0x62')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xce'));}this[_0x69a8('0x3d')][_0x69a8('0xef')]=!![];this['createSquareDetailsReport'](_0x3788e0);this[_0x69a8('0x48')](_0x3788e0[_0x69a8('0x62')],'in','','');this['channel']['noop'](util[_0x69a8('0x2f')](_0x69a8('0xfa'),_0x3788e0[_0x69a8('0x62')]));var _0x51d4d3=this['googleDialogflowV2'][_0x69a8('0x76')](this,_0x3788e0);if(_0x51d4d3){for(var _0x57ceb0 in _0x51d4d3){if(_0x51d4d3[_0x69a8('0x99')](_0x57ceb0)){if(_0x57ceb0!==_0x69a8('0xfb')){this[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0xf1'),_0x57ceb0['toUpperCase']()),_0x51d4d3[_0x57ceb0]);}}}this[_0x69a8('0x48')](_0x51d4d3[_0x69a8('0xf2')],_0x69a8('0xf3'),_0x69a8('0xfc'),_0x51d4d3['providerResponse']);return this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')](_0x69a8('0xfd'),_0x51d4d3[_0x69a8('0xf2')]));}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x3788e0,_0x69a8('0xfe'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0xff')]=function(_0x5147c9){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20SESTEKNDA\x20(%s)\x20block',_0x5147c9[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x5147c9[_0x69a8('0x100')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x101'));}if(!this['isConfigured'](_0x5147c9['username'])){return this['channel'][_0x69a8('0xaf')](_0x69a8('0x102'));}if(!this[_0x69a8('0xab')](_0x5147c9[_0x69a8('0x103')])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0x104'));}if(!this[_0x69a8('0xab')](_0x5147c9[_0x69a8('0x105')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xce'));}this['channel'][_0x69a8('0xef')]=!![];this[_0x69a8('0x3c')](_0x5147c9);this[_0x69a8('0x48')](_0x5147c9[_0x69a8('0x62')],'in','','');this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0x106'),_0x5147c9[_0x69a8('0x62')]));var _0x1c26f5=this[_0x69a8('0x85')][_0x69a8('0x76')](this,_0x5147c9);if(_0x1c26f5){for(var _0xaf1fef in _0x1c26f5){if(_0x1c26f5[_0x69a8('0x99')](_0xaf1fef)){this['channel']['setVariable'](util[_0x69a8('0x2f')](_0x69a8('0x107'),_0xaf1fef['toUpperCase']()),_0x1c26f5[_0xaf1fef]);}}this[_0x69a8('0x48')](_0x1c26f5['speech'],_0x69a8('0xf3'),_0x69a8('0xff'),'');if(_0x1c26f5['audiofile']){this['channel'][_0x69a8('0xaf')](util['format']('Sestek\x20NDA\x20%s\x20file\x20created',_0x1c26f5[_0x69a8('0x108')]));var _0x57556=this[_0x69a8('0x3d')][_0x69a8('0x109')](_0x1c26f5[_0x69a8('0x108')]);try{fs['unlink'](_0x1c26f5[_0x69a8('0x108')]+_0x69a8('0x10a'));}catch(_0x3c2f56){logger[_0x69a8('0x31')](_0x3c2f56);}return _0x57556;}else{return this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')](_0x69a8('0x10b'),_0x1c26f5[_0x69a8('0xf2')]));}}return this[_0x69a8('0x3d')]['error'](_0x5147c9,_0x69a8('0x10c'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x10d')]=function(_0x249899){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x10e'),_0x249899[_0x69a8('0x3f')]));return this['channel'][_0x69a8('0xaf')]('end');};AGIVertices[_0x69a8('0x16')]['ext_dial']=function(_0x52bfb4){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x10f'),_0x52bfb4[_0x69a8('0x3f')]));var _0x7c6ab3='';if(_0x52bfb4[_0x69a8('0x110')]){if(!this[_0x69a8('0xab')](_0x52bfb4['trunk_id'])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x52bfb4,'no\x20trunk\x20selected');}else{var _0x4c5224=parseInt(_0x52bfb4['trunk_id'],0xa);if(isNaN(_0x4c5224)){_0x7c6ab3=_0x52bfb4[_0x69a8('0x110')];}else{_0x7c6ab3=this[_0x69a8('0x21')][_0x69a8('0x76')](this,_0x52bfb4['trunk_id']);if(!_0x7c6ab3){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x52bfb4,_0x69a8('0x111'));}}}}else if(_0x52bfb4[_0x69a8('0x112')]){_0x7c6ab3=_0x52bfb4['trunk_name'];}else{return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x52bfb4,_0x69a8('0x113'));}var _0x390bce=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0xea'),[util[_0x69a8('0x2f')]('SIP/%s/%s',_0x7c6ab3,_0x52bfb4[_0x69a8('0x4e')]),_0x52bfb4['timeout'],_0x52bfb4[_0x69a8('0xeb')],_0x52bfb4[_0x69a8('0x6a')]]);if(_0x390bce[_0x69a8('0xa9')]===-0x1){return _0x390bce;}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0xec'),_0x69a8('0xea')));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x114')]=function(_0xca71f2){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x115'),_0xca71f2[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x114'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x10')]=function(_0x432f71){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x116'),_0x432f71[_0x69a8('0x3f')]));if(_0x432f71[_0x69a8('0xad')]===0x0){return this[_0x69a8('0xac')](_0x432f71);}_0x432f71[_0x69a8('0xad')]-=0x1;if(!this['isConfigured'](_0x432f71['file_id'])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x432f71,_0x69a8('0x117'));}var _0x4ecfbd=this[_0x69a8('0x23')]['sync'](this,_0x432f71[_0x69a8('0x118')]);if(!_0x4ecfbd){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x432f71,_0x69a8('0x119'));}if(!this[_0x69a8('0xab')](_0x432f71['variable_id'])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x69a8('0x11a'));}var _0x55cb1e=this[_0x69a8('0x3d')]['getData'](_0x4ecfbd,_0x432f71[_0x69a8('0x11b')],_0x432f71[_0x69a8('0x11c')]);var _0x3e060c=_0x55cb1e[_0x69a8('0xa9')]?_0x55cb1e[_0x69a8('0xa9')]['toString']():'';logger[_0x69a8('0x32')](_0x69a8('0x11d'),JSON[_0x69a8('0x79')](_0x55cb1e));if(_0x55cb1e[_0x69a8('0xa9')]===-0x1){this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x432f71,_0x3e060c);return _0x55cb1e;}else if(_0x55cb1e['extra']==='timeout'){_0x55cb1e[_0x69a8('0xa9')]=_0x3e060c['length']>=parseInt(_0x432f71[_0x69a8('0x11e')])?'x':'i';}else{_0x55cb1e[_0x69a8('0xa9')]=_0x3e060c[_0x69a8('0x9f')]>=parseInt(_0x432f71[_0x69a8('0x11e')])&&_0x3e060c[_0x69a8('0x9f')]<=parseInt(_0x432f71['maxdigit'])?'x':'i';}var _0x3d3d62=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x432f71[_0x69a8('0xe1')]);if(!_0x3d3d62){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x432f71,_0x69a8('0x11f'));}this[_0x69a8('0x3d')]['setVariable'](_0x3d3d62,_0x3e060c);if(this[_0x69a8('0xab')](_0x432f71['hiddendigitsnum'])){var _0x1192bd=parseInt(_0x432f71['hiddendigitsnum'],0xa);var _0xc014d7=rs[_0x69a8('0x120')]({'charset':'*','length':_0x1192bd});var _0x45535a=_0x3e060c[_0x69a8('0x9f')];if(_0x45535a>0x0){if(_0x45535a>_0x1192bd){this[_0x69a8('0x3c')]['sync'](this,_0x432f71,_0x432f71['hiddendigitspos']===_0x69a8('0x121')?_0xc014d7+_0x3e060c[_0x69a8('0x122')](_0x1192bd):_0x3e060c['substr'](0x0,_0x45535a-_0x1192bd)+_0xc014d7);}else{this[_0x69a8('0x3c')]['sync'](this,_0x432f71,rs[_0x69a8('0x120')]({'charset':'*','length':_0x45535a}));}}else{this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x432f71,'');}}else{this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x432f71,_0x3e060c);}return _0x55cb1e;};AGIVertices[_0x69a8('0x16')]['getsecretdigits']=function(_0x5d7de9){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x123'),_0x5d7de9[_0x69a8('0x3f')]));return this['getdigits'](_0x5d7de9);};AGIVertices[_0x69a8('0x16')][_0x69a8('0x124')]=function(_0x3d6cb7){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20GOAL\x20(%s)\x20block',_0x3d6cb7[_0x69a8('0x3f')]));this[_0x69a8('0x3c')]['sync'](this,_0x3d6cb7,_0x3d6cb7['goalname']);return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x125'),_0x3d6cb7[_0x69a8('0x126')]));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x127')]=function(_0x3e4170){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('[AGI]\x20Enter\x20in\x20AWSPOLLY\x20(%s)\x20block',_0x3e4170[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x3e4170[_0x69a8('0x8d')])||!this[_0x69a8('0xab')](_0x3e4170[_0x69a8('0x8e')])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0x128'));}if(!this[_0x69a8('0xab')](_0x3e4170[_0x69a8('0x62')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0xce'));}this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x129'),_0x3e4170['text']));var _0x215a53=this[_0x69a8('0x8c')][_0x69a8('0x76')](this,_0x3e4170);if(_0x215a53){this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x12a'),_0x215a53));var _0x38ebc8=this[_0x69a8('0x3d')][_0x69a8('0x109')](_0x215a53);try{fs[_0x69a8('0x12b')](_0x215a53+'.wav');}catch(_0x447f41){logger[_0x69a8('0x31')](_0x447f41);}return _0x38ebc8;}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x3e4170,_0x69a8('0x12c'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x12d')]=function(_0x31b975){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x12e'),_0x31b975[_0x69a8('0x3f')]));if(!this['isConfigured'](_0x31b975[_0x69a8('0x8d')])||!this[_0x69a8('0xab')](_0x31b975[_0x69a8('0x8e')])){return this['channel']['noop']('no\x20valid\x20credentials\x20configured');}if(!this[_0x69a8('0xab')](_0x31b975[_0x69a8('0x93')])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0x12f'));}if(!this[_0x69a8('0xab')](_0x31b975[_0x69a8('0x62')])){return this[_0x69a8('0x3d')]['noop']('no\x20text\x20configured');}this[_0x69a8('0x3d')][_0x69a8('0xef')]=!![];this['createSquareDetailsReport'](_0x31b975);this[_0x69a8('0x48')](_0x31b975[_0x69a8('0x62')],'in','','');this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')]('Trying\x20Amazon\x20Lex:\x20%s',_0x31b975[_0x69a8('0x62')]));var _0x20e7ac=this['awsLex'][_0x69a8('0x76')](this,_0x31b975);if(_0x20e7ac){for(var _0x4bba8b in _0x20e7ac){if(_0x20e7ac[_0x69a8('0x99')](_0x4bba8b)&&_[_0x69a8('0x9a')](_0x20e7ac[_0x4bba8b])){this[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')]('AWS_LEX_%s',_0x4bba8b['toUpperCase']()),_0x20e7ac[_0x4bba8b]);}}if(_[_0x69a8('0x4a')](_0x20e7ac[_0x69a8('0x7c')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('Amazon\x20Lex\x20ready\x20for\x20fulfillment');}else{this[_0x69a8('0x48')](_0x20e7ac[_0x69a8('0x7c')],_0x69a8('0xf3'),_0x69a8('0x130'),'');return this['channel']['noop'](util['format'](_0x69a8('0x131'),_0x20e7ac[_0x69a8('0x7c')]));}}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x31b975,_0x69a8('0x132'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x133')]=function(_0x4f13c2){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x134'),_0x4f13c2[_0x69a8('0x3f')],_0x4f13c2['timeout']));if(!this[_0x69a8('0xab')](_0x4f13c2[_0x69a8('0x7f')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x135'));}var _0x350bcf=_0x69a8('0x136');var _0x1b5bd0=util[_0x69a8('0x2f')](_0x69a8('0x137'),FILES_PATH,rs[_0x69a8('0x120')](0x4));var _0x13e979=util[_0x69a8('0x2f')](_0x69a8('0xa2'),_0x1b5bd0,_0x350bcf);var _0x4a4cfc=!![];if(_0x4f13c2[_0x69a8('0x138')]===_0x69a8('0x139')){_0x4a4cfc=![];}var _0x44e406=this[_0x69a8('0x3d')]['recordFile'](_0x1b5bd0,_0x350bcf,_0x4f13c2['intKey'],_0x4f13c2['timeout'],undefined,_0x4a4cfc);if(_0x44e406[_0x69a8('0xa9')]!==-0x1){this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x13a'),_0x13e979));var _0x14961a=this[_0x69a8('0x94')][_0x69a8('0x76')](this,_0x4f13c2,_0x13e979);if(_0x14961a){for(var _0x5ee7a7 in _0x14961a){if(_0x14961a[_0x69a8('0x99')](_0x5ee7a7)){this[_0x69a8('0x3d')]['setVariable'](util[_0x69a8('0x2f')](_0x69a8('0x13b'),_0x5ee7a7[_0x69a8('0x6f')]()),_0x14961a[_0x5ee7a7]);}}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x13c'),JSON[_0x69a8('0x79')](_0x14961a)));}}return _0x44e406;};AGIVertices[_0x69a8('0x16')]['tildeasr']=function(_0xf0870e){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x13d'),_0xf0870e[_0x69a8('0x3f')]));if(!this['isConfigured'](_0xf0870e[_0x69a8('0x95')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x13e'));}if(!this[_0x69a8('0xab')](_0xf0870e['appsecret'])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0x13f'));}var _0x21ddb9=_0x69a8('0x136');var _0x12ad9a=util['format']('%s/recordings/%s',FILES_PATH,rs[_0x69a8('0x120')](0x4));var _0x46b80d=util[_0x69a8('0x2f')](_0x69a8('0xa2'),_0x12ad9a,_0x21ddb9);var _0x32b584=!![];if(_0xf0870e[_0x69a8('0x138')]===_0x69a8('0x139')){_0x32b584=![];}var _0x31c922=this[_0x69a8('0x3d')][_0x69a8('0x140')](_0x12ad9a,_0x21ddb9,_0xf0870e['intKey'],_0xf0870e[_0x69a8('0x6b')],undefined,_0x32b584);if(_0x31c922['result']!==-0x1){this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')](_0x69a8('0x141'),_0x46b80d));var _0x39d90c=this['tildeASR'][_0x69a8('0x76')](this,_0xf0870e,_0x46b80d);if(_0x39d90c){for(var _0x125a06 in _0x39d90c){if(_0x39d90c['hasOwnProperty'](_0x125a06)){this['channel'][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0x142'),_0x125a06['toUpperCase']()),_0x39d90c[_0x125a06]);}}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('TildeASR\x20Result\x20%s',JSON[_0x69a8('0x79')](_0x39d90c)));}}return _0x31c922;};AGIVertices[_0x69a8('0x16')][_0x69a8('0x143')]=function(_0x182cb4){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x144'),_0x182cb4['label']));return this[_0x69a8('0x3d')][_0x69a8('0x145')](_0x182cb4[_0x69a8('0x146')],_0x182cb4['extension'],_0x182cb4[_0x69a8('0x147')]);};AGIVertices[_0x69a8('0x16')]['gotoif']=function(_0x511ce6){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20GOTOIF\x20(%s)\x20block',_0x511ce6[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x511ce6['condition'])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x511ce6,_0x69a8('0x148'));}try{var _0x4083c=eval(_0x511ce6[_0x69a8('0x149')])?_0x69a8('0x14a'):'false';this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('EVAL\x20CONDITION\x20%s\x20%s',_0x511ce6[_0x69a8('0x149')],_0x4083c));return{'code':0xc8,'result':_0x4083c};}catch(_0x4d27bf){return{'code':0xc8,'result':_0x69a8('0x14b')};}};AGIVertices[_0x69a8('0x16')][_0x69a8('0x14c')]=function(_0x37873c){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x14d'),_0x37873c['label']));if(!this[_0x69a8('0xab')](_0x37873c[_0x69a8('0x14e')])){return this['channel'][_0x69a8('0x31')](_0x37873c,_0x69a8('0x14f'));}var _0x520718=this[_0x69a8('0x29')]['sync'](this,_0x37873c[_0x69a8('0x14e')]);if(!_0x520718){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x37873c,'no\x20intervals\x20found');}for(var _0x531237=0x0;_0x531237<_0x520718[_0x69a8('0x9f')];_0x531237+=0x1){var _0x6cd28d=this[_0x69a8('0x3d')][_0x69a8('0xa6')](util[_0x69a8('0x2f')](_0x69a8('0x150'),_0x520718[_0x531237]));if(_0x6cd28d[_0x69a8('0xa9')]===-0x1){return _0x6cd28d;}logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x151'),_0x520718[_0x531237],_0x6cd28d[_0x69a8('0xa7')]));if(_0x6cd28d[_0x69a8('0xa7')]===_0x69a8('0x14a')){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x151'),_0x520718[_0x531237],_0x69a8('0x14a')));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('IFTIME\x20%s\x20%s',_0x520718[_0x531237],'true'));return{'code':0xc8,'result':'true'};}else{logger[_0x69a8('0x32')](util['format'](_0x69a8('0x151'),_0x520718[_0x531237],_0x69a8('0x14b')));this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('IFTIME\x20%s\x20%s',_0x520718[_0x531237],_0x69a8('0x14b')));}}return{'code':0xc8,'result':_0x69a8('0x14b')};};AGIVertices[_0x69a8('0x16')]['hangup']=function(_0x5ddceb){logger[_0x69a8('0x32')](util['format']('Enter\x20in\x20HANGUP\x20(%s)\x20block',_0x5ddceb['label']));return this['channel']['hangup']();};AGIVertices['prototype'][_0x69a8('0x152')]=function(_0x4c0b76){logger[_0x69a8('0x32')](util['format']('Enter\x20in\x20ISPEECHASR\x20(%s)\x20block',_0x4c0b76[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x4c0b76[_0x69a8('0x7f')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20key\x20configured');}var _0x557ff0=_0x69a8('0x136');var _0x286071=util[_0x69a8('0x2f')](_0x69a8('0x137'),FILES_PATH,rs[_0x69a8('0x120')](0x4));var _0xd31a40=util['format'](_0x69a8('0xa2'),_0x286071,_0x557ff0);var _0x2dc245=!![];if(_0x4c0b76[_0x69a8('0x138')]==='NOBEEP'){_0x2dc245=![];}var _0x536464=this['channel'][_0x69a8('0x140')](_0x286071,_0x557ff0,_0x4c0b76['intKey'],_0x4c0b76[_0x69a8('0x6b')],undefined,_0x2dc245);if(_0x536464['result']!==-0x1){this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0x153'),_0xd31a40));var _0x5ba675=this[_0x69a8('0x88')][_0x69a8('0x76')](this,_0x4c0b76,_0xd31a40);if(_0x5ba675){for(var _0x4e6a42 in _0x5ba675){if(_0x5ba675[_0x69a8('0x99')](_0x4e6a42)){this[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0x154'),_0x4e6a42[_0x69a8('0x6f')]()),_0x5ba675[_0x4e6a42]);}}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x155'),JSON[_0x69a8('0x79')](_0x5ba675)));}}return _0x536464;};AGIVertices['prototype'][_0x69a8('0x156')]=function(_0x2f1ae1){logger['info'](util[_0x69a8('0x2f')]('Enter\x20in\x20ISPEECHTTS\x20(%s)\x20block',_0x2f1ae1[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2f1ae1[_0x69a8('0x7f')])){return this['channel'][_0x69a8('0xaf')](_0x69a8('0x135'));}if(!this[_0x69a8('0xab')](_0x2f1ae1[_0x69a8('0x62')])){return this['channel'][_0x69a8('0xaf')](_0x69a8('0xce'));}this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0x157'),_0x2f1ae1['text']));var _0x5afa47=this[_0x69a8('0x86')]['sync'](this,_0x2f1ae1);if(_0x5afa47){this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x153'),_0x5afa47));var _0x554ffb=this['channel'][_0x69a8('0x109')](_0x5afa47,_0x2f1ae1[_0x69a8('0x158')]);try{fs[_0x69a8('0x12b')](_0x5afa47+'.wav');}catch(_0xe6d53d){logger['error'](_0xe6d53d);}return _0x554ffb;}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x2f1ae1,_0x69a8('0x159'));};AGIVertices['prototype'][_0x69a8('0x15a')]=function(_0x2e090f){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x15b'),_0x2e090f[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2e090f[_0x69a8('0x15c')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x2e090f,'no\x20find\x20by\x20configured');}logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x15d'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x2e090f[_0x69a8('0x15c')]));var _0x5ea3a8=this['agentLogin']['sync'](this,_0x2e090f[_0x69a8('0x15c')]);if(_0x5ea3a8){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('AGENT\x20%s\x20FOUND\x20BY',this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x2e090f[_0x69a8('0x15c')]));this['channel']['noop'](util[_0x69a8('0x2f')](_0x69a8('0x15e'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x2e090f['findBy']));return{'code':0xc8,'result':_0x69a8('0x15f')};}else{logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x160'),this['channel'][_0x69a8('0x42')],_0x2e090f[_0x69a8('0x15c')]));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('AGENT\x20%s\x20NOT\x20FOUND\x20BY',this[_0x69a8('0x3d')]['callerid'],_0x2e090f['findBy']));return{'code':0xc8,'result':'failure'};}};AGIVertices[_0x69a8('0x16')][_0x69a8('0x161')]=function(_0xa5123e){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x162'),_0xa5123e[_0x69a8('0x3f')]));if(!this['isConfigured'](_0xa5123e[_0x69a8('0x15c')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0xa5123e,_0x69a8('0x163'));}logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x15d'),this[_0x69a8('0x3d')]['callerid'],_0xa5123e[_0x69a8('0x15c')]));var _0x239d37=this[_0x69a8('0x58')][_0x69a8('0x76')](this,_0xa5123e[_0x69a8('0x15c')]);if(_0x239d37){logger[_0x69a8('0x32')](util['format']('AGENT\x20%s\x20FOUND\x20BY',this[_0x69a8('0x3d')]['callerid'],_0xa5123e[_0x69a8('0x15c')]));this['channel'][_0x69a8('0xaf')](util['format'](_0x69a8('0x15e'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0xa5123e[_0x69a8('0x15c')]));return{'code':0xc8,'result':_0x69a8('0x15f')};}else{logger[_0x69a8('0x32')](util['format'](_0x69a8('0x160'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0xa5123e['findBy']));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x160'),this[_0x69a8('0x3d')]['callerid'],_0xa5123e[_0x69a8('0x15c')]));return{'code':0xc8,'result':_0x69a8('0x164')};}};AGIVertices[_0x69a8('0x16')][_0x69a8('0x165')]=function(_0x3b1ab2){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x166'),_0x3b1ab2['label']));if(!this['isConfigured'](_0x3b1ab2[_0x69a8('0x167')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x3b1ab2,_0x69a8('0x168'));}this[_0x69a8('0x3d')]['noop'](util['format']('math\x20%s',_0x3b1ab2[_0x69a8('0x167')]));var _0x45f388=eval(_0x3b1ab2['operation']);if(!this[_0x69a8('0xab')](_0x3b1ab2['variable_id'])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x11a'));}var _0x2f23ee=this[_0x69a8('0xa6')]['sync'](this,_0x3b1ab2[_0x69a8('0xe1')]);if(!_0x2f23ee){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x3b1ab2,'no\x20variable\x20found');}if(_[_0x69a8('0x9e')](_0x45f388)){var _0x544243=this;_0x45f388['forEach'](function(_0x567b6e,_0x526d79){_0x544243[_0x69a8('0x3d')][_0x69a8('0xa3')](util[_0x69a8('0x2f')](_0x69a8('0x169'),_0x2f23ee,_0x526d79),_0x567b6e);});return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x16a'),_0x2f23ee));}else{return this['channel'][_0x69a8('0xa3')](_0x2f23ee,_0x45f388);}};AGIVertices[_0x69a8('0x16')][_0x69a8('0xf')]=function(_0x32d28d){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x16b'),_0x32d28d[_0x69a8('0x3f')]));if(_0x32d28d[_0x69a8('0xad')]===0x0){return this[_0x69a8('0xac')](_0x32d28d);}_0x32d28d['retry']-=0x1;if(!this[_0x69a8('0xab')](_0x32d28d[_0x69a8('0x118')])){return this[_0x69a8('0x3d')]['error'](_0x32d28d,'no\x20file\x20audio\x20selected');}var _0x2d19a1=this[_0x69a8('0x23')][_0x69a8('0x76')](this,_0x32d28d[_0x69a8('0x118')]);if(!_0x2d19a1){return this['channel'][_0x69a8('0x31')](_0x32d28d,_0x69a8('0x119'));}var _0x34f90c=this[_0x69a8('0x3d')]['getData'](_0x2d19a1,_0x32d28d[_0x69a8('0x11b')],_0x32d28d['digit']);var _0x1d96f9=_0x34f90c['result'];if(_0x34f90c[_0x69a8('0xa9')]===-0x1){this[_0x69a8('0x3c')]['sync'](this,_0x32d28d,'-1');return _0x34f90c;}else if(_0x34f90c['extra']===_0x69a8('0x6b')){_0x34f90c[_0x69a8('0xa9')]=_0x34f90c[_0x69a8('0xa9')]['length']>0x0?_0x34f90c[_0x69a8('0xa9')]:'t';}else if(_[_0x69a8('0x4c')](_0x34f90c['result'])){_0x34f90c['result']='#';_0x1d96f9='#';}if(!this[_0x69a8('0xab')](_0x32d28d[_0x69a8('0xe1')])){this[_0x69a8('0x3d')]['noop'](_0x69a8('0x11a'));}else{var _0x5832d0=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x32d28d[_0x69a8('0xe1')]);if(!_0x5832d0){return this[_0x69a8('0x3d')]['error'](_0x32d28d,'no\x20variable\x20found');}this['channel']['setVariable'](_0x5832d0,_0x1d96f9);}this[_0x69a8('0x3c')]['sync'](this,_0x32d28d,_0x1d96f9);return _0x34f90c;};AGIVertices[_0x69a8('0x16')][_0x69a8('0xaf')]=function(_0x2e8027){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x16c'),_0x2e8027[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x2e8027['output']||_0x2e8027[_0x69a8('0x3f')]);};AGIVertices[_0x69a8('0x16')][_0x69a8('0x16d')]=function(_0x34f8e3){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x16e'),_0x34f8e3['label']));if(!this[_0x69a8('0xab')](_0x34f8e3[_0x69a8('0x15c')])){return this[_0x69a8('0x3d')]['error'](_0x34f8e3,'no\x20find\x20by\x20configured');}logger['info'](util['format'](_0x69a8('0x15d'),this['channel'][_0x69a8('0x42')],_0x34f8e3[_0x69a8('0x15c')]));var _0x2d4df3=this[_0x69a8('0x16f')]['sync'](this,_0x34f8e3[_0x69a8('0x170')]);var _0x1937e6=this[_0x69a8('0x55')][_0x69a8('0x76')](this,_0x34f8e3['findBy'],_0x2d4df3);if(_0x1937e6){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x15e'),this['channel']['callerid'],_0x34f8e3[_0x69a8('0x15c')]));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('AGENT\x20%s\x20FOUND\x20BY',this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x34f8e3['findBy']));return{'code':0xc8,'result':_0x69a8('0x15f')};}else{logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x160'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x34f8e3[_0x69a8('0x15c')]));this[_0x69a8('0x3d')]['noop'](util[_0x69a8('0x2f')]('AGENT\x20%s\x20FOUND\x20BY',this[_0x69a8('0x3d')]['callerid'],_0x34f8e3[_0x69a8('0x15c')]));return{'code':0xc8,'result':_0x69a8('0x164')};}};AGIVertices[_0x69a8('0x16')][_0x69a8('0x171')]=function(_0x1988ce){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20PLAYBACK\x20(%s)\x20block',_0x1988ce[_0x69a8('0x3f')]));if(!this['isConfigured'](_0x1988ce['file_id'])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x1988ce,'no\x20file\x20audio\x20selected');}var _0x4cc684=this[_0x69a8('0x23')][_0x69a8('0x76')](this,_0x1988ce[_0x69a8('0x118')]);if(!_0x4cc684){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x1988ce,_0x69a8('0x119'));}var _0x53c794=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0x172'),[_0x4cc684,_0x1988ce[_0x69a8('0xeb')]]);if(_0x53c794['result']===-0x1){return _0x53c794;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format']('Executed\x20command\x20%s\x20%s',_0x69a8('0x172'),_0x4cc684));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x173')]=function(_0x1cf507){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x174'),_0x1cf507[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x1cf507[_0x69a8('0x175')])){return this['channel'][_0x69a8('0x31')](_0x1cf507,_0x69a8('0x176'));}var _0x4d1e31='';var _0x3674f2=parseInt(_0x1cf507[_0x69a8('0x175')],0xa);if(isNaN(_0x3674f2)){_0x4d1e31=_0x1cf507[_0x69a8('0x175')];}else{_0x4d1e31=this['getVoiceQueue'][_0x69a8('0x76')](this,_0x1cf507[_0x69a8('0x175')]);if(!_0x4d1e31){return this['channel'][_0x69a8('0x31')](_0x1cf507,_0x69a8('0x177'));}}var _0x153a4b='';if(this['isConfigured'](_0x1cf507['file_id'])){var _0x38f10a=this[_0x69a8('0x23')][_0x69a8('0x76')](this,_0x1cf507[_0x69a8('0x118')]);if(_0x38f10a){_0x153a4b=_0x38f10a;}}this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x1cf507,_0x4d1e31);if(_0x1cf507[_0x69a8('0xeb')][_0x69a8('0x178')]('x')<0x0){_0x1cf507['opts']+='x';}if(_0x1cf507[_0x69a8('0xeb')][_0x69a8('0x178')]('X')<0x0){_0x1cf507[_0x69a8('0xeb')]+='X';}this[_0x69a8('0x3d')][_0x69a8('0xa3')]('XMCS-QUEUE',_0x4d1e31?_0x4d1e31['toLowerCase']():'');var _0x24706f=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0x179'),[_0x4d1e31,_0x1cf507['opts'],_0x1cf507[_0x69a8('0x6a')],_0x153a4b,_0x1cf507[_0x69a8('0x6b')],_0x1cf507[_0x69a8('0x8')],_0x1cf507[_0x69a8('0x17a')],_0x1cf507[_0x69a8('0x17b')],'',_0x1cf507['position']]);if(_0x24706f[_0x69a8('0xa9')]===-0x1){return _0x24706f;}return this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Executed\x20command\x20%s\x20%s',_0x69a8('0x179'),_0x4d1e31));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x17c')]=function(_0x6b82b9){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20RECORD\x20(%s)\x20block',_0x6b82b9[_0x69a8('0x3f')]));var _0x1eb0c8=_0x6b82b9[_0x69a8('0x17d')]||'wav';var _0x340916=util['format'](_0x69a8('0x17e'),this[_0x69a8('0x3d')][_0x69a8('0x3e')],rs[_0x69a8('0x120')](0x5));var _0x13b280=util['format']('%s/recordings/%s.%s',FILES_PATH,_0x340916,_0x1eb0c8);var _0x378c0b=util['format'](_0x69a8('0x137'),FILES_PATH,_0x340916);this[_0x69a8('0x41')]['sync'](this,_0x6b82b9,_0x340916,_0x13b280);this[_0x69a8('0x3d')][_0x69a8('0xa3')]('RECORDING_SAVENAME',_0x340916);logger['info'](_0x69a8('0x17f'),_0x378c0b,_0x1eb0c8,_0x6b82b9[_0x69a8('0x180')],_0x6b82b9[_0x69a8('0x6b')]);return this[_0x69a8('0x3d')][_0x69a8('0x140')](_0x378c0b,_0x1eb0c8,_0x6b82b9[_0x69a8('0x180')],_0x6b82b9[_0x69a8('0x6b')],undefined,!![]);};AGIVertices[_0x69a8('0x16')][_0x69a8('0x181')]=function(_0x2bd875){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x182'),_0x2bd875[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2bd875['url'])){return this[_0x69a8('0x3d')]['noop'](_0x69a8('0x183'));}var _0x230dba=this[_0x69a8('0x69')][_0x69a8('0x76')](this,_0x2bd875);logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x184'),util[_0x69a8('0x185')](_0x230dba,{'showHidden':![],'depth':null})));if(!this[_0x69a8('0xab')](_0x2bd875[_0x69a8('0xe1')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x186'));}var _0x33884c=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x2bd875[_0x69a8('0xe1')]);if(!_0x33884c){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x2bd875,'no\x20variable\x20found');}this[_0x69a8('0x3d')][_0x69a8('0xa3')](util['format']('%s_STATUS_CODE',_0x33884c),_0x230dba[_0x69a8('0x7b')]?_0x230dba[_0x69a8('0x7b')]:_0x69a8('0x187'));this[_0x69a8('0x3d')]['setVariable'](util[_0x69a8('0x2f')](_0x69a8('0x188'),_0x33884c),_0x230dba[_0x69a8('0x189')]?_0x230dba['statusMessage']:'OK');if(_0x230dba[_0x69a8('0x70')]){try{this[_0x69a8('0xa0')](_0x230dba[_0x69a8('0x70')],_0x33884c);}catch(_0x4d6859){logger[_0x69a8('0x31')](util['format'](_0x69a8('0x18a'),_0x33884c));}}return this[_0x69a8('0x3d')]['noop'](util['format'](_0x69a8('0xe6'),_0x33884c));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x18b')]=function(_0x4b7367){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x18c'),_0x4b7367[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')][_0x69a8('0x18d')](_0x4b7367[_0x69a8('0x18e')][_0x69a8('0x5f')](/\s+/g,''),_0x4b7367['escape_digits']);};AGIVertices[_0x69a8('0x16')][_0x69a8('0x18f')]=function(_0xb5b926){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x190'),_0xb5b926[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')][_0x69a8('0x191')](_0xb5b926['number'][_0x69a8('0x5f')](/\s+/g,''),_0xb5b926['escape_digits']);};AGIVertices[_0x69a8('0x16')]['sayphonetic']=function(_0x39a135){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x192'),_0x39a135[_0x69a8('0x3f')]));return this[_0x69a8('0x3d')]['sayPhonetic'](_0x39a135[_0x69a8('0x62')],_0x39a135[_0x69a8('0x180')]);};AGIVertices['prototype'][_0x69a8('0x193')]=function(_0x4c1fad){logger['info'](util['format'](_0x69a8('0x194'),_0x4c1fad['label']));if(!this[_0x69a8('0xab')](_0x4c1fad[_0x69a8('0x195')])){return this['channel'][_0x69a8('0xaf')](_0x69a8('0x196'));}var _0x4b1bfd=this['getMailAccount'][_0x69a8('0x76')](this,_0x4c1fad['account_id']);if(!_0x4b1bfd||!_0x4b1bfd[_0x69a8('0x197')]){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x4c1fad,_0x69a8('0x198'));}var _0x3b6b20={'from':util[_0x69a8('0x2f')](_0x69a8('0x199'),_0x4b1bfd[_0x69a8('0x15')],_0x4b1bfd[_0x69a8('0x19a')]||_0x4b1bfd[_0x69a8('0x197')][_0x69a8('0x19b')]),'to':_0x4c1fad['to']||'','cc':_0x4c1fad['cc']||'','bcc':_0x4c1fad[_0x69a8('0x19c')]||'','subject':_0x4c1fad[_0x69a8('0x19d')],'html':_0x4c1fad[_0x69a8('0x62')],'text':_0x4c1fad[_0x69a8('0x62')]};if(this[_0x69a8('0xab')](_0x4c1fad['template_id'])){}logger['debug'](_0x69a8('0x19e'),JSON[_0x69a8('0x79')](_0x3b6b20));this['createSquareDetailsReport'][_0x69a8('0x76')](this,_0x4c1fad,_0x4c1fad[_0x69a8('0x195')]);this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x19f'),_0x4b1bfd[_0x69a8('0x15')]));this[_0x69a8('0x28')][_0x69a8('0x76')](this,_0x4b1bfd['smtpOptions'],_0x3b6b20);return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x1a0'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1a1')]=function(_0x2ef7a3){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x1a2'),_0x2ef7a3[_0x69a8('0x3f')]));return this['channel'][_0x69a8('0xaf')](_0x69a8('0x1a3'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1a4')]=function(_0xbd2572){logger[_0x69a8('0x32')](util['format']('Enter\x20in\x20SENDSMS\x20(%s)\x20block',_0xbd2572[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0xbd2572[_0x69a8('0x1a5')])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x1a6'));}var _0x587adc=this[_0x69a8('0x39')][_0x69a8('0x76')](this,_0xbd2572[_0x69a8('0x1a5')]);if(!_0x587adc){return this[_0x69a8('0x3d')]['error'](_0xbd2572,_0x69a8('0x1a7'));}var _0x97fff3={'body':_0xbd2572[_0x69a8('0x1a8')],'phone':_0xbd2572['to']||'','SmsAccountId':_0x587adc['id']};logger[_0x69a8('0xe8')](_0x69a8('0x1a9'),JSON[_0x69a8('0x79')](_0x97fff3));this['createSquareDetailsReport'][_0x69a8('0x76')](this,_0xbd2572,_0xbd2572[_0x69a8('0x1a5')]);this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Trying\x20SendSMS\x20with\x20account\x20%s',_0x587adc[_0x69a8('0x15')]));this[_0x69a8('0x3b')]['sync'](this,_0x97fff3);return this['channel'][_0x69a8('0xaf')]('Sms\x20message\x20added\x20to\x20outgoing\x20process');};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1aa')]=function(_0x2e9ea8){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20SET\x20(%s)\x20block',_0x2e9ea8[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x2e9ea8['variable_id'])){return this['channel'][_0x69a8('0x31')](_0x2e9ea8,_0x69a8('0x1ab'));}var _0xd4fda1=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x2e9ea8[_0x69a8('0xe1')]);if(!_0xd4fda1){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x2e9ea8,_0x69a8('0x11f'));}return this[_0x69a8('0x3d')]['setVariable'](_0xd4fda1,_0x2e9ea8['variable_value']);};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1ac')]=function(_0x2d199c){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x1ad'),_0x2d199c[_0x69a8('0x3f')]));this[_0x69a8('0x3d')][_0x69a8('0xaf')]('START\x20CALLY\x20SQUARE');if(_0x2d199c['answer']===_0x69a8('0x1ae')){this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x1af'));return this[_0x69a8('0x3d')][_0x69a8('0xc2')]();}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](_0x69a8('0x1b0'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1b1')]=function(_0x5ace06){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20SUBPROJECT\x20(%s)\x20block',_0x5ace06[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0x5ace06[_0x69a8('0x1b2')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x5ace06,_0x69a8('0x1b3'));}var _0x372fcc=this[_0x69a8('0x19')][_0x69a8('0x76')](this,_0x5ace06[_0x69a8('0x1b2')]);if(!this[_0x69a8('0xab')](_0x372fcc)){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x5ace06,util[_0x69a8('0x2f')]('no\x20subproject\x20found\x20with\x20id\x20%d',_0x5ace06[_0x69a8('0x1b2')]));}if(_0x372fcc===this['channel'][_0x69a8('0x47')]){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x5ace06,_0x69a8('0x1b4'));}this[_0x69a8('0x3c')][_0x69a8('0x76')](this,_0x5ace06,_0x372fcc);var _0x315722=this['channel'][_0x69a8('0x5d')]('AGI',util[_0x69a8('0x2f')](_0x69a8('0x1b5'),config[_0x69a8('0x8')][_0x69a8('0x1b6')]||_0x69a8('0x1b7'),_0x372fcc,this[_0x69a8('0x3d')][_0x69a8('0x47')]));if(_0x315722[_0x69a8('0xa9')]===-0x1){return _0x315722;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Executed\x20command\x20%s\x20%s',_0x69a8('0x1b8'),_0x372fcc));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1b9')]=function(_0x184380){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x1ba'),_0x184380['label']));var _0x8ed0d5=this[_0x69a8('0x5c')][_0x69a8('0x76')](this,_0x184380['command']);this[_0x69a8('0x3c')]['sync'](this,_0x184380,_0x184380[_0x69a8('0xbd')]);if(this['isConfigured'](_0x184380[_0x69a8('0xe1')])){var _0x46b099=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0x184380[_0x69a8('0xe1')]);if(_0x46b099){this[_0x69a8('0x3d')]['setVariable'](_0x46b099,_0x8ed0d5);return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0x1bb'),_0x184380[_0x69a8('0xbd')],_0x46b099));}}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util['format'](_0x69a8('0x1bc'),_0x184380[_0x69a8('0xbd')]));};AGIVertices['prototype'][_0x69a8('0x1bd')]=function(_0x3e5b60){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('Enter\x20in\x20Google\x20Cloud\x20TTS\x20(%s)\x20block',_0x3e5b60[_0x69a8('0x3f')]));_0x3e5b60[_0x69a8('0x62')]=_0x3e5b60[_0x69a8('0x62')][_0x69a8('0x5f')](/(\r\n|\n|\r)/gm,'\x20');if(!this['isConfigured'](_0x3e5b60['apiKey'])){return this[_0x69a8('0x3d')][_0x69a8('0xaf')]('no\x20apiKey\x20configured');}if(!this[_0x69a8('0xab')](_0x3e5b60[_0x69a8('0x62')])){return this['channel']['noop'](_0x69a8('0xce'));}this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x1be'),_0x3e5b60['text']));var _0x1bc73c=this['googleCloudTTS'][_0x69a8('0x76')](this,_0x3e5b60);if(_0x1bc73c){this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Google\x20Cloud\x20TTS\x20%s\x20file\x20created',_0x1bc73c));var _0xc5d538=this[_0x69a8('0x3d')]['streamFile'](_0x1bc73c);try{fs[_0x69a8('0x12b')](_0x1bc73c+'.wav');}catch(_0x3c3707){logger[_0x69a8('0x31')](_0x3c3707);}return _0xc5d538;}return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x3e5b60,_0x69a8('0x1bf'));};AGIVertices[_0x69a8('0x16')][_0x69a8('0x1c0')]=function(_0x1e9a56){logger[_0x69a8('0x32')](util['format'](_0x69a8('0x1c1'),_0x1e9a56[_0x69a8('0x3f')]));_0x1e9a56['text']=_0x1e9a56[_0x69a8('0x62')][_0x69a8('0x5f')](/(\r\n|\n|\r)/gm,'\x20');if(!this['isConfigured'](_0x1e9a56[_0x69a8('0x62')])){return this[_0x69a8('0x3d')]['noop']('no\x20text\x20configured');}this['channel'][_0x69a8('0xaf')](util['format']('Trying\x20Google\x20TTS\x20%s',_0x1e9a56[_0x69a8('0x62')]));var _0x42a3bf=this[_0x69a8('0x67')][_0x69a8('0x76')](this,_0x1e9a56);if(_0x42a3bf){this['channel'][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x1c2'),_0x42a3bf));var _0x17925a=this['channel'][_0x69a8('0x109')](_0x42a3bf);try{fs[_0x69a8('0x12b')](_0x42a3bf+_0x69a8('0x10a'));}catch(_0x3cb216){logger[_0x69a8('0x31')](_0x3cb216);}return _0x17925a;}return this[_0x69a8('0x3d')]['error'](_0x1e9a56,_0x69a8('0x1c3'));};AGIVertices['prototype'][_0x69a8('0x1c4')]=function(_0x32e4f2){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x1c5'),_0x32e4f2[_0x69a8('0x3f')]));if(!this['isConfigured'](_0x32e4f2[_0x69a8('0x15c')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0x32e4f2,_0x69a8('0x163'));}logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x15d'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x32e4f2[_0x69a8('0x15c')]));var _0x19bb44=this['agentUnpause'][_0x69a8('0x76')](this,_0x32e4f2['findBy']);if(_0x19bb44){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')]('AGENT\x20%s\x20FOUND\x20BY',this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x32e4f2[_0x69a8('0x15c')]));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x15e'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x32e4f2[_0x69a8('0x15c')]));return{'code':0xc8,'result':_0x69a8('0x15f')};}else{logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x160'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x32e4f2[_0x69a8('0x15c')]));this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')](_0x69a8('0x160'),this[_0x69a8('0x3d')][_0x69a8('0x42')],_0x32e4f2['findBy']));return{'code':0xc8,'result':'failure'};}};AGIVertices['prototype'][_0x69a8('0x1c6')]=function(_0x55d164){logger[_0x69a8('0x32')](util[_0x69a8('0x2f')](_0x69a8('0x1c7'),_0x55d164[_0x69a8('0x3f')]));var _0x238417=this[_0x69a8('0x3d')][_0x69a8('0x5d')](_0x69a8('0x1c8'),[_0x55d164['mailbox'],_0x55d164['options']]);if(_0x238417[_0x69a8('0xa9')]===-0x1){return _0x238417;}return this[_0x69a8('0x3d')][_0x69a8('0xaf')](util[_0x69a8('0x2f')]('Executed\x20command\x20%s\x20%s',_0x69a8('0x1c8'),_0x55d164[_0x69a8('0x1c9')]));};AGIVertices['prototype'][_0x69a8('0x1ca')]=function(_0xe9d977){logger['info'](util[_0x69a8('0x2f')](_0x69a8('0x1cb'),_0xe9d977[_0x69a8('0x3f')]));if(!this[_0x69a8('0xab')](_0xe9d977[_0x69a8('0xe1')])){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0xe9d977,'no\x20variable\x20selected');}var _0x5f955f=this[_0x69a8('0xa6')][_0x69a8('0x76')](this,_0xe9d977['variable_id']);if(!_0x5f955f){return this[_0x69a8('0x3d')][_0x69a8('0x31')](_0xe9d977,_0x69a8('0x11f'));}var _0xd0e8ef=this[_0x69a8('0x3d')][_0x69a8('0xa6')](_0x5f955f);return{'code':0xc8,'result':_0xd0e8ef[_0x69a8('0xa7')]?_0xd0e8ef[_0x69a8('0xa7')]:'-'};};String[_0x69a8('0x16')][_0x69a8('0xa5')]=function(_0x805bb9,_0x58a269){return this['split'](_0x805bb9)[_0x69a8('0x1cc')](_0x58a269);};module[_0x69a8('0x1cd')]=AGIVertices; \ No newline at end of file diff --git a/server/services/ami/acw/index.js b/server/services/ami/acw/index.js new file mode 100644 index 0000000..3742dae --- /dev/null +++ b/server/services/ami/acw/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbf77=['transfereeuniqueid','secondtransfereruniqueid','transfertargetuniqueid','origtransfereruniqueid','[ACW][syncAttendedTransfer]\x20%s','transfereruniqueid','[%s][BLINDTRANSFER:UNIQUEID]','transfererlinkedid','[%s][BLINDTRANSFER:LINKEDID]','[ACW][syncBlindTransfer]\x20%s','syncAgentRingNoAnswer','autopause','[%s][AUTOPAUSE][AGENT:%s][QUEUE:%]','Auto-Pause','../ami','../../../config/logger','acw','../rpc/user','../rpc/voiceAgentReport','voiceQueues','agents','timers','agentconnect','syncAgentConnect','hanguprequest','bind','syncHangup','agentringnoanswer','attendedtransfer','blindtransfer','syncBlindTransfer','custom:agentConnectPreview','milliseconds','diff','seconds','startAcw','channels','interface','ACW','mandatoryDisposition','name','mandatoryDispositionPause','Action','QueuePause','then','getAgent','voicePause','info','[%s][START][AGENT:%s][QUEUE:%s]','destlinkedid','[%s][TIMER:%s][AGENT:%s][QUEUE:%s]','timer','acwTimeout','lastPauseAt','YYYY-MM-DD\x20HH:mm:ss','uniqueid','updateAcw','update','error','[%s][UPDATE][ERRORS:%s]','[%s][INPAUSE][AGENT:%s][QUEUE:%s]','catch','finally','[ACW][START]\x20%s','message','prototype','stopAcw','queue','[%s][TIMER][STOP][AGENT:%s]','saveUnpause','[%s][UPDATE][ACWTIME:%s]','[ACW][STOP]\x20Interface\x20%s\x20doesn\x27t\x20have\x20timer','[ACW][TIMERS]','stringify','[ACW][syncAgentConnect]\x20%s','syncAgentConnectPreview','[ACW][syncAgentConnectPreview]\x20%s','linkedid','attended','[%s][HANGUP:LINKEDID]','[ACW][syncHangupRequest]\x20%s','[%s][HANGUPATTENDEDTRANSFER:LINKEDID]','[ACW][syncHangup]\x20%s','isNil'];(function(_0x5c595c,_0x113c41){var _0x122cb6=function(_0x4acb44){while(--_0x4acb44){_0x5c595c['push'](_0x5c595c['shift']());}};_0x122cb6(++_0x113c41);}(_0xbf77,0x10a));var _0x7bf7=function(_0x46698a,_0x8de1e4){_0x46698a=_0x46698a-0x0;var _0x356db0=_0xbf77[_0x46698a];return _0x356db0;};'use strict';var _=require('lodash');var moment=require('moment');var ami=require(_0x7bf7('0x0'));var logger=require(_0x7bf7('0x1'))(_0x7bf7('0x2'));var RpcUser=require(_0x7bf7('0x3'));var RpcVoiceAgentReport=require(_0x7bf7('0x4'));function Acw(_0x110fe2){this[_0x7bf7('0x5')]=_0x110fe2['voiceQueues'];this['agents']=_0x110fe2[_0x7bf7('0x6')];this['timers']=_0x110fe2[_0x7bf7('0x7')];this['channels']={};ami['on'](_0x7bf7('0x8'),this[_0x7bf7('0x9')]['bind'](this));ami['on'](_0x7bf7('0xa'),this['syncHangupRequest'][_0x7bf7('0xb')](this));ami['on']('hangup',this[_0x7bf7('0xc')][_0x7bf7('0xb')](this));ami['on'](_0x7bf7('0xd'),this['syncAgentRingNoAnswer'][_0x7bf7('0xb')](this));ami['on'](_0x7bf7('0xe'),this['syncAttendedTransfer'][_0x7bf7('0xb')](this));ami['on'](_0x7bf7('0xf'),this[_0x7bf7('0x10')][_0x7bf7('0xb')](this));ami['on'](_0x7bf7('0x11'),this['syncAgentConnectPreview'][_0x7bf7('0xb')](this));}function getDiff(_0x5a2ba3){var _0x41e8de=moment()['milliseconds'](0x0);var _0x563b51=moment(_0x5a2ba3)[_0x7bf7('0x12')](0x0);return _0x41e8de[_0x7bf7('0x13')](_0x563b51,_0x7bf7('0x14'));}Acw['prototype'][_0x7bf7('0x15')]=function(_0x5e23f2){try{var _0x3db4ed=this;var _0x34b58f=this[_0x7bf7('0x16')][_0x5e23f2][_0x7bf7('0x17')];var _0x326e50=this[_0x7bf7('0x16')][_0x5e23f2]['queue'];var _0x72a943=this['voiceQueues'][_0x326e50];var _0xd8e139=![];var _0x22d225=_0x7bf7('0x18');if(_0x72a943[_0x7bf7('0x19')]){if(_0x72a943['mandatoryDispositionPause'][_0x7bf7('0x1a')]){_0xd8e139=!![];_0x22d225=_0x72a943[_0x7bf7('0x1b')][_0x7bf7('0x1a')];}}return ami[_0x7bf7('0x1c')]({'action':_0x7bf7('0x1d'),'interface':_0x34b58f,'paused':!![],'reason':_0x22d225})[_0x7bf7('0x1e')](function(){if(_0x3db4ed[_0x7bf7('0x6')][_0x34b58f]){return RpcUser[_0x7bf7('0x1f')](_0x3db4ed[_0x7bf7('0x6')][_0x34b58f]['id'])[_0x7bf7('0x1e')](function(_0x54dac7){if(_0x54dac7&&!_0x54dac7[_0x7bf7('0x20')]){logger[_0x7bf7('0x21')](_0x7bf7('0x22'),_0x5e23f2,_0x34b58f,_0x326e50);var _0x576352=_0x3db4ed[_0x7bf7('0x16')][_0x5e23f2]['attended']&&_0x3db4ed[_0x7bf7('0x16')][_0x5e23f2][_0x7bf7('0x23')]?_0x3db4ed[_0x7bf7('0x16')][_0x5e23f2][_0x7bf7('0x23')]:_0x5e23f2;return RpcUser['savePause'](_0x3db4ed[_0x7bf7('0x6')][_0x34b58f],_0x22d225,_0x576352)[_0x7bf7('0x1e')](function(){if(!_0xd8e139){_0x3db4ed['timers'][_0x34b58f]={};logger[_0x7bf7('0x21')](_0x7bf7('0x24'),_0x5e23f2,_0x3db4ed[_0x7bf7('0x5')][_0x326e50]['acwTimeout'],_0x34b58f,_0x326e50);_0x3db4ed[_0x7bf7('0x7')][_0x34b58f][_0x7bf7('0x25')]=setTimeout(_0x3db4ed['stopAcw']['bind'](_0x3db4ed,_0x34b58f),_0x3db4ed[_0x7bf7('0x5')][_0x326e50][_0x7bf7('0x26')]*0x3e8);_0x3db4ed[_0x7bf7('0x7')][_0x34b58f][_0x7bf7('0x27')]=moment()['format'](_0x7bf7('0x28'));_0x3db4ed['timers'][_0x34b58f][_0x7bf7('0x29')]=_0x5e23f2;_0x3db4ed['timers'][_0x34b58f]['queue']=_0x326e50;_0x3db4ed['timers'][_0x34b58f][_0x7bf7('0x2a')]=function(){var _0x307586=getDiff(_0x3db4ed[_0x7bf7('0x7')][_0x34b58f][_0x7bf7('0x27')]);clearTimeout(_0x3db4ed[_0x7bf7('0x7')][_0x34b58f][_0x7bf7('0x25')]);_0x3db4ed[_0x7bf7('0x7')][_0x34b58f][_0x7bf7('0x25')]=![];RpcVoiceAgentReport[_0x7bf7('0x2b')]({'acwtime':_0x307586},_0x3db4ed['timers'][_0x34b58f][_0x7bf7('0x29')],_0x34b58f)['then'](function(_0x137a3a){logger[_0x7bf7('0x21')]('[%s][UPDATE][ACWTIME:%s]',_0x5e23f2,_0x307586,_0x137a3a);})['catch'](function(_0x30de67){logger[_0x7bf7('0x2c')](_0x7bf7('0x2d'),_0x5e23f2,_0x30de67);});delete _0x3db4ed[_0x7bf7('0x7')][_0x34b58f];};}});}else{logger[_0x7bf7('0x21')](_0x7bf7('0x2e'),_0x5e23f2,_0x34b58f,_0x326e50);}});}})[_0x7bf7('0x2f')](function(){logger['error'](_0x7bf7('0x24'),_0x5e23f2,_0x3db4ed['voiceQueues'][_0x326e50][_0x7bf7('0x26')],_0x34b58f,_0x326e50);})[_0x7bf7('0x30')](function(){delete _0x3db4ed[_0x7bf7('0x16')][_0x5e23f2];});}catch(_0x33ae4c){logger['error'](_0x7bf7('0x31'),_0x33ae4c[_0x7bf7('0x32')]);}};Acw[_0x7bf7('0x33')][_0x7bf7('0x34')]=function(_0x3c41c3){try{var _0x4f1bc7=this;if(_0x4f1bc7[_0x7bf7('0x7')][_0x3c41c3]){_0x4f1bc7['timers'][_0x3c41c3][_0x7bf7('0x25')]=![];var _0xd644c4=_0x4f1bc7[_0x7bf7('0x7')][_0x3c41c3]['uniqueid'];var _0x498fdd=_0x4f1bc7['timers'][_0x3c41c3][_0x7bf7('0x35')];var _0x25671f=_0x4f1bc7[_0x7bf7('0x5')][_0x498fdd][_0x7bf7('0x26')];logger[_0x7bf7('0x21')](_0x7bf7('0x36'),_0xd644c4,_0x3c41c3);RpcUser[_0x7bf7('0x37')](this['agents'][_0x3c41c3]);RpcVoiceAgentReport[_0x7bf7('0x2b')]({'acwtime':_0x25671f,'agentacw':!![]},_0xd644c4,_0x3c41c3)[_0x7bf7('0x1e')](function(_0x444592){logger['info'](_0x7bf7('0x38'),_0xd644c4,_0x25671f,_0x444592);})[_0x7bf7('0x2f')](function(_0x5e1430){logger[_0x7bf7('0x2c')]('[%s][UPDATE][ERRORS:%s]',_0xd644c4,_0x5e1430);});}else{logger[_0x7bf7('0x2c')](_0x7bf7('0x39'),_0x3c41c3);if(_0x4f1bc7[_0x7bf7('0x7')]){logger[_0x7bf7('0x21')](_0x7bf7('0x3a'),JSON[_0x7bf7('0x3b')](_0x4f1bc7[_0x7bf7('0x7')]));}}}catch(_0x3c2870){logger[_0x7bf7('0x2c')]('[ACW][STOP]\x20%s',_0x3c2870[_0x7bf7('0x32')]);}};Acw[_0x7bf7('0x33')]['syncAgentConnect']=function(_0x133dc6){try{if(this[_0x7bf7('0x5')][_0x133dc6[_0x7bf7('0x35')]]&&(this['voiceQueues'][_0x133dc6['queue']][_0x7bf7('0x2')]||this[_0x7bf7('0x5')][_0x133dc6['queue']][_0x7bf7('0x19')])){if(this[_0x7bf7('0x6')][_0x133dc6['interface']]){this[_0x7bf7('0x16')][_0x133dc6[_0x7bf7('0x29')]]={'queue':_0x133dc6[_0x7bf7('0x35')],'interface':_0x133dc6[_0x7bf7('0x17')],'destlinkedid':_0x133dc6['destlinkedid']};}}}catch(_0x9ae252){logger[_0x7bf7('0x2c')](_0x7bf7('0x3c'),_0x9ae252['message']);}};Acw[_0x7bf7('0x33')][_0x7bf7('0x3d')]=function(_0x587b9a){try{if(this['voiceQueues'][_0x587b9a[_0x7bf7('0x35')]]&&(this[_0x7bf7('0x5')][_0x587b9a[_0x7bf7('0x35')]][_0x7bf7('0x2')]||this[_0x7bf7('0x5')][_0x587b9a[_0x7bf7('0x35')]]['mandatoryDisposition'])){if(this[_0x7bf7('0x6')][_0x587b9a[_0x7bf7('0x17')]]){this[_0x7bf7('0x16')][_0x587b9a[_0x7bf7('0x29')]]={'queue':_0x587b9a[_0x7bf7('0x35')],'interface':_0x587b9a[_0x7bf7('0x17')]};}}}catch(_0xc65452){logger['error'](_0x7bf7('0x3e'),_0xc65452[_0x7bf7('0x32')]);}};Acw['prototype']['syncHangupRequest']=function(_0x50d614){try{if(this[_0x7bf7('0x16')][_0x50d614[_0x7bf7('0x29')]]&&_['isUndefined'](this['channels'][_0x50d614[_0x7bf7('0x29')]]['attended'])){logger[_0x7bf7('0x21')]('[%s][HANGUP:UNIQUEID]',_0x50d614[_0x7bf7('0x29')]);this[_0x7bf7('0x15')](_0x50d614[_0x7bf7('0x29')]);}else if(this[_0x7bf7('0x16')][_0x50d614[_0x7bf7('0x3f')]]&&_['isUndefined'](this['channels'][_0x50d614[_0x7bf7('0x3f')]][_0x7bf7('0x40')])){logger[_0x7bf7('0x21')](_0x7bf7('0x41'),_0x50d614[_0x7bf7('0x3f')]);this['startAcw'](_0x50d614[_0x7bf7('0x3f')]);}}catch(_0x4bd836){logger[_0x7bf7('0x2c')](_0x7bf7('0x42'),_0x4bd836['message']);}};Acw[_0x7bf7('0x33')][_0x7bf7('0xc')]=function(_0x19869a){try{if(this[_0x7bf7('0x16')][_0x19869a[_0x7bf7('0x29')]]&&this[_0x7bf7('0x16')][_0x19869a[_0x7bf7('0x29')]][_0x7bf7('0x40')]){logger[_0x7bf7('0x21')]('[%s][HANGUPATTENDEDTRANSFER:UNIQUEID]',_0x19869a[_0x7bf7('0x29')]);this[_0x7bf7('0x15')](_0x19869a[_0x7bf7('0x29')]);}else if(this['channels'][_0x19869a[_0x7bf7('0x3f')]]&&this['channels'][_0x19869a[_0x7bf7('0x3f')]][_0x7bf7('0x40')]){logger[_0x7bf7('0x21')](_0x7bf7('0x43'),_0x19869a[_0x7bf7('0x3f')]);this['startAcw'](_0x19869a[_0x7bf7('0x3f')]);}}catch(_0x3f4b8d){logger[_0x7bf7('0x2c')](_0x7bf7('0x44'),_0x3f4b8d[_0x7bf7('0x32')]);}};Acw[_0x7bf7('0x33')]['syncAttendedTransfer']=function(_0x278a6b){try{if(!_[_0x7bf7('0x45')](this[_0x7bf7('0x16')][_0x278a6b[_0x7bf7('0x46')]])){this[_0x7bf7('0x15')](_0x278a6b[_0x7bf7('0x46')]);if(this[_0x7bf7('0x16')][_0x278a6b['secondtransfereruniqueid']]){this[_0x7bf7('0x16')][_0x278a6b['secondtransfereruniqueid']][_0x7bf7('0x40')]=!![];this[_0x7bf7('0x16')][_0x278a6b['transfertargetuniqueid']]=this[_0x7bf7('0x16')][_0x278a6b[_0x7bf7('0x47')]];delete this[_0x7bf7('0x16')][_0x278a6b['secondtransfereruniqueid']];}}else if(!_['isNil'](this['channels'][_0x278a6b[_0x7bf7('0x48')]])){this[_0x7bf7('0x15')](_0x278a6b[_0x7bf7('0x48')]);if(this[_0x7bf7('0x16')][_0x278a6b['origtransfereruniqueid']]){this[_0x7bf7('0x16')][_0x278a6b[_0x7bf7('0x49')]]['attended']=!![];this[_0x7bf7('0x16')][_0x278a6b[_0x7bf7('0x46')]]=this[_0x7bf7('0x16')][_0x278a6b['origtransfereruniqueid']];delete this['channels'][_0x278a6b['origtransfereruniqueid']];}}}catch(_0x335d24){logger[_0x7bf7('0x2c')](_0x7bf7('0x4a'),_0x335d24[_0x7bf7('0x32')]);}};Acw[_0x7bf7('0x33')][_0x7bf7('0x10')]=function(_0x3a169d){try{if(this[_0x7bf7('0x16')][_0x3a169d[_0x7bf7('0x4b')]]){logger['info'](_0x7bf7('0x4c'),JSON[_0x7bf7('0x3b')](_0x3a169d[_0x7bf7('0x4b')]));this[_0x7bf7('0x15')](_0x3a169d[_0x7bf7('0x4b')]);}else if(this[_0x7bf7('0x16')][_0x3a169d[_0x7bf7('0x4d')]]){logger[_0x7bf7('0x21')](_0x7bf7('0x4e'),JSON['stringify'](_0x3a169d[_0x7bf7('0x4d')]));this['startAcw'](_0x3a169d[_0x7bf7('0x4d')]);}}catch(_0x53c182){logger['error'](_0x7bf7('0x4f'),_0x53c182[_0x7bf7('0x32')]);}};Acw['prototype'][_0x7bf7('0x50')]=function(_0xe2abd0){try{if(this['voiceQueues'][_0xe2abd0[_0x7bf7('0x35')]]&&this['voiceQueues'][_0xe2abd0[_0x7bf7('0x35')]][_0x7bf7('0x51')]==='all'){if(this[_0x7bf7('0x6')][_0xe2abd0[_0x7bf7('0x17')]]){logger[_0x7bf7('0x21')](_0x7bf7('0x52'),_0xe2abd0[_0x7bf7('0x29')],_0xe2abd0[_0x7bf7('0x17')],_0xe2abd0[_0x7bf7('0x35')]);return RpcUser['savePause'](this['agents'][_0xe2abd0[_0x7bf7('0x17')]],_0x7bf7('0x53'),_0xe2abd0[_0x7bf7('0x29')]);}}}catch(_0x2b75cb){logger[_0x7bf7('0x2c')]('[ACW][syncAgentRingNoAnswer]\x20%s',_0x2b75cb[_0x7bf7('0x32')]);}};module['exports']=Acw; \ No newline at end of file diff --git a/server/services/ami/ami.js b/server/services/ami/ami.js new file mode 100644 index 0000000..63d3f84 --- /dev/null +++ b/server/services/ami/ami.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf6f4=['queuesummary','actionCoreShowChannels','once','connect','shutdown','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','info','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','catch','[ami.js][fullybooted]','asterisk-manager','bluebird','util','../../config/logger','ami','asterisk','port','Action','promisify','action','error','format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','username','inspect','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','actionSipPeerStatus','sippeerstatus'];(function(_0x5b7645,_0x1708e1){var _0xd47880=function(_0x479fd0){while(--_0x479fd0){_0x5b7645['push'](_0x5b7645['shift']());}};_0xd47880(++_0x1708e1);}(_0xf6f4,0x1c6));var _0x4f6f=function(_0x6f27e1,_0x883a63){_0x6f27e1=_0x6f27e1-0x0;var _0x110267=_0xf6f4[_0x6f27e1];return _0x110267;};'use strict';var Manager=require(_0x4f6f('0x0'));var BPromise=require(_0x4f6f('0x1'));var util=require(_0x4f6f('0x2'));var logger=require(_0x4f6f('0x3'))(_0x4f6f('0x4'));var config=require('../../config/environment');var ami=new Manager(config[_0x4f6f('0x5')][_0x4f6f('0x6')],config[_0x4f6f('0x5')]['ip'],config[_0x4f6f('0x5')]['username'],config[_0x4f6f('0x5')]['password'],!![]);ami['keepConnected']();ami[_0x4f6f('0x7')]=BPromise[_0x4f6f('0x8')](ami[_0x4f6f('0x9')]);function error(_0x19bac8){logger[_0x4f6f('0xa')](util[_0x4f6f('0xb')](_0x4f6f('0xc'),config[_0x4f6f('0x5')][_0x4f6f('0xd')],config[_0x4f6f('0x5')]['ip'],config[_0x4f6f('0x5')][_0x4f6f('0x6')],util[_0x4f6f('0xe')](_0x19bac8,![],null)));}function close(){logger[_0x4f6f('0xa')](util['format'](_0x4f6f('0xf'),config[_0x4f6f('0x5')][_0x4f6f('0xd')],config['asterisk']['ip'],config['asterisk'][_0x4f6f('0x6')]));}ami[_0x4f6f('0x10')]=function(){return function(){return ami['Action']({'action':_0x4f6f('0x11')});};};ami[_0x4f6f('0x12')]=function(){return function(){return ami['Action']({'action':_0x4f6f('0x13')});};};ami[_0x4f6f('0x14')]=function(){return function(){return ami['Action']({'action':_0x4f6f('0x15')});};};ami['actionQueueSummary']=function(){return function(){return ami[_0x4f6f('0x7')]({'action':_0x4f6f('0x16')});};};ami[_0x4f6f('0x17')]=function(){return function(){return ami[_0x4f6f('0x7')]({'action':'coreshowchannels'});};};function connect(){logger['info'](util[_0x4f6f('0xb')]('Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s',config[_0x4f6f('0x5')][_0x4f6f('0xd')],config[_0x4f6f('0x5')]['ip'],config[_0x4f6f('0x5')]['port']));ami[_0x4f6f('0x18')]('error',error);ami[_0x4f6f('0x18')]('close',close);}ami['on'](_0x4f6f('0x19'),connect);ami['on'](_0x4f6f('0x1a'),function(_0x488b7d){logger['info'](util[_0x4f6f('0xb')](_0x4f6f('0x1b'),config[_0x4f6f('0x5')][_0x4f6f('0xd')],config[_0x4f6f('0x5')]['ip'],config[_0x4f6f('0x5')][_0x4f6f('0x6')],util[_0x4f6f('0xe')](_0x488b7d,![],null)));});ami['on']('fullybooted',function(){logger[_0x4f6f('0x1c')](util[_0x4f6f('0xb')](_0x4f6f('0x1d'),config[_0x4f6f('0x5')]['username'],config['asterisk']['ip'],config['asterisk']['port']));return Promise[_0x4f6f('0x1e')]()[_0x4f6f('0x1f')](ami[_0x4f6f('0x10')]())[_0x4f6f('0x1f')](ami[_0x4f6f('0x12')]())[_0x4f6f('0x1f')](ami['actionSipPeerStatus']())['then'](ami['actionQueueSummary']())[_0x4f6f('0x1f')](ami[_0x4f6f('0x17')]())[_0x4f6f('0x20')](function(_0x187764){logger['error'](_0x4f6f('0x21'),util[_0x4f6f('0xe')](_0x187764,{'showHidden':![],'depth':null}));});});ami[_0x4f6f('0x18')](_0x4f6f('0xa'),error);ami[_0x4f6f('0x18')]('close',close);module['exports']=ami; \ No newline at end of file diff --git a/server/services/ami/client.js b/server/services/ami/client.js new file mode 100644 index 0000000..ffdca76 --- /dev/null +++ b/server/services/ami/client.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe706=['result','catch','exports','jayson/promise','bluebird','../../config/logger','client','http','Request','request','then','debug','rpc','memberReport','error','message'];(function(_0x77d286,_0x1ddc6d){var _0x5446a5=function(_0x45e2cf){while(--_0x45e2cf){_0x77d286['push'](_0x77d286['shift']());}};_0x5446a5(++_0x1ddc6d);}(_0xe706,0xa3));var _0x6e70=function(_0x3ccc44,_0x207b0c){_0x3ccc44=_0x3ccc44-0x0;var _0x5d74bb=_0xe706[_0x3ccc44];return _0x5d74bb;};'use strict';var jayson=require(_0x6e70('0x0'));var BPromise=require(_0x6e70('0x1'));var logger=require(_0x6e70('0x2'))('ami');var client=jayson[_0x6e70('0x3')][_0x6e70('0x4')]({'port':0x2329});client[_0x6e70('0x5')]=function(_0x7dfbc3,_0x142c27){return new BPromise(function(_0x2164a4,_0x376a8d){return client[_0x6e70('0x6')](_0x7dfbc3,_0x142c27)[_0x6e70('0x7')](function(_0x4381d1){logger[_0x6e70('0x8')](_0x6e70('0x9'),_0x6e70('0xa'),_0x7dfbc3,_0x142c27,_0x4381d1);if(_0x4381d1[_0x6e70('0xb')]){logger[_0x6e70('0xb')](_0x6e70('0x9'),_0x6e70('0xa'),_0x7dfbc3,_0x4381d1[_0x6e70('0xb')][_0x6e70('0xc')],_0x142c27);return _0x376a8d(_0x4381d1[_0x6e70('0xb')][_0x6e70('0xc')]);}else{return _0x2164a4(_0x4381d1[_0x6e70('0xd')]);}})[_0x6e70('0xe')](function(_0x4600f9){logger['error']('rpc',_0x6e70('0xa'),_0x7dfbc3,_0x4600f9,_0x142c27);return _0x376a8d(_0x4600f9);});});};module[_0x6e70('0xf')]=client; \ No newline at end of file diff --git a/server/services/ami/dialer/index.js b/server/services/ami/dialer/index.js new file mode 100644 index 0000000..23beef6 --- /dev/null +++ b/server/services/ami/dialer/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6b26=['\x20Intervals\x20is\x20null\x20','EMPTY_INTERVAL','timezones','UNKNOWN_TIMEZONE','\x20Timezone\x20unknow\x20','isArray','length','Action','iftime\x20%s,%s','interval','indexOf','catch','push','command','true','all','some','OVERTIME_GLOBAL_INTERVAL','OVERTIME_INTERVAL','[ifTime][promiseAll]','Global:\x20','\x20Interval\x20is\x20overtime:\x20','Timezone:\x20','ifTime','resetActiveCalls','syncCampaigns','undefined','isIVRCampaign','dialGlobalInterval','dialTimezone','launchHandleIvr','checkDialMethod','dialMethod','progressive','handlePower','power','dialPowerLevel','Queue','method\x20not\x20recognized','silly','Dialer::ifTime()','Voice\x20Queue\x20%s\x20$s','intervalIftime','isGlobal','AMI\x20IfTime','Error','queue','uniqueid','updateOriginated','YYYY-MM-DD\x20HH:mm:ss','ivr','agent','agiafterat','dialQueueProject2','dialAgiAfterHangupAgent','createHistory','[syncAgentComplete][createHistory]','moveContactManagedDialer','[syncAgentComplete]','syncQueueCallerAbandon','droptime','getSeconds','dialQueueTimeout','predictiveIntervalDroppedCallsTimeout','outboundDropCallsDayTimeout','dropreason','countdropretry','dialDropRetryFrequency','callAdditionalPhoneAfterMin','verifyAdditionalPhones','additional','dialDropMaxRetry','queueCallerAbandonCreateState','rescheduleContact','add','ContactId','VoiceQueueId','CampaignId','[rescheduleContact][Drop]','Drop','calleridname','[syncAgentComplete][createHistory][10]','swapAdditionalPhones','outboundDropCallsDayCallersExit','CALLEREXIT','countabandonedretry','countglobal','dialAbandonedRetryFrequency','voiceQueue','dialAbandonedMaxRetry','ListId','Abandoned','calleridnum','[syncAgentComplete][createHistory][11]','actions','channel','actionid','rrmemory','roundrobin','isNil','locked','paused','stateinterface','idHopper','strategy','run','[Catch][Preview][syncQueueStatusComplete]','[unlock][syncQueueStatusComplete]','unlockRR','[booked][RR]','Agent:\x20','contactAgent-idHopper:\x20','[booked][RR][finaly]','[booked][unlock]','[unlock2][syncQueueStatusComplete]','[unlock3][syncQueueStatusComplete]','getQueue','response','callProgressDetecting','[callProgressDetecting]\x20','syncVarSet','variable','xcally-motion-dialer','dialAMDActive','value','HANGUP','outboundAnswerAgiCallsDay','HangupInAMD','membername','AMD','emit','custom:amd','buildObj','amd','[syncHangupInAMD][createHistory]','[syncHangupInAMD]','MACHINE','outboundAnswerCallsDay','countbusyretry','countcongestionretry','countnoanswerretry','countnosuchnumberretry','countmachineretry','countagentrejectretry','stateGlobal','dialMachineMaxRetry','createStateFinal','reason\x2019\x20machine....','dialMachineRetryFrequency','minutes','[rescheduleContact][Machine]','saveInDb','[syncHangupInAMDIvr][createHistory]','Machine','[syncAgentComplete][createHistory][0]','ivrAnswerCallsDay','[syncHangupIvr][createHistory]','[syncHangupIvr]','dialQueueProject','AGI','outboundUnknownCallsDay','cause-txt','Unknow','running','isPreviewCampaign','statusMessage','getQueueCampaignStatusMessage','resolve','available','inUse','talking','pTalking','ACTIVE','[syncQueueSummary]','compareToOutboundQueue','queueSummaryCountersUpdated','updateReportFromOutboundQueue','assign','syncQueueSummaryComplete','filter','online','map','user:dialPreviewRecallReminder','checkPreviewRecallReminder','clearZombieChannels','[uniqueid]','No\x20such\x20channel','[Dialer][checkChannel]','[Dialer][checkChannel][ivr]','getVoiceQueueRtPauses','[getVoiceQueueRtPauses]\x20','[updateOriginated]\x20object\x20originated\x20is\x20negative','[updateOriginated]\x20is\x20null\x20or\x20undefined','loggerHandler','emptyContact','UserId','[emptyContact][createHistory]','[syncQueueCallerAbandon]\x20[Drop]','Agent','user:%s','handleIvr','actionOriginate','voiceQueue\x20is\x20undefine','phone','originate','getCaller','NONE','\x22agi://%s/square,%s\x22','isOutboundQueue','\x22%s,%s%s,,,%s\x22','dialQueueOptions','XMD-AMDINITIALSILENCE','dialAMDInitialSilence','dialAMDGreeting','XMD-AMDAFTERGREETINGSILENCE','XMD-AMDTOTALANALYSISTIME','dialAMDTotalAnalysisTime','XMD-AMDMINWORDLENGTH','XMD-AMDBETWEENWORDSSILENCE','dialAMDBetweenWordsSilence','XMD-AMDMAXIMUMNUMBEROFWORDS','dialAMDMaximumNumberOfWords','XMD-AMDSILENCETHRESHOLD','dialAMDSilenceThreshold','XMD-AMDMAXIMUMWORDLENGTH','XMD-VOICEQUEUEID','Contact','createdAt','updatedAt','%s%s','toUpper','getCallerId','callerid','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','XMD-ORIGINATECALLERIDNAME','extractCalleridName','variables','SIP/%s/%s%s','dialPrefix','dialCutDigit','trim','substring','from-sip','outboundOriginateFailureCallsDay','[originateError]:\x20%s','[originate][error]','originate\x20action\x20Error','dialNoAnswerMaxRetry','[rescheduleContact][NoAnswer]','dialBusyMaxRetry','dialBusyRetryFrequency','[rescheduleContact]\x20[Busy]','dialCongestionMaxRetry','dialCongestionRetryFrequency','[rescheduleContact]\x20[Congestion]','dialNoSuchNumberMaxRetry','dialNoSuchNumberRetryFrequency','[rescheduleContact][NoSuchNumber]','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','[rescheduleContact][AgentReject]','object','[callProgressDetecting]','entity\x20is\x20undefine','evt\x20is\x20undefine','reason','outboundNoSuchCallsDay','NoSuchNumber','nosuchnumber','reason\x200\x20no\x20such\x20number....','NoAnswer','buildNoAnswerEventPayload','custom:agentnoanswer','dialNoAnswerRetryFrequency','[syncAgentComplete][createHistory][3]','reason\x203\x20ringing\x20no\x20answer','outboundBusyCallsDay','Busy','busy','checkRetriveMax','reason\x205\x20busy','outboundCongestionCallsDay','Congestion','custom:agentcongestion','[syncAgentComplete][createHistory][8]','reason\x208\x20congestion','outboundAbandonedCallsDay','reason\x2011\x20abandoned','outboundRejectCallsDay','AgentReject','custom:agentreject','[syncAgentComplete][createHistory][20]','reason\x2020\x20agentreject','[syncAgentComplete][createHistory][?]','dialGlobalMaxRetry','Global','[moveContactManagedDialer][0]','contact\x20not\x20moved','dialPredictiveOptimizationPercentage','round','predictiveIntervalAvailable','predictiveIntervalMaxThreshold','predictiveIntervalMinThreshold','predictiveIntervalMultiplicativeFactor','[startMethodPredictive][StartProgressive]','check\x20predictive\x20is\x20not\x20undefine','check\x20handlePredictive\x20is\x20not\x20undefine','dialPredictiveInterval','[startMethodPredictive][StartProgressive][Loop]','predictiveIntervalErlangCallsDroppedCalls','dialPredictiveOptimization','[stopMethodPredictive][ReStartProgressive][ExceededDropDay]','[stopMethodPredictive][ReStartProgressive][ExceededDropInterval]','Max\x20Drop\x20','started\x20in\x20predictive\x20at','getDataPredictive','startMethodPredictive','Predictive\x20after\x20first\x20interval','recalculate\x20predictive\x20at','avgHandleTime','Predictive\x20for\x20every\x20interval','switch\x20in\x20progressive\x20because\x20available\x20agents\x20(',')\x20are\x20less\x20than\x20threshold\x20(','predictiveIntervalHitRate','dropRate','abandonmentRate','agentBusyFactor','busyFactor','[getDataPredictive]','Unknown\x20Predictive','getDataPredictiveOld','outboundQueuePauses','predictiveIntervalPauses','[CatchErlangB]','check\x20failure','floor','erlangCallToSecond','one\x20call\x20every:','milliseconds','[handlePredictive]','fail\x20to\x20scheduled\x20calls','checkContactBlack','recallme','booked','[booked][checkContactBlack]','queueStatusComplete:\x20','Queue:\x20','queuestatus','[booked][checkContactBlack][else]','[unlockOriginate][syncQueueStatusComplete]','scheduledat','dialRecallMeTimeout','outboundReCallsDay','dialRecallInQueue','[Originate][HistoryDialRecallInQueue][historyCatch]','outboundBlacklistCallsDay','Blacklist','[Originate][historyBlacklist]','[Originate][MoveBlacklist]','inBlackList','temp','getContactDialerIvr','dialOrderByScheduledAt','checkContactEmpty','[getContactCampaign2][Empty]','RUNNING','ivrTotalCallsDays','[actionOriginate]\x20','checkIsBlackListIvr','[actionOriginateIvr]\x20','[getContactCampaign2]','dialLimitQueue','not_inuse','checkIsBlackList','[getContactDialer2]','[handlePredictive][limitChannel]','tryOriginatePredictive','countReScheduled','[countReScheduled]\x20','[actionOriginatePredictive]\x20','[getContactDialerPredictive]','--------\x20Drop\x20Rate\x20--------','M:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Interval:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Ts:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','P:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Amax:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','[abandonmentRate]','m\x20=\x20','Ts\x20=\x20','p\x20=\x20','interval\x20=\x20','erlangb','----\x20Agent\x20Busy\x20Factor\x20----','Umin:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','[busyFactor]','Umin\x20=\x20','exports','util','lodash','moment','ioredis','./utils/hopper','../preview/util/util','../../../config/environment/','../../../config/logger','dialer','predictive','syncQueueSummary','redis','../rpc/cmHopper','../rpc/voiceQueueRt','../rpc/setting','./models/action','./models/agentComplete','./models/queueCallerAbandon','XCALLY_IP_AGI','127.0.0.1','enqueue','tail','finally','sequence','preview','voiceQueues','campaigns','agents','trunks','maxNumberOriginate','channels','uniqueId','optionPredictive','startProgressive','ivrOriginated','queueBooked','queueBookedRR','queuesSummary','agentconnect','syncAgentConnect','bind','originateresponse','syncOriginateResponse','agentcomplete','syncAgentComplete','custom:queuesummary','custom:queuesummarycomplete','syncHangup','newexten','syncNewExten','varset','queuemember','syncQueueMember','queuestatuscomplete','loopCampaigns','getSettings','then','previewRecallmeReminderInterval','isUndefined','type','outbound','debug','[voiceQueueReport][queuesummary]\x20sending\x20voice_queue:save\x20event:','format','voice:queue:%s','name','isEmpty','info','-----\x20Stats\x20Predictive\x20---','Total\x20Calls:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','predictiveIntervalTotalCalls','Answered\x20Calls:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','predictiveIntervalAnsweredCalls','Dropped\x20Timeout:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Dropped\x20Exit:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','predictiveIntervalDroppedCallsCallersExit','AVG\x20Hold\x20Time:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','AVG\x20Talk\x20Time:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','predictiveIntervalAvgTalktime','Avg\x20Talk\x20Time\x20is\x20not\x20enough\x20for\x20predictive','predictiveIntervalAvgHoldtime','Avg\x20Hold\x20Time\x20is\x20not\x20enough\x20for\x20predictive','Total\x20Calls\x20are\x20not\x20enough\x20for\x20predictive','History\x20information\x20are\x20empty','Scheduled\x20Calls:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','erlangCalls','One\x20call\x20every:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','Drop\x20Rate:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','erlangAbandonmentRate','Agent\x20Busy\x20Factor:\x20\x20\x20\x20\x20\x20\x20\x20\x20','erlangBusyFactor','---------------------------','merge','startProgressive\x20value\x20cleared','startPredictive','startPredictive\x20value\x20cleared','handlePredictive','error','stack','inspect','checkContactLowerLimitOriginate','contactsRescheduled','CAMPAIGN_STATUS','CONTACTS_RESCHEDULED','[getContactDialer2][ReScheduled]','contacts','message','NO_AVAILABLE_CONTACTS','state','statedesc','endtime','starttime','queueStatusComplete','stringify','pick','\x20INTERVAL_IS_NULL','Intervals','Interval','NULL_INTERVAL','INACTIVE','\x20NOT\x20Active','campaign:save','sendMessageOneNotActive','originated','[syncQueueSummary]\x20Campaign\x20Ivr:\x20','is\x20not\x20active','DISACTIVED','is\x20disactive','[ifTime][Action]','prototype','isTrunkReachable','active','SIP/%s','status','reachable','unmonitored','checkIsTrunkReachable','Trunk','TrunkBackup','TRUNK_NOT_REACHABLE','\x20trunk\x20is\x20not\x20reachable','checkIfTime','checkIfTimeIntervals','ifTimeIvr','Failure'];(function(_0x1fdcd1,_0x18ffe1){var _0x57a25c=function(_0x3edcb4){while(--_0x3edcb4){_0x1fdcd1['push'](_0x1fdcd1['shift']());}};_0x57a25c(++_0x18ffe1);}(_0x6b26,0x191));var _0x66b2=function(_0x4b56f4,_0x46c976){_0x4b56f4=_0x4b56f4-0x0;var _0x966059=_0x6b26[_0x4b56f4];return _0x966059;};'use strict';var util=require(_0x66b2('0x0'));var _=require(_0x66b2('0x1'));var uuid=require('uuid');var moment=require(_0x66b2('0x2'));var rr=require('rr');var Redis=require(_0x66b2('0x3'));var utils=require('./utils');var hopperUtils=require(_0x66b2('0x4'));var ut=require(_0x66b2('0x5'));var config=require(_0x66b2('0x6'));var logger=require(_0x66b2('0x7'))(_0x66b2('0x8'));var loggerBooked=require(_0x66b2('0x7'))('booked');var loggerPredictive=require(_0x66b2('0x7'))(_0x66b2('0x9'));var loggerPredictiveCalls=require(_0x66b2('0x7'))('predictiveCalls');var loggerSyncQueueSummary=require('../../../config/logger')(_0x66b2('0xa'));var ami=require('../ami');config[_0x66b2('0xb')]=_['defaults'](config[_0x66b2('0xb')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x66b2('0xb')]));var cmHopper=require(_0x66b2('0xc'));var voiceQueueRt=require(_0x66b2('0xd'));var RpcSetting=require(_0x66b2('0xe'));var Interval=require('../rpc/interval');var Action=require(_0x66b2('0xf'));var History=require('./models/history');var Final=require('./models/final');var AgentComplete=require(_0x66b2('0x10'));var QueueCallerAbandon=require(_0x66b2('0x11'));var Hangup=require('./models/hangup');var ipAgi=process['env'][_0x66b2('0x12')]||_0x66b2('0x13');var previewRecallmeReminderInterval=0x1;var Sequence=function(){};Sequence['prototype'][_0x66b2('0x14')]=function(_0x41d6b6){this[_0x66b2('0x15')]=this[_0x66b2('0x15')]?this[_0x66b2('0x15')][_0x66b2('0x16')](_0x41d6b6):_0x41d6b6();};function Dialer(_0x49819f,_0xb08291){this[_0x66b2('0x17')]=new Sequence();this[_0x66b2('0x18')]=_0xb08291;this[_0x66b2('0x19')]=_0x49819f[_0x66b2('0x19')];this[_0x66b2('0x1a')]=_0x49819f[_0x66b2('0x1a')];this[_0x66b2('0x1b')]=_0x49819f[_0x66b2('0x1b')];this['trunks']=_0x49819f[_0x66b2('0x1c')];this[_0x66b2('0x1d')]=config['maxNumberOriginate']||0x2;this[_0x66b2('0x1e')]={};this['actions']={};this['contactsId']={};this[_0x66b2('0x1f')]={};this[_0x66b2('0x20')]={};this['startPredictive']={};this[_0x66b2('0x21')]={};this[_0x66b2('0x22')]={};this[_0x66b2('0x23')]={};this[_0x66b2('0x24')]={};this[_0x66b2('0x25')]={};ami['on'](_0x66b2('0x26'),this[_0x66b2('0x27')][_0x66b2('0x28')](this));ami['on']('queuecallerabandon',this['syncQueueCallerAbandon']['bind'](this));ami['on'](_0x66b2('0x29'),this[_0x66b2('0x2a')][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x2b'),this[_0x66b2('0x2c')][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x2d'),this['syncQueueSummary'][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x2e'),this['syncQueueSummaryComplete']['bind'](this));ami['on']('hangup',this[_0x66b2('0x2f')][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x30'),this[_0x66b2('0x31')][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x32'),this['syncVarSet'][_0x66b2('0x28')](this));ami['on'](_0x66b2('0x33'),this[_0x66b2('0x34')]['bind'](this));ami['on'](_0x66b2('0x35'),this['syncQueueStatusComplete']['bind'](this));this[_0x66b2('0x36')]();this['loopClearZombieChannels']();RpcSetting[_0x66b2('0x37')]()[_0x66b2('0x38')](function(_0x1e2fa7){previewRecallmeReminderInterval=_0x1e2fa7[_0x66b2('0x39')];});}function isNotNull(_0x3ce410){return _0x3ce410!==null&&!_[_0x66b2('0x3a')](_0x3ce410);}function msgResponse(_0x2bcb73,_0x108041,_0x294e4c){return{'action':_0x2bcb73,'response':_0x108041,'message':_0x294e4c,'stack':_0x294e4c};}function emit(_0x200806,_0x4727cb,_0x31f8f0){io['to'](_0x200806)['emit'](_0x4727cb,_0x31f8f0);}function emitOutboundVoiceQueueSummary(_0xb5e3ae){if(_0xb5e3ae[_0x66b2('0x3b')]===_0x66b2('0x3c')){logger[_0x66b2('0x3d')](_0x66b2('0x3e'),util['inspect'](_0xb5e3ae,{'showHidden':![],'depth':null}));emit(util[_0x66b2('0x3f')](_0x66b2('0x40'),_0xb5e3ae[_0x66b2('0x41')]),'voice_queue:save',_0xb5e3ae);}}function checkGetDataPredictive(_0x79f11c){if(isNotNull(_0x79f11c)&&!_[_0x66b2('0x42')](_0x79f11c)){loggerPredictive[_0x66b2('0x43')](_0x66b2('0x44'));loggerPredictive[_0x66b2('0x43')](_0x66b2('0x45'),_0x79f11c[_0x66b2('0x46')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x47'),_0x79f11c[_0x66b2('0x48')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x49'),_0x79f11c['predictiveIntervalDroppedCallsTimeout']);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x4a'),_0x79f11c[_0x66b2('0x4b')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x4c'),_0x79f11c['predictiveIntervalAvgHoldtime']);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x4d'),_0x79f11c['predictiveIntervalAvgTalktime']);loggerPredictive[_0x66b2('0x43')]('---------------------------');if(_0x79f11c[_0x66b2('0x46')]>0x0){if(!_[_0x66b2('0x3a')](_0x79f11c[_0x66b2('0x4e')])&&_0x79f11c[_0x66b2('0x4e')]>0x0){return!![];}loggerPredictive[_0x66b2('0x43')](_0x66b2('0x4f'));if(!_['isUndefined'](_0x79f11c[_0x66b2('0x50')])&&_0x79f11c[_0x66b2('0x50')]>0x0){return!![];}loggerPredictive[_0x66b2('0x43')](_0x66b2('0x51'));}else{loggerPredictive['info'](_0x66b2('0x52'));}}else{loggerPredictive['info'](_0x66b2('0x53'));}return![];}function mergeDataErlangB(_0x51520d){return function(_0x4a1696){loggerPredictive[_0x66b2('0x43')]('---------\x20ErlangB\x20---------');loggerPredictive['info'](_0x66b2('0x54'),_0x4a1696[_0x66b2('0x55')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x56'),_0x4a1696['erlangCallToSecond']);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x57'),_0x4a1696[_0x66b2('0x58')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x59'),_0x4a1696[_0x66b2('0x5a')]);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x57'),_0x4a1696['erlangAbandonmentRate']);loggerPredictive['info'](_0x66b2('0x5b'));_[_0x66b2('0x5c')](_0x51520d,_0x4a1696);};}function ifInterval(_0x5276c8,_0x25a76d){if(_[_0x66b2('0x3a')](_0x25a76d)){return![];}return utils['getSeconds'](undefined,_0x25a76d)<_0x5276c8*0x3c;}function clearPredictiveAttributes(_0x2be553){if(_0x2be553['startProgressive']){_0x2be553[_0x66b2('0x21')]=undefined;loggerPredictive['debug'](_0x2be553[_0x66b2('0x41')],_0x66b2('0x5d'));}if(_0x2be553['startPredictive']){_0x2be553[_0x66b2('0x5e')]=undefined;loggerPredictive['debug'](_0x2be553[_0x66b2('0x41')],_0x66b2('0x5f'));}if(_0x2be553['handlePredictive']){clearInterval(_0x2be553[_0x66b2('0x60')]);_0x2be553[_0x66b2('0x60')]=undefined;loggerPredictive[_0x66b2('0x3d')](_0x2be553[_0x66b2('0x41')],'handlePredictive\x20interval\x20cleared');}}function loggerCatchPredictive(_0x117c9e,_0x4491a0){return function(_0x4ed009){loggerPredictive['error'](_0x4491a0['name'],_0x117c9e);loggerPredictive[_0x66b2('0x61')](_0x4ed009[_0x66b2('0x62')]);clearPredictiveAttributes(_0x4491a0);};}function loggerCatch(_0x3437e8){return function(_0x165780){logger[_0x66b2('0x61')](_0x3437e8,util[_0x66b2('0x63')](_0x165780,{'showHidden':![],'depth':null}));};}function loggerGetContactDialer(_0x481578,_0x48b6ff,_0x487ebd){return function(_0x40f29a){utils[_0x66b2('0x64')](_0x48b6ff,_0x487ebd,0x0);logger[_0x66b2('0x61')](_0x481578,util[_0x66b2('0x63')](_0x40f29a,{'showHidden':![],'depth':null}));};}function sendMessageReschedule(_0x26f12c){return function(_0x20e94d){if(isNotNull(_0x20e94d)&&isNotNull(_0x20e94d[0x0])){if(_0x20e94d[0x0][_0x66b2('0x65')]>0x0){_0x26f12c['message']=utils[_0x66b2('0x66')][_0x66b2('0x67')];logger[_0x66b2('0x43')](_0x66b2('0x68')+_0x26f12c[_0x66b2('0x41')],_0x20e94d[0x0][_0x66b2('0x65')],_0x66b2('0x69'));}else{_0x26f12c[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x6b')];logger[_0x66b2('0x43')]('[getContactDialer2][Empty]'+_0x26f12c[_0x66b2('0x41')]);}}};}function createObjHistory(_0x2dc340,_0x4594f3,_0x16b9bf,_0x4d9e3e,_0x6897d1){_0x2dc340[_0x66b2('0x6a')]=_0x16b9bf;var _0x5dde53=new Action(_0x2dc340,_0x4594f3);var _0x3724f2=new History(_0x5dde53);_0x3724f2[_0x66b2('0x6c')]=_0x4d9e3e;_0x3724f2[_0x66b2('0x6d')]=_0x6897d1;_0x3724f2[_0x66b2('0x6e')]=_0x5dde53[_0x66b2('0x6f')];return _0x3724f2;}function unlockQueueStatus(_0x2ffe9c,_0x592d0c){setTimeout(function(){if(_[_0x66b2('0x3a')](_0x2ffe9c[_0x66b2('0x70')])){loggerBooked[_0x66b2('0x61')]('[unlockQueueStatus][undefined]',_0x592d0c);}_0x2ffe9c[_0x66b2('0x70')]=!![];loggerBooked[_0x66b2('0x43')]('[booked][unlockQueueStatus]',_0x592d0c,JSON[_0x66b2('0x71')](_[_0x66b2('0x72')](_0x2ffe9c,[_0x66b2('0x41'),_0x66b2('0x70')])));},0x1f3);}function checkInterval(_0x32945c){return function(){if(!isNotNull(_0x32945c['Interval'])){_0x32945c[_0x66b2('0x6a')]=utils[_0x66b2('0x66')]['NULL_INTERVAL'];throw _0x32945c[_0x66b2('0x41')]+_0x66b2('0x73');}if(!isNotNull(_0x32945c['Interval'][_0x66b2('0x74')])){_0x32945c['message']=utils[_0x66b2('0x66')]['NULL_INTERVAL'];throw _0x32945c['name']+'\x20INTERVAL_IS_NULL';}if(!isNotNull(_[_0x66b2('0x42')](_0x32945c[_0x66b2('0x75')]['Intervals']))){_0x32945c[_0x66b2('0x6a')]=utils['CAMPAIGN_STATUS'][_0x66b2('0x76')];throw _0x32945c[_0x66b2('0x41')]+_0x66b2('0x73');}};}function checkIsIVRCampaignActive(_0x32fc3b){return function(){if(!utils['isIVRCampaignActive'](_0x32fc3b)){_0x32fc3b['message']=utils['CAMPAIGN_STATUS'][_0x66b2('0x77')];throw _0x32fc3b[_0x66b2('0x41')]+_0x66b2('0x78');}};}function emitCampaignSummary(_0x5e2e48){if(utils['isIVRCampaign'](_0x5e2e48)){emit(util[_0x66b2('0x3f')]('campaign:ivr:%s',_0x5e2e48[_0x66b2('0x41')]),_0x66b2('0x79'),_0x5e2e48);}}function loggerCatchQueueSummary(_0x2c0bdc,_0x3b233a){return function(_0x14f7b4){clearPredictiveAttributes(_0x3b233a);emitCampaignSummary(_0x3b233a);loggerSyncQueueSummary[_0x66b2('0x3d')](_0x2c0bdc,util[_0x66b2('0x63')](_0x14f7b4,{'showHidden':![],'depth':null}));};}function notSendMessagesCampaign(_0x622852){if(_0x622852[_0x66b2('0x7a')]){if(_0x622852[_0x66b2('0x7b')]===0x0){_0x622852[_0x66b2('0x7a')]=![];_0x622852[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x77')];loggerSyncQueueSummary[_0x66b2('0x3d')](_0x66b2('0x7c'),_0x622852[_0x66b2('0x41')],_0x66b2('0x7d'));}else{_0x622852[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x7e')];loggerSyncQueueSummary[_0x66b2('0x3d')](_0x66b2('0x7c'),_0x622852['name'],_0x66b2('0x7f'));}emitCampaignSummary(_0x622852);}}function myreject(_0x3bb465){return function(_0x24b1eb){return _0x3bb465(msgResponse(_0x66b2('0x80'),'Error',JSON[_0x66b2('0x71')](_0x24b1eb)));};}Dialer[_0x66b2('0x81')][_0x66b2('0x82')]=function(_0x59fb54){return!_['isUndefined'](_0x59fb54)&&_0x59fb54&&!_['isUndefined'](_0x59fb54[_0x66b2('0x41')])&&!_['isUndefined'](_0x59fb54[_0x66b2('0x83')])&&_0x59fb54[_0x66b2('0x83')]&&(this[_0x66b2('0x1c')][util[_0x66b2('0x3f')](_0x66b2('0x84'),_0x59fb54[_0x66b2('0x41')])][_0x66b2('0x85')]===_0x66b2('0x86')||this[_0x66b2('0x1c')][util[_0x66b2('0x3f')](_0x66b2('0x84'),_0x59fb54[_0x66b2('0x41')])]['status']===_0x66b2('0x87'));};Dialer[_0x66b2('0x81')][_0x66b2('0x88')]=function(_0x1be2c9){var _0x37ceb5=this;return function(){if(!_0x37ceb5[_0x66b2('0x82')](_0x1be2c9[_0x66b2('0x89')])){if(!_0x37ceb5[_0x66b2('0x82')](_0x1be2c9[_0x66b2('0x8a')])){_0x1be2c9[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x8b')];throw _0x1be2c9[_0x66b2('0x41')]+_0x66b2('0x8c');}}};};Dialer[_0x66b2('0x81')][_0x66b2('0x8d')]=function(_0x38b7ce,_0x2870f6,_0x3327cb,_0x34b72f){var _0x21488d=this;return function(){var _0x2ef77e=!![];return _0x21488d['ifTimeIvr'](_0x38b7ce,_0x2870f6,_0x3327cb,_0x34b72f,_0x2ef77e);};};Dialer['prototype'][_0x66b2('0x8e')]=function(_0x29878d,_0x2a6a73,_0x816496,_0x57f062){var _0x23c1df=this;return function(){var _0x3c9a05=![];return _0x23c1df[_0x66b2('0x8f')](_0x29878d[_0x66b2('0x74')],_0x2a6a73,_0x816496,_0x57f062,_0x3c9a05);};};Dialer[_0x66b2('0x81')][_0x66b2('0x8f')]=function(_0x11c67b,_0x4c59b9,_0x541e02,_0xbade66,_0x4892a1){var _0x540106=[];return new Promise(function(_0x4c3b75,_0x15299c){if(!isNotNull(_0x11c67b)){_0xbade66[_0x66b2('0x6a')]=utils[_0x66b2('0x66')]['NULL_INTERVAL'];return _0x15299c(msgResponse('ifTime',_0x66b2('0x90'),_0x541e02+_0x66b2('0x91')));}if(_[_0x66b2('0x42')](_0x11c67b)){_0xbade66['message']=utils[_0x66b2('0x66')][_0x66b2('0x92')];return _0x15299c(msgResponse('ifTime',_0x66b2('0x90'),_0x541e02+'\x20Intervals\x20is\x20empty\x20'));}if(_0x4c59b9&&_[_0x66b2('0x3a')](config[_0x66b2('0x93')][_0x4c59b9])){_0xbade66[_0x66b2('0x6a')]=utils['CAMPAIGN_STATUS'][_0x66b2('0x94')];return _0x15299c(msgResponse('ifTime',_0x66b2('0x90'),_0x541e02+_0x66b2('0x95')+_0x4c59b9));}if(_[_0x66b2('0x96')](_0x11c67b)){for(var _0xf6a454=0x0;_0xf6a454<_0x11c67b[_0x66b2('0x97')];_0xf6a454+=0x1){_0x540106['push'](ami[_0x66b2('0x98')]({'action':'command','command':util[_0x66b2('0x3f')](_0x66b2('0x99'),_0x11c67b[_0xf6a454][_0x66b2('0x9a')],!_[_0x66b2('0x3a')](config[_0x66b2('0x93')][_0x4c59b9])?_0x4c59b9:'')})[_0x66b2('0x38')](function(_0x43ea9e){return _0x43ea9e['content'][_0x66b2('0x9b')]('true')>=0x0;})[_0x66b2('0x9c')](myreject(_0x15299c)));}}else{_0x540106[_0x66b2('0x9d')](ami[_0x66b2('0x98')]({'action':_0x66b2('0x9e'),'command':util[_0x66b2('0x3f')](_0x66b2('0x99'),_0x11c67b,!_['isUndefined'](config[_0x66b2('0x93')][_0x4c59b9])?_0x4c59b9:'')})[_0x66b2('0x38')](function(_0x81bac1){return _0x81bac1['content'][_0x66b2('0x9b')](_0x66b2('0x9f'))>=0x0;})[_0x66b2('0x9c')](myreject(_0x15299c)));}Promise[_0x66b2('0xa0')](_0x540106)[_0x66b2('0x38')](function(_0x15f2f2){var _0x485ab1=_[_0x66b2('0xa1')](_0x15f2f2);if(_0x485ab1){return _0x4c3b75(_0x485ab1);}else{_0xbade66[_0x66b2('0x6a')]=_0x4892a1?utils[_0x66b2('0x66')][_0x66b2('0xa2')]:utils[_0x66b2('0x66')][_0x66b2('0xa3')];return _0x15299c(msgResponse(_0x66b2('0xa4'),'Failure',_0x66b2('0xa5')+_0x4892a1+'\x20'+_0x541e02+_0x66b2('0xa6')+util[_0x66b2('0x63')](_0x11c67b,{'showHidden':![],'depth':null})+_0x66b2('0xa7')+_0x4c59b9));}})[_0x66b2('0x9c')](function(_0x166431){return _0x15299c(msgResponse(_0x66b2('0xa8'),_0x66b2('0x90'),JSON[_0x66b2('0x71')](_0x166431)));});});};Dialer[_0x66b2('0x81')]['loopCampaigns']=function(){var _0x96cc21=this;return cmHopper[_0x66b2('0xa9')]({'active':![]},{'where':{'active':!![]}})['then'](function(){setInterval(function(){_0x96cc21[_0x66b2('0xaa')]();},0x3e8);});};Dialer[_0x66b2('0x81')]['syncCampaigns']=function(){var _0x579e89=this;var _0x3e1e28;for(var _0x4e3630 in this['campaigns']){if(typeof this['campaigns'][_0x4e3630]!==_0x66b2('0xab')){_0x3e1e28=this[_0x66b2('0x1a')][_0x4e3630];if(utils[_0x66b2('0xac')](_0x3e1e28)&&utils['isIVRCampaignActive'](_0x3e1e28)){_0x3e1e28[_0x66b2('0x7a')]=!![];Promise['resolve']()[_0x66b2('0x38')](checkIsIVRCampaignActive(_0x3e1e28))[_0x66b2('0x38')](checkInterval(_0x3e1e28))['then'](_0x579e89[_0x66b2('0x88')](_0x3e1e28))['then'](_0x579e89[_0x66b2('0x8d')](_0x3e1e28[_0x66b2('0xad')],_0x3e1e28[_0x66b2('0xae')],_0x3e1e28[_0x66b2('0x41')],_0x3e1e28))[_0x66b2('0x38')](_0x579e89[_0x66b2('0x8e')](_0x3e1e28[_0x66b2('0x75')],_0x3e1e28[_0x66b2('0xae')],_0x3e1e28[_0x66b2('0x41')],_0x3e1e28))[_0x66b2('0x38')](_0x579e89[_0x66b2('0xaf')](_0x3e1e28))['catch'](loggerCatchQueueSummary('[syncCampaigns]',_0x3e1e28));}else{notSendMessagesCampaign(_0x3e1e28);}}}};Dialer['prototype'][_0x66b2('0xb0')]=function(_0x2e54d6){if(_0x2e54d6[_0x66b2('0xb1')]!=='predictive'){clearPredictiveAttributes(_0x2e54d6);}switch(_0x2e54d6[_0x66b2('0xb1')]){case _0x66b2('0xb2'):this[_0x66b2('0xb3')](_0x2e54d6,0x1);break;case _0x66b2('0xb4'):this[_0x66b2('0xb3')](_0x2e54d6,_0x2e54d6[_0x66b2('0xb5')]);break;case _0x66b2('0x9'):this[_0x66b2('0x9')](_0x2e54d6);break;case'booked':this['handlePower'](_0x2e54d6,0x1);break;default:logger['error'](_0x66b2('0xb6'),_0x2e54d6[_0x66b2('0x41')],_0x66b2('0xb7'));}};Dialer[_0x66b2('0x81')][_0x66b2('0xa8')]=function(_0x57a609,_0xbaa802){var _0x451cfc=_0x57a609[_0x66b2('0xae')];var _0x36b2a4=_0xbaa802?_0x57a609[_0x66b2('0xad')]:_0x57a609[_0x66b2('0x75')][_0x66b2('0x74')];logger[_0x66b2('0xb8')](_0x66b2('0xb9'),_0x36b2a4,_0x451cfc,_0x57a609['name'],util[_0x66b2('0x3f')](_0x66b2('0xba'),_0x57a609['name'],_0x57a609['id']));var _0xb481d9=null;return Interval[_0x66b2('0xbb')](_0x36b2a4,_0x451cfc)[_0x66b2('0x38')](function(_0x41e566){if(_0x41e566===!![]){return _0x41e566;}else{_0x57a609['message']=_0xbaa802?utils[_0x66b2('0x66')][_0x66b2('0xa2')]:utils[_0x66b2('0x66')][_0x66b2('0xa3')];_0xb481d9=msgResponse(_0x66b2('0xa4'),_0x66b2('0x90'),_0x66b2('0xa5')+_0xbaa802+'\x20'+_0x57a609[_0x66b2('0x41')]+_0x66b2('0xa6')+util[_0x66b2('0x63')](_0x36b2a4,{'showHidden':![],'depth':null})+'Timezone:\x20'+_0x451cfc);}if(_0xb481d9!==null){logger[_0x66b2('0xb8')]('Dialer::ifTime()\x20errResponse\x20NOT\x20NULL:',_0xb481d9);_0xb481d9[_0x66b2('0xbc')]=_0xbaa802;throw _0xb481d9;}})[_0x66b2('0x9c')](function(_0x155d91){logger[_0x66b2('0x61')](_0x66b2('0xbd'),_0x155d91);throw msgResponse('[ifTime][Action]',_0x66b2('0xbe'),util[_0x66b2('0x63')](_0x155d91,{'showHidden':![],'depth':null}));});};Dialer['prototype'][_0x66b2('0x27')]=function(_0x3529f4){if(this['voiceQueues'][_0x3529f4[_0x66b2('0xbf')]]){if(this[_0x66b2('0x1f')][_0x3529f4['uniqueid']]&&this[_0x66b2('0x1f')][_0x3529f4[_0x66b2('0xc0')]][_0x66b2('0x3b')]!=='ivr'){this[_0x66b2('0xc1')](this[_0x66b2('0x19')][_0x3529f4[_0x66b2('0xbf')]]);this[_0x66b2('0x1f')][_0x3529f4['uniqueid']]['answertime']=moment()[_0x66b2('0x3f')](_0x66b2('0xc2'));}}};Dialer[_0x66b2('0x81')][_0x66b2('0x2c')]=function(_0x1b4d91){var _0x18f6d6=this['uniqueId'][_0x1b4d91[_0x66b2('0xc0')]];if(this['voiceQueues'][_0x1b4d91[_0x66b2('0xbf')]]){if(_0x18f6d6&&_0x18f6d6['type']!==_0x66b2('0xc3')){delete this[_0x66b2('0x1f')][_0x1b4d91[_0x66b2('0xc0')]];this[_0x66b2('0x19')][_0x1b4d91[_0x66b2('0xbf')]]['outboundAnswerCallsDay']+=0x1;var _0x2b6c6c=new AgentComplete(_0x18f6d6,_0x1b4d91);if(_0x1b4d91['reason']===_0x66b2('0xc4')){_0x2b6c6c[_0x66b2('0xc5')]=this[_0x66b2('0x19')][_0x1b4d91[_0x66b2('0xbf')]][_0x66b2('0xc6')]&&this[_0x66b2('0x19')][_0x1b4d91[_0x66b2('0xbf')]][_0x66b2('0xc7')]?moment()[_0x66b2('0x3f')](_0x66b2('0xc2')):undefined;}hopperUtils[_0x66b2('0xc8')](_0x2b6c6c)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xc9')));hopperUtils[_0x66b2('0xca')](_0x2b6c6c)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xcb')));}}};Dialer[_0x66b2('0x81')][_0x66b2('0xcc')]=function(_0xba8ab1){var _0x45123e=this[_0x66b2('0x1f')][_0xba8ab1[_0x66b2('0xc0')]];var _0x56cf82=this;var _0x203d1e=![];var _0x38ad9f;var _0x12fddc;if(this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]]){if(_0x45123e&&_0x45123e[_0x66b2('0x3b')]!==_0x66b2('0xc3')){delete this['uniqueId'][_0xba8ab1[_0x66b2('0xc0')]];this[_0x66b2('0xc1')](this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]]);_0x45123e[_0x66b2('0xcd')]=moment()[_0x66b2('0x3f')](_0x66b2('0xc2'));var _0xd26129=new QueueCallerAbandon(_0x45123e,_0xba8ab1);if(utils[_0x66b2('0xce')](_0x45123e['droptime'],_0x45123e['responsetime'])>=_0x45123e[_0x66b2('0xcf')]){this['voiceQueues'][_0xba8ab1['queue']][_0x66b2('0xd0')]+=0x1;this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xd1')]+=0x1;this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]]['predictiveIntervalErlangCallsDroppedCalls']+=0x1;_0xd26129['state']=0xa;_0xd26129[_0x66b2('0x6d')]='Drop';_0xd26129[_0x66b2('0xd2')]='TIMEOUT';_0xd26129[_0x66b2('0xc5')]=this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xc6')]?moment()[_0x66b2('0x3f')](_0x66b2('0xc2')):undefined;_0xd26129[_0x66b2('0xd3')]+=0x1;_0xd26129['countglobal']+=0x1;_0x38ad9f=this[_0x66b2('0x19')][_0xba8ab1['queue']][_0x66b2('0xd4')];_0x12fddc=this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xd5')];hopperUtils[_0x66b2('0xd6')](_0xd26129,_0xd26129[_0x66b2('0x6c')],_0x45123e['voiceQueue'])['then'](function(_0x1923c2){_0x203d1e=_0x1923c2[_0x66b2('0xd7')]==0x1;if(_0xd26129['countdropretry']>=_0x56cf82[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xd8')]){_0x56cf82[_0x66b2('0xd9')](_0xd26129,_0x1923c2['additional']);}else{hopperUtils[_0x66b2('0xda')]({'active':![],'countdropretry':_0xd26129['countdropretry'],'scheduledat':moment()[_0x66b2('0xdb')](_0x56cf82[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xd4')],'minutes')[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x45123e[_0x66b2('0xdc')],'ListId':_0x45123e['ListId'],'VoiceQueueId':_0x45123e[_0x66b2('0xdd')]||undefined,'CampaignId':_0x45123e[_0x66b2('0xde')]||undefined})['catch'](loggerCatch(_0x66b2('0xdf')));var _0x14de35=new History(_0xd26129);_0x14de35[_0x66b2('0x6c')]=0xa;_0x14de35[_0x66b2('0x6d')]=_0x66b2('0xe0');_0x14de35[_0x66b2('0x6f')]=moment()[_0x66b2('0x3f')]('YYYY-MM-DD\x20HH:mm:ss');_0x14de35[_0x66b2('0x6e')]=_0x14de35[_0x66b2('0x6f')];_0x14de35[_0x66b2('0xe1')]=_0xd26129[_0x66b2('0xe1')];_0x14de35['calleridnum']=_0xd26129['calleridnum'];hopperUtils[_0x66b2('0xc8')](_0x14de35)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xe2')));}})['then'](function(){if(_0x203d1e)hopperUtils[_0x66b2('0xe3')](_0xd26129,_0x38ad9f,_0x12fddc)[_0x66b2('0x38')](function(){return 0x1;});});}else{this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0x4b')]+=0x1;this[_0x66b2('0x19')][_0xba8ab1['queue']][_0x66b2('0xe4')]+=0x1;_0xd26129[_0x66b2('0x6c')]=0xb;_0xd26129['statedesc']='Abandoned';_0xd26129[_0x66b2('0xd2')]=_0x66b2('0xe5');_0xd26129[_0x66b2('0xe6')]+=0x1;_0xd26129[_0x66b2('0xe7')]+=0x1;_0x38ad9f=this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xe8')];_0x12fddc=this[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xd5')];hopperUtils[_0x66b2('0xd6')](_0xd26129,_0xd26129[_0x66b2('0x6c')],_0x45123e[_0x66b2('0xe9')])[_0x66b2('0x38')](function(_0x189050){if(_0xd26129[_0x66b2('0xe6')]>=_0x56cf82[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]][_0x66b2('0xea')]){_0x56cf82[_0x66b2('0xd9')](_0xd26129,_0x189050[_0x66b2('0xd7')]);}else{hopperUtils['rescheduleContact']({'active':![],'countabandonedretry':_0xd26129[_0x66b2('0xe6')],'scheduledat':moment()[_0x66b2('0xdb')](_0x56cf82[_0x66b2('0x19')][_0xba8ab1[_0x66b2('0xbf')]]['dialAbandonedRetryFrequency'],'minutes')[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x45123e[_0x66b2('0xdc')],'ListId':_0x45123e[_0x66b2('0xeb')],'VoiceQueueId':_0x45123e['VoiceQueueId']||undefined,'CampaignId':_0x45123e[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch('[rescheduleContact][Abandoned]'));var _0x133966=new History(_0xd26129);_0x133966[_0x66b2('0x6c')]=0xb;_0x133966['statedesc']=_0x66b2('0xec');_0x133966[_0x66b2('0x6f')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x133966[_0x66b2('0x6e')]=_0x133966[_0x66b2('0x6f')];_0x133966[_0x66b2('0xe1')]=_0xd26129[_0x66b2('0xe1')];_0x133966[_0x66b2('0xed')]=_0xd26129[_0x66b2('0xed')];hopperUtils[_0x66b2('0xc8')](_0x133966)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xee')));}})[_0x66b2('0x38')](function(){if(_0x203d1e)hopperUtils['swapAdditionalPhones'](_0xd26129,_0x38ad9f,_0x12fddc)['then'](function(){return 0x1;});});}}}};Dialer[_0x66b2('0x81')][_0x66b2('0x31')]=function(_0x41ad5a){if(this[_0x66b2('0xef')][_0x41ad5a[_0x66b2('0xc0')]]){this[_0x66b2('0xef')][_0x41ad5a[_0x66b2('0xc0')]][_0x66b2('0xf0')]=_0x41ad5a['channel'];}if(this[_0x66b2('0x1f')][_0x41ad5a[_0x66b2('0xc0')]]){this[_0x66b2('0x1f')][_0x41ad5a[_0x66b2('0xc0')]]['channel']=_0x41ad5a[_0x66b2('0xf0')];}};Dialer[_0x66b2('0x81')][_0x66b2('0x34')]=function(_0x47e1ef){if(!this['actions'][_0x47e1ef[_0x66b2('0xf1')]]){return;}var _0x4e8115=this['voiceQueues'][this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xbf')]]['strategy']||_0x66b2('0xf2');if(_0x4e8115===_0x66b2('0xf3')){if(this['actions'][_0x47e1ef[_0x66b2('0xf1')]]&&_[_0x66b2('0xf4')](this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xf5')])&&_0x47e1ef[_0x66b2('0x85')]==='1'&&_0x47e1ef[_0x66b2('0xf6')]==='0'){if(this[_0x66b2('0x1b')][_0x47e1ef[_0x66b2('0xf7')]]){if(!this[_0x66b2('0x1b')][_0x47e1ef[_0x66b2('0xf7')]][_0x66b2('0xf5')]){this[_0x66b2('0x1b')][_0x47e1ef[_0x66b2('0xf7')]][_0x66b2('0xf5')]=!![];this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xf5')]=!![];this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]]['stateinterface']=_0x47e1ef[_0x66b2('0xf7')];}}}}else if(_0x4e8115===_0x66b2('0xf2')){if(this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]]){if(this[_0x66b2('0x1b')][_0x47e1ef[_0x66b2('0xf7')]]){this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xf7')]=_0x47e1ef[_0x66b2('0xf7')];if(_['isNil'](this['queueBooked'][this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xbf')]])){this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xbf')]]=[];}this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x47e1ef[_0x66b2('0xf1')]][_0x66b2('0xbf')]][_0x66b2('0x9d')](_[_0x66b2('0x5c')](_[_0x66b2('0x72')](this['actions'][_0x47e1ef[_0x66b2('0xf1')]],[_0x66b2('0xf8'),_0x66b2('0xf7')]),{'status':_0x47e1ef[_0x66b2('0x85')],'paused':_0x47e1ef[_0x66b2('0xf6')]}));}}}};Dialer['prototype']['syncQueueStatusComplete']=function(_0x595cc1){if(!this['actions'][_0x595cc1[_0x66b2('0xf1')]]){return;}var _0x30bcc5=this;var _0x5817d9=this['voiceQueues'][this['actions'][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]];var _0x1b6620=_0x5817d9[_0x66b2('0xf9')]||_0x66b2('0xf2');if(_0x1b6620===_0x66b2('0xf3')){if(this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]]&&this[_0x66b2('0xef')][_0x595cc1['actionid']][_0x66b2('0xf7')]){this[_0x66b2('0x18')][_0x66b2('0xfa')](this['actions'][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xf8')],this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xf7')])[_0x66b2('0x9c')](function(_0x179727){logger[_0x66b2('0x61')](_0x66b2('0xfb'),util['inspect'](_0x179727,{'showHidden':![],'depth':null}));})['finally'](function(){_0x30bcc5[_0x66b2('0xc1')](_0x30bcc5['voiceQueues'][_0x30bcc5[_0x66b2('0xef')][_0x595cc1['actionid']][_0x66b2('0xbf')]]);_0x30bcc5['agents'][_0x30bcc5[_0x66b2('0xef')][_0x595cc1['actionid']][_0x66b2('0xf7')]][_0x66b2('0xf5')]=![];delete _0x30bcc5[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]];unlockQueueStatus(_0x5817d9);});}else{this[_0x66b2('0xc1')](this[_0x66b2('0x19')][this['actions'][_0x595cc1[_0x66b2('0xf1')]]['queue']]);hopperUtils['rescheduleContact']({'active':![],'ContactId':this['actions'][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xdc')],'ListId':this['actions'][_0x595cc1['actionid']]['ListId'],'VoiceQueueId':this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]]['VoiceQueueId']||undefined,'CampaignId':this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xfc')));delete this['actions'][_0x595cc1[_0x66b2('0xf1')]];unlockQueueStatus(_0x5817d9);}}else if(_0x1b6620===_0x66b2('0xf2')){var _0x53ef72;if(this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]]&&!_[_0x66b2('0x42')](this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x595cc1['actionid']][_0x66b2('0xbf')]])){if(this[_0x66b2('0x24')][_0x30bcc5[_0x66b2('0xef')][_0x595cc1['actionid']][_0x66b2('0xbf')]]){this[_0x66b2('0x24')][_0x30bcc5['actions'][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]]=this[_0x66b2('0x24')][this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]]['queue']]?this[_0x66b2('0x24')][this['actions'][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]]:this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]]?this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]]['_rr']||0x0:0x0;}this[_0x66b2('0x23')][this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]]['_rr']=this[_0x66b2('0x24')][this[_0x66b2('0xef')][_0x595cc1[_0x66b2('0xf1')]][_0x66b2('0xbf')]];for(var _0x58b67d=0x0;_0x58b67d=_0x5062ff['dialGlobalMaxRetry']){_0x90ac4[_0x66b2('0x121')](_0x33ca58,_0x7f7c18,_0x1b664a,'reason19\x20machine....');}else{if(_0x33ca58['countmachineretry']>=_0x5062ff[_0x66b2('0x122')]){_0x90ac4[_0x66b2('0x123')](_0x33ca58,_0x7f7c18,_0x1b664a,_0x66b2('0x124'));}else{hopperUtils['rescheduleContact']({'active':![],'countmachineretry':_0x33ca58['countmachineretry'],'scheduledat':moment()[_0x66b2('0xdb')](_0x5062ff[_0x66b2('0x125')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x33ca58[_0x66b2('0xdc')],'ListId':_0x33ca58[_0x66b2('0xeb')],'VoiceQueueId':_0x33ca58['VoiceQueueId']||undefined,'CampaignId':_0x33ca58[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x127')));_0x7f7c18({'reschedule':0x1});}}});}if(_0x2bce99[_0x66b2('0x3b')]===_0x66b2('0xc3')&&this[_0x66b2('0x1a')][_0x2bce99[_0x66b2('0xbf')]][_0x66b2('0x10c')]&&_0x1c2ac9[_0x66b2('0x10d')]===_0x66b2('0x10e')){delete this[_0x66b2('0x1f')][_0x1c2ac9[_0x66b2('0xc0')]];this[_0x66b2('0xc1')](this[_0x66b2('0x1a')][_0x2bce99['queue']]);_0x16c97b=new Hangup(_0x2bce99,_0x1c2ac9);_0x16c97b[_0x66b2('0x6c')]=0x12;_0x16c97b[_0x66b2('0x6d')]=_0x66b2('0x110');_0x16c97b['membername']=_0x66b2('0x112');ami['emit']('custom:amd',ut[_0x66b2('0x115')](_0x16c97b,_0x66b2('0x116')));this[_0x66b2('0x128')](_0x16c97b,_0x66b2('0x129'),'[syncHangupInAMDIvr]');}if(_0x2bce99[_0x66b2('0x3b')]===_0x66b2('0xc3')&&this['campaigns'][_0x2bce99[_0x66b2('0xbf')]][_0x66b2('0x10c')]&&_0x1c2ac9['value']===_0x66b2('0x119')){return new Promise(function(_0x30f48a,_0x5d2eac){delete _0x90ac4['uniqueId'][_0x1c2ac9[_0x66b2('0xc0')]];_0x90ac4[_0x66b2('0xc1')](_0x90ac4[_0x66b2('0x1a')][_0x2bce99[_0x66b2('0xbf')]]);_0x90ac4[_0x66b2('0x1a')][_0x2bce99[_0x66b2('0xbf')]]['outboundAnswerCallsDay']+=0x1;_0x90ac4[_0x66b2('0x1a')][_0x2bce99[_0x66b2('0xbf')]][_0x66b2('0x10f')]+=0x1;var _0x122dad=_0x90ac4[_0x66b2('0x1a')][_0x2bce99[_0x66b2('0xbf')]];var _0x22aad0=new Hangup(_0x2bce99,_0x1c2ac9);_0x22aad0[_0x66b2('0x6c')]=0x13;_0x22aad0[_0x66b2('0x6d')]=_0x66b2('0x12a');_0x22aad0[_0x66b2('0x111')]='AMD';_0x22aad0['countmachineretry']+=0x1;_0x22aad0['countglobal']+=0x1;_0x22aad0[_0x66b2('0x116')]=!![];ami[_0x66b2('0x113')](_0x66b2('0x114'),ut[_0x66b2('0x115')](_0x22aad0,_0x66b2('0x116')));hopperUtils[_0x66b2('0xc8')](_0x22aad0)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x12b')));if(_0x22aad0[_0x66b2('0x11b')]+_0x22aad0[_0x66b2('0x11c')]+_0x22aad0[_0x66b2('0x11d')]+_0x22aad0[_0x66b2('0x11e')]+_0x22aad0[_0x66b2('0xd3')]+_0x22aad0['countabandonedretry']+_0x22aad0[_0x66b2('0x11f')]+_0x22aad0[_0x66b2('0x120')]>=_0x122dad['dialGlobalMaxRetry']){_0x90ac4[_0x66b2('0x121')](_0x22aad0,_0x30f48a,_0x5d2eac,'reason19\x20machine....');}else{if(_0x22aad0['countmachineretry']>=_0x122dad[_0x66b2('0x122')]){_0x90ac4[_0x66b2('0x123')](_0x22aad0,_0x30f48a,_0x5d2eac,'reason\x2019\x20machine....');}else{hopperUtils[_0x66b2('0xda')]({'active':![],'countmachineretry':_0x22aad0[_0x66b2('0x11f')],'scheduledat':moment()[_0x66b2('0xdb')](_0x122dad[_0x66b2('0x125')],_0x66b2('0x126'))['format'](_0x66b2('0xc2')),'ContactId':_0x22aad0['ContactId'],'ListId':_0x22aad0[_0x66b2('0xeb')],'VoiceQueueId':_0x22aad0[_0x66b2('0xdd')]||undefined,'CampaignId':_0x22aad0[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch('[rescheduleContact][Machine]'));_0x30f48a({'reschedule':0x1});}}});}}};Dialer[_0x66b2('0x81')][_0x66b2('0x2f')]=function(_0x19ad7b){var _0x21e8a1=this['uniqueId'][_0x19ad7b[_0x66b2('0xc0')]];var _0x2f8041;if(_0x21e8a1&&_0x21e8a1[_0x66b2('0x3b')]===_0x66b2('0xc3')){delete this[_0x66b2('0x1f')][_0x19ad7b[_0x66b2('0xc0')]];this['updateOriginated'](this[_0x66b2('0x1a')][_0x21e8a1['queue']]);this[_0x66b2('0x1a')][_0x21e8a1['queue']][_0x66b2('0x12c')]+=0x1;_0x2f8041=new Hangup(_0x21e8a1,_0x19ad7b);hopperUtils[_0x66b2('0xc8')](_0x2f8041)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x12d')));hopperUtils['moveContactManagedDialer'](_0x2f8041)['catch'](loggerCatch(_0x66b2('0x12e')));}if(_0x21e8a1&&_0x21e8a1[_0x66b2('0x3b')]!==_0x66b2('0xc3')&&isNotNull(this[_0x66b2('0x19')][_0x21e8a1[_0x66b2('0xbf')]][_0x66b2('0x12f')])){delete this[_0x66b2('0x1f')][_0x19ad7b[_0x66b2('0xc0')]];this[_0x66b2('0xc1')](this['voiceQueues'][_0x21e8a1[_0x66b2('0xbf')]]);this['voiceQueues'][_0x21e8a1[_0x66b2('0xbf')]]['outboundAnswerCallsDay']+=0x1;this[_0x66b2('0x19')][_0x21e8a1['queue']][_0x66b2('0x10f')]+=0x1;_0x2f8041=new Hangup(_0x21e8a1,_0x19ad7b);_0x2f8041[_0x66b2('0x6c')]=0x10;_0x2f8041[_0x66b2('0x6d')]='AnswerAGI';_0x2f8041[_0x66b2('0x111')]=_0x66b2('0x130');hopperUtils[_0x66b2('0xc8')](_0x2f8041)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x12d')));hopperUtils[_0x66b2('0xca')](_0x2f8041)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x12e')));}if(_0x21e8a1&&_0x21e8a1[_0x66b2('0x3b')]!==_0x66b2('0xc3')&&!isNotNull(this[_0x66b2('0x19')][_0x21e8a1[_0x66b2('0xbf')]][_0x66b2('0x12f')])){delete this[_0x66b2('0x1f')][_0x19ad7b['uniqueid']];this[_0x66b2('0xc1')](this[_0x66b2('0x19')][_0x21e8a1[_0x66b2('0xbf')]]);this['voiceQueues'][_0x21e8a1['queue']][_0x66b2('0x131')]+=0x1;_0x2f8041=new Hangup(_0x21e8a1,_0x19ad7b);_0x2f8041[_0x66b2('0x6c')]=0xc;_0x2f8041[_0x66b2('0x6d')]=_0x19ad7b[_0x66b2('0x132')];_0x2f8041[_0x66b2('0x111')]=_0x66b2('0x133');hopperUtils[_0x66b2('0xc8')](_0x2f8041)['catch'](loggerCatch(_0x66b2('0x12d')));hopperUtils[_0x66b2('0xca')](_0x2f8041)['catch'](loggerCatch('[syncHangupIvr]'));}};Dialer['prototype']['syncQueueSummary']=function(_0x2292aa){var _0x25e4a5=this;if(!_0x25e4a5[_0x66b2('0x25')][_0x2292aa[_0x66b2('0x41')]]){_0x25e4a5[_0x66b2('0x25')][_0x2292aa[_0x66b2('0x41')]]={'running':![]};}else if(_0x25e4a5[_0x66b2('0x25')][_0x2292aa['name']][_0x66b2('0x134')]===!![]){return;}else if(_0x25e4a5[_0x66b2('0x25')][_0x2292aa[_0x66b2('0x41')]][_0x66b2('0x134')]===![]){_0x25e4a5[_0x66b2('0x25')][_0x2292aa[_0x66b2('0x41')]]['running']=!![];}var _0x400450=_0x25e4a5[_0x66b2('0x19')][_0x2292aa['name']];var _0x5dc954=_0x400450['message']!==utils[_0x66b2('0x66')]['INACTIVE'];var _0x7255fe=utils[_0x66b2('0x135')](_0x400450);_0x400450[_0x66b2('0x136')]=utils[_0x66b2('0x137')](_0x400450,_0x25e4a5[_0x66b2('0x1c')]);Promise[_0x66b2('0x138')]()[_0x66b2('0x38')](function(){if(_0x400450[_0x66b2('0x136')]===utils[_0x66b2('0x66')][_0x66b2('0x77')]){if(_0x5dc954){clearPredictiveAttributes(_0x400450);_0x2292aa[_0x66b2('0x5e')]=undefined;_0x2292aa[_0x66b2('0x21')]=undefined;}if(_0x400450[_0x66b2('0x136')]===utils[_0x66b2('0x66')][_0x66b2('0x77')]){_0x2292aa[_0x66b2('0x139')]=0x0;_0x2292aa['paused']=0x0;_0x2292aa[_0x66b2('0x13a')]=0x0;_0x2292aa[_0x66b2('0x13b')]=0x0;_0x2292aa[_0x66b2('0x13c')]=0x0;}}else if(_0x400450['statusMessage']===utils[_0x66b2('0x66')][_0x66b2('0x13d')]&&!_0x7255fe){return _0x25e4a5[_0x66b2('0xa8')](_0x400450,!![])[_0x66b2('0x38')](function(){return _0x25e4a5[_0x66b2('0xa8')](_0x400450,![]);})['then'](function(){return _0x25e4a5[_0x66b2('0xb0')](_0x400450);})[_0x66b2('0x9c')](function(_0x3ac05a){loggerSyncQueueSummary[_0x66b2('0x3d')](_0x66b2('0x13e'),util[_0x66b2('0x63')](_0x3ac05a,{'showHidden':![],'depth':null}));clearPredictiveAttributes(_0x400450);});}else{clearPredictiveAttributes(_0x400450);}})['then'](function(){var _0xb056cd=_0x2292aa[_0x66b2('0x13f')](_0x400450);if(_0xb056cd||_0x400450[_0x66b2('0x140')]){_0x400450['queueSummaryCountersUpdated']=![];_0x2292aa[_0x66b2('0x141')](_0x400450);Object[_0x66b2('0x142')](_0x400450,_0x2292aa);emitOutboundVoiceQueueSummary(_0x2292aa);}_0x25e4a5[_0x66b2('0x25')][_0x400450[_0x66b2('0x41')]][_0x66b2('0x134')]=![];})[_0x66b2('0x9c')](function(_0x48f66e){logger[_0x66b2('0x61')]('[syncQueueSummary]',util[_0x66b2('0x63')](_0x48f66e,{'showHidden':![],'depth':null}));_0x25e4a5[_0x66b2('0x25')][_0x400450[_0x66b2('0x41')]][_0x66b2('0x134')]=![];});};Dialer[_0x66b2('0x81')][_0x66b2('0x143')]=_['throttle'](function(){var _0x1a1c66=_[_0x66b2('0x144')](this[_0x66b2('0x19')],function(_0xf194be){return _0xf194be['dialPreviewRecallmeReminder'];});var _0xf345a6=_[_0x66b2('0x144')](this[_0x66b2('0x1b')],function(_0x5483c1){return _0x5483c1[_0x66b2('0x145')]&&_0x5483c1[_0x66b2('0x85')]==='reachable';});if(_0x1a1c66[_0x66b2('0x97')]>0x0&&_0xf345a6[_0x66b2('0x97')]>0x0){return Promise[_0x66b2('0x138')]()[_0x66b2('0x38')](cmHopper['handlePreviewRecallNotifications'](_[_0x66b2('0x146')](_0x1a1c66,'id'),previewRecallmeReminderInterval,_[_0x66b2('0x146')](_0xf345a6,'id')))['then'](function(_0x456779){for(var _0x462fea=0x0;_0x462fea<_0x456779['length'];_0x462fea++){var _0x5a9529=_0x456779[_0x462fea]['Agent'][_0x66b2('0x41')];if(_0x5a9529)io['to'](util['format']('user:%s',_0x5a9529))[_0x66b2('0x113')](_0x66b2('0x147'),{'hopper':_0x456779[_0x462fea]});}})[_0x66b2('0x9c')](function(_0x40cf8f){logger[_0x66b2('0x61')](_0x66b2('0x148'),_0x40cf8f);});}},0x3c*0x3e8,{'leading':!![]});Dialer[_0x66b2('0x81')]['loopClearZombieChannels']=function(){var _0x284847=this;setInterval(function(){_0x284847[_0x66b2('0x149')](_0x284847[_0x66b2('0x1f')],_0x66b2('0x14a'));_0x284847[_0x66b2('0x149')](_0x284847[_0x66b2('0xef')],'[actions]');},0x32c8);};Dialer['prototype']['clearZombieChannels']=function(_0x3c3a70,_0x347bc9){var _0x39a18c=this;for(var _0x225ec6 in _0x3c3a70){if(typeof _0x3c3a70[_0x225ec6]!==_0x66b2('0xab')){this['sequence'][_0x66b2('0x14')](function(){if(!_['isNil'](_0x3c3a70[_0x225ec6])){return ami[_0x66b2('0x98')]({'action':_0x66b2('0x85'),'channel':_0x3c3a70[_0x225ec6][_0x66b2('0xf0')]})['catch'](function(_0x37b412){if(_0x37b412[_0x66b2('0x6a')]===_0x66b2('0x14b')){setTimeout(function(){if(_0x3c3a70[_0x225ec6]&&_0x3c3a70[_0x225ec6][_0x66b2('0x3b')]!==_0x66b2('0xc3')){_0x39a18c[_0x66b2('0xc1')](_0x39a18c['voiceQueues'][_0x3c3a70[_0x225ec6][_0x66b2('0xbf')]]);logger[_0x66b2('0x61')](_0x66b2('0x14c'),_0x347bc9,_0x225ec6,_0x3c3a70[_0x225ec6][_0x66b2('0xbf')]);delete _0x3c3a70[_0x225ec6];}if(_0x3c3a70[_0x225ec6]&&_0x3c3a70[_0x225ec6]['type']===_0x66b2('0xc3')){_0x39a18c['updateOriginated'](_0x39a18c[_0x66b2('0x1a')][_0x3c3a70[_0x225ec6][_0x66b2('0xbf')]]);logger[_0x66b2('0x61')](_0x66b2('0x14d'),_0x347bc9,_0x225ec6,_0x3c3a70[_0x225ec6][_0x66b2('0xbf')]);delete _0x3c3a70[_0x225ec6];}},0x2328);}});}});}}};Dialer['prototype'][_0x66b2('0x14e')]=function(_0x465284){return Promise[_0x66b2('0x138')]()[_0x66b2('0x38')](voiceQueueRt[_0x66b2('0x14e')](_0x465284))[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x14f')));};Dialer['prototype']['updateOriginated']=function(_0x3b3e29){if(!_[_0x66b2('0x3a')](_0x3b3e29)&&_0x3b3e29!==null){if(typeof _0x3b3e29['originated']!==_0x66b2('0xab')){if(_0x3b3e29['originated']>0x0){_0x3b3e29[_0x66b2('0x7b')]-=0x1;}else{logger[_0x66b2('0x61')](_0x66b2('0x150'));}}}else{logger[_0x66b2('0x61')](_0x66b2('0x151'));}};Dialer[_0x66b2('0x81')][_0x66b2('0x152')]=function(_0x2455a5,_0x52036f){var _0x3d9b3a=this;return function(_0x470387){_0x3d9b3a[_0x66b2('0xc1')](_0x52036f);logger[_0x66b2('0x61')](_0x2455a5,util[_0x66b2('0x63')](_0x470387,{'showHidden':![],'depth':null}));};};Dialer[_0x66b2('0x81')][_0x66b2('0x153')]=function(_0x5f0c2f,_0x1687c7,_0x3e5cde){var _0x73b821={'state':0x19,'statedesc':'notFound'};this[_0x66b2('0xc1')](_0x1687c7);this[_0x66b2('0x128')](_[_0x66b2('0x5c')](_0x73b821,_[_0x66b2('0x72')](_0x3e5cde,[_0x66b2('0xdc'),_0x66b2('0xeb'),_0x66b2('0x154'),_0x66b2('0xdd'),_0x66b2('0xde')])),_0x66b2('0x155'),'[emptyContact]');logger['error'](_0x5f0c2f);};Dialer[_0x66b2('0x81')][_0x66b2('0x128')]=function(_0x5f2143,_0x5cb28e,_0x2fdc98){hopperUtils[_0x66b2('0xc8')](_0x5f2143)[_0x66b2('0x9c')](loggerCatch(_0x5cb28e));hopperUtils[_0x66b2('0xca')](_0x5f2143)[_0x66b2('0x9c')](loggerCatch(_0x2fdc98));};Dialer[_0x66b2('0x81')][_0x66b2('0xd9')]=function(_0x9517ee,_0x2cdc61){hopperUtils[_0x66b2('0xc8')](_0x9517ee)['catch'](loggerCatch(_0x66b2('0xc9')));if(_0x2cdc61==0x0){hopperUtils[_0x66b2('0xca')](_0x9517ee)['catch'](loggerCatch(_0x66b2('0x156')));}};Dialer[_0x66b2('0x81')]['checkPreviewRecallReminder']=function(_0x2a8b5c){return Promise['resolve']()[_0x66b2('0x38')](cmHopper['handlePreviewRecallNotifications'](_0x2a8b5c['id'],previewRecallmeReminderInterval))[_0x66b2('0x38')](function(_0x4659eb){for(var _0x20c40c=0x0;_0x20c40c<_0x4659eb['length'];_0x20c40c++){var _0x3276cc=_0x4659eb[_0x20c40c][_0x66b2('0x157')][_0x66b2('0x41')];if(_0x3276cc)io['to'](util[_0x66b2('0x3f')](_0x66b2('0x158'),_0x3276cc))[_0x66b2('0x113')]('user:dialPreviewRecallReminder',{'hopper':_0x4659eb[_0x20c40c]});}})[_0x66b2('0x9c')](function(){});};Dialer[_0x66b2('0x81')]['launchHandleIvr']=function(_0x23b619){var _0x179a86=this;return function(){_0x179a86[_0x66b2('0x159')](_0x23b619);};};Dialer[_0x66b2('0x81')][_0x66b2('0x15a')]=function(_0x22859b,_0x18eab9){var _0x2ae11c=this;var _0x4cae6b=uuid['v4']();this[_0x66b2('0xef')][_0x4cae6b]=new Action(_0x22859b,_0x18eab9,_0x4cae6b);return new Promise(function(_0x50f3e5,_0x751b17){if(_['isUndefined'](_0x22859b)&&typeof _0x22859b!=='object'){return _0x751b17(msgResponse('originate','Failure',_0x66b2('0x15b')));}if(_[_0x66b2('0x3a')](_0x18eab9[_0x66b2('0x15c')])||_0x18eab9[_0x66b2('0x15c')]===null){return _0x751b17(msgResponse(_0x66b2('0x15d'),_0x66b2('0x90'),'contact\x20is\x20undefine'));}var _0x369f9c={'XMD-CALLERID':_0x2ae11c[_0x66b2('0xef')][_0x4cae6b][_0x66b2('0x15e')](),'XMD-AGI':_0x22859b[_0x66b2('0x12f')]?util[_0x66b2('0x3f')]('\x22agi://%s/square,%s\x22',ipAgi,_0x22859b['dialQueueProject']):_0x66b2('0x15f'),'XMD-AGIAFTER':_0x22859b['dialQueueProject2']?util[_0x66b2('0x3f')](_0x66b2('0x160'),ipAgi,_0x22859b[_0x66b2('0xc6')]):_0x66b2('0x15f'),'XMD-QUEUE':utils[_0x66b2('0x161')](_0x22859b)?util[_0x66b2('0x3f')](_0x66b2('0x162'),_0x22859b[_0x66b2('0x41')],_0x22859b[_0x66b2('0x163')]||'',_0x22859b[_0x66b2('0xc7')]?'c':'',_0x22859b['dialQueueTimeout']||0x3):_0x66b2('0x15f'),'XMD-CONTACTID':_0x18eab9[_0x66b2('0xdc')],'XMD-CDRTYPE':_0x66b2('0x8'),'CALLERID(all)':_0x2ae11c[_0x66b2('0xef')][_0x4cae6b]['getCaller'](),'XMD-AMD':_0x22859b[_0x66b2('0x10c')]?_0x66b2('0x13d'):_0x66b2('0x15f'),'XMD-DESTINATION':_0x66b2('0x10b')};if(_0x22859b[_0x66b2('0x10c')]){_0x369f9c[_0x66b2('0x164')]=_0x22859b[_0x66b2('0x165')]||0x9c4;_0x369f9c['XMD-AMDGREETING']=_0x22859b[_0x66b2('0x166')]||0x5dc;_0x369f9c[_0x66b2('0x167')]=_0x22859b['dialAMDAfterGreetingSilence']||0x320;_0x369f9c[_0x66b2('0x168')]=_0x22859b[_0x66b2('0x169')]||0x1388;_0x369f9c[_0x66b2('0x16a')]=_0x22859b['dialAMDMinWordLength']||0x64;_0x369f9c[_0x66b2('0x16b')]=_0x22859b[_0x66b2('0x16c')]||0x32;_0x369f9c[_0x66b2('0x16d')]=_0x22859b[_0x66b2('0x16e')]||0x3;_0x369f9c[_0x66b2('0x16f')]=_0x22859b[_0x66b2('0x170')]||0x100;_0x369f9c[_0x66b2('0x171')]=_0x22859b['dialAMDMaximumWordLength']||0x1388;}if(utils['isOutboundQueue'](_0x22859b)){_0x369f9c[_0x66b2('0x172')]=_0x18eab9['VoiceQueueId'];}else{_0x369f9c['XMD-CAMPAIGNID']=_0x18eab9[_0x66b2('0xde')];}for(var _0x294d85 in _0x18eab9[_0x66b2('0x173')]){if(typeof _0x18eab9[_0x66b2('0x173')][_0x294d85]!==_0x66b2('0xab')){if(isNotNull(_0x18eab9[_0x66b2('0x173')][_0x294d85])&&_0x294d85!=='id'&&_0x294d85!=='tags'&&_0x294d85!==_0x66b2('0x174')&&_0x294d85!==_0x66b2('0x175')){_0x369f9c[util[_0x66b2('0x3f')](_0x66b2('0x176'),'XMD-',_[_0x66b2('0x177')](_0x294d85))]=_0x18eab9[_0x66b2('0x173')][_0x294d85];}}}var _0x2f5d50=_0x2ae11c[_0x66b2('0x82')](_0x22859b[_0x66b2('0x89')])?utils[_0x66b2('0x178')](_0x22859b[_0x66b2('0x89')][_0x66b2('0x179')],_0x22859b[_0x66b2('0x17a')],_0x22859b['dialRandomLastDigitCallerIdNumber']>0x0?utils['getCallerIdRandom'](_0x22859b[_0x66b2('0x17b')],_0x22859b['dialRandomLastDigitCallerIdNumber']):_0x22859b[_0x66b2('0x17b')]):utils[_0x66b2('0x178')](_[_0x66b2('0xf4')](_0x22859b[_0x66b2('0x8a')])?_0x22859b[_0x66b2('0x89')][_0x66b2('0x179')]:_0x22859b[_0x66b2('0x8a')][_0x66b2('0x179')],_0x22859b['dialOriginateCallerIdName'],_0x22859b[_0x66b2('0x17c')]>0x0?utils[_0x66b2('0x17d')](_0x22859b[_0x66b2('0x17b')],_0x22859b[_0x66b2('0x17c')]):_0x22859b[_0x66b2('0x17b')]);if(_0x2f5d50){_0x369f9c[_0x66b2('0x17e')]=_0x2ae11c[_0x66b2('0xef')][_0x4cae6b]['originatecalleridname']=utils[_0x66b2('0x17f')](_0x2f5d50);_0x369f9c['XMD-ORIGINATECALLERIDNUM']=_0x18eab9[_0x66b2('0x15c')];}_0x22859b[_0x66b2('0x180')]=_0x369f9c;return ami['Action']({'actionid':_0x4cae6b,'action':'originate','channel':_0x2ae11c[_0x66b2('0x82')](_0x22859b[_0x66b2('0x89')])?util[_0x66b2('0x3f')](_0x66b2('0x181'),_0x22859b[_0x66b2('0x89')][_0x66b2('0x41')],isNotNull(_0x22859b[_0x66b2('0x182')])?_0x22859b[_0x66b2('0x182')]['trim']()||'':'',_0x22859b['dialCutDigit']>0x0?_0x18eab9[_0x66b2('0x15c')]['substring'](_0x22859b[_0x66b2('0x183')]):_0x18eab9[_0x66b2('0x15c')]):util['format'](_0x66b2('0x181'),_['isNil'](_0x22859b['TrunkBackup'])?_0x22859b['Trunk']['name']:_0x22859b[_0x66b2('0x8a')][_0x66b2('0x41')],isNotNull(_0x22859b[_0x66b2('0x182')])?_0x22859b[_0x66b2('0x182')][_0x66b2('0x184')]()||'':'',_0x22859b[_0x66b2('0x183')]>0x0?_0x18eab9[_0x66b2('0x15c')][_0x66b2('0x185')](_0x22859b[_0x66b2('0x183')]):_0x18eab9[_0x66b2('0x15c')]),'callerid':_0x2f5d50,'Exten':_0x66b2('0x10b'),'Context':_0x66b2('0x186'),'Priority':'1','variable':_0x369f9c,'timeout':(_0x22859b['dialOriginateTimeout']||0x1e)*0x3e8,'async':!![],'channelid':_0x4cae6b})[_0x66b2('0x38')](function(_0x29e163){return _0x50f3e5(_0x29e163);})['catch'](function(_0x263bf3){_0x22859b[_0x66b2('0x187')]+=0x1;var _0x2fbe1b=new History(_0x2ae11c['actions'][_0x4cae6b]);logger[_0x66b2('0x61')](util[_0x66b2('0x3f')](_0x66b2('0x188'),JSON['stringify'](_0x263bf3)));_0x2fbe1b[_0x66b2('0x6c')]=0xe;_0x2fbe1b[_0x66b2('0x6d')]='OriginateError';_0x2fbe1b[_0x66b2('0x6f')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x2fbe1b[_0x66b2('0x6e')]=_0x2fbe1b[_0x66b2('0x6f')];hopperUtils[_0x66b2('0xc8')](_0x2fbe1b)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x189')));_0x2ae11c['moveContactManagedDialer'](_0x2fbe1b)[_0x66b2('0x9c')](loggerCatch('[originate][error]'))[_0x66b2('0x16')](function(){delete _0x2ae11c[_0x66b2('0xef')][_0x4cae6b];return _0x751b17(msgResponse(_0x66b2('0x15d'),'Error',_0x66b2('0x18a')));});});});};Dialer[_0x66b2('0x81')]['checkRetriveMax']=function(_0x3db881,_0x434bf0,_0x5a7edb){var _0x5011f1=new History(_0x434bf0);if(_0x5011f1[_0x66b2('0x11b')]+_0x5011f1['countcongestionretry']+_0x5011f1['countnoanswerretry']+_0x5011f1[_0x66b2('0x11e')]+_0x5011f1['countdropretry']+_0x5011f1[_0x66b2('0xe6')]+_0x5011f1[_0x66b2('0x11f')]+_0x5011f1[_0x66b2('0x120')]>=_0x5a7edb['dialGlobalMaxRetry']-0x1){return!![];}switch(_0x3db881){case 0x3:if(_0x5011f1[_0x66b2('0x11d')]>=_0x5a7edb[_0x66b2('0x18b')]-0x1){return!![];}hopperUtils[_0x66b2('0xda')]({'active':![],'countnoanswerretry':_0x5011f1['countnoanswerretry']+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb['dialNoAnswerRetryFrequency'],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1['ContactId'],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1['CampaignId']||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x18c')));break;case 0x5:if(_0x5011f1['countbusyretry']>=_0x5a7edb[_0x66b2('0x18d')]-0x1){return!![];}hopperUtils['rescheduleContact']({'active':![],'countbusyretry':_0x5011f1[_0x66b2('0x11b')]+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb[_0x66b2('0x18e')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1[_0x66b2('0xdc')],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})['catch'](loggerCatch(_0x66b2('0x18f')));break;case 0x8:if(_0x5011f1[_0x66b2('0x11c')]>=_0x5a7edb[_0x66b2('0x190')]-0x1){return!![];}hopperUtils[_0x66b2('0xda')]({'active':![],'countcongestionretry':_0x5011f1['countcongestionretry']+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb[_0x66b2('0x191')],_0x66b2('0x126'))['format'](_0x66b2('0xc2')),'ContactId':_0x5011f1['ContactId'],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1['VoiceQueueId']||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})['catch'](loggerCatch(_0x66b2('0x192')));break;case 0x0:if(_0x5011f1[_0x66b2('0x11e')]>=_0x5a7edb[_0x66b2('0x193')]-0x1){return!![];}else{hopperUtils[_0x66b2('0xda')]({'active':![],'countnosuchnumberretry':_0x5011f1[_0x66b2('0x11e')]+=0x1,'scheduledat':moment()['add'](_0x5a7edb[_0x66b2('0x194')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1[_0x66b2('0xdc')],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1['CampaignId']||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x195')));}break;case 0xa:if(_0x5011f1[_0x66b2('0xd3')]>=_0x5a7edb[_0x66b2('0xd8')]-0x1){return!![];}hopperUtils[_0x66b2('0xda')]({'active':![],'countdropretry':_0x5011f1[_0x66b2('0xd3')]+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb[_0x66b2('0xd4')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1[_0x66b2('0xdc')],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xdf')));break;case 0xb:if(_0x5011f1[_0x66b2('0xe6')]>=_0x5a7edb[_0x66b2('0xea')]-0x1){return!![];}hopperUtils['rescheduleContact']({'active':![],'countabandonedretry':_0x5011f1['countabandonedretry']+=0x1,'scheduledat':moment()['add'](_0x5a7edb[_0x66b2('0xe8')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1['ContactId'],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})['catch'](loggerCatch('[rescheduleContact][Abandoned]'));break;case 0x13:if(_0x5011f1[_0x66b2('0x11f')]>=_0x5a7edb[_0x66b2('0x122')]-0x1){return!![];}hopperUtils[_0x66b2('0xda')]({'active':![],'countmachineretry':_0x5011f1[_0x66b2('0x11f')]+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb[_0x66b2('0x125')],'minutes')[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1[_0x66b2('0xdc')],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1['VoiceQueueId']||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})['catch'](loggerCatch('[rescheduleContact][Machine]'));break;case 0x14:if(_0x5011f1[_0x66b2('0x120')]>=_0x5a7edb[_0x66b2('0x196')]-0x1){return!![];}hopperUtils[_0x66b2('0xda')]({'active':![],'countagentrejectretry':_0x5011f1[_0x66b2('0x120')]+=0x1,'scheduledat':moment()[_0x66b2('0xdb')](_0x5a7edb[_0x66b2('0x197')],_0x66b2('0x126'))[_0x66b2('0x3f')](_0x66b2('0xc2')),'ContactId':_0x5011f1[_0x66b2('0xdc')],'ListId':_0x5011f1[_0x66b2('0xeb')],'VoiceQueueId':_0x5011f1[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5011f1[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x198')));break;default:return!![];}};Dialer[_0x66b2('0x81')][_0x66b2('0x107')]=function(_0x4f7ca9,_0x3179d9,_0x1b228c){var _0x551d4f=this;var _0x45f846=new History(_0x4f7ca9);var _0x422d86=![];var _0x400ef9;var _0x3a6a95;return new Promise(function(_0x386b80,_0x573a71){if(_[_0x66b2('0x3a')](_0x3179d9)&&typeof _0x3179d9!==_0x66b2('0x199')){return _0x573a71(msgResponse(_0x66b2('0x19a'),_0x66b2('0x90'),_0x66b2('0x19b')));}if(_['isUndefined'](_0x1b228c)&&typeof _0x1b228c!==_0x66b2('0x199')){return _0x573a71(msgResponse(_0x66b2('0x19a'),_0x66b2('0x90'),_0x66b2('0x19c')));}hopperUtils['verifyAdditionalPhones'](_0x45f846,_0x1b228c['reason'],_0x3179d9)[_0x66b2('0x38')](function(_0x5c3c0f){if(_0x5c3c0f[_0x66b2('0xd7')]==0x1)_0x422d86=!![];switch(_0x1b228c[_0x66b2('0x19d')]){case'0':_0x3179d9[_0x66b2('0x19e')]+=0x1;_0x45f846['state']=0x0;_0x45f846['statedesc']=_0x66b2('0x19f');_0x45f846[_0x66b2('0x11e')]+=0x1;_0x45f846['countglobal']+=0x1;ami['emit']('custom:agentnosuchnumber',ut[_0x66b2('0x115')](_0x4f7ca9,_0x66b2('0x1a0')));_0x400ef9=_0x3179d9[_0x66b2('0x194')];_0x3a6a95=_0x3179d9[_0x66b2('0xd5')];hopperUtils[_0x66b2('0xc8')](_0x45f846)['catch'](loggerCatch(_0x66b2('0x12b')));if(_0x551d4f['checkRetriveMax'](0x0,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846['countnosuchnumberretry']>=_0x3179d9[_0x66b2('0x193')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1a1'));}else{_0x551d4f[_0x66b2('0x121')](_0x45f846,_0x386b80,_0x573a71,'reason\x200\x20no\x20such\x20number....');}}break;case'3':_0x3179d9['outboundNoAnswerCallsDay']+=0x1;_0x45f846['state']=0x3;_0x45f846[_0x66b2('0x6d')]=_0x66b2('0x1a2');_0x45f846['countnoanswerretry']+=0x1;_0x45f846[_0x66b2('0xe7')]+=0x1;var _0x2ea9a=ut[_0x66b2('0x1a3')](_0x4f7ca9,_0x3179d9);ami[_0x66b2('0x113')](_0x66b2('0x1a4'),_0x2ea9a);_0x400ef9=_0x3179d9[_0x66b2('0x1a5')];_0x3a6a95=_0x3179d9[_0x66b2('0xd5')];hopperUtils[_0x66b2('0xc8')](_0x45f846)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x1a6')));if(_0x551d4f['checkRetriveMax'](0x3,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846[_0x66b2('0x11d')]>=_0x3179d9[_0x66b2('0x18b')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1a7'));}else{_0x551d4f[_0x66b2('0x121')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1a7'));}}break;case'5':_0x3179d9[_0x66b2('0x1a8')]+=0x1;_0x45f846[_0x66b2('0x6c')]=0x5;_0x45f846[_0x66b2('0x6d')]=_0x66b2('0x1a9');_0x45f846['countbusyretry']+=0x1;_0x45f846['countglobal']+=0x1;ami['emit']('custom:agentbusy',ut[_0x66b2('0x115')](_0x4f7ca9,_0x66b2('0x1aa')));_0x400ef9=_0x3179d9[_0x66b2('0x18e')];_0x3a6a95=_0x3179d9['callAdditionalPhoneAfterMin'];hopperUtils['createHistory'](_0x45f846)['catch'](loggerCatch('[syncAgentComplete][createHistory][5]'));if(_0x551d4f[_0x66b2('0x1ab')](0x5,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846[_0x66b2('0x11b')]>=_0x3179d9[_0x66b2('0x18d')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1ac'));}else{_0x551d4f[_0x66b2('0x121')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1ac'));}}break;case'8':_0x3179d9[_0x66b2('0x1ad')]+=0x1;_0x45f846[_0x66b2('0x6c')]=0x8;_0x45f846[_0x66b2('0x6d')]=_0x66b2('0x1ae');_0x45f846[_0x66b2('0x11c')]+=0x1;_0x45f846[_0x66b2('0xe7')]+=0x1;_0x400ef9=_0x3179d9[_0x66b2('0x191')];_0x3a6a95=_0x3179d9[_0x66b2('0xd5')];ami['emit'](_0x66b2('0x1af'),ut[_0x66b2('0x115')](_0x4f7ca9,'congestion'));hopperUtils[_0x66b2('0xc8')](_0x45f846)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x1b0')));if(_0x551d4f['checkRetriveMax'](0x8,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846['countcongestionretry']>=_0x3179d9[_0x66b2('0x190')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1b1'));}else{_0x551d4f['stateGlobal'](_0x45f846,_0x386b80,_0x573a71,'reason\x208\x20congestion');}}break;case'11':_0x3179d9[_0x66b2('0x1b2')]+=0x1;_0x45f846[_0x66b2('0x6c')]=0xb;_0x45f846[_0x66b2('0x6d')]='Abandoned';_0x45f846[_0x66b2('0xe6')]+=0x1;_0x45f846['countglobal']+=0x1;_0x400ef9=_0x3179d9['dialAbandonedRetryFrequency'];_0x3a6a95=_0x3179d9['callAdditionalPhoneAfterMin'];hopperUtils[_0x66b2('0xc8')](_0x45f846)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0xee')));if(_0x551d4f['checkRetriveMax'](0xb,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846[_0x66b2('0xe6')]>=_0x3179d9[_0x66b2('0xea')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1b3'));}else{_0x551d4f[_0x66b2('0x121')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1b3'));}}break;case'20':_0x3179d9[_0x66b2('0x1b4')]+=0x1;_0x45f846['state']=0x14;_0x45f846['statedesc']=_0x66b2('0x1b5');_0x45f846[_0x66b2('0x120')]+=0x1;_0x45f846[_0x66b2('0xe7')]+=0x1;_0x400ef9=_0x3179d9['dialAgentRejectRetryFrequency'];_0x3a6a95=_0x3179d9[_0x66b2('0xd5')];ami['emit'](_0x66b2('0x1b6'),ut['buildObj'](_0x4f7ca9,'agentreject'));hopperUtils[_0x66b2('0xc8')](_0x45f846)[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x1b7')));if(_0x551d4f[_0x66b2('0x1ab')](0x14,_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846[_0x66b2('0x120')]>=_0x3179d9[_0x66b2('0x196')]){_0x551d4f[_0x66b2('0x123')](_0x45f846,_0x386b80,_0x573a71,_0x66b2('0x1b8'));}else{_0x551d4f['stateGlobal'](_0x45f846,_0x386b80,_0x573a71,'reason\x2020\x20agentreject');}}break;default:_0x3179d9['outboundUnknownCallsDay']+=0x1;_0x45f846['state']=0xc;_0x45f846[_0x66b2('0x6d')]=_0x1b228c[_0x66b2('0x19d')];_0x400ef9=_0x3179d9[_0x66b2('0x197')];_0x3a6a95=_0x3179d9[_0x66b2('0xd5')];hopperUtils['createHistory'](_0x45f846)['catch'](loggerCatch(_0x66b2('0x1b9')));if(_0x551d4f[_0x66b2('0x1ab')](_0x1b228c[_0x66b2('0x19d')],_0x4f7ca9,_0x3179d9)&&!_0x422d86){if(_0x45f846[_0x66b2('0x11b')]+_0x45f846[_0x66b2('0x11c')]+_0x45f846['countnoanswerretry']+_0x45f846['countnosuchnumberretry']+_0x45f846[_0x66b2('0xd3')]+_0x45f846[_0x66b2('0xe6')]+_0x45f846[_0x66b2('0x11f')]+_0x45f846[_0x66b2('0x120')]>=_0x3179d9[_0x66b2('0x1ba')]){_0x551d4f[_0x66b2('0x121')](_0x45f846,_0x386b80,_0x573a71,_0x1b228c[_0x66b2('0x19d')]);}else{_0x551d4f['createStateFinal'](_0x45f846,_0x386b80,_0x573a71,_0x1b228c['reason']);}}}})[_0x66b2('0x38')](function(){if(_0x422d86){hopperUtils[_0x66b2('0xe3')](_0x45f846,_0x400ef9,_0x3a6a95)[_0x66b2('0x38')](function(){return _0x386b80(0x1);});}});});};Dialer[_0x66b2('0x81')][_0x66b2('0x121')]=function(_0x2237c9,_0x30886d,_0x557d2e,_0x11180a){var _0x433b04=new Final(_0x2237c9);_0x433b04[_0x66b2('0x6c')]=0xf;_0x433b04[_0x66b2('0x6d')]=_0x66b2('0x1bb');this[_0x66b2('0x123')](_0x433b04,_0x30886d,_0x557d2e,_0x11180a);};Dialer[_0x66b2('0x81')]['createStateFinal']=function(_0x1b66c0,_0x251779,_0xa10206,_0x4ba9b7){hopperUtils['moveContactManagedDialer'](_0x1b66c0)[_0x66b2('0x38')](function(){return _0x251779(msgResponse(_0x66b2('0x19a'),'Success',_0x4ba9b7));})[_0x66b2('0x9c')](function(){return _0xa10206(msgResponse(_0x66b2('0x1bc'),'Failure',_0x66b2('0x1bd')));});};Dialer[_0x66b2('0x81')][_0x66b2('0x9')]=function(_0x486ed7){var _0x3d2cc1=_0x486ed7[_0x66b2('0x1be')]/0x64;var _0x46207e=_0x486ed7['outboundDropCallsDayTimeout']/(_0x486ed7[_0x66b2('0xd1')]+_0x486ed7[_0x66b2('0x11a')]);var _0x2151b8=Math[_0x66b2('0x1bf')](_0x486ed7[_0x66b2('0x1c0')]*(_0x486ed7[_0x66b2('0x1c1')]/0x64));var _0x101e04=Math['round'](_0x486ed7[_0x66b2('0x1c0')]*(_0x486ed7[_0x66b2('0x1c2')]/0x64));var _0x4a3738=_0x486ed7[_0x66b2('0x139')]+_0x486ed7[_0x66b2('0x13b')];var _0x1305f7=Math['floor'](_0x486ed7[_0x66b2('0x55')]*_0x486ed7[_0x66b2('0x58')]*_0x486ed7['predictiveIntervalHitRate']*_0x486ed7[_0x66b2('0x1c3')]);if(_[_0x66b2('0x3a')](_0x486ed7['startProgressive'])){if(!_[_0x66b2('0x3a')](_0x486ed7['startPredictive'])){_0x486ed7[_0x66b2('0x5e')]=undefined;loggerPredictive['error'](_0x66b2('0x1c4'),_0x66b2('0x1c5'));}if(!_['isUndefined'](_0x486ed7['handlePredictive'])){loggerPredictive[_0x66b2('0x61')](_0x66b2('0x1c4'),_0x66b2('0x1c6'));clearInterval(_0x486ed7['handlePredictive']);_0x486ed7[_0x66b2('0x60')]=undefined;}_0x486ed7[_0x66b2('0x21')]=moment()[_0x66b2('0x3f')](_0x66b2('0xc2'));loggerPredictive[_0x66b2('0x43')](_0x486ed7['name'],'collection\x20data\x20in\x20progressive\x20at',_0x486ed7[_0x66b2('0x21')]);this[_0x66b2('0xb3')](_0x486ed7,0x1);}else if(ifInterval(_0x486ed7[_0x66b2('0x1c7')],_0x486ed7['startProgressive'])){this[_0x66b2('0xb3')](_0x486ed7,0x1);loggerPredictiveCalls[_0x66b2('0x43')](_0x66b2('0x1c8'),_0x486ed7['startProgressive'],_0x486ed7['name']);_0x486ed7[_0x66b2('0x55')]=0x0;_0x486ed7[_0x66b2('0x1c9')]=0x0;}else if(_0x3d2cc1<_0x46207e&&_0x486ed7[_0x66b2('0x1ca')]==='dropRate'){clearPredictiveAttributes(_0x486ed7);loggerPredictive['info'](_0x66b2('0x1cb'),'Dropped\x20calls\x20day',_0x46207e,_0x66b2('0x21'),_0x486ed7['name']);}else if(_0x1305f7<_0x486ed7[_0x66b2('0x1c9')]&&_0x486ed7['dialPredictiveOptimization']==='dropRate'){clearPredictiveAttributes(_0x486ed7);loggerPredictive['info'](_0x66b2('0x1cc'),_0x66b2('0x1cd'),_0x1305f7,'Drop\x20in\x20this\x20interval',_0x486ed7[_0x66b2('0x1c9')],_0x66b2('0x21'),_0x486ed7[_0x66b2('0x41')]);}else if(!ifInterval(_0x486ed7[_0x66b2('0x1c7')],_0x486ed7[_0x66b2('0x21')])&&_[_0x66b2('0x3a')](_0x486ed7[_0x66b2('0x5e')])&&!_[_0x66b2('0x3a')](_0x486ed7[_0x66b2('0x21')])){_0x486ed7[_0x66b2('0x5e')]=moment()[_0x66b2('0x3f')](_0x66b2('0xc2'));loggerPredictive[_0x66b2('0x43')](_0x486ed7[_0x66b2('0x41')],_0x66b2('0x1ce'),_0x486ed7['startPredictive']);hopperUtils['avgHandleTime'](_0x486ed7[_0x66b2('0x1c7')])[_0x66b2('0x38')](this[_0x66b2('0x1cf')](_0x486ed7))[_0x66b2('0x38')](mergeDataErlangB(_0x486ed7))[_0x66b2('0x38')](this[_0x66b2('0x1d0')](_0x486ed7))[_0x66b2('0x9c')](loggerCatchPredictive(_0x66b2('0x1d1'),_0x486ed7));}else if(!ifInterval(_0x486ed7[_0x66b2('0x1c7')],_0x486ed7['startPredictive'])){_0x486ed7['predictiveIntervalErlangCallsDroppedCalls']=0x0;_0x486ed7[_0x66b2('0x5e')]=moment()[_0x66b2('0x3f')](_0x66b2('0xc2'));loggerPredictive[_0x66b2('0x43')](_0x486ed7[_0x66b2('0x41')],_0x66b2('0x1d2'),_0x486ed7[_0x66b2('0x5e')]);clearInterval(_0x486ed7[_0x66b2('0x60')]);_0x486ed7[_0x66b2('0x60')]=undefined;hopperUtils[_0x66b2('0x1d3')](_0x486ed7[_0x66b2('0x1c7')])[_0x66b2('0x38')](this[_0x66b2('0x1cf')](_0x486ed7))[_0x66b2('0x38')](mergeDataErlangB(_0x486ed7))[_0x66b2('0x38')](this[_0x66b2('0x1d0')](_0x486ed7))[_0x66b2('0x9c')](loggerCatchPredictive(_0x66b2('0x1d4'),_0x486ed7));}else if(_0x486ed7['predictiveIntervalAvailable']&&_0x4a3738<_0x486ed7['predictiveIntervalAvailable']-_0x101e04){clearPredictiveAttributes(_0x486ed7);loggerPredictive['info'](_0x486ed7[_0x66b2('0x41')],_0x66b2('0x1d5'),_0x4a3738,_0x66b2('0x1d6'),_0x486ed7[_0x66b2('0x1c0')],'-',_0x101e04,'=',_0x486ed7['predictiveIntervalAvailable']-_0x101e04,')');}else if(_0x486ed7[_0x66b2('0x1c0')]&&_0x4a3738>_0x486ed7[_0x66b2('0x1c0')]+_0x2151b8){clearPredictiveAttributes(_0x486ed7);loggerPredictive[_0x66b2('0x43')](_0x486ed7[_0x66b2('0x41')],_0x66b2('0x1d5'),_0x4a3738,')\x20are\x20more\x20than\x20threshold\x20(',_0x486ed7[_0x66b2('0x1c0')],'+',_0x2151b8,'=',_0x486ed7['predictiveIntervalAvailable']+_0x2151b8,')');}};Dialer[_0x66b2('0x81')]['getDataPredictive']=function(_0x2dbc07){var _0x1c6edf=this;return function(_0x355451){return new Promise(function(_0x1d5f48,_0x427814){_[_0x66b2('0x5c')](_0x2dbc07,_0x355451[0x0]);if(checkGetDataPredictive(_0x355451[0x0])){var _0x408d4d=_0x2dbc07[_0x66b2('0x1c0')]=_0x2dbc07['talking']+_0x2dbc07['available'];var _0x2bfb69=_0x2dbc07[_0x66b2('0x1c7')]*0x3c;var _0x3e133a=_0x355451[0x0][_0x66b2('0x4e')]+_0x355451[0x0][_0x66b2('0x50')];var _0x849869=(_0x355451[0x0][_0x66b2('0x48')]+_0x355451[0x0][_0x66b2('0xd0')]+_0x355451[0x0]['predictiveIntervalDroppedCallsCallersExit'])/_0x355451[0x0][_0x66b2('0x46')];_0x2dbc07[_0x66b2('0x1d7')]=_0x849869>0x0?_0x849869:0x1;switch(_0x2dbc07[_0x66b2('0x1ca')]){case _0x66b2('0x1d8'):var _0x1d53a1=_0x2dbc07[_0x66b2('0x1be')]/0x64;return _0x1c6edf[_0x66b2('0x1d9')](_0x408d4d,_0x2bfb69,_0x3e133a,_0x849869,_0x1d53a1)[_0x66b2('0x38')](function(_0x4daad8){return _0x1d5f48(_0x4daad8);});case _0x66b2('0x1da'):var _0x393f8a=_0x2dbc07['dialPredictiveOptimizationPercentage']/0x64;return _0x1c6edf[_0x66b2('0x1db')](_0x408d4d,_0x2bfb69,_0x3e133a,_0x849869,_0x393f8a)['then'](function(_0x2efc30){return _0x1d5f48(_0x2efc30);});default:return _0x427814(msgResponse(_0x66b2('0x1dc'),_0x66b2('0x90'),_0x66b2('0x1dd')));}}else{return _0x427814(msgResponse(_0x66b2('0x1dc'),_0x66b2('0x90'),'check\x20failure'));}});};};Dialer[_0x66b2('0x81')][_0x66b2('0x1de')]=function(_0x222e3d){var _0xcf9e9d=this;return function(_0x39a1ff){return new Promise(function(_0x2718f7,_0x4651a6){_[_0x66b2('0x5c')](_0x222e3d,_0x39a1ff[0x0]);if(checkGetDataPredictive(_0x39a1ff[0x0])){loggerPredictive[_0x66b2('0x43')](JSON[_0x66b2('0x71')](_0x39a1ff[0x0]));if(_0x222e3d[_0x66b2('0x1ca')]===_0x66b2('0x1d8')){return _0xcf9e9d[_0x66b2('0x14e')](_0x222e3d['id'])[_0x66b2('0x38')](function(_0x2f62b5){var _0x15075f=_0x222e3d['loggedIn']-_0x2f62b5[0x0][_0x66b2('0x1df')];var _0x4bceee=_0x222e3d[_0x66b2('0x1c7')]*0x3c;var _0x2817fb=_0x39a1ff[0x0]['predictiveIntervalAvgTalktime']+_0x39a1ff[0x0][_0x66b2('0x50')];var _0x1080d6=(_0x39a1ff[0x0][_0x66b2('0x48')]+_0x39a1ff[0x0][_0x66b2('0xd0')]+_0x39a1ff[0x0][_0x66b2('0x4b')])/_0x39a1ff[0x0]['predictiveIntervalTotalCalls'];var _0x798a50=_0x222e3d[_0x66b2('0x1be')]/0x64;_0x222e3d['predictiveIntervalPauses']=_0x2f62b5[0x0]['outboundQueuePauses']||0x0;_0x222e3d[_0x66b2('0x1d7')]=_0x1080d6>0x0?_0x1080d6:0x1;return _0xcf9e9d[_0x66b2('0x1d9')](_0x15075f,_0x4bceee,_0x2817fb,_0x1080d6,_0x798a50);})['then'](function(_0x46b011){return _0x2718f7(_0x46b011);})[_0x66b2('0x9c')](function(_0x13600b){return _0x4651a6(msgResponse('[CatchErlangB]',_0x66b2('0x90'),JSON[_0x66b2('0x71')](_0x13600b)));});}if(_0x222e3d[_0x66b2('0x1ca')]===_0x66b2('0x1da')){return _0xcf9e9d[_0x66b2('0x14e')](_0x222e3d['id'])[_0x66b2('0x38')](function(_0x3cccf9){var _0x46abf0=_0x222e3d['loggedIn']-_0x3cccf9[0x0]['outboundQueuePauses'];var _0x1bcbc5=_0x222e3d[_0x66b2('0x1c7')]*0x3c;var _0x8efdd=_0x39a1ff[0x0][_0x66b2('0x4e')]+_0x39a1ff[0x0]['predictiveIntervalAvgHoldtime'];var _0x26f1ca=(_0x39a1ff[0x0][_0x66b2('0x48')]+_0x39a1ff[0x0][_0x66b2('0xd0')]+_0x39a1ff[0x0]['predictiveIntervalDroppedCallsCallersExit'])/_0x39a1ff[0x0]['predictiveIntervalTotalCalls'];var _0x173b76=_0x222e3d[_0x66b2('0x1be')]/0x64;_0x222e3d[_0x66b2('0x1e0')]=_0x3cccf9[0x0][_0x66b2('0x1df')]||0x0;_0x222e3d['predictiveIntervalHitRate']=_0x26f1ca>0x0?_0x26f1ca:0x1;return _0xcf9e9d['busyFactor'](_0x46abf0,_0x1bcbc5,_0x8efdd,_0x26f1ca,_0x173b76);})['then'](function(_0x12db48){return _0x2718f7(_0x12db48);})[_0x66b2('0x9c')](function(_0x554352){return _0x4651a6(msgResponse(_0x66b2('0x1e1'),_0x66b2('0x90'),JSON[_0x66b2('0x71')](_0x554352)));});}}else{return _0x4651a6(msgResponse(_0x66b2('0x1dc'),_0x66b2('0x90'),_0x66b2('0x1e2')));}});};};Dialer[_0x66b2('0x81')]['startMethodPredictive']=function(_0x12aa5e){var _0x38bd83=this;return function(){var _0x5adeac=0x0;var _0x37ffa6=Math[_0x66b2('0x1e3')](_0x12aa5e[_0x66b2('0x1e4')]*0x3e8);if(_0x37ffa6>0x0){_0x37ffa6=_0x37ffa6<0x64?0x64:_0x37ffa6;loggerPredictive['info'](_0x12aa5e[_0x66b2('0x41')],_0x66b2('0x1e5'),_0x37ffa6,_0x66b2('0x1e6'));_0x12aa5e[_0x66b2('0x60')]=setInterval(function(){_0x38bd83[_0x66b2('0x60')](_0x12aa5e);loggerPredictiveCalls[_0x66b2('0x43')](_0x66b2('0x1e7'),_0x5adeac+=0x1);},_0x37ffa6);}else{loggerPredictive[_0x66b2('0x43')](_0x12aa5e[_0x66b2('0x41')],_0x66b2('0x1e8'));}};};Dialer['prototype'][_0x66b2('0x1e9')]=function(_0x52cb4e,_0x5c02fd){var _0x19cd7b=this;return function(_0x547131){if(_['isEmpty'](_0x547131)){if(_[_0x66b2('0xf4')](_0x5c02fd[_0x66b2('0x154')])||!_0x5c02fd[_0x66b2('0x1ea')]){if(_0x52cb4e['dialMethod']===_0x66b2('0x1eb')){_0x52cb4e[_0x66b2('0x70')]=_[_0x66b2('0x3a')](_0x52cb4e[_0x66b2('0x70')])?!![]:_0x52cb4e[_0x66b2('0x70')];var _0x3552b9=uuid['v4']();_0x19cd7b['actions'][_0x3552b9]=new Action(_0x52cb4e,_0x5c02fd,_0x3552b9);loggerBooked[_0x66b2('0x43')](_0x66b2('0x1ec'),_0x3552b9,_0x66b2('0x1ed'),JSON['stringify'](_0x52cb4e[_0x66b2('0x70')]),_0x66b2('0x1ee'),_0x52cb4e[_0x66b2('0x41')]);if(_0x52cb4e['queueStatusComplete']){_0x52cb4e[_0x66b2('0x70')]=![];_0x19cd7b[_0x66b2('0x23')][_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xbf')]]=[];ami[_0x66b2('0x98')]({'actionid':_0x3552b9,'action':_0x66b2('0x1ef'),'queue':_0x52cb4e[_0x66b2('0x41')]})['catch'](function(){_0x19cd7b[_0x66b2('0xc1')](_0x52cb4e);hopperUtils['rescheduleContact']({'active':![],'ContactId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xdc')],'ListId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xeb')],'VoiceQueueId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9]['VoiceQueueId']||undefined,'CampaignId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch('[unlockOriginate][syncQueueStatusComplete]'));delete _0x19cd7b[_0x66b2('0xef')][_0x3552b9];});}else{loggerBooked[_0x66b2('0x43')](_0x66b2('0x1f0'),JSON['stringify'](_0x52cb4e[_0x66b2('0x70')]),_0x66b2('0x1ee'),_0x52cb4e['name']);_0x19cd7b[_0x66b2('0xc1')](_0x52cb4e);hopperUtils[_0x66b2('0xda')]({'active':![],'ContactId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xdc')],'ListId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9]['ListId'],'VoiceQueueId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9][_0x66b2('0xdd')]||undefined,'CampaignId':_0x19cd7b[_0x66b2('0xef')][_0x3552b9]['CampaignId']||undefined})['catch'](loggerCatch(_0x66b2('0x1f1')));delete _0x19cd7b[_0x66b2('0xef')][_0x3552b9];}}else{return _0x19cd7b['actionOriginate'](_0x52cb4e,_0x5c02fd);}}else{if(utils[_0x66b2('0xce')](undefined,_0x5c02fd[_0x66b2('0x1f2')])<_0x52cb4e[_0x66b2('0x1f3')]*0x3c){if(_0x5c02fd[_0x66b2('0x157')]&&!_0x5c02fd[_0x66b2('0x157')]['voicePause']){_0x19cd7b[_0x66b2('0x18')][_0x66b2('0xfa')](_0x5c02fd['id'])['finally'](function(){_0x19cd7b['updateOriginated'](_0x52cb4e);});}else{hopperUtils['unlockContact']({'active':![]},_0x5c02fd['id'],0x1)[_0x66b2('0x16')](function(){_0x19cd7b[_0x66b2('0xc1')](_0x52cb4e);});}}else{_0x52cb4e[_0x66b2('0x1f4')]+=0x1;_0x19cd7b['updateOriginated'](_0x52cb4e);if(_0x52cb4e[_0x66b2('0x1f5')]){hopperUtils[_0x66b2('0xda')]({'active':![],'recallme':![],'UserId':null,'ContactId':_0x5c02fd[_0x66b2('0xdc')],'ListId':_0x5c02fd[_0x66b2('0xeb')],'VoiceQueueId':_0x5c02fd[_0x66b2('0xdd')]||undefined,'CampaignId':_0x5c02fd[_0x66b2('0xde')]||undefined})[_0x66b2('0x9c')](loggerCatch('[rescheduleContact][dialRecallInQueue]'));hopperUtils[_0x66b2('0xc8')](createObjHistory(_0x52cb4e,_0x5c02fd,utils[_0x66b2('0x66')]['QUEUE_RECALL'],0x17,'RecallInQueue'))[_0x66b2('0x9c')](loggerCatch(_0x66b2('0x1f6')));}else{_0x19cd7b[_0x66b2('0x128')](createObjHistory(_0x52cb4e,_0x5c02fd,utils[_0x66b2('0x66')]['RECALL_TIMEOUT'],0x16,'RecallFailedTimeout'),'[Originate][HistoryRecallClose][historyCatch]','[Originate][HistoryRecallClose]');}}}}else{_0x52cb4e[_0x66b2('0x1f7')]+=0x1;_0x19cd7b[_0x66b2('0x128')](createObjHistory(_0x52cb4e,_0x5c02fd,utils['CAMPAIGN_STATUS']['BLACKLIST'],0xd,_0x66b2('0x1f8')),_0x66b2('0x1f9'),_0x66b2('0x1fa'));throw _0x66b2('0x1fb');}};};Dialer['prototype']['handleIvr']=function(_0x57d5ce){var _0x439632=this;var _0x19e26c=_0x57d5ce['limitCalls']-_0x57d5ce[_0x66b2('0x7b')]-_0x57d5ce[_0x66b2('0x1fc')];emitCampaignSummary(_0x57d5ce);if(_0x19e26c>0x0){if(_0x19e26c>this[_0x66b2('0x1d')]){_0x19e26c=this['maxNumberOriginate'];}_0x57d5ce[_0x66b2('0x1fc')]+=_0x19e26c;hopperUtils[_0x66b2('0x1fd')](_0x57d5ce['id'],_0x19e26c,_0x57d5ce[_0x66b2('0x1fe')],_0x57d5ce)[_0x66b2('0x38')](function(_0x31488c){_0x57d5ce['temp']-=_0x19e26c;_0x57d5ce['temp']=_0x57d5ce[_0x66b2('0x1fc')]>0x0?_0x57d5ce[_0x66b2('0x1fc')]:0x0;if(!utils[_0x66b2('0x1ff')](_0x31488c)){_0x57d5ce[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x6b')];logger[_0x66b2('0x43')](_0x66b2('0x200')+_0x57d5ce[_0x66b2('0x41')]);}else{_0x57d5ce[_0x66b2('0x7b')]+=_0x31488c[_0x66b2('0x97')];_0x57d5ce[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x201')];for(var _0x56c025=0x0;_0x56c025<_0x31488c['length'];_0x56c025+=0x1){_0x57d5ce[_0x66b2('0x202')]+=0x1;if(_[_0x66b2('0xf4')](_0x31488c[_0x56c025])||_[_0x66b2('0xf4')](_0x31488c[_0x56c025]['Contact'])||_['isNil'](_0x31488c[_0x56c025][_0x66b2('0x15c')])){_0x439632[_0x66b2('0x153')](_0x66b2('0x203'),_0x57d5ce,_0x31488c[_0x56c025]);}else{hopperUtils[_0x66b2('0x204')](_[_0x66b2('0x72')](_0x31488c[_0x56c025],[_0x66b2('0xde'),_0x66b2('0x15c')]))[_0x66b2('0x38')](_0x439632[_0x66b2('0x1e9')](_0x57d5ce,_0x31488c[_0x56c025]))[_0x66b2('0x9c')](_0x439632['loggerHandler'](_0x66b2('0x205'),_0x57d5ce));}}}})[_0x66b2('0x9c')](loggerGetContactDialer(_0x66b2('0x206'),_0x57d5ce,_0x19e26c));}};Dialer[_0x66b2('0x81')][_0x66b2('0xb3')]=function(_0x18ee85,_0xdd724d){var _0xa0222c=this;var _0x27f126=[];if(_0xdd724d<0x1||_0x18ee85['dialMethod']==='booked'){_0xdd724d=0x1;}var _0x85b441=Math['floor'](_0x18ee85['available']*_0xdd724d)-_0x18ee85[_0x66b2('0x7b')]-_0x18ee85[_0x66b2('0x1fc')];if(_0x18ee85[_0x66b2('0x207')]>0x0){var _0x4ffc2f=_0x18ee85['dialLimitQueue']-_0x18ee85['originated']-_0x18ee85['talking']-_0x18ee85[_0x66b2('0x1fc')]-_0x18ee85[_0x66b2('0x13c')];if(_0x85b441>_0x4ffc2f){_0x85b441=_0x4ffc2f;}}if(_0x85b441>0x0){if(_0x18ee85[_0x66b2('0xb1')]===_0x66b2('0x1eb')){_0x85b441=0x1;}if(_0x85b441>this[_0x66b2('0x1d')]){_0x85b441=this[_0x66b2('0x1d')];}_0x18ee85[_0x66b2('0x1fc')]+=_0x85b441;for(var _0x32f2b2 in this['agents']){if(typeof this[_0x66b2('0x1b')][_0x32f2b2]!==_0x66b2('0xab')){if(this[_0x66b2('0x1b')][_0x32f2b2]['state']===_0x66b2('0x208')&&this['agents'][_0x32f2b2][_0x66b2('0x85')]==='reachable'){_0x27f126['push'](this[_0x66b2('0x1b')][_0x32f2b2]['id']);}}}hopperUtils['getContactDialer'](_0x18ee85,_0x27f126,_0x85b441)[_0x66b2('0x38')](function(_0x1ad224){_0x18ee85['temp']-=_0x85b441;_0x18ee85[_0x66b2('0x1fc')]=_0x18ee85[_0x66b2('0x1fc')]>0x0?_0x18ee85[_0x66b2('0x1fc')]:0x0;if(!utils[_0x66b2('0x1ff')](_0x1ad224)){hopperUtils['countReScheduled'](_0x18ee85)['then'](sendMessageReschedule(_0x18ee85))[_0x66b2('0x9c')](loggerCatch('[countReScheduled]\x20'));}else{_0x18ee85[_0x66b2('0x7b')]+=_0x1ad224[_0x66b2('0x97')];_0x18ee85[_0x66b2('0x6a')]=_0x18ee85[_0x66b2('0xb1')]===_0x66b2('0x1eb')?utils[_0x66b2('0x66')]['ACTIVE']:utils[_0x66b2('0x66')][_0x66b2('0x201')];for(var _0x5af4b2=0x0;_0x5af4b2<_0x1ad224[_0x66b2('0x97')];_0x5af4b2+=0x1){if(_[_0x66b2('0xf4')](_0x1ad224[_0x5af4b2])||_['isNil'](_0x1ad224[_0x5af4b2][_0x66b2('0x173')])||_[_0x66b2('0xf4')](_0x1ad224[_0x5af4b2][_0x66b2('0x15c')])){_0xa0222c['emptyContact'](_0x66b2('0x203'),_0x18ee85,_0x1ad224[_0x5af4b2]);}else{hopperUtils[_0x66b2('0x209')](_[_0x66b2('0x72')](_0x1ad224[_0x5af4b2],['VoiceQueueId','phone']))['then'](_0xa0222c[_0x66b2('0x1e9')](_0x18ee85,_0x1ad224[_0x5af4b2]))[_0x66b2('0x9c')](_0xa0222c[_0x66b2('0x152')](_0x66b2('0x203'),_0x18ee85));}}}})[_0x66b2('0x9c')](loggerGetContactDialer(_0x66b2('0x20a'),_0x18ee85,_0x85b441));}};Dialer[_0x66b2('0x81')]['handlePredictive']=function(_0x167cac){if(_0x167cac[_0x66b2('0x207')]>0x0){var _0x1f85eb=_0x167cac[_0x66b2('0x207')]-_0x167cac[_0x66b2('0x7b')]-_0x167cac[_0x66b2('0x13b')];if(_0x1f85eb>0x0){this['tryOriginatePredictive'](_0x167cac);}else{loggerPredictiveCalls['info'](_0x66b2('0x20b'));}}else{this[_0x66b2('0x20c')](_0x167cac);}};Dialer['prototype'][_0x66b2('0x20c')]=function(_0x389e27){var _0x54bd00=this;var _0x3b5bdb=[];_0x389e27[_0x66b2('0x7b')]+=0x1;for(var _0x56ab33 in this[_0x66b2('0x1b')]){if(typeof this['agents'][_0x56ab33]!==_0x66b2('0xab')){if(this[_0x66b2('0x1b')][_0x56ab33][_0x66b2('0x6c')]===_0x66b2('0x208')&&this[_0x66b2('0x1b')][_0x56ab33][_0x66b2('0x85')]===_0x66b2('0x86')){_0x3b5bdb['push'](this[_0x66b2('0x1b')][_0x56ab33]['id']);}}}return this['getContactDialer'](_0x389e27['id'],_0x3b5bdb,0x1,_0x389e27[_0x66b2('0x1fe')],_0x389e27)['then'](function(_0xb42d5f){if(!utils['checkContactEmpty'](_0xb42d5f)){utils[_0x66b2('0x64')](_0x389e27,0x1,0x0);return hopperUtils[_0x66b2('0x20d')](_0x389e27)['then'](sendMessageReschedule(_0x389e27))['catch'](loggerCatch(_0x66b2('0x20e')));}else{_0x389e27[_0x66b2('0x6a')]=utils[_0x66b2('0x66')][_0x66b2('0x201')];if(_[_0x66b2('0xf4')](_0xb42d5f[0x0])||_['isNil'](_0xb42d5f[0x0]['Contact'])||_[_0x66b2('0xf4')](_0xb42d5f[0x0][_0x66b2('0x15c')])){_0x54bd00['emptyContact'](_0x66b2('0x203'),_0x389e27,_0xb42d5f[0x0]);}else{return hopperUtils['checkIsBlackList'](_[_0x66b2('0x72')](_0xb42d5f[0x0],['VoiceQueueId',_0x66b2('0x15c')]))[_0x66b2('0x38')](_0x54bd00[_0x66b2('0x1e9')](_0x389e27,_0xb42d5f[0x0]))['catch'](_0x54bd00[_0x66b2('0x152')](_0x66b2('0x20f'),_0x389e27));}}})[_0x66b2('0x9c')](loggerGetContactDialer(_0x66b2('0x210'),_0x389e27,0x1));};Dialer[_0x66b2('0x81')]['abandonmentRate']=function(_0xebe06c,_0x22896d,_0xecab56,_0x33db9d,_0x3e8c1b,_0x3c6059){loggerPredictive[_0x66b2('0x43')](_0x66b2('0x211'));loggerPredictive[_0x66b2('0x43')](_0x66b2('0x212'),_0xebe06c);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x213'),_0x22896d);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x214'),_0xecab56);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x215'),_0x33db9d);loggerPredictive['info'](_0x66b2('0x216'),_0x3e8c1b);loggerPredictive['info'](_0x66b2('0x5b'));return new Promise(function(_0x406d70,_0x50db19){if(_0xebe06c<=0x0||isNaN(_0xebe06c)){return _0x50db19(msgResponse(_0x66b2('0x217'),_0x66b2('0xbe'),_0x66b2('0x218')+_0xebe06c));}if(_0xecab56<=0x0||isNaN(_0xecab56)){return _0x50db19(msgResponse(_0x66b2('0x217'),_0x66b2('0xbe'),_0x66b2('0x219')+_0xecab56));}if(_0x33db9d<=0x0||isNaN(_0x33db9d)){return _0x50db19(msgResponse(_0x66b2('0x217'),_0x66b2('0xbe'),_0x66b2('0x21a')+_0x33db9d));}if(_0x22896d<=0x0||isNaN(_0x22896d)){return _0x50db19(msgResponse(_0x66b2('0x217'),_0x66b2('0xbe'),_0x66b2('0x21b')+_0x22896d));}if(_0x3e8c1b<=0x0||isNaN(_0x3e8c1b)){return _0x50db19(msgResponse(_0x66b2('0x217'),_0x66b2('0xbe'),'Amax\x20=\x20'+_0x3e8c1b));}_0x3c6059=_0x3c6059||0x0;var _0x1e9144=0x1/_0xecab56;var _0x6d7242=0x0;var _0x4a59ad=0x0;var _0x291613=0x0;var _0x2b2190=0x0;for(var _0x3919d3=0x0;_0x291613<_0x3e8c1b;_0x3919d3+=0x1){_0x4a59ad=_0x3919d3/_0x22896d;_0x6d7242=(_0x33db9d*_0x4a59ad+_0x3c6059)/_0x1e9144;_0x291613=utils[_0x66b2('0x21c')](_0x6d7242,_0xebe06c);_0x2b2190=_0x6d7242/_0xebe06c*(0x1-utils[_0x66b2('0x21c')](_0x6d7242,_0xebe06c));}return _0x406d70({'erlangCalls':_0x3919d3,'erlangCallToSecond':_0x22896d/_0x3919d3,'erlangAbandonmentRate':_0x291613,'erlangBusyFactor':_0x2b2190});});};Dialer[_0x66b2('0x81')][_0x66b2('0x1db')]=function(_0x354b4a,_0x2145b8,_0x5e5ef2,_0x39a8c4,_0x449270,_0x5a6f37){loggerPredictive[_0x66b2('0x43')](_0x66b2('0x21d'));loggerPredictive['info']('M:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',_0x354b4a);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x213'),_0x2145b8);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x214'),_0x5e5ef2);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x215'),_0x39a8c4);loggerPredictive['info'](_0x66b2('0x21e'),_0x449270);loggerPredictive[_0x66b2('0x43')](_0x66b2('0x5b'));return new Promise(function(_0x11fa00,_0x20dca5){if(_0x354b4a<=0x0||isNaN(_0x354b4a)){return _0x20dca5(msgResponse(_0x66b2('0x21f'),'Error',_0x66b2('0x218')+_0x354b4a));}if(_0x5e5ef2<=0x0||isNaN(_0x5e5ef2)){return _0x20dca5(msgResponse('[busyFactor]',_0x66b2('0xbe'),'Ts\x20=\x20'+_0x5e5ef2));}if(_0x39a8c4<=0x0||isNaN(_0x39a8c4)){return _0x20dca5(msgResponse(_0x66b2('0x21f'),_0x66b2('0xbe'),'p\x20=\x20'+_0x39a8c4));}if(_0x2145b8<=0x0||isNaN(_0x2145b8)){return _0x20dca5(msgResponse(_0x66b2('0x21f'),_0x66b2('0xbe'),_0x66b2('0x21b')+_0x2145b8));}if(_0x449270<=0x0||isNaN(_0x449270)){return _0x20dca5(msgResponse(_0x66b2('0x21f'),'Error',_0x66b2('0x220')+_0x449270));}_0x5a6f37=_0x5a6f37||0x0;var _0x71bd86=0x1/_0x5e5ef2;var _0x441cc0=0x0;var _0x18b102=0x0;var _0x26cb35=0x0;var _0x43f64a=0x0;for(var _0x318fb3=0x0;_0x43f64a<_0x449270;_0x318fb3+=0x1){_0x18b102=_0x318fb3/_0x2145b8;_0x441cc0=(_0x39a8c4*_0x18b102+_0x5a6f37)/_0x71bd86;_0x26cb35=utils[_0x66b2('0x21c')](_0x441cc0,_0x354b4a);_0x43f64a=_0x441cc0/_0x354b4a*(0x1-utils['erlangb'](_0x441cc0,_0x354b4a));}return _0x11fa00({'erlangCalls':_0x318fb3,'erlangCallToSecond':_0x2145b8/_0x318fb3,'erlangAbandonmentRate':_0x26cb35,'erlangBusyFactor':_0x43f64a});});};module[_0x66b2('0x221')]=Dialer; \ No newline at end of file diff --git a/server/services/ami/dialer/models/action.js b/server/services/ami/dialer/models/action.js new file mode 100644 index 0000000..a4d12b4 --- /dev/null +++ b/server/services/ami/dialer/models/action.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5321=['countbusyretry','countcongestionretry','countnoanswerretry','countnosuchnumberretry','countabandonedretry','countmachineretry','countagentrejectretry','ContactId','ListId','UserId','VoiceQueueId','CampaignId','idHopper','ContactFirstName','starttime','format','YYYY-MM-DD\x20HH:mm:ss','callback','callbackuniqueid','callbackat','recallme','prototype','getCaller','\x22%s\x22\x20<%s>','voiceQueue','substring','getQueue','exports','util','lodash','moment','isNil','string','name','Contact','firstName','lastName','number','phone','queue','active','type','dialQueueTimeout','scheduledat'];(function(_0x21383b,_0x5158af){var _0x1e55ed=function(_0x3bbc5d){while(--_0x3bbc5d){_0x21383b['push'](_0x21383b['shift']());}};_0x1e55ed(++_0x5158af);}(_0x5321,0x1d4));var _0x1532=function(_0x1cce4d,_0x5bc2cc){_0x1cce4d=_0x1cce4d-0x0;var _0x5aa577=_0x5321[_0x1cce4d];return _0x5aa577;};'use strict';var util=require(_0x1532('0x0'));var _=require(_0x1532('0x1'));var moment=require(_0x1532('0x2'));function checkNameSurname(_0x3ceee8,_0x77ea13,_0x190a3c){var _0x29c7d6='';if(!_[_0x1532('0x3')](_0x77ea13)&&_0x1532('0x4')===typeof _0x77ea13){_0x29c7d6+=_0x77ea13;}if(!_[_0x1532('0x3')](_0x190a3c)&&'string'===typeof _0x190a3c){_0x29c7d6+='\x20'+_0x190a3c;}if(_0x29c7d6!==''){return _0x29c7d6;}return _0x3ceee8;}function Action(_0x8d8e24,_0xc976a8,_0x589db8){this['voiceQueue']=_0x8d8e24;this['uniqueid']=_0x589db8||undefined;this[_0x1532('0x5')]=checkNameSurname(_0xc976a8[_0x1532('0x6')]['phone'],_0xc976a8[_0x1532('0x6')][_0x1532('0x7')],_0xc976a8[_0x1532('0x6')][_0x1532('0x8')]);this[_0x1532('0x9')]=_0xc976a8[_0x1532('0xa')];this[_0x1532('0xb')]=_0x8d8e24[_0x1532('0x5')];this['active']=_0xc976a8[_0x1532('0xc')]||![];this[_0x1532('0xd')]=_0x8d8e24['type'];this[_0x1532('0xe')]=_0x8d8e24[_0x1532('0xe')]||0x3;this[_0x1532('0xf')]=_0xc976a8[_0x1532('0xf')];this[_0x1532('0x10')]=_0xc976a8[_0x1532('0x10')];this[_0x1532('0x11')]=_0xc976a8['countcongestionretry'];this[_0x1532('0x12')]=_0xc976a8[_0x1532('0x12')];this[_0x1532('0x13')]=_0xc976a8[_0x1532('0x13')];this['countdropretry']=_0xc976a8['countdropretry'];this[_0x1532('0x14')]=_0xc976a8[_0x1532('0x14')];this[_0x1532('0x15')]=_0xc976a8['countmachineretry'];this[_0x1532('0x16')]=_0xc976a8[_0x1532('0x16')];this[_0x1532('0x17')]=_0xc976a8[_0x1532('0x17')];this[_0x1532('0x18')]=_0xc976a8['ListId'];this['UserId']=_0xc976a8[_0x1532('0x19')];this[_0x1532('0x1a')]=_0xc976a8['VoiceQueueId'];this[_0x1532('0x1b')]=_0xc976a8[_0x1532('0x1b')];this[_0x1532('0x1c')]=_0xc976a8['id'];this[_0x1532('0x1d')]=_0xc976a8[_0x1532('0x6')][_0x1532('0x7')]||'';this[_0x1532('0x1e')]=moment()[_0x1532('0x1f')](_0x1532('0x20'));this[_0x1532('0x21')]=_0xc976a8[_0x1532('0x21')];this[_0x1532('0x22')]=_0xc976a8[_0x1532('0x22')];this[_0x1532('0x23')]=_0xc976a8[_0x1532('0x23')];this[_0x1532('0x24')]=_0xc976a8[_0x1532('0x24')];this['originatecalleridnum']='';this['originatecalleridname']='';}Action[_0x1532('0x25')][_0x1532('0x26')]=function(){return util['format'](_0x1532('0x27'),this[_0x1532('0x5')],this[_0x1532('0x28')]['dialCutDigit']>0x0?this[_0x1532('0x9')][_0x1532('0x29')](this[_0x1532('0x28')]['dialCutDigit']):this[_0x1532('0x9')]);};Action[_0x1532('0x25')][_0x1532('0x2a')]=function(){return this[_0x1532('0xb')];};module[_0x1532('0x2b')]=Action; \ No newline at end of file diff --git a/server/services/ami/dialer/models/agentComplete.js b/server/services/ami/dialer/models/agentComplete.js new file mode 100644 index 0000000..9960451 --- /dev/null +++ b/server/services/ami/dialer/models/agentComplete.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2187=['statedesc','Answer','scheduledat','campaigntype','outbound','queue','type','countbusyretry','countcongestionretry','countnoanswerretry','countglobal','countdropretry','countabandonedretry','countmachineretry','countagentrejectretry','countnosuchnumberretry','uniqueid','calleridname','name','calleridnum','number','starttime','responsetime','answertime','YYYY-MM-DD\x20HH:mm:ss','ringtime','getSeconds','talktime','membername','reason','callback','callbackuniqueid','callbackat','recallme','ContactId','UserId','VoiceQueueId','CampaignId','originatecalleridnum','originatecalleridname','agiafterat','exports','../utils','state'];(function(_0x140ca1,_0x37dbca){var _0x12d530=function(_0x5f3aaa){while(--_0x5f3aaa){_0x140ca1['push'](_0x140ca1['shift']());}};_0x12d530(++_0x37dbca);}(_0x2187,0x1e2));var _0x7218=function(_0x2e6c75,_0x1bdbb7){_0x2e6c75=_0x2e6c75-0x0;var _0x13a9ea=_0x2187[_0x2e6c75];return _0x13a9ea;};'use strict';var moment=require('moment');var utils=require(_0x7218('0x0'));function AgentComplete(_0x373dd3,_0x1058ab){this[_0x7218('0x1')]=0x4;this[_0x7218('0x2')]=_0x7218('0x3');this[_0x7218('0x4')]=_0x373dd3[_0x7218('0x4')];this['type']=_0x373dd3['type'];this[_0x7218('0x5')]=_0x373dd3['type']===_0x7218('0x6')?_0x7218('0x7'):_0x373dd3[_0x7218('0x8')];this[_0x7218('0x9')]=_0x373dd3[_0x7218('0x9')];this[_0x7218('0xa')]=_0x373dd3[_0x7218('0xa')];this[_0x7218('0xb')]=_0x373dd3[_0x7218('0xb')];this[_0x7218('0xc')]=_0x373dd3[_0x7218('0x9')]+_0x373dd3[_0x7218('0xa')]+_0x373dd3['countnoanswerretry']+_0x373dd3['countnosuchnumberretry']+_0x373dd3[_0x7218('0xd')]+_0x373dd3[_0x7218('0xe')]+_0x373dd3[_0x7218('0xf')]+_0x373dd3[_0x7218('0x10')];this[_0x7218('0x11')]=_0x373dd3[_0x7218('0x11')];this['countdropretry']=_0x373dd3[_0x7218('0xd')];this[_0x7218('0xe')]=_0x373dd3[_0x7218('0xe')];this['countmachineretry']=_0x373dd3[_0x7218('0xf')];this[_0x7218('0x10')]=_0x373dd3['countagentrejectretry'];this[_0x7218('0x12')]=_0x1058ab[_0x7218('0x12')];this[_0x7218('0x13')]=_0x373dd3[_0x7218('0x14')];this[_0x7218('0x15')]=_0x373dd3[_0x7218('0x16')];this[_0x7218('0x17')]=_0x373dd3[_0x7218('0x17')];this[_0x7218('0x18')]=_0x373dd3[_0x7218('0x18')];this['answertime']=_0x373dd3[_0x7218('0x19')];this['endtime']=moment()['format'](_0x7218('0x1a'));this[_0x7218('0x1b')]=utils[_0x7218('0x1c')](_0x373dd3['responsetime'],_0x373dd3[_0x7218('0x17')]);this['holdtime']=utils[_0x7218('0x1c')](_0x373dd3['answertime'],_0x373dd3[_0x7218('0x18')]);this[_0x7218('0x1d')]=utils[_0x7218('0x1c')](this['endtime'],_0x373dd3[_0x7218('0x19')]);this['queue']=_0x1058ab[_0x7218('0x7')];this[_0x7218('0x1e')]=_0x1058ab['membername'];this[_0x7218('0x1f')]=_0x1058ab[_0x7218('0x1f')];this[_0x7218('0x20')]=_0x373dd3['callback'];this[_0x7218('0x21')]=_0x373dd3[_0x7218('0x21')];this[_0x7218('0x22')]=_0x373dd3[_0x7218('0x22')];this['recallme']=_0x373dd3[_0x7218('0x23')];this[_0x7218('0x24')]=_0x373dd3['ContactId'];this['ListId']=_0x373dd3['ListId'];this[_0x7218('0x25')]=_0x373dd3[_0x7218('0x25')];this[_0x7218('0x26')]=_0x373dd3[_0x7218('0x26')];this[_0x7218('0x27')]=_0x373dd3[_0x7218('0x27')];this[_0x7218('0x28')]=_0x373dd3[_0x7218('0x28')]||'';this[_0x7218('0x29')]=_0x373dd3[_0x7218('0x29')]||'';this[_0x7218('0x2a')]=_0x373dd3['agiafterat'];}module[_0x7218('0x2b')]=AgentComplete; \ No newline at end of file diff --git a/server/services/ami/dialer/models/final.js b/server/services/ami/dialer/models/final.js new file mode 100644 index 0000000..a64735c --- /dev/null +++ b/server/services/ami/dialer/models/final.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x975d=['ContactId','ListId','UserId','VoiceQueueId','CampaignId','originatecalleridnum','originatecalleridname','state','statedesc','exports','uniqueid','scheduledat','campaigntype','type','outbound','queue','countbusyretry','countcongestionretry','countnoanswerretry','countglobal','countnosuchnumberretry','countdropretry','countabandonedretry','countmachineretry','calleridname','calleridnum','starttime','endtime','responsetime','ringtime','holdtime','talktime','callback','callbackat','recallme'];(function(_0x4ab286,_0x15f6bd){var _0x102661=function(_0x2dff3b){while(--_0x2dff3b){_0x4ab286['push'](_0x4ab286['shift']());}};_0x102661(++_0x15f6bd);}(_0x975d,0xb9));var _0xd975=function(_0x53693a,_0x2a7209){_0x53693a=_0x53693a-0x0;var _0x70b250=_0x975d[_0x53693a];return _0x70b250;};'use strict';function Final(_0x3e0ac7){this['uniqueid']=_0x3e0ac7[_0xd975('0x0')];this[_0xd975('0x1')]=_0x3e0ac7[_0xd975('0x1')];this['type']=_0x3e0ac7['type'];this[_0xd975('0x2')]=_0x3e0ac7[_0xd975('0x3')]===_0xd975('0x4')?_0xd975('0x5'):_0x3e0ac7[_0xd975('0x3')];this[_0xd975('0x6')]=_0x3e0ac7['countbusyretry'];this[_0xd975('0x7')]=_0x3e0ac7['countcongestionretry'];this[_0xd975('0x8')]=_0x3e0ac7['countnoanswerretry'];this[_0xd975('0x9')]=_0x3e0ac7['countbusyretry']+_0x3e0ac7['countcongestionretry']+_0x3e0ac7['countnoanswerretry']+_0x3e0ac7[_0xd975('0xa')]+_0x3e0ac7[_0xd975('0xb')]+_0x3e0ac7[_0xd975('0xc')]+_0x3e0ac7['countmachineretry']+_0x3e0ac7['countagentrejectretry'];this[_0xd975('0xa')]=_0x3e0ac7[_0xd975('0xa')];this[_0xd975('0xb')]=_0x3e0ac7[_0xd975('0xb')];this[_0xd975('0xc')]=_0x3e0ac7[_0xd975('0xc')];this[_0xd975('0xd')]=_0x3e0ac7[_0xd975('0xd')];this['countagentrejectretry']=_0x3e0ac7['countagentrejectretry'];this[_0xd975('0x5')]=_0x3e0ac7[_0xd975('0x5')];this[_0xd975('0xe')]=_0x3e0ac7[_0xd975('0xe')];this[_0xd975('0xf')]=_0x3e0ac7[_0xd975('0xf')];this[_0xd975('0x10')]=_0x3e0ac7[_0xd975('0x10')];this['responsetime']=_0x3e0ac7['responsetime'];this[_0xd975('0x11')]=_0x3e0ac7[_0xd975('0x12')];this[_0xd975('0x13')]=_0x3e0ac7[_0xd975('0x13')]||0x0;this[_0xd975('0x14')]=_0x3e0ac7[_0xd975('0x14')]||0x0;this[_0xd975('0x15')]=_0x3e0ac7[_0xd975('0x15')]||0x0;this[_0xd975('0x16')]=_0x3e0ac7[_0xd975('0x16')];this['callbackuniqueid']=_0x3e0ac7['callbackuniqueid'];this[_0xd975('0x17')]=_0x3e0ac7[_0xd975('0x17')];this[_0xd975('0x18')]=_0x3e0ac7['recallme'];this[_0xd975('0x19')]=_0x3e0ac7[_0xd975('0x19')];this[_0xd975('0x1a')]=_0x3e0ac7[_0xd975('0x1a')];this[_0xd975('0x1b')]=_0x3e0ac7[_0xd975('0x1b')];this[_0xd975('0x1c')]=_0x3e0ac7[_0xd975('0x1c')];this[_0xd975('0x1d')]=_0x3e0ac7[_0xd975('0x1d')];this[_0xd975('0x1e')]=_0x3e0ac7['originatecalleridnum']||'';this[_0xd975('0x1f')]=_0x3e0ac7[_0xd975('0x1f')]||'';this[_0xd975('0x20')]=_0x3e0ac7[_0xd975('0x20')];this[_0xd975('0x21')]=_0x3e0ac7['statedesc'];}module[_0xd975('0x22')]=Final; \ No newline at end of file diff --git a/server/services/ami/dialer/models/hangup.js b/server/services/ami/dialer/models/hangup.js new file mode 100644 index 0000000..5012e1e --- /dev/null +++ b/server/services/ami/dialer/models/hangup.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x688e=['countbusyretry','countnoanswerretry','countglobal','countcongestionretry','countnosuchnumberretry','countdropretry','countabandonedretry','countmachineretry','countagentrejectretry','uniqueid','calleridnum','number','starttime','responsetime','endtime','YYYY-MM-DD\x20HH:mm:ss','ringtime','talktime','queue','membername','IVR','reason','cause-txt','callback','callbackuniqueid','callbackat','recallme','ContactId','ListId','UserId','VoiceQueueId','CampaignId','moment','state','statedesc','Answer','scheduledat','type','campaigntype','outbound','amd'];(function(_0x3bd6c0,_0x6c45b9){var _0xdbf20c=function(_0x59817a){while(--_0x59817a){_0x3bd6c0['push'](_0x3bd6c0['shift']());}};_0xdbf20c(++_0x6c45b9);}(_0x688e,0x72));var _0xe688=function(_0x25e632,_0x18f3f1){_0x25e632=_0x25e632-0x0;var _0x387e4d=_0x688e[_0x25e632];return _0x387e4d;};'use strict';var moment=require(_0xe688('0x0'));var utils=require('../utils');function Hangup(_0x3842b1,_0x1f2cf4){this[_0xe688('0x1')]=0x4;this[_0xe688('0x2')]=_0xe688('0x3');this[_0xe688('0x4')]=_0x3842b1['scheduledat'];this['type']=_0x3842b1[_0xe688('0x5')];this[_0xe688('0x6')]=_0x3842b1[_0xe688('0x5')]===_0xe688('0x7')?'queue':_0x3842b1[_0xe688('0x5')];this[_0xe688('0x8')]=_0x3842b1['amd']||![];this[_0xe688('0x9')]=_0x3842b1[_0xe688('0x9')];this['countcongestionretry']=_0x3842b1['countcongestionretry'];this['countnoanswerretry']=_0x3842b1[_0xe688('0xa')];this[_0xe688('0xb')]=_0x3842b1[_0xe688('0x9')]+_0x3842b1[_0xe688('0xc')]+_0x3842b1[_0xe688('0xa')]+_0x3842b1[_0xe688('0xd')]+_0x3842b1[_0xe688('0xe')]+_0x3842b1[_0xe688('0xf')]+_0x3842b1[_0xe688('0x10')]+_0x3842b1['countagentrejectretry'];this[_0xe688('0xd')]=_0x3842b1[_0xe688('0xd')];this[_0xe688('0xe')]=_0x3842b1['countdropretry'];this[_0xe688('0xf')]=_0x3842b1[_0xe688('0xf')];this[_0xe688('0x10')]=_0x3842b1[_0xe688('0x10')];this[_0xe688('0x11')]=_0x3842b1[_0xe688('0x11')];this[_0xe688('0x12')]=_0x1f2cf4[_0xe688('0x12')];this['calleridname']=_0x3842b1['name'];this[_0xe688('0x13')]=_0x3842b1[_0xe688('0x14')];this[_0xe688('0x15')]=_0x3842b1[_0xe688('0x15')];this[_0xe688('0x16')]=_0x3842b1[_0xe688('0x16')];this[_0xe688('0x17')]=moment()['format'](_0xe688('0x18'));this[_0xe688('0x19')]=utils['getSeconds'](_0x3842b1['responsetime'],_0x3842b1[_0xe688('0x15')]);this['holdtime']=0x0;this[_0xe688('0x1a')]=utils['getSeconds'](this[_0xe688('0x17')],_0x3842b1['responsetime']);this[_0xe688('0x1b')]=_0x3842b1['queue'];this[_0xe688('0x1c')]=_0xe688('0x1d');this[_0xe688('0x1e')]=_0x1f2cf4[_0xe688('0x1f')];this[_0xe688('0x20')]=_0x3842b1['callback'];this[_0xe688('0x21')]=_0x3842b1[_0xe688('0x21')];this[_0xe688('0x22')]=_0x3842b1[_0xe688('0x22')];this[_0xe688('0x23')]=_0x3842b1[_0xe688('0x23')];this[_0xe688('0x24')]=_0x3842b1[_0xe688('0x24')];this[_0xe688('0x25')]=_0x3842b1[_0xe688('0x25')];this[_0xe688('0x26')]=_0x3842b1['UserId'];this[_0xe688('0x27')]=_0x3842b1['VoiceQueueId'];this[_0xe688('0x28')]=_0x3842b1[_0xe688('0x28')];}module['exports']=Hangup; \ No newline at end of file diff --git a/server/services/ami/dialer/models/history.js b/server/services/ami/dialer/models/history.js new file mode 100644 index 0000000..e39642a --- /dev/null +++ b/server/services/ami/dialer/models/history.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe907=['calleridname','name','number','starttime','responsetime','endtime','ringtime','getSeconds','talktime','callback','callbackuniqueid','callbackat','recallme','ContactId','ListId','UserId','VoiceQueueId','originatecalleridnum','originatecalleridname','state','statedesc','../utils','uniqueid','scheduledat','type','campaigntype','queue','countbusyretry','countcongestionretry','countnosuchnumberretry','countdropretry','countabandonedretry','countmachineretry','countagentrejectretry'];(function(_0x72e04a,_0x398f0b){var _0x4e8acf=function(_0x56ea91){while(--_0x56ea91){_0x72e04a['push'](_0x72e04a['shift']());}};_0x4e8acf(++_0x398f0b);}(_0xe907,0xe1));var _0x7e90=function(_0x483c0a,_0xcc3bc1){_0x483c0a=_0x483c0a-0x0;var _0x312228=_0xe907[_0x483c0a];return _0x312228;};'use strict';var utils=require(_0x7e90('0x0'));function History(_0x539361){this[_0x7e90('0x1')]=_0x539361[_0x7e90('0x1')];this[_0x7e90('0x2')]=_0x539361[_0x7e90('0x2')]||undefined;this[_0x7e90('0x3')]=_0x539361[_0x7e90('0x3')];this[_0x7e90('0x4')]=_0x539361['type']==='outbound'?_0x7e90('0x5'):_0x539361[_0x7e90('0x3')];this[_0x7e90('0x6')]=_0x539361['countbusyretry'];this[_0x7e90('0x7')]=_0x539361[_0x7e90('0x7')];this['countnoanswerretry']=_0x539361['countnoanswerretry'];this['countglobal']=_0x539361[_0x7e90('0x6')]+_0x539361[_0x7e90('0x7')]+_0x539361['countnoanswerretry']+_0x539361[_0x7e90('0x8')]+_0x539361[_0x7e90('0x9')]+_0x539361[_0x7e90('0xa')]+_0x539361[_0x7e90('0xb')]+_0x539361[_0x7e90('0xc')];this[_0x7e90('0x8')]=_0x539361['countnosuchnumberretry'];this['countdropretry']=_0x539361[_0x7e90('0x9')];this[_0x7e90('0xa')]=_0x539361[_0x7e90('0xa')];this[_0x7e90('0xb')]=_0x539361['countmachineretry'];this['countagentrejectretry']=_0x539361[_0x7e90('0xc')];this['queue']=_0x539361[_0x7e90('0x5')];this[_0x7e90('0xd')]=_0x539361[_0x7e90('0xe')];this['calleridnum']=_0x539361[_0x7e90('0xf')];this[_0x7e90('0x10')]=_0x539361[_0x7e90('0x10')];this[_0x7e90('0x11')]=_0x539361[_0x7e90('0x11')];this[_0x7e90('0x12')]=_0x539361['responsetime'];this[_0x7e90('0x13')]=utils[_0x7e90('0x14')](_0x539361[_0x7e90('0x11')],_0x539361[_0x7e90('0x10')]);this['holdtime']=0x0;this[_0x7e90('0x15')]=0x0;this[_0x7e90('0x16')]=_0x539361['callback'];this[_0x7e90('0x17')]=_0x539361[_0x7e90('0x17')];this[_0x7e90('0x18')]=_0x539361[_0x7e90('0x18')];this[_0x7e90('0x19')]=_0x539361[_0x7e90('0x19')];this['ContactId']=_0x539361[_0x7e90('0x1a')];this[_0x7e90('0x1b')]=_0x539361['ListId'];this[_0x7e90('0x1c')]=_0x539361[_0x7e90('0x1c')];this[_0x7e90('0x1d')]=_0x539361['VoiceQueueId'];this['CampaignId']=_0x539361['CampaignId'];this[_0x7e90('0x1e')]=_0x539361[_0x7e90('0x1e')]||'';this['originatecalleridname']=_0x539361[_0x7e90('0x1f')]||'';this[_0x7e90('0x20')]=_0x539361[_0x7e90('0x20')];this['statedesc']=_0x539361[_0x7e90('0x21')];}module['exports']=History; \ No newline at end of file diff --git a/server/services/ami/dialer/models/queueCallerAbandon.js b/server/services/ami/dialer/models/queueCallerAbandon.js new file mode 100644 index 0000000..27d5ea9 --- /dev/null +++ b/server/services/ami/dialer/models/queueCallerAbandon.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8d18=['droptime','dropreason','endtime','ringtime','getSeconds','holdtime','talktime','membername','connectedlinename','reason','callbackuniqueid','callbackat','recallme','ContactId','UserId','VoiceQueueId','CampaignId','originatecalleridnum','originatecalleridname','agiafterat','state','statedesc','scheduledat','type','campaigntype','outbound','queue','countbusyretry','countcongestionretry','countnoanswerretry','countglobal','countdropretry','countmachineretry','countagentrejectretry','countnosuchnumberretry','countabandonedretry','uniqueid','calleridname','name','calleridnum','number','starttime','responsetime'];(function(_0x45fefe,_0x438dbe){var _0x4bec6b=function(_0x201b29){while(--_0x201b29){_0x45fefe['push'](_0x45fefe['shift']());}};_0x4bec6b(++_0x438dbe);}(_0x8d18,0x97));var _0x88d1=function(_0x55e08b,_0x421620){_0x55e08b=_0x55e08b-0x0;var _0xd1a7ff=_0x8d18[_0x55e08b];return _0xd1a7ff;};'use strict';var utils=require('../utils');function QueueCallerAbandon(_0x45ed4c,_0x176899){this[_0x88d1('0x0')]=_0x45ed4c['scheduledat'];this['type']=_0x45ed4c[_0x88d1('0x1')];this[_0x88d1('0x2')]=_0x45ed4c['type']===_0x88d1('0x3')?_0x88d1('0x4'):_0x45ed4c[_0x88d1('0x1')];this[_0x88d1('0x5')]=_0x45ed4c[_0x88d1('0x5')];this[_0x88d1('0x6')]=_0x45ed4c['countcongestionretry'];this[_0x88d1('0x7')]=_0x45ed4c[_0x88d1('0x7')];this[_0x88d1('0x8')]=_0x45ed4c['countbusyretry']+_0x45ed4c['countcongestionretry']+_0x45ed4c['countnoanswerretry']+_0x45ed4c['countnosuchnumberretry']+_0x45ed4c[_0x88d1('0x9')]+_0x45ed4c['countabandonedretry']+_0x45ed4c[_0x88d1('0xa')]+_0x45ed4c[_0x88d1('0xb')];this[_0x88d1('0xc')]=_0x45ed4c[_0x88d1('0xc')];this['countdropretry']=_0x45ed4c['countdropretry'];this['countabandonedretry']=_0x45ed4c[_0x88d1('0xd')];this[_0x88d1('0xa')]=_0x45ed4c[_0x88d1('0xa')];this[_0x88d1('0xb')]=_0x45ed4c[_0x88d1('0xb')];this[_0x88d1('0xe')]=_0x176899['uniqueid'];this[_0x88d1('0xf')]=_0x45ed4c[_0x88d1('0x10')];this[_0x88d1('0x11')]=_0x45ed4c[_0x88d1('0x12')];this[_0x88d1('0x13')]=_0x45ed4c[_0x88d1('0x13')];this[_0x88d1('0x14')]=_0x45ed4c[_0x88d1('0x14')];this['droptime']=_0x45ed4c[_0x88d1('0x15')];this['dropreason']=_0x45ed4c[_0x88d1('0x16')];this[_0x88d1('0x17')]=this['droptime'];this[_0x88d1('0x18')]=utils[_0x88d1('0x19')](_0x45ed4c[_0x88d1('0x14')],_0x45ed4c[_0x88d1('0x13')]);this[_0x88d1('0x1a')]=utils['getSeconds'](this['droptime'],_0x45ed4c[_0x88d1('0x14')]);this[_0x88d1('0x1b')]=0x0;this[_0x88d1('0x4')]=_0x176899[_0x88d1('0x4')];this[_0x88d1('0x1c')]=_0x176899[_0x88d1('0x1d')];this[_0x88d1('0x1e')]=_0x176899[_0x88d1('0x1e')];this['callback']=_0x45ed4c['callback'];this[_0x88d1('0x1f')]=_0x45ed4c[_0x88d1('0x1f')];this[_0x88d1('0x20')]=_0x45ed4c['callbackat'];this[_0x88d1('0x21')]=_0x45ed4c['recallme'];this['ContactId']=_0x45ed4c[_0x88d1('0x22')];this['ListId']=_0x45ed4c['ListId'];this[_0x88d1('0x23')]=_0x45ed4c['UserId'];this[_0x88d1('0x24')]=_0x45ed4c[_0x88d1('0x24')];this[_0x88d1('0x25')]=_0x45ed4c['CampaignId'];this[_0x88d1('0x26')]=_0x45ed4c[_0x88d1('0x26')]||'';this[_0x88d1('0x27')]=_0x45ed4c[_0x88d1('0x27')]||'';this[_0x88d1('0x28')]=_0x45ed4c['agiafterat'];this[_0x88d1('0x29')]=_0x45ed4c[_0x88d1('0x29')];this[_0x88d1('0x2a')]=_0x45ed4c[_0x88d1('0x2a')];}module['exports']=QueueCallerAbandon; \ No newline at end of file diff --git a/server/services/ami/dialer/utils/hopper.js b/server/services/ami/dialer/utils/hopper.js new file mode 100644 index 0000000..9d8f575 --- /dev/null +++ b/server/services/ami/dialer/utils/hopper.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8b0=['moveContactManagedDialer','[moveContactManagedDialer]','checkIsBlackList','[checkIsBlackListIvr]','checkIsBlackListIvr','verifyAdditionalPhones','[verifyAdditionalPhone]','swapAdditionalPhones','[swapAdditionalPhone]','avgHandleTime','[avgHandleTime]','[createHistory]','createHistory','util','../../../../config/logger','../../rpc/cmHopperBlack','../../rpc/cmHopperHistory','inspect','getContactDialer','dialOrderByScheduledAt','catch','temp','error','[getContactDialer]','getContactDialerIvr','[getContactDialerIvr]','countReScheduled','[countReScheduled]','rescheduleContact','[rescheduleContact]','unlockContact','[unlockContact]'];(function(_0x3cc234,_0x4e009f){var _0x48b3f4=function(_0x56a85e){while(--_0x56a85e){_0x3cc234['push'](_0x3cc234['shift']());}};_0x48b3f4(++_0x4e009f);}(_0xd8b0,0xad));var _0x0d8b=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xd8b0[_0xa464c9];return _0x3d73c4;};'use strict';var util=require(_0x0d8b('0x0'));var logger=require(_0x0d8b('0x1'))('dialer');var cmHopper=require('../../rpc/cmHopper');var cmHopperAdditionalPhone=require('../../rpc/cmHopperAdditionalPhone');var cmHopperBlack=require(_0x0d8b('0x2'));var cmHopperHistory=require(_0x0d8b('0x3'));function inspectError(_0x43bca1){return util[_0x0d8b('0x4')](_0x43bca1,{'showHidden':![],'depth':null});}function getContactDialer(_0x8196ed,_0x577834,_0x5e15e6){return cmHopper[_0x0d8b('0x5')](_0x8196ed['id'],_0x577834,_0x5e15e6,_0x8196ed[_0x0d8b('0x6')])[_0x0d8b('0x7')](function(_0x4a4470){_0x8196ed[_0x0d8b('0x8')]-=_0x5e15e6;if(_0x8196ed[_0x0d8b('0x8')]<0x0){_0x8196ed['temp']=0x0;}logger[_0x0d8b('0x9')](_0x0d8b('0xa'),inspectError(_0x4a4470));});}exports[_0x0d8b('0x5')]=getContactDialer;function getContactDialerIvr(_0x1f4800,_0x28ff7f){return cmHopper[_0x0d8b('0xb')](_0x1f4800['id'],_0x28ff7f,_0x1f4800[_0x0d8b('0x6')])[_0x0d8b('0x7')](function(_0x48fa16){_0x1f4800[_0x0d8b('0x8')]-=_0x28ff7f;if(_0x1f4800['temp']<0x0){_0x1f4800[_0x0d8b('0x8')]=0x0;}logger[_0x0d8b('0x9')](_0x0d8b('0xc'),inspectError(_0x48fa16));});}exports[_0x0d8b('0xb')]=getContactDialerIvr;function countReScheduled(_0x35a07b){return cmHopper[_0x0d8b('0xd')](_0x35a07b)[_0x0d8b('0x7')](function(_0x31a8cc){logger[_0x0d8b('0x9')](_0x0d8b('0xe'),inspectError(_0x31a8cc));});}exports[_0x0d8b('0xd')]=countReScheduled;function rescheduleContact(_0xe65334){return cmHopper[_0x0d8b('0xf')](_0xe65334)[_0x0d8b('0x7')](function(_0x4f6f21){logger[_0x0d8b('0x9')](_0x0d8b('0x10'),inspectError(_0x4f6f21));});}exports[_0x0d8b('0xf')]=rescheduleContact;function unlockContact(_0xe2e167,_0x2cb03c,_0x5cd485){return cmHopper[_0x0d8b('0x11')](_0xe2e167,_0x2cb03c,_0x5cd485)[_0x0d8b('0x7')](function(_0x2fd0fc){logger[_0x0d8b('0x9')](_0x0d8b('0x12'),inspectError(_0x2fd0fc));});}exports[_0x0d8b('0x11')]=unlockContact;function moveContactManagedDialer(_0x264b39){return cmHopper[_0x0d8b('0x13')](_0x264b39)['catch'](function(_0x27512e){logger[_0x0d8b('0x9')](_0x0d8b('0x14'),inspectError(_0x27512e));});}exports[_0x0d8b('0x13')]=moveContactManagedDialer;function checkIsBlackList(_0x24e8ed){return cmHopperBlack[_0x0d8b('0x15')](_0x24e8ed)[_0x0d8b('0x7')](function(_0x352c17){logger['error']('[checkIsBlackList]',inspectError(_0x352c17));});}exports[_0x0d8b('0x15')]=checkIsBlackList;function checkIsBlackListIvr(_0x54a9a7){return cmHopperBlack['checkIsBlackListIvr'](_0x54a9a7)['catch'](function(_0x238728){logger[_0x0d8b('0x9')](_0x0d8b('0x16'),inspectError(_0x238728));});}exports[_0x0d8b('0x17')]=checkIsBlackListIvr;function verifyAdditionalPhones(_0x221071,_0x2c64e2,_0x30980c){return cmHopperAdditionalPhone[_0x0d8b('0x18')](_0x221071,_0x2c64e2,_0x30980c)[_0x0d8b('0x7')](function(_0x5e5bc3){logger[_0x0d8b('0x9')](_0x0d8b('0x19'),inspectError(_0x5e5bc3));});}exports['verifyAdditionalPhones']=verifyAdditionalPhones;function swapAdditionalPhones(_0xe1ef20,_0x4a0ae4,_0x3dd149){return cmHopperAdditionalPhone[_0x0d8b('0x1a')](_0xe1ef20,_0x4a0ae4,_0x3dd149)[_0x0d8b('0x7')](function(_0x4fe6f9){logger['error'](_0x0d8b('0x1b'),inspectError(_0x4fe6f9));});}exports[_0x0d8b('0x1a')]=swapAdditionalPhones;function avgHandleTime(_0x4c05ee){return cmHopperHistory[_0x0d8b('0x1c')](_0x4c05ee)['catch'](function(_0x1b2b59){logger['error'](_0x0d8b('0x1d'),inspectError(_0x1b2b59));});}exports['avgHandleTime']=avgHandleTime;function createHistory(_0x2ab00d){return cmHopperHistory['createHistory'](_0x2ab00d)[_0x0d8b('0x7')](function(_0x544735){logger[_0x0d8b('0x9')](_0x0d8b('0x1e'),inspectError(_0x544735));});}exports[_0x0d8b('0x1f')]=createHistory; \ No newline at end of file diff --git a/server/services/ami/dialer/utils/index.js b/server/services/ami/dialer/utils/index.js new file mode 100644 index 0000000..7800e1c --- /dev/null +++ b/server/services/ami/dialer/utils/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeb3e=['milliseconds','seconds','getSeconds','message','loggedIn','loggedInDb','paused','talking','pTalking','waiting','inUse','originated','Trunk','name','hasQueueCampaignDataChanged','dialTimezone','isNil','Interval','Intervals','NULL_INTERVAL','isEmpty','dialGlobalInterval','EMPTY_INTERVAL','UNKNOWN_TIMEZONE','SIP/','unmonitored','includes','status','TrunkBackup','INACTIVE','NO_AGENTS_LOGGED','UNREACHABLE_TRUNK','getQueueCampaignStatusMessage','DISACTIVED','match','isUndefined','string','\x22%s\x22\x20<%s>','format','\x22\x22\x20<>','getCallerId','\x5cw{0,','pow','random','toString','getCallerIdRandom','[decrementOriginate]\x20queue\x20originate\x20value\x20is\x20negative','decrementOriginate','length','checkContactEmpty','checkContactLowerLimitOriginate','lodash','moment','../../../../config/logger','dialer','../../../../config/environment/shared','timezones','ACTIVE','IS_DISACTIVED','INTERVAL_IS_EMPTY','NOT_ACTIVE','AVAILABLE_CONTACTS_FINISHED','INTERVAL_IS_NULL','INTERVAL_IS_OVERTIME','GLOBAL_INTERVAL_IS_OVERTIME','RECALLINQUEUE','RECALLFAILEDTIMEOUT','RUNNING','TRUNK_IS_NOT_REACHABLE','CAMPAIGN_STATUS','dialMethod','isPreviewCampaign','type','ivr','isIVRCampaign','outbound','dialActive','isQueueCampaignActive','active','isIVRCampaignActive'];(function(_0x2d8cf6,_0x94997c){var _0x930c42=function(_0x3a186c){while(--_0x3a186c){_0x2d8cf6['push'](_0x2d8cf6['shift']());}};_0x930c42(++_0x94997c);}(_0xeb3e,0x1c3));var _0xeeb3=function(_0xfd58c7,_0x28c446){_0xfd58c7=_0xfd58c7-0x0;var _0x2563f6=_0xeb3e[_0xfd58c7];return _0x2563f6;};'use strict';var _=require(_0xeeb3('0x0'));var moment=require(_0xeeb3('0x1'));var util=require('util');var logger=require(_0xeeb3('0x2'))(_0xeeb3('0x3'));var timezones=require(_0xeeb3('0x4'))[_0xeeb3('0x5')];var CAMPAIGN_STATUS={'ACTIVE':_0xeeb3('0x6'),'BLACKLIST':'BLACKLIST','CONTACTS_RESCHEDULED':'RESCHEDULED_CONTACTS','DEACTIVATED':'DEACTIVATED','DISACTIVED':_0xeeb3('0x7'),'EMPTY_INTERVAL':_0xeeb3('0x8'),'INACTIVE':_0xeeb3('0x9'),'NO_AGENTS_LOGGED':'AGENTS_NOT_LOGGED','NO_AVAILABLE_CONTACTS':_0xeeb3('0xa'),'NULL_INTERVAL':_0xeeb3('0xb'),'OVERTIME_INTERVAL':_0xeeb3('0xc'),'OVERTIME_GLOBAL_INTERVAL':_0xeeb3('0xd'),'QUEUE_RECALL':_0xeeb3('0xe'),'RECALL_TIMEOUT':_0xeeb3('0xf'),'RUNNING':_0xeeb3('0x10'),'UNKNOWN_TIMEZONE':'TIMEZONE_UNKNOW','UNREACHABLE_TRUNK':_0xeeb3('0x11')};exports[_0xeeb3('0x12')]=CAMPAIGN_STATUS;function isPreviewCampaign(_0x57958f){return _0x57958f[_0xeeb3('0x13')]==='preview';}exports[_0xeeb3('0x14')]=isPreviewCampaign;function isIVRCampaign(_0xf7a96a){return _0xf7a96a[_0xeeb3('0x15')]===_0xeeb3('0x16');}exports[_0xeeb3('0x17')]=isIVRCampaign;function isOutboundQueue(_0x2876c6){return _0x2876c6[_0xeeb3('0x15')]===_0xeeb3('0x18');}exports['isOutboundQueue']=isOutboundQueue;function isQueueCampaignActive(_0x5603ee){return _0x5603ee[_0xeeb3('0x19')];}exports[_0xeeb3('0x1a')]=isQueueCampaignActive;function isIVRCampaignActive(_0x425893){return _0x425893[_0xeeb3('0x1b')];}exports[_0xeeb3('0x1c')]=isIVRCampaignActive;function getSeconds(_0x146bdb,_0x1cf8e){var _0x85b298=moment(_0x146bdb)[_0xeeb3('0x1d')](0x0);var _0x529a14=moment(_0x1cf8e)['milliseconds'](0x0);return _0x85b298['diff'](_0x529a14,_0xeeb3('0x1e'));}exports[_0xeeb3('0x1f')]=getSeconds;function hasQueueCampaignDataChanged(_0x12194a,_0x31b798){var _0x3ea494=![];var _0x27c23a=_0x12194a[_0xeeb3('0x13')]!==_0x31b798[_0xeeb3('0x13')]||_0x12194a[_0xeeb3('0x19')]!==_0x31b798[_0xeeb3('0x19')]||_0x12194a['message']!==_0x31b798[_0xeeb3('0x20')];var _0xb0dfba=_0x12194a['available']!==_0x31b798['available']||_0x12194a[_0xeeb3('0x21')]!==_0x31b798[_0xeeb3('0x21')]||_0x12194a[_0xeeb3('0x22')]!==_0x31b798['loggedInDb']||_0x12194a[_0xeeb3('0x23')]!==_0x31b798[_0xeeb3('0x23')]||_0x12194a[_0xeeb3('0x24')]!==_0x31b798['talking']||_0x12194a[_0xeeb3('0x25')]!==_0x31b798['pTalking']||_0x12194a[_0xeeb3('0x26')]!==_0x31b798[_0xeeb3('0x26')]||_0x12194a[_0xeeb3('0x27')]!==_0x31b798['inUse']||_0x12194a[_0xeeb3('0x28')]!==_0x31b798['originated'];if(_0x12194a[_0xeeb3('0x29')]&&_0x31b798[_0xeeb3('0x29')]){_0x3ea494=_0x12194a[_0xeeb3('0x29')][_0xeeb3('0x2a')]!==_0x31b798[_0xeeb3('0x29')][_0xeeb3('0x2a')]||_0x12194a[_0xeeb3('0x29')][_0xeeb3('0x1b')]!==_0x31b798[_0xeeb3('0x29')][_0xeeb3('0x1b')];}return _0x27c23a||_0xb0dfba||_0x3ea494;}exports[_0xeeb3('0x2b')]=hasQueueCampaignDataChanged;function checkAnyValidQueueCampaignInterval(_0x1268b3){var _0x4254d8=null;var _0x1816f1=_0x1268b3[_0xeeb3('0x2c')];if(_[_0xeeb3('0x2d')](_0x1268b3['dialGlobalInterval'])||_[_0xeeb3('0x2d')](_0x1268b3[_0xeeb3('0x2e')])||_[_0xeeb3('0x2d')](_0x1268b3[_0xeeb3('0x2e')][_0xeeb3('0x2f')])){_0x4254d8=CAMPAIGN_STATUS[_0xeeb3('0x30')];}else if(_[_0xeeb3('0x31')](_0x1268b3[_0xeeb3('0x32')])||_[_0xeeb3('0x31')](_0x1268b3['Interval']['Intervals'])){_0x4254d8=CAMPAIGN_STATUS[_0xeeb3('0x33')];}else if(_0x1816f1&&!timezones[_0x1816f1]){_0x4254d8=CAMPAIGN_STATUS[_0xeeb3('0x34')];}return _0x4254d8;}function checkAnyValidTrunk(_0x3859ed,_0x514974){var _0xbdf0e8=null;var _0xc9ce5f=_0xeeb3('0x35');var _0x8a881b=['reachable',_0xeeb3('0x36')];var _0x303162=!![];if(_0x3859ed[_0xeeb3('0x29')]&&_0x3859ed[_0xeeb3('0x29')][_0xeeb3('0x1b')]){_0xc9ce5f+=_0x3859ed[_0xeeb3('0x29')][_0xeeb3('0x2a')];_0xbdf0e8=_0x514974[_0xc9ce5f];_0x303162=_0x8a881b[_0xeeb3('0x37')](_0xbdf0e8[_0xeeb3('0x38')]);}else if(_0x3859ed['TrunkBackup']&&_0x3859ed[_0xeeb3('0x39')][_0xeeb3('0x1b')]){_0xc9ce5f+=_0x3859ed[_0xeeb3('0x39')]['name'];_0xbdf0e8=_0x514974[_0xc9ce5f];_0x303162=_0x8a881b[_0xeeb3('0x37')](_0xbdf0e8[_0xeeb3('0x38')]);}return _0x303162;}function getQueueCampaignStatusMessage(_0x2d1045,_0x464102){var _0x273151=CAMPAIGN_STATUS[_0xeeb3('0x6')];var _0x5a59ba=isPreviewCampaign(_0x2d1045);if(!isQueueCampaignActive(_0x2d1045)){if(_0x5a59ba){_0x273151=CAMPAIGN_STATUS[_0xeeb3('0x3a')];}else{if(_0x2d1045[_0xeeb3('0x28')]===0x0&&_0x2d1045['talking']===0x0&&_0x2d1045[_0xeeb3('0x26')]===0x0&&(_0x2d1045[_0xeeb3('0x25')]||0x0)===0x0){_0x273151=CAMPAIGN_STATUS[_0xeeb3('0x3a')];}else{_0x273151=CAMPAIGN_STATUS['DISACTIVED'];}}}else if(_0x2d1045['loggedIn']===0x0){_0x273151=CAMPAIGN_STATUS[_0xeeb3('0x3b')];}else if(!checkAnyValidTrunk(_0x2d1045,_0x464102)){_0x273151=CAMPAIGN_STATUS[_0xeeb3('0x3c')];}else if(!isPreviewCampaign(_0x2d1045)){var _0x44d669=checkAnyValidQueueCampaignInterval(_0x2d1045);if(_0x44d669){_0x273151=_0x44d669;}}return _0x273151;}exports[_0xeeb3('0x3d')]=getQueueCampaignStatusMessage;function getQueueCampaignActiveStatusMessage(_0xc328f5){var _0x3ab7ac=CAMPAIGN_STATUS[_0xeeb3('0x3e')];if(_0xc328f5['originated']===0x0&&_0xc328f5[_0xeeb3('0x24')]===0x0&&_0xc328f5[_0xeeb3('0x26')]===0x0&&(_0xc328f5[_0xeeb3('0x25')]||0x0)===0x0){_0x3ab7ac=CAMPAIGN_STATUS[_0xeeb3('0x3a')];}return _0x3ab7ac;}exports['getQueueCampaignActiveStatusMessage']=getQueueCampaignActiveStatusMessage;function extractCalleridName(_0x4d028e){var _0x33e5c3=_0x4d028e[_0xeeb3('0x3f')](/"(.*?)"/);return _0x33e5c3?_0x33e5c3[0x1]:_0x4d028e;}exports['extractCalleridName']=extractCalleridName;function getCallerId(_0x594c4b,_0x3b11f7,_0x29a989){if(!_[_0xeeb3('0x40')](_0x29a989)&&typeof _0x29a989==='string'&&!_[_0xeeb3('0x31')](_0x29a989)){if(!_[_0xeeb3('0x40')](_0x3b11f7)&&typeof _0x3b11f7===_0xeeb3('0x41')&&!_['isEmpty'](_0x3b11f7)){return util['format'](_0xeeb3('0x42'),_0x3b11f7,_0x29a989);}return util[_0xeeb3('0x43')](_0xeeb3('0x42'),_0x29a989,_0x29a989);}if(!_['isUndefined'](_0x594c4b)&&typeof _0x594c4b===_0xeeb3('0x41')&&!_[_0xeeb3('0x31')](_0x594c4b)){return _0x594c4b;}return _0xeeb3('0x44');}exports[_0xeeb3('0x45')]=getCallerId;function getCallerIdRandom(_0x5d98c4,_0x1607d4){var _0x46316e;var _0x2cba08;var _0x11903f;if(_0x1607d4<=0x0){_0x1607d4=0x1;}_0x46316e=new RegExp(_0xeeb3('0x46')+_0x1607d4+'}$');_0x2cba08=Math[_0xeeb3('0x47')](0xa,_0x1607d4-0x1);_0x11903f=Math['pow'](0xa,_0x1607d4)-0x1;return util['format']('%s',_['replace'](_0x5d98c4,_0x46316e,_[_0xeeb3('0x48')](_0x2cba08,_0x11903f)[_0xeeb3('0x49')]()));}exports[_0xeeb3('0x4a')]=getCallerIdRandom;function decrementOriginate(_0x588bf5){if(_0x588bf5['originated']&&_0x588bf5[_0xeeb3('0x28')]>0x0){_0x588bf5[_0xeeb3('0x28')]-=0x1;}else{logger['error'](_0xeeb3('0x4b'));}}exports[_0xeeb3('0x4c')]=decrementOriginate;function checkContactEmpty(_0x4ec8cb){return _0x4ec8cb&&_0x4ec8cb[_0xeeb3('0x4d')]>0x0;}exports[_0xeeb3('0x4e')]=checkContactEmpty;function erlangb(_0x435ba7,_0x495c6e){if(_0x495c6e===0x0){return 0x0;}var _0x4bdde6=0x1;for(var _0x26ebc7=0x1;_0x26ebc7<=_0x495c6e;_0x26ebc7+=0x1){_0x4bdde6=0x1+_0x4bdde6*_0x26ebc7/_0x435ba7;}return 0x1/_0x4bdde6;}exports['erlangb']=erlangb;function checkContactLowerLimitOriginate(_0x4d8bbd,_0x2792ba,_0x564415){if(_0x2792ba>_0x564415){for(var _0x554452=0x0;_0x554452<_0x2792ba-_0x564415;_0x554452+=0x1){decrementOriginate(_0x4d8bbd);}}}exports[_0xeeb3('0x4f')]=checkContactLowerLimitOriginate; \ No newline at end of file diff --git a/server/services/ami/fax/action.js b/server/services/ami/fax/action.js new file mode 100644 index 0000000..71a7db0 --- /dev/null +++ b/server/services/ami/fax/action.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['fax','localstationid','path','AttachmentId','exports','util','lodash','moment','channel','format','%s/%s/%s','tech','Trunk'];(function(_0x54f0c4,_0x5cd3cf){var _0x8b37b3=function(_0x9b6725){while(--_0x9b6725){_0x54f0c4['push'](_0x54f0c4['shift']());}};_0x8b37b3(++_0x5cd3cf);}(_0xa9e0,0x123));var _0x0a9e=function(_0x110c3d,_0x12ee06){_0x110c3d=_0x110c3d-0x0;var _0x226d67=_0xa9e0[_0x110c3d];return _0x226d67;};'use strict';var util=require(_0x0a9e('0x0'));var _=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));function Action(_0x5dd881,_0x550fbc,_0x18d5c9){this['uniqueid']=_0x5dd881||undefined;this[_0x0a9e('0x3')]=util[_0x0a9e('0x4')](_0x0a9e('0x5'),_0x550fbc[_0x0a9e('0x6')],_0x550fbc[_0x0a9e('0x7')]['name'],_0x18d5c9[_0x0a9e('0x8')]);this[_0x0a9e('0x9')]=_0x550fbc[_0x0a9e('0x9')];this['headerinfo']=_0x550fbc['headerinfo'];this[_0x0a9e('0xa')]=_0x18d5c9['path'];this['AttachmentId']=_0x18d5c9[_0x0a9e('0xb')];}module[_0x0a9e('0xc')]=Action; \ No newline at end of file diff --git a/server/services/ami/fax/channel.js b/server/services/ami/fax/channel.js new file mode 100644 index 0000000..6e23d8b --- /dev/null +++ b/server/services/ami/fax/channel.js @@ -0,0 +1,17 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* diff --git a/server/services/ami/fax/index.js b/server/services/ami/fax/index.js new file mode 100644 index 0000000..e9a1431 --- /dev/null +++ b/server/services/ami/fax/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadd7=['../rpc/faxAccount','../rpc/attachment','faxAccounts','trunks','actions','newchannel','bind','varset','syncVarSet','newstate','syncNewState','newexten','faxstatus','syncFaxStatus','receivefax','syncHangup','originateresponse','syncOriginateResponse','prototype','context','from-voip-provider','hasOwnProperty','localstationid','uniqueid','channels','channel','name','info','\x20syncNewchannel\x20','variable','value','channelstate','channelstatedesc','syncNewExten','operation','status','\x20syncFaxStatus\x20','syncReceiveFax','remotestationid','pagestransferred','resolution','transferrate','filename','calleridnum','/var/opt/motion2/server/files/attachments/','\x20result\x20conversion\x20file\x20','message','create','parse','.pdf','notify','catch','error','\x20notify\x20','stringify','\x20receiveFax\x20','response','update','AttachmentId','SENDING\x20FAILED\x20','then','logger','[Fax][Message][Error][NoUpdate1]','[Fax][Message][Updated]','[Fax][Message][NoUpdate1]','finally','\x20hangup\x20sendFile\x20','faxpages','SUCCESS','updateStatus','faxstatusstring','SENDING\x20FAILED:\x20','SENDING\x20FAILED','execOriginate','FaxAccountId','[Fax][execOriginate][success]','[Fax][execOriginate][failure]','Fax\x20failed','checkTrunk','isValid','format','execute','%s/%s.tif','XMF-PATH','Convert\x20pdf\x20to\x20tif','Action','variablesAction','ext','isTrunkReachable','isNil','SIP/%s','reachable','unmonitored','[Fax][checkTrunk][Trunk\x20not\x20working\x20correctly]','\x20Trunk\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','[Fax][checkTrunk][Empty\x20Fax]','Empty\x20Fax','[Fax][checkTrunk][Empty\x20path]','Empty\x20path','Is\x20Valid','exports','lodash','bluebird','path','tiff2pdf','./util/gs','../../../config/logger','fax','../ami','./channel','./util/util','./action'];(function(_0x17c00c,_0x20665b){var _0xedd744=function(_0x1f99b5){while(--_0x1f99b5){_0x17c00c['push'](_0x17c00c['shift']());}};_0xedd744(++_0x20665b);}(_0xadd7,0x1b9));var _0x7add=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xadd7[_0x321bb2];return _0x9c12ed;};'use strict';var util=require('util');var _=require(_0x7add('0x0'));var BPromise=require(_0x7add('0x1'));var uuid=require('uuid');var moment=require('moment');var path=require(_0x7add('0x2'));var tiff2pdf=require(_0x7add('0x3'));var gs=require(_0x7add('0x4'));var logger=require(_0x7add('0x5'))(_0x7add('0x6'));var ami=require(_0x7add('0x7'));var rpcDb=require('./rpcDb');var Channel=require(_0x7add('0x8'));var ut=require(_0x7add('0x9'));var Action=require(_0x7add('0xa'));var faxAccount=require(_0x7add('0xb'));var attachment=require(_0x7add('0xc'));var faxMessage=require('../rpc/faxMessage');function Fax(_0x28e39a){this['channels']={};this[_0x7add('0xd')]=_0x28e39a[_0x7add('0xd')];this[_0x7add('0xe')]=_0x28e39a['trunks'];this[_0x7add('0xf')]={};ami['on'](_0x7add('0x10'),this['syncNewchannel'][_0x7add('0x11')](this));ami['on'](_0x7add('0x12'),this[_0x7add('0x13')]['bind'](this));ami['on'](_0x7add('0x14'),this[_0x7add('0x15')][_0x7add('0x11')](this));ami['on'](_0x7add('0x16'),this['syncNewExten'][_0x7add('0x11')](this));ami['on'](_0x7add('0x17'),this[_0x7add('0x18')][_0x7add('0x11')](this));ami['on'](_0x7add('0x19'),this['syncReceiveFax']['bind'](this));ami['on']('hangup',this[_0x7add('0x1a')][_0x7add('0x11')](this));ami['on'](_0x7add('0x1b'),this[_0x7add('0x1c')]['bind'](this));}Fax[_0x7add('0x1d')]['syncNewchannel']=function(_0x2195d0){if(_0x2195d0[_0x7add('0x1e')]===_0x7add('0x1f')){for(var _0x559109 in this[_0x7add('0xd')]){if(this[_0x7add('0xd')][_0x7add('0x20')](_0x559109)){if(_0x2195d0['exten']===this[_0x7add('0xd')][_0x559109][_0x7add('0x21')]){this['channels'][_0x2195d0[_0x7add('0x22')]]={};this[_0x7add('0x23')][_0x2195d0[_0x7add('0x22')]][_0x7add('0x24')]=_0x2195d0[_0x7add('0x24')];this['channels'][_0x2195d0[_0x7add('0x22')]]['id']=this[_0x7add('0xd')][_0x559109]['id'];this['channels'][_0x2195d0[_0x7add('0x22')]]['name']=this[_0x7add('0xd')][_0x559109][_0x7add('0x25')];logger[_0x7add('0x26')](_0x2195d0[_0x7add('0x22')],_0x7add('0x27'));}}}}if(this[_0x7add('0xf')][_0x2195d0[_0x7add('0x22')]]){this[_0x7add('0x23')][_0x2195d0[_0x7add('0x22')]]={};this[_0x7add('0x23')][_0x2195d0[_0x7add('0x22')]][_0x7add('0x24')]=_0x2195d0['channel'];logger['info'](_0x2195d0[_0x7add('0x22')],'\x20syncNewchannel\x20');}};Fax[_0x7add('0x1d')][_0x7add('0x13')]=function(_0x1a4a51){if(this[_0x7add('0x23')][_0x1a4a51[_0x7add('0x22')]]){for(var _0x1a5fdf in _0x1a4a51['variable']){if(_0x1a4a51[_0x7add('0x28')][_0x7add('0x20')](_0x1a5fdf)){this[_0x7add('0x23')][_0x1a4a51[_0x7add('0x22')]][_0x1a5fdf]=_0x1a4a51[_0x7add('0x29')];}}}};Fax['prototype']['syncNewState']=function(_0x5d0158){if(this[_0x7add('0x23')][_0x5d0158[_0x7add('0x22')]]){this['channels'][_0x5d0158[_0x7add('0x22')]][_0x7add('0x2a')]=_0x5d0158[_0x7add('0x2a')];this[_0x7add('0x23')][_0x5d0158[_0x7add('0x22')]][_0x7add('0x2b')]=_0x5d0158[_0x7add('0x2b')];}};Fax['prototype'][_0x7add('0x2c')]=function(_0x32b0d7){if(this[_0x7add('0x23')][_0x32b0d7[_0x7add('0x22')]]){for(var _0xd937d9 in _0x32b0d7[_0x7add('0x28')]){if(_0x32b0d7[_0x7add('0x28')][_0x7add('0x20')](_0xd937d9)){this[_0x7add('0x23')][_0x32b0d7[_0x7add('0x22')]][_0xd937d9]=_0x32b0d7[_0x7add('0x29')];}}}};Fax['prototype'][_0x7add('0x18')]=function(_0x218ffb){if(this['channels'][_0x218ffb[_0x7add('0x22')]]){this['channels'][_0x218ffb['uniqueid']][_0x7add('0x2d')]=_0x218ffb[_0x7add('0x2d')];this[_0x7add('0x23')][_0x218ffb[_0x7add('0x22')]][_0x7add('0x2e')]=_0x218ffb[_0x7add('0x2e')];this['channels'][_0x218ffb['uniqueid']]['localstationid']=_0x218ffb[_0x7add('0x21')];this[_0x7add('0x23')][_0x218ffb['uniqueid']]['filename']=_0x218ffb['filename'];logger['info'](_0x218ffb[_0x7add('0x22')],_0x7add('0x2f'));}};Fax[_0x7add('0x1d')][_0x7add('0x30')]=function(_0x32ffce){var _0x3c2004=this;if(this['channels'][_0x32ffce['uniqueid']]){var _0x3585ec=this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]]['id'];this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]][_0x7add('0x31')]=_0x32ffce['remotestationid'];this['channels'][_0x32ffce['uniqueid']][_0x7add('0x32')]=_0x32ffce[_0x7add('0x32')];this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]]['localstationid']=_0x32ffce[_0x7add('0x21')];this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]][_0x7add('0x33')]=_0x32ffce[_0x7add('0x33')];this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]][_0x7add('0x34')]=_0x32ffce['transferrate'];this[_0x7add('0x23')][_0x32ffce[_0x7add('0x22')]][_0x7add('0x35')]=_0x32ffce[_0x7add('0x35')];this[_0x7add('0x23')][_0x32ffce['uniqueid']][_0x7add('0x36')]=_0x32ffce[_0x7add('0x36')];if(this[_0x7add('0x23')][_0x32ffce['uniqueid']]['pagestransferred']>0x0){tiff2pdf(_0x32ffce[_0x7add('0x35')],_0x7add('0x37'),function(_0x461f10){logger[_0x7add('0x26')](_0x32ffce['uniqueid'],_0x7add('0x38'),_0x461f10[_0x7add('0x39')]);attachment[_0x7add('0x3a')]({'name':path[_0x7add('0x3b')](_0x32ffce[_0x7add('0x35')])['name'],'basename':path[_0x7add('0x3b')](_0x32ffce['filename'])[_0x7add('0x25')]+_0x7add('0x3c'),'type':'application/pdf'})['then'](function(_0x3f7328){faxAccount[_0x7add('0x3d')](_0x3585ec,{'from':_0x32ffce[_0x7add('0x36')],'mapKey':_0x7add('0x6'),'body':path[_0x7add('0x3b')](_0x32ffce[_0x7add('0x35')])[_0x7add('0x25')]+'.pdf','AttachmentId':_0x3f7328['id']})[_0x7add('0x3e')](function(_0x41893c){logger[_0x7add('0x3f')](_0x32ffce[_0x7add('0x22')],_0x7add('0x40'),JSON[_0x7add('0x41')](_0x41893c));});})[_0x7add('0x3e')](function(_0x3d46dc){logger[_0x7add('0x3f')](_0x32ffce['uniqueid'],_0x7add('0x42'),JSON[_0x7add('0x41')](_0x3d46dc));});});}logger[_0x7add('0x26')](_0x32ffce['uniqueid'],'\x20receiveFax\x20');}};Fax[_0x7add('0x1d')]['syncOriginateResponse']=function(_0x1fc080){if(this[_0x7add('0xf')][_0x1fc080[_0x7add('0x22')]]){_['merge'](this[_0x7add('0x23')][_0x1fc080[_0x7add('0x22')]],_['pick'](_0x1fc080,[_0x7add('0x43'),'reason']));}};function updateStatus(_0x339d10){if(_0x339d10['AttachmentId']){faxMessage[_0x7add('0x44')](_0x339d10[_0x7add('0x45')],{'failMessage':_0x7add('0x46')})[_0x7add('0x47')](function(_0x523233){ut[_0x7add('0x48')]('[Fax][Message][Error][Updated]',_0x523233);})[_0x7add('0x3e')](function(_0x5e14c0){ut[_0x7add('0x48')](_0x7add('0x49'),_0x5e14c0);});}else{ut[_0x7add('0x48')]('[Fax][Message][Error][NoUpdate2]');}}Fax[_0x7add('0x1d')]['updateStatus']=function(_0x4d5892,_0x32d02f,_0x888a4c){var _0x6d528f=this;var _0x15c1d4={};if(_0x32d02f){_0x15c1d4={'read':_0x32d02f};}else{_0x15c1d4={'failMessage':_0x888a4c};}if(this[_0x7add('0xf')][_0x4d5892]['AttachmentId']){faxMessage['update'](this[_0x7add('0xf')][_0x4d5892][_0x7add('0x45')],_0x15c1d4)['then'](function(_0x3675cb){ut[_0x7add('0x48')](_0x7add('0x4a'),_0x3675cb);})[_0x7add('0x3e')](function(_0x183fff){ut[_0x7add('0x48')](_0x7add('0x4b'),_0x183fff);})[_0x7add('0x4c')](function(){delete _0x6d528f[_0x7add('0x23')][_0x4d5892];delete _0x6d528f[_0x7add('0xf')][_0x4d5892];});}else{ut[_0x7add('0x48')]('[Fax][Message][NoUpdate2]');delete this[_0x7add('0x23')][_0x4d5892];delete this[_0x7add('0xf')][_0x4d5892];}};Fax[_0x7add('0x1d')]['syncHangup']=function(_0x100c3c){var _0x24f9c1=this;if(this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]]){if(this[_0x7add('0xf')][_0x100c3c[_0x7add('0x22')]]){this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]]['id']=this['actions'][_0x100c3c[_0x7add('0x22')]]['id'];this['channels'][_0x100c3c[_0x7add('0x22')]][_0x7add('0x25')]=this[_0x7add('0xf')][_0x100c3c['uniqueid']][_0x7add('0x25')];}logger[_0x7add('0x26')](_0x100c3c[_0x7add('0x22')],this[_0x7add('0xf')][_0x100c3c['uniqueid']]?_0x7add('0x4d'):'\x20hangup\x20faxRiceive\x20',JSON[_0x7add('0x41')](this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]]));if(this[_0x7add('0xf')][_0x100c3c[_0x7add('0x22')]]){if(this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]][_0x7add('0x4e')]>0x0&&this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]][_0x7add('0x17')]===_0x7add('0x4f')){this['updateStatus'](_0x100c3c[_0x7add('0x22')],!![]);}else{this[_0x7add('0x50')](_0x100c3c[_0x7add('0x22')],![],this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]][_0x7add('0x51')]?_0x7add('0x52')+this[_0x7add('0x23')][_0x100c3c[_0x7add('0x22')]]['faxstatusstring']:_0x7add('0x53'));}}}};Fax[_0x7add('0x1d')]['send']=function(_0x34d0ca){var _0x129eb9=this;return new BPromise(function(_0x856c23,_0x2b6fa1){_0x129eb9[_0x7add('0x54')](_0x34d0ca,_0x129eb9['faxAccounts'][_0x34d0ca[_0x7add('0x55')]])[_0x7add('0x47')](function(_0x32811e){ut[_0x7add('0x48')](_0x7add('0x56'),_0x32811e);_0x856c23(ut[_0x7add('0x39')]('Fax\x20received'));})[_0x7add('0x3e')](function(_0x2f1a3b){ut['logger'](_0x7add('0x57'),_0x2f1a3b);updateStatus(_0x34d0ca);_0x2b6fa1(ut['message'](_0x7add('0x58')));});});};Fax[_0x7add('0x1d')]['checkAfterSend']=function(_0xa24208){var _0x361d70=this;return new BPromise(function(_0x50974f,_0x2853f0){var _0x1e3877=_0x361d70[_0x7add('0x59')](_0x361d70['faxAccounts'][_0xa24208[_0x7add('0x55')]]['Trunk'],_0xa24208);if(_0x1e3877[_0x7add('0x5a')]){_0x50974f(ut[_0x7add('0x39')]('Trunk\x20Reachable'));}else{_0x2853f0(ut[_0x7add('0x39')](_0x1e3877[_0x7add('0x39')]));}});};function originate(_0x4bf47e,_0xd6ad13,_0x5bb86c){return new BPromise(function(_0x25f51c,_0x398654){if(_0x5bb86c){var _0x13c958=util[_0x7add('0x5b')]('gs\x20-q\x20-dNOPAUSE\x20-dBATCH\x20-sDEVICE=tiffg4\x20-sPAPERSIZE=letter\x20-sOutputFile=/var/opt/motion2/server/files/attachments/%s.tif\x20\x20%s\x20-c\x20quit',path[_0x7add('0x3b')](_0x4bf47e[_0x7add('0x2')])[_0x7add('0x25')],_0x4bf47e[_0x7add('0x2')]);gs[_0x7add('0x5c')](_0x13c958)[_0x7add('0x47')](function(){_0x4bf47e['path']=util[_0x7add('0x5b')](_0x7add('0x5d'),path['parse'](_0x4bf47e['path'])['dir'],path[_0x7add('0x3b')](_0x4bf47e[_0x7add('0x2')])[_0x7add('0x25')]);_0xd6ad13[_0x7add('0x5e')]=_0x4bf47e['path'];ut[_0x7add('0x48')](_0x7add('0x5f'),'');ami[_0x7add('0x60')](ut[_0x7add('0x61')](_0x4bf47e,_0xd6ad13))[_0x7add('0x47')](function(_0x3a08e6){_0x25f51c(_0x3a08e6);})['catch'](function(_0x25a74a){_0x398654(_0x25a74a);});})[_0x7add('0x3e')](function(_0x4ad1fd){_0x398654(_0x4ad1fd);});}else{ami[_0x7add('0x60')](ut[_0x7add('0x61')](_0x4bf47e,_0xd6ad13))['then'](function(_0x21c0f6){_0x25f51c(_0x21c0f6);})[_0x7add('0x3e')](function(_0x36df02){_0x398654(_0x36df02);});}});}Fax['prototype']['execOriginate']=function(_0xf6301a,_0x249a7b){var _0x22945b=this;return new BPromise(function(_0x597ce4,_0x3b7a96){var _0x4a7a95=uuid['v4']();var _0xf471f8=ut['addVariables'](_0xf6301a,_0x249a7b);_0x22945b[_0x7add('0xf')][_0x4a7a95]=new Action(_0x4a7a95,_0x249a7b,_0xf6301a);var _0x160a69=_0x22945b[_0x7add('0xf')][_0x4a7a95];if(path[_0x7add('0x3b')](_0xf6301a[_0x7add('0x2')])[_0x7add('0x62')]===_0x7add('0x3c')){originate(_0x160a69,_0xf471f8,!![])[_0x7add('0x47')](function(_0x881513){_0x597ce4(_0x881513);})['catch'](function(_0x28abdc){_0x3b7a96(_0x28abdc);});}else{originate(_0x160a69,_0xf471f8,![])['then'](function(_0x4615c5){_0x597ce4(_0x4615c5);})['catch'](function(_0x317068){_0x3b7a96(_0x317068);});}});};Fax[_0x7add('0x1d')][_0x7add('0x63')]=function(_0xc91d8c){return!_[_0x7add('0x64')](_0xc91d8c)&&!_[_0x7add('0x64')](_0xc91d8c[_0x7add('0x25')])&&!_[_0x7add('0x64')](_0xc91d8c['active'])&&_0xc91d8c['active']&&!_['isNil'](this[_0x7add('0xe')][util[_0x7add('0x5b')](_0x7add('0x65'),_0xc91d8c[_0x7add('0x25')])])&&!_[_0x7add('0x64')](this[_0x7add('0xe')][util[_0x7add('0x5b')]('SIP/%s',_0xc91d8c[_0x7add('0x25')])][_0x7add('0x2e')])&&(this['trunks'][util[_0x7add('0x5b')](_0x7add('0x65'),_0xc91d8c[_0x7add('0x25')])][_0x7add('0x2e')]===_0x7add('0x66')||this[_0x7add('0xe')][util[_0x7add('0x5b')](_0x7add('0x65'),_0xc91d8c['name'])][_0x7add('0x2e')]===_0x7add('0x67'));};Fax[_0x7add('0x1d')][_0x7add('0x59')]=function(_0x105c7d,_0x42ba2f){if(!this[_0x7add('0x63')](_0x105c7d)){ut[_0x7add('0x48')](_0x7add('0x68'),_[_0x7add('0x64')](_0x105c7d)?'':_0x105c7d['name']+_0x7add('0x69'));return{'isValid':![],'message':_0x7add('0x6a')};}if(_[_0x7add('0x64')](_0x42ba2f['fax'])){ut[_0x7add('0x48')](_0x7add('0x6b'),JSON['stringify'](_0x42ba2f));return{'isValid':![],'message':_0x7add('0x6c')};}if(_[_0x7add('0x64')](_0x42ba2f[_0x7add('0x2')])){ut['logger'](_0x7add('0x6d'),JSON[_0x7add('0x41')](_0x42ba2f));return{'isValid':![],'message':_0x7add('0x6e')};}return{'isValid':!![],'message':_0x7add('0x6f')};};module[_0x7add('0x70')]=Fax; \ No newline at end of file diff --git a/server/services/ami/fax/rpcDb.js b/server/services/ami/fax/rpcDb.js new file mode 100644 index 0000000..6253fc6 --- /dev/null +++ b/server/services/ami/fax/rpcDb.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xeb6d=['lodash','../rpc/faxAccount','error','inspect','notify','resolve','then','catch','[Notify]\x20','bluebird','preview'];(function(_0x3c67a5,_0x196965){var _0xb63e10=function(_0x160684){while(--_0x160684){_0x3c67a5['push'](_0x3c67a5['shift']());}};_0xb63e10(++_0x196965);}(_0xeb6d,0x153));var _0xdeb6=function(_0x5834bc,_0x3d4801){_0x5834bc=_0x5834bc-0x0;var _0x3e183a=_0xeb6d[_0x5834bc];return _0x3e183a;};'use strict';var util=require('util');var BPromise=require(_0xdeb6('0x0'));var logger=require('../../../config/logger')(_0xdeb6('0x1'));var _=require(_0xdeb6('0x2'));var faxAccount=require(_0xdeb6('0x3'));function loggerCatch(_0x5b5852){return function(_0x5d8ec3){logger[_0xdeb6('0x4')](_0x5b5852,util[_0xdeb6('0x5')](_0x5d8ec3,{'showHidden':![],'depth':null}));};}exports[_0xdeb6('0x6')]=function(_0x1b95f0,_0x54fd81){return BPromise[_0xdeb6('0x7')]()[_0xdeb6('0x8')](faxAccount[_0xdeb6('0x6')](_0x1b95f0,_0x54fd81))[_0xdeb6('0x9')](loggerCatch(_0xdeb6('0xa')));}; \ No newline at end of file diff --git a/server/services/ami/fax/util/gs.js b/server/services/ami/fax/util/gs.js new file mode 100644 index 0000000..d66b78e --- /dev/null +++ b/server/services/ami/fax/util/gs.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd16f=['bluebird','child_process','exec','info','Exec\x20gs','\x20Error\x20:','util','../../../../config/logger'];(function(_0x532c0d,_0x5b9288){var _0x11062e=function(_0xee0ac0){while(--_0xee0ac0){_0x532c0d['push'](_0x532c0d['shift']());}};_0x11062e(++_0x5b9288);}(_0xd16f,0x136));var _0xfd16=function(_0x1d386c,_0x283f29){_0x1d386c=_0x1d386c-0x0;var _0x1d41aa=_0xd16f[_0x1d386c];return _0x1d41aa;};'use strict';var util=require(_0xfd16('0x0'));var logger=require(_0xfd16('0x1'))('fax');var BPromise=require(_0xfd16('0x2'));var exec=require(_0xfd16('0x3'))[_0xfd16('0x4')];exports['execute']=function(_0x425ab2){return new BPromise(function(_0x3dc175,_0x54a532){exec(_0x425ab2,function(_0xfdeb54,_0x52c5e0,_0x16c6dd){logger[_0xfd16('0x5')](_0xfd16('0x6'),_0x52c5e0);if(_0xfdeb54){logger[_0xfd16('0x5')](_0xfd16('0x6'),_0xfd16('0x7'),util['inspect'](_0xfdeb54,{'showHidden':![],'depth':null}),_0x52c5e0,_0x16c6dd);_0x54a532(_0xfdeb54);}_0x3dc175(_0x52c5e0);});});}; \ No newline at end of file diff --git a/server/services/ami/fax/util/util.js b/server/services/ami/fax/util/util.js new file mode 100644 index 0000000..7362d22 --- /dev/null +++ b/server/services/ami/fax/util/util.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc627=['moment','../../../../config/logger','fax','message','info','inspect','addVariables','ecm','maxrate','format','\x22%s\x22','modem','faxdetect','t38timeout','localstationid','path','uniqueid','xcally-motion-fax','from-sip','headerinfo','lodash'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xc627,0x1cd));var _0x7c62=function(_0x37e9b0,_0x117b2b){_0x37e9b0=_0x37e9b0-0x0;var _0xda9fc6=_0xc627[_0x37e9b0];return _0xda9fc6;};'use strict';var util=require('util');var _=require(_0x7c62('0x0'));var moment=require(_0x7c62('0x1'));var logger=require(_0x7c62('0x2'))(_0x7c62('0x3'));exports[_0x7c62('0x4')]=function(_0xaf337f){return{'message':_0xaf337f};};exports['logger']=function(_0xdbb8d3,_0x1cff98){logger[_0x7c62('0x5')](_0xdbb8d3,util[_0x7c62('0x6')](_0x1cff98,{'showHidden':![],'depth':null}));};exports[_0x7c62('0x7')]=function(_0x447012,_0x150365){var _0x2a369d={'XMF-ECM':_0x150365[_0x7c62('0x8')],'XMF-HEADERINFO':_0x150365['headerinfo'],'XMF-MINRATE':_0x150365['minrate'],'XMF-MAXRATE':_0x150365[_0x7c62('0x9')],'XMF-MODEM':util[_0x7c62('0xa')](_0x7c62('0xb'),_0x150365[_0x7c62('0xc')]),'XMF-GATEWAY':_0x150365['gateway'],'XMF-FAXDETECT':_0x150365[_0x7c62('0xd')],'XMF-T38TIMEOUT':_0x150365[_0x7c62('0xe')],'XMF-LOCALSTATIONID':_0x150365[_0x7c62('0xf')],'XMF-PATH':_0x447012[_0x7c62('0x10')]};return _0x2a369d;};exports['variablesAction']=function(_0x1d8caf,_0x27224f){return{'actionid':_0x1d8caf[_0x7c62('0x11')],'action':'originate','channel':_0x1d8caf['channel'],'Exten':_0x7c62('0x12'),'Context':_0x7c62('0x13'),'Priority':'1','callerid':util[_0x7c62('0xa')]('\x22%s\x22\x20<%s>',_0x1d8caf[_0x7c62('0x14')]?_0x1d8caf[_0x7c62('0x14')]:'',_0x1d8caf['localstationid']),'variable':_0x27224f,'timeout':0x1e*0x3e8,'async':!![],'channelid':_0x1d8caf[_0x7c62('0x11')]};}; \ No newline at end of file diff --git a/server/services/ami/index.js b/server/services/ami/index.js new file mode 100644 index 0000000..4904214 --- /dev/null +++ b/server/services/ami/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6e1e=['getDeskAccounts','initDeskAccounts','getZohoAccounts','getVtigerAccounts','getFreshsalesAccounts','getServicenowAccounts','initDynamics365Accounts','getCampaigns','initCampaigns','getVoiceExtensions','getFaxAccounts','initFaxAccounts','initVoiceQueueReports','getVoiceQueueHopperHistory','initVoiceQueueHopperHistory','initCampaignHopperHistory','getVoiceCallReports','initVoiceCallReports','catch','error','[index.js][initParams]','[index.js][main]','inspect','moment','./server','./report','./acw','./trigger','./preview','./fax','./rpc/user','./rpc/voiceQueue','./rpc/voiceQueueReport','./rpc/trunk','./rpc/trigger','./rpc/voiceExtension','./rpc/faxAccount','./rpc/integrations/zendesk','./rpc/integrations/sugarcrm','./rpc/integrations/freshdesk','./rpc/integrations/desk','./rpc/integrations/zoho','./rpc/integrations/freshsales','./rpc/integrations/dynamics365','ami','get','hour','resolve','then','initAgents','initTelephones','getTrunks','initTrunks','getVoiceQueues','initVoiceQueues','getTriggers','initTriggers','getTemplates','initTemplates','getZendeskAccounts','initZendeskAccounts','getSalesforceAccounts','initSalesforceAccounts','getSugarcrmAccounts','initSugarcrmAccounts','getFreshdeskAccounts','initFreshdeskAccounts'];(function(_0x38b383,_0x53d603){var _0x305957=function(_0xbb59a7){while(--_0xbb59a7){_0x38b383['push'](_0x38b383['shift']());}};_0x305957(++_0x53d603);}(_0x6e1e,0x1a9));var _0xe6e1=function(_0x3d7649,_0x38a79c){_0x3d7649=_0x3d7649-0x0;var _0x100ee0=_0x6e1e[_0x3d7649];return _0x100ee0;};'use strict';var util=require('util');var moment=require(_0xe6e1('0x0'));var server=require(_0xe6e1('0x1'));var Realtime=require('./realtime');var Report=require(_0xe6e1('0x2'));var Acw=require(_0xe6e1('0x3'));var Trigger=require(_0xe6e1('0x4'));var Dialer=require('./dialer');var Preview=require(_0xe6e1('0x5'));var Fax=require(_0xe6e1('0x6'));var user=require(_0xe6e1('0x7'));var voiceQueue=require(_0xe6e1('0x8'));var voiceQueueReport=require(_0xe6e1('0x9'));var voiceCallReport=require('./rpc/voiceCallReport');var trunk=require(_0xe6e1('0xa'));var trigger=require(_0xe6e1('0xb'));var template=require('./rpc/template');var cmHopperHistory=require('./rpc/cmHopperHistory');var campaign=require('./rpc/campaign');var voiceExtension=require(_0xe6e1('0xc'));var faxAccount=require(_0xe6e1('0xd'));var zendesk=require(_0xe6e1('0xe'));var salesforce=require('./rpc/integrations/salesforce');var sugarcrm=require(_0xe6e1('0xf'));var freshdesk=require(_0xe6e1('0x10'));var desk=require(_0xe6e1('0x11'));var zoho=require(_0xe6e1('0x12'));var vtiger=require('./rpc/integrations/vtiger');var freshsales=require(_0xe6e1('0x13'));var servicenow=require('./rpc/integrations/servicenow');var dynamics365=require(_0xe6e1('0x14'));var realtime=new Realtime();var report=new Report(realtime);var acw=new Acw(realtime);var channelTrigger=new Trigger(realtime);var preview=new Preview(realtime);var dialer=new Dialer(realtime,preview);var fax=new Fax(realtime);var logger=require('../../config/logger')(_0xe6e1('0x15'));var isTrue=!![];var initP=!![];function ifMidnight(){if(moment()[_0xe6e1('0x16')](_0xe6e1('0x17'))===0x0&&initP){initP=![];isTrue=!![];initParams();}if(moment()['get'](_0xe6e1('0x17'))===0x1&&isTrue){isTrue=![];initP=!![];}}function initRealtime(){ifMidnight();return Promise[_0xe6e1('0x18')]()['then'](user['getAgents']())[_0xe6e1('0x19')](realtime[_0xe6e1('0x1a')]())[_0xe6e1('0x19')](user['getTelephones']())[_0xe6e1('0x19')](realtime[_0xe6e1('0x1b')]())[_0xe6e1('0x19')](trunk[_0xe6e1('0x1c')]())['then'](realtime[_0xe6e1('0x1d')]())[_0xe6e1('0x19')](voiceQueue[_0xe6e1('0x1e')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x1f')]())['then'](trigger[_0xe6e1('0x20')]())['then'](realtime[_0xe6e1('0x21')]())[_0xe6e1('0x19')](template[_0xe6e1('0x22')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x23')]())[_0xe6e1('0x19')](zendesk[_0xe6e1('0x24')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x25')]())[_0xe6e1('0x19')](salesforce[_0xe6e1('0x26')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x27')]())[_0xe6e1('0x19')](sugarcrm[_0xe6e1('0x28')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x29')]())[_0xe6e1('0x19')](freshdesk[_0xe6e1('0x2a')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x2b')]())['then'](desk[_0xe6e1('0x2c')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x2d')]())['then'](zoho[_0xe6e1('0x2e')]())[_0xe6e1('0x19')](realtime['initZohoAccounts']())[_0xe6e1('0x19')](vtiger[_0xe6e1('0x2f')]())[_0xe6e1('0x19')](realtime['initVtigerAccounts']())[_0xe6e1('0x19')](freshsales[_0xe6e1('0x30')]())['then'](realtime['initFreshsalesAccounts']())[_0xe6e1('0x19')](servicenow[_0xe6e1('0x31')]())[_0xe6e1('0x19')](realtime['initServicenowAccounts']())[_0xe6e1('0x19')](dynamics365['getDynamics365Accounts']())['then'](realtime[_0xe6e1('0x32')]())[_0xe6e1('0x19')](campaign[_0xe6e1('0x33')]())['then'](realtime[_0xe6e1('0x34')]())[_0xe6e1('0x19')](voiceExtension[_0xe6e1('0x35')]())[_0xe6e1('0x19')](realtime['initVoiceExtensions']())[_0xe6e1('0x19')](faxAccount[_0xe6e1('0x36')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x37')]())[_0xe6e1('0x19')](function(){return realtime;});}function initParams(){return Promise[_0xe6e1('0x18')]()['then'](voiceQueueReport['getVoiceQueueReports']())['then'](realtime[_0xe6e1('0x38')]())[_0xe6e1('0x19')](cmHopperHistory[_0xe6e1('0x39')]())[_0xe6e1('0x19')](realtime[_0xe6e1('0x3a')]())['then'](cmHopperHistory['getCampaignHopperHistory']())[_0xe6e1('0x19')](realtime[_0xe6e1('0x3b')]())[_0xe6e1('0x19')](voiceCallReport[_0xe6e1('0x3c')]())['then'](realtime[_0xe6e1('0x3d')]())[_0xe6e1('0x3e')](function(_0x5c9bae){logger[_0xe6e1('0x3f')](_0xe6e1('0x40'),util['inspect'](_0x5c9bae,{'showHidden':![],'depth':null}));});}function main(){return server['listen'](realtime,preview,fax)[_0xe6e1('0x19')](function(){return initRealtime();})[_0xe6e1('0x19')](function(){return initParams();})['then'](function(){report['sync']();setInterval(initRealtime,0x1388);})[_0xe6e1('0x3e')](function(_0x28b795){logger[_0xe6e1('0x3f')](_0xe6e1('0x41'),util[_0xe6e1('0x42')](_0x28b795,{'showHidden':![],'depth':null}));});}main(); \ No newline at end of file diff --git a/server/services/ami/model/agent.js b/server/services/ami/model/agent.js new file mode 100644 index 0000000..b052b28 --- /dev/null +++ b/server/services/ami/model/agent.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbcae=['toLowerCase','not_inuse','idle','talking','voiceStatus','statePause','format','status','address','stringify','user:%s','emit','user:presence','lodash','util','moment','md5','ioredis','../../../config/environment','redis','defaults','localhost','name','email','accountcode','fullname','state','unknown','stateTime','phone','mobile','interface','online','voiceStatusTime','voiceStatusCallerIdNumber','voiceStatusQueue','onhold','local','prototype'];(function(_0x20d7fd,_0x48d9ec){var _0x250857=function(_0x125ff6){while(--_0x125ff6){_0x20d7fd['push'](_0x20d7fd['shift']());}};_0x250857(++_0x48d9ec);}(_0xbcae,0xa9));var _0xebca=function(_0xc611f5,_0x303476){_0xc611f5=_0xc611f5-0x0;var _0x225281=_0xbcae[_0xc611f5];return _0x225281;};'use strict';var _=require(_0xebca('0x0'));var util=require(_0xebca('0x1'));var moment=require(_0xebca('0x2'));var md5=require(_0xebca('0x3'));var Redis=require(_0xebca('0x4'));var config=require(_0xebca('0x5'));config[_0xebca('0x6')]=_[_0xebca('0x7')](config[_0xebca('0x6')],{'host':_0xebca('0x8'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xebca('0x6')]));function Agent(_0x149c78){this['id']=_0x149c78['id']||0x0;this['name']=_0x149c78[_0xebca('0x9')]||'';this[_0xebca('0xa')]=_0x149c78[_0xebca('0xa')]||'';this['accountcode']=_0x149c78[_0xebca('0xb')]||'';this[_0xebca('0xc')]=_0x149c78[_0xebca('0xc')]||'';this[_0xebca('0xd')]=_0xebca('0xe');this[_0xebca('0xf')]=0x0;this['status']='unknown';this['address']='';this[_0xebca('0x10')]='';this[_0xebca('0x11')]='';this[_0xebca('0x12')]='';this[_0xebca('0x13')]=_0x149c78[_0xebca('0x13')]||![];this['voiceStatus']=_0xebca('0xe');this[_0xebca('0x14')]=0x0;this[_0xebca('0x15')]='';this[_0xebca('0x16')]='';this[_0xebca('0x17')]=![];this[_0xebca('0x18')]=![];this[_0xebca('0x3')]='';}Agent[_0xebca('0x19')]['updateStatusRealtime']=function(_0x5481f9){var _0x224f4b;if(_0x5481f9&&_0x5481f9['state']){_0x224f4b=_0x5481f9[_0xebca('0xd')][_0xebca('0x1a')]();switch(_0x224f4b){case _0xebca('0x1b'):_0x224f4b=_0xebca('0x1c');break;case'inuse':_0x224f4b=_0xebca('0x1d');break;}}if(_0x224f4b&&this[_0xebca('0x1e')]!==_0x224f4b||_0x5481f9[_0xebca('0x1f')]){this[_0xebca('0x14')]=_['toNumber'](moment()[_0xebca('0x20')]('x'));}if(_0x224f4b){this[_0xebca('0x1e')]=_0x224f4b;}var _0x23b411={'id':this['id'],'name':this['name'],'email':this[_0xebca('0xa')],'accountcode':this[_0xebca('0xb')],'fullname':this['fullname'],'state':this[_0xebca('0xd')],'stateTime':this[_0xebca('0xf')],'status':this[_0xebca('0x21')],'address':this[_0xebca('0x22')],'online':this[_0xebca('0x13')],'voiceStatus':this[_0xebca('0x1e')],'voiceStatusTime':this[_0xebca('0x14')],'voiceStatusCallerIdNumber':this[_0xebca('0x15')],'voiceStatusQueue':this[_0xebca('0x16')],'interface':this[_0xebca('0x12')],'onhold':this[_0xebca('0x17')]};var _0x451ed3=md5(JSON[_0xebca('0x23')](_0x23b411));if(this[_0xebca('0x3')]!==_0x451ed3){this['md5']=_0x451ed3;io['to'](util[_0xebca('0x20')](_0xebca('0x24'),_0x23b411[_0xebca('0x9')]))['emit']('user:save',_0x23b411);io[_0xebca('0x25')](_0xebca('0x26'),_0x23b411);}};module['exports']=Agent; \ No newline at end of file diff --git a/server/services/ami/model/campaign.js b/server/services/ami/model/campaign.js new file mode 100644 index 0000000..4581425 --- /dev/null +++ b/server/services/ami/model/campaign.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xfb7f=['Interval','SquareProject','dialAMDActive','dialAMDInitialSilence','dialAMDGreeting','dialAMDAfterGreetingSilence','dialAMDTotalAnalysisTime','dialAMDMinWordLength','dialAMDBetweenWordsSilence','dialAMDMaximumNumberOfWords','dialAMDMaximumWordLength','exports','name','type','originated','temp','ivrAnswerCallsDay','message','sendMessageOneNotActive','limitCalls','dialGlobalInterval','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialCongestionMaxRetry','dialCongestionRetryFrequency','dialBusyMaxRetry','dialBusyRetryFrequency','dialNoAnswerRetryFrequency','dialGlobalMaxRetry','dialNoSuchNumberMaxRetry','dialNoSuchNumberRetryFrequency','dialDropMaxRetry','dialDropRetryFrequency','dialAbandonedMaxRetry','dialAbandonedRetryFrequency','dialMachineMaxRetry','dialMachineRetryFrequency','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','dialOrderByScheduledAt','DESC','dialPrefix','dialRandomLastDigitCallerIdNumber','dialCutDigit','TrunkBackup','Trunk'];(function(_0xdf4058,_0x3d913d){var _0x141888=function(_0x52b935){while(--_0x52b935){_0xdf4058['push'](_0xdf4058['shift']());}};_0x141888(++_0x3d913d);}(_0xfb7f,0x184));var _0xffb7=function(_0x1015b8,_0x3755de){_0x1015b8=_0x1015b8-0x0;var _0x2fc31a=_0xfb7f[_0x1015b8];return _0x2fc31a;};'use strict';function Campaign(_0x100e53){this['id']=_0x100e53['id']||0x0;this['name']=_0x100e53[_0xffb7('0x0')]||'';this[_0xffb7('0x1')]=_0x100e53['type']||'campaign';this[_0xffb7('0x2')]=0x0;this[_0xffb7('0x3')]=0x0;this[_0xffb7('0x4')]=0x0;this['ivrTotalCallsDays']=0x0;this[_0xffb7('0x5')]='';this[_0xffb7('0x6')]=!![];this['active']=_0x100e53['active'];this[_0xffb7('0x7')]=_0x100e53[_0xffb7('0x7')];this['dialTimezone']=_0x100e53['dialTimezone']||null;this[_0xffb7('0x8')]=_0x100e53['dialGlobalInterval']?_0x100e53[_0xffb7('0x8')]:null;this[_0xffb7('0x9')]=_0x100e53[_0xffb7('0x9')];this[_0xffb7('0xa')]=_0x100e53[_0xffb7('0xa')];this['dialOriginateTimeout']=_0x100e53[_0xffb7('0xb')]||0x1e;this['dialCongestionMaxRetry']=_0x100e53[_0xffb7('0xc')];this[_0xffb7('0xd')]=_0x100e53['dialCongestionRetryFrequency'];this[_0xffb7('0xe')]=_0x100e53[_0xffb7('0xe')];this[_0xffb7('0xf')]=_0x100e53[_0xffb7('0xf')];this['dialNoAnswerMaxRetry']=_0x100e53['dialNoAnswerMaxRetry'];this[_0xffb7('0x10')]=_0x100e53[_0xffb7('0x10')];this[_0xffb7('0x11')]=_0x100e53[_0xffb7('0x11')];this['dialNoSuchNumberMaxRetry']=_0x100e53[_0xffb7('0x12')]||0x3;this[_0xffb7('0x13')]=_0x100e53['dialNoSuchNumberRetryFrequency']||0x96;this['dialDropMaxRetry']=_0x100e53[_0xffb7('0x14')]||0x3;this[_0xffb7('0x15')]=_0x100e53[_0xffb7('0x15')]||0x96;this[_0xffb7('0x16')]=_0x100e53[_0xffb7('0x16')]||0x3;this[_0xffb7('0x17')]=_0x100e53[_0xffb7('0x17')]||0x96;this[_0xffb7('0x18')]=_0x100e53[_0xffb7('0x18')]||0x3;this[_0xffb7('0x19')]=_0x100e53[_0xffb7('0x19')]||0x96;this[_0xffb7('0x1a')]=_0x100e53['dialAgentRejectMaxRetry']||0x3;this['dialAgentRejectRetryFrequency']=_0x100e53[_0xffb7('0x1b')]||0x96;this[_0xffb7('0x1c')]=_0x100e53[_0xffb7('0x1c')]||_0xffb7('0x1d');this[_0xffb7('0x1e')]=_0x100e53[_0xffb7('0x1e')]||undefined;this[_0xffb7('0x1f')]=_0x100e53['dialRandomLastDigitCallerIdNumber']||undefined;this[_0xffb7('0x20')]=_0x100e53[_0xffb7('0x20')]||undefined;this[_0xffb7('0x21')]=_0x100e53[_0xffb7('0x21')]?_0x100e53[_0xffb7('0x21')]:undefined;this['Trunk']=_0x100e53[_0xffb7('0x22')]?_0x100e53[_0xffb7('0x22')]:undefined;this[_0xffb7('0x23')]=_0x100e53[_0xffb7('0x23')]?_0x100e53[_0xffb7('0x23')]:undefined;this[_0xffb7('0x24')]=_0x100e53[_0xffb7('0x24')]?_0x100e53[_0xffb7('0x24')]:undefined;this['dialQueueProject']=_0x100e53['SquareProject']?_0x100e53[_0xffb7('0x24')][_0xffb7('0x0')]:undefined;this[_0xffb7('0x25')]=_0x100e53[_0xffb7('0x25')]||![];this[_0xffb7('0x26')]=_0x100e53[_0xffb7('0x26')];this[_0xffb7('0x27')]=_0x100e53[_0xffb7('0x27')];this[_0xffb7('0x28')]=_0x100e53[_0xffb7('0x28')];this[_0xffb7('0x29')]=_0x100e53['dialAMDTotalAnalysisTime'];this[_0xffb7('0x2a')]=_0x100e53[_0xffb7('0x2a')];this['dialAMDBetweenWordsSilence']=_0x100e53[_0xffb7('0x2b')];this[_0xffb7('0x2c')]=_0x100e53[_0xffb7('0x2c')];this['dialAMDSilenceThreshold']=_0x100e53['dialAMDSilenceThreshold'];this[_0xffb7('0x2d')]=_0x100e53['dialAMDMaximumWordLength'];}module[_0xffb7('0x2e')]=Campaign; \ No newline at end of file diff --git a/server/services/ami/model/channel.js b/server/services/ami/model/channel.js new file mode 100644 index 0000000..a85de6b --- /dev/null +++ b/server/services/ami/model/channel.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7e22=['lastdata','duration','billableseconds','holdtime','type','tag','monitor','monitorFilename','monitors','transfercalleridnum','transferconnectedlinenum','transferType','exports','starttime','destinationchannel','calleridnum','calleridname','connectedlinenum','connectedlinename','accountcode','uniqueid','exten','answered','answertime','endtime','abandoned','lastapplication'];(function(_0x1aba25,_0x1faed1){var _0x47d997=function(_0x4f9e11){while(--_0x4f9e11){_0x1aba25['push'](_0x1aba25['shift']());}};_0x47d997(++_0x1faed1);}(_0x7e22,0x1d8));var _0x27e2=function(_0x47b259,_0x176986){_0x47b259=_0x47b259-0x0;var _0x545d55=_0x7e22[_0x47b259];return _0x545d55;};'use strict';function Channel(){this[_0x27e2('0x0')]=null;this['channel']='';this[_0x27e2('0x1')]='';this[_0x27e2('0x2')]=0x0;this[_0x27e2('0x3')]='';this[_0x27e2('0x4')]=undefined;this[_0x27e2('0x5')]=undefined;this[_0x27e2('0x6')]=0x0;this['context']='';this[_0x27e2('0x7')]=0x0;this['linkedid']=0x0;this[_0x27e2('0x8')]=0x0;this[_0x27e2('0x9')]=![];this[_0x27e2('0xa')]=null;this[_0x27e2('0xb')]=null;this['unmanaged']=![];this[_0x27e2('0xc')]=![];this[_0x27e2('0xd')]='';this[_0x27e2('0xe')]='';this[_0x27e2('0xf')]=0x0;this[_0x27e2('0x10')]=0x0;this[_0x27e2('0x11')]=0x0;this[_0x27e2('0x12')]=null;this[_0x27e2('0x13')]=null;this['disposition']=null;this[_0x27e2('0x14')]=![];this[_0x27e2('0x15')]=null;this['queue']=null;this[_0x27e2('0x16')]=[];this[_0x27e2('0x17')]=undefined;this[_0x27e2('0x18')]=undefined;this[_0x27e2('0x19')]=undefined;this['mohtime']=0x0;}module[_0x27e2('0x1a')]=Channel; \ No newline at end of file diff --git a/server/services/ami/model/deskAccount.js b/server/services/ami/model/deskAccount.js new file mode 100644 index 0000000..bd18f6b --- /dev/null +++ b/server/services/ami/model/deskAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6b58=['remoteUri','authType','password','consumerKey','consumerSecret','token','tokenSecret','type','serverUrl','Configurations','exports','name','username'];(function(_0x110e42,_0x134a3e){var _0x343f58=function(_0x58f189){while(--_0x58f189){_0x110e42['push'](_0x110e42['shift']());}};_0x343f58(++_0x134a3e);}(_0x6b58,0xce));var _0x86b5=function(_0x10291b,_0x518773){_0x10291b=_0x10291b-0x0;var _0x1d5fbe=_0x6b58[_0x10291b];return _0x1d5fbe;};'use strict';function DeskAccount(_0x2613d5){this['id']=_0x2613d5['id']||0x0;this[_0x86b5('0x0')]=_0x2613d5[_0x86b5('0x0')]||'';this['username']=_0x2613d5[_0x86b5('0x1')]||'';this[_0x86b5('0x2')]=_0x2613d5[_0x86b5('0x2')]||'';this[_0x86b5('0x3')]=_0x2613d5[_0x86b5('0x3')]||'';this['password']=_0x2613d5[_0x86b5('0x4')]||'';this[_0x86b5('0x5')]=_0x2613d5['consumerKey']||'';this['consumerSecret']=_0x2613d5[_0x86b5('0x6')]||'';this[_0x86b5('0x7')]=_0x2613d5[_0x86b5('0x7')]||'';this[_0x86b5('0x8')]=_0x2613d5[_0x86b5('0x8')]||'';this[_0x86b5('0x9')]=_0x2613d5['type']||'';this[_0x86b5('0xa')]=_0x2613d5[_0x86b5('0xa')]||'';this[_0x86b5('0xb')]=_0x2613d5[_0x86b5('0xb')]||{};}module[_0x86b5('0xc')]=DeskAccount; \ No newline at end of file diff --git a/server/services/ami/model/dynamics365Account.js b/server/services/ami/model/dynamics365Account.js new file mode 100644 index 0000000..5c47919 --- /dev/null +++ b/server/services/ami/model/dynamics365Account.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x832d=['name','username','password','remoteUri','tenantId','clientId','clientSecret','serverUrl','modernAuthentication','Configurations','CloudProvider'];(function(_0x38fb0d,_0x52b5db){var _0x30a5d6=function(_0x31eba6){while(--_0x31eba6){_0x38fb0d['push'](_0x38fb0d['shift']());}};_0x30a5d6(++_0x52b5db);}(_0x832d,0x108));var _0xd832=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x832d[_0x14add3];return _0x4a174f;};'use strict';function Dynamics365Account(_0x33b9c0){this['id']=_0x33b9c0['id']||0x0;this[_0xd832('0x0')]=_0x33b9c0[_0xd832('0x0')]||'';this[_0xd832('0x1')]=_0x33b9c0[_0xd832('0x1')]||'';this[_0xd832('0x2')]=_0x33b9c0['password']||'';this[_0xd832('0x3')]=_0x33b9c0['remoteUri']||'';this[_0xd832('0x4')]=_0x33b9c0[_0xd832('0x4')]||'';this[_0xd832('0x5')]=_0x33b9c0[_0xd832('0x5')]||'';this[_0xd832('0x6')]=_0x33b9c0[_0xd832('0x6')]||{};this[_0xd832('0x7')]=_0x33b9c0[_0xd832('0x7')]||'';this['modernAuthentication']=_0x33b9c0[_0xd832('0x8')]||![];this[_0xd832('0x9')]=_0x33b9c0[_0xd832('0x9')]||{};this['CloudProvider']=_0x33b9c0[_0xd832('0xa')]||{};}module['exports']=Dynamics365Account; \ No newline at end of file diff --git a/server/services/ami/model/faxAccount.js b/server/services/ami/model/faxAccount.js new file mode 100644 index 0000000..92d7bd3 --- /dev/null +++ b/server/services/ami/model/faxAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x646e=['t38timeout','tech','SIP','Trunk','ListId','key','exports','name','description','headerinfo','localstationid','minrate','maxrate','modem','v17,v27,v29','gateway','faxdetect'];(function(_0x298ed3,_0x4ab5e1){var _0x5aad28=function(_0x168687){while(--_0x168687){_0x298ed3['push'](_0x298ed3['shift']());}};_0x5aad28(++_0x4ab5e1);}(_0x646e,0xc2));var _0xe646=function(_0x5220be,_0x1933b7){_0x5220be=_0x5220be-0x0;var _0x4eaa77=_0x646e[_0x5220be];return _0x4eaa77;};'use strict';function FaxAccount(_0x7352e3){this['id']=_0x7352e3['id']||0x0;this[_0xe646('0x0')]=_0x7352e3[_0xe646('0x0')]||'';this['description']=_0x7352e3[_0xe646('0x1')];this['ecm']=_0x7352e3['ecm'];this[_0xe646('0x2')]=_0x7352e3['headerinfo'];this[_0xe646('0x3')]=_0x7352e3[_0xe646('0x3')];this[_0xe646('0x4')]=_0x7352e3[_0xe646('0x4')]||0x960;this[_0xe646('0x5')]=_0x7352e3['maxrate']||0x3840;this[_0xe646('0x6')]=_0x7352e3[_0xe646('0x6')]||_0xe646('0x7');this[_0xe646('0x8')]=_0x7352e3[_0xe646('0x8')]||'no';this[_0xe646('0x9')]=_0x7352e3[_0xe646('0x9')]||'no';this[_0xe646('0xa')]=_0x7352e3[_0xe646('0xa')]||0x1388;this[_0xe646('0xb')]=_0x7352e3[_0xe646('0xb')]||_0xe646('0xc');this[_0xe646('0xd')]=_0x7352e3['Trunk']?_0x7352e3[_0xe646('0xd')]:undefined;this[_0xe646('0xe')]=_0x7352e3['ListId'];this['key']=_0x7352e3[_0xe646('0xf')];}module[_0xe646('0x10')]=FaxAccount; \ No newline at end of file diff --git a/server/services/ami/model/freshdeskAccount.js b/server/services/ami/model/freshdeskAccount.js new file mode 100644 index 0000000..06e788e --- /dev/null +++ b/server/services/ami/model/freshdeskAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9184=['Configurations','exports','name','username','apiKey','token','remoteUri','serverUrl'];(function(_0x521929,_0x479be5){var _0x632436=function(_0x288290){while(--_0x288290){_0x521929['push'](_0x521929['shift']());}};_0x632436(++_0x479be5);}(_0x9184,0x172));var _0x4918=function(_0x2ae099,_0x1d9376){_0x2ae099=_0x2ae099-0x0;var _0x2ce323=_0x9184[_0x2ae099];return _0x2ce323;};'use strict';function FreshdeskAccount(_0x5b543a){this['id']=_0x5b543a['id']||0x0;this['name']=_0x5b543a[_0x4918('0x0')]||'';this[_0x4918('0x1')]=_0x5b543a['username']||'';this[_0x4918('0x2')]=_0x5b543a[_0x4918('0x3')]||'';this[_0x4918('0x4')]=_0x5b543a[_0x4918('0x4')]||'';this[_0x4918('0x5')]=_0x5b543a[_0x4918('0x5')]||'';this[_0x4918('0x6')]=_0x5b543a['Configurations']||{};}module[_0x4918('0x7')]=FreshdeskAccount; \ No newline at end of file diff --git a/server/services/ami/model/freshsalesAccount.js b/server/services/ami/model/freshsalesAccount.js new file mode 100644 index 0000000..37ea983 --- /dev/null +++ b/server/services/ami/model/freshsalesAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf3cc=['token','remoteUri','serverUrl','Configurations','exports','name','username','apiKey'];(function(_0x6ca7f4,_0x51a5df){var _0x494fa6=function(_0x359532){while(--_0x359532){_0x6ca7f4['push'](_0x6ca7f4['shift']());}};_0x494fa6(++_0x51a5df);}(_0xf3cc,0x10d));var _0xcf3c=function(_0x59eacf,_0x56ec4a){_0x59eacf=_0x59eacf-0x0;var _0x5d74f2=_0xf3cc[_0x59eacf];return _0x5d74f2;};'use strict';function FreshsalesAccount(_0x48162b){this['id']=_0x48162b['id']||0x0;this[_0xcf3c('0x0')]=_0x48162b[_0xcf3c('0x0')]||'';this[_0xcf3c('0x1')]=_0x48162b['username']||'';this[_0xcf3c('0x2')]=_0x48162b[_0xcf3c('0x3')]||'';this[_0xcf3c('0x4')]=_0x48162b['remoteUri']||'';this[_0xcf3c('0x5')]=_0x48162b[_0xcf3c('0x5')]||'';this['Configurations']=_0x48162b[_0xcf3c('0x6')]||{};}module[_0xcf3c('0x7')]=FreshsalesAccount; \ No newline at end of file diff --git a/server/services/ami/model/queueReport.js b/server/services/ami/model/queueReport.js new file mode 100644 index 0000000..a8b8856 --- /dev/null +++ b/server/services/ami/model/queueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe7e2=['type','calleridname','queue','queuecallerjoinAt','queuecallerabandonAt','queuecallercompleteAt','queuecallerexitAt','originalposition','connectedlinenum','accountcode','context','exten','priority','motionChannel','voice','mohtime','variables','exports'];(function(_0x4f7c42,_0x28a695){var _0x5da7de=function(_0x4b10e4){while(--_0x4b10e4){_0x4f7c42['push'](_0x4f7c42['shift']());}};_0x5da7de(++_0x28a695);}(_0xe7e2,0xa2));var _0x2e7e=function(_0x3e3e86,_0x4f6b0a){_0x3e3e86=_0x3e3e86-0x0;var _0x4da863=_0xe7e2[_0x3e3e86];return _0x4da863;};'use strict';function QueueReport(){this[_0x2e7e('0x0')]='inbound';this['uniqueid']='';this['calleridnum']='';this[_0x2e7e('0x1')]='';this[_0x2e7e('0x2')]='';this[_0x2e7e('0x3')]=null;this['queuecallerleaveAt']=null;this['position']=0x1;this['count']=0x1;this['queuecallerabandon']=![];this[_0x2e7e('0x4')]=null;this['queuecallercomplete']=![];this[_0x2e7e('0x5')]=null;this['queuecallerexit']=![];this[_0x2e7e('0x6')]=null;this[_0x2e7e('0x7')]=0x1;this['channel']='';this[_0x2e7e('0x8')]='';this['connectedlinename']='';this[_0x2e7e('0x9')]='';this[_0x2e7e('0xa')]='';this[_0x2e7e('0xb')]='';this[_0x2e7e('0xc')]='';this['holdtime']=0x0;this['assigned']=![];this['lastAssignedTo']='';this[_0x2e7e('0xd')]=_0x2e7e('0xe');this['routealias']=null;this[_0x2e7e('0xf')]=0x0;this[_0x2e7e('0x10')]={};}module[_0x2e7e('0x11')]=QueueReport; \ No newline at end of file diff --git a/server/services/ami/model/salesforceAccount.js b/server/services/ami/model/salesforceAccount.js new file mode 100644 index 0000000..91eeeca --- /dev/null +++ b/server/services/ami/model/salesforceAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x4469=['Configurations','exports','name','username','remoteUri','password','clientId','clientSecret','securityToken','type','integrationTab','serverUrl'];(function(_0x28947d,_0x4cc9c6){var _0x12d2ee=function(_0x3f38fc){while(--_0x3f38fc){_0x28947d['push'](_0x28947d['shift']());}};_0x12d2ee(++_0x4cc9c6);}(_0x4469,0xb6));var _0x9446=function(_0x3016d3,_0x2ff811){_0x3016d3=_0x3016d3-0x0;var _0xb6f505=_0x4469[_0x3016d3];return _0xb6f505;};'use strict';function SalesforceAccount(_0x31b9e1){this['id']=_0x31b9e1['id']||0x0;this[_0x9446('0x0')]=_0x31b9e1['name']||'';this[_0x9446('0x1')]=_0x31b9e1[_0x9446('0x1')]||'';this[_0x9446('0x2')]=_0x31b9e1[_0x9446('0x2')]||'';this[_0x9446('0x3')]=_0x31b9e1['password']||'';this[_0x9446('0x4')]=_0x31b9e1['clientId']||'';this[_0x9446('0x5')]=_0x31b9e1[_0x9446('0x5')]||'';this[_0x9446('0x6')]=_0x31b9e1[_0x9446('0x6')]||'';this[_0x9446('0x7')]=_0x31b9e1[_0x9446('0x7')]||_0x9446('0x8');this[_0x9446('0x9')]=_0x31b9e1[_0x9446('0x9')]||'';this[_0x9446('0xa')]=_0x31b9e1['Configurations']||{};}module[_0x9446('0xb')]=SalesforceAccount; \ No newline at end of file diff --git a/server/services/ami/model/servicenowAccount.js b/server/services/ami/model/servicenowAccount.js new file mode 100644 index 0000000..9d760e1 --- /dev/null +++ b/server/services/ami/model/servicenowAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x007b=['name','username','password','remoteUri','serverUrl','Configurations','exports'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x007b,0x13b));var _0xb007=function(_0x2465ed,_0x54d08b){_0x2465ed=_0x2465ed-0x0;var _0x1654d3=_0x007b[_0x2465ed];return _0x1654d3;};'use strict';function ServicenowAccount(_0xa000b4){this['id']=_0xa000b4['id']||0x0;this[_0xb007('0x0')]=_0xa000b4['name']||'';this['username']=_0xa000b4[_0xb007('0x1')]||'';this[_0xb007('0x2')]=_0xa000b4[_0xb007('0x2')]||'';this[_0xb007('0x3')]=_0xa000b4[_0xb007('0x3')]||'';this[_0xb007('0x4')]=_0xa000b4[_0xb007('0x4')]||'';this[_0xb007('0x5')]=_0xa000b4[_0xb007('0x5')]||{};}module[_0xb007('0x6')]=ServicenowAccount; \ No newline at end of file diff --git a/server/services/ami/model/sugarcrmAccount.js b/server/services/ami/model/sugarcrmAccount.js new file mode 100644 index 0000000..42aa24c --- /dev/null +++ b/server/services/ami/model/sugarcrmAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdb8d=['Configurations','exports','name','username','password','remoteUri','serverUrl'];(function(_0xaade6a,_0xd15afd){var _0x4f9ce1=function(_0x269ce6){while(--_0x269ce6){_0xaade6a['push'](_0xaade6a['shift']());}};_0x4f9ce1(++_0xd15afd);}(_0xdb8d,0x128));var _0xddb8=function(_0x1c1f3e,_0x665593){_0x1c1f3e=_0x1c1f3e-0x0;var _0x325903=_0xdb8d[_0x1c1f3e];return _0x325903;};'use strict';function SugarcrmAccount(_0xfd8fe1){this['id']=_0xfd8fe1['id']||0x0;this[_0xddb8('0x0')]=_0xfd8fe1[_0xddb8('0x0')]||'';this[_0xddb8('0x1')]=_0xfd8fe1[_0xddb8('0x1')]||'';this[_0xddb8('0x2')]=_0xfd8fe1[_0xddb8('0x2')]||'';this[_0xddb8('0x3')]=_0xfd8fe1[_0xddb8('0x3')]||'';this[_0xddb8('0x4')]=_0xfd8fe1[_0xddb8('0x4')]||'';this[_0xddb8('0x5')]=_0xfd8fe1[_0xddb8('0x5')]||{};}module[_0xddb8('0x6')]=SugarcrmAccount; \ No newline at end of file diff --git a/server/services/ami/model/telephone.js b/server/services/ami/model/telephone.js new file mode 100644 index 0000000..51ba11c --- /dev/null +++ b/server/services/ami/model/telephone.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xf29f=['exports','name','accountcode','state','unknown','status'];(function(_0x1bab46,_0x4cfb6d){var _0x12fb36=function(_0x4fb6ed){while(--_0x4fb6ed){_0x1bab46['push'](_0x1bab46['shift']());}};_0x12fb36(++_0x4cfb6d);}(_0xf29f,0x18d));var _0xff29=function(_0x3ad166,_0x4d06dc){_0x3ad166=_0x3ad166-0x0;var _0x384d22=_0xf29f[_0x3ad166];return _0x384d22;};'use strict';function Telephone(_0xb467ef){this['id']=_0xb467ef['id']||0x0;this[_0xff29('0x0')]=_0xb467ef[_0xff29('0x0')]||'';this[_0xff29('0x1')]=_0xb467ef['accountcode']||'';this[_0xff29('0x2')]=_0xff29('0x3');this['stateTime']=0x0;this[_0xff29('0x4')]=_0xff29('0x3');this['address']='';}module[_0xff29('0x5')]=Telephone; \ No newline at end of file diff --git a/server/services/ami/model/template.js b/server/services/ami/model/template.js new file mode 100644 index 0000000..bff255c --- /dev/null +++ b/server/services/ami/model/template.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['exports','name'];(function(_0x46d008,_0x553fed){var _0x4b1f5d=function(_0x363e08){while(--_0x363e08){_0x46d008['push'](_0x46d008['shift']());}};_0x4b1f5d(++_0x553fed);}(_0xa9e0,0x123));var _0x0a9e=function(_0x9df060,_0x253d33){_0x9df060=_0x9df060-0x0;var _0x338dfe=_0xa9e0[_0x9df060];return _0x338dfe;};'use strict';function template(_0x1f0015){this['id']=_0x1f0015['id']||0x0;this[_0x0a9e('0x0')]=_0x1f0015[_0x0a9e('0x0')]||'';this['html']=_0x1f0015['html']||'';}module[_0x0a9e('0x1')]=template; \ No newline at end of file diff --git a/server/services/ami/model/trigger.js b/server/services/ami/model/trigger.js new file mode 100644 index 0000000..3ecf76d --- /dev/null +++ b/server/services/ami/model/trigger.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda2d=['channel','voice','AllConditions','AnyConditions','Actions','exports','name'];(function(_0x4d66d5,_0x366a6c){var _0x27edd8=function(_0xcf6a40){while(--_0xcf6a40){_0x4d66d5['push'](_0x4d66d5['shift']());}};_0x27edd8(++_0x366a6c);}(_0xda2d,0x102));var _0xdda2=function(_0x18bc5b,_0x13cab6){_0x18bc5b=_0x18bc5b-0x0;var _0x290f86=_0xda2d[_0x18bc5b];return _0x290f86;};'use strict';function Trigger(_0x2625ed){this['id']=_0x2625ed['id']||0x0;this[_0xdda2('0x0')]=_0x2625ed[_0xdda2('0x0')]||'';this[_0xdda2('0x1')]=_0x2625ed[_0xdda2('0x1')]||_0xdda2('0x2');this['status']=_0x2625ed['status']||![];this['AllConditions']=_0x2625ed[_0xdda2('0x3')]||[];this[_0xdda2('0x4')]=_0x2625ed[_0xdda2('0x4')]||[];this[_0xdda2('0x5')]=_0x2625ed[_0xdda2('0x5')]||[];}module[_0xdda2('0x6')]=Trigger; \ No newline at end of file diff --git a/server/services/ami/model/trunk.js b/server/services/ami/model/trunk.js new file mode 100644 index 0000000..5cae107 --- /dev/null +++ b/server/services/ami/model/trunk.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7b64=['unknown','stateTime','status','registry','domain','domainport','refresh','stateRegistry','registrationtime','defaultuser','exports','active','name','state'];(function(_0x5b27da,_0x4a6532){var _0x3254f4=function(_0x4194c6){while(--_0x4194c6){_0x5b27da['push'](_0x5b27da['shift']());}};_0x3254f4(++_0x4a6532);}(_0x7b64,0x107));var _0x47b6=function(_0x537013,_0x5c6c65){_0x537013=_0x537013-0x0;var _0x1c7c94=_0x7b64[_0x537013];return _0x1c7c94;};'use strict';function Trunk(_0x210b90){this['id']=_0x210b90['id']||0x0;this['active']=_0x210b90[_0x47b6('0x0')]||![];this[_0x47b6('0x1')]=_0x210b90[_0x47b6('0x1')]||'';this[_0x47b6('0x2')]=_0x47b6('0x3');this[_0x47b6('0x4')]=0x0;this[_0x47b6('0x5')]=_0x47b6('0x3');this[_0x47b6('0x6')]=_0x210b90[_0x47b6('0x6')]&&_0x210b90[_0x47b6('0x6')]['indexOf'](':')?_0x210b90['registry']['split'](':')[0x0]:'';this['host']='';this['port']='';this[_0x47b6('0x7')]='';this[_0x47b6('0x8')]='';this[_0x47b6('0x9')]='';this[_0x47b6('0xa')]=_0x47b6('0x3');this[_0x47b6('0xb')]='';this['address']='';this[_0x47b6('0xc')]=_0x210b90['defaultuser']||'';}module[_0x47b6('0xd')]=Trunk; \ No newline at end of file diff --git a/server/services/ami/model/voiceExtension.js b/server/services/ami/model/voiceExtension.js new file mode 100644 index 0000000..c85582f --- /dev/null +++ b/server/services/ami/model/voiceExtension.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xda42=['mandatoryDisposition','exports','exten','recordingFormat','none'];(function(_0x22ef56,_0x57ebb7){var _0x1d3c5a=function(_0x2a36da){while(--_0x2a36da){_0x22ef56['push'](_0x22ef56['shift']());}};_0x1d3c5a(++_0x57ebb7);}(_0xda42,0x1a6));var _0x2da4=function(_0x309d86,_0x827499){_0x309d86=_0x309d86-0x0;var _0xe326be=_0xda42[_0x309d86];return _0xe326be;};'use strict';function voiceExtension(_0x5ef6d1){this['id']=_0x5ef6d1['id']||0x0;this[_0x2da4('0x0')]=_0x5ef6d1['exten']||'';this[_0x2da4('0x1')]=_0x5ef6d1[_0x2da4('0x1')]||_0x2da4('0x2');this['mandatoryDisposition']=_0x5ef6d1[_0x2da4('0x3')]||![];}module[_0x2da4('0x4')]=voiceExtension; \ No newline at end of file diff --git a/server/services/ami/model/voiceQueue.js b/server/services/ami/model/voiceQueue.js new file mode 100644 index 0000000..c7c2edf --- /dev/null +++ b/server/services/ami/model/voiceQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x37b2=['dialQueueProject2','dialAgiAfterHangupClient','dialAgiAfterHangupAgent','mandatoryDisposition','mandatoryDispositionPause','queueSummaryCountersUpdated','wav49','gsm','fewestcalls','linear','random','ringall','rrmemory','rrordered','wrandom','name','monitor_format','type','inbound','total','sumHoldTime','unmanaged','abandoned','available','loggedIn','notInUse','onHold','ringing','ringInUse','talking','unavailable','acw','acwTimeout','autopause','sendMessageOneNotActive','message','statusMessage','dialTimezone','dialGlobalInterval','dialActive','dialMethod','dialLimitChannel','dialLimitQueue','dialPowerLevel','dialPredictiveOptimization','dialPredictiveOptimizationPercentage','dialPredictiveInterval','dialOriginateCallerIdName','anonymous','dialOriginateCallerIdNumber','dialOriginateTimeout','dialQueueOptions','dialQueueTimeout','dialQueueProject','dialCongestionMaxRetry','dialCongestionRetryFrequency','dialBusyMaxRetry','dialBusyRetryFrequency','dialNoAnswerMaxRetry','dialNoSuchNumberMaxRetry','dialNoSuchNumberRetryFrequency','dialDropMaxRetry','dialDropRetryFrequency','dialAbandonedMaxRetry','dialAbandonedRetryFrequency','dialMachineMaxRetry','dialMachineRetryFrequency','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','Trunk','TrunkBackup','dialPrefix','Interval','dialOrderByScheduledAt','DESC','dialRandomLastDigitCallerIdNumber','dialCutDigit','strategy','queueStatusComplete','dialAMDActive','dialAMDInitialSilence','dialAMDGreeting','dialAMDTotalAnalysisTime','dialAMDMinWordLength','dialAMDBetweenWordsSilence','dialAMDMaximumNumberOfWords','dialAMDSilenceThreshold','dialAMDMaximumWordLength','pTalking','timeout','outboundAnswerCallsDay','outboundAnswerAgiCallsDay','outboundNoAnswerCallsDay','outboundCongestionCallsDay','outboundNoSuchCallsDay','outboundBlacklistCallsDay','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundDropCallsDayACS','outboundReCallsDay','outboundAbandonedDay','startProgressive','startPredictive','handlePredictive','predictiveIntervalMultiplicativeFactor','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvailable','predictiveIntervalMaxThreshold','dialPredictiveIntervalMaxThreshold','predictiveIntervalMinThreshold','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','erlangAbandonmentRate','erlangBusyFactor','dialRecallMeTimeout','dialRecallInQueue','dialPreviewAutoRecallMe','dialPreviewRecallmeReminder'];(function(_0x13d07a,_0x41efc3){var _0x5ee0ee=function(_0x4ca94a){while(--_0x4ca94a){_0x13d07a['push'](_0x13d07a['shift']());}};_0x5ee0ee(++_0x41efc3);}(_0x37b2,0xf8));var _0x237b=function(_0x422a51,_0x1782d8){_0x422a51=_0x422a51-0x0;var _0x250b2a=_0x37b2[_0x422a51];return _0x250b2a;};'use strict';var monitorFormat={'wav':'wav','wav49':_0x237b('0x0'),'gsm':_0x237b('0x1')};var strategy={'fewestcalls':_0x237b('0x2'),'leastrecent':'leastrecent','linear':_0x237b('0x3'),'random':_0x237b('0x4'),'ringall':_0x237b('0x5'),'rr':'roundrobin','rrmemory':_0x237b('0x6'),'rrordered':_0x237b('0x7'),'wrandom':_0x237b('0x8')};function VoiceQueue(_0x5a3d8e){this['id']=_0x5a3d8e['id']||0x0;this[_0x237b('0x9')]=_0x5a3d8e[_0x237b('0x9')]||'';this['monitor_format']=_0x5a3d8e[_0x237b('0xa')]||'';this[_0x237b('0xb')]=_0x5a3d8e[_0x237b('0xb')]||_0x237b('0xc');this['waiting']=0x0;this[_0x237b('0xd')]=0x0;this['answered']=0x0;this['sumDuration']=0x0;this[_0x237b('0xe')]=0x0;this['sumBillable']=0x0;this[_0x237b('0xf')]=0x0;this[_0x237b('0x10')]=0x0;this[_0x237b('0x11')]=0x0;this['busy']=0x0;this['inUse']=0x0;this['invalid']=0x0;this[_0x237b('0x12')]=0x0;this[_0x237b('0x13')]=0x0;this[_0x237b('0x14')]=0x0;this['paused']=0x0;this[_0x237b('0x15')]=0x0;this[_0x237b('0x16')]=0x0;this[_0x237b('0x17')]=0x0;this[_0x237b('0x18')]=0x0;this['unknown']=0x0;this[_0x237b('0x19')]=_0x5a3d8e[_0x237b('0x19')]||![];this[_0x237b('0x1a')]=_0x5a3d8e[_0x237b('0x1a')]||0xa;this[_0x237b('0x1b')]=_0x5a3d8e[_0x237b('0x1b')]||'no';this[_0x237b('0x1c')]=!![];this[_0x237b('0x1d')]='';this[_0x237b('0x1e')]='';this['originated']=0x0;this['temp']=0x0;this[_0x237b('0x1f')]=_0x5a3d8e[_0x237b('0x1f')]||null;this['dialGlobalInterval']=_0x5a3d8e[_0x237b('0x20')]?_0x5a3d8e['dialGlobalInterval']:null;this[_0x237b('0x21')]=_0x5a3d8e['dialActive'];this[_0x237b('0x22')]=_0x5a3d8e[_0x237b('0x22')]||'progressive';this[_0x237b('0x23')]=_0x5a3d8e[_0x237b('0x23')]||0x0;this[_0x237b('0x24')]=_0x5a3d8e[_0x237b('0x24')]||0x0;this[_0x237b('0x25')]=_0x5a3d8e[_0x237b('0x25')]||0x1;this[_0x237b('0x26')]=_0x5a3d8e[_0x237b('0x26')]||'dropRate';this[_0x237b('0x27')]=_0x5a3d8e['dialPredictiveOptimizationPercentage']||0.03;this[_0x237b('0x28')]=_0x5a3d8e[_0x237b('0x28')]||0x258;this['dialOriginateCallerIdName']=_0x5a3d8e[_0x237b('0x29')]||_0x237b('0x2a');this['dialOriginateCallerIdNumber']=_0x5a3d8e[_0x237b('0x2b')]||_0x237b('0x2a');this[_0x237b('0x2c')]=_0x5a3d8e[_0x237b('0x2c')]||0x1e;this['dialQueueOptions']=_0x5a3d8e[_0x237b('0x2d')]||'tTxX';this[_0x237b('0x2e')]=_0x5a3d8e[_0x237b('0x2e')]||0x3;this[_0x237b('0x2f')]=_0x5a3d8e[_0x237b('0x2f')]||undefined;this[_0x237b('0x30')]=_0x5a3d8e[_0x237b('0x30')]||0x3;this[_0x237b('0x31')]=_0x5a3d8e[_0x237b('0x31')]||0x96;this[_0x237b('0x32')]=_0x5a3d8e['dialBusyMaxRetry']||0x3;this[_0x237b('0x33')]=_0x5a3d8e[_0x237b('0x33')]||0x96;this[_0x237b('0x34')]=_0x5a3d8e[_0x237b('0x34')]||0x3;this['dialNoAnswerRetryFrequency']=_0x5a3d8e['dialNoAnswerRetryFrequency']||0x96;this[_0x237b('0x35')]=_0x5a3d8e[_0x237b('0x35')]||0x3;this[_0x237b('0x36')]=_0x5a3d8e[_0x237b('0x36')]||0x96;this['dialDropMaxRetry']=_0x5a3d8e[_0x237b('0x37')]||0x3;this['dialDropRetryFrequency']=_0x5a3d8e[_0x237b('0x38')]||0x96;this[_0x237b('0x39')]=_0x5a3d8e['dialAbandonedMaxRetry']||0x3;this[_0x237b('0x3a')]=_0x5a3d8e[_0x237b('0x3a')]||0x96;this[_0x237b('0x3b')]=_0x5a3d8e[_0x237b('0x3b')]||0x3;this[_0x237b('0x3c')]=_0x5a3d8e[_0x237b('0x3c')]||0x96;this['dialAgentRejectMaxRetry']=_0x5a3d8e[_0x237b('0x3d')]||0x3;this[_0x237b('0x3e')]=_0x5a3d8e['dialAgentRejectRetryFrequency']||0x96;this[_0x237b('0x3f')]=_0x5a3d8e[_0x237b('0x3f')]||0x3;this['dialGlobalMaxRetry']=_0x5a3d8e[_0x237b('0x40')]||0x4;this['Trunk']=_0x5a3d8e[_0x237b('0x41')]?_0x5a3d8e[_0x237b('0x41')]:undefined;this[_0x237b('0x42')]=_0x5a3d8e[_0x237b('0x42')]?_0x5a3d8e[_0x237b('0x42')]:undefined;this[_0x237b('0x43')]=_0x5a3d8e[_0x237b('0x43')]||undefined;this[_0x237b('0x44')]=_0x5a3d8e[_0x237b('0x44')]?_0x5a3d8e[_0x237b('0x44')]:undefined;this[_0x237b('0x45')]=_0x5a3d8e[_0x237b('0x45')]||_0x237b('0x46');this[_0x237b('0x47')]=_0x5a3d8e[_0x237b('0x47')]||undefined;this['dialCutDigit']=_0x5a3d8e[_0x237b('0x48')]||undefined;this[_0x237b('0x49')]=strategy[_0x5a3d8e[_0x237b('0x49')]];this[_0x237b('0x4a')]=!![];this[_0x237b('0x4b')]=_0x5a3d8e[_0x237b('0x4b')]||![];this[_0x237b('0x4c')]=_0x5a3d8e[_0x237b('0x4c')];this[_0x237b('0x4d')]=_0x5a3d8e[_0x237b('0x4d')];this['dialAMDAfterGreetingSilence']=_0x5a3d8e['dialAMDAfterGreetingSilence'];this[_0x237b('0x4e')]=_0x5a3d8e[_0x237b('0x4e')];this['dialAMDMinWordLength']=_0x5a3d8e[_0x237b('0x4f')];this['dialAMDBetweenWordsSilence']=_0x5a3d8e[_0x237b('0x50')];this[_0x237b('0x51')]=_0x5a3d8e[_0x237b('0x51')];this['dialAMDSilenceThreshold']=_0x5a3d8e[_0x237b('0x52')];this[_0x237b('0x53')]=_0x5a3d8e[_0x237b('0x53')];this['outboundRejectCallsDay']=0x0;this[_0x237b('0x54')]=0x0;this[_0x237b('0x55')]=_0x5a3d8e[_0x237b('0x55')];this[_0x237b('0x56')]=0x0;this[_0x237b('0x57')]=0x0;this[_0x237b('0x58')]=0x0;this['outboundBusyCallsDay']=0x0;this[_0x237b('0x59')]=0x0;this[_0x237b('0x5a')]=0x0;this['outboundUnknownCallsDay']=0x0;this[_0x237b('0x5b')]=0x0;this['outboundOriginateFailureCallsDay']=0x0;this[_0x237b('0x5c')]=0x0;this[_0x237b('0x5d')]=0x0;this[_0x237b('0x5e')]=0x0;this[_0x237b('0x5f')]=0x0;this[_0x237b('0x60')]=0x0;this[_0x237b('0x61')]=undefined;this[_0x237b('0x62')]=undefined;this[_0x237b('0x63')]=undefined;this[_0x237b('0x64')]=1.05;this['predictiveIntervalTotalCalls']=0x0;this[_0x237b('0x65')]=0x0;this['predictiveIntervalDroppedCallsCallersExit']=0x0;this['predictiveIntervalDroppedCallsTimeout']=0x0;this[_0x237b('0x66')]=0x0;this['predictiveIntervalAvgTalktime']=0x0;this['predictiveIntervalPauses']=0x0;this[_0x237b('0x67')]=0x0;this[_0x237b('0x68')]=_0x5a3d8e[_0x237b('0x69')]||0x14;this[_0x237b('0x6a')]=_0x5a3d8e[_0x237b('0x69')]||0xa;this['predictiveIntervalErlangCalls']=0x0;this[_0x237b('0x6b')]=0x0;this[_0x237b('0x6c')]=0x1;this['erlangCalls']=0x0;this['erlangCallToSecond']=0x0;this[_0x237b('0x6d')]=0x0;this[_0x237b('0x6e')]=0x0;this['dialRecallMeTimeout']=_0x5a3d8e[_0x237b('0x6f')]||0x1e;this[_0x237b('0x70')]=_0x5a3d8e[_0x237b('0x70')]||![];this[_0x237b('0x71')]=!!_0x5a3d8e[_0x237b('0x71')]||![];this['dialPreviewRecallmeReminder']=!!_0x5a3d8e[_0x237b('0x72')]||![];this['dialQueueProject2']=_0x5a3d8e[_0x237b('0x73')]||undefined;this[_0x237b('0x74')]=_0x5a3d8e[_0x237b('0x74')]||![];this[_0x237b('0x75')]=_0x5a3d8e[_0x237b('0x75')]||![];this['monitor_format']=monitorFormat[_0x5a3d8e[_0x237b('0xa')]]?monitorFormat[_0x5a3d8e[_0x237b('0xa')]]:undefined;this[_0x237b('0x76')]=_0x5a3d8e['mandatoryDisposition']||![];this['mandatoryDispositionPause']=_0x5a3d8e['mandatoryDispositionPause']?_0x5a3d8e[_0x237b('0x77')]:undefined;this[_0x237b('0x78')]=![];}module['exports']=VoiceQueue; \ No newline at end of file diff --git a/server/services/ami/model/voiceQueueSummary.js b/server/services/ami/model/voiceQueueSummary.js new file mode 100644 index 0000000..bf89a1e --- /dev/null +++ b/server/services/ami/model/voiceQueueSummary.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe105=['notInUse','paused','ringing','ringInUse','sumBillable','sumHoldTime','type','unavailable','unknown','unmanaged','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','message','statusMessage','Trunk','active','callerid','prototype','createReport','loggedin','callers','length','online','incall','includes','status','booked','keys','queue','exten','xcally-motion-preview','compareToOutboundQueue','updateReportFromOutboundQueue','preview','exports','available','talking','waiting','answered','loggedIn','loggedInDb','outboundAbandonedCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','pTalking','sumDuration','total','name','strategy','abandoned','busy','inUse','invalid','onHold'];(function(_0x4fe4ed,_0x5c9ab3){var _0x3e79d4=function(_0x2224e3){while(--_0x2224e3){_0x4fe4ed['push'](_0x4fe4ed['shift']());}};_0x3e79d4(++_0x5c9ab3);}(_0xe105,0xef));var _0x5e10=function(_0x4b48d4,_0x5c5a05){_0x4b48d4=_0x4b48d4-0x0;var _0x517b1b=_0xe105[_0x4b48d4];return _0x517b1b;};'use strict';var INBOUND_COUNTERS=[_0x5e10('0x0'),'loggedIn','loggedInDb','paused','ringing',_0x5e10('0x1'),_0x5e10('0x2')];var OUTBOUND_COUNTERS=[_0x5e10('0x0'),_0x5e10('0x3'),'inUse',_0x5e10('0x4'),_0x5e10('0x5'),'originated',_0x5e10('0x6'),'outboundAnswerCallsDay','outboundBlacklistCallsDay',_0x5e10('0x7'),_0x5e10('0x8'),'outboundNoAnswerCallsDay','outboundNoSuchCallsDay',_0x5e10('0x9'),_0x5e10('0xa'),_0x5e10('0xb'),'paused',_0x5e10('0xc'),_0x5e10('0x1'),'sumBillable',_0x5e10('0xd'),_0x5e10('0xe'),_0x5e10('0x2')];function VoiceQueueSummary(_0x2323a7){this['id']=_0x2323a7['id'];this['name']=_0x2323a7[_0x5e10('0xf')];this['strategy']=_0x2323a7[_0x5e10('0x10')];this[_0x5e10('0x11')]=_0x2323a7[_0x5e10('0x11')]||0x0;this[_0x5e10('0x3')]=_0x2323a7[_0x5e10('0x3')]||0x0;this[_0x5e10('0x0')]=_0x2323a7[_0x5e10('0x0')]||0x0;this['busy']=_0x2323a7[_0x5e10('0x12')]||0x0;this[_0x5e10('0x13')]=_0x2323a7[_0x5e10('0x13')]||0x0;this[_0x5e10('0x14')]=_0x2323a7[_0x5e10('0x14')]||0x0;this['loggedIn']=_0x2323a7[_0x5e10('0x4')]||0x0;this[_0x5e10('0x5')]=_0x2323a7[_0x5e10('0x5')]||0x0;this[_0x5e10('0x15')]=_0x2323a7[_0x5e10('0x15')]||0x0;this[_0x5e10('0x16')]=_0x2323a7[_0x5e10('0x16')]||0x0;this['paused']=_0x2323a7[_0x5e10('0x17')]||0x0;this['ringing']=_0x2323a7[_0x5e10('0x18')]||0x0;this[_0x5e10('0x19')]=_0x2323a7[_0x5e10('0x19')];this['sumBillable']=_0x2323a7[_0x5e10('0x1a')];this[_0x5e10('0xd')]=_0x2323a7[_0x5e10('0xd')];this[_0x5e10('0x1b')]=_0x2323a7[_0x5e10('0x1b')]||0x0;this[_0x5e10('0x1')]=_0x2323a7[_0x5e10('0x1')]||0x0;this[_0x5e10('0xe')]=_0x2323a7[_0x5e10('0xe')]||0x0;this[_0x5e10('0x1c')]=_0x2323a7['type'];this['unavailable']=_0x2323a7[_0x5e10('0x1d')]||0x0;this['unknown']=_0x2323a7[_0x5e10('0x1e')]||0x0;this[_0x5e10('0x1f')]=_0x2323a7[_0x5e10('0x1f')]||0x0;this[_0x5e10('0x2')]=_0x2323a7[_0x5e10('0x2')]||0x0;if(_0x2323a7[_0x5e10('0x1c')]==='outbound'){this['pTalking']=_0x2323a7[_0x5e10('0xc')]||0x0;this['dialActive']=_0x2323a7[_0x5e10('0x20')];this[_0x5e10('0x21')]=_0x2323a7[_0x5e10('0x21')];this[_0x5e10('0x22')]=_0x2323a7[_0x5e10('0x22')];this['dialOriginateCallerIdNumber']=_0x2323a7['dialOriginateCallerIdNumber'];this[_0x5e10('0x23')]=_0x2323a7[_0x5e10('0x23')];this[_0x5e10('0x24')]=_0x2323a7[_0x5e10('0x24')];this[_0x5e10('0x25')]=_0x2323a7[_0x5e10('0x25')];this[_0x5e10('0x26')]=_0x2323a7[_0x5e10('0x26')];this[_0x5e10('0x27')]=_0x2323a7[_0x5e10('0x27')];this[_0x5e10('0x28')]=_0x2323a7[_0x5e10('0x28')];this[_0x5e10('0x7')]=_0x2323a7[_0x5e10('0x7')];this[_0x5e10('0x8')]=_0x2323a7[_0x5e10('0x8')];this['outboundDropCallsDayACS']=_0x2323a7[_0x5e10('0x29')];this[_0x5e10('0x2a')]=_0x2323a7[_0x5e10('0x2a')];this[_0x5e10('0x2b')]=_0x2323a7['outboundDropCallsDayTimeout'];this[_0x5e10('0x2c')]=_0x2323a7[_0x5e10('0x2c')];this['outboundNoSuchCallsDay']=_0x2323a7[_0x5e10('0x2d')];this['outboundOriginateFailureCallsDay']=_0x2323a7['outboundOriginateFailureCallsDay'];this['outboundReCallsDay']=_0x2323a7[_0x5e10('0x9')];this[_0x5e10('0xa')]=_0x2323a7[_0x5e10('0xa')];this[_0x5e10('0xb')]=_0x2323a7[_0x5e10('0xb')];this[_0x5e10('0x2e')]=_0x2323a7[_0x5e10('0x2e')];this['predictiveIntervalAvgHoldtime']=_0x2323a7[_0x5e10('0x2f')];this[_0x5e10('0x30')]=_0x2323a7['predictiveIntervalAvgTalktime'];this[_0x5e10('0x31')]=_0x2323a7['predictiveIntervalDroppedCallsCallersExit'];this[_0x5e10('0x32')]=_0x2323a7[_0x5e10('0x32')];this[_0x5e10('0x33')]=_0x2323a7[_0x5e10('0x33')];this[_0x5e10('0x34')]=_0x2323a7[_0x5e10('0x34')];this['predictiveIntervalHitRate']=_0x2323a7['predictiveIntervalHitRate'];this['predictiveIntervalMultiplicativeFactor']=_0x2323a7[_0x5e10('0x35')];this['predictiveIntervalPauses']=_0x2323a7[_0x5e10('0x36')];this[_0x5e10('0x37')]=_0x2323a7['predictiveIntervalAvailable'];this[_0x5e10('0x38')]=_0x2323a7[_0x5e10('0x38')];this['originated']=_0x2323a7[_0x5e10('0x39')];this[_0x5e10('0x3a')]=_0x2323a7['erlangCalls'];this[_0x5e10('0x3b')]=_0x2323a7['erlangCallToSecond'];this[_0x5e10('0x3c')]=_0x2323a7[_0x5e10('0x3c')];this[_0x5e10('0x3d')]=_0x2323a7[_0x5e10('0x3d')];this[_0x5e10('0x3e')]=_0x2323a7[_0x5e10('0x3e')];this[_0x5e10('0x3f')]=_0x2323a7['startProgressive'];this[_0x5e10('0x40')]=_0x2323a7[_0x5e10('0x40')];this[_0x5e10('0x41')]=_0x2323a7[_0x5e10('0x41')];}if(_0x2323a7[_0x5e10('0x42')]){this[_0x5e10('0x42')]={'id':_0x2323a7['Trunk']['id'],'name':_0x2323a7[_0x5e10('0x42')][_0x5e10('0xf')],'active':_0x2323a7['Trunk'][_0x5e10('0x43')],'callerid':_0x2323a7[_0x5e10('0x42')][_0x5e10('0x44')]};}}VoiceQueueSummary[_0x5e10('0x45')][_0x5e10('0x46')]=function(_0x5c1813,_0x330fc4,_0x6d22da,_0xc1e52){this['loggedInDb']=0x0;this[_0x5e10('0x1')]=0x0;this[_0x5e10('0x17')]=0x0;this[_0x5e10('0x1e')]=0x0;this[_0x5e10('0x16')]=0x0;this[_0x5e10('0x13')]=0x0;this[_0x5e10('0x12')]=0x0;this[_0x5e10('0x14')]=0x0;this['unavailable']=0x0;this[_0x5e10('0x18')]=0x0;this['ringInUse']=0x0;this['onHold']=0x0;if(_0x6d22da){if(_0x6d22da['available']){this[_0x5e10('0x0')]=Number(_0x6d22da[_0x5e10('0x0')]);}if(_0x6d22da['loggedin']){this[_0x5e10('0x4')]=Number(_0x6d22da[_0x5e10('0x47')]);}if(_0x6d22da[_0x5e10('0x48')]){this[_0x5e10('0x2')]=Number(_0x6d22da[_0x5e10('0x48')]);}}for(var _0x1c363b=0x0;_0x1c363b<_0x5c1813[_0x5e10('0x49')];_0x1c363b++){var _0x12d291=_0x330fc4['SIP/'+_0x5c1813[_0x1c363b]['name']];if(_0x12d291&&_0x12d291[_0x5e10('0x4a')]){this[_0x5e10('0x5')]+=0x1;}if(_0x5c1813[_0x1c363b][_0x5e10('0x4b')]==='1'){this['talking']+=0x1;}if(_0x5c1813[_0x1c363b][_0x5e10('0x17')]==='1'&&!['2','7','8'][_0x5e10('0x4c')](_0x5c1813[_0x1c363b][_0x5e10('0x4d')])){this[_0x5e10('0x17')]+=0x1;}switch(_0x5c1813[_0x1c363b][_0x5e10('0x4d')]){case'0':this['unknown']+=0x1;break;case'1':this[_0x5e10('0x16')]+=0x1;break;case'2':this[_0x5e10('0x13')]+=0x1;break;case'3':this['busy']+=0x1;break;case'4':this['invalid']+=0x1;break;case'5':this[_0x5e10('0x1d')]+=0x1;break;case'6':this[_0x5e10('0x18')]+=0x1;break;case'7':this[_0x5e10('0x19')]+=0x1;break;case'8':this[_0x5e10('0x15')]+=0x1;break;}}if(this[_0x5e10('0x21')]===_0x5e10('0x4e')){var _0x5562bc=Object[_0x5e10('0x4f')](_0xc1e52);for(var _0x4ebdfb=0x0;_0x4ebdfb<_0x5562bc[_0x5e10('0x49')];_0x4ebdfb++){var _0x5290d1=_0x5562bc[_0x4ebdfb];var _0x3bc07a=_0xc1e52[_0x5290d1];if(_0x3bc07a[_0x5e10('0x50')]===this[_0x5e10('0xf')]&&_0x3bc07a[_0x5e10('0x1c')]==='dialer'&&_0x3bc07a[_0x5e10('0x51')]===_0x5e10('0x52')){this[_0x5e10('0x1')]+=0x1;}}if(this[_0x5e10('0x1')]>this[_0x5e10('0x13')]){this[_0x5e10('0x1')]=this[_0x5e10('0x13')];}this[_0x5e10('0xc')]=0x0;}return this;};VoiceQueueSummary[_0x5e10('0x45')]['compareToInboundQueue']=function(_0x59544b){var _0x1f3e91=![];if(_0x59544b){_0x1f3e91=INBOUND_COUNTERS['some'](function(_0x259b54){return this[_0x259b54]!==_0x59544b[_0x259b54];},this);}return _0x1f3e91;};VoiceQueueSummary[_0x5e10('0x45')][_0x5e10('0x53')]=function(_0x2fa8f0){var _0x330f29=![];var _0x14a37b=![];var _0x20d45c=![];if(_0x2fa8f0){_0x330f29=this[_0x5e10('0x21')]!==_0x2fa8f0[_0x5e10('0x21')]||this[_0x5e10('0x20')]!==_0x2fa8f0['dialActive']||this['message']!==_0x2fa8f0[_0x5e10('0x40')]||this[_0x5e10('0x41')]!==_0x2fa8f0[_0x5e10('0x41')];_0x14a37b=OUTBOUND_COUNTERS['some'](function(_0x5ae2b6){return this[_0x5ae2b6]!==_0x2fa8f0[_0x5ae2b6];},this);if(this[_0x5e10('0x42')]&&_0x2fa8f0[_0x5e10('0x42')]){_0x20d45c=this[_0x5e10('0x42')][_0x5e10('0xf')]!==_0x2fa8f0['Trunk'][_0x5e10('0xf')]||this[_0x5e10('0x42')][_0x5e10('0x43')]!==_0x2fa8f0[_0x5e10('0x42')][_0x5e10('0x43')];}}return _0x330f29||_0x14a37b||_0x20d45c;};VoiceQueueSummary[_0x5e10('0x45')][_0x5e10('0x54')]=function(_0x44a6a2){this['answered']=_0x44a6a2[_0x5e10('0x3')];this['message']=_0x44a6a2[_0x5e10('0x40')];this[_0x5e10('0x41')]=_0x44a6a2['statusMessage'];this[_0x5e10('0x39')]=_0x44a6a2[_0x5e10('0x39')];this[_0x5e10('0x6')]=_0x44a6a2[_0x5e10('0x6')];this[_0x5e10('0x27')]=_0x44a6a2[_0x5e10('0x27')];this['outboundBlacklistCallsDay']=_0x44a6a2[_0x5e10('0x28')];this[_0x5e10('0x7')]=_0x44a6a2[_0x5e10('0x7')];this[_0x5e10('0x8')]=_0x44a6a2[_0x5e10('0x8')];this[_0x5e10('0x2c')]=_0x44a6a2[_0x5e10('0x2c')];this[_0x5e10('0x2d')]=_0x44a6a2[_0x5e10('0x2d')];this['outboundReCallsDay']=_0x44a6a2[_0x5e10('0x9')];this[_0x5e10('0xa')]=_0x44a6a2[_0x5e10('0xa')];this[_0x5e10('0xb')]=_0x44a6a2[_0x5e10('0xb')];this['sumBillable']=_0x44a6a2[_0x5e10('0x1a')];this[_0x5e10('0xd')]=_0x44a6a2[_0x5e10('0xd')];this[_0x5e10('0xe')]=_0x44a6a2[_0x5e10('0xe')];if(this[_0x5e10('0x21')]===_0x5e10('0x55')){this['pTalking']=_0x44a6a2[_0x5e10('0xc')];}};module[_0x5e10('0x56')]=VoiceQueueSummary; \ No newline at end of file diff --git a/server/services/ami/model/vtigerAccount.js b/server/services/ami/model/vtigerAccount.js new file mode 100644 index 0000000..d140cd2 --- /dev/null +++ b/server/services/ami/model/vtigerAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3cb7=['remoteUri','serverUrl','Configurations','exports','name','username','accessKey'];(function(_0x31a9d1,_0x283ae9){var _0x127d8e=function(_0x5b7079){while(--_0x5b7079){_0x31a9d1['push'](_0x31a9d1['shift']());}};_0x127d8e(++_0x283ae9);}(_0x3cb7,0xcf));var _0x73cb=function(_0x276468,_0x29685a){_0x276468=_0x276468-0x0;var _0x36dc3a=_0x3cb7[_0x276468];return _0x36dc3a;};'use strict';function VtigerAccount(_0x56ec4a){this['id']=_0x56ec4a['id']||0x0;this['name']=_0x56ec4a[_0x73cb('0x0')]||'';this['username']=_0x56ec4a[_0x73cb('0x1')]||'';this[_0x73cb('0x2')]=_0x56ec4a[_0x73cb('0x2')]||'';this[_0x73cb('0x3')]=_0x56ec4a[_0x73cb('0x3')]||'';this[_0x73cb('0x4')]=_0x56ec4a[_0x73cb('0x4')]||'';this[_0x73cb('0x5')]=_0x56ec4a['Configurations']||{};}module[_0x73cb('0x6')]=VtigerAccount; \ No newline at end of file diff --git a/server/services/ami/model/zendeskAccount.js b/server/services/ami/model/zendeskAccount.js new file mode 100644 index 0000000..3b5b374 --- /dev/null +++ b/server/services/ami/model/zendeskAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa160=['exports','name','username','password','token','remoteUri','authType','integrationTab','serverUrl','Configurations'];(function(_0x43bf40,_0x54ebb0){var _0x38a066=function(_0x32bf15){while(--_0x32bf15){_0x43bf40['push'](_0x43bf40['shift']());}};_0x38a066(++_0x54ebb0);}(_0xa160,0x1a5));var _0x0a16=function(_0x2677f7,_0x629d71){_0x2677f7=_0x2677f7-0x0;var _0x219c85=_0xa160[_0x2677f7];return _0x219c85;};'use strict';function ZendeskAccount(_0x5c7f94){this['id']=_0x5c7f94['id']||0x0;this[_0x0a16('0x0')]=_0x5c7f94[_0x0a16('0x0')]||'';this[_0x0a16('0x1')]=_0x5c7f94['username']||'';this[_0x0a16('0x2')]=_0x5c7f94[_0x0a16('0x2')]||'';this[_0x0a16('0x3')]=_0x5c7f94[_0x0a16('0x3')]||'';this[_0x0a16('0x4')]=_0x5c7f94['remoteUri']||'';this[_0x0a16('0x5')]=_0x5c7f94[_0x0a16('0x5')]||'';this['type']=_0x5c7f94['type']||_0x0a16('0x6');this[_0x0a16('0x7')]=_0x5c7f94['serverUrl']||'';this['Configurations']=_0x5c7f94[_0x0a16('0x8')]||{};}module[_0x0a16('0x9')]=ZendeskAccount; \ No newline at end of file diff --git a/server/services/ami/model/zohoAccount.js b/server/services/ami/model/zohoAccount.js new file mode 100644 index 0000000..993b411 --- /dev/null +++ b/server/services/ami/model/zohoAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb184=['serverUrl','refreshToken','Configurations','exports','name','description','host','zone','clientSecret'];(function(_0x574b0e,_0x4c7f9b){var _0x32db82=function(_0x1e6ac0){while(--_0x1e6ac0){_0x574b0e['push'](_0x574b0e['shift']());}};_0x32db82(++_0x4c7f9b);}(_0xb184,0x124));var _0x4b18=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xb184[_0x3dd15e];return _0x231fd0;};'use strict';function ZohoAccount(_0x3dfda1){this['id']=_0x3dfda1['id']||0x0;this['name']=_0x3dfda1[_0x4b18('0x0')]||'';this[_0x4b18('0x1')]=_0x3dfda1[_0x4b18('0x1')]||'';this[_0x4b18('0x2')]=_0x3dfda1[_0x4b18('0x2')]||'';this['zone']=_0x3dfda1[_0x4b18('0x3')]||'';this['clientId']=_0x3dfda1['clientId']||'';this['clientSecret']=_0x3dfda1[_0x4b18('0x4')]||'';this[_0x4b18('0x5')]=_0x3dfda1[_0x4b18('0x5')]||'';this['code']=_0x3dfda1['code']||'';this[_0x4b18('0x6')]=_0x3dfda1[_0x4b18('0x6')]||'';this[_0x4b18('0x7')]=_0x3dfda1[_0x4b18('0x7')]||{};}module[_0x4b18('0x8')]=ZohoAccount; \ No newline at end of file diff --git a/server/services/ami/preview/action.js b/server/services/ami/preview/action.js new file mode 100644 index 0000000..56bf2de --- /dev/null +++ b/server/services/ami/preview/action.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7708=['uniqueid','idContact','queue','name','type','campaigntype','membername','Agent','channelAgent','format','calleridname','Contact','phone','firstName','lastName','active','calleridnum','scheduledat','countbusyretry','countnoanswerretry','countglobal','countnosuchnumberretry','countdropretry','countabandonedretry','countmachineretry','countagentrejectretry','callback','callbackuniqueid','callbackat','recallme','ContactId','ListId','UserId','VoiceQueueId','originatecalleridnum','originatecalleridname','getCaller','\x22%s\x22\x20<%s>','number','exports','util','lodash','string','isNil'];(function(_0xdc541e,_0x5e9b6b){var _0x225e81=function(_0x4dd116){while(--_0x4dd116){_0xdc541e['push'](_0xdc541e['shift']());}};_0x225e81(++_0x5e9b6b);}(_0x7708,0x188));var _0x8770=function(_0x41bdd4,_0x3d5c76){_0x41bdd4=_0x41bdd4-0x0;var _0x5c03a6=_0x7708[_0x41bdd4];return _0x5c03a6;};'use strict';var util=require(_0x8770('0x0'));var _=require(_0x8770('0x1'));var moment=require('moment');function checkNameSurname(_0x141ddf,_0x5a8b5b,_0x5ca46f){var _0x555477='';if(!_['isNil'](_0x5a8b5b)&&_0x8770('0x2')===typeof _0x5a8b5b){_0x555477+=_0x5a8b5b;}if(!_[_0x8770('0x3')](_0x5ca46f)&&'string'===typeof _0x5ca46f){_0x555477+='\x20'+_0x5ca46f;}if(_0x555477!==''){return _0x555477;}return _0x141ddf;}function Action(_0x40d401,_0x50bab7,_0x31390d,_0x42d305,_0x2b0295){this[_0x8770('0x4')]=_0x31390d||undefined;this[_0x8770('0x5')]=_0x40d401['id'];this[_0x8770('0x6')]=_0x50bab7[_0x8770('0x7')];this['type']=_0x50bab7[_0x8770('0x8')];this[_0x8770('0x9')]=_0x8770('0x6');this['dialAnswer']=![];this[_0x8770('0xa')]=_[_0x8770('0x3')](_0x40d401[_0x8770('0xb')])?undefined:_0x40d401[_0x8770('0xb')]['name'];this[_0x8770('0xc')]=this[_0x8770('0xa')]?util[_0x8770('0xd')]('SIP/%s',this[_0x8770('0xa')]):_0x42d305||undefined;this[_0x8770('0xe')]=checkNameSurname(_0x40d401[_0x8770('0xf')][_0x8770('0x10')],_0x40d401[_0x8770('0xf')][_0x8770('0x11')],_0x40d401[_0x8770('0xf')][_0x8770('0x12')]);this['active']=_0x40d401[_0x8770('0x13')]||![];this[_0x8770('0x14')]=_0x40d401['phone'];this[_0x8770('0x15')]=_0x40d401['scheduledat'];this[_0x8770('0x16')]=_0x40d401['countbusyretry']||0x0;this['countcongestionretry']=_0x40d401['countcongestionretry']||0x0;this[_0x8770('0x17')]=_0x40d401[_0x8770('0x17')]||0x0;this[_0x8770('0x18')]=(_0x40d401[_0x8770('0x16')]||0x0)+(_0x40d401['countcongestionretry']||0x0)+(_0x40d401['countnoanswerretry']||0x0)+(_0x40d401[_0x8770('0x19')]||0x0)+(_0x40d401[_0x8770('0x1a')]||0x0)+(_0x40d401[_0x8770('0x1b')]||0x0)+(_0x40d401[_0x8770('0x1c')]||0x0)+(_0x40d401[_0x8770('0x1d')]||0x0);this['countnosuchnumberretry']=_0x40d401[_0x8770('0x19')]||0x0;this[_0x8770('0x1a')]=_0x40d401[_0x8770('0x1a')]||0x0;this[_0x8770('0x1b')]=_0x40d401['countabandonedretry']||0x0;this['countmachineretry']=_0x40d401[_0x8770('0x1c')]||0x0;this[_0x8770('0x1d')]=_0x40d401[_0x8770('0x1d')]||0x0;this[_0x8770('0x1e')]=_0x40d401[_0x8770('0x1e')];this[_0x8770('0x1f')]=_0x40d401['callbackuniqueid'];this[_0x8770('0x20')]=_0x40d401[_0x8770('0x20')];this[_0x8770('0x21')]=_0x40d401[_0x8770('0x21')];this['ContactId']=_0x40d401[_0x8770('0x22')];this['ListId']=_0x40d401[_0x8770('0x23')];this[_0x8770('0x24')]=_[_0x8770('0x3')](_0x40d401[_0x8770('0xb')])?_0x40d401[_0x8770('0x24')]:_0x40d401[_0x8770('0xb')]['id'];this[_0x8770('0x25')]=_0x40d401[_0x8770('0x25')];this[_0x8770('0x26')]='';this[_0x8770('0x27')]='';}Action['prototype'][_0x8770('0x28')]=function(){return util[_0x8770('0xd')](_0x8770('0x29'),this[_0x8770('0xe')],this[_0x8770('0x2a')]);};module[_0x8770('0x2b')]=Action; \ No newline at end of file diff --git a/server/services/ami/preview/index.js b/server/services/ami/preview/index.js new file mode 100644 index 0000000..b00fa75 --- /dev/null +++ b/server/services/ami/preview/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xedd9=['channel','catch','message','updateOriginated','[clearZombieChannel]','decrementTalkink','loggerError','[Dialer][checkChannel][Preview]','clearZombieChannels','[action]','size','getContactRecallMe','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','outboundReCallsDay','logCustomer','dialRecallInQueue','rescheduleContactInQueue','createBody','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','createCustomerHistory','createCustomerFinal','[HistoryRecallClose]','[getContactRecallMe]','IsNotLoggedIn','loggedIn','CAMPAIGN_STATUS','NO_AGENTS_LOGGED','isActive','isTrunkReachable','TrunkBackup','UNREACHABLE_TRUNK','ACTIVE','outboundNoSuchCallsDay','countnosuchnumberretry','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','cloneAction','dialNoSuchNumberMaxRetry','rescheduleContact','dialNoSuchNumberRetryFrequency','activeContact','linkedid','idContact','incrementPreviewCounters','swapAdditionalPhones','then','YYYY-MM-DD\x20HH:mm:ss','[syncHangup][talking][increment]','uniqueid','\x20Queue','custom:agentconnect','connect','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','complete','outboundAnswerCallsDay','total','answered','[16]','countglobal','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','sumDuration','talktime','sumBillable','[syncHangup][talking][decrement]','BUSY','dialBusyRetryFrequency','custom:agentbusy','busy','Global','[callProgressDetectingCustomer][logBusyGlobal]','countbusyretry','dialBusyMaxRetry','[callProgressDetectingCustomer][logBusy]','scheduledAt','unlockAgent','NOANSWER','outboundNoAnswerCallsDay','countnoanswerretry','NoAnswer','custom:agentnoanswer','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerRetryFrequency','CONGESTION','countcongestionretry','Congestion','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','CANCEL','outboundRejectCallsDay','countagentrejectretry','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','ABANDONED','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','dialAbandonedMaxRety','dialAbandonedRetryFrequency','outboundUnknownCallsDay','countmachineretry','dialstatus','amd','[callProgressDetectingCustomer][hangupInAMD]','cause-txt','[callProgressDetectingCustomer][machine]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','queueSummaryCountersUpdated','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logNoAnswer]','Busy','[callProgressDetectingAgent][logBusy]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','checkInBlack','Contact','phone','Contact\x20is\x20undefined','lookAgent','isEmpty','[Preview][execCall][success]','Queue:\x20','called','Calling','Call\x20failed','outboundBlacklistCallsDay','logBlacklist','[Blacklist][error]','Contact\x20in\x20black\x20List','active','SIP/%s','status','reachable','execRun','unlock','unlockContact','getContactPreview','recallme','checkIsBlackList','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','validateContact','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','Trunk','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','Is\x20Valid','execCall','dialPrefix','trim','dialCutDigit','substring','SIP/%s/%s%s','dialOriginateCallerIdName','getCallerIdRandom','dialOriginateCallerIdNumber','getCallerId','callerid','dialRandomLastDigitCallerIdNumber','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','addVariables','merge','toLowerVariables','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','actionid','logLookAgent','clone','responsetime','isFailure','response','custom:agentringnoanswer','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','callProgressDetectingCustomer','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','addVariable','variables','syncVarSet','filterKey','keys','variable','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','lodash','uuid','moment','ioredis','../../../config/environment','../../../config/logger','preview','../ami','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','../dialer/utils','defaults','redis','localhost','socket.io-emitter','prototype','tail','finally','sequence','campaignsPreview','voiceQueues','trunks','actions','agents','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','syncNewExten','varset','syncAttendedTransfer','emit','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','format','name','voice_queue_channel:remove','voice_queue_presence:remove','originated','pTalking','sendMessageOneNotActive','available','paused','INACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','DEACTIVATED','\x20is\x20deactivated','loopCampaigns','syncCampaigns','clockClearZombieChannels','hasOwnProperty','dialMethod','booked','type','outbound','dialActive','setMessage','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','enqueue','isNil','info','Queue','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','contactId','VoiceQueueId','ListId','Action'];(function(_0x5b8b97,_0x6b4dfa){var _0x1fdf84=function(_0x2ced4c){while(--_0x2ced4c){_0x5b8b97['push'](_0x5b8b97['shift']());}};_0x1fdf84(++_0x6b4dfa);}(_0xedd9,0xfc));var _0x9edd=function(_0x4c8884,_0x248d8f){_0x4c8884=_0x4c8884-0x0;var _0x326b7d=_0xedd9[_0x4c8884];return _0x326b7d;};'use strict';var util=require('util');var _=require(_0x9edd('0x0'));var uuid=require(_0x9edd('0x1'));var moment=require(_0x9edd('0x2'));var Redis=require(_0x9edd('0x3'));var config=require(_0x9edd('0x4'));var logger=require(_0x9edd('0x5'))(_0x9edd('0x6'));var loggerAction=require(_0x9edd('0x5'))('actionPreview');var ami=require(_0x9edd('0x7'));var rpcDb=require(_0x9edd('0x8'));var cmHopperAdditionalPhone=require(_0x9edd('0x9'));var Action=require(_0x9edd('0xa'));var ut=require('./util/util');var utils=require(_0x9edd('0xb'));config['redis']=_[_0x9edd('0xc')](config[_0x9edd('0xd')],{'host':_0x9edd('0xe'),'port':0x18eb});var io=require(_0x9edd('0xf'))(new Redis(config['redis']));var Sequence=function(){};Sequence[_0x9edd('0x10')]['enqueue']=function(_0x2076fc){this[_0x9edd('0x11')]=this['tail']?this[_0x9edd('0x11')][_0x9edd('0x12')](_0x2076fc):_0x2076fc();};function Preview(_0x5b6c00){this[_0x9edd('0x13')]=new Sequence();this[_0x9edd('0x14')]=_0x5b6c00[_0x9edd('0x15')];this[_0x9edd('0x16')]=_0x5b6c00[_0x9edd('0x16')];this[_0x9edd('0x17')]={};this[_0x9edd('0x18')]=_0x5b6c00[_0x9edd('0x18')];this['clockClearZombieChannels']=0x0;ami['on'](_0x9edd('0x19'),this[_0x9edd('0x1a')][_0x9edd('0x1b')](this));ami['on'](_0x9edd('0x1c'),this[_0x9edd('0x1d')][_0x9edd('0x1b')](this));ami['on'](_0x9edd('0x1e'),this[_0x9edd('0x1f')]['bind'](this));ami['on'](_0x9edd('0x20'),this[_0x9edd('0x21')][_0x9edd('0x1b')](this));ami['on']('newexten',this[_0x9edd('0x22')][_0x9edd('0x1b')](this));ami['on'](_0x9edd('0x23'),this['syncVarSet'][_0x9edd('0x1b')](this));ami['on']('attendedtransfer',this[_0x9edd('0x24')][_0x9edd('0x1b')](this));ami['on']('blindtransfer',this['syncBlindTransfer'][_0x9edd('0x1b')](this));this['loopCampaigns'](this[_0x9edd('0x14')]);}function emit(_0x54a03f,_0x535f37,_0x356751){io['to'](_0x54a03f)[_0x9edd('0x25')](_0x535f37,_0x356751);}function emitVoiceQueueChannelRemove(_0x4fb7bf){logger['info'](_0x9edd('0x26'),JSON[_0x9edd('0x27')](_0x4fb7bf));emit(util[_0x9edd('0x28')]('voice:queue:%s',_0x4fb7bf[_0x9edd('0x29')]),_0x9edd('0x2a'),_0x4fb7bf);io[_0x9edd('0x25')](_0x9edd('0x2b'),_0x4fb7bf);}function notSendMessagesQueue(_0x339a0d){if(_0x339a0d['sendMessageOneNotActive']){if(_0x339a0d[_0x9edd('0x2c')]===0x0&&_0x339a0d[_0x9edd('0x2d')]===0x0){_0x339a0d[_0x9edd('0x2e')]=![];_0x339a0d[_0x9edd('0x2f')]=0x0;_0x339a0d[_0x9edd('0x30')]=0x0;_0x339a0d['message']=utils['CAMPAIGN_STATUS'][_0x9edd('0x31')];ut[_0x9edd('0x32')](_0x9edd('0x33'),_0x339a0d[_0x9edd('0x29')]+_0x9edd('0x34'));}else{_0x339a0d['message']=utils['CAMPAIGN_STATUS'][_0x9edd('0x35')];ut[_0x9edd('0x32')](_0x9edd('0x33'),_0x339a0d['name']+_0x9edd('0x36'));}}}Preview[_0x9edd('0x10')][_0x9edd('0x37')]=function(){var _0x41af53=this;setInterval(function(){_0x41af53['syncCampaigns']();},0x7cf);};Preview[_0x9edd('0x10')][_0x9edd('0x38')]=function(){var _0xbe87e1=this[_0x9edd('0x14')];this[_0x9edd('0x39')]+=0x1;for(var _0x42e664 in _0xbe87e1){if(_0xbe87e1[_0x9edd('0x3a')](_0x42e664)&&(_0xbe87e1[_0x42e664][_0x9edd('0x3b')]===_0x9edd('0x6')||_0xbe87e1[_0x42e664][_0x9edd('0x3b')]===_0x9edd('0x3c'))&&_0xbe87e1[_0x42e664][_0x9edd('0x3d')]===_0x9edd('0x3e')){if(this[_0x9edd('0x39')]>0x7){this[_0x9edd('0x39')]=0x0;this['clearZombieChannels']();}}if(_0xbe87e1[_0x9edd('0x3a')](_0x42e664)&&_0xbe87e1[_0x42e664][_0x9edd('0x3b')]===_0x9edd('0x6')&&_0xbe87e1[_0x42e664]['type']===_0x9edd('0x3e')){if(_0xbe87e1[_0x42e664][_0x9edd('0x3f')]){this[_0x9edd('0x40')](_0xbe87e1[_0x42e664]);if(_0xbe87e1[_0x42e664][_0x9edd('0x41')])this[_0x9edd('0x42')](_0xbe87e1[_0x42e664]);}else{notSendMessagesQueue(_0xbe87e1[_0x42e664]);}}}};Preview[_0x9edd('0x10')][_0x9edd('0x43')]=function(_0x438a5d){var _0xd0fd74=this;this[_0x9edd('0x13')][_0x9edd('0x44')](function(){if(!_[_0x9edd('0x45')](_0xd0fd74[_0x9edd('0x17')][_0x438a5d])){loggerAction[_0x9edd('0x46')]('[clearZombieChannels][talking]',_0x438a5d,_0x9edd('0x47'),_0xd0fd74['actions'][_0x438a5d][_0x9edd('0x48')],_0x9edd('0x49'),JSON[_0x9edd('0x27')](_0xd0fd74[_0x9edd('0x14')][_0xd0fd74[_0x9edd('0x17')][_0x438a5d]['queue']][_0x9edd('0x2c')]),_0x9edd('0x4a'),JSON[_0x9edd('0x27')](_0xd0fd74[_0x9edd('0x14')][_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x48')]][_0x9edd('0x2d')]),JSON[_0x9edd('0x27')](_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x4b')]),JSON['stringify'](_[_0x9edd('0x4c')](_0xd0fd74['actions'][_0x438a5d],[_0x9edd('0x4d'),'UserId',_0x9edd('0x4e'),_0x9edd('0x4f')])));return ami[_0x9edd('0x50')]({'action':'status','channel':_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x51')]})[_0x9edd('0x52')](function(_0x48958a){if(_0x48958a[_0x9edd('0x53')]==='No\x20such\x20channel'){setTimeout(function(){if(_0xd0fd74[_0x9edd('0x17')][_0x438a5d]){ut[_0x9edd('0x54')](_0xd0fd74['campaignsPreview'][_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x48')]],_0x9edd('0x55'));if(_0xd0fd74[_0x9edd('0x17')][_0x438a5d]['dialAnswer']===!![]){ut[_0x9edd('0x56')](_0xd0fd74['campaignsPreview'][_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x48')]],'[clearZombieChannel]');ut[_0x9edd('0x57')]('[Dialer][checkChannel][pTalking][Preview]'+_0x438a5d,_0xd0fd74['actions'][_0x438a5d][_0x9edd('0x48')]);}ut[_0x9edd('0x57')](_0x9edd('0x58')+_0x438a5d,_0xd0fd74[_0x9edd('0x17')][_0x438a5d][_0x9edd('0x48')]);delete _0xd0fd74[_0x9edd('0x17')][_0x438a5d];}},0x2328);}});}});};Preview[_0x9edd('0x10')][_0x9edd('0x59')]=function(){var _0x18c149=this;loggerAction[_0x9edd('0x46')](_0x9edd('0x5a'),_[_0x9edd('0x5b')](this[_0x9edd('0x17')]));for(var _0xbbe8fc in this[_0x9edd('0x17')]){if(_0x18c149['actions'][_0x9edd('0x3a')](_0xbbe8fc)){_0x18c149[_0x9edd('0x43')](_0xbbe8fc);}}};Preview[_0x9edd('0x10')][_0x9edd('0x42')]=function(_0x241929){var _0x3ecdfd=this;rpcDb[_0x9edd('0x5c')](_0x241929['id'],ut['agentReadyId'](this['agents']))['then'](function(_0x4a7dc9){if(!_['isNil'](_0x4a7dc9)){for(var _0x8b1fdb=0x0;_0x8b1fdb<_0x4a7dc9[_0x9edd('0x5d')];_0x8b1fdb+=0x1){if(ut[_0x9edd('0x5e')](_0x4a7dc9[_0x8b1fdb][_0x9edd('0x5f')])<_0x241929[_0x9edd('0x60')]*0x3c){if(_0x4a7dc9[_0x8b1fdb]['Agent']&&!_0x4a7dc9[_0x8b1fdb][_0x9edd('0x61')][_0x9edd('0x62')]){_0x3ecdfd[_0x9edd('0x63')](_0x4a7dc9[_0x8b1fdb]['id'])['then'](ut[_0x9edd('0x64')](_0x9edd('0x65')))[_0x9edd('0x52')](ut[_0x9edd('0x64')](_0x9edd('0x65')));}else{rpcDb[_0x9edd('0x66')](_0x4a7dc9[_0x8b1fdb]['id']);}}else{var _0x4d4f33=new Action(_0x4a7dc9[_0x8b1fdb],_0x241929);_0x4d4f33[_0x9edd('0x67')]=moment()[_0x9edd('0x28')]('YYYY-MM-DD\x20HH:mm:ss');_0x241929[_0x9edd('0x68')]+=0x1;ut[_0x9edd('0x69')](_0x4d4f33,0x17,'RecallInQueue');if(_0x241929[_0x9edd('0x6a')]){rpcDb[_0x9edd('0x6b')](ut[_0x9edd('0x6c')](_0x4a7dc9[_0x8b1fdb]));rpcDb['createCustomerHistory'](_0x4d4f33,_0x9edd('0x6d'));}else{ut[_0x9edd('0x69')](_0x4d4f33,0x16,_0x9edd('0x6e'));rpcDb[_0x9edd('0x6f')](_0x4d4f33,'[HistoryRecallClose]');rpcDb[_0x9edd('0x70')](_0x4d4f33,_0x9edd('0x71'));}}}}})[_0x9edd('0x52')](ut['logger2'](_0x9edd('0x72')));};Preview[_0x9edd('0x10')]['setMessage']=function(_0x8e59bd){_0x8e59bd['sendMessageOneNotActive']=!![];if(ut[_0x9edd('0x73')](_0x8e59bd[_0x9edd('0x74')])){_0x8e59bd[_0x9edd('0x53')]=utils[_0x9edd('0x75')][_0x9edd('0x76')];}else if(!ut[_0x9edd('0x77')](_0x8e59bd[_0x9edd('0x3f')])){_0x8e59bd[_0x9edd('0x53')]=utils[_0x9edd('0x75')][_0x9edd('0x31')];}else if(!this[_0x9edd('0x78')](_0x8e59bd['Trunk'])){if(!this[_0x9edd('0x78')](_0x8e59bd[_0x9edd('0x79')])){_0x8e59bd[_0x9edd('0x53')]=utils['CAMPAIGN_STATUS'][_0x9edd('0x7a')];}else{_0x8e59bd['message']=utils['CAMPAIGN_STATUS']['ACTIVE'];}}else{_0x8e59bd[_0x9edd('0x53')]=utils[_0x9edd('0x75')][_0x9edd('0x7b')];}};Preview[_0x9edd('0x10')]['callProgressDetectingCustomer']=function(_0x56b38b,_0x4e3c3e,_0x71820f){var _0x5f666b=this;var _0xd5090a=this[_0x9edd('0x17')][_0x4e3c3e];var _0x2e2920=this[_0x9edd('0x14')][_0xd5090a[_0x9edd('0x48')]];var _0x1e3087;var _0x4eb780=![];var _0x16dfdc=0x2;var _0x49d0ce=0x3;if(_0x2e2920){switch(_0x71820f){case'1':_0x2e2920[_0x9edd('0x7c')]+=0x1;_0xd5090a[_0x9edd('0x7d')]+=0x1;_0xd5090a['countglobal']=ut[_0x9edd('0x7e')](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0x0,_0x9edd('0x7f'));ami['emit'](_0x9edd('0x80'),ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0x82')));rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0x83'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'0',_0x2e2920)['then'](function(_0x4aa337){_0x4eb780=_0x4aa337[_0x9edd('0x85')]==0x1;_0x16dfdc=_0x2e2920['dialNoSuchNumberRetryFrequency'];_0x49d0ce=_0x2e2920[_0x9edd('0x86')];if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920[_0x9edd('0x87')]){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,'Global');rpcDb[_0x9edd('0x70')](_0x1e3087,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{if(_0xd5090a[_0x9edd('0x7d')]>=_0x2e2920[_0x9edd('0x89')]){rpcDb[_0x9edd('0x70')](_0xd5090a,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{rpcDb[_0x9edd('0x8a')](ut['scheduledAt'](_0xd5090a,_0x9edd('0x7d'),_0x2e2920[_0x9edd('0x8b')]),_0xd5090a['unlockAgent'],_0xd5090a[_0x9edd('0x8c')]);}}delete this['actions'][_0x56b38b[_0x9edd('0x8d')]];}else{_0xd5090a[_0x9edd('0x7d')]++;logger[_0x9edd('0x46')]('actioncountonusuch',_0xd5090a[_0x9edd('0x7d')]);logger[_0x9edd('0x46')]('id',_0xd5090a[_0x9edd('0x8e')]);_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnosuchnumberretry':_0xd5090a['countnosuchnumberretry']}})['then'](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)[_0x9edd('0x91')](function(){});});}});break;case'ANSWER':var _0x5496e9=moment()['format'](_0x9edd('0x92'));_0xd5090a['responsetime']=_0x5496e9;_0xd5090a['answertime']=_0x5496e9;_0xd5090a[_0x9edd('0x4b')]=!![];_0x2e2920[_0x9edd('0x2d')]+=0x1;logger['info'](_0x9edd('0x93'),_0xd5090a[_0x9edd('0x94')],_0x9edd('0x95'),_0x2e2920['name'],_0x9edd('0x4a'),_0x2e2920['pTalking']);ami[_0x9edd('0x25')](_0x9edd('0x96'),ut['buildObj'](_0xd5090a,_0x9edd('0x97'),this[_0x9edd('0x14')][_0xd5090a['queue']]));if(_0x2e2920[_0x9edd('0x98')]){ami[_0x9edd('0x25')](_0x9edd('0x99'),ut[_0x9edd('0x9a')](_0xd5090a));}break;case'16':ami['emit'](_0x9edd('0x9b'),ut['buildObj'](_0xd5090a,_0x9edd('0x9c'),this[_0x9edd('0x14')][_0xd5090a[_0x9edd('0x48')]]));emitVoiceQueueChannelRemove(ut['buildObj'](_0xd5090a,_0x9edd('0x9c')));_0x2e2920[_0x9edd('0x9d')]+=0x1;_0x2e2920[_0x9edd('0x9e')]+=0x1;_0x2e2920[_0x9edd('0x9f')]+=0x1;ut[_0x9edd('0x56')](_0x2e2920,_0x9edd('0xa0'));_0xd5090a[_0x9edd('0xa1')]=ut['totalGlobal'](_0xd5090a);ut['logCustomer'](_0xd5090a,0x4,_0x9edd('0xa2'));rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0xa3'));rpcDb[_0x9edd('0x70')](_0xd5090a,_0x9edd('0xa4'));rpcDb['crateCustomerReportQueue'](_0xd5090a);_0x2e2920[_0x9edd('0xa5')]+=_0xd5090a[_0x9edd('0xa6')];_0x2e2920[_0x9edd('0xa7')]+=_0xd5090a['talktime'];logger[_0x9edd('0x46')](_0x9edd('0xa8'),_0xd5090a['uniqueid'],_0x9edd('0x95'),_0x2e2920[_0x9edd('0x29')],'pTalking:\x20',_0x2e2920[_0x9edd('0x2d')]);delete this[_0x9edd('0x17')][_0x56b38b['linkedid']];break;case _0x9edd('0xa9'):_0x2e2920['outboundBusyCallsDay']+=0x1;_0xd5090a['countbusyretry']+=0x1;_0xd5090a[_0x9edd('0xa1')]=ut[_0x9edd('0x7e')](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0x5,'Busy');_0x16dfdc=_0x2e2920[_0x9edd('0xaa')];_0x49d0ce=_0x2e2920[_0x9edd('0x86')];ami['emit'](_0x9edd('0xab'),ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0xac')));rpcDb[_0x9edd('0x6f')](_0xd5090a,'[callProgressDetectingCustomer][logBusy]');_0x5f666b['verifyAdditionalPhones'](_0xd5090a,'5',_0x2e2920)[_0x9edd('0x91')](function(_0x5bb28c){_0x4eb780=_0x5bb28c[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920[_0x9edd('0x87')]){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,_0x9edd('0xad'));rpcDb[_0x9edd('0x70')](_0x1e3087,_0x9edd('0xae'));}else{if(_0xd5090a[_0x9edd('0xaf')]>=_0x2e2920[_0x9edd('0xb0')]){rpcDb['createCustomerFinal'](_0xd5090a,_0x9edd('0xb1'));}else{rpcDb[_0x9edd('0x8a')](ut[_0x9edd('0xb2')](_0xd5090a,_0x9edd('0xaf'),_0x2e2920[_0x9edd('0xaa')]),_0xd5090a[_0x9edd('0xb3')],_0xd5090a[_0x9edd('0x8c')]);}}}else{_0xd5090a['countbusyretry']++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countbusyretry':_0xd5090a['countbusyretry']}})[_0x9edd('0x91')](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)['then'](function(){});});}});break;case _0x9edd('0xb4'):_0x2e2920[_0x9edd('0xb5')]+=0x1;_0xd5090a[_0x9edd('0xb6')]+=0x1;_0xd5090a['countglobal']=ut[_0x9edd('0x7e')](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0x3,_0x9edd('0xb7'));_0x16dfdc=_0x2e2920['dialNoAnswerRetryFrequency'];_0x49d0ce=_0x2e2920['callAdditionalPhoneAfterMin'];var _0x5378ca=ut['buildNoAnswerEventPayload'](_0xd5090a,_0x2e2920);ami[_0x9edd('0x25')](_0x9edd('0xb8'),_0x5378ca);rpcDb[_0x9edd('0x6f')](_0xd5090a,'[callProgressDetectingCustomer][logNoAnswer]');_0x5f666b['verifyAdditionalPhones'](_0xd5090a,'3',_0x2e2920)['then'](function(_0x56d794){_0x4eb780=_0x56d794[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920[_0x9edd('0x87')]){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,_0x9edd('0xad'));rpcDb[_0x9edd('0x70')](_0x1e3087,_0x9edd('0xb9'));}else{if(_0xd5090a[_0x9edd('0xb6')]>=_0x2e2920[_0x9edd('0xba')]){rpcDb[_0x9edd('0x70')](_0xd5090a,_0x9edd('0xbb'));}else{rpcDb['rescheduleContact'](ut[_0x9edd('0xb2')](_0xd5090a,_0x9edd('0xb6'),_0x2e2920[_0x9edd('0xbc')]),_0xd5090a[_0x9edd('0xb3')],_0xd5090a[_0x9edd('0x8c')]);}}}else{_0xd5090a[_0x9edd('0xb6')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnoanswerretry':_0xd5090a['countnoanswerretry']}})['then'](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)['then'](function(){});});}});break;case _0x9edd('0xbd'):_0x2e2920['outboundCongestionCallsDay']+=0x1;_0xd5090a[_0x9edd('0xbe')]+=0x1;_0xd5090a[_0x9edd('0xa1')]=ut['totalGlobal'](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0x8,_0x9edd('0xbf'));_0x16dfdc=_0x2e2920['dialCongestionRetryFrequency'];_0x49d0ce=_0x2e2920[_0x9edd('0x86')];ami[_0x9edd('0x25')](_0x9edd('0xc0'),ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0xc1')));rpcDb['createCustomerHistory'](_0xd5090a,_0x9edd('0xc2'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'8',_0x2e2920)[_0x9edd('0x91')](function(_0x24488b){_0x4eb780=_0x24488b[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut['totalGlobal'](_0xd5090a)>=_0x2e2920['dialGlobalMaxRetry']){_0x1e3087=ut['cloneAction'](_0xd5090a,0xf,'Global');rpcDb['createCustomerFinal'](_0x1e3087,_0x9edd('0xc3'));}else{if(_0xd5090a['countcongestionretry']>=_0x2e2920['dialCongestionMaxRetry']){rpcDb[_0x9edd('0x70')](_0xd5090a,_0x9edd('0xc2'));}else{rpcDb[_0x9edd('0x8a')](ut[_0x9edd('0xb2')](_0xd5090a,_0x9edd('0xbe'),_0x2e2920[_0x9edd('0xaa')]),_0xd5090a[_0x9edd('0xb3')],_0xd5090a[_0x9edd('0x8c')]);}}}else{_0xd5090a[_0x9edd('0xbe')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a['idContact'],'field':{'countcongestionretry':_0xd5090a[_0x9edd('0xbe')]}})[_0x9edd('0x91')](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)[_0x9edd('0x91')](function(){});});}});break;case _0x9edd('0xc4'):_0x2e2920[_0x9edd('0xc5')]+=0x1;_0xd5090a[_0x9edd('0xc6')]+=0x1;_0xd5090a[_0x9edd('0xa1')]=ut['totalGlobal'](_0xd5090a);ut['logCustomer'](_0xd5090a,0x14,_0x9edd('0xc7'));_0x16dfdc=_0x2e2920[_0x9edd('0xc8')];_0x49d0ce=_0x2e2920[_0x9edd('0x86')];ami[_0x9edd('0x25')](_0x9edd('0xc9'),ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0xca')));rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0xcb'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'20',_0x2e2920)[_0x9edd('0x91')](function(_0x260cc6){_0x4eb780=_0x260cc6[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920['dialGlobalMaxRetry']){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0x14,_0x9edd('0xc7'));rpcDb['createCustomerFinal'](_0x1e3087,_0x9edd('0xcc'));}else{if(_0xd5090a[_0x9edd('0xc6')]>=_0x2e2920[_0x9edd('0xcd')]){rpcDb[_0x9edd('0x70')](_0xd5090a,'[callProgressDetectingCustomer][logAgentReject]');}else{rpcDb[_0x9edd('0x8a')](ut[_0x9edd('0xb2')](_0xd5090a,_0x9edd('0xc6'),_0x2e2920[_0x9edd('0xc8')]),_0xd5090a[_0x9edd('0xb3')],_0xd5090a['activeContact']);}}}else{_0xd5090a[_0x9edd('0xb6')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnoanswerretry':_0xd5090a[_0x9edd('0xb6')]}})[_0x9edd('0x91')](function(){_0x5f666b['swapAdditionalPhones'](_0xd5090a,_0x16dfdc,_0x49d0ce)['then'](function(){});});}});break;case _0x9edd('0xce'):_0x2e2920['outboundAbandonedCallsDay']+=0x1;_0xd5090a[_0x9edd('0xcf')]+=0x1;_0xd5090a['countglobal']=ut[_0x9edd('0x7e')](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0xb,_0x9edd('0xd0'));rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0xd1'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'11',_0x2e2920)['then'](function(_0x186e02){_0x4eb780=_0x186e02[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920[_0x9edd('0x87')]){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,_0x9edd('0xad'));rpcDb[_0x9edd('0x70')](_0x1e3087,_0x9edd('0xd1'));}else{if(_0xd5090a['countabandonedetry']>=_0x2e2920[_0x9edd('0xd2')]){rpcDb[_0x9edd('0x70')](_0xd5090a,_0x9edd('0xd1'));}else{rpcDb[_0x9edd('0x8a')](ut[_0x9edd('0xb2')](_0xd5090a,_0x9edd('0xcf'),_0x2e2920[_0x9edd('0xd3')]),_0xd5090a[_0x9edd('0xb3')],_0xd5090a[_0x9edd('0x8c')]);}}}else{_0xd5090a[_0x9edd('0xb6')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnoanswerretry':_0xd5090a[_0x9edd('0xb6')]}})[_0x9edd('0x91')](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)[_0x9edd('0x91')](function(){});});}});break;case'18':_0x2e2920[_0x9edd('0xd4')]+=0x1;_0xd5090a[_0x9edd('0xd5')]+=0x1;_0xd5090a[_0x9edd('0xa1')]=ut[_0x9edd('0x7e')](_0xd5090a);ut[_0x9edd('0x69')](_0xd5090a,0x12,_0x56b38b['cause-txt']||_0x56b38b[_0x9edd('0xd6')]);ami['emit']('custom:amd',ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0xd7')));rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0xd8'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'18',_0x2e2920)[_0x9edd('0x91')](function(_0x3b5c12){_0x4eb780=_0x3b5c12[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920[_0x9edd('0x87')]){_0x1e3087=ut['cloneAction'](_0xd5090a,0x12,_0x9edd('0xad'));rpcDb[_0x9edd('0x70')](_0x1e3087,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb['createCustomerFinal'](_0xd5090a,_0x9edd('0xd8'));}}else{_0xd5090a[_0x9edd('0xb6')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnoanswerretry':_0xd5090a['countnoanswerretry']}})['then'](function(){_0x5f666b[_0x9edd('0x90')](_0xd5090a,_0x16dfdc,_0x49d0ce)['then'](function(){});});}});delete this[_0x9edd('0x17')][_0x56b38b[_0x9edd('0x8d')]];break;case'19':_0x2e2920[_0x9edd('0xd4')]+=0x1;_0xd5090a['countglobal']=ut['totalGlobal'](_0xd5090a);ut['logCustomer'](_0xd5090a,0x13,_0x56b38b[_0x9edd('0xd9')]||_0x56b38b[_0x9edd('0xd6')]);ami[_0x9edd('0x25')]('custom:amd',ut[_0x9edd('0x81')](_0xd5090a,_0x9edd('0xd7')));rpcDb['createCustomerHistory'](_0xd5090a,_0x9edd('0xda'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'18',_0x2e2920)['then'](function(_0x5c9b3e){_0x4eb780=_0x5c9b3e[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut[_0x9edd('0x7e')](_0xd5090a)>=_0x2e2920['dialGlobalMaxRetry']){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,_0x9edd('0xad'));rpcDb['createCustomerFinal'](_0x1e3087,_0x9edd('0xda'));}else{rpcDb['createCustomerFinal'](_0xd5090a,_0x9edd('0xda'));}}else{_0xd5090a[_0x9edd('0xb6')]++;_0x5f666b[_0x9edd('0x8f')]({'id':_0xd5090a[_0x9edd('0x8e')],'field':{'countnoanswerretry':_0xd5090a[_0x9edd('0xb6')]}})[_0x9edd('0x91')](function(){_0x5f666b['swapAdditionalPhones'](_0xd5090a,_0x16dfdc,_0x49d0ce)[_0x9edd('0x91')](function(){});});}});delete this[_0x9edd('0x17')][_0x56b38b[_0x9edd('0x8d')]];break;default:if(_0xd5090a['dialAnswer']){ut[_0x9edd('0x56')](_0x2e2920,'[default]');ut[_0x9edd('0x57')](_0x9edd('0xdb')+_0x2e2920[_0x9edd('0x29')],_0x56b38b);}_0x2e2920[_0x9edd('0xd4')]+=0x1;_0xd5090a['countglobal']=ut['totalGlobal'](_0xd5090a);ut['logCustomer'](_0xd5090a,0xc,_0x56b38b[_0x9edd('0xd9')]||_0x56b38b[_0x9edd('0xd6')]);_0x16dfdc=_0x2e2920[_0x9edd('0xc8')];_0x49d0ce=_0x2e2920['callAdditionalPhoneAfterMin'];rpcDb[_0x9edd('0x6f')](_0xd5090a,_0x9edd('0xdc'));_0x5f666b[_0x9edd('0x84')](_0xd5090a,'20',_0x2e2920)[_0x9edd('0x91')](function(_0x1aa77f){_0x4eb780=_0x1aa77f[_0x9edd('0x85')]==0x1;if(!_0x4eb780){if(ut['totalGlobal'](_0xd5090a)>=_0x2e2920['dialGlobalMaxRetry']){_0x1e3087=ut[_0x9edd('0x88')](_0xd5090a,0xf,_0x9edd('0xad'));rpcDb[_0x9edd('0x70')](_0x1e3087,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb[_0x9edd('0x70')](_0xd5090a,_0x9edd('0xdd'));}delete this[_0x9edd('0x17')][_0x56b38b[_0x9edd('0x8d')]];}else{_0x5f666b['swapAdditionalPhones'](_0xd5090a,_0x16dfdc,_0x49d0ce)[_0x9edd('0x91')](function(){});}});}if(!(_0xd5090a['dialAnswer']&&_0x71820f==='16')){ut[_0x9edd('0x54')](_0x2e2920,_0x9edd('0xde'));logger[_0x9edd('0x46')](_0x9edd('0xdf'),_0xd5090a[_0x9edd('0x94')],'\x20Queue',_0x2e2920[_0x9edd('0x29')],'originated:\x20',_0x2e2920[_0x9edd('0x2c')]);}if(_0x71820f!=='ANSWER'){delete this[_0x9edd('0x17')][_0x56b38b['linkedid']];delete this[_0x9edd('0x17')][_0x56b38b[_0x9edd('0xe0')]];}_0x2e2920[_0x9edd('0xe1')]=!![];}};Preview['prototype'][_0x9edd('0xe2')]=function(_0x7512ea,_0x1c5038,_0x2e7b0d){if(_[_0x9edd('0xe3')](_0x1c5038)&&_0x9edd('0xe4')!==typeof _0x1c5038){return;}if(_[_0x9edd('0xe3')](_0x2e7b0d)&&_0x9edd('0xe4')!==typeof _0x2e7b0d){return;}switch(_0x2e7b0d[_0x9edd('0xe5')]){case'0':ut[_0x9edd('0xe6')](_0x7512ea,0x0,_0x9edd('0x7f'));rpcDb[_0x9edd('0xe7')](_0x7512ea,_0x9edd('0xe8'));break;case'3':ut[_0x9edd('0xe6')](_0x7512ea,0x3,_0x9edd('0xb7'));rpcDb[_0x9edd('0xe7')](_0x7512ea,_0x9edd('0xe9'));break;case'5':ut[_0x9edd('0xe6')](_0x7512ea,0x5,_0x9edd('0xea'));rpcDb[_0x9edd('0xe7')](_0x7512ea,_0x9edd('0xeb'));break;case'8':ut[_0x9edd('0xe6')](_0x7512ea,0x8,'Congestion');rpcDb[_0x9edd('0xe7')](_0x7512ea,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0x9edd('0xe6')](_0x7512ea,0x16,_0x9edd('0xec'));rpcDb[_0x9edd('0xe7')](_0x7512ea,_0x9edd('0xed'));break;default:ut[_0x9edd('0xe6')](_0x7512ea,0xc,_0x2e7b0d['reason']);rpcDb[_0x9edd('0xe7')](_0x7512ea,'[callProgressDetectingAgent][logCongestion]');}ut[_0x9edd('0x54')](_0x1c5038,_0x9edd('0xee'));logger[_0x9edd('0x46')](_0x9edd('0xef'),_0x7512ea[_0x9edd('0x94')],_0x9edd('0x95'),_0x1c5038['name'],_0x9edd('0x49'),_0x1c5038[_0x9edd('0x2c')]);delete this['actions'][_0x7512ea['uniqueid']];};Preview['prototype']['verifyAdditionalPhones']=function(_0x2a8525,_0x12707f,_0x2e1258){return cmHopperAdditionalPhone[_0x9edd('0x84')](_0x2a8525,_0x12707f,_0x2e1258)[_0x9edd('0x52')](logger[_0x9edd('0x46')](_0x9edd('0xf0')));};Preview[_0x9edd('0x10')][_0x9edd('0x90')]=function(_0x3cddf5,_0x5510a1,_0x361b57){return cmHopperAdditionalPhone['swapAdditionalPhones'](_0x3cddf5,_0x5510a1,_0x361b57)['catch'](logger[_0x9edd('0x46')](_0x9edd('0xf1')));};Preview[_0x9edd('0x10')][_0x9edd('0x8f')]=function(_0x3ee216){return Promise['resolve']()[_0x9edd('0x91')](cmHopperAdditionalPhone[_0x9edd('0x8f')](_0x3ee216))[_0x9edd('0x52')](logger[_0x9edd('0x46')]('[incrementPreviewCounters]\x20'));};Preview[_0x9edd('0x10')][_0x9edd('0xf2')]=function(_0x3df631,_0x236e7d,_0x30a1c5,_0x29fef9,_0x55052b){var _0x9ff2d3=this;return new Promise(function(_0x1eea2f,_0xa8c1f7){if(_[_0x9edd('0x45')](_0x236e7d)||_['isNil'](_0x236e7d[_0x9edd('0xf3')])||_[_0x9edd('0x45')](_0x236e7d[_0x9edd('0xf4')])||_[_0x9edd('0x45')](_0x236e7d[_0x9edd('0x4e')])){_0xa8c1f7(ut[_0x9edd('0x53')](_0x9edd('0xf5'),_0x29fef9,_0x55052b));return;}var _0x39e3b3=uuid['v4']();var _0x4a3955=_0x9ff2d3['campaignsPreview'][_0x236e7d['Queue'][_0x9edd('0x29')]];var _0x46041c=_0x30a1c5?_0x9ff2d3[_0x9edd('0x18')][_0x30a1c5]['id']:undefined;_0x9ff2d3[_0x9edd('0x17')][_0x39e3b3]=new Action(_0x236e7d,_0x4a3955,_0x39e3b3,_0x30a1c5,_0x46041c);var _0x223c42=_0x9ff2d3[_0x9edd('0x17')][_0x39e3b3];_0x223c42[_0x9edd('0xb3')]=_0x29fef9;_0x223c42[_0x9edd('0x8c')]=_0x55052b;_0x223c42[_0x9edd('0xf6')]=_0x30a1c5;if(_[_0x9edd('0xf7')](_0x3df631)){_0x9ff2d3['execCall'](_0x223c42,_0x4a3955,_0x236e7d,_0x30a1c5)[_0x9edd('0x91')](function(_0x56dc7e){logger['info'](_0x9edd('0xf8'),_0x9edd('0xf9')+_0x223c42[_0x9edd('0x48')]+'\x20IdHopper:\x20'+_0x223c42['idContact'],JSON['stringify'](_0x56dc7e));ami['emit']('custom:agentcalled',ut[_0x9edd('0x81')](_0x223c42,_0x9edd('0xfa'),_0x9ff2d3[_0x9edd('0x14')][_0x223c42['queue']]));_0x1eea2f(ut[_0x9edd('0x53')](_0x9edd('0xfb')));})[_0x9edd('0x52')](function(_0x557156){ut[_0x9edd('0x32')]('[Preview][execCall][failure]',_0x557156);_0xa8c1f7(ut[_0x9edd('0x53')](_0x9edd('0xfc'),_0x29fef9,_0x55052b));});}else{_0x4a3955[_0x9edd('0xfd')]+=0x1;ut[_0x9edd('0xfe')](_0x223c42);rpcDb['createHistory'](_0x223c42,_0x9edd('0xff'));delete _0x9ff2d3[_0x9edd('0x17')][_0x39e3b3];_0xa8c1f7(ut['message'](_0x9edd('0x100'),_0x29fef9,_0x55052b));}});};Preview[_0x9edd('0x10')][_0x9edd('0x78')]=function(_0x32fc90){return!_['isNil'](_0x32fc90)&&!_[_0x9edd('0x45')](_0x32fc90[_0x9edd('0x29')])&&!_[_0x9edd('0x45')](_0x32fc90[_0x9edd('0x101')])&&_0x32fc90[_0x9edd('0x101')]&&!_[_0x9edd('0x45')](this[_0x9edd('0x16')][util['format'](_0x9edd('0x102'),_0x32fc90['name'])])&&!_[_0x9edd('0x45')](this[_0x9edd('0x16')][util['format'](_0x9edd('0x102'),_0x32fc90[_0x9edd('0x29')])][_0x9edd('0x103')])&&(this['trunks'][util[_0x9edd('0x28')](_0x9edd('0x102'),_0x32fc90[_0x9edd('0x29')])]['status']===_0x9edd('0x104')||this['trunks'][util[_0x9edd('0x28')](_0x9edd('0x102'),_0x32fc90[_0x9edd('0x29')])][_0x9edd('0x103')]==='unmonitored');};Preview['prototype'][_0x9edd('0x63')]=function(_0x12f23f,_0x29d783){return this[_0x9edd('0x105')](_0x12f23f,_0x29d783)[_0x9edd('0x91')](function(_0x4b92fc){return _[_0x9edd('0x4c')](_0x4b92fc,[_0x9edd('0x53')]);})[_0x9edd('0x52')](function(_0x1a6dba){if(_0x1a6dba[_0x9edd('0x106')]){rpcDb[_0x9edd('0x107')](_0x12f23f);}if(_0x1a6dba[_0x9edd('0x101')]){rpcDb[_0x9edd('0x66')](_0x12f23f);}throw _[_0x9edd('0x4c')](_0x1a6dba,[_0x9edd('0x53')]);});};Preview[_0x9edd('0x10')][_0x9edd('0x105')]=function(_0x10fa41,_0x549cd6){var _0x213818=this;var _0x15d391,_0x404cc6;return rpcDb[_0x9edd('0x108')](_0x10fa41)['then'](function(_0x1d660d){if(!_[_0x9edd('0x45')](_0x1d660d[0x0])){_0x404cc6=_0x1d660d[0x0][_0x9edd('0x109')]?![]:!![];_0x15d391=_0x1d660d[0x0]['recallme']?!![]:![];_0x15d391=_0x549cd6?!![]:_0x15d391;}var _0x910adf=_0x213818['validateContact'](_0x1d660d);if(_0x910adf['isValid']){rpcDb[_0x9edd('0x10a')](_[_0x9edd('0x4c')](_0x1d660d[0x0],[_0x9edd('0x4e'),_0x9edd('0xf4')]))['then'](function(_0x1ead85){_0x213818[_0x9edd('0xf2')](_0x1ead85,_0x1d660d[0x0],_0x549cd6,_0x404cc6,_0x15d391)[_0x9edd('0x91')](function(_0x12a75d){return _0x12a75d;})[_0x9edd('0x52')](function(_0x38efe5){throw _0x38efe5;});})[_0x9edd('0x52')](function(_0x20e500){ut[_0x9edd('0x32')](_0x9edd('0x10b'),_0x20e500);throw ut[_0x9edd('0x53')](_0x9edd('0x10c'),_0x404cc6,_0x15d391);});}else{throw ut['message'](_0x910adf[_0x9edd('0x53')],_0x404cc6,_0x15d391);}})[_0x9edd('0x52')](function(_0x12b2c5){ut[_0x9edd('0x32')](_0x9edd('0x10d'),_0x12b2c5);throw ut['message'](_0x9edd('0x10c'),![],!![]);});};Preview['prototype'][_0x9edd('0x10e')]=function(_0x22fb1d){if(_['isNil'](_0x22fb1d)||_['isEmpty'](_0x22fb1d)||!_[_0x9edd('0x45')](_0x22fb1d[0x0][_0x9edd('0x61')])&&_[_0x9edd('0x45')](_0x22fb1d[0x0][_0x9edd('0x61')][_0x9edd('0x29')])){ut['logger']('[Preview][validateContact][Empty\x20Contact]',_0x22fb1d);return{'isValid':![],'message':_0x9edd('0x10f')};}var _0x2a10ba=this[_0x9edd('0x14')][_0x22fb1d[0x0][_0x9edd('0x47')]['name']];_0x2a10ba[_0x9edd('0x53')]=utils[_0x9edd('0x75')][_0x9edd('0x7b')];if(_[_0x9edd('0x45')](_0x2a10ba)){ut[_0x9edd('0x32')](_0x9edd('0x110'),_0x2a10ba);return{'isValid':![],'message':_0x9edd('0x111')};}if(!this['isTrunkReachable'](_0x2a10ba[_0x9edd('0x112')])){ut[_0x9edd('0x32')](_0x9edd('0x113'),_0x9edd('0x114')+_0x2a10ba[_0x9edd('0x29')]+_0x9edd('0x115'));if(!this[_0x9edd('0x78')](_0x2a10ba[_0x9edd('0x79')])){ut[_0x9edd('0x32')](_0x9edd('0x113'),_0x2a10ba[_0x9edd('0x29')]+_0x9edd('0x116'));return{'isValid':![],'message':_0x9edd('0x117')};}}if(!ut['isActive'](_0x2a10ba[_0x9edd('0x3f')])){ut[_0x9edd('0x32')](_0x9edd('0x118'),_0x2a10ba[_0x9edd('0x29')]+'\x20Not\x20Active');return{'isValid':![],'message':_0x9edd('0x114')+_0x2a10ba[_0x9edd('0x29')]+_0x9edd('0x119')};}return{'isValid':!![],'message':_0x9edd('0x11a')};};Preview[_0x9edd('0x10')][_0x9edd('0x11b')]=function(_0xffe3c4,_0x26a224,_0x21ef16,_0x345d90){var _0x304e90=this;return new Promise(function(_0x524a47,_0x3627be){var _0x7916cf=_0xffe3c4[_0x9edd('0x94')];var _0x257dee=_0x304e90[_0x9edd('0x78')](_0x26a224[_0x9edd('0x112')])?util[_0x9edd('0x28')]('SIP/%s/%s%s',_0x26a224[_0x9edd('0x112')][_0x9edd('0x29')],_[_0x9edd('0x45')](_0x26a224[_0x9edd('0x11c')])?'':_0x26a224[_0x9edd('0x11c')][_0x9edd('0x11d')]()||'',_0x26a224[_0x9edd('0x11e')]>0x0?_0x21ef16[_0x9edd('0xf4')][_0x9edd('0x11f')](_0x26a224[_0x9edd('0x11e')]):_0x21ef16[_0x9edd('0xf4')]):util[_0x9edd('0x28')](_0x9edd('0x120'),_[_0x9edd('0x45')](_0x26a224[_0x9edd('0x79')])?_0x26a224[_0x9edd('0x112')][_0x9edd('0x29')]:_0x26a224['TrunkBackup'][_0x9edd('0x29')],_[_0x9edd('0x45')](_0x26a224[_0x9edd('0x11c')])?'':_0x26a224[_0x9edd('0x11c')][_0x9edd('0x11d')]()||'',_0x26a224[_0x9edd('0x11e')]>0x0?_0x21ef16[_0x9edd('0xf4')][_0x9edd('0x11f')](_0x26a224[_0x9edd('0x11e')]):_0x21ef16['phone']);var _0x12cb33=_0x304e90[_0x9edd('0x78')](_0x26a224[_0x9edd('0x112')])?ut['getCallerId'](_0x26a224[_0x9edd('0x112')]['callerid'],_0x26a224[_0x9edd('0x121')],_0x26a224['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x9edd('0x122')](_0x26a224[_0x9edd('0x123')],_0x26a224['dialRandomLastDigitCallerIdNumber']):_0x26a224[_0x9edd('0x123')]):ut[_0x9edd('0x124')](_[_0x9edd('0x45')](_0x26a224[_0x9edd('0x79')])?_0x26a224[_0x9edd('0x112')][_0x9edd('0x125')]:_0x26a224[_0x9edd('0x79')]['callerid'],_0x26a224[_0x9edd('0x121')],_0x26a224[_0x9edd('0x126')]>0x0?ut['getCallerIdRandom'](_0x26a224[_0x9edd('0x123')],_0x26a224['dialRandomLastDigitCallerIdNumber']):_0x26a224[_0x9edd('0x123')]);if(_0x12cb33){_0xffe3c4[_0x9edd('0x127')]=ut[_0x9edd('0x128')](_0x12cb33);_0xffe3c4[_0x9edd('0x129')]=ut[_0x9edd('0x12a')](_0x12cb33);}var _0x4629fd=ut[_0x9edd('0x12b')](_0x26a224,_0x21ef16,_0x257dee,_0x12cb33,_0x7916cf,_0xffe3c4);_[_0x9edd('0x12c')](_0xffe3c4,ut[_0x9edd('0x12d')](_0x4629fd));_0xffe3c4[_0x9edd('0x67')]=moment()[_0x9edd('0x28')](_0x9edd('0x92'));_0x26a224['variables']=_0x4629fd;var _0x5e9b74=ut[_0x9edd('0x12e')](_0xffe3c4,_0x26a224,_0x4629fd,_0xffe3c4[_0x9edd('0x8c')],_0x345d90);return ami[_0x9edd('0x50')](_0x5e9b74)[_0x9edd('0x91')](function(_0x34dd61){_0x26a224[_0x9edd('0x2c')]+=0x1;logger[_0x9edd('0x46')](_0x9edd('0x12f'),_0x7916cf,_0x9edd('0x95'),_0x26a224['name'],_0x9edd('0x49'),_0x26a224['originated']);_0x524a47(_0x34dd61);})[_0x9edd('0x52')](function(_0x44c0bb){ut[_0x9edd('0xe6')](_0xffe3c4,0xe,_0x9edd('0x130'));rpcDb[_0x9edd('0xe7')](_0xffe3c4,_0x9edd('0x131'));_0x3627be(_0x44c0bb);});});};Preview[_0x9edd('0x10')][_0x9edd('0x22')]=function(_0x39243e){if(this[_0x9edd('0x17')][_0x39243e[_0x9edd('0x8d')]]){this[_0x9edd('0x17')][_0x39243e[_0x9edd('0x8d')]][_0x9edd('0x51')]=_0x39243e[_0x9edd('0x51')];}};Preview[_0x9edd('0x10')][_0x9edd('0x1a')]=function(_0x2a515a){var _0x3f20b7=this;var _0x55bdaf=this['actions'][_0x2a515a[_0x9edd('0x132')]];if(_0x55bdaf){if(_0x55bdaf['lookAgent']&&this[_0x9edd('0x18')][_0x55bdaf[_0x9edd('0xf6')]]){ut[_0x9edd('0x133')](_0x55bdaf,this[_0x9edd('0x18')][_0x55bdaf['lookAgent']]['name'],this[_0x9edd('0x18')][_0x55bdaf[_0x9edd('0xf6')]]['id']);}var _0x7397cc=_[_0x9edd('0x134')](_0x55bdaf);_0x7397cc[_0x9edd('0x135')]=moment()['format'](_0x9edd('0x92'));var _0x48f055=_0x3f20b7[_0x9edd('0x14')][_0x55bdaf[_0x9edd('0x48')]];if(ut[_0x9edd('0x136')](_0x2a515a[_0x9edd('0x137')])){if(_0x55bdaf['unlockAgent']){rpcDb['unlockContact'](_0x55bdaf['idContact']);}if(_0x55bdaf[_0x9edd('0x8c')]){rpcDb[_0x9edd('0x66')](_0x55bdaf[_0x9edd('0x8e')]);}ami[_0x9edd('0x25')](_0x9edd('0x138'),ut[_0x9edd('0x81')](_0x55bdaf,'rejected',this[_0x9edd('0x14')][_0x55bdaf[_0x9edd('0x48')]]));this['callProgressDetectingAgent'](_0x7397cc,_0x48f055,_0x2a515a);}else{_0x55bdaf['starttime']=moment()[_0x9edd('0x28')](_0x9edd('0x92'));ut[_0x9edd('0xe6')](_0x7397cc,0x4,'Answer');rpcDb[_0x9edd('0xe7')](_0x7397cc,_0x9edd('0x139'));}}};Preview[_0x9edd('0x10')][_0x9edd('0x1d')]=function(_0x504550){var _0x3dd408=this[_0x9edd('0x17')][_0x504550[_0x9edd('0x8d')]];var _0x18924e;if(_0x3dd408){_0x18924e=this[_0x9edd('0x14')][_0x3dd408[_0x9edd('0x48')]];logger['info'](_0x9edd('0x13a'),_0x504550[_0x9edd('0x8d')],_0x9edd('0x95'),_0x18924e[_0x9edd('0x29')],'pTalking:\x20',_0x18924e['pTalking']);}if(this[_0x9edd('0x17')][_0x504550[_0x9edd('0x8d')]]&&_0x504550[_0x9edd('0x8d')]!==_0x504550[_0x9edd('0x94')]){if(_0x504550[_0x9edd('0x13b')]==='16'&&this[_0x9edd('0x17')][_0x504550[_0x9edd('0x8d')]][_0x9edd('0x4b')]){this[_0x9edd('0x13c')](_0x504550,_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')]);}else if(this[_0x9edd('0x17')][_0x504550['linkedid']]['dialAnswer']){logger[_0x9edd('0x46')](_0x9edd('0x13d'),_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')],_0x9edd('0x95'),_0x18924e[_0x9edd('0x29')],_0x9edd('0x4a'),_0x18924e[_0x9edd('0x2d')]);this['callProgressDetectingCustomer'](_0x504550,_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')]);}}else if(_0x3dd408&&_[_0x9edd('0x45')](_0x3dd408[_0x9edd('0x13e')])&&_0x18924e[_0x9edd('0x13f')]&&_0x504550[_0x9edd('0x8d')]===_0x504550['uniqueid']&&_['isNil'](_0x504550[_0x9edd('0xe5')])&&_0x504550[_0x9edd('0x13b')]==='16'&&_0x504550[_0x9edd('0x140')]==='6'&&_['isUndefined'](_0x3dd408['transfer'])){if(_0x3dd408[_0x9edd('0xb3')]){rpcDb[_0x9edd('0x107')](_0x3dd408[_0x9edd('0x8e')]);}if(_0x3dd408[_0x9edd('0x8c')]){rpcDb[_0x9edd('0x66')](_0x3dd408[_0x9edd('0x8e')]);}_0x504550[_0x9edd('0xe5')]='22';this[_0x9edd('0xe2')](_0x3dd408,_0x18924e,_0x504550);}else if(_0x3dd408&&_0x3dd408[_0x9edd('0x141')]){if(_0x504550[_0x9edd('0x13b')]==='16'&&this[_0x9edd('0x17')][_0x504550['linkedid']][_0x9edd('0x4b')]){logger['info']('[syncHangup][talking][transfer]',_0x504550['linkedid'],_0x504550[_0x9edd('0x13b')],_0x9edd('0x95'),_0x18924e['name'],'pTalking:\x20',_0x18924e['pTalking']);this['callProgressDetectingCustomer'](_0x504550,_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')]);}else if(this[_0x9edd('0x17')][_0x504550['linkedid']][_0x9edd('0x4b')]){logger[_0x9edd('0x46')](_0x9edd('0x13d'),_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')],'\x20Queue',_0x18924e[_0x9edd('0x29')],'pTalking:\x20',_0x18924e[_0x9edd('0x2d')]);this['callProgressDetectingCustomer'](_0x504550,_0x504550[_0x9edd('0x8d')],_0x504550[_0x9edd('0x13b')]);}}};Preview[_0x9edd('0x10')]['syncDialEnd']=function(_0x2ef921){if(this[_0x9edd('0x17')][_0x2ef921[_0x9edd('0xe0')]]&&_0x2ef921['destlinkedid']!==_0x2ef921['destuniqueid']){this[_0x9edd('0x13c')](_0x2ef921,_0x2ef921[_0x9edd('0xe0')],_0x2ef921[_0x9edd('0xd6')]);}};Preview[_0x9edd('0x10')][_0x9edd('0x1f')]=function(_0x83693e){if(this[_0x9edd('0x17')][_0x83693e[_0x9edd('0x8d')]]&&_0x83693e[_0x9edd('0x8d')]!==_0x83693e[_0x9edd('0x94')]&&!this['actions'][_0x83693e[_0x9edd('0x8d')]][_0x9edd('0x4b')]){if(_0x83693e['cause']==='1'){this['callProgressDetectingCustomer'](_0x83693e,_0x83693e[_0x9edd('0x8d')],_0x83693e[_0x9edd('0x13b')]);}}};Preview[_0x9edd('0x10')][_0x9edd('0x142')]=function(_0x5eec20,_0xc23db6,_0x33a71d){if(this[_0x9edd('0x17')][_0x5eec20]){if(_[_0x9edd('0x45')](this['actions'][_0x5eec20][_0x9edd('0x143')])){this[_0x9edd('0x17')][_0x5eec20][_0x9edd('0x143')]={};}this['actions'][_0x5eec20][_0x9edd('0x143')][_0xc23db6]=_0x33a71d;}};Preview[_0x9edd('0x10')][_0x9edd('0x144')]=function(_0x307f73){try{if(!_[_0x9edd('0x45')](_0x307f73)){if(ut[_0x9edd('0x145')](_[_0x9edd('0x146')](_0x307f73['variable'])[0x0])){this[_0x9edd('0x142')](_0x307f73[_0x9edd('0x94')],_['keys'](_0x307f73[_0x9edd('0x147')])[0x0],_0x307f73['value']);}}}catch(_0x5a43af){logger[_0x9edd('0x148')](_0x9edd('0x149'),util[_0x9edd('0x14a')](_0x5a43af,{'showHidden':![],'depth':null}));}};Preview[_0x9edd('0x10')][_0x9edd('0x24')]=function(_0x3109ba){if(_0x3109ba){if(this[_0x9edd('0x17')][_0x3109ba[_0x9edd('0x14b')]]){this[_0x9edd('0x17')][_0x3109ba[_0x9edd('0x14b')]][_0x9edd('0x141')]=!![];}}};Preview['prototype']['syncBlindTransfer']=function(_0x211e79){if(_0x211e79){if(this[_0x9edd('0x17')][_0x211e79[_0x9edd('0x14c')]]){this[_0x9edd('0x17')][_0x211e79[_0x9edd('0x14c')]][_0x9edd('0x141')]=!![];}}};module['exports']=Preview; \ No newline at end of file diff --git a/server/services/ami/preview/rpcDb.js b/server/services/ami/preview/rpcDb.js new file mode 100644 index 0000000..2e5418e --- /dev/null +++ b/server/services/ami/preview/rpcDb.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd221=['assigned','lastAssignedTo','queuecallerexitreason','COMPLETED','getContactRecallMe','rescheduleContactInQueue','[rescheduleContactInQueue]\x20','util','bluebird','../../../config/logger','preview','../rpc/cmHopperHistory','../rpc/cmHopperBlack','../rpc/agentReportPreview','../rpc/voiceQueueReport','createHistory','catch','resolve','then','moveContactManagedDialer','checkIsBlackList','[checkIsBlackList]\x20','getContactPreview','createCustomerFinal','rescheduleContact','UserId','[rescheduleContact]\x20','countReScheduled','[countReScheduled]\x20','unlockContact','[unlockContact]\x20','disableContact','[activeContact]\x20','type','uniqueid','calleridnum','calleridname','queue','queuecallerjoinAt','queuecallerleaveAt','answertime','queuecallercomplete','queuecallercompleteAt','endtime','connectedlinename','context','exten','xcally-motion-preview'];(function(_0x25d73d,_0xd8facb){var _0xe5dabd=function(_0x27fe79){while(--_0x27fe79){_0x25d73d['push'](_0x25d73d['shift']());}};_0xe5dabd(++_0xd8facb);}(_0xd221,0x157));var _0x1d22=function(_0x2d350d,_0x4d1e87){_0x2d350d=_0x2d350d-0x0;var _0x4ebf60=_0xd221[_0x2d350d];return _0x4ebf60;};'use strict';var util=require(_0x1d22('0x0'));var BPromise=require(_0x1d22('0x1'));var logger=require(_0x1d22('0x2'))(_0x1d22('0x3'));var cmHopper=require('../rpc/cmHopper');var cmHopperHistory=require(_0x1d22('0x4'));var cmHopperBlack=require(_0x1d22('0x5'));var agentReportPreview=require(_0x1d22('0x6'));var voiceQueueReport=require(_0x1d22('0x7'));function loggerCatch(_0x5e3f03){return function(_0x93222){logger['error'](_0x5e3f03,util['inspect'](_0x93222,{'showHidden':![],'depth':null}));};}function create(_0x52d7c1){return cmHopperHistory[_0x1d22('0x8')](_0x52d7c1)[_0x1d22('0x9')](loggerCatch('[createHistory]\x20'));}function createAgent(_0x37fc50){return BPromise[_0x1d22('0xa')]()[_0x1d22('0xb')](agentReportPreview['createHistory'](_0x37fc50))['catch'](loggerCatch('[createHistory]\x20'));}function moveContact(_0x52bb6b){return cmHopper[_0x1d22('0xc')](_0x52bb6b,!![])['catch'](loggerCatch('[moveContactManagedDialer]\x20'));}exports[_0x1d22('0xd')]=function(_0xd2e8c6){return cmHopperBlack[_0x1d22('0xd')](_0xd2e8c6)['catch'](loggerCatch(_0x1d22('0xe')));};exports[_0x1d22('0xf')]=function(_0x2cb3f1){return BPromise[_0x1d22('0xa')]()[_0x1d22('0xb')](cmHopper[_0x1d22('0xf')](_0x2cb3f1))[_0x1d22('0x9')](loggerCatch('[getContactPreview]\x20'));};exports['createHistory']=function(_0x477e94,_0x452ced){create(_0x477e94)[_0x1d22('0x9')](loggerCatch(_0x452ced));moveContact(_0x477e94)['catch'](loggerCatch(_0x452ced));};exports['createAgentHistory']=function(_0x306901,_0x29361d){createAgent(_0x306901)[_0x1d22('0x9')](loggerCatch(_0x29361d));};exports['createCustomerHistory']=function(_0x3a03ef,_0x5c9940){create(_0x3a03ef)[_0x1d22('0x9')](loggerCatch(_0x5c9940));};exports[_0x1d22('0x10')]=function(_0x2938c5,_0x43850a){moveContact(_0x2938c5)['catch'](loggerCatch(_0x43850a));};exports[_0x1d22('0x11')]=function(_0x56668b,_0xc6e261,_0x105d32){if(_0xc6e261){_0x56668b[_0x1d22('0x12')]=null;}if(_0x105d32){_0x56668b['active']=![];}return cmHopper['rescheduleContact'](_0x56668b)[_0x1d22('0x9')](loggerCatch(_0x1d22('0x13')));};exports[_0x1d22('0x14')]=function(_0xe42041){return cmHopper[_0x1d22('0x14')](_0xe42041)[_0x1d22('0x9')](loggerCatch(_0x1d22('0x15')));};exports[_0x1d22('0x16')]=function(_0x462a1e){return cmHopper['unlockContact']({'UserId':null},_0x462a1e,0x1)['catch'](loggerCatch(_0x1d22('0x17')));};exports[_0x1d22('0x18')]=function(_0x55aa82){return cmHopper[_0x1d22('0x16')]({'active':![]},_0x55aa82,0x1)['catch'](loggerCatch(_0x1d22('0x19')));};exports['crateCustomerReportQueue']=function(_0x30e827){var _0x3034c2={};_0x3034c2[_0x1d22('0x1a')]=_0x30e827[_0x1d22('0x1a')];_0x3034c2[_0x1d22('0x1b')]=_0x30e827['uniqueid'];_0x3034c2[_0x1d22('0x1c')]=_0x30e827[_0x1d22('0x1c')];_0x3034c2[_0x1d22('0x1d')]=_0x30e827[_0x1d22('0x1d')];_0x3034c2[_0x1d22('0x1e')]=_0x30e827[_0x1d22('0x1e')];_0x3034c2[_0x1d22('0x1f')]=_0x30e827['answertime'];_0x3034c2[_0x1d22('0x20')]=_0x30e827[_0x1d22('0x21')];_0x3034c2[_0x1d22('0x22')]=0x1;_0x3034c2[_0x1d22('0x23')]=_0x30e827[_0x1d22('0x24')];_0x3034c2[_0x1d22('0x25')]=_0x30e827['membername'];_0x3034c2[_0x1d22('0x26')]='from-sip';_0x3034c2[_0x1d22('0x27')]=_0x1d22('0x28');_0x3034c2['holdtime']=0x0;_0x3034c2[_0x1d22('0x29')]=0x1;_0x3034c2[_0x1d22('0x2a')]=_0x30e827['membername'];_0x3034c2[_0x1d22('0x2b')]=_0x1d22('0x2c');return BPromise[_0x1d22('0xa')]()[_0x1d22('0xb')](voiceQueueReport['create'](_0x3034c2))['catch'](loggerCatch('[voiceQueueReport]\x20'));};exports['getContactRecallMe']=function(_0x5bd102,_0x35b7eb){return BPromise[_0x1d22('0xa')]()[_0x1d22('0xb')](cmHopper[_0x1d22('0x2d')](_0x5bd102,_0x35b7eb))[_0x1d22('0x9')](loggerCatch('[GetContactRecallMe]\x20'));};exports[_0x1d22('0x2e')]=function(_0x1722ab){return cmHopper[_0x1d22('0x11')](_0x1722ab,!![],!![])[_0x1d22('0x9')](loggerCatch(_0x1d22('0x2f')));}; \ No newline at end of file diff --git a/server/services/ami/preview/util/util.js b/server/services/ami/preview/util/util.js new file mode 100644 index 0000000..82123c1 --- /dev/null +++ b/server/services/ami/preview/util/util.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3e88=['talktime','answertime','Failure','variablesAction','RECALL','uniqueid','originate','channelAgent','from-sip','timeout','totalGlobal','countbusyretry','countcongestionretry','countnoanswerretry','countagentrejectretry','cloneAction','clone','Global','active','add','minutes','ListId','pTalking','[decrementTalkink]\x20object\x20talking\x20is\x20negative','[decrementTalkink]\x20is\x20null\x20or\x20undefined','IsNotLoggedIn','lastevent','motionChannel','mandatoryDisposition','buildObj','buildAcw','queue','interface','agentReadyId','not_inuse','reachable','push','getDiff','milliseconds','diff','createBody','CampaignId','type','campaigntype','dialAnswer','scheduledat','countglobal','callback','callbackuniqueid','callbackat','sipcallid','xmd-voicequeueid','xmd-queue','xmd-dialtimeout','xmd-dialid','xmd-dialchannel','xmd-contactid','xmd-cdrtype','xmd-callerid','xmd-agiafter','xmd-agi','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','bridgepeer','pow','replace','extractCalleridName','extractCalleridNumber','noanswer','variables','keys','forEach','toLowerCase','moment','../../../../config/logger','preview','env','127.0.0.1','../../dialer/utils','loggerCatch','error','inspect','logger','info','logger2','message','getCallerId','isUndefined','string','isEmpty','\x22%s\x22\x20<%s>','isNil','Queue','name','format','calleridname','calleridnum','ContactId','dialer','VoiceQueueId','dialOriginateTimeout','\x22rtTxX%s%s\x22','dialQueueProject2','dialPreviewUrl','\x22agi://%s/square,%s\x22','dialQueueProject','NONE','originatecalleridnum','xcally-motion-preview','Call-Type:\x20PREVIEW','_XCALLY_MIXMONITOR_FORMAT','_XCALLY_MIXMONITOR_UNIQUEID','Contact','createdAt','updatedAt','%s%s','toLowerVariables','hasOwnProperty','toLower','originated','[updateOriginated]\x20object\x20originated\x20is\x20negative','[updateOriginated]\x20is\x20null\x20or\x20undefined','logBlacklist','YYYY-MM-DD\x20HH:mm:ss','statedesc','Blacklist','endtime','state','responsetime','ringtime','getSeconds','starttime','logLookAgent','membername','UserId','logCustomer'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x3e88,0xdd));var _0x83e8=function(_0x2a60eb,_0x23ec35){_0x2a60eb=_0x2a60eb-0x0;var _0x25ddb6=_0x3e88[_0x2a60eb];return _0x25ddb6;};'use strict';var util=require('util');var _=require('lodash');var moment=require(_0x83e8('0x0'));var logger=require(_0x83e8('0x1'))(_0x83e8('0x2'));var ipAgi=process[_0x83e8('0x3')]['XCALLY_IP_AGI']||_0x83e8('0x4');var utils=require(_0x83e8('0x5'));exports[_0x83e8('0x6')]=function(_0x4313cf){return function(_0x25441a){logger[_0x83e8('0x7')](_0x4313cf,util[_0x83e8('0x8')](_0x25441a,{'showHidden':![],'depth':null}));};};exports[_0x83e8('0x9')]=function(_0x1aef52,_0x114f8f){logger[_0x83e8('0xa')](_0x1aef52,util[_0x83e8('0x8')](_0x114f8f,{'showHidden':![],'depth':null}));};exports['loggerError']=function(_0x1b658e,_0x1d5ab0){logger['error'](_0x1b658e,util[_0x83e8('0x8')](_0x1d5ab0,{'showHidden':![],'depth':null}));};exports[_0x83e8('0xb')]=function(_0x186de0){return function(_0x46ae62){logger[_0x83e8('0xa')](_0x186de0,util[_0x83e8('0x8')](_0x46ae62,{'showHidden':![],'depth':null}));};};exports[_0x83e8('0xc')]=function(_0x571fcd,_0xf6f310,_0x16e6a9){return{'message':_0x571fcd,'unlock':_0xf6f310,'active':_0x16e6a9};};exports[_0x83e8('0xd')]=function(_0x1e38bf,_0x42175d,_0x1009e9){if(!_[_0x83e8('0xe')](_0x1009e9)&&_0x83e8('0xf')===typeof _0x1009e9&&!_[_0x83e8('0x10')](_0x1009e9)){if(!_[_0x83e8('0xe')](_0x42175d)&&_0x83e8('0xf')===typeof _0x42175d&&!_[_0x83e8('0x10')](_0x42175d)){return util['format'](_0x83e8('0x11'),_0x42175d,_0x1009e9);}return util['format'](_0x83e8('0x11'),_0x1009e9,_0x1009e9);}if(!_['isUndefined'](_0x1e38bf)&&_0x83e8('0xf')===typeof _0x1e38bf&&!_[_0x83e8('0x10')](_0x1e38bf)){return _0x1e38bf;}return'\x22\x22\x20<>';};exports['isActive']=function(_0x59af2a){if(_[_0x83e8('0x12')](_0x59af2a)){return![];}return _0x59af2a;};exports['addVariables']=function(_0x3ad734,_0x590e26,_0x1dcd7e,_0x1a50ee,_0x2a5070,_0x5efd03){var _0x32d5be={'XMD-QUEUE':_0x590e26[_0x83e8('0x13')]?_0x590e26[_0x83e8('0x13')][_0x83e8('0x14')]:'','XMD-CALLERID':_0x1a50ee,'XMD-CALLERID-PREVIEW':_0x5efd03?util[_0x83e8('0x15')]('\x22%s\x22\x20<%s>',_0x5efd03[_0x83e8('0x16')],_0x5efd03[_0x83e8('0x17')]):_0x1a50ee,'XMD-DIALID':_0x2a5070,'XMD-CONTACTID':_0x590e26[_0x83e8('0x18')],'XMD-CDRTYPE':_0x83e8('0x19'),'CALLERID(all)':_0x1a50ee,'XMD-VOICEQUEUEID':_0x590e26[_0x83e8('0x1a')],'XMD-DIALCHANNEL':_0x1dcd7e,'XMD-DIALTIMEOUT':_0x3ad734[_0x83e8('0x1b')]||0x1e,'XMD-DIALOPTIONS':util[_0x83e8('0x15')](_0x83e8('0x1c'),_0x3ad734[_0x83e8('0x1d')]?'g':'',_[_0x83e8('0x10')](_0x3ad734['monitor_format'])?'':'U(xcally-mixmonitor-context)'),'XMD-DIALURL':_0x3ad734[_0x83e8('0x1e')]||'','XMD-AGI':_0x3ad734['dialQueueProject']?util[_0x83e8('0x15')](_0x83e8('0x1f'),ipAgi,_0x3ad734[_0x83e8('0x20')]):'NONE','XMD-AGIAFTER':_0x3ad734[_0x83e8('0x1d')]?util[_0x83e8('0x15')](_0x83e8('0x1f'),ipAgi,_0x3ad734[_0x83e8('0x1d')]):_0x83e8('0x21'),'XMD-ORIGINATECALLERIDNUM':_0x5efd03?_0x5efd03[_0x83e8('0x22')]:'','XMD-ORIGINATECALLERIDNAME':_0x5efd03?_0x5efd03['originatecalleridname']:'','XMD-DESTINATION':_0x83e8('0x23'),'SIPADDHEADER':_0x83e8('0x24')};if(!_['isEmpty'](_0x3ad734['monitor_format'])){_0x32d5be[util[_0x83e8('0x15')]('%s',_0x83e8('0x25'))]=_0x3ad734['monitor_format'];_0x32d5be[util[_0x83e8('0x15')]('%s',_0x83e8('0x26'))]=_0x2a5070;}if(_0x590e26&&_0x590e26[_0x83e8('0x27')]){for(var _0x53418d in _0x590e26['Contact']){if(_0x590e26[_0x83e8('0x27')]['hasOwnProperty'](_0x53418d)){if(!_[_0x83e8('0x12')](_0x590e26[_0x83e8('0x27')][_0x53418d])&&_0x53418d!=='id'&&_0x53418d!=='tags'&&_0x53418d!==_0x83e8('0x28')&&_0x53418d!==_0x83e8('0x29')){_0x32d5be[util[_0x83e8('0x15')](_0x83e8('0x2a'),'XMD-',_['toUpper'](_0x53418d))]=_0x590e26[_0x83e8('0x27')][_0x53418d];}}}}return _0x32d5be;};exports[_0x83e8('0x2b')]=function(_0x12c41c){var _0x5d3959={};for(var _0x57c015 in _0x12c41c){if(_0x12c41c[_0x83e8('0x2c')](_0x57c015)){_0x5d3959[util[_0x83e8('0x15')]('%s',_[_0x83e8('0x2d')](_0x57c015))]=_0x12c41c[_0x57c015];}}return{'variables':_0x5d3959};};exports['updateOriginated']=function(_0x452b0d,_0x53114c){if(!_['isNil'](_0x452b0d)){if(_0x452b0d[_0x83e8('0x2c')](_0x83e8('0x2e'))){if(_0x452b0d[_0x83e8('0x2e')]>0x0){_0x452b0d[_0x83e8('0x2e')]-=0x1;}else{logger[_0x83e8('0x7')](_0x83e8('0x2f'),_0x53114c);}}}else{logger['error'](_0x83e8('0x30'),_0x53114c);}};exports[_0x83e8('0x31')]=function(_0x167b3a){var _0x409636=moment()[_0x83e8('0x15')](_0x83e8('0x32'));_0x167b3a['state']=0xd;_0x167b3a[_0x83e8('0x33')]=_0x83e8('0x34');_0x167b3a['starttime']=_0x409636;_0x167b3a['responsetime']=_0x409636;_0x167b3a[_0x83e8('0x35')]=_0x409636;};exports['logAgent']=function(_0x147050,_0x4f7870,_0x1880c9){var _0x2f7df0=moment()[_0x83e8('0x15')](_0x83e8('0x32'));_0x147050[_0x83e8('0x36')]=_0x4f7870;_0x147050['statedesc']=_0x1880c9;_0x147050[_0x83e8('0x37')]=_0x2f7df0;_0x147050[_0x83e8('0x38')]=utils[_0x83e8('0x39')](_0x147050[_0x83e8('0x37')],_0x147050[_0x83e8('0x3a')]);};exports[_0x83e8('0x3b')]=function(_0x33d263,_0x47ddd2,_0x4739cb){_0x33d263[_0x83e8('0x3c')]=_0x47ddd2;_0x33d263[_0x83e8('0x3d')]=_0x4739cb;};exports[_0x83e8('0x3e')]=function(_0x3d15c1,_0x2a54af,_0x424c85){var _0x25fa16=moment()[_0x83e8('0x15')](_0x83e8('0x32'));_0x3d15c1[_0x83e8('0x36')]=_0x2a54af;_0x3d15c1[_0x83e8('0x33')]=_0x424c85;_0x3d15c1[_0x83e8('0x37')]=_0x3d15c1['responsetime']?_0x3d15c1[_0x83e8('0x37')]:_0x25fa16;_0x3d15c1[_0x83e8('0x35')]=_0x3d15c1[_0x83e8('0x35')]?_0x3d15c1[_0x83e8('0x35')]:_0x25fa16;_0x3d15c1[_0x83e8('0x38')]=utils[_0x83e8('0x39')](_0x3d15c1[_0x83e8('0x37')]||0x0,_0x3d15c1[_0x83e8('0x3a')]||0x0);_0x3d15c1[_0x83e8('0x3f')]=_0x3d15c1[_0x83e8('0x40')]?utils['getSeconds'](_0x3d15c1[_0x83e8('0x35')],_0x3d15c1[_0x83e8('0x40')]):0x0;};exports['isFailure']=function(_0x44fda0){return _0x44fda0===_0x83e8('0x41');};exports[_0x83e8('0x42')]=function(_0x494332,_0x21bc83,_0x3bb260,_0x136f8d,_0xd19168){var _0x3cafb4=_0x136f8d?_0x83e8('0x43'):_0x494332[_0x83e8('0x16')];_0x3cafb4=_0xd19168?'BOOKED':_0x3cafb4;return{'actionid':_0x494332[_0x83e8('0x44')],'action':_0x83e8('0x45'),'channel':_0x494332[_0x83e8('0x46')],'callerid':util[_0x83e8('0x15')](_0x83e8('0x11'),_0x3cafb4,_0x494332[_0x83e8('0x17')]),'Exten':'xcally-motion-preview','Context':_0x83e8('0x47'),'Priority':'1','variable':_0x3bb260,'timeout':(_0x21bc83[_0x83e8('0x48')]||0x1e)*0x3e8,'async':!![],'channelid':_0x494332[_0x83e8('0x44')]};};exports[_0x83e8('0x49')]=function(_0xd47861){return _0xd47861[_0x83e8('0x4a')]+_0xd47861[_0x83e8('0x4b')]+_0xd47861[_0x83e8('0x4c')]+_0xd47861[_0x83e8('0x4d')]+_0xd47861['countnosuchnumberretry'];};exports[_0x83e8('0x4e')]=function(_0x164cbe){var _0x21f34e=_[_0x83e8('0x4f')](_0x164cbe);_0x21f34e[_0x83e8('0x36')]=0xf;_0x21f34e[_0x83e8('0x33')]=_0x83e8('0x50');return _0x21f34e;};exports['scheduledAt']=function(_0x1a2472,_0x10f20f,_0x169451){var _0x542365={};_0x542365[_0x10f20f]=_0x1a2472[_0x10f20f];_0x542365[_0x83e8('0x51')]=![];_0x542365['scheduledat']=moment()[_0x83e8('0x52')](_0x169451,_0x83e8('0x53'))['format'](_0x83e8('0x32'));_0x542365[_0x83e8('0x18')]=_0x1a2472[_0x83e8('0x18')];_0x542365['ListId']=_0x1a2472[_0x83e8('0x54')];_0x542365[_0x83e8('0x1a')]=_0x1a2472['VoiceQueueId']||undefined;return _0x542365;};exports['decrementTalkink']=function(_0x49d58d,_0x1b7bee){if(!_['isNil'](_0x49d58d)){if(_0x49d58d[_0x83e8('0x55')]>0x0){_0x49d58d[_0x83e8('0x55')]-=0x1;}else{logger[_0x83e8('0x7')](_0x1b7bee,_0x83e8('0x56'));}}else{logger[_0x83e8('0x7')](_0x1b7bee,_0x83e8('0x57'));}};exports[_0x83e8('0x58')]=function(_0x1eb887){if(_0x1eb887<=0x0){return!![];}return![];};function buildObj(_0x57d25c,_0x2bb3ef,_0x2ed0d7){_0x57d25c[_0x83e8('0x59')]=_0x2bb3ef;_0x57d25c[_0x83e8('0x14')]=_0x57d25c['queue'];_0x57d25c['interface']=_0x57d25c['channelAgent'];_0x57d25c[_0x83e8('0x5a')]='voice';if(_0x2ed0d7){_0x57d25c[_0x83e8('0x5b')]=_0x2ed0d7[_0x83e8('0x5b')];}return _0x57d25c;}exports[_0x83e8('0x5c')]=buildObj;exports[_0x83e8('0x5d')]=function(_0x31f6ca){var _0x401e27={};_0x401e27['queue']=_0x31f6ca[_0x83e8('0x5e')];_0x401e27[_0x83e8('0x5f')]=_0x31f6ca[_0x83e8('0x46')];_0x401e27['uniqueid']=_0x31f6ca['uniqueid'];return _0x401e27;};exports[_0x83e8('0x60')]=function(_0x3bae92){var _0x40cc4e=[];for(var _0x18b9ee in _0x3bae92){if(_0x3bae92['hasOwnProperty'](_0x18b9ee)){if(!_['isNil'](_0x3bae92[_0x18b9ee])&&_0x3bae92[_0x18b9ee][_0x83e8('0x36')]===_0x83e8('0x61')&&_0x3bae92[_0x18b9ee]['status']===_0x83e8('0x62')){_0x40cc4e[_0x83e8('0x63')](_0x3bae92[_0x18b9ee]['id']);}}}return _0x40cc4e;};exports[_0x83e8('0x64')]=function(_0x3b3922){var _0x2d14f3=moment()[_0x83e8('0x65')](0x0);var _0x2723ff=moment(_0x3b3922)[_0x83e8('0x65')](0x0);return _0x2d14f3[_0x83e8('0x66')](_0x2723ff,'seconds');};exports[_0x83e8('0x67')]=function(_0x594aff){return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x594aff[_0x83e8('0x18')],'ListId':_0x594aff[_0x83e8('0x54')],'VoiceQueueId':_0x594aff[_0x83e8('0x1a')]||undefined,'CampaignId':_0x594aff[_0x83e8('0x68')]||undefined};};exports['filterKey']=function(_0x1b8754){if(_0x1b8754==='uniqueid'||_0x1b8754==='idContact'||_0x1b8754===_0x83e8('0x5e')||_0x1b8754===_0x83e8('0x69')||_0x1b8754===_0x83e8('0x6a')||_0x1b8754===_0x83e8('0x6b')||_0x1b8754===_0x83e8('0x3c')||_0x1b8754==='channelAgent'||_0x1b8754===_0x83e8('0x16')||_0x1b8754===_0x83e8('0x51')||_0x1b8754===_0x83e8('0x17')||_0x1b8754===_0x83e8('0x6c')||_0x1b8754===_0x83e8('0x4a')||_0x1b8754===_0x83e8('0x4b')||_0x1b8754===_0x83e8('0x4c')||_0x1b8754===_0x83e8('0x6d')||_0x1b8754===_0x83e8('0x6e')||_0x1b8754===_0x83e8('0x6f')||_0x1b8754===_0x83e8('0x70')||_0x1b8754==='recallme'||_0x1b8754===_0x83e8('0x18')||_0x1b8754==='ListId'||_0x1b8754===_0x83e8('0x3d')||_0x1b8754===_0x83e8('0x1a')||_0x1b8754===_0x83e8('0x71')||_0x1b8754===_0x83e8('0x72')||_0x1b8754===_0x83e8('0x73')||_0x1b8754==='xmd-phone'||_0x1b8754==='xmd-listid'||_0x1b8754==='xmd-dialurl'||_0x1b8754===_0x83e8('0x74')||_0x1b8754==='xmd-dialoptions'||_0x1b8754===_0x83e8('0x75')||_0x1b8754===_0x83e8('0x76')||_0x1b8754===_0x83e8('0x77')||_0x1b8754===_0x83e8('0x78')||_0x1b8754===_0x83e8('0x79')||_0x1b8754===_0x83e8('0x7a')||_0x1b8754===_0x83e8('0x7b')||_0x1b8754===_0x83e8('0x7c')||_0x1b8754===_0x83e8('0x7d')||_0x1b8754===_0x83e8('0x7e')||_0x1b8754===_0x83e8('0x7f')||_0x1b8754===_0x83e8('0x80')||_0x1b8754===_0x83e8('0x81')||_0x1b8754===_0x83e8('0x82')||_0x1b8754===_0x83e8('0x83')||_0x1b8754===_0x83e8('0x7c')||_0x1b8754===_0x83e8('0x7d')||_0x1b8754===_0x83e8('0x7e')||_0x1b8754==='rtpaudioqosjitterbridged'||_0x1b8754===_0x83e8('0x80')||_0x1b8754===_0x83e8('0x81')||_0x1b8754==='rtpaudioqosrtt'||_0x1b8754===_0x83e8('0x83')||_0x1b8754===_0x83e8('0x84')||_0x1b8754==='bridgepvtcallid'||_0x1b8754===_0x83e8('0x36')||_0x1b8754==='statedesc'){return![];}return!![];};exports['getCallerIdRandom']=function(_0x2869c6,_0x2e9e75){var _0x4d30b7,_0x24fdd8,_0x1e42fd;if(_0x2e9e75<=0x0){_0x2e9e75=0x1;}_0x4d30b7=new RegExp('\x5cw{0,'+_0x2e9e75+'}$');_0x24fdd8=Math['pow'](0xa,_0x2e9e75-0x1);_0x1e42fd=Math[_0x83e8('0x85')](0xa,_0x2e9e75)-0x1;return util[_0x83e8('0x15')]('%s',_[_0x83e8('0x86')](_0x2869c6,_0x4d30b7,_['random'](_0x24fdd8,_0x1e42fd)));};exports[_0x83e8('0x87')]=function(_0x2aac0c){var _0x311791=_0x2aac0c['match'](/"(.*?)"/);return _0x311791?_0x311791[0x1]:_0x2aac0c;};exports[_0x83e8('0x88')]=function(_0x4afbe0){var _0x3d29d7=_0x4afbe0['match'](/<(.*?)>/);return _0x3d29d7?_0x3d29d7[0x1]:_0x4afbe0;};function buildNoAnswerEventPayload(_0x4535c9,_0x5e50b8){var _0x5a289e=buildObj(_0x4535c9,_0x83e8('0x89'));if(!_[_0x83e8('0x10')](_0x5e50b8[_0x83e8('0x8a')])){Object[_0x83e8('0x8b')](_0x5e50b8['variables'])[_0x83e8('0x8c')](function(_0x17d38e){_0x5a289e[_0x17d38e[_0x83e8('0x8d')]()]=_0x5e50b8[_0x83e8('0x8a')][_0x17d38e];});}return _0x5a289e;}exports['buildNoAnswerEventPayload']=buildNoAnswerEventPayload; \ No newline at end of file diff --git a/server/services/ami/properties.js b/server/services/ami/properties.js new file mode 100644 index 0000000..d81a788 --- /dev/null +++ b/server/services/ami/properties.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2bd8=['reload','voicechannel','voicequeuechannelhangup','voicequeuechannelredirect','queueadd','string','number','boolean','queueremove','queuepause'];(function(_0xae93a4,_0x14c338){var _0x582985=function(_0x29c47c){while(--_0x29c47c){_0xae93a4['push'](_0xae93a4['shift']());}};_0x582985(++_0x14c338);}(_0x2bd8,0x72));var _0x82bd=function(_0x431721,_0x45b6fc){_0x431721=_0x431721-0x0;var _0x53ee25=_0x2bd8[_0x431721];return _0x53ee25;};'use strict';exports[_0x82bd('0x0')]={'queue':{'type':'string','required':!![]},'interface':{'type':'string','required':!![]},'membername':{'type':_0x82bd('0x1'),'required':!![]},'penalty':{'type':_0x82bd('0x2'),'required':![]},'paused':{'type':_0x82bd('0x3'),'required':![]}};exports[_0x82bd('0x4')]={'queue':{'type':'string','required':!![]},'interface':{'type':'string','required':!![]}};exports[_0x82bd('0x5')]={'interface':{'type':_0x82bd('0x1'),'required':!![]},'paused':{'type':_0x82bd('0x3')},'reason':{'type':_0x82bd('0x1'),'required':![]}};exports[_0x82bd('0x6')]={'module':{'type':_0x82bd('0x1'),'required':![]}};exports['voicequeuechannel']={'uniqueid':{'type':_0x82bd('0x1'),'required':!![]}};exports[_0x82bd('0x7')]={'uniqueid':{'type':_0x82bd('0x1'),'required':!![]},'filename':{'type':_0x82bd('0x1')},'format':{'type':_0x82bd('0x1')},'mixmonitorid':{'type':_0x82bd('0x1')}};exports[_0x82bd('0x8')]={'uniqueid':{'type':_0x82bd('0x1'),'required':!![]}};exports[_0x82bd('0x9')]={'uniqueid':{'type':_0x82bd('0x1'),'required':!![]},'exten':{'type':_0x82bd('0x1'),'required':!![]},'context':{'type':_0x82bd('0x1')}}; \ No newline at end of file diff --git a/server/services/ami/realtime/index.js b/server/services/ami/realtime/index.js new file mode 100644 index 0000000..0cc94f8 --- /dev/null +++ b/server/services/ami/realtime/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xadb5=['ivrTotalCallsDays','ivrAnswerCallsDay','unmanaged','sumBillable','outboundAnswerAgiCallsDay','outboundNoAnswerCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundUnknownCallsDay','outboundDropCallsDayTimeout','outboundDropCallsDayCallersExit','outboundBlacklistCallsDay','outboundOriginateFailureCallsDay','outboundRejectCallsDay','outboundReCallsDay','outboundAnswerCallsDay','queueStatusComplete','mergeFromDatabase','prototype','initAgents','initTelephones','length','isUndefined','triggers','initTemplates','initZendeskAccounts','initSalesforceAccounts','initFreshdeskAccounts','initDeskAccounts','initSugarcrmAccounts','sugarcrmAccounts','initVtigerAccounts','vtigerAccounts','initServicenowAccounts','dynamics365Accounts','initFreshsalesAccounts','initVoiceQueueHopperHistory','merge','initVoiceQueueReports','voiceQueues','groupBy','uniqueid','queue','queuecallerexit','queuecallerabandon','abandoned','queuecallerleaveAt','diff','seconds','queuecallerabandonAt','queuecallerexitAt','queuecallerjoinAt','queuecallercomplete','queuecallercompleteAt','duration','ANSWERED','billableseconds','initCampaigns','dialQueueProject','initVoiceExtensions','voiceExtensions','initCampaignHopperHistory','initFaxAccounts','moment','../model/agent','../model/telephone','../model/trunk','../model/trigger','../model/template','../model/campaign','../model/zendeskAccount','../model/salesforceAccount','../model/freshdeskAccount','../model/sugarcrmAccount','../model/zohoAccount','../model/deskAccount','../model/vtigerAccount','../model/servicenowAccount','../model/dynamics365Account','../model/freshsalesAccount','../model/faxAccount','agents','telephones','trunks','campaigns','templates','outbound','channels','outboundChannels','settings','zendeskAccounts','salesforceAccounts','freshdeskAccounts','zohoAccounts','deskAccounts','servicenowAccounts','freshsalesAccounts','faxAccounts','mapKeys','name','hasOwnProperty','isNil','interface','format','SIP/%s','total','answered','sumHoldTime','sumDuration','isEmpty'];(function(_0x13b470,_0x39f432){var _0x14b02d=function(_0x3b2a22){while(--_0x3b2a22){_0x13b470['push'](_0x13b470['shift']());}};_0x14b02d(++_0x39f432);}(_0xadb5,0xad));var _0x5adb=function(_0xa63ec2,_0x382697){_0xa63ec2=_0xa63ec2-0x0;var _0x562c25=_0xadb5[_0xa63ec2];return _0x562c25;};'use strict';var _=require('lodash');var moment=require(_0x5adb('0x0'));var util=require('util');var Agent=require(_0x5adb('0x1'));var Telephone=require(_0x5adb('0x2'));var Trunk=require(_0x5adb('0x3'));var VoiceQueue=require('../model/voiceQueue');var Trigger=require(_0x5adb('0x4'));var Template=require(_0x5adb('0x5'));var Campaign=require(_0x5adb('0x6'));var VoiceExtension=require('../model/voiceExtension');var ZendeskAccount=require(_0x5adb('0x7'));var SalesforceAccount=require(_0x5adb('0x8'));var FreshdeskAccount=require(_0x5adb('0x9'));var SugarcrmAccount=require(_0x5adb('0xa'));var ZohoAccount=require(_0x5adb('0xb'));var DeskAccount=require(_0x5adb('0xc'));var VtigerAccount=require(_0x5adb('0xd'));var ServicenowAccount=require(_0x5adb('0xe'));var Dynamics365Account=require(_0x5adb('0xf'));var FreshsalesAccount=require(_0x5adb('0x10'));var FaxAccount=require(_0x5adb('0x11'));function Realtime(){this[_0x5adb('0x12')]={};this[_0x5adb('0x13')]={};this[_0x5adb('0x14')]={};this['voiceQueues']={};this['triggers']={};this[_0x5adb('0x15')]={};this[_0x5adb('0x16')]={};this[_0x5adb('0x17')]={'total':0x0,'answered':0x0,'sumHoldTime':0x0,'sumDuration':0x0,'sumBillable':0x0};this['voiceExtensions']={};this[_0x5adb('0x18')]={};this['queueChannels']={};this[_0x5adb('0x19')]={};this['timers']={};this[_0x5adb('0x1a')]={};this[_0x5adb('0x1b')]={};this[_0x5adb('0x1c')]={};this['sugarcrmAccounts']={};this[_0x5adb('0x1d')]={};this[_0x5adb('0x1e')]={};this[_0x5adb('0x1f')]={};this['vtigerAccounts']={};this[_0x5adb('0x20')]={};this['dynamics365Accounts']={};this[_0x5adb('0x21')]={};this[_0x5adb('0x22')]={};}function freeIsNotKey(_0x30614e,_0x304784,_0x1c0f97){var _0x39d24d=_[_0x5adb('0x23')](_0x30614e,function(_0x42f4c6){return _0x42f4c6[_0x1c0f97];});for(var _0xb953a6 in _0x304784){if(_0x304784['hasOwnProperty'](_0xb953a6)){if(!_0x39d24d[_0xb953a6]){delete _0x304784[_0xb953a6];}}}}function freeIsNotKeySip(_0x3fff62,_0x5de028){var _0x1d9e86=_['mapKeys'](_0x3fff62,function(_0x3ef465){return util['format']('SIP/%s',_0x3ef465[_0x5adb('0x24')]);});for(var _0x1bed20 in _0x5de028){if(_0x5de028[_0x5adb('0x25')](_0x1bed20)){if(!_0x1d9e86[_0x1bed20]){delete _0x5de028[_0x1bed20];}}}}function freeIsNotKeyAgent(_0x1fd4a7,_0x99bc6c){var _0x5af69d=_[_0x5adb('0x23')](_0x1fd4a7,function(_0x5c296e){var _0x4e9f16=_[_0x5adb('0x26')](_0x5c296e[_0x5adb('0x27')])?util[_0x5adb('0x28')](_0x5adb('0x29'),_0x5c296e[_0x5adb('0x24')]):_0x5c296e[_0x5adb('0x27')];return _0x4e9f16;});for(var _0xfd9bb9 in _0x99bc6c){if(_0x99bc6c['hasOwnProperty'](_0xfd9bb9)){if(!_0x5af69d[_0xfd9bb9]){delete _0x99bc6c[_0xfd9bb9];}}}}function clearVoiceCallReports(_0x4b1957){_0x4b1957[_0x5adb('0x2a')]=0x0;_0x4b1957[_0x5adb('0x2b')]=0x0;_0x4b1957[_0x5adb('0x2c')]=0x0;_0x4b1957[_0x5adb('0x2d')]=0x0;_0x4b1957['sumBillable']=0x0;}function clearCampaigns(_0x2fee18){if(!_[_0x5adb('0x2e')](_0x2fee18)){for(var _0x5aed76 in _0x2fee18){if(_0x2fee18[_0x5adb('0x25')](_0x5aed76)){_0x2fee18[_0x5aed76][_0x5adb('0x2f')]=0x0;_0x2fee18[_0x5aed76][_0x5adb('0x30')]=0x0;}}}}function clearVoiceQueues(_0x55b40a){if(!_[_0x5adb('0x2e')](_0x55b40a)){for(var _0xbe21b1 in _0x55b40a){if(_0x55b40a[_0x5adb('0x25')](_0xbe21b1)){_0x55b40a[_0xbe21b1][_0x5adb('0x2a')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x2b')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x31')]=0x0;_0x55b40a[_0xbe21b1]['abandoned']=0x0;_0x55b40a[_0xbe21b1]['sumHoldTime']=0x0;_0x55b40a[_0xbe21b1]['sumDuration']=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x32')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x33')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x34')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x35')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x36')]=0x0;_0x55b40a[_0xbe21b1]['outboundNoSuchCallsDay']=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x37')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x38')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x39')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3a')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3b')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3c')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3d')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x33')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3e')]=0x0;_0x55b40a[_0xbe21b1][_0x5adb('0x3f')]=!![];}}}}Realtime['prototype'][_0x5adb('0x40')]=function(_0x4c8b2e,_0x12424d){for(var _0x20cde6 in _0x12424d){if(_0x4c8b2e['hasOwnProperty'](_0x20cde6)){_0x4c8b2e[_0x20cde6]=_0x12424d[_0x20cde6];}}};Realtime[_0x5adb('0x41')][_0x5adb('0x42')]=function(){var _0x461a39=this;return function(_0x4a3661){if(_0x4a3661){freeIsNotKeyAgent(_0x4a3661,_0x461a39[_0x5adb('0x12')]);for(var _0x14cf00=0x0,_0x4b5887={};_0x14cf00<_0x4a3661['length'];_0x14cf00+=0x1){_0x4b5887=_0x4a3661[_0x14cf00];var _0x1ed9ea=_['isNil'](_0x4b5887[_0x5adb('0x27')])?util[_0x5adb('0x28')](_0x5adb('0x29'),_0x4b5887[_0x5adb('0x24')]):_0x4b5887[_0x5adb('0x27')];if(_['isUndefined'](_0x461a39[_0x5adb('0x12')][_0x1ed9ea])){_0x461a39[_0x5adb('0x12')][_0x1ed9ea]=new Agent(_0x4b5887);}else{_0x461a39[_0x5adb('0x40')](_0x461a39['agents'][_0x1ed9ea],_0x4b5887);}}}return _0x461a39['agents'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x43')]=function(){var _0x586820=this;return function(_0x2355bc){if(_0x2355bc){freeIsNotKeySip(_0x2355bc,_0x586820['telephones']);for(var _0x199d3b=0x0,_0x58cc5d={};_0x199d3b<_0x2355bc[_0x5adb('0x44')];_0x199d3b+=0x1){_0x58cc5d=_0x2355bc[_0x199d3b];if(_['isUndefined'](_0x586820[_0x5adb('0x13')][util[_0x5adb('0x28')]('SIP/%s',_0x58cc5d[_0x5adb('0x24')])])){_0x586820['telephones'][util[_0x5adb('0x28')](_0x5adb('0x29'),_0x58cc5d[_0x5adb('0x24')])]=new Telephone(_0x58cc5d);}else{_0x586820['mergeFromDatabase'](_0x586820[_0x5adb('0x13')][util[_0x5adb('0x28')](_0x5adb('0x29'),_0x58cc5d[_0x5adb('0x24')])],_0x58cc5d);}}}return _0x586820[_0x5adb('0x13')];};};Realtime['prototype']['initTrunks']=function(){var _0x4f491a=this;return function(_0x599999){if(_0x599999){freeIsNotKeySip(_0x599999,_0x4f491a[_0x5adb('0x14')]);for(var _0x2fbe14=0x0,_0x3a104a={};_0x2fbe14<_0x599999[_0x5adb('0x44')];_0x2fbe14+=0x1){_0x3a104a=_0x599999[_0x2fbe14];if(_[_0x5adb('0x45')](_0x4f491a[_0x5adb('0x14')][util[_0x5adb('0x28')](_0x5adb('0x29'),_0x3a104a['name'])])){_0x4f491a['trunks'][util[_0x5adb('0x28')]('SIP/%s',_0x3a104a[_0x5adb('0x24')])]=new Trunk(_0x3a104a);}else{_0x4f491a[_0x5adb('0x40')](_0x4f491a[_0x5adb('0x14')][util[_0x5adb('0x28')](_0x5adb('0x29'),_0x3a104a['name'])],_0x3a104a);}}}return _0x4f491a[_0x5adb('0x14')];};};Realtime[_0x5adb('0x41')]['initTriggers']=function(){var _0x4160ad=this;return function(_0x1a256c){if(_0x1a256c){freeIsNotKey(_0x1a256c,_0x4160ad['triggers'],'id');for(var _0x120497=0x0,_0x407a4c={};_0x120497<_0x1a256c[_0x5adb('0x44')];_0x120497+=0x1){_0x407a4c=_0x1a256c[_0x120497];if(_[_0x5adb('0x45')](_0x4160ad[_0x5adb('0x46')][_0x407a4c['id']])){_0x4160ad[_0x5adb('0x46')][_0x407a4c['id']]=new Trigger(_0x407a4c);}else{_0x4160ad[_0x5adb('0x40')](_0x4160ad['triggers'][_0x407a4c['id']],_0x407a4c);}}}return _0x4160ad['triggers'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x47')]=function(){var _0x1cd0a3=this;return function(_0xb79d85){if(_0xb79d85){freeIsNotKey(_0xb79d85,_0x1cd0a3['templates'],'id');for(var _0x507e48=0x0,_0xaa32e4={};_0x507e48<_0xb79d85[_0x5adb('0x44')];_0x507e48+=0x1){_0xaa32e4=_0xb79d85[_0x507e48];if(_[_0x5adb('0x45')](_0x1cd0a3[_0x5adb('0x16')][_0xaa32e4['id']])){_0x1cd0a3[_0x5adb('0x16')][_0xaa32e4['id']]=new Template(_0xaa32e4);}else{_0x1cd0a3['mergeFromDatabase'](_0x1cd0a3[_0x5adb('0x16')][_0xaa32e4['id']],_0xaa32e4);}}}return _0x1cd0a3[_0x5adb('0x16')];};};Realtime['prototype'][_0x5adb('0x48')]=function(){var _0x251f45=this;return function(_0x1cdb03){if(_0x1cdb03){freeIsNotKey(_0x1cdb03,_0x251f45[_0x5adb('0x1b')],'id');for(var _0x186bd2=0x0,_0x3a5409={};_0x186bd2<_0x1cdb03[_0x5adb('0x44')];_0x186bd2+=0x1){_0x3a5409=_0x1cdb03[_0x186bd2];if(_[_0x5adb('0x45')](_0x251f45['zendeskAccounts'][_0x3a5409['id']])){_0x251f45[_0x5adb('0x1b')][_0x3a5409['id']]=new ZendeskAccount(_0x3a5409);}else{_0x251f45['mergeFromDatabase'](_0x251f45['zendeskAccounts'][_0x3a5409['id']],_0x3a5409);}}}return _0x251f45['zendeskAccounts'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x49')]=function(){var _0x207a81=this;return function(_0x4ba0b5){if(_0x4ba0b5){freeIsNotKey(_0x4ba0b5,_0x207a81[_0x5adb('0x1c')],'id');for(var _0x5cbab5=0x0,_0x177a81={};_0x5cbab5<_0x4ba0b5[_0x5adb('0x44')];_0x5cbab5+=0x1){_0x177a81=_0x4ba0b5[_0x5cbab5];if(_[_0x5adb('0x45')](_0x207a81['salesforceAccounts'][_0x177a81['id']])){_0x207a81[_0x5adb('0x1c')][_0x177a81['id']]=new SalesforceAccount(_0x177a81);}else{_0x207a81['mergeFromDatabase'](_0x207a81[_0x5adb('0x1c')][_0x177a81['id']],_0x177a81);}}}return _0x207a81[_0x5adb('0x1c')];};};Realtime['prototype'][_0x5adb('0x4a')]=function(){var _0x1ab97b=this;return function(_0x3594e3){if(_0x3594e3){freeIsNotKey(_0x3594e3,_0x1ab97b[_0x5adb('0x1d')],'id');for(var _0x372734=0x0,_0x4cb36c={};_0x372734<_0x3594e3[_0x5adb('0x44')];_0x372734+=0x1){_0x4cb36c=_0x3594e3[_0x372734];if(_[_0x5adb('0x45')](_0x1ab97b[_0x5adb('0x1d')][_0x4cb36c['id']])){_0x1ab97b[_0x5adb('0x1d')][_0x4cb36c['id']]=new FreshdeskAccount(_0x4cb36c);}else{_0x1ab97b['mergeFromDatabase'](_0x1ab97b[_0x5adb('0x1d')][_0x4cb36c['id']],_0x4cb36c);}}}return _0x1ab97b[_0x5adb('0x1d')];};};Realtime[_0x5adb('0x41')]['initZohoAccounts']=function(){var _0x2b34a8=this;return function(_0xd0e5b7){if(_0xd0e5b7){freeIsNotKey(_0xd0e5b7,_0x2b34a8[_0x5adb('0x1e')],'id');for(var _0xfd3471=0x0,_0x4f2da9={};_0xfd3471<_0xd0e5b7[_0x5adb('0x44')];_0xfd3471+=0x1){_0x4f2da9=_0xd0e5b7[_0xfd3471];if(_[_0x5adb('0x45')](_0x2b34a8[_0x5adb('0x1e')][_0x4f2da9['id']])){_0x2b34a8[_0x5adb('0x1e')][_0x4f2da9['id']]=new ZohoAccount(_0x4f2da9);}else{_0x2b34a8[_0x5adb('0x40')](_0x2b34a8['zohoAccounts'][_0x4f2da9['id']],_0x4f2da9);}}}return _0x2b34a8[_0x5adb('0x1e')];};};Realtime['prototype'][_0x5adb('0x4b')]=function(){var _0x4f7227=this;return function(_0x31ae72){if(_0x31ae72){freeIsNotKey(_0x31ae72,_0x4f7227[_0x5adb('0x1f')],'id');for(var _0x1a9358=0x0,_0x42f6d9={};_0x1a9358<_0x31ae72['length'];_0x1a9358+=0x1){_0x42f6d9=_0x31ae72[_0x1a9358];if(_[_0x5adb('0x45')](_0x4f7227[_0x5adb('0x1f')][_0x42f6d9['id']])){_0x4f7227[_0x5adb('0x1f')][_0x42f6d9['id']]=new DeskAccount(_0x42f6d9);}else{_0x4f7227['mergeFromDatabase'](_0x4f7227['deskAccounts'][_0x42f6d9['id']],_0x42f6d9);}}}return _0x4f7227['deskAccounts'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x4c')]=function(){var _0xa5ecc0=this;return function(_0x12a146){if(_0x12a146){freeIsNotKey(_0x12a146,_0xa5ecc0[_0x5adb('0x4d')],'id');for(var _0xb06bee=0x0,_0x204b9b={};_0xb06bee<_0x12a146[_0x5adb('0x44')];_0xb06bee+=0x1){_0x204b9b=_0x12a146[_0xb06bee];if(_[_0x5adb('0x45')](_0xa5ecc0[_0x5adb('0x4d')][_0x204b9b['id']])){_0xa5ecc0[_0x5adb('0x4d')][_0x204b9b['id']]=new SugarcrmAccount(_0x204b9b);}else{_0xa5ecc0[_0x5adb('0x40')](_0xa5ecc0[_0x5adb('0x4d')][_0x204b9b['id']],_0x204b9b);}}}return _0xa5ecc0['sugarcrmAccounts'];};};Realtime['prototype'][_0x5adb('0x4e')]=function(){var _0x27a8e4=this;return function(_0x43cde9){if(_0x43cde9){freeIsNotKey(_0x43cde9,_0x27a8e4[_0x5adb('0x4f')],'id');for(var _0x5d7a9f=0x0,_0xfba0d5={};_0x5d7a9f<_0x43cde9[_0x5adb('0x44')];_0x5d7a9f+=0x1){_0xfba0d5=_0x43cde9[_0x5d7a9f];if(_['isUndefined'](_0x27a8e4[_0x5adb('0x4f')][_0xfba0d5['id']])){_0x27a8e4[_0x5adb('0x4f')][_0xfba0d5['id']]=new VtigerAccount(_0xfba0d5);}else{_0x27a8e4[_0x5adb('0x40')](_0x27a8e4['vtigerAccounts'][_0xfba0d5['id']],_0xfba0d5);}}}return _0x27a8e4[_0x5adb('0x4f')];};};Realtime[_0x5adb('0x41')][_0x5adb('0x50')]=function(){var _0x30c92c=this;return function(_0x330290){if(_0x330290){freeIsNotKey(_0x330290,_0x30c92c[_0x5adb('0x20')],'id');for(var _0x513f26=0x0,_0x836b91={};_0x513f26<_0x330290[_0x5adb('0x44')];_0x513f26+=0x1){_0x836b91=_0x330290[_0x513f26];if(_[_0x5adb('0x45')](_0x30c92c['servicenowAccounts'][_0x836b91['id']])){_0x30c92c[_0x5adb('0x20')][_0x836b91['id']]=new ServicenowAccount(_0x836b91);}else{_0x30c92c[_0x5adb('0x40')](_0x30c92c[_0x5adb('0x20')][_0x836b91['id']],_0x836b91);}}}return _0x30c92c['servicenowAccounts'];};};Realtime[_0x5adb('0x41')]['initDynamics365Accounts']=function(){var _0xa8ff64=this;return function(_0x1e7e3a){if(_0x1e7e3a){freeIsNotKey(_0x1e7e3a,_0xa8ff64[_0x5adb('0x51')],'id');for(var _0x57f0a4=0x0,_0x192b1f={};_0x57f0a4<_0x1e7e3a[_0x5adb('0x44')];_0x57f0a4+=0x1){_0x192b1f=_0x1e7e3a[_0x57f0a4];if(_['isUndefined'](_0xa8ff64[_0x5adb('0x51')][_0x192b1f['id']])){_0xa8ff64[_0x5adb('0x51')][_0x192b1f['id']]=new Dynamics365Account(_0x192b1f);}else{_0xa8ff64[_0x5adb('0x40')](_0xa8ff64[_0x5adb('0x51')][_0x192b1f['id']],_0x192b1f);}}}return _0xa8ff64['dynamics365Accounts'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x52')]=function(){var _0x307f07=this;return function(_0x16716e){if(_0x16716e){freeIsNotKey(_0x16716e,_0x307f07['freshsalesAccounts'],'id');for(var _0x53a4bc=0x0,_0x304512={};_0x53a4bc<_0x16716e['length'];_0x53a4bc+=0x1){_0x304512=_0x16716e[_0x53a4bc];if(_['isUndefined'](_0x307f07['freshsalesAccounts'][_0x304512['id']])){_0x307f07[_0x5adb('0x21')][_0x304512['id']]=new FreshsalesAccount(_0x304512);}else{_0x307f07[_0x5adb('0x40')](_0x307f07['freshsalesAccounts'][_0x304512['id']],_0x304512);}}}return _0x307f07[_0x5adb('0x21')];};};Realtime[_0x5adb('0x41')][_0x5adb('0x53')]=function(){var _0xf6ef8a=this;return function(_0x358a23){for(var _0x126e38=0x0;_0x126e38<_0x358a23[_0x5adb('0x44')];_0x126e38+=0x1){_[_0x5adb('0x54')](_0xf6ef8a['voiceQueues'][_0x358a23[_0x126e38]['name']],_0x358a23[_0x126e38]);}return _0xf6ef8a['voiceQueues'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x55')]=function(){var _0x3a0d1b=this;return function(_0x2a55a3){clearVoiceQueues(_0x3a0d1b[_0x5adb('0x56')]);if(_0x2a55a3){_0x2a55a3=_[_0x5adb('0x57')](_0x2a55a3,_0x5adb('0x58'));for(var _0x25f761 in _0x2a55a3){if(_0x2a55a3['hasOwnProperty'](_0x25f761)){for(var _0x5e55c2=0x0;_0x5e55c2<_0x2a55a3[_0x25f761][_0x5adb('0x44')];_0x5e55c2+=0x1){var _0x56df90=_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x59')];if(_0x3a0d1b[_0x5adb('0x56')][_0x56df90]){if(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x5a')]){_0x3a0d1b[_0x5adb('0x56')][_0x56df90][_0x5adb('0x31')]+=0x1;}if(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x5b')]){_0x3a0d1b[_0x5adb('0x56')][_0x56df90][_0x5adb('0x5c')]+=0x1;}_0x3a0d1b['voiceQueues'][_0x56df90][_0x5adb('0x2c')]+=moment(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x5d')])[_0x5adb('0x5e')](moment(_0x2a55a3[_0x25f761][_0x5e55c2]['queuecallerjoinAt']),_0x5adb('0x5f'))||0x0;if(_0x5e55c2===_0x2a55a3[_0x25f761][_0x5adb('0x44')]-0x1){_0x3a0d1b['voiceQueues'][_0x56df90][_0x5adb('0x2d')]+=moment(_0x2a55a3[_0x25f761][_0x5e55c2]['queuecallercompleteAt']||_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x60')]||_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x61')])['diff'](moment(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x62')]),_0x5adb('0x5f'))||0x0;_0x3a0d1b[_0x5adb('0x56')][_0x56df90][_0x5adb('0x2a')]+=0x1;if(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x63')]){_0x3a0d1b[_0x5adb('0x56')][_0x56df90][_0x5adb('0x2b')]+=0x1;_0x3a0d1b[_0x5adb('0x56')][_0x56df90]['sumBillable']+=moment(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x64')])[_0x5adb('0x5e')](moment(_0x2a55a3[_0x25f761][_0x5e55c2][_0x5adb('0x5d')]),'seconds')||0x0;}}else{_0x3a0d1b['voiceQueues'][_0x56df90][_0x5adb('0x2d')]+=_0x3a0d1b['voiceQueues'][_0x56df90][_0x5adb('0x2c')]||0x0;}}}}}}return _0x3a0d1b[_0x5adb('0x56')];};};Realtime[_0x5adb('0x41')]['initVoiceCallReports']=function(){var _0x3a9735=this;return function(_0x288e4f){clearVoiceCallReports(_0x3a9735[_0x5adb('0x17')]);if(_0x288e4f){for(var _0x3ecc56=0x0;_0x3ecc56<_0x288e4f[_0x5adb('0x44')];_0x3ecc56+=0x1){_0x3a9735['outbound'][_0x5adb('0x2a')]+=0x1;_0x3a9735[_0x5adb('0x17')][_0x5adb('0x2d')]+=_0x288e4f[_0x3ecc56][_0x5adb('0x65')];if(_0x288e4f[_0x3ecc56]['disposition']===_0x5adb('0x66')){_0x3a9735[_0x5adb('0x17')][_0x5adb('0x2b')]+=0x1;_0x3a9735[_0x5adb('0x17')][_0x5adb('0x2c')]+=_0x288e4f[_0x3ecc56][_0x5adb('0x65')]-_0x288e4f[_0x3ecc56][_0x5adb('0x67')]||0x0;_0x3a9735['outbound'][_0x5adb('0x32')]+=_0x288e4f[_0x3ecc56][_0x5adb('0x67')];}}}return _0x3a9735['outbound'];};};Realtime[_0x5adb('0x41')][_0x5adb('0x68')]=function(){var _0x4fc0d5=this;return function(_0x462fa0){if(_0x462fa0){freeIsNotKey(_0x462fa0,_0x4fc0d5['campaigns'],_0x5adb('0x24'));for(var _0x268df2=0x0,_0x4a2ebc={};_0x268df2<_0x462fa0[_0x5adb('0x44')];_0x268df2+=0x1){_0x4a2ebc=_0x462fa0[_0x268df2];if(_['isUndefined'](_0x4fc0d5[_0x5adb('0x15')][_0x4a2ebc[_0x5adb('0x24')]])){_0x4fc0d5[_0x5adb('0x15')][_0x4a2ebc[_0x5adb('0x24')]]=new Campaign(_0x4a2ebc);}else{_0x4fc0d5[_0x5adb('0x40')](_0x4fc0d5['campaigns'][_0x4a2ebc[_0x5adb('0x24')]],_0x4a2ebc);_0x4fc0d5[_0x5adb('0x15')][_0x4a2ebc[_0x5adb('0x24')]][_0x5adb('0x69')]=_0x4a2ebc['SquareProject']?_0x4a2ebc['SquareProject'][_0x5adb('0x24')]:undefined;}}}return _0x4fc0d5[_0x5adb('0x15')];};};Realtime[_0x5adb('0x41')][_0x5adb('0x6a')]=function(){var _0x277668=this;return function(_0xc74e86){if(_0xc74e86){freeIsNotKey(_0xc74e86,_0x277668[_0x5adb('0x6b')],'id');for(var _0x514833=0x0,_0xda26cc={};_0x514833<_0xc74e86[_0x5adb('0x44')];_0x514833+=0x1){_0xda26cc=_0xc74e86[_0x514833];if(_[_0x5adb('0x45')](_0x277668[_0x5adb('0x6b')][_0xda26cc['id']])){_0x277668['voiceExtensions'][_0xda26cc['id']]=new VoiceExtension(_0xda26cc);}else{_0x277668[_0x5adb('0x40')](_0x277668[_0x5adb('0x6b')][_0xda26cc['id']],_0xda26cc);}}}return _0x277668[_0x5adb('0x6b')];};};Realtime[_0x5adb('0x41')][_0x5adb('0x6c')]=function(){var _0x188cbd=this;return function(_0x315ac6){clearCampaigns(_0x188cbd[_0x5adb('0x15')]);for(var _0x1f753e=0x0;_0x1f753e<_0x315ac6['length'];_0x1f753e+=0x1){_[_0x5adb('0x54')](_0x188cbd[_0x5adb('0x15')][_0x315ac6[_0x1f753e]['name']],_0x315ac6[_0x1f753e]);}return _0x188cbd[_0x5adb('0x15')];};};Realtime[_0x5adb('0x41')][_0x5adb('0x6d')]=function(){var _0x3bb3fc=this;return function(_0x200221){if(_0x200221){freeIsNotKey(_0x200221,_0x3bb3fc[_0x5adb('0x22')],'id');for(var _0x450516=0x0,_0x350bb1={};_0x450516<_0x200221['length'];_0x450516+=0x1){_0x350bb1=_0x200221[_0x450516];if(_[_0x5adb('0x45')](_0x3bb3fc[_0x5adb('0x22')][_0x350bb1['id']])){_0x3bb3fc['faxAccounts'][_0x350bb1['id']]=new FaxAccount(_0x350bb1);}else{_0x3bb3fc[_0x5adb('0x40')](_0x3bb3fc[_0x5adb('0x22')][_0x350bb1['id']],_0x350bb1);}}}return _0x3bb3fc[_0x5adb('0x22')];};};Realtime['prototype']['initVoiceQueues']=function(){var _0x2d7a9f=this;return function(_0x328851){if(_0x328851){freeIsNotKey(_0x328851,_0x2d7a9f[_0x5adb('0x56')],'name');for(var _0x14b36f=0x0,_0x321c3a={};_0x14b36f<_0x328851[_0x5adb('0x44')];_0x14b36f+=0x1){_0x321c3a=_0x328851[_0x14b36f];if(_[_0x5adb('0x45')](_0x2d7a9f[_0x5adb('0x56')][_0x321c3a[_0x5adb('0x24')]])){_0x2d7a9f[_0x5adb('0x56')][_0x321c3a[_0x5adb('0x24')]]=new VoiceQueue(_0x321c3a);}else{_0x2d7a9f[_0x5adb('0x40')](_0x2d7a9f[_0x5adb('0x56')][_0x321c3a[_0x5adb('0x24')]],_0x321c3a);}}}return _0x2d7a9f[_0x5adb('0x56')];};};module['exports']=Realtime; \ No newline at end of file diff --git a/server/services/ami/realtime/utils.js b/server/services/ami/realtime/utils.js new file mode 100644 index 0000000..996e8be --- /dev/null +++ b/server/services/ami/realtime/utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x230d=['assign'];(function(_0x5c2a2b,_0x22c94e){var _0x19921f=function(_0x3fb937){while(--_0x3fb937){_0x5c2a2b['push'](_0x5c2a2b['shift']());}};_0x19921f(++_0x22c94e);}(_0x230d,0xd4));var _0xd230=function(_0x4a9fb1,_0x273043){_0x4a9fb1=_0x4a9fb1-0x0;var _0x348672=_0x230d[_0x4a9fb1];return _0x348672;};'use strict';function mergeDBDataToRealtime(_0x2624d6,_0x1dacf8){var _0x97260a=Object[_0xd230('0x0')]({},_0x2624d6);for(var _0x543423 in _0x1dacf8){if(_0x97260a['hasOwnProperty'](_0x543423)){_0x97260a[_0x543423]=_0x1dacf8[_0x543423];}}return _0x97260a;}exports['mergeDBDataToRealtime']=mergeDBDataToRealtime; \ No newline at end of file diff --git a/server/services/ami/report/index.js b/server/services/ami/report/index.js new file mode 100644 index 0000000..5ec1181 --- /dev/null +++ b/server/services/ami/report/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe35e=['lastdata','queue','context','from-voip-provider','from-sip','xcally-motion-preview','calleridpreview','calleridnum','destinationchannel','disposition','ANSWERED','callerid','\x22%s\x22\x20<%s>','calleridname','linkedid','transfereelinkedid','uniqueid','transfers','split','monitor','monitors','createdAt','connectedlinename','membername','exten','originatecalleridnum','xcally-motion-dialer','isArray','forEach','startsWith','Local','substring','indexOf','mobile','phone','lastIndexOf','transfererlinkedid','exports','lodash','../../../config/environment','../rpc/voiceAgentReport','../rpc/voiceDialReport','../rpc/memberReport','../rpc/voiceQueueReport','../rpc/voiceRecording','../rpc/voiceTransferReport','./voiceQueueReport','./voiceAgentReport','./voiceDialReport','./userReport','realtime','agents','telephones','prototype','sync','xdr','disabled','voiceQueueReport','custom:voiceCallReport','voiceCallReport','bind','voiceAgentReport','custom:voiceDialReport','voiceDialReport','blindtransfer','blindTransfer','attendedtransfer','attendedTransfer','findAgent','find','accountcode','name','isNil','format','SIP/%s','length','connectedlinenum','assigned','lastAssignedTo','interface','queuecallercomplete','YYYY-MM-DD\x20HH:mm:ss','queuecallerexit','queuecallerexitAt','create','match','getAgentByInternal','keys','getCallType','channel','outbound','internal','destination','type','dialer','lastapplication'];(function(_0x50055b,_0x3d86e2){var _0x42d1ae=function(_0x29dbad){while(--_0x29dbad){_0x50055b['push'](_0x50055b['shift']());}};_0x42d1ae(++_0x3d86e2);}(_0xe35e,0xe6));var _0xee35=function(_0x3b90ab,_0x174a22){_0x3b90ab=_0x3b90ab-0x0;var _0x206e92=_0xe35e[_0x3b90ab];return _0x206e92;};'use strict';var _=require(_0xee35('0x0'));var moment=require('moment');var util=require('util');var config=require(_0xee35('0x1'));var ami=require('../ami');var RpcVoiceAgentReport=require(_0xee35('0x2'));var RpcVoiceCallReport=require('../rpc/voiceCallReport');var RpcVoiceDialReport=require(_0xee35('0x3'));var RpcMemberReport=require(_0xee35('0x4'));var RpcVoiceQueueReport=require(_0xee35('0x5'));var RpcVoiceRecording=require(_0xee35('0x6'));var RpcVoiceTransferReport=require(_0xee35('0x7'));var VoiceQueueReport=require(_0xee35('0x8'));var VoiceCallReport=require('./voiceCallReport');var VoiceAgentReport=require(_0xee35('0x9'));var VoiceDialReport=require(_0xee35('0xa'));var UserReport=require(_0xee35('0xb'));function Report(_0xce1ddf){this[_0xee35('0xc')]=_0xce1ddf;this[_0xee35('0xd')]=_0xce1ddf[_0xee35('0xd')];this[_0xee35('0xe')]=_0xce1ddf[_0xee35('0xe')];}Report[_0xee35('0xf')][_0xee35('0x10')]=function(_0x367d22){var _0x4cc277=new VoiceQueueReport(this[_0xee35('0xc')]);var _0xd22d88=new VoiceAgentReport(this['realtime']);var _0x115e0e=new VoiceDialReport(this[_0xee35('0xc')]);var _0x437917=new VoiceCallReport(this[_0xee35('0xc')]);var _0x2d4e2c=new UserReport(this['realtime']);if(config[_0xee35('0x11')]&&config[_0xee35('0x11')][_0xee35('0x12')]){ami['on']('custom:voiceQueueReport',this[_0xee35('0x13')]['bind'](this));ami['on'](_0xee35('0x14'),this[_0xee35('0x15')][_0xee35('0x16')](this));ami['on']('custom:voiceAgentReport',this[_0xee35('0x17')][_0xee35('0x16')](this));ami['on'](_0xee35('0x18'),this[_0xee35('0x19')][_0xee35('0x16')](this));ami['on'](_0xee35('0x1a'),this[_0xee35('0x1b')][_0xee35('0x16')](this));ami['on'](_0xee35('0x1c'),this[_0xee35('0x1d')][_0xee35('0x16')](this));}};Report['prototype'][_0xee35('0x1e')]=function(_0x44cb7e){var _0x1712e1;_0x1712e1=_[_0xee35('0x1f')](this[_0xee35('0xd')],function(_0x45082b){return _0x45082b[_0xee35('0x20')]==_0x44cb7e||_0x45082b[_0xee35('0x21')]==_0x44cb7e;});if(_[_0xee35('0x22')](_0x1712e1)){var _0x336337=_[_0xee35('0x1f')](this[_0xee35('0xe')],function(_0x1887f2){return _0x1887f2[_0xee35('0x20')]==_0x44cb7e||_0x1887f2[_0xee35('0x21')]==_0x44cb7e;});if(_0x336337){_0x1712e1=_[_0xee35('0x1f')](this['agents'],function(_0x51d288){return _0x51d288['interface']==util[_0xee35('0x23')](_0xee35('0x24'),_0x336337['name']);});}}return _0x1712e1;};Report[_0xee35('0xf')][_0xee35('0x13')]=function(_0x2c7b1c){for(var _0x207331=0x0;_0x207331<_0x2c7b1c[_0xee35('0x25')];_0x207331+=0x1){var _0x3686af=this[_0xee35('0x1e')](_0x2c7b1c[_0x207331][_0xee35('0x26')]);if(_0x3686af){_0x2c7b1c[_0x207331][_0xee35('0x20')]=_0x3686af[_0xee35('0x20')];_0x2c7b1c[_0x207331][_0xee35('0x27')]=!![];_0x2c7b1c[_0x207331][_0xee35('0x28')]=_0x3686af['name'];_0x2c7b1c[_0x207331][_0xee35('0x29')]=_['isNil'](_0x3686af[_0xee35('0x29')])?util[_0xee35('0x23')](_0xee35('0x24'),_0x3686af[_0xee35('0x21')]):_0x3686af[_0xee35('0x29')];if(_0x2c7b1c[_0x207331][_0xee35('0x2a')]){_0x2c7b1c[_0x207331]['queuecallercompleteAt']=moment()[_0xee35('0x23')](_0xee35('0x2b'));}if(_0x2c7b1c[_0x207331][_0xee35('0x2c')]){_0x2c7b1c[_0x207331][_0xee35('0x2d')]=moment()['format'](_0xee35('0x2b'));}RpcMemberReport[_0xee35('0x13')](_0x2c7b1c[_0x207331]);}RpcVoiceQueueReport[_0xee35('0x2e')](_0x2c7b1c[_0x207331]);}};function extractCalleridNumber(_0x2f9e11){var _0x5d8306=_0x2f9e11[_0xee35('0x2f')](/<(.*?)>/);return _0x5d8306?_0x5d8306[0x1]:_0x2f9e11;}Report[_0xee35('0xf')][_0xee35('0x30')]=function(_0x5bd489){for(var _0x464ada=0x0;_0x464ada0x0?!![]:![];if(!_0x6e5c98){return this['syncQueueSummaryComplete'](this[_0x13b0('0x14')][_0x13b0('0x68')]);}};VoiceQueueReport[_0x13b0('0xa')][_0x13b0('0x19')]=function(_0x3cb7b5){var _0x1c52af=this[_0x13b0('0x14')]['id'];if(this[_0x13b0('0x14')]['queuestatus'][_0x1c52af]&&this[_0x13b0('0x14')][_0x13b0('0x60')][_0x1c52af][_0x3cb7b5[_0x13b0('0x5f')]]){this[_0x13b0('0x14')][_0x13b0('0x60')][_0x1c52af][_0x3cb7b5[_0x13b0('0x5f')]][_0x13b0('0x10')][_0x13b0('0x69')](_0x3cb7b5);}};VoiceQueueReport[_0x13b0('0xa')][_0x13b0('0x6a')]=function(_0x2c8dbf){var _0x265d3f=this;try{if(this['isNotNull'](_0x2c8dbf)&&this[_0x13b0('0x58')](_0x2c8dbf[_0x13b0('0x4c')])){logger[_0x13b0('0x46')](_0x13b0('0x6b'),util[_0x13b0('0x40')](_0x2c8dbf,{'showHidden':![],'depth':null}));var _0xa65d3f=this[_0x13b0('0x12')][_0x2c8dbf['queue']];if(_0xa65d3f){logger[_0x13b0('0x6c')](_0x13b0('0x6d'),_0xa65d3f[_0x13b0('0x62')]);this[_0x13b0('0x14')][_0x13b0('0x5a')][_0xa65d3f['name']]={'summaryEvent':_0x2c8dbf};this['summary'][_0x13b0('0x67')]+=0x1;return ami[_0x13b0('0x37')]({'action':'queuestatus','queue':_0xa65d3f['name']})[_0x13b0('0x5e')](function(_0x1ba657){if(!_0x265d3f['summary'][_0x13b0('0x60')][_0x2c8dbf[_0x13b0('0x5f')]]){_0x265d3f[_0x13b0('0x14')][_0x13b0('0x60')][_0x2c8dbf['actionid']]={};}_0x265d3f[_0x13b0('0x14')][_0x13b0('0x60')][_0x2c8dbf[_0x13b0('0x5f')]][_0x1ba657[_0x13b0('0x5f')]]={'queue':_0xa65d3f['name'],'agents':[]};})[_0x13b0('0x3a')](function(_0x8e00b6){throw _0x8e00b6;});}}}catch(_0x46548a){logger['error']('[voiceQueueReport][queuesummary]',util[_0x13b0('0x40')](_0x46548a,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0x13b0('0xa')]['syncQueueSummaryComplete']=function(_0xe2bc60){if(this[_0x13b0('0x14')]['statusRequests']>0x0){this[_0x13b0('0x14')]['completeEvent']=_0xe2bc60;return;}logger[_0x13b0('0x46')](_0x13b0('0x6e'),util[_0x13b0('0x40')](_0xe2bc60,{'showHidden':![],'depth':null}));this[_0x13b0('0x14')]=initializeSummary();ami[_0x13b0('0x45')](_0x13b0('0x6f'),{});};VoiceQueueReport[_0x13b0('0xa')]['syncQueueCallerJoin']=function(_0x484436){try{if(this[_0x13b0('0x58')](_0x484436)){logger[_0x13b0('0x46')](_0x13b0('0x70'),_0x484436[_0x13b0('0x49')],util[_0x13b0('0x40')](_0x484436,{'showHidden':![],'depth':null}));if(_['isUndefined'](this[_0x13b0('0xe')][_0x484436[_0x13b0('0x49')]])){this[_0x13b0('0xe')][_0x484436['uniqueid']]=[];}if(_[_0x13b0('0x59')](this[_0x13b0('0x11')][_0x484436['uniqueid']])){this[_0x13b0('0x11')][_0x484436[_0x13b0('0x49')]]={};}var _0x445e14=new QueueReport();_0x445e14[_0x13b0('0x4c')]=_0x484436[_0x13b0('0x4c')];_0x445e14['type']=this['voiceQueues'][_0x445e14[_0x13b0('0x4c')]]&&this[_0x13b0('0x12')][_0x445e14['queue']][_0x13b0('0x55')]?this['voiceQueues'][_0x445e14[_0x13b0('0x4c')]]['type']||_0x13b0('0x56'):_0x13b0('0x56');_0x445e14[_0x13b0('0x71')]=moment()[_0x13b0('0x4a')](_0x13b0('0x72'));_0x445e14[_0x13b0('0x73')]=_0x484436[_0x13b0('0x73')];_0x445e14[_0x13b0('0x74')]=_0x484436['count'];_0x445e14[_0x13b0('0x49')]=_0x484436[_0x13b0('0x49')];_0x445e14[_0x13b0('0x75')]=this[_0x13b0('0x11')][_0x484436[_0x13b0('0x49')]][_0x13b0('0x75')];logger[_0x13b0('0x6c')](_0x13b0('0x76'),_0x445e14[_0x13b0('0x4c')],_0x445e14[_0x13b0('0x55')]);_[_0x13b0('0x77')](_0x445e14,_[_0x13b0('0x78')](_0x484436,_['keys'](_0x445e14)));this['queueReports'][_0x484436[_0x13b0('0x49')]][_0x13b0('0x69')](_0x445e14);this[_0x13b0('0x11')][_0x484436[_0x13b0('0x49')]]=_0x445e14;this[_0x13b0('0x79')](_0x445e14,_0x13b0('0x7a'));}}catch(_0x3a0316){logger[_0x13b0('0x3d')](_0x13b0('0x70'),_0x484436[_0x13b0('0x49')],util['inspect'](_0x3a0316,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0x13b0('0xa')]['syncQueueCallerAbandon']=function(_0x2d895a){try{if(this[_0x13b0('0x58')](_0x2d895a)){logger[_0x13b0('0x46')](_0x13b0('0x7b'),_0x2d895a['uniqueid'],util[_0x13b0('0x40')](_0x2d895a,{'showHidden':![],'depth':null}));if(this['queueReports'][_0x2d895a['uniqueid']]){var _0xc1c019=_[_0x13b0('0x7c')](this[_0x13b0('0xe')][_0x2d895a['uniqueid']]);_0xc1c019[_0x13b0('0x7d')]=![];_0xc1c019[_0x13b0('0x7e')]=null;_0xc1c019['holdtime']=_0x2d895a['holdtime'];_0xc1c019[_0x13b0('0x7f')]=_0x2d895a['originalposition'];_0xc1c019[_0x13b0('0x1c')]=!![];_0xc1c019['queuecallerabandonAt']=moment()[_0x13b0('0x4a')]('YYYY-MM-DD\x20HH:mm:ss');_0xc1c019[_0x13b0('0x50')]=_0x13b0('0x80');_0xc1c019[_0x13b0('0x81')]=null;logger[_0x13b0('0x6c')](_0x13b0('0x82'),_0xc1c019[_0x13b0('0x4c')],_0xc1c019[_0x13b0('0x55')]);this[_0x13b0('0x11')][_0x2d895a[_0x13b0('0x49')]]=_0xc1c019;this[_0x13b0('0x43')](_0xc1c019,_0x13b0('0x1c'));}}}catch(_0x4ad31a){logger[_0x13b0('0x3d')](_0x13b0('0x7b'),_0x2d895a['uniqueid'],util['inspect'](_0x4ad31a,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype'][_0x13b0('0x1f')]=function(_0x39964b){try{if(this[_0x13b0('0x58')](_0x39964b)){logger[_0x13b0('0x46')]('[%s][voiceQueueReport][queuecallerleave]',_0x39964b[_0x13b0('0x49')],util[_0x13b0('0x40')](_0x39964b,{'showHidden':![],'depth':null}));if(this[_0x13b0('0xe')][_0x39964b['uniqueid']]){var _0x2b5fb9=_[_0x13b0('0x7c')](this[_0x13b0('0xe')][_0x39964b[_0x13b0('0x49')]]);_0x2b5fb9[_0x13b0('0x83')]=moment()[_0x13b0('0x4a')](_0x13b0('0x72'));_0x2b5fb9[_0x13b0('0x84')]=_0x39964b[_0x13b0('0x84')];_0x2b5fb9[_0x13b0('0x85')]=_0x39964b[_0x13b0('0x85')];logger[_0x13b0('0x6c')](_0x13b0('0x86'),_0x2b5fb9['queue'],_0x2b5fb9[_0x13b0('0x55')],_0x39964b[_0x13b0('0x84')],_0x39964b[_0x13b0('0x85')]);this[_0x13b0('0x11')][_0x39964b[_0x13b0('0x49')]]=_0x2b5fb9;this['emitVoiceQueueChannelSave'](_0x2b5fb9,_0x13b0('0x1e'));}}}catch(_0x27516a){logger[_0x13b0('0x3d')]('[%s][voiceQueueReport][queuecallerleave]',_0x39964b['uniqueid'],util[_0x13b0('0x40')](_0x27516a,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0x13b0('0xa')][_0x13b0('0x21')]=function(_0x3c4a7d){try{if(this['isNotNull'](_0x3c4a7d)){logger[_0x13b0('0x46')]('[%s][voiceQueueReport][agentconnect]',_0x3c4a7d['uniqueid'],util[_0x13b0('0x40')](_0x3c4a7d,{'showHidden':![],'depth':null}));if(this[_0x13b0('0xe')][_0x3c4a7d[_0x13b0('0x49')]]){var _0x169dc8=_['last'](this[_0x13b0('0xe')][_0x3c4a7d[_0x13b0('0x49')]]);_0x169dc8[_0x13b0('0x7d')]=!![];_0x169dc8['queuecallerexitreason']=_0x13b0('0x87');logger[_0x13b0('0x6c')](_0x13b0('0x88'),_0x169dc8[_0x13b0('0x4c')],_0x169dc8[_0x13b0('0x55')]);}}}catch(_0x2910c6){logger['error'](_0x13b0('0x89'),_0x3c4a7d[_0x13b0('0x49')],util[_0x13b0('0x40')](_0x2910c6,{'showHidden':![],'depth':null}));}};VoiceQueueReport['prototype']['syncAgentComplete']=function(_0x17ddb4){try{if(this['isNotNull'](_0x17ddb4)){logger[_0x13b0('0x46')]('[%s][voiceQueueReport][agentcomplete]',_0x17ddb4[_0x13b0('0x49')],util['inspect'](_0x17ddb4,{'showHidden':![],'depth':null}));if(this[_0x13b0('0xe')][_0x17ddb4['uniqueid']]){var _0x343375=_[_0x13b0('0x7c')](this[_0x13b0('0xe')][_0x17ddb4[_0x13b0('0x49')]]);_0x343375[_0x13b0('0x1c')]=![];_0x343375[_0x13b0('0x8a')]=null;_0x343375[_0x13b0('0x8b')]=!![];_0x343375['lastAssignedTo']=_0x17ddb4['membername'];_0x343375[_0x13b0('0x8c')]=_0x17ddb4[_0x13b0('0x8c')];_0x343375[_0x13b0('0x7d')]=!![];_0x343375['queuecallerexit']=![];_0x343375['queuecallerexitAt']=null;if(!_0x343375[_0x13b0('0x8d')]){if(_0x17ddb4['reason']=='transfer'){_0x343375[_0x13b0('0x50')]=_0x13b0('0x8e');logger[_0x13b0('0x6c')](_0x13b0('0x8f'),_0x343375[_0x13b0('0x4c')],_0x343375[_0x13b0('0x55')]);}else{if(_[_0x13b0('0x90')](_0x17ddb4[_0x13b0('0x39')][_0x13b0('0x91')](),'local/')){if(this[_0x13b0('0xe')][_0x17ddb4[_0x13b0('0x92')]]){var _0x1b093f=_[_0x13b0('0x7c')](this[_0x13b0('0xe')][_0x17ddb4[_0x13b0('0x92')]]);_0x1b093f[_0x13b0('0x7d')]=![];_0x1b093f['queuecallerexit']=!![];_0x1b093f['queuecallerexitAt']=moment(_0x343375[_0x13b0('0x71')])[_0x13b0('0x93')](_0x17ddb4[_0x13b0('0x8c')],_0x13b0('0x94'))[_0x13b0('0x4a')](_0x13b0('0x72'));_0x1b093f[_0x13b0('0x50')]='FORWARDTRANSFER';_0x1b093f[_0x13b0('0x8d')]=!![];_0x1b093f['transfertype']='FORWARD';_0x1b093f[_0x13b0('0x95')]=_0x17ddb4['destexten'];_0x1b093f['transferuniqueid']=_0x17ddb4[_0x13b0('0x49')];logger['info'](_0x13b0('0x96'),_0x1b093f[_0x13b0('0x4c')],_0x1b093f[_0x13b0('0x55')]);var _0x14cf33=this[_0x13b0('0xe')][_0x17ddb4['linkedid']];this['queueReports'][_0x17ddb4[_0x13b0('0x92')]]=this['queueReports'][_0x17ddb4[_0x13b0('0x49')]];this[_0x13b0('0xe')][_0x17ddb4['uniqueid']]=_0x14cf33;}}else{_0x343375[_0x13b0('0x50')]='COMPLETEDBY'+_0x17ddb4[_0x13b0('0x97')]['toUpperCase']();logger['info'](_0x13b0('0x98'),_0x343375[_0x13b0('0x4c')],_0x343375[_0x13b0('0x55')],_0x343375[_0x13b0('0x50')]);}}}this['channels'][_0x17ddb4[_0x13b0('0x49')]]=_0x343375;this[_0x13b0('0x43')](_0x343375,'agentcomplete');}}}catch(_0x566242){logger['error'](_0x13b0('0x99'),_0x17ddb4[_0x13b0('0x49')],util[_0x13b0('0x40')](_0x566242,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0x13b0('0xa')]['syncVarSet']=function(_0x132d96){try{if(this[_0x13b0('0x58')](_0x132d96)){logger[_0x13b0('0x46')]('[%s][voiceQueueReport][varset]',_0x132d96['uniqueid'],util[_0x13b0('0x40')](_0x132d96,{'showHidden':![],'depth':null}));this['addVariable'](_0x132d96[_0x13b0('0x49')],_['keys'](_0x132d96['variable'])[0x0],_0x132d96['value']);if(this[_0x13b0('0xe')][_0x132d96[_0x13b0('0x49')]]){var _0x1d9e09=_[_0x13b0('0x7c')](this[_0x13b0('0xe')][_0x132d96[_0x13b0('0x49')]]);if(_0x1d9e09){if(this[_0x13b0('0x58')](_0x132d96['variable'])&&this[_0x13b0('0x58')](_0x132d96[_0x13b0('0x9a')][_0x13b0('0x60')])){switch(_0x132d96[_0x13b0('0x9b')]){case _0x13b0('0x9c'):_0x1d9e09[_0x13b0('0x9d')]=![];_0x1d9e09[_0x13b0('0x9e')]=null;break;case _0x13b0('0x9f'):_0x1d9e09[_0x13b0('0xa0')]='timeout';_0x1d9e09['queuecallerexit']=!![];_0x1d9e09['queuecallerexitAt']=moment()[_0x13b0('0x4a')]('YYYY-MM-DD\x20HH:mm:ss');_0x1d9e09[_0x13b0('0x83')]=moment()[_0x13b0('0x4a')](_0x13b0('0x72'));logger[_0x13b0('0x46')](_0x13b0('0xa1'),_0x132d96['uniqueid'],util[_0x13b0('0x40')](_0x1d9e09,{'showHidden':![],'depth':null}));ami[_0x13b0('0x45')](_0x13b0('0xa2'),_0x1d9e09);break;default:_0x1d9e09[_0x13b0('0x9d')]=!![];_0x1d9e09[_0x13b0('0x9e')]=moment()['format'](_0x13b0('0x72'));_0x1d9e09[_0x13b0('0x83')]=moment()[_0x13b0('0x4a')](_0x13b0('0x72'));}_0x1d9e09['queuecallerabandon']=![];_0x1d9e09[_0x13b0('0x8a')]=null;_0x1d9e09[_0x13b0('0x50')]=_0x132d96[_0x13b0('0x9b')];this['channels'][_0x132d96['uniqueid']]=_0x1d9e09;this[_0x13b0('0x43')](_0x1d9e09,_0x13b0('0x22'));}else if(this['isNotNull'](_0x132d96['variable'])&&this[_0x13b0('0x58')](_0x132d96[_0x13b0('0x9a')][_0x13b0('0xa3')])){if(!_0x1d9e09[_0x13b0('0x1c')]){_0x1d9e09['queuecallerexit']=!![];_0x1d9e09[_0x13b0('0x9e')]=moment()[_0x13b0('0x4a')]('YYYY-MM-DD\x20HH:mm:ss');_0x1d9e09[_0x13b0('0x50')]=_0x13b0('0xa4');_0x1d9e09[_0x13b0('0x83')]=moment()[_0x13b0('0x4a')](_0x13b0('0x72'));this[_0x13b0('0x11')][_0x132d96[_0x13b0('0x49')]]=_0x1d9e09;}}logger['info']('[%s][voiceQueueReport][varset]\x20name:%s\x20type:%s\x20variable:%s\x20value:%s',_0x132d96['uniqueid'],_0x1d9e09[_0x13b0('0x4c')],_0x1d9e09[_0x13b0('0x55')],_['keys'](_0x132d96[_0x13b0('0x9a')])[0x0],_0x132d96[_0x13b0('0x9b')]);_0x1d9e09['variables']=this[_0x13b0('0x15')][_0x132d96[_0x13b0('0x49')]];}}}}catch(_0x5f0d04){logger[_0x13b0('0x3d')](_0x13b0('0xa5'),_0x132d96[_0x13b0('0x49')],util[_0x13b0('0x40')](_0x5f0d04,{'showHidden':![],'depth':null}));}};VoiceQueueReport[_0x13b0('0xa')][_0x13b0('0xa6')]=function(_0x2dfd48,_0x321dac,_0x46615a){var _0x5d7656=[_0x13b0('0xa7'),_0x13b0('0xa8'),_0x13b0('0xa9'),_0x13b0('0xaa'),_0x13b0('0xab'),'rtpaudioqoslossbridged',_0x13b0('0xac'),'rtpaudioqosrttbridged',_0x13b0('0xad'),_0x13b0('0xae'),_0x13b0('0xaf'),_0x13b0('0xb0'),_0x13b0('0xb1'),_0x13b0('0xb2'),_0x13b0('0xb3'),'memberlastcall',_0x13b0('0xb4'),'memberpenalty',_0x13b0('0xb5')];if(!_[_0x13b0('0xb6')](_0x321dac)&&!_['includes'](_0x5d7656,_0x321dac)){if(_[_0x13b0('0x59')](this['variables'][_0x2dfd48])){this[_0x13b0('0x15')][_0x2dfd48]={};}this['variables'][_0x2dfd48][_0x321dac]=_0x46615a;}};VoiceQueueReport[_0x13b0('0xa')][_0x13b0('0xb7')]=function(_0x4a3609,_0x54a369,_0x143b27){var _0x2e8d03={};for(var _0x324380=0x0;_0x324380=0x0?moment(_0x13f8f8[_0x46d9('0x18')])[_0x46d9('0xc')](_0x13f8f8['starttime'],'seconds'):null,'data1':_0x46d9('0x19'),'data2':_0x13f8f8[_0x46d9('0x13')],'data3':_0x13f8f8[_0x46d9('0x10')],'data4':_0x13f8f8['dialstring']||null,'role':'agent','internal':_0x13f8f8[_0x46d9('0x13')]?_['toNumber'](_0x13f8f8[_0x46d9('0x13')]):undefined,'uniqueid':_0x13f8f8[_0x46d9('0x1a')]},'log':_0x46d9('0x7')});}; \ No newline at end of file diff --git a/server/services/ami/rpc/setting.js b/server/services/ami/rpc/setting.js new file mode 100644 index 0000000..823727e --- /dev/null +++ b/server/services/ami/rpc/setting.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8109=['Request','ShowSetting','previewRecallmeReminderInterval','GetSettings','../client'];(function(_0x2e0763,_0x37e6e4){var _0x189643=function(_0x20802b){while(--_0x20802b){_0x2e0763['push'](_0x2e0763['shift']());}};_0x189643(++_0x37e6e4);}(_0x8109,0xa9));var _0x9810=function(_0x3092c1,_0x57a048){_0x3092c1=_0x3092c1-0x0;var _0x5e22c9=_0x8109[_0x3092c1];return _0x5e22c9;};'use strict';var client=require(_0x9810('0x0'));exports['getSettings']=function(){return client[_0x9810('0x1')](_0x9810('0x2'),{'options':{'raw':!![],'where':{'id':0x1},'attributes':['stopRecordingOnTransfer',_0x9810('0x3')]},'log':_0x9810('0x4')});}; \ No newline at end of file diff --git a/server/services/ami/rpc/template.js b/server/services/ami/rpc/template.js new file mode 100644 index 0000000..a8211f5 --- /dev/null +++ b/server/services/ami/rpc/template.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb846=['GetTemplate','../client','getTemplates','html'];(function(_0x5d2ec2,_0x5d0e35){var _0x5a4e5d=function(_0x2f9529){while(--_0x2f9529){_0x5d2ec2['push'](_0x5d2ec2['shift']());}};_0x5a4e5d(++_0x5d0e35);}(_0xb846,0x145));var _0x6b84=function(_0x2b4411,_0x2625ed){_0x2b4411=_0x2b4411-0x0;var _0x8e41ef=_0xb846[_0x2b4411];return _0x8e41ef;};'use strict';var client=require(_0x6b84('0x0'));exports[_0x6b84('0x1')]=function(_0x3051c3){return function(_0x14b15b){return client['Request']('GetTemplate',{'options':{'raw':!![],'attributes':['id','name',_0x6b84('0x2')]},'log':_0x6b84('0x3')});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/trigger.js b/server/services/ami/rpc/trigger.js new file mode 100644 index 0000000..efe5011 --- /dev/null +++ b/server/services/ami/rpc/trigger.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['getTriggers','Request','GetTrigger','name','channel','status','Condition','AllConditions','field','operator','value','AnyConditions','Action','Actions','data1','data2','data3','data4','data5','../client'];(function(_0x79ef34,_0x42d1a1){var _0x43d708=function(_0x36576e){while(--_0x36576e){_0x79ef34['push'](_0x79ef34['shift']());}};_0x43d708(++_0x42d1a1);}(_0x7a54,0x117));var _0x47a5=function(_0x2f3e7c,_0x3522f5){_0x2f3e7c=_0x2f3e7c-0x0;var _0x4ffca2=_0x7a54[_0x2f3e7c];return _0x4ffca2;};'use strict';var client=require(_0x47a5('0x0'));exports[_0x47a5('0x1')]=function(_0x3cc94b){return function(_0x431354){return client[_0x47a5('0x2')](_0x47a5('0x3'),{'options':{'raw':![],'attributes':['id',_0x47a5('0x4'),_0x47a5('0x5'),_0x47a5('0x6')],'include':[{'model':_0x47a5('0x7'),'as':_0x47a5('0x8'),'attributes':['id',_0x47a5('0x9'),_0x47a5('0xa'),_0x47a5('0xb')]},{'model':_0x47a5('0x7'),'as':_0x47a5('0xc'),'attributes':['id',_0x47a5('0x9'),_0x47a5('0xa'),_0x47a5('0xb')]},{'model':_0x47a5('0xd'),'as':_0x47a5('0xe'),'attributes':['id','action',_0x47a5('0xf'),_0x47a5('0x10'),_0x47a5('0x11'),_0x47a5('0x12'),_0x47a5('0x13'),'data6','data7']}]},'log':_0x47a5('0x3')});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/trunk.js b/server/services/ami/rpc/trunk.js new file mode 100644 index 0000000..e5d9393 --- /dev/null +++ b/server/services/ami/rpc/trunk.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb9bb=['registry'];(function(_0x3b0bcd,_0x553926){var _0x2e6057=function(_0x302bfe){while(--_0x302bfe){_0x3b0bcd['push'](_0x3b0bcd['shift']());}};_0x2e6057(++_0x553926);}(_0xb9bb,0xa4));var _0xbb9b=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xb9bb[_0x2641f9];return _0x585741;};'use strict';var client=require('../client');exports['getTrunks']=function(_0x1e6836){return function(_0x412d3f){return client['Request']('GetTrunk',{'options':{'raw':!![],'where':{'active':0x1},'attributes':['id','name',_0xbb9b('0x0'),'defaultuser']},'log':'GetTrunk'});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/user.js b/server/services/ami/rpc/user.js new file mode 100644 index 0000000..4f0935f --- /dev/null +++ b/server/services/ami/rpc/user.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x34e8=['../client','getAgents','Request','GetUser','name','email','accountcode','fullname','online','lastLoginAt','pauseType','voicePause','mobile','interface','getTelephones','telephone','internal','savePause','PauseUser','saveUnpause','UnpauseUser','getAgent','ShowUser','agent','lastPauseAt'];(function(_0x50cc40,_0x2ec2e9){var _0x326844=function(_0x44b797){while(--_0x44b797){_0x50cc40['push'](_0x50cc40['shift']());}};_0x326844(++_0x2ec2e9);}(_0x34e8,0x12c));var _0x834e=function(_0x2809af,_0x583503){_0x2809af=_0x2809af-0x0;var _0x70506c=_0x34e8[_0x2809af];return _0x70506c;};'use strict';var client=require(_0x834e('0x0'));exports[_0x834e('0x1')]=function(){return function(){return client[_0x834e('0x2')](_0x834e('0x3'),{'options':{'raw':![],'where':{'role':'agent'},'attributes':['id',_0x834e('0x4'),_0x834e('0x5'),_0x834e('0x6'),_0x834e('0x7'),_0x834e('0x8'),_0x834e('0x9'),_0x834e('0xa'),'lastPauseAt',_0x834e('0xb'),'phone',_0x834e('0xc'),_0x834e('0xd')]},'log':_0x834e('0x1')});};};exports[_0x834e('0xe')]=function(){return function(){return client[_0x834e('0x2')](_0x834e('0x3'),{'options':{'raw':!![],'where':{'role':_0x834e('0xf')},'attributes':['id',_0x834e('0x4'),_0x834e('0x6'),_0x834e('0x10')]},'log':_0x834e('0xe')});};};exports[_0x834e('0x11')]=function(_0x14038b,_0x2e1a37,_0x293514){return client[_0x834e('0x2')](_0x834e('0x12'),{'body':{'type':_0x2e1a37,'uniqueid':_0x293514},'options':{'where':{'id':_0x14038b['id']}},'log':'savePause'});};exports[_0x834e('0x13')]=function(_0x6cd9b9){return client['Request'](_0x834e('0x14'),{'body':{},'options':{'where':{'id':_0x6cd9b9['id']}},'log':_0x834e('0x11')});};exports[_0x834e('0x15')]=function(_0x21cc0a){return client['Request'](_0x834e('0x16'),{'options':{'raw':![],'where':{'role':_0x834e('0x17'),'id':_0x21cc0a},'attributes':['id','name',_0x834e('0x5'),'accountcode',_0x834e('0x7'),_0x834e('0x8'),'lastLoginAt',_0x834e('0xa'),_0x834e('0x18'),_0x834e('0xb'),'interface']},'log':_0x834e('0x15')});}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceAgentReport.js b/server/services/ami/rpc/voiceAgentReport.js new file mode 100644 index 0000000..7e9606e --- /dev/null +++ b/server/services/ami/rpc/voiceAgentReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1f62=['../client','create','CreateVoiceAgentReport','update','Request','UpdateVoiceAgentReport'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0x1f62,0x1b0));var _0x21f6=function(_0xf7058b,_0x22c9b7){_0xf7058b=_0xf7058b-0x0;var _0x24cbf0=_0x1f62[_0xf7058b];return _0x24cbf0;};'use strict';var client=require(_0x21f6('0x0'));exports[_0x21f6('0x1')]=function(_0x2d0479){return client['Request'](_0x21f6('0x2'),{'body':_0x2d0479,'log':_0x21f6('0x2')});};exports[_0x21f6('0x3')]=function(_0x182fe7,_0x28b2fc,_0x52ee9b){return client[_0x21f6('0x4')](_0x21f6('0x5'),{'body':_0x182fe7,'options':{'where':{'uniqueid':_0x28b2fc,'interface':_0x52ee9b,'agentcomplete':!![]}},'log':'UpdateVoiceAgentReport'});}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceCallReport.js b/server/services/ami/rpc/voiceCallReport.js new file mode 100644 index 0000000..7aefd94 --- /dev/null +++ b/server/services/ami/rpc/voiceCallReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x252f=['startOf','endOf','format','duration','billableseconds','moment','util','../client','create','CreateVoiceCallReport','context','getVoiceCallReports','GetVoiceCallReport','outbound'];(function(_0x456e36,_0x318c15){var _0x188de9=function(_0x76d1de){while(--_0x76d1de){_0x456e36['push'](_0x456e36['shift']());}};_0x188de9(++_0x318c15);}(_0x252f,0xc9));var _0xf252=function(_0x19f8ee,_0x3e08c2){_0x19f8ee=_0x19f8ee-0x0;var _0x3b68f2=_0x252f[_0x19f8ee];return _0x3b68f2;};'use strict';var moment=require(_0xf252('0x0'));var util=require(_0xf252('0x1'));var _=require('lodash');var client=require(_0xf252('0x2'));exports[_0xf252('0x3')]=function(_0x1af5c5){return client['Request'](_0xf252('0x4'),{'body':_['merge'](_0x1af5c5,{'source':_0x1af5c5['calleridnum'],'destinationcontext':_0x1af5c5[_0xf252('0x5')],'callerid':_0x1af5c5['callerid'],'amaflags':'DOCUMENTATION'}),'log':_0xf252('0x4')});};exports[_0xf252('0x6')]=function(){return function(){return client['Request'](_0xf252('0x7'),{'options':{'where':{'type':[_0xf252('0x8')],'createdAt':{'$between':[moment()[_0xf252('0x9')]('day')['format']('YYYY-MM-DD\x20HH:mm:ss'),moment()[_0xf252('0xa')]('day')[_0xf252('0xb')]('YYYY-MM-DD\x20HH:mm:ss')]}},'attributes':['type','disposition',_0xf252('0xc'),_0xf252('0xd')]},'log':'GetVoiceCallReports'});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceDialReport.js b/server/services/ami/rpc/voiceDialReport.js new file mode 100644 index 0000000..d677bd2 --- /dev/null +++ b/server/services/ami/rpc/voiceDialReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x220b=['Request','CreateVoiceDialReport','create'];(function(_0x57b54c,_0x54ce0d){var _0x59cc19=function(_0xa33bc6){while(--_0xa33bc6){_0x57b54c['push'](_0x57b54c['shift']());}};_0x59cc19(++_0x54ce0d);}(_0x220b,0xd1));var _0xb220=function(_0x46361e,_0x243aaf){_0x46361e=_0x46361e-0x0;var _0x14e302=_0x220b[_0x46361e];return _0x14e302;};'use strict';var client=require('../client');exports[_0xb220('0x0')]=function(_0x499198){return client[_0xb220('0x1')](_0xb220('0x2'),{'body':_0x499198,'log':_0xb220('0x2')});}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceExtension.js b/server/services/ami/rpc/voiceExtension.js new file mode 100644 index 0000000..229c28b --- /dev/null +++ b/server/services/ami/rpc/voiceExtension.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6ea9=['GetVoiceExtension','exten','../client','getVoiceExtensions','Request'];(function(_0x2c8d60,_0x43fa57){var _0x504dc8=function(_0x5d7fad){while(--_0x5d7fad){_0x2c8d60['push'](_0x2c8d60['shift']());}};_0x504dc8(++_0x43fa57);}(_0x6ea9,0x89));var _0x96ea=function(_0x36b14f,_0x196e83){_0x36b14f=_0x36b14f-0x0;var _0x44faad=_0x6ea9[_0x36b14f];return _0x44faad;};'use strict';var client=require(_0x96ea('0x0'));exports[_0x96ea('0x1')]=function(){return function(){return client[_0x96ea('0x2')](_0x96ea('0x3'),{'options':{'raw':!![],'attributes':['id',_0x96ea('0x4'),'recordingFormat'],'where':{'VoiceExtensionId':null}},'log':_0x96ea('0x1')});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceQueue.js b/server/services/ami/rpc/voiceQueue.js new file mode 100644 index 0000000..210f818 --- /dev/null +++ b/server/services/ami/rpc/voiceQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3cee=['dialNoSuchNumberRetryFrequency','dialDropMaxRetry','dialDropRetryFrequency','dialAbandonedRetryFrequency','dialMachineMaxRetry','dialMachineRetryFrequency','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','mandatoryDisposition','dialPredictiveIntervalMaxThreshold','dialPredictiveIntervalMinThreshold','dialPreviewRecallmeReminder','Trunk','callerid','mandatoryDispositionPause','TrunkBackup','active','Interval','Intervals','interval','getVoiceQueues','../client','GetVoiceQueue','name','acw','acwTimeout','monitor_format','dialActive','dialLimitChannel','dialLimitQueue','dialPowerLevel','dialPredictiveOptimization','dialPredictiveOptimizationPercentage','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialQueueOptions','dialQueueTimeout','dialQueueProject','dialCongestionMaxRetry','dialCongestionRetryFrequency','dialNoAnswerMaxRetry','dialNoAnswerRetryFrequency','dialPrefix','dialCheckDuplicateType','dialAMDActive','dialAMDInitialSilence','dialAMDGreeting','dialAMDAfterGreetingSilence','dialAMDTotalAnalysisTime','dialAMDMinWordLength','dialAMDMaximumNumberOfWords','dialAMDSilenceThreshold','dialAMDMaximumWordLength','timeout','dialRecallMeTimeout','dialRecallInQueue','dialOrderByScheduledAt','dialAgiAfterHangupAgent','dialQueueProject2','strategy','dialRandomLastDigitCallerIdNumber','dialCutDigit','dialNoSuchNumberMaxRetry'];(function(_0x5576a9,_0x330f68){var _0xa8eab7=function(_0x18a731){while(--_0x18a731){_0x5576a9['push'](_0x5576a9['shift']());}};_0xa8eab7(++_0x330f68);}(_0x3cee,0x1d5));var _0xe3ce=function(_0x1250ae,_0x1b3225){_0x1250ae=_0x1250ae-0x0;var _0x52df86=_0x3cee[_0x1250ae];return _0x52df86;};'use strict';var client=require(_0xe3ce('0x0'));exports['getVoiceQueues']=function(){return function(){return client['Request'](_0xe3ce('0x1'),{'options':{'raw':![],'attributes':['id',_0xe3ce('0x2'),_0xe3ce('0x3'),_0xe3ce('0x4'),'autopause',_0xe3ce('0x5'),'type',_0xe3ce('0x6'),'dialMethod',_0xe3ce('0x7'),_0xe3ce('0x8'),_0xe3ce('0x9'),_0xe3ce('0xa'),_0xe3ce('0xb'),'dialPredictiveInterval',_0xe3ce('0xc'),_0xe3ce('0xd'),_0xe3ce('0xe'),_0xe3ce('0xf'),_0xe3ce('0x10'),_0xe3ce('0x11'),_0xe3ce('0x12'),_0xe3ce('0x13'),'dialBusyMaxRetry','dialBusyRetryFrequency',_0xe3ce('0x14'),_0xe3ce('0x15'),'dialGlobalMaxRetry','dialTimezone','dialGlobalInterval',_0xe3ce('0x16'),_0xe3ce('0x17'),_0xe3ce('0x18'),_0xe3ce('0x19'),_0xe3ce('0x1a'),_0xe3ce('0x1b'),_0xe3ce('0x1c'),_0xe3ce('0x1d'),'dialAMDBetweenWordsSilence',_0xe3ce('0x1e'),_0xe3ce('0x1f'),_0xe3ce('0x20'),_0xe3ce('0x21'),_0xe3ce('0x22'),_0xe3ce('0x23'),_0xe3ce('0x24'),_0xe3ce('0x25'),'dialAgiAfterHangupClient',_0xe3ce('0x26'),_0xe3ce('0x5'),_0xe3ce('0x27'),_0xe3ce('0x28'),_0xe3ce('0x29'),_0xe3ce('0x2a'),_0xe3ce('0x2b'),_0xe3ce('0x2c'),_0xe3ce('0x2d'),'dialAbandonedMaxRetry',_0xe3ce('0x2e'),_0xe3ce('0x2f'),_0xe3ce('0x30'),_0xe3ce('0x31'),_0xe3ce('0x32'),_0xe3ce('0x33'),_0xe3ce('0x34'),_0xe3ce('0x35'),'dialPreviewAutoRecallMe',_0xe3ce('0x36')],'include':[{'model':_0xe3ce('0x37'),'as':'Trunk','attributes':['id',_0xe3ce('0x2'),_0xe3ce('0x38'),'active']},{'model':'Pause','as':_0xe3ce('0x39'),'attributes':['id',_0xe3ce('0x2')]},{'model':_0xe3ce('0x37'),'as':_0xe3ce('0x3a'),'attributes':['id',_0xe3ce('0x2'),_0xe3ce('0x38'),_0xe3ce('0x3b')]},{'model':_0xe3ce('0x3c'),'as':_0xe3ce('0x3c'),'attributes':['id','name'],'include':[{'model':_0xe3ce('0x3c'),'as':_0xe3ce('0x3d'),'attributes':['id',_0xe3ce('0x2'),_0xe3ce('0x3e')]}]}]},'log':_0xe3ce('0x3f')});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceQueueReport.js b/server/services/ami/rpc/voiceQueueReport.js new file mode 100644 index 0000000..a5b3b13 --- /dev/null +++ b/server/services/ami/rpc/voiceQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['queuecallerexit','queuecallerexitAt','moment','lodash','../client','Request','CreateVoiceQueueReport','getVoiceQueueReports','GetVoiceQueueReport','startOf','format','YYYY-MM-DD\x20HH:mm:ss','endOf','queuecallerjoinAt','queuecallerleaveAt','queuecallercomplete','queuecallercompleteAt'];(function(_0x1214c0,_0x481d4b){var _0x21d39f=function(_0x3b1629){while(--_0x3b1629){_0x1214c0['push'](_0x1214c0['shift']());}};_0x21d39f(++_0x481d4b);}(_0xa9e0,0x123));var _0x0a9e=function(_0x24237f,_0x4cf32c){_0x24237f=_0x24237f-0x0;var _0x48298e=_0xa9e0[_0x24237f];return _0x48298e;};'use strict';var moment=require(_0x0a9e('0x0'));var _=require(_0x0a9e('0x1'));var client=require(_0x0a9e('0x2'));exports['create']=function(_0x550fbc){return client[_0x0a9e('0x3')]('CreateVoiceQueueReport',{'body':_0x550fbc,'log':_0x0a9e('0x4')});};exports[_0x0a9e('0x5')]=function(){return function(){return client[_0x0a9e('0x3')](_0x0a9e('0x6'),{'options':{'where':{'createdAt':{'$between':[moment()[_0x0a9e('0x7')]('day')[_0x0a9e('0x8')](_0x0a9e('0x9')),moment()[_0x0a9e('0xa')]('day')['format'](_0x0a9e('0x9'))]}},'attributes':['uniqueid','queue',_0x0a9e('0xb'),_0x0a9e('0xc'),_0x0a9e('0xd'),_0x0a9e('0xe'),_0x0a9e('0xf'),_0x0a9e('0x10'),'queuecallerabandon','queuecallerabandonAt']},'log':'GetVoiceQueueReports'});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceQueueRt.js b/server/services/ami/rpc/voiceQueueRt.js new file mode 100644 index 0000000..5b70c61 --- /dev/null +++ b/server/services/ami/rpc/voiceQueueRt.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa330=['../client','Request','GetVoiceQueueRtPauses','getVoiceQueueRtPauses'];(function(_0x22f79b,_0x52a971){var _0x41dd15=function(_0x3547c8){while(--_0x3547c8){_0x22f79b['push'](_0x22f79b['shift']());}};_0x41dd15(++_0x52a971);}(_0xa330,0x98));var _0x0a33=function(_0x58e469,_0x95ee3e){_0x58e469=_0x58e469-0x0;var _0x4c01c5=_0xa330[_0x58e469];return _0x4c01c5;};'use strict';var client=require(_0x0a33('0x0'));exports['getVoiceQueueRtPauses']=function(_0xe5237f){return function(){return client[_0x0a33('0x1')](_0x0a33('0x2'),{'options':{'where':{'VoiceQueueId':_0xe5237f,'paused':!![]},'raw':!![]},'log':_0x0a33('0x3')});};}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceRecording.js b/server/services/ami/rpc/voiceRecording.js new file mode 100644 index 0000000..905c63f --- /dev/null +++ b/server/services/ami/rpc/voiceRecording.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['create','Request','CreateVoiceRecording','monitorFilename','lodash','../client'];(function(_0x403abe,_0xc6b6c5){var _0x313c92=function(_0x3a3d69){while(--_0x3a3d69){_0x403abe['push'](_0x403abe['shift']());}};_0x313c92(++_0xc6b6c5);}(_0x7a54,0x106));var _0x47a5=function(_0x4cc2f7,_0x3573a8){_0x4cc2f7=_0x4cc2f7-0x0;var _0x1062d0=_0x7a54[_0x4cc2f7];return _0x1062d0;};'use strict';var _=require(_0x47a5('0x0'));var client=require(_0x47a5('0x1'));exports[_0x47a5('0x2')]=function(_0x58157c){return client[_0x47a5('0x3')](_0x47a5('0x4'),{'body':_['merge'](_0x58157c,{'value':_0x58157c[_0x47a5('0x5')]}),'log':_0x47a5('0x4')});}; \ No newline at end of file diff --git a/server/services/ami/rpc/voiceTransferReport.js b/server/services/ami/rpc/voiceTransferReport.js new file mode 100644 index 0000000..2d5032f --- /dev/null +++ b/server/services/ami/rpc/voiceTransferReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xde5b=['secondtransferercontext','origtransfererlinkedid','transfertargetchannel','transfertargetcalleridnum','transfertargetcalleridname','transfertargetconnectedlinenum','transfertargetconnectedlinename','transfertargetaccountcode','transfertargetcontext','transfertargetexten','attended','../client','transfers','transfererchannel','transferercalleridnum','transfererconnectedlinename','transfereraccountcode','transferercontext','transfererlinkedid','transfereechannel','transfereecalleridnum','transfereecalleridname','transfereeconnectedlinename','transfereelinkedid','isexternal','context','CreateVoiceTransferReport','attendedTransfer','Request','result','origtransfererchannel','origtransferercalleridname','secondtransfererconnectedlinename','origtransfereraccountcode'];(function(_0x1bf3de,_0x3b62be){var _0x186596=function(_0x435a45){while(--_0x435a45){_0x1bf3de['push'](_0x1bf3de['shift']());}};_0x186596(++_0x3b62be);}(_0xde5b,0x1e7));var _0xbde5=function(_0x32a3b3,_0x1d630c){_0x32a3b3=_0x32a3b3-0x0;var _0x122f96=_0xde5b[_0x32a3b3];return _0x122f96;};'use strict';var client=require(_0xbde5('0x0'));exports[_0xbde5('0x1')]={};exports['blindTransfer']=function(_0x2f9341){return client['Request']('CreateVoiceTransferReport',{'body':{'result':_0x2f9341['result'],'transfererchannel':_0x2f9341[_0xbde5('0x2')],'transferercalleridnum':_0x2f9341[_0xbde5('0x3')],'transferercalleridname':_0x2f9341['transferercalleridname'],'transfererconnectedlinenum':_0x2f9341['transfererconnectedlinenum'],'transfererconnectedlinename':_0x2f9341[_0xbde5('0x4')],'transfereraccountcode':_0x2f9341[_0xbde5('0x5')],'transferercontext':_0x2f9341[_0xbde5('0x6')],'transfererexten':_0x2f9341['transfererexten'],'transfererlinkedid':_0x2f9341[_0xbde5('0x7')],'transfereechannel':_0x2f9341[_0xbde5('0x8')],'transfereecalleridnum':_0x2f9341[_0xbde5('0x9')],'transfereecalleridname':_0x2f9341[_0xbde5('0xa')],'transfereeconnectedlinenum':_0x2f9341['transfereeconnectedlinenum'],'transfereeconnectedlinename':_0x2f9341[_0xbde5('0xb')],'transfereeaccountcode':_0x2f9341['transfereeaccountcode'],'transfereecontext':_0x2f9341['transfereecontext'],'transfereeexten':_0x2f9341['transfereeexten'],'transfereelinkedid':_0x2f9341[_0xbde5('0xc')],'isexternal':_0x2f9341[_0xbde5('0xd')],'context':_0x2f9341[_0xbde5('0xe')],'extension':_0x2f9341['extension'],'type':'blind'},'log':_0xbde5('0xf')});};exports[_0xbde5('0x10')]=function(_0x5d3648){return client[_0xbde5('0x11')](_0xbde5('0xf'),{'body':{'result':_0x5d3648[_0xbde5('0x12')],'transfererchannel':_0x5d3648[_0xbde5('0x13')],'transferercalleridnum':_0x5d3648['origtransferercalleridnum'],'transferercalleridname':_0x5d3648[_0xbde5('0x14')],'transfererconnectedlinenum':_0x5d3648['secondtransfererconnectedlinenum'],'transfererconnectedlinename':_0x5d3648[_0xbde5('0x15')],'transfereraccountcode':_0x5d3648[_0xbde5('0x16')],'transferercontext':_0x5d3648[_0xbde5('0x17')],'transfererexten':_0x5d3648['secondtransfererexten'],'transfererlinkedid':_0x5d3648[_0xbde5('0x18')],'transfereechannel':_0x5d3648[_0xbde5('0x19')],'transfereecalleridnum':_0x5d3648[_0xbde5('0x1a')],'transfereecalleridname':_0x5d3648[_0xbde5('0x1b')],'transfereeconnectedlinenum':_0x5d3648[_0xbde5('0x1c')],'transfereeconnectedlinename':_0x5d3648[_0xbde5('0x1d')],'transfereeaccountcode':_0x5d3648[_0xbde5('0x1e')],'transfereecontext':_0x5d3648[_0xbde5('0x1f')],'transfereeexten':_0x5d3648[_0xbde5('0x20')],'transfereelinkedid':_0x5d3648['transfertargetlinkedid'],'isexternal':_0x5d3648['isexternal'],'context':_0x5d3648['origtransferercontext'],'extension':_0x5d3648['origtransfererexten'],'type':_0xbde5('0x21')},'log':_0xbde5('0xf')});}; \ No newline at end of file diff --git a/server/services/ami/server/index.js b/server/services/ami/server/index.js new file mode 100644 index 0000000..cf191cd --- /dev/null +++ b/server/services/ami/server/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdbf5=['outbound','includes','filter','count','rows','voicequeuechannel','voicequeuechannelhangup','Hangup','exten','context','agents','telephones','trunks','outboundChannels','run','event','Event\x20name\x20mandatory','emit','send','checkAfterSend','127.0.0.1','log','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','util','moment','../../../config/environment','../properties','../ami','../model/voiceQueueSummary','listen','%s/%s','SIP','name','timers','updateAcw','updateStatusRealtime','QueuePause','asterisk','ami\x20disconnected','join','pick','keys','reload','module','action','then','message','catch','isConnected','error','command','Command','Action','content','voiceQueues','hasOwnProperty','push','length','find','undefined','values','channels','username','voicechannel','validate','map','uniqueid','channel','format','filename','wav','MixMonitor','ai(mixmonitorid)','monitors','/var/spool/asterisk/monitor/','toLowerCase','isNil','YYYY-MM-DD\x20HH:mm:ss','mixmonitorid','rec','status','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','resolve','StopMixMonitor','destinationchannel','%s.%s','stop','StopMixMonitor\x20Success','queueChannels','type','inbound'];(function(_0x320b9e,_0x1f892f){var _0x5e4416=function(_0x160fcc){while(--_0x160fcc){_0x320b9e['push'](_0x320b9e['shift']());}};_0x5e4416(++_0x1f892f);}(_0xdbf5,0x18c));var _0x5dbf=function(_0x352ae1,_0x25fa04){_0x352ae1=_0x352ae1-0x0;var _0x53fd34=_0xdbf5[_0x352ae1];return _0x53fd34;};'use strict';var _=require('lodash');var util=require(_0x5dbf('0x0'));var jayson=require('jayson/promise');var schema=require('validate');var moment=require(_0x5dbf('0x1'));var config=require(_0x5dbf('0x2'));var properties=require(_0x5dbf('0x3'));var ami=require(_0x5dbf('0x4'));var VoiceQueueSummary=require(_0x5dbf('0x5'));exports[_0x5dbf('0x6')]=function(_0x776036,_0x1decd2,_0x3f8628){return new Promise(function(_0x3f8222,_0x209b7d){var _0x88128e={'QueuePause':function(_0x93e657){return new Promise(function(_0x52b039){var _0x134810=util['format'](_0x5dbf('0x7'),_0x5dbf('0x8'),_0x93e657[_0x5dbf('0x9')]);if(_0x776036[_0x5dbf('0xa')]&&_0x776036['timers'][_0x134810]&&_0x776036[_0x5dbf('0xa')][_0x134810]['timer']){_0x776036['timers'][_0x134810][_0x5dbf('0xb')]();}if(_0x776036['agents'][_0x134810]){_0x776036['agents'][_0x134810][_0x5dbf('0xc')]({'statePause':_0x93e657['pause']?!![]:![]});}_0x52b039({'code':0xc8,'message':_0x5dbf('0xd')});});},'Reload':function(_0x2bb7ed){var _0x1453a9=this;return new Promise(function(_0x7cb848,_0x14493a){if(ami['isConnected']()==![]){return _0x14493a(_0x1453a9['error'](0x1f4,[config[_0x5dbf('0xe')]['ip'],config[_0x5dbf('0xe')]['username'],_0x5dbf('0xf')][_0x5dbf('0x10')]('\x20')));}_0x2bb7ed=_[_0x5dbf('0x11')](_0x2bb7ed,_[_0x5dbf('0x12')](properties[_0x5dbf('0x13')][_0x5dbf('0x14')]));_0x2bb7ed[_0x5dbf('0x15')]='Reload';return ami['Action'](_0x2bb7ed)[_0x5dbf('0x16')](function(_0xc4cb1c){_0x7cb848({'code':0xc8,'message':_0xc4cb1c[_0x5dbf('0x17')]});})[_0x5dbf('0x18')](function(_0x20c2b0){_0x14493a(_0x1453a9['error'](0x1f5,_0x20c2b0[_0x5dbf('0x17')]));});});},'Command':function(_0x4dd03c){var _0x565efa=this;return new Promise(function(_0x577ca2,_0x23d1e7){if(ami[_0x5dbf('0x19')]()==![]){return _0x23d1e7(_0x565efa[_0x5dbf('0x1a')](0x1f4,[config[_0x5dbf('0xe')]['ip'],config[_0x5dbf('0xe')]['username'],_0x5dbf('0xf')]['join']('\x20')));}_0x4dd03c=_[_0x5dbf('0x11')](_0x4dd03c,_0x5dbf('0x1b'));_0x4dd03c[_0x5dbf('0x15')]=_0x5dbf('0x1c');return ami[_0x5dbf('0x1d')](_0x4dd03c)[_0x5dbf('0x16')](function(_0x58085e){_0x577ca2({'code':0xc8,'message':_0x58085e[_0x5dbf('0x1e')]});})[_0x5dbf('0x18')](function(_0x2d3e1b){_0x23d1e7(_0x565efa[_0x5dbf('0x1a')](0x1f5,_0x2d3e1b[_0x5dbf('0x17')]));});});},'VoiceQueues':function(){return new Promise(function(_0x226b93){var _0x290456=[];for(var _0x20ab1b in _0x776036[_0x5dbf('0x1f')]){if(_0x776036[_0x5dbf('0x1f')][_0x5dbf('0x20')](_0x20ab1b)){var _0x232c77=_0x776036[_0x5dbf('0x1f')][_0x20ab1b];var _0x407741=new VoiceQueueSummary(_0x232c77);_0x290456[_0x5dbf('0x21')](_0x407741);}}_0x226b93({'count':_0x290456[_0x5dbf('0x22')],'rows':_0x290456});});},'UpdateVoiceQueue':function(_0x466985){return new Promise(function(_0x3f8341,_0x159e61){var _0x22ec42=_[_0x5dbf('0x23')](_0x776036[_0x5dbf('0x1f')],{'id':parseInt(_0x466985['id'])});var _0x21cd00=_['omit'](_0x466985,['id']);if(_0x22ec42){for(var _0x2f71eb in _0x21cd00){if(typeof _0x21cd00[_0x2f71eb]!==_0x5dbf('0x24')&&typeof _0x22ec42[_0x2f71eb]!==_0x5dbf('0x24')){_0x22ec42[_0x2f71eb]=_0x21cd00[_0x2f71eb];}}_0x3f8341(_0x22ec42);}else{_0x159e61();}});},'VoiceChannels':function(){return new Promise(function(_0x1fb9a7){var _0x38825a=_[_0x5dbf('0x25')](_0x776036[_0x5dbf('0x26')]);_0x1fb9a7({'count':_0x38825a[_0x5dbf('0x22')],'rows':_0x38825a});});},'VoiceChannelMixMonitor':function(_0x406ce6){var _0x273b63=this;return new Promise(function(_0x294dd7,_0x50a307){if(ami['isConnected']()==![]){return _0x50a307(_0x273b63[_0x5dbf('0x1a')](0x1f4,[config[_0x5dbf('0xe')]['ip'],config[_0x5dbf('0xe')][_0x5dbf('0x27')],_0x5dbf('0xf')]['join']('\x20')));}var _0x5cc3f1=schema(properties[_0x5dbf('0x28')])[_0x5dbf('0x29')](_0x406ce6);if(_0x5cc3f1['length']>0x0){return _0x50a307(_0x273b63[_0x5dbf('0x1a')](0x1f4,_[_0x5dbf('0x2a')](_0x5cc3f1,_0x5dbf('0x17'))[_0x5dbf('0x10')](',\x20')));}var _0x27e058=_['find'](_0x776036[_0x5dbf('0x26')],{'uniqueid':_0x406ce6[_0x5dbf('0x2b')]});if(_0x27e058&&_0x27e058[_0x5dbf('0x2c')]){var _0x273577=util[_0x5dbf('0x2d')]('%s.%s',_0x406ce6[_0x5dbf('0x2e')]||_0x406ce6[_0x5dbf('0x2b')],_0x406ce6[_0x5dbf('0x2d')]||_0x5dbf('0x2f'));return ami['Action']({'action':_0x5dbf('0x30'),'channel':_0x27e058[_0x5dbf('0x2c')],'file':_0x273577,'options':_0x5dbf('0x31')})[_0x5dbf('0x16')](function(_0x3e309a){var _0x843d9a=_[_0x5dbf('0x23')](_0x27e058[_0x5dbf('0x32')],{'filename':_0x5dbf('0x33')+_0x273577[_0x5dbf('0x34')]()});if(_[_0x5dbf('0x35')](_0x843d9a)){_0x27e058['monitors'][_0x5dbf('0x21')]({'filename':_0x5dbf('0x33')+_0x273577[_0x5dbf('0x34')](),'createdAt':moment()['format'](_0x5dbf('0x36')),'mixmonitorid':_0x3e309a[_0x5dbf('0x37')],'status':_0x5dbf('0x38')});}else{_0x843d9a['mixmonitorid']=_0x3e309a[_0x5dbf('0x37')];_0x843d9a[_0x5dbf('0x39')]=_0x5dbf('0x38');}_0x294dd7({'code':0xc8,'message':[_0x406ce6['uniqueid'],_0x5dbf('0x3a'),_0x3e309a[_0x5dbf('0x37')]][_0x5dbf('0x10')]('\x20'),'mixmonitorid':_0x3e309a[_0x5dbf('0x37')]});})[_0x5dbf('0x18')](function(_0x6ebcc6){_0x50a307(_0x273b63[_0x5dbf('0x1a')](0x1f5,[_0x406ce6[_0x5dbf('0x2b')],_0x6ebcc6['message']['toLowerCase']()]['join']('\x20')));});}else{return _0x50a307(_0x273b63['error'](0x1f5,_0x5dbf('0x3b')));}});},'VoiceChannelStopMixMonitor':function(_0x21122d){var _0x54e5e7=this;return new Promise(function(_0x3ef0eb,_0x229abf){if(ami['isConnected']()==![]){return _0x229abf(_0x54e5e7[_0x5dbf('0x1a')](0x1f4,[config[_0x5dbf('0xe')]['ip'],config[_0x5dbf('0xe')][_0x5dbf('0x27')],_0x5dbf('0xf')][_0x5dbf('0x10')]('\x20')));}var _0x2745df=schema(properties[_0x5dbf('0x28')])[_0x5dbf('0x29')](_0x21122d);if(_0x2745df[_0x5dbf('0x22')]>0x0){return _0x229abf(_0x54e5e7['error'](0x1f4,_[_0x5dbf('0x2a')](_0x2745df,_0x5dbf('0x17'))[_0x5dbf('0x10')](',\x20')));}var _0x50880d=_[_0x5dbf('0x23')](_0x776036[_0x5dbf('0x26')],{'uniqueid':_0x21122d[_0x5dbf('0x2b')]});if(_0x50880d){return Promise[_0x5dbf('0x3c')]()['then'](function(){if(_0x50880d[_0x5dbf('0x2c')]){return ami['Action']({'action':_0x5dbf('0x3d'),'channel':_0x50880d[_0x5dbf('0x2c')],'mixmonitorid':_0x21122d[_0x5dbf('0x37')]})[_0x5dbf('0x18')](function(){});}})['then'](function(){if(_0x50880d['destinationchannel']){return ami[_0x5dbf('0x1d')]({'action':_0x5dbf('0x3d'),'channel':_0x50880d[_0x5dbf('0x3e')],'mixmonitorid':_0x21122d['mixmonitorid']})[_0x5dbf('0x18')](function(){});}})['then'](function(){var _0x4d8df1=_['find'](_0x50880d['monitors'],{'mixmonitorid':_0x21122d[_0x5dbf('0x37')]});if(_0x4d8df1){_0x4d8df1[_0x5dbf('0x39')]='stop';}})[_0x5dbf('0x16')](function(){var _0x3ba5cb=util['format'](_0x5dbf('0x3f'),_0x21122d[_0x5dbf('0x2e')]||_0x21122d['uniqueid'],_0x21122d[_0x5dbf('0x2d')]||'wav');var _0x5ab862=_[_0x5dbf('0x23')](_0x50880d[_0x5dbf('0x32')],{'filename':_0x5dbf('0x33')+_0x3ba5cb['toLowerCase']()});if(_0x5ab862){_0x5ab862['status']=_0x5dbf('0x40');}})[_0x5dbf('0x16')](function(){_0x3ef0eb({'code':0xc8,'message':[_0x21122d[_0x5dbf('0x2b')],_0x5dbf('0x41')][_0x5dbf('0x10')]('\x20')});})[_0x5dbf('0x18')](function(_0x3b49c6){_0x229abf(_0x54e5e7[_0x5dbf('0x1a')](0x1f5,[_0x21122d['uniqueid'],_0x3b49c6[_0x5dbf('0x17')][_0x5dbf('0x34')]()][_0x5dbf('0x10')]('\x20')));});}else{return _0x229abf(_0x54e5e7[_0x5dbf('0x1a')](0x1f5,_0x5dbf('0x3b')));}});},'VoiceQueuesChannels':function(_0x3cc286){var _0x328dc5=this;return new Promise(function(_0x59f825){var _0x1b0b13=_['values'](_0x776036[_0x5dbf('0x42')]);var _0x1a5d82={'count':_0x1b0b13[_0x5dbf('0x22')],'rows':_0x1b0b13};if(_0x3cc286&&_0x3cc286[_0x5dbf('0x43')]){if(![_0x5dbf('0x44'),_0x5dbf('0x45')][_0x5dbf('0x46')](_0x3cc286['type'])){return _0x209b7d(_0x328dc5['error'](0x190,'Invalid\x20type\x20parameter.\x20Allowed\x20values:\x20inbound,\x20outbound'));}var _0x1e1876=_[_0x5dbf('0x47')](_0x1b0b13,function(_0x36a787){return _0x36a787['type']===_0x3cc286['type'];});_0x1a5d82[_0x5dbf('0x48')]=_0x1e1876[_0x5dbf('0x22')];_0x1a5d82[_0x5dbf('0x49')]=_0x1e1876;}_0x59f825(_0x1a5d82);});},'VoiceQueuesChannel':function(_0x5d70cc){var _0x2c9876=this;return new Promise(function(_0x56633d,_0x3ce224){var _0x37f16f=schema(properties[_0x5dbf('0x4a')])['validate'](_0x5d70cc);if(_0x37f16f['length']>0x0){return _0x3ce224(_0x2c9876[_0x5dbf('0x1a')](0x1f4,_[_0x5dbf('0x2a')](_0x37f16f,_0x5dbf('0x17'))[_0x5dbf('0x10')](',\x20')));}var _0x4c034f=_[_0x5dbf('0x23')](_0x776036[_0x5dbf('0x42')],{'uniqueid':_0x5d70cc['uniqueid']});if(_0x4c034f){_0x56633d(_0x4c034f);}else{return _0x3ce224(_0x2c9876['error'](0x1f5,_0x5dbf('0x3b')));}});},'VoiceQueuesChannelHangup':function(_0x14bdb1){var _0x197e8c=this;return new Promise(function(_0x20ee69,_0x3e13cb){if(ami[_0x5dbf('0x19')]()==![]){return _0x3e13cb(_0x197e8c['error'](0x1f4,[config[_0x5dbf('0xe')]['ip'],config['asterisk']['username'],'ami\x20disconnected'][_0x5dbf('0x10')]('\x20')));}var _0x5f2005=schema(properties[_0x5dbf('0x4b')])[_0x5dbf('0x29')](_0x14bdb1);if(_0x5f2005[_0x5dbf('0x22')]>0x0){return _0x3e13cb(_0x197e8c[_0x5dbf('0x1a')](0x1f4,_[_0x5dbf('0x2a')](_0x5f2005,_0x5dbf('0x17'))[_0x5dbf('0x10')](',\x20')));}var _0x100d83=_[_0x5dbf('0x23')](_0x776036[_0x5dbf('0x42')],{'uniqueid':_0x14bdb1[_0x5dbf('0x2b')]});if(_0x100d83&&_0x100d83[_0x5dbf('0x2c')]){return ami[_0x5dbf('0x1d')]({'action':_0x5dbf('0x4c'),'channel':_0x100d83[_0x5dbf('0x2c')]})['then'](function(_0x3fbc3d){_0x20ee69({'code':0xc8,'message':[_0x14bdb1['uniqueid'],_0x3fbc3d[_0x5dbf('0x17')][_0x5dbf('0x34')]()][_0x5dbf('0x10')]('\x20')});})[_0x5dbf('0x18')](function(_0x5a975a){_0x3e13cb(_0x197e8c[_0x5dbf('0x1a')](0x1f5,[_0x14bdb1[_0x5dbf('0x2b')],_0x5a975a[_0x5dbf('0x17')][_0x5dbf('0x34')]()][_0x5dbf('0x10')]('\x20')));});}else{return _0x3e13cb(_0x197e8c[_0x5dbf('0x1a')](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannelRedirect':function(_0x5ccda4){var _0x3e5a96=this;return new Promise(function(_0x3b0465,_0x18bc53){if(ami[_0x5dbf('0x19')]()==![]){return _0x18bc53(_0x3e5a96[_0x5dbf('0x1a')](0x1f4,[config[_0x5dbf('0xe')]['ip'],config[_0x5dbf('0xe')][_0x5dbf('0x27')],_0x5dbf('0xf')][_0x5dbf('0x10')]('\x20')));}var _0x2997a8=schema(properties['voicequeuechannelredirect'])['validate'](_0x5ccda4);if(_0x2997a8[_0x5dbf('0x22')]>0x0){return _0x18bc53(_0x3e5a96[_0x5dbf('0x1a')](0x1f4,_[_0x5dbf('0x2a')](_0x2997a8,_0x5dbf('0x17'))[_0x5dbf('0x10')](',\x20')));}var _0x377d52=_[_0x5dbf('0x23')](_0x776036[_0x5dbf('0x42')],{'uniqueid':_0x5ccda4[_0x5dbf('0x2b')]});if(_0x377d52&&_0x377d52['channel']){return ami['Action']({'action':'Redirect','channel':_0x377d52['channel'],'exten':_0x5ccda4[_0x5dbf('0x4d')],'context':_0x5ccda4[_0x5dbf('0x4e')]||_0x377d52[_0x5dbf('0x4e')],'priority':0x1})[_0x5dbf('0x16')](function(_0x29c4d9){_0x3b0465({'code':0xc8,'message':[_0x5ccda4[_0x5dbf('0x2b')],_0x29c4d9['message']['toLowerCase']()][_0x5dbf('0x10')]('\x20')});})[_0x5dbf('0x18')](function(_0x5e84ab){_0x18bc53(_0x3e5a96[_0x5dbf('0x1a')](0x1f5,[_0x5ccda4[_0x5dbf('0x2b')],_0x5e84ab[_0x5dbf('0x17')][_0x5dbf('0x34')]()]['join']('\x20')));});}else{return _0x18bc53(_0x3e5a96[_0x5dbf('0x1a')](0x1f5,_0x5dbf('0x3b')));}});},'Agents':function(_0x131100){return new Promise(function(_0x1afaff){var _0x2aed16=_['values'](_0x776036[_0x5dbf('0x4f')]);if(_0x131100&&_0x131100['id']){var _0x3fce29=_[_0x5dbf('0x23')](_0x2aed16,function(_0x242e02){return _0x242e02['id']===_0x131100['id'];});_0x1afaff(_0x3fce29);}else{_0x1afaff({'count':_0x2aed16['length'],'rows':_0x2aed16});}});},'Telephones':function(){return new Promise(function(_0x11db7e){var _0x5b75a2=_[_0x5dbf('0x25')](_0x776036[_0x5dbf('0x50')]);_0x11db7e({'count':_0x5b75a2[_0x5dbf('0x22')],'rows':_0x5b75a2});});},'Trunks':function(){return new Promise(function(_0x5f2d67){var _0x46db8d=_[_0x5dbf('0x25')](_0x776036[_0x5dbf('0x51')]);_0x5f2d67({'count':_0x46db8d[_0x5dbf('0x22')],'rows':_0x46db8d});});},'OutboundChannels':function(){return new Promise(function(_0x50db0b){var _0x1f9d2d=_[_0x5dbf('0x25')](_0x776036[_0x5dbf('0x52')]);_0x50db0b({'count':_0x1f9d2d[_0x5dbf('0x22')],'rows':_0x1f9d2d});});},'Outbound':function(){return new Promise(function(_0x392a9b){_0x392a9b(_0x776036[_0x5dbf('0x45')]);});},'Campaigns':function(){return new Promise(function(_0x560d62){var _0x1efc21=_[_0x5dbf('0x25')](_0x776036['campaigns']);_0x560d62({'count':_0x1efc21[_0x5dbf('0x22')],'rows':_0x1efc21});});},'VoiceQueuesPreview':function(_0x2754bb){var _0x1a71fe=this;return new Promise(function(_0x3457de,_0x252be1){_0x1decd2[_0x5dbf('0x53')](_0x2754bb['id'])[_0x5dbf('0x16')](function(_0xdc4439){_0x3457de({'code':0xc8,'message':_0xdc4439[_0x5dbf('0x17')]});})[_0x5dbf('0x18')](function(_0x1fa250){_0x252be1(_0x1a71fe[_0x5dbf('0x1a')](0x1f4,_0x1fa250[_0x5dbf('0x17')]));});});},'EventManager':function(_0x248c1d){var _0x19f5ab=this;return new Promise(function(_0x37c1a3,_0x542667){if(!_0x248c1d[_0x5dbf('0x54')]){return _0x542667(_0x19f5ab[_0x5dbf('0x1a')](0x1f4,_0x5dbf('0x55')));}ami[_0x5dbf('0x56')]('custom:'+_0x248c1d[_0x5dbf('0x54')],_0x248c1d[_0x5dbf('0x17')]);_0x37c1a3({'code':0xc8,'message':_0x248c1d});});},'FaxAccounts':function(){return new Promise(function(_0x29a71a){var _0x42df4d=_[_0x5dbf('0x25')](_0x776036['faxAccounts']);_0x29a71a({'count':_0x42df4d[_0x5dbf('0x22')],'rows':_0x42df4d});});},'SendFax':function(_0x1ba14c){var _0x4e0117=this;return new Promise(function(_0x5d02f7,_0x3dac55){_0x3f8628[_0x5dbf('0x57')](_0x1ba14c)[_0x5dbf('0x16')](function(_0x8ca7de){_0x5d02f7({'code':0xc8,'message':_0x8ca7de[_0x5dbf('0x17')]});})[_0x5dbf('0x18')](function(_0x22339b){_0x3dac55(_0x4e0117['error'](0x1f4,_0x22339b[_0x5dbf('0x17')]));});});},'CheckAfterSend':function(_0x3b01c0){var _0x25c831=this;return new Promise(function(_0x1dd5b4,_0x39e600){_0x3f8628[_0x5dbf('0x58')](_0x3b01c0)['then'](function(_0x625875){_0x1dd5b4({'code':0xc8,'message':_0x625875[_0x5dbf('0x17')]});})[_0x5dbf('0x18')](function(_0x2c5a6e){_0x39e600(_0x25c831[_0x5dbf('0x1a')](0x1f4,_0x2c5a6e['message']));});});}};var _0x2ef784=jayson['server'](_0x88128e)['http']();_0x2ef784['on']('error',function(_0x496306){return _0x209b7d(_0x496306);});_0x2ef784[_0x5dbf('0x6')](0x232a,_0x5dbf('0x59'),function(){console[_0x5dbf('0x5a')](_0x5dbf('0x5b'),0x232a);return _0x3f8222(_0x5dbf('0x5c')+0x232a);});});}; \ No newline at end of file diff --git a/server/services/ami/trigger/cmContact/index.js b/server/services/ami/trigger/cmContact/index.js new file mode 100644 index 0000000..f32b736 --- /dev/null +++ b/server/services/ami/trigger/cmContact/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x08e2=['../../../../config/environment','../../rpc/cmContact','redis','defaults','localhost','socket.io-emitter','info','[CM][%s][%s]','stringify','exec','data1','data2','isNil','data5','xmd-contactid','ListId','data3','split','phone','$or','map','destcalleridnum','calleridnum','routeId','firstName','lastName','fax','createdAt','scheduledAt','updatedAt','union','resolve','getContacts','then','isEmpty','length','uniqueid','[CM][%s][%s]\x20Multiple\x20contacts\x20found:[%s]','join','[CM][%s][%s]\x20Contact\x20not\x20found','data4','calleridname','','Unknown','destcalleridname','createContact','push','[CM][%s][%s]\x20Autocreate\x20disabled','name','format','trigger:%s','action','toLowerCase','lodash','bluebird','ioredis','util'];(function(_0x4f7418,_0x1755cc){var _0x4afe7e=function(_0x5ae646){while(--_0x5ae646){_0x4f7418['push'](_0x4f7418['shift']());}};_0x4afe7e(++_0x1755cc);}(_0x08e2,0xe0));var _0x208e=function(_0x1593d4,_0x12895e){_0x1593d4=_0x1593d4-0x0;var _0x4402fd=_0x08e2[_0x1593d4];return _0x4402fd;};'use strict';var _=require(_0x208e('0x0'));var BPromise=require(_0x208e('0x1'));var Redis=require(_0x208e('0x2'));var util=require(_0x208e('0x3'));var config=require(_0x208e('0x4'));var logger=require('../../../../config/logger')('trigger');var cmContactRpc=require(_0x208e('0x5'));config[_0x208e('0x6')]=_[_0x208e('0x7')](config[_0x208e('0x6')],{'host':_0x208e('0x8'),'port':0x18eb});var io=require(_0x208e('0x9'))(new Redis(config[_0x208e('0x6')]));function emit(_0x17e1fe,_0x4eb19c,_0x584658,_0x3b5841,_0x19b511){logger[_0x208e('0xa')](_0x208e('0xb'),_0x17e1fe,_0x4eb19c['id'],_0x584658,_0x3b5841,JSON[_0x208e('0xc')](_0x19b511));io['to'](_0x584658)['emit'](_0x3b5841,_0x19b511);}exports[_0x208e('0xd')]=function(_0x10f1de,_0x6fa747,_0x8c04e8,_0xec2af8){var _0x261e4a,_0xdd4149;var _0x41f983={};var _0x31257b;var _0x3d3c1c=Number(_0x8c04e8[_0x208e('0xe')]);var _0xc131b1=_0x8c04e8[_0x208e('0xf')]?Boolean(Number(_0x8c04e8[_0x208e('0xf')])):![];var _0x328785;var _0x3bfd48=![];if(!_[_0x208e('0x10')](_0x8c04e8[_0x208e('0x11')])){if(_0x8c04e8[_0x208e('0x11')]=='1')_0x3bfd48=!![];}if(!_0x3bfd48){if(_0xec2af8[_0x208e('0x12')]){_0x41f983['id']=_0xec2af8[_0x208e('0x12')];}}if(!_0x41f983['id']){_0x41f983[_0x208e('0x13')]=_0x3d3c1c;_0x328785=_0x8c04e8[_0x208e('0x14')]&&_0x8c04e8['data3']!=='0'?_0x8c04e8['data3'][_0x208e('0x15')](','):[_0x208e('0x16')];_0x41f983[_0x208e('0x17')]=_[_0x208e('0x18')](_0x328785,function(_0x1dca9f){var _0xc2a1d4={};_0xc2a1d4[_0x1dca9f]=_0xec2af8['routeId']?_0xec2af8[_0x208e('0x19')]:_0xec2af8[_0x208e('0x1a')];return _0xc2a1d4;});_0x31257b=_0xec2af8[_0x208e('0x1b')]?_0xec2af8[_0x208e('0x19')]:_0xec2af8[_0x208e('0x1a')];}var _0x4be8a5=['id',_0x208e('0x1c'),_0x208e('0x1d'),_0x208e('0x16'),'mobile',_0x208e('0x1e'),_0x208e('0x13'),_0x208e('0x1f'),_0x208e('0x20'),_0x208e('0x21')];var _0x1d4cd2=_[_0x208e('0x22')](_0x4be8a5,_0x328785);BPromise[_0x208e('0x23')]()['then'](cmContactRpc[_0x208e('0x24')]({'attributes':_0x1d4cd2,'where':_0x41f983,'phone':_0x31257b}))[_0x208e('0x25')](function(_0x18bc35){_0xdd4149=_0x18bc35;if(!_[_0x208e('0x26')](_0xdd4149)){if(_0xdd4149[_0x208e('0x27')]===0x1){_0x261e4a=_0xdd4149[0x0];logger[_0x208e('0xa')]('[CM][%s][%s]\x20Contact\x20found:%s',_0xec2af8[_0x208e('0x28')],_0x6fa747['id'],_0x261e4a['id']);}else{logger[_0x208e('0xa')](_0x208e('0x29'),_0xec2af8[_0x208e('0x28')],_0x6fa747['id'],_['map'](_0xdd4149,'id')[_0x208e('0x2a')](','));}return;}else{logger[_0x208e('0xa')](_0x208e('0x2b'),_0xec2af8[_0x208e('0x28')],_0x6fa747['id']);var _0x569179={'ListId':_0x3d3c1c};var _0x3e8bd1=_0x8c04e8[_0x208e('0x2c')]&&_0x8c04e8[_0x208e('0x2c')]!=='0'?_0x8c04e8[_0x208e('0x2c')]:_0x208e('0x16');if(_0xc131b1){logger[_0x208e('0xa')]('[CM][%s][%s]\x20Autocreate\x20enabled',_0xec2af8[_0x208e('0x28')],_0x6fa747['id']);_0x569179[_0x3e8bd1]=_[_0x208e('0x10')](_0xec2af8[_0x208e('0x1b')])?_0xec2af8[_0x208e('0x1a')]:_0xec2af8[_0x208e('0x19')];if(_[_0x208e('0x10')](_0xec2af8['routeId'])){_0x569179[_0x208e('0x1c')]=_0xec2af8[_0x208e('0x2d')]&&_0xec2af8[_0x208e('0x2d')]!==_0x208e('0x2e')?_0xec2af8['calleridname']:_0x208e('0x2f');}else{_0x569179[_0x208e('0x1c')]=_0xec2af8[_0x208e('0x30')]&&_0xec2af8['destcalleridname']!==''?_0xec2af8['destcalleridname']:_0x208e('0x2f');}return BPromise[_0x208e('0x23')]()[_0x208e('0x25')](cmContactRpc[_0x208e('0x31')](_0x569179))['then'](function(_0x11e966){_0x261e4a=_0x11e966;_0xdd4149[_0x208e('0x32')](_0x11e966);if(_0x261e4a){logger[_0x208e('0xa')]('[CM][%s][%s]\x20Contact\x20created:%s',_0xec2af8['uniqueid'],_0x6fa747['id'],_0x261e4a['id']);}return;});}else{logger[_0x208e('0xa')](_0x208e('0x33'),_0xec2af8[_0x208e('0x28')],_0x6fa747['id']);_0x569179[_0x3e8bd1]=_[_0x208e('0x10')](_0xec2af8[_0x208e('0x1b')])?_0xec2af8[_0x208e('0x1a')]:_0xec2af8[_0x208e('0x19')];if(_[_0x208e('0x10')](_0xec2af8['routeId'])){_0x569179[_0x208e('0x1c')]=_0xec2af8['calleridname']&&_0xec2af8[_0x208e('0x2d')]!==_0x208e('0x2e')?_0xec2af8[_0x208e('0x2d')]:_0x208e('0x2f');}else{_0x569179[_0x208e('0x1c')]=_0xec2af8[_0x208e('0x30')]&&_0xec2af8['destcalleridname']!==_0x208e('0x2e')?_0xec2af8['destcalleridname']:_0x208e('0x2f');}_0x261e4a=_0x569179;_0xdd4149['push'](_0x569179);return;}}})[_0x208e('0x25')](function(){if(_0x10f1de){emit(_0xec2af8[_0x208e('0x28')],_0x6fa747,util['format']('user:%s',_0x10f1de[_0x208e('0x34')]),util[_0x208e('0x35')](_0x208e('0x36'),_0x8c04e8[_0x208e('0x37')][_0x208e('0x38')]()),{'evt':_['merge'](_0xec2af8,{'autoCreate':_0xc131b1}),'contact':_0x261e4a===undefined?{}:_0x261e4a,'contacts':_0xdd4149[_0x208e('0x27')]===0x0?undefined:_0xdd4149});}});}; \ No newline at end of file diff --git a/server/services/ami/trigger/index.js b/server/services/ami/trigger/index.js new file mode 100644 index 0000000..d66e222 --- /dev/null +++ b/server/services/ami/trigger/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc86=['length','action','toLowerCase','contactmanager','motionbar','browser','data1','TemplateId','html','data2','render','data3','isNil','data4','location','uriLocation','windowWidth','data5','windowHeight','data6','600','winApplication','winArguments','user:%s','name','format','trigger:%s','exec','integration','accounts','voiceExtensions','routeId','urlforward','script','search','replace','channel','AllConditions','checkConditions','AnyConditions','some','field','chat','ChatWebsiteId','value','operator','AccountId','interaction','event','queue','membername','lastevent','offlineMessage','equals','lodash','mustache','./urlforward','./integration','./cmContact','./script','../../../config/environment','trigger','../ami','redis','defaults','localhost','socket.io-emitter','popup','url','winapp','triggers','agents','voiceQueues','templates','zendeskAccounts','freshdeskAccounts','salesforceAccounts','sugarcrmAccounts','zohoAccounts','deskAccounts','vtigerAccounts','servicenowAccounts','dynamics365Accounts','freshsalesAccounts','custom:agentcalled','syncCustomEvent','bind','custom:agentconnect','custom:agentringnoanswer','custom:agentnosuchnumber','custom:agentbusy','custom:agentcongestion','custom:timeout','custom:dialbegin','syncAgentDial','custom:dialconnect','custom:closedinteraction','custom:substatus','custom:rejectmessage','emit','info','prototype','clone','motionChannel','voice','checkTriggers','interface','hasOwnProperty','status','checkTrigger','merge','variables','Actions'];(function(_0x5aca64,_0x4707e6){var _0x695bd0=function(_0x5788be){while(--_0x5788be){_0x5aca64['push'](_0x5aca64['shift']());}};_0x695bd0(++_0x4707e6);}(_0xdc86,0x118));var _0x6dc8=function(_0x4a747d,_0x3b747f){_0x4a747d=_0x4a747d-0x0;var _0x3a5b5c=_0xdc86[_0x4a747d];return _0x3a5b5c;};'use strict';var util=require('util');var _=require(_0x6dc8('0x0'));var url=require('url');var Mustache=require(_0x6dc8('0x1'));var Redis=require('ioredis');var urlforward=require(_0x6dc8('0x2'));var integration=require(_0x6dc8('0x3'));var cmContact=require(_0x6dc8('0x4'));var script=require(_0x6dc8('0x5'));var config=require(_0x6dc8('0x6'));var logger=require('../../../config/logger')(_0x6dc8('0x7'));var ami=require(_0x6dc8('0x8'));config[_0x6dc8('0x9')]=_[_0x6dc8('0xa')](config[_0x6dc8('0x9')],{'host':_0x6dc8('0xb'),'port':0x18eb});var io=require(_0x6dc8('0xc'))(new Redis(config[_0x6dc8('0x9')]));var operators={'equals':function(_0x4a4efe,_0x4583b7){return _0x4a4efe==_0x4583b7;},'not_equals':function(_0x58dfa6,_0x2f0692){return _0x58dfa6!=_0x2f0692;}};var barAndWebActions=[_0x6dc8('0xd'),_0x6dc8('0xe'),_0x6dc8('0xf')];function Trigger(_0x504a47){this[_0x6dc8('0x10')]=_0x504a47[_0x6dc8('0x10')];this[_0x6dc8('0x11')]=_0x504a47[_0x6dc8('0x11')];this[_0x6dc8('0x12')]=_0x504a47[_0x6dc8('0x12')];this['templates']=_0x504a47[_0x6dc8('0x13')];this['voiceExtensions']=_0x504a47['voiceExtensions'];this[_0x6dc8('0x14')]=_0x504a47[_0x6dc8('0x14')];this[_0x6dc8('0x15')]=_0x504a47['freshdeskAccounts'];this[_0x6dc8('0x16')]=_0x504a47[_0x6dc8('0x16')];this[_0x6dc8('0x17')]=_0x504a47[_0x6dc8('0x17')];this[_0x6dc8('0x18')]=_0x504a47[_0x6dc8('0x18')];this[_0x6dc8('0x19')]=_0x504a47[_0x6dc8('0x19')];this[_0x6dc8('0x1a')]=_0x504a47['vtigerAccounts'];this['servicenowAccounts']=_0x504a47[_0x6dc8('0x1b')];this[_0x6dc8('0x1c')]=_0x504a47[_0x6dc8('0x1c')];this[_0x6dc8('0x1d')]=_0x504a47[_0x6dc8('0x1d')];this['accounts']={'zendesk':this['zendeskAccounts'],'salesforce':this['salesforceAccounts'],'freshdesk':this[_0x6dc8('0x15')],'sugarcrm':this['sugarcrmAccounts'],'zoho':this[_0x6dc8('0x18')],'desk':this['deskAccounts'],'vtiger':this[_0x6dc8('0x1a')],'dynamics365':this[_0x6dc8('0x1c')],'freshsales':this[_0x6dc8('0x1d')],'servicenow':this[_0x6dc8('0x1b')]};ami['on'](_0x6dc8('0x1e'),this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x21'),this[_0x6dc8('0x1f')]['bind'](this));ami['on'](_0x6dc8('0x22'),this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:agentcomplete',this[_0x6dc8('0x1f')]['bind'](this));ami['on'](_0x6dc8('0x23'),this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:agentnoanswer',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x24'),this['syncCustomEvent'][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x25'),this[_0x6dc8('0x1f')]['bind'](this));ami['on']('custom:agentreject',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:amd',this[_0x6dc8('0x1f')]['bind'](this));ami['on']('custom:queuecallerabandon',this['syncCustomEvent'][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x26'),this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x27'),this[_0x6dc8('0x28')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x29'),this[_0x6dc8('0x28')][_0x6dc8('0x20')](this));ami['on']('custom:dialend',this[_0x6dc8('0x28')]['bind'](this));ami['on']('custom:newinteraction',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x2a'),this[_0x6dc8('0x1f')]['bind'](this));ami['on'](_0x6dc8('0x2b'),this['syncCustomEvent'][_0x6dc8('0x20')](this));ami['on']('custom:incomingmessage',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:outgoingmessage',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:acceptmessage',this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on'](_0x6dc8('0x2c'),this[_0x6dc8('0x1f')][_0x6dc8('0x20')](this));ami['on']('custom:offlineMessage',this['syncCustomEvent'][_0x6dc8('0x20')](this));}Trigger['prototype'][_0x6dc8('0x2d')]=function(_0x1cf28f,_0x4b5695,_0x5d91df){logger[_0x6dc8('0x2e')](_0x1cf28f,_0x4b5695,JSON['stringify'](_0x5d91df));io['to'](_0x1cf28f)[_0x6dc8('0x2d')](_0x4b5695,_0x5d91df);};Trigger[_0x6dc8('0x2f')][_0x6dc8('0x1f')]=function(_0x41f5c1){var _0x16532b=_[_0x6dc8('0x30')](_0x41f5c1);if(typeof _0x16532b[_0x6dc8('0x31')]==='undefined'){_0x16532b[_0x6dc8('0x31')]=_0x6dc8('0x32');}this[_0x6dc8('0x33')](_0x16532b);};Trigger[_0x6dc8('0x2f')][_0x6dc8('0x28')]=function(_0x446eb6){if(this[_0x6dc8('0x11')][_0x446eb6[_0x6dc8('0x34')]]){this[_0x6dc8('0x1f')](_0x446eb6);}};Trigger['prototype']['checkTriggers']=function(_0x6cab90){var _0x3159c2;for(var _0x4ca5c4 in this[_0x6dc8('0x10')]){if(this[_0x6dc8('0x10')][_0x6dc8('0x35')](_0x4ca5c4)){if(this[_0x6dc8('0x10')][_0x4ca5c4][_0x6dc8('0x36')]){_0x3159c2=this[_0x6dc8('0x37')](this[_0x6dc8('0x10')][_0x4ca5c4],_0x6cab90);if(_0x3159c2){_[_0x6dc8('0x38')](_0x6cab90,_0x6cab90[_0x6dc8('0x39')]);for(var _0x60c16f=0x0,_0x151630,_0x253cc1,_0x33e04b;_0x60c16f0x0){_0x53c904=_[_0x7721('0x2a')](_0x315202,_0x343c19);}return _0x53c904;}function getCustomFields(_0x37b9f0,_0xd7d703){var _0x1da2d8=[];var _0x5c54f0={'custom_fields':{}};if(_0x37b9f0[_0x7721('0x29')]>0x0){_[_0x7721('0x2b')](_0x37b9f0,function(_0x497f9f){if(_['includes']([_0x7721('0x2c'),_0x7721('0x2d')],_0x497f9f['type'])&&_0x497f9f[_0x7721('0x2e')]&&!_0x497f9f[_0x7721('0x2f')]){_0x5c54f0[_0x497f9f[_0x7721('0x2e')]['toLowerCase']()]=_0x497f9f[_0x7721('0x30')][_0x7721('0x31')]();}else if(_[_0x7721('0x32')]([_0x7721('0x2c'),_0x7721('0x2d')],_0x497f9f['type'])&&_0x497f9f[_0x7721('0x33')]&&_0x497f9f[_0x7721('0x2f')]){_0x5c54f0[_0x7721('0x34')][_0x497f9f['idField']]=_0x497f9f[_0x7721('0x30')][_0x7721('0x31')]();}else if(_0x497f9f['type']===_0x7721('0x35')&&_0x497f9f['variableName']&&_0x497f9f[_0x7721('0x33')]&&_0x497f9f[_0x7721('0x2f')]){_0xd7d703[_0x497f9f[_0x7721('0x36')]]&&(_0x5c54f0[_0x7721('0x34')][_0x497f9f[_0x7721('0x33')]]=_0xd7d703[_0x497f9f[_0x7721('0x36')]][_0x7721('0x31')]());}else if(_0x497f9f[_0x7721('0x37')]===_0x7721('0x38')&&_0x497f9f[_0x7721('0x39')]&&_0x497f9f[_0x7721('0x39')]['name']&&_0x497f9f[_0x7721('0x33')]&&_0x497f9f['customField']){_0xd7d703[_0x497f9f[_0x7721('0x39')][_0x7721('0x3a')][_0x7721('0x3b')]()]&&(_0x5c54f0[_0x7721('0x34')][_0x497f9f[_0x7721('0x33')]]=_0xd7d703[_0x497f9f[_0x7721('0x39')]['name']['toLowerCase']()]['toString']());}});}if(_0x5c54f0['priority']){_0x5c54f0[_0x7721('0x3c')]=Number(_0x5c54f0[_0x7721('0x3c')]);}return _0x5c54f0;}function getTicket(_0x1acc72,_0x22ef35,_0x4a90ce,_0xa389fa,_0x4cf659){logger[_0x7721('0x15')](_0x7721('0x3d'));var _0x5a278e=_[_0x7721('0x3e')]({'subject':intUtil[_0x7721('0x3f')](_0xa389fa['Subjects'],_0x4cf659,'\x20'),'type':'phone','status':_0x7721('0x40'),'labels':[_0x7721('0x41'),_0x7721('0x42'),_0x7721('0x43')]['concat'](getTags(_0xa389fa[_0x7721('0x44')],_0x7721('0x3a'))),'description':intUtil[_0x7721('0x3f')](_0xa389fa[_0x7721('0x45')],_0x4cf659,'\x0a'),'_links':{'assigned_user':{'href':util[_0x7721('0xe')]('/api/v2/users/%d',_0x22ef35['id']),'class':_0x7721('0x46')}},'message':{'direction':'in','body':intUtil['getString'](_0xa389fa[_0x7721('0x45')],_0x4cf659,'\x0a')}},getCustomFields(_0xa389fa['Fields'],_0x4cf659));return request({'uri':util[_0x7721('0xe')](_0x7721('0x47'),_0x1acc72[_0x7721('0x10')],_0x4a90ce['id']),'method':'POST','body':_0x5a278e});}exports[_0x7721('0x48')]=function(_0x11d853,_0x1ad315,_0x481fa8,_0x9f7b1d,_0x754071,_0xdb3033){var _0x2d5f35,_0x135dbc;_0xdb3033[_0x7721('0x10')]=intUtil[_0x7721('0x49')](_0xdb3033['remoteUri']);_0xdb3033['serverUrl']=intUtil[_0x7721('0x49')](_0xdb3033[_0x7721('0x4a')]);if(_0x754071&&_0x754071[_0x7721('0x4b')]){logger[_0x7721('0x15')](_0x7721('0x4c'),_0x7721('0x4d'));_0x1ad315[_0x7721('0x4e')]=util[_0x7721('0xe')](_0x7721('0x4f'),_0xdb3033[_0x7721('0x4a')],_0x1ad315['uniqueid'],md5(_0x1ad315['uniqueid']));}else{_0x1ad315[_0x7721('0x4e')]='';}headers[_0x7721('0x50')]=getAuth(_0xdb3033);return getUser(_0xdb3033,_0x9f7b1d[_0x7721('0x51')])[_0x7721('0x11')](function(_0x589e95){_0x2d5f35=_0x589e95;logger[_0x7721('0x15')](_0x7721('0x52'),_0x2d5f35['id']);return getEndUser(_0xdb3033,_0x1ad315['calleridname'],_0x1ad315[_0x7721('0x53')]);})['then'](function(_0x2682b1){_0x135dbc=_0x2682b1;logger['info'](_0x7721('0x54'),_0x135dbc['id']);return getTicket(_0xdb3033,_0x2d5f35,_0x135dbc,_0x481fa8,_0x1ad315);})[_0x7721('0x11')](function(_0xf17c40){if(_0xf17c40){logger['info'](_0x7721('0x55'));logger[_0x7721('0x15')]('The\x20Ticket\x20ID\x20is:',_0xf17c40['id']);switch(_0xdb3033[_0x7721('0x37')]){case _0x7721('0x56'):logger[_0x7721('0x15')]('[QUEUE]',_0x7721('0x57'));emit(util['format'](_0x7721('0x58'),_0x9f7b1d[_0x7721('0x3a')]),_0x7721('0x59'),{'recordId':_0xf17c40['id']});break;case _0x7721('0x5a'):logger[_0x7721('0x15')](_0x7721('0x4c'),_0x7721('0x5b'));emit(util[_0x7721('0xe')](_0x7721('0x58'),_0x9f7b1d[_0x7721('0x3a')]),_0x7721('0x5c'),{'uri':util[_0x7721('0xe')](_0x7721('0x5d'),_0xf17c40['id'])});break;default:logger[_0x7721('0x5e')](_0x7721('0x4c'),'Desk\x20account\x20type\x20not\x20recognized');}}})[_0x7721('0x5f')](function(_0x2f6f30){console[_0x7721('0x5e')](_0x2f6f30);logger[_0x7721('0x5e')](_0x7721('0x4c'),JSON[_0x7721('0x1a')](_0x2f6f30));});};exports[_0x7721('0x60')]=function(_0x57484c,_0x234bee,_0x17036e,_0x134908,_0x3b7382,_0x1f1e84,_0x9c0d4){var _0x7fbd6c,_0x33287d;_0x1f1e84[_0x7721('0x10')]=intUtil[_0x7721('0x49')](_0x1f1e84[_0x7721('0x10')]);_0x1f1e84['serverUrl']=intUtil[_0x7721('0x49')](_0x1f1e84[_0x7721('0x4a')]);if(_0x9c0d4&&_0x9c0d4[_0x7721('0x61')]&&_0x9c0d4[_0x7721('0x61')]!==_0x7721('0x62')){logger[_0x7721('0x15')](_0x7721('0x63'),_0x7721('0x4d'));_0x234bee[_0x7721('0x4e')]=util[_0x7721('0xe')](_0x7721('0x4f'),_0x1f1e84[_0x7721('0x4a')],_0x234bee[_0x7721('0x64')],md5(_0x234bee[_0x7721('0x64')]));}headers[_0x7721('0x50')]=getAuth(_0x1f1e84);return getUser(_0x1f1e84,_0x134908['email'])['then'](function(_0x4e112e){_0x7fbd6c=_0x4e112e;logger[_0x7721('0x15')]('The\x20User\x20ID\x20is:',_0x7fbd6c['id']);return getEndUser(_0x1f1e84,_0x234bee['destcalleridname'],_0x234bee['destcalleridnum']);})['then'](function(_0x47925a){_0x33287d=_0x47925a;logger[_0x7721('0x15')](_0x7721('0x54'),_0x33287d['id']);return getTicket(_0x1f1e84,_0x7fbd6c,_0x33287d,_0x17036e,_0x234bee);})['then'](function(_0x5181d7){if(_0x5181d7){logger['info']('Ticket\x20created!');logger['info'](_0x7721('0x65'),_0x5181d7['id']);switch(_0x1f1e84['type']){case'integrationTab':logger['info'](_0x7721('0x4c'),_0x7721('0x57'));emit(util[_0x7721('0xe')]('user:%s',_0x134908[_0x7721('0x3a')]),_0x7721('0x59'),{'recordId':_0x5181d7['id']});break;case _0x7721('0x5a'):logger[_0x7721('0x15')](_0x7721('0x4c'),_0x7721('0x5b'));emit(util[_0x7721('0xe')](_0x7721('0x58'),_0x134908[_0x7721('0x3a')]),_0x7721('0x5c'),{'uri':util[_0x7721('0xe')](_0x7721('0x66'),_0x1f1e84[_0x7721('0x10')],_0x5181d7['id'])});break;default:logger[_0x7721('0x5e')](_0x7721('0x63'),'Desk\x20account\x20type\x20not\x20recognized');}}})[_0x7721('0x5f')](function(_0x2c93b0){logger[_0x7721('0x5e')](_0x7721('0x63'),JSON['stringify'](_0x2c93b0));});};exports[_0x7721('0x67')]=function(_0x104f05,_0x4c8284,_0x3e7df3,_0x5d37ad,_0x1f508d,_0x4bfb48){var _0x36a3a6,_0x3f9eaa;_0x4bfb48[_0x7721('0x10')]=intUtil[_0x7721('0x49')](_0x4bfb48[_0x7721('0x10')]);_0x4bfb48[_0x7721('0x4a')]=intUtil[_0x7721('0x49')](_0x4bfb48['serverUrl']);if(_0x1f508d&&_0x1f508d[_0x7721('0x4b')]){logger[_0x7721('0x15')]('['+_0x4c8284[_0x7721('0x68')][_0x7721('0x69')]()+']',_0x7721('0x4d'));_0x4c8284[_0x7721('0x4e')]=util[_0x7721('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x4bfb48[_0x7721('0x4a')],_0x4c8284[_0x7721('0x64')],md5(_0x4c8284['uniqueid']));}else{_0x4c8284[_0x7721('0x4e')]='';}headers['Authorization']=getAuth(_0x4bfb48);return getUser(_0x4bfb48)[_0x7721('0x11')](function(_0x382800){_0x36a3a6=_0x382800;logger[_0x7721('0x15')](_0x7721('0x52'),_0x36a3a6['id']);return getEndUser(_0x4bfb48,_0x4c8284[_0x7721('0x6a')],_0x4c8284[_0x7721('0x53')]);})[_0x7721('0x11')](function(_0x5dca04){_0x3f9eaa=_0x5dca04;logger[_0x7721('0x15')](_0x7721('0x54'),_0x3f9eaa['id']);return getTicket(_0x4bfb48,_0x36a3a6,_0x3f9eaa,_0x3e7df3,_0x4c8284);})[_0x7721('0x11')](function(_0x5f08cc){if(_0x5f08cc){logger['info']('Ticket\x20created!');logger['info']('The\x20Ticket\x20ID\x20is:',_0x5f08cc['id']);}})[_0x7721('0x5f')](function(_0x2645dd){logger['error']('['+_0x4c8284[_0x7721('0x68')][_0x7721('0x69')]()+']',JSON[_0x7721('0x1a')](_0x2645dd));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/dynamics365.js b/server/services/ami/trigger/integration/dynamics365.js new file mode 100644 index 0000000..ab64e21 --- /dev/null +++ b/server/services/ami/trigger/integration/dynamics365.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa3f8=['odata-entityid','substring','lastIndexOf','enduserId','telephone1','contacts?$select=','\x20eq\x20\x27','replace','%2b','contactid','nothing',']\x20Enduser\x20NOT\x20Created\x20-\x20ModuleCreate\x20=\x20Nothing',']\x20Enduser\x20created!','forEach','includes','nameField','indexOf','content','ticketType','incident','incidents','getString','Subjects','Descriptions','/contacts(','Fields','callDirection','queue','/systemusers(','assign','format','emit','trigger:browser:url','stripTrailingSlash','serverUrl','unmanaged','%s/api/data/v9.0/','data7','https://login.microsoftonline.com/%s/oauth2/token','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','moduleCreate','additionalSearchContact',']\x20The\x20Enduser\x20ID\x20is:',']\x20The\x20Enduser\x20phone\x20is:',']\x20The\x20%s\x20ID\x20is:\x20%s','ticketId',']\x20Call\x20direction:\x20%s','openNewTab','Displaying\x20call\x20in\x20a\x20new\x20tab...',']\x20Error\x20running\x20Dynamics365\x20integration','Error\x20running\x20Dynamics365\x20integration','lodash','./util','md5','ioredis','../../../../config/logger','dynamics365','../../../../config/environment','redis','defaults','socket.io-emitter','modernAuthentication','remoteUri','CloudProvider','tenantId','data2','resolve','clientId','username','password','clientSecret','then','catch','error','toUpperCase',']\x20Wrong\x20credentials!','message','systemusers?$select=internalemailaddress,isdisabled,systemuserid','Bearer\x20','4.0','value','validateEmail','email','userEmail','length','internalemailaddress','isdisabled','info',']\x20Agent\x20found\x20','systemuserid','userId',']\x20Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','toLowerCase','outbound','destcalleridnum','calleridnum','POST','contacts','body'];(function(_0x2e3dfc,_0x454d6c){var _0x4b1245=function(_0x5e9faa){while(--_0x5e9faa){_0x2e3dfc['push'](_0x2e3dfc['shift']());}};_0x4b1245(++_0x454d6c);}(_0xa3f8,0x111));var _0x8a3f=function(_0x23ec06,_0x561142){_0x23ec06=_0x23ec06-0x0;var _0x2831d4=_0xa3f8[_0x23ec06];return _0x2831d4;};'use strict';var _=require(_0x8a3f('0x0'));var rp=require('request-promise');var util=require('util');var intUtil=require(_0x8a3f('0x1'));var md5=require(_0x8a3f('0x2'));var Redis=require(_0x8a3f('0x3'));var logger=require(_0x8a3f('0x4'))(_0x8a3f('0x5'));var config=require(_0x8a3f('0x6'));config[_0x8a3f('0x7')]=_[_0x8a3f('0x8')](config[_0x8a3f('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x8a3f('0x9'))(new Redis(config['redis']));function getAuthToken(_0x411795,_0x593e97,_0x51e32c){if(_0x411795[_0x8a3f('0xa')]){_0x411795[_0x8a3f('0xb')]=_0x411795[_0x8a3f('0xc')]['data7'];_0x411795[_0x8a3f('0xd')]=_0x411795[_0x8a3f('0xc')][_0x8a3f('0xe')];return Promise[_0x8a3f('0xf')](_0x411795[_0x8a3f('0xc')]['data5']);}var _0x5bdc00={'method':'POST','uri':_0x593e97,'form':{'client_id':_0x411795[_0x8a3f('0x10')],'resource':_0x411795['remoteUri'],'username':_0x411795[_0x8a3f('0x11')],'password':_0x411795[_0x8a3f('0x12')],'grant_type':'password','client_secret':_0x411795[_0x8a3f('0x13')]},'json':!![]};return rp(_0x5bdc00)[_0x8a3f('0x14')](function(_0x48b5ed){return _0x48b5ed['access_token'];})[_0x8a3f('0x15')](function(_0x47bb78){logger[_0x8a3f('0x16')]('['+[_0x51e32c[_0x8a3f('0x17')]()]+_0x8a3f('0x18'));return _0x47bb78[_0x8a3f('0x19')];});}function getUser(_0x5dbe0b,_0x4e5d94,_0x591ea8,_0x26c298,_0x4610fa,_0x129755){return new Promise(function(_0x11dc84,_0x3551e1){return getAuthToken(_0x4e5d94,_0x26c298,_0x129755)[_0x8a3f('0x14')](function(_0x3f4bc2){var _0x33dde8={'method':'GET','uri':_0x4610fa+_0x8a3f('0x1a'),'headers':{'Authorization':_0x8a3f('0x1b')+_0x3f4bc2,'OData-Version':_0x8a3f('0x1c')},'json':!![]};return rp(_0x33dde8);})[_0x8a3f('0x14')](function(_0x1094e1){var _0x254102=_0x1094e1[_0x8a3f('0x1d')];var _0x3c2da4=![];var _0x3b3655=null;if(!_['isNil'](_0x591ea8)){if(intUtil[_0x8a3f('0x1e')](_0x591ea8[_0x8a3f('0x1f')])){_0x5dbe0b[_0x8a3f('0x20')]=_0x591ea8[_0x8a3f('0x1f')];for(_0x3b3655=0x0;_0x3b3655<_0x254102[_0x8a3f('0x21')];_0x3b3655++){if(_0x254102[_0x3b3655][_0x8a3f('0x22')]===_0x591ea8['email']&&!_0x254102[_0x3b3655][_0x8a3f('0x23')]){_0x3c2da4=!![];logger[_0x8a3f('0x24')]('['+[_0x129755[_0x8a3f('0x17')]()]+_0x8a3f('0x25')+_0x254102[_0x3b3655][_0x8a3f('0x26')]+'!');_0x5dbe0b[_0x8a3f('0x27')]=_0x254102[_0x3b3655]['systemuserid'];}}}}if(!_0x3c2da4){logger[_0x8a3f('0x24')]('['+[_0x129755[_0x8a3f('0x17')]()]+_0x8a3f('0x28'));_0x5dbe0b[_0x8a3f('0x20')]=_0x4e5d94[_0x8a3f('0x11')];for(_0x3b3655=0x0;_0x3b3655<_0x254102[_0x8a3f('0x21')];_0x3b3655++){if(_0x254102[_0x3b3655][_0x8a3f('0x22')]===_0x4e5d94[_0x8a3f('0x11')]){_0x5dbe0b[_0x8a3f('0x27')]=_0x254102[_0x3b3655][_0x8a3f('0x26')];}}}_0x11dc84(_0x5dbe0b);})[_0x8a3f('0x15')](function(_0x570987){_0x3551e1(_0x570987[_0x8a3f('0x19')]);});});}function createEndUser(_0xbc2e5e,_0x37e4d7,_0x5880b5,_0x2f2138,_0xd0ce2b,_0x5c3d13,_0xe4615f){return new Promise(function(_0x9f2ee9,_0x5f3410){return getAuthToken(_0x37e4d7,_0x5880b5,_0x5c3d13)[_0x8a3f('0x14')](function(_0xa2427b){var _0xb49164=_0x5c3d13[_0x8a3f('0x29')]()===_0x8a3f('0x2a')?_0xd0ce2b[_0x8a3f('0x2b')]:_0xd0ce2b[_0x8a3f('0x2c')];var _0x731401={'method':_0x8a3f('0x2d'),'uri':_0x2f2138+_0x8a3f('0x2e'),'body':{'fullname':_0xb49164,'firstname':_0xb49164,'lastname':'_','mobilephone':null,'address1_telephone1':null,'ownerid@odata.bind':'/systemusers('+_0xbc2e5e[_0x8a3f('0x27')]+')'},'headers':{'Authorization':_0x8a3f('0x1b')+_0xa2427b,'OData-Version':_0x8a3f('0x1c')},'json':!![],'resolveWithFullResponse':!![]};_0x731401[_0x8a3f('0x2f')][_0xe4615f]=_0xb49164;return rp(_0x731401);})[_0x8a3f('0x14')](function(_0x36aff7){var _0x59c2af=_0x36aff7['headers'][_0x8a3f('0x30')];var _0x3ad247=_0x59c2af[_0x8a3f('0x31')](_0x59c2af[_0x8a3f('0x32')]('(')+0x1,_0x59c2af[_0x8a3f('0x32')](')'));_0xbc2e5e[_0x8a3f('0x33')]=_0x3ad247;_0x9f2ee9(_0xbc2e5e);})[_0x8a3f('0x15')](function(_0x1fc5e6){_0x5f3410(_0x1fc5e6['message']);});});}function getEndUser(_0x2cd258,_0x4205e7,_0x8a749e,_0x5d4cc4,_0x3d6912,_0x16ce5e,_0x4cc2ea,_0x272a88){var _0x5c586f=_0x16ce5e[_0x8a3f('0x29')]()===_0x8a3f('0x2a')?_0x3d6912['destcalleridnum']:_0x3d6912[_0x8a3f('0x2c')];return getAuthToken(_0x4205e7,_0x8a749e,_0x16ce5e)[_0x8a3f('0x14')](function(_0x2a85a9){_0x272a88=_0x272a88?_0x272a88:_0x8a3f('0x34');var _0x3d372d={'method':'GET','uri':_0x5d4cc4+_0x8a3f('0x35')+_0x272a88+'&$filter='+_0x272a88+_0x8a3f('0x36')+_0x5c586f[_0x8a3f('0x37')]('+',_0x8a3f('0x38'))+'\x27','headers':{'Authorization':_0x8a3f('0x1b')+_0x2a85a9,'If-None-Match':null,'OData-Version':_0x8a3f('0x1c')},'json':!![]};return rp(_0x3d372d);})['then'](function(_0x49370f){var _0x9ba0ac=![];if(!_0x49370f)return _0x9ba0ac;var _0x7677f0=_0x49370f[_0x8a3f('0x1d')];for(var _0x573709=0x0;_0x573709<_0x7677f0[_0x8a3f('0x21')];_0x573709++){if(_0x7677f0[_0x573709][_0x272a88]===_0x5c586f){_0x9ba0ac=!![];_0x2cd258[_0x8a3f('0x33')]=_0x7677f0[_0x573709][_0x8a3f('0x39')];}}return _0x9ba0ac;})[_0x8a3f('0x14')](function(_0x1ae4b3){if(_0x1ae4b3)return _0x2cd258;if(_0x4cc2ea===_0x8a3f('0x3a')){logger[_0x8a3f('0x24')]('['+[_0x16ce5e[_0x8a3f('0x17')]()]+_0x8a3f('0x3b'));return _0x2cd258;}return createEndUser(_0x2cd258,_0x4205e7,_0x8a749e,_0x5d4cc4,_0x3d6912,_0x16ce5e,_0x272a88)['then'](function(_0x4f14a0){logger[_0x8a3f('0x24')]('['+[_0x16ce5e[_0x8a3f('0x17')]()]+_0x8a3f('0x3c'),_0x4f14a0[_0x8a3f('0x33')]);return _0x4f14a0;});});}function getCustomFields(_0x290f79,_0x1c324b,_0x28e686){var _0x475251={};if(_0x290f79[_0x8a3f('0x21')]>0x0){_[_0x8a3f('0x3d')](_0x290f79,function(_0x76cfc4){if(_[_0x8a3f('0x3e')](['string','picklist'],_0x76cfc4['type'])&&_0x76cfc4[_0x8a3f('0x3f')]&&!_0x76cfc4['customField']){var _0x3b629a=_0x76cfc4['idField'][_0x8a3f('0x29')]();var _0x2875d5=_0x3b629a[_0x8a3f('0x31')](0x0,_0x3b629a[_0x8a3f('0x40')]('_'));var _0x2916af=_0x3b629a[_0x8a3f('0x31')](_0x3b629a[_0x8a3f('0x40')]('_')+0x1);if(_0x2875d5===_0x28e686){_0x475251[_0x2916af]=_0x76cfc4[_0x8a3f('0x41')];}}});}return _0x475251;}function getTicket(_0x56aee4,_0x2d86ae,_0x49cef5,_0x55d431,_0x42cd56,_0x9866d6,_0x8c82d){return new Promise(function(_0x1ab877,_0x40e8e9){var _0x306861;return getAuthToken(_0x2d86ae,_0x49cef5,_0x8c82d)[_0x8a3f('0x14')](function(_0x22cd2e){if(_0x9866d6[_0x8a3f('0x42')]===_0x8a3f('0x43')){_0x306861={'method':_0x8a3f('0x2d'),'uri':_0x55d431+_0x8a3f('0x44'),'body':Object['assign']({},{'title':intUtil[_0x8a3f('0x45')](_0x9866d6[_0x8a3f('0x46')],_0x42cd56,'\x20'),'description':intUtil[_0x8a3f('0x45')](_0x9866d6[_0x8a3f('0x47')],_0x42cd56,'\x0a'),'customerid_contact@odata.bind':_0x56aee4[_0x8a3f('0x33')]?_0x8a3f('0x48')+_0x56aee4[_0x8a3f('0x33')]+')':undefined,'ownerid@odata.bind':'/systemusers('+_0x56aee4[_0x8a3f('0x27')]+')','caseorigincode':'1'},getCustomFields(_0x9866d6[_0x8a3f('0x49')],_0x42cd56,_0x9866d6[_0x8a3f('0x42')])),'headers':{'Authorization':_0x8a3f('0x1b')+_0x22cd2e,'OData-Version':'4.0'},'json':!![],'resolveWithFullResponse':!![]};}if(_0x9866d6[_0x8a3f('0x42')]==='phonecall'){var _0x15fa9b=_0x56aee4[_0x8a3f('0x33')]?[{'partyid_systemuser@odata.bind':'/systemusers('+_0x56aee4['userId']+')','participationtypemask':_0x56aee4[_0x8a3f('0x4a')]===_0x8a3f('0x4b')?0x2:0x1},{'partyid_contact@odata.bind':_0x8a3f('0x48')+_0x56aee4[_0x8a3f('0x33')]+')','participationtypemask':_0x56aee4[_0x8a3f('0x4a')]==='queue'?0x1:0x2}]:[{'partyid_systemuser@odata.bind':_0x8a3f('0x4c')+_0x56aee4['userId']+')','participationtypemask':_0x56aee4['callDirection']===_0x8a3f('0x4b')?0x2:0x1}];_0x306861={'method':_0x8a3f('0x2d'),'uri':_0x55d431+'phonecalls','body':Object[_0x8a3f('0x4d')]({},{'subject':intUtil[_0x8a3f('0x45')](_0x9866d6[_0x8a3f('0x46')],_0x42cd56,'\x20'),'phonenumber':String(_0x42cd56[_0x8a3f('0x2c')]),'description':intUtil[_0x8a3f('0x45')](_0x9866d6[_0x8a3f('0x47')],_0x42cd56,'\x0a'),'regardingobjectid_contact@odata.bind':_0x56aee4[_0x8a3f('0x33')]?_0x8a3f('0x48')+_0x56aee4['enduserId']+')':undefined,'ownerid@odata.bind':_0x8a3f('0x4c')+_0x56aee4[_0x8a3f('0x27')]+')','directioncode':_0x56aee4[_0x8a3f('0x4a')]===_0x8a3f('0x4b')?![]:!![],'phonecall_activity_parties':_0x15fa9b},getCustomFields(_0x9866d6[_0x8a3f('0x49')],_0x42cd56,_0x9866d6[_0x8a3f('0x42')])),'headers':{'Authorization':_0x8a3f('0x1b')+_0x22cd2e,'OData-Version':'4.0'},'json':!![],'resolveWithFullResponse':!![]};}return rp(_0x306861);})[_0x8a3f('0x14')](function(_0x5078c2){var _0x38f3ae=_0x5078c2['headers'][_0x8a3f('0x30')];var _0x12f6ea=_0x38f3ae[_0x8a3f('0x31')](_0x38f3ae['lastIndexOf']('(')+0x1,_0x38f3ae[_0x8a3f('0x32')](')'));_0x56aee4['ticketId']=_0x12f6ea;_0x1ab877(_0x56aee4);})[_0x8a3f('0x15')](function(_0xcbb070){_0x40e8e9(_0xcbb070['message']);});});}function emit(_0x5365cd,_0x39996e,_0xdfe5df,_0x522530){var _0x108d9a={'uri':util[_0x8a3f('0x4e')]('%s/main.aspx?pagetype=entityrecord&etn=%s&id=%s',_0x5365cd,_0xdfe5df,_0x522530)};io['to'](util[_0x8a3f('0x4e')]('user:%s',_0x39996e))[_0x8a3f('0x4f')](_0x8a3f('0x50'),_0x108d9a);}exports['cs']=function(_0x3a2ce5,_0x177e45,_0xa61013,_0x555ec2,_0x5ba529,_0xbc2a6c,_0x4d69d8,_0x4d041d){var _0x2b07ed={};_0xbc2a6c[_0x8a3f('0xb')]=_0xbc2a6c[_0x8a3f('0xa')]?intUtil[_0x8a3f('0x51')](_0xbc2a6c[_0x8a3f('0xc')]['data7']):intUtil[_0x8a3f('0x51')](_0xbc2a6c[_0x8a3f('0xb')]);_0xbc2a6c[_0x8a3f('0x52')]=intUtil[_0x8a3f('0x51')](_0xbc2a6c[_0x8a3f('0x52')]);_0x2b07ed[_0x8a3f('0x4a')]=_0x4d041d==='queue'||_0x4d041d===_0x8a3f('0x53')?_0x8a3f('0x4b'):_0x8a3f('0x2a');var _0x4f0836=_0xbc2a6c['modernAuthentication']?util[_0x8a3f('0x4e')](_0x8a3f('0x54'),_0xbc2a6c[_0x8a3f('0xc')][_0x8a3f('0x55')]):util[_0x8a3f('0x4e')]('%s/api/data/v9.0/',_0xbc2a6c[_0x8a3f('0xb')]);var _0x54ae5b=util[_0x8a3f('0x4e')](_0x8a3f('0x56'),_0xbc2a6c['tenantId']);var _0x2cd150=util[_0x8a3f('0x4e')](_0x8a3f('0x57'),_0xbc2a6c[_0x8a3f('0x52')],_0x177e45['uniqueid'],md5(_0x177e45[_0x8a3f('0x58')]));if(_0x5ba529&&_0x5ba529[_0x8a3f('0x59')]){logger[_0x8a3f('0x24')](_0x8a3f('0x5a'),_0x8a3f('0x5b'));_0x177e45[_0x8a3f('0x5c')]=_0x2cd150;}else if(_0x4d69d8&&_0x4d69d8['recordingFormat']&&_0x4d69d8[_0x8a3f('0x5d')]!==_0x8a3f('0x5e')){logger['info'](_0x8a3f('0x5f'),_0x8a3f('0x5b'));_0x177e45[_0x8a3f('0x5c')]=_0x2cd150;}else{_0x177e45[_0x8a3f('0x5c')]='';}return getUser(_0x2b07ed,_0xbc2a6c,_0x555ec2,_0x54ae5b,_0x4f0836,_0x4d041d)[_0x8a3f('0x14')](function(_0x4fde3e){logger[_0x8a3f('0x24')]('['+_0x4d041d[_0x8a3f('0x17')]()+']\x20The\x20User\x20ID\x20is:',_0x4fde3e[_0x8a3f('0x27')]);logger[_0x8a3f('0x24')]('['+_0x4d041d['toUpperCase']()+']\x20The\x20User\x20email\x20is:',_0x4fde3e['userEmail']);return getEndUser(_0x4fde3e,_0xbc2a6c,_0x54ae5b,_0x4f0836,_0x177e45,_0x4d041d,_0xa61013[_0x8a3f('0x60')],_0xa61013[_0x8a3f('0x61')]);})[_0x8a3f('0x14')](function(_0x41ddff){logger[_0x8a3f('0x24')]('['+_0x4d041d[_0x8a3f('0x17')]()+_0x8a3f('0x62'),_0x41ddff[_0x8a3f('0x33')]);logger[_0x8a3f('0x24')]('['+_0x4d041d[_0x8a3f('0x17')]()+_0x8a3f('0x63'),_0x177e45['calleridnum']);return getTicket(_0x41ddff,_0xbc2a6c,_0x54ae5b,_0x4f0836,_0x177e45,_0xa61013,_0x4d041d);})['then'](function(_0x48a2cd){logger[_0x8a3f('0x24')](util[_0x8a3f('0x4e')]('['+_0x4d041d[_0x8a3f('0x17')]()+_0x8a3f('0x64'),_0xa61013[_0x8a3f('0x42')],_0x48a2cd[_0x8a3f('0x65')]));logger[_0x8a3f('0x24')](util[_0x8a3f('0x4e')]('['+_0x4d041d[_0x8a3f('0x17')]()+_0x8a3f('0x66'),_0x4d041d));if(_0x4d041d!=='unmanaged'&&_0xa61013[_0x8a3f('0x67')]){logger[_0x8a3f('0x24')]('['+_0x4d041d['toUpperCase']()+']',_0x8a3f('0x68'));emit(_0xbc2a6c[_0x8a3f('0xb')],_0x555ec2['name'],_0xa61013[_0x8a3f('0x42')],_0x48a2cd[_0x8a3f('0x65')]);}})[_0x8a3f('0x15')](function(_0x435b9f){logger[_0x8a3f('0x16')]('['+_0x4d041d[_0x8a3f('0x17')]()+_0x8a3f('0x69'),_0x435b9f['message']);console['error'](_0x8a3f('0x6a'),_0x435b9f);});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/freshdesk.js b/server/services/ami/trigger/integration/freshdesk.js new file mode 100644 index 0000000..7c7d67c --- /dev/null +++ b/server/services/ami/trigger/integration/freshdesk.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1ed5=['Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Enduser\x20created.','apiKey','toString','base64','debug','stringify','GET','includes','content','string','picklist','type','idField','customField','variable','variableName','push','customVariable','Variable','toLowerCase','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','error','outbound','recordingFormat','none','[OUTBOUND]','Authorization','destcalleridname','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','catch','unmanaged','lastevent','toUpperCase','lodash','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','info','Creating\x20new\x20ticket...','merge','Caller\x20-\x20%s','calleridname','calleridnum','getString','Descriptions','Tags','name','Fields','custom_fields','keyBy','format','remoteUri','POST','Ticket\x20created!','validateEmail','then','length','Agent\x20found!','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts'];(function(_0x22ca9a,_0x462572){var _0x525a23=function(_0x358b44){while(--_0x358b44){_0x22ca9a['push'](_0x22ca9a['shift']());}};_0x525a23(++_0x462572);}(_0x1ed5,0x1ed));var _0x51ed=function(_0x2808d0,_0x221a9f){_0x2808d0=_0x2808d0-0x0;var _0x3aef7c=_0x1ed5[_0x2808d0];return _0x3aef7c;};'use strict';var _=require(_0x51ed('0x0'));var rp=require('request-promise');var md5=require('md5');var util=require(_0x51ed('0x1'));var Redis=require(_0x51ed('0x2'));var intUtil=require(_0x51ed('0x3'));var config=require(_0x51ed('0x4'));var logger=require(_0x51ed('0x5'))(_0x51ed('0x6'));config[_0x51ed('0x7')]=_[_0x51ed('0x8')](config[_0x51ed('0x7')],{'host':_0x51ed('0x9'),'port':0x18eb});var io=require(_0x51ed('0xa'))(new Redis(config[_0x51ed('0x7')]));var headers={'Content-Type':_0x51ed('0xb'),'Accept':_0x51ed('0xb')};function emit(_0x2ce675,_0x27c613,_0x4629d4){io['to'](_0x2ce675)['emit'](_0x27c613,_0x4629d4);}function getTicket(_0x1d9bfd,_0x3b47e2,_0x45b712,_0x286cb7,_0x293fc5){logger[_0x51ed('0xc')](_0x51ed('0xd'));var _0x4c753b=_[_0x51ed('0xe')]({'responder_id':_0x3b47e2['id'],'requester_id':_0x45b712['id'],'name':util['format'](_0x51ed('0xf'),_0x293fc5[_0x51ed('0x10')]),'phone':_0x293fc5[_0x51ed('0x11')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0x286cb7['Subjects'],_0x293fc5,'\x20'),'description':intUtil[_0x51ed('0x12')](_0x286cb7[_0x51ed('0x13')],_0x293fc5,'
'),'tags':getTags(_0x286cb7[_0x51ed('0x14')],_0x51ed('0x15'))},getCustomFields(_0x286cb7[_0x51ed('0x16')],_0x293fc5));_0x4c753b[_0x51ed('0x17')]=_['mapValues'](_[_0x51ed('0x18')](_0x4c753b[_0x51ed('0x17')],'id'),'value');return request({'uri':util[_0x51ed('0x19')]('%s/api/v2/tickets',_0x1d9bfd[_0x51ed('0x1a')]),'method':_0x51ed('0x1b'),'body':_0x4c753b})['then'](function(_0x16e5b2){logger[_0x51ed('0xc')](_0x51ed('0x1c'));return _0x16e5b2;});}function getUser(_0x5279f2,_0x46a213){if(intUtil[_0x51ed('0x1d')](_0x46a213)){return request({'uri':util['format']('%s/api/v2/agents',_0x5279f2['remoteUri']),'qs':{'email':_0x46a213}})[_0x51ed('0x1e')](function(_0x22ee34){if(_0x22ee34[_0x51ed('0x1f')]){logger[_0x51ed('0xc')](_0x51ed('0x20'));return _[_0x51ed('0x21')](_0x22ee34,function(_0x37e2ef){return _0x37e2ef[_0x51ed('0x22')][_0x51ed('0x23')]===_0x46a213;});}else{logger[_0x51ed('0xc')](_0x51ed('0x24'));return request({'uri':util[_0x51ed('0x19')](_0x51ed('0x25'),_0x5279f2[_0x51ed('0x1a')])})[_0x51ed('0x1e')](function(_0x1554b9){logger[_0x51ed('0xc')](_0x51ed('0x26'));return _0x1554b9;});}});}else{logger[_0x51ed('0xc')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x51ed('0x19')](_0x51ed('0x25'),_0x5279f2[_0x51ed('0x1a')])})[_0x51ed('0x1e')](function(_0x4297f4){logger[_0x51ed('0xc')](_0x51ed('0x26'));return _0x4297f4;});}}function getEndUser(_0x578c2a,_0x1a1d72,_0x33f052){logger[_0x51ed('0xc')](_0x51ed('0x27'),_0x33f052);return request({'uri':util[_0x51ed('0x19')](_0x51ed('0x28'),_0x578c2a['remoteUri']),'qs':{'phone':_0x33f052}})[_0x51ed('0x1e')](function(_0x3c50d6){if(_0x3c50d6[_0x51ed('0x1f')]){logger[_0x51ed('0xc')](_0x51ed('0x29'));return _[_0x51ed('0x21')](_0x3c50d6,{'phone':_0x33f052});}else{logger['info'](_0x51ed('0x2a'));return request({'uri':util['format'](_0x51ed('0x28'),_0x578c2a[_0x51ed('0x1a')]),'method':_0x51ed('0x1b'),'body':{'name':_0x1a1d72,'phone':_0x33f052}})[_0x51ed('0x1e')](function(_0x44533e){logger['info'](_0x51ed('0x2b'));return _0x44533e;});}});}function getAuth(_0x22358c){return util['format']('Basic\x20%s',new Buffer(_0x22358c[_0x51ed('0x2c')]+':X')[_0x51ed('0x2d')](_0x51ed('0x2e')));}function request(_0xaf89c0){logger[_0x51ed('0x2f')]('[HTTP]',JSON[_0x51ed('0x30')](_0xaf89c0));return rp(_[_0x51ed('0x8')](_0xaf89c0,{'method':_0x51ed('0x31'),'headers':headers,'json':!![]}));}function getTags(_0x1e6c4e,_0x210150){var _0x419052=[];if(_0x1e6c4e&&_0x1e6c4e[_0x51ed('0x1f')]>0x0){_0x419052=_['map'](_0x1e6c4e,_0x210150);}return _0x419052;}function getCustomFields(_0x42a665,_0xdd8c58){var _0x5427c3=[];var _0x1d05e1={'custom_fields':[]};if(_0x42a665['length']>0x0){_['forEach'](_0x42a665,function(_0x939f62){if(_[_0x51ed('0x32')](['string','picklist'],_0x939f62['type'])&&_0x939f62['nameField']&&!_0x939f62['customField']){_0x1d05e1[_0x939f62['nameField']['toLowerCase']()]=_0x939f62[_0x51ed('0x33')][_0x51ed('0x2d')]();}else if(_[_0x51ed('0x32')]([_0x51ed('0x34'),_0x51ed('0x35')],_0x939f62[_0x51ed('0x36')])&&_0x939f62[_0x51ed('0x37')]&&_0x939f62[_0x51ed('0x38')]){_0x1d05e1['custom_fields']['push']({'id':_0x939f62[_0x51ed('0x37')],'value':_0x939f62['content']['toString']()});}else if(_0x939f62[_0x51ed('0x36')]===_0x51ed('0x39')&&_0x939f62['variableName']&&_0x939f62[_0x51ed('0x37')]&&_0x939f62[_0x51ed('0x38')]){_0xdd8c58[_0x939f62[_0x51ed('0x3a')]]&&_0x1d05e1[_0x51ed('0x17')][_0x51ed('0x3b')]({'id':_0x939f62[_0x51ed('0x37')],'value':_0xdd8c58[_0x939f62[_0x51ed('0x3a')]][_0x51ed('0x2d')]()});}else if(_0x939f62[_0x51ed('0x36')]===_0x51ed('0x3c')&&_0x939f62['Variable']&&_0x939f62[_0x51ed('0x3d')][_0x51ed('0x15')]&&_0x939f62[_0x51ed('0x37')]&&_0x939f62['customField']){_0xdd8c58[_0x939f62['Variable'][_0x51ed('0x15')][_0x51ed('0x3e')]()]&&_0x1d05e1[_0x51ed('0x17')][_0x51ed('0x3b')]({'id':_0x939f62[_0x51ed('0x37')],'value':_0xdd8c58[_0x939f62[_0x51ed('0x3d')][_0x51ed('0x15')][_0x51ed('0x3e')]()][_0x51ed('0x2d')]()});}});}return _0x1d05e1;}exports['queue']=function(_0xb205cc,_0x54178b,_0x5cf7ef,_0x5c3686,_0x40bdcf,_0x5d87cc){var _0x42f676,_0xd85389;_0x5d87cc[_0x51ed('0x1a')]=intUtil[_0x51ed('0x3f')](_0x5d87cc['remoteUri']);_0x5d87cc[_0x51ed('0x40')]=intUtil[_0x51ed('0x3f')](_0x5d87cc[_0x51ed('0x40')]);if(_0x40bdcf&&_0x40bdcf[_0x51ed('0x41')]){logger[_0x51ed('0xc')](_0x51ed('0x42'),_0x51ed('0x43'));_0x54178b[_0x51ed('0x44')]=util['format'](_0x51ed('0x45'),_0x5d87cc[_0x51ed('0x40')],_0x54178b[_0x51ed('0x46')],md5(_0x54178b[_0x51ed('0x46')]));}else{_0x54178b['recordingURL']='';}headers['Authorization']=getAuth(_0x5d87cc);return getUser(_0x5d87cc,_0x5c3686[_0x51ed('0x23')])[_0x51ed('0x1e')](function(_0x17140b){_0x42f676=_0x17140b;logger[_0x51ed('0xc')](_0x51ed('0x47'),_0x42f676['id']);return getEndUser(_0x5d87cc,_0x54178b[_0x51ed('0x10')],_0x54178b['calleridnum']);})['then'](function(_0x2a6584){_0xd85389=_0x2a6584;logger[_0x51ed('0xc')](_0x51ed('0x48'),_0xd85389['id']);return getTicket(_0x5d87cc,_0x42f676,_0xd85389,_0x5cf7ef,_0x54178b);})[_0x51ed('0x1e')](function(_0x801875){if(_0x801875&&_0x801875['id']){logger[_0x51ed('0xc')](_0x51ed('0x1c'));logger[_0x51ed('0xc')](_0x51ed('0x49'),_0x801875['id']);logger[_0x51ed('0xc')]('[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x51ed('0x19')](_0x51ed('0x4a'),_0x5c3686[_0x51ed('0x15')]),_0x51ed('0x4b'),{'uri':util[_0x51ed('0x19')](_0x51ed('0x4c'),_0x5d87cc[_0x51ed('0x1a')],_0x801875['id'])});}})['catch'](function(_0x342938){logger[_0x51ed('0x4d')](_0x51ed('0x42'),JSON[_0x51ed('0x30')](_0x342938));});};exports[_0x51ed('0x4e')]=function(_0x5c2d48,_0x3ca6f2,_0x15c50e,_0x20eb43,_0x37d920,_0x378c3c,_0x56a20b){var _0x52a3c2,_0x38d0d8;_0x378c3c[_0x51ed('0x1a')]=intUtil[_0x51ed('0x3f')](_0x378c3c[_0x51ed('0x1a')]);_0x378c3c['serverUrl']=intUtil[_0x51ed('0x3f')](_0x378c3c[_0x51ed('0x40')]);if(_0x56a20b&&_0x56a20b['recordingFormat']&&_0x56a20b[_0x51ed('0x4f')]!==_0x51ed('0x50')){logger[_0x51ed('0xc')](_0x51ed('0x51'),_0x51ed('0x43'));_0x3ca6f2[_0x51ed('0x44')]=util['format'](_0x51ed('0x45'),_0x378c3c[_0x51ed('0x40')],_0x3ca6f2[_0x51ed('0x46')],md5(_0x3ca6f2[_0x51ed('0x46')]));}headers[_0x51ed('0x52')]=getAuth(_0x378c3c);return getUser(_0x378c3c,_0x20eb43[_0x51ed('0x23')])[_0x51ed('0x1e')](function(_0x2283f0){_0x52a3c2=_0x2283f0;logger['info'](_0x51ed('0x47'),_0x52a3c2['id']);return getEndUser(_0x378c3c,_0x3ca6f2[_0x51ed('0x53')],_0x3ca6f2['destcalleridnum']);})[_0x51ed('0x1e')](function(_0xac5ac0){_0x38d0d8=_0xac5ac0;logger[_0x51ed('0xc')](_0x51ed('0x48'),_0x38d0d8['id']);return getTicket(_0x378c3c,_0x52a3c2,_0x38d0d8,_0x15c50e,_0x3ca6f2);})[_0x51ed('0x1e')](function(_0x354aed){if(_0x354aed&&_0x354aed['id']){logger[_0x51ed('0xc')](_0x51ed('0x1c'));logger[_0x51ed('0xc')]('The\x20Ticket\x20ID\x20is:',_0x354aed['id']);logger[_0x51ed('0xc')](_0x51ed('0x51'),_0x51ed('0x54'));emit(util['format']('user:%s',_0x20eb43[_0x51ed('0x15')]),_0x51ed('0x4b'),{'uri':util[_0x51ed('0x19')](_0x51ed('0x4c'),_0x378c3c[_0x51ed('0x1a')],_0x354aed['id'])});}})[_0x51ed('0x55')](function(_0x15cae2){logger[_0x51ed('0x4d')](_0x51ed('0x51'),JSON[_0x51ed('0x30')](_0x15cae2));});};exports[_0x51ed('0x56')]=function(_0x50f2d0,_0x5e138e,_0x11503f,_0x3d7bee,_0x3007ac,_0x42311e){var _0x511950,_0x59722c;_0x42311e['remoteUri']=intUtil[_0x51ed('0x3f')](_0x42311e[_0x51ed('0x1a')]);_0x42311e[_0x51ed('0x40')]=intUtil[_0x51ed('0x3f')](_0x42311e[_0x51ed('0x40')]);if(_0x3007ac&&_0x3007ac[_0x51ed('0x41')]){logger[_0x51ed('0xc')]('['+_0x5e138e[_0x51ed('0x57')][_0x51ed('0x58')]()+']',_0x51ed('0x43'));_0x5e138e[_0x51ed('0x44')]=util[_0x51ed('0x19')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x42311e[_0x51ed('0x40')],_0x5e138e['uniqueid'],md5(_0x5e138e[_0x51ed('0x46')]));}else{_0x5e138e[_0x51ed('0x44')]='';}headers[_0x51ed('0x52')]=getAuth(_0x42311e);return getUser(_0x42311e,'')[_0x51ed('0x1e')](function(_0x3e96c3){_0x511950=_0x3e96c3;logger['info'](_0x51ed('0x47'),_0x511950['id']);return getEndUser(_0x42311e,_0x5e138e[_0x51ed('0x10')],_0x5e138e[_0x51ed('0x11')]);})['then'](function(_0x2180e3){_0x59722c=_0x2180e3;logger[_0x51ed('0xc')](_0x51ed('0x48'),_0x59722c['id']);return getTicket(_0x42311e,_0x511950,_0x59722c,_0x11503f,_0x5e138e);})['then'](function(_0xca5078){if(_0xca5078){logger['info'](_0x51ed('0x1c'));logger['info']('The\x20Ticket\x20ID\x20is:',_0xca5078['id']);}})[_0x51ed('0x55')](function(_0x392e47){logger['error']('['+_0x5e138e[_0x51ed('0x57')][_0x51ed('0x58')]()+']',JSON[_0x51ed('0x30')](_0x392e47));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/freshsales.js b/server/services/ami/trigger/integration/freshsales.js new file mode 100644 index 0000000..8a7863a --- /dev/null +++ b/server/services/ami/trigger/integration/freshsales.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd38a=['Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','lodash','md5','util','moment','./util','../../../../config/environment','../../../../config/logger','redis','localhost','socket.io-emitter','GET','headers','info','Getting\x20admin\x20information','then','adminEmail','adminId','Admin\x20found:','catch','error','toUpperCase','message','Getting\x20user\x20list','users','agentEmail','userEmail','length','userId','Requested\x20Resource\x20not\x20Found','/api/lookup?q=','&f=','&entities=contact','find','format','contactNumber','mobile_number','endUserId','Contact\x20found\x20mobile_number:','work_number','Contact\x20found\x20work_number:','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','POST','getString','add','ticketId','task','Task\x20created:','/contacts/','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','stripTrailingSlash','serverUrl','username','toLowerCase','outbound','destcalleridnum','callDirection','queue','email','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','The\x20ticket\x20ID\x20is:\x20%s','unmanaged'];(function(_0x397f37,_0x3cf86d){var _0x31cae6=function(_0x5cddb9){while(--_0x5cddb9){_0x397f37['push'](_0x397f37['shift']());}};_0x31cae6(++_0x3cf86d);}(_0xd38a,0x9f));var _0xad38=function(_0xc7d00f,_0x3d31c9){_0xc7d00f=_0xc7d00f-0x0;var _0x416f1d=_0xd38a[_0xc7d00f];return _0x416f1d;};'use strict';var _=require(_0xad38('0x0'));var rp=require('request-promise');var md5=require(_0xad38('0x1'));var util=require(_0xad38('0x2'));var moment=require(_0xad38('0x3'));var Promise=require('bluebird');var Redis=require('ioredis');var intUtil=require(_0xad38('0x4'));var config=require(_0xad38('0x5'));var logger=require(_0xad38('0x6'))('freshsales');config[_0xad38('0x7')]=_['defaults'](config[_0xad38('0x7')],{'host':_0xad38('0x8'),'port':0x18eb});var io=require(_0xad38('0x9'))(new Redis(config['redis']));function getAdminId(_0x497953,_0x10d257,_0x381800,_0xcb6fb9){return new Promise(function(_0x3e2dfd,_0x340261){var _0x239ac9=![];var _0x1ece3e={'method':_0xad38('0xa'),'uri':_0xcb6fb9+'/api/selector/owners','json':!![]};_0x1ece3e[_0xad38('0xb')]=_0x381800;logger[_0xad38('0xc')](_0xad38('0xd'));return rp(_0x1ece3e)[_0xad38('0xe')](function(_0x502d93){if(_0x502d93){var _0x45cead=_0x502d93['users'];var _0x2a2f4f=null;for(_0x2a2f4f=0x0;_0x2a2f4f<_0x45cead['length'];_0x2a2f4f++){if(_0x45cead[_0x2a2f4f]['email']===_0x497953[_0xad38('0xf')]){_0x497953[_0xad38('0x10')]=_0x45cead[_0x2a2f4f]['id'];_0x239ac9=!![];}}if(_0x239ac9){logger['info'](_0xad38('0x11'),_0x497953[_0xad38('0x10')]);_0x3e2dfd(_0x497953);}else{_0x340261({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x340261({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0xad38('0x12')](function(_0x59dd30){logger[_0xad38('0x13')]('['+[_0x10d257[_0xad38('0x14')]()]+']',_0x59dd30[_0xad38('0x15')]);_0x340261(_0x59dd30);});});}function getUser(_0x3fe7ba,_0x57e5cf,_0x4e4eda){return function(_0x520503){return new Promise(function(_0x321a22,_0x87343a){var _0x56fc66={'method':_0xad38('0xa'),'uri':_0x4e4eda+'/api/selector/owners','json':!![]};_0x56fc66[_0xad38('0xb')]=_0x57e5cf;logger[_0xad38('0xc')](_0xad38('0x16'));return rp(_0x56fc66)['then'](function(_0xdea8a7){if(_0xdea8a7){var _0x151e97=_0xdea8a7[_0xad38('0x17')];var _0x37ee3e=![];var _0x580938=null;if(_0x520503[_0xad38('0x18')]!==null){logger[_0xad38('0xc')]('Getting\x20user\x20with\x20email',_0x520503[_0xad38('0x18')]);_0x520503[_0xad38('0x19')]=_0x520503[_0xad38('0x18')];for(_0x580938=0x0;_0x580938<_0x151e97[_0xad38('0x1a')];_0x580938++){if(_0x151e97[_0x580938]['email']===_0x520503['agentEmail']){_0x37ee3e=!![];_0x520503[_0xad38('0x1b')]=_0x151e97[_0x580938]['id'];logger[_0xad38('0xc')]('User\x20found:',_0x520503[_0xad38('0x1b')]);}}}if(!_0x37ee3e){logger[_0xad38('0xc')]('Admin\x20selected');_0x520503[_0xad38('0x19')]=_0x520503[_0xad38('0xf')];_0x520503[_0xad38('0x1b')]=_0x520503[_0xad38('0x10')];_0x37ee3e=!![];}if(_0x37ee3e){_0x321a22(_0x520503);}else{_0x87343a({'statusCode':0x194,'message':_0xad38('0x1c')});}}else{_0x87343a({'statusCode':0x194,'message':_0xad38('0x1c')});}})[_0xad38('0x12')](function(_0x479a8c){logger[_0xad38('0x13')]('['+[_0x3fe7ba['toUpperCase']()]+']',_0x479a8c[_0xad38('0x15')]);_0x87343a(_0x479a8c);});});};}function searchContact(_0x4283ce,_0x506599,_0x461913,_0x566e1e){return new Promise(function(_0x51faff,_0x2963a0){var _0x45917f={'method':'GET','headers':_0x506599,'uri':_0x4283ce+_0xad38('0x1d')+_0x566e1e+_0xad38('0x1e')+_0x461913+_0xad38('0x1f'),'json':!![]};rp(_0x45917f)[_0xad38('0xe')](function(_0x37fc7f){var _0x30d37f=_[_0xad38('0x20')](_0x37fc7f['contacts']['contacts'],[_0x461913,_0x566e1e]);_0x51faff(_0x30d37f);})[_0xad38('0x12')](function(_0x356eff){_0x2963a0(_0x356eff);});});}function getEndUser(_0x56bb44,_0x1bbc3e,_0x54d75b){return function(_0x1ff932){return new Promise(function(_0x27ed7d,_0x39f8c9){logger[_0xad38('0xc')](util[_0xad38('0x21')]('Searching\x20contact\x20with\x20phone\x20%s',_0x1ff932[_0xad38('0x22')]));searchContact(_0x54d75b,_0x1bbc3e,_0xad38('0x23'),_0x1ff932['contactNumber'])['then'](function(_0x2f7b15){if(_0x2f7b15){_0x1ff932[_0xad38('0x24')]=_0x2f7b15['id'];logger[_0xad38('0xc')](_0xad38('0x25'),_0x1ff932[_0xad38('0x24')]);return _0x27ed7d(_0x1ff932);}searchContact(_0x54d75b,_0x1bbc3e,_0xad38('0x26'),_0x1ff932[_0xad38('0x22')])[_0xad38('0xe')](function(_0x863b24){if(_0x863b24){_0x1ff932[_0xad38('0x24')]=_0x863b24['id'];logger[_0xad38('0xc')](_0xad38('0x27'),_0x1ff932['endUserId']);return _0x27ed7d(_0x1ff932);}createEndUser(_0x1ff932,_0x56bb44,_0x1bbc3e,_0x54d75b)[_0xad38('0xe')](function(_0x3b67d3){logger['info']('Contact\x20created:',_0x3b67d3['endUserId']);return _0x27ed7d(_0x3b67d3);});});})[_0xad38('0x12')](function(_0x561fd7){_0x39f8c9(_0x561fd7);});});};}function createEndUser(_0x74117b,_0x854ef4,_0x2056e7,_0x4ca8d0){return new Promise(function(_0x5da8c0,_0x259323){var _0x3eb925=moment();var _0x10b57b={'method':'POST','uri':_0x4ca8d0+'/api/contacts','body':{'contact':{'last_name':_0x74117b['contactNumber'],'work_number':_0x74117b[_0xad38('0x22')],'mobile_number':_0x74117b['contactNumber'],'owner_id':_0x74117b[_0xad38('0x1b')],'created_at':_0x3eb925[_0xad38('0x21')](_0xad38('0x28'))}},'json':!![]};_0x10b57b['headers']=_0x2056e7;logger['info'](_0xad38('0x29'));return rp(_0x10b57b)[_0xad38('0xe')](function(_0x4e6dc6){_0x74117b[_0xad38('0x24')]=_0x4e6dc6[_0xad38('0x2a')]['id'];_0x5da8c0(_0x74117b);})['catch'](function(_0x2c1420){logger['error']('['+[_0x854ef4['toUpperCase']()]+']',_0x2c1420[_0xad38('0x15')]);_0x259323(_0x2c1420[_0xad38('0x15')]);});});}function getTicket(_0x5729ff,_0x4c782e,_0x3dbc5d,_0x37b4a5,_0x145b67){return function(_0x50866d){logger[_0xad38('0xc')](_0xad38('0x2b'));return new Promise(function(_0x129ba4,_0x41ddc5){var _0x124866=moment();var _0x385e68={'method':_0xad38('0x2c'),'uri':_0x3dbc5d+'/api/tasks','body':{'title':intUtil[_0xad38('0x2d')](_0x37b4a5['Subjects'],_0x145b67,'\x20'),'description':intUtil[_0xad38('0x2d')](_0x37b4a5['Descriptions'],_0x145b67,'\x0a'),'owner_id':_0x50866d['userId'],'creater_id':_0x50866d[_0xad38('0x10')],'targetable_id':_0x50866d['endUserId'],'targetable_type':'Contact','created_at':_0x124866[_0xad38('0x21')](_0xad38('0x28')),'due_date':_0x124866[_0xad38('0x2e')](0x1e,'m')[_0xad38('0x21')](_0xad38('0x28'))},'json':!![]};_0x385e68['headers']=_0x4c782e;return rp(_0x385e68)[_0xad38('0xe')](function(_0x1c68f4){_0x50866d[_0xad38('0x2f')]=_0x1c68f4[_0xad38('0x30')]['id'];logger[_0xad38('0xc')](_0xad38('0x31'),_0x50866d[_0xad38('0x2f')]);_0x129ba4(_0x50866d);})['catch'](function(_0x264a99){logger[_0xad38('0x13')]('['+[_0x5729ff[_0xad38('0x14')]()]+']',_0x264a99[_0xad38('0x15')]);_0x41ddc5(_0x264a99['message']);});});};}function emit(_0x47eda4,_0xad3574,_0x4e7be4){var _0x3f6fef={'uri':_0x47eda4+_0xad38('0x32')+_0x4e7be4};io['to'](util[_0xad38('0x21')](_0xad38('0x33'),_0xad3574))[_0xad38('0x34')](_0xad38('0x35'),_0x3f6fef);}exports['cs']=function(_0xcdb9eb,_0x3a0d60,_0x5f19e5,_0x399695,_0x56f8af,_0x1d1761,_0x2b0eb5,_0x315963){var _0x4d4e09={};var _0xea240d={'Authorization':_0xad38('0x36')+_0x1d1761[_0xad38('0x37')]};_0x1d1761[_0xad38('0x38')]=intUtil[_0xad38('0x39')](_0x1d1761[_0xad38('0x38')]);_0x1d1761[_0xad38('0x3a')]=intUtil[_0xad38('0x39')](_0x1d1761[_0xad38('0x3a')]);var _0x36f1fb=_0x1d1761[_0xad38('0x38')];_0x4d4e09[_0xad38('0xf')]=_0x1d1761[_0xad38('0x3b')];_0x4d4e09[_0xad38('0x22')]=_0x315963[_0xad38('0x3c')]()===_0xad38('0x3d')?_0x3a0d60[_0xad38('0x3e')]:_0x3a0d60['calleridnum'];_0x4d4e09[_0xad38('0x3f')]=_0x315963===_0xad38('0x40')||_0x315963==='unmanaged'?_0xad38('0x40'):'outbound';if(_0x399695){_0x4d4e09[_0xad38('0x18')]=_0x399695[_0xad38('0x41')];}var _0x4f85a2=util['format'](_0xad38('0x42'),_0x1d1761[_0xad38('0x3a')],_0x3a0d60[_0xad38('0x43')],md5(_0x3a0d60[_0xad38('0x43')]));if(_0x56f8af&&_0x56f8af['monitor_format']){logger['info'](_0xad38('0x44'),_0xad38('0x45'));_0x3a0d60[_0xad38('0x46')]=_0x4f85a2;}else if(_0x2b0eb5&&_0x2b0eb5[_0xad38('0x47')]&&_0x2b0eb5['recordingFormat']!==_0xad38('0x48')){logger[_0xad38('0xc')]('[OUTBOUND]',_0xad38('0x45'));_0x3a0d60[_0xad38('0x46')]=_0x4f85a2;}else{_0x3a0d60[_0xad38('0x46')]='';}return getAdminId(_0x4d4e09,_0x315963,_0xea240d,_0x36f1fb)[_0xad38('0xe')](getUser(_0x315963,_0xea240d,_0x36f1fb))[_0xad38('0xe')](getEndUser(_0x315963,_0xea240d,_0x36f1fb))['then'](getTicket(_0x315963,_0xea240d,_0x36f1fb,_0x5f19e5,_0x3a0d60))[_0xad38('0xe')](function(_0x346b38){logger['info'](util['format'](_0xad38('0x49'),_0x346b38[_0xad38('0x2f')]));if(_0x315963!==_0xad38('0x4a')){logger['info']('['+[_0x315963[_0xad38('0x14')]()]+']',_0xad38('0x4b'));emit(_0x36f1fb,_0x399695[_0xad38('0x4c')],_0x346b38[_0xad38('0x24')]);}})[_0xad38('0x12')](function(_0x4a9e4f){logger[_0xad38('0x13')]('['+[_0x315963[_0xad38('0x14')]()]+_0xad38('0x4d'),util['inspect'](_0x4a9e4f,{'showHidden':!![],'depth':null}));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/index.js b/server/services/ami/trigger/integration/index.js new file mode 100644 index 0000000..a1f758d --- /dev/null +++ b/server/services/ami/trigger/integration/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd2a4=['toLowerCase','data2','find','Configurations','data3','outbound','log','EVENT\x20UNKNOWN','unmanaged','data1','salesforce','unknown\x20integration','../../../../config/logger','format','%s\x20configuration\x20#%s\x20not\x20found','error','[EXEC]','%s\x20account\x20#%s\x20not\x20found','lodash','./zendesk','./freshdesk','./zoho','./desk','./servicenow','./dynamics365','./freshsales','zendesk','sugarcrm','freshdesk','zoho','desk','vtiger','dynamics365','freshsales','servicenow','exec','includes'];(function(_0x3d6c3a,_0x37855c){var _0x13de15=function(_0xbe2a7c){while(--_0xbe2a7c){_0x3d6c3a['push'](_0x3d6c3a['shift']());}};_0x13de15(++_0x37855c);}(_0xd2a4,0x15f));var _0x4d2a=function(_0x35e2d7,_0x39e854){_0x35e2d7=_0x35e2d7-0x0;var _0x405bff=_0xd2a4[_0x35e2d7];return _0x405bff;};'use strict';var _=require(_0x4d2a('0x0'));var util=require('util');var zendesk=require(_0x4d2a('0x1'));var salesforce=require('./salesforce');var sugarcrm=require('./sugarcrm');var freshdesk=require(_0x4d2a('0x2'));var zoho=require(_0x4d2a('0x3'));var desk=require(_0x4d2a('0x4'));var vtiger=require('./vtiger');var servicenow=require(_0x4d2a('0x5'));var dynamics365=require(_0x4d2a('0x6'));var freshsales=require(_0x4d2a('0x7'));var integrations=[_0x4d2a('0x8'),'salesforce',_0x4d2a('0x9'),_0x4d2a('0xa'),_0x4d2a('0xb'),_0x4d2a('0xc'),_0x4d2a('0xd'),_0x4d2a('0xe'),_0x4d2a('0xf'),_0x4d2a('0x10')];exports[_0x4d2a('0x11')]=function(_0x3d137b,_0x5e2b24,_0x5beea4,_0x408dbe,_0x4e507e,_0x457e68){if(_0x5beea4){if(_[_0x4d2a('0x12')](integrations,_0x3d137b['data1']['toLowerCase']())){try{var _0x9c488d=null;var _0x180f20='';var _0x3e33bb=_0x5beea4[_0x3d137b['data1'][_0x4d2a('0x13')]()];if(_0x3e33bb){var _0x195598=_0x3e33bb[_0x3d137b[_0x4d2a('0x14')]];if(_0x195598){var _0x3b674c=_[_0x4d2a('0x15')](_0x195598[_0x4d2a('0x16')],{'id':parseInt(_0x3d137b[_0x4d2a('0x17')],0xa)});if(_0x3b674c){if(_0x408dbe){if(_0x4e507e&&_0x5e2b24['queue']){_0x180f20='queue';}else if(_0x5e2b24['routeId']){_0x180f20=_0x4d2a('0x18');}else{console[_0x4d2a('0x19')](_0x4d2a('0x1a'),_0x5e2b24);}}else{_0x180f20=_0x4d2a('0x1b');}switch(_0x3d137b[_0x4d2a('0x1c')][_0x4d2a('0x13')]()){case _0x4d2a('0x8'):zendesk[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case _0x4d2a('0x1d'):salesforce[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case'sugarcrm':sugarcrm[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case'freshdesk':freshdesk[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case _0x4d2a('0xb'):zoho[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case'desk':desk[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case _0x4d2a('0xd'):vtiger[_0x180f20](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68);break;case _0x4d2a('0xf'):freshsales['cs'](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68,_0x180f20);break;case _0x4d2a('0x10'):servicenow['cs'](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68,_0x180f20);break;case _0x4d2a('0xe'):dynamics365['cs'](_0x3d137b,_0x5e2b24,_0x3b674c,_0x408dbe,_0x4e507e,_0x195598,_0x457e68,_0x180f20);break;default:console[_0x4d2a('0x19')](_0x4d2a('0x1e'));}}else{_0x9c488d=require(_0x4d2a('0x1f'))(_0x3d137b[_0x4d2a('0x1c')][_0x4d2a('0x13')]());_0x9c488d['error']('[EXEC]',util[_0x4d2a('0x20')](_0x4d2a('0x21'),_0x3d137b[_0x4d2a('0x1c')][_0x4d2a('0x13')](),_0x3d137b[_0x4d2a('0x17')]));}}else{_0x9c488d=require(_0x4d2a('0x1f'))(_0x3d137b['data1'][_0x4d2a('0x13')]());_0x9c488d[_0x4d2a('0x22')](_0x4d2a('0x23'),util['format'](_0x4d2a('0x24'),_0x3d137b[_0x4d2a('0x1c')][_0x4d2a('0x13')](),_0x3d137b['data2']));}}else{}}catch(_0x3f8775){console[_0x4d2a('0x22')](_0x3f8775);}}}}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/salesforce.js b/server/services/ami/trigger/integration/salesforce.js new file mode 100644 index 0000000..ea43bf6 --- /dev/null +++ b/server/services/ami/trigger/integration/salesforce.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5925=['recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','calleridnum','Fields','[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','trigger:salesforce:display','newTab','user:%s','trigger:browser:url','%s/%s/e','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','recordingFormat','none','[OUTBOUND]','destcalleridname','destcalleridnum','outbound','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','Salesforce\x20account\x20type\x20not\x20recognized','toUpperCase',']\x20Ticket\x20%s\x20created.','lastevent','lodash','request-promise','moment','md5','jsforce','util','ioredis','./util','../../../../config/environment','localhost','socket.io-emitter','redis','getString','Subjects','Descriptions','ticketType','Task','IsReminderSet','endUserType','contact','lead','WhoId','account','ContactId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','create','isNil','validateEmail','execute','then','length','Agent\x20%s\x20found.','Name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','identity','resolve','user_id','display_name','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','Contact','find','additionalSearchLead','account_contact_lead','additionalSearchAccount','Account','Lead','first','Phone','attributes','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','moduleCreate','LastName','','format','Caller\x20-\x20%s','Company','No\x20Company','upperFirst','forEach','includes','string','picklist','type','idField','content','toString','variable','variableName','customVariable','Variable','toLowerCase','name','password','concat','securityToken','remoteUri','clientId','clientSecret','login','username','Connection\x20established.','serverUrl','stripTrailingSlash','[QUEUE]','Recording\x20is\x20enabled!'];(function(_0x2c3182,_0x252ce0){var _0x3b76fe=function(_0x337626){while(--_0x337626){_0x2c3182['push'](_0x2c3182['shift']());}};_0x3b76fe(++_0x252ce0);}(_0x5925,0x118));var _0x5592=function(_0x547587,_0x48cbd9){_0x547587=_0x547587-0x0;var _0x3d7777=_0x5925[_0x547587];return _0x3d7777;};'use strict';var _=require(_0x5592('0x0'));var rp=require(_0x5592('0x1'));var moment=require(_0x5592('0x2'));var BPromise=require('bluebird');var md5=require(_0x5592('0x3'));var jsforce=require(_0x5592('0x4'));var util=require(_0x5592('0x5'));var Redis=require(_0x5592('0x6'));var intUtil=require(_0x5592('0x7'));var config=require(_0x5592('0x8'));var logger=require('../../../../config/logger')('salesforce');config['redis']=_['defaults'](config['redis'],{'host':_0x5592('0x9'),'port':0x18eb});var io=require(_0x5592('0xa'))(new Redis(config[_0x5592('0xb')]));function emit(_0x9403a7,_0x5f2e8e,_0x1128ca){io['to'](_0x9403a7)['emit'](_0x5f2e8e,_0x1128ca);}function getTicket(_0x108bfc,_0x2c7231,_0x57c616,_0x30f065,_0x2e299c,_0x350ba4,_0xa9e5e5,_0x52a165){var _0x4123f7=Object['assign']({},{'OwnerId':_0x2c7231['id'],'Subject':intUtil[_0x5592('0xc')](_0x30f065[_0x5592('0xd')],_0x2e299c,'\x20'),'Description':intUtil['getString'](_0x30f065[_0x5592('0xe')],_0x2e299c,'\x0a')},getCustomFields(_0x350ba4,_0x2e299c));if(_0x57c616){if(_0x30f065[_0x5592('0xf')]===_0x5592('0x10')){_0x4123f7['ActivityDate']=moment['utc']();_0x4123f7[_0x5592('0x11')]=![];_0x4123f7['IsRecurrence']=![];if(_0x57c616[_0x5592('0x12')]===_0x5592('0x13')||_0x57c616[_0x5592('0x12')]===_0x5592('0x14')){_0x4123f7[_0x5592('0x15')]=_0x57c616['id'];}else if(_0x57c616[_0x5592('0x12')]===_0x5592('0x16')){_0x4123f7['WhatId']=_0x57c616['id'];}}else if(_0x30f065[_0x5592('0xf')]==='Case'){if(_0x57c616[_0x5592('0x12')]===_0x5592('0x13')){_0x4123f7[_0x5592('0x17')]=_0x57c616['id'];}else if(_0x57c616[_0x5592('0x12')]===_0x5592('0x16')){_0x4123f7['AccountId']=_0x57c616['id'];}else if(_0x57c616[_0x5592('0x12')]===_0x5592('0x14')&&_0x30f065['leadId']){_0x4123f7[_0x30f065['leadId']]=_0x57c616['id'];}else{logger[_0x5592('0x18')](_0x5592('0x19'));}}}return _0xa9e5e5[_0x5592('0x1a')](_0x30f065[_0x5592('0xf')])[_0x5592('0x1b')](_0x4123f7);}function getUser(_0x538ffd,_0x2b84ce,_0x45a8b0){if(!_[_0x5592('0x1c')](_0x2b84ce)&&intUtil[_0x5592('0x1d')](_0x2b84ce)){var _0x514519={'Email':_0x2b84ce};var _0x1eef1f={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x45a8b0[_0x5592('0x1a')]('User')['find'](_0x514519,_0x1eef1f)[_0x5592('0x1e')]()[_0x5592('0x1f')](function(_0x357d1a){if(_0x357d1a[_0x5592('0x20')]){var _0x2162e0=_['find'](_0x357d1a,function(_0x1d4ff1){return _0x1d4ff1['Email']===_0x2b84ce;});if(_0x2162e0){logger[_0x5592('0x18')](_0x5592('0x21'),_0x2b84ce);return BPromise['resolve']({'id':_0x2162e0['Id'],'name':_0x2162e0[_0x5592('0x22')]});}}else{logger[_0x5592('0x18')](_0x5592('0x23'),_0x2b84ce);return _0x45a8b0[_0x5592('0x24')]()[_0x5592('0x1f')](function(_0x2c02fe){return BPromise[_0x5592('0x25')]({'id':_0x2c02fe[_0x5592('0x26')],'name':_0x2c02fe[_0x5592('0x27')]});});}});}else{logger['info'](_0x5592('0x23'),_0x2b84ce);return _0x45a8b0[_0x5592('0x24')]()[_0x5592('0x1f')](function(_0x4eee9e){return BPromise[_0x5592('0x25')]({'id':_0x4eee9e[_0x5592('0x26')],'name':_0x4eee9e[_0x5592('0x27')]});});}}function getEndUser(_0x152548,_0x30590f,_0xaca15a,_0x54d8f2,_0x5aa002){var _0x4a6650={'$or':{'Phone':_0x54d8f2}};var _0x22b44a={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x5592('0x25')]()[_0x5592('0x1f')](function(){logger[_0x5592('0x18')](_0x5592('0x28'),_0x54d8f2,_0x30590f[_0x5592('0x29')]);switch(_0x30590f['moduleSearch']){case _0x5592('0x2a'):var _0x4dbe9f=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f[_0x5592('0x2c')]){var _0x461cf2={};_0x461cf2[_0x30590f['additionalSearchContact']]=_0x54d8f2;_[_0x5592('0x2d')](_0x4dbe9f[_0x5592('0x2e')],_0x461cf2);}return _0x5aa002[_0x5592('0x1a')](_0x5592('0x2f'))[_0x5592('0x30')](_0x4dbe9f,_0x22b44a)[_0x5592('0x1e')]()[_0x5592('0x1f')](function(_0x58f8ce){if(_0x58f8ce&&_0x58f8ce['length']){return _0x58f8ce;}else{var _0x353385=_['cloneDeep'](_0x4a6650);if(_0x30590f[_0x5592('0x31')]){var _0x4b27f7={};_0x4b27f7[_0x30590f[_0x5592('0x31')]]=_0x54d8f2;_[_0x5592('0x2d')](_0x353385[_0x5592('0x2e')],_0x4b27f7);}return _0x5aa002['sobject']('Lead')['find'](_0x353385,_0x22b44a);}});case _0x5592('0x32'):var _0xab1a6c=_['cloneDeep'](_0x4a6650);if(_0x30590f[_0x5592('0x33')]){var _0x461cf2={};_0x461cf2[_0x30590f['additionalSearchAccount']]=_0x54d8f2;_[_0x5592('0x2d')](_0xab1a6c[_0x5592('0x2e')],_0x461cf2);}return _0x5aa002['sobject'](_0x5592('0x34'))[_0x5592('0x30')](_0xab1a6c,_0x22b44a)['execute']()[_0x5592('0x1f')](function(_0x210de8){if(_0x210de8&&_0x210de8[_0x5592('0x20')]){return _0x210de8;}else{var _0x2a82bc=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f[_0x5592('0x2c')]){var _0x37aebe={};_0x37aebe[_0x30590f[_0x5592('0x2c')]]=_0x54d8f2;_[_0x5592('0x2d')](_0x2a82bc[_0x5592('0x2e')],_0x37aebe);}return _0x5aa002['sobject'](_0x5592('0x2f'))[_0x5592('0x30')](_0x2a82bc,_0x22b44a)[_0x5592('0x1f')](function(_0x2597a2){if(_0x2597a2&&_0x2597a2[_0x5592('0x20')]){return _0x2597a2;}else{var _0x3cf79a=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f[_0x5592('0x31')]){var _0x317e8c={};_0x317e8c[_0x30590f[_0x5592('0x31')]]=_0x54d8f2;_[_0x5592('0x2d')](_0x3cf79a[_0x5592('0x2e')],_0x317e8c);}return _0x5aa002['sobject'](_0x5592('0x35'))['find'](_0x3cf79a,_0x22b44a);}});}});case'contact':var _0x4dbe9f=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f[_0x5592('0x2c')]){var _0x461cf2={};_0x461cf2[_0x30590f[_0x5592('0x2c')]]=_0x54d8f2;_['merge'](_0x4dbe9f[_0x5592('0x2e')],_0x461cf2);}return _0x5aa002[_0x5592('0x1a')](_0x5592('0x2f'))[_0x5592('0x30')](_0x4dbe9f,_0x22b44a)['execute']();case _0x5592('0x14'):var _0x52060d=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f['additionalSearchLead']){var _0x461cf2={};_0x461cf2[_0x30590f[_0x5592('0x31')]]=_0x54d8f2;_[_0x5592('0x2d')](_0x52060d[_0x5592('0x2e')],_0x461cf2);}return _0x5aa002[_0x5592('0x1a')](_0x5592('0x35'))[_0x5592('0x30')](_0x52060d,_0x22b44a);case _0x5592('0x16'):var _0xab1a6c=_[_0x5592('0x2b')](_0x4a6650);if(_0x30590f[_0x5592('0x33')]){var _0x461cf2={};_0x461cf2[_0x30590f[_0x5592('0x33')]]=_0x54d8f2;_[_0x5592('0x2d')](_0xab1a6c['$or'],_0x461cf2);}return _0x5aa002[_0x5592('0x1a')](_0x5592('0x34'))[_0x5592('0x30')](_0xab1a6c,_0x22b44a);default:return null;}})['then'](function(_0x360d2e){if(_0x360d2e&&_0x360d2e[_0x5592('0x20')]){var _0x26c09e=_[_0x5592('0x36')](_0x360d2e);if(_0x26c09e){return BPromise[_0x5592('0x25')]({'id':_0x26c09e['Id'],'name':_0x26c09e[_0x5592('0x22')],'phone':_0x26c09e[_0x5592('0x37')],'endUserType':_0x26c09e[_0x5592('0x38')]['type']['toLowerCase']()});}}})[_0x5592('0x1f')](function(_0x24b4ed){if(_0x24b4ed){logger[_0x5592('0x18')](_0x5592('0x39'),_0x24b4ed[_0x5592('0x12')],_0x54d8f2);return BPromise[_0x5592('0x25')](_0x24b4ed);}else{logger[_0x5592('0x18')](_0x5592('0x3a'),_0x54d8f2);var _0x1af2da={'Phone':_0x54d8f2};if(_0x30590f['moduleCreate']){if(_0x30590f['moduleCreate']===_0x5592('0x13')){logger[_0x5592('0x18')](_0x5592('0x3b'),_0x54d8f2,_0x30590f[_0x5592('0x3c')]);_0x1af2da[_0x5592('0x3d')]=_0xaca15a!==_0x5592('0x3e')?_0xaca15a:util[_0x5592('0x3f')](_0x5592('0x40'),_0x54d8f2);}else if(_0x30590f[_0x5592('0x3c')]===_0x5592('0x14')){logger[_0x5592('0x18')](_0x5592('0x3b'),_0x54d8f2,_0x30590f[_0x5592('0x3c')]);_0x1af2da[_0x5592('0x3d')]=_0xaca15a!==_0x5592('0x3e')?_0xaca15a:util[_0x5592('0x3f')]('Caller\x20-\x20%s',_0x54d8f2);_0x1af2da[_0x5592('0x41')]=_0x5592('0x42');}else if(_0x30590f[_0x5592('0x3c')]===_0x5592('0x16')){logger[_0x5592('0x18')](_0x5592('0x3b'),_0x54d8f2,_0x30590f[_0x5592('0x3c')]);_0x1af2da[_0x5592('0x22')]=_0xaca15a!==_0x5592('0x3e')?_0xaca15a:util['format'](_0x5592('0x40'),_0x54d8f2);}else{return null;}}return _0x5aa002[_0x5592('0x1a')](_[_0x5592('0x43')](_0x30590f[_0x5592('0x3c')]))['create'](_0x1af2da)[_0x5592('0x1f')](function(_0x4e6e2d){return BPromise[_0x5592('0x25')]({'id':_0x4e6e2d['id'],'endUserType':_0x30590f[_0x5592('0x3c')]});});}});}function getCustomFields(_0x3f3229,_0x29509a){var _0x3af0ff={};if(_0x3f3229[_0x5592('0x20')]>0x0){_[_0x5592('0x44')](_0x3f3229,function(_0x4ec007){if(_[_0x5592('0x45')]([_0x5592('0x46'),_0x5592('0x47')],_0x4ec007[_0x5592('0x48')])&&_0x4ec007['idField']){_0x3af0ff[_0x4ec007[_0x5592('0x49')]]=_0x4ec007[_0x5592('0x4a')][_0x5592('0x4b')]();}else if(_0x4ec007['type']===_0x5592('0x4c')&&_0x4ec007[_0x5592('0x4d')]&&_0x4ec007[_0x5592('0x49')]){_0x29509a[_0x4ec007[_0x5592('0x4d')]]&&(_0x3af0ff[_0x4ec007[_0x5592('0x49')]]=_0x29509a[_0x4ec007[_0x5592('0x4d')]]['toString']());}else if(_0x4ec007[_0x5592('0x48')]===_0x5592('0x4e')&&_0x4ec007[_0x5592('0x4f')]&&_0x4ec007['Variable']['name']&&_0x4ec007['idField']){_0x29509a[_0x4ec007[_0x5592('0x4f')]['name'][_0x5592('0x50')]()]&&(_0x3af0ff[_0x4ec007[_0x5592('0x49')]]=_0x29509a[_0x4ec007[_0x5592('0x4f')][_0x5592('0x51')][_0x5592('0x50')]()]['toString']());}});}return _0x3af0ff;}function getConnection(_0x46a396){var _0x59e700=_0x46a396[_0x5592('0x52')][_0x5592('0x53')](_0x46a396[_0x5592('0x54')]);var _0x58eacc=new jsforce['Connection']({'oauth2':{'loginUrl':_0x46a396[_0x5592('0x55')]||'https://login.salesforce.com','clientId':_0x46a396[_0x5592('0x56')],'clientSecret':_0x46a396[_0x5592('0x57')]}});return _0x58eacc[_0x5592('0x58')](_0x46a396[_0x5592('0x59')],_0x59e700)['then'](function(){logger[_0x5592('0x18')](_0x5592('0x5a'));return _0x58eacc;});}exports['queue']=function(_0x3b4674,_0xac008f,_0x5de7f6,_0xb878ab,_0xfb142f,_0x3fca90){var _0x42621d,_0x59b1fb,_0x5562ee,_0x2287c3;_0x3fca90[_0x5592('0x5b')]=intUtil[_0x5592('0x5c')](_0x3fca90['serverUrl']);_0x3fca90[_0x5592('0x55')]=intUtil['stripTrailingSlash'](_0x3fca90['remoteUri']);if(_0xfb142f&&_0xfb142f['monitor_format']){logger[_0x5592('0x18')](_0x5592('0x5d'),_0x5592('0x5e'));_0xac008f[_0x5592('0x5f')]=util['format'](_0x5592('0x60'),_0x3fca90[_0x5592('0x5b')],_0xac008f[_0x5592('0x61')],md5(_0xac008f[_0x5592('0x61')]));}else{_0xac008f[_0x5592('0x5f')]='';}return getConnection(_0x3fca90)[_0x5592('0x1f')](function(_0x2d5239){_0x2287c3=_0x2d5239;return getUser(_0x3fca90,_0xb878ab[_0x5592('0x62')],_0x2287c3);})[_0x5592('0x1f')](function(_0x32d9ba){_0x42621d=_0x32d9ba;return getEndUser(_0x3fca90,_0x5de7f6,_0xac008f[_0x5592('0x63')],_0xac008f[_0x5592('0x64')],_0x2287c3);})[_0x5592('0x1f')](function(_0x46cc22){_0x59b1fb=_0x46cc22;return getTicket(_0x3fca90,_0x42621d,_0x59b1fb,_0x5de7f6,_0xac008f,_0x5de7f6[_0x5592('0x65')],_0x2287c3,'queue');})[_0x5592('0x1f')](function(_0x1ba6a4){_0x5562ee=_0x1ba6a4;logger[_0x5592('0x18')]('[QUEUE]\x20Ticket\x20%s\x20created',_0x5562ee['id']);logger[_0x5592('0x18')](_0x5592('0x66'),_0x5562ee['id'],_0xb878ab[_0x5592('0x51')],_0x3fca90['type']);switch(_0x3fca90['type']){case _0x5592('0x67'):emit(util[_0x5592('0x3f')]('user:%s',_0xb878ab['name']),_0x5592('0x68'),{'recordId':_0x5562ee['id']});break;case _0x5592('0x69'):emit(util[_0x5592('0x3f')](_0x5592('0x6a'),_0xb878ab[_0x5592('0x51')]),_0x5592('0x6b'),{'uri':util[_0x5592('0x3f')](_0x5592('0x6c'),_0x2287c3[_0x5592('0x6d')],_0x5562ee['id'])});break;default:logger[_0x5592('0x6e')](_0x5592('0x6f'));}})[_0x5592('0x70')](function(_0x291345){logger['error'](_0x5592('0x5d'),_0x291345);});};exports['outbound']=function(_0x4149a3,_0x575d45,_0x17e679,_0x1544ef,_0x1e2bc7,_0x567a45,_0x25dbf6){var _0x2ace8d,_0x458d36,_0x3d9e91,_0x2bda44;_0x567a45[_0x5592('0x5b')]=intUtil[_0x5592('0x5c')](_0x567a45['serverUrl']);_0x567a45[_0x5592('0x55')]=intUtil[_0x5592('0x5c')](_0x567a45['remoteUri']);if(_0x25dbf6&&_0x25dbf6['recordingFormat']&&_0x25dbf6[_0x5592('0x71')]!==_0x5592('0x72')){logger[_0x5592('0x18')](_0x5592('0x73'),_0x5592('0x5e'));_0x575d45[_0x5592('0x5f')]=util[_0x5592('0x3f')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x567a45['serverUrl'],_0x575d45[_0x5592('0x61')],md5(_0x575d45[_0x5592('0x61')]));}return getConnection(_0x567a45)[_0x5592('0x1f')](function(_0x254eef){_0x2bda44=_0x254eef;return getUser(_0x567a45,_0x1544ef[_0x5592('0x62')],_0x2bda44);})[_0x5592('0x1f')](function(_0x365aa9){_0x2ace8d=_0x365aa9;return getEndUser(_0x567a45,_0x17e679,_0x575d45[_0x5592('0x74')],_0x575d45[_0x5592('0x75')],_0x2bda44);})[_0x5592('0x1f')](function(_0x1db8b6){_0x458d36=_0x1db8b6;return getTicket(_0x567a45,_0x2ace8d,_0x458d36,_0x17e679,_0x575d45,_0x17e679[_0x5592('0x65')],_0x2bda44,_0x5592('0x76'));})[_0x5592('0x1f')](function(_0x270cf4){_0x3d9e91=_0x270cf4;logger['info'](_0x5592('0x77'),_0x3d9e91['id']);logger[_0x5592('0x18')](_0x5592('0x78'),_0x3d9e91['id'],_0x1544ef['name'],_0x567a45[_0x5592('0x48')]);switch(_0x567a45[_0x5592('0x48')]){case _0x5592('0x67'):emit(util[_0x5592('0x3f')](_0x5592('0x6a'),_0x1544ef[_0x5592('0x51')]),_0x5592('0x68'),{'recordId':_0x3d9e91['id']});break;case _0x5592('0x69'):emit(util[_0x5592('0x3f')]('user:%s',_0x1544ef[_0x5592('0x51')]),_0x5592('0x6b'),{'uri':util[_0x5592('0x3f')](_0x5592('0x6c'),_0x2bda44[_0x5592('0x6d')],_0x3d9e91['id'])});break;default:logger[_0x5592('0x6e')](_0x5592('0x73'),_0x5592('0x79'));}})[_0x5592('0x70')](function(_0x302fe4){logger['error'](_0x5592('0x73'),_0x302fe4);});};exports['unmanaged']=function(_0x3ed46e,_0x2b42ec,_0x5707e5,_0x255642,_0x4658a4,_0x27fef4){var _0x34e2a2,_0x15eaaf,_0xad0262,_0x5663a2;_0x27fef4[_0x5592('0x5b')]=intUtil['stripTrailingSlash'](_0x27fef4[_0x5592('0x5b')]);_0x27fef4[_0x5592('0x55')]=intUtil[_0x5592('0x5c')](_0x27fef4[_0x5592('0x55')]);if(_0x4658a4&&_0x4658a4['monitor_format']){logger[_0x5592('0x18')]('['+_0x2b42ec['lastevent'][_0x5592('0x7a')]()+']',_0x5592('0x5e'));_0x2b42ec['recordingURL']=util[_0x5592('0x3f')](_0x5592('0x60'),_0x27fef4[_0x5592('0x5b')],_0x2b42ec['uniqueid'],md5(_0x2b42ec[_0x5592('0x61')]));}else{_0x2b42ec[_0x5592('0x5f')]='';}return getConnection(_0x27fef4)[_0x5592('0x1f')](function(_0x56d23e){_0x5663a2=_0x56d23e;if(!_[_0x5592('0x1c')](_0x255642)){return getUser(_0x27fef4,_0x255642[_0x5592('0x51')],_0x5663a2);}else{return getUser(_0x27fef4,null,_0x5663a2);}})[_0x5592('0x1f')](function(_0x50720a){_0x34e2a2=_0x50720a;return getEndUser(_0x27fef4,_0x5707e5,_0x2b42ec[_0x5592('0x63')],_0x2b42ec['calleridnum'],_0x5663a2);})[_0x5592('0x1f')](function(_0x2f64d9){_0x15eaaf=_0x2f64d9;return getTicket(_0x27fef4,_0x34e2a2,_0x15eaaf,_0x5707e5,_0x2b42ec,_0x5707e5['Fields'],_0x5663a2);})[_0x5592('0x1f')](function(_0x2b602c){_0xad0262=_0x2b602c;logger[_0x5592('0x18')]('['+_0x2b42ec['lastevent'][_0x5592('0x7a')]()+_0x5592('0x7b'),_0xad0262['id']);logger[_0x5592('0x18')]('['+_0x2b42ec['lastevent'][_0x5592('0x7a')]()+']\x20Integration\x20account\x20type\x20%s.',_0x27fef4['type']);})[_0x5592('0x70')](function(_0x40863a){logger[_0x5592('0x6e')]('['+_0x2b42ec[_0x5592('0x7c')][_0x5592('0x7a')]()+']',_0x40863a);});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/servicenow.js b/server/services/ami/trigger/integration/servicenow.js new file mode 100644 index 0000000..1f79d4b --- /dev/null +++ b/server/services/ami/trigger/integration/servicenow.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8f70=['validateEmail','userEmail','sys_user?sysparm_query=email%3D','],\x20getUser\x20rp\x20obj','then','length','active','userId','sys_id','adminEmail',']\x20using\x20admin\x20profile','],\x20createEndUser\x20input\x20crm','sys_user?','endUserNumber','System','],\x20EndUser\x20schema','endUserId','],\x20getEndUser\x20input\x20crm','sys_user?sysparm_query=phone%3D','],\x20getEndUser\x20crm','includes','string','nameField','customField','toString','picklist','type','idField','toLowerCase','variableName','customVariable','Variable','name',']\x20getTicket\x20input\x20crm','outbound','POST','assign','true','getString','Subjects','Descriptions',']\x20POST\x20incident\x20entity\x20schema','ticketId','number',']\x20getTicket\x20crm','label','?sysparm_query=name%3D','incident','Incident\x20-\x20','ticketNumber','forEach','push','all','Tags','map','%26sysparm_record_target%3Dincident','%26sysparm_record_list%3Dactive%253Dtrue','/nav_to.do?uri=incident.do?sys_id%3D','format','user:%s','emit','trigger:browser:url','username','password','sysparm_limit=1','sysparm_display_value=true','remoteUri','stripTrailingSlash','serverUrl','%s/api/now/table/','isNil','email','destcalleridnum','calleridnum','callDirection','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','The\x20ticket\x20ID\x20is:\x20%s','unmanaged','Displaying\x20call\x20in\x20a\x20new\x20tab...',']\x20Error\x20running\x20ServiceNow\x20integration','inspect','lodash','bluebird','request-promise','util','md5','ioredis','../../../../config/environment','servicenow','redis','defaults','localhost','socket.io-emitter','GET','sys_user?sysparm_query=user_name%3Dadmin','result','adminId','info','toUpperCase','catch','error','message','],\x20getUser\x20input\x20crm'];(function(_0x4ef4f,_0x510891){var _0x1ea0d1=function(_0x4b3ec){while(--_0x4b3ec){_0x4ef4f['push'](_0x4ef4f['shift']());}};_0x1ea0d1(++_0x510891);}(_0x8f70,0x137));var _0x08f7=function(_0x1d56af,_0x3b8f7e){_0x1d56af=_0x1d56af-0x0;var _0x3d37ee=_0x8f70[_0x1d56af];return _0x3d37ee;};'use strict';var _=require(_0x08f7('0x0'));var Promise=require(_0x08f7('0x1'));var rp=require(_0x08f7('0x2'));var util=require(_0x08f7('0x3'));var md5=require(_0x08f7('0x4'));var Redis=require(_0x08f7('0x5'));var intUtil=require('./util');var config=require(_0x08f7('0x6'));var logger=require('../../../../config/logger')(_0x08f7('0x7'));config[_0x08f7('0x8')]=_[_0x08f7('0x9')](config[_0x08f7('0x8')],{'host':_0x08f7('0xa'),'port':0x18eb});var io=require(_0x08f7('0xb'))(new Redis(config[_0x08f7('0x8')]));function getAdminUser(_0x5d57b3,_0x3f41cd,_0x5b6c66,_0x234c11,_0x2fbb97,_0x5fa836){return new Promise(function(_0x117a1f,_0x16bf08){var _0x315450={'method':_0x08f7('0xc'),'uri':_0x234c11+_0x08f7('0xd')+'&'+_0x2fbb97+'&'+_0x5fa836,'auth':_0x3f41cd,'json':!![]};return rp(_0x315450)['then'](function(_0x3c4634){if(_0x3c4634[_0x08f7('0xe')]['length']>0x0){_0x5b6c66[_0x08f7('0xf')]=_0x3c4634[_0x08f7('0xe')][0x0]['sys_id'];}logger[_0x08f7('0x10')]('['+[_0x5d57b3[_0x08f7('0x11')]()]+'],\x20getAdminUser\x20crm',_0x5b6c66);_0x117a1f(_0x5b6c66);})[_0x08f7('0x12')](function(_0x5b1734){logger[_0x08f7('0x13')]('['+[_0x5d57b3[_0x08f7('0x11')]()]+']',_0x5b1734['message']);_0x16bf08(_0x5b1734[_0x08f7('0x14')]);});});}function getUser(_0x321092,_0x4f9b32,_0x1d4c3e,_0x3aab53,_0x2d91b2){return function(_0x3ebb75){logger[_0x08f7('0x10')]('['+[_0x321092['toUpperCase']()]+_0x08f7('0x15'),_0x3ebb75);return new Promise(function(_0x3cc8db,_0x2fe0b7){if(intUtil[_0x08f7('0x16')](_0x3ebb75[_0x08f7('0x17')])){var _0x3f0b28={'method':_0x08f7('0xc'),'uri':_0x1d4c3e+_0x08f7('0x18')+_0x3ebb75[_0x08f7('0x17')]+'&'+_0x3aab53+'&'+_0x2d91b2,'auth':_0x4f9b32,'json':!![]};logger[_0x08f7('0x10')]('['+[_0x321092[_0x08f7('0x11')]()]+_0x08f7('0x19'),_0x3f0b28);return rp(_0x3f0b28)[_0x08f7('0x1a')](function(_0x572e5f){logger['info']('['+[_0x321092['toUpperCase']()]+'],\x20getUser\x20entity',_0x572e5f);if(_0x572e5f[_0x08f7('0xe')][_0x08f7('0x1b')]>0x0&&String(_0x572e5f[_0x08f7('0xe')][0x0][_0x08f7('0x1c')])==='true'){_0x3ebb75[_0x08f7('0x1d')]=_0x572e5f['result'][0x0][_0x08f7('0x1e')];}else{_0x3ebb75[_0x08f7('0x1d')]=_0x3ebb75['adminId'];_0x3ebb75[_0x08f7('0x17')]=_0x3ebb75[_0x08f7('0x1f')];}logger[_0x08f7('0x10')]('['+[_0x321092['toUpperCase']()]+'],\x20getUser\x20crm',_0x3ebb75);_0x3cc8db(_0x3ebb75);})['catch'](function(_0x5f0c65){logger[_0x08f7('0x13')]('['+[_0x321092[_0x08f7('0x11')]()]+']',_0x5f0c65[_0x08f7('0x14')]);_0x2fe0b7(_0x5f0c65[_0x08f7('0x14')]);});}else{logger[_0x08f7('0x10')]('['+[_0x321092[_0x08f7('0x11')]()]+_0x08f7('0x20'));_0x3ebb75[_0x08f7('0x1d')]=_0x3ebb75[_0x08f7('0xf')];_0x3ebb75[_0x08f7('0x17')]=_0x3ebb75[_0x08f7('0x1f')];_0x3cc8db(_0x3ebb75);}});};}function createEndUser(_0x5b6c9b,_0x66e33b,_0x2a9eb6,_0x5c2b68,_0x1d3944){logger['info']('['+[_0x5b6c9b[_0x08f7('0x11')]()]+_0x08f7('0x21'),_0x2a9eb6);return new Promise(function(_0x194f28,_0x1c176f){var _0x3921ff={'method':'POST','uri':_0x5c2b68+_0x08f7('0x22')+_0x1d3944,'body':{'user_name':_0x2a9eb6['endUserNumber'],'roles':'user','first_name':_0x2a9eb6[_0x08f7('0x23')],'active':'true','date_format':_0x08f7('0x24'),'phone':_0x2a9eb6['endUserNumber']},'auth':_0x66e33b,'json':!![]};return rp(_0x3921ff)[_0x08f7('0x1a')](function(_0x69372d){logger['info']('['+[_0x5b6c9b['toUpperCase']()]+_0x08f7('0x25'),_0x69372d[_0x08f7('0xe')]);_0x2a9eb6[_0x08f7('0x26')]=_0x69372d[_0x08f7('0xe')]['sys_id'];_0x194f28(_0x2a9eb6);})[_0x08f7('0x12')](function(_0x3fba8c){logger['error']('['+[_0x5b6c9b[_0x08f7('0x11')]()]+']',_0x3fba8c[_0x08f7('0x14')]);_0x1c176f(_0x3fba8c[_0x08f7('0x14')]);});});}function getEndUser(_0x2ba147,_0x5ef41f,_0x4a881d,_0x379060,_0x4cfe61){return function(_0x27c05f){logger[_0x08f7('0x10')]('['+[_0x2ba147[_0x08f7('0x11')]()]+_0x08f7('0x27'),_0x27c05f);return new Promise(function(_0x50f2c2,_0x4ef984){var _0x45e46e={'method':_0x08f7('0xc'),'uri':_0x4a881d+_0x08f7('0x28')+_0x27c05f[_0x08f7('0x23')]+'&'+_0x379060+'&'+_0x4cfe61,'auth':_0x5ef41f,'json':!![]};return rp(_0x45e46e)['then'](function(_0xf06513){if(_0xf06513[_0x08f7('0xe')][_0x08f7('0x1b')]>0x0){_0x27c05f[_0x08f7('0x26')]=_0xf06513[_0x08f7('0xe')][0x0]['sys_id'];logger[_0x08f7('0x10')]('['+[_0x2ba147['toUpperCase']()]+_0x08f7('0x29'),_0x27c05f);_0x50f2c2(_0x27c05f);}else{return createEndUser(_0x2ba147,_0x5ef41f,_0x27c05f,_0x4a881d,_0x379060)[_0x08f7('0x1a')](function(_0x40dce5){logger[_0x08f7('0x10')]('['+[_0x2ba147['toUpperCase']()]+'],\x20createEndUser\x20crm',_0x40dce5);_0x50f2c2(_0x40dce5);});}})[_0x08f7('0x12')](function(_0x1b6005){logger['error']('['+[_0x2ba147[_0x08f7('0x11')]()]+']',_0x1b6005[_0x08f7('0x14')]);_0x4ef984(_0x1b6005[_0x08f7('0x14')]);});});};}function getCustomFields(_0xc202b4,_0x1c10ae){var _0xa48289={};if(_0xc202b4[_0x08f7('0x1b')]>0x0){_['forEach'](_0xc202b4,function(_0x565588){if(_[_0x08f7('0x2a')]([_0x08f7('0x2b'),'picklist'],_0x565588['type'])&&_0x565588[_0x08f7('0x2c')]&&!_0x565588[_0x08f7('0x2d')]){_0xa48289[_0x565588[_0x08f7('0x2c')]['toLowerCase']()]=_0x565588['content'][_0x08f7('0x2e')]();}else if(_[_0x08f7('0x2a')]([_0x08f7('0x2b'),_0x08f7('0x2f')],_0x565588[_0x08f7('0x30')])&&_0x565588[_0x08f7('0x31')]&&_0x565588[_0x08f7('0x2d')]){_0xa48289[_0x565588['idField'][_0x08f7('0x32')]()]=_0x565588['content'][_0x08f7('0x2e')]();}else if(_0x565588[_0x08f7('0x30')]==='variable'&&_0x565588[_0x08f7('0x33')]&&_0x565588[_0x08f7('0x31')]&&_0x565588[_0x08f7('0x2d')]){_0xa48289[_0x565588[_0x08f7('0x31')][_0x08f7('0x32')]()]=_0x1c10ae[_0x565588[_0x08f7('0x33')]][_0x08f7('0x2e')]();}else if(_0x565588[_0x08f7('0x30')]===_0x08f7('0x34')&&_0x565588['Variable']&&_0x565588[_0x08f7('0x35')]['name']&&_0x565588[_0x08f7('0x31')]&&_0x565588[_0x08f7('0x2d')]){_0xa48289[_0x565588['idField'][_0x08f7('0x32')]()]=_0x1c10ae[_0x565588['Variable'][_0x08f7('0x36')][_0x08f7('0x32')]()][_0x08f7('0x2e')]();}});}return _0xa48289;}function getTicket(_0x4b61bd,_0x2e38a8,_0x5d7f11,_0x330afb,_0x2b92d9,_0x1b62f8){return function(_0x310816){logger[_0x08f7('0x10')]('['+[_0x4b61bd[_0x08f7('0x11')]()]+_0x08f7('0x37'),_0x310816);return new Promise(function(_0x264fc0,_0x54a449){var _0x5bacce=_0x4b61bd['toLowerCase']()===_0x08f7('0x38')?_0x310816['userId']:_0x310816[_0x08f7('0x26')];var _0x532827={'method':_0x08f7('0x39'),'uri':_0x5d7f11+'incident'+'?'+_0x1b62f8,'body':Object[_0x08f7('0x3a')]({},{'active':_0x08f7('0x3b'),'caller_id':_0x5bacce,'assigned_to':_0x310816['userId'],'short_description':intUtil[_0x08f7('0x3c')](_0x330afb[_0x08f7('0x3d')],_0x2b92d9,'\x20'),'description':intUtil[_0x08f7('0x3c')](_0x330afb[_0x08f7('0x3e')],_0x2b92d9,'\x0a')},getCustomFields(_0x330afb['Fields'],_0x2b92d9)),'auth':_0x2e38a8,'json':!![]};return rp(_0x532827)[_0x08f7('0x1a')](function(_0x2ca08c){logger[_0x08f7('0x10')]('['+[_0x4b61bd['toUpperCase']()]+_0x08f7('0x3f'),_0x2ca08c['result']);_0x310816[_0x08f7('0x40')]=_0x2ca08c[_0x08f7('0xe')][_0x08f7('0x1e')];_0x310816['ticketNumber']=_0x2ca08c[_0x08f7('0xe')][_0x08f7('0x41')];logger[_0x08f7('0x10')]('['+[_0x4b61bd[_0x08f7('0x11')]()]+_0x08f7('0x42'),_0x310816);_0x264fc0(_0x310816);})[_0x08f7('0x12')](function(_0x233b89){logger['error']('['+[_0x4b61bd['toUpperCase']()]+']',_0x233b89[_0x08f7('0x14')]);_0x54a449(_0x233b89[_0x08f7('0x14')]);});});};}function createRemoteTag(_0x1acf05,_0x17c474,_0xc8f083,_0x4379fe){return new Promise(function(_0x783dd5,_0x170098){var _0x1d0683={'method':'POST','uri':_0xc8f083+'label'+'?'+_0x4379fe,'body':{'short_description':_0x1acf05,'global':!![],'active':!![],'name':_0x1acf05},'auth':_0x17c474,'json':!![]};return rp(_0x1d0683)[_0x08f7('0x1a')](function(_0x29898a){var _0x4cc76a=_0x29898a['result'][_0x08f7('0x1e')];_0x783dd5(_0x4cc76a);});});}function getRemoteTag(_0x2922a4,_0x590d1e,_0x14b35d,_0x5f3045,_0x8c8e24){return new Promise(function(_0x3f7a05,_0xee86c7){var _0x3b163a={'method':_0x08f7('0xc'),'uri':_0x14b35d+_0x08f7('0x43')+_0x08f7('0x44')+_0x2922a4+'&'+_0x5f3045,'auth':_0x590d1e,'json':!![]};return rp(_0x3b163a)['then'](function(_0x1b018b){if(_0x1b018b['result']['length']>0x0){var _0xd43b19=_0x1b018b[_0x08f7('0xe')][0x0][_0x08f7('0x1e')];_0x3f7a05(_0xd43b19);}else{return createRemoteTag(_0x2922a4,_0x590d1e,_0x14b35d,_0x5f3045)[_0x08f7('0x1a')](function(_0x5689e2){_0x3f7a05(_0x5689e2);});}});});}function assignTagToIncident(_0x38bf7e,_0x418919,_0x4b9c8e,_0x2e932a,_0x66b7da){return new Promise(function(_0x6abfba,_0x2ff66d){var _0x1fe4f8={'method':_0x08f7('0x39'),'uri':_0x4b9c8e+'label_entry'+'?'+_0x66b7da,'body':{'label':_0x38bf7e,'table':_0x08f7('0x45'),'id_type':'Incident','table_key':_0x2e932a[_0x08f7('0x40')],'title':_0x08f7('0x46')+_0x2e932a[_0x08f7('0x47')],'id_display':_0x2e932a[_0x08f7('0x47')]},'auth':_0x418919,'json':!![]};return rp(_0x1fe4f8)[_0x08f7('0x1a')](function(_0x48e86b){_0x6abfba();})[_0x08f7('0x12')](function(){_0x6abfba();});});}function manageTags(_0x4fe042,_0x1184d4,_0x63e854,_0x56f217,_0x4b83a7,_0x314d69,_0x10c4c2){return new Promise(function(_0x2813d8,_0x14f333){var _0x1726d5=[];_0x1184d4[_0x08f7('0x48')](function(_0x5a1ae7){_0x1726d5[_0x08f7('0x49')](getRemoteTag(_0x5a1ae7,_0x63e854,_0x56f217,_0x314d69,_0x10c4c2));});return Promise['all'](_0x1726d5)['then'](function(_0x8611e3){if(_0x8611e3[_0x08f7('0x1b')]){logger['info']('['+[_0x4fe042[_0x08f7('0x11')]()]+']\x20arrayPromises:\x20IDs\x20in\x20table\x20label',_0x8611e3);var _0x1f31c0=[];_0x8611e3[_0x08f7('0x48')](function(_0x96b517){_0x1f31c0['push'](assignTagToIncident(_0x96b517,_0x63e854,_0x56f217,_0x4b83a7,_0x314d69));});return Promise[_0x08f7('0x4a')](_0x1f31c0)[_0x08f7('0x1a')](function(){_0x2813d8();})['catch'](function(){_0x2813d8();});}else{_0x2813d8();}});});}function getTags(_0x442462,_0x1acc97,_0x29c16c,_0x401aa2,_0x6366a7,_0x1cdd60){return function(_0x4d7dfe){return new Promise(function(_0x17a09f,_0x450289){var _0x327f6d=[];var _0x3e454c=_0x401aa2[_0x08f7('0x4b')];if(_0x3e454c&&_0x3e454c[_0x08f7('0x1b')]>0x0){_0x327f6d=_[_0x08f7('0x4c')](_0x3e454c,_0x08f7('0x36'));}if(_0x327f6d[_0x08f7('0x1b')]>0x0){return manageTags(_0x442462,_0x327f6d,_0x1acc97,_0x29c16c,_0x4d7dfe,_0x6366a7,_0x1cdd60)[_0x08f7('0x1a')](function(){_0x17a09f(_0x4d7dfe);});}else{_0x17a09f(_0x4d7dfe);}});};}function emit(_0x128a60,_0x328590,_0x463816){var _0x2e8275=_0x08f7('0x4d')+'%26sysparm_record_row%3D1%26sysparm_record_rows%3D39'+_0x08f7('0x4e')+'%255EORDERBYDESCnumber';var _0x12d309={'uri':_0x128a60+_0x08f7('0x4f')+_0x463816+_0x2e8275};io['to'](util[_0x08f7('0x50')](_0x08f7('0x51'),_0x328590))[_0x08f7('0x52')](_0x08f7('0x53'),_0x12d309);}exports['cs']=function(_0x13c736,_0xfde01f,_0x4a00ff,_0x4bfdb3,_0x9f44ca,_0x4f6ec6,_0x2077d7,_0x40d6b1){var _0x4ef008={};var _0x49fd11={'user':_0x4f6ec6[_0x08f7('0x54')],'pass':_0x4f6ec6[_0x08f7('0x55')]};var _0x3e5b67=_0x08f7('0x56');var _0x5e358b=_0x08f7('0x57');_0x4f6ec6[_0x08f7('0x58')]=intUtil[_0x08f7('0x59')](_0x4f6ec6[_0x08f7('0x58')]);_0x4f6ec6[_0x08f7('0x5a')]=intUtil[_0x08f7('0x59')](_0x4f6ec6['serverUrl']);var _0x4b9c35=util[_0x08f7('0x50')](_0x08f7('0x5b'),_0x4f6ec6[_0x08f7('0x58')]);_0x4ef008[_0x08f7('0x17')]=!_[_0x08f7('0x5c')](_0x4bfdb3)?_0x4bfdb3[_0x08f7('0x5d')]:null;_0x4ef008[_0x08f7('0x1f')]=_0x4f6ec6[_0x08f7('0x5d')];_0x4ef008[_0x08f7('0x23')]=_0x40d6b1[_0x08f7('0x32')]()===_0x08f7('0x38')?_0xfde01f[_0x08f7('0x5e')]:_0xfde01f[_0x08f7('0x5f')];_0x4ef008[_0x08f7('0x60')]=_0x40d6b1==='queue'||_0x40d6b1==='unmanaged'?_0x08f7('0x61'):_0x08f7('0x38');var _0x5ce121=util['format'](_0x08f7('0x62'),_0x4f6ec6[_0x08f7('0x5a')],_0xfde01f[_0x08f7('0x63')],md5(_0xfde01f[_0x08f7('0x63')]));if(_0x9f44ca&&_0x9f44ca['monitor_format']){logger[_0x08f7('0x10')](_0x08f7('0x64'),_0x08f7('0x65'));_0xfde01f[_0x08f7('0x66')]=_0x5ce121;}else if(_0x2077d7&&_0x2077d7[_0x08f7('0x67')]&&_0x2077d7[_0x08f7('0x67')]!==_0x08f7('0x68')){logger[_0x08f7('0x10')](_0x08f7('0x69'),'Recording\x20is\x20enabled!');_0xfde01f[_0x08f7('0x66')]=_0x5ce121;}else{_0xfde01f[_0x08f7('0x66')]='';}return getAdminUser(_0x40d6b1,_0x49fd11,_0x4ef008,_0x4b9c35,_0x5e358b,_0x3e5b67)[_0x08f7('0x1a')](getUser(_0x40d6b1,_0x49fd11,_0x4b9c35,_0x5e358b,_0x3e5b67))[_0x08f7('0x1a')](getEndUser(_0x40d6b1,_0x49fd11,_0x4b9c35,_0x5e358b,_0x3e5b67))[_0x08f7('0x1a')](getTicket(_0x40d6b1,_0x49fd11,_0x4b9c35,_0x4a00ff,_0xfde01f,_0x5e358b))['then'](function(_0x538c90){logger[_0x08f7('0x10')](util[_0x08f7('0x50')](_0x08f7('0x6a'),_0x538c90[_0x08f7('0x40')]));logger[_0x08f7('0x10')](util[_0x08f7('0x50')]('call\x20direction:\x20%s',_0x40d6b1));if(_0x40d6b1!==_0x08f7('0x6b')){logger['info']('['+[_0x40d6b1[_0x08f7('0x11')]()]+']',_0x08f7('0x6c'));emit(_0x4f6ec6[_0x08f7('0x58')],_0x4bfdb3['name'],_0x538c90['ticketId']);}})[_0x08f7('0x12')](function(_0x437157){logger['error']('['+[_0x40d6b1['toUpperCase']()]+_0x08f7('0x6d'),util[_0x08f7('0x6e')](_0x437157,{'showHidden':!![],'depth':null}));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/sugarcrm.js b/server/services/ami/trigger/integration/sugarcrm.js new file mode 100644 index 0000000..16e252b --- /dev/null +++ b/server/services/ami/trigger/integration/sugarcrm.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xada6=['stripTrailingSlash','remoteUri','serverUrl','uri','%s/service/v4_1/rest.php','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','calleridname','The\x20Enduser\x20ID\x20is:','Inbound','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','users','contacts','charAt','%s/#bwc/index.php?module=Calls&action=EditView&record=%s','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','catch','error','recordingFormat','none','The\x20User\x20ID\x20is:','Outbound','%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s','[OUTBOUND]','lastevent','calleridnum','Fields','toUpperCase','lodash','request-promise','util','ioredis','./util','../../../../config/logger','sugarcrm','redis','defaults','localhost','socket.io-emitter','POST','emit','info','Creating\x20new\x20ticket...','Subjects','getString','Descriptions','date_start','toISOString','slice','duration_minutes','parent_id','parent_type','Contacts','name','direction','length','forEach','variableName','push','idField','set_entry','stringify','Calls','Basic\x20%s','apiKey','base64','get_server_info','JSON','isNil','get_entry_list','format','INSTR\x20(\x20users.user_name,\x20\x22%s\x22)\x20>\x200','user_name','then','find','entry_list','name_value_list','value','Agent\x20found!','resolve','user_id','Searching\x20enduser\x20with\x20phone','phone_home','Enduser\x20found!','Caller\x20-\x20%s','Enduser\x20created.','first_name','debug','[HTTP]','merge','map','type','string','nameField','customField','toLowerCase','content','custom_fields','toString','customVariable','Variable','login','username','password','xCALLY\x20Motion\x20integration','set_relationship','queue'];(function(_0x8615e8,_0x574b98){var _0x4c366f=function(_0x388633){while(--_0x388633){_0x8615e8['push'](_0x8615e8['shift']());}};_0x4c366f(++_0x574b98);}(_0xada6,0x93));var _0x6ada=function(_0x172709,_0x5e6abe){_0x172709=_0x172709-0x0;var _0x15cde4=_0xada6[_0x172709];return _0x15cde4;};'use strict';var _=require(_0x6ada('0x0'));var rp=require(_0x6ada('0x1'));var BPromise=require('bluebird');var md5=require('md5');var util=require(_0x6ada('0x2'));var Redis=require(_0x6ada('0x3'));var intUtil=require(_0x6ada('0x4'));var config=require('../../../../config/environment');var logger=require(_0x6ada('0x5'))(_0x6ada('0x6'));config[_0x6ada('0x7')]=_[_0x6ada('0x8')](config[_0x6ada('0x7')],{'host':_0x6ada('0x9'),'port':0x18eb});var io=require(_0x6ada('0xa'))(new Redis(config[_0x6ada('0x7')]));var def={'method':_0x6ada('0xb'),'json':!![]};function emit(_0x133898,_0x2e121a,_0x3988ca){io['to'](_0x133898)[_0x6ada('0xc')](_0x2e121a,_0x3988ca);}function getTicket(_0x500347,_0x3e2a78,_0x2f6050,_0x4e587f,_0x47b075,_0x18d5fc,_0x4ffe2d,_0x25b822){logger[_0x6ada('0xd')](_0x6ada('0xe'));var _0x3df48f=new Date();var _0x35a0ee=[{'name':'name','value':intUtil['getString'](_0x4e587f[_0x6ada('0xf')],_0x47b075,'\x20')},{'name':'assigned_user_id','value':_0x3e2a78['id']},{'name':'created_by','value':_0x3e2a78['id']},{'name':'description','value':intUtil[_0x6ada('0x10')](_0x4e587f[_0x6ada('0x11')],_0x47b075,'\x0a')},{'name':_0x6ada('0x12'),'value':_0x3df48f[_0x6ada('0x13')]()[_0x6ada('0x14')](0x0,0x13)['replace']('T','\x20')},{'name':'duration_hours','value':'0'},{'name':_0x6ada('0x15'),'value':'15'},{'name':_0x6ada('0x16'),'value':_0x2f6050['id']},{'name':_0x6ada('0x17'),'value':_0x6ada('0x18')},{'name':'parent_name','value':_0x2f6050[_0x6ada('0x19')]},{'name':_0x6ada('0x1a'),'value':_0x25b822}];if(_0x18d5fc[_0x6ada('0x1b')]){_[_0x6ada('0x1c')](_0x18d5fc,function(_0x45daca){if(_0x47b075[_0x45daca[_0x6ada('0x1d')]]){_0x35a0ee[_0x6ada('0x1e')]({'name':_0x45daca[_0x6ada('0x1f')],'value':_0x47b075[_0x45daca[_0x6ada('0x1d')]]});}});}return request({'form':{'method':_0x6ada('0x20'),'input_type':'JSON','response_type':'JSON','rest_data':JSON[_0x6ada('0x21')]({'session':_0x4ffe2d['id'],'module_name':_0x6ada('0x22'),'name_value_list':_0x35a0ee})}});}function getAuth(_0x189dd2){return util['format'](_0x6ada('0x23'),new Buffer(_0x189dd2[_0x6ada('0x24')]+':X')['toString'](_0x6ada('0x25')));}function getServerInfo(_0x4f551e){return request({'form':{'method':_0x6ada('0x26'),'input_type':_0x6ada('0x27'),'response_type':_0x6ada('0x27'),'rest_data':JSON[_0x6ada('0x21')]({'session':_0x4f551e['id']})}});}function getUser(_0x594f8d,_0x3b21fe,_0x3d074d){if(!_[_0x6ada('0x28')](_0x3b21fe)){logger[_0x6ada('0xd')]('Getting\x20agent\x20with\x20name',_0x3b21fe);return request({'form':{'method':_0x6ada('0x29'),'input_type':_0x6ada('0x27'),'response_type':'JSON','rest_data':JSON[_0x6ada('0x21')]({'session':_0x3d074d['id'],'module_name':'Employees','query':util[_0x6ada('0x2a')](_0x6ada('0x2b'),_0x3b21fe),'order_by':'','offset':'0','select_fields':['id',_0x6ada('0x19'),_0x6ada('0x2c')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})[_0x6ada('0x2d')](function(_0x1c357e){if(_0x1c357e['entry_list']['length']){var _0x1342ff=_[_0x6ada('0x2e')](_0x1c357e[_0x6ada('0x2f')],function(_0x53d3eb){return _0x53d3eb[_0x6ada('0x30')][_0x6ada('0x2c')][_0x6ada('0x31')]===_0x3b21fe;});if(_0x1342ff){logger[_0x6ada('0xd')](_0x6ada('0x32'));return BPromise[_0x6ada('0x33')]({'id':_0x1342ff['name_value_list']['id']['value'],'name':_0x1342ff[_0x6ada('0x30')][_0x6ada('0x19')]['value']});}}logger['info']('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return BPromise[_0x6ada('0x33')]({'id':_0x3d074d[_0x6ada('0x30')]['user_id']['value'],'name':_0x3d074d[_0x6ada('0x30')][_0x6ada('0x2c')][_0x6ada('0x31')]});});}else{logger[_0x6ada('0xd')]('Agent\x20not\x20available,\x20using\x20the\x20admin\x20account!');return BPromise[_0x6ada('0x33')]({'id':_0x3d074d[_0x6ada('0x30')][_0x6ada('0x34')][_0x6ada('0x31')],'name':_0x3d074d['name_value_list'][_0x6ada('0x2c')][_0x6ada('0x31')]});}}function getEndUser(_0x3e2ebf,_0x56e4d8,_0xa39c22,_0x3494f0){logger[_0x6ada('0xd')](_0x6ada('0x35'),_0xa39c22);return request({'form':{'method':_0x6ada('0x29'),'input_type':'JSON','response_type':_0x6ada('0x27'),'rest_data':JSON[_0x6ada('0x21')]({'session':_0x3494f0['id'],'module_name':_0x6ada('0x18'),'query':util[_0x6ada('0x2a')]('contacts.phone_home\x20=\x20\x22%s\x22',_0xa39c22),'order_by':'','offset':'0','select_fields':['id','name',_0x6ada('0x36')],'link_name_to_fields_array':[],'max_results':-0x1,'deleted':'0'})}})[_0x6ada('0x2d')](function(_0x543e4b){if(_0x543e4b[_0x6ada('0x2f')][_0x6ada('0x1b')]){var _0x2f7c49=_[_0x6ada('0x2e')](_0x543e4b[_0x6ada('0x2f')],function(_0x2ba141){return _0x2ba141[_0x6ada('0x30')][_0x6ada('0x36')]['value']===_0xa39c22;});if(_0x2f7c49){logger[_0x6ada('0xd')](_0x6ada('0x37'));return BPromise[_0x6ada('0x33')]({'id':_0x2f7c49[_0x6ada('0x30')]['id'][_0x6ada('0x31')],'name':_0x2f7c49[_0x6ada('0x30')][_0x6ada('0x19')][_0x6ada('0x31')],'phone':_0x2f7c49[_0x6ada('0x30')][_0x6ada('0x36')][_0x6ada('0x31')]});}}else{logger[_0x6ada('0xd')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'form':{'method':_0x6ada('0x20'),'input_type':'JSON','response_type':_0x6ada('0x27'),'rest_data':JSON[_0x6ada('0x21')]({'session':_0x3494f0['id'],'module_name':'Contacts','name_value_list':[{'name':'first_name','value':_0x56e4d8!==''?_0x56e4d8:util[_0x6ada('0x2a')](_0x6ada('0x38'),_0xa39c22)},{'name':_0x6ada('0x36'),'value':_0xa39c22}]})}})['then'](function(_0x54dd9c){logger[_0x6ada('0xd')](_0x6ada('0x39'));return BPromise[_0x6ada('0x33')]({'id':_0x54dd9c['id'],'name':_0x54dd9c[_0x6ada('0x2f')][_0x6ada('0x3a')]['value'],'phone':_0x54dd9c[_0x6ada('0x2f')][_0x6ada('0x36')]['value']});});}});}function request(_0x3f7df2){logger[_0x6ada('0x3b')](_0x6ada('0x3c'),JSON[_0x6ada('0x21')](_0x3f7df2));return rp(_[_0x6ada('0x3d')](def,_0x3f7df2));}function getTags(_0x2eb053,_0x5bcb5e){var _0x53af15=[];if(_0x2eb053&&_0x2eb053['length']>0x0){_0x53af15=_[_0x6ada('0x3e')](_0x2eb053,_0x5bcb5e);}return _0x53af15;}function getCustomFields(_0x5b6c31,_0x24dbc5){var _0x5ba626=[];var _0x33bcd6={'custom_fields':[]};if(_0x5b6c31[_0x6ada('0x1b')]>0x0){_[_0x6ada('0x1c')](_0x5b6c31,function(_0xc467c9){if(_0xc467c9[_0x6ada('0x3f')]===_0x6ada('0x40')&&_0xc467c9[_0x6ada('0x41')]&&!_0xc467c9[_0x6ada('0x42')]){_0x33bcd6[_0xc467c9[_0x6ada('0x41')][_0x6ada('0x43')]()]=_0xc467c9[_0x6ada('0x44')]['toString']();}else if(_0xc467c9[_0x6ada('0x3f')]===_0x6ada('0x40')&&_0xc467c9['idField']&&_0xc467c9[_0x6ada('0x42')]){_0x33bcd6[_0x6ada('0x45')][_0x6ada('0x1e')]({'id':_0xc467c9[_0x6ada('0x1f')],'value':_0xc467c9[_0x6ada('0x44')][_0x6ada('0x46')]()});}else if(_0xc467c9[_0x6ada('0x3f')]==='variable'&&_0xc467c9['variableName']&&_0xc467c9['idField']&&_0xc467c9['customField']){_0x24dbc5[_0xc467c9[_0x6ada('0x1d')]]&&_0x33bcd6[_0x6ada('0x45')][_0x6ada('0x1e')]({'id':_0xc467c9[_0x6ada('0x1f')],'value':_0x24dbc5[_0xc467c9[_0x6ada('0x1d')]][_0x6ada('0x46')]()});}else if(_0xc467c9['type']===_0x6ada('0x47')&&_0xc467c9['Variable']&&_0xc467c9[_0x6ada('0x48')]['name']&&_0xc467c9[_0x6ada('0x1f')]&&_0xc467c9[_0x6ada('0x42')]){_0x24dbc5[_0xc467c9['Variable'][_0x6ada('0x19')]['toLowerCase']()]&&_0x33bcd6[_0x6ada('0x45')]['push']({'id':_0xc467c9['idField'],'value':_0x24dbc5[_0xc467c9[_0x6ada('0x48')][_0x6ada('0x19')][_0x6ada('0x43')]()][_0x6ada('0x46')]()});}});}return _0x33bcd6;}function getConnection(_0x391f6d){return request({'method':_0x6ada('0xb'),'form':{'method':_0x6ada('0x49'),'input_type':'JSON','response_type':'JSON','rest_data':JSON[_0x6ada('0x21')]({'user_auth':{'user_name':_0x391f6d[_0x6ada('0x4a')],'password':_0x391f6d[_0x6ada('0x4b')],'encryption':'PLAIN'},'application':_0x6ada('0x4c')})}})[_0x6ada('0x2d')](function(_0x325180){var _0x5c9c07=_0x325180;if(_0x5c9c07['id']){def['sessionID']=_0x5c9c07['id'];return BPromise[_0x6ada('0x33')](_0x5c9c07);}else{throw new Error(util[_0x6ada('0x2a')]('Account\x20%d\x20is\x20not\x20valid',_0x391f6d['id']));}});}function setRelationship(_0x46ae89,_0x5d33f5,_0x32e5ac,_0x1b673b){return request({'form':{'method':_0x6ada('0x4d'),'input_type':_0x6ada('0x27'),'response_type':'JSON','rest_data':JSON[_0x6ada('0x21')]({'session':_0x46ae89['id'],'module_name':_0x6ada('0x22'),'module_id':_0x32e5ac['id'],'link_field_name':_0x1b673b,'related_ids':[_0x5d33f5['id']],'name_value_list':[],'delete':0x0})}});}exports[_0x6ada('0x4e')]=function(_0x2548f1,_0x93d8b8,_0x2cb415,_0x361ee7,_0x23aaa4,_0x4bc0c0){var _0x1b74e6,_0x3321ef,_0x18f3f5,_0x9fc1c5;_0x4bc0c0['remoteUri']=intUtil[_0x6ada('0x4f')](_0x4bc0c0[_0x6ada('0x50')]);_0x4bc0c0['serverUrl']=intUtil[_0x6ada('0x4f')](_0x4bc0c0[_0x6ada('0x51')]);def[_0x6ada('0x52')]=util['format'](_0x6ada('0x53'),_0x4bc0c0[_0x6ada('0x50')]);if(_0x23aaa4&&_0x23aaa4['monitor_format']){logger[_0x6ada('0xd')](_0x6ada('0x54'),_0x6ada('0x55'));_0x93d8b8[_0x6ada('0x56')]=util[_0x6ada('0x2a')](_0x6ada('0x57'),_0x4bc0c0[_0x6ada('0x51')],_0x93d8b8[_0x6ada('0x58')],md5(_0x93d8b8[_0x6ada('0x58')]));}else{_0x93d8b8[_0x6ada('0x56')]='';}return getConnection(_0x4bc0c0)[_0x6ada('0x2d')](function(_0x50ae8f){_0x9fc1c5=_0x50ae8f;return getUser(_0x4bc0c0,_0x361ee7[_0x6ada('0x19')],_0x9fc1c5);})['then'](function(_0x35def1){_0x1b74e6=_0x35def1;logger[_0x6ada('0xd')]('The\x20User\x20ID\x20is:',_0x1b74e6['id']);return getEndUser(_0x4bc0c0,_0x93d8b8[_0x6ada('0x59')],_0x93d8b8['calleridnum'],_0x9fc1c5);})[_0x6ada('0x2d')](function(_0x47ec8e){_0x3321ef=_0x47ec8e;logger[_0x6ada('0xd')](_0x6ada('0x5a'),_0x3321ef['id']);return getTicket(_0x4bc0c0,_0x1b74e6,_0x3321ef,_0x2cb415,_0x93d8b8,_0x2cb415['Fields'],_0x9fc1c5,_0x6ada('0x5b'));})[_0x6ada('0x2d')](function(_0x9b3611){_0x18f3f5=_0x9b3611;logger['info'](_0x6ada('0x5c'));logger['info'](_0x6ada('0x5d'),_0x18f3f5['id']);return setRelationship(_0x9fc1c5,_0x1b74e6,_0x18f3f5,_0x6ada('0x5e'));})[_0x6ada('0x2d')](function(){return setRelationship(_0x9fc1c5,_0x3321ef,_0x18f3f5,_0x6ada('0x5f'));})[_0x6ada('0x2d')](function(){return getServerInfo(_0x9fc1c5);})['then'](function(_0x33dac4){var _0x58bdd0=parseInt(_0x33dac4['version'][_0x6ada('0x60')](0x0));var _0x1e93ad=util['format']('%s/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCalls%26action%3DEditView%26record%3D%s',_0x4bc0c0['remoteUri'],_0x18f3f5['id']);if(_0x58bdd0>0x6){_0x1e93ad=util[_0x6ada('0x2a')](_0x6ada('0x61'),_0x4bc0c0[_0x6ada('0x50')],_0x18f3f5['id']);}logger['info'](_0x6ada('0x54'),_0x6ada('0x62'));emit(util[_0x6ada('0x2a')](_0x6ada('0x63'),_0x361ee7['name']),_0x6ada('0x64'),{'uri':_0x1e93ad});})[_0x6ada('0x65')](function(_0x4b0297){logger[_0x6ada('0x66')]('[QUEUE]',JSON[_0x6ada('0x21')](_0x4b0297));});};exports['outbound']=function(_0x357334,_0x1ba060,_0x3960ad,_0x2f8198,_0x248fdc,_0x5e187f,_0x1fe058){var _0x9f5d62,_0x403d53,_0x3a1094,_0x34dd99;_0x5e187f['remoteUri']=intUtil[_0x6ada('0x4f')](_0x5e187f[_0x6ada('0x50')]);_0x5e187f['serverUrl']=intUtil[_0x6ada('0x4f')](_0x5e187f[_0x6ada('0x51')]);def[_0x6ada('0x52')]=util[_0x6ada('0x2a')]('%s/service/v4_1/rest.php',_0x5e187f[_0x6ada('0x50')]);if(_0x1fe058&&_0x1fe058[_0x6ada('0x67')]&&_0x1fe058[_0x6ada('0x67')]!==_0x6ada('0x68')){logger[_0x6ada('0xd')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x1ba060[_0x6ada('0x56')]=util['format']('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x5e187f[_0x6ada('0x51')],_0x1ba060[_0x6ada('0x58')],md5(_0x1ba060['uniqueid']));}return getConnection(_0x5e187f)[_0x6ada('0x2d')](function(_0x1b398e){_0x34dd99=_0x1b398e;return getUser(_0x5e187f,_0x2f8198[_0x6ada('0x19')],_0x34dd99);})[_0x6ada('0x2d')](function(_0x379ec8){_0x9f5d62=_0x379ec8;logger[_0x6ada('0xd')](_0x6ada('0x69'),_0x9f5d62['id']);return getEndUser(_0x5e187f,_0x1ba060['destcalleridname'],_0x1ba060['destcalleridnum'],_0x34dd99);})[_0x6ada('0x2d')](function(_0x21f5d7){_0x403d53=_0x21f5d7;logger['info'](_0x6ada('0x5a'),_0x403d53['id']);return getTicket(_0x5e187f,_0x9f5d62,_0x403d53,_0x3960ad,_0x1ba060,_0x3960ad['Fields'],_0x34dd99,_0x6ada('0x6a'));})[_0x6ada('0x2d')](function(_0x2d614c){_0x3a1094=_0x2d614c;logger[_0x6ada('0xd')](_0x6ada('0x5c'));logger[_0x6ada('0xd')]('The\x20Ticket\x20ID\x20is:',_0x3a1094['id']);return setRelationship(_0x34dd99,_0x9f5d62,_0x3a1094,_0x6ada('0x5e'));})['then'](function(){return setRelationship(_0x34dd99,_0x403d53,_0x3a1094,_0x6ada('0x5f'));})[_0x6ada('0x2d')](function(){return getServerInfo(_0x34dd99);})[_0x6ada('0x2d')](function(_0x4e5d84){var _0x5a4e81=parseInt(_0x4e5d84['version'][_0x6ada('0x60')](0x0));var _0x41c542=util['format'](_0x6ada('0x6b'),_0x5e187f[_0x6ada('0x50')],_0x3a1094['id']);if(_0x5a4e81>0x6){_0x41c542=util[_0x6ada('0x2a')](_0x6ada('0x61'),_0x5e187f[_0x6ada('0x50')],_0x3a1094['id']);}logger[_0x6ada('0xd')](_0x6ada('0x6c'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x6ada('0x2a')](_0x6ada('0x63'),_0x2f8198[_0x6ada('0x19')]),'trigger:browser:url',{'uri':_0x41c542});})['catch'](function(_0x5a32ac){logger[_0x6ada('0x66')](_0x6ada('0x6c'),JSON[_0x6ada('0x21')](_0x5a32ac));});};exports['unmanaged']=function(_0x39b128,_0x5ecca8,_0x45728c,_0x2eab01,_0x38768e,_0xab1863){var _0x52da4d,_0x9c9d10,_0xf2e334,_0x4e6269;_0xab1863[_0x6ada('0x50')]=intUtil[_0x6ada('0x4f')](_0xab1863['remoteUri']);_0xab1863[_0x6ada('0x51')]=intUtil[_0x6ada('0x4f')](_0xab1863['serverUrl']);def['uri']=util['format']('%s/service/v4_1/rest.php',_0xab1863[_0x6ada('0x50')]);if(_0x38768e&&_0x38768e['monitor_format']){logger[_0x6ada('0xd')]('['+_0x5ecca8[_0x6ada('0x6d')]['toUpperCase']()+']',_0x6ada('0x55'));_0x5ecca8[_0x6ada('0x56')]=util[_0x6ada('0x2a')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0xab1863[_0x6ada('0x51')],_0x5ecca8[_0x6ada('0x58')],md5(_0x5ecca8[_0x6ada('0x58')]));}else{_0x5ecca8[_0x6ada('0x56')]='';}return getConnection(_0xab1863)[_0x6ada('0x2d')](function(_0x161f29){_0x4e6269=_0x161f29;if(!_['isNil'](_0x2eab01)){return getUser(_0xab1863,_0x2eab01[_0x6ada('0x19')],_0x4e6269);}else{return getUser(_0xab1863,null,_0x4e6269);}})[_0x6ada('0x2d')](function(_0x2b38fa){_0x52da4d=_0x2b38fa;logger['info'](_0x6ada('0x69'),_0x52da4d['id']);return getEndUser(_0xab1863,_0x5ecca8['calleridname'],_0x5ecca8[_0x6ada('0x6e')],_0x4e6269);})['then'](function(_0x2a72c3){_0x9c9d10=_0x2a72c3;logger['info'](_0x6ada('0x5a'),_0x9c9d10['id']);return getTicket(_0xab1863,_0x52da4d,_0x9c9d10,_0x45728c,_0x5ecca8,_0x45728c[_0x6ada('0x6f')],_0x4e6269,_0x6ada('0x5b'));})[_0x6ada('0x2d')](function(_0x8a9697){_0xf2e334=_0x8a9697;logger[_0x6ada('0xd')](_0x6ada('0x5c'));logger[_0x6ada('0xd')](_0x6ada('0x5d'),_0xf2e334['id']);return setRelationship(_0x4e6269,_0x52da4d,_0xf2e334,_0x6ada('0x5e'));})['then'](function(){return setRelationship(_0x4e6269,_0x9c9d10,_0xf2e334,_0x6ada('0x5f'));})[_0x6ada('0x2d')](function(){return getServerInfo(_0x4e6269);})[_0x6ada('0x65')](function(_0xdeaca7){logger[_0x6ada('0x66')]('['+_0x5ecca8[_0x6ada('0x6d')][_0x6ada('0x70')]()+']',JSON[_0x6ada('0x21')](_0xdeaca7));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/util.js b/server/services/ami/trigger/integration/util.js new file mode 100644 index 0000000..b6231c7 --- /dev/null +++ b/server/services/ami/trigger/integration/util.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd8fe=['lodash','util','getString','length','string','push','type','variable','variableName','toString','customVariable','Variable','name','toLowerCase','keyValue','keyType','key','format','%s:\x20%s','keyContent','join','stripTrailingSlash','slice','substring','lastIndexOf','validateEmail','test'];(function(_0x34217f,_0x4954d9){var _0x533721=function(_0x5ea689){while(--_0x5ea689){_0x34217f['push'](_0x34217f['shift']());}};_0x533721(++_0x4954d9);}(_0xd8fe,0xa2));var _0xed8f=function(_0x65c50e,_0x1aa926){_0x65c50e=_0x65c50e-0x0;var _0x4573e7=_0xd8fe[_0x65c50e];return _0x4573e7;};'use strict';var _=require(_0xed8f('0x0'));var util=require(_0xed8f('0x1'));exports[_0xed8f('0x2')]=function(_0x8b694c,_0x4f8f91,_0x88348f){var _0x5a5cc1=[];if(_0x8b694c[_0xed8f('0x3')]>0x0){var _0x238aaa=_['sortBy'](_0x8b694c,['id']);for(var _0x26a50e=0x0;_0x26a50e<_0x238aaa[_0xed8f('0x3')];_0x26a50e++){var _0x20c641=_0x238aaa[_0x26a50e];if(_0x20c641['type']===_0xed8f('0x4')){_0x5a5cc1[_0xed8f('0x5')](_0x20c641['content']);}else if(_0x20c641[_0xed8f('0x6')]===_0xed8f('0x7')&&_0x20c641[_0xed8f('0x8')]){_0x4f8f91[_0x20c641['variableName']]&&_0x5a5cc1[_0xed8f('0x5')](_0x4f8f91[_0x20c641[_0xed8f('0x8')]][_0xed8f('0x9')]());}else if(_0x20c641['type']===_0xed8f('0xa')&&_0x20c641[_0xed8f('0xb')]&&_0x20c641[_0xed8f('0xb')][_0xed8f('0xc')]){_0x4f8f91[_0x20c641[_0xed8f('0xb')][_0xed8f('0xc')]['toLowerCase']()]&&_0x5a5cc1[_0xed8f('0x5')](_0x4f8f91[_0x20c641[_0xed8f('0xb')]['name'][_0xed8f('0xd')]()][_0xed8f('0x9')]());}else if(_0x20c641[_0xed8f('0x6')]===_0xed8f('0xe')){if(_0x20c641[_0xed8f('0xf')]===_0xed8f('0x4')&&_0x20c641[_0xed8f('0x10')]){_0x5a5cc1[_0xed8f('0x5')](util[_0xed8f('0x11')](_0xed8f('0x12'),_0x20c641[_0xed8f('0x10')],_0x20c641[_0xed8f('0x13')]));}else if(_0x20c641[_0xed8f('0xf')]===_0xed8f('0x7')&&_0x20c641[_0xed8f('0x8')]&&_0x20c641['key']){_0x4f8f91[_0x20c641[_0xed8f('0x8')]]&&_0x5a5cc1[_0xed8f('0x5')](util[_0xed8f('0x11')]('%s:\x20%s',_0x20c641[_0xed8f('0x10')],_0x4f8f91[_0x20c641[_0xed8f('0x8')]]));}else if(_0x20c641[_0xed8f('0xf')]===_0xed8f('0xa')&&_0x20c641[_0xed8f('0xb')]&&_0x20c641[_0xed8f('0xb')]['name']&&_0x20c641['key']){_0x4f8f91[_0x20c641[_0xed8f('0xb')][_0xed8f('0xc')][_0xed8f('0xd')]()]&&_0x5a5cc1[_0xed8f('0x5')](util['format'](_0xed8f('0x12'),_0x20c641[_0xed8f('0x10')],_0x4f8f91[_0x20c641[_0xed8f('0xb')]['name'][_0xed8f('0xd')]()]));}}}}return _0x5a5cc1[_0xed8f('0x14')](_0x88348f);};exports[_0xed8f('0x15')]=function(_0x3bdfa1){var _0x4c221e=_0x3bdfa1[_0xed8f('0x16')](-0x1);if(_0x4c221e==='/'){_0x3bdfa1=_0x3bdfa1[_0xed8f('0x17')](0x0,_0x3bdfa1[_0xed8f('0x18')](_0x4c221e));}return _0x3bdfa1;};exports[_0xed8f('0x19')]=function(_0x3b025a){if(!_['isNil'](_0x3b025a)&&_0x3b025a!==''){var _0x46ea6f=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return _0x46ea6f[_0xed8f('0x1a')](String(_0x3b025a)[_0xed8f('0xd')]());}else{return![];}}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/vtiger.js b/server/services/ami/trigger/integration/vtiger.js new file mode 100644 index 0000000..044a0fc --- /dev/null +++ b/server/services/ami/trigger/integration/vtiger.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe706=['result','Agent\x20found!','email1','first_name','last_name','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','userId','admin','getUser','username','Searching\x20end\x20user\x20with\x20phone','remoteUri','SELECT\x20id,\x20firstname,\x20lastname,\x20email,\x20phone,\x20mobile,\x20homephone,\x20otherphone,\x20assistantphone\x20FROM\x20Contacts\x20WHERE\x20phone\x20=\x20\x27%s\x27\x20OR\x20mobile\x20=\x27%s\x27\x20OR\x20homephone\x20=\x27%s\x27\x20OR\x20otherphone\x20=\x27%s\x27\x20OR\x20assistantphone\x20=\x27%s\x27;','Enduser\x20found!','firstname','lastname','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Contacts','phone','catch','accessKey','getchallenge','token','Account\x20%d\x20is\x20not\x20valid','getConnection','queue','stripTrailingSlash','[QUEUE]','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','serverUrl','uniqueid','email','The\x20User\x20ID\x20is:','calleridname','calleridnum','The\x20Enduser\x20ID\x20is:','Fields','Ticket\x20created!','%s/index.php?module=HelpDesk&view=Detail&record=%s&app=SUPPORT','split','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','outbound','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','destcalleridname','destcalleridnum','The\x20Ticket\x20ID\x20is:','user:%s','unmanaged','lastevent','toUpperCase','lodash','request-promise','bluebird','util','ioredis','./util','../../../../config/environment','../../../../config/logger','vTiger','redis','defaults','localhost','socket.io-emitter','emit','length','forEach','includes','string','idField','content','toString','type','variable','variableName','Variable','name','toLowerCase','info','Creating\x20new\x20ticket...','merge','Normal','Open','Subjects','getString','Descriptions','POST','format','%s/webservice.php','create','stringify','then','success','resolve','Ticket\x20could\x20not\x20be\x20created\x20due\x20to:\x20%s','statusCode','error','[vTiger],\x20%s,\x20%s,\x20%s','validateEmail','Getting\x20agent\x20with\x20email','GET','query','sessionName','SELECT\x20first_name,\x20last_name,\x20email1\x20FROM\x20Users\x20WHERE\x20email1=\x27%s\x27;'];(function(_0x1381df,_0xa4f9e9){var _0x3dd915=function(_0x104735){while(--_0x104735){_0x1381df['push'](_0x1381df['shift']());}};_0x3dd915(++_0xa4f9e9);}(_0xe706,0xa3));var _0x6e70=function(_0x59c6dc,_0x2f43d2){_0x59c6dc=_0x59c6dc-0x0;var _0x3ae1b6=_0xe706[_0x59c6dc];return _0x3ae1b6;};'use strict';var _=require(_0x6e70('0x0'));var rp=require(_0x6e70('0x1'));var BPromise=require(_0x6e70('0x2'));var md5=require('md5');var util=require(_0x6e70('0x3'));var Redis=require(_0x6e70('0x4'));var intUtil=require(_0x6e70('0x5'));var config=require(_0x6e70('0x6'));var logger=require(_0x6e70('0x7'))(_0x6e70('0x8'));config[_0x6e70('0x9')]=_[_0x6e70('0xa')](config[_0x6e70('0x9')],{'host':_0x6e70('0xb'),'port':0x18eb});var io=require(_0x6e70('0xc'))(new Redis(config[_0x6e70('0x9')]));function emit(_0x45a2d4,_0x188ed3,_0x3c4843){io['to'](_0x45a2d4)[_0x6e70('0xd')](_0x188ed3,_0x3c4843);}function getCustomFields(_0x954545,_0x25e61c){var _0x100eb7={};if(_0x954545[_0x6e70('0xe')]>0x0){_[_0x6e70('0xf')](_0x954545,function(_0x3f474a){if(_[_0x6e70('0x10')]([_0x6e70('0x11'),'picklist'],_0x3f474a['type'])&&_0x3f474a[_0x6e70('0x12')]){_0x100eb7[_0x3f474a[_0x6e70('0x12')]]=_0x3f474a[_0x6e70('0x13')][_0x6e70('0x14')]();}else if(_0x3f474a[_0x6e70('0x15')]===_0x6e70('0x16')&&_0x3f474a[_0x6e70('0x17')]&&_0x3f474a[_0x6e70('0x12')]&&_0x25e61c[_0x3f474a['variableName']]){_0x100eb7[_0x3f474a['idField']]=_0x25e61c[_0x3f474a['variableName']][_0x6e70('0x14')]();}else if(_0x3f474a['type']==='customVariable'&&_0x3f474a[_0x6e70('0x18')]&&_0x3f474a[_0x6e70('0x18')]['name']&&_0x3f474a[_0x6e70('0x12')]&&_0x25e61c[_0x3f474a['Variable'][_0x6e70('0x19')][_0x6e70('0x1a')]()]){_0x100eb7[_0x3f474a['idField']]=_0x25e61c[_0x3f474a['Variable'][_0x6e70('0x19')]['toLowerCase']()][_0x6e70('0x14')]();}});}return _0x100eb7;}function createTicket(_0x173afe,_0x53acdc,_0x497d61,_0xc238ba,_0x208e21,_0x2368eb,_0x3a9978){logger[_0x6e70('0x1b')](_0x6e70('0x1c'));var _0x1b2453=_[_0x6e70('0x1d')]({'parent_id':'','assigned_user_id':_0x53acdc['id'],'ticketpriorities':_0x6e70('0x1e'),'ticketstatus':_0x6e70('0x1f'),'ticket_title':intUtil['getString'](_0xc238ba[_0x6e70('0x20')],_0x208e21,'\x20'),'description':intUtil[_0x6e70('0x21')](_0xc238ba[_0x6e70('0x22')],_0x208e21,'\x0a'),'contact_id':_0x497d61['id']},getCustomFields(_0x2368eb,_0x208e21));var _0x502b2d={'method':_0x6e70('0x23'),'uri':util[_0x6e70('0x24')](_0x6e70('0x25'),_0x173afe['remoteUri']),'form':{'operation':_0x6e70('0x26'),'username':_0x173afe['username'],'sessionName':_0x3a9978['sessionName'],'elementType':'HelpDesk','element':JSON[_0x6e70('0x27')](_0x1b2453)},'json':!![]};return request(_0x502b2d)[_0x6e70('0x28')](function(_0x51d292){if(_0x51d292[_0x6e70('0x29')]){return BPromise[_0x6e70('0x2a')]({'id':_0x51d292['result']['id']});}else{throw new Error(util[_0x6e70('0x24')](_0x6e70('0x2b'),JSON[_0x6e70('0x27')](_0x51d292['error'])));}})['catch'](function(_0x2c4d37){var _0x3af17f=_0x2c4d37[_0x6e70('0x2c')]||0x1f4;logger[_0x6e70('0x2d')](_0x6e70('0x2e'),'createTicket',_0x3af17f,JSON[_0x6e70('0x27')](_0x2c4d37));});}function getUser(_0x406f29,_0xecf336,_0x2864a0){if(intUtil[_0x6e70('0x2f')](_0xecf336)){logger[_0x6e70('0x1b')](_0x6e70('0x30'),_0xecf336);return request({'method':_0x6e70('0x31'),'uri':util[_0x6e70('0x24')](_0x6e70('0x25'),_0x406f29['remoteUri']),'qs':{'operation':_0x6e70('0x32'),'username':_0x406f29['username'],'sessionName':_0x2864a0[_0x6e70('0x33')],'query':util['format'](_0x6e70('0x34'),_0xecf336)},'json':!![]})[_0x6e70('0x28')](function(_0x30fa0b){if(_0x30fa0b['success']&&_0x30fa0b[_0x6e70('0x35')][_0x6e70('0xe')]){logger['info'](_0x6e70('0x36'));return BPromise[_0x6e70('0x2a')]({'id':_0x30fa0b['result'][0x0]['id'],'email':_0x30fa0b[_0x6e70('0x35')][0x0][_0x6e70('0x37')],'name':_0x30fa0b[_0x6e70('0x35')][0x0][_0x6e70('0x38')]+'\x20'+_0x30fa0b[_0x6e70('0x35')][_0x6e70('0x39')]});}else{logger[_0x6e70('0x1b')](_0x6e70('0x3a'));return BPromise[_0x6e70('0x2a')]({'id':_0x2864a0[_0x6e70('0x3b')],'email':_0x406f29['username'],'name':_0x6e70('0x3c')});}})['catch'](function(_0x23cd1a){var _0x3222a2=_0x23cd1a[_0x6e70('0x2c')]||0x1f4;logger[_0x6e70('0x2d')](_0x6e70('0x2e'),_0x6e70('0x3d'),_0x3222a2,JSON[_0x6e70('0x27')](_0x23cd1a));});}else{logger[_0x6e70('0x1b')](_0x6e70('0x3a'));return BPromise[_0x6e70('0x2a')]({'id':_0x2864a0[_0x6e70('0x3b')],'email':_0x406f29[_0x6e70('0x3e')],'name':_0x6e70('0x3c')})['catch'](function(_0x5446a2){var _0x5424eb=_0x5446a2[_0x6e70('0x2c')]||0x1f4;logger[_0x6e70('0x2d')](_0x6e70('0x2e'),_0x6e70('0x3d'),_0x5424eb,JSON[_0x6e70('0x27')](_0x5446a2));});}}function getEndUser(_0x3bdd87,_0x572a71,_0x3b508c,_0x9e7ad2){logger[_0x6e70('0x1b')](_0x6e70('0x3f'),_0x3b508c);return request({'method':_0x6e70('0x31'),'uri':util[_0x6e70('0x24')](_0x6e70('0x25'),_0x3bdd87[_0x6e70('0x40')]),'qs':{'operation':'query','username':_0x3bdd87[_0x6e70('0x3e')],'sessionName':_0x9e7ad2[_0x6e70('0x33')],'query':util[_0x6e70('0x24')](_0x6e70('0x41'),_0x3b508c,_0x3b508c,_0x3b508c,_0x3b508c,_0x3b508c)},'json':!![]})[_0x6e70('0x28')](function(_0x1de947){if(_0x1de947[_0x6e70('0x29')]&&_0x1de947['result']['length']){logger['info'](_0x6e70('0x42'));return BPromise[_0x6e70('0x2a')]({'id':_0x1de947[_0x6e70('0x35')][0x0]['id'],'name':_0x1de947[_0x6e70('0x35')][0x0][_0x6e70('0x43')]+'\x20'+_0x1de947['result'][0x0][_0x6e70('0x44')],'phone':_0x3b508c});}else{logger[_0x6e70('0x1b')](_0x6e70('0x45'));return request({'method':'POST','uri':util['format']('%s/webservice.php',_0x3bdd87[_0x6e70('0x40')]),'form':{'operation':'create','sessionName':_0x9e7ad2[_0x6e70('0x33')],'elementType':_0x6e70('0x46'),'element':JSON[_0x6e70('0x27')]({'lastname':_0x572a71,'phone':_0x3b508c,'assigned_user_id':'\x20'})},'json':!![]})[_0x6e70('0x28')](function(_0x59c87d){logger[_0x6e70('0x1b')]('Enduser\x20created.');return BPromise[_0x6e70('0x2a')]({'id':_0x59c87d[_0x6e70('0x35')]['id'],'name':_0x59c87d[_0x6e70('0x35')][_0x6e70('0x44')],'phone':_0x59c87d['result'][_0x6e70('0x47')]});})[_0x6e70('0x48')](function(_0x3d39c3){var _0xac87d6=_0x3d39c3[_0x6e70('0x2c')]||0x1f4;logger[_0x6e70('0x2d')](_0x6e70('0x2e'),'getEndUser',_0xac87d6,JSON[_0x6e70('0x27')](_0x3d39c3));});}});}function getConnection(_0x3884a4){var _0x10de2a=_0x3884a4[_0x6e70('0x3e')];var _0x3f86cf=_0x3884a4[_0x6e70('0x49')];return request({'method':_0x6e70('0x31'),'uri':util['format'](_0x6e70('0x25'),_0x3884a4['remoteUri']),'qs':{'operation':_0x6e70('0x4a'),'username':_0x10de2a},'json':!![]})[_0x6e70('0x28')](function(_0x4b351e){if(_0x4b351e['success']){return request({'method':_0x6e70('0x23'),'uri':util[_0x6e70('0x24')](_0x6e70('0x25'),_0x3884a4['remoteUri']),'form':{'operation':'login','username':_0x10de2a,'accessKey':md5(_0x4b351e[_0x6e70('0x35')][_0x6e70('0x4b')]+_0x3f86cf)},'json':!![]});}})[_0x6e70('0x28')](function(_0x79653){if(_0x79653[_0x6e70('0x29')]){return BPromise[_0x6e70('0x2a')](_0x79653['result']);}else{throw new Error(util[_0x6e70('0x24')](_0x6e70('0x4c'),_0x3884a4['id']));}})[_0x6e70('0x48')](function(_0x6ed023){var _0x2c3a7d=_0x6ed023['statusCode']||0x1f4;logger['error'](_0x6e70('0x2e'),_0x6e70('0x4d'),_0x2c3a7d,JSON[_0x6e70('0x27')](_0x6ed023));});}function request(_0x15f994){logger[_0x6e70('0x1b')]('[HTTP]',JSON[_0x6e70('0x27')](_0x15f994));return rp(_0x15f994);}exports[_0x6e70('0x4e')]=function(_0x1fa320,_0x23ebfb,_0x3aba34,_0x4a111a,_0x1142cd,_0x1dd242){var _0x2c20d3,_0x3fb0d3,_0x8ef4f7,_0x3fd03d;_0x1dd242['remoteUri']=intUtil[_0x6e70('0x4f')](_0x1dd242[_0x6e70('0x40')]);if(_0x1142cd&&_0x1142cd['monitor_format']){logger[_0x6e70('0x1b')](_0x6e70('0x50'),'Recording\x20is\x20enabled!');_0x23ebfb[_0x6e70('0x51')]=util[_0x6e70('0x24')](_0x6e70('0x52'),_0x1dd242[_0x6e70('0x53')],_0x23ebfb[_0x6e70('0x54')],md5(_0x23ebfb['uniqueid']));}else{_0x23ebfb[_0x6e70('0x51')]='';}return getConnection(_0x1dd242)[_0x6e70('0x28')](function(_0x10d655){_0x3fd03d=_0x10d655;return getUser(_0x1dd242,_0x4a111a[_0x6e70('0x55')],_0x3fd03d);})[_0x6e70('0x28')](function(_0x1fe13a){_0x2c20d3=_0x1fe13a;logger[_0x6e70('0x1b')](_0x6e70('0x56'),_0x2c20d3['id']);return getEndUser(_0x1dd242,_0x23ebfb[_0x6e70('0x57')],_0x23ebfb[_0x6e70('0x58')],_0x3fd03d);})[_0x6e70('0x28')](function(_0x1b12a1){_0x3fb0d3=_0x1b12a1;logger[_0x6e70('0x1b')](_0x6e70('0x59'),_0x3fb0d3['id']);return createTicket(_0x1dd242,_0x2c20d3,_0x3fb0d3,_0x3aba34,_0x23ebfb,_0x3aba34[_0x6e70('0x5a')],_0x3fd03d);})[_0x6e70('0x28')](function(_0x324fa6){_0x8ef4f7=_0x324fa6;logger[_0x6e70('0x1b')](_0x6e70('0x5b'));logger[_0x6e70('0x1b')]('The\x20Ticket\x20ID\x20is:',_0x8ef4f7['id']);var _0x28898a=util[_0x6e70('0x24')](_0x6e70('0x5c'),_0x1dd242[_0x6e70('0x40')],_[_0x6e70('0x5d')](_0x8ef4f7['id'],'x')[0x1]);logger[_0x6e70('0x1b')]('[QUEUE]',_0x6e70('0x5e'));emit(util[_0x6e70('0x24')]('user:%s',_0x4a111a[_0x6e70('0x19')]),_0x6e70('0x5f'),{'uri':_0x28898a});})[_0x6e70('0x48')](function(_0x590f7f){logger['error'](_0x6e70('0x50'),JSON[_0x6e70('0x27')](_0x590f7f));});};exports[_0x6e70('0x60')]=function(_0x41a861,_0x10d299,_0x739946,_0x30cd88,_0x57bfe5,_0x4d47e1,_0x2c8dc6){var _0x1e23c5,_0x2bf9ec,_0x2ad395,_0x5b1e6f;_0x4d47e1['remoteUri']=intUtil[_0x6e70('0x4f')](_0x4d47e1[_0x6e70('0x40')]);_0x4d47e1['serverUrl']=intUtil['stripTrailingSlash'](_0x4d47e1[_0x6e70('0x53')]);if(_0x2c8dc6&&_0x2c8dc6['recordingFormat']&&_0x2c8dc6[_0x6e70('0x61')]!==_0x6e70('0x62')){logger[_0x6e70('0x1b')](_0x6e70('0x63'),_0x6e70('0x64'));_0x10d299[_0x6e70('0x51')]=util[_0x6e70('0x24')](_0x6e70('0x52'),_0x4d47e1['serverUrl'],_0x10d299[_0x6e70('0x54')],md5(_0x10d299[_0x6e70('0x54')]));}return getConnection(_0x4d47e1)[_0x6e70('0x28')](function(_0x346c79){_0x5b1e6f=_0x346c79;return getUser(_0x4d47e1,_0x30cd88[_0x6e70('0x55')],_0x5b1e6f);})['then'](function(_0x5f5b02){_0x1e23c5=_0x5f5b02;logger['info'](_0x6e70('0x56'),_0x1e23c5['id']);return getEndUser(_0x4d47e1,_0x10d299[_0x6e70('0x65')],_0x10d299[_0x6e70('0x66')],_0x5b1e6f);})['then'](function(_0x58cf1c){_0x2bf9ec=_0x58cf1c;logger[_0x6e70('0x1b')](_0x6e70('0x59'),_0x2bf9ec['id']);return createTicket(_0x4d47e1,_0x1e23c5,_0x2bf9ec,_0x739946,_0x10d299,_0x739946[_0x6e70('0x5a')],_0x5b1e6f);})[_0x6e70('0x28')](function(_0x2285f1){_0x2ad395=_0x2285f1;logger[_0x6e70('0x1b')]('Ticket\x20created!');logger[_0x6e70('0x1b')](_0x6e70('0x67'),_0x2ad395['id']);var _0x30d11b=util[_0x6e70('0x24')]('%s/index.php?module=HelpDesk&view=Detail&record=%s&app=SUPPORT',_0x4d47e1[_0x6e70('0x40')],_['split'](_0x2ad395['id'],'x')[0x1]);logger['info'](_0x6e70('0x63'),_0x6e70('0x5e'));emit(util[_0x6e70('0x24')](_0x6e70('0x68'),_0x30cd88[_0x6e70('0x19')]),_0x6e70('0x5f'),{'uri':_0x30d11b});})['catch'](function(_0x370eeb){logger[_0x6e70('0x2d')](_0x6e70('0x63'),JSON[_0x6e70('0x27')](_0x370eeb));});};exports[_0x6e70('0x69')]=function(_0x13c092,_0x363722,_0xd9b4a9,_0x2f1362,_0x29621a,_0x575938){var _0x44c877,_0x303c5a,_0x577c3b,_0x5d398a;_0x575938['remoteUri']=intUtil[_0x6e70('0x4f')](_0x575938[_0x6e70('0x40')]);_0x575938[_0x6e70('0x53')]=intUtil[_0x6e70('0x4f')](_0x575938[_0x6e70('0x53')]);if(_0x29621a&&_0x29621a['monitor_format']){logger['info']('['+_0x363722[_0x6e70('0x6a')][_0x6e70('0x6b')]()+']','Recording\x20is\x20enabled!');_0x363722[_0x6e70('0x51')]=util[_0x6e70('0x24')](_0x6e70('0x52'),_0x575938[_0x6e70('0x53')],_0x363722[_0x6e70('0x54')],md5(_0x363722[_0x6e70('0x54')]));}else{_0x363722[_0x6e70('0x51')]='';}return getConnection(_0x575938)[_0x6e70('0x28')](function(_0x3650e9){_0x5d398a=_0x3650e9;return getUser(_0x575938,'',_0x5d398a);})[_0x6e70('0x28')](function(_0x347cc4){_0x44c877=_0x347cc4;logger[_0x6e70('0x1b')](_0x6e70('0x56'),_0x44c877['id']);return getEndUser(_0x575938,_0x363722[_0x6e70('0x57')],_0x363722['calleridnum'],_0x5d398a);})['then'](function(_0x39ed95){_0x303c5a=_0x39ed95;logger['info'](_0x6e70('0x59'),_0x303c5a['id']);return createTicket(_0x575938,_0x44c877,_0x303c5a,_0xd9b4a9,_0x363722,_0xd9b4a9['Fields'],_0x5d398a);})['then'](function(_0x402f6f){_0x577c3b=_0x402f6f;logger['info']('Ticket\x20created!');logger[_0x6e70('0x1b')](_0x6e70('0x67'),_0x577c3b['id']);})[_0x6e70('0x48')](function(_0x4e9fda){logger['error']('['+_0x363722['lastevent'][_0x6e70('0x6b')]()+']',JSON['stringify'](_0x4e9fda));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/zendesk.js b/server/services/ami/trigger/integration/zendesk.js new file mode 100644 index 0000000..c1ee891 --- /dev/null +++ b/server/services/ami/trigger/integration/zendesk.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x803a=['count','Agent\x20found!','results','agent','%s/users/me.json','remoteUri','Admin\x20account\x20selected.','user','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Searching\x20enduser\x20with\x20phone','%s/search.json','type:user\x20role:end-user\x20phone:%s','filter','end-user','length','Enduser\x20found!','%s/users.json','POST','Enduser\x20created.','authType','%s:%s','username','password','token','%s/token:%s','Basic\x20%s','toString','base64','debug','[HTTP]','stringify','defaults','map','forEach','includes','string','picklist','type','nameField','customField','toLowerCase','content','idField','custom_fields','push','variable','variableName','customVariable','Variable','name','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','uniqueid','recordingURL','Authorization','email','The\x20User\x20ID\x20is:','calleridname','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','integrationTab','newTab','user:%s','trigger:browser:url','%s/agent/tickets/%s','replace','Zendesk\x20account\x20type\x20not\x20recognized','catch','error','[QUEUE]\x20Error\x20running\x20Zendesk\x20integration','outbound','recordingFormat','[OUTBOUND]','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','destcalleridnum','Displaying\x20ticket\x20to\x20agent...','%s/channels/voice/agents/%d/tickets/%d/display.json','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','/api/v2','inspect','unmanaged','toUpperCase','lastevent','\x20Error\x20running\x20Zendesk\x20integration','lodash','request-promise','md5','util','ioredis','../../../../config/environment','../../../../config/logger','zendesk','redis','localhost','socket.io-emitter','application/json','info','merge','Tags','getString','Subjects','Fields','then','Ticket\x20created!','ticket','Getting\x20agent\x20with\x20email','format'];(function(_0x24259d,_0x64a194){var _0x5a701=function(_0x204516){while(--_0x204516){_0x24259d['push'](_0x24259d['shift']());}};_0x5a701(++_0x64a194);}(_0x803a,0x1a9));var _0xa803=function(_0x31df30,_0x571312){_0x31df30=_0x31df30-0x0;var _0x54811b=_0x803a[_0x31df30];return _0x54811b;};'use strict';var _=require(_0xa803('0x0'));var rp=require(_0xa803('0x1'));var md5=require(_0xa803('0x2'));var util=require(_0xa803('0x3'));var Redis=require(_0xa803('0x4'));var intUtil=require('./util');var config=require(_0xa803('0x5'));var logger=require(_0xa803('0x6'))(_0xa803('0x7'));config[_0xa803('0x8')]=_['defaults'](config['redis'],{'host':_0xa803('0x9'),'port':0x18eb});var io=require(_0xa803('0xa'))(new Redis(config[_0xa803('0x8')]));function emit(_0x319bdf,_0x1df017,_0xc1a847){io['to'](_0x319bdf)['emit'](_0x1df017,_0xc1a847);}var headers={'Content-Type':'application/json','Accept':_0xa803('0xb')};function getTicket(_0x3f93cd,_0x11c797,_0x25734e,_0x1642b4,_0x5d5c03){logger[_0xa803('0xc')]('Creating\x20new\x20ticket...');return request({'uri':util['format']('%s/tickets.json',_0x3f93cd['remoteUri']),'method':'POST','body':{'ticket':_[_0xa803('0xd')]({'requester_id':_0x25734e['id'],'submitter_id':_0x11c797?_0x11c797['id']:undefined,'assignee_id':_0x11c797?_0x11c797['id']:undefined,'tags':getTags(_0x1642b4[_0xa803('0xe')],'name'),'subject':intUtil[_0xa803('0xf')](_0x1642b4[_0xa803('0x10')],_0x5d5c03,'\x20'),'description':intUtil['getString'](_0x1642b4['Descriptions'],_0x5d5c03,'\x0a'),'comment':{'public':![],'body':intUtil['getString'](_0x1642b4['Descriptions'],_0x5d5c03,'\x0a')}},getCustomFields(_0x1642b4[_0xa803('0x11')],_0x5d5c03))}})[_0xa803('0x12')](function(_0x9490c0){logger[_0xa803('0xc')](_0xa803('0x13'));return _0x9490c0[_0xa803('0x14')];});}function getUser(_0x2e22ef,_0x14bb21){if(intUtil['validateEmail'](_0x14bb21)){logger[_0xa803('0xc')](_0xa803('0x15'),_0x14bb21);return request({'uri':util[_0xa803('0x16')]('%s/search.json',_0x2e22ef['remoteUri']),'qs':{'query':util[_0xa803('0x16')]('type:user\x20role:agent\x20email:%s',_0x14bb21)}})[_0xa803('0x12')](function(_0x428256){if(_0x428256[_0xa803('0x17')]){logger[_0xa803('0xc')](_0xa803('0x18'));return _['find'](_0x428256[_0xa803('0x19')],{'email':_0x14bb21,'role':_0xa803('0x1a')});}else{logger[_0xa803('0xc')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0xa803('0x16')](_0xa803('0x1b'),_0x2e22ef[_0xa803('0x1c')])})[_0xa803('0x12')](function(_0x137f9e){logger[_0xa803('0xc')](_0xa803('0x1d'));return _0x137f9e[_0xa803('0x1e')];});}});}else{logger[_0xa803('0xc')](_0xa803('0x1f'));return request({'uri':util[_0xa803('0x16')](_0xa803('0x1b'),_0x2e22ef[_0xa803('0x1c')])})[_0xa803('0x12')](function(_0x55f1d3){logger['info']('Admin\x20account\x20selected.');return _0x55f1d3[_0xa803('0x1e')];});}}function getEndUser(_0x186454,_0x222655,_0x230a13){logger['info'](_0xa803('0x20'),_0x230a13);return request({'uri':util[_0xa803('0x16')](_0xa803('0x21'),_0x186454['remoteUri']),'qs':{'query':util[_0xa803('0x16')](_0xa803('0x22'),_0x230a13)}})[_0xa803('0x12')](function(_0x4169ce){var _0x326831;if(_0x4169ce['results']['length']){_0x4169ce['results']=_[_0xa803('0x23')](_0x4169ce['results'],{'suspended':![],'role':_0xa803('0x24')});if(_0x4169ce[_0xa803('0x19')][_0xa803('0x25')]){_0x326831=_['first'](_0x4169ce[_0xa803('0x19')]);}}if(_0x326831){logger['info'](_0xa803('0x26'));return _0x326831;}else{logger[_0xa803('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0xa803('0x16')](_0xa803('0x27'),_0x186454['remoteUri']),'method':_0xa803('0x28'),'body':{'user':{'role':_0xa803('0x24'),'name':util[_0xa803('0x16')]('Caller\x20-\x20%s',_0x222655||_0x230a13),'phone':_0x230a13}}})[_0xa803('0x12')](function(_0x44cdd8){logger[_0xa803('0xc')](_0xa803('0x29'));return _0x44cdd8[_0xa803('0x1e')];});}});}function getAuth(_0xcc0a11){var _0x440d88;if(_0xcc0a11[_0xa803('0x2a')]==='password'){_0x440d88=util[_0xa803('0x16')](_0xa803('0x2b'),_0xcc0a11[_0xa803('0x2c')],_0xcc0a11[_0xa803('0x2d')]);}else if(_0xcc0a11[_0xa803('0x2a')]===_0xa803('0x2e')){_0x440d88=util[_0xa803('0x16')](_0xa803('0x2f'),_0xcc0a11[_0xa803('0x2c')],_0xcc0a11[_0xa803('0x2e')]);}return util[_0xa803('0x16')](_0xa803('0x30'),new Buffer(_0x440d88)[_0xa803('0x31')](_0xa803('0x32')));}function request(_0x4e289b){logger[_0xa803('0x33')](_0xa803('0x34'),JSON[_0xa803('0x35')](_0x4e289b));return rp(_[_0xa803('0x36')](_0x4e289b,{'method':'GET','headers':headers,'json':!![]}));}function getTags(_0x4cbf1c,_0x57facd){var _0x20b5b0=[];if(_0x4cbf1c&&_0x4cbf1c['length']>0x0){_0x20b5b0=_[_0xa803('0x37')](_0x4cbf1c,_0x57facd);}return _0x20b5b0;}function getCustomFields(_0x519c32,_0x17cd94){var _0x59b81f=[];var _0x1b9c0a={'custom_fields':[]};if(_0x519c32['length']>0x0){_[_0xa803('0x38')](_0x519c32,function(_0x46a424){if(_[_0xa803('0x39')]([_0xa803('0x3a'),_0xa803('0x3b')],_0x46a424[_0xa803('0x3c')])&&_0x46a424[_0xa803('0x3d')]&&!_0x46a424[_0xa803('0x3e')]){_0x1b9c0a[_0x46a424[_0xa803('0x3d')][_0xa803('0x3f')]()]=_0x46a424[_0xa803('0x40')][_0xa803('0x31')]();}else if(_[_0xa803('0x39')](['string','picklist'],_0x46a424[_0xa803('0x3c')])&&_0x46a424[_0xa803('0x41')]&&_0x46a424[_0xa803('0x3e')]){_0x1b9c0a[_0xa803('0x42')][_0xa803('0x43')]({'id':_0x46a424[_0xa803('0x41')],'value':_0x46a424[_0xa803('0x40')]['toString']()});}else if(_0x46a424[_0xa803('0x3c')]===_0xa803('0x44')&&_0x46a424[_0xa803('0x45')]&&_0x46a424[_0xa803('0x41')]&&_0x46a424[_0xa803('0x3e')]){_0x17cd94[_0x46a424[_0xa803('0x45')]]&&_0x1b9c0a[_0xa803('0x42')][_0xa803('0x43')]({'id':_0x46a424['idField'],'value':_0x17cd94[_0x46a424[_0xa803('0x45')]]['toString']()});}else if(_0x46a424['type']===_0xa803('0x46')&&_0x46a424[_0xa803('0x47')]&&_0x46a424[_0xa803('0x47')][_0xa803('0x48')]&&_0x46a424[_0xa803('0x41')]&&_0x46a424[_0xa803('0x3e')]){_0x17cd94[_0x46a424['Variable'][_0xa803('0x48')][_0xa803('0x3f')]()]&&_0x1b9c0a[_0xa803('0x42')][_0xa803('0x43')]({'id':_0x46a424['idField'],'value':_0x17cd94[_0x46a424[_0xa803('0x47')][_0xa803('0x48')][_0xa803('0x3f')]()][_0xa803('0x31')]()});}});}return _0x1b9c0a;}exports[_0xa803('0x49')]=function(_0x4e6f5f,_0x234509,_0x26048a,_0x23b8a0,_0x5cfbee,_0x55d346){var _0x59b02f,_0x48d9e3;_0x55d346[_0xa803('0x1c')]=intUtil[_0xa803('0x4a')](_0x55d346[_0xa803('0x1c')]);_0x55d346[_0xa803('0x4b')]=intUtil[_0xa803('0x4a')](_0x55d346[_0xa803('0x4b')]);if(_0x5cfbee&&_0x5cfbee[_0xa803('0x4c')]){logger[_0xa803('0xc')](_0xa803('0x4d'),_0xa803('0x4e'));_0x234509['recordingURL']=util[_0xa803('0x16')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x55d346[_0xa803('0x4b')],_0x234509['uniqueid'],md5(_0x234509[_0xa803('0x4f')]));}else{_0x234509[_0xa803('0x50')]='';}headers[_0xa803('0x51')]=getAuth(_0x55d346);return getUser(_0x55d346,_0x23b8a0[_0xa803('0x52')])[_0xa803('0x12')](function(_0x969090){_0x59b02f=_0x969090;logger[_0xa803('0xc')](_0xa803('0x53'),_0x59b02f['id']);return getEndUser(_0x55d346,_0x234509[_0xa803('0x54')],_0x234509[_0xa803('0x55')]);})[_0xa803('0x12')](function(_0x12962b){_0x48d9e3=_0x12962b;logger[_0xa803('0xc')](_0xa803('0x56'),_0x48d9e3['id']);return getTicket(_0x55d346,_0x59b02f,_0x48d9e3,_0x26048a,_0x234509);})['then'](function(_0xdcc3e5){if(_0xdcc3e5){logger[_0xa803('0xc')](_0xa803('0x57'),_0xdcc3e5['id']);switch(_0x55d346[_0xa803('0x3c')]){case _0xa803('0x58'):logger[_0xa803('0xc')](_0xa803('0x4d'),'Displaying\x20ticket\x20to\x20agent...');return request({'uri':util['format']('%s/channels/voice/agents/%d/tickets/%d/display.json',_0x55d346[_0xa803('0x1c')],_0x59b02f['id'],_0xdcc3e5['id']),'method':'POST'});case _0xa803('0x59'):logger[_0xa803('0xc')](_0xa803('0x4d'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xa803('0x16')](_0xa803('0x5a'),_0x23b8a0[_0xa803('0x48')]),_0xa803('0x5b'),{'uri':util[_0xa803('0x16')](_0xa803('0x5c'),_0x55d346[_0xa803('0x1c')][_0xa803('0x5d')]('/api/v2',''),_0xdcc3e5['id'])});break;default:logger['error'](_0xa803('0x4d'),_0xa803('0x5e'));}}})[_0xa803('0x5f')](function(_0x1f3759){logger[_0xa803('0x60')](_0xa803('0x61'),util['inspect'](_0x1f3759,{'showHidden':!![],'depth':null}));});};exports[_0xa803('0x62')]=function(_0x14e587,_0x7f452f,_0x18eef8,_0x55bbea,_0x4cdc2e,_0x507af2,_0x2c6dd7){var _0x269465,_0x3abe2d;_0x507af2[_0xa803('0x1c')]=intUtil[_0xa803('0x4a')](_0x507af2[_0xa803('0x1c')]);_0x507af2[_0xa803('0x4b')]=intUtil[_0xa803('0x4a')](_0x507af2['serverUrl']);if(_0x2c6dd7&&_0x2c6dd7[_0xa803('0x63')]&&_0x2c6dd7[_0xa803('0x63')]!=='none'){logger[_0xa803('0xc')](_0xa803('0x64'),_0xa803('0x4e'));_0x7f452f[_0xa803('0x50')]=util[_0xa803('0x16')](_0xa803('0x65'),_0x507af2['serverUrl'],_0x7f452f['uniqueid'],md5(_0x7f452f[_0xa803('0x4f')]));}headers['Authorization']=getAuth(_0x507af2);return getUser(_0x507af2,_0x55bbea['email'])[_0xa803('0x12')](function(_0x322de9){_0x269465=_0x322de9;logger[_0xa803('0xc')](_0xa803('0x53'),_0x269465['id']);return getEndUser(_0x507af2,_0x7f452f['destcalleridname'],_0x7f452f[_0xa803('0x66')]);})[_0xa803('0x12')](function(_0x347cb2){_0x3abe2d=_0x347cb2;logger[_0xa803('0xc')](_0xa803('0x56'),_0x3abe2d['id']);return getTicket(_0x507af2,_0x269465,_0x3abe2d,_0x18eef8,_0x7f452f);})[_0xa803('0x12')](function(_0x4430a2){if(_0x4430a2){logger[_0xa803('0xc')](_0xa803('0x57'),_0x4430a2['id']);switch(_0x507af2['type']){case _0xa803('0x58'):logger[_0xa803('0xc')](_0xa803('0x64'),_0xa803('0x67'));return request({'uri':util[_0xa803('0x16')](_0xa803('0x68'),_0x507af2[_0xa803('0x1c')],_0x269465['id'],_0x4430a2['id']),'method':_0xa803('0x28')});case _0xa803('0x59'):logger[_0xa803('0xc')](_0xa803('0x64'),_0xa803('0x69'));emit(util[_0xa803('0x16')](_0xa803('0x5a'),_0x55bbea[_0xa803('0x48')]),_0xa803('0x5b'),{'uri':util['format'](_0xa803('0x5c'),_0x507af2['remoteUri']['replace'](_0xa803('0x6a'),''),_0x4430a2['id'])});break;default:logger[_0xa803('0x60')](_0xa803('0x64'),_0xa803('0x5e'));}}})[_0xa803('0x5f')](function(_0x2a4065){logger[_0xa803('0x60')]('[OUTBOUND]\x20Error\x20running\x20Zendesk\x20integration',util[_0xa803('0x6b')](_0x2a4065,{'showHidden':!![],'depth':null}));});};exports[_0xa803('0x6c')]=function(_0x7a2050,_0x13227a,_0x5c780c,_0x1ca359,_0x488073,_0x5b4503){var _0x5b39c2,_0x55cbca;_0x5b4503[_0xa803('0x1c')]=intUtil[_0xa803('0x4a')](_0x5b4503['remoteUri']);_0x5b4503[_0xa803('0x4b')]=intUtil[_0xa803('0x4a')](_0x5b4503[_0xa803('0x4b')]);if(_0x488073&&_0x488073[_0xa803('0x4c')]){logger[_0xa803('0xc')]('['+_0x13227a['lastevent'][_0xa803('0x6d')]()+']',_0xa803('0x4e'));_0x13227a[_0xa803('0x50')]=util[_0xa803('0x16')](_0xa803('0x65'),_0x5b4503['serverUrl'],_0x13227a['uniqueid'],md5(_0x13227a[_0xa803('0x4f')]));}else{_0x13227a[_0xa803('0x50')]='';}headers['Authorization']=getAuth(_0x5b4503);return getUser(_0x5b4503)['then'](function(_0x383aa0){_0x5b39c2=_0x383aa0;logger[_0xa803('0xc')](_0xa803('0x53'),_0x5b39c2['id']);return getEndUser(_0x5b4503,_0x13227a[_0xa803('0x54')],_0x13227a['calleridnum']);})[_0xa803('0x12')](function(_0x44b390){_0x55cbca=_0x44b390;logger[_0xa803('0xc')](_0xa803('0x56'),_0x55cbca['id']);return getTicket(_0x5b4503,_0x5b39c2,_0x55cbca,_0x5c780c,_0x13227a);})[_0xa803('0x12')](function(_0x1ce392){if(_0x1ce392){logger['info']('The\x20Ticket\x20ID\x20is:',_0x1ce392['id']);}})[_0xa803('0x5f')](function(_0x3c7db4){logger[_0xa803('0x60')]('['+_0x13227a[_0xa803('0x6e')][_0xa803('0x6d')]()+']'+_0xa803('0x6f'),util['inspect'](_0x3c7db4,{'showHidden':!![],'depth':null}));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/integration/zoho.js b/server/services/ami/trigger/integration/zoho.js new file mode 100644 index 0000000..479ac12 --- /dev/null +++ b/server/services/ami/trigger/integration/zoho.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe589=['calleridname','The\x20Call\x20ID\x20is:','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','https://crm.','/crm/EntityInfo.do?module=Calls&id=','[QUEUE]','recordingFormat','none','Recording\x20is\x20enabled!','/downloads?type=uniqueid&token=','email','The\x20User\x20ID\x20is:','destcalleridname','destcalleridnum','Outbound','[OUTBOUND]','unmanaged','monitor_format','toUpperCase','calleridnum','md5','util','ioredis','bluebird','../../../../config/environment','../../../../config/logger','redis','localhost','socket.io-emitter','debug','[HTTP]','forEach','includes','string','picklist','type','idField','content','toString','variable','variableName','customVariable','Variable','name','toLowerCase','split','isNil','access_token','isBefore','zone','https://accounts.zoho.com.au','https://accounts.zoho.in','https://accounts.zoho.com.cn','https://accounts.zoho.eu','POST','/oauth/v2/token','refreshToken','clientId','clientSecret','refresh_token','then','add','seconds','catch','error','Failing\x20creating\x20the\x20access_token','stack','Search\x20user','GET','format','https://www.zohoapis.%s/crm/v2/users','ActiveUsers','Zoho-oauthtoken\x20','users','isArrayLikeObject','findIndex','Agent\x20found!','info','Using\x20the\x20admin\x20account!','profile','Administrator','user','The\x20failing\x20result\x20is','stringify','Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20','data','enduserType','https://www.zohoapis.','/crm/v2/','startCase','moduleCreate','role','first_name','last_name','code','details','Error:\x20','log','contact_lead','uri','/crm/v2/Contacts/search?criteria=((Phone:equals:','Contacts','/crm/v2/Leads/search?criteria=((Phone:equals:','nothing','contact','lead','Leads','Creating\x20new\x20call...','Owner','administrator','Subject','getString','Subjects','Descriptions','Who_Id','Full_Name','Last_Name','What_Id','First_Name','$se_module','talktime','Call_Duration','endtime','utc','YYYY-MM-DDTHH:mm:ss','mm:ss','lastevent','called','Call_Result','complete','connect','Answered','rejected','Rejected','Abandoned','timeout','Call_Start_Time','outbound','agentcalledAt','Call_Type','merge','Fields','SUCCESS','Call\x20created!','err','queue','host','stripTrailingSlash','serverUrl','recordingURL','/api/voice/recordings/','uniqueid','zoho.eu','com'];(function(_0x5b4dd6,_0x15cd99){var _0x3b2271=function(_0x239d46){while(--_0x239d46){_0x5b4dd6['push'](_0x5b4dd6['shift']());}};_0x3b2271(++_0x15cd99);}(_0xe589,0x14e));var _0x9e58=function(_0x3c532a,_0x5582db){_0x3c532a=_0x3c532a-0x0;var _0x63508c=_0xe589[_0x3c532a];return _0x63508c;};'use strict';var _=require('lodash');var rp=require('request-promise');var md5=require(_0x9e58('0x0'));var util=require(_0x9e58('0x1'));var intUtil=require('./util');var moment=require('moment');var Redis=require(_0x9e58('0x2'));var BPromise=require(_0x9e58('0x3'));var config=require(_0x9e58('0x4'));var logger=require(_0x9e58('0x5'))('zoho');config[_0x9e58('0x6')]=_['defaults'](config[_0x9e58('0x6')],{'host':_0x9e58('0x7'),'port':0x18eb});var io=require(_0x9e58('0x8'))(new Redis(config[_0x9e58('0x6')]));function emit(_0x4f743f,_0x22c9ce,_0x3f6989){io['to'](_0x4f743f)['emit'](_0x22c9ce,_0x3f6989);}function request(_0x5dd085){logger[_0x9e58('0x9')](_0x9e58('0xa'),JSON['stringify'](_0x5dd085));return rp(_0x5dd085);}function getCustomFields(_0x186258,_0x529e1e){var _0x1f0723={};if(_0x186258['length']>0x0){_[_0x9e58('0xb')](_0x186258,function(_0x564feb){if(_[_0x9e58('0xc')]([_0x9e58('0xd'),_0x9e58('0xe')],_0x564feb[_0x9e58('0xf')])&&_0x564feb[_0x9e58('0x10')]){_0x1f0723[_0x564feb[_0x9e58('0x10')]]=_0x564feb[_0x9e58('0x11')][_0x9e58('0x12')]();}else if(_0x564feb['type']===_0x9e58('0x13')&&_0x564feb[_0x9e58('0x14')]&&_0x564feb[_0x9e58('0x10')]&&_0x529e1e[_0x564feb['variableName']]){_0x1f0723[_0x564feb[_0x9e58('0x10')]]=_0x529e1e[_0x564feb[_0x9e58('0x14')]][_0x9e58('0x12')]();}else if(_0x564feb[_0x9e58('0xf')]===_0x9e58('0x15')&&_0x564feb[_0x9e58('0x16')]&&_0x564feb['Variable'][_0x9e58('0x17')]&&_0x564feb[_0x9e58('0x10')]&&_0x529e1e[_0x564feb['Variable'][_0x9e58('0x17')]['toLowerCase']()]){_0x1f0723[_0x564feb[_0x9e58('0x10')]]=_0x529e1e[_0x564feb[_0x9e58('0x16')][_0x9e58('0x17')][_0x9e58('0x18')]()][_0x9e58('0x12')]();}});}return _0x1f0723;}function getName(_0x4b9017){if(_0x4b9017['indexOf']('\x20')>0x0){var _0x44f367=_0x4b9017[_0x9e58('0x19')](/ (.+)/);if(_0x44f367[0x1]){return _0x44f367;}}return[_0x4b9017,_0x4b9017];}var accountsTokens={};function getAccessToken(_0x5b223b){return new Promise(function(_0x41cdd2,_0xc1d41){if(!_[_0x9e58('0x1a')](accountsTokens[_0x5b223b['id']])&&!_['isNil'](accountsTokens[_0x5b223b['id']][_0x9e58('0x1b')])){if(moment()[_0x9e58('0x1c')](accountsTokens[_0x5b223b['id']]['expires_in'])){_0x41cdd2(accountsTokens[_0x5b223b['id']][_0x9e58('0x1b')]);}}var _0xaa24b0;switch(_0x5b223b[_0x9e58('0x1d')]){case'US':_0xaa24b0='https://accounts.zoho.com';break;case'AU':_0xaa24b0=_0x9e58('0x1e');break;case'EU':_0xaa24b0='https://accounts.zoho.eu';break;case'IN':_0xaa24b0=_0x9e58('0x1f');break;case'CN':_0xaa24b0=_0x9e58('0x20');break;default:_0xaa24b0=_0x9e58('0x21');break;}var _0x218f80={'method':_0x9e58('0x22'),'uri':_0xaa24b0+_0x9e58('0x23'),'qs':{'refresh_token':_0x5b223b[_0x9e58('0x24')],'client_id':_0x5b223b[_0x9e58('0x25')],'client_secret':_0x5b223b[_0x9e58('0x26')],'grant_type':_0x9e58('0x27')},'json':!![]};return rp(_0x218f80)[_0x9e58('0x28')](function(_0xc5676){accountsTokens[_0x5b223b['id']]={'access_token':_0xc5676[_0x9e58('0x1b')],'expires_in':moment()[_0x9e58('0x29')](_0xc5676['expires_in'],_0x9e58('0x2a'))};_0x41cdd2(_0xc5676[_0x9e58('0x1b')]);})[_0x9e58('0x2b')](function(_0x1f7b8c){logger[_0x9e58('0x2c')](_0x9e58('0x2d'),_0x1f7b8c[_0x9e58('0x2e')]);_0xc1d41(_0x1f7b8c);});});}function getUser(_0x3baae3,_0x468d6d,_0x27d3c0,_0x3c95c5){logger['info'](_0x9e58('0x2f'));return request({'method':_0x9e58('0x30'),'uri':util[_0x9e58('0x31')](_0x9e58('0x32'),_0x468d6d),'qs':{'type':_0x9e58('0x33')},'headers':{'Authorization':_0x9e58('0x34')+_0x3baae3},'json':!![]})[_0x9e58('0x28')](function(_0x4177fc){if(_0x4177fc[_0x9e58('0x35')]){var _0x15b79e=-0x1;if(_[_0x9e58('0x36')](_0x4177fc['users'])){if(!_[_0x9e58('0x1a')](_0x3c95c5)){_0x15b79e=_[_0x9e58('0x37')](_0x4177fc['users'],function(_0x571c68){return _0x571c68['email']===_0x3c95c5;});}if(_0x15b79e>=0x0){logger['info'](_0x9e58('0x38'));}else{logger[_0x9e58('0x39')](_0x9e58('0x3a'));_0x15b79e=_[_0x9e58('0x37')](_0x4177fc[_0x9e58('0x35')],function(_0x44c147){return _0x44c147[_0x9e58('0x3b')][_0x9e58('0x17')]===_0x9e58('0x3c');});}return _0x4177fc[_0x9e58('0x35')][_0x15b79e];}else{if(_0x4177fc[_0x9e58('0x3d')][_0x9e58('0x3b')][_0x9e58('0x17')]===_0x9e58('0x3c')){logger[_0x9e58('0x39')]('Using\x20the\x20admin\x20account!');user=_0x4177fc[_0x9e58('0x3d')];return user;}else{logger['error'](_0x9e58('0x3e'),JSON[_0x9e58('0x3f')](_0x4177fc));throw new Error(_0x9e58('0x40')+JSON[_0x9e58('0x3f')](_0x4177fc));}}}else{logger[_0x9e58('0x2c')](_0x9e58('0x3e'),JSON[_0x9e58('0x3f')](_0x4177fc));throw new Error(_0x9e58('0x40')+JSON['stringify'](_0x4177fc));}})[_0x9e58('0x2b')](function(_0x17988d){console['error'](_0x17988d);});}function getZohoUser(_0x93de87,_0x1f9934){return new BPromise(function(_0x1e01e2,_0x366a31){request(_0x93de87)[_0x9e58('0x28')](function(_0x4a82a1){var _0x2bdff1=null;if(_0x4a82a1){_0x2bdff1=_0x4a82a1[_0x9e58('0x41')][0x0];_0x2bdff1[_0x9e58('0x42')]=_0x1f9934;}_0x1e01e2(_0x2bdff1);})['catch'](function(_0x3e9188){_0x366a31(_0x3e9188);});});}function createEndUser(_0x41fbf9,_0x3b65a8,_0x2b4fbe,_0x5b7de0,_0x50caa0,_0x24a0b5){var _0x2b4fbe=getName(_0x2b4fbe);return request({'method':_0x9e58('0x22'),'uri':_0x9e58('0x43')+_0x3b65a8+_0x9e58('0x44')+_[_0x9e58('0x45')](_0x24a0b5[_0x9e58('0x46')])+'s','body':{'data':[{'Last_Name':_0x2b4fbe[0x1],'First_Name':_0x2b4fbe[0x0],'Phone':_0x5b7de0,'Owner':{'name':!_['isNil'](_0x50caa0[_0x9e58('0x47')][_0x9e58('0x17')])?_0x50caa0['role'][_0x9e58('0x17')]:!_[_0x9e58('0x1a')](_0x50caa0[_0x9e58('0x48')])?_0x50caa0[_0x9e58('0x48')]+'\x20'+_0x50caa0['last_name']:_0x50caa0[_0x9e58('0x49')],'id':_0x50caa0['id']}}]},'headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x41fbf9},'json':!![]})[_0x9e58('0x28')](function(_0x39ab73){if(_0x39ab73&&_0x39ab73[_0x9e58('0x41')][0x0][_0x9e58('0x4a')]==='SUCCESS'){var _0x216cb9=_0x39ab73['data'][0x0][_0x9e58('0x4b')];_0x216cb9[_0x9e58('0x42')]=_['startCase'](_0x24a0b5['moduleCreate'])+'s';return _0x216cb9;}logger['error'](_0x9e58('0x3e'),JSON[_0x9e58('0x3f')](data));throw new Error(_0x9e58('0x4c')+JSON[_0x9e58('0x3f')](data));})['catch'](function(_0x2c60c4){console[_0x9e58('0x4d')]('CREATE\x20ERROR',_0x2c60c4);});}function getEndUser(_0x54eec7,_0x3f1b90,_0x57df43,_0xce1a1d,_0x400b46,_0x11a30a,_0x454ae7){var _0x189309={'method':_0x9e58('0x30'),'uri':'','headers':{'Authorization':_0x9e58('0x34')+_0x54eec7},'json':!![]};switch(_0x454ae7['moduleSearch']){case _0x9e58('0x4e'):_0x189309[_0x9e58('0x4f')]='https://www.zohoapis.'+_0x3f1b90+_0x9e58('0x50')+_0x400b46+'))';return getZohoUser(_0x189309,_0x9e58('0x51'))['then'](function(_0x8e8a3f){if(_0x8e8a3f)return _0x8e8a3f;_0x189309[_0x9e58('0x4f')]=_0x9e58('0x43')+_0x3f1b90+_0x9e58('0x52')+_0x400b46+'))';return getZohoUser(_0x189309,'Leads')[_0x9e58('0x28')](function(_0xb6d662){if(_0xb6d662)return _0xb6d662;if(_0x454ae7[_0x9e58('0x46')]!=_0x9e58('0x53')){return createEndUser(_0x54eec7,_0x3f1b90,_0xce1a1d,_0x400b46,_0x11a30a,_0x454ae7);}else{return{};}});});break;case _0x9e58('0x54'):_0x189309[_0x9e58('0x4f')]=_0x9e58('0x43')+_0x3f1b90+_0x9e58('0x50')+_0x400b46+'))';return getZohoUser(_0x189309,_0x9e58('0x51'))[_0x9e58('0x28')](function(_0x2f7dc4){if(_0x2f7dc4)return _0x2f7dc4;if(_0x454ae7['moduleCreate']!=_0x9e58('0x53')){return createEndUser(_0x54eec7,_0x3f1b90,_0xce1a1d,_0x400b46,_0x11a30a,_0x454ae7);}else{return{};}});break;case _0x9e58('0x55'):_0x189309[_0x9e58('0x4f')]=_0x9e58('0x43')+_0x3f1b90+_0x9e58('0x52')+_0x400b46+'))';return getZohoUser(_0x189309,_0x9e58('0x56'))['then'](function(_0x236b65){if(_0x236b65)return _0x236b65;if(_0x454ae7[_0x9e58('0x46')]!=_0x9e58('0x53')){return createEndUser(_0x54eec7,_0x3f1b90,_0xce1a1d,_0x400b46,_0x11a30a,_0x454ae7);}else{return{};}});break;}}function getCall(_0x339f03,_0x423f58,_0x55f4b2,_0x138f27,_0x29efa7,_0x509014,_0x1bc070,_0x593d33){logger[_0x9e58('0x39')](_0x9e58('0x57'));var _0x2fbfee={};_0x2fbfee[_0x9e58('0x58')]={'name':!_[_0x9e58('0x1a')](_0x138f27[_0x9e58('0x47')][_0x9e58('0x17')])&&!_[_0x9e58('0x1a')](_0x138f27['profile'][_0x9e58('0x17')])&&_0x138f27[_0x9e58('0x3b')][_0x9e58('0x17')]===_0x9e58('0x59')?_0x138f27[_0x9e58('0x47')]['name']:!_[_0x9e58('0x1a')](_0x138f27[_0x9e58('0x48')])?_0x138f27[_0x9e58('0x48')]+'\x20'+_0x138f27[_0x9e58('0x49')]:_0x138f27[_0x9e58('0x49')],'id':_0x138f27['id']};_0x2fbfee[_0x9e58('0x5a')]=intUtil[_0x9e58('0x5b')](_0x509014[_0x9e58('0x5c')],_0x1bc070,'\x20');_0x2fbfee['Description']=intUtil[_0x9e58('0x5b')](_0x509014[_0x9e58('0x5d')],_0x1bc070,'\x0a');if(_0x29efa7[_0x9e58('0x42')]===_0x9e58('0x51')){_0x2fbfee[_0x9e58('0x5e')]={'name':!_[_0x9e58('0x1a')](_0x29efa7[_0x9e58('0x5f')])?_0x29efa7[_0x9e58('0x5f')]:!_[_0x9e58('0x1a')](_0x29efa7['First_Name'])?_0x29efa7['First_Name']+'\x20'+_0x29efa7[_0x9e58('0x60')]:_0x29efa7[_0x9e58('0x60')],'id':_0x29efa7['id']};}if(_0x29efa7['enduserType']==='Leads'){_0x2fbfee[_0x9e58('0x61')]={'name':!_[_0x9e58('0x1a')](_0x29efa7[_0x9e58('0x5f')])?_0x29efa7[_0x9e58('0x5f')]:!_[_0x9e58('0x1a')](_0x29efa7[_0x9e58('0x62')])?_0x29efa7[_0x9e58('0x62')]+'\x20'+_0x29efa7[_0x9e58('0x60')]:_0x29efa7[_0x9e58('0x60')],'id':_0x29efa7['id']};_0x2fbfee[_0x9e58('0x63')]=_[_0x9e58('0x45')](_0x29efa7[_0x9e58('0x42')]);}if(_0x1bc070[_0x9e58('0x64')]){_0x2fbfee[_0x9e58('0x65')]=moment['utc'](parseInt(_0x1bc070[_0x9e58('0x64')])*0x3e8)[_0x9e58('0x31')]('mm:ss');}else if(_0x1bc070['answertime']&&_0x1bc070[_0x9e58('0x66')]){_0x2fbfee[_0x9e58('0x65')]=moment[_0x9e58('0x67')](moment(_0x1bc070[_0x9e58('0x66')],_0x9e58('0x68'))['diff'](moment(_0x1bc070['starttime'],'YYYY-MM-DDTHH:mm:ss')))[_0x9e58('0x31')](_0x9e58('0x69'));}switch(_0x1bc070[_0x9e58('0x6a')]){case _0x9e58('0x6b'):_0x2fbfee[_0x9e58('0x6c')]='Called';break;case _0x9e58('0x6d'):case _0x9e58('0x6e'):_0x2fbfee[_0x9e58('0x6c')]=_0x9e58('0x6f');break;case _0x9e58('0x70'):_0x2fbfee['Call_Result']=_0x9e58('0x71');break;case'abandoned':_0x2fbfee['Call_Result']=_0x9e58('0x72');break;case _0x9e58('0x73'):_0x2fbfee['Call_Result']='Timeout';default:}_0x2fbfee[_0x9e58('0x74')]=(_0x593d33===_0x9e58('0x75')?moment(_0x1bc070['starttime'])['format'](_0x9e58('0x68')):moment(_0x1bc070[_0x9e58('0x76')])[_0x9e58('0x31')](_0x9e58('0x68')))||moment()[_0x9e58('0x31')](_0x9e58('0x68'));_0x2fbfee[_0x9e58('0x77')]=_0x593d33||'Inbound';_0x2fbfee=_[_0x9e58('0x78')](_0x2fbfee,getCustomFields(_0x509014[_0x9e58('0x79')],_0x1bc070));return request({'method':_0x9e58('0x22'),'uri':_0x9e58('0x43')+_0x423f58+'/crm/v2/Calls','headers':{'Authorization':_0x9e58('0x34')+_0x339f03},'body':{'data':[_0x2fbfee]},'json':!![]})[_0x9e58('0x28')](function(_0x5ed9c8){if(_0x5ed9c8&&_0x5ed9c8[_0x9e58('0x41')][0x0][_0x9e58('0x4a')]===_0x9e58('0x7a')){logger[_0x9e58('0x39')](_0x9e58('0x7b'));return{'id':_0x5ed9c8[_0x9e58('0x41')][0x0]['details']['id']};}})['catch'](function(_0x2715ab){logger['info'](_0x9e58('0x7c'),_0x2715ab[_0x9e58('0x2e')]);console[_0x9e58('0x4d')](_0x9e58('0x7c'),_0x2715ab);});}exports[_0x9e58('0x7d')]=function(_0x3a847f,_0x63cf8a,_0x43fffc,_0x3010a8,_0x17b418,_0x45f7e5){var _0x346ddf,_0x5b8f5f,_0x87438f;_0x45f7e5[_0x9e58('0x7e')]=intUtil[_0x9e58('0x7f')](_0x45f7e5[_0x9e58('0x7e')]);_0x45f7e5['serverUrl']=intUtil[_0x9e58('0x7f')](_0x45f7e5[_0x9e58('0x80')]);if(_0x17b418&&_0x17b418['monitor_format']){logger['info']('[QUEUE]','Recording\x20is\x20enabled!');_0x63cf8a[_0x9e58('0x81')]=_0x45f7e5[_0x9e58('0x80')]+_0x9e58('0x82')+_0x63cf8a[_0x9e58('0x83')]+'/downloads?type=uniqueid&token='+md5(_0x63cf8a[_0x9e58('0x83')]);}else{_0x63cf8a[_0x9e58('0x81')]='';}var _0x58c0d4=_0x45f7e5[_0x9e58('0x7e')]===_0x9e58('0x84')?'eu':_0x9e58('0x85');return getAccessToken(_0x45f7e5)[_0x9e58('0x28')](function(_0x1905c6){_0x87438f=_0x1905c6;return getUser(_0x87438f,_0x58c0d4,_0x45f7e5,_0x3010a8['email']);})[_0x9e58('0x28')](function(_0x412279){_0x346ddf=_0x412279;logger[_0x9e58('0x39')]('The\x20User\x20ID\x20is:',_0x346ddf['id']);return getEndUser(_0x87438f,_0x58c0d4,_0x45f7e5,_0x63cf8a[_0x9e58('0x86')],_0x63cf8a['calleridnum'],_0x346ddf,_0x43fffc);})[_0x9e58('0x28')](function(_0x27a9b6){_0x5b8f5f=_0x27a9b6;return getCall(_0x87438f,_0x58c0d4,_0x45f7e5,_0x346ddf,_0x5b8f5f,_0x43fffc,_0x63cf8a,'Inbound');})[_0x9e58('0x28')](function(_0x10a4ab){if(_0x10a4ab){logger['info'](_0x9e58('0x87'),_0x10a4ab['id']);logger[_0x9e58('0x39')]('[QUEUE]',_0x9e58('0x88'));emit(util[_0x9e58('0x31')](_0x9e58('0x89'),_0x3010a8[_0x9e58('0x17')]),_0x9e58('0x8a'),{'uri':_0x9e58('0x8b')+_0x45f7e5[_0x9e58('0x7e')]+_0x9e58('0x8c')+_0x10a4ab['id']});}})['catch'](function(_0x2ed616){logger[_0x9e58('0x2c')](_0x9e58('0x8d'),JSON[_0x9e58('0x3f')](_0x2ed616));});};exports[_0x9e58('0x75')]=function(_0x43747f,_0x1451e9,_0x13cacd,_0x1a4348,_0x44a28e,_0xfcda87,_0x34bbad){var _0x5e5f59,_0x296ad8,_0x535d22;_0xfcda87[_0x9e58('0x7e')]=intUtil[_0x9e58('0x7f')](_0xfcda87['host']);_0xfcda87[_0x9e58('0x80')]=intUtil[_0x9e58('0x7f')](_0xfcda87[_0x9e58('0x80')]);if(_0x34bbad&&_0x34bbad[_0x9e58('0x8e')]&&_0x34bbad[_0x9e58('0x8e')]!==_0x9e58('0x8f')){logger[_0x9e58('0x39')]('[OUTBOUND]',_0x9e58('0x90'));_0x1451e9[_0x9e58('0x81')]=_0xfcda87[_0x9e58('0x80')]+_0x9e58('0x82')+_0x1451e9[_0x9e58('0x83')]+_0x9e58('0x91')+md5(_0x1451e9[_0x9e58('0x83')]);}var _0x1b142c=_0xfcda87[_0x9e58('0x7e')]===_0x9e58('0x84')?'eu':_0x9e58('0x85');return getAccessToken(_0xfcda87)[_0x9e58('0x28')](function(_0x1adbc8){_0x535d22=_0x1adbc8;return getUser(_0x535d22,_0x1b142c,_0xfcda87,_0x1a4348[_0x9e58('0x92')]);})[_0x9e58('0x28')](function(_0x39235e){_0x5e5f59=_0x39235e;logger[_0x9e58('0x39')](_0x9e58('0x93'),_0x5e5f59['id']);return getEndUser(_0x535d22,_0x1b142c,_0xfcda87,_0x1451e9[_0x9e58('0x94')],_0x1451e9[_0x9e58('0x95')],_0x5e5f59,_0x13cacd);})['then'](function(_0x46f6b6){_0x296ad8=_0x46f6b6;return getCall(_0x535d22,_0x1b142c,_0xfcda87,_0x5e5f59,_0x296ad8,_0x13cacd,_0x1451e9,_0x9e58('0x96'));})[_0x9e58('0x28')](function(_0x14ffb5){if(_0x14ffb5){logger[_0x9e58('0x39')](_0x9e58('0x87'),_0x14ffb5['id']);logger[_0x9e58('0x39')](_0x9e58('0x97'),_0x9e58('0x88'));emit(util[_0x9e58('0x31')](_0x9e58('0x89'),_0x1a4348[_0x9e58('0x17')]),_0x9e58('0x8a'),{'uri':_0x9e58('0x8b')+_0xfcda87[_0x9e58('0x7e')]+'/crm/EntityInfo.do?module=Calls&id='+_0x14ffb5['id']});}})['catch'](function(_0x3bdfe0){logger[_0x9e58('0x2c')](_0x9e58('0x97'),JSON[_0x9e58('0x3f')](_0x3bdfe0));});};exports[_0x9e58('0x98')]=function(_0x448990,_0x37820f,_0x374e47,_0x211016,_0x5d6854,_0x120326){var _0x4fd224,_0x59e28b,_0x433867;_0x120326[_0x9e58('0x7e')]=intUtil[_0x9e58('0x7f')](_0x120326[_0x9e58('0x7e')]);_0x120326[_0x9e58('0x80')]=intUtil[_0x9e58('0x7f')](_0x120326[_0x9e58('0x80')]);if(_0x5d6854&&_0x5d6854[_0x9e58('0x99')]){logger['info']('['+_0x37820f['lastevent'][_0x9e58('0x9a')]()+']',_0x9e58('0x90'));_0x37820f[_0x9e58('0x81')]=_0x120326[_0x9e58('0x80')]+_0x9e58('0x82')+_0x37820f['uniqueid']+_0x9e58('0x91')+md5(_0x37820f[_0x9e58('0x83')]);}else{_0x37820f['recordingURL']='';}var _0x2012f7=_0x120326[_0x9e58('0x7e')]===_0x9e58('0x84')?'eu':'com';return getAccessToken(_0x120326)['then'](function(_0x54bbb9){_0x433867=_0x54bbb9;return getUser(_0x433867,_0x2012f7,_0x120326);})['then'](function(_0x2914a7){_0x4fd224=_0x2914a7;logger['info'](_0x9e58('0x93'),_0x4fd224['id']);return getEndUser(_0x433867,_0x2012f7,_0x120326,_0x37820f[_0x9e58('0x86')],_0x37820f[_0x9e58('0x9b')],_0x4fd224,_0x374e47);})['then'](function(_0x319475){_0x59e28b=_0x319475;return getCall(_0x433867,_0x2012f7,_0x120326,_0x4fd224,_0x59e28b,_0x374e47,_0x37820f,'Inbound');})[_0x9e58('0x28')](function(_0x320fd0){if(_0x320fd0){logger[_0x9e58('0x39')](_0x9e58('0x87'),_0x320fd0['id']);}})[_0x9e58('0x2b')](function(_0x3b24c9){logger['error']('['+_0x37820f[_0x9e58('0x6a')][_0x9e58('0x9a')]()+']',JSON[_0x9e58('0x3f')](_0x3b24c9));});}; \ No newline at end of file diff --git a/server/services/ami/trigger/script/index.js b/server/services/ami/trigger/script/index.js new file mode 100644 index 0000000..f468ad1 --- /dev/null +++ b/server/services/ami/trigger/script/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xea30=['shelljs','mustache','../../../../config/logger','trigger','exec','data2','Script','render','error','format','%s\x20\x27%s\x27\x20failed\x20with\x20code\x20%d\x20and\x20error:\x20%s','info','%s\x20\x27%s\x27\x20succeeded\x20with\x20output:\x20%s','util'];(function(_0x50c492,_0x5c1e67){var _0x3505a8=function(_0x2f7937){while(--_0x2f7937){_0x50c492['push'](_0x50c492['shift']());}};_0x3505a8(++_0x5c1e67);}(_0xea30,0x125));var _0x0ea3=function(_0x6e26b3,_0x27f8c2){_0x6e26b3=_0x6e26b3-0x0;var _0x3ee399=_0xea30[_0x6e26b3];return _0x3ee399;};'use strict';var util=require(_0x0ea3('0x0'));var sh=require(_0x0ea3('0x1'));var Mustache=require(_0x0ea3('0x2'));var logger=require(_0x0ea3('0x3'))(_0x0ea3('0x4'));exports[_0x0ea3('0x5')]=function(_0x53043a,_0x5ca61c){var _0x440613=_0x53043a['data2']?_0x53043a[_0x0ea3('0x6')]:_0x0ea3('0x7');var _0x210199=_0x53043a['data3']?Mustache[_0x0ea3('0x8')](_0x53043a['data3'],_0x5ca61c):_0x5ca61c;sh[_0x0ea3('0x5')](_0x210199,function(_0x10c756,_0x4bf0ec,_0x4777aa){if(_0x10c756!==0x0){logger[_0x0ea3('0x9')](util[_0x0ea3('0xa')](_0x0ea3('0xb'),_0x440613,_0x210199,_0x10c756,_0x4777aa));}else{logger[_0x0ea3('0xc')](util[_0x0ea3('0xa')](_0x0ea3('0xd'),_0x440613,_0x210199,_0x4bf0ec));}});}; \ No newline at end of file diff --git a/server/services/ami/trigger/urlforward/index.js b/server/services/ami/trigger/urlforward/index.js new file mode 100644 index 0000000..97181ef --- /dev/null +++ b/server/services/ami/trigger/urlforward/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x91e9=['data1','GET','DELETE','PUT','parse','data7','stack','body','%s\x20%s\x20sending\x20request\x20with\x20following\x20options:\x20%s','stringify','then','isNil',',\x20request\x20body:\x20','object','%s\x20%s\x20succeeded\x20with\x20status:\x20%d\x20and\x20response:\x20%s','catch','format','%s\x20%s\x20failed\x20with\x20status:\x20%d\x20and\x20error:\x20%s\x20%s','name','request-promise','util','lodash','trigger','exec','toUpperCase','render','data2','data5','number','headers','data6','error'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x91e9,0x1d3));var _0x991e=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x91e9[_0x2c91e9];return _0x13f0ff;};'use strict';var rp=require(_0x991e('0x0'));var util=require(_0x991e('0x1'));var _=require(_0x991e('0x2'));var Mustache=require('mustache');var logger=require('../../../../config/logger')(_0x991e('0x3'));exports[_0x991e('0x4')]=function(_0x36c70d,_0x80c81d){var _0x398daa,_0xe11452;var _0x2974b8={'method':_0x36c70d['data1'][_0x991e('0x5')](),'uri':Mustache[_0x991e('0x6')](_0x36c70d[_0x991e('0x7')],_0x80c81d),'json':!![],'resolveWithFullResponse':!![],'timeout':typeof parseInt(_0x36c70d[_0x991e('0x8')])===_0x991e('0x9')&&parseInt(_0x36c70d[_0x991e('0x8')])>=0x1&&parseInt(_0x36c70d[_0x991e('0x8')])<=0xa?parseInt(_0x36c70d[_0x991e('0x8')])*0x3e8:0x5*0x3e8};try{_0x2974b8[_0x991e('0xa')]=_0x36c70d[_0x991e('0xb')]?JSON['parse'](Mustache[_0x991e('0x6')](_0x36c70d['data6'],_0x80c81d)):{};}catch(_0x1d1f91){logger[_0x991e('0xc')](_0x1d1f91['stack']);}switch(_0x36c70d[_0x991e('0xd')][_0x991e('0x5')]()){case _0x991e('0xe'):case _0x991e('0xf'):_0x398daa=null;_0x2974b8['qs']=_0x80c81d;break;case'POST':case _0x991e('0x10'):if(_0x36c70d['data7']){try{_0x398daa=JSON[_0x991e('0x11')](Mustache[_0x991e('0x6')](_0x36c70d[_0x991e('0x12')],_0x80c81d));_0x2974b8['body']=_0x398daa;}catch(_0x73bbc9){logger[_0x991e('0xc')](_0x73bbc9[_0x991e('0x13')]);logger[_0x991e('0xc')]('body\x20has\x20been\x20passed\x20to\x20URLforward\x20in\x20a\x20wrong\x20format');}}else{_0x398daa=_0x80c81d;_0x2974b8[_0x991e('0x14')]=_0x398daa;}break;}logger['info'](util['format'](_0x991e('0x15'),_0x36c70d[_0x991e('0xd')],_0x36c70d[_0x991e('0x7')],JSON[_0x991e('0x16')](_0x2974b8)));rp(_0x2974b8)[_0x991e('0x17')](function(_0x1b830a){_0x398daa=!_[_0x991e('0x18')](_0x398daa)?_0x991e('0x19')+_0x398daa:'';_0xe11452=typeof _0x1b830a[_0x991e('0x14')]===_0x991e('0x1a')?JSON[_0x991e('0x16')](_0x1b830a[_0x991e('0x14')]):_0x1b830a[_0x991e('0x14')];logger['info'](util['format'](_0x991e('0x1b'),_0x36c70d[_0x991e('0xd')],_0x36c70d[_0x991e('0x7')],_0x1b830a['statusCode'],_0xe11452));})[_0x991e('0x1c')](function(_0x5e385c){logger[_0x991e('0xc')](util[_0x991e('0x1d')](_0x991e('0x1e'),_0x36c70d[_0x991e('0xd')],_0x36c70d[_0x991e('0x7')],_0x5e385c['statusCode'],_0x5e385c[_0x991e('0x1f')],_0x5e385c['message']));});}; \ No newline at end of file diff --git a/server/services/email/client.js b/server/services/email/client.js new file mode 100644 index 0000000..e94f808 --- /dev/null +++ b/server/services/email/client.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x83bd=['exports','jayson/promise','routing','request','then','error','rpc','message','result','catch'];(function(_0x5c41be,_0x18918a){var _0x3dabbe=function(_0x3a4985){while(--_0x3a4985){_0x5c41be['push'](_0x5c41be['shift']());}};_0x3dabbe(++_0x18918a);}(_0x83bd,0xd3));var _0xd83b=function(_0x2459fd,_0x575d9b){_0x2459fd=_0x2459fd-0x0;var _0x364cd2=_0x83bd[_0x2459fd];return _0x364cd2;};'use strict';var jayson=require(_0xd83b('0x0'));var BPromise=require('bluebird');var logger=require('../../config/logger')(_0xd83b('0x1'));var client=jayson['client']['http']({'port':0x2329});client['Request']=function(_0x474eb6,_0x4d65a4){return new BPromise(function(_0x5a995a,_0x10fef1){return client[_0xd83b('0x2')](_0x474eb6,_0x4d65a4)[_0xd83b('0x3')](function(_0x19e18c){logger['debug']('rpc',_0xd83b('0x1'),_0x474eb6,_0x4d65a4,_0x19e18c);if(_0x19e18c[_0xd83b('0x4')]){logger['error'](_0xd83b('0x5'),_0xd83b('0x1'),_0x474eb6,_0x19e18c['error'][_0xd83b('0x6')],_0x4d65a4);return _0x10fef1(_0x19e18c['error'][_0xd83b('0x6')]);}else{return _0x5a995a(_0x19e18c[_0xd83b('0x7')]);}})[_0xd83b('0x8')](function(_0x1d19a6){logger[_0xd83b('0x4')](_0xd83b('0x5'),'routing',_0x474eb6,_0x1d19a6,_0x4d65a4);return _0x10fef1(_0x1d19a6);});});};module[_0xd83b('0x9')]=client; \ No newline at end of file diff --git a/server/services/email/index.js b/server/services/email/index.js new file mode 100644 index 0000000..50f2038 --- /dev/null +++ b/server/services/email/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x49fe=['./lib/email','./rpc/mailAccount','../../config/logger','email','resolve','then','getMailAccounts','initMailAccounts','mailAccounts','listen','getSettings','loginMailFrequency','error','Email\x20service\x20initialization','./server','./realtime'];(function(_0x2157aa,_0x2e5e04){var _0x690e60=function(_0x5142d8){while(--_0x5142d8){_0x2157aa['push'](_0x2157aa['shift']());}};_0x690e60(++_0x2e5e04);}(_0x49fe,0x19e));var _0xe49f=function(_0x35314a,_0x3cca7d){_0x35314a=_0x35314a-0x0;var _0x35ad31=_0x49fe[_0x35314a];return _0x35ad31;};'use strict';var server=require(_0xe49f('0x0'));var Realtime=require(_0xe49f('0x1'));var EmailChannel=require(_0xe49f('0x2'));var mailAccount=require(_0xe49f('0x3'));var setting=require('./rpc/setting');var logger=require(_0xe49f('0x4'))(_0xe49f('0x5'));var realtime=new Realtime();var email=new EmailChannel(realtime);function initRealtime(){return Promise[_0xe49f('0x6')]()[_0xe49f('0x7')](mailAccount[_0xe49f('0x8')]())['then'](realtime[_0xe49f('0x9')]())['then'](function(){email['refresh'](realtime[_0xe49f('0xa')]);return realtime;});}function main(){return server[_0xe49f('0xb')](realtime,email)['then'](function(){return initRealtime();})[_0xe49f('0x7')](function(){return setting[_0xe49f('0xc')]();})[_0xe49f('0x7')](function(_0x45f8ec){return setInterval(initRealtime,_0x45f8ec[_0xe49f('0xd')]*0x3e8);})['catch'](function(_0xf90820){logger[_0xe49f('0xe')](_0xe49f('0xf'),_0xf90820);});}main(); \ No newline at end of file diff --git a/server/services/email/lib/email.js b/server/services/email/lib/email.js new file mode 100644 index 0000000..06e2cfe --- /dev/null +++ b/server/services/email/lib/email.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9d71=['start\x20email\x20channel','mailAccounts','smtp','prototype','emit','name','active','Imap','total','stringify','mailAccount:update','hasOwnProperty','service','provider','custom','imapAccounts','box','handleImapBox','bind','handleImapEmail','end','handleImapEnd','error','handleImapError','isNil','disabled','messageStatus','status','connected','messages','lastName','from','notify','then','Mail\x20accepted\x20from\x20routing','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','sendMail','send','verifySmtp','Smtp','verify','verified','catch','moment','bluebird','md5','ioredis','../../../config/environment','../../../config/logger','email','redis','defaults','localhost','socket.io-emitter','./imap','../rpc/mailAccount','info'];(function(_0x1492bd,_0x1ad636){var _0x317259=function(_0x2b90cc){while(--_0x2b90cc){_0x1492bd['push'](_0x1492bd['shift']());}};_0x317259(++_0x1ad636);}(_0x9d71,0x188));var _0x19d7=function(_0x300d6,_0x5aea3f){_0x300d6=_0x300d6-0x0;var _0x33ab97=_0x9d71[_0x300d6];return _0x33ab97;};'use strict';var _=require('lodash');var moment=require(_0x19d7('0x0'));var BPromise=require(_0x19d7('0x1'));var md5=require(_0x19d7('0x2'));var Redis=require(_0x19d7('0x3'));var config=require(_0x19d7('0x4'));var logger=require(_0x19d7('0x5'))(_0x19d7('0x6'));config[_0x19d7('0x7')]=_[_0x19d7('0x8')](config[_0x19d7('0x7')],{'host':_0x19d7('0x9'),'port':0x18eb});var io=require(_0x19d7('0xa'))(new Redis(config['redis']));var EmailImap=require(_0x19d7('0xb'));var EmailSmtp=require('./smtp');var mailAccount=require(_0x19d7('0xc'));var md5Accounts={};function EmailChannel(_0x448e15){logger[_0x19d7('0xd')](_0x19d7('0xe'));this[_0x19d7('0xf')]=_0x448e15['mailAccounts'];this['imapAccounts']={};this[_0x19d7('0x10')]=new EmailSmtp();}EmailChannel[_0x19d7('0x11')][_0x19d7('0x12')]=function(_0x19902f){var _0x3fe66b=this[_0x19d7('0xf')][_0x19902f];var _0xdd2e49={'id':_0x3fe66b['id'],'name':_0x3fe66b[_0x19d7('0x13')],'key':_0x3fe66b['key'],'active':_0x3fe66b[_0x19d7('0x14')],'Imap':{'status':_0x3fe66b['Imap']['status'],'messageStatus':_0x3fe66b[_0x19d7('0x15')]['messageStatus'],'total':_0x3fe66b[_0x19d7('0x15')][_0x19d7('0x16')]}};if(_['isNil'](md5Accounts[_0x19902f])){md5Accounts[_0x19902f]={};}var _0x467fe1=md5(JSON[_0x19d7('0x17')](_0xdd2e49));if(md5Accounts[_0x19902f][_0x19d7('0x2')]!==_0x467fe1){md5Accounts[_0x19902f][_0x19d7('0x2')]=_0x467fe1;io[_0x19d7('0x12')](_0x19d7('0x18'),_0xdd2e49);}};EmailChannel['prototype']['refresh']=function(_0x1d4e7c){for(var _0x11727d in _0x1d4e7c){if(_0x1d4e7c[_0x19d7('0x19')](_0x11727d)){if(_0x1d4e7c[_0x11727d][_0x19d7('0x15')]&&_0x1d4e7c[_0x11727d][_0x19d7('0x14')]){var _0x54af62=_0x1d4e7c[_0x11727d][_0x19d7('0x15')];if(!_0x54af62[_0x19d7('0x1a')]&&_0x1d4e7c[_0x11727d][_0x19d7('0x1b')]!==_0x19d7('0x1c'))_0x54af62['service']=_0x1d4e7c[_0x11727d][_0x19d7('0x1b')];if(!this[_0x19d7('0x1d')][_0x19d7('0x19')](_0x54af62['id'])){this[_0x19d7('0x1d')][_0x54af62['id']]=new EmailImap(_0x54af62,_0x1d4e7c[_0x11727d][_0x19d7('0x6')]);this['imapAccounts'][_0x54af62['id']]['on'](_0x19d7('0x1e'),this[_0x19d7('0x1f')][_0x19d7('0x20')](this,_0x11727d));this[_0x19d7('0x1d')][_0x54af62['id']]['on'](_0x19d7('0x6'),this[_0x19d7('0x21')][_0x19d7('0x20')](this,_0x11727d));this[_0x19d7('0x1d')][_0x54af62['id']]['on'](_0x19d7('0x22'),this[_0x19d7('0x23')]['bind'](this,_0x11727d));this['imapAccounts'][_0x54af62['id']]['on'](_0x19d7('0x24'),this[_0x19d7('0x25')][_0x19d7('0x20')](this,_0x11727d));}}else{if(_[_0x19d7('0x26')](this[_0x19d7('0xf')][_0x11727d][_0x19d7('0x15')])){this[_0x19d7('0xf')][_0x11727d][_0x19d7('0x15')]={};}this[_0x19d7('0xf')][_0x11727d]['Imap']['status']=_0x19d7('0x27');this[_0x19d7('0xf')][_0x11727d]['Imap'][_0x19d7('0x28')]='';this[_0x19d7('0x12')](_0x11727d);}}}};EmailChannel[_0x19d7('0x11')][_0x19d7('0x1f')]=function(_0x5786d6,_0x41fe9e){if(this[_0x19d7('0xf')][_0x5786d6]){this['mailAccounts'][_0x5786d6][_0x19d7('0x15')][_0x19d7('0x29')]=_0x19d7('0x2a');this[_0x19d7('0xf')][_0x5786d6][_0x19d7('0x15')][_0x19d7('0x28')]=_0x41fe9e['name'];if(_0x41fe9e[_0x19d7('0x2b')]){this[_0x19d7('0xf')][_0x5786d6][_0x19d7('0x15')][_0x19d7('0x16')]=_0x41fe9e[_0x19d7('0x2b')][_0x19d7('0x16')];}return this[_0x19d7('0x12')](_0x5786d6);}};EmailChannel[_0x19d7('0x11')][_0x19d7('0x21')]=function(_0xcfd040,_0x27ab46){logger[_0x19d7('0xd')]('New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s',_0x27ab46['firstName'],_0x27ab46[_0x19d7('0x2c')],_0x27ab46[_0x19d7('0x2d')],_0xcfd040);if(this[_0x19d7('0xf')][_0xcfd040]){return mailAccount[_0x19d7('0x2e')](_0xcfd040,_0x27ab46)[_0x19d7('0x2f')](function(_0x30fc4e){if(_0x30fc4e){logger['info'](_0x19d7('0x30'));}})['catch'](function(_0x93e87a){logger[_0x19d7('0x24')](_0x19d7('0x31'),JSON[_0x19d7('0x17')](_0x93e87a));});}};EmailChannel['prototype']['handleImapEnd']=function(_0x206220){if(this[_0x19d7('0xf')][_0x206220]&&this[_0x19d7('0xf')][_0x206220][_0x19d7('0x15')]){if(this[_0x19d7('0x1d')][this['mailAccounts'][_0x206220][_0x19d7('0x15')]['id']]){delete this[_0x19d7('0x1d')][this[_0x19d7('0xf')][_0x206220]['Imap']['id']];}this[_0x19d7('0xf')][_0x206220][_0x19d7('0x15')][_0x19d7('0x32')]=moment();this[_0x19d7('0x12')](_0x206220);}};EmailChannel[_0x19d7('0x11')]['handleImapError']=function(_0x2ebb2d,_0x52741d){if(this[_0x19d7('0xf')][_0x2ebb2d]){this['mailAccounts'][_0x2ebb2d]['Imap']['status']=_0x19d7('0x24');this[_0x19d7('0xf')][_0x2ebb2d]['Imap']['messageStatus']=_0x52741d;return this[_0x19d7('0x12')](_0x2ebb2d);}};EmailChannel[_0x19d7('0x11')][_0x19d7('0x33')]=function(_0x1357cf,_0x303a5e){return this[_0x19d7('0x10')][_0x19d7('0x34')](_0x1357cf,_0x303a5e);};EmailChannel[_0x19d7('0x11')][_0x19d7('0x35')]=function(_0x5b60a2){var _0x26d712=this;if(this['mailAccounts'][_0x5b60a2['id']]){if(_[_0x19d7('0x26')](this[_0x19d7('0xf')][_0x5b60a2['id']][_0x19d7('0x36')])){this[_0x19d7('0xf')][_0x5b60a2['id']]['Smtp']={};}this[_0x19d7('0xf')][_0x5b60a2['id']][_0x19d7('0x36')]['lastSync']=moment();return new BPromise(function(_0x3f5956,_0x230c99){return _0x26d712[_0x19d7('0x10')][_0x19d7('0x37')](_0x5b60a2)[_0x19d7('0x2f')](function(_0x2faa84){_0x26d712[_0x19d7('0xf')][_0x5b60a2['id']][_0x19d7('0x36')][_0x19d7('0x29')]=_0x19d7('0x38');_0x26d712['mailAccounts'][_0x5b60a2['id']]['Smtp']['messageStatus']='';_0x26d712[_0x19d7('0x12')](_0x5b60a2['id']);_0x3f5956(_0x2faa84);})[_0x19d7('0x39')](function(_0x102f8a){_0x26d712[_0x19d7('0xf')][_0x5b60a2['id']]['Smtp'][_0x19d7('0x29')]=_0x19d7('0x24');_0x26d712['mailAccounts'][_0x5b60a2['id']][_0x19d7('0x36')][_0x19d7('0x28')]=_0x102f8a;_0x26d712['emit'](_0x5b60a2['id']);_0x230c99(_0x102f8a);});});}return this[_0x19d7('0x10')][_0x19d7('0x37')](_0x5b60a2);};module['exports']=EmailChannel; \ No newline at end of file diff --git a/server/services/email/lib/imap.js b/server/services/email/lib/imap.js new file mode 100644 index 0000000..18b6214 --- /dev/null +++ b/server/services/email/lib/imap.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5d51=['password','authentication','email','anonymous@xcally.com','host','port','tls','autotls','required','prototype','openBox','handleOpenBox','emit','box','readUnseen','handleCloseBox','search','UNSEEN','handleReadUnseen','fetch','message','error','handleFetchError','end','handleFetchEnd','handleFetchMessage','body','attributes','handleMessageAttributes','handleSimpleParser','handleMessageEnd','parser','handleEnd','stringify','textCode','upperFirst','lodash','util','imap','iconv','Iconv','events','EventEmitter','mailbox','account','once','ready','handleReady','bind','handleError','connTimeout','authTimeout','service','user','modernAuthentication','xoauth2','generateXOAuth2Token','CloudProvider'];(function(_0x3f2397,_0x154b0b){var _0x3d4ed5=function(_0x5ef9db){while(--_0x5ef9db){_0x3f2397['push'](_0x3f2397['shift']());}};_0x3d4ed5(++_0x154b0b);}(_0x5d51,0x146));var _0x15d5=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x5d51[_0x6c993a];return _0x27f547;};'use strict';var _=require(_0x15d5('0x0'));var util=require(_0x15d5('0x1'));var Imap=require(_0x15d5('0x2'));var simpleParser=require('mailparser')['simpleParser'];var Iconv=require(_0x15d5('0x3'))[_0x15d5('0x4')];var EventEmitter=require(_0x15d5('0x5'))[_0x15d5('0x6')];var utils=require('./utils');var logger=require('../../../config/logger')('email');function EmailImap(_0x23ca41,_0x4e13d7){this[_0x15d5('0x7')]=_0x23ca41['mailbox'];this[_0x15d5('0x8')]=this['getAccount'](_0x23ca41,_0x4e13d7);this[_0x15d5('0x2')]=new Imap(this[_0x15d5('0x8')]);this[_0x15d5('0x2')][_0x15d5('0x9')](_0x15d5('0xa'),this[_0x15d5('0xb')][_0x15d5('0xc')](this));this['imap'][_0x15d5('0x9')]('end',this['handleEnd'][_0x15d5('0xc')](this));this[_0x15d5('0x2')]['on']('error',this[_0x15d5('0xd')][_0x15d5('0xc')](this));this[_0x15d5('0x2')]['connect']();}util['inherits'](EmailImap,EventEmitter);EmailImap['prototype']['getAccount']=function(_0x3f5caa,_0x42dcff){var _0x11c8c2={'connTimeout':_0x3f5caa['connTimeout']?_0x3f5caa[_0x15d5('0xe')]*0x3e8:0x2710,'authTimeout':_0x3f5caa[_0x15d5('0xf')]?_0x3f5caa[_0x15d5('0xf')]*0x3e8:0x1388};if(_0x3f5caa[_0x15d5('0x10')]){_0x11c8c2[_0x15d5('0x11')]=_0x3f5caa['user'];if(_0x3f5caa[_0x15d5('0x12')]){_0x11c8c2[_0x15d5('0x13')]=utils[_0x15d5('0x14')](_0x3f5caa[_0x15d5('0x15')]['data5'],_0x3f5caa[_0x15d5('0x11')]);}else{_0x11c8c2[_0x15d5('0x16')]=_0x3f5caa[_0x15d5('0x16')];}}else{if(_0x3f5caa[_0x15d5('0x17')]){_0x11c8c2['user']=_0x3f5caa[_0x15d5('0x11')];_0x11c8c2[_0x15d5('0x16')]=_0x3f5caa[_0x15d5('0x16')];}}_0x11c8c2[_0x15d5('0x18')]=_0x42dcff||_0x3f5caa['user']||_0x15d5('0x19');_0x11c8c2[_0x15d5('0x1a')]=_0x3f5caa[_0x15d5('0x1a')];_0x11c8c2[_0x15d5('0x1b')]=_0x3f5caa[_0x15d5('0x1b')]||0x3e1;if(_0x3f5caa[_0x15d5('0x1c')]){_0x11c8c2[_0x15d5('0x1c')]=!![];}else{_0x11c8c2[_0x15d5('0x1c')]=![];_0x11c8c2[_0x15d5('0x1d')]=_0x15d5('0x1e');}return _0x11c8c2;};EmailImap[_0x15d5('0x1f')][_0x15d5('0xb')]=function(){this[_0x15d5('0x2')][_0x15d5('0x20')](this[_0x15d5('0x7')],![],this[_0x15d5('0x21')][_0x15d5('0xc')](this));};EmailImap[_0x15d5('0x1f')]['handleOpenBox']=function(_0x4eef0a,_0x27999b){if(_0x4eef0a){this[_0x15d5('0xd')](_0x4eef0a,!![]);}else{this[_0x15d5('0x22')](_0x15d5('0x23'),_0x27999b);this[_0x15d5('0x24')]();}};EmailImap[_0x15d5('0x1f')][_0x15d5('0x25')]=function(_0x3eb256){if(_0x3eb256){this['handleError'](_0x3eb256,!![]);}else{this[_0x15d5('0x2')]['end']();}};EmailImap[_0x15d5('0x1f')][_0x15d5('0x24')]=function(){this[_0x15d5('0x2')][_0x15d5('0x26')]([_0x15d5('0x27')],this[_0x15d5('0x28')][_0x15d5('0xc')](this));};EmailImap[_0x15d5('0x1f')][_0x15d5('0x28')]=function(_0x5ce2e6,_0x2b7325){if(_0x5ce2e6){this[_0x15d5('0xd')](_0x5ce2e6,!![]);}else{if(_0x2b7325['length']){try{var _0x1aa23d=this[_0x15d5('0x2')][_0x15d5('0x29')](_0x2b7325,{'bodies':'','markSeen':!![]});_0x1aa23d['on'](_0x15d5('0x2a'),this['handleFetchMessage'][_0x15d5('0xc')](this));_0x1aa23d[_0x15d5('0x9')](_0x15d5('0x2b'),this[_0x15d5('0x2c')]['bind'](this));_0x1aa23d['once'](_0x15d5('0x2d'),this[_0x15d5('0x2e')][_0x15d5('0xc')](this));}catch(_0x160286){logger[_0x15d5('0x2b')](_0x160286);}}else{this[_0x15d5('0x2')]['closeBox'](!![],this[_0x15d5('0x25')][_0x15d5('0xc')](this));}}};EmailImap['prototype'][_0x15d5('0x2f')]=function(_0x4dc279){_0x4dc279['on'](_0x15d5('0x30'),this['handleMessageBody'][_0x15d5('0xc')](this));_0x4dc279[_0x15d5('0x9')](_0x15d5('0x31'),this[_0x15d5('0x32')]['bind'](this));_0x4dc279['once']('end',this['handleMessageEnd'][_0x15d5('0xc')](this));};EmailImap[_0x15d5('0x1f')]['handleMessageBody']=function(_0xc0bb6){simpleParser(_0xc0bb6,{'Iconv':Iconv},this[_0x15d5('0x33')][_0x15d5('0xc')](this));};EmailImap[_0x15d5('0x1f')]['handleMessageAttributes']=function(){};EmailImap[_0x15d5('0x1f')][_0x15d5('0x34')]=function(){};EmailImap[_0x15d5('0x1f')][_0x15d5('0x33')]=function(_0x13c40d,_0x34f7e6){if(_0x13c40d){logger[_0x15d5('0x2b')](_0x13c40d);}else{var _0x43f0b4=this;utils[_0x15d5('0x35')](this[_0x15d5('0x8')],_0x34f7e6,function(_0x3e8113){_0x43f0b4[_0x15d5('0x22')](_0x15d5('0x18'),_0x3e8113);});}};EmailImap['prototype'][_0x15d5('0x2e')]=function(){this[_0x15d5('0x2')]['closeBox'](!![],this[_0x15d5('0x25')]['bind'](this));};EmailImap['prototype'][_0x15d5('0x2c')]=function(_0x590c0b){this['handleError'](_0x590c0b);this['imap']['closeBox'](!![],this['handleCloseBox'][_0x15d5('0xc')](this));};EmailImap[_0x15d5('0x1f')][_0x15d5('0x36')]=function(){this[_0x15d5('0x22')](_0x15d5('0x2d'));};EmailImap[_0x15d5('0x1f')]['handleError']=function(_0x5a44b9,_0x3f2234){logger[_0x15d5('0x2b')]('handleError',this[_0x15d5('0x8')][_0x15d5('0x18')],JSON[_0x15d5('0x37')](_0x5a44b9));var _0x2e5a8b='';if(_0x5a44b9){if(_0x5a44b9[_0x15d5('0x38')]){_0x2e5a8b=_0x5a44b9['textCode'];}else{for(var _0x5b8796 in _0x5a44b9){if(_0x5a44b9['hasOwnProperty'](_0x5b8796)){_0x2e5a8b+=_[_0x15d5('0x39')](_0x5b8796)+':\x20'+_0x5a44b9[_0x5b8796]+'\x0a';}}}}if(_0x3f2234){this[_0x15d5('0x2')][_0x15d5('0x2d')]();}else{this[_0x15d5('0x22')]('error',_0x2e5a8b);this['emit'](_0x15d5('0x2d'));}};module['exports']=EmailImap; \ No newline at end of file diff --git a/server/services/email/lib/smtp.js b/server/services/email/lib/smtp.js new file mode 100644 index 0000000..a019a98 --- /dev/null +++ b/server/services/email/lib/smtp.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0eaa=['verify','Not\x20verifired','exports','nodemailer-plugin-inline-base64','prototype','send','createTransport','sendMail','toString'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x0eaa,0x1a1));var _0xa0ea=function(_0x2a3922,_0x225dd2){_0x2a3922=_0x2a3922-0x0;var _0x3ccc8c=_0x0eaa[_0x2a3922];return _0x3ccc8c;};'use strict';var nodemailer=require('nodemailer');var inlineBase64=require(_0xa0ea('0x0'));function EmailSmtp(){}EmailSmtp[_0xa0ea('0x1')][_0xa0ea('0x2')]=function(_0x407aa2,_0x4ebb0b){return new Promise(function(_0x399aec,_0x4968b1){var _0x5da29e=nodemailer[_0xa0ea('0x3')](_0x407aa2);_0x5da29e['use']('compile',inlineBase64());_0x5da29e[_0xa0ea('0x4')](_0x4ebb0b,function(_0x571be7,_0x15f1d3){if(_0x571be7){_0x4968b1(_0x571be7[_0xa0ea('0x5')]());}else{_0x399aec(_0x15f1d3);}});});};EmailSmtp[_0xa0ea('0x1')][_0xa0ea('0x6')]=function(_0x3ca47a){return new Promise(function(_0x5f0783,_0x547e93){var _0x1f52b5=nodemailer[_0xa0ea('0x3')](_0x3ca47a);_0x1f52b5[_0xa0ea('0x6')](function(_0xcc02d9,_0x5493e8){if(_0xcc02d9){_0x547e93(_0xcc02d9[_0xa0ea('0x5')]());}else{if(_0x5493e8){_0x5f0783(_0x5493e8);}else{_0x547e93(_0xa0ea('0x7'));}}});});};module[_0xa0ea('0x8')]=EmailSmtp; \ No newline at end of file diff --git a/server/services/email/lib/utils.js b/server/services/email/lib/utils.js new file mode 100644 index 0000000..c11480c --- /dev/null +++ b/server/services/email/lib/utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9834=['push','filename','_SRC','_IMG','\x20[Attachment:\x20','\x20]','body','Empty\x20message

','Attachments','Title','Data','generateXOAuth2Token','auth=Bearer\x20','toString','base64','lodash','moment','randomstring','path','util','node-tnef','email','head','value','address','anonymous','generate','name','substring','indexOf','length','Anonymous','split','pop','isEmpty','@xcally.com','html','test','replace','includes','0x1?_0x4dc239['slice'](0x0,-0x1)['join']('\x20'):_0x46dc61[_0x4983('0xc')];}return _0x4983('0x10');}function getLastName(_0x3b0808){var _0x5dbaa8=_[_0x4983('0x7')](_0x3b0808['value']);if(_0x5dbaa8&&_0x5dbaa8[_0x4983('0xc')]){var _0x31b538=_0x5dbaa8[_0x4983('0xc')][_0x4983('0x11')](/\s+/);return _0x31b538[_0x4983('0xf')]>0x1?_0x31b538[_0x4983('0x12')]():'';}return'';}function getMails(_0xceb729,_0x3c7ff3){var _0xea94fd='';for(var _0x413769=0x0;_0x413769<_0x3c7ff3[_0x4983('0x8')][_0x4983('0xf')];_0x413769+=0x1){if(_0x3c7ff3['value'][_0x413769][_0x4983('0x9')]!==_0xceb729){if(!_[_0x4983('0x13')](_0xea94fd)){_0xea94fd+=',';}_0xea94fd+=_0x3c7ff3[_0x4983('0x8')][_0x413769][_0x4983('0xc')]||_0x3c7ff3['value'][_0x413769]['address']||'';_0xea94fd+='\x20<';_0xea94fd+=_0x3c7ff3[_0x4983('0x8')][_0x413769][_0x4983('0x9')]?_0x3c7ff3[_0x4983('0x8')][_0x413769][_0x4983('0x9')]:_0x4983('0xa')+random[_0x4983('0xb')](0x6)+_0x4983('0x14');_0xea94fd+='>';}}return _0xea94fd;}function parseEmail(_0x176db8,_0x3f39d5,_0x68448b){if(_0x3f39d5[_0x4983('0x15')]){var _0x50b4ee=/)<[^<]*)*<\/script>/gi;while(_0x50b4ee[_0x4983('0x16')](_0x3f39d5[_0x4983('0x15')])){_0x3f39d5[_0x4983('0x15')]=_0x3f39d5[_0x4983('0x15')][_0x4983('0x17')](_0x50b4ee,'');}if(_0x3f39d5[_0x4983('0x15')][_0x4983('0x18')](_0x4983('0x19'))){var _0x1d21a4=[];_0x3f39d5[_0x4983('0x1a')][_0x4983('0x1b')](_0x356d9b=>{_0x1d21a4[_0x4983('0x1c')](_0x356d9b[_0x4983('0x1d')]);});var _0x4e1b85=/]+>/g;var _0x22ac15=/src="data:image\/([a-zA-Z]*);base64,([^"]*)"/g;var _0x44871=_0x3f39d5[_0x4983('0x15')][_0x4983('0x17')](_0x22ac15,_0x4983('0x1e'));var _0xb5fa6b=_0x44871[_0x4983('0x17')](_0x4e1b85,_0x4983('0x1f'));for(let _0x31337d=0x0;_0x31337d<_0x1d21a4[_0x4983('0xf')];_0x31337d++){var _0x4dd94c=_0xb5fa6b[_0x4983('0x17')](_0x4983('0x1f'),_0x4983('0x20')+_0x1d21a4[_0x31337d]+_0x4983('0x21'));_0xb5fa6b=_0x4dd94c;}_0x3f39d5[_0x4983('0x15')]=_0xb5fa6b;}_0x68448b[_0x4983('0x22')]=_0x3f39d5[_0x4983('0x15')];}else{_0x68448b[_0x4983('0x22')]=_0x3f39d5['textAsHtml'];}if(_0x68448b[_0x4983('0x22')]){_0x68448b['body']=_0x68448b['body'][_0x4983('0x17')](/0x0){var _0x268ade=[_0x4983('0x33'),_0x4983('0x34'),_0x4983('0x35')];for(var _0x55efbb=0x0;_0x55efbb<_0x3f39d5[_0x4983('0x32')][_0x4983('0xf')];_0x55efbb++){var _0x25e185=_[_0x4983('0xe')](_0x268ade,_0x3f39d5['headerLines'][_0x55efbb][_0x4983('0x36')]);if(_0x25e185>=0x0){_0x68448b['isAutoreply']=!![];}}}return _0x68448b;}exports['parser']=function(_0x5c5435,_0x43c53c,_0x38dd0e){var _0x121409={'from':getAddress(_0x43c53c[_0x4983('0x37')]),'firstName':getFirstName(_0x43c53c[_0x4983('0x37')]),'lastName':getLastName(_0x43c53c[_0x4983('0x37')]),'mapKey':_0x4983('0x6'),'message':{'from':getMails(_0x5c5435[_0x4983('0x6')],_0x43c53c[_0x4983('0x37')]),'to':_0x5c5435['email'],'cc':'','subject':_0x43c53c[_0x4983('0x38')]||'','messageId':_0x43c53c[_0x4983('0x39')],'inReplyTo':_0x43c53c[_0x4983('0x3a')],'sentAt':moment(_0x43c53c[_0x4983('0x3b')])['format'](_0x4983('0x3c')),'attach':![],'attachments':[]}};if(!_0x43c53c[_0x4983('0x15')]&&!_0x43c53c[_0x4983('0x3d')]){var _0x4797ef=_[_0x4983('0x3e')](_0x43c53c['attachments'],{'contentType':_0x4983('0x3f')});if(_0x4797ef['length']){logger[_0x4983('0x40')](util[_0x4983('0x2c')](_0x4983('0x41'),_0x43c53c[_0x4983('0x39')]));tnef[_0x4983('0x42')](_[_0x4983('0x43')](_0x4797ef)[_0x4983('0x44')],function(_0x2661e8,_0x3f23ff){if(_0x3f23ff){_0x43c53c[_0x4983('0x15')]=_0x3f23ff[_0x4983('0x45')]||_0x4983('0x46');if(_0x3f23ff[_0x4983('0x47')]){for(var _0x14dc01=0x0;_0x14dc01<_0x3f23ff[_0x4983('0x47')][_0x4983('0xf')];_0x14dc01++){var _0x2432e0=_0x3f23ff['Attachments'][_0x14dc01];_0x121409[_0x4983('0x24')]['attachments']['push']({'filename':_0x2432e0[_0x4983('0x48')],'content':Buffer['from'](_0x2432e0[_0x4983('0x49')])});}}}_0x38dd0e(parseEmail(_0x5c5435,_0x43c53c,_0x121409));});}else{_0x43c53c[_0x4983('0x15')]=_0x4983('0x46');_0x38dd0e(parseEmail(_0x5c5435,_0x43c53c,_0x121409));}}else{_0x38dd0e(parseEmail(_0x5c5435,_0x43c53c,_0x121409));}};exports[_0x4983('0x4a')]=function(_0x4ad82c,_0x1f5e96){var _0x34e8ee=['user='+(_0x1f5e96||''),_0x4983('0x4b')+_0x4ad82c,'',''];return Buffer[_0x4983('0x37')](_0x34e8ee[_0x4983('0x2e')](''),'utf-8')[_0x4983('0x4c')](_0x4983('0x4d'));}; \ No newline at end of file diff --git a/server/services/email/model/mailAccount.js b/server/services/email/model/mailAccount.js new file mode 100644 index 0000000..fdcbf41 --- /dev/null +++ b/server/services/email/model/mailAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8a3d=['Service','key','SERV','active','Imap','Smtp','lodash','name'];(function(_0x588b89,_0x189acc){var _0x5d7e5e=function(_0x12aa9c){while(--_0x12aa9c){_0x588b89['push'](_0x588b89['shift']());}};_0x5d7e5e(++_0x189acc);}(_0x8a3d,0xb6));var _0xd8a3=function(_0x3d12c0,_0x4fa80f){_0x3d12c0=_0x3d12c0-0x0;var _0x283f59=_0x8a3d[_0x3d12c0];return _0x283f59;};'use strict';var _=require(_0xd8a3('0x0'));function MailAccount(_0x7b9e25){this['id']=_0x7b9e25['id']||0x0;this[_0xd8a3('0x1')]=_0x7b9e25[_0xd8a3('0x1')]||_0xd8a3('0x2');this[_0xd8a3('0x3')]=_0x7b9e25['key']||_0xd8a3('0x4');this[_0xd8a3('0x5')]=_0x7b9e25[_0xd8a3('0x5')]||![];this['Imap']=_0x7b9e25[_0xd8a3('0x6')]||[];this[_0xd8a3('0x7')]=_0x7b9e25[_0xd8a3('0x7')]||[];}module['exports']=MailAccount; \ No newline at end of file diff --git a/server/services/email/realtime/index.js b/server/services/email/realtime/index.js new file mode 100644 index 0000000..7008fbe --- /dev/null +++ b/server/services/email/realtime/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa848=['merge','exports','lodash','../model/mailAccount','mailAccounts','mapKeys','hasOwnProperty','prototype','mergeFromDatabase','length','isUndefined'];(function(_0x34db7f,_0x3e22f8){var _0x509554=function(_0x112764){while(--_0x112764){_0x34db7f['push'](_0x34db7f['shift']());}};_0x509554(++_0x3e22f8);}(_0xa848,0x120));var _0x8a84=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0xa848[_0x167cc1];return _0x10bc4b;};'use strict';var _=require(_0x8a84('0x0'));var MailAccount=require(_0x8a84('0x1'));var Realtime=function(){this[_0x8a84('0x2')]={};};function freeIsNotKey(_0x1f8f06,_0x1a7666,_0x59efac){var _0x5e2525=_[_0x8a84('0x3')](_0x1f8f06,function(_0x4b97df,_0x447e18){return _0x4b97df[_0x59efac];});for(var _0x42dde4 in _0x1a7666){if(_0x1a7666[_0x8a84('0x4')](_0x42dde4)){if(!_0x5e2525[_0x42dde4]){delete _0x1a7666[_0x42dde4];}}}}Realtime[_0x8a84('0x5')][_0x8a84('0x6')]=function(_0x375e6c,_0x684c4){for(var _0x167558 in _0x684c4){if(_0x375e6c['hasOwnProperty'](_0x167558)){_0x375e6c[_0x167558]=_0x684c4[_0x167558];}}};Realtime[_0x8a84('0x5')]['initMailAccounts']=function(){var _0x46eb36=this;return function(_0x4b6b64){if(_0x4b6b64){freeIsNotKey(_0x4b6b64,_0x46eb36[_0x8a84('0x2')],'id');for(var _0x5054b8=0x0,_0x5e6944={},_0x4be4c8={};_0x5054b8<_0x4b6b64[_0x8a84('0x7')];_0x5054b8+=0x1){_0x5e6944=_0x4b6b64[_0x5054b8];if(_[_0x8a84('0x8')](_0x46eb36[_0x8a84('0x2')][_0x5e6944['id']])){_0x46eb36[_0x8a84('0x2')][_0x5e6944['id']]=new MailAccount(_0x5e6944);}else{_[_0x8a84('0x9')](_0x46eb36[_0x8a84('0x2')][_0x5e6944['id']],_0x5e6944);}}}return _0x46eb36[_0x8a84('0x2')];};};module[_0x8a84('0xa')]=Realtime; \ No newline at end of file diff --git a/server/services/email/rpc/mailAccount.js b/server/services/email/rpc/mailAccount.js new file mode 100644 index 0000000..8fc0ce6 --- /dev/null +++ b/server/services/email/rpc/mailAccount.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8fcd=['NotifyMailAccount','../client','getMailAccounts','Request','GetMailAccount','name','email','active','key','ListId','TemplateId','MailServerIn','type','data5','CloudProvider','MailServerOut'];(function(_0x328bd3,_0x9cf5a5){var _0x458149=function(_0x3f60d9){while(--_0x3f60d9){_0x328bd3['push'](_0x328bd3['shift']());}};_0x458149(++_0x9cf5a5);}(_0x8fcd,0xa1));var _0xd8fc=function(_0x3406ad,_0x1100c2){_0x3406ad=_0x3406ad-0x0;var _0x52e70=_0x8fcd[_0x3406ad];return _0x52e70;};'use strict';var client=require(_0xd8fc('0x0'));exports[_0xd8fc('0x1')]=function(){return function(){return client[_0xd8fc('0x2')](_0xd8fc('0x3'),{'options':{'attributes':['id',_0xd8fc('0x4'),'provider','service',_0xd8fc('0x5'),_0xd8fc('0x6'),_0xd8fc('0x7'),_0xd8fc('0x8'),_0xd8fc('0x9')],'raw':![],'include':[{'model':_0xd8fc('0xa'),'as':'Imap','include':[{'model':'CloudProvider','attributes':['id',_0xd8fc('0x4'),'service',_0xd8fc('0xb'),_0xd8fc('0xc')],'as':_0xd8fc('0xd')}]},{'model':_0xd8fc('0xe'),'as':'Smtp','include':[{'model':'CloudProvider','attributes':['id',_0xd8fc('0x4'),'service','type',_0xd8fc('0xc')],'as':_0xd8fc('0xd')}]}]},'log':'getMailAccount'});};};exports['notify']=function(_0x1c119d,_0x7023f2){return client['Request'](_0xd8fc('0xf'),{'account':{'id':_0x1c119d},'body':_0x7023f2,'log':_0xd8fc('0xf')});}; \ No newline at end of file diff --git a/server/services/email/rpc/setting.js b/server/services/email/rpc/setting.js new file mode 100644 index 0000000..6145916 --- /dev/null +++ b/server/services/email/rpc/setting.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1594=['../client','getSettings','Request','ShowSetting','loginMailFrequency','GetSettings'];(function(_0x28f4ee,_0x1ff74e){var _0x5b52d7=function(_0x35edf3){while(--_0x35edf3){_0x28f4ee['push'](_0x28f4ee['shift']());}};_0x5b52d7(++_0x1ff74e);}(_0x1594,0x1a4));var _0x4159=function(_0x16a4a8,_0x38799c){_0x16a4a8=_0x16a4a8-0x0;var _0x2c5290=_0x1594[_0x16a4a8];return _0x2c5290;};'use strict';var client=require(_0x4159('0x0'));exports[_0x4159('0x1')]=function(){return client[_0x4159('0x2')](_0x4159('0x3'),{'options':{'raw':!![],'where':{'id':0x1},'attributes':[_0x4159('0x4')]},'log':_0x4159('0x5')});}; \ No newline at end of file diff --git a/server/services/email/server/index.js b/server/services/email/server/index.js new file mode 100644 index 0000000..e601b99 --- /dev/null +++ b/server/services/email/server/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['catch','values','mailAccounts','length','Imap','password','Smtp','pass','server','http','stringify','127.0.0.1','log','Email\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','jayson/promise','bluebird','lodash','listen','sendMail','then','error','Verified'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0xa9e0,0x123));var _0x0a9e=function(_0x484e36,_0x4482d8){_0x484e36=_0x484e36-0x0;var _0xafc85d=_0xa9e0[_0x484e36];return _0xafc85d;};'use strict';var jayson=require(_0x0a9e('0x0'));var BPromise=require(_0x0a9e('0x1'));var _=require(_0x0a9e('0x2'));var logger=require('../../../config/logger')('email');exports[_0x0a9e('0x3')]=function(_0x4ce2f1,_0x333808){return new BPromise(function(_0x432180,_0x2ab90b){var _0x991246={'SendMail':function(_0x981158){var _0x57b080=this;return new Promise(function(_0x219af0,_0x441e3a){_0x333808[_0x0a9e('0x4')](_0x981158['account'],_0x981158['message'])[_0x0a9e('0x5')](function(_0x56465b){_0x219af0({'code':0xc8,'message':_0x56465b});})['catch'](function(_0x39753a){_0x441e3a(_0x57b080[_0x0a9e('0x6')](0x1f4,_0x39753a));});});},'VerifySmtp':function(_0x307b3e){var _0x3ab53f=this;return new Promise(function(_0xfeb75b,_0xbd1168){_0x333808['verifySmtp'](_0x307b3e['account'])['then'](function(_0x4cfe67){_0xfeb75b({'code':0xc8,'message':_0x0a9e('0x7')});})[_0x0a9e('0x8')](function(_0xd5b662){_0xbd1168(_0x3ab53f[_0x0a9e('0x6')](0x1f4,_0xd5b662));});});},'MailAccounts':function(_0x32d742){return new Promise(function(_0x69aeb7,_0x5db4b0){var _0x4283ce=_[_0x0a9e('0x9')](_0x4ce2f1[_0x0a9e('0xa')]);for(var _0x281129=0x0;_0x281129<_0x4283ce[_0x0a9e('0xb')];_0x281129+=0x1){if(_0x4283ce[_0x281129][_0x0a9e('0xc')]&&_0x4283ce[_0x281129]['Imap'][_0x0a9e('0xd')]){delete _0x4283ce[_0x281129]['Imap'][_0x0a9e('0xd')];}if(_0x4283ce[_0x281129]['Smtp']&&_0x4283ce[_0x281129][_0x0a9e('0xe')][_0x0a9e('0xf')]){delete _0x4283ce[_0x281129]['Smtp'][_0x0a9e('0xf')];}}_0x69aeb7({'count':_0x4283ce['length'],'rows':_0x4283ce});});}};var _0x459eb1=jayson[_0x0a9e('0x10')](_0x991246)[_0x0a9e('0x11')]();_0x459eb1['on'](_0x0a9e('0x6'),function(_0x31b1ca){logger[_0x0a9e('0x6')](JSON[_0x0a9e('0x12')](_0x31b1ca));return _0x2ab90b(_0x31b1ca);});_0x459eb1[_0x0a9e('0x3')](0x232b,_0x0a9e('0x13'),function(){console[_0x0a9e('0x14')](_0x0a9e('0x15'),0x232b);return _0x432180(_0x0a9e('0x16')+0x232b);});});}; \ No newline at end of file diff --git a/server/services/express/index.js b/server/services/express/index.js new file mode 100644 index 0000000..bf81200 --- /dev/null +++ b/server/services/express/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe986=['sticky-session','ioredis','createServer','timeout','listen','port','socket.io','polling','redis','localhost','adapter','socket.io-redis','../../config/socketio','../../config/express','default','../../routes','once','listening','log','Express\x20server\x20listening\x20on\x20port\x20%d!','exports','express'];(function(_0x105045,_0x2e471e){var _0x2487d0=function(_0x243428){while(--_0x243428){_0x105045['push'](_0x105045['shift']());}};_0x2487d0(++_0x2e471e);}(_0xe986,0x1b7));var _0x6e98=function(_0xdd96c3,_0x5e61c7){_0xdd96c3=_0xdd96c3-0x0;var _0x1f52ae=_0xe986[_0xdd96c3];return _0x1f52ae;};'use strict';var _=require('lodash');var http=require('http');var express=require(_0x6e98('0x0'));var sticky=require(_0x6e98('0x1'));var Redis=require(_0x6e98('0x2'));var config=require('../../config/environment');var app=express();var server=http[_0x6e98('0x3')](app);server[_0x6e98('0x4')]=0xdbba0;if(sticky[_0x6e98('0x5')](server,config[_0x6e98('0x6')])){var socketio=require(_0x6e98('0x7'))(server,{'transports':['websocket',_0x6e98('0x8')]});config['redis']=_['defaults'](config[_0x6e98('0x9')],{'host':_0x6e98('0xa'),'port':0x18eb});socketio[_0x6e98('0xb')](require(_0x6e98('0xc'))({'pubClient':new Redis(config[_0x6e98('0x9')]),'subClient':new Redis(config[_0x6e98('0x9')])}));require('../../config/triggers')['default']();require(_0x6e98('0xd'))['default'](socketio);require(_0x6e98('0xe'))[_0x6e98('0xf')](app);require(_0x6e98('0x10'))['default'](app);}else{server[_0x6e98('0x11')](_0x6e98('0x12'),function(){console[_0x6e98('0x13')](_0x6e98('0x14'),config[_0x6e98('0x6')]);});}exports=module[_0x6e98('0x15')]=app; \ No newline at end of file diff --git a/server/services/routing/client.js b/server/services/routing/client.js new file mode 100644 index 0000000..cc8d813 --- /dev/null +++ b/server/services/routing/client.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5ad5=['http','Request','then','debug','rpc','error','message','exports','../../config/logger','routing','client'];(function(_0x3dfa3e,_0x293558){var _0x3ff9ed=function(_0x400e9b){while(--_0x400e9b){_0x3dfa3e['push'](_0x3dfa3e['shift']());}};_0x3ff9ed(++_0x293558);}(_0x5ad5,0x11b));var _0x55ad=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0x5ad5[_0x5b644e];return _0x49c6bf;};'use strict';var jayson=require('jayson/promise');var BPromise=require('bluebird');var logger=require(_0x55ad('0x0'))(_0x55ad('0x1'));var client=jayson[_0x55ad('0x2')][_0x55ad('0x3')]({'port':0x2329});client[_0x55ad('0x4')]=function(_0x2f5620,_0x4fd6c9){return new BPromise(function(_0x5ba9f9,_0x69e883){return client['request'](_0x2f5620,_0x4fd6c9)[_0x55ad('0x5')](function(_0x3ef7ab){logger[_0x55ad('0x6')](_0x55ad('0x7'),_0x55ad('0x1'),_0x2f5620,_0x4fd6c9,_0x3ef7ab);if(_0x3ef7ab[_0x55ad('0x8')]){logger[_0x55ad('0x8')](_0x55ad('0x7'),'routing',_0x2f5620,_0x3ef7ab[_0x55ad('0x8')][_0x55ad('0x9')],_0x4fd6c9);return _0x69e883(_0x3ef7ab[_0x55ad('0x8')]['message']);}else{return _0x5ba9f9(_0x3ef7ab['result']);}})['catch'](function(_0x306727){logger[_0x55ad('0x8')](_0x55ad('0x7'),'routing',_0x2f5620,_0x306727,_0x4fd6c9);return _0x69e883(_0x306727);});});};module[_0x55ad('0xa')]=client; \ No newline at end of file diff --git a/server/services/routing/index.js b/server/services/routing/index.js new file mode 100644 index 0000000..686d71c --- /dev/null +++ b/server/services/routing/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb142=['log','./server','./realtime','./rpc/user','./rpc/interval','./rpc/openchannelQueue','./rpc/smsQueue','./rpc/mailQueue','then','getAgents','initAgents','initIntervals','getOpenchannelQueues','getChatQueues','initChatQueues','getSmsQueues','initSmsQueues','getMailQueues','initMailQueues','getFaxQueues','initFaxQueues','initWhatsappQueues','listen','catch'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0xb142,0x151));var _0x2b14=function(_0x4316fa,_0x5e6dbf){_0x4316fa=_0x4316fa-0x0;var _0x22183c=_0xb142[_0x4316fa];return _0x22183c;};'use strict';var BPromise=require('bluebird');var server=require(_0x2b14('0x0'));var Realtime=require(_0x2b14('0x1'));var user=require(_0x2b14('0x2'));var interval=require(_0x2b14('0x3'));var openchannelQueue=require(_0x2b14('0x4'));var chatQueue=require('./rpc/chatQueue');var smsQueue=require(_0x2b14('0x5'));var mailQueue=require(_0x2b14('0x6'));var faxQueue=require('./rpc/faxQueue');var whatsappQueue=require('./rpc/whatsappQueue');var realtime=new Realtime();function initRealtime(){return BPromise['resolve']()[_0x2b14('0x7')](user[_0x2b14('0x8')]())[_0x2b14('0x7')](realtime[_0x2b14('0x9')]())[_0x2b14('0x7')](interval['getIntervals']())['then'](realtime[_0x2b14('0xa')]())[_0x2b14('0x7')](openchannelQueue[_0x2b14('0xb')]())['then'](realtime['initOpenchannelQueues']())[_0x2b14('0x7')](chatQueue[_0x2b14('0xc')]())['then'](realtime[_0x2b14('0xd')]())[_0x2b14('0x7')](smsQueue[_0x2b14('0xe')]())[_0x2b14('0x7')](realtime[_0x2b14('0xf')]())[_0x2b14('0x7')](mailQueue[_0x2b14('0x10')]())['then'](realtime[_0x2b14('0x11')]())[_0x2b14('0x7')](faxQueue[_0x2b14('0x12')]())['then'](realtime[_0x2b14('0x13')]())[_0x2b14('0x7')](whatsappQueue['getWhatsappQueues']())[_0x2b14('0x7')](realtime[_0x2b14('0x14')]())['then'](function(){return realtime;});}function main(){return server[_0x2b14('0x15')](realtime)[_0x2b14('0x7')](function(_0x11361b){return initRealtime();})[_0x2b14('0x7')](function(_0xf9475a){return setInterval(initRealtime,0x1388);})[_0x2b14('0x16')](function(_0x1b998a){console[_0x2b14('0x17')](_0x1b998a);});}main(); \ No newline at end of file diff --git a/server/services/routing/lib/rule-engine.js b/server/services/routing/lib/rule-engine.js new file mode 100644 index 0000000..a0228aa --- /dev/null +++ b/server/services/routing/lib/rule-engine.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc4aa=['ruleRef','name','nextTick','push','call','next','isEqual','restart','isNil','length','condition','matchPath','noop','findRules','matches','turn','prioritize','priority','toJSON','toString','fromJSON','isString','parse','register','exports','lodash','util','events','EventEmitter','ignoreFactChanges','inherits','prototype','init','rules','activeRules','isArray','concat','isObject','sync','filter','orderBy','asc','execute','result','clone','consequence'];(function(_0x5b59eb,_0x505169){var _0x143836=function(_0x4ca965){while(--_0x4ca965){_0x5b59eb['push'](_0x5b59eb['shift']());}};_0x143836(++_0x505169);}(_0xc4aa,0x1b7));var _0xac4a=function(_0x3d42d8,_0x4cffaa){_0x3d42d8=_0x3d42d8-0x0;var _0x27fc41=_0xc4aa[_0x3d42d8];return _0x27fc41;};'use strict';var _=require(_0xac4a('0x0'));var util=require(_0xac4a('0x1'));var EventEmitter=require(_0xac4a('0x2'))[_0xac4a('0x3')];function RuleEngine(_0x275161,_0x22469d){this['init']();if(!_['isNil'](_0x275161)){this['register'](_0x275161);}if(_0x22469d){this[_0xac4a('0x4')]=_0x22469d[_0xac4a('0x4')];}return this;}util[_0xac4a('0x5')](RuleEngine,EventEmitter);RuleEngine[_0xac4a('0x6')][_0xac4a('0x7')]=function(_0x15cd34){this[_0xac4a('0x8')]=[];this[_0xac4a('0x9')]=[];};RuleEngine['prototype']['register']=function(_0x1aba6d){if(Array[_0xac4a('0xa')](_0x1aba6d)){this[_0xac4a('0x8')]=this['rules'][_0xac4a('0xb')](_0x1aba6d);}else if(_0x1aba6d!==null&&_[_0xac4a('0xc')](_0x1aba6d)){this[_0xac4a('0x8')]['push'](_0x1aba6d);}this[_0xac4a('0xd')]();};RuleEngine['prototype'][_0xac4a('0xd')]=function(){this['activeRules']=this[_0xac4a('0x8')][_0xac4a('0xe')](function(_0x24291d){if(_['isNil'](_0x24291d['on'])){_0x24291d['on']=!![];}if(_0x24291d['on']===!![]){return _0x24291d;}});this[_0xac4a('0x9')]=_[_0xac4a('0xf')](this[_0xac4a('0x9')],['p'],[_0xac4a('0x10')]);};RuleEngine[_0xac4a('0x6')][_0xac4a('0x11')]=function(_0x34bc01,_0x33c287){var _0x190418=![];_0x34bc01[_0xac4a('0x12')]=!![];var _0x11e101=_[_0xac4a('0x13')](_0x34bc01);var _0x4a2119=_[_0xac4a('0x13')](_0x34bc01);var _0x34d797=this[_0xac4a('0x9')];var _0x144553=[];var _0x3e88e3=this[_0xac4a('0x4')];(function FnRuleLoop(_0x28e304){var _0x44ec59={'rules':function(){return _0x34d797;},'rule':function(){return _0x34d797[_0x28e304];},'when':function(_0x546c5d){if(_0x546c5d){var _0x5ac21e=_0x34d797[_0x28e304][_0xac4a('0x14')];_0x5ac21e[_0xac4a('0x15')]=_0x34d797[_0x28e304]['id']||_0x34d797[_0x28e304][_0xac4a('0x16')]||'index_'+_0x28e304;process[_0xac4a('0x17')](function(){_0x144553[_0xac4a('0x18')](_0x5ac21e[_0xac4a('0x15')]);_0x5ac21e[_0xac4a('0x19')](_0x11e101,_0x44ec59);});}else{process[_0xac4a('0x17')](function(){_0x44ec59[_0xac4a('0x1a')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x190418=!![];return FnRuleLoop(0x0);},'next':function(_0xe38996){if(!_0x3e88e3&&!_[_0xac4a('0x1b')](_0x4a2119,_0x11e101)){_0x4a2119=_['clone'](_0x11e101);process[_0xac4a('0x17')](function(){_0x44ec59[_0xac4a('0x1c')]();});}else{process['nextTick'](function(){if(_[_0xac4a('0x1d')](_0xe38996)){return FnRuleLoop(_0x28e304+0x1);}else{return FnRuleLoop(_0xe38996);}});}}};if(_0x28e304<_0x34d797[_0xac4a('0x1e')]&&_0x190418===![]){var _0x3eacd3=_0x34d797[_0x28e304][_0xac4a('0x1f')];_0x3eacd3['call'](_0x11e101,_0x44ec59);}else{process[_0xac4a('0x17')](function(){_0x11e101[_0xac4a('0x20')]=_0x144553;return _0x33c287?_0x33c287(_0x11e101):_[_0xac4a('0x21')]();});}}(0x0));};RuleEngine[_0xac4a('0x6')][_0xac4a('0x22')]=function(_0x2b0dc2){if(_[_0xac4a('0x1d')](_0x2b0dc2)){return this[_0xac4a('0x8')];}else{var _0x3e2c69=_[_0xac4a('0x23')](_0x2b0dc2);return _[_0xac4a('0xe')](this[_0xac4a('0x8')],_0x3e2c69);}};RuleEngine[_0xac4a('0x6')][_0xac4a('0x24')]=function(_0x1c13dc,_0x20202c){var _0x4e17ce=_0x1c13dc==='on'||_0x1c13dc==='ON'?!![]:![];var _0x23b061=this[_0xac4a('0x22')](_0x20202c);for(var _0x42a33c=0x0,_0x2772fe=_0x23b061[_0xac4a('0x1e')];_0x42a33c<_0x2772fe;_0x42a33c+=0x1){_0x23b061[_0x42a33c]['on']=_0x4e17ce;}this['sync']();};RuleEngine['prototype'][_0xac4a('0x25')]=function(_0x7a948b,_0x1f12d5){_0x7a948b=parseInt(_0x7a948b,0xa);var _0x546b65=this['findRules'](_0x1f12d5);for(var _0x355755=0x0,_0x2896bc=_0x546b65[_0xac4a('0x1e')];_0x355755<_0x2896bc;_0x355755+=0x1){_0x546b65[_0x355755][_0xac4a('0x26')]=_0x7a948b;}this[_0xac4a('0xd')]();};RuleEngine['prototype'][_0xac4a('0x27')]=function(){var _0x482afc=this[_0xac4a('0x8')];if(_0x482afc instanceof Array){_0x482afc=_0x482afc['map'](function(_0x17e6de){_0x17e6de[_0xac4a('0x1f')]=_0x17e6de[_0xac4a('0x1f')][_0xac4a('0x28')]();_0x17e6de[_0xac4a('0x14')]=_0x17e6de[_0xac4a('0x14')][_0xac4a('0x28')]();return _0x17e6de;});}else if(!_[_0xac4a('0x1d')](_0x482afc)){_0x482afc[_0xac4a('0x1f')]=_0x482afc[_0xac4a('0x1f')][_0xac4a('0x28')]();_0x482afc[_0xac4a('0x14')]=_0x482afc[_0xac4a('0x14')][_0xac4a('0x28')]();}return _0x482afc;};RuleEngine['prototype'][_0xac4a('0x29')]=function(_0x1c41fb){this['init']();if(_[_0xac4a('0x2a')](_0x1c41fb)){_0x1c41fb=JSON[_0xac4a('0x2b')](_0x1c41fb);}if(_0x1c41fb instanceof Array){_0x1c41fb=_0x1c41fb['map'](function(_0x58804b){_0x58804b[_0xac4a('0x1f')]=eval('('+_0x58804b[_0xac4a('0x1f')]+')');_0x58804b[_0xac4a('0x14')]=eval('('+_0x58804b[_0xac4a('0x14')]+')');return _0x58804b;});}else if(_0x1c41fb!==null&&typeof _0x1c41fb=='object'){_0x1c41fb[_0xac4a('0x1f')]=eval('('+_0x1c41fb[_0xac4a('0x1f')]+')');_0x1c41fb['consequence']=eval('('+_0x1c41fb[_0xac4a('0x14')]+')');}this[_0xac4a('0x2c')](_0x1c41fb);};module[_0xac4a('0x2d')]=RuleEngine; \ No newline at end of file diff --git a/server/services/routing/mailRpc/index.js b/server/services/routing/mailRpc/index.js new file mode 100644 index 0000000..2c31476 --- /dev/null +++ b/server/services/routing/mailRpc/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc761=['message','result','catch','sendMailMessage','SendMail','bluebird','jayson/promise','http','then','error'];(function(_0x138adb,_0x193fee){var _0x1b27f2=function(_0x5e97a2){while(--_0x5e97a2){_0x138adb['push'](_0x138adb['shift']());}};_0x1b27f2(++_0x193fee);}(_0xc761,0x181));var _0x1c76=function(_0x484bf4,_0x2b975c){_0x484bf4=_0x484bf4-0x0;var _0x31c683=_0xc761[_0x484bf4];return _0x31c683;};'use strict';var BPromise=require(_0x1c76('0x0'));var jayson=require(_0x1c76('0x1'));var client=jayson['client'][_0x1c76('0x2')]({'port':0x232b});function request(_0x9a3a3f,_0x1ed86f){return new BPromise(function(_0x302fb9,_0x273768){return client['request'](_0x9a3a3f,_0x1ed86f)[_0x1c76('0x3')](function(_0x506b6c){if(_0x506b6c[_0x1c76('0x4')]){return _0x273768(_0x506b6c[_0x1c76('0x4')][_0x1c76('0x5')]);}else{return _0x302fb9(_0x506b6c[_0x1c76('0x6')]);}})[_0x1c76('0x7')](function(_0x395ab1){return _0x273768(_0x395ab1);});});}exports[_0x1c76('0x8')]=function(_0x12a7d8,_0x5bcbd5){return request(_0x1c76('0x9'),{'account':_0x12a7d8,'message':_0x5bcbd5});}; \ No newline at end of file diff --git a/server/services/routing/model/agent.js b/server/services/routing/model/agent.js new file mode 100644 index 0000000..174c069 --- /dev/null +++ b/server/services/routing/model/agent.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xd61c=['openchannelStatusTime','openchannelCapacity','openchannelCurrentCapacity','busy','busyQueue','faxWaitingInteractions','mailWaitingInteractions','openchannelWaitingInteractions','updateRealtime','getChannelStatus','Capacity','CurrentCapacity','maxcapacity','working','idle','mail','chat','openchannel','fax','sms','whatsapp','toNumber','format','smsCurrentCapacity','chatWaitingInteractions','smsWaitingInteractions','whatsappWaitingInteractions','stringify','emit','user:save','exports','moment','md5','ioredis','../../../config/environment','defaults','localhost','socket.io-emitter','redis','name','online','voicePause','chatPause','mailPause','faxPause','smsPause','openchannelPause','chatStatus','chatStatusTime','chatCapacity','chatCurrentCapacity','mailStatus','unknown','mailStatusTime','mailCapacity','mailCurrentCapacity','faxStatusTime','faxCapacity','faxCurrentCapacity','smsStatus','smsStatusTime','smsCapacity','whatsappStatusTime','whatsappCapacity','whatsappCurrentCapacity','openchannelStatus'];(function(_0x3c4582,_0x295d6a){var _0xbf1bd4=function(_0x38eb54){while(--_0x38eb54){_0x3c4582['push'](_0x3c4582['shift']());}};_0xbf1bd4(++_0x295d6a);}(_0xd61c,0x1ed));var _0xcd61=function(_0x2b7312,_0xdd928e){_0x2b7312=_0x2b7312-0x0;var _0x18e25f=_0xd61c[_0x2b7312];return _0x18e25f;};'use strict';var _=require('lodash');var moment=require(_0xcd61('0x0'));var md5=require(_0xcd61('0x1'));var Redis=require(_0xcd61('0x2'));var config=require(_0xcd61('0x3'));config['redis']=_[_0xcd61('0x4')](config['redis'],{'host':_0xcd61('0x5'),'port':0x18eb});var io=require(_0xcd61('0x6'))(new Redis(config[_0xcd61('0x7')]));function Agent(_0x438345){this['id']=_0x438345['id']||0x0;this[_0xcd61('0x8')]=_0x438345[_0xcd61('0x8')]||'';this[_0xcd61('0x9')]=_0x438345['online']||!![];this[_0xcd61('0xa')]=_0x438345[_0xcd61('0xa')]||![];this[_0xcd61('0xb')]=_0x438345[_0xcd61('0xb')]||![];this[_0xcd61('0xc')]=_0x438345[_0xcd61('0xc')]||![];this[_0xcd61('0xd')]=_0x438345['faxPause']||![];this[_0xcd61('0xe')]=_0x438345[_0xcd61('0xe')]||![];this['openchannelPause']=_0x438345[_0xcd61('0xf')]||![];this[_0xcd61('0x10')]='unknown';this[_0xcd61('0x11')]=0x0;this['chatCapacity']=_0x438345[_0xcd61('0x12')]||0x0;this[_0xcd61('0x13')]=0x0;this[_0xcd61('0x14')]=_0xcd61('0x15');this[_0xcd61('0x16')]=0x0;this['mailCapacity']=_0x438345[_0xcd61('0x17')]||0x0;this[_0xcd61('0x18')]=0x0;this['faxStatus']='unknown';this[_0xcd61('0x19')]=0x0;this[_0xcd61('0x1a')]=_0x438345['faxCapacity']||0x0;this[_0xcd61('0x1b')]=0x0;this[_0xcd61('0x1c')]=_0xcd61('0x15');this[_0xcd61('0x1d')]=0x0;this[_0xcd61('0x1e')]=_0x438345[_0xcd61('0x1e')]||0x0;this['smsCurrentCapacity']=0x0;this['whatsappStatus']=_0xcd61('0x15');this[_0xcd61('0x1f')]=0x0;this[_0xcd61('0x20')]=_0x438345['whatsappCapacity']||0x0;this[_0xcd61('0x21')]=0x0;this[_0xcd61('0x22')]='unknown';this[_0xcd61('0x23')]=0x0;this[_0xcd61('0x24')]=_0x438345[_0xcd61('0x24')]||0x0;this[_0xcd61('0x25')]=0x0;this[_0xcd61('0x26')]=![];this[_0xcd61('0x27')]=undefined;this[_0xcd61('0x1')]='';this['chatWaitingInteractions']={};this[_0xcd61('0x28')]={};this[_0xcd61('0x29')]={};this[_0xcd61('0x2a')]={};this['smsWaitingInteractions']={};this['whatsappWaitingInteractions']={};this[_0xcd61('0x2b')]();}Agent['prototype'][_0xcd61('0x2c')]=function(_0x260334){if(this[_0x260334+'CurrentCapacity']>0x0){if(this[_0x260334+_0xcd61('0x2d')]>0x0&&this[_0x260334+_0xcd61('0x2e')]>=this[_0x260334+_0xcd61('0x2d')]){return _0xcd61('0x2f');}else{return _0xcd61('0x30');}}else{return _0xcd61('0x31');}};Agent['prototype'][_0xcd61('0x2b')]=function(){var _0x7a1d31=[_0xcd61('0x32'),_0xcd61('0x33'),_0xcd61('0x34'),_0xcd61('0x35'),_0xcd61('0x36'),_0xcd61('0x37')];for(var _0x33f612=0x0;_0x33f612<_0x7a1d31['length'];_0x33f612+=0x1){var _0x4d6425=this[_0xcd61('0x2c')](_0x7a1d31[_0x33f612]);if(this[_0x7a1d31[_0x33f612]+'Status']!==_0x4d6425){this[_0x7a1d31[_0x33f612]+'StatusTime']=_[_0xcd61('0x38')](moment()[_0xcd61('0x39')]('x'));}this[_0x7a1d31[_0x33f612]+'Status']=_0x4d6425;}var _0x5b2455={'id':this['id'],'name':this[_0xcd61('0x8')],'online':this[_0xcd61('0x9')],'voicePause':this['voicePause'],'chatPause':this[_0xcd61('0xb')],'mailPause':this[_0xcd61('0xc')],'smsPause':this['smsPause'],'faxPause':this[_0xcd61('0xd')],'openchannelPause':this[_0xcd61('0xf')],'chatStatus':this['chatStatus'],'chatStatusTime':this[_0xcd61('0x11')],'chatCapacity':this[_0xcd61('0x12')],'chatCurrentCapacity':this[_0xcd61('0x13')],'mailStatus':this[_0xcd61('0x14')],'mailStatusTime':this[_0xcd61('0x16')],'mailCapacity':this['mailCapacity'],'mailCurrentCapacity':this['mailCurrentCapacity'],'faxStatus':this['faxStatus'],'faxStatusTime':this[_0xcd61('0x19')],'faxCapacity':this[_0xcd61('0x1a')],'faxCurrentCapacity':this[_0xcd61('0x1b')],'smsStatus':this[_0xcd61('0x1c')],'smsStatusTime':this['smsStatusTime'],'smsCapacity':this[_0xcd61('0x1e')],'smsCurrentCapacity':this[_0xcd61('0x3a')],'whatsappStatus':this['whatsappStatus'],'whatsappStatusTime':this[_0xcd61('0x1f')],'whatsappCapacity':this[_0xcd61('0x20')],'whatsappCurrentCapacity':this[_0xcd61('0x21')],'openchannelStatus':this[_0xcd61('0x22')],'openchannelStatusTime':this['openchannelStatusTime'],'openchannelCapacity':this[_0xcd61('0x24')],'openchannelCurrentCapacity':this[_0xcd61('0x25')],'busy':this['busy'],'busyQueue':this[_0xcd61('0x27')],'chatWaitingInteractions':this[_0xcd61('0x3b')],'faxWaitingInteractions':this['faxWaitingInteractions'],'mailWaitingInteractions':this['mailWaitingInteractions'],'openchannelWaitingInteractions':this['openchannelWaitingInteractions'],'smsWaitingInteractions':this[_0xcd61('0x3c')],'whatsappWaitingInteractions':this[_0xcd61('0x3d')]};var _0x1cb7d4=md5(JSON[_0xcd61('0x3e')](_0x5b2455));if(this['md5']!==_0x1cb7d4){this[_0xcd61('0x1')]=_0x1cb7d4;io[_0xcd61('0x3f')](_0xcd61('0x40'),_0x5b2455);}};module[_0xcd61('0x41')]=Agent; \ No newline at end of file diff --git a/server/services/routing/model/chatQueue.js b/server/services/routing/model/chatQueue.js new file mode 100644 index 0000000..a42ffbd --- /dev/null +++ b/server/services/routing/model/chatQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdd24=['waiting','stringify','format','chat:queue:%s','exports','lodash','md5','redis','socket.io-emitter','name','strategy','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','length','online','chatPause','available'];(function(_0x4e9628,_0x250573){var _0x27bc8c=function(_0xb3b7ae){while(--_0xb3b7ae){_0x4e9628['push'](_0x4e9628['shift']());}};_0x27bc8c(++_0x250573);}(_0xdd24,0x1e8));var _0x4dd2=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0xdd24[_0x6c993a];return _0x27f547;};'use strict';var _=require(_0x4dd2('0x0'));var md5=require(_0x4dd2('0x1'));var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');config[_0x4dd2('0x2')]=_['defaults'](config[_0x4dd2('0x2')],{'host':'localhost','port':0x18eb});var io=require(_0x4dd2('0x3'))(new Redis(config[_0x4dd2('0x2')]));function ChatQueue(_0x3f30b3){this['id']=_0x3f30b3['id']||0x0;this['name']=_0x3f30b3[_0x4dd2('0x4')]||'';this['timeout']=_0x3f30b3['timeout']||0xa;this[_0x4dd2('0x5')]=_0x3f30b3[_0x4dd2('0x5')]||'beepall';this['Agents']=_0x3f30b3[_0x4dd2('0x6')];this[_0x4dd2('0x7')]={};this['waiting']=0x0;this[_0x4dd2('0x1')]='';this[_0x4dd2('0x8')]();this[_0x4dd2('0x9')]();}ChatQueue[_0x4dd2('0xa')][_0x4dd2('0x8')]=function(){var _0x3c018d=this['mapAgentsId'][_0x4dd2('0xb')];this[_0x4dd2('0x7')]=_['map'](this['Agents'],'id');this[_0x4dd2('0x7')]['_rr']=_0x3c018d;};ChatQueue['prototype'][_0x4dd2('0x9')]=function(){this[_0x4dd2('0xc')]=0x0;this[_0x4dd2('0xd')]=0x0;for(var _0x401767=0x0;_0x401767=0x0?this[_0x4dd2('0x11')]:0x0;var _0x5a8605={'id':this['id'],'available':this[_0x4dd2('0x11')],'loggedIn':this[_0x4dd2('0xc')],'name':this[_0x4dd2('0x4')],'paused':this[_0x4dd2('0xd')],'waiting':this[_0x4dd2('0x12')]};var _0x58bcbf=md5(JSON[_0x4dd2('0x13')](_0x5a8605));if(this[_0x4dd2('0x1')]!==_0x58bcbf){this['md5']=_0x58bcbf;io['to'](util[_0x4dd2('0x14')](_0x4dd2('0x15'),_0x5a8605['name']))['emit']('chat_queue:save',_0x5a8605);}};module[_0x4dd2('0x16')]=ChatQueue; \ No newline at end of file diff --git a/server/services/routing/model/faxQueue.js b/server/services/routing/model/faxQueue.js new file mode 100644 index 0000000..6f4bfeb --- /dev/null +++ b/server/services/routing/model/faxQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd5c=['loggedIn','paused','length','online','faxPause','available','format','fax:queue:%s','emit','fax_queue:save','exports','lodash','md5','util','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','prototype','updateRouting','_rr','map','updateRealtime'];(function(_0x32e47e,_0x47266e){var _0x502140=function(_0x26a098){while(--_0x26a098){_0x32e47e['push'](_0x32e47e['shift']());}};_0x502140(++_0x47266e);}(_0xcd5c,0x9c));var _0xccd5=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0xcd5c[_0x59ee6f];return _0x4c0979;};'use strict';var _=require(_0xccd5('0x0'));var md5=require(_0xccd5('0x1'));var util=require(_0xccd5('0x2'));var Redis=require('ioredis');var config=require(_0xccd5('0x3'));config[_0xccd5('0x4')]=_[_0xccd5('0x5')](config[_0xccd5('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xccd5('0x6'))(new Redis(config[_0xccd5('0x4')]));function FaxQueue(_0x1c0865){this['id']=_0x1c0865['id']||0x0;this[_0xccd5('0x7')]=_0x1c0865['name']||'';this[_0xccd5('0x8')]=_0x1c0865['timeout']||0xa;this[_0xccd5('0x9')]=_0x1c0865['strategy']||'beepall';this[_0xccd5('0xa')]=_0x1c0865[_0xccd5('0xa')];this[_0xccd5('0xb')]={};this[_0xccd5('0xc')]=0x0;this[_0xccd5('0x1')]='';this['updateRouting']();this['updateRealtime']();}FaxQueue[_0xccd5('0xd')][_0xccd5('0xe')]=function(){var _0x24fc91=this[_0xccd5('0xb')][_0xccd5('0xf')];this[_0xccd5('0xb')]=_[_0xccd5('0x10')](this[_0xccd5('0xa')],'id');this[_0xccd5('0xb')][_0xccd5('0xf')]=_0x24fc91;};FaxQueue['prototype'][_0xccd5('0x11')]=function(){this[_0xccd5('0x12')]=0x0;this[_0xccd5('0x13')]=0x0;for(var _0x18586e=0x0;_0x18586e=0x0?this[_0xccd5('0x17')]:0x0;var _0x42de0f={'id':this['id'],'available':this[_0xccd5('0x17')],'loggedIn':this[_0xccd5('0x12')],'name':this[_0xccd5('0x7')],'paused':this[_0xccd5('0x13')],'waiting':this['waiting']};var _0x3c77b9=md5(JSON['stringify'](_0x42de0f));if(this[_0xccd5('0x1')]!==_0x3c77b9){this[_0xccd5('0x1')]=_0x3c77b9;io['to'](util[_0xccd5('0x18')](_0xccd5('0x19'),_0x42de0f[_0xccd5('0x7')]))[_0xccd5('0x1a')](_0xccd5('0x1b'),_0x42de0f);}};module[_0xccd5('0x1c')]=FaxQueue; \ No newline at end of file diff --git a/server/services/routing/model/interval.js b/server/services/routing/model/interval.js new file mode 100644 index 0000000..59c2601 --- /dev/null +++ b/server/services/routing/model/interval.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xab18=['exports','name'];(function(_0x36003e,_0x58b5bb){var _0x5bbadc=function(_0x54ad57){while(--_0x54ad57){_0x36003e['push'](_0x36003e['shift']());}};_0x5bbadc(++_0x58b5bb);}(_0xab18,0x111));var _0x8ab1=function(_0x4cd07c,_0x4474f1){_0x4cd07c=_0x4cd07c-0x0;var _0x4907a7=_0xab18[_0x4cd07c];return _0x4907a7;};'use strict';function Interval(_0x13070a){this['id']=_0x13070a['id']||0x0;this[_0x8ab1('0x0')]=_0x13070a['name']||'';this['Intervals']=_0x13070a['Intervals']||{};}module[_0x8ab1('0x1')]=Interval; \ No newline at end of file diff --git a/server/services/routing/model/mailQueue.js b/server/services/routing/model/mailQueue.js new file mode 100644 index 0000000..1df2209 --- /dev/null +++ b/server/services/routing/model/mailQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0c30=['updateRouting','_rr','map','loggedIn','paused','length','online','mailPause','available','stringify','md5','format','mail:queue:%s','emit','mail_queue:save','lodash','ioredis','../../../config/environment','defaults','redis','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','prototype'];(function(_0x32a767,_0x4e3e76){var _0x2b4e6d=function(_0x5e0702){while(--_0x5e0702){_0x32a767['push'](_0x32a767['shift']());}};_0x2b4e6d(++_0x4e3e76);}(_0x0c30,0x127));var _0x00c3=function(_0x23ec06,_0x561142){_0x23ec06=_0x23ec06-0x0;var _0x2831d4=_0x0c30[_0x23ec06];return _0x2831d4;};'use strict';var _=require(_0x00c3('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x00c3('0x1'));var config=require(_0x00c3('0x2'));config['redis']=_[_0x00c3('0x3')](config[_0x00c3('0x4')],{'host':_0x00c3('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x00c3('0x4')]));function MailQueue(_0x4ee158){this['id']=_0x4ee158['id']||0x0;this[_0x00c3('0x6')]=_0x4ee158[_0x00c3('0x6')]||'';this['timeout']=_0x4ee158[_0x00c3('0x7')]||0xa;this['strategy']=_0x4ee158[_0x00c3('0x8')]||'beepall';this[_0x00c3('0x9')]=_0x4ee158['Agents'];this[_0x00c3('0xa')]={};this[_0x00c3('0xb')]=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}MailQueue[_0x00c3('0xc')][_0x00c3('0xd')]=function(){var _0x140165=this['mapAgentsId'][_0x00c3('0xe')];this[_0x00c3('0xa')]=_[_0x00c3('0xf')](this[_0x00c3('0x9')],'id');this['mapAgentsId']['_rr']=_0x140165;};MailQueue[_0x00c3('0xc')]['updateRealtime']=function(){this[_0x00c3('0x10')]=0x0;this[_0x00c3('0x11')]=0x0;for(var _0x5daea9=0x0;_0x5daea9=0x0?this[_0x00c3('0x15')]:0x0;var _0x98d665={'id':this['id'],'available':this[_0x00c3('0x15')],'loggedIn':this[_0x00c3('0x10')],'name':this[_0x00c3('0x6')],'paused':this[_0x00c3('0x11')],'waiting':this[_0x00c3('0xb')]};var _0x15aee9=md5(JSON[_0x00c3('0x16')](_0x98d665));if(this[_0x00c3('0x17')]!==_0x15aee9){this['md5']=_0x15aee9;io['to'](util[_0x00c3('0x18')](_0x00c3('0x19'),_0x98d665[_0x00c3('0x6')]))[_0x00c3('0x1a')](_0x00c3('0x1b'),_0x98d665);}};module['exports']=MailQueue; \ No newline at end of file diff --git a/server/services/routing/model/openchannelQueue.js b/server/services/routing/model/openchannelQueue.js new file mode 100644 index 0000000..cde677b --- /dev/null +++ b/server/services/routing/model/openchannelQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['exports','lodash','md5','util','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','waiting','updateRealtime','mapAgentsId','_rr','map','Agents','prototype','loggedIn','paused','length','openchannelPause','available','stringify','format','openchannel:queue:%s','emit','openchannel_queue:save'];(function(_0x5d80de,_0x2cf15d){var _0x1c7556=function(_0x5bd806){while(--_0x5bd806){_0x5d80de['push'](_0x5d80de['shift']());}};_0x1c7556(++_0x2cf15d);}(_0x7a54,0x106));var _0x47a5=function(_0x270d6c,_0x20e37d){_0x270d6c=_0x270d6c-0x0;var _0x14e1ee=_0x7a54[_0x270d6c];return _0x14e1ee;};'use strict';var _=require(_0x47a5('0x0'));var md5=require(_0x47a5('0x1'));var util=require(_0x47a5('0x2'));var Redis=require('ioredis');var config=require(_0x47a5('0x3'));config[_0x47a5('0x4')]=_['defaults'](config[_0x47a5('0x4')],{'host':_0x47a5('0x5'),'port':0x18eb});var io=require(_0x47a5('0x6'))(new Redis(config[_0x47a5('0x4')]));function OpenchannelQueue(_0xfdf934){this['id']=_0xfdf934['id']||0x0;this['name']=_0xfdf934[_0x47a5('0x7')]||'';this['timeout']=_0xfdf934[_0x47a5('0x8')]||0xa;this[_0x47a5('0x9')]=_0xfdf934['strategy']||_0x47a5('0xa');this['Agents']=_0xfdf934['Agents'];this['mapAgentsId']={};this[_0x47a5('0xb')]=0x0;this[_0x47a5('0x1')]='';this['updateRouting']();this[_0x47a5('0xc')]();}OpenchannelQueue['prototype']['updateRouting']=function(){var _0x1f47f4=this[_0x47a5('0xd')][_0x47a5('0xe')];this[_0x47a5('0xd')]=_[_0x47a5('0xf')](this[_0x47a5('0x10')],'id');this[_0x47a5('0xd')]['_rr']=_0x1f47f4;};OpenchannelQueue[_0x47a5('0x11')][_0x47a5('0xc')]=function(){this[_0x47a5('0x12')]=0x0;this[_0x47a5('0x13')]=0x0;for(var _0x139f25=0x0;_0x139f25=0x0?this['available']:0x0;var _0x423a81={'id':this['id'],'available':this[_0x47a5('0x16')],'loggedIn':this[_0x47a5('0x12')],'name':this[_0x47a5('0x7')],'paused':this[_0x47a5('0x13')],'waiting':this[_0x47a5('0xb')]};var _0x2763d6=md5(JSON[_0x47a5('0x17')](_0x423a81));if(this[_0x47a5('0x1')]!==_0x2763d6){this['md5']=_0x2763d6;io['to'](util[_0x47a5('0x18')](_0x47a5('0x19'),_0x423a81['name']))[_0x47a5('0x1a')](_0x47a5('0x1b'),_0x423a81);}};module[_0x47a5('0x1c')]=OpenchannelQueue; \ No newline at end of file diff --git a/server/services/routing/model/smsQueue.js b/server/services/routing/model/smsQueue.js new file mode 100644 index 0000000..bd0cc99 --- /dev/null +++ b/server/services/routing/model/smsQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x01fe=['defaults','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','map','prototype','loggedIn','paused','length','online','available','stringify','md5','sms:queue:%s','emit','sms_queue:save','exports','lodash','util','ioredis'];(function(_0x1c0e1a,_0x361353){var _0x46840d=function(_0x460250){while(--_0x460250){_0x1c0e1a['push'](_0x1c0e1a['shift']());}};_0x46840d(++_0x361353);}(_0x01fe,0x102));var _0xe01f=function(_0x193ed0,_0x3f2aa1){_0x193ed0=_0x193ed0-0x0;var _0x46ea4b=_0x01fe[_0x193ed0];return _0x46ea4b;};'use strict';var _=require(_0xe01f('0x0'));var md5=require('md5');var util=require(_0xe01f('0x1'));var Redis=require(_0xe01f('0x2'));var config=require('../../../config/environment');config['redis']=_[_0xe01f('0x3')](config[_0xe01f('0x4')],{'host':_0xe01f('0x5'),'port':0x18eb});var io=require(_0xe01f('0x6'))(new Redis(config['redis']));function SmsQueue(_0x14340f){this['id']=_0x14340f['id']||0x0;this['name']=_0x14340f[_0xe01f('0x7')]||'';this[_0xe01f('0x8')]=_0x14340f[_0xe01f('0x8')]||0xa;this[_0xe01f('0x9')]=_0x14340f[_0xe01f('0x9')]||'beepall';this[_0xe01f('0xa')]=_0x14340f[_0xe01f('0xa')];this['mapAgentsId']={};this[_0xe01f('0xb')]=0x0;this['md5']='';this[_0xe01f('0xc')]();this[_0xe01f('0xd')]();}SmsQueue['prototype'][_0xe01f('0xc')]=function(){var _0x4f409c=this[_0xe01f('0xe')][_0xe01f('0xf')];this[_0xe01f('0xe')]=_[_0xe01f('0x10')](this[_0xe01f('0xa')],'id');this[_0xe01f('0xe')][_0xe01f('0xf')]=_0x4f409c;};SmsQueue[_0xe01f('0x11')]['updateRealtime']=function(){this[_0xe01f('0x12')]=0x0;this[_0xe01f('0x13')]=0x0;for(var _0x2d55c8=0x0;_0x2d55c8=0x0?this[_0xe01f('0x16')]:0x0;var _0x26cd4d={'id':this['id'],'available':this[_0xe01f('0x16')],'loggedIn':this[_0xe01f('0x12')],'name':this['name'],'paused':this[_0xe01f('0x13')],'waiting':this['waiting']};var _0x948cfa=md5(JSON[_0xe01f('0x17')](_0x26cd4d));if(this[_0xe01f('0x18')]!==_0x948cfa){this[_0xe01f('0x18')]=_0x948cfa;io['to'](util['format'](_0xe01f('0x19'),_0x26cd4d[_0xe01f('0x7')]))[_0xe01f('0x1a')](_0xe01f('0x1b'),_0x26cd4d);}};module[_0xe01f('0x1c')]=SmsQueue; \ No newline at end of file diff --git a/server/services/routing/model/whatsappQueue.js b/server/services/routing/model/whatsappQueue.js new file mode 100644 index 0000000..bb2b904 --- /dev/null +++ b/server/services/routing/model/whatsappQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8351=['socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','prototype','_rr','updateRealtime','loggedIn','paused','length','online','available','waiting','stringify','emit','whatsapp_queue:save','exports','md5','util','ioredis','../../../config/environment','redis','defaults','localhost'];(function(_0xefd519,_0xc62635){var _0x4bb882=function(_0x37e0a1){while(--_0x37e0a1){_0xefd519['push'](_0xefd519['shift']());}};_0x4bb882(++_0xc62635);}(_0x8351,0x19d));var _0x1835=function(_0x26c457,_0x3e9e8e){_0x26c457=_0x26c457-0x0;var _0x5a0079=_0x8351[_0x26c457];return _0x5a0079;};'use strict';var _=require('lodash');var md5=require(_0x1835('0x0'));var util=require(_0x1835('0x1'));var Redis=require(_0x1835('0x2'));var config=require(_0x1835('0x3'));config[_0x1835('0x4')]=_[_0x1835('0x5')](config['redis'],{'host':_0x1835('0x6'),'port':0x18eb});var io=require(_0x1835('0x7'))(new Redis(config[_0x1835('0x4')]));function WhatsappQueue(_0x26028e){this['id']=_0x26028e['id']||0x0;this[_0x1835('0x8')]=_0x26028e[_0x1835('0x8')]||'';this[_0x1835('0x9')]=_0x26028e['timeout']||0xa;this[_0x1835('0xa')]=_0x26028e[_0x1835('0xa')]||_0x1835('0xb');this[_0x1835('0xc')]=_0x26028e[_0x1835('0xc')];this[_0x1835('0xd')]={};this['waiting']=0x0;this[_0x1835('0x0')]='';this[_0x1835('0xe')]();this['updateRealtime']();}WhatsappQueue[_0x1835('0xf')]['updateRouting']=function(){var _0x3b4ee5=this['mapAgentsId']['_rr'];this['mapAgentsId']=_['map'](this[_0x1835('0xc')],'id');this[_0x1835('0xd')][_0x1835('0x10')]=_0x3b4ee5;};WhatsappQueue['prototype'][_0x1835('0x11')]=function(){this[_0x1835('0x12')]=0x0;this[_0x1835('0x13')]=0x0;for(var _0x1fea38=0x0;_0x1fea38=0x0?this[_0x1835('0x16')]:0x0;var _0x2461fb={'id':this['id'],'available':this['available'],'loggedIn':this[_0x1835('0x12')],'name':this[_0x1835('0x8')],'paused':this['paused'],'waiting':this[_0x1835('0x17')]};var _0x310150=md5(JSON[_0x1835('0x18')](_0x2461fb));if(this[_0x1835('0x0')]!==_0x310150){this[_0x1835('0x0')]=_0x310150;io['to'](util['format']('whatsapp:queue:%s',_0x2461fb[_0x1835('0x8')]))[_0x1835('0x19')](_0x1835('0x1a'),_0x2461fb);}};module[_0x1835('0x1b')]=WhatsappQueue; \ No newline at end of file diff --git a/server/services/routing/realtime/index.js b/server/services/routing/realtime/index.js new file mode 100644 index 0000000..0471911 --- /dev/null +++ b/server/services/routing/realtime/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['isUndefined','initIntervals','updateRealtime','updateRouting','initSmsQueues','smsQueues','initMailQueues','mailQueues','initWhatsappQueues','whatsappQueues','exports','bluebird','util','lodash','../model/interval','../model/chatQueue','../model/smsQueue','../model/mailQueue','../model/faxQueue','../model/whatsappQueue','intervals','openchannelQueues','chatQueues','faxQueues','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','hasOwnProperty','prototype','mergeFromDatabase','initAgents','agents','length'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xa9e0,0x123));var _0x0a9e=function(_0x3a6efd,_0x2a5102){_0x3a6efd=_0x3a6efd-0x0;var _0x487b9a=_0xa9e0[_0x3a6efd];return _0x487b9a;};'use strict';var BPromise=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var _=require(_0x0a9e('0x2'));var moment=require('moment');var Agent=require('../model/agent');var Interval=require(_0x0a9e('0x3'));var OpenchannelQueue=require('../model/openchannelQueue');var ChatQueue=require(_0x0a9e('0x4'));var SmsQueue=require(_0x0a9e('0x5'));var MailQueue=require(_0x0a9e('0x6'));var FaxQueue=require(_0x0a9e('0x7'));var WhatsappQueue=require(_0x0a9e('0x8'));var Realtime=function(){this['agents']={};this[_0x0a9e('0x9')]={};this[_0x0a9e('0xa')]={};this[_0x0a9e('0xb')]={};this['smsQueues']={};this['mailQueues']={};this[_0x0a9e('0xc')]={};this['whatsappQueues']={};this['chatQueuesWaitingInteractions']={};this[_0x0a9e('0xd')]={};this[_0x0a9e('0xe')]={};this[_0x0a9e('0xf')]={};this[_0x0a9e('0x10')]={};this[_0x0a9e('0x11')]={};};function freeIsNotKey(_0xbd1168,_0x4a4c56,_0x50dfb2){var _0x527cdd=_['mapKeys'](_0xbd1168,function(_0x273d4d,_0x36471c){return _0x273d4d[_0x50dfb2];});for(var _0xd5b662 in _0x4a4c56){if(_0x4a4c56[_0x0a9e('0x12')](_0xd5b662)){if(!_0x527cdd[_0xd5b662]){delete _0x4a4c56[_0xd5b662];}}}}Realtime[_0x0a9e('0x13')][_0x0a9e('0x14')]=function(_0x5db4b0,_0x4283ce){for(var _0x239b12 in _0x4283ce){if(_0x5db4b0[_0x0a9e('0x12')](_0x239b12)){_0x5db4b0[_0x239b12]=_0x4283ce[_0x239b12];}}};Realtime[_0x0a9e('0x13')][_0x0a9e('0x15')]=function(){var _0x4d5611=this;return function(_0x52a03d){if(_0x52a03d){freeIsNotKey(_0x52a03d,_0x4d5611[_0x0a9e('0x16')],'id');for(var _0x5d0880=0x0,_0x1985b6={},_0x519dfd={};_0x5d0880<_0x52a03d[_0x0a9e('0x17')];_0x5d0880+=0x1){_0x1985b6=_0x52a03d[_0x5d0880];if(_[_0x0a9e('0x18')](_0x4d5611['agents'][_0x1985b6['id']])){_0x4d5611[_0x0a9e('0x16')][_0x1985b6['id']]=new Agent(_0x1985b6);}else{_0x4d5611['mergeFromDatabase'](_0x4d5611[_0x0a9e('0x16')][_0x1985b6['id']],_0x1985b6);}}}return _0x4d5611[_0x0a9e('0x16')];};};Realtime[_0x0a9e('0x13')][_0x0a9e('0x19')]=function(){var _0x31b1ca=this;return function(_0x2eb11f){if(_0x2eb11f){freeIsNotKey(_0x2eb11f,_0x31b1ca[_0x0a9e('0x9')],'id');for(var _0x20559e=0x0,_0x1314ae={},_0x112016={};_0x20559e<_0x2eb11f[_0x0a9e('0x17')];_0x20559e+=0x1){_0x1314ae=_0x2eb11f[_0x20559e];if(_[_0x0a9e('0x18')](_0x31b1ca['intervals'][_0x1314ae['id']])){_0x31b1ca[_0x0a9e('0x9')][_0x1314ae['id']]=new Interval(_0x1314ae);}else{_0x31b1ca[_0x0a9e('0x14')](_0x31b1ca['intervals'][_0x1314ae['id']],_0x1314ae);}}}return _0x31b1ca[_0x0a9e('0x9')];};};Realtime['prototype']['initOpenchannelQueues']=function(){var _0x3a02e1=this;return function(_0x432e56){if(_0x432e56){freeIsNotKey(_0x432e56,_0x3a02e1[_0x0a9e('0xa')],'id');for(var _0x30bae6=0x0,_0x4abc77={},_0xfb6e48={};_0x30bae6<_0x432e56[_0x0a9e('0x17')];_0x30bae6+=0x1){_0x4abc77=_0x432e56[_0x30bae6];if(_[_0x0a9e('0x18')](_0x3a02e1[_0x0a9e('0xa')][_0x4abc77['id']])){_0x3a02e1[_0x0a9e('0xa')][_0x4abc77['id']]=new OpenchannelQueue(_0x4abc77);}else{_0x3a02e1[_0x0a9e('0x14')](_0x3a02e1[_0x0a9e('0xa')][_0x4abc77['id']],_0x4abc77);}_0x3a02e1['openchannelQueues'][_0x4abc77['id']]['updateRouting']();_0x3a02e1[_0x0a9e('0xa')][_0x4abc77['id']][_0x0a9e('0x1a')]();}}return _0x3a02e1[_0x0a9e('0xa')];};};Realtime[_0x0a9e('0x13')]['initChatQueues']=function(){var _0x384319=this;return function(_0x479bc4){if(_0x479bc4){freeIsNotKey(_0x479bc4,_0x384319[_0x0a9e('0xb')],'id');for(var _0x5bfb33=0x0,_0x1dc186={},_0x34dc65={};_0x5bfb33<_0x479bc4[_0x0a9e('0x17')];_0x5bfb33+=0x1){_0x1dc186=_0x479bc4[_0x5bfb33];if(_[_0x0a9e('0x18')](_0x384319[_0x0a9e('0xb')][_0x1dc186['id']])){_0x384319[_0x0a9e('0xb')][_0x1dc186['id']]=new ChatQueue(_0x1dc186);}else{_0x384319[_0x0a9e('0x14')](_0x384319[_0x0a9e('0xb')][_0x1dc186['id']],_0x1dc186);}_0x384319['chatQueues'][_0x1dc186['id']][_0x0a9e('0x1b')]();_0x384319[_0x0a9e('0xb')][_0x1dc186['id']][_0x0a9e('0x1a')]();}}return _0x384319[_0x0a9e('0xb')];};};Realtime['prototype'][_0x0a9e('0x1c')]=function(){var _0x40e7a3=this;return function(_0x1843b2){if(_0x1843b2){freeIsNotKey(_0x1843b2,_0x40e7a3[_0x0a9e('0x1d')],'id');for(var _0x58b06f=0x0,_0x563b45={},_0x296f41={};_0x58b06f<_0x1843b2[_0x0a9e('0x17')];_0x58b06f+=0x1){_0x563b45=_0x1843b2[_0x58b06f];if(_[_0x0a9e('0x18')](_0x40e7a3['smsQueues'][_0x563b45['id']])){_0x40e7a3[_0x0a9e('0x1d')][_0x563b45['id']]=new SmsQueue(_0x563b45);}else{_0x40e7a3['mergeFromDatabase'](_0x40e7a3[_0x0a9e('0x1d')][_0x563b45['id']],_0x563b45);}_0x40e7a3[_0x0a9e('0x1d')][_0x563b45['id']][_0x0a9e('0x1b')]();_0x40e7a3[_0x0a9e('0x1d')][_0x563b45['id']][_0x0a9e('0x1a')]();}}return _0x40e7a3['smsQueues'];};};Realtime[_0x0a9e('0x13')][_0x0a9e('0x1e')]=function(){var _0x40cb85=this;return function(_0x2da5c0){if(_0x2da5c0){freeIsNotKey(_0x2da5c0,_0x40cb85[_0x0a9e('0x1f')],'id');for(var _0x409319=0x0,_0x332d35={},_0x39e565={};_0x409319<_0x2da5c0['length'];_0x409319+=0x1){_0x332d35=_0x2da5c0[_0x409319];if(_[_0x0a9e('0x18')](_0x40cb85['mailQueues'][_0x332d35['id']])){_0x40cb85[_0x0a9e('0x1f')][_0x332d35['id']]=new MailQueue(_0x332d35);}else{_0x40cb85[_0x0a9e('0x14')](_0x40cb85[_0x0a9e('0x1f')][_0x332d35['id']],_0x332d35);}_0x40cb85[_0x0a9e('0x1f')][_0x332d35['id']]['updateRouting']();_0x40cb85[_0x0a9e('0x1f')][_0x332d35['id']][_0x0a9e('0x1a')]();}}return _0x40cb85[_0x0a9e('0x1f')];};};Realtime[_0x0a9e('0x13')]['initFaxQueues']=function(){var _0x54135e=this;return function(_0x1e8694){if(_0x1e8694){freeIsNotKey(_0x1e8694,_0x54135e['faxQueues'],'id');for(var _0x24936a=0x0,_0x3d9717={},_0x381c37={};_0x24936a<_0x1e8694[_0x0a9e('0x17')];_0x24936a+=0x1){_0x3d9717=_0x1e8694[_0x24936a];if(_['isUndefined'](_0x54135e[_0x0a9e('0xc')][_0x3d9717['id']])){_0x54135e[_0x0a9e('0xc')][_0x3d9717['id']]=new FaxQueue(_0x3d9717);}else{_0x54135e[_0x0a9e('0x14')](_0x54135e['faxQueues'][_0x3d9717['id']],_0x3d9717);}_0x54135e[_0x0a9e('0xc')][_0x3d9717['id']][_0x0a9e('0x1b')]();_0x54135e[_0x0a9e('0xc')][_0x3d9717['id']]['updateRealtime']();}}return _0x54135e['faxQueues'];};};Realtime[_0x0a9e('0x13')][_0x0a9e('0x20')]=function(){var _0x5adda1=this;return function(_0x2b814e){if(_0x2b814e){freeIsNotKey(_0x2b814e,_0x5adda1[_0x0a9e('0x21')],'id');for(var _0x2e1b3a=0x0,_0x148f55={},_0x4b38d9={};_0x2e1b3a<_0x2b814e['length'];_0x2e1b3a+=0x1){_0x148f55=_0x2b814e[_0x2e1b3a];if(_[_0x0a9e('0x18')](_0x5adda1[_0x0a9e('0x21')][_0x148f55['id']])){_0x5adda1['whatsappQueues'][_0x148f55['id']]=new WhatsappQueue(_0x148f55);}else{_0x5adda1[_0x0a9e('0x14')](_0x5adda1[_0x0a9e('0x21')][_0x148f55['id']],_0x148f55);}_0x5adda1[_0x0a9e('0x21')][_0x148f55['id']]['updateRouting']();_0x5adda1[_0x0a9e('0x21')][_0x148f55['id']][_0x0a9e('0x1a')]();}}return _0x5adda1[_0x0a9e('0x21')];};};module[_0x0a9e('0x22')]=Realtime; \ No newline at end of file diff --git a/server/services/routing/rpc/chatInteraction.js b/server/services/routing/rpc/chatInteraction.js new file mode 100644 index 0000000..5854942 --- /dev/null +++ b/server/services/routing/rpc/chatInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3ccf=['addTagsToChatInteraction','../client','Request','UpdateChatInteraction','updateChatInteraction','addTags','AddTagsToChatInteraction'];(function(_0x4182ba,_0x47372e){var _0x288f8c=function(_0x1e2095){while(--_0x1e2095){_0x4182ba['push'](_0x4182ba['shift']());}};_0x288f8c(++_0x47372e);}(_0x3ccf,0x104));var _0xf3cc=function(_0x450d62,_0x43bda4){_0x450d62=_0x450d62-0x0;var _0x39d501=_0x3ccf[_0x450d62];return _0x39d501;};'use strict';var client=require(_0xf3cc('0x0'));exports['update']=function(_0x1b8ed3,_0x3d5332){return client[_0xf3cc('0x1')](_0xf3cc('0x2'),{'body':_0x3d5332,'options':{'where':{'id':_0x1b8ed3}},'log':_0xf3cc('0x3')});};exports[_0xf3cc('0x4')]=function(_0x58110a,_0x1f45c9){return client[_0xf3cc('0x1')](_0xf3cc('0x5'),{'body':_0x1f45c9,'options':{'where':{'id':_0x58110a}},'log':_0xf3cc('0x6')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/chatMessage.js b/server/services/routing/rpc/chatMessage.js new file mode 100644 index 0000000..2cad043 --- /dev/null +++ b/server/services/routing/rpc/chatMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa129=['../client','create','CreateChatMessage','createChatMessage'];(function(_0x2b3f32,_0x539d64){var _0x1a4335=function(_0x2812e7){while(--_0x2812e7){_0x2b3f32['push'](_0x2b3f32['shift']());}};_0x1a4335(++_0x539d64);}(_0xa129,0x1f4));var _0x9a12=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa129[_0x3dd15e];return _0x231fd0;};'use strict';var client=require(_0x9a12('0x0'));exports[_0x9a12('0x1')]=function(_0xc9287a){return client['Request'](_0x9a12('0x2'),{'body':_0xc9287a,'log':_0x9a12('0x3')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/chatQueue.js b/server/services/routing/rpc/chatQueue.js new file mode 100644 index 0000000..12b302c --- /dev/null +++ b/server/services/routing/rpc/chatQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdf98=['strategy','User','Agents','name','online','chatPause','getChatQueues','../client','Request','timeout'];(function(_0x2d7daa,_0x3698e0){var _0x119a17=function(_0x4f717a){while(--_0x4f717a){_0x2d7daa['push'](_0x2d7daa['shift']());}};_0x119a17(++_0x3698e0);}(_0xdf98,0xcf));var _0x8df9=function(_0x5650d7,_0x51f443){_0x5650d7=_0x5650d7-0x0;var _0x42431d=_0xdf98[_0x5650d7];return _0x42431d;};'use strict';var client=require(_0x8df9('0x0'));exports['getChatQueues']=function(){return function(){return client[_0x8df9('0x1')]('GetChatQueue',{'options':{'raw':![],'attributes':['id','name',_0x8df9('0x2'),_0x8df9('0x3')],'include':[{'model':_0x8df9('0x4'),'as':_0x8df9('0x5'),'attributes':['id',_0x8df9('0x6'),_0x8df9('0x7'),_0x8df9('0x8')]}]},'log':_0x8df9('0x9')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/chatQueueReport.js b/server/services/routing/rpc/chatQueueReport.js new file mode 100644 index 0000000..c5f3f23 --- /dev/null +++ b/server/services/routing/rpc/chatQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x46fc=['../client','create','Request','CreateChatQueueReport','update','DESC','UpdateChatQueueReport'];(function(_0x32ab41,_0x99f9a2){var _0x118262=function(_0x2b9141){while(--_0x2b9141){_0x32ab41['push'](_0x32ab41['shift']());}};_0x118262(++_0x99f9a2);}(_0x46fc,0x103));var _0xc46f=function(_0x17c56a,_0x329fc8){_0x17c56a=_0x17c56a-0x0;var _0x15cbfc=_0x46fc[_0x17c56a];return _0x15cbfc;};'use strict';var client=require(_0xc46f('0x0'));exports[_0xc46f('0x1')]=function(_0xf5212c){return client[_0xc46f('0x2')](_0xc46f('0x3'),{'body':_0xf5212c,'log':_0xc46f('0x3')});};exports[_0xc46f('0x4')]=function(_0x24058a,_0x3a56db){return client['Request']('UpdateChatQueueReport',{'body':_0x3a56db,'options':{'where':{'uniqueid':_0x24058a},'order':[['id',_0xc46f('0x5')]],'limit':0x1},'log':_0xc46f('0x6')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/faxInteraction.js b/server/services/routing/rpc/faxInteraction.js new file mode 100644 index 0000000..00b82ed --- /dev/null +++ b/server/services/routing/rpc/faxInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7a54=['Request','UpdateFaxInteraction','addTags','AddTagsToFaxInteraction','../client','update'];(function(_0x26f1b2,_0x33d843){var _0x1624a4=function(_0x58dfb7){while(--_0x58dfb7){_0x26f1b2['push'](_0x26f1b2['shift']());}};_0x1624a4(++_0x33d843);}(_0x7a54,0x106));var _0x47a5=function(_0x5708d6,_0x224ca2){_0x5708d6=_0x5708d6-0x0;var _0x52f35a=_0x7a54[_0x5708d6];return _0x52f35a;};'use strict';var client=require(_0x47a5('0x0'));exports[_0x47a5('0x1')]=function(_0x44b31e,_0x58157c){return client[_0x47a5('0x2')](_0x47a5('0x3'),{'body':_0x58157c,'options':{'where':{'id':_0x44b31e}},'log':'updateFaxInteraction'});};exports[_0x47a5('0x4')]=function(_0x11bf85,_0x2a1a7e){return client[_0x47a5('0x2')](_0x47a5('0x5'),{'body':_0x2a1a7e,'options':{'where':{'id':_0x11bf85}},'log':'addTagsToFaxInteraction'});}; \ No newline at end of file diff --git a/server/services/routing/rpc/faxMessage.js b/server/services/routing/rpc/faxMessage.js new file mode 100644 index 0000000..d547759 --- /dev/null +++ b/server/services/routing/rpc/faxMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1a4b=['../client','Request','CreateFaxMessage','createFaxMessage'];(function(_0x32f7d7,_0x54231b){var _0x133d09=function(_0x41a7ab){while(--_0x41a7ab){_0x32f7d7['push'](_0x32f7d7['shift']());}};_0x133d09(++_0x54231b);}(_0x1a4b,0x158));var _0xb1a4=function(_0x283318,_0x2932f4){_0x283318=_0x283318-0x0;var _0x5d4ab2=_0x1a4b[_0x283318];return _0x5d4ab2;};'use strict';var client=require(_0xb1a4('0x0'));exports['create']=function(_0x5652c6){return client[_0xb1a4('0x1')](_0xb1a4('0x2'),{'body':_0x5652c6,'log':_0xb1a4('0x3')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/faxQueue.js b/server/services/routing/rpc/faxQueue.js new file mode 100644 index 0000000..832a357 --- /dev/null +++ b/server/services/routing/rpc/faxQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc4e0=['Request','GetFaxQueue','timeout','strategy','User','Agents','name','online','../client','getFaxQueues'];(function(_0x2bbe8d,_0x5156c2){var _0x539e7a=function(_0x518447){while(--_0x518447){_0x2bbe8d['push'](_0x2bbe8d['shift']());}};_0x539e7a(++_0x5156c2);}(_0xc4e0,0x1e8));var _0x0c4e=function(_0xc133e4,_0x5e5dea){_0xc133e4=_0xc133e4-0x0;var _0x449769=_0xc4e0[_0xc133e4];return _0x449769;};'use strict';var client=require(_0x0c4e('0x0'));exports[_0x0c4e('0x1')]=function(){return function(){return client[_0x0c4e('0x2')](_0x0c4e('0x3'),{'options':{'raw':![],'attributes':['id','name',_0x0c4e('0x4'),_0x0c4e('0x5')],'include':[{'model':_0x0c4e('0x6'),'as':_0x0c4e('0x7'),'attributes':['id',_0x0c4e('0x8'),_0x0c4e('0x9'),'faxPause']}]},'log':'getFaxQueues'});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/faxQueueReport.js b/server/services/routing/rpc/faxQueueReport.js new file mode 100644 index 0000000..3238f83 --- /dev/null +++ b/server/services/routing/rpc/faxQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0d9c=['CreateFaxQueueReport','update','DESC','UpdateFaxQueueReport','create','Request'];(function(_0x54a9b9,_0x31352f){var _0x2a34ef=function(_0x50f592){while(--_0x50f592){_0x54a9b9['push'](_0x54a9b9['shift']());}};_0x2a34ef(++_0x31352f);}(_0x0d9c,0x7c));var _0xc0d9=function(_0x33d4dd,_0xab8529){_0x33d4dd=_0x33d4dd-0x0;var _0x44d328=_0x0d9c[_0x33d4dd];return _0x44d328;};'use strict';var client=require('../client');exports[_0xc0d9('0x0')]=function(_0x42effb){return client[_0xc0d9('0x1')](_0xc0d9('0x2'),{'body':_0x42effb,'log':'CreateFaxQueueReport'});};exports[_0xc0d9('0x3')]=function(_0x243377,_0x5e6b8d){return client[_0xc0d9('0x1')]('UpdateFaxQueueReport',{'body':_0x5e6b8d,'options':{'where':{'uniqueid':_0x243377},'order':[['id',_0xc0d9('0x4')]],'limit':0x1},'log':_0xc0d9('0x5')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/interval.js b/server/services/routing/rpc/interval.js new file mode 100644 index 0000000..b39532d --- /dev/null +++ b/server/services/routing/rpc/interval.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x2b3b=['Intervals','name','interval','getIntervals','../client','Request','GetInterval','Interval'];(function(_0x14781a,_0xfb7f61){var _0x154ea4=function(_0x4adead){while(--_0x4adead){_0x14781a['push'](_0x14781a['shift']());}};_0x154ea4(++_0xfb7f61);}(_0x2b3b,0x8c));var _0xb2b3=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0x2b3b[_0x167cc1];return _0x10bc4b;};'use strict';var client=require(_0xb2b3('0x0'));exports['getIntervals']=function(){return function(){return client[_0xb2b3('0x1')](_0xb2b3('0x2'),{'options':{'raw':![],'where':{'IntervalId':null},'attributes':['id','name'],'include':[{'model':_0xb2b3('0x3'),'as':_0xb2b3('0x4'),'attributes':['id',_0xb2b3('0x5'),_0xb2b3('0x6')]}]},'log':_0xb2b3('0x7')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/mailInteraction.js b/server/services/routing/rpc/mailInteraction.js new file mode 100644 index 0000000..804f6f4 --- /dev/null +++ b/server/services/routing/rpc/mailInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb03e=['addTagsToChatInteraction','update','Request','UpdateMailInteraction','updateMailInteraction','addTags','AddTagsToMailInteraction'];(function(_0x49e827,_0x146e0f){var _0x156bf4=function(_0x3d2771){while(--_0x3d2771){_0x49e827['push'](_0x49e827['shift']());}};_0x156bf4(++_0x146e0f);}(_0xb03e,0x1eb));var _0xeb03=function(_0x82aa85,_0x1f7866){_0x82aa85=_0x82aa85-0x0;var _0x4dc5bb=_0xb03e[_0x82aa85];return _0x4dc5bb;};'use strict';var client=require('../client');exports[_0xeb03('0x0')]=function(_0x399504,_0x868905){return client[_0xeb03('0x1')](_0xeb03('0x2'),{'body':_0x868905,'options':{'where':{'id':_0x399504}},'log':_0xeb03('0x3')});};exports[_0xeb03('0x4')]=function(_0x1fe650,_0x474450){return client[_0xeb03('0x1')](_0xeb03('0x5'),{'body':_0x474450,'options':{'where':{'id':_0x1fe650}},'log':_0xeb03('0x6')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/mailMessage.js b/server/services/routing/rpc/mailMessage.js new file mode 100644 index 0000000..886a384 --- /dev/null +++ b/server/services/routing/rpc/mailMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8a14=['../client','create','Request','CreateMailMessage','createMailMessage'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x8a14,0x186));var _0x48a1=function(_0x127d7b,_0x54ec03){_0x127d7b=_0x127d7b-0x0;var _0x3da9b7=_0x8a14[_0x127d7b];return _0x3da9b7;};'use strict';var client=require(_0x48a1('0x0'));exports[_0x48a1('0x1')]=function(_0x35b55c){return client[_0x48a1('0x2')](_0x48a1('0x3'),{'body':_0x35b55c,'log':_0x48a1('0x4')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/mailQueue.js b/server/services/routing/rpc/mailQueue.js new file mode 100644 index 0000000..1280f4c --- /dev/null +++ b/server/services/routing/rpc/mailQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6cfc=['name','timeout','User','Agents','online','getMailQueues','Request','GetMailQueue'];(function(_0xdea41a,_0x552987){var _0x15d0d8=function(_0x1e0d0b){while(--_0x1e0d0b){_0xdea41a['push'](_0xdea41a['shift']());}};_0x15d0d8(++_0x552987);}(_0x6cfc,0x95));var _0xc6cf=function(_0x4c0622,_0x5dacaf){_0x4c0622=_0x4c0622-0x0;var _0x1799d8=_0x6cfc[_0x4c0622];return _0x1799d8;};'use strict';var client=require('../client');exports[_0xc6cf('0x0')]=function(){return function(){return client[_0xc6cf('0x1')](_0xc6cf('0x2'),{'options':{'raw':![],'attributes':['id',_0xc6cf('0x3'),_0xc6cf('0x4'),'strategy'],'include':[{'model':_0xc6cf('0x5'),'as':_0xc6cf('0x6'),'attributes':['id',_0xc6cf('0x3'),_0xc6cf('0x7'),'mailPause']}]},'log':_0xc6cf('0x0')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/mailQueueReport.js b/server/services/routing/rpc/mailQueueReport.js new file mode 100644 index 0000000..0eec1f4 --- /dev/null +++ b/server/services/routing/rpc/mailQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x388e=['DESC','../client','CreateMailQueueReport','update','Request','UpdateMailQueueReport'];(function(_0x40f795,_0x57337a){var _0x1ce6ab=function(_0xca7bea){while(--_0xca7bea){_0x40f795['push'](_0x40f795['shift']());}};_0x1ce6ab(++_0x57337a);}(_0x388e,0x127));var _0xe388=function(_0x420278,_0x23b281){_0x420278=_0x420278-0x0;var _0x3d1dfa=_0x388e[_0x420278];return _0x3d1dfa;};'use strict';var client=require(_0xe388('0x0'));exports['create']=function(_0x1750ae){return client['Request']('CreateMailQueueReport',{'body':_0x1750ae,'log':_0xe388('0x1')});};exports[_0xe388('0x2')]=function(_0x242e8d,_0x4f7887){return client[_0xe388('0x3')](_0xe388('0x4'),{'body':_0x4f7887,'options':{'where':{'uniqueid':_0x242e8d},'order':[['id',_0xe388('0x5')]],'limit':0x1},'log':'UpdateMailQueueReport'});}; \ No newline at end of file diff --git a/server/services/routing/rpc/openchannelInteraction.js b/server/services/routing/rpc/openchannelInteraction.js new file mode 100644 index 0000000..a0e14dd --- /dev/null +++ b/server/services/routing/rpc/openchannelInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x184b=['../client','Request','UpdateOpenchannelInteraction','updateOpenchannelInteraction'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x184b,0x6c));var _0xb184=function(_0x1d094b,_0x251681){_0x1d094b=_0x1d094b-0x0;var _0x1bf90b=_0x184b[_0x1d094b];return _0x1bf90b;};'use strict';var client=require(_0xb184('0x0'));exports['update']=function(_0x5ee8b3,_0x394563){return client[_0xb184('0x1')](_0xb184('0x2'),{'body':_0x394563,'options':{'where':{'id':_0x5ee8b3}},'log':_0xb184('0x3')});};exports['addTags']=function(_0x51c94d,_0x50c4ec){return client[_0xb184('0x1')]('AddTagsToOpenchannelInteraction',{'body':_0x50c4ec,'options':{'where':{'id':_0x51c94d}},'log':'addTagsToChatInteraction'});}; \ No newline at end of file diff --git a/server/services/routing/rpc/openchannelMessage.js b/server/services/routing/rpc/openchannelMessage.js new file mode 100644 index 0000000..2da8a39 --- /dev/null +++ b/server/services/routing/rpc/openchannelMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0eb4=['../client','create'];(function(_0x4eedda,_0x4f1f2c){var _0x859f0=function(_0x177cb6){while(--_0x177cb6){_0x4eedda['push'](_0x4eedda['shift']());}};_0x859f0(++_0x4f1f2c);}(_0x0eb4,0x1e6));var _0x40eb=function(_0xb1439,_0x2a9484){_0xb1439=_0xb1439-0x0;var _0x2c103b=_0x0eb4[_0xb1439];return _0x2c103b;};'use strict';var client=require(_0x40eb('0x0'));exports[_0x40eb('0x1')]=function(_0x4eb788){return client['Request']('CreateOpenchannelMessage',{'body':_0x4eb788,'log':'createOpenchannelMessage'});}; \ No newline at end of file diff --git a/server/services/routing/rpc/openchannelQueue.js b/server/services/routing/rpc/openchannelQueue.js new file mode 100644 index 0000000..9f63f78 --- /dev/null +++ b/server/services/routing/rpc/openchannelQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x93ed=['Request','GetOpenchannelQueue','name','strategy','Agents','openchannelPause','../client','getOpenchannelQueues'];(function(_0x3a3ea6,_0x84d32){var _0x13a16b=function(_0x21b739){while(--_0x21b739){_0x3a3ea6['push'](_0x3a3ea6['shift']());}};_0x13a16b(++_0x84d32);}(_0x93ed,0xfe));var _0xd93e=function(_0x3c9eb2,_0x161a8a){_0x3c9eb2=_0x3c9eb2-0x0;var _0x2333ca=_0x93ed[_0x3c9eb2];return _0x2333ca;};'use strict';var client=require(_0xd93e('0x0'));exports[_0xd93e('0x1')]=function(){return function(){return client[_0xd93e('0x2')](_0xd93e('0x3'),{'options':{'raw':![],'attributes':['id',_0xd93e('0x4'),'timeout',_0xd93e('0x5')],'include':[{'model':'User','as':_0xd93e('0x6'),'attributes':['id',_0xd93e('0x4'),'online',_0xd93e('0x7')]}]},'log':_0xd93e('0x1')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/openchannelQueueReport.js b/server/services/routing/rpc/openchannelQueueReport.js new file mode 100644 index 0000000..2427c12 --- /dev/null +++ b/server/services/routing/rpc/openchannelQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8978=['CreateOpenchannelQueueReport','update','Request','UpdateOpenchannelQueueReport'];(function(_0x384ca8,_0x32d496){var _0x1c1cda=function(_0x45317d){while(--_0x45317d){_0x384ca8['push'](_0x384ca8['shift']());}};_0x1c1cda(++_0x32d496);}(_0x8978,0x1cc));var _0x8897=function(_0x1035c1,_0x2d8583){_0x1035c1=_0x1035c1-0x0;var _0x308d67=_0x8978[_0x1035c1];return _0x308d67;};'use strict';var client=require('../client');exports['create']=function(_0xcf3330){return client['Request'](_0x8897('0x0'),{'body':_0xcf3330,'log':'CreateOpenchannelQueueReport'});};exports[_0x8897('0x1')]=function(_0x477c4e,_0x3b5a32){return client[_0x8897('0x2')](_0x8897('0x3'),{'body':_0x3b5a32,'options':{'where':{'uniqueid':_0x477c4e},'order':[['id','DESC']],'limit':0x1},'log':_0x8897('0x3')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/smsInteraction.js b/server/services/routing/rpc/smsInteraction.js new file mode 100644 index 0000000..053f3bc --- /dev/null +++ b/server/services/routing/rpc/smsInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe700=['updateSmsInteraction','addTagsToSmsInteraction','../client','update','Request'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xe700,0x16a));var _0x0e70=function(_0x12e7b7,_0x1ece92){_0x12e7b7=_0x12e7b7-0x0;var _0x5bbd6f=_0xe700[_0x12e7b7];return _0x5bbd6f;};'use strict';var client=require(_0x0e70('0x0'));exports[_0x0e70('0x1')]=function(_0x245ff7,_0x1c63f0){return client[_0x0e70('0x2')]('UpdateSmsInteraction',{'body':_0x1c63f0,'options':{'where':{'id':_0x245ff7}},'log':_0x0e70('0x3')});};exports['addTags']=function(_0x20335e,_0x2cc22e){return client['Request']('AddTagsToSmsInteraction',{'body':_0x2cc22e,'options':{'where':{'id':_0x20335e}},'log':_0x0e70('0x4')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/smsMessage.js b/server/services/routing/rpc/smsMessage.js new file mode 100644 index 0000000..dc26227 --- /dev/null +++ b/server/services/routing/rpc/smsMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xed83=['createSmsMessage','../client','create','Request','CreateSmsMessage'];(function(_0x57b947,_0xd0ccb8){var _0x1b75e9=function(_0x3318f0){while(--_0x3318f0){_0x57b947['push'](_0x57b947['shift']());}};_0x1b75e9(++_0xd0ccb8);}(_0xed83,0x10f));var _0x3ed8=function(_0x24af20,_0xb1b03b){_0x24af20=_0x24af20-0x0;var _0x20bbc5=_0xed83[_0x24af20];return _0x20bbc5;};'use strict';var client=require(_0x3ed8('0x0'));exports[_0x3ed8('0x1')]=function(_0x1b2aee){return client[_0x3ed8('0x2')](_0x3ed8('0x3'),{'body':_0x1b2aee,'log':_0x3ed8('0x4')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/smsQueue.js b/server/services/routing/rpc/smsQueue.js new file mode 100644 index 0000000..4eae86a --- /dev/null +++ b/server/services/routing/rpc/smsQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0713=['getSmsQueues','Request','GetSmsQueue','name','timeout','strategy','Agents','online','smsPause'];(function(_0x51904f,_0x439694){var _0x24dc27=function(_0x3046b1){while(--_0x3046b1){_0x51904f['push'](_0x51904f['shift']());}};_0x24dc27(++_0x439694);}(_0x0713,0x1ba));var _0x3071=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0713[_0x3dd15e];return _0x231fd0;};'use strict';var client=require('../client');exports['getSmsQueues']=function(){return function(){return client[_0x3071('0x0')](_0x3071('0x1'),{'options':{'raw':![],'attributes':['id',_0x3071('0x2'),_0x3071('0x3'),_0x3071('0x4')],'include':[{'model':'User','as':_0x3071('0x5'),'attributes':['id',_0x3071('0x2'),_0x3071('0x6'),_0x3071('0x7')]}]},'log':_0x3071('0x8')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/smsQueueReport.js b/server/services/routing/rpc/smsQueueReport.js new file mode 100644 index 0000000..23d8b32 --- /dev/null +++ b/server/services/routing/rpc/smsQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xedd9=['create','Request','CreateSmsQueueReport','update','UpdateSmsQueueReport','DESC'];(function(_0xb6e43,_0x1568fc){var _0x47c40f=function(_0x107786){while(--_0x107786){_0xb6e43['push'](_0xb6e43['shift']());}};_0x47c40f(++_0x1568fc);}(_0xedd9,0xfc));var _0x9edd=function(_0x329073,_0x1ceca5){_0x329073=_0x329073-0x0;var _0x2182f9=_0xedd9[_0x329073];return _0x2182f9;};'use strict';var client=require('../client');exports[_0x9edd('0x0')]=function(_0x2d7989){return client[_0x9edd('0x1')](_0x9edd('0x2'),{'body':_0x2d7989,'log':_0x9edd('0x2')});};exports[_0x9edd('0x3')]=function(_0x3e6d3a,_0x36b53f){return client['Request'](_0x9edd('0x4'),{'body':_0x36b53f,'options':{'where':{'uniqueid':_0x3e6d3a},'order':[['id',_0x9edd('0x5')]],'limit':0x1},'log':_0x9edd('0x4')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/user.js b/server/services/routing/rpc/user.js new file mode 100644 index 0000000..4ed55b6 --- /dev/null +++ b/server/services/routing/rpc/user.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa9e0=['name','pauseType','lastPauseAt','voicePause','chatPause','mailPause','smsPause','whatsappPause','openchannelPause','faxCapacity','openchannelCapacity','../client','getAgents','Request'];(function(_0x3ec73d,_0x57407b){var _0x401d5c=function(_0x317037){while(--_0x317037){_0x3ec73d['push'](_0x3ec73d['shift']());}};_0x401d5c(++_0x57407b);}(_0xa9e0,0x123));var _0x0a9e=function(_0x5e3b04,_0xbb6795){_0x5e3b04=_0x5e3b04-0x0;var _0x1fc44d=_0xa9e0[_0x5e3b04];return _0x1fc44d;};'use strict';var client=require(_0x0a9e('0x0'));exports[_0x0a9e('0x1')]=function(){return function(){return client[_0x0a9e('0x2')]('GetUser',{'options':{'raw':!![],'where':{'role':'agent'},'attributes':['id',_0x0a9e('0x3'),'online',_0x0a9e('0x4'),_0x0a9e('0x5'),_0x0a9e('0x6'),_0x0a9e('0x7'),_0x0a9e('0x8'),'faxPause',_0x0a9e('0x9'),_0x0a9e('0xa'),_0x0a9e('0xb'),'chatCapacity','mailCapacity',_0x0a9e('0xc'),'smsCapacity','whatsappCapacity',_0x0a9e('0xd')]},'log':_0x0a9e('0x1')});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/whatsappInteraction.js b/server/services/routing/rpc/whatsappInteraction.js new file mode 100644 index 0000000..dfda00b --- /dev/null +++ b/server/services/routing/rpc/whatsappInteraction.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7919=['UpdateWhatsappInteraction','updateWhatsappInteraction','AddTagsToWhatsappInteraction','addTagsToWhatsappInteraction','../client','update','Request'];(function(_0xaa2270,_0x207784){var _0x41cc2c=function(_0x556c76){while(--_0x556c76){_0xaa2270['push'](_0xaa2270['shift']());}};_0x41cc2c(++_0x207784);}(_0x7919,0xeb));var _0x9791=function(_0x1db7fb,_0x54396b){_0x1db7fb=_0x1db7fb-0x0;var _0x5dd4c7=_0x7919[_0x1db7fb];return _0x5dd4c7;};'use strict';var client=require(_0x9791('0x0'));exports[_0x9791('0x1')]=function(_0x466be6,_0x1c714b){return client[_0x9791('0x2')](_0x9791('0x3'),{'body':_0x1c714b,'options':{'where':{'id':_0x466be6}},'log':_0x9791('0x4')});};exports['addTags']=function(_0x13a1a5,_0x193919){return client['Request'](_0x9791('0x5'),{'body':_0x193919,'options':{'where':{'id':_0x13a1a5}},'log':_0x9791('0x6')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/whatsappMessage.js b/server/services/routing/rpc/whatsappMessage.js new file mode 100644 index 0000000..7f57d89 --- /dev/null +++ b/server/services/routing/rpc/whatsappMessage.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0fbf=['create','Request','CreateWhatsappMessage','createWhatsappMessage','../client'];(function(_0xfcc030,_0x3ec053){var _0x5caa66=function(_0xf2e6d2){while(--_0xf2e6d2){_0xfcc030['push'](_0xfcc030['shift']());}};_0x5caa66(++_0x3ec053);}(_0x0fbf,0x130));var _0xf0fb=function(_0x694e86,_0x2da8d7){_0x694e86=_0x694e86-0x0;var _0x29b21c=_0x0fbf[_0x694e86];return _0x29b21c;};'use strict';var client=require(_0xf0fb('0x0'));exports[_0xf0fb('0x1')]=function(_0x3318b1){return client[_0xf0fb('0x2')](_0xf0fb('0x3'),{'body':_0x3318b1,'log':_0xf0fb('0x4')});}; \ No newline at end of file diff --git a/server/services/routing/rpc/whatsappQueue.js b/server/services/routing/rpc/whatsappQueue.js new file mode 100644 index 0000000..76d4561 --- /dev/null +++ b/server/services/routing/rpc/whatsappQueue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xbedb=['Agents','online','whatsappPause','../client','getWhatsappQueues','Request','GetWhatsappQueue','name','strategy','User'];(function(_0x1ec280,_0x5b56b3){var _0x4eaf0d=function(_0x333b9d){while(--_0x333b9d){_0x1ec280['push'](_0x1ec280['shift']());}};_0x4eaf0d(++_0x5b56b3);}(_0xbedb,0x17f));var _0xbbed=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xbedb[_0x3dd15e];return _0x231fd0;};'use strict';var client=require(_0xbbed('0x0'));exports[_0xbbed('0x1')]=function(){return function(){return client[_0xbbed('0x2')](_0xbbed('0x3'),{'options':{'raw':![],'attributes':['id',_0xbbed('0x4'),'timeout',_0xbbed('0x5')],'include':[{'model':_0xbbed('0x6'),'as':_0xbbed('0x7'),'attributes':['id',_0xbbed('0x4'),_0xbbed('0x8'),_0xbbed('0x9')]}]},'log':'getWhatsappQueues'});};}; \ No newline at end of file diff --git a/server/services/routing/rpc/whatsappQueueReport.js b/server/services/routing/rpc/whatsappQueueReport.js new file mode 100644 index 0000000..593a26a --- /dev/null +++ b/server/services/routing/rpc/whatsappQueueReport.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x42a8=['DESC','UpdateWhatsappQueueReport','../client','create','Request','CreateWhatsappQueueReport'];(function(_0x76ccdb,_0x17d9f3){var _0x39ce12=function(_0x1d5d76){while(--_0x1d5d76){_0x76ccdb['push'](_0x76ccdb['shift']());}};_0x39ce12(++_0x17d9f3);}(_0x42a8,0xc8));var _0x842a=function(_0x51d129,_0x175d7d){_0x51d129=_0x51d129-0x0;var _0x44c377=_0x42a8[_0x51d129];return _0x44c377;};'use strict';var client=require(_0x842a('0x0'));exports[_0x842a('0x1')]=function(_0x1daebc){return client[_0x842a('0x2')]('CreateWhatsappQueueReport',{'body':_0x1daebc,'log':_0x842a('0x3')});};exports['update']=function(_0x5ad0c2,_0x3177c6){return client[_0x842a('0x2')]('UpdateWhatsappQueueReport',{'body':_0x3177c6,'options':{'where':{'uniqueid':_0x5ad0c2},'order':[['id',_0x842a('0x4')]],'limit':0x1},'log':_0x842a('0x5')});}; \ No newline at end of file diff --git a/server/services/routing/server/applications/agent.js b/server/services/routing/server/applications/agent.js new file mode 100644 index 0000000..930f6d7 --- /dev/null +++ b/server/services/routing/server/applications/agent.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x1089=['[%s][AGENT][NAME:%s][STATUS:%s]','name','toLowerCase','length','message','join','stop','find','createQueue','atimeout','channel','START:%s','end','[%s][AGENT]\x20ROUTING\x20STOPPED','close','rules','complete','[%s][AGENT]\x20ROUTING\x20END','next','agent','[%s][QUEUE]\x20%s','stack','validate','lodash','util','seq-queue','../../../../config/logger','./strategy','string','name\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','info','format'];(function(_0x3342cc,_0x41e015){var _0x3d0d3a=function(_0x32e7b9){while(--_0x32e7b9){_0x3342cc['push'](_0x3342cc['shift']());}};_0x3d0d3a(++_0x41e015);}(_0x1089,0xbb));var _0x9108=function(_0x328a2c,_0xb5d7d5){_0x328a2c=_0x328a2c-0x0;var _0x841706=_0x1089[_0x328a2c];return _0x841706;};'use strict';var schema=require(_0x9108('0x0'));var _=require(_0x9108('0x1'));var util=require(_0x9108('0x2'));var seqqueue=require(_0x9108('0x3'));var logger=require(_0x9108('0x4'))('routing');var strategy=require(_0x9108('0x5'));var queue=schema({'name':{'type':_0x9108('0x6'),'required':!![],'message':_0x9108('0x7')},'timeout':{'type':_0x9108('0x8'),'message':'timeout\x20is\x20a\x20number'}});function writeLog(_0x19ba5d,_0x60ebe5,_0x5a18ef){return logger[_0x9108('0x9')](util[_0x9108('0xa')](_0x9108('0xb'),_0x19ba5d,_0x60ebe5[_0x9108('0xc')],_0x5a18ef));}function handleFindAgent(_0x47dc66){return function(_0x5d8c16){return _0x5d8c16[_0x9108('0xc')]['toLowerCase']()===_0x47dc66[_0x9108('0xd')]();};}exports['consequence']=function(_0xa13e3d,_0x51a00d,_0x4db99e,_0x1f736e){return function(_0x339f85){try{var _0x5dfc11={'name':_0x51a00d[0x0],'timeout':_0x51a00d[0x1]};var _0x127cdb=queue['validate'](_0x5dfc11,{'typecast':!![]});if(_0x127cdb[_0x9108('0xe')]){logger['error']('[%s][AGENT]\x20%s',_0xa13e3d,_['map'](_0x127cdb,_0x9108('0xf'))[_0x9108('0x10')](',\x20'));_0x339f85[_0x9108('0x11')]();}else{var _0x305b00=_[_0x9108('0x12')](_0x4db99e['agents'],handleFindAgent(_0x5dfc11[_0x9108('0xc')]));if(_0x305b00){var _0x1b307c=(_0x5dfc11['timeout']||0xa)*0x3e8;var _0x50f9fd,_0x523f31;var _0x1b17ef=seqqueue[_0x9108('0x13')](_0x1b307c);_0x1b17ef['id']=_0xa13e3d;_0x1b17ef[_0x9108('0x14')]=_0x1b307c;_0x1b17ef[_0x9108('0x15')]=_0x1f736e[_0x9108('0x15')];writeLog(_0xa13e3d,_0x305b00,util['format'](_0x9108('0x16'),_0x1b307c));_0x4db99e['rules'][_0xa13e3d]['on'](_0x9108('0x17'),function(){logger['info'](_0x9108('0x18'),_0xa13e3d);clearTimeout(_0x523f31);_0x523f31=undefined;_0x1b17ef[_0x9108('0x19')]();if(_0x4db99e['rules'][_0xa13e3d]){delete _0x4db99e['rules'][_0xa13e3d];}_0x339f85['stop']();});_0x4db99e[_0x9108('0x1a')][_0xa13e3d]['on'](_0x9108('0x1b'),function(){if(_0x4db99e[_0x9108('0x1a')][_0xa13e3d]){delete _0x4db99e[_0x9108('0x1a')][_0xa13e3d];}});_0x523f31=setTimeout(function(){logger['info'](_0x9108('0x1c'),_0xa13e3d);clearTimeout(_0x523f31);_0x1b17ef[_0x9108('0x19')]();_0x339f85[_0x9108('0x1d')]();},_0x1b307c);strategy[_0x9108('0x1e')](_0x1b17ef,_0x305b00,_0x4db99e,_0x1f736e);}else{logger['error']('[%s][AGENT]\x20agent\x20not\x20found\x20%s',_0xa13e3d,_0x5dfc11[_0x9108('0xc')]);_0x339f85[_0x9108('0x11')]();}}}catch(_0x2a094d){console['log'](_0x2a094d);logger['error'](_0x9108('0x1f'),_0xa13e3d,_0x2a094d[_0x9108('0x20')]);_0x339f85[_0x9108('0x11')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/amazonlex.js b/server/services/routing/server/applications/amazonlex.js new file mode 100644 index 0000000..625bf40 --- /dev/null +++ b/server/services/routing/server/applications/amazonlex.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x7254=['out','channel','whatsapp','phone','upperFirst','AccountId','account','InteractionId','created','isEmpty','body','getMustacheRender','Message','create','info','[%s][AMAZONLEX]\x20%s','catch','error','stringify','finally','[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','LexRuntime','$LATEST','message','amazonlex','providerName','then','dialogState','Failed','lodash','moment','aws-sdk','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','next','contact','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x57e17c,_0x3b99be){var _0x3bb416=function(_0x26c802){while(--_0x26c802){_0x57e17c['push'](_0x57e17c['shift']());}};_0x3bb416(++_0x3b99be);}(_0x7254,0x114));var _0x4725=function(_0x3324e2,_0xcca163){_0x3324e2=_0x3324e2-0x0;var _0x4ce66b=_0x7254[_0x3324e2];return _0x4ce66b;};'use strict';var _=require(_0x4725('0x0'));var moment=require(_0x4725('0x1'));var AWS=require(_0x4725('0x2'));var utils=require(_0x4725('0x3'));var logger=require('../../../../config/logger')(_0x4725('0x4'));var rpc={'chatMessage':require(_0x4725('0x5')),'openchannelMessage':require(_0x4725('0x6')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0x4725('0x7')),'faxMessage':require(_0x4725('0x8')),'whatsappMessage':require(_0x4725('0x9'))};exports[_0x4725('0xa')]=function(_0x5d4f13,_0x495857){return function(_0x2efa06){try{if(!_[_0x4725('0xb')](this[_0x4725('0xc')][_0x4725('0xd')])){logger['info']('[%s][AMAZONLEX]\x20%s',_0x5d4f13,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x2efa06[_0x4725('0xe')]();}var _0x4eed46={'ContactId':this[_0x4725('0xf')]['id'],'sentAt':moment()[_0x4725('0x10')](_0x4725('0x11')),'direction':_0x4725('0x12')};if(this[_0x4725('0x13')]==='sms'||this[_0x4725('0x13')]===_0x4725('0x14')){_0x4eed46['phone']=this[_0x4725('0xc')][_0x4725('0x15')];}var _0x3d999d=this[_0x4725('0x13')];if(_0x3d999d==='chat'){_0x4eed46['ChatWebsiteId']=this['account']['id'];}else{_0x4eed46[_[_0x4725('0x16')](_0x3d999d)+_0x4725('0x17')]=this[_0x4725('0x18')]['id'];}_0x4eed46[_['upperFirst'](_0x3d999d)+_0x4725('0x19')]=this['interaction']['id'];if(this['interaction'][_0x4725('0x1a')]){var _0x19be9a=_0x495857[0x4];if(!_[_0x4725('0x1b')](_0x19be9a)){_0x4eed46[_0x4725('0x1c')]=utils[_0x4725('0x1d')](_0x19be9a,this);return rpc[_0x3d999d+_0x4725('0x1e')][_0x4725('0x1f')](_0x4eed46)['then'](function(_0x5f7ea1){logger[_0x4725('0x20')](_0x4725('0x21'),_0x5d4f13,_0x4eed46['body']);})[_0x4725('0x22')](function(_0x36a626){logger[_0x4725('0x23')](_0x4725('0x21'),_0x5d4f13,JSON[_0x4725('0x24')](_0x36a626));})[_0x4725('0x25')](function(){logger[_0x4725('0x20')](_0x4725('0x26'),_0x5d4f13);_0x2efa06[_0x4725('0x27')]();});}else{logger[_0x4725('0x20')](_0x4725('0x28'),_0x5d4f13);_0x2efa06['stop']();}}else{var _0x21e132=this;var _0x246c6e=new AWS[(_0x4725('0x29'))]({'accessKeyId':_0x495857[0x0],'secretAccessKey':_0x495857[0x1],'region':_0x495857[0x2]});var _0x225973={'botAlias':_0x4725('0x2a'),'botName':_0x495857[0x3],'inputText':this[_0x4725('0x2b')][_0x4725('0x1c')],'userId':this[_0x4725('0x13')]+':'+this[_0x4725('0xc')]['id']['toString']()};_0x246c6e['postText'](_0x225973,function(_0x788f17,_0x24404a){if(_0x788f17){logger[_0x4725('0x23')](_0x4725('0x21'),_0x5d4f13,_0x788f17[_0x4725('0x2b')]);_0x2efa06[_0x4725('0xe')]();}else if(_0x24404a&&_0x24404a[_0x4725('0x2b')]){_0x21e132['body'][_0x4725('0x2c')]=_0x24404a;_0x4eed46['body']=_0x24404a[_0x4725('0x2b')];_0x4eed46[_0x4725('0x2d')]='amazonlex';_0x4eed46['providerResponse']=JSON[_0x4725('0x24')](_0x24404a);return rpc[_0x3d999d+_0x4725('0x1e')][_0x4725('0x1f')](_0x4eed46)[_0x4725('0x2e')](function(_0x265a1e){logger[_0x4725('0x20')](_0x4725('0x21'),_0x5d4f13,_0x4eed46[_0x4725('0x1c')]);if(_0x24404a[_0x4725('0x2f')]==_0x4725('0x30')){_0x2efa06[_0x4725('0xe')]();}else{_0x2efa06[_0x4725('0x27')]();}})[_0x4725('0x22')](function(_0x396d5f){logger[_0x4725('0x23')]('[%s][AMAZONLEX]\x20%s',_0x5d4f13,JSON[_0x4725('0x24')](_0x396d5f));_0x2efa06[_0x4725('0xe')]();});}else{_0x2efa06[_0x4725('0xe')]();}});}}catch(_0x5e4c73){logger['error'](_0x4725('0x21'),_0x5d4f13,JSON['stringify'](_0x5e4c73));_0x2efa06[_0x4725('0x27')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/autoreply.js b/server/services/routing/server/applications/autoreply.js new file mode 100644 index 0000000..6ae47ec --- /dev/null +++ b/server/services/routing/server/applications/autoreply.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x92e9=['YYYY-MM-DD\x20HH:mm:ss','getMustacheRender','message','from','phone','read','subject','Re:','Re:\x20','ChatWebsiteId','upperFirst','AccountId','account','Message','inReplyTo','messageId','html','','replace','','auto-replied','All','sendMailMessage','smtpOptions','then','stringify','catch','error','[RPC][%s][AUTOREPLY]\x20%s','Interaction','update','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','create','finally','resolve','stop','lodash','moment','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/chatInteraction','../../rpc/openchannelInteraction','../../rpc/mailInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','../../mailRpc','channel','mail','body','isAutoreply','info','[%s][AUTOREPLY]\x20%s','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','next','isNil','interaction','created','Autoreply\x20already\x20sent','autoreplyExecuted','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','One\x20Time\x20already\x20sent','contact','format'];(function(_0x38bcf8,_0x11307d){var _0x2a035e=function(_0x35e3f0){while(--_0x35e3f0){_0x38bcf8['push'](_0x38bcf8['shift']());}};_0x2a035e(++_0x11307d);}(_0x92e9,0xae));var _0x992e=function(_0x158bda,_0x3f9a8b){_0x158bda=_0x158bda-0x0;var _0x2643fe=_0x92e9[_0x158bda];return _0x2643fe;};'use strict';var _=require(_0x992e('0x0'));var moment=require(_0x992e('0x1'));var utils=require(_0x992e('0x2'));var logger=require(_0x992e('0x3'))('routing');var rpc={'chatMessage':require(_0x992e('0x4')),'openchannelMessage':require(_0x992e('0x5')),'mailMessage':require(_0x992e('0x6')),'smsMessage':require(_0x992e('0x7')),'faxMessage':require(_0x992e('0x8')),'whatsappMessage':require('../../rpc/whatsappMessage'),'chatInteraction':require(_0x992e('0x9')),'openchannelInteraction':require(_0x992e('0xa')),'mailInteraction':require(_0x992e('0xb')),'smsInteraction':require(_0x992e('0xc')),'faxInteraction':require(_0x992e('0xd')),'whatsappInteraction':require(_0x992e('0xe'))};var mailRpc=require(_0x992e('0xf'));exports['consequence']=function(_0x509ea2,_0x193eb6,_0x56226c,_0x29dedb){return function(_0x4a0bf6){try{var _0x5f3eb5=this[_0x992e('0x10')];if(_0x5f3eb5===_0x992e('0x11')&&_0x29dedb[_0x992e('0x12')][_0x992e('0x13')]){logger[_0x992e('0x14')](_0x992e('0x15'),_0x509ea2,_0x992e('0x16'));return _0x4a0bf6[_0x992e('0x17')]();}if(_0x193eb6[0x0]==='1'&&(_[_0x992e('0x18')](this[_0x992e('0x19')][_0x992e('0x1a')])||!this[_0x992e('0x19')][_0x992e('0x1a')])){logger[_0x992e('0x14')](_0x992e('0x15'),_0x509ea2,_0x992e('0x1b'));return _0x4a0bf6['next']();}if(_0x193eb6[0x0]==='2'&&this[_0x992e('0x19')][_0x992e('0x1c')]){logger[_0x992e('0x14')](_0x992e('0x1d'),_0x509ea2,_0x992e('0x1e'));return _0x4a0bf6[_0x992e('0x17')]();}var _0x4a7b72={'ContactId':this[_0x992e('0x1f')]['id'],'sentAt':moment()[_0x992e('0x20')](_0x992e('0x21')),'direction':'out'};if(this[_0x992e('0x10')]===_0x992e('0x11')){_0x4a7b72['body']=utils[_0x992e('0x22')](_0x193eb6[0x2],this);}else{_0x4a7b72['body']=utils[_0x992e('0x22')](_0x193eb6[0x1],this);}if(this[_0x992e('0x23')]){_0x4a7b72['to']=this[_0x992e('0x23')][_0x992e('0x24')]||'';if(this['channel']==='mail'&&_0x193eb6[0x1]==='1'){_0x4a7b72['cc']=this['message']['cc']||'';}_0x4a7b72[_0x992e('0x24')]=this[_0x992e('0x23')]['to']||'';_0x4a7b72[_0x992e('0x25')]=this[_0x992e('0x23')]['phone']||'';_0x4a7b72[_0x992e('0x26')]=!![];if(this[_0x992e('0x23')][_0x992e('0x27')]){_0x4a7b72[_0x992e('0x27')]='';_0x4a7b72['subject']+=_['startsWith'](this[_0x992e('0x23')]['subject'],_0x992e('0x28'))?'':_0x992e('0x29');_0x4a7b72[_0x992e('0x27')]+=this['message']['subject'];}}if(this[_0x992e('0x10')]==='chat'){_0x4a7b72[_0x992e('0x2a')]=this['account']['id'];}else{_0x4a7b72[_[_0x992e('0x2b')](this[_0x992e('0x10')])+_0x992e('0x2c')]=this[_0x992e('0x2d')]['id'];}_0x4a7b72[_[_0x992e('0x2b')](this[_0x992e('0x10')])+'InteractionId']=this[_0x992e('0x19')]['id'];var _0x4012e6=this['interaction'];if(rpc[this['channel']+_0x992e('0x2e')]){if(this[_0x992e('0x10')]===_0x992e('0x11')){_0x4a7b72[_0x992e('0x2f')]=this['message'][_0x992e('0x30')];_0x4a7b72[_0x992e('0x31')]=_0x992e('0x32')+_[_0x992e('0x33')](_0x4a7b72[_0x992e('0x12')],']+(>|$)/g,''),'priorityTrue':_0x44c94c[0x1],'priorityFalse':_0x44c94c[0x2]};var _0x5ae961=gotoif[_0x5a56('0x0')](_0x4304fa,{'typecast':!![]});if(_0x5ae961[_0x5a56('0xd')]){logger[_0x5a56('0xe')](_0x5a56('0xf'),_0x3e1cf1,_['map'](_0x5ae961,_0x5a56('0x10'))[_0x5a56('0x11')](',\x20'));_0x46e433[_0x5a56('0x12')]();}else{try{var _0xb7d41f=eval('('+_0x4304fa[_0x5a56('0x13')]+')');var _0x4d35e0=_0xb7d41f?_0x4304fa['priorityTrue']:_0x4304fa[_0x5a56('0x14')];logger['info'](_0x5a56('0x15'),_0x3e1cf1,_0x4304fa[_0x5a56('0x13')],_0xb7d41f,_0x4d35e0||_0x5a56('0x16'));if(_0x4d35e0){var _0x3e3974=_['findIndex'](_0x46e433[_0x5a56('0x17')](),{'p':_0x4d35e0});if(_0x3e3974>=0x0){logger['info'](_0x5a56('0x18'),_0x3e1cf1,_0x4d35e0||_0x5a56('0x16'),_0x3e3974);_0x46e433[_0x5a56('0x16')](_0x3e3974);}else{logger[_0x5a56('0x19')]('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x3e1cf1,_0x4d35e0||_0x5a56('0x16'));_0x46e433[_0x5a56('0x12')]();}}else{_0x46e433[_0x5a56('0x16')]();}}catch(_0x520551){logger[_0x5a56('0xe')](_0x5a56('0x1a'),_0x3e1cf1,_0x520551[_0x5a56('0x10')]);_0x46e433[_0x5a56('0x12')]();}}}catch(_0x4395d2){logger['error'](_0x5a56('0xf'),_0x3e1cf1,JSON[_0x5a56('0x1b')](_0x4395d2));_0x46e433['stop']();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/gotop.js b/server/services/routing/server/applications/gotop.js new file mode 100644 index 0000000..6934894 --- /dev/null +++ b/server/services/routing/server/applications/gotop.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc316=['lodash','../../../../config/logger','routing','number','priority\x20is\x20a\x20number\x20and\x20it\x20is\x20required','consequence','length','error','map','message','join','stop','[%s][GOTOP]\x20priority\x20%s','priority','rules','[%s][GOTOP]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','next','info','[%s][GOTOP]\x20priority\x20%s\x20not\x20found','[%s][GOTOP]\x20%s','stringify','validate'];(function(_0x4a3e73,_0x4fea7c){var _0x2d8eb9=function(_0x37f8bf){while(--_0x37f8bf){_0x4a3e73['push'](_0x4a3e73['shift']());}};_0x2d8eb9(++_0x4fea7c);}(_0xc316,0x6d));var _0x6c31=function(_0x23eaf0,_0x347b70){_0x23eaf0=_0x23eaf0-0x0;var _0x353da4=_0xc316[_0x23eaf0];return _0x353da4;};'use strict';var schema=require(_0x6c31('0x0'));var _=require(_0x6c31('0x1'));var logger=require(_0x6c31('0x2'))(_0x6c31('0x3'));var gotop=schema({'priority':{'type':_0x6c31('0x4'),'required':!![],'message':_0x6c31('0x5')}});exports[_0x6c31('0x6')]=function(_0x527483,_0x623393){return function(_0xa7ea79){try{var _0x5b0fdf={'priority':_0x623393[0x0]};var _0x20c4c7=gotop[_0x6c31('0x0')](_0x5b0fdf,{'typecast':!![]});if(_0x20c4c7[_0x6c31('0x7')]){logger[_0x6c31('0x8')]('[%s][GOTOP]\x20%s',_0x527483,_[_0x6c31('0x9')](_0x20c4c7,_0x6c31('0xa'))[_0x6c31('0xb')](',\x20'));_0xa7ea79[_0x6c31('0xc')]();}else{logger['info'](_0x6c31('0xd'),_0x527483,_0x5b0fdf[_0x6c31('0xe')]);if(_0x5b0fdf[_0x6c31('0xe')]){var _0x1909dd=_['findIndex'](_0xa7ea79[_0x6c31('0xf')](),{'p':_0x5b0fdf['priority']});if(_0x1909dd>=0x0){logger['info'](_0x6c31('0x10'),_0x527483,_0x5b0fdf['priority']||_0x6c31('0x11'),_0x1909dd);_0xa7ea79[_0x6c31('0x11')](_0x1909dd);}else{logger[_0x6c31('0x12')](_0x6c31('0x13'),_0x527483,_0x5b0fdf[_0x6c31('0xe')]||'next');_0xa7ea79['stop']();}}else{_0xa7ea79[_0x6c31('0x11')]();}}}catch(_0x96770f){logger['error'](_0x6c31('0x14'),_0x527483,JSON[_0x6c31('0x15')](_0x96770f));_0xa7ea79[_0x6c31('0xc')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/message.js b/server/services/routing/server/applications/message.js new file mode 100644 index 0000000..3c1a2d4 --- /dev/null +++ b/server/services/routing/server/applications/message.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe51b=['routing','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','getMustacheRender','ChatWebsiteId','account','upperFirst','channel','AccountId','InteractionId','interaction','Message','create','then','info','[%s][MESSAGE]\x20%s','body','catch','error','stop','stringify','lodash','./utils'];(function(_0x303bdb,_0x443c92){var _0x125fe8=function(_0xd845e8){while(--_0xd845e8){_0x303bdb['push'](_0x303bdb['shift']());}};_0x125fe8(++_0x443c92);}(_0xe51b,0x15c));var _0xbe51=function(_0x867f95,_0x43d423){_0x867f95=_0x867f95-0x0;var _0x4cd98d=_0xe51b[_0x867f95];return _0x4cd98d;};'use strict';var _=require(_0xbe51('0x0'));var utils=require(_0xbe51('0x1'));var logger=require('../../../../config/logger')(_0xbe51('0x2'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0xbe51('0x3')),'faxMessage':require(_0xbe51('0x4')),'whatsappMessage':require(_0xbe51('0x5'))};exports[_0xbe51('0x6')]=function(_0x320931,_0x480903){return function(_0x12625d){try{var _0x31a7e6={'body':utils[_0xbe51('0x7')](_0x480903[0x0],this),'ContactId':this['contact']['id']};if(this['channel']==='chat'){_0x31a7e6[_0xbe51('0x8')]=this[_0xbe51('0x9')]['id'];}else{_0x31a7e6[_[_0xbe51('0xa')](this[_0xbe51('0xb')])+_0xbe51('0xc')]=this['account']['id'];}_0x31a7e6[_[_0xbe51('0xa')](this[_0xbe51('0xb')])+_0xbe51('0xd')]=this[_0xbe51('0xe')]['id'];if(rpc[this['channel']+_0xbe51('0xf')]){return rpc[this[_0xbe51('0xb')]+_0xbe51('0xf')][_0xbe51('0x10')](_0x31a7e6)[_0xbe51('0x11')](function(_0x26afea){logger[_0xbe51('0x12')](_0xbe51('0x13'),_0x320931,_0x31a7e6[_0xbe51('0x14')]);_0x12625d['next']();})[_0xbe51('0x15')](function(_0x5ae980){logger[_0xbe51('0x16')](_0xbe51('0x13'),_0x320931,JSON['stringify'](_0x5ae980));_0x12625d[_0xbe51('0x17')]();});}}catch(_0xab768c){logger[_0xbe51('0x16')](_0xbe51('0x13'),_0x320931,JSON[_0xbe51('0x18')](_0xab768c));_0x12625d[_0xbe51('0x17')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/noop.js b/server/services/routing/server/applications/noop.js new file mode 100644 index 0000000..71f6d7f --- /dev/null +++ b/server/services/routing/server/applications/noop.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8043=['stringify','./utils','../../../../config/logger','consequence','info','[%s][NOOP]\x20%s','getMustacheRender','next','error'];(function(_0x181b74,_0x31852d){var _0x58595a=function(_0x1290dc){while(--_0x1290dc){_0x181b74['push'](_0x181b74['shift']());}};_0x58595a(++_0x31852d);}(_0x8043,0xa3));var _0x3804=function(_0x2aea9e,_0x1f587f){_0x2aea9e=_0x2aea9e-0x0;var _0x430b92=_0x8043[_0x2aea9e];return _0x430b92;};'use strict';var utils=require(_0x3804('0x0'));var logger=require(_0x3804('0x1'))('routing');exports[_0x3804('0x2')]=function(_0xd1af9c,_0x32387c){return function(_0x31de5c){try{logger[_0x3804('0x3')](_0x3804('0x4'),_0xd1af9c,utils[_0x3804('0x5')](_0x32387c[0x0],this));_0x31de5c[_0x3804('0x6')]();}catch(_0x2d7877){logger[_0x3804('0x7')](_0x3804('0x4'),_0xd1af9c,JSON[_0x3804('0x8')](_0x2d7877));_0x31de5c['stop']();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/queue.js b/server/services/routing/server/applications/queue.js new file mode 100644 index 0000000..617c1f0 --- /dev/null +++ b/server/services/routing/server/applications/queue.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x000b=['createQueue','atimeout','qtimeout','rules','close','complete','strategy','rrmemory','beepall','[%s][QUEUE]\x20queue\x20not\x20found\x20%s','stack','validate','lodash','util','seq-queue','moment','../../../../config/environment','../../../../config/logger','routing','redis','localhost','queue_id','account','from','emit','clone','queue','InteractionId','format','%sQueuesWaitingInteractions','pick','%s:queue:%s','../../rpc/mailQueueReport','../../rpc/chatQueueReport','../../rpc/smsQueueReport','../../rpc/faxQueueReport','../../rpc/whatsappQueueReport','string','number','timeout\x20is\x20a\x20number','waiting','body','YYYY-MM-DD\x20HH:mm:ss','contact','list','upperFirst','channel','interaction','message','chat','AccountId','WebsiteId','info','[%s][START:QUEUE][NAME:%s]','QueueReport','catch','error','name','update','update\x20queue\x20report','timeout','[%s][END:QUEUE][NAME:%s]','toLowerCase','consequence','length','[%s][QUEUE]\x20%s','map','join','stop','find','Queues'];(function(_0x3f5744,_0x13b29d){var _0x21c4a0=function(_0xf74015){while(--_0xf74015){_0x3f5744['push'](_0x3f5744['shift']());}};_0x21c4a0(++_0x13b29d);}(_0x000b,0xe0));var _0xb000=function(_0xb1cf84,_0x813740){_0xb1cf84=_0xb1cf84-0x0;var _0x4bad2e=_0x000b[_0xb1cf84];return _0x4bad2e;};'use strict';var schema=require(_0xb000('0x0'));var _=require(_0xb000('0x1'));var util=require(_0xb000('0x2'));var seqqueue=require(_0xb000('0x3'));var moment=require(_0xb000('0x4'));var Redis=require('ioredis');var config=require(_0xb000('0x5'));var logger=require(_0xb000('0x6'))(_0xb000('0x7'));var strategy=require('./strategy');config['redis']=_['defaults'](config[_0xb000('0x8')],{'host':_0xb000('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var attributes=['id',_0xb000('0xa'),_0xb000('0xb'),'queue',_0xb000('0xc'),'joinAt'];function emit(_0x3b3584,_0x5c3f6e,_0x5cbc4d){io['to'](_0x3b3584)[_0xb000('0xd')](_0x5c3f6e,_0x5cbc4d);}function emitChannelQueueInteraction(_0x59b355,_0x1c78d2,_0x4257b2,_0x1ee8f8,_0x315f2e,_0x1e5946,_0x5f1f3b,_0xf948a){var _0x5c6155=_[_0xb000('0xe')](_0x4257b2);_0x5c6155['queue_id']=_0xf948a;_0x5c6155[_0xb000('0xf')]=_0x1c78d2;_0x5c6155[_0xb000('0xb')]=_0x1ee8f8;_0x5c6155['id']=_0x315f2e;if(_0x1e5946){attributes['push'](_['capitalize'](_0x59b355)+_0xb000('0x10'));_0x5f1f3b[util[_0xb000('0x11')](_0xb000('0x12'),_0x59b355)][_0x315f2e]=_[_0xb000('0x13')](_0x5c6155,attributes);}else{delete _0x5f1f3b[util['format'](_0xb000('0x12'),_0x59b355)][_0x315f2e];}emit(util['format'](_0xb000('0x14'),_0x59b355,_0x1c78d2),util[_0xb000('0x11')]('%s_queue_waiting_interaction:%s',_0x59b355,_0x1e5946?'save':'remove'),_[_0xb000('0x13')](_0x5c6155,attributes));}var rpc={'openchannelQueueReport':require('../../rpc/openchannelQueueReport'),'mailQueueReport':require(_0xb000('0x15')),'chatQueueReport':require(_0xb000('0x16')),'smsQueueReport':require(_0xb000('0x17')),'faxQueueReport':require(_0xb000('0x18')),'whatsappQueueReport':require(_0xb000('0x19'))};var queue=schema({'name':{'type':_0xb000('0x1a'),'required':!![],'message':'name\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'timeout':{'type':_0xb000('0x1b'),'message':_0xb000('0x1c')}});function startRouting(_0x3d0af8,_0x4156e9,_0x558b62,_0xebf1c9){if(_0x3d0af8&&_0x4156e9&&_0x558b62){_0x4156e9[_0xb000('0x1d')]+=0x1;var _0x9125e7={'uniqueid':_0x3d0af8,'from':_0x558b62[_0xb000('0x1e')]?_0x558b62[_0xb000('0x1e')]['from']:'','joinAt':moment()[_0xb000('0x11')](_0xb000('0x1f')),'ContactId':_0x558b62[_0xb000('0x20')]?_0x558b62['contact']['id']:null,'ListId':_0x558b62[_0xb000('0x21')]?_0x558b62[_0xb000('0x21')]['id']:null};_0x9125e7[_[_0xb000('0x22')](_0x558b62[_0xb000('0x23')])+'QueueId']=_0x4156e9['id']||null;_0x9125e7[_[_0xb000('0x22')](_0x558b62[_0xb000('0x23')])+_0xb000('0x10')]=_0x558b62[_0xb000('0x24')]?_0x558b62[_0xb000('0x24')]['id']:null;_0x9125e7[_[_0xb000('0x22')](_0x558b62[_0xb000('0x23')])+'MessageId']=_0x558b62[_0xb000('0x25')]?_0x558b62['message']['id']:null;_0x9125e7[_['upperFirst'](_0x558b62[_0xb000('0x23')])+(_0x558b62[_0xb000('0x23')]!==_0xb000('0x26')?_0xb000('0x27'):_0xb000('0x28'))]=_0x558b62['account']?_0x558b62[_0xb000('0xb')]['id']:null;logger[_0xb000('0x29')](util[_0xb000('0x11')](_0xb000('0x2a'),_0x3d0af8,_0x4156e9['name']));emitChannelQueueInteraction(_0x558b62[_0xb000('0x23')],_0x4156e9['name'],_0x9125e7,_0x558b62[_0xb000('0xb')]['name'],_0x558b62[_0xb000('0x25')]['id'],!![],_0xebf1c9,_0x4156e9['id']);if(rpc[_0x558b62[_0xb000('0x23')]+_0xb000('0x2b')]){return rpc[_0x558b62['channel']+'QueueReport']['create'](_0x9125e7)[_0xb000('0x2c')](function(_0x59a1da){logger[_0xb000('0x2d')]('create\x20queue\x20report');});}}}function stopRouting(_0x194773,_0x1518ef,_0x54985d,_0x5b2682){if(_0x194773&&_0x1518ef){_0x1518ef[_0xb000('0x1d')]-=0x1;var _0x2ff61b={'leaveAt':moment()[_0xb000('0x11')](_0xb000('0x1f')),'acceptAt':moment()[_0xb000('0x11')](_0xb000('0x1f')),'reason':'accepted'};logger[_0xb000('0x29')](util['format']('[%s][STOP:QUEUE][NAME:%s]',_0x194773,_0x1518ef[_0xb000('0x2e')]));emitChannelQueueInteraction(_0x54985d['channel'],_0x1518ef['name'],_0x54985d['body'],_0x54985d[_0xb000('0xb')]['name'],_0x54985d[_0xb000('0x25')]['id'],![],_0x5b2682,_0x1518ef['id']);if(rpc[_0x54985d[_0xb000('0x23')]+_0xb000('0x2b')]){return rpc[_0x54985d[_0xb000('0x23')]+_0xb000('0x2b')][_0xb000('0x2f')](_0x194773,_0x2ff61b)[_0xb000('0x2c')](function(_0x206cb6){logger[_0xb000('0x2d')](_0xb000('0x30'));});}}}function endRouting(_0x58838d,_0x14b9f7,_0x50fe00,_0x1f2333){if(_0x58838d&&_0x14b9f7){_0x14b9f7[_0xb000('0x1d')]-=0x1;var _0x19721d={'leaveAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'exitAt':moment()[_0xb000('0x11')](_0xb000('0x1f')),'reason':_0xb000('0x31')};logger[_0xb000('0x29')](util['format'](_0xb000('0x32'),_0x58838d,_0x14b9f7[_0xb000('0x2e')]));emitChannelQueueInteraction(_0x50fe00[_0xb000('0x23')],_0x14b9f7[_0xb000('0x2e')],_0x50fe00['body'],_0x50fe00['account'][_0xb000('0x2e')],_0x50fe00[_0xb000('0x25')]['id'],![],_0x1f2333);if(rpc[_0x50fe00[_0xb000('0x23')]+_0xb000('0x2b')]){return rpc[_0x50fe00[_0xb000('0x23')]+_0xb000('0x2b')][_0xb000('0x2f')](_0x58838d,_0x19721d)[_0xb000('0x2c')](function(_0x31b5cd){logger[_0xb000('0x2d')](_0xb000('0x30'));});}}}function handleFindQueue(_0x2afd63){return function(_0x1232f0){return _0x1232f0[_0xb000('0x2e')][_0xb000('0x33')]()===_0x2afd63['toLowerCase']();};}exports[_0xb000('0x34')]=function(_0x31fb8b,_0xb9dcc6,_0xb2b2c2,_0x286632){return function(_0x4fbf7c){try{var _0x8d2fc={'name':_0xb9dcc6[0x0],'timeout':_0xb9dcc6[0x1]};var _0x4cc6b5=queue[_0xb000('0x0')](_0x8d2fc,{'typecast':!![]});if(_0x4cc6b5[_0xb000('0x35')]){logger['error'](_0xb000('0x36'),_0x31fb8b,_[_0xb000('0x37')](_0x4cc6b5,_0xb000('0x25'))[_0xb000('0x38')](',\x20'));_0x4fbf7c[_0xb000('0x39')]();}else{var _0x47f565=_[_0xb000('0x3a')](_0xb2b2c2[_0x286632['channel']+_0xb000('0x3b')],handleFindQueue(_0x8d2fc['name']));if(_0x47f565){startRouting(_0x31fb8b,_0x47f565,_0x286632,_0xb2b2c2);var _0x2b4de8=(_0x47f565[_0xb000('0x31')]||0xa)*0x3e8;var _0x2f2048=(_0x8d2fc[_0xb000('0x31')]||0x14)*0x3e8;var _0x28714f;if(_0x2b4de8>_0x2f2048){_0x2f2048=_0x2b4de8;}var _0x2f5b54=seqqueue[_0xb000('0x3c')](_0x2b4de8);_0x2f5b54['id']=_0x31fb8b;_0x2f5b54[_0xb000('0x3d')]=_0x2b4de8;_0x2f5b54[_0xb000('0x3e')]=_0x2f2048;_0x2f5b54['channel']=_0x286632[_0xb000('0x23')];_0xb2b2c2[_0xb000('0x3f')][_0x31fb8b]['on']('end',function(){logger[_0xb000('0x29')]('[%s][QUEUE]\x20ROUTING\x20STOPPED',_0x31fb8b);stopRouting(_0x31fb8b,_0x47f565,_0x286632,_0xb2b2c2);clearTimeout(_0x28714f);_0x28714f=undefined;_0x2f5b54[_0xb000('0x40')](!![]);if(_0xb2b2c2[_0xb000('0x3f')][_0x31fb8b]){delete _0xb2b2c2[_0xb000('0x3f')][_0x31fb8b];}_0x4fbf7c[_0xb000('0x39')]();});_0xb2b2c2[_0xb000('0x3f')][_0x31fb8b]['on'](_0xb000('0x41'),function(){if(_0xb2b2c2['rules'][_0x31fb8b]){delete _0xb2b2c2[_0xb000('0x3f')][_0x31fb8b];}});_0x28714f=setTimeout(function(){logger[_0xb000('0x29')]('[%s][QUEUE]\x20APPLICATION\x20END',_0x31fb8b);endRouting(_0x31fb8b,_0x47f565,_0x286632,_0xb2b2c2);clearTimeout(_0x28714f);_0x2f5b54['close'](!![]);_0x4fbf7c['next']();},_0x2f2048);switch(_0x47f565[_0xb000('0x42')]){case _0xb000('0x43'):strategy[_0xb000('0x43')](_0x2f5b54,_0x47f565,_0xb2b2c2,_0x286632);break;default:strategy[_0xb000('0x44')](_0x2f5b54,_0x47f565,_0xb2b2c2,_0x286632);}}else{logger[_0xb000('0x2d')](_0xb000('0x45'),_0x31fb8b,_0x8d2fc['name']);_0x4fbf7c[_0xb000('0x39')]();}}}catch(_0x4b4e92){console['log'](_0x4b4e92);logger[_0xb000('0x2d')](_0xb000('0x36'),_0x31fb8b,_0x4b4e92[_0xb000('0x46')]);_0x4fbf7c[_0xb000('0x39')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/strategy/agent.js b/server/services/routing/server/applications/strategy/agent.js new file mode 100644 index 0000000..3a8ef19 --- /dev/null +++ b/server/services/routing/server/applications/strategy/agent.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x29d4=['routing','notificationId','squeue','agent','realtime','push','bind','timeout','handleDrained','prototype','handleRun','[%s][AGENT]\x20try\x20with\x20%s','isNil','agents','debug','forcedOwnership','isAgentAvailable','channel','busy','busyQueue','saveWaitingNotification','showNotification','RINGING',':FORCED','[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','[%s][AGENT]\x20timeout\x20with\x20%s','hideNotification','removeWaitingNotification','STOP','TIMEOUT','exports','lodash','./util','../../../../../config/logger'];(function(_0x4ca1d5,_0x404eea){var _0x5bbebc=function(_0x313a47){while(--_0x313a47){_0x4ca1d5['push'](_0x4ca1d5['shift']());}};_0x5bbebc(++_0x404eea);}(_0x29d4,0x1a1));var _0x429d=function(_0x4d07cc,_0x587613){_0x4d07cc=_0x4d07cc-0x0;var _0x42de3b=_0x29d4[_0x4d07cc];return _0x42de3b;};'use strict';var _=require(_0x429d('0x0'));var uuid=require('uuid');var util=require(_0x429d('0x1'));var logger=require(_0x429d('0x2'))(_0x429d('0x3'));var Agent=function(_0x472fc9,_0x45df1c,_0x4e287b,_0xc3989d){this[_0x429d('0x4')]=uuid['v4']();this[_0x429d('0x5')]=_0x472fc9;this[_0x429d('0x6')]=_0x45df1c;this[_0x429d('0x7')]=_0x4e287b;this[_0x429d('0x3')]=_0xc3989d;this[_0x429d('0x5')][_0x429d('0x8')](this['handleRun'][_0x429d('0x9')](this),this['handleTimeout'][_0x429d('0x9')](this));this[_0x429d('0x5')]['on'](_0x429d('0xa'),this['handleTimeout'][_0x429d('0x9')](this));this[_0x429d('0x5')]['on']('drained',this[_0x429d('0xb')][_0x429d('0x9')](this));};Agent[_0x429d('0xc')]['push']=function(){this[_0x429d('0x5')][_0x429d('0x8')](this[_0x429d('0xd')][_0x429d('0x9')](this),this['handleTimeout'][_0x429d('0x9')](this));};Agent[_0x429d('0xc')][_0x429d('0xb')]=function(){this['handleTimeout'](!![]);};Agent[_0x429d('0xc')][_0x429d('0xd')]=function(){logger['debug'](_0x429d('0xe'),this[_0x429d('0x5')]['id'],this[_0x429d('0x6')]['id']);if(_[_0x429d('0xf')](this[_0x429d('0x7')][_0x429d('0x10')][this['agent']['id']])){logger[_0x429d('0x11')]('[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x429d('0x5')]['id'],this[_0x429d('0x6')]['id']);setTimeout(this[_0x429d('0x8')][_0x429d('0x9')](this),0x3e8);}else{if(this['routing'][_0x429d('0x12')]||util[_0x429d('0x13')](this[_0x429d('0x5')]['id'],this['realtime'][_0x429d('0x10')][this[_0x429d('0x6')]['id']],this[_0x429d('0x5')][_0x429d('0x14')],![])){this[_0x429d('0x7')][_0x429d('0x10')][this['agent']['id']][_0x429d('0x15')]=!![];this[_0x429d('0x7')][_0x429d('0x10')][this['agent']['id']][_0x429d('0x16')]=undefined;util[_0x429d('0x17')](this[_0x429d('0x7')],this[_0x429d('0x3')],this[_0x429d('0x6')],this[_0x429d('0x5')]['channel']);util[_0x429d('0x18')](this[_0x429d('0x4')],this['squeue']['id'],this[_0x429d('0x7')][_0x429d('0x10')][this[_0x429d('0x6')]['id']],null,this[_0x429d('0x3')]);util['writeLog'](this[_0x429d('0x5')]['id'],this[_0x429d('0x7')][_0x429d('0x10')][this[_0x429d('0x6')]['id']],_0x429d('0x19')+(this['routing'][_0x429d('0x12')]?_0x429d('0x1a'):''));}else{logger[_0x429d('0x11')](_0x429d('0x1b'),this[_0x429d('0x5')]['id'],this[_0x429d('0x6')]['id']);setTimeout(this[_0x429d('0x8')][_0x429d('0x9')](this),0x3e8);}}};Agent[_0x429d('0xc')]['handleTimeout']=function(_0x31cae6){if(_[_0x429d('0xf')](this['realtime'][_0x429d('0x10')][this[_0x429d('0x6')]['id']])){return logger[_0x429d('0x11')](_0x429d('0x1c'),this[_0x429d('0x5')]['id'],this['agent']['id']);}else{logger[_0x429d('0x11')](_0x429d('0x1d'),this[_0x429d('0x5')]['id'],this[_0x429d('0x6')]['id']);util[_0x429d('0x1e')](this[_0x429d('0x4')],this['squeue']['id'],this['realtime'][_0x429d('0x10')][this[_0x429d('0x6')]['id']],null,this['routing']);this['realtime'][_0x429d('0x10')][this['agent']['id']][_0x429d('0x15')]=![];this[_0x429d('0x7')][_0x429d('0x10')][this[_0x429d('0x6')]['id']]['busyQueue']=undefined;util[_0x429d('0x1f')](this[_0x429d('0x7')],this['routing'],this['agent'],this['squeue']['channel']);util['writeLog'](this[_0x429d('0x5')]['id'],this['realtime']['agents'][this[_0x429d('0x6')]['id']],_0x31cae6?_0x429d('0x20'):_0x429d('0x21'));}if(!_0x31cae6){setTimeout(this[_0x429d('0x8')][_0x429d('0x9')](this),0x3e8);}};function agent(_0x1a5d80,_0x4b23ab,_0x423dc8,_0x2c5fa5){return new Agent(_0x1a5d80,_0x4b23ab,_0x423dc8,_0x2c5fa5);}module[_0x429d('0x22')]=agent; \ No newline at end of file diff --git a/server/services/routing/server/applications/strategy/beepall.js b/server/services/routing/server/applications/strategy/beepall.js new file mode 100644 index 0000000..d5761d8 --- /dev/null +++ b/server/services/routing/server/applications/strategy/beepall.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x8ac7=['realtime','handleRun','bind','timeout','handleTimeout','handleDrained','prototype','push','isNil','Agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','agents','channel','writeLog','busyQueue','name','saveWaitingNotification','showNotification','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','length','hideNotification','STOP','busy','exports','lodash','uuid','./util','routing','squeue','queue'];(function(_0x721409,_0x2f6eb8){var _0x4aced1=function(_0x27b420){while(--_0x27b420){_0x721409['push'](_0x721409['shift']());}};_0x4aced1(++_0x2f6eb8);}(_0x8ac7,0x9a));var _0x78ac=function(_0xdaee8,_0x9b9d42){_0xdaee8=_0xdaee8-0x0;var _0x3536dd=_0x8ac7[_0xdaee8];return _0x3536dd;};'use strict';var _=require(_0x78ac('0x0'));var uuid=require(_0x78ac('0x1'));var util=require(_0x78ac('0x2'));var logger=require('../../../../../config/logger')(_0x78ac('0x3'));var Beepall=function(_0x1df4cc,_0x11dd0b,_0x30ae50,_0x306266){this['notificationId']=uuid['v4']();this[_0x78ac('0x4')]=_0x1df4cc;this[_0x78ac('0x5')]=_0x11dd0b;this[_0x78ac('0x6')]=_0x30ae50;this[_0x78ac('0x3')]=_0x306266;this['squeue']['push'](this[_0x78ac('0x7')][_0x78ac('0x8')](this),this['handleTimeout'][_0x78ac('0x8')](this));this['squeue']['on'](_0x78ac('0x9'),this[_0x78ac('0xa')]['bind'](this));this['squeue']['on']('drained',this[_0x78ac('0xb')][_0x78ac('0x8')](this));};Beepall[_0x78ac('0xc')][_0x78ac('0xd')]=function(){this[_0x78ac('0x4')]['push'](this[_0x78ac('0x7')]['bind'](this),this['handleTimeout'][_0x78ac('0x8')](this));};Beepall['prototype'][_0x78ac('0xb')]=function(){this[_0x78ac('0xa')](!![]);};Beepall[_0x78ac('0xc')][_0x78ac('0x7')]=function(){var _0x3be3d5=!![];if(!_[_0x78ac('0xe')](this[_0x78ac('0x5')])&&!_[_0x78ac('0xe')](this[_0x78ac('0x5')][_0x78ac('0xf')])&&this[_0x78ac('0x5')][_0x78ac('0xf')]['length']>0x0){for(var _0x46c2a4=0x0,_0x42a000;_0x46c2a40x0&&_0x11b408[_0x2cd17f+_0x2c0c('0x26')]>=_0x11b408[_0x2cd17f+_0x2c0c('0x25')]){writeLog(_0x483736,_0x11b408,_0x2cd17f[_0x2c0c('0x27')]()+_0x2c0c('0x28'));return![];}}return!![];};exports[_0x2c0c('0x29')]=function(_0x4fd803,_0xd44322,_0x3452b9,_0x239705,_0x214c4b){return sendNotification(!![],_0x4fd803,_0xd44322,_0x3452b9,_0x239705,_0x214c4b);};exports[_0x2c0c('0x2a')]=function(_0x342462,_0x312a6a,_0x4e462f,_0x3984d7,_0x1593cb){return sendNotification(![],_0x342462,_0x312a6a,_0x4e462f,_0x3984d7,_0x1593cb);};exports[_0x2c0c('0x2b')]=function(_0x335d1d,_0x3f9298,_0x580b10){var _0x348bef=_0x3f9298[_0x2c0c('0x2c')][_0x2c0c('0x2d')];if(!_0x348bef&&_0x580b10){_0x348bef=_0x580b10['id'];}var _0xa93abb=_['some'](_0x335d1d[_0x3f9298[_0x2c0c('0x2e')]+_0x2c0c('0x2f')],function(_0x137fc2){var _0x483a5b=_[_0x2c0c('0x30')](_0x3f9298[_0x2c0c('0x2e')])+_0x2c0c('0x31');return _0x137fc2[_0x483a5b]===_0x3f9298[_0x2c0c('0x2c')]['id'];});if(!_0xa93abb&&_0x348bef){_0xa93abb=_[_0x2c0c('0x32')](_0x335d1d[_0x2c0c('0x33')][_0x348bef][_0x3f9298[_0x2c0c('0x2e')]+_0x2c0c('0x34')],function(_0x1f8b2b){return _0x1f8b2b['id']===_0x3f9298[_0x2c0c('0x2c')]['id'];});}return _0xa93abb;};exports[_0x2c0c('0x35')]=function(_0xa78594,_0x4c7631,_0x22f1b6,_0x3c7ba0){_0xa78594[_0x2c0c('0x33')][_0x22f1b6['id']][_0x3c7ba0+'WaitingInteractions'][_0x4c7631[_0x2c0c('0x1a')]['id']]={'id':_0x4c7631[_0x2c0c('0x2c')]['id']};};exports[_0x2c0c('0x36')]=function(_0x289f03,_0x80c988,_0x54e19c,_0x2014c0){delete _0x289f03[_0x2c0c('0x33')][_0x54e19c['id']][_0x2014c0+_0x2c0c('0x34')][_0x80c988['message']['id']];};exports['writeLog']=writeLog; \ No newline at end of file diff --git a/server/services/routing/server/applications/system.js b/server/services/routing/server/applications/system.js new file mode 100644 index 0000000..92e53ad --- /dev/null +++ b/server/services/routing/server/applications/system.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5b40=['routing','string','command\x20is\x20a\x20string\x20and\x20it\x20is\x20required','length','error','map','join','info','[%s][SYSTEM]\x20no\x20command\x20executed,\x20force\x20next','next','[%s][SYSTEM]\x20commnad:\x20%s','exec','trim','[%s][SYSTEM]\x20result\x20code:\x20%s','isNil','isEmpty','body','[%s][SYSTEM]\x20set\x20variable\x20%s:\x20%s','isObject','stringify','shelljs','lodash','./utils'];(function(_0x5d1935,_0x43a4c5){var _0x210b54=function(_0x229f67){while(--_0x229f67){_0x5d1935['push'](_0x5d1935['shift']());}};_0x210b54(++_0x43a4c5);}(_0x5b40,0x111));var _0x05b4=function(_0x46b5fd,_0x3fef76){_0x46b5fd=_0x46b5fd-0x0;var _0x3ad06c=_0x5b40[_0x46b5fd];return _0x3ad06c;};'use strict';var schema=require('validate');var sh=require(_0x05b4('0x0'));var _=require(_0x05b4('0x1'));var utils=require(_0x05b4('0x2'));var logger=require('../../../../config/logger')(_0x05b4('0x3'));var system=schema({'command':{'type':_0x05b4('0x4'),'required':!![],'message':_0x05b4('0x5')}});exports['consequence']=function(_0x47696a,_0xcb49cc){return function(_0x5c36cc){try{var _0x52ff3c={'command':_0xcb49cc[0x0]};var _0x4b735e=system['validate'](_0x52ff3c,{'typecast':!![]});if(_0x4b735e[_0x05b4('0x6')]){logger[_0x05b4('0x7')]('[%s][SYSTEM]\x20%s',_0x47696a,_[_0x05b4('0x8')](_0x4b735e,'message')[_0x05b4('0x9')](',\x20'));logger[_0x05b4('0xa')](_0x05b4('0xb'),_0x47696a);_0x5c36cc[_0x05b4('0xc')]();}else{var _0x267fe9=this;var _0x4174ad=utils['getMustacheRender'](_0xcb49cc[0x0],this);logger[_0x05b4('0xa')](_0x05b4('0xd'),_0x47696a,_0x4174ad);sh[_0x05b4('0xe')](_[_0x05b4('0xf')](_0x4174ad),function(_0x500390,_0x22f759){logger[_0x05b4('0xa')](_0x05b4('0x10'),_0x47696a,_0x500390);if(_0x500390==0x0){var _0x16d723=_0x22f759['replace'](/(\r\n|\n|\r)/gm,'');if(_[_0x05b4('0x11')](_0xcb49cc[0x1])||_[_0x05b4('0x12')](_0xcb49cc[0x1])){logger[_0x05b4('0xa')]('[%s][SYSTEM]\x20no\x20variable',_0x47696a);_0x267fe9[_0x05b4('0x13')][_0xcb49cc[0x1]]=_0x16d723;}else{logger[_0x05b4('0xa')](_0x05b4('0x14'),_0x47696a,_0xcb49cc[0x1],_0x16d723);_0x267fe9['body'][_0xcb49cc[0x1]]=_0x16d723;}}_0x5c36cc[_0x05b4('0xc')]();});}}catch(_0x40cc63){logger[_0x05b4('0x7')]('[%s][SYSTEM]\x20%s',_0x47696a,_[_0x05b4('0x15')](_0x40cc63)?JSON[_0x05b4('0x16')](_0x40cc63):_0x40cc63);logger['info'](_0x05b4('0xb'),_0x47696a);_0x5c36cc[_0x05b4('0xc')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/tag.js b/server/services/routing/server/applications/tag.js new file mode 100644 index 0000000..bb285ca --- /dev/null +++ b/server/services/routing/server/applications/tag.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0cd6=['routing','number','TagId\x20is\x20a\x20string\x20and\x20it\x20is\x20required','consequence','length','error','[%s][TAG]\x20%s','map','message','join','info','next','channel','Interaction','then','interaction','catch','stringify','[%s][TAG]\x20no\x20tags\x20saved,\x20force\x20next','finally','isObject','validate','lodash','../../rpc/chatInteraction','../../rpc/openchannelInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction'];(function(_0x525c7b,_0x488fcc){var _0x27b33e=function(_0x56d43b){while(--_0x56d43b){_0x525c7b['push'](_0x525c7b['shift']());}};_0x27b33e(++_0x488fcc);}(_0x0cd6,0x181));var _0x60cd=function(_0x229d7e,_0x5bc489){_0x229d7e=_0x229d7e-0x0;var _0xa78280=_0x0cd6[_0x229d7e];return _0xa78280;};'use strict';var schema=require(_0x60cd('0x0'));var _=require(_0x60cd('0x1'));var rpc={'chatInteraction':require(_0x60cd('0x2')),'openchannelInteraction':require(_0x60cd('0x3')),'smsInteraction':require(_0x60cd('0x4')),'mailInteraction':require('../../rpc/mailInteraction'),'faxInteraction':require(_0x60cd('0x5')),'whatsappInteraction':require(_0x60cd('0x6'))};var logger=require('../../../../config/logger')(_0x60cd('0x7'));var tag=schema({'tag':{'type':_0x60cd('0x8'),'required':!![],'message':_0x60cd('0x9')}});exports[_0x60cd('0xa')]=function(_0x27d254,_0x11d6b3,_0x2f6bc1,_0x84563e){return function(_0x102115){try{var _0x1d0e54={'tag':_0x11d6b3[0x0]};var _0x3bf2d1=tag[_0x60cd('0x0')](_0x1d0e54,{'typecast':!![]});if(_0x3bf2d1[_0x60cd('0xb')]){logger[_0x60cd('0xc')](_0x60cd('0xd'),_0x27d254,_[_0x60cd('0xe')](_0x3bf2d1,_0x60cd('0xf'))[_0x60cd('0x10')](',\x20'));logger[_0x60cd('0x11')]('[%s][TAG]\x20no\x20tags\x20saved,\x20force\x20next',_0x27d254);_0x102115[_0x60cd('0x12')]();}else{var _0x56c41b={'ids':[_0x11d6b3[0x0]]};if(rpc[_0x84563e[_0x60cd('0x13')]+_0x60cd('0x14')]){rpc[_0x84563e[_0x60cd('0x13')]+_0x60cd('0x14')]['addTags'](_0x84563e['interaction']['id'],_0x56c41b)[_0x60cd('0x15')](function(_0x5d1e22){logger[_0x60cd('0x11')]('[%s][TAG]\x20tag\x20\x22%s\x22\x20added\x20to\x20%s\x20interaction\x20%s',_0x27d254,_0x11d6b3[0x1],_0x84563e[_0x60cd('0x13')],_0x84563e[_0x60cd('0x16')]['id']);})[_0x60cd('0x17')](function(_0x36b70d){logger[_0x60cd('0xc')]('[%s][TAG]\x20%s',_0x27d254,JSON[_0x60cd('0x18')](_0x36b70d));logger[_0x60cd('0x11')](_0x60cd('0x19'),_0x27d254);})[_0x60cd('0x1a')](function(){_0x102115['next']();});}}}catch(_0x46ca03){logger[_0x60cd('0xc')]('[%s][TAG]\x20%s',_0x27d254,_[_0x60cd('0x1b')](_0x46ca03)?JSON[_0x60cd('0x18')](_0x46ca03):_0x46ca03);logger[_0x60cd('0x11')](_0x60cd('0x19'),_0x27d254);_0x102115[_0x60cd('0x12')]();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/tvox.js b/server/services/routing/server/applications/tvox.js new file mode 100644 index 0000000..8f865f3 --- /dev/null +++ b/server/services/routing/server/applications/tvox.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x58e9=['urlOnAnswer','?params=','urlOnRing','jsonrpc','method','login','params','stringify','utf8','POST','application/json-rpc','logged','Unable\x20to\x20login\x20with\x20TVox\x20application','&serviceId=','&data=','then','[%s][TVOX]\x20Request\x20sent\x20to\x20TVox:\x20%s','stop','catch','error','[%s][TVOX]\x20%s','info','[%s][TVOX]\x20Application\x20already\x20executed\x20for\x20the\x20current\x20session,\x20force\x20next','request-promise','routing','lodash','consequence','replace','\x20-\x20','includes','push'];(function(_0x158da6,_0x3cb06d){var _0x429c30=function(_0x2d5895){while(--_0x2d5895){_0x158da6['push'](_0x158da6['shift']());}};_0x429c30(++_0x3cb06d);}(_0x58e9,0x10f));var _0x958e=function(_0x449af4,_0x163251){_0x449af4=_0x449af4-0x0;var _0xf6ad52=_0x58e9[_0x449af4];return _0xf6ad52;};'use strict';var rp=require(_0x958e('0x0'));var logger=require('../../../../config/logger')(_0x958e('0x1'));var _=require(_0x958e('0x2'));var arr=[];exports[_0x958e('0x3')]=function(_0x255f0a,_0x13b0cc){return function(_0x484e11){var _0x34f049=_0x13b0cc[0xa];var _0x30810a=_0x13b0cc[0xb];var _0x53d3c2=_0x13b0cc[0xc];var _0x3daca3=_0x13b0cc[0xd];var _0x14d256=_0x13b0cc[0xe];var _0x31231b=_0x13b0cc[0xf][_0x958e('0x4')](/\n/g,_0x958e('0x5'));var _0x7fef6a=_0x13b0cc[0x10][_0x958e('0x4')](/\n/g,'\x20');if(!arr[_0x958e('0x6')](_0x30810a)){arr[_0x958e('0x7')](_0x30810a);var _0x1e667d=_0x13b0cc[0x3];var _0x109a4d=_0x13b0cc[0x4];var _0x4adf9e=_0x13b0cc[0x1];var _0x17fb89=_0x13b0cc[0x0];var _0x23f746={};_0x23f746[_0x958e('0x8')]=_0x13b0cc[0x8]+_0x958e('0x9')+_0x53d3c2+'|'+_0x34f049+'|'+_0x3daca3+'|'+_0x30810a+'|'+_0x14d256;_0x23f746[_0x958e('0xa')]=_0x13b0cc[0x7]+'?params='+_0x53d3c2+'|'+_0x34f049+'|'+_0x3daca3+'|'+_0x30810a+'|'+_0x14d256+'|'+_0x31231b+'|'+_0x7fef6a;_0x23f746['title']=_0x13b0cc[0x9];var _0x4b0554={};_0x4b0554[_0x958e('0xb')]='2.0';_0x4b0554[_0x958e('0xc')]=_0x958e('0xd');var _0x219d9e=[];_0x219d9e[_0x958e('0x7')](_0x13b0cc[0x2]);_0x219d9e[_0x958e('0x7')](_0x13b0cc[0x5]);_0x219d9e[_0x958e('0x7')](_0x13b0cc[0x6]);_0x4b0554[_0x958e('0xe')]=_0x219d9e;_0x4b0554['id']=0x1;var _0x59f336=JSON[_0x958e('0xf')](_0x4b0554);var _0x59ffb2={'encoding':_0x958e('0x10'),'method':_0x958e('0x11'),'timeout':0x2710,'url':_0x1e667d,'headers':{'Content-Type':_0x958e('0x12')},'body':_0x59f336};return rp(_0x59ffb2)['then'](function(_0x107de9){const _0x2029bf=JSON['parse'](_0x107de9);if(!_0x2029bf['result'][_0x958e('0x13')]){throw new Error(_0x958e('0x14'));}var _0x426cdb=_0x30810a;var _0x244ff5='channelId='+_0x4adf9e+_0x958e('0x15')+_0x17fb89+'&sessionId='+_0x426cdb+_0x958e('0x16')+JSON['stringify'](_0x23f746);var _0x408123=_0x109a4d+'?'+_0x244ff5;return rp(_0x408123);})[_0x958e('0x17')](function(_0x261c2d){logger['info'](_0x958e('0x18'),_0x255f0a,_0x261c2d);_0x484e11[_0x958e('0x19')]();})[_0x958e('0x1a')](function(_0x282e1d){logger[_0x958e('0x1b')](_0x958e('0x1c'),_0x255f0a,_['isObject'](_0x282e1d)?JSON[_0x958e('0xf')](_0x282e1d):_0x282e1d);_0x484e11[_0x958e('0x19')]();});}else{logger[_0x958e('0x1d')](_0x958e('0x1e'),_0x255f0a);_0x484e11['next']();}};}; \ No newline at end of file diff --git a/server/services/routing/server/applications/utils.js b/server/services/routing/server/applications/utils.js new file mode 100644 index 0000000..aa0739c --- /dev/null +++ b/server/services/routing/server/applications/utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9c44=['merge','body','account','list','exports','render'];(function(_0x13a9d7,_0x1949c2){var _0x48ddc3=function(_0x4d1a97){while(--_0x4d1a97){_0x13a9d7['push'](_0x13a9d7['shift']());}};_0x48ddc3(++_0x1949c2);}(_0x9c44,0x178));var _0x49c4=function(_0x550d12,_0x5384bd){_0x550d12=_0x550d12-0x0;var _0x12103d=_0x9c44[_0x550d12];return _0x12103d;};'use strict';var Mustache=require('mustache');var _=require('lodash');module[_0x49c4('0x0')]={'getMustacheRender':function(_0x18bf2d,_0x26844b){return Mustache[_0x49c4('0x1')](_0x18bf2d,_[_0x49c4('0x2')](_0x26844b[_0x49c4('0x3')],{'contact':_0x26844b['contact'],'message':_0x26844b['message'],'account':_0x26844b[_0x49c4('0x4')],'interaction':_0x26844b['interaction'],'list':_0x26844b[_0x49c4('0x5')]}))||'';}}; \ No newline at end of file diff --git a/server/services/routing/server/index.js b/server/services/routing/server/index.js new file mode 100644 index 0000000..82f9891 --- /dev/null +++ b/server/services/routing/server/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xe8c6=['rules','channel','message','interaction','isArray','applications','length','existsSync','join','.js','app','toLowerCase','appdata','mail','push','slice','split','dialogflowv2','amazonlex','tag','TagId','tvox','account','notificationTemplate','ChatWebsiteId','body','%s:%s:%s','condition','intervals','./applications/','consequence','priority','on\x20interval','\x20|\x20','error','Please\x20create\x20a\x20new\x20file\x20under','execute','info','Applications\x20executed','stringify','emit','complete','format','Skipped\x20routing\x20for\x20%s','No\x20applications\x20to\x20execute','stack','agent','agents','busy','busyQueue','end','QueueReport','update','UserId','error\x20update\x20queue\x20report','message\x20is\x20empty','hasOwnProperty','capacity','CurrentCapacity','updateRealtime','agent\x20not\x20found','values','find','chatQueues','available','loggedIn','name','waiting','mailQueues','paused','openchannelQueues','smsQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','mailQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','server','http','listen','127.0.0.1','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','path','jayson/promise','./applications/strategy/util','../../../config/logger','../rpc/openchannelQueueReport','../rpc/mailQueueReport','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','%s.%s.%s','isNil','IntervalId','Intervals','map','interval'];(function(_0x6c993a,_0x5ea3ab){var _0x27f547=function(_0x22df20){while(--_0x22df20){_0x6c993a['push'](_0x6c993a['shift']());}};_0x27f547(++_0x5ea3ab);}(_0xe8c6,0x1f0));var _0x6e8c=function(_0x573f8b,_0x3324d9){_0x573f8b=_0x573f8b-0x0;var _0x12e9bd=_0xe8c6[_0x573f8b];return _0x12e9bd;};'use strict';var _=require(_0x6e8c('0x0'));var util=require(_0x6e8c('0x1'));var path=require(_0x6e8c('0x2'));var fs=require('fs');var jayson=require(_0x6e8c('0x3'));var BPromise=require('bluebird');var utils=require('./applications/utils');var sUtils=require(_0x6e8c('0x4'));var logger=require(_0x6e8c('0x5'))('routing');var rpc={'openchannelQueueReport':require(_0x6e8c('0x6')),'mailQueueReport':require(_0x6e8c('0x7')),'chatQueueReport':require(_0x6e8c('0x8')),'smsQueueReport':require(_0x6e8c('0x9')),'faxQueueReport':require(_0x6e8c('0xa')),'whatsappQueueReport':require(_0x6e8c('0xb'))};var RuleEngine=require(_0x6e8c('0xc'));function getId(_0x3d6acf,_0x4a9ce5,_0x5189ab){return util['format'](_0x6e8c('0xd'),_0x3d6acf,_0x4a9ce5||0x0,_0x5189ab||0x0);}function getIntervals(_0x2691ec,_0x11ce88){var _0xb6065d=[];if(!_[_0x6e8c('0xe')](_0x11ce88[_0x6e8c('0xf')])&&!_['isNil'](_0x2691ec[_0x11ce88[_0x6e8c('0xf')]])&&!_[_0x6e8c('0xe')](_0x2691ec[_0x11ce88[_0x6e8c('0xf')]][_0x6e8c('0x10')])){_0xb6065d=_[_0x6e8c('0x11')](_0x2691ec[_0x11ce88[_0x6e8c('0xf')]][_0x6e8c('0x10')],_0x6e8c('0x12'));}else if(!_[_0x6e8c('0xe')](_0x11ce88[_0x6e8c('0x12')])){_0xb6065d=[_0x11ce88['interval']];}return _0xb6065d;}exports['listen']=function(_0x365c5d){_0x365c5d[_0x6e8c('0x13')]={};return new BPromise(function(_0x3903db,_0x29ed51){var _0x3e7ad3={'Start':function(_0x1efe8d){var _0x35b18d=this;return new Promise(function(_0x4de55a,_0x3e52ec){if(_0x1efe8d){try{var _0x3f5873=[];var _0x4c3707=getId(_0x1efe8d[_0x6e8c('0x14')],_0x1efe8d[_0x6e8c('0x15')]?_0x1efe8d[_0x6e8c('0x15')]['id']:0x0,_0x1efe8d[_0x6e8c('0x16')]?_0x1efe8d[_0x6e8c('0x16')]['id']:0x0);var _0x8e37e4=sUtils['checkWaitingNotifications'](_0x365c5d,_0x1efe8d);if(!_0x8e37e4&&_0x1efe8d['applications']&&_[_0x6e8c('0x17')](_0x1efe8d[_0x6e8c('0x18')])&&_0x1efe8d[_0x6e8c('0x18')][_0x6e8c('0x19')]){for(var _0x199c20=0x0;_0x199c20<_0x1efe8d[_0x6e8c('0x18')][_0x6e8c('0x19')];_0x199c20+=0x1){var _0xc00822=_0x1efe8d['applications'][_0x199c20];if(fs[_0x6e8c('0x1a')](path[_0x6e8c('0x1b')](__dirname,_0x6e8c('0x18'),_0xc00822['app']+_0x6e8c('0x1c')))){var _0x53a74f=[];switch(_0xc00822[_0x6e8c('0x1d')][_0x6e8c('0x1e')]()){case'autoreply':var _0x3729f9=_0xc00822[_0x6e8c('0x1f')]['split'](',');if(_0x1efe8d['channel']===_0x6e8c('0x20')){_0x53a74f[_0x6e8c('0x21')](_0x3729f9[0x0]);_0x53a74f['push'](_0x3729f9[0x1]);_0x53a74f[_0x6e8c('0x21')](_0x3729f9['slice'](0x2,_0x3729f9[_0x6e8c('0x19')])[_0x6e8c('0x1b')](','));}else{_0x53a74f[_0x6e8c('0x21')](_0x3729f9[0x0]);_0x53a74f[_0x6e8c('0x21')](_0x3729f9[_0x6e8c('0x22')](0x1,_0x3729f9['length'])[_0x6e8c('0x1b')](','));}break;case'dialogflow':var _0x4c0f3a=_0xc00822[_0x6e8c('0x1f')][_0x6e8c('0x23')](',');_0x53a74f[_0x6e8c('0x21')](_0x4c0f3a[0x0]);_0x53a74f[_0x6e8c('0x21')](_0x4c0f3a[0x1]);_0x53a74f['push'](_0x4c0f3a[_0x6e8c('0x22')](0x2,_0x4c0f3a[_0x6e8c('0x19')])[_0x6e8c('0x1b')](','));break;case _0x6e8c('0x24'):var _0x3cef6a=_0xc00822['appdata']['split'](',');_0x53a74f['push'](_0x3cef6a[0x0]);_0x53a74f[_0x6e8c('0x21')](_0x3cef6a[0x1]);_0x53a74f[_0x6e8c('0x21')](_0x3cef6a[0x2]);_0x53a74f['push'](_0x3cef6a[0x3]);_0x53a74f[_0x6e8c('0x21')](_0x3cef6a[_0x6e8c('0x22')](0x4,_0x3cef6a[_0x6e8c('0x19')])[_0x6e8c('0x1b')](','));break;case _0x6e8c('0x25'):var _0x15d59b=_0xc00822[_0x6e8c('0x1f')]['split'](',');_0x53a74f[_0x6e8c('0x21')](_0x15d59b[0x0]);_0x53a74f[_0x6e8c('0x21')](_0x15d59b[0x1]);_0x53a74f[_0x6e8c('0x21')](_0x15d59b[0x2]);_0x53a74f[_0x6e8c('0x21')](_0x15d59b[0x3]);_0x53a74f[_0x6e8c('0x21')](_0x15d59b['slice'](0x4,_0x15d59b['length'])[_0x6e8c('0x1b')](','));break;case _0x6e8c('0x15'):_0x53a74f[_0x6e8c('0x21')](_0xc00822[_0x6e8c('0x1f')]);break;case _0x6e8c('0x26'):_0x53a74f[_0x6e8c('0x21')](_0xc00822[_0x6e8c('0x27')]);_0x53a74f[_0x6e8c('0x21')](_0xc00822[_0x6e8c('0x1f')]);break;case _0x6e8c('0x28'):var _0x8d0363=utils['getMustacheRender'](_0x1efe8d[_0x6e8c('0x29')][_0x6e8c('0x2a')],_0x1efe8d);var _0xb20da7=_0xc00822['appdata'][_0x6e8c('0x23')](',');_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x0]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x1]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x2]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x3]);_0x53a74f['push'](_0xb20da7[0x4]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x5]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x6]);_0x53a74f['push'](_0xb20da7[0x7]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0x8]);_0x53a74f['push'](_0xb20da7[0x9]);_0x53a74f[_0x6e8c('0x21')](_0xb20da7[0xa]);_0x53a74f[_0x6e8c('0x21')](_0x1efe8d[_0x6e8c('0x16')]['id']);_0x53a74f[_0x6e8c('0x21')](_0x1efe8d[_0x6e8c('0x15')]['id']);_0x53a74f[_0x6e8c('0x21')](_0xc00822[_0x6e8c('0x2b')]);_0x53a74f[_0x6e8c('0x21')](_0x1efe8d[_0x6e8c('0x16')]['ContactId']);_0x53a74f[_0x6e8c('0x21')](_0x1efe8d[_0x6e8c('0x2c')][_0x6e8c('0x2c')]);_0x53a74f[_0x6e8c('0x21')](_0x8d0363);break;default:_0x53a74f=_['isNil'](_0xc00822['appdata'])?[]:_0xc00822[_0x6e8c('0x1f')]['split'](',');}var _0x15fba9={'id':util['format'](_0x6e8c('0x2d'),_0x4c3707,_0xc00822['id'],_0xc00822['app']),'condition':require('./interval')[_0x6e8c('0x2e')](_0x4c3707,getIntervals(_0x365c5d[_0x6e8c('0x2f')],_0xc00822),_0x365c5d),'consequence':require(_0x6e8c('0x30')+_0xc00822[_0x6e8c('0x1d')])[_0x6e8c('0x31')](_0x4c3707,_0x53a74f,_0x365c5d,_0x1efe8d),'p':_0xc00822[_0x6e8c('0x32')]||0x0};logger['info']('Push\x20new\x20rule',_0x15fba9['id'],_0x6e8c('0x33'),getIntervals(_0x365c5d[_0x6e8c('0x2f')],_0xc00822)[_0x6e8c('0x1b')](_0x6e8c('0x34')));_0x3f5873['push'](_0x15fba9);}else{logger[_0x6e8c('0x35')](_0x6e8c('0x36'),path[_0x6e8c('0x1b')](__dirname,_0x6e8c('0x18'),_0xc00822[_0x6e8c('0x1d')]+_0x6e8c('0x1c')));}}_0x365c5d[_0x6e8c('0x13')][_0x4c3707]=new RuleEngine(_0x3f5873);_0x365c5d[_0x6e8c('0x13')][_0x4c3707][_0x6e8c('0x37')](_0x1efe8d,function(_0x2ae531){logger[_0x6e8c('0x38')](_0x6e8c('0x39'),JSON[_0x6e8c('0x3a')](_0x2ae531['matchPath']));if(_0x365c5d[_0x6e8c('0x13')][_0x4c3707]){_0x365c5d[_0x6e8c('0x13')][_0x4c3707][_0x6e8c('0x3b')](_0x6e8c('0x3c'));}});return _0x4de55a({'code':0xc8,'message':_0x1efe8d});}else{if(_0x8e37e4){logger['info'](util[_0x6e8c('0x3d')](_0x6e8c('0x3e'),_0x4c3707));}else{logger[_0x6e8c('0x38')](_0x6e8c('0x3f'));}return _0x4de55a({'code':0xc8,'message':_0x1efe8d});}}catch(_0x3e8912){logger[_0x6e8c('0x35')](_0x3e8912[_0x6e8c('0x40')]);return _0x3e52ec(_0x35b18d[_0x6e8c('0x35')](0x1f4,_0x3e8912));}}return _0x3e52ec('routing\x20is\x20empty');});},'AcceptMessage':function(_0x3b6deb){var _0x210a35=this;return new Promise(function(_0x106790,_0x1f2407){if(_0x3b6deb[_0x6e8c('0x41')]&&_0x3b6deb[_0x6e8c('0x41')]['id']){if(_0x365c5d['agents'][_0x3b6deb[_0x6e8c('0x41')]['id']]){_0x365c5d[_0x6e8c('0x42')][_0x3b6deb[_0x6e8c('0x41')]['id']][_0x6e8c('0x43')]=![];_0x365c5d['agents'][_0x3b6deb[_0x6e8c('0x41')]['id']][_0x6e8c('0x44')]=undefined;}}if(_0x3b6deb['message']&&_0x3b6deb['message']['id']){try{var _0x702c4c=getId(_0x3b6deb[_0x6e8c('0x14')],_0x3b6deb[_0x6e8c('0x15')]?_0x3b6deb[_0x6e8c('0x15')]['id']:0x0,_0x3b6deb[_0x6e8c('0x16')]?_0x3b6deb['interaction']['id']:0x0);if(_0x365c5d[_0x6e8c('0x13')][_0x702c4c]){_0x365c5d['rules'][_0x702c4c][_0x6e8c('0x3b')](_0x6e8c('0x45'));if(rpc[_0x3b6deb[_0x6e8c('0x14')]+'QueueReport']){rpc[_0x3b6deb['channel']+_0x6e8c('0x46')][_0x6e8c('0x47')](_0x702c4c,{'UserId':_0x3b6deb[_0x6e8c('0x15')][_0x6e8c('0x48')]})['catch'](function(){logger[_0x6e8c('0x35')](_0x6e8c('0x49'));});}}return _0x106790({'code':0xc8,'message':_0x3b6deb});}catch(_0x5909ee){logger[_0x6e8c('0x35')](_0x5909ee[_0x6e8c('0x40')]);return _0x1f2407(_0x210a35[_0x6e8c('0x35')](0x1f4,_0x5909ee));}}logger[_0x6e8c('0x35')](_0x6e8c('0x4a'));return _0x1f2407(_0x210a35[_0x6e8c('0x35')](0x1f4,_0x6e8c('0x4a')));});},'RejectMessage':function(_0x2a4134){var _0x5c0672=this;return new Promise(function(_0x58f630,_0x2b667a){if(_0x2a4134[_0x6e8c('0x41')]&&_0x2a4134['agent']['id']){try{if(_0x365c5d[_0x6e8c('0x42')][_0x2a4134[_0x6e8c('0x41')]['id']]){_0x365c5d[_0x6e8c('0x42')][_0x2a4134[_0x6e8c('0x41')]['id']]['busy']=![];_0x365c5d['agents'][_0x2a4134['agent']['id']][_0x6e8c('0x44')]=undefined;}return _0x58f630({'code':0xc8,'message':_0x2a4134});}catch(_0x1112b1){logger['error'](_0x1112b1[_0x6e8c('0x40')]);return _0x2b667a(_0x5c0672[_0x6e8c('0x35')](0x1f4,_0x1112b1));}}logger['error'](_0x6e8c('0x4a'));return _0x2b667a(_0x5c0672[_0x6e8c('0x35')](0x1f4,_0x6e8c('0x4a')));});},'AbandonInteraction':function(_0x96d3f1){var _0x19f1b2=this;return new Promise(function(_0xb4b76e,_0x239bb4){if(_0x96d3f1[_0x6e8c('0x14')]&&_0x96d3f1[_0x6e8c('0x16')]&&_0x96d3f1[_0x6e8c('0x16')]['id']){try{var _0x16dd78=getId(_0x96d3f1[_0x6e8c('0x14')],_0x96d3f1[_0x6e8c('0x15')]?_0x96d3f1[_0x6e8c('0x15')]['id']:0x0,_0x96d3f1[_0x6e8c('0x16')]?_0x96d3f1[_0x6e8c('0x16')]['id']:0x0);if(_0x365c5d[_0x6e8c('0x13')][_0x16dd78]){_0x365c5d[_0x6e8c('0x13')][_0x16dd78]['emit'](_0x6e8c('0x45'));}return _0xb4b76e({'code':0xc8,'message':_0x96d3f1});}catch(_0x509e46){logger[_0x6e8c('0x35')](_0x509e46[_0x6e8c('0x40')]);return _0x239bb4(_0x19f1b2[_0x6e8c('0x35')](0x1f4,_0x509e46));}}logger['error'](_0x6e8c('0x4a'));return _0x239bb4(_0x19f1b2[_0x6e8c('0x35')](0x1f4,'message\x20is\x20empty'));});},'AgentCapacity':function(_0x279229){var _0x35ebf6=this;return new Promise(function(_0x4e2226,_0x10c9cd){if(_0x365c5d[_0x6e8c('0x42')][_0x6e8c('0x4b')](_0x279229['id'])){for(var _0x8f1d54 in _0x279229[_0x6e8c('0x4c')]){if(_0x279229['capacity'][_0x6e8c('0x4b')](_0x8f1d54)){if(_0x365c5d[_0x6e8c('0x42')][_0x279229['id']]['hasOwnProperty'](_0x8f1d54+_0x6e8c('0x4d'))){_0x365c5d[_0x6e8c('0x42')][_0x279229['id']][_0x8f1d54+_0x6e8c('0x4d')]=parseInt(_0x279229[_0x6e8c('0x4c')][_0x8f1d54],0xa);}}}_0x365c5d[_0x6e8c('0x42')][_0x279229['id']][_0x6e8c('0x4e')]();return _0x4e2226({'code':0xc8,'message':_0x365c5d[_0x6e8c('0x42')][_0x279229['id']]});}else{return _0x10c9cd(_0x35ebf6[_0x6e8c('0x35')](0x1f4,_0x6e8c('0x4f')));}});},'Agents':function(_0x4bb09e){return new Promise(function(_0xde6e1d){var _0x3defbf=_[_0x6e8c('0x50')](_0x365c5d[_0x6e8c('0x42')]);if(_0x4bb09e&&_0x4bb09e['id']){var _0x5e9558=_[_0x6e8c('0x51')](_0x3defbf,function(_0x7b6207){return _0x7b6207['id']===_0x4bb09e['id'];});_0xde6e1d(_0x5e9558);}else{_0xde6e1d({'count':_0x3defbf[_0x6e8c('0x19')],'rows':_0x3defbf});}});},'ChatQueues':function(){return new Promise(function(_0x300312){var _0x4940f8=[];for(var _0x1c189b in _0x365c5d[_0x6e8c('0x52')]){if(_0x365c5d[_0x6e8c('0x52')][_0x6e8c('0x4b')](_0x1c189b)){var _0x12bdde=_0x365c5d[_0x6e8c('0x52')][_0x1c189b];var _0xb7d7d0={'id':_0x12bdde['id'],'available':_0x12bdde[_0x6e8c('0x53')],'loggedIn':_0x12bdde[_0x6e8c('0x54')],'name':_0x12bdde[_0x6e8c('0x55')],'paused':_0x12bdde['paused'],'waiting':_0x12bdde[_0x6e8c('0x56')]};_0x4940f8[_0x6e8c('0x21')](_0xb7d7d0);}}_0x300312({'count':_0x4940f8['length'],'rows':_0x4940f8});});},'MailQueues':function(){return new Promise(function(_0x171325){var _0x486e4b=[];for(var _0x1d7d17 in _0x365c5d[_0x6e8c('0x57')]){if(_0x365c5d['mailQueues'][_0x6e8c('0x4b')](_0x1d7d17)){var _0x558a1e=_0x365c5d[_0x6e8c('0x57')][_0x1d7d17];var _0x176cd2={'id':_0x558a1e['id'],'available':_0x558a1e['available'],'loggedIn':_0x558a1e[_0x6e8c('0x54')],'name':_0x558a1e[_0x6e8c('0x55')],'paused':_0x558a1e[_0x6e8c('0x58')],'waiting':_0x558a1e[_0x6e8c('0x56')]};_0x486e4b[_0x6e8c('0x21')](_0x176cd2);}}_0x171325({'count':_0x486e4b['length'],'rows':_0x486e4b});});},'OpenchannelQueues':function(){return new Promise(function(_0x567aa6){var _0x139ed4=[];for(var _0x2c0e9d in _0x365c5d[_0x6e8c('0x59')]){if(_0x365c5d[_0x6e8c('0x59')][_0x6e8c('0x4b')](_0x2c0e9d)){var _0x1c8201=_0x365c5d[_0x6e8c('0x59')][_0x2c0e9d];var _0x1ebdb5={'id':_0x1c8201['id'],'available':_0x1c8201[_0x6e8c('0x53')],'loggedIn':_0x1c8201[_0x6e8c('0x54')],'name':_0x1c8201[_0x6e8c('0x55')],'paused':_0x1c8201[_0x6e8c('0x58')],'waiting':_0x1c8201['waiting']};_0x139ed4[_0x6e8c('0x21')](_0x1ebdb5);}}_0x567aa6({'count':_0x139ed4[_0x6e8c('0x19')],'rows':_0x139ed4});});},'SmsQueues':function(){return new Promise(function(_0x10392e){var _0x29a921=[];for(var _0x33ede3 in _0x365c5d[_0x6e8c('0x5a')]){if(_0x365c5d[_0x6e8c('0x5a')][_0x6e8c('0x4b')](_0x33ede3)){var _0x64b8af=_0x365c5d[_0x6e8c('0x5a')][_0x33ede3];var _0x3b23d7={'id':_0x64b8af['id'],'available':_0x64b8af[_0x6e8c('0x53')],'loggedIn':_0x64b8af['loggedIn'],'name':_0x64b8af[_0x6e8c('0x55')],'paused':_0x64b8af[_0x6e8c('0x58')],'waiting':_0x64b8af[_0x6e8c('0x56')]};_0x29a921[_0x6e8c('0x21')](_0x3b23d7);}}_0x10392e({'count':_0x29a921['length'],'rows':_0x29a921});});},'FaxQueues':function(){return new Promise(function(_0x234dac){var _0x113b74=[];for(var _0x5406af in _0x365c5d[_0x6e8c('0x5b')]){if(_0x365c5d[_0x6e8c('0x5b')][_0x6e8c('0x4b')](_0x5406af)){var _0x575088=_0x365c5d[_0x6e8c('0x5b')][_0x5406af];var _0x31d882={'id':_0x575088['id'],'available':_0x575088[_0x6e8c('0x53')],'loggedIn':_0x575088[_0x6e8c('0x54')],'name':_0x575088[_0x6e8c('0x55')],'paused':_0x575088['paused'],'waiting':_0x575088[_0x6e8c('0x56')]};_0x113b74['push'](_0x31d882);}}_0x234dac({'count':_0x113b74[_0x6e8c('0x19')],'rows':_0x113b74});});},'WhatsappQueues':function(){return new Promise(function(_0x4281a){var _0x4f4290=[];for(var _0x1bf57d in _0x365c5d['whatsappQueues']){if(_0x365c5d[_0x6e8c('0x5c')][_0x6e8c('0x4b')](_0x1bf57d)){var _0x51a465=_0x365c5d[_0x6e8c('0x5c')][_0x1bf57d];var _0x1c6add={'id':_0x51a465['id'],'available':_0x51a465[_0x6e8c('0x53')],'loggedIn':_0x51a465[_0x6e8c('0x54')],'name':_0x51a465['name'],'paused':_0x51a465[_0x6e8c('0x58')],'waiting':_0x51a465['waiting']};_0x4f4290[_0x6e8c('0x21')](_0x1c6add);}}_0x4281a({'count':_0x4f4290[_0x6e8c('0x19')],'rows':_0x4f4290});});},'ChatQueuesWaitingInteractions':function(){return new Promise(function(_0x3b976f){var _0x48b8c9=_[_0x6e8c('0x50')](_0x365c5d[_0x6e8c('0x5d')]);_0x3b976f({'count':_0x48b8c9[_0x6e8c('0x19')],'rows':_0x48b8c9});});},'MailQueuesWaitingInteractions':function(){return new Promise(function(_0x126bcd){var _0xee6eba=_[_0x6e8c('0x50')](_0x365c5d[_0x6e8c('0x5e')]);_0x126bcd({'count':_0xee6eba[_0x6e8c('0x19')],'rows':_0xee6eba});});},'OpenchannelQueuesWaitingInteractions':function(){return new Promise(function(_0x3fc0de){var _0x29df9c=_[_0x6e8c('0x50')](_0x365c5d['openchannelQueuesWaitingInteractions']);_0x3fc0de({'count':_0x29df9c[_0x6e8c('0x19')],'rows':_0x29df9c});});},'SmsQueuesWaitingInteractions':function(){return new Promise(function(_0x5ad5dd){var _0x269a41=_[_0x6e8c('0x50')](_0x365c5d[_0x6e8c('0x5f')]);_0x5ad5dd({'count':_0x269a41[_0x6e8c('0x19')],'rows':_0x269a41});});},'FaxQueuesWaitingInteractions':function(){return new Promise(function(_0x205710){var _0x1f3101=_[_0x6e8c('0x50')](_0x365c5d[_0x6e8c('0x60')]);_0x205710({'count':_0x1f3101[_0x6e8c('0x19')],'rows':_0x1f3101});});},'WhatsappQueuesWaitingInteractions':function(){return new Promise(function(_0x72e0ab){var _0x1b6b46=_[_0x6e8c('0x50')](_0x365c5d['whatsappQueuesWaitingInteractions']);_0x72e0ab({'count':_0x1b6b46['length'],'rows':_0x1b6b46});});}};var _0x1347a2=jayson[_0x6e8c('0x61')](_0x3e7ad3)[_0x6e8c('0x62')]();_0x1347a2['on'](_0x6e8c('0x35'),function(_0x399618){logger[_0x6e8c('0x35')](JSON[_0x6e8c('0x3a')](_0x399618));return _0x29ed51(_0x399618);});_0x1347a2[_0x6e8c('0x63')](0x232c,_0x6e8c('0x64'),function(){console['log'](_0x6e8c('0x65'),0x232c);return _0x3903db(_0x6e8c('0x66')+0x232c);});});}; \ No newline at end of file diff --git a/server/services/routing/server/interval.js b/server/services/routing/server/interval.js new file mode 100644 index 0000000..60f688b --- /dev/null +++ b/server/services/routing/server/interval.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb049=['format','iftime\x20%s','then','indexOf','some','[%s][INTERVAL]\x20%s\x20%s','join','when','log','\x20|\x20','stack','util','bluebird','jayson/promise','lodash','../../../config/logger','routing','client','http','request','error','message','result','catch','condition','rules','info','[%s][INTERVAL]\x20ROUTING\x20STOPPED','stop','length','push','Command'];(function(_0x2ee4c8,_0x316127){var _0x35e4a2=function(_0x594094){while(--_0x594094){_0x2ee4c8['push'](_0x2ee4c8['shift']());}};_0x35e4a2(++_0x316127);}(_0xb049,0x14b));var _0x9b04=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xb049[_0xa464c9];return _0x3d73c4;};'use strict';var util=require(_0x9b04('0x0'));var BPromise=require(_0x9b04('0x1'));var jayson=require(_0x9b04('0x2'));var _=require(_0x9b04('0x3'));var logger=require(_0x9b04('0x4'))(_0x9b04('0x5'));var client=jayson[_0x9b04('0x6')][_0x9b04('0x7')]({'port':0x232a});function request(_0x4fceb3,_0x5dddca){return new BPromise(function(_0x4d5136,_0x227669){return client[_0x9b04('0x8')](_0x4fceb3,_0x5dddca)['then'](function(_0x43834f){if(_0x43834f[_0x9b04('0x9')]){return _0x227669(_0x43834f[_0x9b04('0x9')][_0x9b04('0xa')]);}else{return _0x4d5136(_0x43834f[_0x9b04('0xb')]);}})[_0x9b04('0xc')](function(_0x4aece8){return _0x227669(_0x4aece8);});});}exports[_0x9b04('0xd')]=function(_0xcbeefe,_0x305811,_0x5ddfe0){return function(_0x4e816c){if(_0x5ddfe0[_0x9b04('0xe')]&&!_0x5ddfe0[_0x9b04('0xe')][_0xcbeefe]){logger[_0x9b04('0xf')](_0x9b04('0x10'),_0xcbeefe);return _0x4e816c[_0x9b04('0x11')]();}var _0x56837a=[];for(var _0x5d25c2=0x0;_0x5d25c2<_0x305811[_0x9b04('0x12')];_0x5d25c2+=0x1){_0x56837a[_0x9b04('0x13')](request(_0x9b04('0x14'),{'command':util[_0x9b04('0x15')](_0x9b04('0x16'),_0x305811[_0x5d25c2])})[_0x9b04('0x17')](function(_0x2ac874){return _0x2ac874&&_0x2ac874[_0x9b04('0xa')]&&_0x2ac874[_0x9b04('0xa')][_0x9b04('0x18')]('true')>=0x0?!![]:![];})[_0x9b04('0xc')](function(_0x546081){logger[_0x9b04('0x9')]('[%s][INTERVAL]\x20%s',_0xcbeefe,_0x305811[_0x5d25c2]);}));}BPromise['all'](_0x56837a)[_0x9b04('0x17')](function(_0x4598e2){var _0x497b6e=_[_0x9b04('0x19')](_0x4598e2);logger['info'](_0x9b04('0x1a'),_0xcbeefe,_0x305811[_0x9b04('0x1b')]('\x20|\x20'),_0x497b6e);_0x4e816c[_0x9b04('0x1c')](_0x497b6e);})[_0x9b04('0xc')](function(_0x243bc5){console[_0x9b04('0x1d')](_0x243bc5);logger[_0x9b04('0x9')]('[%s][INTERVAL]\x20%s\x20%s',_0xcbeefe,_0x305811[_0x9b04('0x1b')](_0x9b04('0x1e')),_0x243bc5[_0x9b04('0x1f')]);_0x4e816c[_0x9b04('0x11')]();});};}; \ No newline at end of file diff --git a/server/services/xdr/agents.controller.js b/server/services/xdr/agents.controller.js new file mode 100644 index 0000000..136d350 --- /dev/null +++ b/server/services/xdr/agents.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9aea=['[%s][agents][agentcalled]','agentcalledAt','now','called','connectedlinename','error','agentringnoanswer','isNil','debug','agentringnoanswerAt','timeout','reason','holdtime','ringtime','[%s][agents][agentringnoanswer]','forIn','[%s][agents][queuecallerabandon]','[%s][agents][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned','abandoned','talktime','[%s][agents][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','connect','answered_elsewhere','answeredelsewheredestinationuniqueid','answeredelsewheremembername','[%s][agents][agentcomplete]','[%s][agents][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','agentcompleteAt','diffTime','complete','blindtransfer','transfereruniqueid','[%s][agents][blindtransfer]','transfertype','extension','transferuniqueid','attendedtransfer','[%s][agents][attendedtransfer]','origtransfereruniqueid','origtransfererlinkedid','[%s][agents][attendedtransfer]\x20agent:%s','secondtransfereruniqueid','transfer','origtransfererexten','transfereeuniqueid','clone','calleridname','agententerreason','transferexten','transfertargetuniqueid','hangup','[%s][agents][hangup]','cause','rejected','indexOf','splice','agent','[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s','lodash','./utils','info','[%s][agents][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','uniqueid','channel','queue','membername','calleridnum','connectedlinenum','lastevent','getVoiceQueueByName','then','type','agentacw','agentcomplete','acw','request','CreateVoiceAgentReport','destuniqueid','agentcalled','format'];(function(_0x384d13,_0x533f32){var _0x215bc3=function(_0xc9b08d){while(--_0xc9b08d){_0x384d13['push'](_0x384d13['shift']());}};_0x215bc3(++_0x533f32);}(_0x9aea,0xdd));var _0xa9ae=function(_0x2bca07,_0x1049b7){_0x2bca07=_0x2bca07-0x0;var _0x791d26=_0x9aea[_0x2bca07];return _0x791d26;};'use strict';var _=require(_0xa9ae('0x0'));var util=require('util');var utils=require(_0xa9ae('0x1'));var agents={};var transfers={};var unanswered=[];function writeDB(_0x5e1d51,_0x2b5e0c){utils[_0xa9ae('0x2')](util['format'](_0xa9ae('0x3'),_0x5e1d51[_0xa9ae('0x4')],_0x5e1d51[_0xa9ae('0x5')],_0x5e1d51[_0xa9ae('0x6')],_0x5e1d51[_0xa9ae('0x7')],_0x5e1d51['interface'],_0x5e1d51[_0xa9ae('0x8')],_0x5e1d51[_0xa9ae('0x9')],_0x5e1d51[_0xa9ae('0xa')]));if(_0x5e1d51['queue']){utils[_0xa9ae('0xb')](_0x5e1d51[_0xa9ae('0x6')])[_0xa9ae('0xc')](function(_0x44cf1b){if(_0x44cf1b){_0x5e1d51[_0xa9ae('0xd')]=_0x44cf1b[_0xa9ae('0xd')];_0x5e1d51[_0xa9ae('0xe')]=_0x5e1d51[_0xa9ae('0xf')]?_0x44cf1b[_0xa9ae('0x10')]:![];_0x5e1d51['acwtime']=_0x5e1d51[_0xa9ae('0xe')]?_0x44cf1b['acwTimeout']:0x0;}utils[_0xa9ae('0x11')](_0xa9ae('0x12'),_0x5e1d51);});}else{utils[_0xa9ae('0x11')](_0xa9ae('0x12'),_0x5e1d51);}if(_0x2b5e0c){delete transfers[_0x5e1d51[_0xa9ae('0x4')]];}else{delete agents[_0x5e1d51[_0xa9ae('0x13')]];}}exports[_0xa9ae('0x14')]=function(_0x2b511a){try{utils['debug'](util[_0xa9ae('0x15')](_0xa9ae('0x16'),_0x2b511a[_0xa9ae('0x4')]),_0x2b511a);agents[_0x2b511a[_0xa9ae('0x13')]]=_0x2b511a;agents[_0x2b511a['destuniqueid']][_0xa9ae('0x17')]=utils[_0xa9ae('0x18')]();agents[_0x2b511a[_0xa9ae('0x13')]][_0xa9ae('0xa')]=_0xa9ae('0x19');agents[_0x2b511a[_0xa9ae('0x13')]]['connectedlinenum']=null;agents[_0x2b511a[_0xa9ae('0x13')]][_0xa9ae('0x1a')]=null;utils[_0xa9ae('0x2')](util['format']('[%s][agents][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called',_0x2b511a[_0xa9ae('0x4')],agents[_0x2b511a['destuniqueid']]['membername'],_0x2b511a[_0xa9ae('0x13')]));}catch(_0x3b8245){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')]('[%s][agents][agentcalled]',_0x2b511a[_0xa9ae('0x4')]),_0x3b8245);}};exports[_0xa9ae('0x1c')]=function(_0x39f133){try{if(!_[_0xa9ae('0x1d')](agents[_0x39f133[_0xa9ae('0x13')]])){utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')]('[%s][agents][agentringnoanswer]',_0x39f133[_0xa9ae('0x4')]),_0x39f133);utils['info'](util['format']('[%s][agents][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:timeout',_0x39f133['uniqueid'],agents[_0x39f133[_0xa9ae('0x13')]]['membername'],_0x39f133[_0xa9ae('0x13')]));agents[_0x39f133['destuniqueid']][_0xa9ae('0x1c')]=!![];agents[_0x39f133[_0xa9ae('0x13')]][_0xa9ae('0x1f')]=utils[_0xa9ae('0x18')]();agents[_0x39f133[_0xa9ae('0x13')]][_0xa9ae('0xa')]=_0xa9ae('0x20');agents[_0x39f133['destuniqueid']][_0xa9ae('0x21')]=_0xa9ae('0x20');agents[_0x39f133[_0xa9ae('0x13')]][_0xa9ae('0x22')]=_0x39f133[_0xa9ae('0x23')]?parseInt(_0x39f133[_0xa9ae('0x23')])/0x3e8:0x0;agents[_0x39f133[_0xa9ae('0x13')]]['talktime']=0x0;unanswered['push'](_0x39f133[_0xa9ae('0x13')]);}}catch(_0x3c324e){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')](_0xa9ae('0x24'),_0x39f133['uniqueid']),_0x3c324e);}};exports['queuecallerabandon']=function(_0x1892b5){try{_[_0xa9ae('0x25')](agents,function(_0x372ec7,_0x3a48b7){if(_0x372ec7[_0xa9ae('0x4')]==_0x1892b5[_0xa9ae('0x4')]&&!_['includes'](unanswered,_0x372ec7['destuniqueid'])){utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')](_0xa9ae('0x26'),_0x1892b5[_0xa9ae('0x4')]),_0x1892b5);utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')](_0xa9ae('0x27'),_0x1892b5[_0xa9ae('0x4')],_0x372ec7['membername'],_0x372ec7[_0xa9ae('0x13')]));_0x372ec7['agentringnoanswer']=!![];_0x372ec7[_0xa9ae('0x1f')]=utils[_0xa9ae('0x18')]();_0x372ec7[_0xa9ae('0xa')]='abandoned';_0x372ec7[_0xa9ae('0x21')]=_0xa9ae('0x28');_0x372ec7[_0xa9ae('0x22')]=_0x1892b5[_0xa9ae('0x22')];_0x372ec7[_0xa9ae('0x29')]=0x0;writeDB(_0x372ec7);}});}catch(_0x4cb3ae){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')](_0xa9ae('0x26'),_0x1892b5['uniqueid']),_0x4cb3ae);}};exports['agentconnect']=function(_0x2155c8){try{if(agents[_0x2155c8[_0xa9ae('0x13')]]){utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')]('[%s][agents][agentconnect]',_0x2155c8[_0xa9ae('0x4')]),_0x2155c8);utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')](_0xa9ae('0x2a'),_0x2155c8[_0xa9ae('0x4')],agents[_0x2155c8['destuniqueid']][_0xa9ae('0x7')],_0x2155c8['destuniqueid']));agents[_0x2155c8[_0xa9ae('0x13')]][_0xa9ae('0x2b')]=utils[_0xa9ae('0x18')]();agents[_0x2155c8['destuniqueid']][_0xa9ae('0x9')]=_0x2155c8[_0xa9ae('0x9')];agents[_0x2155c8[_0xa9ae('0x13')]]['connectedlinename']=_0x2155c8[_0xa9ae('0x1a')];agents[_0x2155c8[_0xa9ae('0x13')]]['holdtime']=_0x2155c8[_0xa9ae('0x23')];agents[_0x2155c8['destuniqueid']][_0xa9ae('0xa')]=_0xa9ae('0x2c');_['forIn'](agents,function(_0x37da9b,_0x15ce12){if(_0x37da9b[_0xa9ae('0x13')]!=_0x2155c8[_0xa9ae('0x13')]&&_0x37da9b[_0xa9ae('0x4')]==_0x2155c8[_0xa9ae('0x4')]){_0x37da9b['talktime']=0x0;_0x37da9b[_0xa9ae('0x22')]=_0x2155c8[_0xa9ae('0x23')];_0x37da9b['agentringnoanswer']=!![];_0x37da9b['agentringnoanswerAt']=utils[_0xa9ae('0x18')]();_0x37da9b[_0xa9ae('0xa')]=_0xa9ae('0x2d');_0x37da9b[_0xa9ae('0x21')]='answered_elsewhere';_0x37da9b[_0xa9ae('0x2e')]=_0x2155c8[_0xa9ae('0x13')];_0x37da9b[_0xa9ae('0x2f')]=_0x2155c8[_0xa9ae('0x7')];writeDB(_0x37da9b);}});}}catch(_0x23c91d){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')]('[%s][agents][agentconnect]',_0x2155c8[_0xa9ae('0x4')]),_0x23c91d);}};exports[_0xa9ae('0xf')]=function(_0x566cb0){try{if(!_[_0xa9ae('0x1d')](agents[_0x566cb0['destuniqueid']])){utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')](_0xa9ae('0x30'),_0x566cb0[_0xa9ae('0x4')]),_0x566cb0);utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')](_0xa9ae('0x31'),_0x566cb0['uniqueid'],agents[_0x566cb0[_0xa9ae('0x13')]][_0xa9ae('0x7')],_0x566cb0['destuniqueid']));agents[_0x566cb0[_0xa9ae('0x13')]][_0xa9ae('0xf')]=!![];agents[_0x566cb0[_0xa9ae('0x13')]][_0xa9ae('0x32')]=utils[_0xa9ae('0x18')]();agents[_0x566cb0[_0xa9ae('0x13')]]['talktime']=utils[_0xa9ae('0x33')](agents[_0x566cb0['destuniqueid']][_0xa9ae('0x32')],agents[_0x566cb0[_0xa9ae('0x13')]]['agentconnectAt']);agents[_0x566cb0['destuniqueid']][_0xa9ae('0x21')]=_0x566cb0[_0xa9ae('0x21')];agents[_0x566cb0[_0xa9ae('0x13')]][_0xa9ae('0xa')]=_0xa9ae('0x34');writeDB(agents[_0x566cb0[_0xa9ae('0x13')]]);}}catch(_0x2961e4){utils[_0xa9ae('0x1b')](util['format']('[%s][agents][agentcomplete]',_0x566cb0[_0xa9ae('0x4')]),_0x2961e4);}};exports[_0xa9ae('0x35')]=function(_0x4efe55){try{if(!_[_0xa9ae('0x1d')](agents[_0x4efe55[_0xa9ae('0x36')]])){utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')](_0xa9ae('0x37'),_0x4efe55[_0xa9ae('0x4')]),_0x4efe55);utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')]('[%s][agents][blindtransfer]\x20agent:%s\x20transferuniqueid:%s',_0x4efe55[_0xa9ae('0x4')],agents[_0x4efe55[_0xa9ae('0x36')]]['membername'],agents[_0x4efe55[_0xa9ae('0x36')]]['uniqueid']));agents[_0x4efe55['transfereruniqueid']]['transfer']=!![];agents[_0x4efe55[_0xa9ae('0x36')]][_0xa9ae('0x38')]='blind';agents[_0x4efe55['transfereruniqueid']]['transferexten']=_0x4efe55[_0xa9ae('0x39')];agents[_0x4efe55['transfereruniqueid']][_0xa9ae('0x3a')]=agents[_0x4efe55[_0xa9ae('0x36')]]['uniqueid'];}}catch(_0x1be415){utils['error'](util[_0xa9ae('0x15')](_0xa9ae('0x37'),_0x4efe55[_0xa9ae('0x4')]),_0x1be415);}};exports[_0xa9ae('0x3b')]=function(_0x371760){try{utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')](_0xa9ae('0x3c'),_0x371760[_0xa9ae('0x3d')]),_0x371760);if(_0x371760[_0xa9ae('0x3d')]==_0x371760[_0xa9ae('0x3e')]){if(!_[_0xa9ae('0x1d')](agents[_0x371760['secondtransfereruniqueid']])){utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')](_0xa9ae('0x3f'),_0x371760[_0xa9ae('0x3d')],agents[_0x371760[_0xa9ae('0x40')]]['membername']));agents[_0x371760['secondtransfereruniqueid']][_0xa9ae('0x41')]=!![];agents[_0x371760[_0xa9ae('0x40')]]['transfertype']='ATTENDED';agents[_0x371760[_0xa9ae('0x40')]]['transferexten']=_0x371760[_0xa9ae('0x42')];agents[_0x371760[_0xa9ae('0x40')]][_0xa9ae('0x3a')]=_0x371760['origtransfereruniqueid'];}if(_0x371760[_0xa9ae('0x43')]&&agents[_0x371760['transfereeuniqueid']]){agents[_0x371760[_0xa9ae('0x43')]]['agententerreason']=0x1;transfers[_0x371760[_0xa9ae('0x43')]]=_[_0xa9ae('0x44')](agents[_0x371760[_0xa9ae('0x43')]]);transfers[_0x371760[_0xa9ae('0x43')]][_0xa9ae('0x8')]=agents[_0x371760[_0xa9ae('0x40')]]['calleridnum'];transfers[_0x371760[_0xa9ae('0x43')]][_0xa9ae('0x45')]=agents[_0x371760[_0xa9ae('0x40')]][_0xa9ae('0x45')];transfers[_0x371760['transfereeuniqueid']][_0xa9ae('0x17')]=utils[_0xa9ae('0x18')]();transfers[_0x371760[_0xa9ae('0x43')]][_0xa9ae('0x2b')]=utils[_0xa9ae('0x18')]();transfers[_0x371760[_0xa9ae('0x43')]][_0xa9ae('0x22')]=0x0;transfers[_0x371760[_0xa9ae('0x43')]][_0xa9ae('0x46')]=0x2;}}else if(_0x371760[_0xa9ae('0x40')]==_0x371760['secondtransfererlinkedid']){if(!_[_0xa9ae('0x1d')](agents[_0x371760[_0xa9ae('0x3d')]])){utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')]('[%s][agents][attendedtransfer]\x20agent:%s',_0x371760[_0xa9ae('0x3d')],agents[_0x371760[_0xa9ae('0x3d')]]['membername']));agents[_0x371760[_0xa9ae('0x3d')]][_0xa9ae('0x41')]=!![];agents[_0x371760[_0xa9ae('0x3d')]]['transfertype']='ATTENDED';agents[_0x371760[_0xa9ae('0x3d')]][_0xa9ae('0x47')]=_0x371760['secondtransfererexten'];agents[_0x371760['origtransfereruniqueid']][_0xa9ae('0x3a')]=_0x371760[_0xa9ae('0x40')];}if(_0x371760[_0xa9ae('0x48')]&&agents[_0x371760['transfertargetuniqueid']]){agents[_0x371760[_0xa9ae('0x48')]][_0xa9ae('0x46')]=0x1;transfers[_0x371760[_0xa9ae('0x48')]]=_[_0xa9ae('0x44')](agents[_0x371760[_0xa9ae('0x48')]]);transfers[_0x371760[_0xa9ae('0x48')]][_0xa9ae('0x8')]=agents[_0x371760[_0xa9ae('0x3d')]][_0xa9ae('0x8')];transfers[_0x371760[_0xa9ae('0x48')]]['calleridname']=agents[_0x371760['origtransfereruniqueid']][_0xa9ae('0x45')];transfers[_0x371760[_0xa9ae('0x48')]][_0xa9ae('0x17')]=utils['now']();transfers[_0x371760[_0xa9ae('0x48')]][_0xa9ae('0x2b')]=utils[_0xa9ae('0x18')]();transfers[_0x371760['transfertargetuniqueid']]['holdtime']=0x0;transfers[_0x371760[_0xa9ae('0x48')]]['agententerreason']=0x2;}}}catch(_0x14a720){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')](_0xa9ae('0x3c'),_0x371760[_0xa9ae('0x3d')]),_0x14a720);}};exports[_0xa9ae('0x49')]=function(_0x1bf8e3){try{utils[_0xa9ae('0x1e')](util[_0xa9ae('0x15')](_0xa9ae('0x4a'),_0x1bf8e3['uniqueid']),_0x1bf8e3);if(agents[_0x1bf8e3[_0xa9ae('0x4')]]&&agents[_0x1bf8e3['uniqueid']][_0xa9ae('0x21')]===_0xa9ae('0x20')){if(_0x1bf8e3[_0xa9ae('0x4b')]==='21'){agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x21')]='rejected';agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0xa')]=_0xa9ae('0x4c');}utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')]('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x1bf8e3[_0xa9ae('0x4')],agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x7')],agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x21')],agents[_0x1bf8e3['uniqueid']]['lastevent']));writeDB(agents[_0x1bf8e3[_0xa9ae('0x4')]]);var _0x2f4a73=unanswered[_0xa9ae('0x4d')](_0x1bf8e3[_0xa9ae('0x4')]);if(_0x2f4a73>-0x1){unanswered[_0xa9ae('0x4e')](_0x2f4a73,0x1);}}if(transfers[_0x1bf8e3['uniqueid']]){transfers[_0x1bf8e3['uniqueid']][_0xa9ae('0xf')]=!![];transfers[_0x1bf8e3[_0xa9ae('0x4')]]['agentcompleteAt']=utils['now']();transfers[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x29')]=utils[_0xa9ae('0x33')](transfers[_0x1bf8e3[_0xa9ae('0x4')]]['agentcompleteAt'],transfers[_0x1bf8e3['uniqueid']][_0xa9ae('0x2b')]);transfers[_0x1bf8e3['uniqueid']]['reason']='agent';transfers[_0x1bf8e3['uniqueid']][_0xa9ae('0xa')]=_0xa9ae('0x34');utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')]('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x1bf8e3[_0xa9ae('0x4')],transfers[_0x1bf8e3[_0xa9ae('0x4')]]['membername'],transfers[_0x1bf8e3[_0xa9ae('0x4')]]['reason'],transfers[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0xa')]));writeDB(transfers[_0x1bf8e3[_0xa9ae('0x4')]],!![]);}if(agents[_0x1bf8e3[_0xa9ae('0x4')]]&&agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x2b')]){agents[_0x1bf8e3['uniqueid']][_0xa9ae('0xf')]=!![];agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x32')]=utils[_0xa9ae('0x18')]();agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x29')]=utils[_0xa9ae('0x33')](agents[_0x1bf8e3[_0xa9ae('0x4')]]['agentcompleteAt'],agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x2b')]);agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x21')]=agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x41')]?_0xa9ae('0x41'):_0xa9ae('0x4f');agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0xa')]=_0xa9ae('0x34');utils[_0xa9ae('0x2')](util[_0xa9ae('0x15')](_0xa9ae('0x50'),_0x1bf8e3[_0xa9ae('0x4')],agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x7')],agents[_0x1bf8e3[_0xa9ae('0x4')]][_0xa9ae('0x21')],agents[_0x1bf8e3['uniqueid']][_0xa9ae('0xa')]));writeDB(agents[_0x1bf8e3[_0xa9ae('0x4')]]);}}catch(_0x1f6465){utils[_0xa9ae('0x1b')](util[_0xa9ae('0x15')](_0xa9ae('0x4a'),_0x1bf8e3[_0xa9ae('0x4')]),_0x1f6465);}}; \ No newline at end of file diff --git a/server/services/xdr/calls.controller.js b/server/services/xdr/calls.controller.js new file mode 100644 index 0000000..9f88d3d --- /dev/null +++ b/server/services/xdr/calls.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x6ff4=['varset','xmd-originatecalleridnum','source','value','variable','destination','\x22\x20<','xmd-callerid-preview','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-callerid','xmcs-queue','xmd-queue','lastapplication','lastdata','xmd-contactid','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','xmd-cdrtype','[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s','type','outboundrouteid','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','[%s][calls][varset]\x20variable:sipcallid\x20value:%s','[%s][calls][varset]','[%s][calls][newexten]\x20application:%s\x20appdata:%s','appdata','application','set','toLowerCase','cdr','substring','includes','hangup','noop','execif','gotoif','[%s][calls][newexten]','lodash','util','./utils','./transfers.controller','FAILED','NO\x20ANSWER','ANSWERED','BUSY','blinds','uniqueid','info','format','[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','channel','queue','membername','interface','calleridnum','connectedlinenum','lastevent','accountcode','getUserByInternal','then','request','CreateVoiceCallReport','recording','debug','[%s][calls][newchannel]','linkedid','OutgoingSpoolFailed','[%s][calls][newchannel]\x20context:%s\x20exten:%s','exten','context','now','DOCUMENTATION','error','newstate','[%s][calls][newstate]','isNil','channelstate','[%s][calls][newstate]\x20context:%s\x20channel:%s','systemanswertime','transfer','[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','destinationchannel','answertime','disposition','toNumber','callerid','calleridname','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','duration','diffTime','endtime','starttime','billableseconds','[%s][calls][hangup]','attendedtransfer','origtransfereruniqueid','transfereechannel','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','localtwolinkedid','secondtransfererchannel','_attended','origtransfererchannel','userfield','[%s][calls][attendedtransfer]','[%s][calls][musiconholdstart]','musiconholdstartAt','[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s','musiconholdstop','[%s][calls][musiconholdstop]'];(function(_0x16e5b3,_0x30d91d){var _0x4d6874=function(_0x2fffbe){while(--_0x2fffbe){_0x16e5b3['push'](_0x16e5b3['shift']());}};_0x4d6874(++_0x30d91d);}(_0x6ff4,0x90));var _0x46ff=function(_0x14b8ee,_0x26d31a){_0x14b8ee=_0x14b8ee-0x0;var _0x50ef2b=_0x6ff4[_0x14b8ee];return _0x50ef2b;};'use strict';var _=require(_0x46ff('0x0'));var util=require(_0x46ff('0x1'));var utils=require(_0x46ff('0x2'));var transfers=require(_0x46ff('0x3'));var dispositions=['NO\x20ANSWER',_0x46ff('0x4'),_0x46ff('0x4'),'NO\x20ANSWER',_0x46ff('0x5'),'NO\x20ANSWER',_0x46ff('0x6'),_0x46ff('0x7'),'FAILED',_0x46ff('0x4'),_0x46ff('0x4')];var channels={};function writeDB(_0x29c1aa){var _0x264ed0;if(transfers[_0x46ff('0x8')][_0x29c1aa[_0x46ff('0x9')]]){_0x264ed0=_0x29c1aa['uniqueid'];_0x29c1aa[_0x46ff('0x9')]=transfers[_0x46ff('0x8')][_0x29c1aa[_0x46ff('0x9')]]['transfereeuniqueid'];}utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0xc'),_0x29c1aa[_0x46ff('0x9')],_0x29c1aa[_0x46ff('0xd')],_0x29c1aa[_0x46ff('0xe')],_0x29c1aa[_0x46ff('0xf')],_0x29c1aa[_0x46ff('0x10')],_0x29c1aa[_0x46ff('0x11')],_0x29c1aa[_0x46ff('0x12')],_0x29c1aa[_0x46ff('0x13')]));if(_0x29c1aa[_0x46ff('0x14')]){utils[_0x46ff('0x15')](_0x29c1aa['accountcode'])[_0x46ff('0x16')](function(_0x11272b){if(_0x11272b){_0x29c1aa['UserId']=_0x11272b['id'];}utils[_0x46ff('0x17')]('CreateVoiceCallReport',_0x29c1aa);});}else{utils[_0x46ff('0x17')](_0x46ff('0x18'),_0x29c1aa);}if(channels[_0x29c1aa['uniqueid']]){delete channels[_0x29c1aa[_0x46ff('0x9')]];}else if(_0x264ed0&&channels[_0x264ed0]){if(!transfers[_0x46ff('0x8')][_0x264ed0][_0x46ff('0x19')])delete transfers[_0x46ff('0x8')][_0x264ed0];delete channels[_0x264ed0];}}exports['newchannel']=function(_0x38256d){try{utils[_0x46ff('0x1a')](util['format'](_0x46ff('0x1b'),_0x38256d[_0x46ff('0x9')]),_0x38256d);if(_0x38256d[_0x46ff('0x9')]==_0x38256d[_0x46ff('0x1c')]&&_0x38256d[_0x46ff('0xd')]!=_0x46ff('0x1d')){utils['info'](util[_0x46ff('0xb')](_0x46ff('0x1e'),_0x38256d[_0x46ff('0x9')],_0x38256d['context'],_0x38256d['exten']));channels[_0x38256d[_0x46ff('0x9')]]={'uniqueid':_0x38256d[_0x46ff('0x9')],'accountcode':_0x38256d[_0x46ff('0x14')],'source':_0x38256d[_0x46ff('0x11')],'destination':_0x38256d[_0x46ff('0x1f')],'destinationcontext':_0x38256d[_0x46ff('0x20')],'channel':_0x38256d[_0x46ff('0xd')],'starttime':utils[_0x46ff('0x21')](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':'NO\x20ANSWER','amaflags':_0x46ff('0x22')};}}catch(_0x32ca54){utils[_0x46ff('0x23')](util[_0x46ff('0xb')](_0x46ff('0x1b'),_0x38256d[_0x46ff('0x9')]),_0x32ca54);}};exports[_0x46ff('0x24')]=function(_0x53f997){try{utils[_0x46ff('0x1a')](util[_0x46ff('0xb')](_0x46ff('0x25'),_0x53f997[_0x46ff('0x9')]),_0x53f997);if(!_[_0x46ff('0x26')](channels[_0x53f997['uniqueid']])&&_0x53f997[_0x46ff('0x27')]==0x6){utils['info'](util['format'](_0x46ff('0x28'),_0x53f997[_0x46ff('0x9')],_0x53f997[_0x46ff('0x20')],_0x53f997[_0x46ff('0xd')]));if(_[_0x46ff('0x26')](channels[_0x53f997[_0x46ff('0x9')]][_0x46ff('0x29')])){channels[_0x53f997[_0x46ff('0x9')]][_0x46ff('0x29')]=utils[_0x46ff('0x21')]();}}else if(!_[_0x46ff('0x26')](channels[_0x53f997[_0x46ff('0x1c')]])&&_0x53f997['channelstate']==0x6&&_0x53f997[_0x46ff('0x20')]!=_0x46ff('0x2a')){utils[_0x46ff('0xa')](util['format'](_0x46ff('0x2b'),_0x53f997['uniqueid'],_0x53f997[_0x46ff('0x1c')],_0x53f997[_0x46ff('0x20')],_0x53f997['channel']));channels[_0x53f997[_0x46ff('0x1c')]][_0x46ff('0x14')]=_0x53f997['accountcode'];channels[_0x53f997['linkedid']][_0x46ff('0x2c')]=_0x53f997[_0x46ff('0xd')];if(_[_0x46ff('0x26')](channels[_0x53f997['linkedid']][_0x46ff('0x2d')])){channels[_0x53f997[_0x46ff('0x1c')]][_0x46ff('0x2d')]=utils['now']();}channels[_0x53f997[_0x46ff('0x1c')]][_0x46ff('0x2e')]=dispositions[_[_0x46ff('0x2f')](_0x53f997[_0x46ff('0x27')])]||'ANSWERED';}}catch(_0x5534cb){utils[_0x46ff('0x23')](util[_0x46ff('0xb')](_0x46ff('0x25'),_0x53f997[_0x46ff('0x9')]),_0x5534cb);}};exports['hangup']=function(_0x3c26b6){try{if(!_[_0x46ff('0x26')](channels[_0x3c26b6[_0x46ff('0x9')]])){utils[_0x46ff('0x1a')](util[_0x46ff('0xb')]('[%s][calls][hangup]',_0x3c26b6[_0x46ff('0x9')]),_0x3c26b6);if(_[_0x46ff('0x26')](channels[_0x3c26b6[_0x46ff('0x9')]][_0x46ff('0x30')])){channels[_0x3c26b6[_0x46ff('0x9')]]['callerid']=_0x3c26b6[_0x46ff('0x31')]+'\x20<'+_0x3c26b6[_0x46ff('0x11')]+'>';}utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0x32'),_0x3c26b6[_0x46ff('0x9')],channels[_0x3c26b6[_0x46ff('0x9')]]['callerid'],_0x3c26b6['cause-txt']));channels[_0x3c26b6[_0x46ff('0x9')]]['endtime']=utils['now']();channels[_0x3c26b6[_0x46ff('0x9')]][_0x46ff('0x33')]=utils[_0x46ff('0x34')](channels[_0x3c26b6['uniqueid']][_0x46ff('0x35')],channels[_0x3c26b6[_0x46ff('0x9')]][_0x46ff('0x36')]);channels[_0x3c26b6[_0x46ff('0x9')]][_0x46ff('0x37')]=channels[_0x3c26b6[_0x46ff('0x9')]]['answertime']?utils[_0x46ff('0x34')](channels[_0x3c26b6[_0x46ff('0x9')]][_0x46ff('0x35')],channels[_0x3c26b6[_0x46ff('0x9')]]['answertime']):0x0;writeDB(channels[_0x3c26b6[_0x46ff('0x9')]]);}}catch(_0x527a11){utils[_0x46ff('0x23')](util[_0x46ff('0xb')](_0x46ff('0x38'),_0x3c26b6[_0x46ff('0x9')]),_0x527a11);}};exports[_0x46ff('0x39')]=function(_0x385450){try{if(!_[_0x46ff('0x26')](channels[_0x385450['localtwolinkedid']])){utils['debug'](util[_0x46ff('0xb')]('[%s][calls][attendedtransfer]',_0x385450[_0x46ff('0x3a')]),_0x385450);if(channels[_0x385450['localtwolinkedid']][_0x46ff('0xd')]==_0x385450[_0x46ff('0x3b')]){utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0x3c'),_0x385450[_0x46ff('0x3a')],_0x385450[_0x46ff('0x3d')],_0x385450[_0x46ff('0x3e')]));channels[_0x385450[_0x46ff('0x3d')]][_0x46ff('0x2c')]=_0x385450['secondtransfererchannel'];channels[_0x385450['localtwolinkedid']]['userfield']=_0x46ff('0x3f');}else if(channels[_0x385450[_0x46ff('0x3d')]][_0x46ff('0xd')]=_0x385450['transfertargetchannel']){utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0x3c'),_0x385450[_0x46ff('0x3a')],_0x385450[_0x46ff('0x3d')],_0x385450[_0x46ff('0x40')]));channels[_0x385450[_0x46ff('0x3d')]][_0x46ff('0x2c')]=_0x385450[_0x46ff('0x40')];channels[_0x385450[_0x46ff('0x3d')]][_0x46ff('0x41')]='_attended';}}}catch(_0x3d0334){utils['error'](util[_0x46ff('0xb')](_0x46ff('0x42'),_0x385450[_0x46ff('0x3a')]),_0x3d0334);}};exports['musiconholdstart']=function(_0x1b6118){try{if(!_[_0x46ff('0x26')](channels[_0x1b6118['uniqueid']])){utils[_0x46ff('0x1a')](util[_0x46ff('0xb')](_0x46ff('0x43'),_0x1b6118[_0x46ff('0x9')]),_0x1b6118);channels[_0x1b6118['uniqueid']][_0x46ff('0x44')]=utils[_0x46ff('0x21')]();utils['info'](util['format'](_0x46ff('0x45'),_0x1b6118['uniqueid'],channels[_0x1b6118[_0x46ff('0x9')]][_0x46ff('0x44')]));}}catch(_0x113890){utils[_0x46ff('0x23')](util[_0x46ff('0xb')]('[%s][calls][musiconholdstart]',_0x1b6118[_0x46ff('0x9')]),_0x113890);}};exports[_0x46ff('0x46')]=function(_0x27d62c){try{if(!_['isNil'](channels[_0x27d62c[_0x46ff('0x9')]])){utils[_0x46ff('0x1a')](util[_0x46ff('0xb')](_0x46ff('0x47'),_0x27d62c['uniqueid']),_0x27d62c);if(!_[_0x46ff('0x26')](channels[_0x27d62c[_0x46ff('0x9')]][_0x46ff('0x44')])){channels[_0x27d62c['uniqueid']]['mohtime']+=utils['diffTime'](utils[_0x46ff('0x21')](),channels[_0x27d62c[_0x46ff('0x9')]]['musiconholdstartAt']);utils[_0x46ff('0xa')](util[_0x46ff('0xb')]('[%s][calls][musiconholdstop]\x20mohtime:%s',_0x27d62c[_0x46ff('0x9')],channels[_0x27d62c['uniqueid']]['mohtime']));delete channels[_0x27d62c[_0x46ff('0x9')]]['musiconholdstartAt'];}}}catch(_0x73c5d){utils['error'](util[_0x46ff('0xb')](_0x46ff('0x47'),_0x27d62c['uniqueid']),_0x73c5d);}};exports[_0x46ff('0x48')]=function(_0x35b87c){try{if(!_[_0x46ff('0x26')](channels[_0x35b87c['uniqueid']])){utils[_0x46ff('0x1a')](util[_0x46ff('0xb')]('[%s][calls][varset]',_0x35b87c[_0x46ff('0x9')]),_0x35b87c);if(!_[_0x46ff('0x26')](_0x35b87c['variable'][_0x46ff('0x49')])){utils[_0x46ff('0xa')](util[_0x46ff('0xb')]('[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s',_0x35b87c[_0x46ff('0x9')],_0x35b87c['value']));channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0x4a')]=_0x35b87c[_0x46ff('0x4b')];}if(!_['isNil'](_0x35b87c[_0x46ff('0x4c')]['xmd-phone'])){utils[_0x46ff('0xa')](util[_0x46ff('0xb')]('[%s][calls][varset]\x20variable:xmd-phone\x20value:%s',_0x35b87c[_0x46ff('0x9')],_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0x4d')]=_0x35b87c[_0x46ff('0x4b')];channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0x30')]='\x22'+_0x35b87c[_0x46ff('0x4b')]+_0x46ff('0x4e')+_0x35b87c[_0x46ff('0x4b')]+'>';}if(!_[_0x46ff('0x26')](_0x35b87c[_0x46ff('0x4c')][_0x46ff('0x4f')])||!_[_0x46ff('0x26')](_0x35b87c['variable']['xmd-callerid'])){utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0x50'),_0x35b87c['uniqueid'],!_[_0x46ff('0x26')](_0x35b87c['variable'][_0x46ff('0x4f')])?_0x46ff('0x4f'):_0x46ff('0x51'),_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c['uniqueid']][_0x46ff('0x30')]=_0x35b87c['value'];}if(!_['isNil'](_0x35b87c[_0x46ff('0x4c')]['xmd-queue'])||!_[_0x46ff('0x26')](_0x35b87c['variable'][_0x46ff('0x52')])){utils[_0x46ff('0xa')](util[_0x46ff('0xb')](_0x46ff('0x50'),_0x35b87c[_0x46ff('0x9')],!_[_0x46ff('0x26')](_0x35b87c[_0x46ff('0x4c')][_0x46ff('0x53')])?'xmd-queue':_0x46ff('0x52'),_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0x54')]='Queue';channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0x55')]=_0x35b87c[_0x46ff('0x4b')];channels[_0x35b87c[_0x46ff('0x9')]][_0x46ff('0xe')]=!![];}if(!_['isNil'](_0x35b87c[_0x46ff('0x4c')][_0x46ff('0x56')])){utils['info'](util[_0x46ff('0xb')](_0x46ff('0x57'),_0x35b87c['uniqueid'],_0x35b87c['value']));channels[_0x35b87c[_0x46ff('0x9')]]['ContactId']=_0x35b87c['value'];}if(!_['isNil'](_0x35b87c['variable'][_0x46ff('0x58')])){utils['info'](util['format'](_0x46ff('0x59'),_0x35b87c['uniqueid'],_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c['uniqueid']][_0x46ff('0x5a')]=_0x35b87c[_0x46ff('0x4b')];}if(!_[_0x46ff('0x26')](_0x35b87c[_0x46ff('0x4c')][_0x46ff('0x5b')])){utils['info'](util['format'](_0x46ff('0x5c'),_0x35b87c[_0x46ff('0x9')],_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c[_0x46ff('0x9')]]['routeid']=_0x35b87c[_0x46ff('0x4b')];}if(!_[_0x46ff('0x26')](_0x35b87c[_0x46ff('0x4c')]['sipcallid'])){utils[_0x46ff('0xa')](util['format'](_0x46ff('0x5d'),_0x35b87c[_0x46ff('0x9')],_0x35b87c[_0x46ff('0x4b')]));channels[_0x35b87c[_0x46ff('0x9')]]['sipcallid']=_0x35b87c[_0x46ff('0x4b')];}}}catch(_0x1e02be){utils[_0x46ff('0x23')](util['format'](_0x46ff('0x5e'),_0x35b87c[_0x46ff('0x9')]),_0x1e02be);}};exports['newexten']=function(_0x21b5ff){try{if(!_[_0x46ff('0x26')](channels[_0x21b5ff['uniqueid']])){utils[_0x46ff('0x1a')](util[_0x46ff('0xb')]('[%s][calls][newexten]',_0x21b5ff[_0x46ff('0x9')]),_0x21b5ff);utils[_0x46ff('0xa')](util['format'](_0x46ff('0x5f'),_0x21b5ff['uniqueid'],_0x21b5ff['application'],_0x21b5ff[_0x46ff('0x60')]));if(_0x21b5ff[_0x46ff('0x61')]['toLowerCase']()==_0x46ff('0x62')&&_['startsWith'](_0x21b5ff[_0x46ff('0x60')][_0x46ff('0x63')](),_0x46ff('0x64'))){var _0x3ef221=_0x21b5ff['appdata']['split']('=');var _0x383b41=_0x3ef221[0x0][_0x46ff('0x65')](_0x3ef221[0x0]['lastIndexOf']('(')+0x1,_0x3ef221[0x0]['lastIndexOf'](')'));var _0x38667a=_0x3ef221[0x1];channels[_0x21b5ff[_0x46ff('0x9')]][_0x383b41]=_0x38667a;}if(!_[_0x46ff('0x66')]([_0x46ff('0x67'),_0x46ff('0x68'),_0x46ff('0x69'),_0x46ff('0x62'),_0x46ff('0x6a')],_0x21b5ff[_0x46ff('0x61')][_0x46ff('0x63')]())){channels[_0x21b5ff['uniqueid']][_0x46ff('0x54')]=_0x21b5ff[_0x46ff('0x61')];channels[_0x21b5ff[_0x46ff('0x9')]][_0x46ff('0x55')]=_0x21b5ff['appdata'];}}}catch(_0x5d8f29){utils['error'](util[_0x46ff('0xb')](_0x46ff('0x6b'),_0x21b5ff[_0x46ff('0x9')]),_0x5d8f29);}}; \ No newline at end of file diff --git a/server/services/xdr/core.controller.js b/server/services/xdr/core.controller.js new file mode 100644 index 0000000..1f67ba0 --- /dev/null +++ b/server/services/xdr/core.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x0c75=['[core]\x20shutdown','fullybooted','[core]\x20fullybooted','[core]\x20error','[core]\x20close','managerevent','connect','[core]\x20connected','shutdown','info'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x0c75,0x6a));var _0x50c7=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x0c75[_0x122ef9];return _0x42fba0;};'use strict';var utils=require('./utils');exports[_0x50c7('0x0')]=function(){utils['info'](_0x50c7('0x1'));};exports[_0x50c7('0x2')]=function(){utils[_0x50c7('0x3')](_0x50c7('0x4'));};exports[_0x50c7('0x5')]=function(){utils[_0x50c7('0x3')](_0x50c7('0x6'));};exports['error']=function(_0x4b982e){utils['error'](_0x50c7('0x7'),_0x4b982e);};exports['close']=function(){utils[_0x50c7('0x3')](_0x50c7('0x8'));};exports[_0x50c7('0x9')]=function(_0x53ef83){}; \ No newline at end of file diff --git a/server/services/xdr/dials.controller.js b/server/services/xdr/dials.controller.js new file mode 100644 index 0000000..c222ab9 --- /dev/null +++ b/server/services/xdr/dials.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xb733=['startsWith','toLowerCase','cdr(routeid)','split','error','[%s][dials][newexten]','[%s][dials][varset]','isNil','variable','[%s][dials][varset]\x20variable:outboundrouteid\x20value:%s','value','[%s][dials][dialbegin]','assign','starttime','now','called','[%s][dials][hangup]\x20starttime:%s\x20lastevent:called','dialend','[%s][dials][dialend]','ANSWER','answertime','lastevent','connect','hangup','[%s][dials][hangup]','calleridname','complete','duration','endtime','holdtime','diffTime','billableseconds','lodash','util','info','[%s][dials][writeDB]\x20channel:%s\x20dialstring:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20dialstatus:%s','uniqueid','calleridnum','dialstatus','CreateVoiceDialReport','debug','format','[%s][dials][newexten]\x20application:%s\x20appdata:%s','application','appdata'];(function(_0x4fc9e6,_0xc51915){var _0x551d28=function(_0x1a603b){while(--_0x1a603b){_0x4fc9e6['push'](_0x4fc9e6['shift']());}};_0x551d28(++_0xc51915);}(_0xb733,0x7a));var _0x3b73=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0xb733[_0x397e5f];return _0x5302b8;};'use strict';var _=require(_0x3b73('0x0'));var util=require(_0x3b73('0x1'));var utils=require('./utils');var dials={};function writeDB(_0x494cea){utils[_0x3b73('0x2')](util['format'](_0x3b73('0x3'),_0x494cea[_0x3b73('0x4')],_0x494cea['channel'],_0x494cea['dialstring'],_0x494cea[_0x3b73('0x5')],_0x494cea['connectedlinenum'],_0x494cea[_0x3b73('0x6')]));utils['request'](_0x3b73('0x7'),_0x494cea);delete dials[_0x494cea['uniqueid']];}exports['newexten']=function(_0x4ad3ae){try{utils[_0x3b73('0x8')](util['format']('[%s][dials][newexten]',_0x4ad3ae[_0x3b73('0x4')]),_0x4ad3ae);utils['info'](util[_0x3b73('0x9')](_0x3b73('0xa'),_0x4ad3ae[_0x3b73('0x4')],_0x4ad3ae[_0x3b73('0xb')],_0x4ad3ae[_0x3b73('0xc')]));if(_0x4ad3ae[_0x3b73('0xb')]['toLowerCase']()=='set'&&_[_0x3b73('0xd')](_0x4ad3ae[_0x3b73('0xc')][_0x3b73('0xe')](),_0x3b73('0xf'))){var _0x3bdf0a=_0x4ad3ae[_0x3b73('0xc')][_0x3b73('0x10')]('=');dials[_0x4ad3ae[_0x3b73('0x4')]]={'routeId':_0x3bdf0a[0x1]};}}catch(_0x37b46e){utils[_0x3b73('0x11')](util[_0x3b73('0x9')](_0x3b73('0x12'),_0x4ad3ae[_0x3b73('0x4')]),_0x37b46e);}};exports['varset']=function(_0xe59492){try{utils[_0x3b73('0x8')](util[_0x3b73('0x9')](_0x3b73('0x13'),_0xe59492[_0x3b73('0x4')]),_0xe59492);if(!_[_0x3b73('0x14')](_0xe59492[_0x3b73('0x15')]['outboundrouteid'])){utils['info'](util[_0x3b73('0x9')](_0x3b73('0x16'),_0xe59492[_0x3b73('0x4')],_0xe59492[_0x3b73('0x17')]));dials[_0xe59492['uniqueid']]={'routeId':_0xe59492[_0x3b73('0x17')]};}}catch(_0x3c087a){utils[_0x3b73('0x11')](util[_0x3b73('0x9')](_0x3b73('0x13'),_0xe59492[_0x3b73('0x4')]),_0x3c087a);}};exports['dialbegin']=function(_0x171bfe){try{if(!_[_0x3b73('0x14')](dials[_0x171bfe[_0x3b73('0x4')]])){utils[_0x3b73('0x8')](util[_0x3b73('0x9')](_0x3b73('0x18'),_0x171bfe['uniqueid']),_0x171bfe);dials[_0x171bfe['uniqueid']]=_[_0x3b73('0x19')](dials[_0x171bfe[_0x3b73('0x4')]],_0x171bfe);dials[_0x171bfe[_0x3b73('0x4')]][_0x3b73('0x1a')]=utils[_0x3b73('0x1b')]();dials[_0x171bfe[_0x3b73('0x4')]]['lastevent']=_0x3b73('0x1c');utils['info'](util['format'](_0x3b73('0x1d'),_0x171bfe[_0x3b73('0x4')],dials[_0x171bfe[_0x3b73('0x4')]][_0x3b73('0x1a')]));}}catch(_0x46b273){utils['error'](util[_0x3b73('0x9')](_0x3b73('0x18'),_0x171bfe[_0x3b73('0x4')]),_0x46b273);}};exports[_0x3b73('0x1e')]=function(_0x3bae1d){try{if(!_[_0x3b73('0x14')](dials[_0x3bae1d[_0x3b73('0x4')]])){utils[_0x3b73('0x8')](util[_0x3b73('0x9')](_0x3b73('0x1f'),_0x3bae1d[_0x3b73('0x4')]),_0x3bae1d);dials[_0x3bae1d[_0x3b73('0x4')]]['dialstatus']=_0x3bae1d['dialstatus'];if(_0x3bae1d[_0x3b73('0x6')]==_0x3b73('0x20')){dials[_0x3bae1d['uniqueid']]=_[_0x3b73('0x19')](dials[_0x3bae1d[_0x3b73('0x4')]],_0x3bae1d);dials[_0x3bae1d[_0x3b73('0x4')]][_0x3b73('0x21')]=utils[_0x3b73('0x1b')]();dials[_0x3bae1d[_0x3b73('0x4')]][_0x3b73('0x22')]=_0x3b73('0x23');utils[_0x3b73('0x2')](util[_0x3b73('0x9')]('[%s][dials][dialend]\x20dialstatus:%s\x20answertime:%s\x20lastevent:connect',_0x3bae1d[_0x3b73('0x4')],_0x3bae1d[_0x3b73('0x6')],dials[_0x3bae1d[_0x3b73('0x4')]][_0x3b73('0x21')]));}else{utils[_0x3b73('0x2')](util[_0x3b73('0x9')]('[%s][dials][dialend]\x20dialstatus:%s',_0x3bae1d[_0x3b73('0x4')],_0x3bae1d['dialstatus']));}}}catch(_0x1c5a6a){utils['error'](util[_0x3b73('0x9')](_0x3b73('0x1f'),_0x3bae1d[_0x3b73('0x4')]),_0x1c5a6a);}};exports[_0x3b73('0x24')]=function(_0x57854b){try{if(!_[_0x3b73('0x14')](dials[_0x57854b[_0x3b73('0x4')]])){utils[_0x3b73('0x8')](util['format'](_0x3b73('0x25'),_0x57854b[_0x3b73('0x4')]),_0x57854b);utils[_0x3b73('0x2')](util[_0x3b73('0x9')]('[%s][dials][hangup]\x20calleridnum:%s\x20calleridname:%s\x20lastevent:complete\x20reason:%s',_0x57854b[_0x3b73('0x4')],_0x57854b[_0x3b73('0x5')],_0x57854b[_0x3b73('0x26')],_0x57854b['cause-txt']));dials[_0x57854b[_0x3b73('0x4')]]=_[_0x3b73('0x19')](dials[_0x57854b[_0x3b73('0x4')]],{'endtime':utils[_0x3b73('0x1b')](),'lastevent':_0x3b73('0x27')});dials[_0x57854b['uniqueid']][_0x3b73('0x28')]=utils['diffTime'](dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x29')],dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x1a')]);dials[_0x57854b['uniqueid']][_0x3b73('0x2a')]=utils[_0x3b73('0x2b')](dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x21')]||dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x29')],dials[_0x57854b['uniqueid']][_0x3b73('0x1a')]);dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x2c')]=dials[_0x57854b[_0x3b73('0x4')]][_0x3b73('0x21')]?utils['diffTime'](dials[_0x57854b['uniqueid']]['endtime'],dials[_0x57854b[_0x3b73('0x4')]]['answertime']):0x0;writeDB(dials[_0x57854b['uniqueid']]);}}catch(_0x57a554){utils[_0x3b73('0x11')](util[_0x3b73('0x9')](_0x3b73('0x25'),_0x57854b[_0x3b73('0x4')]),_0x57a554);}}; \ No newline at end of file diff --git a/server/services/xdr/index.js b/server/services/xdr/index.js new file mode 100644 index 0000000..b2d0702 --- /dev/null +++ b/server/services/xdr/index.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x5e98=['[%s][index][agentcomplete]','agentcomplete','queuecallerabandon','[%s][index][queuecallerabandon]','queuecallerjoin','[%s][index][queuecallerjoin]','[%s][index][queuecallerleave]','queuecallerleave','musiconholdstart','[%s][index][musiconholdstart]','musiconholdstop','[%s][index][musiconholdstop]','[%s][index][newstate]','newstate','[%s][index][hangup]','hangup','cdr','[%s][index][cdr]','blindtransfer','[%s][index][blindtransfer]','attendedtransfer','[%s][index][attendedtransfer]','origtransfereruniqueid','varset','[%s][index][varset]','newexten','[%s][index][newexten]','[%s][index][newchannel]','newchannel','dialbegin','[%s][index][dialbegin]','[%s]dialbegin','dialend','[%s][index][dialend]','./utils','util','xdr','disabled','env','production','local','asterisk','port','username','info','XDR\x20DISABLED','Asterisk\x20disabled\x20on\x20localhost','./agents.controller','./calls.controller','./queues.controller','./recordings.controller','./members.controller','./dials.controller','./transfers.controller','./core.controller','connect','shutdown','error','close','managerevent','format','[%s][index][devicestatechange]','device','agentcalled','debug','[%s][index][agentcalled]','uniqueid','agentringnoanswer','[%s][index][agentringnoanswer]','agentconnect','[%s][index][agentconnect]'];(function(_0x32bce8,_0x54f965){var _0x38badc=function(_0x1ed1ee){while(--_0x1ed1ee){_0x32bce8['push'](_0x32bce8['shift']());}};_0x38badc(++_0x54f965);}(_0x5e98,0x185));var _0x85e9=function(_0x44436e,_0x44d29c){_0x44436e=_0x44436e-0x0;var _0x2488e9=_0x5e98[_0x44436e];return _0x2488e9;};var AsteriskManager=require('asterisk-manager');var config=require('../../config/environment');var utils=require(_0x85e9('0x0'));var util=require(_0x85e9('0x1'));var isXDREnabled=config[_0x85e9('0x2')]&&config[_0x85e9('0x2')]['disabled']?!config[_0x85e9('0x2')][_0x85e9('0x3')]:!![];var isProduction=config[_0x85e9('0x4')]===_0x85e9('0x5')||![];var isLocalAsterisk=config[_0x85e9('0x2')]&&config[_0x85e9('0x2')][_0x85e9('0x6')]===!![]||![];var ami=new AsteriskManager(config[_0x85e9('0x7')][_0x85e9('0x8')],config[_0x85e9('0x7')]['ip'],config[_0x85e9('0x7')][_0x85e9('0x9')],config[_0x85e9('0x7')]['password'],!![]);ami['keepConnected']();if(!isXDREnabled){utils[_0x85e9('0xa')](_0x85e9('0xb'));}else if(!isProduction&&!isLocalAsterisk){utils[_0x85e9('0xa')](_0x85e9('0xc'));}else{var agents=require(_0x85e9('0xd'));var calls=require(_0x85e9('0xe'));var queues=require(_0x85e9('0xf'));var recordings=require(_0x85e9('0x10'));var members=require(_0x85e9('0x11'));var dials=require(_0x85e9('0x12'));var transfers=require(_0x85e9('0x13'));var core=require(_0x85e9('0x14'));ami['on'](_0x85e9('0x15'),core[_0x85e9('0x15')]);ami['on'](_0x85e9('0x16'),core[_0x85e9('0x16')]);ami['on']('fullybooted',core['fullybooted']);ami['on'](_0x85e9('0x17'),core[_0x85e9('0x17')]);ami['on'](_0x85e9('0x18'),core[_0x85e9('0x18')]);ami['on'](_0x85e9('0x19'),core['managerevent']);ami['on']('devicestatechange',function(_0x406eca){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x1b'),_0x406eca[_0x85e9('0x1c')]),_0x406eca);members['devicestatechange'](_0x406eca);}catch(_0x3b74dd){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x1b'),_0x406eca[_0x85e9('0x1c')]),_0x3b74dd);}});ami['on'](_0x85e9('0x1d'),function(_0x24fc3f){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x1f'),_0x24fc3f[_0x85e9('0x20')]),_0x24fc3f);agents[_0x85e9('0x1d')](_0x24fc3f);}catch(_0x31a2de){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')]('[%s][index][agentcalled]',_0x24fc3f['uniqueid']),_0x31a2de);}});ami['on'](_0x85e9('0x21'),function(_0x25d554){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x22'),_0x25d554['uniqueid']),_0x25d554);agents[_0x85e9('0x21')](_0x25d554);}catch(_0x2b8f92){utils[_0x85e9('0x17')](util['format'](_0x85e9('0x22'),_0x25d554[_0x85e9('0x20')]),_0x2b8f92);}});ami['on'](_0x85e9('0x23'),function(_0x57243e){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x24'),_0x57243e['uniqueid']),_0x57243e);agents['agentconnect'](_0x57243e);queues['agentconnect'](_0x57243e);}catch(_0x353256){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x24'),_0x57243e[_0x85e9('0x20')]),_0x353256);}});ami['on']('agentcomplete',function(_0x45ca6a){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x25'),_0x45ca6a[_0x85e9('0x20')]),_0x45ca6a);agents[_0x85e9('0x26')](_0x45ca6a);queues['agentcomplete'](_0x45ca6a);members['agentcomplete'](_0x45ca6a);}catch(_0x75c31d){utils['error'](util[_0x85e9('0x1a')]('[%s][index][agentcomplete]',_0x45ca6a[_0x85e9('0x20')]),_0x75c31d);}});ami['on'](_0x85e9('0x27'),function(_0x542ae1){try{utils[_0x85e9('0x1e')](util['format'](_0x85e9('0x28'),_0x542ae1['uniqueid']),_0x542ae1);agents[_0x85e9('0x27')](_0x542ae1);queues[_0x85e9('0x27')](_0x542ae1);}catch(_0x95a185){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x28'),_0x542ae1[_0x85e9('0x20')]),_0x95a185);}});ami['on'](_0x85e9('0x29'),function(_0x4aa2aa){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x2a'),_0x4aa2aa[_0x85e9('0x20')]),_0x4aa2aa);queues[_0x85e9('0x29')](_0x4aa2aa);recordings[_0x85e9('0x29')](_0x4aa2aa);}catch(_0x534f08){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x2a'),_0x4aa2aa[_0x85e9('0x20')]),_0x534f08);}});ami['on']('queuecallerleave',function(_0x3b467d){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x2b'),_0x3b467d[_0x85e9('0x20')]),_0x3b467d);queues[_0x85e9('0x2c')](_0x3b467d);}catch(_0x4549a6){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x2b'),_0x3b467d[_0x85e9('0x20')]),_0x4549a6);}});ami['on'](_0x85e9('0x2d'),function(_0x50ea29){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x2e'),_0x50ea29[_0x85e9('0x20')]),_0x50ea29);queues[_0x85e9('0x2d')](_0x50ea29);calls[_0x85e9('0x2d')](_0x50ea29);}catch(_0x56bcdf){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x2e'),_0x50ea29[_0x85e9('0x20')]),_0x56bcdf);}});ami['on'](_0x85e9('0x2f'),function(_0x5c93b4){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x30'),_0x5c93b4[_0x85e9('0x20')]),_0x5c93b4);queues[_0x85e9('0x2f')](_0x5c93b4);calls[_0x85e9('0x2f')](_0x5c93b4);}catch(_0x153fa8){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x30'),_0x5c93b4[_0x85e9('0x20')]),_0x153fa8);}});ami['on']('newstate',function(_0x377352){try{utils['debug'](util[_0x85e9('0x1a')](_0x85e9('0x31'),_0x377352['uniqueid']),_0x377352);calls[_0x85e9('0x32')](_0x377352);recordings[_0x85e9('0x32')](_0x377352);}catch(_0x577e43){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')]('[%s][index][newstate]',_0x377352['uniqueid']),_0x577e43);}});ami['on']('hangup',function(_0x12c00f){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x33'),_0x12c00f['uniqueid']),_0x12c00f);calls[_0x85e9('0x34')](_0x12c00f);recordings[_0x85e9('0x34')](_0x12c00f);dials[_0x85e9('0x34')](_0x12c00f);agents[_0x85e9('0x34')](_0x12c00f);queues[_0x85e9('0x34')](_0x12c00f);}catch(_0x4200f4){utils['error'](util[_0x85e9('0x1a')](_0x85e9('0x33'),_0x12c00f[_0x85e9('0x20')]),_0x4200f4);}});ami['on'](_0x85e9('0x35'),function(_0xda5c34){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x36'),_0xda5c34[_0x85e9('0x20')]),_0xda5c34);members[_0x85e9('0x35')](_0xda5c34);}catch(_0xc0de89){utils[_0x85e9('0x17')](util['format'](_0x85e9('0x36'),_0xda5c34[_0x85e9('0x20')]),_0xc0de89);}});ami['on'](_0x85e9('0x37'),function(_0x8ce7c9){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')]('[%s][index][blindtransfer]',_0x8ce7c9['uniqueid']),_0x8ce7c9);queues[_0x85e9('0x37')](_0x8ce7c9);agents[_0x85e9('0x37')](_0x8ce7c9);transfers['blindtransfer'](_0x8ce7c9);recordings[_0x85e9('0x37')](_0x8ce7c9);}catch(_0x3bfb54){utils['error'](util[_0x85e9('0x1a')](_0x85e9('0x38'),_0x8ce7c9[_0x85e9('0x20')]),_0x3bfb54);}});ami['on'](_0x85e9('0x39'),function(_0x43b810){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x3a'),_0x43b810[_0x85e9('0x3b')]),_0x43b810);queues['attendedtransfer'](_0x43b810);transfers['attendedtransfer'](_0x43b810);agents['attendedtransfer'](_0x43b810);calls[_0x85e9('0x39')](_0x43b810);}catch(_0x38c055){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')]('[%s][index][attendedtransfer]',_0x43b810['origtransfereruniqueid']),_0x38c055);}});ami['on'](_0x85e9('0x3c'),function(_0x31060a){try{utils[_0x85e9('0x1e')](util['format']('[%s][index][varset]',_0x31060a[_0x85e9('0x20')]),_0x31060a);queues[_0x85e9('0x3c')](_0x31060a);recordings['varset'](_0x31060a);calls[_0x85e9('0x3c')](_0x31060a);dials[_0x85e9('0x3c')](_0x31060a);}catch(_0x1c71af){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x3d'),_0x31060a[_0x85e9('0x20')]),_0x1c71af);}});ami['on'](_0x85e9('0x3e'),function(_0x5ea71c){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x3f'),_0x5ea71c[_0x85e9('0x20')]),_0x5ea71c);calls['newexten'](_0x5ea71c);recordings[_0x85e9('0x3e')](_0x5ea71c);dials[_0x85e9('0x3e')](_0x5ea71c);}catch(_0x314d18){utils['error'](util[_0x85e9('0x1a')](_0x85e9('0x3f'),_0x5ea71c[_0x85e9('0x20')]),_0x314d18);}});ami['on']('newchannel',function(_0x2398ae){try{utils[_0x85e9('0x1e')](util['format'](_0x85e9('0x40'),_0x2398ae[_0x85e9('0x20')]),_0x2398ae);calls[_0x85e9('0x41')](_0x2398ae);recordings[_0x85e9('0x41')](_0x2398ae);}catch(_0x44e2ab){utils['error'](util['format'](_0x85e9('0x40'),_0x2398ae['uniqueid']),_0x44e2ab);}});ami['on'](_0x85e9('0x42'),function(_0x5590bd){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x43'),_0x5590bd[_0x85e9('0x20')]),_0x5590bd);dials[_0x85e9('0x42')](_0x5590bd);}catch(_0x72cc0){utils[_0x85e9('0x17')](util['format'](_0x85e9('0x44'),_0x5590bd[_0x85e9('0x20')]),_0x72cc0);}});ami['on'](_0x85e9('0x45'),function(_0x141715){try{utils[_0x85e9('0x1e')](util[_0x85e9('0x1a')](_0x85e9('0x46'),_0x141715['uniqueid']),_0x141715);dials[_0x85e9('0x45')](_0x141715);}catch(_0x494b51){utils[_0x85e9('0x17')](util[_0x85e9('0x1a')](_0x85e9('0x46'),_0x141715[_0x85e9('0x20')]),_0x494b51);}});} \ No newline at end of file diff --git a/server/services/xdr/members.controller.js b/server/services/xdr/members.controller.js new file mode 100644 index 0000000..a04b850 --- /dev/null +++ b/server/services/xdr/members.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xc9b7=['then','name','internal','request','CreateMemberReport','split','catch','error','[%s][members][writeDB]','some','startsWith','format','[%s][members][devicestatechange]','device','[%s][members][devicestatechange]\x20state:%s\x20interface:%s','state','INUSE','BUSY','voice','TALKING','now','agent','NOT_INUSE','isNil','exitAt','duration','diffTime','enterAt','agentcomplete','debug','[%s][members][agentcomplete]','[%s][members][agentcomplete]\x20interface:%s\x20queue:%s','queue','cdr','assign','source','data3','destination','data1','destinationchannel','[%s][members][cdr]\x20type:%s\x20source:%s\x20destination:%s','[%s][members][cdr]','lodash','util','./utils','Local/_attended@transfer','info','[%s][members][writeDB]\x20interface:%s\x20channel:%s\x20data2:%s\x20agent:%s\x20type:%s','uniqueid','interface','channel','data2','membername','type','getUserByInterface'];(function(_0x32ac72,_0x41f8a5){var _0x4f6ef2=function(_0x3d4361){while(--_0x3d4361){_0x32ac72['push'](_0x32ac72['shift']());}};_0x4f6ef2(++_0x41f8a5);}(_0xc9b7,0x1ab));var _0x7c9b=function(_0x1b0899,_0x179c99){_0x1b0899=_0x1b0899-0x0;var _0x30273f=_0xc9b7[_0x1b0899];return _0x30273f;};'use strict';var _=require(_0x7c9b('0x0'));var util=require(_0x7c9b('0x1'));var utils=require(_0x7c9b('0x2'));var members={};var exclude=[_0x7c9b('0x3'),'Queue:'];function writeDB(_0x46f817){utils[_0x7c9b('0x4')](util['format'](_0x7c9b('0x5'),_0x46f817[_0x7c9b('0x6')],_0x46f817[_0x7c9b('0x7')],_0x46f817[_0x7c9b('0x8')],_0x46f817[_0x7c9b('0x9')],_0x46f817[_0x7c9b('0xa')],_0x46f817[_0x7c9b('0xb')]));if(_0x46f817[_0x7c9b('0x7')]){utils[_0x7c9b('0xc')](_0x46f817[_0x7c9b('0x7')])[_0x7c9b('0xd')](function(_0x3d2f35){if(_0x3d2f35){_0x46f817[_0x7c9b('0xa')]=_0x3d2f35[_0x7c9b('0xe')];_0x46f817[_0x7c9b('0xf')]=_0x3d2f35[_0x7c9b('0xf')];utils[_0x7c9b('0x10')](_0x7c9b('0x11'),_0x46f817);}else{utils['getUserByName'](_0x46f817[_0x7c9b('0x7')][_0x7c9b('0x12')]('/')[0x1])[_0x7c9b('0xd')](function(_0x4cba7a){if(_0x4cba7a){_0x46f817[_0x7c9b('0xa')]=_0x4cba7a['name'];_0x46f817[_0x7c9b('0xf')]=_0x4cba7a[_0x7c9b('0xf')];utils['request'](_0x7c9b('0x11'),_0x46f817);}});}})[_0x7c9b('0x13')](function(_0x271052){utils[_0x7c9b('0x14')](util['format'](_0x7c9b('0x15'),_0x46f817[_0x7c9b('0x6')]),_0x271052);});}delete members[_0x46f817['interface']];}function startsWith(_0x2f1ecb,_0x482e81){return _[_0x7c9b('0x16')](_0x2f1ecb,function(_0x2f1967){return _[_0x7c9b('0x17')](_0x482e81,_0x2f1967);});}exports['devicestatechange']=function(_0x4bab89){try{utils['debug'](util[_0x7c9b('0x18')](_0x7c9b('0x19'),members[_0x4bab89[_0x7c9b('0x1a')]]?members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x6')]:_0x4bab89[_0x7c9b('0x1a')]),_0x4bab89);utils['info'](util[_0x7c9b('0x18')](_0x7c9b('0x1b'),members[_0x4bab89[_0x7c9b('0x1a')]]?members[_0x4bab89['device']][_0x7c9b('0x6')]:_0x4bab89[_0x7c9b('0x1a')],_0x4bab89[_0x7c9b('0x1c')],_0x4bab89[_0x7c9b('0x1a')]));switch(_0x4bab89['state']){case _0x7c9b('0x1d'):case _0x7c9b('0x1e'):if(!startsWith(exclude,_0x4bab89[_0x7c9b('0x1a')])){members[_0x4bab89['device']]={'channel':_0x7c9b('0x1f'),'interface':_0x4bab89['device'],'type':_0x7c9b('0x20'),'enterAt':utils[_0x7c9b('0x21')](),'role':_0x7c9b('0x22')};}break;case _0x7c9b('0x23'):if(!_[_0x7c9b('0x24')](members[_0x4bab89['device']])){members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x25')]=utils[_0x7c9b('0x21')]();members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x26')]=utils[_0x7c9b('0x27')](members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x25')],members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x28')]);if(members[_0x4bab89['device']]['uniqueid']){writeDB(members[_0x4bab89[_0x7c9b('0x1a')]]);}}break;default:break;}}catch(_0x4a1392){utils['error'](util[_0x7c9b('0x18')]('[%s][members][devicestatechange]',members[_0x4bab89[_0x7c9b('0x1a')]]?members[_0x4bab89[_0x7c9b('0x1a')]][_0x7c9b('0x6')]:_0x4bab89[_0x7c9b('0x1a')]),_0x4a1392);}};exports[_0x7c9b('0x29')]=function(_0x2cbe6f){try{if(!_[_0x7c9b('0x24')](members[_0x2cbe6f[_0x7c9b('0x7')]])){utils[_0x7c9b('0x2a')](util['format'](_0x7c9b('0x2b'),_0x2cbe6f[_0x7c9b('0x6')]),_0x2cbe6f);utils[_0x7c9b('0x4')](util[_0x7c9b('0x18')](_0x7c9b('0x2c'),_0x2cbe6f[_0x7c9b('0x6')],_0x2cbe6f[_0x7c9b('0x7')],_0x2cbe6f[_0x7c9b('0x2d')]));members[_0x2cbe6f['interface']]=_['assign'](members[_0x2cbe6f[_0x7c9b('0x7')]],{'data4':_0x2cbe6f[_0x7c9b('0x2d')],'uniqueid':_0x2cbe6f[_0x7c9b('0x6')]});}}catch(_0xfc4456){utils[_0x7c9b('0x14')](util[_0x7c9b('0x18')](_0x7c9b('0x2b'),_0x2cbe6f[_0x7c9b('0x6')]),_0xfc4456);}};exports[_0x7c9b('0x2e')]=function(_0x608a13){try{utils[_0x7c9b('0x2a')](util[_0x7c9b('0x18')]('[%s][members][cdr]',_0x608a13[_0x7c9b('0x6')]),_0x608a13);if(_0x608a13[_0x7c9b('0x8')]){var _0x5ad5c2=_0x608a13[_0x7c9b('0x8')][_0x7c9b('0x12')]('-')[0x0];if(!_[_0x7c9b('0x24')](members[_0x5ad5c2])){members[_0x5ad5c2]=_[_0x7c9b('0x2f')](members[_0x5ad5c2],{'data1':members[_0x5ad5c2]['data1']||_0x608a13[_0x7c9b('0xb')],'data2':members[_0x5ad5c2][_0x7c9b('0x9')]||_0x608a13[_0x7c9b('0x30')],'data3':members[_0x5ad5c2][_0x7c9b('0x31')]||_0x608a13[_0x7c9b('0x32')],'uniqueid':members[_0x5ad5c2][_0x7c9b('0x6')]||_0x608a13[_0x7c9b('0x6')]});utils['info'](util[_0x7c9b('0x18')]('[%s][members][cdr]\x20type:%s\x20source:%s\x20destination:%s',_0x608a13['uniqueid'],members[_0x5ad5c2][_0x7c9b('0x33')],members[_0x5ad5c2][_0x7c9b('0x9')],members[_0x5ad5c2][_0x7c9b('0x31')]));if(members[_0x5ad5c2][_0x7c9b('0x25')]){writeDB(members[_0x5ad5c2]);}}}if(_0x608a13[_0x7c9b('0x34')]){var _0x3f1318=_0x608a13[_0x7c9b('0x34')][_0x7c9b('0x12')]('-')[0x0];if(!_['isNil'](members[_0x3f1318])){members[_0x3f1318]=_['assign'](members[_0x3f1318],{'data1':members[_0x3f1318][_0x7c9b('0x33')]||_0x608a13[_0x7c9b('0xb')],'data2':members[_0x3f1318][_0x7c9b('0x9')]||_0x608a13[_0x7c9b('0x30')],'data3':members[_0x3f1318][_0x7c9b('0x31')]||_0x608a13[_0x7c9b('0x32')],'uniqueid':members[_0x3f1318][_0x7c9b('0x6')]||_0x608a13[_0x7c9b('0x6')]});utils[_0x7c9b('0x4')](util[_0x7c9b('0x18')](_0x7c9b('0x35'),_0x608a13[_0x7c9b('0x6')],members[_0x3f1318]['data1'],members[_0x3f1318][_0x7c9b('0x9')],members[_0x3f1318][_0x7c9b('0x31')]));if(members[_0x3f1318][_0x7c9b('0x25')]){writeDB(members[_0x3f1318]);}}}}catch(_0x5b30de){utils['error'](util[_0x7c9b('0x18')](_0x7c9b('0x36'),_0x608a13[_0x7c9b('0x6')]),_0x5b30de);}}; \ No newline at end of file diff --git a/server/services/xdr/queues.controller.js b/server/services/xdr/queues.controller.js new file mode 100644 index 0000000..65c0360 --- /dev/null +++ b/server/services/xdr/queues.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x3458=['[%s][queues][varset]\x20name:%s\x20variable:queuestatus\x20value:%s\x20queuecallerexitreason:%s','queueposition','queuecallerabandon','[%s][queues][queuecallerabandon]','ABANDONED','[%s][queues][queuecallerabandon]\x20name:%s\x20queuecallerexitreason:%s','[%s][queues][queuecallerleave]','[%s][queues][queuecallerleave]\x20name:%s\x20connectedlinenum:%s\x20connectedlinename:%s','connectedlinenum','queuecallerleave','holdtime','diffTime','queuecallerjoinAt','count','[%s][queues][agentconnect]','membername','destaccountcode','assigned','agentcomplete','[%s][queues][agentcomplete]','queuecallercompleteAt','reason','TRANSFER','COMPLETEDBY','[%s][queues][agentcomplete]\x20name:%s\x20agent:%s\x20queuecallerexitreason:%s','blindtransfer','transfereeuniqueid','transfer','BLIND','transferexten','extension','BLINDTRANSFER','[%s][queues][blindtransfer]','attendedtransfer','[%s][queues][attendedtransfer]','origtransfererlinkedid','secondtransfererlinkedid','[%s][queues][attendedtransfer]\x20name:%s\x20transferexten:%s\x20queuecallerexitreason:ATTENDEDTRANSFER','origtransfererexten','transfertype','ATTENDED','transferuniqueid','origtransfereruniqueid','ATTENDEDTRANSFER','transfereelinkedid','transfertargetuniqueid','calleridname','mohtime','[%s][queues][attendedtransfer]\x20name:%s\x20calleridnum:%s\x20calleridname:%s','secondtransfereruniqueid','[%s][queues][attendedtransfer]\x20name:%s\x20transferuniqueid:%s\x20transferexten:%s\x20queuecallerexitreason:ATTENDEDTRANSFER','transfertargetlinkedid','clone','[%s][queues][attendedtransfer]\x20name:%s\x20transfereduniqueid:%s\x20calleridnum:%s\x20calleridname:%s','musiconholdstart','[%s][queues][musiconholdstart]','musiconholdstartAt','[%s][queues][musiconholdstop]\x20name:%s\x20musiconholdstartAt:%s','musiconholdstop','[%s][queues][musiconholdstop]','[%s][queues][musiconholdstop]\x20name:%s\x20mohtime:%s','lodash','./utils','info','format','[%s][queues][writeDB]\x20channel:%s\x20queue:%s\x20lastAssignedTo:%s\x20calleridnum:%s\x20accountcode:%s\x20queuecallerexitreason:%s','uniqueid','channel','queue','lastAssignedTo','calleridnum','accountcode','queuecallerexitreason','getVoiceQueueByName','then','type','request','CreateVoiceQueueReport','transfereduniqueid','queuecallerjoin','debug','[%s][queues][queuecallerjoin]','[%s][queues][queuecallerjoin]\x20name:%s\x20position:%s','position','assign','now','error','hangup','isNil','queuecallerleaveAt','queuecallerexit','COMPLETEDBYAGENT','name','[%s][queues][hangup]\x20name:%s\x20transfereduniqueid:%s','queuecallerenterreason','[%s][queues][hangup]','varset','variable','queuestatus','value','toUpperCase','queuecallerabandonAt','queuecallerexitAt'];(function(_0x145d21,_0x24e058){var _0x197c9f=function(_0x10d3f7){while(--_0x10d3f7){_0x145d21['push'](_0x145d21['shift']());}};_0x197c9f(++_0x24e058);}(_0x3458,0x10b));var _0x8345=function(_0x5dd8a6,_0x271d66){_0x5dd8a6=_0x5dd8a6-0x0;var _0x2eb653=_0x3458[_0x5dd8a6];return _0x2eb653;};'use strict';var _=require(_0x8345('0x0'));var util=require('util');var utils=require(_0x8345('0x1'));var queues={};function writeDB(_0x4a6ca5){utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x4'),_0x4a6ca5[_0x8345('0x5')],_0x4a6ca5[_0x8345('0x6')],_0x4a6ca5[_0x8345('0x7')],_0x4a6ca5[_0x8345('0x8')],_0x4a6ca5[_0x8345('0x9')],_0x4a6ca5[_0x8345('0xa')],_0x4a6ca5[_0x8345('0xb')]));if(_0x4a6ca5['queue']){utils[_0x8345('0xc')](_0x4a6ca5[_0x8345('0x7')])[_0x8345('0xd')](function(_0x2b5792){if(_0x2b5792){_0x4a6ca5[_0x8345('0xe')]=_0x2b5792[_0x8345('0xe')];}utils[_0x8345('0xf')]('CreateVoiceQueueReport',_0x4a6ca5);});}else{utils[_0x8345('0xf')](_0x8345('0x10'),_0x4a6ca5);}if(_0x4a6ca5[_0x8345('0x11')]){delete queues[_0x4a6ca5[_0x8345('0x11')]];}else{delete queues[_0x4a6ca5[_0x8345('0x5')]];}}exports[_0x8345('0x12')]=function(_0x5635c1){try{utils[_0x8345('0x13')](util[_0x8345('0x3')](_0x8345('0x14'),_0x5635c1[_0x8345('0x5')]),_0x5635c1);utils[_0x8345('0x2')](util['format'](_0x8345('0x15'),_0x5635c1[_0x8345('0x5')],_0x5635c1[_0x8345('0x7')],_0x5635c1[_0x8345('0x16')]));queues[_0x5635c1['uniqueid']]=_[_0x8345('0x17')](_0x5635c1,{'originalposition':_0x5635c1[_0x8345('0x16')],'queuecallerjoinAt':utils[_0x8345('0x18')](),'mohtime':0x0});}catch(_0xdf179){utils[_0x8345('0x19')](util[_0x8345('0x3')](_0x8345('0x14'),_0x5635c1[_0x8345('0x5')]),_0xdf179);}};exports[_0x8345('0x1a')]=function(_0x41aae0){try{if(!_[_0x8345('0x1b')](queues[_0x41aae0[_0x8345('0x5')]])){utils[_0x8345('0x13')](util[_0x8345('0x3')]('[%s][queues][hangup]',_0x41aae0[_0x8345('0x5')]),_0x41aae0);if(queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x1c')]){if(!queues[_0x41aae0[_0x8345('0x5')]]['queuecallerabandon']&&!queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x1d')]){queues[_0x41aae0[_0x8345('0x5')]]['queuecallercomplete']=!![];queues[_0x41aae0[_0x8345('0x5')]]['queuecallercompleteAt']=utils[_0x8345('0x18')]();queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0xb')]=_0x8345('0x1e');}utils[_0x8345('0x2')](util[_0x8345('0x3')]('[%s][queues][hangup]\x20name:%s\x20queuecallerexitreason:%s',_0x41aae0[_0x8345('0x5')],queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x1f')],queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0xb')]));writeDB(queues[_0x41aae0['uniqueid']]);}else if(queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x11')]){utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x20'),_0x41aae0[_0x8345('0x5')],queues[_0x41aae0[_0x8345('0x5')]]['name'],queues[_0x41aae0['uniqueid']][_0x8345('0x11')]));queues[queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x11')]]=queues[_0x41aae0['uniqueid']];queues[queues[_0x41aae0[_0x8345('0x5')]][_0x8345('0x11')]][_0x8345('0x21')]=0x2;delete queues[_0x41aae0['uniqueid']];}}}catch(_0x429b4a){utils['error'](util[_0x8345('0x3')](_0x8345('0x22'),_0x41aae0[_0x8345('0x5')]),_0x429b4a);}};exports[_0x8345('0x23')]=function(_0x5d262c){try{utils[_0x8345('0x13')](util[_0x8345('0x3')]('[%s][queues][varset]',_0x5d262c[_0x8345('0x5')]),_0x5d262c);if(!_[_0x8345('0x1b')](_0x5d262c[_0x8345('0x24')][_0x8345('0x25')])&&_0x5d262c[_0x8345('0x26')][_0x8345('0x27')]()!=='CONTINUE'){if(!_[_0x8345('0x1b')](queues[_0x5d262c[_0x8345('0x5')]])){queues[_0x5d262c[_0x8345('0x5')]]['queuecallerabandon']=![];queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0x28')]=null;queues[_0x5d262c['uniqueid']][_0x8345('0x1d')]=!![];queues[_0x5d262c['uniqueid']][_0x8345('0x29')]=utils['now']();queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0xb')]=_0x5d262c[_0x8345('0x26')]['toUpperCase']();utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x2a'),_0x5d262c[_0x8345('0x5')],queues[_0x5d262c[_0x8345('0x5')]]['name'],_0x5d262c[_0x8345('0x26')],queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0xb')]));writeDB(queues[_0x5d262c[_0x8345('0x5')]]);}}else if(!_[_0x8345('0x1b')](_0x5d262c[_0x8345('0x24')][_0x8345('0x2b')])){if(!_[_0x8345('0x1b')](queues[_0x5d262c[_0x8345('0x5')]])&&!queues[_0x5d262c['uniqueid']]['queuecallerabandon']){queues[_0x5d262c['uniqueid']]['queuecallerabandon']=![];queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0x28')]=null;queues[_0x5d262c[_0x8345('0x5')]]['queuecallerexit']=!![];queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0x29')]=utils[_0x8345('0x18')]();queues[_0x5d262c[_0x8345('0x5')]][_0x8345('0xb')]='EXITWITHKEY';utils[_0x8345('0x2')](util[_0x8345('0x3')]('[%s][queues][varset]\x20name:%s\x20variable:queueposition\x20value:%s\x20queuecallerexitreason:%s',_0x5d262c[_0x8345('0x5')],queues[_0x5d262c[_0x8345('0x5')]]['name'],_0x5d262c[_0x8345('0x26')],queues[_0x5d262c[_0x8345('0x5')]]['queuecallerexitreason']));}}}catch(_0x4df9dd){utils[_0x8345('0x19')](util[_0x8345('0x3')]('[%s][queues][varset]',_0x5d262c[_0x8345('0x5')]),_0x4df9dd);}};exports[_0x8345('0x2c')]=function(_0x2533b9){try{if(!_[_0x8345('0x1b')](queues[_0x2533b9[_0x8345('0x5')]])){utils['debug'](util['format'](_0x8345('0x2d'),_0x2533b9[_0x8345('0x5')]),_0x2533b9);queues[_0x2533b9['uniqueid']][_0x8345('0x1d')]=![];queues[_0x2533b9[_0x8345('0x5')]][_0x8345('0x29')]=null;queues[_0x2533b9[_0x8345('0x5')]][_0x8345('0x2c')]=!![];queues[_0x2533b9[_0x8345('0x5')]][_0x8345('0x28')]=utils['now']();queues[_0x2533b9['uniqueid']]['queuecallerexitreason']=_0x8345('0x2e');utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x2f'),_0x2533b9[_0x8345('0x5')],queues[_0x2533b9[_0x8345('0x5')]][_0x8345('0x1f')],queues[_0x2533b9['uniqueid']][_0x8345('0xb')]));}}catch(_0x4cd6cc){utils[_0x8345('0x19')](util[_0x8345('0x3')](_0x8345('0x2d'),_0x2533b9['uniqueid']),_0x4cd6cc);}};exports['queuecallerleave']=function(_0xd8606e){try{if(!_[_0x8345('0x1b')](queues[_0xd8606e[_0x8345('0x5')]])){utils[_0x8345('0x13')](util[_0x8345('0x3')](_0x8345('0x30'),_0xd8606e[_0x8345('0x5')]),_0xd8606e);utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x31'),_0xd8606e[_0x8345('0x5')],queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x1f')],_0xd8606e[_0x8345('0x32')],_0xd8606e['connectedlinename']));queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x33')]=!![];queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x1c')]=utils[_0x8345('0x18')]();queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x34')]=utils[_0x8345('0x35')](queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x1c')],queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x36')]);queues[_0xd8606e[_0x8345('0x5')]]['position']=_0xd8606e['position'];queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x37')]=_0xd8606e[_0x8345('0x37')];queues[_0xd8606e[_0x8345('0x5')]][_0x8345('0x32')]=_0xd8606e['connectedlinenum'];queues[_0xd8606e['uniqueid']]['connectedlinename']=_0xd8606e['connectedlinename'];}}catch(_0x45d3dc){utils[_0x8345('0x19')](util[_0x8345('0x3')]('[%s][queues][queuecallerleave]',_0xd8606e['uniqueid']),_0x45d3dc);}};exports['agentconnect']=function(_0xeaa06e){try{if(!_[_0x8345('0x1b')](queues[_0xeaa06e[_0x8345('0x5')]])){utils[_0x8345('0x13')](util[_0x8345('0x3')](_0x8345('0x38'),_0xeaa06e['uniqueid']),_0xeaa06e);utils[_0x8345('0x2')](util[_0x8345('0x3')]('[%s][queues][agentconnect]\x20name:%s\x20agent:%s\x20accountcode:%s',_0xeaa06e[_0x8345('0x5')],queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x1f')],_0xeaa06e[_0x8345('0x39')],_0xeaa06e[_0x8345('0x3a')]));queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x2c')]=![];queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x2c')]=![];queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x28')]=null;queues[_0xeaa06e['uniqueid']]['queuecallerexit']=![];queues[_0xeaa06e['uniqueid']][_0x8345('0xb')]=null;queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x29')]=null;queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x3b')]=!![];queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0xa')]=_0xeaa06e[_0x8345('0x3a')];queues[_0xeaa06e[_0x8345('0x5')]][_0x8345('0x8')]=_0xeaa06e['membername'];}}catch(_0x56c2c5){utils['error'](util['format'](_0x8345('0x38'),_0xeaa06e['uniqueid']),_0x56c2c5);}};exports[_0x8345('0x3c')]=function(_0xfb851f){try{if(!_[_0x8345('0x1b')](queues[_0xfb851f['uniqueid']])){if(queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x1c')]){utils[_0x8345('0x13')](util['format'](_0x8345('0x3d'),_0xfb851f[_0x8345('0x5')]),_0xfb851f);queues[_0xfb851f['uniqueid']][_0x8345('0x2c')]=![];queues[_0xfb851f[_0x8345('0x5')]]['queuecallerabandon']=![];queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x28')]=null;queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x1d')]=![];queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x29')]=null;queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x3b')]=!![];queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x8')]=_0xfb851f[_0x8345('0x39')];queues[_0xfb851f[_0x8345('0x5')]]['queuecallercomplete']=!![];queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0x3e')]=utils[_0x8345('0x18')]();if(_0xfb851f[_0x8345('0x3f')]=='transfer'){if(!queues[_0xfb851f['uniqueid']]['transfer']){queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0xb')]=_0x8345('0x40');}}else{queues[_0xfb851f[_0x8345('0x5')]][_0x8345('0xb')]=_0x8345('0x41')+_0xfb851f['reason'][_0x8345('0x27')]();}utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x42'),_0xfb851f['uniqueid'],queues[_0xfb851f[_0x8345('0x5')]]['name'],_0xfb851f['membername'],queues[_0xfb851f[_0x8345('0x5')]]['queuecallerexitreason']));writeDB(queues[_0xfb851f['uniqueid']]);}}}catch(_0x28f118){utils['error'](util[_0x8345('0x3')]('[%s][queues][agentcomplete]',_0xfb851f['uniqueid']),_0x28f118);}};exports[_0x8345('0x43')]=function(_0x106963){try{if(!_['isNil'](queues[_0x106963[_0x8345('0x44')]])){utils[_0x8345('0x13')](util[_0x8345('0x3')]('[%s][queues][blindtransfer]',_0x106963[_0x8345('0x5')]),_0x106963);queues[_0x106963[_0x8345('0x44')]][_0x8345('0x45')]=!![];queues[_0x106963['transfereeuniqueid']]['transfertype']=_0x8345('0x46');queues[_0x106963[_0x8345('0x44')]][_0x8345('0x47')]=_0x106963[_0x8345('0x48')];queues[_0x106963[_0x8345('0x44')]]['transferuniqueid']=_0x106963[_0x8345('0x44')];queues[_0x106963[_0x8345('0x44')]][_0x8345('0xb')]=_0x8345('0x49');utils['info'](util[_0x8345('0x3')]('[%s][queues][blindtransfer]\x20name:%s\x20transferuniqueid:%s\x20transferexten:%s\x20queuecallerexitreason:BLINDTRANSFER',_0x106963['uniqueid'],queues[_0x106963[_0x8345('0x44')]][_0x8345('0x1f')],_0x106963[_0x8345('0x44')],_0x106963[_0x8345('0x48')]));}}catch(_0x54d578){utils[_0x8345('0x19')](util[_0x8345('0x3')](_0x8345('0x4a'),_0x106963['uniqueid']),_0x54d578);}};exports[_0x8345('0x4b')]=function(_0xc90b2e){try{utils[_0x8345('0x13')](util[_0x8345('0x3')](_0x8345('0x4c'),_0xc90b2e['origtransfereruniqueid']),_0xc90b2e);if(_0xc90b2e['origtransfereruniqueid']==_0xc90b2e[_0x8345('0x4d')]){if(!_[_0x8345('0x1b')](queues[_0xc90b2e[_0x8345('0x4e')]])){utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x4f'),_0xc90b2e['origtransfereruniqueid'],queues[_0xc90b2e['secondtransfererlinkedid']]['name'],_0xc90b2e[_0x8345('0x50')]));queues[_0xc90b2e[_0x8345('0x4e')]][_0x8345('0x45')]=!![];queues[_0xc90b2e[_0x8345('0x4e')]][_0x8345('0x51')]=_0x8345('0x52');queues[_0xc90b2e[_0x8345('0x4e')]]['transferexten']=_0xc90b2e['origtransfererexten'];queues[_0xc90b2e[_0x8345('0x4e')]][_0x8345('0x53')]=_0xc90b2e[_0x8345('0x54')];queues[_0xc90b2e[_0x8345('0x4e')]]['queuecallerexitreason']=_0x8345('0x55');}if(!_[_0x8345('0x1b')](queues[_0xc90b2e['origtransfererlinkedid']])){if(_0xc90b2e[_0x8345('0x56')]&&queues[_0xc90b2e['transfereelinkedid']]){queues[_0xc90b2e[_0x8345('0x56')]][_0x8345('0x21')]=0x1;queues[_0xc90b2e['transfereeuniqueid']]=_['clone'](queues[_0xc90b2e[_0x8345('0x56')]]);queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x11')]=_0xc90b2e[_0x8345('0x57')];queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x21')]=0x2;queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x9')]=queues[_0xc90b2e[_0x8345('0x4e')]][_0x8345('0x9')];queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x58')]=queues[_0xc90b2e[_0x8345('0x4e')]][_0x8345('0x58')];queues[_0xc90b2e['transfereeuniqueid']][_0x8345('0x36')]=utils['now']();queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x1c')]=utils[_0x8345('0x18')]();queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x34')]=0x0;queues[_0xc90b2e['transfereeuniqueid']][_0x8345('0x59')]=0x0;utils['info'](util[_0x8345('0x3')](_0x8345('0x5a'),_0xc90b2e[_0x8345('0x54')],queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x1f')],queues[_0xc90b2e[_0x8345('0x44')]]['calleridnum'],queues[_0xc90b2e[_0x8345('0x44')]][_0x8345('0x58')]));}else{utils[_0x8345('0x2')](util[_0x8345('0x3')]('[%s][queues][attendedtransfer]\x20name:%s\x20transfereduniqueid:%s',_0xc90b2e[_0x8345('0x54')],queues[_0xc90b2e['origtransfererlinkedid']][_0x8345('0x1f')],_0xc90b2e[_0x8345('0x4e')]));queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x11')]=_0xc90b2e[_0x8345('0x4e')];}}}else if(_0xc90b2e[_0x8345('0x5b')]==_0xc90b2e[_0x8345('0x4e')]){if(!_[_0x8345('0x1b')](queues[_0xc90b2e['origtransfererlinkedid']])){utils['info'](util[_0x8345('0x3')](_0x8345('0x5c'),_0xc90b2e[_0x8345('0x54')],queues[_0xc90b2e['origtransfererlinkedid']]['name'],_0xc90b2e[_0x8345('0x5b')],_0xc90b2e['secondtransfererexten']));queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x45')]=!![];queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x51')]=_0x8345('0x52');queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x47')]=_0xc90b2e['secondtransfererexten'];queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x53')]=_0xc90b2e[_0x8345('0x5b')];queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0xb')]=_0x8345('0x55');}if(!_[_0x8345('0x1b')](queues[_0xc90b2e[_0x8345('0x4e')]])){if(_0xc90b2e[_0x8345('0x5d')]&&queues[_0xc90b2e['transfertargetlinkedid']]){queues[_0xc90b2e['transfertargetlinkedid']]['queuecallerenterreason']=0x1;queues[_0xc90b2e[_0x8345('0x57')]]=_[_0x8345('0x5e')](queues[_0xc90b2e[_0x8345('0x5d')]]);queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x11')]=_0xc90b2e[_0x8345('0x57')];queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x21')]=0x2;queues[_0xc90b2e['transfertargetuniqueid']][_0x8345('0x9')]=queues[_0xc90b2e['origtransfererlinkedid']][_0x8345('0x9')];queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x58')]=queues[_0xc90b2e[_0x8345('0x4d')]][_0x8345('0x58')];queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x36')]=utils[_0x8345('0x18')]();queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x1c')]=utils['now']();queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x34')]=0x0;queues[_0xc90b2e['transfertargetuniqueid']][_0x8345('0x59')]=0x0;utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x5f'),_0xc90b2e[_0x8345('0x54')],queues[_0xc90b2e[_0x8345('0x57')]][_0x8345('0x1f')],queues[_0xc90b2e[_0x8345('0x57')]]['transfereduniqueid'],queues[_0xc90b2e[_0x8345('0x57')]]['calleridnum'],queues[_0xc90b2e['transfertargetuniqueid']][_0x8345('0x58')]));}else{utils[_0x8345('0x2')](util[_0x8345('0x3')]('[%s][queues][attendedtransfer]\x20name:%s\x20transfereduniqueid:%s',_0xc90b2e['origtransfereruniqueid'],queues[_0xc90b2e['secondtransfererlinkedid']][_0x8345('0x1f')],_0xc90b2e[_0x8345('0x4d')]));queues[_0xc90b2e['secondtransfererlinkedid']][_0x8345('0x11')]=_0xc90b2e['origtransfererlinkedid'];}}}}catch(_0x3be693){utils[_0x8345('0x19')](util[_0x8345('0x3')](_0x8345('0x4c'),_0xc90b2e[_0x8345('0x54')]),_0x3be693);}};exports[_0x8345('0x60')]=function(_0xf30b8a){try{if(!_[_0x8345('0x1b')](queues[_0xf30b8a[_0x8345('0x5')]])){utils['debug'](util[_0x8345('0x3')](_0x8345('0x61'),_0xf30b8a[_0x8345('0x5')]),_0xf30b8a);queues[_0xf30b8a[_0x8345('0x5')]][_0x8345('0x62')]=utils[_0x8345('0x18')]();utils[_0x8345('0x2')](util[_0x8345('0x3')](_0x8345('0x63'),_0xf30b8a[_0x8345('0x5')],queues[_0xf30b8a[_0x8345('0x5')]]['name'],queues[_0xf30b8a[_0x8345('0x5')]][_0x8345('0x62')]));}}catch(_0x1d6cd8){utils[_0x8345('0x19')](util[_0x8345('0x3')]('[%s][queues][musiconholdstart]',_0xf30b8a[_0x8345('0x5')]),_0x1d6cd8);}};exports[_0x8345('0x64')]=function(_0x343c0a){try{if(!_['isNil'](queues[_0x343c0a[_0x8345('0x5')]])){if(!_[_0x8345('0x1b')](queues[_0x343c0a[_0x8345('0x5')]][_0x8345('0x62')])){utils['debug'](util[_0x8345('0x3')](_0x8345('0x65'),_0x343c0a[_0x8345('0x5')]),_0x343c0a);queues[_0x343c0a[_0x8345('0x5')]][_0x8345('0x59')]+=utils[_0x8345('0x35')](utils[_0x8345('0x18')](),queues[_0x343c0a[_0x8345('0x5')]][_0x8345('0x62')]);utils[_0x8345('0x2')](util['format'](_0x8345('0x66'),_0x343c0a['uniqueid'],queues[_0x343c0a[_0x8345('0x5')]]['name'],queues[_0x343c0a['uniqueid']][_0x8345('0x59')]));delete queues[_0x343c0a[_0x8345('0x5')]][_0x8345('0x62')];}}}catch(_0x2dbfd6){utils[_0x8345('0x19')](util[_0x8345('0x3')](_0x8345('0x65'),_0x343c0a['uniqueid']),_0x2dbfd6);}}; \ No newline at end of file diff --git a/server/services/xdr/recordings.controller.js b/server/services/xdr/recordings.controller.js new file mode 100644 index 0000000..fe741a4 --- /dev/null +++ b/server/services/xdr/recordings.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x00e1=['exten','context','channel','[%s][recordings][newstate]','isNil','channelstate','[%s][recordings][newstate]\x20context:%s\x20channel:%s','error','varset','variable','mixmonitor_filename','[%s][recordings][varset]','[%s][recordings][varset]\x20variable:%s\x20value:%s','value','endsWith','replace','.wav49','.WAV','find','monitors','push','hangup','[%s][recordings][hangup]','calleridnum','calleridname','cause-txt','connectedlinenum','connectedlinename','type','outbound','clone','newexten','[%s][recordings][newexten]','application','startsWith','toLowerCase','cdr','split','lastIndexOf','queuecallerjoin','[%s][recordings][queuecallerjoin]','[%s][recordings][queuecallerjoin]\x20queue:%s','queue','blindtransfer','[%s][recordings][blindtransfer]','transferercalleridnum','transferercalleridname','transfereecalleridnum','transfereruniqueid','recording','lodash','util','./utils','./transfers.controller','info','[%s][recordings][writeDB]','blinds','uniqueid','accountcode','getUserByInternal','UserId','request','CreateVoiceRecording','newchannel','debug','format','[%s][recordings][newchannel]','linkedid'];(function(_0x1bcc18,_0x375344){var _0x5e942a=function(_0x1f5210){while(--_0x1f5210){_0x1bcc18['push'](_0x1bcc18['shift']());}};_0x5e942a(++_0x375344);}(_0x00e1,0x142));var _0x100e=function(_0x4f9693,_0x13f8c6){_0x4f9693=_0x4f9693-0x0;var _0x4c03b3=_0x00e1[_0x4f9693];return _0x4c03b3;};'use strict';var _=require(_0x100e('0x0'));var util=require(_0x100e('0x1'));var utils=require(_0x100e('0x2'));var transfers=require(_0x100e('0x3'));var recordings={};function writeDB(_0x5565ff){var _0x1f3f67;utils[_0x100e('0x4')](util['format'](_0x100e('0x5'),_0x5565ff['uniqueid']));if(transfers[_0x100e('0x6')][_0x5565ff[_0x100e('0x7')]]){_0x1f3f67=_0x5565ff[_0x100e('0x7')];_0x5565ff['uniqueid']=transfers[_0x100e('0x6')][_0x5565ff[_0x100e('0x7')]]['transfereeuniqueid'];}if(_0x5565ff[_0x100e('0x8')]){utils[_0x100e('0x9')](_0x5565ff[_0x100e('0x8')])['then'](function(_0x4e6969){if(_0x4e6969){_0x5565ff['membername']=_0x4e6969['name'];_0x5565ff[_0x100e('0xa')]=_0x4e6969['id'];}utils[_0x100e('0xb')](_0x100e('0xc'),_0x5565ff);});}else{utils[_0x100e('0xb')](_0x100e('0xc'),_0x5565ff);}if(_0x1f3f67)delete transfers[_0x100e('0x6')][_0x1f3f67];}exports[_0x100e('0xd')]=function(_0x582f4e){try{utils[_0x100e('0xe')](util[_0x100e('0xf')](_0x100e('0x10'),_0x582f4e['uniqueid']),_0x582f4e);if(_0x582f4e[_0x100e('0x7')]==_0x582f4e[_0x100e('0x11')]){utils['info'](util[_0x100e('0xf')]('[%s][recordings][newchannel]\x20context:%s\x20exten:%s',_0x582f4e[_0x100e('0x7')],_0x582f4e['context'],_0x582f4e[_0x100e('0x12')]));recordings[_0x582f4e[_0x100e('0x7')]]={'uniqueid':_0x582f4e['uniqueid'],'accountcode':_0x582f4e[_0x100e('0x8')],'exten':_0x582f4e[_0x100e('0x12')],'context':_0x582f4e[_0x100e('0x13')],'channel':_0x582f4e[_0x100e('0x14')],'monitors':[]};}}catch(_0x1801ba){utils['error'](util[_0x100e('0xf')]('[%s][recordings][newchannel]',_0x582f4e[_0x100e('0x7')]),_0x1801ba);}};exports['newstate']=function(_0x37a50c){try{utils['debug'](util[_0x100e('0xf')](_0x100e('0x15'),_0x37a50c['uniqueid']),_0x37a50c);if(!_[_0x100e('0x16')](recordings[_0x37a50c[_0x100e('0x7')]])&&_0x37a50c[_0x100e('0x17')]==0x6){utils[_0x100e('0x4')](util[_0x100e('0xf')](_0x100e('0x18'),_0x37a50c[_0x100e('0x7')],_0x37a50c[_0x100e('0x13')],_0x37a50c[_0x100e('0x14')]));}else if(!_[_0x100e('0x16')](recordings[_0x37a50c['linkedid']])&&_0x37a50c[_0x100e('0x17')]==0x6&&_0x37a50c[_0x100e('0x13')]!='transfer'){utils[_0x100e('0x4')](util['format']('[%s][recordings][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s',_0x37a50c[_0x100e('0x7')],_0x37a50c[_0x100e('0x11')],_0x37a50c[_0x100e('0x13')],_0x37a50c[_0x100e('0x14')]));recordings[_0x37a50c[_0x100e('0x11')]][_0x100e('0x8')]=_0x37a50c[_0x100e('0x8')];}}catch(_0x50d4bd){utils[_0x100e('0x19')](util['format'](_0x100e('0x15'),_0x37a50c[_0x100e('0x7')]),_0x50d4bd);}};exports[_0x100e('0x1a')]=function(_0x5e9f1c){try{if(!_[_0x100e('0x16')](_0x5e9f1c[_0x100e('0x1b')])&&!_[_0x100e('0x16')](_0x5e9f1c[_0x100e('0x1b')][_0x100e('0x1c')])){utils[_0x100e('0xe')](util[_0x100e('0xf')](_0x100e('0x1d'),_0x5e9f1c[_0x100e('0x7')]),_0x5e9f1c);utils[_0x100e('0x4')](util[_0x100e('0xf')](_0x100e('0x1e'),_0x5e9f1c[_0x100e('0x7')],_0x5e9f1c[_0x100e('0x1b')],_0x5e9f1c[_0x100e('0x1f')]));if(_[_0x100e('0x20')](_0x5e9f1c[_0x100e('0x1f')],'.wav49')){_0x5e9f1c[_0x100e('0x1f')]=_0x5e9f1c[_0x100e('0x1f')][_0x100e('0x21')](_0x100e('0x22'),_0x100e('0x23'));}if(recordings[_0x5e9f1c['linkedid']]){var _0x3e02ae=_[_0x100e('0x24')](recordings[_0x5e9f1c['linkedid']][_0x100e('0x25')],{'value':_0x5e9f1c[_0x100e('0x1f')]});if(_[_0x100e('0x16')](_0x3e02ae)){recordings[_0x5e9f1c[_0x100e('0x11')]]['monitors'][_0x100e('0x26')]({'value':_0x5e9f1c[_0x100e('0x1f')]});}}}}catch(_0x2d74f3){utils[_0x100e('0x19')](util[_0x100e('0xf')](_0x100e('0x1d'),_0x5e9f1c[_0x100e('0x7')]),_0x2d74f3);}};exports[_0x100e('0x27')]=function(_0x9b2328){try{if(!_[_0x100e('0x16')](recordings[_0x9b2328[_0x100e('0x7')]])){utils[_0x100e('0xe')](util[_0x100e('0xf')](_0x100e('0x28'),_0x9b2328[_0x100e('0x7')]),_0x9b2328);utils[_0x100e('0x4')](util[_0x100e('0xf')]('[%s][recordings][hangup]\x20calleridnum:%s\x20calleridname:%s\x20reason:%s',_0x9b2328[_0x100e('0x7')],_0x9b2328[_0x100e('0x29')],_0x9b2328[_0x100e('0x2a')],_0x9b2328[_0x100e('0x2b')]));recordings[_0x9b2328[_0x100e('0x7')]]['calleridnum']=_0x9b2328[_0x100e('0x29')];recordings[_0x9b2328['uniqueid']]['calleridname']=_0x9b2328[_0x100e('0x2a')];recordings[_0x9b2328['uniqueid']][_0x100e('0x2c')]=_0x9b2328[_0x100e('0x2c')];recordings[_0x9b2328['uniqueid']][_0x100e('0x2d')]=_0x9b2328[_0x100e('0x2d')];if(recordings[_0x9b2328['uniqueid']][_0x100e('0x2e')]==_0x100e('0x2f')&&recordings[_0x9b2328[_0x100e('0x7')]]['accountcode']){recordings[_0x9b2328[_0x100e('0x7')]][_0x100e('0x2c')]=recordings[_0x9b2328[_0x100e('0x7')]][_0x100e('0x8')];recordings[_0x9b2328[_0x100e('0x7')]]['connectedlinename']='';}recordings[_0x9b2328[_0x100e('0x7')]][_0x100e('0x25')]['forEach'](function(_0x3a2065){var _0x1ca810=_[_0x100e('0x30')](recordings[_0x9b2328[_0x100e('0x7')]]);_0x1ca810[_0x100e('0x1f')]=_0x3a2065[_0x100e('0x1f')];writeDB(_0x1ca810);});delete recordings[_0x9b2328[_0x100e('0x7')]];}}catch(_0x3e0134){utils[_0x100e('0x19')](util[_0x100e('0xf')](_0x100e('0x28'),_0x9b2328['uniqueid']),_0x3e0134);}};exports[_0x100e('0x31')]=function(_0x592c17){try{if(!_[_0x100e('0x16')](recordings[_0x592c17[_0x100e('0x7')]])){utils['debug'](util['format'](_0x100e('0x32'),_0x592c17[_0x100e('0x7')]),_0x592c17);utils['info'](util[_0x100e('0xf')]('[%s][recordings][newexten]\x20application:%s\x20appdata:%s',_0x592c17['uniqueid'],_0x592c17[_0x100e('0x33')],_0x592c17['appdata']));if(_0x592c17[_0x100e('0x33')]['toLowerCase']()=='set'&&_[_0x100e('0x34')](_0x592c17['appdata'][_0x100e('0x35')](),_0x100e('0x36'))){var _0x57ed1e=_0x592c17['appdata'][_0x100e('0x37')]('=');var _0x46be55=_0x57ed1e[0x0]['substring'](_0x57ed1e[0x0]['lastIndexOf']('(')+0x1,_0x57ed1e[0x0][_0x100e('0x38')](')'));var _0x4966aa=_0x57ed1e[0x1];recordings[_0x592c17[_0x100e('0x7')]][_0x46be55]=_0x4966aa;}}}catch(_0x5e041e){utils[_0x100e('0x19')](util[_0x100e('0xf')](_0x100e('0x32'),_0x592c17[_0x100e('0x7')]),_0x5e041e);}};exports[_0x100e('0x39')]=function(_0x355503){try{if(!_[_0x100e('0x16')](recordings[_0x355503[_0x100e('0x7')]])){utils[_0x100e('0xe')](util[_0x100e('0xf')](_0x100e('0x3a'),_0x355503[_0x100e('0x7')]),_0x355503);utils[_0x100e('0x4')](util[_0x100e('0xf')](_0x100e('0x3b'),_0x355503[_0x100e('0x7')],_0x355503[_0x100e('0x3c')]));recordings[_0x355503['uniqueid']]['queue']=_0x355503[_0x100e('0x3c')];}}catch(_0x3f4752){utils[_0x100e('0x19')](util[_0x100e('0xf')](_0x100e('0x3a'),_0x355503['uniqueid']),_0x3f4752);}};exports[_0x100e('0x3d')]=function(_0x239e3e){try{utils[_0x100e('0xe')](util[_0x100e('0xf')](_0x100e('0x3e'),_0x239e3e[_0x100e('0x7')]),_0x239e3e);utils[_0x100e('0x4')](util['format']('[%s][recordings][blindtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s',_0x239e3e[_0x100e('0x7')],_0x239e3e[_0x100e('0x3f')],_0x239e3e[_0x100e('0x40')],_0x239e3e[_0x100e('0x41')],_0x239e3e['transfereecalleridname']));if(recordings[_0x239e3e[_0x100e('0x42')]]&&transfers[_0x100e('0x6')][_0x239e3e[_0x100e('0x42')]]){transfers[_0x100e('0x6')][_0x239e3e[_0x100e('0x42')]][_0x100e('0x43')]=!![];}}catch(_0xfb01f4){utils['error'](util[_0x100e('0xf')](_0x100e('0x3e'),_0x239e3e[_0x100e('0x7')]),_0xfb01f4);}}; \ No newline at end of file diff --git a/server/services/xdr/transfers.controller.js b/server/services/xdr/transfers.controller.js new file mode 100644 index 0000000..eca94e0 --- /dev/null +++ b/server/services/xdr/transfers.controller.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xcd37=['[%s][transfers][attendedtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s','origtransferercalleridnum','origtransferercalleridname','transfertargetcalleridnum','transfertargetcalleridname','assign','origtransfererchannel','secondtransfererconnectedlinename','origtransfereraccountcode','secondtransferercontext','secondtransfererexten','origtransfererlinkedid','origtransferercontext','origtransfererexten','attended','transfereechannel','transfertargetchannel','transfertargetconnectedlinename','transfertargetaccountcode','transfertargetcontext','transfertargetexten','transfertargetlinkedid','lodash','util','format','[%s][transfers][writeDB]\x20type:%s','origtransfereruniqueid','uniqueid','type','blinds','blindtransfer','info','[%s][transfers][blindtransfer]\x20transferercalleridnum:%s\x20transferercalleridname:%s\x20transfereecalleridnum:%s\x20transfereecalleridname:%s','transferercalleridnum','transferercalleridname','transfereecalleridnum','transfereecalleridname','blind','error','[%s][transfers][blindtransfer]','attendedtransfer','debug','[%s][transfers][attendedtransfer]'];(function(_0x72895a,_0x433607){var _0x5226d5=function(_0x5b7d21){while(--_0x5b7d21){_0x72895a['push'](_0x72895a['shift']());}};_0x5226d5(++_0x433607);}(_0xcd37,0x143));var _0x7cd3=function(_0x184bab,_0x581ff5){_0x184bab=_0x184bab-0x0;var _0x2faaf5=_0xcd37[_0x184bab];return _0x2faaf5;};'use strict';var _=require(_0x7cd3('0x0'));var util=require(_0x7cd3('0x1'));var utils=require('./utils');function writeDB(_0x1b9497){utils['info'](util[_0x7cd3('0x2')](_0x7cd3('0x3'),_0x1b9497['type']==='attended'?_0x1b9497[_0x7cd3('0x4')]:_0x1b9497[_0x7cd3('0x5')],_0x1b9497[_0x7cd3('0x6')]));utils['request']('CreateVoiceTransferReport',_0x1b9497);}exports[_0x7cd3('0x7')]={};exports[_0x7cd3('0x8')]=function(_0x5ec926){try{utils['debug'](util[_0x7cd3('0x2')]('[%s][transfers][blindtransfer]',_0x5ec926[_0x7cd3('0x5')]),_0x5ec926);utils[_0x7cd3('0x9')](util[_0x7cd3('0x2')](_0x7cd3('0xa'),_0x5ec926[_0x7cd3('0x5')],_0x5ec926[_0x7cd3('0xb')],_0x5ec926[_0x7cd3('0xc')],_0x5ec926[_0x7cd3('0xd')],_0x5ec926[_0x7cd3('0xe')]));_0x5ec926['type']=_0x7cd3('0xf');exports[_0x7cd3('0x7')][_0x5ec926['transfereruniqueid']]=_0x5ec926;writeDB(_0x5ec926);}catch(_0x444b58){utils[_0x7cd3('0x10')](util[_0x7cd3('0x2')](_0x7cd3('0x11'),_0x5ec926[_0x7cd3('0x5')]),_0x444b58);}};exports[_0x7cd3('0x12')]=function(_0x2f7cd2){try{utils[_0x7cd3('0x13')](util['format'](_0x7cd3('0x14'),_0x2f7cd2[_0x7cd3('0x4')]),_0x2f7cd2);utils[_0x7cd3('0x9')](util[_0x7cd3('0x2')](_0x7cd3('0x15'),_0x2f7cd2[_0x7cd3('0x4')],_0x2f7cd2[_0x7cd3('0x16')],_0x2f7cd2[_0x7cd3('0x17')],_0x2f7cd2[_0x7cd3('0x18')],_0x2f7cd2[_0x7cd3('0x19')]));_0x2f7cd2=_[_0x7cd3('0x1a')](_0x2f7cd2,{'transfererchannel':_0x2f7cd2[_0x7cd3('0x1b')],'transferercalleridnum':_0x2f7cd2[_0x7cd3('0x16')],'transferercalleridname':_0x2f7cd2['origtransferercalleridname'],'transfererconnectedlinenum':_0x2f7cd2['secondtransfererconnectedlinenum'],'transfererconnectedlinename':_0x2f7cd2[_0x7cd3('0x1c')],'transfereraccountcode':_0x2f7cd2[_0x7cd3('0x1d')],'transferercontext':_0x2f7cd2[_0x7cd3('0x1e')],'transfererexten':_0x2f7cd2[_0x7cd3('0x1f')],'transfererlinkedid':_0x2f7cd2[_0x7cd3('0x20')],'context':_0x2f7cd2[_0x7cd3('0x21')],'extension':_0x2f7cd2[_0x7cd3('0x22')],'type':_0x7cd3('0x23')});if(_['isNil'](_0x2f7cd2[_0x7cd3('0x24')])){_0x2f7cd2=_['assign'](_0x2f7cd2,{'transfereechannel':_0x2f7cd2[_0x7cd3('0x25')],'transfereecalleridnum':_0x2f7cd2[_0x7cd3('0x18')],'transfereecalleridname':_0x2f7cd2[_0x7cd3('0x19')],'transfereeconnectedlinenum':_0x2f7cd2['transfertargetconnectedlinenum'],'transfereeconnectedlinename':_0x2f7cd2[_0x7cd3('0x26')],'transfereeaccountcode':_0x2f7cd2[_0x7cd3('0x27')],'transfereecontext':_0x2f7cd2[_0x7cd3('0x28')],'transfereeexten':_0x2f7cd2[_0x7cd3('0x29')],'transfereelinkedid':_0x2f7cd2[_0x7cd3('0x2a')]});}writeDB(_0x2f7cd2);}catch(_0x3e884f){utils[_0x7cd3('0x10')](util['format']('[%s][transfers][attendedtransfer]',_0x2f7cd2[_0x7cd3('0x4')]),_0x3e884f);}}; \ No newline at end of file diff --git a/server/services/xdr/utils.js b/server/services/xdr/utils.js new file mode 100644 index 0000000..6b8e5fd --- /dev/null +++ b/server/services/xdr/utils.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x736c=['[utils][getUserByName]','getVoiceQueueByName','GetVoiceQueue','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','addTime','seconds','subtractTime','format','YYYY-MM-DD\x20HH:mm:ss','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','util','client','http','../../config/logger','xdr','info','debug','inspect','error','request','then','[utils][request]\x20name:%s','catch','GetUser','internal','name','interface','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','notfound','[utils][getUserByInterface]','getUserByName'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x736c,0x190));var _0xc736=function(_0x5557c2,_0x37de81){_0x5557c2=_0x5557c2-0x0;var _0x2c1eff=_0x736c[_0x5557c2];return _0x2c1eff;};'use strict';var BPromise=require(_0xc736('0x0'));var jayson=require(_0xc736('0x1'));var moment=require('moment');var util=require(_0xc736('0x2'));var client=jayson[_0xc736('0x3')][_0xc736('0x4')]({'port':0x2329});var logger=require(_0xc736('0x5'))(_0xc736('0x6'));exports[_0xc736('0x7')]=function(_0xb57164,_0x3f00f0){logger['info'](_0xb57164,_0x3f00f0?util['inspect'](_0x3f00f0,{'showHidden':![],'depth':null}):'');};exports[_0xc736('0x8')]=function(_0x480ef2,_0x58245d){logger['debug'](_0x480ef2,_0x58245d?util[_0xc736('0x9')](_0x58245d,{'showHidden':![],'depth':null}):'');};exports[_0xc736('0xa')]=function(_0x268e4a,_0x21eb49){logger[_0xc736('0xa')](_0x268e4a,_0x21eb49?util[_0xc736('0x9')](_0x21eb49,{'showHidden':![],'depth':null}):'');};exports[_0xc736('0xb')]=function(_0x523260,_0x437e33){return client[_0xc736('0xb')](_0x523260,{'body':_0x437e33})[_0xc736('0xc')](function(_0x2537fc){logger[_0xc736('0x8')](_0xc736('0xd'),_0x523260,_0x2537fc?util[_0xc736('0x9')](_0x2537fc,{'showHidden':![],'depth':null}):'');})[_0xc736('0xe')](function(_0x3c3cf7){logger[_0xc736('0xa')]('[utils][request]\x20name:%s',_0x523260,_0x3c3cf7?util[_0xc736('0x9')](_0x3c3cf7,{'showHidden':![],'depth':null}):'');});};function getUser(_0xf24ccd){return client[_0xc736('0xb')](_0xc736('0xf'),{'options':{'raw':!![],'attributes':['id',_0xc736('0x10'),_0xc736('0x11'),_0xc736('0x12')],'where':_0xf24ccd,'limit':0x1}})['then'](function(_0x3dc6c7){logger[_0xc736('0x8')](_0xc736('0x13'),JSON[_0xc736('0x14')](_0xf24ccd),_0x3dc6c7?util[_0xc736('0x9')](_0x3dc6c7,{'showHidden':![],'depth':null}):'');return _0x3dc6c7[_0xc736('0x15')][_0xc736('0x16')]?_0x3dc6c7[_0xc736('0x15')][0x0]:null;});}exports[_0xc736('0x17')]=function(_0x1ce82f){return new BPromise(function(_0x3d54ad,_0x14a290){if(_0x1ce82f){return getUser({'internal':_0x1ce82f})[_0xc736('0xc')](function(_0x4bcf76){logger['info'](_0xc736('0x18'),_0x1ce82f,_0x4bcf76?_0xc736('0x19'):'notfound');return _0x3d54ad(_0x4bcf76);})[_0xc736('0xe')](function(_0xa1d18a){logger['error'](_0xc736('0x1a'),_0xa1d18a?util['inspect'](_0xa1d18a,{'showHidden':![],'depth':null}):'');return _0x3d54ad(null);});}return _0x3d54ad(null);});};exports[_0xc736('0x1b')]=function(_0xbd315f){return new BPromise(function(_0x418637,_0xf72ad3){if(_0xbd315f){return getUser({'interface':_0xbd315f})[_0xc736('0xc')](function(_0x137d0d){logger['info'](_0xc736('0x1c'),_0xbd315f,_0x137d0d?_0xc736('0x19'):_0xc736('0x1d'));return _0x418637(_0x137d0d);})[_0xc736('0xe')](function(_0x59d6c2){logger[_0xc736('0xa')](_0xc736('0x1e'),_0x59d6c2?util[_0xc736('0x9')](_0x59d6c2,{'showHidden':![],'depth':null}):'');return _0x418637(null);});}return _0x418637(null);});};exports[_0xc736('0x1f')]=function(_0x34eca3){return new BPromise(function(_0xa8f3a7,_0x5c2af3){if(_0x34eca3){return getUser({'name':_0x34eca3})[_0xc736('0xc')](function(_0x48ffb3){logger['info']('[utils][getUserByName]\x20name:%s\x20%s',_0x34eca3,_0x48ffb3?_0xc736('0x19'):'notfound');return _0xa8f3a7(_0x48ffb3);})[_0xc736('0xe')](function(_0x6292b1){logger[_0xc736('0xa')](_0xc736('0x20'),_0x6292b1?util[_0xc736('0x9')](_0x6292b1,{'showHidden':![],'depth':null}):'');return _0xa8f3a7(null);});}return _0xa8f3a7(null);});};exports[_0xc736('0x21')]=function(_0x5f20e8){return new BPromise(function(_0x27f074,_0x1a9aa4){if(_0x5f20e8){return client[_0xc736('0xb')](_0xc736('0x22'),{'options':{'raw':!![],'attributes':['id',_0xc736('0x11'),'type',_0xc736('0x23'),_0xc736('0x24')],'where':{'name':_0x5f20e8},'limit':0x1}})[_0xc736('0xc')](function(_0x4a1ada){logger['debug']('[utils][getVoiceQueueByName]\x20name:%s',_0x5f20e8,_0x4a1ada?util['inspect'](_0x4a1ada,{'showHidden':![],'depth':null}):'');logger[_0xc736('0x7')](_0xc736('0x25'),_0x5f20e8,_0x4a1ada?_0xc736('0x19'):_0xc736('0x1d'));return _0x27f074(_0x4a1ada[_0xc736('0x15')][_0xc736('0x16')]?_0x4a1ada['result'][0x0]:null);})[_0xc736('0xe')](function(_0x20a17a){logger[_0xc736('0xa')](_0xc736('0x26'),_0x20a17a?util[_0xc736('0x9')](_0x20a17a,{'showHidden':![],'depth':null}):'');return _0x27f074(null);});}return _0x27f074(null);});};exports[_0xc736('0x27')]=function(_0x27faa8,_0x2bc770){return moment(_0x27faa8)['add'](_0x2bc770,_0xc736('0x28'))['format']('YYYY-MM-DD\x20HH:mm:ss');};exports[_0xc736('0x29')]=function(_0x2fb78b,_0x12d25f){return moment(_0x2fb78b)['subtract'](_0x12d25f,_0xc736('0x28'))[_0xc736('0x2a')](_0xc736('0x2b'));};exports['diffTime']=function(_0x4954ca,_0x2e51b7){return moment(_0x4954ca)['diff'](moment(_0x2e51b7),_0xc736('0x28'));};exports[_0xc736('0x2c')]=function(_0x2951bc,_0x2b3402){return parseInt(_0x2951bc,0xa)+parseInt(_0x2b3402,0xa);};exports[_0xc736('0x2d')]=function(){return moment()[_0xc736('0x2a')](_0xc736('0x2b'));};exports[_0xc736('0x2e')]=function(_0x5616e7,_0xec8272){if(_0xec8272){return moment(_0x5616e7)['isAfter'](_0xec8272);}return!![];};exports[_0xc736('0x2f')]=function(_0x33f1bd,_0x8068e0){if(_0x8068e0){return moment(_0x33f1bd)[_0xc736('0x2f')](_0x8068e0);}else if(_0x33f1bd){return!![];}return![];}; \ No newline at end of file diff --git a/server/utils/client-side-logger.js b/server/utils/client-side-logger.js new file mode 100644 index 0000000..d817792 --- /dev/null +++ b/server/utils/client-side-logger.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x277a=['lodash','express-winston','./loggers','fileLogger','safeTemplate','./mask-sensitive-data','maskSensitiveData','join','/var','log','xcally','client','role','name','then','catch','user','no-user','data','error','api','auth','set','client-side-logger','use','logger','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s','isEmpty','body','\x20body=%s','format','x-forwarded-for','headers','connection','remoteAddress','url','statusCode','responseTime','inspect','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s','agent_id','%s\x20%s\x20%s\x20%s\x20%sms\x20id=%s\x20name=%s\x20role=%s\x20device=%s\x20(id=%s\x20name=%s)','method','device','other','agent_name','test','setupLoggers','fs-extra'];(function(_0x30c594,_0x5ccdc8){var _0x4723cc=function(_0x4c76c1){while(--_0x4c76c1){_0x30c594['push'](_0x30c594['shift']());}};_0x4723cc(++_0x5ccdc8);}(_0x277a,0xf4));var _0xa277=function(_0xd43a9b,_0x3ca7dd){_0xd43a9b=_0xd43a9b-0x0;var _0x2a0956=_0x277a[_0xd43a9b];return _0x2a0956;};var fs=require(_0xa277('0x0'));var _=require(_0xa277('0x1'));var ewinston=require(_0xa277('0x2'));var path=require('path');var util=require('util');var fileLogger=require(_0xa277('0x3'))[_0xa277('0x4')];var safeTemplate=require('./safe-template')[_0xa277('0x5')];var maskSensitiveData=require(_0xa277('0x6'))[_0xa277('0x7')];function ClientSideLogger(){function _0x4f60bc(_0x54d6cf){var _0x5c5add=path[_0xa277('0x8')](_0xa277('0x9'),_0xa277('0xa'),_0xa277('0xb'));var _0x339bdb=path[_0xa277('0x8')](_0xa277('0xc'),_0x54d6cf[_0xa277('0xd')]+'-'+_0x54d6cf[_0xa277('0xe')]);return fs['ensureDir'](path['join'](_0x5c5add,_0x339bdb))[_0xa277('0xf')](function(){var _0x5ca09f=fileLogger(_0xa277('0xc'),path['join'](_0x5c5add,_0x339bdb));return _0x5ca09f;})[_0xa277('0x10')](function(_0x5d6f66){throw _0x5d6f66;});}this['log']=function(_0x1e9ebc,_0x16c145,_0x113a24,_0x3e9ce2){return _0x4f60bc(_0x1e9ebc[_0xa277('0x11')])[_0xa277('0xf')](function(_0x5978cd){var _0x373406=_0x5978cd[_0x16c145];return _0x373406;})[_0xa277('0xf')](function(_0x32fd82){var _0x11f3af=_0x1e9ebc[_0xa277('0x11')]?_0x1e9ebc[_0xa277('0x11')]['id']:_0xa277('0x12');var _0x2fe4bd=_0x3e9ce2[_0xa277('0x13')];var _0x525d3f=_0x3e9ce2['timestamp'];var _0x3d6b46=new Date(Number(_0x525d3f));return _0x32fd82(_0x11f3af,_0x3d6b46,_0x113a24,_0x2fe4bd);})[_0xa277('0x10')](function(_0x20a573){fileLogger(_0xa277('0xc'))[_0xa277('0x14')](_0x20a573);});};}function setupLoggers(_0x31599d){return new Promise(function(_0x141816){var _0x190fd1=new ClientSideLogger();var _0x5a36ec=fileLogger(_0xa277('0x15'));var _0x3d9e5b=fileLogger(_0xa277('0x16'));_0x31599d[_0xa277('0x17')](_0xa277('0x18'),_0x190fd1);_0x31599d[_0xa277('0x19')](ewinston[_0xa277('0x1a')]({'winstonInstance':_0x5a36ec,'meta':![],'statusLevels':!![],'msg':function(_0x5928f7,_0x4dc26a){var _0x1db652=_0xa277('0x1b');if(!_[_0xa277('0x1c')](_0x5928f7[_0xa277('0x1d')])){_0x1db652+=_0xa277('0x1e');var _0x1befeb=_0x5928f7[_0xa277('0x1d')];maskSensitiveData(_0x1befeb);}return safeTemplate(util[_0xa277('0x1f')](_0x1db652,_0x5928f7['method'],_0x5928f7['headers'][_0xa277('0x20')]?_0x5928f7[_0xa277('0x21')][_0xa277('0x20')]:_0x5928f7[_0xa277('0x22')][_0xa277('0x23')]||_0x5928f7['ip'],_0x5928f7[_0xa277('0x24')],_0x4dc26a[_0xa277('0x25')],_0x4dc26a[_0xa277('0x26')],_0x5928f7[_0xa277('0x11')]?_0x5928f7[_0xa277('0x11')]['id']:null,_0x5928f7['user']?_0x5928f7[_0xa277('0x11')][_0xa277('0xe')]:null,_0x5928f7[_0xa277('0x11')]?_0x5928f7['user'][_0xa277('0xd')]:null,_0x1befeb?util[_0xa277('0x27')](_0x1befeb,![],null):''));}}));_0x31599d[_0xa277('0x19')](ewinston[_0xa277('0x1a')]({'winstonInstance':_0x3d9e5b,'meta':![],'statusLevels':!![],'msg':function(_0x240b2d,_0x29826f){var _0x2ea211=_0xa277('0x28');if(_0x240b2d[_0xa277('0x1d')]&&_0x240b2d[_0xa277('0x1d')]['device']&&_0x240b2d[_0xa277('0x1d')][_0xa277('0x29')]){_0x2ea211=_0xa277('0x2a');}return util['format'](_0x2ea211,_0x240b2d[_0xa277('0x2b')],_0x240b2d[_0xa277('0x21')][_0xa277('0x20')]?_0x240b2d['headers'][_0xa277('0x20')]:_0x240b2d[_0xa277('0x22')][_0xa277('0x23')]||_0x240b2d['ip'],_0x240b2d['url'],_0x29826f[_0xa277('0x25')],_0x29826f[_0xa277('0x26')],_0x240b2d[_0xa277('0x11')]?_0x240b2d[_0xa277('0x11')]['id']:null,_0x240b2d[_0xa277('0x11')]?_0x240b2d['user'][_0xa277('0xe')]:null,_0x240b2d[_0xa277('0x11')]?_0x240b2d[_0xa277('0x11')]['role']:null,_0x240b2d[_0xa277('0x1d')]&&_0x240b2d[_0xa277('0x1d')][_0xa277('0x2c')]?_0x240b2d[_0xa277('0x1d')][_0xa277('0x2c')]:_0xa277('0x2d'),_0x240b2d[_0xa277('0x1d')]&&_0x240b2d[_0xa277('0x1d')][_0xa277('0x29')]?_0x240b2d[_0xa277('0x1d')][_0xa277('0x29')]:'',_0x240b2d[_0xa277('0x1d')]&&_0x240b2d['body'][_0xa277('0x2e')]?_0x240b2d[_0xa277('0x1d')][_0xa277('0x2e')]:'');},'ignoreRoute':function(_0x1d6bee){var _0x525013=/\/api\/users\/[0-9]+\/(login|logout)/gi;return!_0x525013[_0xa277('0x2f')](_0x1d6bee['url']);}}));return _0x141816();});}exports[_0xa277('0x30')]=setupLoggers; \ No newline at end of file diff --git a/server/utils/iftime.js b/server/utils/iftime.js new file mode 100644 index 0000000..85fbeec --- /dev/null +++ b/server/utils/iftime.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x9811=['join','isValid','split','locale','weekdaysShort','indexOf','slice','exports','toLowerCase','concat','clone','hours','minutes','endOf','day','isBetween','format','ddd','max','domCompare','MMM','includes','monthCompare','test','isMoment','padStart','length','iftime','lodash','map','source'];(function(_0x20c290,_0x47e736){var _0x3d7b3b=function(_0x5d837f){while(--_0x5d837f){_0x20c290['push'](_0x20c290['shift']());}};_0x3d7b3b(++_0x47e736);}(_0x9811,0x98));var _0x1981=function(_0x4f34f5,_0x4d7309){_0x4f34f5=_0x4f34f5-0x0;var _0xb1e3fd=_0x9811[_0x4f34f5];return _0xb1e3fd;};var _=require(_0x1981('0x0'));var moment=require('moment-timezone');var timeRx=/(\*|(\d{1,2}:\d{1,2})(-(\d{1,2}:\d{1,2}))?)/;var dowRx=/(\*|((sun|mon|tue|wed|thu|fri|sat)(-(sun|mon|tue|wed|thu|fri|sat))?))/;var domRx=/(\*|(\d{1,2})(-(\d{1,2}))?)/;var moyRx=/(\*|(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec))?)/;var globalRx=[timeRx,dowRx,domRx,moyRx][_0x1981('0x1')](function(_0x3ec8f2){return _0x3ec8f2[_0x1981('0x2')];})[_0x1981('0x3')](',');var validateRx=new RegExp('^'+globalRx+'$');var EINVALID_STRING='Interval\x20string\x20not\x20valid';var EINVALID_DATE='Date\x20not\x20valid';function throwIfDateNotValid(_0x309a5b){if(!_0x309a5b[_0x1981('0x4')]()){throw new Error(EINVALID_DATE);}}function extractTime(_0x453208){var _0x458ae5=_0x453208[_0x1981('0x5')](':')['map'](function(_0x351f2b){return parseInt(_0x351f2b,0xa);});var _0x585e51=_0x458ae5[0x0];var _0x527ff5=_0x458ae5[0x1];if(_0x585e51<0x0||_0x585e51>0x17||_0x527ff5<0x0||_0x527ff5>0x3b){throw new Error(EINVALID_DATE);}return[_0x585e51,_0x527ff5];}function circularDoWInterval(_0x4b5003,_0x17cff9){if(_0x4b5003===_0x17cff9){return[_0x4b5003];}else{var _0x45249c=moment[_0x1981('0x6')]();moment[_0x1981('0x6')]('en');var _0x800d87=moment[_0x1981('0x7')]()[_0x1981('0x1')](function(_0x22038b){return _0x22038b['toLowerCase']();});moment['locale'](_0x45249c);var _0x5a70a9=_0x800d87[_0x1981('0x8')](_0x4b5003);var _0x388ad2=_0x800d87[_0x1981('0x8')](_0x17cff9);if(_0x388ad2>_0x5a70a9){return _0x800d87[_0x1981('0x9')](_0x5a70a9,_0x388ad2+0x1);}else{var _0x3638ed=_0x800d87['slice'](0x0,_0x388ad2+0x1);var _0x339681=_0x800d87['slice'](_0x5a70a9);return _0x339681['concat'](_0x3638ed);}}}module[_0x1981('0xa')]['circularDoWInterval']=circularDoWInterval;function circularMonthInterval(_0x36b91a,_0x4feb68){if(_0x36b91a===_0x4feb68){return[_0x36b91a];}else{var _0x1282af=moment[_0x1981('0x6')]();moment['locale']('en');var _0x17f4ef=moment['monthsShort']()[_0x1981('0x1')](function(_0x29fe65){return _0x29fe65[_0x1981('0xb')]();});moment[_0x1981('0x6')](_0x1282af);var _0x38ebb2=_0x17f4ef[_0x1981('0x8')](_0x36b91a);var _0x4775bf=_0x17f4ef['indexOf'](_0x4feb68);if(_0x4775bf>_0x38ebb2){return _0x17f4ef[_0x1981('0x9')](_0x38ebb2,_0x4775bf+0x1);}else{var _0x1c85c1=_0x17f4ef[_0x1981('0x9')](0x0,_0x4775bf+0x1);var _0xba11c1=_0x17f4ef['slice'](_0x38ebb2);return _0xba11c1[_0x1981('0xc')](_0x1c85c1);}}}module[_0x1981('0xa')]['circularMonthInterval']=circularMonthInterval;function parseDom(_0x28cf7d){var _0x3caa38=parseInt(_0x28cf7d,0xa);if(_0x3caa38<0x1||_0x3caa38>0x1f){throw new Error(EINVALID_DATE);}return _0x3caa38;}function timeCompare(_0xaec568,_0x196465,_0x3dbc8b){var _0x2be9ea=_0xaec568[_0x1981('0xd')]();var _0xfc6c19=extractTime(_0x196465);var _0x457ab3=_0xfc6c19[0x0];var _0x1fbe36=_0xfc6c19[0x1];var _0x3f786e=_0xaec568[_0x1981('0xd')]()[_0x1981('0xe')](_0x457ab3)['minutes'](_0x1fbe36);throwIfDateNotValid(_0x3f786e);var _0x365a50=extractTime(_0x3dbc8b);var _0x14a633=_0x365a50[0x0];var _0x5be0c6=_0x365a50[0x1];var _0x574417=_0xaec568[_0x1981('0xd')]()['hours'](_0x14a633)[_0x1981('0xf')](_0x5be0c6);throwIfDateNotValid(_0x574417);if(_0x574417['isBefore'](_0x3f786e)){var _0x4922b2=_0x2be9ea[_0x1981('0xd')]()['startOf']('day');var _0x3d04b4=_0x2be9ea[_0x1981('0xd')]()[_0x1981('0x10')](_0x1981('0x11'));return _0x2be9ea['isBetween'](_0x3f786e,_0x3d04b4,undefined,'[]')||_0x2be9ea[_0x1981('0x12')](_0x4922b2,_0x574417,undefined,'[]');}else{return _0x2be9ea[_0x1981('0x12')](_0x3f786e,_0x574417,undefined,'[]');}}module[_0x1981('0xa')]['timeCompare']=timeCompare;function dowCompare(_0x338a3c,_0x245e99,_0x117be5){var _0x223129=_0x338a3c[_0x1981('0x6')]('en')[_0x1981('0x13')](_0x1981('0x14'))[_0x1981('0xb')]();return circularDoWInterval(_0x245e99,_0x117be5)['includes'](_0x223129);}module[_0x1981('0xa')]['dowCompare']=dowCompare;function domCompare(_0x256e8a,_0x3c3ad3,_0x5c5b15){var _0x1cebdd=_0x256e8a['date']();if(_0x3c3ad3===_0x5c5b15){return _0x1cebdd===_0x3c3ad3;}else{var _0x1f67d1=_0x256e8a['daysInMonth']();var _0x2282e6=_0x3c3ad3<_0x5c5b15;let _0x2e367f=![];var _0x4b49f9=0x0;var _0x5cefde=0x0;if(_0x2282e6){_0x4b49f9=Math[_0x1981('0x15')](0x1,_0x3c3ad3);_0x5cefde=Math['min'](_0x5c5b15,_0x1f67d1);_0x2e367f=_0x1cebdd>=_0x4b49f9&&_0x1cebdd<=_0x5cefde;}else{_0x4b49f9=Math['min'](_0x3c3ad3,_0x1f67d1);_0x5cefde=Math[_0x1981('0x15')](0x1,_0x5c5b15);_0x2e367f=_0x1cebdd>=_0x4b49f9||_0x1cebdd<=_0x5cefde;}return _0x2e367f;}}module[_0x1981('0xa')][_0x1981('0x16')]=domCompare;function monthCompare(_0x19faa8,_0x1500e9,_0x5332fa){var _0x1e5fbe=_0x19faa8['locale']('en')[_0x1981('0x13')](_0x1981('0x17'))[_0x1981('0xb')]();return circularMonthInterval(_0x1500e9,_0x5332fa)[_0x1981('0x18')](_0x1e5fbe);}module[_0x1981('0xa')][_0x1981('0x19')]=monthCompare;function iftime(_0x3ee24e,_0x1df82e=moment['tz']['guess'](),_0x13943c=moment()){if(!validateRx[_0x1981('0x1a')](_0x3ee24e)){throw new Error(EINVALID_STRING);}else{var _0x4ee65d=(moment[_0x1981('0x1b')](_0x13943c)?_0x13943c[_0x1981('0xd')]():moment(_0x13943c))['tz'](_0x1df82e)['locale']('en');throwIfDateNotValid(_0x4ee65d);var _0x385154=_0x3ee24e[_0x1981('0x5')](',');var _0x5787b0=_0x385154[0x0];var _0x5050cc=_0x385154[0x1];var _0x15aeca=_0x385154[0x2];var _0x41ed1d=_0x385154[0x3];let _0x9f9266=!![];if(_0x5787b0!=='*'){var _0x5f1424=_0x5787b0[_0x1981('0x5')]('-');var _0x122128=_[_0x1981('0x1c')](_0x5f1424[0x0],0x5,'0');var _0x14606f=_0x5f1424[_0x1981('0x1d')]===0x2?_[_0x1981('0x1c')](_0x5f1424[0x1],0x5,'0'):_0x122128;_0x9f9266=timeCompare(_0x4ee65d,_0x122128,_0x14606f);}let _0x3c31f5=!![];if(_0x5050cc!=='*'){var _0x15f066=_0x5050cc[_0x1981('0x5')]('-');var _0x45e11c=_0x15f066[0x0];var _0x42bc0d=_0x15f066['length']===0x2?_0x15f066[0x1]:_0x45e11c;_0x3c31f5=dowCompare(_0x4ee65d,_0x45e11c,_0x42bc0d);}let _0x4bcf82=!![];if(_0x15aeca!=='*'){var _0x478a0c=_0x15aeca['split']('-');var _0x49ef14=parseDom(_0x478a0c[0x0]);var _0x3f4656=_0x478a0c[_0x1981('0x1d')]===0x2?parseDom(_0x478a0c[0x1]):_0x49ef14;_0x4bcf82=domCompare(_0x4ee65d,_0x49ef14,_0x3f4656);}let _0x26d16e=!![];if(_0x41ed1d!=='*'){var _0x3a8cd8=_0x41ed1d[_0x1981('0x5')]('-');var _0x4bfdc3=_0x3a8cd8[0x0];var _0x26f6f0=_0x3a8cd8[_0x1981('0x1d')]===0x2?_0x3a8cd8[0x1]:_0x3a8cd8[0x0];_0x26d16e=monthCompare(_0x4ee65d,_0x4bfdc3,_0x26f6f0);}return _0x9f9266&&_0x3c31f5&&_0x4bcf82&&_0x26d16e;}}module[_0x1981('0xa')][_0x1981('0x1e')]=iftime; \ No newline at end of file diff --git a/server/utils/loggers.js b/server/utils/loggers.js new file mode 100644 index 0000000..9292aa8 --- /dev/null +++ b/server/utils/loggers.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xdc9f=['{{{','[%s]\x20[%s]\x20%s\x20-\x20%s','YYYY-MM-DD\x20HH:mm:ss','level','toUpperCase','meta','keys','stringify','[%s]\x20[%s]\x20%s\x20-\x20%s\x20%s','Logger','transports','Console','warn','File','%s-%s','error','consoleLogger','fileLogger','path','util','moment','winston','../config/environment','debugLevel','toLowerCase','redBG\x20white','red','bold\x20yellow','gray','bold\x20blue','bold\x20cyan','/var/log/xcally','join','format','%s-%s.log','message','replace'];(function(_0x1afbcb,_0x592f0a){var _0x40d039=function(_0x384ddf){while(--_0x384ddf){_0x1afbcb['push'](_0x1afbcb['shift']());}};_0x40d039(++_0x592f0a);}(_0xdc9f,0x13a));var _0xfdc9=function(_0x22fee6,_0x395b9d){_0x22fee6=_0x22fee6-0x0;var _0x258622=_0xdc9f[_0x22fee6];return _0x258622;};'use strict';var path=require(_0xfdc9('0x0'));var util=require(_0xfdc9('0x1'));var moment=require(_0xfdc9('0x2'));var winston=require(_0xfdc9('0x3'));var config=require(_0xfdc9('0x4'));var debugLevel=config[_0xfdc9('0x5')]?config[_0xfdc9('0x5')][_0xfdc9('0x6')]():'info';var XC_LOG_LEVELS={'fatal':0x0,'error':0x0,'warn':0x1,'info':0x2,'print':0x2,'success':0x2,'http':0x3,'verbose':0x4,'debug':0x5,'silly':0x6};var XC_LOG_COLORS={'fatal':_0xfdc9('0x7'),'error':_0xfdc9('0x8'),'warn':_0xfdc9('0x9'),'info':'white','print':'bold\x20white','success':'bold\x20green','http':_0xfdc9('0xa'),'verbose':'bold\x20magenta','debug':_0xfdc9('0xb'),'silly':_0xfdc9('0xc')};winston['addColors'](XC_LOG_COLORS);function getLogFileName(_0x42311a,_0x140ba2,_0x11cf18){var _0x5cb728=_0x42311a||_0xfdc9('0xd');return path[_0xfdc9('0xe')](_0x5cb728,util[_0xfdc9('0xf')](_0xfdc9('0x10'),_0x140ba2,_0x11cf18));}function formatter(_0x4e95b1,_0x5bc43c){_0x5bc43c[_0xfdc9('0x11')]=_0x5bc43c[_0xfdc9('0x11')][_0xfdc9('0x12')](/@@{/g,_0xfdc9('0x13'))[_0xfdc9('0x12')](/}@@/g,'}}}')[_0xfdc9('0x12')](/@{/g,'{{')['replace'](/}@/g,'}}');return util[_0xfdc9('0xf')](_0xfdc9('0x14'),moment()[_0xfdc9('0xf')](_0xfdc9('0x15')),_0x5bc43c[_0xfdc9('0x16')][_0xfdc9('0x17')](),_0x4e95b1,_0x5bc43c[_0xfdc9('0x11')]);}function fileFormat(_0x8b6aee,_0x1d0b49){_0x1d0b49[_0xfdc9('0x11')]=_0x1d0b49['message'][_0xfdc9('0x12')](/@@{/g,_0xfdc9('0x13'))[_0xfdc9('0x12')](/}@@/g,'}}}')['replace'](/@{/g,'{{')[_0xfdc9('0x12')](/}@/g,'}}');var _0x185d9e=_0x1d0b49[_0xfdc9('0x18')]&&Object[_0xfdc9('0x19')](_0x1d0b49['meta'])['length']?'\x0a\x09'+JSON[_0xfdc9('0x1a')](_0x1d0b49['meta']):'';return util[_0xfdc9('0xf')](_0xfdc9('0x1b'),moment()['format'](_0xfdc9('0x15')),_0x1d0b49[_0xfdc9('0x16')]['toUpperCase'](),_0x8b6aee,_0x1d0b49['message'],_0x185d9e);}function consoleLogger(){var _0x2289c8=new winston[(_0xfdc9('0x1c'))]({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xfdc9('0x1d'))][(_0xfdc9('0x1e'))]({'level':_0xfdc9('0x1f'),'json':![],'formatter':function(_0x3a0e3e){return formatter('',_0x3a0e3e);}})]});return _0x2289c8;}function fileLogger(_0x2c5182,_0x140294){var _0x448b09=new winston['Logger']({'levels':XC_LOG_LEVELS,'transports':[new winston[(_0xfdc9('0x1d'))][(_0xfdc9('0x20'))]({'name':util[_0xfdc9('0xf')](_0xfdc9('0x21'),_0x2c5182,_0xfdc9('0x22')),'filename':getLogFileName(_0x140294,_0x2c5182,_0xfdc9('0x22')),'level':'error','json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x2ab842){return fileFormat(_0x2c5182,_0x2ab842);}}),new winston[(_0xfdc9('0x1d'))][(_0xfdc9('0x20'))]({'name':util[_0xfdc9('0xf')]('%s-%s',_0x2c5182,debugLevel),'filename':getLogFileName(_0x140294,_0x2c5182,debugLevel),'level':debugLevel,'json':![],'maxsize':0xa00000,'maxFiles':0xa,'tailable':!![],'formatter':function(_0x14a3fc){return fileFormat(_0x2c5182,_0x14a3fc);}}),new winston[(_0xfdc9('0x1d'))]['Console']({'level':_0xfdc9('0x1f'),'json':![],'formatter':function(_0x53b371){return fileFormat(_0x2c5182,_0x53b371);}})]});return _0x448b09;}exports[_0xfdc9('0x23')]=consoleLogger;exports[_0xfdc9('0x24')]=fileLogger; \ No newline at end of file diff --git a/server/utils/mask-sensitive-data.js b/server/utils/mask-sensitive-data.js new file mode 100644 index 0000000..0f1587f --- /dev/null +++ b/server/utils/mask-sensitive-data.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0x14a0=['membername','calleridnum','exten','clientEmail','privateKey','accesskeyid','secretaccesskey','key','user','pass','accountSid','localstationid','dsn','secret','registry','isArray','length','isPlainObject','isString','replace','@@{','}@@','includes','exports','maskSensitiveData','username','password','newPassword','apiKey','firstName','lastName','street','fax','email','clientId','code','accessKey','tenantId','accessToken'];(function(_0x562441,_0x35cb3a){var _0x4f5404=function(_0x4e0cee){while(--_0x4e0cee){_0x562441['push'](_0x562441['shift']());}};_0x4f5404(++_0x35cb3a);}(_0x14a0,0x8e));var _0x014a=function(_0x2ae22a,_0x4fe753){_0x2ae22a=_0x2ae22a-0x0;var _0x286a82=_0x14a0[_0x2ae22a];return _0x286a82;};var _=require('lodash');var sensitiveFields=[_0x014a('0x0'),_0x014a('0x1'),_0x014a('0x2'),_0x014a('0x3'),_0x014a('0x4'),_0x014a('0x5'),_0x014a('0x6'),'phone','mobile',_0x014a('0x7'),_0x014a('0x8'),_0x014a('0x9'),'clientSecret','securityToken',_0x014a('0xa'),_0x014a('0xb'),_0x014a('0xc'),'token','channelSecret',_0x014a('0xd'),'accessTokenSecret','authToken','consumerKey','consumerSecret',_0x014a('0xe'),'calleridname',_0x014a('0xf'),_0x014a('0x10'),'vidaooApiKey',_0x014a('0x11'),_0x014a('0x12'),_0x014a('0x13'),_0x014a('0x14'),_0x014a('0x15'),_0x014a('0x16'),_0x014a('0x17'),_0x014a('0x18'),_0x014a('0x19'),_0x014a('0x1a'),_0x014a('0x1b'),_0x014a('0x1c'),'oldPassword'];function maskSensitiveData(_0x130d13){const _0x3cf92f=/(?!^)[\s\S](?!$)/g;if(_['isPlainObject'](_0x130d13)){for(const _0x3a836f in _0x130d13){if(_[_0x014a('0x1d')](_0x130d13[_0x3a836f])){for(let _0x59a4ea=0x0;_0x59a4ea<_0x130d13[_0x3a836f][_0x014a('0x1e')];_0x59a4ea++){maskSensitiveData(_0x130d13[_0x3a836f][_0x59a4ea]);}}else if(_[_0x014a('0x1f')](_0x130d13[_0x3a836f])){maskSensitiveData(_0x130d13[_0x3a836f]);}else if(_[_0x014a('0x20')](_0x130d13[_0x3a836f])){_0x130d13[_0x3a836f]=_0x130d13[_0x3a836f][_0x014a('0x21')](/{{{/g,_0x014a('0x22'))[_0x014a('0x21')](/}}}/g,_0x014a('0x23'))[_0x014a('0x21')](/{{/g,'@{')[_0x014a('0x21')](/}}/g,'}@');if(_[_0x014a('0x24')](sensitiveFields,_0x3a836f)){_0x130d13[_0x3a836f]=_0x130d13[_0x3a836f][_0x014a('0x21')](_0x3cf92f,'*');}}}}}module[_0x014a('0x25')][_0x014a('0x26')]=maskSensitiveData; \ No newline at end of file diff --git a/server/utils/safe-template.js b/server/utils/safe-template.js new file mode 100644 index 0000000..e768da0 --- /dev/null +++ b/server/utils/safe-template.js @@ -0,0 +1,18 @@ +// ************************************************************************* +// * * +// * xCALLY Motion - The Omnichannel Contact Center * +// * Copyright (c) Xenialab s.r.l. All Rights Reserved * +// * * +// ************************************************************************* +// * * +// * Email: info@xcally.com * +// * Website: https://www.xcally.com * +// * * +// ************************************************************************* +// * * +// * The SOFTWARE PRODUCT is protected by copyright laws and international * +// * copyright treaties, as well as other intellectual property laws and * +// * treaties. The SOFTWARE PRODUCT is licensed, not sold. * +// * * +// ************************************************************************* +var _0xa571=['reduce','exports','lodash','{\x20{\x20','\x20}\x20}','string','map','isPlainObject','keys'];(function(_0x1be54c,_0x5bfa3a){var _0xad0132=function(_0x31fc28){while(--_0x31fc28){_0x1be54c['push'](_0x1be54c['shift']());}};_0xad0132(++_0x5bfa3a);}(_0xa571,0x107));var _0x1a57=function(_0x3baaed,_0xa8994c){_0x3baaed=_0x3baaed-0x0;var _0x1f3d6b=_0xa571[_0x3baaed];return _0x1f3d6b;};var _=require(_0x1a57('0x0'));var mustacheLikeBracketsRx=/(\{|\}){2}/gm;function bracketsReplacer(_0x289e99){return _0x289e99==='{{'?_0x1a57('0x1'):_0x1a57('0x2');}function safeTemplate(_0x48485e){var _0x1a071f=_0x48485e;if(typeof _0x48485e===_0x1a57('0x3')){_0x1a071f=_0x48485e['replace'](mustacheLikeBracketsRx,bracketsReplacer);}else if(Array['isArray'](_0x48485e)){_0x1a071f=_0x48485e[_0x1a57('0x4')](function(_0x5067fa){return safeTemplate(_0x5067fa);});}else if(_[_0x1a57('0x5')](_0x48485e)){_0x1a071f=Object[_0x1a57('0x6')](_0x48485e)[_0x1a57('0x7')](function(_0x3c5352,_0x2492f5){_0x3c5352[_0x2492f5]=safeTemplate(_0x48485e[_0x2492f5]);return _0x3c5352;},{});}return _0x1a071f;}module[_0x1a57('0x8')]['safeTemplate']=safeTemplate; \ No newline at end of file diff --git a/server/views/404.html b/server/views/404.html new file mode 100644 index 0000000..558e7eb --- /dev/null +++ b/server/views/404.html @@ -0,0 +1,161 @@ + + + + + + Page Not Found :( + + + + +
+

Not found :(

+

Sorry, but the page you were trying to view does not exist.

+

It looks like this was the result of either:

+
    +
  • a mistyped address
  • +
  • an out-of-date link
  • +
+ + +
+ + + \ No newline at end of file diff --git a/server/views/downloadInteraction.ejs b/server/views/downloadInteraction.ejs new file mode 100644 index 0000000..126cd0a --- /dev/null +++ b/server/views/downloadInteraction.ejs @@ -0,0 +1,131 @@ + + + + PDF document + + + + + + + + + + + <% if (interaction.channel.toLowerCase()==='chat' ) { -%> + + + <% } else { -%> + + + <% } -%> + + + <% if (interaction.channel.toLowerCase()==='openchannel' ) { -%> + + + + <% } -%> + <% if (interaction.channel.toLowerCase()==='chat' ) { -%> + + + + + + <% } -%> + +
+
+

+ <% if (interaction.channel.toLowerCase()==='chat' ) { -%> + Website <% } else { %> Account <% } -%> +

+

+ <%- interaction.account %> +

+
+
+
+

Agent

+

+ <%- interaction.agent %> +

+
+
+
+

Created

+

+ <%- interaction.createdAt %> +

+
+
+
+

Browser

+

+ <%- interaction.chatInfo.browser %> +

+
+
+
+

Operating System

+

+ <%- interaction.chatInfo.os %> +

+
+
+
+

Disposition

+

+ <%- interaction.disposition %> +

+
+
  +
+

Closed

+

+ <%- interaction.closedAt %> +

+
+
+
+

Visibility

+

+ <%- interaction.visibility %> +

+
+
+
+

Referer

+

+ <%- interaction.chatInfo.referer %> +

+
+
+
+

Originating TCP Port

+

+ <%- interaction.chatInfo.customerPort %> +

+
+
+
+

Originating IP Address

+

+ <%- interaction.chatInfo.customerIp %> +

+
+
+
+ <% interaction.messages.forEach(function(message) { -%> +

+

[<%- message.direction %>] <%- message.date %> | <%- message.sender %> + <% if(interaction.channel.toLowerCase()==='chat' && message.read) { -%> + <% }-%> +
+ <% if (interaction.channel.toLowerCase()==='openchannel' && message.attachment) { -%>[ATTACHMENT] <% } -%> + <%- message.body %> +

+ <% }); -%> +
+ + \ No newline at end of file